2013-06-22 05:11:53 +02:00
|
|
|
/**
|
|
|
|
* IPv6 constants, data structs, and prototypes
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 INRIA.
|
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-06-22 05:11:53 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* @ingroup sixlowpan
|
|
|
|
* @{
|
|
|
|
* @file sixlowip.h
|
|
|
|
* @brief 6lowpan IP layer header
|
|
|
|
* @author Stephan Zeisberg <zeisberg@mi.fu-berlin.de>
|
|
|
|
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
* @author Eric Engel <eric.engel@fu-berlin.de>
|
|
|
|
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2010-10-12 21:42:03 +02:00
|
|
|
/* 6LoWPAN IP header file */
|
|
|
|
|
2013-08-05 16:10:54 +02:00
|
|
|
#ifndef _SIXLOWPAN_IP_H
|
|
|
|
#define _SIXLOWPAN_IP_H
|
2010-10-17 16:03:48 +02:00
|
|
|
|
2010-10-12 21:42:03 +02:00
|
|
|
#include <stdint.h>
|
2013-08-08 13:39:00 +02:00
|
|
|
|
2014-02-13 13:57:59 +01:00
|
|
|
#include "kernel.h"
|
2013-08-08 13:39:00 +02:00
|
|
|
#include "timex.h"
|
|
|
|
#include "mutex.h"
|
2014-02-13 13:57:59 +01:00
|
|
|
#include "net_if.h"
|
2010-10-12 21:42:03 +02:00
|
|
|
|
2013-08-13 06:41:05 +02:00
|
|
|
#include "sixlowpan/ip.h"
|
2013-08-08 16:22:37 +02:00
|
|
|
#include "sixlowpan/types.h"
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
/* IPv6 field values */
|
2013-08-13 06:41:05 +02:00
|
|
|
#define IPV6_VER (0x60)
|
2010-10-17 16:03:48 +02:00
|
|
|
/* size of global buffer */
|
2013-08-13 06:41:05 +02:00
|
|
|
#define BUFFER_SIZE (LL_HDR_LEN + IPV6_MTU)
|
2010-10-19 23:06:47 +02:00
|
|
|
|
2013-08-13 06:41:05 +02:00
|
|
|
#define MULTIHOP_HOPLIMIT (64)
|
2013-07-27 15:04:51 +02:00
|
|
|
|
|
|
|
#define SIXLOWIP_MAX_REGISTERED (4)
|
2014-02-13 13:57:59 +01:00
|
|
|
#define IP_PROCESS_STACKSIZE (KERNEL_CONF_STACKSIZE_MAIN)
|
2013-07-27 15:04:51 +02:00
|
|
|
|
2011-01-07 23:38:42 +01:00
|
|
|
/* extern variables */
|
2010-10-17 16:03:48 +02:00
|
|
|
extern uint8_t ipv6_ext_hdr_len;
|
2014-02-13 13:57:59 +01:00
|
|
|
extern int ip_process_pid;
|
2011-02-22 13:19:16 +01:00
|
|
|
|
2010-11-09 22:20:26 +01:00
|
|
|
/* base header lengths */
|
2013-08-13 06:41:05 +02:00
|
|
|
#define LL_HDR_LEN (0x4)
|
|
|
|
#define ICMPV6_HDR_LEN (0x4)
|
|
|
|
#define IPV6_HDR_LEN (0x28)
|
|
|
|
|
2014-02-13 13:57:59 +01:00
|
|
|
#define IPV6_NET_IF_ADDR_LIST_LEN (10) // maybe to much
|
2011-01-18 11:02:48 +01:00
|
|
|
|
2010-11-30 10:21:29 +01:00
|
|
|
/* buffer */
|
2011-06-24 02:31:55 +02:00
|
|
|
extern uint8_t buffer[BUFFER_SIZE];
|
2014-02-13 13:57:59 +01:00
|
|
|
extern char ip_process_buf[IP_PROCESS_STACKSIZE];
|
2010-11-30 10:21:29 +01:00
|
|
|
|
2013-07-27 15:04:51 +02:00
|
|
|
extern int sixlowip_reg[SIXLOWIP_MAX_REGISTERED];
|
2010-11-30 10:21:29 +01:00
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2014-02-13 13:57:59 +01:00
|
|
|
struct net_if_addr_t *addr_next;
|
|
|
|
struct net_if_addr_t *addr_prev;
|
|
|
|
net_if_l3p_t addr_protocol;
|
|
|
|
ipv6_addr_t *addr_data;
|
|
|
|
uint8_t addr_len;
|
|
|
|
ndp_addr_state_t ndp_state;
|
|
|
|
timex_t valid_lifetime;
|
|
|
|
timex_t preferred_lifetime;
|
|
|
|
uint8_t is_anycast;
|
|
|
|
} ipv6_net_if_addr_t;
|
2011-01-18 11:02:48 +01:00
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2014-02-13 13:57:59 +01:00
|
|
|
ipv6_net_if_addr_t *addr;
|
|
|
|
int if_id;
|
|
|
|
} ipv6_net_if_hit_t;
|
|
|
|
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
|
|
uint8_t prefix; ///< prefix length of the sub-net
|
2011-01-18 11:02:48 +01:00
|
|
|
uint8_t adv_cur_hop_limit;
|
|
|
|
uint32_t adv_reachable_time;
|
|
|
|
uint32_t adv_retrans_timer;
|
2014-02-13 13:57:59 +01:00
|
|
|
} ipv6_net_if_ext_t;
|
2011-01-07 23:38:42 +01:00
|
|
|
|
2010-11-09 22:20:26 +01:00
|
|
|
/* function prototypes */
|
2014-02-13 13:57:59 +01:00
|
|
|
ipv6_net_if_ext_t *ipv6_net_if_get_ext(int if_id);
|
|
|
|
|
2013-08-13 06:41:05 +02:00
|
|
|
icmpv6_hdr_t *get_icmpv6_buf(uint8_t ext_len);
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t *get_payload_buf(uint8_t ext_len);
|
|
|
|
uint8_t *get_payload_buf_send(uint8_t ext_len);
|
2010-11-22 12:52:56 +01:00
|
|
|
|
2013-08-13 06:41:05 +02:00
|
|
|
int icmpv6_demultiplex(const icmpv6_hdr_t *hdr);
|
2014-02-13 13:57:59 +01:00
|
|
|
int ipv6_init_as_router(void);
|
2014-03-04 20:20:01 +01:00
|
|
|
void *ipv6_process(void *);
|
2014-02-13 13:57:59 +01:00
|
|
|
ipv6_net_if_hit_t *ipv6_net_if_addr_prefix_eq(ipv6_net_if_hit_t *hit, ipv6_addr_t *addr);
|
|
|
|
ipv6_net_if_hit_t *ipv6_net_if_addr_match(ipv6_net_if_hit_t *hit, const ipv6_addr_t *addr);
|
2012-01-11 17:02:43 +01:00
|
|
|
uint32_t get_remaining_time(timex_t *t);
|
|
|
|
void set_remaining_time(timex_t *t, uint32_t time);
|
2013-08-13 06:41:05 +02:00
|
|
|
|
2013-08-05 16:10:54 +02:00
|
|
|
#endif /* _SIXLOWPAN_IP_H*/
|