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

92 lines
2.3 KiB
C
Raw Normal View History

/**
* 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
* 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>
* @}
*/
/* 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
#include <stdint.h>
#include "timex.h"
#include "mutex.h"
2013-08-13 06:41:05 +02:00
#include "sixlowpan/ip.h"
2013-08-08 16:22:37 +02:00
#include "sixlowpan/types.h"
/* 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)
2013-08-13 06:41:05 +02:00
#define MULTIHOP_HOPLIMIT (64)
#define SIXLOWIP_MAX_REGISTERED (4)
/* extern variables */
2010-10-17 16:03:48 +02:00
extern uint8_t ipv6_ext_hdr_len;
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)
#define IFACE_ADDR_LIST_LEN (10) // maybe to much
/* buffer */
extern uint8_t buffer[BUFFER_SIZE];
extern int sixlowip_reg[SIXLOWIP_MAX_REGISTERED];
typedef struct __attribute__((packed)) {
2013-08-13 06:41:05 +02:00
ipv6_addr_t addr;
ipv6_addr_type_t type;
ndp_addr_state_t state;
timex_t val_ltime;
timex_t pref_ltime;
} addr_list_t;
typedef struct __attribute__((packed)) {
ieee_802154_short_t saddr;
ieee_802154_long_t laddr;
addr_list_t addr_list[IFACE_ADDR_LIST_LEN];
uint8_t adv_cur_hop_limit;
uint32_t adv_reachable_time;
uint32_t adv_retrans_timer;
} iface_t;
extern iface_t iface;
2010-11-09 22:20:26 +01:00
/* function prototypes */
2013-08-13 06:41:05 +02:00
void ipv6_send_bytes(ipv6_hdr_t *bytes);
icmpv6_hdr_t *get_icmpv6_buf(uint8_t ext_len);
uint8_t *get_payload_buf(uint8_t ext_len);
uint8_t *get_payload_buf_send(uint8_t ext_len);
2013-08-13 06:41:05 +02:00
int icmpv6_demultiplex(const icmpv6_hdr_t *hdr);
void ipv6_init_iface_as_router(void);
void ipv6_process(void);
addr_list_t *ipv6_iface_addr_prefix_eq(ipv6_addr_t *addr);
2013-08-13 06:41:05 +02:00
addr_list_t *ipv6_iface_addr_match(const ipv6_addr_t *addr);
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*/