2013-06-22 05:11:53 +02:00
|
|
|
/**
|
2013-08-08 13:39:00 +02:00
|
|
|
* 6lowpan border router multiplexer
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2013 INRIA.
|
|
|
|
*
|
|
|
|
* This file subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* @ingroup sixlowpan
|
|
|
|
* @{
|
2013-08-08 13:39:00 +02:00
|
|
|
* @file bordermultiplex.h
|
2013-06-22 05:11:53 +02:00
|
|
|
* @brief data structs for border router multiplexing
|
|
|
|
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2013-08-05 16:10:54 +02:00
|
|
|
#ifndef _SIXLOWPAN_BORDERMULTIPLEX_H
|
|
|
|
#define _SIXLOWPAN_BORDERMULTIPLEX_H
|
2011-07-25 17:00:18 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-08-05 16:10:54 +02:00
|
|
|
#include "ip.h"
|
2011-07-25 17:00:18 +02:00
|
|
|
|
|
|
|
/* packet types of uart-packets */
|
2013-08-12 11:08:19 +02:00
|
|
|
#define BORDER_PACKET_RAW_TYPE (0)
|
|
|
|
#define BORDER_PACKET_CONF_TYPE (2)
|
|
|
|
#define BORDER_PACKET_L3_TYPE (3)
|
2011-07-25 17:00:18 +02:00
|
|
|
|
|
|
|
/* configuration types */
|
2013-08-12 11:08:19 +02:00
|
|
|
#define BORDER_CONF_CONTEXT (2)
|
|
|
|
#define BORDER_CONF_IPADDR (3)
|
2011-07-25 17:00:18 +02:00
|
|
|
|
|
|
|
/* ethertypes for L3 packets */
|
2013-08-12 11:08:19 +02:00
|
|
|
#define BORDER_ETHERTYPE_IPV6 (0x86DD)
|
2011-07-25 17:00:18 +02:00
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2011-08-05 15:45:38 +02:00
|
|
|
uint8_t empty;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
} border_packet_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2011-08-05 15:45:38 +02:00
|
|
|
uint8_t empty;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint16_t ethertype;
|
|
|
|
} border_l3_header_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2011-08-05 15:45:38 +02:00
|
|
|
uint8_t empty;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
|
|
|
} border_conf_header_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2011-08-05 15:45:38 +02:00
|
|
|
uint8_t empty;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
2011-07-26 02:04:29 +02:00
|
|
|
uint16_t version;
|
2011-07-25 17:00:18 +02:00
|
|
|
ipv6_addr_t addr;
|
|
|
|
} border_addr_packet_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2011-08-05 15:45:38 +02:00
|
|
|
uint8_t empty;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t seq_num;
|
|
|
|
uint8_t conftype;
|
|
|
|
struct border_context_t {
|
2011-07-26 02:04:29 +02:00
|
|
|
uint16_t version;
|
2011-07-25 17:00:18 +02:00
|
|
|
uint8_t cid;
|
|
|
|
ipv6_addr_t prefix;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t comp;
|
|
|
|
uint16_t lifetime;
|
|
|
|
} context;
|
|
|
|
} border_context_packet_t;
|
|
|
|
|
2013-08-13 06:41:05 +02:00
|
|
|
#define BORDER_BUFFER_SIZE (sizeof(border_l3_header_t) + IPV6_MTU)
|
2011-07-25 17:00:18 +02:00
|
|
|
|
|
|
|
void demultiplex(border_packet_t *packet, int len);
|
2013-06-24 14:11:30 +02:00
|
|
|
void multiplex_send_ipv6_over_uart(ipv6_hdr_t *packet);
|
2011-07-25 17:00:18 +02:00
|
|
|
void multiplex_send_addr_over_uart(ipv6_addr_t *addr);
|
|
|
|
|
|
|
|
int readpacket(uint8_t *packet_buf, size_t size);
|
|
|
|
int writepacket(uint8_t *packet_buf, size_t size);
|
|
|
|
|
2013-08-05 16:10:54 +02:00
|
|
|
#endif /* _SIXLOWPAN_BORDERMULTIPLEX_H*/
|