Packet¶
Network packet abstraction type and helper functions.
-
struct gnrc_pktsnip
gnrc_pktsnip_t
¶ Type to represent parts (either headers or payload) of a packet, called snips.
The idea behind the packet snips is that they either can represent protocol-specific headers or payload. A packet can be comprised of multiple pktsnip_t elements.
Example:
To keep data duplication as low as possible the order of the snips in a packet will be reversed depending on if you send the packet or if you received it. For sending the order is from (in the network stack) lowest protocol snip to the highest, for receiving the order is from highest snip to the lowest. This way, if a layer needs to duplicate the packet a tree is created rather than a duplication of the whole package.
A very extreme example for this (we only expect one or two duplications at maximum per package) can be seen here:
The first three fields (next, data, size) match iolist_t (named iol_next, iol_base and iol_len there). That means that any pktsnip can be casted to iolist_t for direct passing to e.g., netdev
socket.h::send()
functions.Note
This type has no initializer on purpose. Please use Packet buffer as factory.
-
msp430_types.h::size_t
gnrc_pkt_len
(constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt)¶ Calculates length of a packet in byte.
Parameters
pkt: list of packet snips. Return values
- length of the list of headers.
-
msp430_types.h::size_t
gnrc_pkt_len_upto
(constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt,nettype.h::gnrc_nettype_t
type)¶ Calculates length of a packet in byte upto (including) a snip with the given type.
Parameters
pkt: list of packet snips. type: type of snip to stop calculation. Return values
- length of the list of headers.
-
msp430_types.h::size_t
gnrc_pkt_count
(constinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt)¶ Count the numbers of snips in the given packet.
Parameters
pkt: first snip in the packet Return values
- number of snips in the given packet
-
include/net/gnrc/pkt.h::gnrc_pktsnip_t
*gnrc_pktsnip_search_type
(include/net/gnrc/pkt.h::gnrc_pktsnip_t
* pkt,nettype.h::gnrc_nettype_t
type)¶ Searches the packet for a packet snip of a specific type.
Parameters
pkt: list of packet snips type: the type to search for Return values
- the packet snip in
pkt
withnettype.h::gnrc_nettype_t
type
- NULL, if none of the snips in
pkt
is oftype
- the packet snip in
-
struct
gnrc_pktsnip
¶ Type to represent parts (either headers or payload) of a packet, called snips.
The idea behind the packet snips is that they either can represent protocol-specific headers or payload. A packet can be comprised of multiple pktsnip_t elements.
Example:
To keep data duplication as low as possible the order of the snips in a packet will be reversed depending on if you send the packet or if you received it. For sending the order is from (in the network stack) lowest protocol snip to the highest, for receiving the order is from highest snip to the lowest. This way, if a layer needs to duplicate the packet a tree is created rather than a duplication of the whole package.
A very extreme example for this (we only expect one or two duplications at maximum per package) can be seen here:
The first three fields (next, data, size) match iolist_t (named iol_next, iol_base and iol_len there). That means that any pktsnip can be casted to iolist_t for direct passing to e.g., netdev
socket.h::send()
functions.Note
This type has no initializer on purpose. Please use Packet buffer as factory.
-
struct gnrc_pktsnip *
next
¶ next snip in the packet
-
void *
data
¶ pointer to the data of the snip
-
msp430_types.h::size_t
size
¶ the length of the snip in byte
-
unsigned int
users
¶ Counter of threads currently having control over this packet.
-
nettype.h::gnrc_nettype_t
type
¶ protocol of the packet snip
-
struct gnrc_pktsnip *