Merge branch 'contiki' into osd
This commit is contained in:
commit
a02be51f08
274 changed files with 1159 additions and 1285 deletions
|
@ -123,11 +123,11 @@
|
|||
* project-specific configuration to save memory.
|
||||
*/
|
||||
|
||||
/* UIP_CONF_IPV6 specifies whether or not IPv6 should be used. If IPv6
|
||||
/* NETSTACK_CONF_WITH_IPV6 specifies whether or not IPv6 should be used. If IPv6
|
||||
is not used, IPv4 is used instead. */
|
||||
#ifndef UIP_CONF_IPV6
|
||||
#define UIP_CONF_IPV6 0
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#ifndef NETSTACK_CONF_WITH_IPV6
|
||||
#define NETSTACK_CONF_WITH_IPV6 0
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* UIP_CONF_BUFFER_SIZE specifies how much memory should be reserved
|
||||
for the uIP packet buffer. This sets an upper bound on the largest
|
||||
|
|
|
@ -45,10 +45,10 @@
|
|||
#include "net/ip/uip-udp-packet.h"
|
||||
#include "net/ip/simple-udp.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#include "net/ipv6/uip-icmp6.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#include "net/ip/resolv.h"
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@ slip_set_input_callback(void (*c)(void))
|
|||
/* slip_send: forward (IPv4) packets with {UIP_FW_NETIF(..., slip_send)}
|
||||
* was used in slip-bridge.c
|
||||
*/
|
||||
//#if WITH_UIP
|
||||
uint8_t
|
||||
slip_send(void)
|
||||
{
|
||||
|
@ -125,7 +124,6 @@ slip_send(void)
|
|||
|
||||
return UIP_FW_OK;
|
||||
}
|
||||
//#endif /* WITH_UIP */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint8_t
|
||||
slip_write(const void *_ptr, int len)
|
||||
|
@ -264,7 +262,7 @@ PROCESS_THREAD(slip_process, ev, data)
|
|||
/* Move packet from rxbuf to buffer provided by uIP. */
|
||||
uip_len = slip_poll_handler(&uip_buf[UIP_LLH_LEN],
|
||||
UIP_BUFSIZE - UIP_LLH_LEN);
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
if(uip_len == 4 && strncmp((char*)&uip_buf[UIP_LLH_LEN], "?IPA", 4) == 0) {
|
||||
char buf[8];
|
||||
memcpy(&buf[0], "=IPA", 4);
|
||||
|
@ -298,7 +296,7 @@ PROCESS_THREAD(slip_process, ev, data)
|
|||
uip_len = 0;
|
||||
SLIP_STATISTICS(slip_ip_drop++);
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
if(uip_len > 0) {
|
||||
if(input_callback) {
|
||||
input_callback();
|
||||
|
@ -309,7 +307,7 @@ PROCESS_THREAD(slip_process, ev, data)
|
|||
tcpip_input();
|
||||
#endif
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
|
|
|
@ -151,8 +151,13 @@ mmem_free(struct mmem *m)
|
|||
void
|
||||
mmem_init(void)
|
||||
{
|
||||
static int inited = 0;
|
||||
if(inited) {
|
||||
return;
|
||||
}
|
||||
list_init(mmemlist);
|
||||
avail_memory = MMEM_SIZE;
|
||||
inited = 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ strcasecmp(const char *s1, const char *s2)
|
|||
#define DNS_TYPE_ANY 255
|
||||
#define DNS_TYPE_NSEC 47
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#define NATIVE_DNS_TYPE DNS_TYPE_AAAA /* IPv6 */
|
||||
#else
|
||||
#define NATIVE_DNS_TYPE DNS_TYPE_A /* IPv4 */
|
||||
|
@ -227,19 +227,16 @@ struct dns_hdr {
|
|||
uint16_t numextrarr;
|
||||
};
|
||||
|
||||
#define RESOLV_ENCODE_INDEX(i) (uip_htons(i+1))
|
||||
#define RESOLV_DECODE_INDEX(i) (unsigned char)(uip_ntohs(i-1))
|
||||
|
||||
/** These default values for the DNS server are Google's public DNS:
|
||||
* <https://developers.google.com/speed/public-dns/docs/using>
|
||||
*/
|
||||
static uip_ipaddr_t resolv_default_dns_server =
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
{ { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 } };
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
{ { 8, 8, 8, 8 } };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/** \internal The DNS answer message structure. */
|
||||
struct dns_answer {
|
||||
|
@ -249,7 +246,7 @@ struct dns_answer {
|
|||
uint16_t class;
|
||||
uint16_t ttl[2];
|
||||
uint16_t len;
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uint8_t ipaddr[16];
|
||||
#else
|
||||
uint8_t ipaddr[4];
|
||||
|
@ -264,6 +261,7 @@ struct namemap {
|
|||
#define STATE_DONE 4
|
||||
uint8_t state;
|
||||
uint8_t tmr;
|
||||
uint16_t id;
|
||||
uint8_t retries;
|
||||
uint8_t seqno;
|
||||
#if RESOLV_SUPPORTS_RECORD_EXPIRATION
|
||||
|
@ -315,13 +313,13 @@ enum {
|
|||
static uint8_t mdns_state;
|
||||
|
||||
static const uip_ipaddr_t resolv_mdns_addr =
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
{ { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb } };
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
{ { 224, 0, 0, 251 } };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
static int mdns_needs_host_announce;
|
||||
|
||||
PROCESS(mdns_probe_process, "mDNS probe");
|
||||
|
@ -506,9 +504,7 @@ start_name_collision_check(clock_time_t after)
|
|||
static unsigned char *
|
||||
mdns_write_announce_records(unsigned char *queryptr, uint8_t *count)
|
||||
{
|
||||
struct dns_answer *ans;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < UIP_DS6_ADDR_NB; ++i) {
|
||||
|
@ -524,7 +520,6 @@ mdns_write_announce_records(unsigned char *queryptr, uint8_t *count)
|
|||
*queryptr++ = 0xc0;
|
||||
*queryptr++ = sizeof(struct dns_hdr);
|
||||
}
|
||||
ans = (struct dns_answer *)queryptr;
|
||||
|
||||
*queryptr++ = (uint8_t) ((NATIVE_DNS_TYPE) >> 8);
|
||||
*queryptr++ = (uint8_t) ((NATIVE_DNS_TYPE));
|
||||
|
@ -545,7 +540,9 @@ mdns_write_announce_records(unsigned char *queryptr, uint8_t *count)
|
|||
++(*count);
|
||||
}
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
struct dns_answer *ans;
|
||||
|
||||
queryptr = encode_name(queryptr, resolv_hostname);
|
||||
ans = (struct dns_answer *)queryptr;
|
||||
ans->type = UIP_HTONS(NATIVE_DNS_TYPE);
|
||||
|
@ -556,7 +553,7 @@ mdns_write_announce_records(unsigned char *queryptr, uint8_t *count)
|
|||
uip_gethostaddr((uip_ipaddr_t *) ans->ipaddr);
|
||||
queryptr = (unsigned char *)ans + sizeof(*ans);
|
||||
++(*count);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
return queryptr;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -585,17 +582,17 @@ mdns_prep_host_announce_packet(void)
|
|||
0x00,
|
||||
0x04,
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
0x40,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -603,8 +600,6 @@ mdns_prep_host_announce_packet(void)
|
|||
|
||||
uint8_t total_answers = 0;
|
||||
|
||||
struct dns_answer *ans;
|
||||
|
||||
/* Be aware that, unless `ARCH_DOESNT_NEED_ALIGNED_STRUCTS` is set,
|
||||
* writing directly to the uint16_t members of this struct is an error. */
|
||||
struct dns_hdr *hdr = (struct dns_hdr *)uip_appdata;
|
||||
|
@ -703,7 +698,8 @@ check_entries(void)
|
|||
}
|
||||
hdr = (struct dns_hdr *)uip_appdata;
|
||||
memset(hdr, 0, sizeof(struct dns_hdr));
|
||||
hdr->id = RESOLV_ENCODE_INDEX(i);
|
||||
hdr->id = random_rand();
|
||||
namemapptr->id = hdr->id;
|
||||
#if RESOLV_CONF_SUPPORTS_MDNS
|
||||
if(!namemapptr->is_mdns || namemapptr->is_probe) {
|
||||
hdr->flags1 = DNS_FLAG1_RD;
|
||||
|
@ -903,10 +899,13 @@ newdata(void)
|
|||
} else
|
||||
#endif /* RESOLV_CONF_SUPPORTS_MDNS */
|
||||
{
|
||||
/* The ID in the DNS header should be our entry into the name table. */
|
||||
i = RESOLV_DECODE_INDEX(hdr->id);
|
||||
|
||||
namemapptr = &names[i];
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
namemapptr = &names[i];
|
||||
if(namemapptr->state == STATE_ASKING &&
|
||||
namemapptr->id == hdr->id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i >= RESOLV_ENTRIES || i < 0 || namemapptr->state != STATE_ASKING) {
|
||||
PRINTF("resolver: DNS response has bad ID (%04X) \n", uip_ntohs(hdr->id));
|
||||
|
@ -1141,7 +1140,7 @@ PROCESS_THREAD(resolv_process, ev, data)
|
|||
PRINTF("resolver: Supports MDNS.\n");
|
||||
uip_udp_bind(resolv_conn, UIP_HTONS(MDNS_PORT));
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uip_ds6_maddr_add(&resolv_mdns_addr);
|
||||
#else
|
||||
/* TODO: Is there anything we need to do here for IPv4 multicast? */
|
||||
|
@ -1200,6 +1199,16 @@ PROCESS_THREAD(resolv_process, ev, data)
|
|||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static uint8_t initialized = 0;
|
||||
if(!initialized) {
|
||||
process_start(&resolv_process, NULL);
|
||||
initialized = 1;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if RESOLV_AUTO_REMOVE_TRAILING_DOTS
|
||||
static const char *
|
||||
remove_trailing_dots(const char *name) {
|
||||
|
@ -1233,6 +1242,8 @@ resolv_query(const char *name)
|
|||
|
||||
register struct namemap *nameptr = 0;
|
||||
|
||||
init();
|
||||
|
||||
lseq = lseqi = 0;
|
||||
|
||||
/* Remove trailing dots, if present. */
|
||||
|
@ -1316,12 +1327,12 @@ resolv_lookup(const char *name, uip_ipaddr_t ** ipaddr)
|
|||
#if UIP_CONF_LOOPBACK_INTERFACE
|
||||
if(strcmp(name, "localhost")) {
|
||||
static uip_ipaddr_t loopback =
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } };
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
{ { 127, 0, 0, 1 } };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
if(ipaddr) {
|
||||
*ipaddr = &loopback;
|
||||
}
|
||||
|
@ -1369,7 +1380,8 @@ resolv_lookup(const char *name, uip_ipaddr_t ** ipaddr)
|
|||
|
||||
#if VERBOSE_DEBUG
|
||||
switch (ret) {
|
||||
case RESOLV_STATUS_CACHED:{
|
||||
case RESOLV_STATUS_CACHED:
|
||||
if(ipaddr) {
|
||||
PRINTF("resolver: Found \"%s\" in cache.\n", name);
|
||||
const uip_ipaddr_t *addr = *ipaddr;
|
||||
|
||||
|
@ -1428,7 +1440,7 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr)
|
|||
#if RESOLV_CONF_SUPPORTS_MDNS
|
||||
if(strncasecmp(resolv_hostname, name, strlen(resolv_hostname)) == 0 &&
|
||||
ipaddr
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
&& !uip_ds6_is_my_addr(ipaddr)
|
||||
#else
|
||||
&& uip_ipaddr_cmp(&uip_hostaddr, ipaddr) != 0
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* \defgroup simple-udp
|
||||
* \defgroup simple-udp A simple UDP API
|
||||
*
|
||||
* The default Contiki UDP API is difficult to use. The simple-udp
|
||||
* module provides a significantly simpler API.
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "net/ip/uip-split.h"
|
||||
#include "net/ip/uip-packetqueue.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#include "net/ipv6/uip-nd6.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#endif
|
||||
|
@ -80,7 +80,7 @@ process_event_t tcpip_icmp6_event;
|
|||
/* Periodic check of active connections. */
|
||||
static struct etimer periodic;
|
||||
|
||||
#if UIP_CONF_IPV6 && UIP_CONF_IPV6_REASSEMBLY
|
||||
#if NETSTACK_CONF_WITH_IPV6 && UIP_CONF_IPV6_REASSEMBLY
|
||||
/* Timer for reassembly. */
|
||||
extern struct etimer uip_reass_timer;
|
||||
#endif
|
||||
|
@ -107,7 +107,7 @@ enum {
|
|||
};
|
||||
|
||||
/* Called on IP packet output. */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
static uint8_t (* outputfunc)(const uip_lladdr_t *a);
|
||||
|
||||
|
@ -194,7 +194,7 @@ packet_input(void)
|
|||
#if UIP_CONF_TCP_SPLIT
|
||||
uip_split_output();
|
||||
#else /* UIP_CONF_TCP_SPLIT */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
PRINTF("tcpip packet_input forward output len %d\n", uip_len);
|
||||
|
@ -213,7 +213,7 @@ packet_input(void)
|
|||
#if UIP_CONF_TCP_SPLIT
|
||||
uip_split_output();
|
||||
#else /* UIP_CONF_TCP_SPLIT */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
PRINTF("tcpip packet_input output len %d\n", uip_len);
|
||||
|
@ -331,11 +331,11 @@ udp_broadcast_new(uint16_t port, void *appstate)
|
|||
uip_ipaddr_t addr;
|
||||
struct uip_udp_conn *conn;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uip_create_linklocal_allnodes_mcast(&addr);
|
||||
#else
|
||||
uip_ipaddr(&addr, 255,255,255,255);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
conn = udp_new(&addr, port, appstate);
|
||||
if(conn != NULL) {
|
||||
udp_bind(conn, port);
|
||||
|
@ -434,7 +434,7 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
connections. */
|
||||
etimer_restart(&periodic);
|
||||
uip_periodic(i);
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
if(uip_len > 0) {
|
||||
|
@ -442,7 +442,7 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
tcpip_output();
|
||||
PRINTF("tcpip_output after periodic len %d\n", uip_len);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
}
|
||||
#endif /* UIP_TCP */
|
||||
|
@ -451,7 +451,7 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
#endif /* UIP_CONF_IP_FORWARD */
|
||||
}
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#if UIP_CONF_IPV6_REASSEMBLY
|
||||
/*
|
||||
* check the timer for reassembly
|
||||
|
@ -483,7 +483,7 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
uip_ds6_periodic();
|
||||
tcpip_ipv6_output();
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -491,14 +491,14 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
case TCP_POLL:
|
||||
if(data != NULL) {
|
||||
uip_poll_conn(data);
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
if(uip_len > 0) {
|
||||
PRINTF("tcpip_output from tcp poll len %d\n", uip_len);
|
||||
tcpip_output();
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* Start the periodic polling, if it isn't already active. */
|
||||
start_periodic_tcp_timer();
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ eventhandler(process_event_t ev, process_data_t data)
|
|||
case UDP_POLL:
|
||||
if(data != NULL) {
|
||||
uip_udp_periodic_conn(data);
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
if(uip_len > 0) {
|
||||
|
@ -530,12 +530,12 @@ tcpip_input(void)
|
|||
{
|
||||
process_post_synch(&tcpip_process, PACKET_INPUT, NULL);
|
||||
uip_len = 0;
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uip_ext_len = 0;
|
||||
#endif /*UIP_CONF_IPV6*/
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
void
|
||||
tcpip_ipv6_output(void)
|
||||
{
|
||||
|
@ -616,7 +616,7 @@ tcpip_ipv6_output(void)
|
|||
|
||||
rpl_repair_root(instance->instance_id);
|
||||
}
|
||||
#endif /* UIP_CONF_RPL */
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
uip_ds6_route_rm(route);
|
||||
|
||||
/* We don't have a nexthop to send the packet to, so we drop
|
||||
|
@ -729,7 +729,7 @@ tcpip_ipv6_output(void)
|
|||
uip_len = 0;
|
||||
uip_ext_len = 0;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_UDP
|
||||
void
|
||||
|
@ -818,7 +818,7 @@ PROCESS_THREAD(tcpip_process, ev, data)
|
|||
UIP_FALLBACK_INTERFACE.init();
|
||||
#endif
|
||||
/* initialize RPL if configured for using RPL */
|
||||
#if UIP_CONF_IPV6 && UIP_CONF_IPV6_RPL
|
||||
#if NETSTACK_CONF_WITH_IPV6 && UIP_CONF_IPV6_RPL
|
||||
rpl_init();
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ CCIF void tcpip_input(void);
|
|||
* \brief Output packet to layer 2
|
||||
* The eventual parameter is the MAC address of the destination.
|
||||
*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uint8_t tcpip_output(const uip_lladdr_t *);
|
||||
void tcpip_set_outputfunc(uint8_t (* f)(const uip_lladdr_t *));
|
||||
#else
|
||||
|
@ -351,7 +351,7 @@ void tcpip_set_outputfunc(uint8_t (* f)(void));
|
|||
/**
|
||||
* \brief This function does address resolution and then calls tcpip_output
|
||||
*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
void tcpip_ipv6_output(void);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
|
|||
printf("(NULL IP addr)");
|
||||
return;
|
||||
}
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uint16_t a;
|
||||
unsigned int i;
|
||||
int f;
|
||||
|
@ -66,9 +66,9 @@ uip_debug_ipaddr_print(const uip_ipaddr_t *addr)
|
|||
PRINTA("%x", a);
|
||||
}
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
PRINTA("%u.%u.%u.%u", addr->u8[0], addr->u8[1], addr->u8[2], addr->u8[3]);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
|
|
@ -73,33 +73,33 @@ uip_split_output(void)
|
|||
/* Create the first packet. This is done by altering the length
|
||||
field of the IP header and updating the checksums. */
|
||||
uip_len = len1 + UIP_TCPIP_HLEN;
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||
length. */
|
||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
BUF->len[0] = uip_len >> 8;
|
||||
BUF->len[1] = uip_len & 0xff;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Recalculate the TCP checksum. */
|
||||
BUF->tcpchksum = 0;
|
||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
/* Recalculate the IP checksum. */
|
||||
BUF->ipchksum = 0;
|
||||
BUF->ipchksum = ~(uip_ipchksum());
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Transmit the first packet. */
|
||||
/* uip_fw_output();*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
tcpip_output();
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Now, create the second packet. To do this, it is not enough to
|
||||
just alter the length field, but we must also update the TCP
|
||||
|
@ -107,15 +107,15 @@ uip_split_output(void)
|
|||
memory. This place is detemined by the length of the first
|
||||
packet (len1). */
|
||||
uip_len = len2 + UIP_TCPIP_HLEN;
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||
length. */
|
||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
BUF->len[0] = uip_len >> 8;
|
||||
BUF->len[1] = uip_len & 0xff;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* uip_appdata += len1;*/
|
||||
memcpy(uip_appdata, (uint8_t *)uip_appdata + len1, len2);
|
||||
|
@ -130,29 +130,29 @@ uip_split_output(void)
|
|||
BUF->tcpchksum = 0;
|
||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
/* Recalculate the IP checksum. */
|
||||
BUF->ipchksum = 0;
|
||||
BUF->ipchksum = ~(uip_ipchksum());
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Transmit the second packet. */
|
||||
/* uip_fw_output();*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
tcpip_output();
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
return;
|
||||
}
|
||||
#endif /* UIP_TCP */
|
||||
|
||||
/* uip_fw_output();*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
tcpip_output();
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -66,7 +66,7 @@ uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
|
|||
}
|
||||
#endif /* UIP_IPV6_MULTICAST */
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
if(uip_len > 0) {
|
||||
|
|
|
@ -53,12 +53,12 @@
|
|||
#define UIP_H_
|
||||
|
||||
/* Header sizes. */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#define UIP_IPH_LEN 40
|
||||
#define UIP_FRAGH_LEN 8
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
#define UIP_IPH_LEN 20 /* Size of IP header */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#define UIP_UDPH_LEN 8 /* Size of UDP header */
|
||||
#define UIP_TCPH_LEN 20 /* Size of TCP header */
|
||||
|
@ -75,7 +75,7 @@
|
|||
+ IP header */
|
||||
#define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* size of L2
|
||||
+ IP header */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/**
|
||||
* The sums below are quite used in ND. When used for uip_buf, we
|
||||
* include link layer length when used for uip_len, we do not, hence
|
||||
|
@ -86,7 +86,7 @@
|
|||
#define uip_l2_l3_icmp_hdr_len (UIP_LLH_LEN + UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN)
|
||||
#define uip_l3_hdr_len (UIP_IPH_LEN + uip_ext_len)
|
||||
#define uip_l3_icmp_hdr_len (UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN)
|
||||
#endif /*UIP_CONF_IPV6*/
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
|
||||
|
||||
#include "net/ip/uipopt.h"
|
||||
|
@ -108,11 +108,11 @@ typedef union uip_ip6addr_t {
|
|||
uint16_t u16[8];
|
||||
} uip_ip6addr_t;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
typedef uip_ip6addr_t uip_ipaddr_t;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
typedef uip_ip4addr_t uip_ipaddr_t;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -1056,11 +1056,11 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport);
|
|||
(addr1)->u16[1] == (addr2)->u16[1])
|
||||
#define uip_ip6addr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#define uip_ipaddr_cmp(addr1, addr2) uip_ip6addr_cmp(addr1, addr2)
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
#define uip_ipaddr_cmp(addr1, addr2) uip_ip4addr_cmp(addr1, addr2)
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/**
|
||||
* Compare two IP addresses with netmasks
|
||||
|
@ -1494,13 +1494,13 @@ struct uip_stats {
|
|||
checksum. */
|
||||
} udp; /**< UDP statistics. */
|
||||
#endif /* UIP_UDP */
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
struct {
|
||||
uip_stats_t drop; /**< Number of dropped ND6 packets. */
|
||||
uip_stats_t recv; /**< Number of recived ND6 packets */
|
||||
uip_stats_t sent; /**< Number of sent ND6 packets */
|
||||
} nd6;
|
||||
#endif /*UIP_CONF_IPV6*/
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -1610,7 +1610,7 @@ void uip_process(uint8_t flag);
|
|||
|
||||
/* The TCP and IP headers. */
|
||||
struct uip_tcpip_hdr {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* IPv6 header. */
|
||||
uint8_t vtc,
|
||||
tcflow;
|
||||
|
@ -1618,7 +1618,7 @@ struct uip_tcpip_hdr {
|
|||
uint8_t len[2];
|
||||
uint8_t proto, ttl;
|
||||
uip_ip6addr_t srcipaddr, destipaddr;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* IPv4 header. */
|
||||
uint8_t vhl,
|
||||
tos,
|
||||
|
@ -1629,7 +1629,7 @@ struct uip_tcpip_hdr {
|
|||
proto;
|
||||
uint16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* TCP header. */
|
||||
uint16_t srcport,
|
||||
|
@ -1646,7 +1646,7 @@ struct uip_tcpip_hdr {
|
|||
|
||||
/* The ICMP and IP headers. */
|
||||
struct uip_icmpip_hdr {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* IPv6 header. */
|
||||
uint8_t vtc,
|
||||
tcf;
|
||||
|
@ -1654,7 +1654,7 @@ struct uip_icmpip_hdr {
|
|||
uint8_t len[2];
|
||||
uint8_t proto, ttl;
|
||||
uip_ip6addr_t srcipaddr, destipaddr;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* IPv4 header. */
|
||||
uint8_t vhl,
|
||||
tos,
|
||||
|
@ -1665,21 +1665,21 @@ struct uip_icmpip_hdr {
|
|||
proto;
|
||||
uint16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* ICMP header. */
|
||||
uint8_t type, icode;
|
||||
uint16_t icmpchksum;
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
uint16_t id, seqno;
|
||||
uint8_t payload[1];
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
#endif /* !NETSTACK_CONF_WITH_IPV6 */
|
||||
};
|
||||
|
||||
|
||||
/* The UDP and IP headers. */
|
||||
struct uip_udpip_hdr {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* IPv6 header. */
|
||||
uint8_t vtc,
|
||||
tcf;
|
||||
|
@ -1687,7 +1687,7 @@ struct uip_udpip_hdr {
|
|||
uint8_t len[2];
|
||||
uint8_t proto, ttl;
|
||||
uip_ip6addr_t srcipaddr, destipaddr;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* IP header. */
|
||||
uint8_t vhl,
|
||||
tos,
|
||||
|
@ -1698,7 +1698,7 @@ struct uip_udpip_hdr {
|
|||
proto;
|
||||
uint16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* UDP header. */
|
||||
uint16_t srcport,
|
||||
|
@ -1714,7 +1714,7 @@ struct uip_udpip_hdr {
|
|||
*/
|
||||
/* The IP header */
|
||||
struct uip_ip_hdr {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* IPV6 header */
|
||||
uint8_t vtc;
|
||||
uint8_t tcflow;
|
||||
|
@ -1722,7 +1722,7 @@ struct uip_ip_hdr {
|
|||
uint8_t len[2];
|
||||
uint8_t proto, ttl;
|
||||
uip_ip6addr_t srcipaddr, destipaddr;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* IPV4 header */
|
||||
uint8_t vhl,
|
||||
tos,
|
||||
|
@ -1733,7 +1733,7 @@ struct uip_ip_hdr {
|
|||
proto;
|
||||
uint16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -1842,9 +1842,9 @@ struct uip_tcp_hdr {
|
|||
struct uip_icmp_hdr {
|
||||
uint8_t type, icode;
|
||||
uint16_t icmpchksum;
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
uint16_t id, seqno;
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
#endif /* !NETSTACK_CONF_WITH_IPV6 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -1880,7 +1880,7 @@ struct uip_udp_hdr {
|
|||
#define UIP_PROTO_ICMP6 58
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/** @{ */
|
||||
/** \brief extension headers types */
|
||||
#define UIP_PROTO_HBHO 0
|
||||
|
@ -1917,7 +1917,7 @@ struct uip_udp_hdr {
|
|||
/** @} */
|
||||
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
|
||||
#if UIP_FIXEDADDR
|
||||
|
@ -1937,7 +1937,7 @@ CCIF extern uip_lladdr_t uip_lladdr;
|
|||
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/** Length of the link local prefix */
|
||||
#define UIP_LLPREF_LEN 10
|
||||
|
||||
|
@ -2162,7 +2162,7 @@ CCIF extern uip_lladdr_t uip_lladdr;
|
|||
(((a)->u8[14]) == ((b)->u8[14])) && \
|
||||
(((a)->u8[15]) == ((b)->u8[15])))
|
||||
|
||||
#endif /*UIP_CONF_IPV6*/
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
|
||||
/**
|
||||
* Calculate the Internet checksum over a buffer.
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "net/ip/uip-debug.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
int
|
||||
uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *ipaddr)
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *ipaddr)
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Parse a IPv4-address from a string. Returns the number of characters read
|
||||
* for the address. */
|
||||
|
|
|
@ -67,11 +67,11 @@
|
|||
* \retval 0 If the IP address could not be parsed.
|
||||
* \retval Non-zero If the IP address was parsed.
|
||||
*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#define uiplib_ipaddrconv uiplib_ip6addrconv
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
#define uiplib_ipaddrconv uiplib_ip4addrconv
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
CCIF int uiplib_ip4addrconv(const char *addrstr, uip_ip4addr_t *addr);
|
||||
CCIF int uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *addr);
|
||||
|
|
|
@ -282,9 +282,9 @@ void uip_log(char *msg);
|
|||
/** The maximum transmission unit at the IP Layer*/
|
||||
#define UIP_LINK_MTU 1280
|
||||
|
||||
#ifndef UIP_CONF_IPV6
|
||||
#ifndef NETSTACK_CONF_WITH_IPV6
|
||||
/** Do we use IPv6 or not (default: no) */
|
||||
#define UIP_CONF_IPV6 0
|
||||
#define NETSTACK_CONF_WITH_IPV6 0
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_IPV6_QUEUE_PKT
|
||||
|
@ -351,7 +351,7 @@ void uip_log(char *msg);
|
|||
#ifdef UIP_CONF_UDP_CHECKSUMS
|
||||
#define UIP_UDP_CHECKSUMS (UIP_CONF_UDP_CHECKSUMS)
|
||||
#else
|
||||
#define UIP_UDP_CHECKSUMS (UIP_CONF_IPV6)
|
||||
#define UIP_UDP_CHECKSUMS (NETSTACK_CONF_WITH_IPV6)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "ip64-conf.h"
|
||||
|
||||
#include "lib/random.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef IP64_ADDRMAP_CONF_ENTRIES
|
||||
|
@ -173,10 +175,8 @@ ip64_addrmap_lookup_port(uint16_t mapped_port, uint8_t protocol)
|
|||
static void
|
||||
increase_mapped_port(void)
|
||||
{
|
||||
mapped_port++;
|
||||
if(mapped_port >= LAST_MAPPED_PORT) {
|
||||
mapped_port = FIRST_MAPPED_PORT;
|
||||
}
|
||||
mapped_port = (random_rand() % (LAST_MAPPED_PORT - FIRST_MAPPED_PORT)) +
|
||||
FIRST_MAPPED_PORT;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct ip64_addrmap_entry *
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "net/ipv4/uip-fw.h"
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
PROCESS(uip_fw_process, "IP forwarding");
|
||||
|
||||
|
@ -51,4 +51,4 @@ PROCESS_THREAD(uip_fw_process, ev, data)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
|
|
@ -75,15 +75,15 @@
|
|||
#include "net/ipv4/uip_arp.h"
|
||||
#include "net/ip/uip_arch.h"
|
||||
|
||||
#if !UIP_CONF_IPV6 /* If UIP_CONF_IPV6 is defined, we compile the
|
||||
#if !NETSTACK_CONF_WITH_IPV6 /* If NETSTACK_CONF_WITH_IPV6 is defined, we compile the
|
||||
uip6.c file instead of this one. Therefore
|
||||
this #ifndef removes the entire compilation
|
||||
output of the uip.c file */
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
#include "net/ipv4/uip-neighbor.h"
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -106,12 +106,12 @@ uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;
|
|||
#endif /* UIP_FIXEDADDR */
|
||||
|
||||
const uip_ipaddr_t uip_broadcast_addr =
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
{ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
{ { 0xff, 0xff, 0xff, 0xff } };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
const uip_ipaddr_t uip_all_zeroes_addr = { { 0x0, /* rest is 0 */ } };
|
||||
|
||||
#if UIP_FIXEDETHADDR
|
||||
|
@ -322,11 +322,11 @@ upper_layer_chksum(uint8_t proto)
|
|||
uint16_t upper_layer_len;
|
||||
uint16_t sum;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* First sum pseudoheader. */
|
||||
|
||||
|
@ -342,14 +342,14 @@ upper_layer_chksum(uint8_t proto)
|
|||
return (sum == 0) ? 0xffff : uip_htons(sum);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uint16_t
|
||||
uip_icmp6chksum(void)
|
||||
{
|
||||
return upper_layer_chksum(UIP_PROTO_ICMP6);
|
||||
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uint16_t
|
||||
uip_tcpchksum(void)
|
||||
|
@ -529,7 +529,7 @@ uip_listen(uint16_t port)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* XXX: IP fragment reassembly: not well-tested. */
|
||||
|
||||
#if UIP_REASSEMBLY && !UIP_CONF_IPV6
|
||||
#if UIP_REASSEMBLY && !NETSTACK_CONF_WITH_IPV6
|
||||
#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN)
|
||||
static uint8_t uip_reassbuf[UIP_REASS_BUFSIZE];
|
||||
static uint8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
|
||||
|
@ -828,7 +828,7 @@ uip_process(uint8_t flag)
|
|||
|
||||
/* Start of IP input header processing code. */
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* Check validity of the IP header. */
|
||||
if((BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
|
@ -836,7 +836,7 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("ipv6: invalid version.");
|
||||
goto drop;
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* Check validity of the IP header. */
|
||||
if(BUF->vhl != 0x45) { /* IP version and header length. */
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
|
@ -844,7 +844,7 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("ip: invalid version or header length.");
|
||||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* Check the size of the packet. If the size reported to us in
|
||||
uip_len is smaller the size reported in the IP header, we assume
|
||||
|
@ -855,7 +855,7 @@ uip_process(uint8_t flag)
|
|||
|
||||
if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
|
||||
uip_len = (BUF->len[0] << 8) + BUF->len[1];
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uip_len += 40; /* The length reported in the IPv6 header is the
|
||||
length of the payload that follows the
|
||||
header. However, uIP uses the uip_len variable
|
||||
|
@ -865,13 +865,13 @@ uip_process(uint8_t flag)
|
|||
contains the length of the entire packet. But
|
||||
for IPv6 we need to add the size of the IPv6
|
||||
header (40 bytes). */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
} else {
|
||||
UIP_LOG("ip: packet shorter than reported in IP header.");
|
||||
goto drop;
|
||||
}
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
/* Check the fragment flag. */
|
||||
if((BUF->ipoffset[0] & 0x3f) != 0 ||
|
||||
BUF->ipoffset[1] != 0) {
|
||||
|
@ -887,13 +887,13 @@ uip_process(uint8_t flag)
|
|||
goto drop;
|
||||
#endif /* UIP_REASSEMBLY */
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
if(uip_ipaddr_cmp(&uip_hostaddr, &uip_all_zeroes_addr)) {
|
||||
/* If we are configured to use ping IP address configuration and
|
||||
hasn't been assigned an IP address yet, we accept all ICMP
|
||||
packets. */
|
||||
#if UIP_PINGADDRCONF && !UIP_CONF_IPV6
|
||||
#if UIP_PINGADDRCONF && !NETSTACK_CONF_WITH_IPV6
|
||||
if(BUF->proto == UIP_PROTO_ICMP) {
|
||||
UIP_LOG("ip: possible ping config packet received.");
|
||||
goto icmp_input;
|
||||
|
@ -924,12 +924,12 @@ uip_process(uint8_t flag)
|
|||
#endif /* UIP_BROADCAST */
|
||||
|
||||
/* Check if the packet is destined for our IP address. */
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
if(!uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr)) {
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
goto drop;
|
||||
}
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
/* For IPv6, packet reception is a little trickier as we need to
|
||||
make sure that we listen to certain multicast addresses (all
|
||||
hosts multicast address, and the solicited-node multicast
|
||||
|
@ -940,10 +940,10 @@ uip_process(uint8_t flag)
|
|||
UIP_STAT(++uip_stat.ip.drop);
|
||||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
if(uip_ipchksum() != 0xffff) { /* Compute and check the IP header
|
||||
checksum. */
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
|
@ -951,7 +951,7 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("ip: bad checksum.");
|
||||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#if UIP_TCP
|
||||
if(BUF->proto == UIP_PROTO_TCP) { /* Check for TCP packet. If so,
|
||||
|
@ -967,7 +967,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
#if !UIP_CONF_IPV6
|
||||
#if !NETSTACK_CONF_WITH_IPV6
|
||||
/* ICMPv4 processing code follows. */
|
||||
if(BUF->proto != UIP_PROTO_ICMP) { /* We only allow ICMP packets from
|
||||
here. */
|
||||
|
@ -1018,7 +1018,7 @@ uip_process(uint8_t flag)
|
|||
goto ip_send_nolen;
|
||||
|
||||
/* End of IPv4 input header processing code. */
|
||||
#else /* !UIP_CONF_IPV6 */
|
||||
#else /* !NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/* This is IPv6 ICMPv6 processing code. */
|
||||
DEBUG_PRINTF("icmp6_input: length %d\n", uip_len);
|
||||
|
@ -1086,7 +1086,7 @@ uip_process(uint8_t flag)
|
|||
|
||||
/* End of IPv6 ICMP processing. */
|
||||
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
#endif /* !NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
#if UIP_UDP
|
||||
/* UDP input processing. */
|
||||
|
@ -1137,7 +1137,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
UIP_LOG("udp: no matching connection found");
|
||||
UIP_STAT(++uip_stat.udp.drop);
|
||||
#if UIP_CONF_ICMP_DEST_UNREACH && !UIP_CONF_IPV6
|
||||
#if UIP_CONF_ICMP_DEST_UNREACH && !NETSTACK_CONF_WITH_IPV6
|
||||
/* Copy fields from packet header into payload of this ICMP packet. */
|
||||
memcpy(&(ICMPBUF->payload[0]), ICMPBUF, UIP_IPH_LEN + 8);
|
||||
|
||||
|
@ -1183,15 +1183,15 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
uip_len = uip_slen + UIP_IPUDPH_LEN;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||
length. */
|
||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
BUF->len[0] = (uip_len >> 8);
|
||||
BUF->len[1] = (uip_len & 0xff);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
BUF->ttl = uip_udp_conn->ttl;
|
||||
BUF->proto = UIP_PROTO_UDP;
|
||||
|
@ -1894,15 +1894,15 @@ uip_process(uint8_t flag)
|
|||
|
||||
tcp_send_noconn:
|
||||
BUF->ttl = UIP_TTL;
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/* For IPv6, the IP length field does not include the IPv6 IP header
|
||||
length. */
|
||||
BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
|
||||
BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
BUF->len[0] = (uip_len >> 8);
|
||||
BUF->len[1] = (uip_len & 0xff);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
BUF->urgp[0] = BUF->urgp[1] = 0;
|
||||
|
||||
|
@ -1912,11 +1912,11 @@ uip_process(uint8_t flag)
|
|||
#endif
|
||||
|
||||
ip_send_nolen:
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
BUF->vtc = 0x60;
|
||||
BUF->tcflow = 0x00;
|
||||
BUF->flow = 0x00;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
BUF->vhl = 0x45;
|
||||
BUF->tos = 0;
|
||||
BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
|
||||
|
@ -1927,11 +1927,11 @@ uip_process(uint8_t flag)
|
|||
BUF->ipchksum = 0;
|
||||
BUF->ipchksum = ~(uip_ipchksum());
|
||||
DEBUG_PRINTF("uip ip_send_nolen: chkecum 0x%04x\n", uip_ipchksum());
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
UIP_STAT(++uip_stat.tcp.sent);
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
send:
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
DEBUG_PRINTF("Sending packet with length %d (%d)\n", uip_len,
|
||||
(BUF->len[0] << 8) | BUF->len[1]);
|
||||
|
||||
|
@ -1973,6 +1973,6 @@ uip_send(const void *data, int len)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
#define VERBOSE_PRINT_SEED(...)
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Data Representation */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -1448,5 +1447,3 @@ const struct uip_mcast6_driver roll_tm_driver = {
|
|||
in,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Macros */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -207,5 +206,3 @@ const struct uip_mcast6_driver smrf_driver = {
|
|||
in,
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Size of the multicast routing table */
|
||||
#ifdef UIP_MCAST6_ROUTE_CONF_ROUTES
|
||||
|
@ -129,5 +128,3 @@ uip_mcast6_route_init()
|
|||
list_init(mcast_route_list);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -69,8 +69,6 @@
|
|||
#include "net/ipv6/sicslowpan.h"
|
||||
#include "net/netstack.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
|
@ -1929,4 +1927,3 @@ const struct network_driver sicslowpan_driver = {
|
|||
};
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -201,12 +201,25 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
|
|||
LINK_NEIGHBOR_CALLBACK(dest, status, numtx);
|
||||
|
||||
#if UIP_DS6_LL_NUD
|
||||
/* From RFC4861, page 72, last paragraph of section 7.3.3:
|
||||
*
|
||||
* "In some cases, link-specific information may indicate that a path to
|
||||
* a neighbor has failed (e.g., the resetting of a virtual circuit). In
|
||||
* such cases, link-specific information may be used to purge Neighbor
|
||||
* Cache entries before the Neighbor Unreachability Detection would do
|
||||
* so. However, link-specific information MUST NOT be used to confirm
|
||||
* the reachability of a neighbor; such information does not provide
|
||||
* end-to-end confirmation between neighboring IP layers."
|
||||
*
|
||||
* However, we assume that receiving a link layer ack ensures the delivery
|
||||
* of the transmitted packed to the IP stack of the neighbour. This is a
|
||||
* fair assumption and allows battery powered nodes save some battery by
|
||||
* not re-testing the state of a neighbour periodically if it
|
||||
* acknowledges link packets. */
|
||||
if(status == MAC_TX_OK) {
|
||||
uip_ds6_nbr_t *nbr;
|
||||
nbr = uip_ds6_nbr_ll_lookup((uip_lladdr_t *)dest);
|
||||
if(nbr != NULL &&
|
||||
(nbr->state == NBR_STALE || nbr->state == NBR_DELAY ||
|
||||
nbr->state == NBR_PROBE)) {
|
||||
if(nbr != NULL && nbr->state != NBR_INCOMPLETE) {
|
||||
nbr->state = NBR_REACHABLE;
|
||||
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
|
||||
PRINTF("uip-ds6-neighbor : received a link layer ACK : ");
|
||||
|
@ -227,10 +240,32 @@ uip_ds6_neighbor_periodic(void)
|
|||
switch(nbr->state) {
|
||||
case NBR_REACHABLE:
|
||||
if(stimer_expired(&nbr->reachable)) {
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
/* when a neighbor leave it's REACHABLE state and is a default router,
|
||||
instead of going to STALE state it enters DELAY state in order to
|
||||
force a NUD on it. Otherwise, if there is no upward traffic, the
|
||||
node never knows if the default router is still reachable. This
|
||||
mimics the 6LoWPAN-ND behavior.
|
||||
*/
|
||||
if(uip_ds6_defrt_lookup(&nbr->ipaddr) != NULL) {
|
||||
PRINTF("REACHABLE: defrt moving to DELAY (");
|
||||
PRINT6ADDR(&nbr->ipaddr);
|
||||
PRINTF(")\n");
|
||||
nbr->state = NBR_DELAY;
|
||||
stimer_set(&nbr->reachable, UIP_ND6_DELAY_FIRST_PROBE_TIME);
|
||||
nbr->nscount = 0;
|
||||
} else {
|
||||
PRINTF("REACHABLE: moving to STALE (");
|
||||
PRINT6ADDR(&nbr->ipaddr);
|
||||
PRINTF(")\n");
|
||||
nbr->state = NBR_STALE;
|
||||
}
|
||||
#else /* UIP_CONF_IPV6_RPL */
|
||||
PRINTF("REACHABLE: moving to STALE (");
|
||||
PRINT6ADDR(&nbr->ipaddr);
|
||||
PRINTF(")\n");
|
||||
nbr->state = NBR_STALE;
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
}
|
||||
break;
|
||||
#if UIP_ND6_SEND_NA
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include "lib/memb.h"
|
||||
#include "net/nbr-table.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* The nbr_routes holds a neighbor table to be able to maintain
|
||||
|
@ -216,6 +214,10 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
|||
uip_ipaddr_prefixcmp(addr, &r->ipaddr, r->length)) {
|
||||
longestmatch = r->length;
|
||||
found_route = r;
|
||||
/* check if total match - e.g. all 128 bits do match */
|
||||
if(longestmatch == 128) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,13 +231,14 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
|||
PRINTF("uip-ds6-route: No route found\n");
|
||||
}
|
||||
|
||||
if(found_route != NULL) {
|
||||
/* If we found a route, we put it at the end of the routeslist
|
||||
if(found_route != NULL && found_route != list_head(routelist)) {
|
||||
/* If we found a route, we put it at the start of the routeslist
|
||||
list. The list is ordered by how recently we looked them up:
|
||||
the least recently used route will be at the start of the
|
||||
list. */
|
||||
the least recently used route will be at the end of the
|
||||
list - for fast lookups (assuming multiple packets to the same node). */
|
||||
|
||||
list_remove(routelist, found_route);
|
||||
list_add(routelist, found_route);
|
||||
list_push(routelist, found_route);
|
||||
}
|
||||
|
||||
return found_route;
|
||||
|
@ -282,7 +285,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
|||
least recently used route is the first route on the list. */
|
||||
uip_ds6_route_t *oldest;
|
||||
|
||||
oldest = uip_ds6_route_head();
|
||||
oldest = list_tail(routelist); /* uip_ds6_route_head(); */
|
||||
PRINTF("uip_ds6_route_add: dropping route to ");
|
||||
PRINT6ADDR(&oldest->ipaddr);
|
||||
PRINTF("\n");
|
||||
|
@ -328,7 +331,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
list_add(routelist, r);
|
||||
/* add new routes first - assuming that there is a reason to add this
|
||||
and that there is a packet coming soon. */
|
||||
list_push(routelist, r);
|
||||
|
||||
nbrr = memb_alloc(&neighborroutememb);
|
||||
if(nbrr == NULL) {
|
||||
|
@ -386,7 +391,7 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
|||
PRINT6ADDR(&route->ipaddr);
|
||||
PRINTF("\n");
|
||||
|
||||
/* Remove the neighbor from the route list */
|
||||
/* Remove the route from the route list */
|
||||
list_remove(routelist, route);
|
||||
|
||||
/* Find the corresponding neighbor_route and remove it. */
|
||||
|
@ -624,5 +629,3 @@ uip_ds6_defrt_periodic(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -50,8 +50,6 @@
|
|||
#include "net/ipv6/uip-ds6.h"
|
||||
#include "net/ip/uip-packetqueue.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
|
@ -188,12 +186,12 @@ uip_ds6_periodic(void)
|
|||
|
||||
uip_ds6_neighbor_periodic();
|
||||
|
||||
#if UIP_CONF_ROUTER & UIP_ND6_SEND_RA
|
||||
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA
|
||||
/* Periodic RA sending */
|
||||
if(stimer_expired(&uip_ds6_timer_ra) && (uip_len == 0)) {
|
||||
uip_ds6_send_ra_periodic();
|
||||
}
|
||||
#endif /* UIP_CONF_ROUTER & UIP_ND6_SEND_RA */
|
||||
#endif /* UIP_CONF_ROUTER && UIP_ND6_SEND_RA */
|
||||
etimer_reset(&uip_ds6_timer_periodic);
|
||||
return;
|
||||
}
|
||||
|
@ -704,6 +702,5 @@ uip_ds6_compute_reachable_time(void)
|
|||
UIP_ND6_MIN_RANDOM_FACTOR(uip_ds6_if.base_reachable_time));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -68,8 +68,6 @@
|
|||
#include "rpl/rpl.h"
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
/** \brief temporary IP address */
|
||||
static uip_ipaddr_t tmp_ipaddr;
|
||||
|
||||
|
@ -421,4 +419,3 @@ uip_icmp6_init()
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -112,7 +112,7 @@ typedef struct uip_icmp6_error{
|
|||
* \brief Send an icmpv6 error message
|
||||
* \param type type of the error message
|
||||
* \param code of the error message
|
||||
* \param type 32 bit parameter of the error message, semantic depends on error
|
||||
* \param param 32 bit parameter of the error message, semantic depends on error
|
||||
*/
|
||||
void
|
||||
uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param);
|
||||
|
|
|
@ -74,7 +74,6 @@
|
|||
#include "net/ipv6/uip-ds6.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*------------------------------------------------------------------*/
|
||||
#define DEBUG 0
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
@ -1036,4 +1035,3 @@ uip_nd6_init()
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* For Debug, logging, statistics */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -1207,7 +1206,11 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
rpl_update_header_empty();
|
||||
if(rpl_update_header_empty()) {
|
||||
/* Packet can not be forwarded */
|
||||
PRINTF("RPL Forward Option Error\n");
|
||||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1;
|
||||
|
@ -2333,4 +2336,3 @@ uip_send(const void *data, int len)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
|
|
@ -87,7 +87,7 @@ anti_replay_was_replayed(struct anti_replay_info *info)
|
|||
|
||||
received_counter = anti_replay_get_counter();
|
||||
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
/* broadcast */
|
||||
if(received_counter <= info->last_broadcast_counter) {
|
||||
return 1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Fraunhofer Heinrich-Hertz-Institut.
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,6 +26,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -78,6 +80,12 @@ struct hdr {
|
|||
uint8_t len;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
hdr_length(void)
|
||||
{
|
||||
return DECORATED_FRAMER.length() + sizeof(struct hdr);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
create(void)
|
||||
|
@ -172,6 +180,7 @@ parse(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct framer contikimac_framer = {
|
||||
hdr_length,
|
||||
create,
|
||||
create_and_secure,
|
||||
parse
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Fraunhofer Heinrich-Hertz-Institut.
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,6 +26,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -522,7 +522,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
|
|||
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
#endif
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
is_broadcast = 1;
|
||||
PRINTDEBUG("contikimac: send broadcast\n");
|
||||
|
||||
|
@ -530,7 +530,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
|
|||
return MAC_TX_COLLISION;
|
||||
}
|
||||
} else {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
PRINTDEBUG("contikimac: send unicast to %02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1],
|
||||
|
@ -540,11 +540,11 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
|
|||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[5],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[6],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[7]);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||
PRINTDEBUG("contikimac: send unicast to %u.%u\n",
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1]);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
is_reliable = packetbuf_attr(PACKETBUF_ATTR_RELIABLE) ||
|
||||
packetbuf_attr(PACKETBUF_ATTR_ERELIABLE);
|
||||
|
@ -878,8 +878,7 @@ input_packet(void)
|
|||
packetbuf_totlen() > 0 &&
|
||||
(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
&linkaddr_node_addr) ||
|
||||
linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
&linkaddr_null))) {
|
||||
packetbuf_holds_broadcast())) {
|
||||
/* This is a regular packet that is destined to us or to the
|
||||
broadcast address. */
|
||||
|
||||
|
|
|
@ -433,11 +433,11 @@ send_packet(void)
|
|||
/* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
#endif
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
is_broadcast = 1;
|
||||
PRINTDEBUG("cxmac: send broadcast\n");
|
||||
} else {
|
||||
#if UIP_CONF_IPV6
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
PRINTDEBUG("cxmac: send unicast to %02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1],
|
||||
|
@ -451,7 +451,7 @@ send_packet(void)
|
|||
PRINTDEBUG("cxmac: send unicast to %u.%u\n",
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1]);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||
}
|
||||
/* is_reliable = packetbuf_attr(PACKETBUF_ATTR_RELIABLE) ||
|
||||
packetbuf_attr(PACKETBUF_ATTR_ERELIABLE);*/
|
||||
|
|
|
@ -104,7 +104,7 @@ create_frame(int type, int do_create)
|
|||
/* Build the FCF. */
|
||||
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
||||
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
params.fcf.ack_required = 0;
|
||||
} else {
|
||||
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
|
||||
|
@ -159,11 +159,7 @@ create_frame(int type, int do_create)
|
|||
}
|
||||
params.dest_pid = mac_dst_pan_id;
|
||||
|
||||
/*
|
||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
||||
* on the 802.15.4 network.
|
||||
*/
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
/* Broadcast requires short address mode. */
|
||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
params.dest_addr[0] = 0xFF;
|
||||
|
|
|
@ -132,8 +132,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
|
|||
|
||||
NETSTACK_RADIO.prepare(packetbuf_hdrptr(), packetbuf_totlen());
|
||||
|
||||
is_broadcast = linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
&linkaddr_null);
|
||||
is_broadcast = packetbuf_holds_broadcast();
|
||||
|
||||
if(NETSTACK_RADIO.receiving_packet() ||
|
||||
(!is_broadcast && NETSTACK_RADIO.pending_packet())) {
|
||||
|
@ -282,8 +281,7 @@ packet_input(void)
|
|||
#if NULLRDC_ADDRESS_FILTER
|
||||
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
&linkaddr_node_addr) &&
|
||||
!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||
&linkaddr_null)) {
|
||||
!packetbuf_holds_broadcast()) {
|
||||
PRINTF("nullrdc: not for us\n");
|
||||
#endif /* NULLRDC_ADDRESS_FILTER */
|
||||
} else {
|
||||
|
|
|
@ -123,11 +123,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
|
||||
params.dest_pid = mac_dst_pan_id;
|
||||
|
||||
/*
|
||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
||||
* on the 802.15.4 network.
|
||||
*/
|
||||
if(linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &linkaddr_null)) {
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
/* Broadcast requires short address mode. */
|
||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
params.dest_addr[0] = 0xFF;
|
||||
|
|
|
@ -320,4 +320,11 @@ packetbuf_addr(uint8_t type)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
||||
int
|
||||
packetbuf_holds_broadcast(void)
|
||||
{
|
||||
return linkaddr_cmp(&packetbuf_addrs[PACKETBUF_ADDR_RECEIVER - PACKETBUF_ADDR_FIRST].addr, &linkaddr_null);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -453,6 +453,12 @@ int packetbuf_set_addr(uint8_t type, const linkaddr_t *addr);
|
|||
const linkaddr_t *packetbuf_addr(uint8_t type);
|
||||
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
|
||||
|
||||
/**
|
||||
* \brief Checks whether the current packet is a broadcast.
|
||||
* \retval 0 iff current packet is not a broadcast
|
||||
*/
|
||||
int packetbuf_holds_broadcast(void);
|
||||
|
||||
void packetbuf_attr_clear(void);
|
||||
|
||||
void packetbuf_attr_copyto(struct packetbuf_attr *attrs,
|
||||
|
|
|
@ -48,8 +48,7 @@
|
|||
#include "net/rime/collect.h"
|
||||
#include "net/rime/collect-neighbor.h"
|
||||
#include "net/rime/collect-link-estimate.h"
|
||||
|
||||
#include "net/packetqueue.h"
|
||||
#include "net/rime/packetqueue.h"
|
||||
|
||||
#include "dev/radio-sensor.h"
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#include "net/rime/runicast.h"
|
||||
#include "net/rime/neighbor-discovery.h"
|
||||
#include "net/rime/collect-neighbor.h"
|
||||
#include "net/packetqueue.h"
|
||||
#include "net/rime/packetqueue.h"
|
||||
#include "sys/ctimer.h"
|
||||
#include "lib/list.h"
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
|
||||
#include "sys/ctimer.h"
|
||||
#include "net/packetqueue.h"
|
||||
#include "net/rime/packetqueue.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
|
@ -59,7 +59,6 @@
|
|||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern rpl_of_t RPL_OF;
|
||||
static rpl_of_t * const objective_functions[] = {&RPL_OF};
|
||||
|
@ -93,6 +92,13 @@ rpl_dag_init(void)
|
|||
nbr_table_register(rpl_parents, (nbr_table_callback *)nbr_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rpl_parent_t *
|
||||
rpl_get_parent(uip_lladdr_t *addr)
|
||||
{
|
||||
rpl_parent_t *p = nbr_table_get_from_lladdr(rpl_parents, (linkaddr_t *)addr);
|
||||
return p;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
rpl_rank_t
|
||||
rpl_get_parent_rank(uip_lladdr_t *addr)
|
||||
{
|
||||
|
@ -513,6 +519,7 @@ rpl_free_instance(rpl_instance_t *instance)
|
|||
|
||||
ctimer_stop(&instance->dio_timer);
|
||||
ctimer_stop(&instance->dao_timer);
|
||||
ctimer_stop(&instance->dao_lifetime_timer);
|
||||
|
||||
if(default_instance == instance) {
|
||||
default_instance = NULL;
|
||||
|
@ -1311,5 +1318,4 @@ rpl_lock_parent(rpl_parent_t *p)
|
|||
nbr_table_lock(rpl_parents, p);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
/** @} */
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "net/ip/tcpip.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
#include "net/rpl/rpl-private.h"
|
||||
#include "net/packetbuf.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
@ -64,7 +65,6 @@
|
|||
#define UIP_EXT_HDR_OPT_PADN_BUF ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
|
||||
#define UIP_EXT_HDR_OPT_RPL_BUF ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset])
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_CONF_IPV6
|
||||
int
|
||||
rpl_verify_header(int uip_ext_opt_offset)
|
||||
{
|
||||
|
@ -105,19 +105,12 @@ rpl_verify_header(int uip_ext_opt_offset)
|
|||
route = uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr);
|
||||
if(route != NULL) {
|
||||
uip_ds6_route_rm(route);
|
||||
|
||||
/* If we are the root and just needed to remove a DAO route,
|
||||
chances are that the network needs to be repaired. The
|
||||
rpl_repair_root() function will cause a global repair if we
|
||||
happen to be the root node of the dag. */
|
||||
PRINTF("RPL: initiate global repair\n");
|
||||
rpl_repair_root(instance->instance_id);
|
||||
}
|
||||
|
||||
/* Remove the forwarding error flag and return 0 to let the packet
|
||||
be forwarded again. */
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->flags &= ~RPL_HDR_OPT_FWD_ERR;
|
||||
return 0;
|
||||
RPL_STAT(rpl_stats.forward_errors++);
|
||||
/* Trigger DAO retransmission */
|
||||
rpl_reset_dio_timer(instance);
|
||||
/* drop the packet as it is not routable */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!instance->current_dag->joined) {
|
||||
|
@ -145,10 +138,9 @@ rpl_verify_header(int uip_ext_opt_offset)
|
|||
sender_closer);
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_RANK_ERR) {
|
||||
PRINTF("RPL: Rank error signalled in RPL option!\n");
|
||||
/* We should try to repair it, not implemented for the moment */
|
||||
/* Packet must be dropped and dio trickle timer reset, see RFC6550 - 11.2.2.2 */
|
||||
rpl_reset_dio_timer(instance);
|
||||
/* Forward the packet anyway. */
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
PRINTF("RPL: Single error tolerated\n");
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_RANK_ERR;
|
||||
|
@ -183,12 +175,13 @@ set_rpl_opt(unsigned uip_ext_opt_offset)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
int
|
||||
rpl_update_header_empty(void)
|
||||
{
|
||||
rpl_instance_t *instance;
|
||||
int uip_ext_opt_offset;
|
||||
int last_uip_ext_len;
|
||||
rpl_parent_t *parent;
|
||||
|
||||
last_uip_ext_len = uip_ext_len;
|
||||
uip_ext_len = 0;
|
||||
|
@ -211,12 +204,12 @@ rpl_update_header_empty(void)
|
|||
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
|
||||
PRINTF("RPL: RPL Hop-by-hop option has wrong length\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF->instance);
|
||||
if(instance == NULL || !instance->used || !instance->current_dag->joined) {
|
||||
PRINTF("RPL: Unable to add hop-by-hop extension header: incorrect instance\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -224,11 +217,11 @@ rpl_update_header_empty(void)
|
|||
if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE) {
|
||||
PRINTF("RPL: Packet too long: impossible to add hop-by-hop option\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
set_rpl_opt(uip_ext_opt_offset);
|
||||
uip_ext_len = last_uip_ext_len + RPL_HOP_BY_HOP_LEN;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch(UIP_EXT_HDR_OPT_BUF->type) {
|
||||
|
@ -244,6 +237,15 @@ rpl_update_header_empty(void)
|
|||
if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) {
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_FWD_ERR;
|
||||
PRINTF("RPL forwarding error\n");
|
||||
/* We should send back the packet to the originating parent,
|
||||
but it is not feasible yet, so we send a No-Path DAO instead */
|
||||
PRINTF("RPL generate No-Path DAO\n");
|
||||
parent = rpl_get_parent((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
if(parent != NULL) {
|
||||
dao_output_target(parent, &UIP_IP_BUF->destipaddr, RPL_ZERO_LIFETIME);
|
||||
}
|
||||
/* Drop packet */
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/* Set the down extension flag correctly as described in Section
|
||||
|
@ -262,11 +264,11 @@ rpl_update_header_empty(void)
|
|||
}
|
||||
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return;
|
||||
return 0;
|
||||
default:
|
||||
PRINTF("RPL: Multi Hop-by-hop options not implemented\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -375,6 +377,5 @@ rpl_insert_header(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RPL_DIO_GROUNDED 0x80
|
||||
#define RPL_DIO_MOP_SHIFT 3
|
||||
|
@ -958,6 +957,5 @@ rpl_icmp6_register_handlers()
|
|||
uip_icmp6_register_input_handler(&dao_ack_handler);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
#include "lib/random.h"
|
||||
#include "sys/ctimer.h"
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
|
@ -325,6 +323,5 @@ rpl_cancel_dao(rpl_instance_t *instance)
|
|||
ctimer_stop(&instance->dao_lifetime_timer);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
#if RPL_CONF_STATS
|
||||
rpl_stats_t rpl_stats;
|
||||
#endif
|
||||
|
@ -316,6 +314,5 @@ rpl_init(void)
|
|||
RPL_OF.reset(NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -240,13 +240,14 @@ int rpl_repair_root(uint8_t instance_id);
|
|||
int rpl_set_default_route(rpl_instance_t *instance, uip_ipaddr_t *from);
|
||||
rpl_dag_t *rpl_get_any_dag(void);
|
||||
rpl_instance_t *rpl_get_instance(uint8_t instance_id);
|
||||
void rpl_update_header_empty(void);
|
||||
int rpl_update_header_empty(void);
|
||||
int rpl_update_header_final(uip_ipaddr_t *addr);
|
||||
int rpl_verify_header(int);
|
||||
void rpl_insert_header(void);
|
||||
void rpl_remove_header(void);
|
||||
uint8_t rpl_invert_header(void);
|
||||
uip_ipaddr_t *rpl_get_parent_ipaddr(rpl_parent_t *nbr);
|
||||
rpl_parent_t *rpl_get_parent(uip_lladdr_t *addr);
|
||||
rpl_rank_t rpl_get_parent_rank(uip_lladdr_t *addr);
|
||||
uint16_t rpl_get_parent_link_metric(const uip_lladdr_t *addr);
|
||||
void rpl_dag_init(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue