Merge branch 'contiki' into osd
This commit is contained in:
commit
349f6bf429
|
@ -57,7 +57,7 @@ uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
|
||||||
memmove(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len);
|
memmove(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len);
|
||||||
uip_process(UIP_UDP_SEND_CONN);
|
uip_process(UIP_UDP_SEND_CONN);
|
||||||
|
|
||||||
#if UIP_CONF_IPV6_MULTICAST
|
#if UIP_IPV6_MULTICAST
|
||||||
/* Let the multicast engine process the datagram before we send it */
|
/* Let the multicast engine process the datagram before we send it */
|
||||||
if(uip_is_addr_mcast_routable(&uip_udp_conn->ripaddr)) {
|
if(uip_is_addr_mcast_routable(&uip_udp_conn->ripaddr)) {
|
||||||
UIP_MCAST6.out();
|
UIP_MCAST6.out();
|
||||||
|
|
|
@ -98,7 +98,7 @@ In order to extend multicast with a new engine, perform the following steps:
|
||||||
- Open `uip-mcast6.h` and add a section in the `#if` spree. This aims to
|
- Open `uip-mcast6.h` and add a section in the `#if` spree. This aims to
|
||||||
configure the uIPv6 core. More specifically, you need to:
|
configure the uIPv6 core. More specifically, you need to:
|
||||||
* Specify if you want to put RPL in MOP3 by defining
|
* Specify if you want to put RPL in MOP3 by defining
|
||||||
`RPL_CONF_MULTICAST`: 1: MOP 3, 0: non-multicast MOP
|
`RPL_WITH_MULTICAST`: 1: MOP 3, 0: non-multicast MOP
|
||||||
* Define your engine details
|
* Define your engine details
|
||||||
|
|
||||||
#define UIP_MCAST6 foo_driver
|
#define UIP_MCAST6 foo_driver
|
||||||
|
|
406
core/net/ipv6/multicast/esmrf.c
Normal file
406
core/net/ipv6/multicast/esmrf.c
Normal file
|
@ -0,0 +1,406 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, Loughborough University - Computer Science
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* This file shows the implementations of the Enhanced Stateless
|
||||||
|
* Multicast RPL Forwarding (ESMRF)
|
||||||
|
*
|
||||||
|
* It will only work in RPL networks in MOP 3 "Storing with Multicast"
|
||||||
|
*
|
||||||
|
* \author
|
||||||
|
* Khaled Qorany kqorany2@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "contiki.h"
|
||||||
|
#include "contiki-net.h"
|
||||||
|
#include "net/ipv6/multicast/uip-mcast6.h"
|
||||||
|
#include "net/ipv6/multicast/uip-mcast6-route.h"
|
||||||
|
#include "net/ipv6/multicast/uip-mcast6-stats.h"
|
||||||
|
#include "net/ipv6/multicast/esmrf.h"
|
||||||
|
#include "net/rpl/rpl.h"
|
||||||
|
#include "net/ip/uip.h"
|
||||||
|
#include "net/netstack.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
extern uint16_t uip_slen;
|
||||||
|
|
||||||
|
#define DEBUG NONE
|
||||||
|
#include "net/ip/uip-debug.h"
|
||||||
|
|
||||||
|
#define ESMRF_VERBOSE NONE
|
||||||
|
|
||||||
|
#if DEBUG && ESMRF_VERBOSE
|
||||||
|
#define VERBOSE_PRINTF(...) PRINTF(__VA_ARGS__)
|
||||||
|
#define VERBOSE_PRINT_SEED(s) PRINT_SEED(s)
|
||||||
|
#else
|
||||||
|
#define VERBOSE_PRINTF(...)
|
||||||
|
#define VERBOSE_PRINT_SEED(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Maintain Stats */
|
||||||
|
#if UIP_MCAST6_STATS
|
||||||
|
static struct esmrf_stats stats;
|
||||||
|
|
||||||
|
#define ESMRF_STATS_ADD(x) stats.x++
|
||||||
|
#define ESMRF_STATS_INIT() do { memset(&stats, 0, sizeof(stats)); } while(0)
|
||||||
|
#else /* UIP_MCAST6_STATS */
|
||||||
|
#define ESMRF_STATS_ADD(x)
|
||||||
|
#define ESMRF_STATS_INIT()
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Macros */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* CCI */
|
||||||
|
#define ESMRF_FWD_DELAY() NETSTACK_RDC.channel_check_interval()
|
||||||
|
/* Number of slots in the next 500ms */
|
||||||
|
#define ESMRF_INTERVAL_COUNT ((CLOCK_SECOND >> 2) / fwd_delay)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Internal Data */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static struct ctimer mcast_periodic;
|
||||||
|
static uint8_t mcast_len;
|
||||||
|
static uip_buf_t mcast_buf;
|
||||||
|
static uint8_t fwd_delay;
|
||||||
|
static uint8_t fwd_spread;
|
||||||
|
static struct uip_udp_conn *c;
|
||||||
|
static uip_ipaddr_t src_ip;
|
||||||
|
static uip_ipaddr_t des_ip;
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* uIPv6 Pointers */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
|
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||||
|
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||||
|
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Local function prototypes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void icmp_input(void);
|
||||||
|
static void icmp_output(void);
|
||||||
|
static void mcast_fwd(void *p);
|
||||||
|
int remove_ext_hdr(void);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Internal Data Structures */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
struct multicast_on_behalf{ /* ICMP message of multicast_on_behalf */
|
||||||
|
uint16_t mcast_port;
|
||||||
|
uip_ipaddr_t mcast_ip;
|
||||||
|
uint8_t mcast_payload[UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN];
|
||||||
|
};
|
||||||
|
#define UIP_ICMP_MOB 18 /* Size of multicast_on_behalf ICMP header */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Temporary Stores */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static struct multicast_on_behalf *locmobptr;
|
||||||
|
static int loclen;
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* ESMRF ICMPv6 handler declaration */
|
||||||
|
UIP_ICMP6_HANDLER(esmrf_icmp_handler, ICMP6_ESMRF,
|
||||||
|
UIP_ICMP6_HANDLER_CODE_ANY, icmp_input);
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
icmp_output()
|
||||||
|
{
|
||||||
|
uint16_t payload_len=0;
|
||||||
|
rpl_dag_t *dag_t;
|
||||||
|
|
||||||
|
struct multicast_on_behalf *mob;
|
||||||
|
mob = (struct multicast_on_behalf *)UIP_ICMP_PAYLOAD;
|
||||||
|
memcpy(&mob->mcast_payload, &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], uip_slen);
|
||||||
|
|
||||||
|
UIP_IP_BUF->vtc = 0x60;
|
||||||
|
UIP_IP_BUF->tcflow = 0;
|
||||||
|
UIP_IP_BUF->flow = 0;
|
||||||
|
UIP_IP_BUF->proto = UIP_PROTO_ICMP6;
|
||||||
|
UIP_IP_BUF->ttl = ESMRF_IP_HOP_LIMIT;
|
||||||
|
|
||||||
|
mob->mcast_port = (uint16_t) uip_udp_conn->rport;
|
||||||
|
uip_ipaddr_copy(&mob->mcast_ip, &UIP_IP_BUF->destipaddr);
|
||||||
|
|
||||||
|
payload_len = UIP_ICMP_MOB + uip_slen;
|
||||||
|
|
||||||
|
dag_t = rpl_get_any_dag();
|
||||||
|
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &dag_t->dag_id);
|
||||||
|
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||||
|
|
||||||
|
VERBOSE_PRINTF("ESMRF: ICMPv6 Out - Hdr @ %p, payload @ %p to: ", UIP_ICMP_BUF, mob);
|
||||||
|
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
|
||||||
|
PRINTF("\n");
|
||||||
|
|
||||||
|
UIP_IP_BUF->len[0] = (UIP_ICMPH_LEN + payload_len) >> 8;
|
||||||
|
UIP_IP_BUF->len[1] = (UIP_ICMPH_LEN + payload_len) & 0xff;
|
||||||
|
|
||||||
|
UIP_ICMP_BUF->type = ICMP6_ESMRF;
|
||||||
|
UIP_ICMP_BUF->icode = ESMRF_ICMP_CODE;
|
||||||
|
|
||||||
|
UIP_ICMP_BUF->icmpchksum = 0;
|
||||||
|
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
|
||||||
|
|
||||||
|
uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + payload_len;
|
||||||
|
|
||||||
|
VERBOSE_PRINTF("ESMRF: ICMPv6 Out - %u bytes, uip_len %u bytes, uip_ext_len %u bytes\n",
|
||||||
|
payload_len, uip_len, uip_ext_len);
|
||||||
|
|
||||||
|
tcpip_ipv6_output();
|
||||||
|
ESMRF_STATS_ADD(icmp_out);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
icmp_input()
|
||||||
|
{
|
||||||
|
#if UIP_CONF_IPV6_CHECKS
|
||||||
|
if(UIP_ICMP_BUF->icode != ESMRF_ICMP_CODE) {
|
||||||
|
PRINTF("ESMRF: ICMPv6 In, bad ICMP code\n");
|
||||||
|
ESMRF_STATS_ADD(icmp_bad);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(UIP_IP_BUF->ttl <= 1) {
|
||||||
|
PRINTF("ESMRF: ICMPv6 In, bad TTL\n");
|
||||||
|
ESMRF_STATS_ADD(icmp_bad);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
remove_ext_hdr();
|
||||||
|
|
||||||
|
PRINTF("ESMRF: ICMPv6 In from ");
|
||||||
|
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||||
|
PRINTF(" len %u, ext %u\n", uip_len, uip_ext_len);
|
||||||
|
|
||||||
|
ESMRF_STATS_ADD(icmp_in);
|
||||||
|
|
||||||
|
VERBOSE_PRINTF("ESMRF: ICMPv6 In, parse from %p to %p\n",
|
||||||
|
UIP_ICMP_PAYLOAD,
|
||||||
|
(uint8_t *)UIP_ICMP_PAYLOAD + uip_len -
|
||||||
|
uip_l2_l3_icmp_hdr_len);
|
||||||
|
|
||||||
|
|
||||||
|
locmobptr = (struct multicast_on_behalf *) UIP_ICMP_PAYLOAD;
|
||||||
|
loclen = uip_len - (uip_l2_l3_icmp_hdr_len + UIP_ICMP_MOB);
|
||||||
|
|
||||||
|
uip_ipaddr_copy(&src_ip, &UIP_IP_BUF->srcipaddr);
|
||||||
|
uip_ipaddr_copy(&des_ip, &UIP_IP_BUF->destipaddr);
|
||||||
|
|
||||||
|
/* Extract the original multicast message */
|
||||||
|
uip_ipaddr_copy(&c->ripaddr, &locmobptr->mcast_ip);
|
||||||
|
c->rport = locmobptr->mcast_port;
|
||||||
|
uip_slen = loclen;
|
||||||
|
uip_udp_conn=c;
|
||||||
|
memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], locmobptr->mcast_payload,
|
||||||
|
loclen > UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN?
|
||||||
|
UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN: loclen);
|
||||||
|
|
||||||
|
uip_process(UIP_UDP_SEND_CONN);
|
||||||
|
|
||||||
|
memcpy(&mcast_buf, uip_buf, uip_len);
|
||||||
|
mcast_len = uip_len;
|
||||||
|
/* pass the packet to our uip_process to check if it is allowed to
|
||||||
|
* accept this packet or not */
|
||||||
|
uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &src_ip);
|
||||||
|
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &des_ip);
|
||||||
|
UIP_UDP_BUF->udpchksum = 0;
|
||||||
|
|
||||||
|
uip_process(UIP_DATA);
|
||||||
|
|
||||||
|
memcpy(uip_buf, &mcast_buf, mcast_len);
|
||||||
|
uip_len = mcast_len;
|
||||||
|
/* Return the IP of the original Multicast sender */
|
||||||
|
uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &src_ip);
|
||||||
|
UIP_UDP_BUF->udpchksum = 0;
|
||||||
|
/* If we have an entry in the multicast routing table, something with
|
||||||
|
* a higher RPL rank (somewhere down the tree) is a group member */
|
||||||
|
if(uip_mcast6_route_lookup(&UIP_IP_BUF->destipaddr)) {
|
||||||
|
PRINTF("ESMRF: Forward this packet\n");
|
||||||
|
/* If we enter here, we will definitely forward */
|
||||||
|
tcpip_ipv6_output();
|
||||||
|
}
|
||||||
|
uip_clear_buf();
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
mcast_fwd(void *p)
|
||||||
|
{
|
||||||
|
memcpy(uip_buf, &mcast_buf, mcast_len);
|
||||||
|
uip_len = mcast_len;
|
||||||
|
UIP_IP_BUF->ttl--;
|
||||||
|
tcpip_output(NULL);
|
||||||
|
uip_clear_buf();
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t
|
||||||
|
in()
|
||||||
|
{
|
||||||
|
rpl_dag_t *d; /* Our DODAG */
|
||||||
|
uip_ipaddr_t *parent_ipaddr; /* Our pref. parent's IPv6 address */
|
||||||
|
const uip_lladdr_t *parent_lladdr; /* Our pref. parent's LL address */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fetch a pointer to the LL address of our preferred parent
|
||||||
|
*
|
||||||
|
* ToDo: This rpl_get_any_dag() call is a dirty replacement of the previous
|
||||||
|
* rpl_get_dag(RPL_DEFAULT_INSTANCE);
|
||||||
|
* so that things can compile with the new RPL code. This needs updated to
|
||||||
|
* read instance ID from the RPL HBHO and use the correct parent accordingly
|
||||||
|
*/
|
||||||
|
d = rpl_get_any_dag();
|
||||||
|
if(!d) {
|
||||||
|
PRINTF("ESMRF: No DODAG\n");
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_dropped);
|
||||||
|
return UIP_MCAST6_DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Retrieve our preferred parent's LL address */
|
||||||
|
parent_ipaddr = rpl_get_parent_ipaddr(d->preferred_parent);
|
||||||
|
parent_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(parent_ipaddr);
|
||||||
|
|
||||||
|
if(parent_lladdr == NULL) {
|
||||||
|
PRINTF("ESMRF: NO Parent exist \n");
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_dropped);
|
||||||
|
return UIP_MCAST6_DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We accept a datagram if it arrived from our preferred parent, discard
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
if(memcmp(parent_lladdr, packetbuf_addr(PACKETBUF_ADDR_SENDER),
|
||||||
|
UIP_LLADDR_LEN)) {
|
||||||
|
PRINTF("ESMRF: Routable in but ESMRF ignored it\n");
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_dropped);
|
||||||
|
return UIP_MCAST6_DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(UIP_IP_BUF->ttl <= 1) {
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_dropped);
|
||||||
|
return UIP_MCAST6_DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_in_all);
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_in_unique);
|
||||||
|
|
||||||
|
/* If we have an entry in the mcast routing table, something with
|
||||||
|
* a higher RPL rank (somewhere down the tree) is a group member */
|
||||||
|
if(uip_mcast6_route_lookup(&UIP_IP_BUF->destipaddr)) {
|
||||||
|
/* If we enter here, we will definitely forward */
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_fwd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a delay (D) of at least ESMRF_FWD_DELAY() to compensate for how
|
||||||
|
* contikimac handles broadcasts. We can't start our TX before the sender
|
||||||
|
* has finished its own.
|
||||||
|
*/
|
||||||
|
fwd_delay = ESMRF_FWD_DELAY();
|
||||||
|
|
||||||
|
/* Finalise D: D = min(ESMRF_FWD_DELAY(), ESMRF_MIN_FWD_DELAY) */
|
||||||
|
#if ESMRF_MIN_FWD_DELAY
|
||||||
|
if(fwd_delay < ESMRF_MIN_FWD_DELAY) {
|
||||||
|
fwd_delay = ESMRF_MIN_FWD_DELAY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(fwd_delay == 0) {
|
||||||
|
/* No delay required, send it, do it now, why wait? */
|
||||||
|
UIP_IP_BUF->ttl--;
|
||||||
|
tcpip_output(NULL);
|
||||||
|
UIP_IP_BUF->ttl++; /* Restore before potential upstack delivery */
|
||||||
|
} else {
|
||||||
|
/* Randomise final delay in [D , D*Spread], step D */
|
||||||
|
fwd_spread = ESMRF_INTERVAL_COUNT;
|
||||||
|
if(fwd_spread > ESMRF_MAX_SPREAD) {
|
||||||
|
fwd_spread = ESMRF_MAX_SPREAD;
|
||||||
|
}
|
||||||
|
if(fwd_spread) {
|
||||||
|
fwd_delay = fwd_delay * (1 + ((random_rand() >> 11) % fwd_spread));
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&mcast_buf, uip_buf, uip_len);
|
||||||
|
mcast_len = uip_len;
|
||||||
|
ctimer_set(&mcast_periodic, fwd_delay, mcast_fwd, NULL);
|
||||||
|
}
|
||||||
|
PRINTF("ESMRF: %u bytes: fwd in %u [%u]\n",
|
||||||
|
uip_len, fwd_delay, fwd_spread);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done with this packet unless we are a member of the mcast group */
|
||||||
|
if(!uip_ds6_is_my_maddr(&UIP_IP_BUF->destipaddr)) {
|
||||||
|
PRINTF("ESMRF: Not a group member. No further processing\n");
|
||||||
|
return UIP_MCAST6_DROP;
|
||||||
|
} else {
|
||||||
|
PRINTF("ESMRF: Ours. Deliver to upper layers\n");
|
||||||
|
UIP_MCAST6_STATS_ADD(mcast_in_ours);
|
||||||
|
return UIP_MCAST6_ACCEPT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
init()
|
||||||
|
{
|
||||||
|
UIP_MCAST6_STATS_INIT(NULL);
|
||||||
|
uip_mcast6_route_init();
|
||||||
|
/* Register the ICMPv6 input handler */
|
||||||
|
uip_icmp6_register_input_handler(&esmrf_icmp_handler);
|
||||||
|
c = udp_new(NULL, 0, NULL);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
out(void)
|
||||||
|
{
|
||||||
|
rpl_dag_t *dag_t;
|
||||||
|
dag_t = rpl_get_any_dag();
|
||||||
|
if (!dag_t){
|
||||||
|
PRINTF("ESMRF: There is no DODAG\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(dag_t->rank == 256){
|
||||||
|
PRINTF("ESMRF: I am the Root, thus send the multicast packet normally. \n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
PRINTF("ESMRF: I am not the Root\n");
|
||||||
|
PRINTF("Send multicast-on-befalf message (ICMPv6) instead to ");
|
||||||
|
PRINT6ADDR(&dag_t->dag_id);
|
||||||
|
PRINTF("\n");
|
||||||
|
icmp_output();
|
||||||
|
uip_slen=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
const struct uip_mcast6_driver esmrf_driver = {
|
||||||
|
"ESMRF",
|
||||||
|
init,
|
||||||
|
out,
|
||||||
|
in,
|
||||||
|
};
|
||||||
|
/*---------------------------------------------------------------------------*/
|
83
core/net/ipv6/multicast/esmrf.h
Normal file
83
core/net/ipv6/multicast/esmrf.h
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, Loughborough University - Computer Science
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Header file for the Enhanced Stateless Multicast RPL Forwarding (ESMRF)
|
||||||
|
*
|
||||||
|
* \author
|
||||||
|
* Khaled Qorany kqorany2@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ESMRF_H_
|
||||||
|
#define ESMRF_H_
|
||||||
|
|
||||||
|
#include "contiki-conf.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Protocol Constants */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define ESMRF_ICMP_CODE 0 /* ICMPv6 code field */
|
||||||
|
#define ESMRF_IP_HOP_LIMIT 0xFF /* Hop limit for ICMP messages */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Configuration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Fmin */
|
||||||
|
#ifdef ESMRF_CONF_MIN_FWD_DELAY
|
||||||
|
#define ESMRF_MIN_FWD_DELAY ESMRF_CONF_MIN_FWD_DELAY
|
||||||
|
#else
|
||||||
|
#define ESMRF_MIN_FWD_DELAY 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Max Spread */
|
||||||
|
#ifdef ESMRF_CONF_MAX_SPREAD
|
||||||
|
#define ESMRF_MAX_SPREAD ESMRF_CONF_MAX_SPREAD
|
||||||
|
#else
|
||||||
|
#define ESMRF_MAX_SPREAD 4
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Stats datatype */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
struct esmrf_stats {
|
||||||
|
uint16_t mcast_in_unique;
|
||||||
|
uint16_t mcast_in_all; /* At layer 3 */
|
||||||
|
uint16_t mcast_in_ours; /* Unique and we are a group member */
|
||||||
|
uint16_t mcast_fwd; /* Forwarded by us but we are not the seed */
|
||||||
|
uint16_t mcast_out; /* We are the seed */
|
||||||
|
uint16_t mcast_bad;
|
||||||
|
uint16_t mcast_dropped;
|
||||||
|
uint16_t icmp_out;
|
||||||
|
uint16_t icmp_in;
|
||||||
|
uint16_t icmp_bad;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ESMRF_H_ */
|
|
@ -50,6 +50,7 @@
|
||||||
#define UIP_MCAST6_ENGINE_NONE 0 /**< Selecting this disables mcast */
|
#define UIP_MCAST6_ENGINE_NONE 0 /**< Selecting this disables mcast */
|
||||||
#define UIP_MCAST6_ENGINE_SMRF 1 /**< The SMRF engine */
|
#define UIP_MCAST6_ENGINE_SMRF 1 /**< The SMRF engine */
|
||||||
#define UIP_MCAST6_ENGINE_ROLL_TM 2 /**< The ROLL TM engine */
|
#define UIP_MCAST6_ENGINE_ROLL_TM 2 /**< The ROLL TM engine */
|
||||||
|
#define UIP_MCAST6_ENGINE_ESMRF 3 /**< The ESMRF engine */
|
||||||
|
|
||||||
#endif /* UIP_MCAST6_ENGINES_H_ */
|
#endif /* UIP_MCAST6_ENGINES_H_ */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "net/ipv6/multicast/uip-mcast6-engines.h"
|
#include "net/ipv6/multicast/uip-mcast6-engines.h"
|
||||||
#include "net/ipv6/multicast/uip-mcast6-route.h"
|
#include "net/ipv6/multicast/uip-mcast6-route.h"
|
||||||
#include "net/ipv6/multicast/smrf.h"
|
#include "net/ipv6/multicast/smrf.h"
|
||||||
|
#include "net/ipv6/multicast/esmrf.h"
|
||||||
#include "net/ipv6/multicast/roll-tm.h"
|
#include "net/ipv6/multicast/roll-tm.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -147,17 +148,23 @@ struct uip_mcast6_driver {
|
||||||
#if UIP_MCAST6_ENGINE
|
#if UIP_MCAST6_ENGINE
|
||||||
|
|
||||||
/* Enable Multicast hooks in the uip6 core */
|
/* Enable Multicast hooks in the uip6 core */
|
||||||
#define UIP_CONF_IPV6_MULTICAST 1
|
#define UIP_IPV6_MULTICAST 1
|
||||||
|
|
||||||
#if UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ROLL_TM
|
#if UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ROLL_TM
|
||||||
#define RPL_CONF_MULTICAST 0 /* Not used by trickle */
|
#define RPL_WITH_MULTICAST 0 /* Not used by trickle */
|
||||||
#define UIP_CONF_IPV6_ROLL_TM 1 /* ROLL Trickle ICMP type support */
|
#define UIP_CONF_IPV6_ROLL_TM 1 /* ROLL Trickle ICMP type support */
|
||||||
|
|
||||||
#define UIP_MCAST6 roll_tm_driver
|
#define UIP_MCAST6 roll_tm_driver
|
||||||
|
|
||||||
#elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_SMRF
|
#elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_SMRF
|
||||||
#define RPL_CONF_MULTICAST 1
|
#define RPL_WITH_MULTICAST 1
|
||||||
|
|
||||||
#define UIP_MCAST6 smrf_driver
|
#define UIP_MCAST6 smrf_driver
|
||||||
|
|
||||||
|
#elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ESMRF
|
||||||
|
#define RPL_CONF_MULTICAST 1
|
||||||
|
#define UIP_MCAST6 esmrf_driver
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Multicast Enabled with an Unknown Engine."
|
#error "Multicast Enabled with an Unknown Engine."
|
||||||
#error "Check the value of UIP_MCAST6_CONF_ENGINE in conf files."
|
#error "Check the value of UIP_MCAST6_CONF_ENGINE in conf files."
|
||||||
|
@ -168,7 +175,7 @@ extern const struct uip_mcast6_driver UIP_MCAST6;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Configuration Checks */
|
/* Configuration Checks */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if RPL_CONF_MULTICAST && (!UIP_CONF_IPV6_RPL)
|
#if RPL_WITH_MULTICAST && (!UIP_CONF_IPV6_RPL)
|
||||||
#error "The selected Multicast mode requires UIP_CONF_IPV6_RPL != 0"
|
#error "The selected Multicast mode requires UIP_CONF_IPV6_RPL != 0"
|
||||||
#error "Check the value of UIP_CONF_IPV6_RPL in conf files."
|
#error "Check the value of UIP_CONF_IPV6_RPL in conf files."
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
#include "net/ipv6/uip-nd6.h"
|
#include "net/ipv6/uip-nd6.h"
|
||||||
#include "net/ipv6/uip-ds6.h"
|
#include "net/ipv6/uip-ds6.h"
|
||||||
|
#include "net/ipv6/multicast/uip-mcast6.h"
|
||||||
#include "net/ip/uip-packetqueue.h"
|
#include "net/ip/uip-packetqueue.h"
|
||||||
|
|
||||||
#define DEBUG DEBUG_NONE
|
#define DEBUG DEBUG_NONE
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
#define ICMP6_PRIV_EXP_200 200 /**< Private Experimentation */
|
#define ICMP6_PRIV_EXP_200 200 /**< Private Experimentation */
|
||||||
#define ICMP6_PRIV_EXP_201 201 /**< Private Experimentation */
|
#define ICMP6_PRIV_EXP_201 201 /**< Private Experimentation */
|
||||||
#define ICMP6_ROLL_TM ICMP6_PRIV_EXP_200 /**< ROLL Trickle Multicast */
|
#define ICMP6_ROLL_TM ICMP6_PRIV_EXP_200 /**< ROLL Trickle Multicast */
|
||||||
|
#define ICMP6_ESMRF ICMP6_PRIV_EXP_201 /**< ESMRF Multicast */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@ uip_init(void)
|
||||||
}
|
}
|
||||||
#endif /* UIP_UDP */
|
#endif /* UIP_UDP */
|
||||||
|
|
||||||
#if UIP_CONF_IPV6_MULTICAST
|
#if UIP_IPV6_MULTICAST
|
||||||
UIP_MCAST6.init();
|
UIP_MCAST6.init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1192,7 @@ uip_process(uint8_t flag)
|
||||||
* All multicast engines must hook in here. After this function returns, we
|
* All multicast engines must hook in here. After this function returns, we
|
||||||
* expect UIP_BUF to be unmodified
|
* expect UIP_BUF to be unmodified
|
||||||
*/
|
*/
|
||||||
#if UIP_CONF_IPV6_MULTICAST
|
#if UIP_IPV6_MULTICAST
|
||||||
if(uip_is_addr_mcast_routable(&UIP_IP_BUF->destipaddr)) {
|
if(uip_is_addr_mcast_routable(&UIP_IP_BUF->destipaddr)) {
|
||||||
if(UIP_MCAST6.in() == UIP_MCAST6_ACCEPT) {
|
if(UIP_MCAST6.in() == UIP_MCAST6_ACCEPT) {
|
||||||
/* Deliver up the stack */
|
/* Deliver up the stack */
|
||||||
|
@ -1202,7 +1202,7 @@ uip_process(uint8_t flag)
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* UIP_IPV6_CONF_MULTICAST */
|
#endif /* UIP_IPV6_MULTICAST */
|
||||||
|
|
||||||
/* TBD Some Parameter problem messages */
|
/* TBD Some Parameter problem messages */
|
||||||
if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) &&
|
if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) &&
|
||||||
|
@ -1276,7 +1276,7 @@ uip_process(uint8_t flag)
|
||||||
uip_ext_bitmap = 0;
|
uip_ext_bitmap = 0;
|
||||||
#endif /* UIP_CONF_ROUTER */
|
#endif /* UIP_CONF_ROUTER */
|
||||||
|
|
||||||
#if UIP_CONF_IPV6_MULTICAST
|
#if UIP_IPV6_MULTICAST
|
||||||
process:
|
process:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1435,7 +1435,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||||
rpl_dag_t *dag, *previous_dag;
|
rpl_dag_t *dag, *previous_dag;
|
||||||
rpl_parent_t *p;
|
rpl_parent_t *p;
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
/* If the root is advertising MOP 2 but we support MOP 3 we can still join
|
/* If the root is advertising MOP 2 but we support MOP 3 we can still join
|
||||||
* In that scenario, we suppress DAOs for multicast targets */
|
* In that scenario, we suppress DAOs for multicast targets */
|
||||||
if(dio->mop < RPL_MOP_STORING_NO_MULTICAST) {
|
if(dio->mop < RPL_MOP_STORING_NO_MULTICAST) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ void RPL_DEBUG_DAO_OUTPUT(rpl_parent_t *);
|
||||||
|
|
||||||
static uint8_t dao_sequence = RPL_LOLLIPOP_INIT;
|
static uint8_t dao_sequence = RPL_LOLLIPOP_INIT;
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
static uip_mcast6_route_t *mcast_group;
|
static uip_mcast6_route_t *mcast_group;
|
||||||
#endif
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -755,7 +755,7 @@ dao_input_storing(void)
|
||||||
PRINT6ADDR(&prefix);
|
PRINT6ADDR(&prefix);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
if(uip_is_addr_mcast_global(&prefix)) {
|
if(uip_is_addr_mcast_global(&prefix)) {
|
||||||
mcast_group = uip_mcast6_route_add(&prefix);
|
mcast_group = uip_mcast6_route_add(&prefix);
|
||||||
if(mcast_group) {
|
if(mcast_group) {
|
||||||
|
@ -845,7 +845,7 @@ dao_input_storing(void)
|
||||||
rep->state.lifetime = RPL_LIFETIME(instance, lifetime);
|
rep->state.lifetime = RPL_LIFETIME(instance, lifetime);
|
||||||
RPL_ROUTE_CLEAR_NOPATH_RECEIVED(rep);
|
RPL_ROUTE_CLEAR_NOPATH_RECEIVED(rep);
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
fwd_dao:
|
fwd_dao:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -203,11 +203,11 @@
|
||||||
#ifdef RPL_CONF_MOP
|
#ifdef RPL_CONF_MOP
|
||||||
#define RPL_MOP_DEFAULT RPL_CONF_MOP
|
#define RPL_MOP_DEFAULT RPL_CONF_MOP
|
||||||
#else /* RPL_CONF_MOP */
|
#else /* RPL_CONF_MOP */
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
#define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
|
#define RPL_MOP_DEFAULT RPL_MOP_STORING_MULTICAST
|
||||||
#else
|
#else
|
||||||
#define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
|
#define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
|
||||||
#endif /* UIP_IPV6_MULTICAST_RPL */
|
#endif /* RPL_WITH_MULTICAST */
|
||||||
#endif /* RPL_CONF_MOP */
|
#endif /* RPL_CONF_MOP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
#define RPL_IS_NON_STORING(instance) (RPL_WITH_NON_STORING && ((instance) != NULL) && ((instance)->mop == RPL_MOP_NON_STORING))
|
#define RPL_IS_NON_STORING(instance) (RPL_WITH_NON_STORING && ((instance) != NULL) && ((instance)->mop == RPL_MOP_NON_STORING))
|
||||||
|
|
||||||
/* Emit a pre-processor error if the user configured multicast with bad MOP */
|
/* Emit a pre-processor error if the user configured multicast with bad MOP */
|
||||||
#if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
|
#if RPL_WITH_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST)
|
||||||
#error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
|
#error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ static void
|
||||||
handle_dao_timer(void *ptr)
|
handle_dao_timer(void *ptr)
|
||||||
{
|
{
|
||||||
rpl_instance_t *instance;
|
rpl_instance_t *instance;
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
uip_mcast6_route_t *mcast_route;
|
uip_mcast6_route_t *mcast_route;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,7 +275,7 @@ handle_dao_timer(void *ptr)
|
||||||
/* Set the route lifetime to the default value. */
|
/* Set the route lifetime to the default value. */
|
||||||
dao_output(instance->current_dag->preferred_parent, instance->default_lifetime);
|
dao_output(instance->current_dag->preferred_parent, instance->default_lifetime);
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
/* Send DAOs for multicast prefixes only if the instance is in MOP 3 */
|
/* Send DAOs for multicast prefixes only if the instance is in MOP 3 */
|
||||||
if(instance->mop == RPL_MOP_STORING_MULTICAST) {
|
if(instance->mop == RPL_MOP_STORING_MULTICAST) {
|
||||||
/* Send a DAO for own multicast addresses */
|
/* Send a DAO for own multicast addresses */
|
||||||
|
|
|
@ -114,7 +114,7 @@ rpl_purge_routes(void)
|
||||||
uip_ds6_route_t *r;
|
uip_ds6_route_t *r;
|
||||||
uip_ipaddr_t prefix;
|
uip_ipaddr_t prefix;
|
||||||
rpl_dag_t *dag;
|
rpl_dag_t *dag;
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
uip_mcast6_route_t *mcast_route;
|
uip_mcast6_route_t *mcast_route;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ rpl_purge_routes(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
mcast_route = uip_mcast6_route_list_head();
|
mcast_route = uip_mcast6_route_list_head();
|
||||||
|
|
||||||
while(mcast_route != NULL) {
|
while(mcast_route != NULL) {
|
||||||
|
@ -178,7 +178,7 @@ void
|
||||||
rpl_remove_routes(rpl_dag_t *dag)
|
rpl_remove_routes(rpl_dag_t *dag)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
uip_ds6_route_t *r;
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
uip_mcast6_route_t *mcast_route;
|
uip_mcast6_route_t *mcast_route;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ rpl_remove_routes(rpl_dag_t *dag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RPL_CONF_MULTICAST
|
#if RPL_WITH_MULTICAST
|
||||||
mcast_route = uip_mcast6_route_list_head();
|
mcast_route = uip_mcast6_route_list_head();
|
||||||
|
|
||||||
while(mcast_route != NULL) {
|
while(mcast_route != NULL) {
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
#include "net/ipv6/multicast/uip-mcast6.h"
|
#include "net/ipv6/multicast/uip-mcast6.h"
|
||||||
|
|
||||||
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_CONF_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
||||||
#error "This example can not work with the current contiki configuration"
|
#error "This example can not work with the current contiki configuration"
|
||||||
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,7 +63,7 @@ static struct uip_udp_conn * mcast_conn;
|
||||||
static char buf[MAX_PAYLOAD_LEN];
|
static char buf[MAX_PAYLOAD_LEN];
|
||||||
static uint32_t seq_id;
|
static uint32_t seq_id;
|
||||||
|
|
||||||
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_CONF_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
||||||
#error "This example can not work with the current contiki configuration"
|
#error "This example can not work with the current contiki configuration"
|
||||||
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,7 +57,7 @@ static uint16_t count;
|
||||||
|
|
||||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
|
|
||||||
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_CONF_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
#if !NETSTACK_CONF_WITH_IPV6 || !UIP_CONF_ROUTER || !UIP_IPV6_MULTICAST || !UIP_CONF_IPV6_RPL
|
||||||
#error "This example can not work with the current contiki configuration"
|
#error "This example can not work with the current contiki configuration"
|
||||||
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
#error "Check the values of: NETSTACK_CONF_WITH_IPV6, UIP_CONF_ROUTER, UIP_CONF_IPV6_RPL"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
#define NETSTACK_CONF_RDC contikimac_driver
|
#define NETSTACK_CONF_RDC contikimac_driver
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disable turning off HF oscillator when the radio is off:
|
||||||
|
* You need to set this in order to use TSCH, disable to save more energy.
|
||||||
|
*/
|
||||||
|
#ifndef CC2650_FAST_RADIO_STARTUP
|
||||||
|
#define CC2650_FAST_RADIO_STARTUP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Configure NullRDC for when it's selected */
|
/* Configure NullRDC for when it's selected */
|
||||||
#define NULLRDC_CONF_802154_AUTOACK 1
|
#define NULLRDC_CONF_802154_AUTOACK 1
|
||||||
|
|
||||||
|
@ -359,12 +367,6 @@ typedef uint32_t rtimer_clock_t;
|
||||||
/* Disable TSCH frame filtering */
|
/* Disable TSCH frame filtering */
|
||||||
#define TSCH_CONF_HW_FRAME_FILTERING 0
|
#define TSCH_CONF_HW_FRAME_FILTERING 0
|
||||||
|
|
||||||
/* Disable turning off HF oscillator when radio is off;
|
|
||||||
enable this for TSCH, disable to save more energy. */
|
|
||||||
#ifndef CC2650_FAST_RADIO_STARTUP
|
|
||||||
#define CC2650_FAST_RADIO_STARTUP 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use hardware timestamps */
|
/* Use hardware timestamps */
|
||||||
#ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
|
#ifndef TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS
|
||||||
#define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
|
#define TSCH_CONF_RESYNC_WITH_SFD_TIMESTAMPS 1
|
||||||
|
|
|
@ -221,11 +221,11 @@ board_i2c_read(uint8_t *data, uint8_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(success) {
|
if(success) {
|
||||||
|
ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
|
||||||
while(ti_lib_i2c_master_busy(I2C0_BASE));
|
while(ti_lib_i2c_master_busy(I2C0_BASE));
|
||||||
success = i2c_status();
|
success = i2c_status();
|
||||||
if(success) {
|
if(success) {
|
||||||
data[len - 1] = ti_lib_i2c_master_data_get(I2C0_BASE);
|
data[len - 1] = ti_lib_i2c_master_data_get(I2C0_BASE);
|
||||||
ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
|
|
||||||
while(ti_lib_i2c_master_bus_busy(I2C0_BASE));
|
while(ti_lib_i2c_master_bus_busy(I2C0_BASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,11 +285,11 @@ board_i2c_write_read(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(success) {
|
if(success) {
|
||||||
|
ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
|
||||||
while(ti_lib_i2c_master_busy(I2C0_BASE));
|
while(ti_lib_i2c_master_busy(I2C0_BASE));
|
||||||
success = i2c_status();
|
success = i2c_status();
|
||||||
if(success) {
|
if(success) {
|
||||||
rdata[rlen - 1] = ti_lib_i2c_master_data_get(I2C0_BASE);
|
rdata[rlen - 1] = ti_lib_i2c_master_data_get(I2C0_BASE);
|
||||||
ti_lib_i2c_master_control(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
|
|
||||||
while(ti_lib_i2c_master_bus_busy(I2C0_BASE));
|
while(ti_lib_i2c_master_bus_busy(I2C0_BASE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue