The function creates a packet and returns it. Each packet must
belong to a trace. The function does not register the packet
in the trace, because a packet could be inserted anywhere.
This cleans up the memory used by a packet. It does
not take care of removing the packet from the tcpdump
list etc -- you likely want to use nd_packet_delete()!
This function removes packet from its trace's
packet lists, removes the GUI line if gui_update
is TRUE, then frees packet.
packet :
deleted packet.
update_gui :
whether to update the GUI or not.
nd_packet_init ()
void nd_packet_init (ND_Packet *packet);
The function initializes a packet, its data offset pointers,
and the protocol types for the protcol stack. It cleans
up before adjusting internal settings, so you can call this
repeatedly.
The function returns a pointer to the packet data containing
the start of proto's data at the given nesting level. If the
packet doesn't contain any such data, NULL is returned.
The function returns a pointer to the first byte after the
data containing the start of proto's data at the given nesting
level. If the packet doesn't contain any such data, NULL
is returned.
Each packet internally maintains a list of data offsets which
store info about the protocol type, nesting etc. This function
appends a new chunk information to that list. It is called from
nd_packet_init() and nd_packet_update(), chances are you want
these functions instead.
This function is like nd_packet_get_data, but does not only
return the data pointer but the full ND_ProtoData structure,
which yields nesting info, data start end end pointers etc.
The predicate returns TRUE when a packet contains a complete header
of the requested protocol, FALSE otherwise. The implementation of
the check itself is up to the implementation of proto's plug-in.
If you only need to know whether a protocol is present in the packet
at all, use nd_packet_has_proto(), which is faster.
The predicate returns TRUE when a packet contains data of the
given protocol. It may contain multiple instances of a protocol,
but the function only checks if a protocol is present at all.
If you need to find out whether a protocol is present at a given
nesting level (e.g. whether a packet contains IP in IP), use
nd_packet_has_complete_header() or nd_packet_has_proto_nested().
The predicate returns TRUE when a packet contains data of the
given protocol at the requested nesting level.
If you only need to find out whether a protocol is present at all,
use nd_packet_has_proto() instead, which is faster.
packet :
packet to query.
proto :
protocol to check for.
nesting :
nesting level of proto.
Returns :
check result.
nd_packet_update_proto_state ()
void nd_packet_update_proto_state (ND_Packet *packet,
int index);
The function iterates over the protocols in the packet, from
outer- to the innermost, and calls cb with that the corresponding
packet, protocol data and user_data.
The function iterates over the protocols in the packet, from
inner- to the outermost, and calls cb with that the corresponding
packet, protocol data and user_data.
packet :
packet whose protocols to iterate.
cb :
callback to call.
user_data :
arbitrary data passed to cb.
nd_packet_modified ()
void nd_packet_modified (ND_Packet *packet);
The function marks a packet as modified and updates the GUI
accordingly. If you know the packet's index, pass it, otherwise
pass -1 for index or use nd_packet_modified().
packet :
packet to mark.
nd_packet_modified_at_index ()
void nd_packet_modified_at_index (ND_Packet *packet,
int index);
packet :
index :
nd_packet_get_index ()
int nd_packet_get_index (const ND_Packet *packet);
The function returns the index of the packet in it's trace,
the first packet has index 0.
packet :
packet to query.
Returns :
index, or -1 if error occurred.
nd_packet_get_proto_nesting ()
int nd_packet_get_proto_nesting (const ND_Packet *packet,
const ND_Protocol *proto,
guchar *data);
The function returns the nesting level of proto at the given
data offset. The first occurrence of a protocol has nesting level 0.
So, if you call this for IP and the data pointer points to somewhere
in or after the IP header in an ICMP error message, the nesting level
will be 1.