2010-10-12 21:42:03 +02:00
|
|
|
/* 6LoWPAN IP header file */
|
|
|
|
|
2010-10-17 16:03:48 +02:00
|
|
|
#ifndef SIXLOWIP_H
|
|
|
|
#define SIXLOWIP_H
|
|
|
|
|
2010-10-12 21:42:03 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2010-10-17 16:03:48 +02:00
|
|
|
#define MSBA2_SENSOR_NODE 1
|
|
|
|
|
2010-10-14 13:10:52 +02:00
|
|
|
/* set maximum transmission unit */
|
|
|
|
#ifdef MSBA2_SENSOR_NODE
|
|
|
|
#define MTU 0x3A
|
|
|
|
#else
|
|
|
|
#define MTU 0x0
|
|
|
|
#endif
|
|
|
|
|
2010-10-12 21:42:03 +02:00
|
|
|
#define IPV6_VERSION 0x60
|
|
|
|
#define ICMP_NEXTHEADER 0x3A
|
2010-10-14 13:10:52 +02:00
|
|
|
#define NEIGHBOR_DISCOVERY_HOPLIMIT 0xFF
|
|
|
|
|
|
|
|
#define ICMP_HEADER_LENGTH 0x4
|
|
|
|
#define IPV6_HEADER_LENGTH 0x28
|
|
|
|
|
|
|
|
/* link layer protocol control information length*/
|
|
|
|
#ifdef MSBA2_SENSOR_NODE
|
|
|
|
#define LL_HEADER_LENGTH 0x4
|
|
|
|
#else
|
|
|
|
#define LL_HEADER_LENGTH 0x0
|
|
|
|
#endif
|
|
|
|
|
2010-10-17 16:03:48 +02:00
|
|
|
#define SIXLOWPAN_IPV6_LL_ADDR_LEN 8
|
|
|
|
|
|
|
|
/* size of global buffer */
|
2010-10-14 13:10:52 +02:00
|
|
|
#define BUFFER_SIZE (LL_HEADER_LENGTH + MTU)
|
|
|
|
|
2010-10-19 23:06:47 +02:00
|
|
|
#define MSBA2_OUI 0x005BA2 // 24bit OUI
|
|
|
|
#define R8BIT 0xA2 // random 8bit
|
|
|
|
|
|
|
|
#ifdef MSBA2_SENSOR_NODE
|
|
|
|
#define OUI 0x005BA2
|
|
|
|
#else
|
|
|
|
#define OUI 0x0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define RADIO_CONF radio_cc1100
|
|
|
|
#define RADIO RADIO_CONF
|
|
|
|
|
|
|
|
|
2010-10-17 16:03:48 +02:00
|
|
|
extern uint8_t ipv6_ext_hdr_len;
|
2010-10-14 13:10:52 +02:00
|
|
|
|
|
|
|
#define LLHDR_IPV6HDR_LENGTH (LL_HEADER_LENGTH + IPV6_HEADER_LENGTH + ipv6_ext_hdr_len)
|
2010-10-17 16:03:48 +02:00
|
|
|
#define LLHDR_ICMPV6HDR_LENGTH (LL_HEADER_LENGTH + IPV6_HEADER_LENGTH + ipv6_ext_hdr_len + ICMP_HEADER_LENGTH)
|
|
|
|
#define IPV6HDR_ICMPV6HDR_LENGTH (IPV6_HEADER_LENGTH + ipv6_ext_hdr_len + ICMP_HEADER_LENGTH)
|
2010-10-14 13:10:52 +02:00
|
|
|
/* global buffer*/
|
2010-10-17 16:03:48 +02:00
|
|
|
|
|
|
|
uint8_t buffer[BUFFER_SIZE];
|
2010-10-14 13:10:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ipv6 extension header length */
|
2010-10-12 21:42:03 +02:00
|
|
|
|
2010-10-14 13:10:52 +02:00
|
|
|
typedef union ipv6_addr{
|
|
|
|
uint8_t uint8[16];
|
|
|
|
uint16_t uint16[8];
|
|
|
|
} ipv6_addr;
|
2010-10-12 21:42:03 +02:00
|
|
|
|
2010-10-14 13:10:52 +02:00
|
|
|
struct icmpv6_hdr{
|
2010-10-12 21:42:03 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t code;
|
|
|
|
uint16_t checksum;
|
2010-10-14 13:10:52 +02:00
|
|
|
};
|
2010-10-12 21:42:03 +02:00
|
|
|
|
2010-10-14 13:10:52 +02:00
|
|
|
struct ipv6_hdr{
|
2010-10-12 21:42:03 +02:00
|
|
|
uint8_t version_trafficclass;
|
|
|
|
uint8_t trafficclass_flowlabel;
|
|
|
|
uint16_t flowlabel;
|
|
|
|
uint16_t length;
|
|
|
|
uint8_t nextheader;
|
|
|
|
uint8_t hoplimit;
|
2010-10-14 13:10:52 +02:00
|
|
|
ipv6_addr srcaddr;
|
|
|
|
ipv6_addr destaddr;
|
|
|
|
};
|
2010-10-17 16:03:48 +02:00
|
|
|
|
|
|
|
typedef struct link_layer_addr{
|
|
|
|
uint8_t uint8[8];
|
|
|
|
} link_layer_addr;
|
|
|
|
|
|
|
|
#define HTONS(a) (uint16_t)((((uint16_t) (a)) << 8) | (((uint16_t) (a)) >> 8))
|
|
|
|
|
2010-10-19 23:06:47 +02:00
|
|
|
void create_link_local_prefix(ipv6_addr *ipaddr);
|
|
|
|
|
|
|
|
void create_all_routers_mcast_addr(ipv6_addr *ipaddr);
|
|
|
|
|
|
|
|
void set_eui64(ipv6_addr *ipaddr);
|
|
|
|
|
|
|
|
link_layer_addr* get_eui(ipv6_addr *ipaddr);
|
|
|
|
|
|
|
|
void bootstrapping(void);
|
|
|
|
|
|
|
|
#endif /* SIXLOWIP_H*/
|