1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/sixlowpan/sixlowip.h

103 lines
2.7 KiB
C
Raw Normal View History

/* 6LoWPAN IP header file */
2010-10-17 16:03:48 +02:00
#ifndef SIXLOWIP_H
#define SIXLOWIP_H
#include <stdint.h>
2010-10-17 16:03:48 +02:00
#define MSBA2_SENSOR_NODE 1
/* set maximum transmission unit */
#ifdef MSBA2_SENSOR_NODE
#define MTU 0x3A
#else
#define MTU 0x0
#endif
2010-11-09 22:20:26 +01:00
/* IPv6 field values */
#define IPV6_VER 0x60
#define ICMPV6_NXT_HDR 0x3A
#define ND_HOPLIMIT 0xFF
2010-10-17 16:03:48 +02:00
#define SIXLOWPAN_IPV6_LL_ADDR_LEN 8
/* size of global buffer */
2010-11-09 22:20:26 +01:00
#define BUFFER_SIZE (LL_HDR_LEN + MTU)
#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-11-09 22:20:26 +01:00
#define MULTIHOP_HOPLIMIT 64
2010-10-17 16:03:48 +02:00
extern uint8_t ipv6_ext_hdr_len;
2010-11-09 22:20:26 +01:00
/* base header lengths */
#ifdef MSBA2_SENSOR_NODE
#define LL_HDR_LEN 0x4
#else
#define LL_HDR_LEN 0x0
#endif /* MSBA2_SENSOR_NODE */
#define ICMPV6_HDR_LEN 0x4
#define IPV6_HDR_LEN 0x28
#define LLHDR_IPV6HDR_LEN (LL_HDR_LEN + IPV6_HDR_LEN + ipv6_ext_hdr_len)
#define LLHDR_ICMPV6HDR_LEN (LL_HDR_LEN + IPV6_HDR_LEN + ipv6_ext_hdr_len + ICMPV6_HDR_LEN)
#define IPV6HDR_ICMPV6HDR_LEN (IPV6_HDR_LEN + ipv6_ext_hdr_len + ICMPV6_HDR_LEN)
/* global buffer*/
2010-10-17 16:03:48 +02:00
uint8_t buffer[BUFFER_SIZE];
2010-11-08 10:33:23 +01:00
/* packet length*/
2010-10-27 21:35:40 +02:00
extern uint16_t packet_length;
/* ipv6 extension header length */
typedef union ipv6_addr{
uint8_t uint8[16];
uint16_t uint16[8];
} ipv6_addr;
struct icmpv6_hdr{
uint8_t type;
uint8_t code;
uint16_t checksum;
};
struct ipv6_hdr{
uint8_t version_trafficclass;
uint8_t trafficclass_flowlabel;
uint16_t flowlabel;
uint16_t length;
uint8_t nextheader;
uint8_t hoplimit;
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-11-08 10:33:23 +01:00
#define HTONL(a) ((((uint32_t) (a) & 0xff000000) >> 24) | \
(((uint32_t) (a) & 0x00ff0000) >> 8) | \
(((uint32_t) (a) & 0x0000ff00) << 8) | \
(((uint32_t) (a) & 0x000000ff) << 24))
2010-10-17 16:03:48 +02:00
2010-11-09 22:20:26 +01:00
/* function prototypes */
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);
2010-11-09 22:20:26 +01:00
void print6addr(ipv6_addr *ipaddr);
#endif /* SIXLOWIP_H*/