Skip to content

Commit 3ab78ca

Browse files
author
Joakim Eriksson
authored
Merge pull request sics-iot#16 from nfi/sparrow-contiki-update
Updated Contiki to latest upstream
2 parents 89e16e8 + 4948b54 commit 3ab78ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1306
-3987
lines changed

apps/sparrow-oam/sparrow.h

-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
#include <stddef.h>
4646
#include "sparrow-byteorder.h"
4747

48-
#ifdef SPARROW_CONF_STORE_LOCATIONID_LOCALLY
49-
#define SPARROW_STORE_LOCATIONID_LOCALLY SPARROW_CONF_STORE_LOCATIONID_LOCALLY
50-
#else
51-
#define SPARROW_STORE_LOCATIONID_LOCALLY 1
52-
#endif /* SPARROW_CONF_STORE_LOCATIONID_LOCALLY */
53-
5448
typedef struct {
5549
uint8_t id[16];
5650
} sparrow_id_t;

contiki

Submodule contiki updated 298 files

core/dev/radio-802154-dev.c

+32-12
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@
4343
#include "dev/radio.h"
4444
#include "dev/watchdog.h"
4545

46-
/*---------------------------------------------------------------------------*/
4746
#define DEBUG 0
4847
#if DEBUG
4948
#include <stdio.h>
5049
#define PRINTF(...) printf(__VA_ARGS__)
5150
#else
5251
#define PRINTF(...)
5352
#endif
53+
54+
static uint8_t handle_collisions = 1;
55+
/*---------------------------------------------------------------------------*/
56+
void
57+
radio_802154_handle_collisions(int on)
58+
{
59+
handle_collisions = on != 0;
60+
}
5461
/*---------------------------------------------------------------------------*/
5562
int
5663
radio_802154_rx_buf_is_empty(const struct radio_802154_driver *radio)
@@ -111,6 +118,13 @@ radio_802154_release_readbuf(const struct radio_802154_driver *radio)
111118
radio->state->write_buf, radio->state->read_buf);
112119
}
113120
/*---------------------------------------------------------------------------*/
121+
void
122+
radio_802154_clear(const struct radio_802154_driver *radio)
123+
{
124+
/* Drop any buffers */
125+
radio->state->read_buf = radio->state->write_buf;
126+
}
127+
/*---------------------------------------------------------------------------*/
114128
/* called from receive Interrupt */
115129
radio_802154_rf_buffer_t *
116130
radio_802154_handle_ack(const struct radio_802154_driver *radio,
@@ -225,18 +239,23 @@ radio_802154_transmit(const struct radio_802154_driver *radio, unsigned short to
225239
break;
226240
case RADIO_TX_COLLISION:
227241
/* radio did give up... no transmission */
228-
wt = RTIMER_NOW();
229-
watchdog_periodic();
230-
while(RTIMER_CLOCK_LT(RTIMER_NOW(),
231-
wt + (radio->collision_wait_time << collisions))) {
232-
}
233-
collisions++;
234-
if(collisions > 4) {
235-
/* Ok give up this transmission - and continue */
236-
collisions = 0;
237-
attempts++; /* count 4 fails as an attempt - but not as transmission */
242+
if(handle_collisions) {
243+
wt = RTIMER_NOW();
244+
watchdog_periodic();
245+
while(RTIMER_CLOCK_LT(RTIMER_NOW(),
246+
wt + (radio->collision_wait_time << collisions))) {
247+
}
248+
collisions++;
249+
if(collisions > 4) {
250+
/* Ok give up this transmission - and continue */
251+
collisions = 0;
252+
attempts++; /* count 4 fails as an attempt - but not as transmission */
253+
}
254+
PRINTF("Collision: %d %d\n", collisions, attempts);
255+
} else {
256+
/* Directly return if collisions should not be handled */
257+
return RADIO_TX_COLLISION;
238258
}
239-
PRINTF("Collission: %d %d\n", collisions, attempts);
240259
ret = RADIO_TX_COLLISION;
241260
break;
242261
case RADIO_TX_ERR:
@@ -252,3 +271,4 @@ radio_802154_transmit(const struct radio_802154_driver *radio, unsigned short to
252271
}
253272
return ret;
254273
}
274+
/*---------------------------------------------------------------------------*/

core/dev/radio-802154-dev.h

+4
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,15 @@ void radio_802154_release_writebuf(const struct radio_802154_driver *radio, uint
108108
radio_802154_rf_buffer_t *radio_802154_get_readbuf(const struct radio_802154_driver *radio);
109109
void radio_802154_release_readbuf(const struct radio_802154_driver *radio);
110110

111+
void radio_802154_clear(const struct radio_802154_driver *radio);
112+
111113
/* Will check if the packet is an ACK and if it has a correct sequence no
112114
* if not - the packet will be buffered */
113115
radio_802154_rf_buffer_t *radio_802154_handle_ack(const struct radio_802154_driver *radio, const uint8_t *buf, int len);
114116

115117
/* The transmit will transmit with built-in retransmission and ACK handling */
116118
int radio_802154_transmit(const struct radio_802154_driver *radio, unsigned short total_len);
117119

120+
void radio_802154_handle_collisions(int on);
121+
118122
#endif /* RADIO_802154_DEV_H_ */

core/net/mac/frame802154.c

+33-12
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,45 @@ frame802154_has_panid(frame802154_fcf_t *fcf, int *has_src_pan_id, int *has_dest
172172
}
173173

174174
if(fcf->frame_version == FRAME802154_IEEE802154E_2012) {
175-
/* IEEE 802.15.4e-2012, Table 2a, PAN ID Compression */
176-
if(!fcf->panid_compression) {
177-
if(fcf->dest_addr_mode) {
178-
/* Use destination PAN ID if destination address is present */
179-
dest_pan_id = 1;
180-
} else if(fcf->src_addr_mode) {
181-
/* Only src address, include src PAN ID */
182-
src_pan_id = 1;
183-
}
184-
} else if((fcf->dest_addr_mode == 0) && (fcf->src_addr_mode == 0)) {
185-
/* No address included: PAN ID compression flag changes meaning */
175+
/*
176+
* IEEE 802.15.4-2015
177+
* Table 7-2, PAN ID Compression value for frame version 0b10
178+
*/
179+
if((fcf->dest_addr_mode == FRAME802154_NOADDR &&
180+
fcf->src_addr_mode == FRAME802154_NOADDR &&
181+
fcf->panid_compression == 1) ||
182+
(fcf->dest_addr_mode != FRAME802154_NOADDR &&
183+
fcf->src_addr_mode == FRAME802154_NOADDR &&
184+
fcf->panid_compression == 0) ||
185+
(fcf->dest_addr_mode == FRAME802154_LONGADDRMODE &&
186+
fcf->src_addr_mode == FRAME802154_LONGADDRMODE &&
187+
fcf->panid_compression == 0) ||
188+
((fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
189+
fcf->src_addr_mode != FRAME802154_NOADDR) ||
190+
(fcf->dest_addr_mode != FRAME802154_NOADDR &&
191+
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE)) ){
186192
dest_pan_id = 1;
187193
}
194+
195+
if(fcf->panid_compression == 0 &&
196+
((fcf->dest_addr_mode == FRAME802154_NOADDR &&
197+
fcf->src_addr_mode == FRAME802154_LONGADDRMODE) ||
198+
(fcf->dest_addr_mode == FRAME802154_NOADDR &&
199+
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE) ||
200+
(fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
201+
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE) ||
202+
(fcf->dest_addr_mode == FRAME802154_SHORTADDRMODE &&
203+
fcf->src_addr_mode == FRAME802154_LONGADDRMODE) ||
204+
(fcf->dest_addr_mode == FRAME802154_LONGADDRMODE &&
205+
fcf->src_addr_mode == FRAME802154_SHORTADDRMODE))) {
206+
src_pan_id = 1;
207+
}
208+
188209
} else {
189210
/* No PAN ID in ACK */
190211
if(fcf->frame_type != FRAME802154_ACKFRAME) {
191212
if(!fcf->panid_compression && fcf->src_addr_mode & 3) {
192-
/* If compressed, don't inclue source PAN ID */
213+
/* If compressed, don't include source PAN ID */
193214
src_pan_id = 1;
194215
}
195216
if(fcf->dest_addr_mode & 3) {

core/net/mac/framer-802154.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ create_frame(int type, int do_create)
153153
* Set up the source address using only the long address mode for
154154
* phase 1.
155155
*/
156-
linkaddr_copy((linkaddr_t *)&params.src_addr, &linkaddr_node_addr);
156+
linkaddr_copy((linkaddr_t *)&params.src_addr,
157+
packetbuf_addr(PACKETBUF_ADDR_SENDER));
157158

158159
params.payload = packetbuf_dataptr();
159160
params.payload_len = packetbuf_datalen();

core/net/mac/nullrdc.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@
4747
#include "net/llsec/anti-replay.h"
4848
#include <string.h>
4949

50-
#if CONTIKI_TARGET_COOJA
50+
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
5151
#include "lib/simEnvChange.h"
52-
#endif /* CONTIKI_TARGET_COOJA */
52+
#include "sys/cooja_mt.h"
53+
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
5354

5455
#define DEBUG 0
5556
#if DEBUG
@@ -198,10 +199,10 @@ send_one_packet(mac_callback_t sent, void *ptr)
198199
wt = RTIMER_NOW();
199200
watchdog_periodic();
200201
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + ACK_WAIT_TIME)) {
201-
#if CONTIKI_TARGET_COOJA
202+
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
202203
simProcessRunValue = 1;
203204
cooja_mt_yield();
204-
#endif /* CONTIKI_TARGET_COOJA */
205+
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
205206
}
206207

207208
ret = MAC_TX_NOACK;
@@ -216,10 +217,10 @@ send_one_packet(mac_callback_t sent, void *ptr)
216217
watchdog_periodic();
217218
while(RTIMER_CLOCK_LT(RTIMER_NOW(),
218219
wt + AFTER_ACK_DETECTED_WAIT_TIME)) {
219-
#if CONTIKI_TARGET_COOJA
220-
simProcessRunValue = 1;
221-
cooja_mt_yield();
222-
#endif /* CONTIKI_TARGET_COOJA */
220+
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
221+
simProcessRunValue = 1;
222+
cooja_mt_yield();
223+
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
223224
}
224225
}
225226

@@ -235,8 +236,8 @@ send_one_packet(mac_callback_t sent, void *ptr)
235236
}
236237
}
237238
} else {
238-
PRINTF("nullrdc tx noack\n");
239-
}
239+
PRINTF("nullrdc tx noack\n");
240+
}
240241
}
241242
break;
242243
case RADIO_TX_COLLISION:
@@ -366,6 +367,7 @@ packet_input(void)
366367
int duplicate = 0;
367368

