Up

module Pcap

: sig
#
val major_version : int

Major version of the pcap format which we understand

#
val minor_version : int

Minor version of the pcap format which we understand

#
type endian =
# | Big
(*Big endian (pcap headers)*)
# | Little
(*Little endian (pcap headers)*)
#
val string_of_endian : endian -> string
#
val sizeof_pcap_header : int

The size of the initial pcap header in bytes

#
val sizeof_pcap_packet : int

The size of the per-packet pcap headers in bytes

#
val magic_number : int32

The magic number which identifies a pcap file (and endian-ness)

#
module Network : sig

Type of outermost network protocol within the captured frames

#
type t =
# | Ethernet
# | Ieee80211
#
val to_int32 : t -> int32
#
val of_int32 : int32 -> t option
end
#
module LE : sig
#
val endian : endian
#
val sizeof_pcap_header : int
#
val get_pcap_header_magic_number : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_magic_number : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_version_major : Cstruct.t -> Cstruct.uint16
#
val set_pcap_header_version_major : Cstruct.t -> Cstruct.uint16 -> unit
#
val get_pcap_header_version_minor : Cstruct.t -> Cstruct.uint16
#
val set_pcap_header_version_minor : Cstruct.t -> Cstruct.uint16 -> unit
#
val get_pcap_header_thiszone : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_thiszone : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_sigfigs : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_sigfigs : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_snaplen : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_snaplen : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_network : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_network : Cstruct.t -> Cstruct.uint32 -> unit
#
val hexdump_pcap_header_to_buffer : Buffer.t -> Cstruct.t -> unit
#
val hexdump_pcap_header : Cstruct.t -> unit
#
val sizeof_pcap_packet : int
#
val get_pcap_packet_ts_sec : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_ts_sec : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_ts_usec : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_ts_usec : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_incl_len : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_incl_len : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_orig_len : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_orig_len : Cstruct.t -> Cstruct.uint32 -> unit
#
val hexdump_pcap_packet_to_buffer : Buffer.t -> Cstruct.t -> unit
#
val hexdump_pcap_packet : Cstruct.t -> unit
end
#
module BE : sig
#
val endian : endian
#
val sizeof_pcap_header : int
#
val get_pcap_header_magic_number : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_magic_number : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_version_major : Cstruct.t -> Cstruct.uint16
#
val set_pcap_header_version_major : Cstruct.t -> Cstruct.uint16 -> unit
#
val get_pcap_header_version_minor : Cstruct.t -> Cstruct.uint16
#
val set_pcap_header_version_minor : Cstruct.t -> Cstruct.uint16 -> unit
#
val get_pcap_header_thiszone : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_thiszone : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_sigfigs : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_sigfigs : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_snaplen : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_snaplen : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_header_network : Cstruct.t -> Cstruct.uint32
#
val set_pcap_header_network : Cstruct.t -> Cstruct.uint32 -> unit
#
val hexdump_pcap_header_to_buffer : Buffer.t -> Cstruct.t -> unit
#
val hexdump_pcap_header : Cstruct.t -> unit
#
val sizeof_pcap_packet : int
#
val get_pcap_packet_ts_sec : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_ts_sec : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_ts_usec : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_ts_usec : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_incl_len : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_incl_len : Cstruct.t -> Cstruct.uint32 -> unit
#
val get_pcap_packet_orig_len : Cstruct.t -> Cstruct.uint32
#
val set_pcap_packet_orig_len : Cstruct.t -> Cstruct.uint32 -> unit
#
val hexdump_pcap_packet_to_buffer : Buffer.t -> Cstruct.t -> unit
#
val hexdump_pcap_packet : Cstruct.t -> unit
end
#
module type HDR = sig

Functions to read/write pcap header fields of a particular endian-ness

#
val endian : endian

The detected endian-ness of the headers

#
val get_pcap_header_magic_number : Cstruct.t -> int32
#
val get_pcap_header_version_major : Cstruct.t -> int
#
val get_pcap_header_version_minor : Cstruct.t -> int
#
val get_pcap_header_thiszone : Cstruct.t -> int32
#
val get_pcap_header_sigfigs : Cstruct.t -> int32
#
val get_pcap_header_snaplen : Cstruct.t -> int32
#
val get_pcap_header_network : Cstruct.t -> int32
#
val set_pcap_header_magic_number : Cstruct.t -> int32 -> unit
#
val set_pcap_header_version_major : Cstruct.t -> int -> unit
#
val set_pcap_header_version_minor : Cstruct.t -> int -> unit
#
val set_pcap_header_thiszone : Cstruct.t -> int32 -> unit
#
val set_pcap_header_sigfigs : Cstruct.t -> int32 -> unit
#
val set_pcap_header_snaplen : Cstruct.t -> int32 -> unit
#
val set_pcap_header_network : Cstruct.t -> int32 -> unit
#
val get_pcap_packet_ts_sec : Cstruct.t -> int32
#
val get_pcap_packet_ts_usec : Cstruct.t -> int32
#
val get_pcap_packet_incl_len : Cstruct.t -> int32
#
val get_pcap_packet_orig_len : Cstruct.t -> int32
#
val set_pcap_packet_ts_sec : Cstruct.t -> int32 -> unit
#
val set_pcap_packet_ts_usec : Cstruct.t -> int32 -> unit
#
val set_pcap_packet_incl_len : Cstruct.t -> int32 -> unit
#
val set_pcap_packet_orig_len : Cstruct.t -> int32 -> unit
end
#
val detect : Cstruct.t -> (module HDR) option

detect buf returns a module capable of reading the pcap header fields, or None if the buffer doesn't contain pcap data.

#
val packets : (module HDR) -> Cstruct.t -> (Cstruct.t * Cstruct.t) Cstruct.iter

packets hdr buf returns a Cstruct.iter (sequence) containing (pcap header, pcap body) pairs.

end