2016-06-23 21:06:24 +08:00
|
|
|
/** @file
|
|
|
|
@brief 6lowpan private header
|
|
|
|
|
|
|
|
This is not to be included by the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-06-23 21:06:24 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* 6lopan dispatches */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_DISPATCH_IPV6 0x41 /* 01000001 */
|
|
|
|
#define NET_6LO_DISPATCH_BROADCAST 0x50 /* 01010000 */
|
|
|
|
#define NET_6LO_DISPATCH_IPHC 0x60 /* 01100000 */
|
|
|
|
#define NET_6LO_DISPATCH_MESH 0x80 /* 10xxxxxx */
|
|
|
|
#define NET_6LO_DISPATCH_FRAG1 0xC0 /* 11000xxx */
|
|
|
|
#define NET_6LO_DISPATCH_FRAGN 0xE0 /* 11100xxx */
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TF (Traffic class and Flow label)
|
|
|
|
* 00: ECN + DSCP + 4-bit Pad + Flow Label (4 bytes)
|
|
|
|
* 01: ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided.
|
|
|
|
* 10: ECN + DSCP (1 byte), Flow Label is elided.
|
|
|
|
* 11: Traffic Class and Flow Label are elided.
|
|
|
|
*/
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_TF_00 0x00
|
|
|
|
#define NET_6LO_IPHC_TF_01 0x08
|
|
|
|
#define NET_6LO_IPHC_TF_10 0x10
|
|
|
|
#define NET_6LO_IPHC_TF_11 0x18
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* NH (next header) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_NH_0 0x00
|
|
|
|
#define NET_6LO_IPHC_NH_1 0x04
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* HLIM (Hop Limit) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_HLIM 0x00 /* 00 */
|
|
|
|
#define NET_6LO_IPHC_HLIM1 0x01 /* 01 */
|
|
|
|
#define NET_6LO_IPHC_HLIM64 0x02 /* 10 */
|
|
|
|
#define NET_6LO_IPHC_HLIM255 0x03 /* 11 */
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* CID (Context Identifier Extension) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_CID_0 0x00
|
|
|
|
#define NET_6LO_IPHC_CID_1 0x80
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* SAC (Source Address Compression) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_SAC_0 0x00
|
|
|
|
#define NET_6LO_IPHC_SAC_1 0x40
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* SAM (Source Address Mode) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_SAM_00 0x00
|
|
|
|
#define NET_6LO_IPHC_SAM_01 0x10
|
|
|
|
#define NET_6LO_IPHC_SAM_10 0x20
|
|
|
|
#define NET_6LO_IPHC_SAM_11 0x30
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* M (Multicast compression) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_M_0 0x00
|
|
|
|
#define NET_6LO_IPHC_M_1 0x08
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* DAC (Destination Address Compression) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_DAC_0 0x00
|
|
|
|
#define NET_6LO_IPHC_DAC_1 0x04
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* DAM (Destination Address Mode) */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_IPHC_DAM_00 0x00
|
|
|
|
#define NET_6LO_IPHC_DAM_01 0x01
|
|
|
|
#define NET_6LO_IPHC_DAM_10 0x02
|
|
|
|
#define NET_6LO_IPHC_DAM_11 0x03
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
/* Next Header UDP */
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_NHC_UDP_BARE 0xF0
|
2016-06-23 21:06:24 +08:00
|
|
|
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_NHC_UDP_CHKSUM_0 0x00
|
|
|
|
#define NET_6LO_NHC_UDP_CHKSUM_1 0x08
|
2016-06-23 21:06:24 +08:00
|
|
|
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_NHC_UDP_PORT_00 0x00
|
|
|
|
#define NET_6LO_NHC_UDP_PORT_01 0x01
|
|
|
|
#define NET_6LO_NHC_UDP_PORT_10 0x02
|
|
|
|
#define NET_6LO_NHC_UDP_PORT_11 0x03
|
2016-06-23 21:06:24 +08:00
|
|
|
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_NHC_UDP_8_BIT_PORT 0xF0
|
|
|
|
#define NET_6LO_NHC_UDP_4_BIT_PORT 0xF0B
|
2016-06-23 21:06:24 +08:00
|
|
|
|
|
|
|
#define IPHC ((frag)->data)
|
2017-04-05 14:37:44 +08:00
|
|
|
#define CIPHC ((pkt->frags)->data)
|
2016-07-11 16:14:21 +08:00
|
|
|
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_FRAG1_HDR_LEN 4
|
|
|
|
#define NET_6LO_FRAGN_HDR_LEN 5
|
2016-07-11 16:14:21 +08:00
|
|
|
|
2016-07-08 22:20:38 +08:00
|
|
|
#define NET_6LO_FRAG_DATAGRAM_SIZE_LEN 2
|
|
|
|
#define NET_6LO_FRAG_DATAGRAM_OFFSET_LEN 2
|
2017-02-21 16:34:39 +08:00
|
|
|
|
|
|
|
/* Timeout when getting net_buf in RX path. In RX, we must not wait forever as
|
|
|
|
* that can cause the stack to deadlock. This can happen if RX side is flooding
|
|
|
|
* incoming data and we cannot get process the packet in 6lo side.
|
|
|
|
*/
|
2017-04-03 23:14:35 +08:00
|
|
|
#define NET_6LO_RX_PKT_TIMEOUT 100 /* in ms */
|