368369
#if NULLRDC_802154_AUTOACK || NULLRDC_802154_AUTOACK_HW
370+
#if RDC_WITH_DUPLICATE_DETECTION
369371
/* Check for duplicate packet. */
370372
duplicate = mac_sequence_is_duplicate();
371373
if(duplicate) {
@@ -375,9 +377,9 @@ packet_input(void)
375377
} else {
376378
mac_sequence_register_seqno();
377379
}
380+
#endif /* RDC_WITH_DUPLICATE_DETECTION */
378381
#endif /* NULLRDC_802154_AUTOACK */
379382

380-
/* TODO We may want to acknowledge only authentic frames */
381383
#if NULLRDC_SEND_802154_ACK
382384
{
383385
frame802154_t info154;

core/net/rpl/rpl-dag.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ nullify_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
317317
}
318318
/*---------------------------------------------------------------------------*/
319319
static int
320-
should_send_dao(rpl_instance_t *instance, rpl_dio_t *dio, rpl_parent_t *p)
320+
should_refresh_routes(rpl_instance_t *instance, rpl_dio_t *dio, rpl_parent_t *p)
321321
{
322322
/* if MOP is set to no downward routes no DAO should be sent */
323323
if(instance->mop == RPL_MOP_NO_DOWNWARD_ROUTES) {
@@ -841,12 +841,16 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
841841
PRINTF("RPL: Changed preferred parent, rank changed from %u to %u\n",
842842
(unsigned)old_rank, best_dag->rank);
843843
RPL_STAT(rpl_stats.parent_switch++);
844-
if(RPL_IS_STORING(instance) && last_parent != NULL) {
845-
/* Send a No-Path DAO to the removed preferred parent. */
846-
dao_output(last_parent, RPL_ZERO_LIFETIME);
844+
if(RPL_IS_STORING(instance)) {
845+
if(last_parent != NULL) {
846+
/* Send a No-Path DAO to the removed preferred parent. */
847+
dao_output(last_parent, RPL_ZERO_LIFETIME);
848+
}
849+
/* Trigger DAO transmission from immediate children.
850+
* Only for storing mode, see RFC6550 section 9.6. */
851+
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
847852
}
848853
/* The DAO parent set changed - schedule a DAO transmission. */
849-
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
850854
rpl_schedule_dao(instance);
851855
rpl_reset_dio_timer(instance);
852856
#if DEBUG
@@ -1332,8 +1336,12 @@ rpl_local_repair(rpl_instance_t *instance)
13321336
instance->has_downward_route = 0;
13331337

13341338
rpl_reset_dio_timer(instance);
1335-
/* Request refresh of DAO registrations next DIO */
1336-
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
1339+
if(RPL_IS_STORING(instance)) {
1340+
/* Request refresh of DAO registrations next DIO. Only for storing mode. In
1341+
* non-storing mode, non-root nodes increment DTSN only on when their parent do,
1342+
* or on global repair (see RFC6550 section 9.6.) */
1343+
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
1344+
}
13371345

13381346
RPL_STAT(rpl_stats.local_repairs++);
13391347
}
@@ -1622,7 +1630,9 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
16221630

16231631
/* We don't use route control, so we can have only one official parent. */
16241632
if(dag->joined && p == dag->preferred_parent) {
1625-
if(should_send_dao(instance, dio, p)) {
1633+
if(should_refresh_routes(instance, dio, p)) {
1634+
/* Our parent is requesting a new DAO. Increment DTSN in turn,
1635+
* in both storing and non-storing mode (see RFC6550 section 9.6.) */
16261636
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
16271637
rpl_schedule_dao(instance);
16281638
}

core/net/rpl/rpl-icmp6.c

+8-29
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,6 @@ rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void *
202202
}
203203
}
204204

205-
if(nbr != NULL) {
206-
#if UIP_ND6_SEND_NA
207-
/* set reachable timer if we added or found the nbr entry - and update
208-
neighbor entry to reachable to avoid sending NS/NA, etc. */
209-
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
210-
nbr->state = NBR_REACHABLE;
211-
#endif /* UIP_ND6_SEND_NA */
212-
}
213205
return nbr;
214206
}
215207
/*---------------------------------------------------------------------------*/
@@ -636,15 +628,13 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
636628
}
637629
/*---------------------------------------------------------------------------*/
638630
static void
639-
dao_input_storing(void)
631+
dao_input_storing(rpl_instance_t *instance)
640632
{
641633
#if RPL_WITH_STORING
642634
uip_ipaddr_t dao_sender_addr;
643635
rpl_dag_t *dag;
644-
rpl_instance_t *instance;
645636
unsigned char *buffer;
646637
uint16_t sequence;
647-
uint8_t instance_id;
648638
uint8_t lifetime;
649639
uint8_t prefixlen;
650640
uint8_t flags;
@@ -672,16 +662,8 @@ dao_input_storing(void)
672662
buffer = UIP_ICMP_PAYLOAD;
673663
buffer_length = uip_len - uip_l3_icmp_hdr_len;
674664

675-
pos = 0;
676-
instance_id = buffer[pos++];
677-
678-
instance = rpl_get_instance(instance_id);
679-
if(instance == NULL) {
680-
PRINTF("RPL: Ignoring a DAO for an unknown RPL instance(%u)\n",
681-
instance_id);
682-
return;
683-
}
684-
665+
/* Position 0 is the instance id that already been handled */
666+
pos = 1;
685667
lifetime = instance->default_lifetime;
686668

687669
flags = buffer[pos++];
@@ -908,16 +890,14 @@ dao_input_storing(void)
908890
}
909891
/*---------------------------------------------------------------------------*/
910892
static void
911-
dao_input_nonstoring(void)
893+
dao_input_nonstoring(rpl_instance_t *instance)
912894
{
913895
#if RPL_WITH_NON_STORING
914896
uip_ipaddr_t dao_sender_addr;
915897
uip_ipaddr_t dao_parent_addr;
916898
rpl_dag_t *dag;
917-
rpl_instance_t *instance;
918899
unsigned char *buffer;
919900
uint16_t sequence;
920-
uint8_t instance_id;
921901
uint8_t lifetime;
922902
uint8_t prefixlen;
923903
uint8_t flags;
@@ -936,9 +916,8 @@ dao_input_nonstoring(void)
936916
buffer = UIP_ICMP_PAYLOAD;
937917
buffer_length = uip_len - uip_l3_icmp_hdr_len;
938918

939-
pos = 0;
940-
instance_id = buffer[pos++];
941-
instance = rpl_get_instance(instance_id);
919+
/* Position 0 is the instance id that already been handled */
920+
pos = 1;
942921
lifetime = instance->default_lifetime;
943922

944923
flags = buffer[pos++];
@@ -1031,9 +1010,9 @@ dao_input(void)
10311010
}
10321011

10331012
if(RPL_IS_STORING(instance)) {
1034-
dao_input_storing();
1013+
dao_input_storing(instance);
10351014
} else if(RPL_IS_NON_STORING(instance)) {
1036-
dao_input_nonstoring();
1015+
dao_input_nonstoring(instance);
10371016
}
10381017

10391018
discard:

0 commit comments

Comments
 (0)