2011-07-23 22:17:52 +02:00
|
|
|
/* 6LoWPAN Border Router header file */
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
#ifndef SIXLOWBORDER_H
|
|
|
|
#define SIXLOWBORDER_H
|
2011-06-22 21:09:06 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2011-07-05 04:24:13 +02:00
|
|
|
#include <mutex.h>
|
2011-07-11 18:26:12 +02:00
|
|
|
#include <vtimer.h>
|
2011-06-22 21:09:06 +02:00
|
|
|
#include "sixlowip.h"
|
|
|
|
#include "sixlowpan.h"
|
|
|
|
#include "sixlownd.h"
|
2011-07-11 18:26:12 +02:00
|
|
|
#include "semaphore.h"
|
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_SWS 8
|
|
|
|
#define BORDER_RWS 8
|
|
|
|
#define BORDER_SL_TIMEOUT 500 // microseconds, maybe smaller
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_HEADER_LENGTH 2
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-05 04:24:13 +02:00
|
|
|
/* packet types of uart-packets */
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_PACKET_RAW_TYPE 0
|
|
|
|
#define BORDER_PACKET_ACK_TYPE 1
|
|
|
|
#define BORDER_PACKET_CONF_TYPE 2
|
|
|
|
#define BORDER_PACKET_L3_TYPE 3
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-11 18:26:12 +02:00
|
|
|
/* configuration types */
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_CONF_SYN 0
|
|
|
|
#define BORDER_CONF_SYNACK 1
|
|
|
|
#define BORDER_CONF_CONTEXT 2
|
|
|
|
#define BORDER_CONF_IPADDR 3
|
2011-07-11 18:26:12 +02:00
|
|
|
|
2011-06-22 21:09:06 +02:00
|
|
|
/* ethertypes for L3 packets */
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_ETHERTYPE_IPV6 0x86DD
|
2011-06-22 21:09:06 +02:00
|
|
|
|
|
|
|
extern uint16_t abro_version;
|
2011-07-11 18:26:12 +02:00
|
|
|
extern int tun_fd;
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_packet_t {
|
2011-07-05 04:24:13 +02:00
|
|
|
uint8_t reserved;
|
2011-06-22 21:09:06 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_packet_t;
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_l3_header_t {
|
2011-07-05 04:24:13 +02:00
|
|
|
uint8_t reserved;
|
2011-06-22 21:09:06 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint16_t ethertype;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_l3_header_t;
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_conf_header_t {
|
2011-07-11 18:26:12 +02:00
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_conf_header_t;
|
2011-07-11 18:26:12 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_syn_packet_t {
|
2011-07-12 15:00:21 +02:00
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t next_seq_num;
|
|
|
|
uint8_t conftype;
|
|
|
|
uint8_t next_exp;
|
|
|
|
ipv6_addr_t addr;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_syn_packet_t;
|
2011-07-12 15:00:21 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_addr_packet_t {
|
2011-07-11 18:26:12 +02:00
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
|
|
|
ipv6_addr_t addr;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_addr_packet_t;
|
2011-07-11 18:26:12 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct __attribute__ ((packed)) border_context_packet_t {
|
2011-07-11 18:26:12 +02:00
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
2011-07-23 22:17:52 +02:00
|
|
|
struct border_context_t {
|
2011-07-24 17:29:50 +02:00
|
|
|
uint8_t cid;
|
2011-07-11 18:26:12 +02:00
|
|
|
ipv6_addr_t prefix;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t comp;
|
|
|
|
uint16_t lifetime;
|
|
|
|
} context;
|
2011-07-23 22:17:52 +02:00
|
|
|
} border_context_packet_t;
|
2011-07-11 18:26:12 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
#define BORDER_BUFFER_SIZE (sizeof (border_l3_header_t) + MTU)
|
2011-07-05 04:24:13 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
typedef struct flowcontrol_stat_t {
|
2011-07-11 18:26:12 +02:00
|
|
|
/* Sender state */
|
|
|
|
uint8_t last_ack;
|
|
|
|
uint8_t last_frame;
|
|
|
|
sem_t send_win_not_full;
|
|
|
|
struct send_slot {
|
|
|
|
vtimer_t timeout;
|
2011-07-23 22:17:52 +02:00
|
|
|
uint8_t frame[BORDER_BUFFER_SIZE];
|
2011-07-11 18:26:12 +02:00
|
|
|
size_t frame_len;
|
2011-07-23 22:17:52 +02:00
|
|
|
} send_win[BORDER_SWS];
|
2011-07-11 18:26:12 +02:00
|
|
|
|
|
|
|
/* Receiver state */
|
|
|
|
uint8_t next_exp;
|
|
|
|
struct recv_slot {
|
|
|
|
int8_t received;
|
2011-07-23 22:17:52 +02:00
|
|
|
uint8_t frame[BORDER_BUFFER_SIZE];
|
2011-07-11 18:26:12 +02:00
|
|
|
size_t frame_len;
|
2011-07-23 22:17:52 +02:00
|
|
|
} recv_win[BORDER_RWS];
|
|
|
|
} flowcontrol_stat_t;
|
|
|
|
|
|
|
|
uint8_t border_initialize(transceiver_type_t trans,ipv6_addr_t *border_router_addr);
|
|
|
|
void multiplex_send_ipv6_over_uart(struct ipv6_hdr_t *packet);
|
2011-07-24 18:06:28 +02:00
|
|
|
void multiplex_send_addr_over_uart(ipv6_addr_t *addr);
|
2011-07-23 22:17:52 +02:00
|
|
|
void flowcontrol_send_over_uart(border_packet_t *packet, int len);
|
|
|
|
void border_send_ipv6_over_lowpan(struct ipv6_hdr_t *packet, uint8_t aro_flag, uint8_t sixco_flag);
|
|
|
|
void border_process_lowpan(void);
|
2011-07-11 18:26:12 +02:00
|
|
|
// to be removed
|
2011-07-23 22:17:52 +02:00
|
|
|
void border_process_uart(void);
|
2011-07-11 18:26:12 +02:00
|
|
|
|
|
|
|
void slwin_init();
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
abr_cache_t *get_border_router_info();
|
2011-06-22 21:09:06 +02:00
|
|
|
|
2011-07-23 22:17:52 +02:00
|
|
|
#endif /* SIXLOWBORDER_H*/
|