Browse Source

Refactor border.h

dev/timer
authmillenon 10 years ago
parent
commit
b1d6e7d639
  1. 1
      Makefile
  2. 20
      sys/net/sixlowpan/border.c
  3. 2
      sys/net/sixlowpan/border.h
  4. 10
      sys/net/sixlowpan/bordermultiplex.c
  5. 12
      sys/net/sixlowpan/bordermultiplex.h
  6. 12
      sys/net/sixlowpan/flowcontrol.h
  7. 3
      sys/net/sixlowpan/include/sixlowpan.h
  8. 24
      sys/net/sixlowpan/include/sixlowpan/borderrouter.h
  9. 16
      sys/net/sixlowpan/include/sixlowpan/lowpan.h
  10. 15
      sys/net/sixlowpan/ip.c
  11. 1
      sys/net/sixlowpan/ip.h

1
Makefile

@ -14,3 +14,4 @@ clean:
doc:
make -BC doc/doxygen

20
sys/net/sixlowpan/border.c

@ -37,7 +37,7 @@
#include "sys/net/ieee802154/ieee802154_frame.h"
#include "sys/net/net_help/net_help.h"
#define READER_STACK_SIZE 512
#define READER_STACK_SIZE (KERNEL_CONF_STACKSIZE_IDLE)
ipv6_addr_t abr_addr;
@ -120,7 +120,8 @@ void serial_reader_f(void)
}
}
uint8_t border_initialize(transceiver_type_t trans, ipv6_addr_t *border_router_addr)
uint8_t sixlowpan_lowpan_border_init(transceiver_type_t trans,
const ipv6_addr_t *border_router_addr)
{
ipv6_addr_t addr;
@ -160,21 +161,6 @@ uint8_t border_initialize(transceiver_type_t trans, ipv6_addr_t *border_router_a
return SUCCESS;
}
void border_send_ipv6_over_lowpan(ipv6_hdr_t *packet, uint8_t aro_flag, uint8_t sixco_flag)
{
uint16_t offset = IPV6_HDR_LEN + HTONS(packet->length);
packet->flowlabel = HTONS(packet->flowlabel);
packet->length = HTONS(packet->length);
memset(buffer, 0, BUFFER_SIZE);
memcpy(buffer + LL_HDR_LEN, packet, offset);
sixlowpan_lowpan_sendto((ieee_802154_long_t *) & (packet->destaddr.uint16[4]),
(uint8_t *)packet,
offset);
}
void border_process_lowpan(void)
{
msg_t m;

2
sys/net/sixlowpan/border.h

@ -36,8 +36,6 @@ uint16_t border_get_serial_reader(void);
uint8_t *get_serial_out_buffer(int offset);
uint8_t *get_serial_in_buffer(int offset);
uint8_t border_initialize(transceiver_type_t trans, ipv6_addr_t *border_router_addr);
void border_send_ipv6_over_lowpan(ipv6_hdr_t *packet, uint8_t aro_flag, uint8_t sixco_flag);
void border_process_lowpan(void);
#endif /* _SIXLOWPAN_BORDER_H*/

10
sys/net/sixlowpan/bordermultiplex.c

@ -29,10 +29,10 @@
#include "bordermultiplex.h"
#define END 0xC0
#define ESC 0xDB
#define END_ESC 0xDC
#define ESC_ESC 0xDD
#define END (0xC0)
#define ESC (0xDB)
#define END_ESC (0xDC)
#define ESC_ESC (0xDD)
void demultiplex(border_packet_t *packet, int len)
{
@ -48,7 +48,7 @@ void demultiplex(border_packet_t *packet, int len)
switch (l3_header_buf->ethertype) {
case (BORDER_ETHERTYPE_IPV6): {
ipv6_hdr_t *ipv6_buf = (ipv6_hdr_t *)(((unsigned char *)packet) + sizeof(border_l3_header_t));
border_send_ipv6_over_lowpan(ipv6_buf, 1, 1);
ipv6_send_buf(ipv6_buf);
break;
}

12
sys/net/sixlowpan/bordermultiplex.h

@ -25,16 +25,16 @@
#include "ip.h"
/* packet types of uart-packets */
#define BORDER_PACKET_RAW_TYPE 0
#define BORDER_PACKET_CONF_TYPE 2
#define BORDER_PACKET_L3_TYPE 3
#define BORDER_PACKET_RAW_TYPE (0)
#define BORDER_PACKET_CONF_TYPE (2)
#define BORDER_PACKET_L3_TYPE (3)
/* configuration types */
#define BORDER_CONF_CONTEXT 2
#define BORDER_CONF_IPADDR 3
#define BORDER_CONF_CONTEXT (2)
#define BORDER_CONF_IPADDR (3)
/* ethertypes for L3 packets */
#define BORDER_ETHERTYPE_IPV6 0x86DD
#define BORDER_ETHERTYPE_IPV6 (0x86DD)
typedef struct __attribute__((packed)) {
uint8_t empty;

12
sys/net/sixlowpan/flowcontrol.h

@ -29,15 +29,15 @@
#include "bordermultiplex.h"
/* packet types for flowcontrol */
#define BORDER_PACKET_ACK_TYPE 1
#define BORDER_PACKET_ACK_TYPE (1)
/* configuration types for flowcontrol */
#define BORDER_CONF_SYN 0
#define BORDER_CONF_SYNACK 1
#define BORDER_CONF_SYN (0)
#define BORDER_CONF_SYNACK (1)
#define BORDER_SWS 1
#define BORDER_RWS 1
#define BORDER_SL_TIMEOUT 500 // microseconds, maybe smaller
#define BORDER_SWS (1)
#define BORDER_RWS (1)
#define BORDER_SL_TIMEOUT (500) // microseconds, maybe smaller
#define SENDING_SLOT_STACK_SIZE (256)

3
sys/net/sixlowpan/include/sixlowpan.h

@ -43,12 +43,9 @@
#include "sixlowpan/error.h"
#include "sixlowpan/types.h"
#include "sixlowpan/borderrouter.h"
#include "sixlowpan/lowpan.h"
#include "sixlowpan/mac.h"
#include "../border.h" /* TODO: remove if not needed anymore */
/**
* @}
*/

24
sys/net/sixlowpan/include/sixlowpan/borderrouter.h

@ -1,24 +0,0 @@
/**
* 6LoWPAN constants, data structs, and prototypes for 6LoWPAN border router
*
* 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/borderrouter.h
* @brief 6LoWPAN borderrouter 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>
* @}
*/
#ifndef SIXLOWPAN_BORDERROUTER_H
#define SIXLOWPAN_BORDERROUTER_H
#endif /* SIXLOWPAN_BORDERROUTER_H */

16
sys/net/sixlowpan/include/sixlowpan/lowpan.h

@ -193,6 +193,22 @@ void sixlowpan_lowpan_adhoc_init(transceiver_type_t trans,
const ipv6_addr_t *prefix,
uint8_t r_addr);
/**
* @brief Initializes a 6LoWPAN border router with an address
*
* @note Currently only working with addresses generated from
* IEEE 802.15.4 16-bit short addresses.
*
* @param[in] trans transceiver to use with 6LoWPAN.
* @param[in] border_router_addr Address of this border router.
*
* @return SUCCESS on success, otherwise SIXLOWERROR_ADDRESS if
* address was not generated from IEEE 802.15.4 16-bit short
* address.
*/
uint8_t sixlowpan_lowpan_border_init(transceiver_type_t trans,
const ipv6_addr_t *border_router_addr);
/**
* @brief Send data via 6LoWPAN to destination node dest.
*

15
sys/net/sixlowpan/ip.c

@ -50,6 +50,21 @@ int rpl_process_pid = 0;
/* registered upper layer threads */
int sixlowip_reg[SIXLOWIP_MAX_REGISTERED];
void ipv6_send_buf(ipv6_hdr_t *buffer)
{
uint16_t offset = IPV6_HDR_LEN + HTONS(buffer->length);
buffer->flowlabel = HTONS(buffer->flowlabel);
buffer->length = HTONS(buffer->length);
memset(buffer, 0, BUFFER_SIZE);
memcpy(buffer + LL_HDR_LEN, buffer, offset);
sixlowpan_lowpan_sendto((ieee_802154_long_t *) & (buffer->destaddr.uint16[4]),
(uint8_t *)buffer,
offset);
}
ipv6_hdr_t *get_ipv6_buf_send(void)
{
return ((ipv6_hdr_t *) & (ip_send_buffer[LL_HDR_LEN]));

1
sys/net/sixlowpan/ip.h

@ -134,6 +134,7 @@ typedef struct __attribute__((packed)) {
extern iface_t iface;
void ipv6_send_buf(ipv6_hdr_t *buffer);
/* function prototypes */
struct icmpv6_hdr_t *get_icmpv6_buf(uint8_t ext_len);
ipv6_hdr_t *get_ipv6_buf(void);

Loading…
Cancel
Save