6LoWPAN¶
GNRC’s 6LoWPAN implementation.
This module is for usage with the GNRC communication interface.
NETAPI command documentation¶
GNRC_NETAPI_MSG_TYPE_RCV¶
netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
expects a Packet (referred to as “packet” in the following) in receive order (link-layer payload first, Generic network interface header last) with the payload marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_SIXLOWPAN. Every other packet will be silently discarded.
If the first byte of the payload is sixlowpan.h::SIXLOWPAN_UNCOMP
this byte will be removed by marking it with a new include/net/gnrc/pkt.h::gnrc_pktsnip_t
and then removing this include/net/gnrc/pkt.h::gnrc_pktsnip_t
, the remaining payload will be marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 and this module will issue a netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
to all subscribers registered to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex context netreg.h::GNRC_NETREG_DEMUX_CTX_ALL
in the Network protocol registry with the packet. Otherwise, the packet will be silently discarded (except for the cases documented below).
Depending on which other modules are included the behavior can be a little different:
- If 6LoWPAN Fragmentation is included and
sixlowpan.h::sixlowpan_frag_is()
is true for the packet, the fragmentation header will be removed and its remaining data will be added to the reassembly buffer (usingrbuf.h::rbuf_add()
) in accordance to the fragmentation header. The packet containing the fragment will be discarded. When the fragmented datagram is complete, its payload will be marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 and issued via anetapi.h::GNRC_NETAPI_MSG_TYPE_RCV
to all subscribers registered to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex contextnetreg.h::GNRC_NETREG_DEMUX_CTX_ALL
in the Network protocol registry. If reassembly times out or if fragments overlap the datagram will be silently discarded. - If IPv6 header compression (IPHC) is included the packet will not be send to the subscribers to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex context
netreg.h::GNRC_NETREG_DEMUX_CTX_ALL
immediately, but it will be checked first ifsixlowpan.h::sixlowpan_iphc_is()
is true for its payload. If false it will be send to the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 subscribers as usual. If true the IPHC dispatch will be decompressed to a full IPv6 header first. The IPv6 header will be included as a newinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
to the packet directly behind the payload. The IPHC dispatch will be removed. The resulting packet will then be issued to the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 subscribers as usual. - If both 6LoWPAN Fragmentation and IPv6 header compression (IPHC) are included the and
sixlowpan.h::sixlowpan_frag_is()
is true for the packet, the fragmented datagram will be reassembled as described in (1). If for the remainder (after removal of the fragment header) of the first fragmentsixlowpan.h::sixlowpan_iphc_is()
is true, it will be decompressed as described in (2), with the exception that the packet will only be send to all receivers of nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 as soon as the datagram was completely reassembled and not after directly after decompression. Ifsixlowpan.h::sixlowpan_iphc_is()
is false, reassembly is handled completely as described in (1). It is assumed that a fragment can fit a full compression header (including inlined fields and possibly NHC/GHC headers) as specified in RFC 6282, section 2.
GNRC_NETAPI_MSG_TYPE_SND¶
netapi.h::GNRC_NETAPI_MSG_TYPE_SND
expects a Packet (referred to as “packet” in the following) in send order (headers first, payload last) with the first header being a valid nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header and the second a nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 header. Every other packet will be silently discarded.
The nettype.h::gnrc_nettype_t::GNRC_NETTYPE_SIXLOWPAN header must at least have the gnrc/netif/hdr.h::gnrc_netif_hdr_t::if_pid
field set to a legal, 6LoWPAN compatible interface referred to as netif
in the following, otherwise the packet will be discarded.
If IPv6 header compression (IPHC) is included and gnrc_sixlowpan_netif_t::iphc_enable of netif
is true the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 header will be compressed according to RFC 6282. If it is false the sixlowpan.h::SIXLOWPAN_UNCOMP
dispatch will be appended as a new include/net/gnrc/pkt.h::gnrc_pktsnip_t
to the packet. The false case also applies if IPv6 header compression (IPHC) is not included.
If the packet without nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header is shorter than gnrc_netif_t::sixlo::max_frag_size of netif
the packet will be send to the netif
’s thread. Otherwise if 6LoWPAN Fragmentation is included the packet will be fragmented according to RFC 4944 if the packet is without nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header shorter than sixlowpan.h::SIXLOWPAN_FRAG_MAX_LEN
. If none of these cases apply, the packet will be discarded silently.
GNRC_NETAPI_MSG_TYPE_SET¶
GNRC_NETAPI_MSG_TYPE_SET
is not supported.
GNRC_NETAPI_MSG_TYPE_GET¶
GNRC_NETAPI_MSG_TYPE_GET
is not supported.
GNRC_NETAPI_MSG_TYPE_RCV¶
netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
expects a Packet (referred to as “packet” in the following) in receive order (link-layer payload first, Generic network interface header last) with the payload marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_SIXLOWPAN. Every other packet will be silently discarded.
If the first byte of the payload is sixlowpan.h::SIXLOWPAN_UNCOMP
this byte will be removed by marking it with a new include/net/gnrc/pkt.h::gnrc_pktsnip_t
and then removing this include/net/gnrc/pkt.h::gnrc_pktsnip_t
, the remaining payload will be marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 and this module will issue a netapi.h::GNRC_NETAPI_MSG_TYPE_RCV
to all subscribers registered to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex context netreg.h::GNRC_NETREG_DEMUX_CTX_ALL
in the Network protocol registry with the packet. Otherwise, the packet will be silently discarded (except for the cases documented below).
Depending on which other modules are included the behavior can be a little different:
- If 6LoWPAN Fragmentation is included and
sixlowpan.h::sixlowpan_frag_is()
is true for the packet, the fragmentation header will be removed and its remaining data will be added to the reassembly buffer (usingrbuf.h::rbuf_add()
) in accordance to the fragmentation header. The packet containing the fragment will be discarded. When the fragmented datagram is complete, its payload will be marked with nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 and issued via anetapi.h::GNRC_NETAPI_MSG_TYPE_RCV
to all subscribers registered to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex contextnetreg.h::GNRC_NETREG_DEMUX_CTX_ALL
in the Network protocol registry. If reassembly times out or if fragments overlap the datagram will be silently discarded. - If IPv6 header compression (IPHC) is included the packet will not be send to the subscribers to nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 with demultiplex context
netreg.h::GNRC_NETREG_DEMUX_CTX_ALL
immediately, but it will be checked first ifsixlowpan.h::sixlowpan_iphc_is()
is true for its payload. If false it will be send to the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 subscribers as usual. If true the IPHC dispatch will be decompressed to a full IPv6 header first. The IPv6 header will be included as a newinclude/net/gnrc/pkt.h::gnrc_pktsnip_t
to the packet directly behind the payload. The IPHC dispatch will be removed. The resulting packet will then be issued to the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 subscribers as usual. - If both 6LoWPAN Fragmentation and IPv6 header compression (IPHC) are included the and
sixlowpan.h::sixlowpan_frag_is()
is true for the packet, the fragmented datagram will be reassembled as described in (1). If for the remainder (after removal of the fragment header) of the first fragmentsixlowpan.h::sixlowpan_iphc_is()
is true, it will be decompressed as described in (2), with the exception that the packet will only be send to all receivers of nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 as soon as the datagram was completely reassembled and not after directly after decompression. Ifsixlowpan.h::sixlowpan_iphc_is()
is false, reassembly is handled completely as described in (1). It is assumed that a fragment can fit a full compression header (including inlined fields and possibly NHC/GHC headers) as specified in RFC 6282, section 2.
GNRC_NETAPI_MSG_TYPE_SND¶
netapi.h::GNRC_NETAPI_MSG_TYPE_SND
expects a Packet (referred to as “packet” in the following) in send order (headers first, payload last) with the first header being a valid nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header and the second a nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 header. Every other packet will be silently discarded.
The nettype.h::gnrc_nettype_t::GNRC_NETTYPE_SIXLOWPAN header must at least have the gnrc/netif/hdr.h::gnrc_netif_hdr_t::if_pid
field set to a legal, 6LoWPAN compatible interface referred to as netif
in the following, otherwise the packet will be discarded.
If IPv6 header compression (IPHC) is included and gnrc_sixlowpan_netif_t::iphc_enable of netif
is true the nettype.h::gnrc_nettype_t::GNRC_NETTYPE_IPV6 header will be compressed according to RFC 6282. If it is false the sixlowpan.h::SIXLOWPAN_UNCOMP
dispatch will be appended as a new include/net/gnrc/pkt.h::gnrc_pktsnip_t
to the packet. The false case also applies if IPv6 header compression (IPHC) is not included.
If the packet without nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header is shorter than gnrc_netif_t::sixlo::max_frag_size of netif
the packet will be send to the netif
’s thread. Otherwise if 6LoWPAN Fragmentation is included the packet will be fragmented according to RFC 4944 if the packet is without nettype.h::gnrc_nettype_t::GNRC_NETTYPE_NETIF header shorter than sixlowpan.h::SIXLOWPAN_FRAG_MAX_LEN
. If none of these cases apply, the packet will be discarded silently.
GNRC_NETAPI_MSG_TYPE_SET¶
GNRC_NETAPI_MSG_TYPE_SET
is not supported.
GNRC_NETAPI_MSG_TYPE_GET¶
GNRC_NETAPI_MSG_TYPE_GET
is not supported.
-
kernel_types.h::kernel_pid_t
gnrc_sixlowpan_init
(void)¶ Initialization of the 6LoWPAN thread.
If 6LoWPAN was already initialized, it will just return the PID of the 6LoWPAN thread.
Return values
- The PID to the 6LoWPAN thread, on success.
- -EINVAL, if
gnrc/sixlowpan.h::GNRC_SIXLOWPAN_PRIO
was greater than or equal tosched.h::SCHED_PRIO_LEVELS
- -EOVERFLOW, if there are too many threads running already in general
-
GNRC_SIXLOWPAN_STACK_SIZE
¶ Default stack size to use for the 6LoWPAN thread.
1
(THREAD_STACKSIZE_DEFAULT)
-
GNRC_SIXLOWPAN_PRIO
¶ Default priority for the 6LoWPAN thread.
1
(THREAD_PRIORITY_MAIN - 4)
-
GNRC_SIXLOWPAN_MSG_QUEUE_SIZE
¶ Default message queue size to use for the 6LoWPAN thread.
1
(8U)