2008-10-14 11:42:33 +02:00
|
|
|
/**
|
|
|
|
* \addtogroup sicslowpan
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008, Swedish Institute of Computer Science.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the Contiki operating system.
|
|
|
|
*
|
A work-in-progress rework of the Contiki MAC and radio layers. The
main ideas are:
* Separates the Contiki low-layer network stack into four layers:
network (e.g. sicslowpan / rime), Medium Access Control MAC
(e.g. CSMA), Radio Duty Cycling RDC (e.g. ContikiMAC, X-MAC), and
radio (e.g. cc2420).
* Introduces a new way to configure the network stack. Four #defines
that specify what mechanism/protocol/driver to use at the four
layers: NETSTACK_CONF_NETWORK, NETSTACK_CONF_MAC, NETSTACK_CONF_RDC,
NETSTACK_CONF_RADIO.
* Adds a callback mechanism to inform the MAC and network layers about
the fate of a transmitted packet: if the packet was not possible to
transmit, the cause of the failure is reported, and if the packets
was successfully transmitted, the number of tries before it was
finally transmitted is reported.
* NULL-protocols at both the MAC and RDC layers: nullmac and nullrdc,
which can be used when MAC and RDC functionality is not needed.
* Extends the radio API with three new functions that enable more
efficient radio duty cycling protocols: channel check, pending
packet, and receiving packet.
* New initialization mechanism, which takes advantage of the NETSTACK
#defines.
2010-02-18 22:48:39 +01:00
|
|
|
* $Id: sicslowpan.h,v 1.6 2010/02/18 21:48:39 adamdunkels Exp $
|
2008-10-14 11:42:33 +02:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Header file for the 6lowpan implementation
|
|
|
|
* (RFC4944 and draft-hui-6lowpan-hc-01)
|
|
|
|
* \author Adam Dunkels <adam@sics.se>
|
|
|
|
* \author Nicolas Tsiftes <nvt@sics.se>
|
|
|
|
* \author Niclas Finne <nfi@sics.se>
|
|
|
|
* \author Mathilde Durvy <mdurvy@cisco.com>
|
|
|
|
* \author Julien Abeille <jabeille@cisco.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SICSLOWPAN_H__
|
|
|
|
#define __SICSLOWPAN_H__
|
|
|
|
#include "net/uip.h"
|
2009-04-06 15:11:20 +02:00
|
|
|
#include "net/mac/mac.h"
|
2008-10-14 11:42:33 +02:00
|
|
|
|
2008-10-14 14:26:18 +02:00
|
|
|
/**
|
2008-10-14 11:42:33 +02:00
|
|
|
* \name General sicslowpan defines
|
|
|
|
* @{
|
|
|
|
*/
|
2009-03-17 21:28:44 +01:00
|
|
|
/* Min and Max compressible UDP ports */
|
2008-10-14 11:42:33 +02:00
|
|
|
#define SICSLOWPAN_UDP_PORT_MIN 0xF0B0
|
|
|
|
#define SICSLOWPAN_UDP_PORT_MAX 0xF0BF /* F0B0 + 15 */
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
2008-10-14 14:26:18 +02:00
|
|
|
/**
|
2009-03-17 21:28:44 +01:00
|
|
|
* \name 6lowpan dispatches
|
2008-10-14 11:42:33 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define SICSLOWPAN_DISPATCH_IPV6 0x41 /* 01000001 = 65 */
|
|
|
|
#define SICSLOWPAN_DISPATCH_HC1 0x42 /* 01000010 = 66 */
|
|
|
|
#define SICSLOWPAN_DISPATCH_IPHC 0x03 /* 00000011 = 3 */
|
|
|
|
#define SICSLOWPAN_DISPATCH_FRAG1 0xc0 /* 11000xxx */
|
|
|
|
#define SICSLOWPAN_DISPATCH_FRAGN 0xe0 /* 11100xxx */
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \name HC1 encoding
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define SICSLOWPAN_HC1_NH_UDP 0x02
|
|
|
|
#define SICSLOWPAN_HC1_NH_TCP 0x06
|
|
|
|
#define SICSLOWPAN_HC1_NH_ICMP6 0x04
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \name HC_UDP encoding (works together with HC1)
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define SICSLOWPAN_HC_UDP_ALL_C 0xE0
|
|
|
|
/** @} */
|
|
|
|
|
2008-10-14 14:26:18 +02:00
|
|
|
/**
|
2008-10-14 11:42:33 +02:00
|
|
|
* \name IPHC encoding
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Values of fields within the IPHC encoding first byte
|
|
|
|
* (C stands for compressed and I for inline)
|
|
|
|
*/
|
|
|
|
#define SICSLOWPAN_IPHC_TC_C 0x80
|
|
|
|
#define SICSLOWPAN_IPHC_VF_C 0x40
|
|
|
|
#define SICSLOWPAN_IPHC_NH_C 0x20
|
|
|
|
#define SICSLOWPAN_IPHC_TTL_1 0x08
|
|
|
|
#define SICSLOWPAN_IPHC_TTL_64 0x10
|
|
|
|
#define SICSLOWPAN_IPHC_TTL_255 0x18
|
|
|
|
#define SICSLOWPAN_IPHC_TTL_I 0x00
|
|
|
|
|
|
|
|
/* Values of fields within the IPHC encoding second byte */
|
|
|
|
#define SICSLOWPAN_IPHC_SAM_I 0x00
|
|
|
|
#define SICSLOWPAN_IPHC_SAM_64 0x40
|
|
|
|
#define SICSLOWPAN_IPHC_SAM_16 0x80
|
|
|
|
#define SICSLOWPAN_IPHC_SAM_0 0xC0
|
|
|
|
#define SICSLOWPAN_IPHC_DAM_I 0x00
|
|
|
|
#define SICSLOWPAN_IPHC_DAM_64 0x04
|
|
|
|
#define SICSLOWPAN_IPHC_DAM_16 0x08
|
|
|
|
#define SICSLOWPAN_IPHC_DAM_0 0x0C
|
|
|
|
|
|
|
|
/* Link local context number */
|
|
|
|
#define SICSLOWPAN_IPHC_ADDR_CONTEXT_LL 0
|
|
|
|
/* 16-bit multicast addresses compression */
|
|
|
|
#define SICSLOWPAN_IPHC_MCAST_RANGE 0xA0
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
2008-10-14 14:26:18 +02:00
|
|
|
/**
|
2008-10-14 11:42:33 +02:00
|
|
|
* \name LOWPAN_UDP encoding (works together with IPHC)
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define SICSLOWPAN_NHC_UDP_ID 0xF8
|
|
|
|
#define SICSLOWPAN_NHC_UDP_C 0xFB
|
|
|
|
#define SICSLOWPAN_NHC_UDP_I 0xF8
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \name The 6lowpan "headers" length
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SICSLOWPAN_IPV6_HDR_LEN 1 /*one byte*/
|
|
|
|
#define SICSLOWPAN_HC1_HDR_LEN 3
|
|
|
|
#define SICSLOWPAN_HC1_HC_UDP_HDR_LEN 7
|
|
|
|
#define SICSLOWPAN_FRAG1_HDR_LEN 4
|
|
|
|
#define SICSLOWPAN_FRAGN_HDR_LEN 5
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2008-10-14 14:26:18 +02:00
|
|
|
* \brief The header for fragments
|
2009-03-17 21:28:44 +01:00
|
|
|
* \note We do not define different structures for FRAG1
|
2008-10-14 14:26:18 +02:00
|
|
|
* and FRAGN headers, which are different. For FRAG1, the
|
2008-10-14 11:42:33 +02:00
|
|
|
* offset field is just not used
|
|
|
|
*/
|
2009-04-06 15:11:20 +02:00
|
|
|
/* struct sicslowpan_frag_hdr { */
|
|
|
|
/* u16_t dispatch_size; */
|
|
|
|
/* u16_t tag; */
|
|
|
|
/* u8_t offset; */
|
|
|
|
/* }; */
|
2008-10-14 11:42:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief The HC1 header when HC_UDP is not used
|
|
|
|
*
|
|
|
|
* When all fields are compressed and HC_UDP is not used,
|
|
|
|
* we use this structure. If HC_UDP is used, the ttl is
|
|
|
|
* in another spot, and we use the sicslowpan_hc1_hc_udp
|
2008-10-14 14:26:18 +02:00
|
|
|
* structure
|
2008-10-14 11:42:33 +02:00
|
|
|
*/
|
2009-04-06 15:11:20 +02:00
|
|
|
/* struct sicslowpan_hc1_hdr { */
|
|
|
|
/* u8_t dispatch; */
|
|
|
|
/* u8_t encoding; */
|
|
|
|
/* u8_t ttl; */
|
|
|
|
/* }; */
|
2008-10-14 11:42:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief HC1 followed by HC_UDP
|
|
|
|
*/
|
2009-04-06 15:11:20 +02:00
|
|
|
/* struct sicslowpan_hc1_hc_udp_hdr { */
|
|
|
|
/* u8_t dispatch; */
|
|
|
|
/* u8_t hc1_encoding; */
|
|
|
|
/* u8_t hc_udp_encoding; */
|
|
|
|
/* u8_t ttl; */
|
|
|
|
/* u8_t ports; */
|
|
|
|
/* u16_t udpchksum; */
|
|
|
|
/* }; */
|
2008-10-14 11:42:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief IPHC dispatch and encoding
|
|
|
|
* the rest (uncompressed fields) is variable
|
|
|
|
*/
|
|
|
|
struct sicslowpan_iphc_hdr {
|
|
|
|
u8_t dispatch;
|
|
|
|
u8_t encoding[2];
|
|
|
|
};
|
|
|
|
|
2009-04-06 15:11:20 +02:00
|
|
|
/* struct sicslowpan_nhc_udp_comp_hdr { */
|
|
|
|
/* u8_t nhcid; */
|
|
|
|
/* u8_t ports; */
|
|
|
|
/* u16_t udpchksum; */
|
|
|
|
/* }; */
|
2008-10-14 11:42:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief An address context for IPHC address compression
|
|
|
|
*/
|
|
|
|
struct sicslowpan_addr_context {
|
|
|
|
u8_t used;
|
|
|
|
u8_t number;
|
|
|
|
u8_t prefix[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \name Address compressibility test functions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief check whether we can compress the IID in
|
|
|
|
* address 'a' to 16 bits.
|
|
|
|
* This is used for unicast addresses only, and is true
|
|
|
|
* if first 49 bits of IID are 0
|
|
|
|
*/
|
|
|
|
#define sicslowpan_is_iid_16_bit_compressable(a) \
|
|
|
|
((((a)->u16[4]) == 0) && \
|
|
|
|
(((a)->u16[5]) == 0) && \
|
|
|
|
(((a)->u16[6]) == 0) && \
|
|
|
|
((((a)->u8[14]) & 0x80) == 0))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief check whether the 9-bit group-id of the
|
|
|
|
* compressed multicast address is known. It is true
|
|
|
|
* if the 9-bit group is the all nodes or all routers
|
|
|
|
* group.
|
|
|
|
* \param a is typed u8_t *
|
|
|
|
*/
|
|
|
|
#define sicslowpan_is_mcast_addr_decompressable(a) \
|
|
|
|
(((*a & 0x01) == 0) && \
|
|
|
|
((*(a + 1) == 0x01) || (*(a + 1) == 0x02)))
|
|
|
|
|
|
|
|
/**
|
2008-10-14 14:26:18 +02:00
|
|
|
* \brief check whether the 112-bit group-id of the
|
2009-03-17 21:28:44 +01:00
|
|
|
* multicast address is mappable to a 9-bit group-id
|
2008-10-14 14:26:18 +02:00
|
|
|
* It is true if the group is the all nodes or all
|
2008-10-14 11:42:33 +02:00
|
|
|
* routers group.
|
|
|
|
*/
|
|
|
|
#define sicslowpan_is_mcast_addr_compressable(a) \
|
|
|
|
((((a)->u16[1]) == 0) && \
|
|
|
|
(((a)->u16[2]) == 0) && \
|
|
|
|
(((a)->u16[3]) == 0) && \
|
|
|
|
(((a)->u16[4]) == 0) && \
|
|
|
|
(((a)->u16[5]) == 0) && \
|
|
|
|
(((a)->u16[6]) == 0) && \
|
|
|
|
(((a)->u8[14]) == 0) && \
|
|
|
|
((((a)->u8[15]) == 1) || (((a)->u8[15]) == 2)))
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
A work-in-progress rework of the Contiki MAC and radio layers. The
main ideas are:
* Separates the Contiki low-layer network stack into four layers:
network (e.g. sicslowpan / rime), Medium Access Control MAC
(e.g. CSMA), Radio Duty Cycling RDC (e.g. ContikiMAC, X-MAC), and
radio (e.g. cc2420).
* Introduces a new way to configure the network stack. Four #defines
that specify what mechanism/protocol/driver to use at the four
layers: NETSTACK_CONF_NETWORK, NETSTACK_CONF_MAC, NETSTACK_CONF_RDC,
NETSTACK_CONF_RADIO.
* Adds a callback mechanism to inform the MAC and network layers about
the fate of a transmitted packet: if the packet was not possible to
transmit, the cause of the failure is reported, and if the packets
was successfully transmitted, the number of tries before it was
finally transmitted is reported.
* NULL-protocols at both the MAC and RDC layers: nullmac and nullrdc,
which can be used when MAC and RDC functionality is not needed.
* Extends the radio API with three new functions that enable more
efficient radio duty cycling protocols: channel check, pending
packet, and receiving packet.
* New initialization mechanism, which takes advantage of the NETSTACK
#defines.
2010-02-18 22:48:39 +01:00
|
|
|
extern const struct mac_driver sicslowpan_driver;
|
2008-10-14 11:42:33 +02:00
|
|
|
|
2010-01-28 14:50:51 +01:00
|
|
|
extern const struct mac_driver *sicslowpan_mac;
|
2008-10-14 11:42:33 +02:00
|
|
|
#endif /* __SICSLOWPAN_H__ */
|
|
|
|
/** @} */
|