Detailed Description

Files

file  gnrc/netif/hdr.h
 Generic network interface header.
 

Data Structures

struct  gnrc_netif_hdr_t
 Generic network interface header. More...
 

Macros

#define GNRC_NETIF_HDR_L2ADDR_MAX_LEN   (8)
 Maximum length of the l2 addresses of the generic interface header in bytes.
 
#define GNRC_NETIF_HDR_L2ADDR_PRINT_LEN   (GNRC_NETIF_HDR_L2ADDR_MAX_LEN * 3)
 Maximum length of the string representatiom of l2 addresses of the generic interface header in bytes.
 

Functions

static void gnrc_netif_hdr_init (gnrc_netif_hdr_t *hdr, uint8_t src_l2addr_len, uint8_t dst_l2addr_len)
 Initialize the given generic network interface header. More...
 
static size_t gnrc_netif_hdr_sizeof (gnrc_netif_hdr_t *hdr)
 Get the size of the given generic network interface header. More...
 
static uint8_t * gnrc_netif_hdr_get_src_addr (gnrc_netif_hdr_t *hdr)
 Get the source address from the given header. More...
 
static void gnrc_netif_hdr_set_src_addr (gnrc_netif_hdr_t *hdr, uint8_t *addr, uint8_t addr_len)
 Set the source address in the given header. More...
 
static uint8_t * gnrc_netif_hdr_get_dst_addr (gnrc_netif_hdr_t *hdr)
 Get the destination address from the given header. More...
 
static void gnrc_netif_hdr_set_dst_addr (gnrc_netif_hdr_t *hdr, uint8_t *addr, uint8_t addr_len)
 Set the destination address in the given header. More...
 
gnrc_pktsnip_tgnrc_netif_hdr_build (uint8_t *src, uint8_t src_len, uint8_t *dst, uint8_t dst_len)
 Builds a generic network interface header for sending and adds it to the packet buffer. More...
 
void gnrc_netif_hdr_print (gnrc_netif_hdr_t *hdr)
 Outputs a generic interface header to stdout. More...
 
uint8_t gnrc_netif_hdr_get_flag (gnrc_pktsnip_t *pkt)
 Fetch the netif header flags of a gnrc packet. More...
 
int gnrc_netif_hdr_get_dstaddr (gnrc_pktsnip_t *pkt, uint8_t **pointer_to_addr)
 Extract the destination address out of a gnrc packet. More...
 
int gnrc_netif_hdr_get_srcaddr (gnrc_pktsnip_t *pkt, uint8_t **pointer_to_addr)
 Extract the source address out of a gnrc packet. More...
 

Flags for the gnrc_netif_hdr_t

#define GNRC_NETIF_HDR_FLAGS_BROADCAST   (0x80)
 Send packet broadcast. More...
 
#define GNRC_NETIF_HDR_FLAGS_MULTICAST   (0x40)
 Send packet multicast. More...
 

Macro Definition Documentation

◆ GNRC_NETIF_HDR_FLAGS_BROADCAST

#define GNRC_NETIF_HDR_FLAGS_BROADCAST   (0x80)

Send packet broadcast.

Packets with this flag set must be send broadcast. gnrc_netif_hdr_t::dst_l2addr_len and any appended destination address must be ignored. If the link layer does not support broadcast the packet must be dropped silently.

Definition at line 59 of file gnrc/netif/hdr.h.

◆ GNRC_NETIF_HDR_FLAGS_MULTICAST

#define GNRC_NETIF_HDR_FLAGS_MULTICAST   (0x40)

Send packet multicast.

Packets with this flag set must be send multicast. gnrc_netif_hdr_t::dst_l2addr_len and any appended destination address must be ignored. The context for the multicast address must be derived from the network layer destination address. If the link layer does not support multicast it should interpret this flag the same way it does GNRC_NETIF_HDR_FLAGS_BROADCAST.

Definition at line 72 of file gnrc/netif/hdr.h.

Function Documentation

◆ gnrc_netif_hdr_build()

gnrc_pktsnip_t* gnrc_netif_hdr_build ( uint8_t *  src,
uint8_t  src_len,
uint8_t *  dst,
uint8_t  dst_len 
)

Builds a generic network interface header for sending and adds it to the packet buffer.

