2013-06-22 05:11:53 +02:00
|
|
|
/*
|
|
|
|
* 6lowpan constants, data structs, and prototypes
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* @{
|
|
|
|
* @file sixlowpan.h
|
|
|
|
* @brief 6lowpan header
|
|
|
|
* @author Stephan Zeisberg <zeisberg@mi.fu-berlin.de>
|
|
|
|
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
|
|
|
* @author Eric Engel <eric.engel@fu-berlin.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2012-01-30 22:44:38 +01:00
|
|
|
#ifndef SIXLOWPAN_H
|
|
|
|
#define SIXLOWPAN_H
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
#define IP_PROCESS_STACKSIZE 3072
|
|
|
|
#define NC_STACKSIZE 512
|
|
|
|
#define CON_STACKSIZE 512
|
|
|
|
#define LOWPAN_TRANSFER_BUF_STACKSIZE 512
|
2012-01-30 22:44:38 +01:00
|
|
|
|
|
|
|
/* fragment size in bytes*/
|
|
|
|
#define FRAG_PART_ONE_HDR_LEN 4
|
|
|
|
#define FRAG_PART_N_HDR_LEN 5
|
|
|
|
|
|
|
|
#define LOWPAN_IPHC_DISPATCH 0x60
|
|
|
|
#define LOWPAN_IPHC_FL_C 0x10
|
|
|
|
#define LOWPAN_IPHC_TC_C 0x08
|
|
|
|
#define LOWPAN_IPHC_CID 0x80
|
|
|
|
#define LOWPAN_IPHC_SAC 0x40
|
|
|
|
#define LOWPAN_IPHC_SAM 0x30
|
|
|
|
#define LOWPAN_IPHC_DAC 0x04
|
|
|
|
#define LOWPAN_IPHC_DAM 0x03
|
|
|
|
#define LOWPAN_IPHC_M 0x08
|
|
|
|
#define LOWPAN_IPHC_NH 0x04
|
|
|
|
#define LOWPAN_IPV6_DISPATCH 0x41
|
|
|
|
#define LOWPAN_CONTEXT_MAX 16
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
#define LOWPAN_REAS_BUF_TIMEOUT 15 * 1000 * 1000 /* TODO: Set back to 3 * 1000 * 1000 */
|
2012-01-30 22:44:38 +01:00
|
|
|
|
|
|
|
#include "transceiver.h"
|
|
|
|
#include "sixlowip.h"
|
|
|
|
#include <vtimer.h>
|
|
|
|
#include <mutex.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
extern mutex_t lowpan_context_mutex;
|
2012-02-20 04:25:52 +01:00
|
|
|
extern uint8_t static_route;
|
|
|
|
extern uint16_t local_address;
|
2012-01-30 22:44:38 +01:00
|
|
|
|
|
|
|
typedef struct lowpan_context_t {
|
|
|
|
uint8_t num;
|
|
|
|
ipv6_addr_t prefix;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t comp;
|
|
|
|
uint16_t lifetime;
|
|
|
|
} lowpan_context_t;
|
|
|
|
|
|
|
|
typedef struct lowpan_interval_list_t {
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t start;
|
|
|
|
uint8_t end;
|
|
|
|
struct lowpan_interval_list_t *next;
|
2012-01-30 22:44:38 +01:00
|
|
|
} lowpan_interval_list_t;
|
|
|
|
|
|
|
|
typedef struct lowpan_reas_buf_t {
|
2013-06-22 05:11:53 +02:00
|
|
|
/* Source Address */
|
|
|
|
ieee_802154_long_t s_laddr;
|
|
|
|
/* Destination Address */
|
|
|
|
ieee_802154_long_t d_laddr;
|
|
|
|
/* Identification Number */
|
|
|
|
uint16_t ident_no;
|
|
|
|
/* Timestamp of last packet fragment */
|
|
|
|
long timestamp;
|
|
|
|
/* Size of reassembled packet with possible IPHC header */
|
|
|
|
uint16_t packet_size;
|
|
|
|
/* Additive size of currently already received fragments */
|
|
|
|
uint16_t current_packet_size;
|
|
|
|
/* Pointer to allocated memory for reassembled packet + 6LoWPAN Dispatch Byte */
|
|
|
|
uint8_t *packet;
|
|
|
|
/* Pointer to list of intervals of received packet fragments (if any) */
|
|
|
|
lowpan_interval_list_t *interval_list_head;
|
|
|
|
/* Pointer to next reassembly buffer (if any) */
|
|
|
|
struct lowpan_reas_buf_t *next;
|
2012-01-30 22:44:38 +01:00
|
|
|
} lowpan_reas_buf_t;
|
|
|
|
|
|
|
|
extern lowpan_reas_buf_t *head;
|
|
|
|
|
|
|
|
void sixlowpan_init(transceiver_type_t trans, uint8_t r_addr, int as_border);
|
2013-06-22 05:11:53 +02:00
|
|
|
void sixlowpan_adhoc_init(transceiver_type_t trans, ipv6_addr_t *prefix,
|
|
|
|
uint8_t r_addr);
|
2012-01-30 22:44:38 +01:00
|
|
|
void lowpan_init(ieee_802154_long_t *addr, uint8_t *data);
|
|
|
|
void lowpan_read(uint8_t *data, uint8_t length, ieee_802154_long_t *s_laddr,
|
2013-06-22 05:11:53 +02:00
|
|
|
ieee_802154_long_t *d_laddr);
|
|
|
|
void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra, uint8_t *ptr);
|
2012-01-30 22:44:38 +01:00
|
|
|
void lowpan_iphc_decoding(uint8_t *data, uint8_t length,
|
|
|
|
ieee_802154_long_t *s_laddr,
|
|
|
|
ieee_802154_long_t *d_laddr);
|
2013-06-10 17:36:56 +02:00
|
|
|
uint8_t lowpan_context_len(void);
|
2012-02-20 04:25:52 +01:00
|
|
|
void add_fifo_packet(lowpan_reas_buf_t *current_packet);
|
2013-06-22 05:11:53 +02:00
|
|
|
lowpan_context_t *lowpan_context_update(
|
|
|
|
uint8_t num, const ipv6_addr_t *prefix,
|
|
|
|
uint8_t length, uint8_t comp,
|
|
|
|
uint16_t lifetime);
|
|
|
|
lowpan_context_t *lowpan_context_get(void);
|
|
|
|
lowpan_context_t *lowpan_context_lookup(ipv6_addr_t *addr);
|
|
|
|
lowpan_context_t *lowpan_context_num_lookup(uint8_t num);
|
2012-02-20 04:25:52 +01:00
|
|
|
lowpan_reas_buf_t *collect_garbage_fifo(lowpan_reas_buf_t *current_buf);
|
2012-02-13 23:31:17 +01:00
|
|
|
lowpan_reas_buf_t *collect_garbage(lowpan_reas_buf_t *current_buf);
|
|
|
|
void check_timeout(void);
|
2012-01-30 22:44:38 +01:00
|
|
|
void lowpan_ipv6_set_dispatch(uint8_t *data);
|
|
|
|
void init_reas_bufs(lowpan_reas_buf_t *buf);
|
|
|
|
void printReasBuffers(void);
|
2012-02-20 04:25:52 +01:00
|
|
|
void printFIFOBuffers(void);
|
2012-01-30 22:44:38 +01:00
|
|
|
#endif
|