Parameters
[in]srcSource address for the header. Can be NULL if not known or required.
[in]src_lenLength of src. Can be 0 if not known or required.
[in]dstDestination address for the header. Can be NULL if not known or required.
[in]dst_lenLength of dst. Can be 0 if not known or required.
Returns
The generic network layer header on success.
NULL on error.

◆ gnrc_netif_hdr_get_dst_addr()

static uint8_t* gnrc_netif_hdr_get_dst_addr ( gnrc_netif_hdr_t hdr)
inlinestatic

Get the destination address from the given header.

Parameters
[in]hdrheader to read from
Returns
pointer to destination address on success
NULL on error

Definition at line 162 of file gnrc/netif/hdr.h.

◆ gnrc_netif_hdr_get_dstaddr()

int gnrc_netif_hdr_get_dstaddr ( gnrc_pktsnip_t pkt,
uint8_t **  pointer_to_addr 
)

Extract the destination address out of a gnrc packet.

Parameters
[in]pktgnrc packet from whom to extract
[out]pointer_to_addrpointer to address will be stored here
Returns
length of destination address
-ENOENT, if no netif header is presented in pkt or if no destination address field presented in netif header.

◆ gnrc_netif_hdr_get_flag()

uint8_t gnrc_netif_hdr_get_flag ( gnrc_pktsnip_t pkt)

Fetch the netif header flags of a gnrc packet.

Parameters
[in]pktgnrc packet from whom to fetch
Returns
netif header flags of pkt
0, if no header is present

◆ gnrc_netif_hdr_get_src_addr()

static uint8_t* gnrc_netif_hdr_get_src_addr ( gnrc_netif_hdr_t hdr)
inlinestatic

Get the source address from the given header.

Parameters
[in]hdrheader to read from
Returns
pointer to source address on success
NULL on error

Definition at line 131 of file gnrc/netif/hdr.h.

◆ gnrc_netif_hdr_get_srcaddr()

int gnrc_netif_hdr_get_srcaddr ( gnrc_pktsnip_t pkt,
uint8_t **  pointer_to_addr 
)

Extract the source address out of a gnrc packet.

Parameters
[in]pktgnrc packet from whom to extract
[out]pointer_to_addrpointer to address will be stored here
Returns
length of source address
-ENOENT, if no netif header is presented in pkt or if no source address field presented in netif header.

◆ gnrc_netif_hdr_init()

static void gnrc_netif_hdr_init ( gnrc_netif_hdr_t hdr,
uint8_t  src_l2addr_len,
uint8_t  dst_l2addr_len 
)
inlinestatic

Initialize the given generic network interface header.

Parameters
[in]hdrheader to initialize
[in]src_l2addr_lenlink layer source address length
[in]dst_l2addr_lenlink layer destination address length

Definition at line 99 of file gnrc/netif/hdr.h.

◆ gnrc_netif_hdr_print()

void gnrc_netif_hdr_print ( gnrc_netif_hdr_t hdr)

Outputs a generic interface header to stdout.

Parameters
[in]hdrA generic interface header.

◆ gnrc_netif_hdr_set_dst_addr()

static void gnrc_netif_hdr_set_dst_addr ( gnrc_netif_hdr_t hdr,
uint8_t *  addr,
uint8_t  addr_len 
)
inlinestatic

Set the destination address in the given header.

Parameters
[in]hdrheader to write to
[in]addrnew destination address
[in]addr_lenaddr length

Definition at line 174 of file gnrc/netif/hdr.h.

◆ gnrc_netif_hdr_set_src_addr()

static void gnrc_netif_hdr_set_src_addr ( gnrc_netif_hdr_t hdr,
uint8_t *  addr,
uint8_t  addr_len 
)
inlinestatic

Set the source address in the given header.

Parameters
[in]hdrheader to write to
[in]addrnew source address
[in]addr_lenaddr length

Definition at line 143 of file gnrc/netif/hdr.h.

◆ gnrc_netif_hdr_sizeof()

static size_t gnrc_netif_hdr_sizeof ( gnrc_netif_hdr_t hdr)
inlinestatic

Get the size of the given generic network interface header.

Parameters
[in]hdrheader to get the size of
Returns
the size of the given header, including link layer addresses

Definition at line 118 of file gnrc/netif/hdr.h.