commit
af556985a8
|
@ -104,3 +104,4 @@ env:
|
|||
- BUILD_TYPE='ipv6' BUILD_CATEGORY='sim'
|
||||
- BUILD_TYPE='base' BUILD_CATEGORY='sim'
|
||||
- BUILD_TYPE='ieee802154' BUILD_CATEGORY='sim'
|
||||
- BUILD_TYPE='6tisch' BUILD_CATEGORY='sim'
|
||||
|
|
|
@ -6,15 +6,14 @@
|
|||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/radiologger-headless</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>0.0</transmitting_range>
|
||||
<interference_range>0.0</interference_range>
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
|
@ -23,63 +22,10 @@
|
|||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype713</identifier>
|
||||
<description>default</description>
|
||||
<source>[CONFIG_DIR]/code/test-tsch-packet.c</source>
|
||||
<commands>make TARGET=cooja clean
|
||||
make TEST_CONFIG_TYPE=DEFAULT test-tsch-packet.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype740</identifier>
|
||||
<description>security on</description>
|
||||
<source>[CONFIG_DIR]/code/test-tsch-packet.c</source>
|
||||
<commands>make TARGET=cooja clean
|
||||
make TEST_CONFIG_TYPE=SECURITY_ON test-tsch-packet.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype399</identifier>
|
||||
<description>all enabled</description>
|
||||
<source>[CONFIG_DIR]/code/test-tsch-packet.c</source>
|
||||
<commands>make TARGET=cooja clean
|
||||
make TEST_CONFIG_TYPE=ALL_ENABLED test-tsch-packet.cooja TARGET=cooja</commands>
|
||||
<identifier>mtype639</identifier>
|
||||
<description>6P node</description>
|
||||
<source>[CONTIKI_DIR]/examples/6tisch/6p-packet/sixp-node.c</source>
|
||||
<commands>make sixp-node.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
|
@ -102,8 +48,8 @@
|
|||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>-49.23869609407765</x>
|
||||
<y>-36.33693008116223</y>
|
||||
<x>-65.17052901237824</x>
|
||||
<y>35.68868314082581</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -118,13 +64,13 @@
|
|||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype713</motetype_identifier>
|
||||
<motetype_identifier>mtype639</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>-17.772442808950224</x>
|
||||
<y>-36.862574776701464</y>
|
||||
<x>-31.58320760838481</x>
|
||||
<y>36.12872091616695</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -139,34 +85,13 @@
|
|||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype740</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>14.488632230762605</x>
|
||||
<y>-35.15143001217301</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype399</motetype_identifier>
|
||||
<motetype_identifier>mtype639</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>2</z>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
|
@ -177,26 +102,88 @@
|
|||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.AttributeVisualizerSkin</skin>
|
||||
<viewport>3.714690054486387 0.0 0.0 3.714690054486387 248.5428583129116 318.25485368648356</viewport>
|
||||
<viewport>2.463050617589194 0.0 0.0 2.463050617589194 316.15467536891634 50.055049291885666</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>0</z>
|
||||
<z>5</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>7</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>837</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>6</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONFIG_DIR]/js/02-tsch-packet-create.js</scriptfile>
|
||||
<script>TIMEOUT(100000, log.testOK());
|
||||
|
||||
while(true) {
|
||||
YIELD();
|
||||
log.log(time + " " + "node-" + id + " "+ msg + "\n");
|
||||
}</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>1</z>
|
||||
<height>525</height>
|
||||
<location_x>185</location_x>
|
||||
<location_y>162</location_y>
|
||||
<width>600</width>
|
||||
<z>2</z>
|
||||
<height>700</height>
|
||||
<location_x>710</location_x>
|
||||
<location_y>30</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>4</z>
|
||||
<height>300</height>
|
||||
<location_x>472</location_x>
|
||||
<location_y>426</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
CONTIKI_PROJECT = sixp-node.c
|
||||
PROJECT_SOURCEFILES += test-sf.c
|
||||
|
||||
CONTIKI = ../../../
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
MODULES += os/net/mac/tsch os/net/mac/tsch/sixtop
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
|
@ -0,0 +1,4 @@
|
|||
6P Packet Examples
|
||||
==================
|
||||
|
||||
You can generate a pcap file having 6P packets with `6p-packet.csc`.
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
|
||||
#define CONTIKI_WITH_RPL 0
|
||||
#undef UIP_CONF_IPV6_RPL
|
||||
#define UIP_CONF_IPV6_RPL 0
|
||||
#define UIP_CONF_ND6_SEND_RA 0
|
||||
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#define COOJA_CONF_SIMULATE_TURNAROUND 0
|
||||
#else
|
||||
#error "This example is intended to be used for Cooja mote."
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
|
||||
#define NETSTACK_CONF_MAC tschmac_driver
|
||||
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
#define TSCH_LOG_CONF_LEVEL 2
|
||||
#define TSCH_CONF_AUTOSTART 1
|
||||
#define TSCH_CONF_DEFAULT_HOPPING_SEQUENCE TSCH_HOPPING_SEQUENCE_1_1
|
||||
|
||||
#endif /* _PROJECT_CONF_H_ */
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <contiki.h>
|
||||
#include <lib/assert.h>
|
||||
#include <sys/node-id.h>
|
||||
#include <net/mac/tsch/tsch.h>
|
||||
#include <net/mac/tsch/tsch-queue.h>
|
||||
#include <net/mac/tsch/sixtop/sixtop.h>
|
||||
|
||||
extern const sixtop_sf_t test_sf;
|
||||
extern int test_sf_start(const linkaddr_t *addr);
|
||||
|
||||
PROCESS(sixp_node_process, "6P node");
|
||||
AUTOSTART_PROCESSES(&sixp_node_process);
|
||||
|
||||
#define COORDINATOR_NODE_ID 1
|
||||
|
||||
PROCESS_THREAD(sixp_node_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
sixtop_add_sf(&test_sf);
|
||||
|
||||
if(node_id == COORDINATOR_NODE_ID) {
|
||||
tsch_set_coordinator(1);
|
||||
assert(test_sf_start(NULL) == 0);
|
||||
} else {
|
||||
static struct etimer et;
|
||||
struct tsch_neighbor *peer;
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
while(tsch_is_associated == 0) {
|
||||
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
||||
etimer_reset(&et);
|
||||
}
|
||||
peer = tsch_queue_get_time_source();
|
||||
assert(test_sf_start((const linkaddr_t *)&peer->addr) == 0);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
|
@ -0,0 +1,784 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <contiki.h>
|
||||
#include <lib/assert.h>
|
||||
#include <net/mac/tsch/tsch-queue.h>
|
||||
#include <net/mac/tsch/sixtop/sixtop.h>
|
||||
#include <net/mac/tsch/sixtop/sixp.h>
|
||||
#include <net/mac/tsch/sixtop/sixp-nbr.h>
|
||||
#include <net/mac/tsch/sixtop/sixp-trans.h>
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include <net/net-debug.h>
|
||||
|
||||
#define SIXP_PKT_BUFLEN 128
|
||||
static uint8_t sixp_pkt_buf[SIXP_PKT_BUFLEN];
|
||||
|
||||
#define TEST_SF_SFID 0x80
|
||||
#define TEST_SF_TIMEOUT CLOCK_SECOND
|
||||
|
||||
PROCESS(test_sf_process, "test-sf initiator process");
|
||||
static linkaddr_t peer_addr;
|
||||
static process_event_t test_sf_trans_done;
|
||||
static enum { TEST_SF_MODE_INITIATOR, TEST_SF_MODE_RESPONDER } test_sf_mode;
|
||||
static int test_index = 0;
|
||||
|
||||
static const sixp_pkt_metadata_t sample_metadata = 0xcafe;
|
||||
static const uint32_t sample_cell_list1[] = { 0xdeadbeef,
|
||||
0xcafebabe,
|
||||
0xbaadf00d };
|
||||
static const uint32_t sample_cell_list2[] = { 0xbaadcafe,
|
||||
0xfacefeed,
|
||||
0xbadcab1e };
|
||||
|
||||
static void test_add_2_step(const linkaddr_t *peer_addr);
|
||||
static void test_add_3_step(const linkaddr_t *peer_addr);
|
||||
static void test_delete_2_step(const linkaddr_t *peer_addr);
|
||||
static void test_delete_3_step(const linkaddr_t *peer_addr);
|
||||
static void test_relocate_2_step(const linkaddr_t *peer_addr);
|
||||
static void test_count_2_step(const linkaddr_t *peer_addr);
|
||||
static void test_list_2_step(const linkaddr_t *peer_addr);
|
||||
static void test_list_2_step_eol(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_success(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_error(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_eol(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_reset(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_version(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_sfid(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_gen(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_busy(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_nores(const linkaddr_t *peer_addr);
|
||||
static void test_clear_2_step_celllist(const linkaddr_t *peer_addr);
|
||||
|
||||
typedef void (*test_func)(const linkaddr_t *peer_addr);
|
||||
static const test_func test_case[] = {
|
||||
test_add_2_step,
|
||||
test_add_3_step,
|
||||
test_delete_2_step,
|
||||
test_delete_3_step,
|
||||
test_relocate_2_step,
|
||||
test_count_2_step,
|
||||
test_list_2_step,
|
||||
test_list_2_step_eol,
|
||||
test_clear_2_step_success,
|
||||
test_clear_2_step_error,
|
||||
test_clear_2_step_eol,
|
||||
test_clear_2_step_reset,
|
||||
test_clear_2_step_version,
|
||||
test_clear_2_step_sfid,
|
||||
test_clear_2_step_gen,
|
||||
test_clear_2_step_busy,
|
||||
test_clear_2_step_nores,
|
||||
test_clear_2_step_celllist,
|
||||
};
|
||||
|
||||
static void
|
||||
advance_gen(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
nbr = sixp_nbr_find(peer_addr);
|
||||
assert(nbr != NULL);
|
||||
assert(sixp_nbr_advance_gen(nbr) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
set_peer_addr(const linkaddr_t *addr)
|
||||
{
|
||||
peer_addr = *addr;
|
||||
PRINTF("test-sf: set peer addr: ");
|
||||
PRINTLLADDR((const uip_lladdr_t *)&peer_addr);
|
||||
PRINTF("\n");
|
||||
}
|
||||
|
||||
int
|
||||
test_sf_start(const linkaddr_t *addr)
|
||||
{
|
||||
if(addr == NULL) {
|
||||
test_sf_mode = TEST_SF_MODE_RESPONDER;
|
||||
} else {
|
||||
test_sf_mode = TEST_SF_MODE_INITIATOR;
|
||||
set_peer_addr(addr);
|
||||
test_sf_trans_done = process_alloc_event();
|
||||
process_start(&test_sf_process, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *src_addr)
|
||||
{
|
||||
if(test_index < (sizeof(test_case) / sizeof(test_func))) {
|
||||
test_case[test_index](src_addr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
timeout(sixp_pkt_cmd_t cmd, const linkaddr_t *peer_addr)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_add_2_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
1,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t) +
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sample_cell_list1),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(uint32_t), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
advance_gen(peer_addr);
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
advance_gen(peer_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_add_3_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
1,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t) +
|
||||
sizeof(sixp_pkt_metadata_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
} else if (state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(uint32_t), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
advance_gen(peer_addr);
|
||||
} else if (state == SIXP_TRANS_STATE_CONFIRMATION_RECEIVED){
|
||||
test_index++;
|
||||
advance_gen(peer_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_delete_2_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
1,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t) +
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sample_cell_list1),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(uint32_t), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
advance_gen(peer_addr);
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
advance_gen(peer_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_delete_3_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
1,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t) +
|
||||
sizeof(sixp_pkt_metadata_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
} else if (state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(uint32_t), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
advance_gen(peer_addr);
|
||||
} else if (state == SIXP_TRANS_STATE_CONFIRMATION_RECEIVED) {
|
||||
test_index++;
|
||||
advance_gen(peer_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_relocate_2_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(
|
||||
sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
3,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
(const uint8_t *)sample_cell_list2,
|
||||
sizeof(sample_cell_list2), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t) +
|
||||
sizeof(sample_cell_list1) +
|
||||
sizeof(sample_cell_list2),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list2,
|
||||
sizeof(uint32_t), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
advance_gen(peer_addr);
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
advance_gen(peer_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_count_2_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(
|
||||
sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_RX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sixp_pkt_cell_options_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
0xf0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_total_num_cells_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_list_2_step(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(
|
||||
sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_RX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(
|
||||
sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
0x0f,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
0xf0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_reserved_t) +
|
||||
sizeof(sixp_pkt_offset_t) +
|
||||
sizeof(sixp_pkt_max_num_cells_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(const uint8_t *)sample_cell_list2,
|
||||
sizeof(sample_cell_list2),
|
||||
sizeof(sample_cell_list1),
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sample_cell_list1) + sizeof(sample_cell_list2),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_list_2_step_eol(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(
|
||||
sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
SIXP_PKT_CELL_OPTION_TX |
|
||||
SIXP_PKT_CELL_OPTION_RX |
|
||||
SIXP_PKT_CELL_OPTION_SHARED,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(
|
||||
sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
0x0f,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
0xf0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_reserved_t) +
|
||||
sizeof(sixp_pkt_offset_t) +
|
||||
sizeof(sixp_pkt_max_num_cells_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL,
|
||||
(const uint8_t *)sample_cell_list1,
|
||||
sizeof(sample_cell_list1), 0,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
assert(
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL,
|
||||
(const uint8_t *)sample_cell_list2,
|
||||
sizeof(sample_cell_list2),
|
||||
sizeof(sample_cell_list1),
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sample_cell_list1) + sizeof(sample_cell_list2),
|
||||
peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step(const linkaddr_t *peer_addr, sixp_pkt_rc_t rc)
|
||||
{
|
||||
sixp_trans_t *trans = sixp_trans_find(peer_addr);
|
||||
|
||||
if(trans == NULL) {
|
||||
memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf));
|
||||
assert(
|
||||
sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR,
|
||||
sample_metadata,
|
||||
sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0);
|
||||
|
||||
assert(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR,
|
||||
TEST_SF_SFID, sixp_pkt_buf,
|
||||
sizeof(sixp_pkt_metadata_t),
|
||||
peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
} else {
|
||||
sixp_trans_state_t state;
|
||||
state = sixp_trans_get_state(trans);
|
||||
if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)rc,
|
||||
TEST_SF_SFID, NULL, 0, peer_addr,
|
||||
NULL, NULL, 0);
|
||||
test_index++;
|
||||
} else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
process_post(&test_sf_process, test_sf_trans_done, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_success(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_error(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_eol(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_EOL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_reset(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_RESET);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_version(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_VERSION);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_sfid(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_SFID);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_gen(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_GEN);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_busy(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_BUSY);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_nores(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_NORES);
|
||||
}
|
||||
|
||||
static void
|
||||
test_clear_2_step_celllist(const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_clear_2_step(peer_addr, SIXP_PKT_RC_CELLLIST);
|
||||
}
|
||||
|
||||
PROCESS_THREAD(test_sf_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
if(test_index == (sizeof(test_case) / sizeof(test_func))) {
|
||||
break;
|
||||
} else {
|
||||
test_case[test_index]((const linkaddr_t *)&peer_addr);
|
||||
}
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == test_sf_trans_done);
|
||||
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
||||
etimer_reset(&et);
|
||||
test_index++;
|
||||
}
|
||||
PRINTF("done\n");
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
const sixtop_sf_t test_sf = {
|
||||
TEST_SF_SFID,
|
||||
TEST_SF_TIMEOUT,
|
||||
init,
|
||||
input,
|
||||
timeout
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
CONTIKI_PROJECT = node-sixtop
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
PROJECT_SOURCEFILES += sf-simple.c
|
||||
CONTIKI=../../..
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
CONTIKI_WITH_IPV6 = 1
|
||||
MAKE_WITH_SECURITY ?= 0 # force Security from command line
|
||||
|
||||
MODULES += os/net/mac/tsch
|
||||
MODULES += os/net/mac/tsch/sixtop
|
||||
|
||||
ifeq ($(MAKE_WITH_SECURITY),1)
|
||||
CFLAGS += -DWITH_SECURITY=1
|
||||
endif
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
|
@ -0,0 +1,39 @@
|
|||
6top Example Description
|
||||
------------------------
|
||||
|
||||
A RPL+TSCH node will act as basic node by default, but can be configured at startup
|
||||
using the user button and following instructions from the log output. Every press
|
||||
of a button toggles the mode as 6ln, 6dr or 6dr-sec (detailled next). After 10s with
|
||||
no button press, the node starts in the last setting.
|
||||
|
||||
The modes are:
|
||||
|
||||
* 6ln (default): 6lowpan node, will join a RPL+TSCH network and act as router.
|
||||
* 6dr: 6lowpan DAG Root, will start its own RPL+TSCH network. Note this is not a
|
||||
border router, i.e. it does not have a serial interface with connection to
|
||||
the Internet. For a border router, see ../border-router.
|
||||
* 6dr-sec: 6lowpan DAG Root, starting a RPL+TSCH network with link-layer security
|
||||
enabled. 6ln nodes are able to join both non-secured or secured networks.
|
||||
|
||||
|
||||
6top Operation
|
||||
---------------
|
||||
|
||||
If the mode is 6ln (node)
|
||||
|
||||
* The application triggers a 6P Add Request to 6dr (neighbor)
|
||||
* Following this the application triggers another 6P Add Request to 6dr
|
||||
* After an interval, the application triggers a 6P Delete Request to 6dr
|
||||
|
||||
For the Cooja simulation, you may use the rpl-tsch-sixtop-z1.csc file in this folder.
|
||||
Once you run the simulation, "Mote output" window of Cooja simulator displays the
|
||||
following messages.
|
||||
|
||||
For a 6P Add transaction,
|
||||
ID:1 TSCH-sixtop: Sixtop IE received
|
||||
ID:1 TSCH-sixtop: Send Link Response to node 2
|
||||
ID:2 TSCH-sixtop: Sixtop IE received
|
||||
ID:2 TSCH-sixtop: Schedule link x as RX with node 2
|
||||
ID:2 TSCH-sixtop: Schedule link x as TX with node 1
|
||||
|
||||
Similarly for a 6P Delete transaction.
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (c) 2015, SICS Swedish ICT.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* To test 6P transaction on a RPL+TSCH network
|
||||
*
|
||||
* \author
|
||||
* Simon Duquennoy <simonduq@sics.se>
|
||||
* Shalu R <shalur@cdac.in>
|
||||
* Lijo Thomas <lijo@cdac.in>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "node-id.h"
|
||||
#include "net/rpl/rpl.h"
|
||||
#include "net/ipv6/uip-ds6-route.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
#include "net/rpl/rpl-private.h"
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
#include "sf-simple.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(node_process, "RPL Node");
|
||||
AUTOSTART_PROCESSES(&node_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
net_init(uip_ipaddr_t *br_prefix)
|
||||
{
|
||||
uip_ipaddr_t global_ipaddr;
|
||||
|
||||
if(br_prefix) { /* We are RPL root. Will be set automatically
|
||||
as TSCH pan coordinator via the tsch-rpl module */
|
||||
memcpy(&global_ipaddr, br_prefix, 16);
|
||||
uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
|
||||
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
|
||||
rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
|
||||
rpl_set_prefix(rpl_get_any_dag(), br_prefix, 64);
|
||||
rpl_repair_root(RPL_DEFAULT_INSTANCE);
|
||||
}
|
||||
|
||||
NETSTACK_MAC.on();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(node_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
struct tsch_neighbor *n;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* 3 possible roles:
|
||||
* - role_6ln: simple node, will join any network, secured or not
|
||||
* - role_6dr: DAG root, will advertise (unsecured) beacons
|
||||
* - role_6dr_sec: DAG root, will advertise secured beacons
|
||||
* */
|
||||
static int is_coordinator = 0, added_num_of_links = 0;
|
||||
static enum { role_6ln, role_6dr, role_6dr_sec } node_role;
|
||||
node_role = role_6ln;
|
||||
|
||||
/* Set node with MAC address c1:0c:00:00:00:00:01 as coordinator,
|
||||
* convenient in cooja for regression tests using z1 nodes
|
||||
* */
|
||||
|
||||
#ifdef CONTIKI_TARGET_Z1
|
||||
extern unsigned char node_mac[8];
|
||||
unsigned char coordinator_mac[8] = { 0xc1, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
|
||||
|
||||
if(memcmp(node_mac, coordinator_mac, 8) == 0) {
|
||||
if(LLSEC802154_ENABLED) {
|
||||
node_role = role_6dr_sec;
|
||||
} else {
|
||||
node_role = role_6dr;
|
||||
}
|
||||
} else {
|
||||
node_role = role_6ln;
|
||||
}
|
||||
#endif
|
||||
|
||||
tsch_set_pan_secured(LLSEC802154_ENABLED && (node_role == role_6dr_sec));
|
||||
is_coordinator = node_role > role_6ln;
|
||||
sixtop_add_sf(&sf_simple_driver);
|
||||
|
||||
if(is_coordinator) {
|
||||
uip_ipaddr_t prefix;
|
||||
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
|
||||
net_init(&prefix);
|
||||
} else {
|
||||
net_init(NULL);
|
||||
}
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND * 30);
|
||||
while(1) {
|
||||
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
||||
etimer_reset(&et);
|
||||
|
||||
/* Get time-source neighbor */
|
||||
n = tsch_queue_get_time_source();
|
||||
|
||||
if(node_id != 1) {
|
||||
clock_delay(1000);
|
||||
if((added_num_of_links == 1) || (added_num_of_links == 3)) {
|
||||
printf("App : Add a link\n");
|
||||
sf_simple_add_links(&n->addr, 1);
|
||||
} else if(added_num_of_links == 5) {
|
||||
printf("App : Delete a link\n");
|
||||
sf_simple_remove_links(&n->addr);
|
||||
}
|
||||
added_num_of_links++;
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright (c) 2015, SICS Swedish ICT.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PROJECT_CONF_H__
|
||||
#define __PROJECT_CONF_H__
|
||||
|
||||
/* Set to enable TSCH security */
|
||||
#ifndef WITH_SECURITY
|
||||
#define WITH_SECURITY 0
|
||||
#endif /* WITH_SECURITY */
|
||||
|
||||
/*******************************************************/
|
||||
/********* Enable RPL non-storing mode *****************/
|
||||
/*******************************************************/
|
||||
|
||||
#undef UIP_CONF_MAX_ROUTES
|
||||
#define UIP_CONF_MAX_ROUTES 0 /* No need for routes */
|
||||
#undef RPL_CONF_MOP
|
||||
#define RPL_CONF_MOP RPL_MOP_NON_STORING /* Mode of operation*/
|
||||
#undef ORCHESTRA_CONF_RULES
|
||||
#define ORCHESTRA_CONF_RULES { &eb_per_time_source, &unicast_per_neighbor_rpl_ns, &default_common } /* Orchestra in non-storing */
|
||||
|
||||
/*******************************************************/
|
||||
/********************* Enable TSCH *********************/
|
||||
/*******************************************************/
|
||||
|
||||
/* Netstack layers */
|
||||
#undef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC tschmac_driver
|
||||
#undef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC nordc_driver
|
||||
#undef NETSTACK_CONF_FRAMER
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
/* IEEE802.15.4 frame version */
|
||||
#undef FRAME802154_CONF_VERSION
|
||||
#define FRAME802154_CONF_VERSION FRAME802154_IEEE802154_2015
|
||||
|
||||
/* TSCH and RPL callbacks */
|
||||
#define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch
|
||||
#define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval
|
||||
#define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network
|
||||
#define TSCH_CALLBACK_LEAVING_NETWORK tsch_rpl_callback_leaving_network
|
||||
|
||||
/* Needed for CC2538 platforms only */
|
||||
/* For TSCH we have to use the more accurate crystal oscillator
|
||||
* by default the RC oscillator is activated */
|
||||
#undef SYS_CTRL_CONF_OSC32K_USE_XTAL
|
||||
#define SYS_CTRL_CONF_OSC32K_USE_XTAL 1
|
||||
|
||||
/* Needed for cc2420 platforms only */
|
||||
/* Disable DCO calibration (uses timerB) */
|
||||
#undef DCOSYNCH_CONF_ENABLED
|
||||
#define DCOSYNCH_CONF_ENABLED 0
|
||||
/* Enable SFD timestamps (uses timerB) */
|
||||
#undef CC2420_CONF_SFD_TIMESTAMPS
|
||||
#define CC2420_CONF_SFD_TIMESTAMPS 1
|
||||
|
||||
/* Enable Sixtop Implementation */
|
||||
#undef TSCH_CONF_WITH_SIXTOP
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
|
||||
/*******************************************************/
|
||||
/******************* Configure TSCH ********************/
|
||||
/*******************************************************/
|
||||
|
||||
/* TSCH logging. */
|
||||
#undef TSCH_LOG_CONF_PER_SLOT
|
||||
#define TSCH_LOG_CONF_PER_SLOT 1
|
||||
|
||||
/* IEEE802.15.4 PANID */
|
||||
#undef IEEE802154_CONF_PANID
|
||||
#define IEEE802154_CONF_PANID 0xabcd
|
||||
|
||||
/* Do not start TSCH at init, wait for NETSTACK_MAC.on() */
|
||||
#undef TSCH_CONF_AUTOSTART
|
||||
#define TSCH_CONF_AUTOSTART 0
|
||||
|
||||
/* 6TiSCH schedule length */
|
||||
#undef TSCH_SCHEDULE_CONF_DEFAULT_LENGTH
|
||||
#define TSCH_SCHEDULE_CONF_DEFAULT_LENGTH 11
|
||||
|
||||
#if WITH_SECURITY
|
||||
|
||||
/* Enable security */
|
||||
#undef LLSEC802154_CONF_ENABLED
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
/* TSCH uses explicit keys to identify k1 and k2 */
|
||||
#undef LLSEC802154_CONF_USES_EXPLICIT_KEYS
|
||||
#define LLSEC802154_CONF_USES_EXPLICIT_KEYS 1
|
||||
/* TSCH uses the ASN rather than frame counter to construct the Nonce */
|
||||
#undef LLSEC802154_CONF_USES_FRAME_COUNTER
|
||||
#define LLSEC802154_CONF_USES_FRAME_COUNTER 0
|
||||
|
||||
#endif /* WITH_SECURITY */
|
||||
|
||||
/*******************************************************/
|
||||
/************* Other system configuration **************/
|
||||
/*******************************************************/
|
||||
|
||||
#if CONTIKI_TARGET_Z1
|
||||
/* Save some space to fit the limited RAM of the z1 */
|
||||
#undef UIP_CONF_TCP
|
||||
#define UIP_CONF_TCP 0
|
||||
#undef QUEUEBUF_CONF_NUM
|
||||
#define QUEUEBUF_CONF_NUM 2
|
||||
#undef RPL_NS_CONF_LINK_NUM
|
||||
#define RPL_NS_CONF_LINK_NUM 2
|
||||
#undef NBR_TABLE_CONF_MAX_NEIGHBORS
|
||||
#define NBR_TABLE_CONF_MAX_NEIGHBORS 2
|
||||
#undef UIP_CONF_ND6_SEND_NA
|
||||
#define UIP_CONF_ND6_SEND_NA 0
|
||||
#undef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 0
|
||||
|
||||
#if WITH_SECURITY
|
||||
/* Note: on sky or z1 in cooja, crypto operations are done in S/W and
|
||||
* cannot be accommodated in normal slots. Use 65ms slots instead, and
|
||||
* a very short 6TiSCH minimal schedule length */
|
||||
#undef TSCH_CONF_DEFAULT_TIMESLOT_LENGTH
|
||||
#define TSCH_CONF_DEFAULT_TIMESLOT_LENGTH 65000
|
||||
#undef TSCH_SCHEDULE_CONF_DEFAULT_LENGTH
|
||||
#define TSCH_SCHEDULE_CONF_DEFAULT_LENGTH 2
|
||||
/* Reduce log level to make space for security on z1 */
|
||||
#undef TSCH_LOG_CONF_LEVEL
|
||||
#define TSCH_LOG_CONF_LEVEL 0
|
||||
#endif /* WITH_SECURITY */
|
||||
|
||||
#endif /* CONTIKI_TARGET_Z1 */
|
||||
|
||||
#if CONTIKI_TARGET_CC2538DK || CONTIKI_TARGET_ZOUL || \
|
||||
CONTIKI_TARGET_OPENMOTE_CC2538
|
||||
#define TSCH_CONF_HW_FRAME_FILTERING 0
|
||||
#endif /* CONTIKI_TARGET_CC2538DK || CONTIKI_TARGET_ZOUL \
|
||||
|| CONTIKI_TARGET_OPENMOTE_CC2538 */
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
|
@ -0,0 +1,160 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.mspmote.Z1MoteType
|
||||
<identifier>z11</identifier>
|
||||
<description>Z1 Mote Type #z11</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-tsch-sixtop/node-sixtop.c</source>
|
||||
<commands EXPORT="discard">make node-sixtop.z1 TARGET=z1</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-tsch-sixtop/node-sixtop.z1</firmware>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDefaultSerial</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>3.827476552301217</x>
|
||||
<y>2.167129170680247</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspClock
|
||||
<deviation>1.0</deviation>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>z11</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>30.278379737463556</x>
|
||||
<y>17.799585117738026</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspClock
|
||||
<deviation>1.0</deviation>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>z11</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>0</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>4.027583163598053 0.0 0.0 4.027583163598053 133.5292942712438 14.03198741893021</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>3</z>
|
||||
<height>160</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter>TSCH-sch</filter>
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>854</width>
|
||||
<z>1</z>
|
||||
<height>342</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>161</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1366</width>
|
||||
<z>5</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>503</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>686</width>
|
||||
<z>4</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
</plugin_config>
|
||||
<width>508</width>
|
||||
<z>2</z>
|
||||
<height>343</height>
|
||||
<location_x>854</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,621 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* Copyright (c) 2016, Centre for Development of Advanced Computing (C-DAC).
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* A 6P Simple Schedule Function
|
||||
* \author
|
||||
* Shalu R <shalur@cdac.in>
|
||||
* Lijo Thomas <lijo@cdac.in>
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "contiki-lib.h"
|
||||
|
||||
#include "lib/assert.h"
|
||||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
#include "net/mac/tsch/sixtop/sixp.h"
|
||||
#include "net/mac/tsch/sixtop/sixp-nbr.h"
|
||||
#include "net/mac/tsch/sixtop/sixp-pkt.h"
|
||||
#include "net/mac/tsch/sixtop/sixp-trans.h"
|
||||
|
||||
#include "sf-simple.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
|
||||
typedef struct {
|
||||
uint16_t timeslot_offset;
|
||||
uint16_t channel_offset;
|
||||
} sf_simple_cell_t;
|
||||
|
||||
static const uint16_t slotframe_handle = 0;
|
||||
static uint8_t res_storage[4 + SF_SIMPLE_MAX_LINKS * 4];
|
||||
static uint8_t req_storage[4 + SF_SIMPLE_MAX_LINKS * 4];
|
||||
|
||||
static void read_cell(const uint8_t *buf, sf_simple_cell_t *cell);
|
||||
static void print_cell_list(const uint8_t *cell_list, uint16_t cell_list_len);
|
||||
static void add_links_to_schedule(const linkaddr_t *peer_addr,
|
||||
uint8_t link_option,
|
||||
const uint8_t *cell_list,
|
||||
uint16_t cell_list_len);
|
||||
static void remove_links_to_schedule(const uint8_t *cell_list,
|
||||
uint16_t cell_list_len);
|
||||
static void add_response_sent_callback(void *arg, uint16_t arg_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_output_status_t status);
|
||||
static void delete_response_sent_callback(void *arg, uint16_t arg_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_output_status_t status);
|
||||
static void add_req_input(const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr);
|
||||
static void delete_req_input(const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr);
|
||||
static void input(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *src_addr);
|
||||
static void request_input(sixp_pkt_cmd_t cmd,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr);
|
||||
static void response_input(sixp_pkt_rc_t rc,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr);
|
||||
|
||||
/*
|
||||
* scheduling policy:
|
||||
* add: if and only if all the requested cells are available, accept the request
|
||||
* delete: if and only if all the requested cells are in use, accept the request
|
||||
*/
|
||||
|
||||
static void
|
||||
read_cell(const uint8_t *buf, sf_simple_cell_t *cell)
|
||||
{
|
||||
cell->timeslot_offset = buf[0] + (buf[1] << 8);
|
||||
cell->channel_offset = buf[2] + (buf[3] << 8);
|
||||
}
|
||||
|
||||
static void
|
||||
print_cell_list(const uint8_t *cell_list, uint16_t cell_list_len)
|
||||
{
|
||||
uint16_t i;
|
||||
sf_simple_cell_t cell;
|
||||
|
||||
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
|
||||
read_cell(&cell_list[i], &cell);
|
||||
PRINTF("%u ", cell.timeslot_offset);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_links_to_schedule(const linkaddr_t *peer_addr, uint8_t link_option,
|
||||
const uint8_t *cell_list, uint16_t cell_list_len)
|
||||
{
|
||||
/* add only the first valid cell */
|
||||
|
||||
sf_simple_cell_t cell;
|
||||
struct tsch_slotframe *slotframe;
|
||||
int i;
|
||||
|
||||
assert(cell_list != NULL);
|
||||
|
||||
slotframe = tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
|
||||
if(slotframe == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
|
||||
read_cell(&cell_list[i], &cell);
|
||||
if(cell.timeslot_offset == 0xffff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PRINTF("sf-simple: Schedule link %d as %s with node %u\n",
|
||||
cell.timeslot_offset,
|
||||
link_option == LINK_OPTION_RX ? "RX" : "TX",
|
||||
peer_addr->u8[7]);
|
||||
tsch_schedule_add_link(slotframe,
|
||||
link_option, LINK_TYPE_NORMAL, peer_addr,
|
||||
cell.timeslot_offset, cell.channel_offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_links_to_schedule(const uint8_t *cell_list, uint16_t cell_list_len)
|
||||
{
|
||||
/* remove all the cells */
|
||||
|
||||
sf_simple_cell_t cell;
|
||||
struct tsch_slotframe *slotframe;
|
||||
int i;
|
||||
|
||||
assert(cell_list != NULL);
|
||||
|
||||
slotframe = tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
|
||||
if(slotframe == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; i < (cell_list_len / sizeof(cell)); i++) {
|
||||
read_cell(&cell_list[i], &cell);
|
||||
if(cell.timeslot_offset == 0xffff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tsch_schedule_remove_link_by_timeslot(slotframe,
|
||||
cell.timeslot_offset);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_response_sent_callback(void *arg, uint16_t arg_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_output_status_t status)
|
||||
{
|
||||
uint8_t *body = (uint8_t *)arg;
|
||||
uint16_t body_len = arg_len;
|
||||
const uint8_t *cell_list;
|
||||
uint16_t cell_list_len;
|
||||
sixp_nbr_t *nbr;
|
||||
|
||||
assert(body != NULL && dest_addr != NULL);
|
||||
|
||||
if(status == SIXP_OUTPUT_STATUS_SUCCESS &&
|
||||
sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) == 0 &&
|
||||
(nbr = sixp_nbr_find(dest_addr)) != NULL) {
|
||||
add_links_to_schedule(dest_addr, LINK_OPTION_RX,
|
||||
cell_list, cell_list_len);
|
||||
sixp_nbr_advance_grx(nbr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
delete_response_sent_callback(void *arg, uint16_t arg_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_output_status_t status)
|
||||
{
|
||||
uint8_t *body = (uint8_t *)arg;
|
||||
uint16_t body_len = arg_len;
|
||||
const uint8_t *cell_list;
|
||||
uint16_t cell_list_len;
|
||||
sixp_nbr_t *nbr;
|
||||
|
||||
assert(body != NULL && dest_addr != NULL);
|
||||
|
||||
if(status == SIXP_OUTPUT_STATUS_SUCCESS &&
|
||||
sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) == 0 &&
|
||||
(nbr = sixp_nbr_find(dest_addr)) != NULL) {
|
||||
remove_links_to_schedule(cell_list, cell_list_len);
|
||||
sixp_nbr_advance_grx(nbr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_req_input(const uint8_t *body, uint16_t body_len, const linkaddr_t *peer_addr)
|
||||
{
|
||||
uint8_t i;
|
||||
sf_simple_cell_t cell;
|
||||
struct tsch_slotframe *slotframe;
|
||||
int feasible_link;
|
||||
uint8_t num_cells;
|
||||
const uint8_t *cell_list;
|
||||
uint16_t cell_list_len;
|
||||
uint16_t res_len;
|
||||
|
||||
assert(body != NULL && peer_addr != NULL);
|
||||
|
||||
if(sixp_pkt_get_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
&num_cells,
|
||||
body, body_len) != 0 ||
|
||||
sixp_pkt_get_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) != 0) {
|
||||
PRINTF("sf-simple: Parse error on add request\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTF("sf-simple: Received a 6P Add Request for %d links from node %d with LinkList : ",
|
||||
num_cells, peer_addr->u8[7]);
|
||||
print_cell_list(cell_list, cell_list_len);
|
||||
PRINTF("\n");
|
||||
|
||||
slotframe = tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
if(slotframe == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(num_cells > 0 && cell_list_len > 0) {
|
||||
memset(res_storage, 0, sizeof(res_storage));
|
||||
res_len = 0;
|
||||
|
||||
/* checking availability for requested slots */
|
||||
for(i = 0, feasible_link = 0;
|
||||
i < cell_list_len && feasible_link < num_cells;
|
||||
i += sizeof(cell)) {
|
||||
read_cell(&cell_list[i], &cell);
|
||||
if(tsch_schedule_get_link_by_timeslot(slotframe,
|
||||
cell.timeslot_offset) == NULL) {
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(uint8_t *)&cell, sizeof(cell),
|
||||
feasible_link,
|
||||
res_storage, sizeof(res_storage));
|
||||
res_len += sizeof(cell);
|
||||
feasible_link++;
|
||||
}
|
||||
}
|
||||
|
||||
if(feasible_link == num_cells) {
|
||||
/* Links are feasible. Create Link Response packet */
|
||||
PRINTF("sf-simple: Send a 6P Response to node %d\n", peer_addr->u8[7]);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
SF_SIMPLE_SFID,
|
||||
res_storage, res_len, peer_addr,
|
||||
add_response_sent_callback, res_storage, res_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
delete_req_input(const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr)
|
||||
{
|
||||
uint8_t i;
|
||||
sf_simple_cell_t cell;
|
||||
struct tsch_slotframe *slotframe;
|
||||
uint8_t num_cells;
|
||||
const uint8_t *cell_list;
|
||||
uint16_t cell_list_len;
|
||||
uint16_t res_len;
|
||||
int removed_link;
|
||||
|
||||
assert(body != NULL && peer_addr != NULL);
|
||||
|
||||
if(sixp_pkt_get_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
&num_cells,
|
||||
body, body_len) != 0 ||
|
||||
sixp_pkt_get_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) != 0) {
|
||||
PRINTF("sf-simple: Parse error on delete request\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTF("sf-simple: Received a 6P Delete Request for %d links from node %d with LinkList : ",
|
||||
num_cells, peer_addr->u8[7]);
|
||||
print_cell_list(cell_list, cell_list_len);
|
||||
PRINTF("\n");
|
||||
|
||||
slotframe = tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
if(slotframe == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(res_storage, 0, sizeof(res_storage));
|
||||
res_len = 0;
|
||||
|
||||
if(num_cells > 0 && cell_list_len > 0) {
|
||||
/* ensure before delete */
|
||||
for(i = 0, removed_link = 0; i < (cell_list_len / sizeof(cell)); i++) {
|
||||
read_cell(&cell_list[i], &cell);
|
||||
if(tsch_schedule_get_link_by_timeslot(slotframe,
|
||||
cell.timeslot_offset) != NULL) {
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
(uint8_t *)&cell, sizeof(cell),
|
||||
removed_link,
|
||||
res_storage, sizeof(res_storage));
|
||||
res_len += sizeof(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Links are feasible. Create Link Response packet */
|
||||
PRINTF("sf-simple: Send a 6P Response to node %d\n", peer_addr->u8[7]);
|
||||
sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
SF_SIMPLE_SFID,
|
||||
res_storage, res_len, peer_addr,
|
||||
delete_response_sent_callback, res_storage, res_len);
|
||||
}
|
||||
|
||||
static void
|
||||
input(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *body, uint16_t body_len, const linkaddr_t *src_addr)
|
||||
{
|
||||
assert(body != NULL && body != NULL);
|
||||
switch(type) {
|
||||
case SIXP_PKT_TYPE_REQUEST:
|
||||
request_input(code.cmd, body, body_len, src_addr);
|
||||
break;
|
||||
case SIXP_PKT_TYPE_RESPONSE:
|
||||
response_input(code.cmd, body, body_len, src_addr);
|
||||
break;
|
||||
default:
|
||||
/* unsupported */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
request_input(sixp_pkt_cmd_t cmd,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr)
|
||||
{
|
||||
assert(body != NULL && peer_addr != NULL);
|
||||
|
||||
switch(cmd) {
|
||||
case SIXP_PKT_CMD_ADD:
|
||||
add_req_input(body, body_len, peer_addr);
|
||||
break;
|
||||
case SIXP_PKT_CMD_DELETE:
|
||||
delete_req_input(body, body_len, peer_addr);
|
||||
break;
|
||||
default:
|
||||
/* unsupported request */
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void
|
||||
response_input(sixp_pkt_rc_t rc,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *peer_addr)
|
||||
{
|
||||
const uint8_t *cell_list;
|
||||
uint16_t cell_list_len;
|
||||
sixp_nbr_t *nbr;
|
||||
sixp_trans_t *trans;
|
||||
|
||||
assert(body != NULL && peer_addr != NULL);
|
||||
|
||||
if((nbr = sixp_nbr_find(peer_addr)) == NULL ||
|
||||
(trans = sixp_trans_find(peer_addr)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(rc == SIXP_PKT_RC_SUCCESS) {
|
||||
switch(sixp_trans_get_cmd(trans)) {
|
||||
case SIXP_PKT_CMD_ADD:
|
||||
if(sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) != 0) {
|
||||
PRINTF("sf-simple: Parse error on add response\n");
|
||||
return;
|
||||
}
|
||||
PRINTF("sf-simple: Received a 6P Add Response with LinkList : ");
|
||||
print_cell_list(cell_list, cell_list_len);
|
||||
PRINTF("\n");
|
||||
add_links_to_schedule(peer_addr, LINK_OPTION_TX,
|
||||
cell_list, cell_list_len);
|
||||
sixp_nbr_advance_gtx(nbr);
|
||||
break;
|
||||
case SIXP_PKT_CMD_DELETE:
|
||||
if(sixp_pkt_get_cell_list(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
&cell_list, &cell_list_len,
|
||||
body, body_len) != 0) {
|
||||
PRINTF("sf-simple: Parse error on add response\n");
|
||||
return;
|
||||
}
|
||||
PRINTF("sf-simple: Received a 6P Delete Response with LinkList : ");
|
||||
print_cell_list(cell_list, cell_list_len);
|
||||
PRINTF("\n");
|
||||
remove_links_to_schedule(cell_list, cell_list_len);
|
||||
sixp_nbr_advance_gtx(nbr);
|
||||
break;
|
||||
case SIXP_PKT_CMD_STATUS:
|
||||
case SIXP_PKT_CMD_LIST:
|
||||
case SIXP_PKT_CMD_CLEAR:
|
||||
default:
|
||||
PRINTF("sf-simple: unsupported response\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Initiates a Sixtop Link addition
|
||||
*/
|
||||
int
|
||||
sf_simple_add_links(linkaddr_t *peer_addr, uint8_t num_links)
|
||||
{
|
||||
uint8_t i = 0, index = 0;
|
||||
struct tsch_slotframe *sf =
|
||||
tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
|
||||
uint8_t req_len;
|
||||
sf_simple_cell_t cell_list[SF_SIMPLE_MAX_LINKS];
|
||||
|
||||
/* Flag to prevent repeated slots */
|
||||
uint8_t slot_check = 1;
|
||||
uint16_t random_slot = 0;
|
||||
|
||||
assert(peer_addr != NULL && sf != NULL);
|
||||
|
||||
do {
|
||||
/* Randomly select a slot offset within TSCH_SCHEDULE_DEFAULT_LENGTH */
|
||||
random_slot = ((random_rand() & 0xFF)) % TSCH_SCHEDULE_DEFAULT_LENGTH;
|
||||
|
||||
if(tsch_schedule_get_link_by_timeslot(sf, random_slot) == NULL) {
|
||||
|
||||
/* To prevent repeated slots */
|
||||
for(i = 0; i < index; i++) {
|
||||
if(cell_list[i].timeslot_offset != random_slot) {
|
||||
/* Random selection resulted in a free slot */
|
||||
if(i == index - 1) { /* Checked till last index of link list */
|
||||
slot_check = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Slot already present in CandidateLinkList */
|
||||
slot_check++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Random selection resulted in a free slot, add it to linklist */
|
||||
if(slot_check == 1) {
|
||||
cell_list[index].timeslot_offset = random_slot;
|
||||
cell_list[index].channel_offset = 0;
|
||||
|
||||
index++;
|
||||
slot_check++;
|
||||
} else if(slot_check > TSCH_SCHEDULE_DEFAULT_LENGTH) {
|
||||
PRINTF("sf-simple:! Number of trials for free slot exceeded...\n");
|
||||
return -1;
|
||||
break; /* exit while loop */
|
||||
}
|
||||
}
|
||||
} while(index < SF_SIMPLE_MAX_LINKS);
|
||||
|
||||
/* Create a Sixtop Add Request. Return 0 if Success */
|
||||
if(index == 0 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(req_storage, 0, sizeof(req_storage));
|
||||
if(sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
SIXP_PKT_CELL_OPTION_TX,
|
||||
req_storage,
|
||||
sizeof(req_storage)) != 0 ||
|
||||
sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
num_links,
|
||||
req_storage,
|
||||
sizeof(req_storage)) != 0 ||
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
(const uint8_t *)cell_list,
|
||||
index * sizeof(sf_simple_cell_t), 0,
|
||||
req_storage, sizeof(req_storage)) != 0) {
|
||||
PRINTF("sf-simple: Build error on add request\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The length of fixed part is 4 bytes: Metadata, CellOptions, and NumCells */
|
||||
req_len = 4 + index * sizeof(sf_simple_cell_t);
|
||||
sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
SF_SIMPLE_SFID,
|
||||
req_storage, req_len, peer_addr,
|
||||
NULL, NULL, 0);
|
||||
|
||||
PRINTF("sf-simple: Send a 6P Add Request for %d links to node %d with LinkList : ",
|
||||
num_links, peer_addr->u8[7]);
|
||||
print_cell_list((const uint8_t *)cell_list, index * sizeof(sf_simple_cell_t));
|
||||
PRINTF("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Initiates a Sixtop Link deletion
|
||||
*/
|
||||
int
|
||||
sf_simple_remove_links(linkaddr_t *peer_addr)
|
||||
{
|
||||
uint8_t i = 0, index = 0;
|
||||
struct tsch_slotframe *sf =
|
||||
tsch_schedule_get_slotframe_by_handle(slotframe_handle);
|
||||
struct tsch_link *l;
|
||||
|
||||
uint16_t req_len;
|
||||
sf_simple_cell_t cell;
|
||||
|
||||
assert(peer_addr != NULL && sf != NULL);
|
||||
|
||||
for(i = 0; i < TSCH_SCHEDULE_DEFAULT_LENGTH; i++) {
|
||||
l = tsch_schedule_get_link_by_timeslot(sf, i);
|
||||
|
||||
if(l) {
|
||||
/* Non-zero value indicates a scheduled link */
|
||||
if((linkaddr_cmp(&l->addr, peer_addr)) && (l->link_options == LINK_OPTION_TX)) {
|
||||
/* This link is scheduled as a TX link to the specified neighbor */
|
||||
cell.timeslot_offset = i;
|
||||
cell.channel_offset = l->channel_offset;
|
||||
index++;
|
||||
break; /* delete atmost one */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(index == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(req_storage, 0, sizeof(req_storage));
|
||||
if(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
1,
|
||||
req_storage,
|
||||
sizeof(req_storage)) != 0 ||
|
||||
sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
(const uint8_t *)&cell, sizeof(cell),
|
||||
0,
|
||||
req_storage, sizeof(req_storage)) != 0) {
|
||||
PRINTF("sf-simple: Build error on add request\n");
|
||||
return -1;
|
||||
}
|
||||
/* The length of fixed part is 4 bytes: Metadata, CellOptions, and NumCells */
|
||||
req_len = 4 + sizeof(sf_simple_cell_t);
|
||||
|
||||
sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE,
|
||||
SF_SIMPLE_SFID,
|
||||
req_storage, req_len, peer_addr,
|
||||
NULL, NULL, 0);
|
||||
|
||||
PRINTF("sf-simple: Send a 6P Delete Request for %d links to node %d with LinkList : ",
|
||||
1, peer_addr->u8[7]);
|
||||
print_cell_list((const uint8_t *)&cell, sizeof(cell));
|
||||
PRINTF("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const sixtop_sf_t sf_simple_driver = {
|
||||
SF_SIMPLE_SFID,
|
||||
CLOCK_SECOND,
|
||||
NULL,
|
||||
input,
|
||||
NULL
|
||||
};
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* Copyright (c) 2016, Centre for Development of Advanced Computing (C-DAC).
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* A 6P Simple Schedule Function
|
||||
* \author
|
||||
* Shalu R <shalur@cdac.in>
|
||||
* Lijo Thomas <lijo@cdac.in>
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef _SIXTOP_SF_SIMPLE_H_
|
||||
#define _SIXTOP_SF_SIMPLE_H_
|
||||
|
||||
#include "net/linkaddr.h"
|
||||
|
||||
int sf_simple_add_links(linkaddr_t *peer_addr, uint8_t num_links);
|
||||
int sf_simple_remove_links(linkaddr_t *peer_addr);
|
||||
|
||||
#define SF_SIMPLE_MAX_LINKS 3
|
||||
#define SF_SIMPLE_SFID 0xf0
|
||||
extern const sixtop_sf_t sf_simple_driver;
|
||||
|
||||
#endif /* !_SIXTOP_SF_SIMPLE_H_ */
|
|
@ -62,6 +62,7 @@ enum ieee802154e_header_ie_id {
|
|||
enum ieee802154e_payload_ie_id {
|
||||
PAYLOAD_IE_ESDU = 0,
|
||||
PAYLOAD_IE_MLME,
|
||||
PAYLOAD_IE_IETF = 0x5,
|
||||
PAYLOAD_IE_LIST_TERMINATION = 0xf,
|
||||
};
|
||||
|
||||
|
@ -81,6 +82,11 @@ enum ieee802154e_mlme_long_subie_id {
|
|||
MLME_LONG_IE_TSCH_CHANNEL_HOPPING_SEQUENCE = 0x9,
|
||||
};
|
||||
|
||||
#include <net/mac/tsch/sixtop/sixtop.h>
|
||||
enum ieee802154e_ietf_subie_id {
|
||||
IETF_IE_6TOP = SIXTOP_SUBIE_ID,
|
||||
};
|
||||
|
||||
#define WRITE16(buf, val) \
|
||||
do { ((uint8_t *)(buf))[0] = (val) & 0xff; \
|
||||
((uint8_t *)(buf))[1] = ((val) >> 8) & 0xff; } while(0);
|
||||
|
@ -194,6 +200,21 @@ frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,
|
|||
}
|
||||
}
|
||||
|
||||
#if TSCH_WITH_SIXTOP
|
||||
/* Payload IE. 6top. Used to nest sub-IEs */
|
||||
int
|
||||
frame80215e_create_ie_ietf(uint8_t *buf, int len, struct ieee802154_ies *ies)
|
||||
{
|
||||
if(len >= 2 && ies != NULL) {
|
||||
create_payload_ie_descriptor(buf,
|
||||
PAYLOAD_IE_IETF,
|
||||
ies->sixtop_ie_content_len);
|
||||
return 2 + ies->sixtop_ie_content_len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* TSCH_WITH_SIXTOP */
|
||||
|
||||
/* Payload IE. MLME. Used to nest sub-IEs */
|
||||
int
|
||||
frame80215e_create_ie_mlme(uint8_t *buf, int len,
|
||||
|
@ -531,6 +552,29 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
|
|||
len = 0; /* Reset len as we want to read subIEs and not jump over them */
|
||||
LOG_DBG("entering MLME ie with len %u\n", nested_mlme_len);
|
||||
break;
|
||||
#if TSCH_WITH_SIXTOP
|
||||
case PAYLOAD_IE_IETF:
|
||||
switch(*buf) {
|
||||
case IETF_IE_6TOP:
|
||||
/*
|
||||
* buf points to the Sub-ID field, a one-octet field, now;
|
||||
* advance it by one and use the result as the head pointer of
|
||||
* 6top IE Content.
|
||||
*/
|
||||
ies->sixtop_ie_content_ptr = buf + 1;
|
||||
/*
|
||||
* Similarly as above, subtract 1 (one octet) from len, which
|
||||
* includes the length of Sub-ID field, and use the result as
|
||||
* the length of 6top IE Content.
|
||||
*/
|
||||
ies->sixtop_ie_content_len = len - 1;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("frame802154e: unsupported IETF sub-IE %u\n", *buf);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif /* TSCH_WITH_SIXTOP */
|
||||
case PAYLOAD_IE_LIST_TERMINATION:
|
||||
LOG_DBG("payload ie list termination %u\n", len);
|
||||
return (len == 0) ? buf + len - start : -1;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "contiki.h"
|
||||
/* We need definitions from tsch-private.h for TSCH-specific information elements */
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/tsch-private.h"
|
||||
|
||||
#define FRAME802154E_IE_MAX_LINKS 4
|
||||
|
@ -80,6 +81,11 @@ struct ieee802154_ies {
|
|||
/* We include and parse only the sequence len and list and omit unused fields */
|
||||
uint16_t ie_hopping_sequence_len;
|
||||
uint8_t ie_hopping_sequence_list[TSCH_HOPPING_SEQUENCE_MAX_LEN];
|
||||
#if TSCH_WITH_SIXTOP
|
||||
/* Payload Sixtop IE */
|
||||
const uint8_t *sixtop_ie_content_ptr;
|
||||
uint16_t sixtop_ie_content_len;
|
||||
#endif /* TSCH_WITH_SIXTOP */
|
||||
};
|
||||
|
||||
/** Insert various Information Elements **/
|
||||
|
@ -97,6 +103,11 @@ int frame80215e_create_ie_header_list_termination_2(uint8_t *buf, int len,
|
|||
/* Payload IE. List termination */
|
||||
int frame80215e_create_ie_payload_list_termination(uint8_t *buf, int len,
|
||||
struct ieee802154_ies *ies);
|
||||
#if TSCH_WITH_SIXTOP
|
||||
/* Payload IE. 6top. Used to nest sub-IEs */
|
||||
int frame80215e_create_ie_ietf(uint8_t *buf, int len,
|
||||
struct ieee802154_ies *ies);
|
||||
#endif /* TSCH_WITH_SIXTOP */
|
||||
/* Payload IE. MLME. Used to nest sub-IEs */
|
||||
int frame80215e_create_ie_mlme(uint8_t *buf, int len,
|
||||
struct ieee802154_ies *ies);
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "lib/random.h"
|
||||
#include <string.h>
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "Frame 15.4"
|
||||
#define LOG_LEVEL LOG_LEVEL_FRAMER
|
||||
|
@ -58,7 +57,7 @@ static uint8_t initialized = 0;
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
create_frame(int type, int do_create)
|
||||
create_frame(int do_create)
|
||||
{
|
||||
frame802154_t params;
|
||||
int hdr_len;
|
||||
|
@ -75,93 +74,32 @@ create_frame(int type, int do_create)
|
|||
mac_dsn = random_rand() & 0xff;
|
||||
}
|
||||
|
||||
/* Build the FCF. */
|
||||
params.fcf.frame_type = packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
||||
params.fcf.frame_pending = 0;
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
params.fcf.ack_required = 0;
|
||||
/* Suppress seqno on broadcast if supported (frame v2 or more) */
|
||||
params.fcf.sequence_number_suppression = FRAME802154_VERSION >= FRAME802154_IEEE802154_2015;
|
||||
} else {
|
||||
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
|
||||
params.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
|
||||
}
|
||||
/* We do not compress PAN ID in outgoing frames, i.e. include one PAN ID (dest by default)
|
||||
* There is one exception, seemingly a typo in Table 2a: rows 2 and 3: when there is no
|
||||
* source nor destination address, we have dest PAN ID iff compression is *set*. */
|
||||
params.fcf.panid_compression = 0;
|
||||
|
||||
/* Insert IEEE 802.15.4 version bits. */
|
||||
params.fcf.frame_version = FRAME802154_VERSION;
|
||||
|
||||
#if LLSEC802154_USES_AUX_HEADER
|
||||
if(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL)) {
|
||||
params.fcf.security_enabled = 1;
|
||||
}
|
||||
/* Setting security-related attributes */
|
||||
params.aux_hdr.security_control.security_level = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL);
|
||||
params.aux_hdr.security_control.frame_counter_suppression = 1;
|
||||
params.aux_hdr.security_control.frame_counter_size = 1;
|
||||
#if LLSEC802154_USES_EXPLICIT_KEYS
|
||||
params.aux_hdr.security_control.key_id_mode = packetbuf_attr(PACKETBUF_ATTR_KEY_ID_MODE);
|
||||
params.aux_hdr.key_index = packetbuf_attr(PACKETBUF_ATTR_KEY_INDEX);
|
||||
params.aux_hdr.key_source.u16[0] = packetbuf_attr(PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1);
|
||||
#endif /* LLSEC802154_USES_EXPLICIT_KEYS */
|
||||
#endif /* LLSEC802154_USES_AUX_HEADER */
|
||||
|
||||
/* Increment and set the data sequence number. */
|
||||
if(!do_create) {
|
||||
/* Only length calculation - no sequence number is needed and
|
||||
should not be consumed. */
|
||||
|
||||
} else if(packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO)) {
|
||||
params.seq = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
|
||||
|
||||
} else {
|
||||
/* Ensure that the sequence number 0 is not used as it would bypass the above check. */
|
||||
/*
|
||||
* Before setting up "params", make sure we won't use 0 as the sequence number
|
||||
* of a newly created frame.
|
||||
*
|
||||
* The case when do_create is 0 is ignored since it's for only length
|
||||
* calculation. No sequence number is needed and should not be consumed.
|
||||
*/
|
||||
if(do_create != 0 && packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO) == 0) {
|
||||
if(mac_dsn == 0) {
|
||||
mac_dsn++;
|
||||
}
|
||||
params.seq = mac_dsn++;
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, params.seq);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, mac_dsn);
|
||||
mac_dsn++;
|
||||
}
|
||||
|
||||
/* Complete the addressing fields. */
|
||||
/**
|
||||
\todo For phase 1 the addresses are all long. We'll need a mechanism
|
||||
in the packetbuf attributes to tell the mac to use long or short for phase 2.
|
||||
*/
|
||||
if(LINKADDR_SIZE == 2) {
|
||||
/* Use short address mode if linkaddr size is short. */
|
||||
params.fcf.src_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
} else {
|
||||
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
|
||||
}
|
||||
params.dest_pid = frame802154_get_pan_id();
|
||||
framer_802154_setup_params(packetbuf_attr, packetbuf_holds_broadcast(),
|
||||
¶ms);
|
||||
|
||||
if(packetbuf_holds_broadcast()) {
|
||||
/* Broadcast requires short address mode. */
|
||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
params.dest_addr[0] = 0xFF;
|
||||
params.dest_addr[1] = 0xFF;
|
||||
} else {
|
||||
linkaddr_copy((linkaddr_t *)¶ms.dest_addr,
|
||||
packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
/* Use short address mode if linkaddr size is small */
|
||||
if(LINKADDR_SIZE == 2) {
|
||||
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
} else {
|
||||
params.fcf.dest_addr_mode = FRAME802154_LONGADDRMODE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the source PAN ID to the global variable. */
|
||||
params.src_pid = frame802154_get_pan_id();
|
||||
|
||||
/*
|
||||
* Set up the source address using only the long address mode for
|
||||
* phase 1.
|
||||
*/
|
||||
linkaddr_copy((linkaddr_t *)¶ms.src_addr,
|
||||
packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
|
||||
|
@ -174,27 +112,123 @@ create_frame(int type, int do_create)
|
|||
} else if(packetbuf_hdralloc(hdr_len)) {
|
||||
frame802154_create(¶ms, packetbuf_hdrptr());
|
||||
|
||||
LOG_INFO("Out: %2X", params.fcf.frame_type);
|
||||
LOG_INFO("15.4-OUT: %2X ", params.fcf.frame_type);
|
||||
LOG_INFO_LLADDR((const linkaddr_t *)params.dest_addr);
|
||||
LOG_INFO_("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
|
||||
LOG_INFO_(" %d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
|
||||
|
||||
return hdr_len;
|
||||
} else {
|
||||
LOG_ERR("Out: too large header: %u\n", hdr_len);
|
||||
LOG_ERR("15.4-OUT: too large header: %u\n", hdr_len);
|
||||
return FRAMER_FAILED;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
framer_802154_setup_params(packetbuf_attr_t (*get_attr)(uint8_t type),
|
||||
uint8_t dest_is_broadcast, frame802154_t *params)
|
||||
{
|
||||
if(get_attr == NULL || params == NULL) {
|
||||
LOG_INFO("framer-802154: cannot setup params because of invalid argument\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't initialize params with 0 because a caller may have already set
|
||||
* something to it
|
||||
*/
|
||||
|
||||
/* Build the FCF. */
|
||||
params->fcf.frame_type = get_attr(PACKETBUF_ATTR_FRAME_TYPE);
|
||||
params->fcf.frame_pending = 0;
|
||||
if(dest_is_broadcast) {
|
||||
params->fcf.ack_required = 0;
|
||||
/* Suppress seqno on broadcast if supported (frame v2 or more) */
|
||||
params->fcf.sequence_number_suppression = FRAME802154_VERSION >= FRAME802154_IEEE802154_2015;
|
||||
} else {
|
||||
params->fcf.ack_required = get_attr(PACKETBUF_ATTR_MAC_ACK);
|
||||
params->fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
|
||||
}
|
||||
|
||||
/* Set IE Present bit */
|
||||
params->fcf.ie_list_present = get_attr(PACKETBUF_ATTR_MAC_METADATA);
|
||||
|
||||
/* Insert IEEE 802.15.4 version bits. */
|
||||
params->fcf.frame_version = FRAME802154_VERSION;
|
||||
|
||||
#if LLSEC802154_USES_AUX_HEADER
|
||||
if(get_attr(PACKETBUF_ATTR_SECURITY_LEVEL)) {
|
||||
params->fcf.security_enabled = 1;
|
||||
}
|
||||
/* Setting security-related attributes */
|
||||
params->aux_hdr.security_control.security_level = get_attr(PACKETBUF_ATTR_SECURITY_LEVEL);
|
||||
#if LLSEC802154_USES_FRAME_COUNTER
|
||||
params->aux_hdr.frame_counter.u16[0] = get_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1);
|
||||
params->aux_hdr.frame_counter.u16[1] = get_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3);
|
||||
#else /* LLSEC802154_USES_FRAME_COUNTER */
|
||||
params->aux_hdr.security_control.frame_counter_suppression = 1;
|
||||
params->aux_hdr.security_control.frame_counter_size = 1;
|
||||
#endif /* LLSEC802154_USES_FRAME_COUNTER */
|
||||
#if LLSEC802154_USES_EXPLICIT_KEYS
|
||||
params->aux_hdr.security_control.key_id_mode = get_attr(PACKETBUF_ATTR_KEY_ID_MODE);
|
||||
params->aux_hdr.key_index = get_attr(PACKETBUF_ATTR_KEY_INDEX);
|
||||
params->aux_hdr.key_source.u16[0] = get_attr(PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1);
|
||||
#endif /* LLSEC802154_USES_EXPLICIT_KEYS */
|
||||
#else
|
||||
params->fcf.security_enabled = 0;
|
||||
#endif /* LLSEC802154_USES_AUX_HEADER */
|
||||
|
||||
params->seq = get_attr(PACKETBUF_ATTR_MAC_SEQNO);
|
||||
|
||||
/* Set the source PAN ID to the global variable. */
|
||||
params->src_pid = frame802154_get_pan_id();
|
||||
|
||||
/* Source address itself should be set outside this function. */
|
||||
if(get_attr(PACKETBUF_ATTR_MAC_NO_SRC_ADDR) == 1) {
|
||||
params->fcf.src_addr_mode = FRAME802154_NOADDR;
|
||||
} else {
|
||||
if(LINKADDR_SIZE == 2) {
|
||||
/* Use short address mode if linkaddr size is short. */
|
||||
params->fcf.src_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
} else {
|
||||
params->fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
|
||||
}
|
||||
}
|
||||
|
||||
params->dest_pid = frame802154_get_pan_id();
|
||||
|
||||
/* Destination address itself should be set outside this function. */
|
||||
if(get_attr(PACKETBUF_ATTR_MAC_NO_DEST_ADDR) == 1) {
|
||||
params->fcf.dest_addr_mode = FRAME802154_NOADDR;
|
||||
} else if(dest_is_broadcast) {
|
||||
/* Broadcast requires short address mode. */
|
||||
params->fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
} else {
|
||||
if(LINKADDR_SIZE == 2) {
|
||||
params->fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
} else {
|
||||
params->fcf.dest_addr_mode = FRAME802154_LONGADDRMODE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Suppress Source PAN ID and put Destination PAN ID by default */
|
||||
if(params->fcf.src_addr_mode == FRAME802154_SHORTADDRMODE ||
|
||||
params->fcf.dest_addr_mode == FRAME802154_SHORTADDRMODE) {
|
||||
params->fcf.panid_compression = 1;
|
||||
} else {
|
||||
params->fcf.panid_compression = 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
hdr_length(void)
|
||||
{
|
||||
return create_frame(FRAME802154_DATAFRAME, 0);
|
||||
return create_frame(0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
create(void)
|
||||
{
|
||||
return create_frame(FRAME802154_DATAFRAME, 1);
|
||||
return create_frame(1);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
|
@ -212,7 +246,7 @@ parse(void)
|
|||
if(frame.dest_pid != frame802154_get_pan_id() &&
|
||||
frame.dest_pid != FRAME802154_BROADCASTPANDID) {
|
||||
/* Packet to another PAN */
|
||||
LOG_WARN("In: for another pan %u\n", frame.dest_pid);
|
||||
LOG_WARN("15.4: for another pan %u\n", frame.dest_pid);
|
||||
return FRAMER_FAILED;
|
||||
}
|
||||
if(!frame802154_is_broadcast_addr(frame.fcf.dest_addr_mode, frame.dest_addr)) {
|
||||
|
@ -225,10 +259,17 @@ parse(void)
|
|||
} else {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, 0xffff);
|
||||
}
|
||||
#if NETSTACK_CONF_WITH_RIME
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.seq);
|
||||
#endif
|
||||
|
||||
#if LLSEC802154_USES_AUX_HEADER
|
||||
if(frame.fcf.security_enabled) {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, frame.aux_hdr.security_control.security_level);
|
||||
#if LLSEC802154_USES_FRAME_COUNTER
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, frame.aux_hdr.frame_counter.u16[0]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, frame.aux_hdr.frame_counter.u16[1]);
|
||||
#endif /* LLSEC802154_USES_FRAME_COUNTER */
|
||||
#if LLSEC802154_USES_EXPLICIT_KEYS
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, frame.aux_hdr.security_control.key_id_mode);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, frame.aux_hdr.key_index);
|
||||
|
@ -237,11 +278,11 @@ parse(void)
|
|||
}
|
||||
#endif /* LLSEC802154_USES_AUX_HEADER */
|
||||
|
||||
LOG_INFO("In: %2X", frame.fcf.frame_type);
|
||||
LOG_INFO("15.4-IN: %2X ", frame.fcf.frame_type);
|
||||
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
LOG_INFO_(" ");
|
||||
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
LOG_INFO_("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
|
||||
LOG_INFO_(" %d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
|
||||
|
||||
return hdr_len;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,14 @@
|
|||
#ifndef FRAMER_802154_H_
|
||||
#define FRAMER_802154_H_
|
||||
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/mac/framer/framer.h"
|
||||
|
||||
/* Setup frame802154_t with use of a specified get_attr */
|
||||
void framer_802154_setup_params(packetbuf_attr_t (*get_attr)(uint8_t type),
|
||||
uint8_t dest_is_broadcast,
|
||||
frame802154_t *params);
|
||||
|
||||
extern const struct framer framer_802154;
|
||||
|
||||
#endif /* FRAMER_802154_H_ */
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
# [EXPERIMENTAL] 6TiSCH Operation Sublayer (6top)
|
||||
|
||||
## Overview
|
||||
|
||||
6TiSCH Operation Sublayer (6top), a logical link layer in the 6TiSCH
|
||||
architecture, provides the abstraction of an IP link over a TSCH MAC layer (IEEE
|
||||
802.15.4e). The functionality of 6top is to facilitate the dynamic cell
|
||||
negotiation with one-hop neighbors.
|
||||
|
||||
This is a Contiki implementation of 6top, developed by:
|
||||
|
||||
- Shalu R, CDAC, shalur@cdac.in, github user: [shalurajendran](https://github.com/shalurajendran)
|
||||
- Lijo Thomas, CDAC, lijo@cdac.in
|
||||
- Yasuyuki Tanaka
|
||||
|
||||
It supports 6P (6top Protocol) of [draft-03](draft-ietf-6tisch-6top-protocol-03)
|
||||
except for concurrent 6P transactions described in [Section
|
||||
4.3.3](https://tools.ietf.org/html/draft-ietf-6tisch-6top-protocol-03#section-4.3.3).
|
||||
|
||||
## Code Structure
|
||||
|
||||
| File | Contents |
|
||||
|-----------------|--------------------------------|
|
||||
| sixtop.[ch] | 6top external APIs |
|
||||
| sixp.[ch] | 6P I/O APIs |
|
||||
| sixp-nbr.[ch] | 6P Neighbor Management APIs |
|
||||
| sixp-pkt.[ch] | 6P Packet Manipulation APIs |
|
||||
| sixp-trans.[ch] | 6P Transaction Management APIs |
|
||||
| sixp-conf.h | 6P Configuration Parameters |
|
||||
|
||||
## Configuration Paramters
|
||||
|
||||
| Parameter | Meaning | Default Value |
|
||||
|--------------------------------------|----------------------------------------------|---------------|
|
||||
| SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS | The maximum number of SFs installed in 6top | 1 |
|
||||
| SIXTOP_CONF_MAX_TRANSACTIONS | The maximum number of transactions at a time | 1 |
|
||||
|
||||
## Caveat
|
||||
|
||||
At this moment, allocated 6P neighbor states never be deleted since 6P has no
|
||||
way to decide to delete them. 6P neighbor state consists of SeqNum to be used
|
||||
for a next reqeust, GTX, and GRX (defined in sixp-nbr.c).
|
||||
|
||||
Once the number of 6P neighbor states reaches to the `SIXTOP_6P_MAX_NEIGHBORS`,
|
||||
a transaction with a new neighbor may fail due to failure in allocating a 6P
|
||||
neighbor state or schedule generation inconsistency.
|
||||
|
||||
## Example
|
||||
|
||||
An example using 6top is provided under `examples/ipv6/rpl-tsch-sxitop/`.
|
||||
|
||||
A simple Scheduling Function (SF) is implemented in `sf-simple.[ch]`. This SF
|
||||
does not have bandwidth monitoring mechanism nor bandwidth adaptation
|
||||
mechanism. Instead, the SF provides APIs so that a user process can add or
|
||||
remove cells dynamically. A sample user process implementation using the SF is
|
||||
found in `node-sixtop.c`, which is tested with `rpl-tsch-sixtop-z1.csc`.
|
||||
|
||||
## Test
|
||||
|
||||
6top or 6P related tests are implemented under `regression-tests/26-6tisch`.
|
||||
|
||||
## Using 6top
|
||||
|
||||
In order to use 6top with your system, `sixtop` module must be built together in
|
||||
addition to [TSCH](../).
|
||||
|
||||
Enable TSCH, then set 1 to `TSCH_CONF_WITH_SIXTOP`, typically, in your
|
||||
`project-conf.h`:
|
||||
|
||||
```C
|
||||
#undef TSCH_CONF_WITH_SIXTOP
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
```
|
||||
|
||||
Next, add `sixtop` into `MODULES` in your Makefile:
|
||||
|
||||
```Makefile
|
||||
MODULES += core/net/mac/tsch/sixtop
|
||||
```
|
||||
|
||||
For now, the simple SF mentioned above is only one SF shipped in the code
|
||||
base. You may have to implement your own SF.
|
||||
|
||||
## Implementing a Scheduling Function
|
||||
|
||||
Scheduling Function (SF) is represented with `sixtop_sf_t`, which defined in
|
||||
`sixtop.h`. An SF can be added into 6top by `sixtop_add_sf()`. After the
|
||||
addition, a handler defined in `sixtop_sf_t` is invoked on a correspondent
|
||||
event, for example, reception of a 6P request or timeout of an ongoing
|
||||
transaction.
|
||||
|
||||
SF can send a 6P packet by `sixp_output()`. After every Add or Delete operation,
|
||||
SF needs to advance schedule generation counter associated with the peer by
|
||||
`sixp_advance_generation()`, counter which is maintaeind by 6P. Otherwise, SF
|
||||
will not able to perform any command request other than Clear due to schedule
|
||||
generation inconsistency.
|
||||
|
||||
## References
|
||||
|
||||
1. [IETF 6TiSCH Working Group](https://datatracker.ietf.org/wg/6tisch)
|
||||
2. [6top Protocol (6P)](https://tools.ietf.org/html/draft-ietf-6tisch-6top-protocol)
|
||||
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Neighbor Management for 6top Protocol (6P)
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "contiki-lib.h"
|
||||
|
||||
#include "lib/assert.h"
|
||||
#include "net/nbr-table.h"
|
||||
|
||||
#include "sixp.h"
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
/**
|
||||
* \brief 6P Neighbor Data Structure (for internal use)
|
||||
*
|
||||
* XXX: for now, we have one nbr object per neighbor, which is shared with
|
||||
* multiple SFs. It's unclear whether we should use a different generation
|
||||
* counter for each SFs.
|
||||
*/
|
||||
typedef struct sixp_nbr {
|
||||
struct sixp_nbr *next;
|
||||
linkaddr_t addr;
|
||||
uint8_t next_seqno;
|
||||
uint8_t gen;
|
||||
} sixp_nbr_t;
|
||||
|
||||
NBR_TABLE(sixp_nbr_t, sixp_nbrs);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_nbr_t *
|
||||
sixp_nbr_find(const linkaddr_t *addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
if(addr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (sixp_nbr_t *)nbr_table_get_from_lladdr(sixp_nbrs, addr);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_nbr_t *
|
||||
sixp_nbr_alloc(const linkaddr_t *addr)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
|
||||
assert(addr != NULL);
|
||||
if(addr == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails because of invalid argument\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(sixp_nbr_find(addr) != NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails because of duplication [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)addr);
|
||||
LOG_ERR_("]\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((nbr = (sixp_nbr_t *)nbr_table_add_lladdr(sixp_nbrs,
|
||||
addr,
|
||||
NBR_TABLE_REASON_SIXTOP,
|
||||
NULL)) == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails to add nbr because of no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
linkaddr_copy(&nbr->addr, addr);
|
||||
nbr->next_seqno = SIXP_INITIAL_SEQUENCE_NUMBER;
|
||||
nbr->gen = 0;
|
||||
|
||||
return nbr;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixp_nbr_free(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr != NULL) {
|
||||
(void)nbr_table_remove(sixp_nbrs, nbr);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int16_t
|
||||
sixp_nbr_get_gen(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_get_gtx() fails because of invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
return nbr->gen;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_nbr_advance_gen(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_advance_gen() fails because of invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(nbr->gen == 0x00 || nbr->gen == 0x09) {
|
||||
nbr->gen = 0x01;
|
||||
} else if(nbr->gen < 0x09) {
|
||||
nbr->gen++;
|
||||
} else {
|
||||
/* unexpected condition */
|
||||
LOG_ERR("6P-nbr: nbr %p has an invalid generation number %02x\n",
|
||||
nbr, nbr->gen);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_nbr_get_next_seqno(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_get_next_seqno() fails because of invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
return nbr->next_seqno;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_nbr_increment_next_seqno(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
LOG_ERR("6P-nbr: sixp_nbr_increment_next_seqno() fails; invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
nbr->next_seqno++;
|
||||
if(nbr->next_seqno > 0x0f) {
|
||||
/*
|
||||
* nbr->next_seqno, which represents a value of the SeqNum field, won't be
|
||||
* larger than 0x0f since he length of SeqNum field is 4 bits.
|
||||
*/
|
||||
nbr->next_seqno = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_nbr_init(void)
|
||||
{
|
||||
sixp_nbr_t *nbr, *next_nbr;
|
||||
if(nbr_table_is_register(sixp_nbrs) == 0) {
|
||||
nbr_table_register(sixp_nbrs, NULL);
|
||||
} else {
|
||||
/* remove all the existing nbrs */
|
||||
nbr = (sixp_nbr_t *)nbr_table_head(sixp_nbrs);
|
||||
while(nbr != NULL) {
|
||||
next_nbr = (sixp_nbr_t *)nbr_table_next(sixp_nbrs, nbr);
|
||||
sixp_nbr_free(nbr);
|
||||
nbr = next_nbr;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Neighbor Management APIs for 6top Protocol (6P)
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "sixp-pkt.h"
|
||||
|
||||
typedef struct sixp_nbr sixp_nbr_t;
|
||||
|
||||
/**
|
||||
* \brief Find a neighbor
|
||||
* \param addr The MAC address of a neighbor
|
||||
* \return The pointer to a neighbor, NULL on failure
|
||||
*/
|
||||
sixp_nbr_t *sixp_nbr_find(const linkaddr_t *addr);
|
||||
|
||||
/**
|
||||
* \brief Allocate a neighbor
|
||||
* \param addr The MAC address of a neighbor
|
||||
* \return The pointer to a allocated neighbor, NULL on failure
|
||||
*/
|
||||
sixp_nbr_t *sixp_nbr_alloc(const linkaddr_t *addr);
|
||||
|
||||
/**
|
||||
* \brief Free a neighbor
|
||||
* \param nbr The pointer to a neighbor to free
|
||||
*/
|
||||
void sixp_nbr_free(sixp_nbr_t *nbr);
|
||||
|
||||
/**
|
||||
* \brief Return GEN (Generation Number) of a neighbor
|
||||
* \param nbr The pointer to a neighbor
|
||||
* \return A value of GEN, -1 on failure
|
||||
*/
|
||||
int16_t sixp_nbr_get_gen(sixp_nbr_t *nbr);
|
||||
|
||||
/**
|
||||
* \brief Advance GTX of a neighbor
|
||||
* \param nbr The pointer to a neighbor
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_nbr_advance_gen(sixp_nbr_t *nbr);
|
||||
|
||||
/**
|
||||
* \brief Get the next sequence number of a neighbor
|
||||
* \param nbr The pointer to a neighbor
|
||||
* \return A sequence number to use for a next request, -1 on failure
|
||||
*/
|
||||
int16_t sixp_nbr_get_next_seqno(sixp_nbr_t *nbr);
|
||||
|
||||
/**
|
||||
* \brief Increment the next sequence number of a neighbor
|
||||
* \param nbr The pointer to a neighbor
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_nbr_increment_next_seqno(sixp_nbr_t *nbr);
|
||||
|
||||
/**
|
||||
* \brief Initialize 6p Neighbor Table
|
||||
*/
|
||||
int sixp_nbr_init(void);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,445 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* Copyright (c) 2016, Centre for Development of Advanced Computing (C-DAC).
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6top Protocol (6P) Packet Manipulation APIs
|
||||
* \author
|
||||
* Shalu R <shalur@cdac.in>
|
||||
* Lijo Thomas <lijo@cdac.in>
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
#ifndef _SIXTOP_6P_PACKET_H_
|
||||
#define _SIXTOP_6P_PACKET_H_
|
||||
|
||||
#define SIXP_PKT_VERSION 0x00
|
||||
|
||||
/* typedefs for code readability */
|
||||
typedef uint8_t sixp_pkt_cell_options_t;
|
||||
typedef uint8_t sixp_pkt_num_cells_t;
|
||||
typedef uint8_t sixp_pkt_reserved_t;
|
||||
typedef uint16_t sixp_pkt_metadata_t;
|
||||
typedef uint16_t sixp_pkt_max_num_cells_t;
|
||||
typedef uint16_t sixp_pkt_offset_t;
|
||||
typedef uint32_t sixp_pkt_cell_t;
|
||||
typedef uint16_t sixp_pkt_total_num_cells_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Message Types
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_PKT_TYPE_REQUEST = 0x00, /**< 6P Request */
|
||||
SIXP_PKT_TYPE_RESPONSE = 0x01, /**< 6P Response */
|
||||
SIXP_PKT_TYPE_CONFIRMATION = 0x02, /**< 6P Confirmation */
|
||||
SIXP_PKT_TYPE_RESERVED = 0x03, /**< Reserved */
|
||||
} sixp_pkt_type_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Command Identifiers
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_PKT_CMD_ADD = 0x01, /**< CMD_ADD */
|
||||
SIXP_PKT_CMD_DELETE = 0x02, /**< CMD_DELETE */
|
||||
SIXP_PKT_CMD_RELOCATE = 0x03, /**< CMD_STATUS */
|
||||
SIXP_PKT_CMD_COUNT = 0x04, /**< CMD_STATUS */
|
||||
SIXP_PKT_CMD_LIST = 0x05, /**< CMD_LIST */
|
||||
SIXP_PKT_CMD_CLEAR = 0x06, /**< CMD_CLEAR */
|
||||
SIXP_PKT_CMD_UNAVAILABLE = 0xff, /**< for internal use */
|
||||
} sixp_pkt_cmd_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Return Codes
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_PKT_RC_SUCCESS = 0x00, /**< RC_SUCCESS */
|
||||
SIXP_PKT_RC_ERROR = 0x01, /**< RC_ERROR */
|
||||
SIXP_PKT_RC_EOL = 0x02, /**< RC_EOL */
|
||||
SIXP_PKT_RC_RESET = 0x03, /**< RC_RESET */
|
||||
SIXP_PKT_RC_VERSION = 0x04, /**< RC_ERR_VER */
|
||||
SIXP_PKT_RC_SFID = 0x05, /**< RC_ERR_SFID */
|
||||
SIXP_PKT_RC_GEN = 0x06, /**< RC_ERR_GEN */
|
||||
SIXP_PKT_RC_BUSY = 0x07, /**< RC_ERR_BUSY */
|
||||
SIXP_PKT_RC_NORES = 0x08, /**< RC_ERR_NORES */
|
||||
SIXP_PKT_RC_CELLLIST = 0x09, /**< RC_ERR_CELLLIST */
|
||||
} sixp_pkt_rc_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Codes integrating Command IDs and Return Codes
|
||||
*/
|
||||
typedef union {
|
||||
sixp_pkt_cmd_t cmd; /**< 6P Command Identifier */
|
||||
sixp_pkt_rc_t rc; /**< 6P Return Code */
|
||||
uint8_t value; /**< 8-bit unsigned integer value */
|
||||
} sixp_pkt_code_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Cell Options
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_PKT_CELL_OPTION_TX = 0x01, /**< TX Cell */
|
||||
SIXP_PKT_CELL_OPTION_RX = 0x02, /**< RX Cell */
|
||||
SIXP_PKT_CELL_OPTION_SHARED = 0x04 /**< SHARED Cell */
|
||||
} sixp_pkt_cell_option_t;
|
||||
|
||||
/**
|
||||
* \brief 6top IE Structure
|
||||
*/
|
||||
typedef struct {
|
||||
sixp_pkt_type_t type; /**< Type */
|
||||
sixp_pkt_code_t code; /**< Code */
|
||||
uint8_t sfid; /**< SFID */
|
||||
uint8_t seqno; /**< SeqNum */
|
||||
uint8_t gen; /**< GEN */
|
||||
const uint8_t *body; /**< Other Fields... */
|
||||
uint16_t body_len; /**< The length of Other Fields */
|
||||
} sixp_pkt_t;
|
||||
|
||||
/**
|
||||
* \brief Write Metadata into "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param metadata Metadata to write
|
||||
* \param body The pointer to "Other Fields" in a buffer
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_metadata(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_metadata_t metadata,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read Metadata stored in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param metadata The pointer to a buffer to store Metadata in
|
||||
* \param body The pointer to the buffer having "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_metadata(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_metadata_t *metadata,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write CellOptions in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cell_options "CellOptions" to write
|
||||
* \param body The pointer to buffer having "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_cell_options(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_cell_options_t cell_options,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read CellOptions in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cell_options The pointer to buffer to store CellOptions in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_cell_options(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_cell_options_t *cell_options,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write NumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param num_cells "NumCells" to write
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_num_cells_t num_cells,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read NumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param num_cells The pointer to buffer to store NumCells in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_num_cells_t *num_cells,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
/**
|
||||
* \brief Write Reserved in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param reserved "Reserved" to write
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_reserved(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_reserved_t reserved,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read Reserved in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param reserved The pointer to buffer to store Reserved in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_reserved(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_reserved_t *reserved,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write Offset in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param offset "Offset" to write
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_offset(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_offset_t offset,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
/**
|
||||
* \brief Read Offset in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param offset The pointer to buffer to store Offset in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_offset(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_offset_t *offset,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write MaxNumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param max_num_cells "MaxNumCells" to write
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_max_num_cells(sixp_pkt_type_t type,
|
||||
sixp_pkt_code_t code,
|
||||
sixp_pkt_max_num_cells_t max_num_cells,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read MaxNumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param max_num_cells The pointer to buffer to store MaxNumCells in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_max_num_cells(sixp_pkt_type_t type,
|
||||
sixp_pkt_code_t code,
|
||||
sixp_pkt_max_num_cells_t *max_num_cells,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write CellList in "Other Fields" of 6P packet
|
||||
* \note "offset" is specified by index in CellList
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cell_list The pointer to "CellList" to write
|
||||
* \param cell_list_len Length to write
|
||||
* \param offset Offset in the "CellList" field to start writing
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *cell_list,
|
||||
uint16_t cell_list_len,
|
||||
uint16_t offset,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
/**
|
||||
* \brief Read CellList in "Other Fields" of 6P packet
|
||||
* \note If you want only the length of CellList, you can set null to cell_list.
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cell_list The double pointer to store the starting address of CellList
|
||||
* \param cell_list_len Pointer to store the length of CellList
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t **cell_list,
|
||||
sixp_pkt_offset_t *cell_list_len,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write RelCellList in "Other Fields" of 6P packet
|
||||
* \note "offset" is specified by index in RelCellList
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param rel_cell_list The pointer to "RelCellList" to write
|
||||
* \param rel_cell_list_len Length to write
|
||||
* \param offset Offset in the "RelCellList" field to start writing
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *rel_cell_list,
|
||||
uint16_t rel_cell_list_len,
|
||||
uint16_t offset,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read RelCellList in "Other Fields" of 6P packet
|
||||
* \note If you want only the length of RelCellList, you can set null to
|
||||
* rel_cell_list.
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param rel_cell_list The double pointer to store the starting address of
|
||||
* RelCellList
|
||||
* \param rel_cell_list_len Pointer to store the length of a returned
|
||||
* RelCellList
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t **rel_cell_list,
|
||||
sixp_pkt_offset_t *rel_cell_list_len,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write CandCellList in "Other Fields" of 6P packet
|
||||
* \note "offset" is specified by index in CandCellList
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cand_cell_list The pointer to "CandCellList" to write
|
||||
* \param cand_cell_list_len Length to write
|
||||
* \param offset Offset in the "CandCellList" field to start writing
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *cand_cell_list,
|
||||
uint16_t cand_cell_list_len,
|
||||
uint16_t offset,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read CandCellList in "Other Fields" of 6P packet
|
||||
* \note If you want only the length of CandCellList, you can set null to
|
||||
* cell_list.
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param cand_cell_list The double pointer to store the starting address of
|
||||
* CandCellList
|
||||
* \param cand_cell_list_len Pointer to store the length of CandCellList
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t **cand_cell_list,
|
||||
sixp_pkt_offset_t *cand_cell_list_len,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Write TotalNumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param total_num_cells "TotalNumCells" to write
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_set_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_total_num_cells_t total_num_cells,
|
||||
uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Read TotalNumCells in "Other Fields" of 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Command Identifier or Return Code
|
||||
* \param total_num_cells The pointer to buffer to store TotalNumCells in
|
||||
* \param body The pointer to buffer pointing to "Other Fields"
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_get_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_total_num_cells_t *total_num_cells,
|
||||
const uint8_t *body, uint16_t body_len);
|
||||
|
||||
/**
|
||||
* \brief Parse a 6P packet
|
||||
* \param buf The pointer to a buffer pointing 6top IE Content
|
||||
* \param len The length of the buffer
|
||||
* \param pkt The pointer to a sixp_pkt_t structure to store packet info
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
sixp_pkt_t *pkt);
|
||||
|
||||
/**
|
||||
* \brief Create a 6P packet
|
||||
* \param type 6P Message Type
|
||||
* \param code 6P Message Code, Command Identifier or Return Code
|
||||
* \param sfid Scheduling Function Identifier
|
||||
* \param seqno Sequence Number
|
||||
* \param gen GEN
|
||||
* \param body The pointer to "Other Fields" in a buffer
|
||||
* \param body_len The length of body, typically "Other Fields" length
|
||||
* \param pkt The pointer to a sixp_pkt_t structure to store packet info
|
||||
* (option)
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
uint8_t sfid, uint8_t seqno, uint8_t gen,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
sixp_pkt_t *pkt);
|
||||
|
||||
#endif /* !_SIXP_PKT_H_ */
|
||||
/** @} */
|
|
@ -0,0 +1,397 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Transaction Management for 6top Protocol (6P)
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "contiki-lib.h"
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "sixtop.h"
|
||||
#include "sixtop-conf.h"
|
||||
#include "sixp-trans.h"
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
/**
|
||||
* \brief 6P Transaction Data Structure (for internal use)
|
||||
*/
|
||||
typedef struct sixp_trans {
|
||||
struct sixp_trans *next;
|
||||
const sixtop_sf_t *sf;
|
||||
linkaddr_t peer_addr;
|
||||
uint8_t seqno;
|
||||
sixp_pkt_cmd_t cmd;
|
||||
sixp_trans_state_t state;
|
||||
sixp_trans_mode_t mode;
|
||||
struct {
|
||||
sixp_sent_callback_t func;
|
||||
void *arg;
|
||||
uint16_t arg_len;
|
||||
} callback;
|
||||
struct ctimer timer;
|
||||
} sixp_trans_t;
|
||||
|
||||
static void handle_trans_timeout(void *ptr);
|
||||
static void process_trans(void *ptr);
|
||||
static void schedule_trans_process(sixp_trans_t *trans);
|
||||
static void free_trans(sixp_trans_t *trans);
|
||||
static sixp_trans_mode_t determine_trans_mode(const sixp_pkt_t *req);
|
||||
|
||||
MEMB(trans_memb, sixp_trans_t, SIXTOP_MAX_TRANSACTIONS);
|
||||
LIST(trans_list);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_trans_timeout(void *ptr)
|
||||
{
|
||||
sixp_trans_t *trans = (sixp_trans_t *)ptr;
|
||||
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trans->sf->timeout != NULL) {
|
||||
trans->sf->timeout(trans->cmd,
|
||||
(const linkaddr_t *)&trans->peer_addr);
|
||||
}
|
||||
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
start_trans_timer(sixp_trans_t *trans)
|
||||
{
|
||||
ctimer_set(&trans->timer, trans->sf->timeout_interval,
|
||||
handle_trans_timeout, trans);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
process_trans(void *ptr)
|
||||
{
|
||||
sixp_trans_t *trans = (sixp_trans_t *)ptr;
|
||||
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* make sure that the timer is stopped */
|
||||
ctimer_stop(&trans->timer);
|
||||
|
||||
/* state-specific operation */
|
||||
if(trans->state == SIXP_TRANS_STATE_TERMINATING) {
|
||||
/* handle the terminating state first */
|
||||
LOG_INFO("6P-trans: trans [peer_addr:");
|
||||
LOG_INFO_LLADDR((const linkaddr_t *)&trans->peer_addr);
|
||||
LOG_INFO_(", seqno:%u] is going to be freed\n", trans->seqno);
|
||||
free_trans(trans);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(trans->state) {
|
||||
/* do for others */
|
||||
case SIXP_TRANS_STATE_RESPONSE_SENT:
|
||||
case SIXP_TRANS_STATE_RESPONSE_RECEIVED:
|
||||
if(trans->mode == SIXP_TRANS_MODE_2_STEP) {
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
}
|
||||
break;
|
||||
case SIXP_TRANS_STATE_CONFIRMATION_SENT:
|
||||
case SIXP_TRANS_STATE_CONFIRMATION_RECEIVED:
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
break;
|
||||
case SIXP_TRANS_STATE_TERMINATING:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(trans->state != SIXP_TRANS_STATE_TERMINATING) {
|
||||
/* set the timer with a timeout values defined by the SF */
|
||||
start_trans_timer(trans);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
schedule_trans_process(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctimer_stop(&trans->timer);
|
||||
ctimer_set(&trans->timer, 0, process_trans, trans); /* expires immediately */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
free_trans(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
list_remove(trans_list, trans);
|
||||
memb_free(&trans_memb, trans);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static sixp_trans_mode_t
|
||||
determine_trans_mode(const sixp_pkt_t *req)
|
||||
{
|
||||
uint16_t cell_list_len;
|
||||
|
||||
assert(req != NULL);
|
||||
if(req == NULL) {
|
||||
return SIXP_TRANS_MODE_UNAVAILABLE;
|
||||
}
|
||||
|
||||
/*
|
||||
* We consider a transaction as 3-step if and only if its request command is
|
||||
* either Add or Delete AND its cell_list is empty. Otherwise, 2-step.
|
||||
*/
|
||||
if(req->type == SIXP_PKT_TYPE_REQUEST &&
|
||||
(req->code.cmd == SIXP_PKT_CMD_ADD ||
|
||||
req->code.cmd == SIXP_PKT_CMD_DELETE) &&
|
||||
sixp_pkt_get_cell_list(req->type, (sixp_pkt_code_t)req->code.value,
|
||||
NULL, &cell_list_len,
|
||||
req->body, req->body_len) == 0 &&
|
||||
cell_list_len == 0) {
|
||||
return SIXP_TRANS_MODE_3_STEP;
|
||||
}
|
||||
|
||||
return SIXP_TRANS_MODE_2_STEP;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_trans_transit_state(sixp_trans_t *trans, sixp_trans_state_t new_state)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6top: invalid argument, trans is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* enforce state transition rules */
|
||||
if(new_state == SIXP_TRANS_STATE_TERMINATING ||
|
||||
(new_state == SIXP_TRANS_STATE_REQUEST_SENT &&
|
||||
trans->state == SIXP_TRANS_STATE_INIT) ||
|
||||
(new_state == SIXP_TRANS_STATE_REQUEST_RECEIVED &&
|
||||
trans->state == SIXP_TRANS_STATE_INIT) ||
|
||||
(new_state == SIXP_TRANS_STATE_RESPONSE_SENT &&
|
||||
trans->state == SIXP_TRANS_STATE_REQUEST_RECEIVED) ||
|
||||
(new_state == SIXP_TRANS_STATE_RESPONSE_RECEIVED &&
|
||||
trans->state == SIXP_TRANS_STATE_REQUEST_SENT) ||
|
||||
(new_state == SIXP_TRANS_STATE_CONFIRMATION_RECEIVED &&
|
||||
trans->state == SIXP_TRANS_STATE_RESPONSE_SENT &&
|
||||
trans->mode == SIXP_TRANS_MODE_3_STEP) ||
|
||||
(new_state == SIXP_TRANS_STATE_CONFIRMATION_SENT &&
|
||||
trans->state == SIXP_TRANS_STATE_RESPONSE_RECEIVED &&
|
||||
trans->mode == SIXP_TRANS_MODE_3_STEP)) {
|
||||
LOG_INFO("6P-trans: trans %p state changes from %u to %u\n",
|
||||
trans, trans->state, new_state);
|
||||
trans->state = new_state;
|
||||
schedule_trans_process(trans);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* invalid transition */
|
||||
LOG_ERR("6P-trans: invalid transaction, from %u to %u, detected on trans %p\n",
|
||||
trans->state, new_state, trans);
|
||||
return -1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_pkt_cmd_t
|
||||
sixp_trans_get_cmd(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return SIXP_PKT_CMD_UNAVAILABLE;
|
||||
}
|
||||
return trans->cmd;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_trans_state_t
|
||||
sixp_trans_get_state(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return SIXP_TRANS_STATE_UNAVAILABLE;
|
||||
}
|
||||
return trans->state;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int16_t
|
||||
sixp_trans_get_seqno(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_get_seqno() fails because trans is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
return trans->seqno;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_trans_mode_t
|
||||
sixp_trans_get_mode(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_get_mode() fails because trans is NULL\n");
|
||||
return SIXP_TRANS_STATE_UNAVAILABLE;
|
||||
}
|
||||
return trans->mode;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixp_trans_invoke_callback(sixp_trans_t *trans, sixp_output_status_t status)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
|
||||
if(trans == NULL || trans->callback.func == NULL) {
|
||||
return;
|
||||
}
|
||||
trans->callback.func(trans->callback.arg, trans->callback.arg_len,
|
||||
&trans->peer_addr, status);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixp_trans_set_callback(sixp_trans_t *trans,
|
||||
sixp_sent_callback_t func, void *arg, uint16_t arg_len)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
return;
|
||||
}
|
||||
trans->callback.func = func;
|
||||
trans->callback.arg = arg;
|
||||
trans->callback.arg_len = arg_len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_trans_t *
|
||||
sixp_trans_alloc(const sixp_pkt_t *pkt, const linkaddr_t *peer_addr)
|
||||
{
|
||||
const sixtop_sf_t *sf;
|
||||
sixp_trans_t *trans;
|
||||
|
||||
assert(pkt != NULL && peer_addr != NULL);
|
||||
if(pkt == NULL || peer_addr == NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because of invalid argument\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((sf = sixtop_find_sf(pkt->sfid)) == NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails; no suitable SF [sfid:%u]\n",
|
||||
pkt->sfid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(sixp_trans_find(peer_addr) != NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because another trans with ");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)peer_addr);
|
||||
LOG_ERR_("is in process\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((trans = memb_alloc(&trans_memb)) == NULL) {
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because of lack of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(trans, 0, sizeof(sixp_trans_t));
|
||||
trans->sf = sf;
|
||||
trans->peer_addr = *peer_addr;
|
||||
trans->seqno = pkt->seqno;
|
||||
trans->cmd = pkt->code.value;
|
||||
trans->state = SIXP_TRANS_STATE_INIT;
|
||||
trans->mode = determine_trans_mode(pkt);
|
||||
list_add(trans_list, trans);
|
||||
start_trans_timer(trans);
|
||||
|
||||
return trans;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
sixp_trans_t *
|
||||
sixp_trans_find(const linkaddr_t *peer_addr)
|
||||
{
|
||||
sixp_trans_t *trans;
|
||||
|
||||
assert(peer_addr != NULL);
|
||||
if(peer_addr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: we don't support concurrent 6P transactions which is mentioned in
|
||||
* Section 4.3.3, draft-ietf-6tisch-6top-protocol-03.
|
||||
*
|
||||
* The assumption here is that there is one transactions for a single peer at
|
||||
* most.
|
||||
*/
|
||||
for(trans = list_head(trans_list);
|
||||
trans != NULL; trans = trans->next) {
|
||||
if(memcmp(peer_addr, &trans->peer_addr, sizeof(linkaddr_t)) == 0) {
|
||||
return trans;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_trans_init(void)
|
||||
{
|
||||
sixp_trans_t *trans, *next_trans;
|
||||
|
||||
/* make sure there's no timer task left before the initialization */
|
||||
for(trans = list_head(trans_list);
|
||||
trans != NULL; trans = next_trans) {
|
||||
next_trans = trans->next;
|
||||
ctimer_stop(&trans->timer);
|
||||
free_trans(trans);
|
||||
}
|
||||
|
||||
list_init(trans_list);
|
||||
memb_init(&trans_memb);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Transaction Management APIs for 6top Protocol (6P)
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "sixp.h"
|
||||
#include "sixp-pkt.h"
|
||||
|
||||
/**
|
||||
* \brief 6P Transaction States (for internal use)
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_TRANS_STATE_UNAVAILABLE = 0,
|
||||
SIXP_TRANS_STATE_INIT,
|
||||
SIXP_TRANS_STATE_REQUEST_SENT,
|
||||
SIXP_TRANS_STATE_REQUEST_RECEIVED,
|
||||
SIXP_TRANS_STATE_RESPONSE_SENT,
|
||||
SIXP_TRANS_STATE_RESPONSE_RECEIVED,
|
||||
SIXP_TRANS_STATE_CONFIRMATION_SENT,
|
||||
SIXP_TRANS_STATE_CONFIRMATION_RECEIVED,
|
||||
SIXP_TRANS_STATE_TERMINATING,
|
||||
} sixp_trans_state_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Transaction Modes (for internal use)
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_TRANS_MODE_UNAVAILABLE = 0,
|
||||
SIXP_TRANS_MODE_2_STEP,
|
||||
SIXP_TRANS_MODE_3_STEP
|
||||
} sixp_trans_mode_t;
|
||||
|
||||
typedef struct sixp_trans sixp_trans_t;
|
||||
|
||||
/**
|
||||
* \brief Change the state of a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \param new_state New state to move the transaction to
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_trans_transit_state(sixp_trans_t *trans,
|
||||
sixp_trans_state_t new_state);
|
||||
|
||||
/**
|
||||
* \brief Return the command associated with a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \return Command identifier; SIXP_PKT_CMD_UNAVAILABLE on failure
|
||||
*/
|
||||
sixp_pkt_cmd_t sixp_trans_get_cmd(sixp_trans_t *trans);
|
||||
|
||||
/**
|
||||
* \brief Return the state of a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \return a state of the transaction; SIXP_TRANS_STATE_UNAVAILABLE if the
|
||||
* transaction is not found in the system.
|
||||
*/
|
||||
sixp_trans_state_t sixp_trans_get_state(sixp_trans_t *trans);
|
||||
|
||||
/**
|
||||
* \brief Return the sequence number associated with a specified transaction
|
||||
* \param trans The pointer of a transaction
|
||||
* \return 0 or larger than 0 on success, -1 on failure
|
||||
*/
|
||||
int16_t sixp_trans_get_seqno(sixp_trans_t *trans);
|
||||
|
||||
/**
|
||||
* \brief Return the mode, 2-step or 3-step, of a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \return The mode of the transaction, SIXP_TRANS_MODE_UNAVAILABLE on failure
|
||||
*/
|
||||
sixp_trans_mode_t sixp_trans_get_mode(sixp_trans_t *trans);
|
||||
|
||||
/**
|
||||
* \brief Invoke the output callback of a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \param status An output result value
|
||||
*/
|
||||
void sixp_trans_invoke_callback(sixp_trans_t *trans,
|
||||
sixp_output_status_t status);
|
||||
|
||||
/**
|
||||
* \brief Set an output callback to a specified transaction
|
||||
* \param trans The pointer to a transaction
|
||||
* \param func The pointer to a callback function
|
||||
* \param arg The pointer to an argument which will be passed to func
|
||||
* \param arg_len The length of the argument
|
||||
*/
|
||||
void sixp_trans_set_callback(sixp_trans_t *trans,
|
||||
sixp_sent_callback_t func,
|
||||
void *arg,
|
||||
uint16_t arg_len);
|
||||
|
||||
/**
|
||||
* \brief Allocate a transaction
|
||||
* \param pkt The pointer to a packet which triggers the allocation
|
||||
* \param peer_addr The peer address which will be associated
|
||||
* \return A pointer to an newly allocated transaction, NULL on failure
|
||||
*/
|
||||
sixp_trans_t *sixp_trans_alloc(const sixp_pkt_t *pkt,
|
||||
const linkaddr_t *peer_addr);
|
||||
|
||||
/**
|
||||
* \brief Find a transaction
|
||||
* \param peer_addr The peer address
|
||||
* \return The pointer to a transaction; NULL on failure
|
||||
*/
|
||||
sixp_trans_t *sixp_trans_find(const linkaddr_t *peer_addr);
|
||||
|
||||
/**
|
||||
* \brief Initialize Memory and List for 6P transactions
|
||||
* This function removes and frees existing transactions.
|
||||
*/
|
||||
int sixp_trans_init(void);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,422 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6top Protocol (6P)
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "contiki-lib.h"
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "sixtop.h"
|
||||
#include "sixp-nbr.h"
|
||||
#include "sixp-pkt.h"
|
||||
#include "sixp-trans.h"
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
static void mac_callback(void *ptr, int status, int transmissions);
|
||||
static int send_back_error(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
uint8_t sfid, uint8_t seqno,
|
||||
const linkaddr_t *dest_addr);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
mac_callback(void *ptr, int status, int transmissions)
|
||||
{
|
||||
sixp_trans_t *trans = (sixp_trans_t *)ptr;
|
||||
sixp_trans_state_t new_state, current_state;
|
||||
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6P: mac_callback() fails because trans is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
current_state = sixp_trans_get_state(trans);
|
||||
if(status == MAC_TX_OK) {
|
||||
switch(current_state) {
|
||||
case SIXP_TRANS_STATE_INIT:
|
||||
new_state = SIXP_TRANS_STATE_REQUEST_SENT;
|
||||
break;
|
||||
case SIXP_TRANS_STATE_REQUEST_RECEIVED:
|
||||
new_state = SIXP_TRANS_STATE_RESPONSE_SENT;
|
||||
break;
|
||||
case SIXP_TRANS_STATE_RESPONSE_RECEIVED:
|
||||
new_state = SIXP_TRANS_STATE_CONFIRMATION_SENT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("6P: mac_callback() fails because of an unexpected state (%u)\n",
|
||||
current_state);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* In a case of transmission failure of a request, a corresponding SF would
|
||||
* retransmit the request with a new transaction. For a response or a
|
||||
* confirmation, the same transaction will be used for retransmission as
|
||||
* long as it doesn't have timeout.
|
||||
*/
|
||||
if(current_state == SIXP_TRANS_STATE_INIT) {
|
||||
/* request case */
|
||||
new_state = SIXP_TRANS_STATE_TERMINATING;
|
||||
} else {
|
||||
/* response or confirmation case: stay the same state */
|
||||
new_state = current_state;
|
||||
}
|
||||
}
|
||||
|
||||
if(new_state != current_state &&
|
||||
sixp_trans_transit_state(trans, new_state) != 0) {
|
||||
LOG_ERR("6P: mac_callback() fails because of state transition failure\n");
|
||||
LOG_ERR("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
return;
|
||||
}
|
||||
|
||||
sixp_trans_invoke_callback(trans,
|
||||
status == MAC_TX_OK ?
|
||||
SIXP_OUTPUT_STATUS_SUCCESS :
|
||||
SIXP_OUTPUT_STATUS_FAILURE);
|
||||
sixp_trans_set_callback(trans, NULL, NULL, 0);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
send_back_error(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
uint8_t sfid, uint8_t seqno,
|
||||
const linkaddr_t *dest_addr)
|
||||
{
|
||||
/* create a 6P packet within packetbuf */
|
||||
if(sixp_pkt_create(type, code, sfid, seqno, 0, NULL, 0, NULL) < 0) {
|
||||
LOG_ERR("6P: failed to create a 6P packet to return an error [rc:%u]\n",
|
||||
code.value);
|
||||
return -1;
|
||||
}
|
||||
/* we don't care about how the transmission goes; no need to set callback */
|
||||
sixtop_output(dest_addr, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_nbr_t *nbr;
|
||||
uint8_t invalid_schedule_generation;
|
||||
sixp_trans_t *trans;
|
||||
const sixtop_sf_t *sf;
|
||||
int16_t seqno;
|
||||
int16_t gen;
|
||||
int ret;
|
||||
|
||||
assert(buf != NULL && src_addr != NULL);
|
||||
if(buf == NULL || src_addr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(sixp_pkt_parse(buf, len, &pkt) < 0) {
|
||||
LOG_ERR("6P: sixp_input() fails because off a malformed 6P packet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pkt.type != SIXP_PKT_TYPE_REQUEST &&
|
||||
pkt.type != SIXP_PKT_TYPE_RESPONSE &&
|
||||
pkt.type != SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
LOG_ERR("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
return;
|
||||
}
|
||||
|
||||
if((sf = sixtop_find_sf(pkt.sfid)) == NULL) {
|
||||
LOG_ERR("6P: sixp_input() fails because SF [sfid:%u] is unavailable\n",
|
||||
pkt.sfid);
|
||||
/*
|
||||
* XXX: what if the incoming packet is a response? confirmation should be
|
||||
* sent back?
|
||||
*/
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SFID,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response\n");
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
nbr = sixp_nbr_find(src_addr);
|
||||
/* Generation Management */
|
||||
if(pkt.code.value == SIXP_PKT_CMD_CLEAR) {
|
||||
/* Not need to validate generation counters in a case of CMD_CLEAR */
|
||||
invalid_schedule_generation = 0;
|
||||
} else if(nbr == NULL) {
|
||||
if(pkt.gen == 0) {
|
||||
invalid_schedule_generation = 0; /* valid combination */
|
||||
} else {
|
||||
LOG_ERR("6P: GEN should be 0 because of no corresponding nbr\n");
|
||||
invalid_schedule_generation = 1;
|
||||
}
|
||||
} else {
|
||||
if((gen = sixp_nbr_get_gen(nbr)) < 0) {
|
||||
LOG_ERR("6P: unexpected error; cannot get our GEN\n");
|
||||
return;
|
||||
}
|
||||
LOG_ERR("6P: received GEN %u, our GEN: %u\n",
|
||||
pkt.gen, sixp_nbr_get_gen(nbr));
|
||||
if(pkt.gen == gen) {
|
||||
invalid_schedule_generation = 0; /* valid combination */
|
||||
} else {
|
||||
invalid_schedule_generation = 1;
|
||||
}
|
||||
}
|
||||
if(invalid_schedule_generation) {
|
||||
LOG_ERR("6P: sixp_input() fails because of schedule generation mismatch\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Transaction Management */
|
||||
trans = sixp_trans_find(src_addr);
|
||||
|
||||
if(pkt.type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(trans != NULL) {
|
||||
/* Error: not supposed to have another transaction with the peer. */
|
||||
LOG_ERR("6P: sixp_input() fails because another request [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)src_addr);
|
||||
LOG_ERR_(" seqno:%u] is in process\n", sixp_trans_get_seqno(trans));
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_BUSY,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response");
|
||||
}
|
||||
return;
|
||||
} else if((trans = sixp_trans_alloc(&pkt, src_addr)) == NULL) {
|
||||
LOG_ERR("6P: sixp_input() fails because of lack of memory\n");
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_NORES,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if(pkt.type == SIXP_PKT_TYPE_RESPONSE ||
|
||||
pkt.type == SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
if(trans == NULL) {
|
||||
/* Error: should have a transaction for incoming packet */
|
||||
LOG_ERR("6P: sixp_input() fails because of no trans [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)src_addr);
|
||||
LOG_ERR_("]\n");
|
||||
return;
|
||||
} else if((seqno = sixp_trans_get_seqno(trans)) < 0 ||
|
||||
seqno != pkt.seqno) {
|
||||
LOG_ERR("6P: sixp_input() fails because of invalid seqno [seqno:%u, %u]\n",
|
||||
seqno, pkt.seqno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* state transition */
|
||||
assert(trans != NULL);
|
||||
switch(pkt.type) {
|
||||
case SIXP_PKT_TYPE_REQUEST:
|
||||
ret = sixp_trans_transit_state(trans,
|
||||
SIXP_TRANS_STATE_REQUEST_RECEIVED);
|
||||
break;
|
||||
case SIXP_PKT_TYPE_RESPONSE:
|
||||
ret = sixp_trans_transit_state(trans,
|
||||
SIXP_TRANS_STATE_RESPONSE_RECEIVED);
|
||||
break;
|
||||
case SIXP_PKT_TYPE_CONFIRMATION:
|
||||
ret = sixp_trans_transit_state(trans,
|
||||
SIXP_TRANS_STATE_CONFIRMATION_RECEIVED);
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
return;
|
||||
}
|
||||
if(ret < 0) {
|
||||
LOG_ERR("6P: sixp_input() fails because of state transition failure\n");
|
||||
LOG_ERR("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
return;
|
||||
}
|
||||
|
||||
if(sf->input != NULL) {
|
||||
sf->input(pkt.type, pkt.code, pkt.body, pkt.body_len, src_addr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_sent_callback_t func, void *arg, uint16_t arg_len)
|
||||
{
|
||||
sixp_trans_t *trans;
|
||||
sixp_nbr_t *nbr;
|
||||
sixp_pkt_cmd_t cmd;
|
||||
int16_t seqno, gen;
|
||||
sixp_pkt_t pkt;
|
||||
|
||||
assert(dest_addr != NULL);
|
||||
|
||||
/* validate the state of a transaction with a specified peer */
|
||||
trans = sixp_trans_find(dest_addr);
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(trans != NULL) {
|
||||
LOG_ERR("6P: sixp_output() fails because another trans for [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("] is in process\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a request */
|
||||
/* we're going to allocate a new transaction later */
|
||||
}
|
||||
} else if(type == SIXP_PKT_TYPE_RESPONSE) {
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6P: sixp_output() fails because of no transaction [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("]\n");
|
||||
return -1;
|
||||
} else if(sixp_trans_get_state(trans) !=
|
||||
SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
LOG_ERR("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a response */
|
||||
}
|
||||
} else if(type == SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
if(trans == NULL) {
|
||||
LOG_ERR("6P: sixp_output() fails because of no transaction [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("\n");
|
||||
return -1;
|
||||
} else if(sixp_trans_get_state(trans) !=
|
||||
SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
LOG_ERR("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a confirmation */
|
||||
}
|
||||
} else {
|
||||
LOG_ERR("6P: sixp_output() fails because of unsupported type [type:%u]\n",
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nbr = sixp_nbr_find(dest_addr);
|
||||
|
||||
/*
|
||||
* Make sure we have a nbr for the peer if the packet is a response with
|
||||
* success so that we can manage the schedule generation.
|
||||
*/
|
||||
if(nbr == NULL &&
|
||||
type == SIXP_PKT_TYPE_RESPONSE && code.value == SIXP_PKT_RC_SUCCESS &&
|
||||
((cmd = sixp_trans_get_cmd(trans)) == SIXP_PKT_CMD_ADD ||
|
||||
cmd == SIXP_PKT_CMD_DELETE) &&
|
||||
(nbr = sixp_nbr_alloc(dest_addr)) == NULL) {
|
||||
LOG_ERR("6P: sixp_output() fails because of no memory for another nbr\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set SeqNum */
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(nbr == NULL &&
|
||||
(nbr = sixp_nbr_alloc(dest_addr)) == NULL) {
|
||||
LOG_ERR("6P: sixp_output() fails because it fails to allocate a nbr\n");
|
||||
return -1;
|
||||
}
|
||||
if((seqno = sixp_nbr_get_next_seqno(nbr)) < 0){
|
||||
LOG_ERR("6P: sixp_output() fails to get the next sequence number\n");
|
||||
return -1;
|
||||
}
|
||||
if(sixp_nbr_increment_next_seqno(nbr) < 0) {
|
||||
LOG_ERR("6P: sixp_output() fails to increment the next sequence number\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
assert(trans != NULL);
|
||||
if((seqno = sixp_trans_get_seqno(trans)) < 0) {
|
||||
LOG_ERR("6P: sixp_output() fails because it fails to get seqno\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* set GEN */
|
||||
if(nbr == NULL) {
|
||||
gen = 0;
|
||||
} else if((gen = sixp_nbr_get_gen(nbr)) < 0) {
|
||||
LOG_ERR("6P: sixp_output() fails to get GEN\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* create a 6P packet within packetbuf */
|
||||
if(sixp_pkt_create(type, code, sfid,
|
||||
(uint8_t)seqno, (uint8_t)gen,
|
||||
body, body_len,
|
||||
type == SIXP_PKT_TYPE_REQUEST ? &pkt : NULL) < 0) {
|
||||
LOG_ERR("6P: sixp_output() fails to create a 6P packet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allocate a transaction for a sending request */
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
assert(trans == NULL);
|
||||
if((trans = sixp_trans_alloc(&pkt, dest_addr)) == NULL) {
|
||||
LOG_ERR("6P: sixp_output() is aborted because of no memory\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready for proceed */
|
||||
}
|
||||
}
|
||||
|
||||
assert(trans != NULL);
|
||||
sixp_trans_set_callback(trans, func, arg, arg_len);
|
||||
sixtop_output(dest_addr, mac_callback, trans);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixp_init(void)
|
||||
{
|
||||
sixp_nbr_init();
|
||||
sixp_trans_init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6top Protocol (6P) APIs
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef _SIXP_H_
|
||||
#define _SIXP_H_
|
||||
|
||||
#include "net/linkaddr.h"
|
||||
#include "sys/clock.h"
|
||||
|
||||
#include "sixp-pkt.h"
|
||||
|
||||
#define SIXP_SUBIE_ID 0x00
|
||||
|
||||
#ifdef SIXP_CONF_WITH_PAYLOAD_TERMINATION_IE
|
||||
#define SIXP_WITH_PAYLOAD_TERMINATION_IE SIXP_CONF_WITH_PAYLOAD_TERMINATION_IE
|
||||
#else
|
||||
#define SIXP_WITH_PAYLOAD_TERMINATION_IE 0
|
||||
#endif /* SIXP_CONF_WITH_PAYLOAD_TERMINATION_IE */
|
||||
|
||||
/**
|
||||
* \brief The initial sequence number used for 6P request
|
||||
*/
|
||||
#define SIXP_INITIAL_SEQUENCE_NUMBER 0
|
||||
|
||||
/**
|
||||
* \brief 6P Send Status, which represents sixp_output() result.
|
||||
*/
|
||||
typedef enum {
|
||||
SIXP_OUTPUT_STATUS_SUCCESS, /**< SUCCESS */
|
||||
SIXP_OUTPUT_STATUS_FAILURE /**< FAILURE */
|
||||
} sixp_output_status_t;
|
||||
|
||||
/**
|
||||
* \brief 6P Packet Sent Handler
|
||||
*/
|
||||
typedef void (*sixp_sent_callback_t)(void *arg, uint16_t arg_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_output_status_t status);
|
||||
|
||||
/**
|
||||
* \brief Input a 6P packet
|
||||
* \param buf The pointer to a buffer pointing the head of 6top IE Content
|
||||
* \param len The lengh of 6top IE Content
|
||||
* \param src_addr The Source address of an incoming packet
|
||||
* \return 0 if , -1 on failure
|
||||
*/
|
||||
void sixp_input(const uint8_t *buf, uint16_t len,
|
||||
const linkaddr_t *src_addr);
|
||||
|
||||
/**
|
||||
* \brief Output a 6P packet
|
||||
* \param type Message Type
|
||||
* \param code Message Code; Command ID or Return Code
|
||||
* \param sfid Scheduling Function Identifier
|
||||
* \param body 6top IE Content
|
||||
* \param body_len The length of 6top IE Content
|
||||
* \param dest_addr The destination Address
|
||||
* \param func callback function invoked after the transmission process
|
||||
* \param arg The pointer to an argument to be passed with the callback
|
||||
* \param arg_len The length of the argument
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
int sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
const uint8_t *body, uint16_t body_len,
|
||||
const linkaddr_t *dest_addr,
|
||||
sixp_sent_callback_t func, void *arg, uint16_t arg_len);
|
||||
|
||||
/**
|
||||
* \brief Initialize 6P Module
|
||||
* It invokes sixp_nbr_init() and sixp_trans_init().
|
||||
*/
|
||||
void sixp_init(void);
|
||||
#endif /* ! _SIXP_H_ */
|
||||
/** @} */
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6top Configuration
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef __SIXTOP_CONF_H__
|
||||
#define __SIXTOP_CONF_H__
|
||||
|
||||
/**
|
||||
* \brief The maximum number of Scheduling Functions in the system.
|
||||
*/
|
||||
#ifdef SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS
|
||||
#define SIXTOP_MAX_SCHEDULING_FUNCTIONS SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS
|
||||
#else
|
||||
#define SIXTOP_MAX_SCHEDULING_FUNCTIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The maximum number of transactions which the sixtop module can handle
|
||||
* at the same time.
|
||||
*/
|
||||
#ifdef SIXTOP_CONF_MAX_TRANSACTIONS
|
||||
#define SIXTOP_MAX_TRANSACTIONS SIXTOP_CONF_MAX_TRANSACTIONS
|
||||
#else
|
||||
#define SIXTOP_MAX_TRANSACTIONS 1
|
||||
#endif
|
||||
|
||||
#endif /* !__SIXTOP_CONF_H__ */
|
||||
/** @} */
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup sixtop
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6TiSCH Operation Sublayer (6top)
|
||||
*
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "net/netstack.h"
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/mac/framer/frame802154.h"
|
||||
#include "net/mac/framer/frame802154e-ie.h"
|
||||
|
||||
#include "sixtop.h"
|
||||
#include "sixtop-conf.h"
|
||||
#include "sixp.h"
|
||||
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
const sixtop_sf_t *scheduling_functions[SIXTOP_MAX_SCHEDULING_FUNCTIONS];
|
||||
|
||||
const sixtop_sf_t *sixtop_find_sf(uint8_t sfid);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
strip_payload_termination_ie(void)
|
||||
{
|
||||
uint8_t *ptr = packetbuf_dataptr();
|
||||
if(ptr[0] == 0x00 && ptr[1] == 0xf8) {
|
||||
/* Payload Termination IE is 2 octets long */
|
||||
packetbuf_hdrreduce(2);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixtop_add_sf(const sixtop_sf_t *sf)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(sf != NULL);
|
||||
|
||||
LOG_INFO("6top: sixtop_add_sf() is adding a SF [SFID:%u]\n", sf->sfid);
|
||||
|
||||
if(sixtop_find_sf(sf->sfid) != NULL) {
|
||||
LOG_ERR("6top: sixtop_add_sf() fails because of duplicate SF\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < SIXTOP_MAX_SCHEDULING_FUNCTIONS; i++) {
|
||||
if(scheduling_functions[i] == NULL) {
|
||||
scheduling_functions[i] = sf;
|
||||
if(sf->init != NULL) {
|
||||
sf->init();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == SIXTOP_MAX_SCHEDULING_FUNCTIONS) {
|
||||
LOG_ERR("6top: sixtop_add_sf() fails because of no memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sf->init != NULL) {
|
||||
sf->init();
|
||||
}
|
||||
LOG_INFO("6top: SF [SFID:%u] has been added and initialized\n", sf->sfid);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const sixtop_sf_t *
|
||||
sixtop_find_sf(uint8_t sfid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < SIXTOP_MAX_SCHEDULING_FUNCTIONS; i++) {
|
||||
if(scheduling_functions[i] != NULL &&
|
||||
scheduling_functions[i]->sfid == sfid) {
|
||||
return (const sixtop_sf_t *)scheduling_functions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
{
|
||||
uint8_t *p;
|
||||
struct ieee802154_ies ies;
|
||||
int len;
|
||||
|
||||
assert(dest_addr != NULL);
|
||||
if(dest_addr == NULL) {
|
||||
LOG_ERR("6top: sixtop_output() fails because dest_addr is NULL\n");
|
||||
if(callback != NULL) {
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* prepend 6top Sub-IE ID */
|
||||
if(packetbuf_hdralloc(1) != 1) {
|
||||
LOG_ERR("6top: sixtop_output() fails because of no room for Sub-IE ID\n");
|
||||
return;
|
||||
}
|
||||
p = packetbuf_hdrptr();
|
||||
p[0] = SIXTOP_SUBIE_ID;
|
||||
|
||||
/*
|
||||
* prepend Payload IE header; 2 octets
|
||||
* only sixtop_ie_content_len matters in frame80215e_create_ie_ietf().
|
||||
*/
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
ies.sixtop_ie_content_len = packetbuf_totlen();
|
||||
if(packetbuf_hdralloc(2) != 1 ||
|
||||
(len = frame80215e_create_ie_ietf(packetbuf_hdrptr(),
|
||||
2,
|
||||
&ies)) < 0) {
|
||||
LOG_ERR("6top: sixtop_output() fails because of Payload IE Header\n");
|
||||
if(callback != NULL) {
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#if SIXP_WITH_PAYLOAD_TERMINATION_IE
|
||||
/* append Payload Termination IE to the data field; 2 octets */
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
if((len = frame80215e_create_ie_payload_list_termination(
|
||||
(uint8_t *)packetbuf_dataptr() + packetbuf_datalen(),
|
||||
PACKETBUF_SIZE - packetbuf_totlen(),
|
||||
&ies)) < 0) {
|
||||
LOG_ERR("6top: sixtop_output() fails because of Payload Termination IE\n");
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
return;
|
||||
}
|
||||
packetbuf_set_datalen(packetbuf_datalen() + len);
|
||||
#endif /* SIXP_WITH_PAYLOAD_TERMINATION_IE */
|
||||
|
||||
/* prepend Termination 1 IE to the header field; 2 octets */
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
if(packetbuf_hdralloc(2) &&
|
||||
frame80215e_create_ie_header_list_termination_1(packetbuf_hdrptr(),
|
||||
2,
|
||||
&ies) < 0) {
|
||||
LOG_ERR("6top: sixtop_output() fails because of Header Termination 1 IE\n");
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* specify with PACKETBUF_ATTR_METADATA that packetbuf has IEs */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAC_METADATA, 1);
|
||||
|
||||
/* 6P packet is data frame */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
|
||||
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, dest_addr);
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
|
||||
NETSTACK_MAC.send(callback, arg);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixtop_input(void)
|
||||
{
|
||||
uint8_t *hdr_ptr, *payload_ptr;
|
||||
uint16_t hdr_len, payload_len;
|
||||
|
||||
frame802154_t frame;
|
||||
struct ieee802154_ies ies;
|
||||
linkaddr_t src_addr;
|
||||
|
||||
/*
|
||||
* A received *DATA* frame is supposed to be stored in packetbuf by
|
||||
* framer_802154.parse(). packetbuf_dataptr() points at the starting address
|
||||
* of the IE field or Frame Payload field if it's available. FCS should not be
|
||||
* in packetbuf, which is expected to be stripped at a radio.
|
||||
*/
|
||||
|
||||
payload_ptr = packetbuf_dataptr();
|
||||
payload_len = packetbuf_datalen();
|
||||
hdr_len = packetbuf_hdrlen();
|
||||
hdr_ptr = payload_ptr - hdr_len;
|
||||
|
||||
memcpy(&src_addr, packetbuf_addr(PACKETBUF_ADDR_SENDER), sizeof(src_addr));
|
||||
|
||||
if(frame802154_parse(hdr_ptr, hdr_len, &frame) == 0) {
|
||||
/* parse error; should not occur, anyway */
|
||||
LOG_ERR("6top: frame802154_parse error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't need to check the frame version nor frame type. The frame version
|
||||
* is turned out to be 0b10 automatically if the frame has a IE list. The
|
||||
* frame type is supposed to be DATA as mentioned above.
|
||||
*/
|
||||
assert(frame.fcf.frame_version == FRAME802154_IEEE802154_2015);
|
||||
assert(frame.fcf.frame_type == FRAME802154_DATAFRAME);
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
if(frame.fcf.ie_list_present &&
|
||||
frame802154e_parse_information_elements(payload_ptr,
|
||||
payload_len, &ies) >= 0 &&
|
||||
ies.sixtop_ie_content_ptr != NULL &&
|
||||
ies.sixtop_ie_content_len > 0) {
|
||||
|
||||
sixp_input(ies.sixtop_ie_content_ptr, ies.sixtop_ie_content_len,
|
||||
&src_addr);
|
||||
|
||||
/*
|
||||
* move payloadbuf_dataptr() to the beginning of the next layer for further
|
||||
* processing
|
||||
*/
|
||||
packetbuf_hdrreduce(ies.sixtop_ie_content_ptr - payload_ptr +
|
||||
ies.sixtop_ie_content_len);
|
||||
strip_payload_termination_ie();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixtop_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
sixp_init();
|
||||
|
||||
for(i = 0; i < SIXTOP_MAX_SCHEDULING_FUNCTIONS; i++) {
|
||||
scheduling_functions[i] = NULL;
|
||||
}
|
||||
|
||||
sixtop_init_sf();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
sixtop_init_sf(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < SIXTOP_MAX_SCHEDULING_FUNCTIONS; i++) {
|
||||
if(scheduling_functions[i] != NULL &&
|
||||
scheduling_functions[i]->init != NULL) {
|
||||
scheduling_functions[i]->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup net
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \defgroup sixtop 6TiSCH Operation Sublayer (6top)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* 6TiSCH Operation Sublayer (6top) APIs
|
||||
* \author
|
||||
* Yasuyuki Tanaka <yasuyuki.tanaka@inf.ethz.ch>
|
||||
*/
|
||||
|
||||
#ifndef _SIXTOP_H_
|
||||
#define _SIXTOP_H_
|
||||
|
||||
#include "net/mac/mac.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
||||
#include "sixp-pkt.h"
|
||||
|
||||
#define SIXTOP_SUBIE_ID 0xc9
|
||||
|
||||
/**
|
||||
* \brief Input Handler of Scheduling Function
|
||||
* \param type 6P Message Type of an input packet
|
||||
* \param code Code, 6P Command Identifier or Return Code, of an input packet
|
||||
* \param body Body, "Other Fields", of an input packet
|
||||
* \param body_len The length of body
|
||||
* \param body src_addr Source address of an input packet
|
||||
*/
|
||||
typedef void (* sixtop_sf_input)(sixp_pkt_type_t type,
|
||||
sixp_pkt_code_t code,
|
||||
const uint8_t *body,
|
||||
uint16_t body_len,
|
||||
const linkaddr_t *src_addr);
|
||||
|
||||
/**
|
||||
* \brief Timeout Handler of Scheduling Function
|
||||
* \param cmd 6P Command (Identifier) in process under the transaction
|
||||
* \param peer_addr The peer address of the transaction
|
||||
*/
|
||||
typedef void (* sixtop_sf_timeout)(sixp_pkt_cmd_t cmd,
|
||||
const linkaddr_t *peer_addr);
|
||||
/**
|
||||
* /brief Scheduling Function Driver
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t sfid; /**< SFID */
|
||||
clock_time_t timeout_interval; /**< Timeout Value */
|
||||
void (*init)(void); /**< Init Function */
|
||||
sixtop_sf_input input; /**< Input Handler */
|
||||
sixtop_sf_timeout timeout; /**< Transaction Timeout Handler */
|
||||
} sixtop_sf_t;
|
||||
/**
|
||||
* \var sixtop_sf_t::sfid
|
||||
* managed: 0x00-0xfe
|
||||
* unmanaged: 0xf0-0xfe
|
||||
* reserved: 0xff
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Add a Scheduling Function (SF) to 6top Sublayer
|
||||
* \param sf The pointer to a Scheduling Function Driver
|
||||
* \return 0 on success, -1 on failure
|
||||
*
|
||||
* If there is a SF whose SF is identical to one of a SF specified to this API,
|
||||
* the addition will fail and -1 will be returned. If there is no room to
|
||||
* another SF, -1 will be returned as well. You can specify how many SFs can be
|
||||
* added with SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS.
|
||||
*/
|
||||
int sixtop_add_sf(const sixtop_sf_t *sf);
|
||||
|
||||
/**
|
||||
* \brief Find a SF which has been added by SFID
|
||||
* \param sfid Scheduling Function Identifier of a SF
|
||||
* \return The pointer to a SF driver having the specified SFID on success, NULL
|
||||
* on failure (not found)
|
||||
*/
|
||||
const sixtop_sf_t *sixtop_find_sf(uint8_t sfid);
|
||||
|
||||
/**
|
||||
* \brief Output a 6P packet which is supposestored in packetbuf
|
||||
* \param dest_addr Destination address of the outgoing packet
|
||||
* \param callback MAC callback function to get a TX result
|
||||
* \param arg The pointer to an argument which is returned with the MAC callback
|
||||
*/
|
||||
void sixtop_output(const linkaddr_t *dest_addr,
|
||||
mac_callback_t callback, void *arg);
|
||||
|
||||
/**
|
||||
* \brief Input a packet stored in packetbuf
|
||||
*/
|
||||
void sixtop_input(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize 6top module
|
||||
* This initialization function removes all the SFs which has been installed
|
||||
* into the 6top sub-layer. In addition, it invokes sixp_init().
|
||||
*/
|
||||
void sixtop_init(void);
|
||||
|
||||
/**
|
||||
* \brief Initialize installed SFs which has been added in the system
|
||||
* This function is supposed to be invoked every time the node gets associated.
|
||||
*/
|
||||
void sixtop_init_sf(void);
|
||||
|
||||
#endif /* !_SIXTOP_H_ */
|
||||
/** @} */
|
||||
/** @} */
|
|
@ -56,64 +56,101 @@
|
|||
#define LOG_MODULE "TSCH Pkt"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||
|
||||
/*
|
||||
* We use a local packetbuf_attr array to collect necessary frame settings to
|
||||
* create an EACK because EACK is generated in the interrupt context where
|
||||
* packetbuf and packetbuf_attrs[] may be in use for another purpose.
|
||||
*
|
||||
* We have accessors of eackbuf_attrs: tsch_packet_eackbuf_set_attr() and
|
||||
* tsch_packet_eackbuf_attr(). For some platform, they might need to be
|
||||
* implemented as inline functions. However, for now, we don't provide the
|
||||
* inline option. Such an optimization is left to the compiler for a target
|
||||
* platform.
|
||||
*/
|
||||
static struct packetbuf_attr eackbuf_attrs[PACKETBUF_NUM_ATTRS];
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
tsch_packet_eackbuf_set_attr(uint8_t type, const packetbuf_attr_t val)
|
||||
{
|
||||
eackbuf_attrs[type].val = val;
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Return the value of a specified attribute */
|
||||
packetbuf_attr_t
|
||||
tsch_packet_eackbuf_attr(uint8_t type)
|
||||
{
|
||||
return eackbuf_attrs[type].val;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Construct enhanced ACK packet and return ACK length */
|
||||
int
|
||||
tsch_packet_create_eack(uint8_t *buf, int buf_size,
|
||||
const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack)
|
||||
tsch_packet_create_eack(uint8_t *buf, uint16_t buf_len,
|
||||
const linkaddr_t *dest_addr, uint8_t seqno,
|
||||
int16_t drift, int nack)
|
||||
{
|
||||
int ret;
|
||||
uint8_t curr_len = 0;
|
||||
frame802154_t p;
|
||||
frame802154_t params;
|
||||
struct ieee802154_ies ies;
|
||||
int hdr_len;
|
||||
int ack_len;
|
||||
|
||||
memset(&p, 0, sizeof(p));
|
||||
p.fcf.frame_type = FRAME802154_ACKFRAME;
|
||||
p.fcf.frame_version = FRAME802154_IEEE802154_2015;
|
||||
p.fcf.ie_list_present = 1;
|
||||
/* Compression unset. According to IEEE802.15.4e-2012:
|
||||
* - if no address is present: elide PAN ID
|
||||
* - if at least one address is present: include exactly one PAN ID (dest by default) */
|
||||
p.fcf.panid_compression = 0;
|
||||
p.dest_pid = IEEE802154_PANID;
|
||||
p.seq = seqno;
|
||||
if(buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(eackbuf_attrs, 0, sizeof(eackbuf_attrs));
|
||||
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_ACKFRAME);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_METADATA, 1);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, seqno);
|
||||
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_NO_DEST_ADDR, 1);
|
||||
#if TSCH_PACKET_EACK_WITH_DEST_ADDR
|
||||
if(dest_addr != NULL) {
|
||||
p.fcf.dest_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;;
|
||||
linkaddr_copy((linkaddr_t *)&p.dest_addr, dest_addr);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_NO_DEST_ADDR, 0);
|
||||
linkaddr_copy((linkaddr_t *)¶ms.dest_addr, dest_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_NO_SRC_ADDR, 1);
|
||||
#if TSCH_PACKET_EACK_WITH_SRC_ADDR
|
||||
p.fcf.src_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;;
|
||||
p.src_pid = IEEE802154_PANID;
|
||||
linkaddr_copy((linkaddr_t *)&p.src_addr, &linkaddr_node_addr);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_MAC_NO_SRC_ADDR, 0);
|
||||
linkaddr_copy((linkaddr_t *)¶ms.src_addr, &linkaddr_node_addr);
|
||||
#endif
|
||||
|
||||
#if LLSEC802154_ENABLED
|
||||
if(tsch_is_pan_secured) {
|
||||
p.fcf.security_enabled = 1;
|
||||
p.aux_hdr.security_control.security_level = TSCH_SECURITY_KEY_SEC_LEVEL_ACK;
|
||||
p.aux_hdr.security_control.key_id_mode = FRAME802154_1_BYTE_KEY_ID_MODE;
|
||||
p.aux_hdr.security_control.frame_counter_suppression = 1;
|
||||
p.aux_hdr.security_control.frame_counter_size = 1;
|
||||
p.aux_hdr.key_index = TSCH_SECURITY_KEY_INDEX_ACK;
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL,
|
||||
TSCH_SECURITY_KEY_SEC_LEVEL_ACK);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE,
|
||||
FRAME802154_1_BYTE_KEY_ID_MODE);
|
||||
tsch_packet_eackbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX,
|
||||
TSCH_SECURITY_KEY_INDEX_ACK);
|
||||
}
|
||||
#endif /* LLSEC802154_ENABLED */
|
||||
|
||||
if((curr_len = frame802154_create(&p, buf)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
framer_802154_setup_params(tsch_packet_eackbuf_attr, 0, ¶ms);
|
||||
hdr_len = frame802154_hdrlen(¶ms);
|
||||
|
||||
/* Append IE timesync */
|
||||
memset(buf, 0, buf_len);
|
||||
|
||||
/* Setup IE timesync */
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
ies.ie_time_correction = drift;
|
||||
ies.ie_is_nack = nack;
|
||||
|
||||
if((ret = frame80215e_create_ie_header_ack_nack_time_correction(buf+curr_len, buf_size-curr_len, &ies)) == -1) {
|
||||
ack_len =
|
||||
frame80215e_create_ie_header_ack_nack_time_correction(buf + hdr_len,
|
||||
buf_len - hdr_len, &ies);
|
||||
if(ack_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
ack_len += hdr_len;
|
||||
|
||||
return curr_len;
|
||||
frame802154_create(¶ms, buf);
|
||||
|
||||
return ack_len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Parse enhanced ACK packet, extract drift and nack */
|
||||
|
@ -183,52 +220,14 @@ tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* Create an EB packet */
|
||||
int
|
||||
tsch_packet_create_eb(uint8_t *buf, int buf_size,
|
||||
uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset)
|
||||
tsch_packet_create_eb(uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t curr_len = 0;
|
||||
uint8_t mlme_ie_offset;
|
||||
|
||||
frame802154_t p;
|
||||
struct ieee802154_ies ies;
|
||||
uint8_t *p;
|
||||
int ie_len;
|
||||
const uint16_t payload_ie_hdr_len = 2;
|
||||
|
||||
if(buf_size < TSCH_PACKET_MAX_LEN) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create 802.15.4 header */
|
||||
memset(&p, 0, sizeof(p));
|
||||
p.fcf.frame_type = FRAME802154_BEACONFRAME;
|
||||
p.fcf.ie_list_present = 1;
|
||||
p.fcf.frame_version = FRAME802154_IEEE802154_2015;
|
||||
p.fcf.src_addr_mode = LINKADDR_SIZE > 2 ? FRAME802154_LONGADDRMODE : FRAME802154_SHORTADDRMODE;
|
||||
p.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
|
||||
p.fcf.sequence_number_suppression = 1;
|
||||
/* It is important not to compress PAN ID, as this would result in not including either
|
||||
* source nor destination PAN ID, leaving potential joining devices unaware of the PAN ID. */
|
||||
p.fcf.panid_compression = 0;
|
||||
|
||||
p.src_pid = frame802154_get_pan_id();
|
||||
p.dest_pid = frame802154_get_pan_id();
|
||||
linkaddr_copy((linkaddr_t *)&p.src_addr, &linkaddr_node_addr);
|
||||
p.dest_addr[0] = 0xff;
|
||||
p.dest_addr[1] = 0xff;
|
||||
|
||||
#if LLSEC802154_ENABLED
|
||||
if(tsch_is_pan_secured) {
|
||||
p.fcf.security_enabled = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL) > 0;
|
||||
p.aux_hdr.security_control.security_level = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL);
|
||||
p.aux_hdr.security_control.key_id_mode = packetbuf_attr(PACKETBUF_ATTR_KEY_ID_MODE);
|
||||
p.aux_hdr.security_control.frame_counter_suppression = 1;
|
||||
p.aux_hdr.security_control.frame_counter_size = 1;
|
||||
p.aux_hdr.key_index = packetbuf_attr(PACKETBUF_ATTR_KEY_INDEX);
|
||||
}
|
||||
#endif /* LLSEC802154_ENABLED */
|
||||
|
||||
if((curr_len = frame802154_create(&p, buf)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
packetbuf_clear();
|
||||
|
||||
/* Prepare Information Elements for inclusion in the EB */
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
|
@ -249,7 +248,8 @@ tsch_packet_create_eb(uint8_t *buf, int buf_size,
|
|||
if(tsch_hopping_sequence_length.val <= sizeof(ies.ie_hopping_sequence_list)) {
|
||||
ies.ie_channel_hopping_sequence_id = 1;
|
||||
ies.ie_hopping_sequence_len = tsch_hopping_sequence_length.val;
|
||||
memcpy(ies.ie_hopping_sequence_list, tsch_hopping_sequence, ies.ie_hopping_sequence_len);
|
||||
memcpy(ies.ie_hopping_sequence_list, tsch_hopping_sequence,
|
||||
ies.ie_hopping_sequence_len);
|
||||
}
|
||||
#endif /* TSCH_PACKET_EB_WITH_HOPPING_SEQUENCE */
|
||||
|
||||
|
@ -265,66 +265,121 @@ tsch_packet_create_eb(uint8_t *buf, int buf_size,
|
|||
ies.ie_tsch_slotframe_and_link.slotframe_size = sf0->size.val;
|
||||
ies.ie_tsch_slotframe_and_link.num_links = 1;
|
||||
ies.ie_tsch_slotframe_and_link.links[0].timeslot = link0->timeslot;
|
||||
ies.ie_tsch_slotframe_and_link.links[0].channel_offset = link0->channel_offset;
|
||||
ies.ie_tsch_slotframe_and_link.links[0].link_options = link0->link_options;
|
||||
ies.ie_tsch_slotframe_and_link.links[0].channel_offset =
|
||||
link0->channel_offset;
|
||||
ies.ie_tsch_slotframe_and_link.links[0].link_options =
|
||||
link0->link_options;
|
||||
}
|
||||
}
|
||||
#endif /* TSCH_PACKET_EB_WITH_SLOTFRAME_AND_LINK */
|
||||
|
||||
/* First add header-IE termination IE to stipulate that next come payload IEs */
|
||||
if((ret = frame80215e_create_ie_header_list_termination_1(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
p = packetbuf_dataptr();
|
||||
|
||||
ie_len = frame80215e_create_ie_tsch_synchronization(p,
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
p += ie_len;
|
||||
packetbuf_set_datalen(packetbuf_datalen() + ie_len);
|
||||
|
||||
/* We start payload IEs, save offset */
|
||||
if(hdr_len != NULL) {
|
||||
*hdr_len = curr_len;
|
||||
}
|
||||
|
||||
/* Save offset of the MLME IE descriptor, we need to know the total length
|
||||
* before writing it */
|
||||
mlme_ie_offset = curr_len;
|
||||
curr_len += 2; /* Space needed for MLME descriptor */
|
||||
|
||||
/* Save the offset of the TSCH Synchronization IE, needed to update ASN and join priority before sending */
|
||||
if(tsch_sync_ie_offset != NULL) {
|
||||
*tsch_sync_ie_offset = curr_len;
|
||||
}
|
||||
if((ret = frame80215e_create_ie_tsch_synchronization(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
ie_len = frame80215e_create_ie_tsch_timeslot(p,
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
p += ie_len;
|
||||
packetbuf_set_datalen(packetbuf_datalen() + ie_len);
|
||||
|
||||
if((ret = frame80215e_create_ie_tsch_timeslot(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
ie_len = frame80215e_create_ie_tsch_channel_hopping_sequence(p,
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
p += ie_len;
|
||||
packetbuf_set_datalen(packetbuf_datalen() + ie_len);
|
||||
|
||||
if((ret = frame80215e_create_ie_tsch_channel_hopping_sequence(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
|
||||
if((ret = frame80215e_create_ie_tsch_slotframe_and_link(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
|
||||
ies.ie_mlme_len = curr_len - mlme_ie_offset - 2;
|
||||
if((ret = frame80215e_create_ie_mlme(buf + mlme_ie_offset, buf_size - mlme_ie_offset, &ies)) == -1) {
|
||||
ie_len = frame80215e_create_ie_tsch_slotframe_and_link(p,
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
p += ie_len;
|
||||
packetbuf_set_datalen(packetbuf_datalen() + ie_len);
|
||||
|
||||
#if 0
|
||||
/* Payload IE list termination: optional */
|
||||
/*
|
||||
if((ret = frame80215e_create_ie_payload_list_termination(buf + curr_len, buf_size - curr_len, &ies)) == -1) {
|
||||
ie_len = frame80215e_create_ie_payload_list_termination(p,
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
curr_len += ret;
|
||||
*/
|
||||
p += ie_len;
|
||||
packetbuf_set_datalen(packetbuf_datalen() + ie_len);
|
||||
#endif
|
||||
|
||||
return curr_len;
|
||||
ies.ie_mlme_len = packetbuf_datalen();
|
||||
|
||||
/* make room for Payload IE header */
|
||||
memmove((uint8_t *)packetbuf_dataptr() + payload_ie_hdr_len,
|
||||
packetbuf_dataptr(), packetbuf_datalen());
|
||||
packetbuf_set_datalen(packetbuf_datalen() + payload_ie_hdr_len);
|
||||
ie_len = frame80215e_create_ie_mlme(packetbuf_dataptr(),
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allocate space for Header Termination IE, the size of which is 2 octets */
|
||||
packetbuf_hdralloc(2);
|
||||
ie_len = frame80215e_create_ie_header_list_termination_1(packetbuf_hdrptr(),
|
||||
packetbuf_remaininglen(),
|
||||
&ies);
|
||||
if(ie_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_BEACONFRAME);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_MAC_METADATA, 1);
|
||||
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &tsch_eb_address);
|
||||
|
||||
#if LLSEC802154_ENABLED
|
||||
if(tsch_is_pan_secured) {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL,
|
||||
TSCH_SECURITY_KEY_SEC_LEVEL_EB);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE,
|
||||
FRAME802154_1_BYTE_KEY_ID_MODE);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX,
|
||||
TSCH_SECURITY_KEY_INDEX_EB);
|
||||
}
|
||||
#endif /* LLSEC802154_ENABLED */
|
||||
|
||||
if(NETSTACK_FRAMER.create() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(hdr_len != NULL) {
|
||||
*hdr_len = packetbuf_hdrlen();
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the offset of the TSCH Synchronization IE, which is expected to be
|
||||
* located just after the Payload IE header, needed to update ASN and join
|
||||
* priority before sending.
|
||||
*/
|
||||
if(tsch_sync_ie_offset != NULL) {
|
||||
*tsch_sync_ie_offset = packetbuf_hdrlen() + payload_ie_hdr_len;
|
||||
}
|
||||
|
||||
return packetbuf_totlen();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Update ASN in EB packet */
|
||||
|
|
|
@ -87,14 +87,14 @@ by default, useful in case of duplicate seqno */
|
|||
/********** Functions *********/
|
||||
|
||||
/* Construct enhanced ACK packet and return ACK length */
|
||||
int tsch_packet_create_eack(uint8_t *buf, int buf_size,
|
||||
const linkaddr_t *dest_addr, uint8_t seqno, int16_t drift, int nack);
|
||||
int tsch_packet_create_eack(uint8_t *buf, uint16_t buf_size,
|
||||
const linkaddr_t *dest_addr, uint8_t seqno,
|
||||
int16_t drift, int nack);
|
||||
/* Parse enhanced ACK packet, extract drift and nack */
|
||||
int tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
|
||||
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len);
|
||||
/* Create an EB packet */
|
||||
int tsch_packet_create_eb(uint8_t *buf, int buf_size,
|
||||
uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
|
||||
int tsch_packet_create_eb(uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
|
||||
/* Update ASN in EB packet */
|
||||
int tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset);
|
||||
/* Parse EB and extract ASN and join priority */
|
||||
|
|
|
@ -180,6 +180,16 @@ tsch_schedule_add_link(struct tsch_slotframe *slotframe,
|
|||
struct tsch_link *l = NULL;
|
||||
if(slotframe != NULL) {
|
||||
/* We currently support only one link per timeslot in a given slotframe. */
|
||||
|
||||
/* Validation of specified timeslot and channel_offset */
|
||||
if(timeslot > (slotframe->size.val - 1)) {
|
||||
LOG_ERR("! add_link invalid timeslot: %u\n", timeslot);
|
||||
return NULL;
|
||||
} else if(channel_offset > 15) {
|
||||
LOG_ERR("! add_link invalid channel_offset: %u\n", channel_offset);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Start with removing the link currently installed at this timeslot (needed
|
||||
* to keep neighbor state in sync with link options etc.) */
|
||||
tsch_schedule_remove_link_by_timeslot(slotframe, timeslot);
|
||||
|
|
|
@ -62,6 +62,10 @@
|
|||
#include "net/mac/tsch/tsch-rpl.h"
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
||||
#if TSCH_WITH_SIXTOP
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
#endif
|
||||
|
||||
#if FRAME802154_VERSION < FRAME802154_IEEE802154_2015
|
||||
#error TSCH: FRAME802154_VERSION must be at least FRAME802154_IEEE802154_2015
|
||||
#endif
|
||||
|
@ -245,7 +249,6 @@ tsch_reset(void)
|
|||
#endif /* TSCH_AUTOSELECT_TIME_SOURCE */
|
||||
tsch_set_eb_period(TSCH_EB_PERIOD);
|
||||
}
|
||||
|
||||
/* TSCH keep-alive functions */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -407,7 +410,6 @@ eb_input(struct input_packet *current_input)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Process pending input packet(s) */
|
||||
static void
|
||||
|
@ -443,7 +445,6 @@ tsch_rx_process_pending()
|
|||
ringbufindex_get(&input_ringbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Pass sent packets to upper layer */
|
||||
static void
|
||||
|
@ -526,7 +527,6 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
|
|||
return 0;
|
||||
}
|
||||
#endif /* TSCH_JOIN_SECURED_ONLY */
|
||||
|
||||
#if LLSEC802154_ENABLED
|
||||
if(!tsch_security_parse_frame(input_eb->payload, hdrlen,
|
||||
input_eb->len - hdrlen - tsch_security_mic_len(&frame),
|
||||
|
@ -672,7 +672,6 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
|
|||
LOG_ERR("! did not associate.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Processes and protothreads used by TSCH */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -816,30 +815,17 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data)
|
|||
if(tsch_is_associated && tsch_current_eb_period > 0) {
|
||||
/* Enqueue EB only if there isn't already one in queue */
|
||||
if(tsch_queue_packet_count(&tsch_eb_address) == 0) {
|
||||
int eb_len;
|
||||
uint8_t hdr_len = 0;
|
||||
uint8_t tsch_sync_ie_offset;
|
||||
/* Prepare the EB packet and schedule it to be sent */
|
||||
packetbuf_clear();
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_BEACONFRAME);
|
||||
#if LLSEC802154_ENABLED
|
||||
if(tsch_is_pan_secured) {
|
||||
/* Set security level, key id and index */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, TSCH_SECURITY_KEY_SEC_LEVEL_EB);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, FRAME802154_1_BYTE_KEY_ID_MODE); /* Use 1-byte key index */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, TSCH_SECURITY_KEY_INDEX_EB);
|
||||
}
|
||||
#endif /* LLSEC802154_ENABLED */
|
||||
eb_len = tsch_packet_create_eb(packetbuf_dataptr(), PACKETBUF_SIZE,
|
||||
&hdr_len, &tsch_sync_ie_offset);
|
||||
if(eb_len > 0) {
|
||||
if(tsch_packet_create_eb(&hdr_len, &tsch_sync_ie_offset) > 0) {
|
||||
struct tsch_packet *p;
|
||||
packetbuf_set_datalen(eb_len);
|
||||
/* Enqueue EB packet */
|
||||
if(!(p = tsch_queue_add_packet(&tsch_eb_address, NULL, NULL))) {
|
||||
LOG_ERR("! could not enqueue EB packet\n");
|
||||
} else {
|
||||
LOG_INFO("enqueue EB packet %u %u\n", eb_len, hdr_len);
|
||||
LOG_INFO("TSCH: enqueue EB packet %u %u\n",
|
||||
packetbuf_totlen(), packetbuf_hdrlen());
|
||||
p->tsch_sync_ie_offset = tsch_sync_ie_offset;
|
||||
p->header_len = hdr_len;
|
||||
}
|
||||
|
@ -946,6 +932,10 @@ tsch_init(void)
|
|||
* If TSCH_AUTOSTART is not set, one needs to call NETSTACK_MAC.on() to start TSCH. */
|
||||
NETSTACK_MAC.on();
|
||||
#endif /* TSCH_AUTOSTART */
|
||||
|
||||
#if TSCH_WITH_SIXTOP
|
||||
sixtop_init();
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Function send for TSCH-MAC, puts the packet in packetbuf in the MAC queue */
|
||||
|
@ -1061,6 +1051,9 @@ packet_input(void)
|
|||
LOG_INFO("received from ");
|
||||
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
LOG_INFO_(" with seqno %u\n", packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
|
||||
#if TSCH_WITH_SIXTOP
|
||||
sixtop_input();
|
||||
#endif /* TSCH_WITH_SIXTOP */
|
||||
NETSTACK_NETWORK.input();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,13 @@
|
|||
#define TSCH_AUTOSELECT_TIME_SOURCE 0
|
||||
#endif /* TSCH_CONF_EB_AUTOSELECT */
|
||||
|
||||
/* To include Sixtop Implementation */
|
||||
#ifdef TSCH_CONF_WITH_SIXTOP
|
||||
#define TSCH_WITH_SIXTOP TSCH_CONF_WITH_SIXTOP
|
||||
#else
|
||||
#define TSCH_WITH_SIXTOP 0
|
||||
#endif /* TSCH_CONF_EB_AUTOSELECT */
|
||||
|
||||
/*********** Callbacks *********/
|
||||
|
||||
/* Called by TSCH when joining a network */
|
||||
|
|
|
@ -301,6 +301,16 @@ nbr_table_register(nbr_table_t *table, nbr_table_callback *callback)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Test whether a specified table has been registered or not */
|
||||
int
|
||||
nbr_table_is_register(nbr_table_t *table)
|
||||
{
|
||||
if(table != NULL && all_tables[table->index] == table) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Returns the first item of the current table */
|
||||
nbr_table_item_t *
|
||||
nbr_table_head(nbr_table_t *table)
|
||||
|
|
|
@ -76,7 +76,7 @@ typedef struct nbr_table {
|
|||
#define NBR_TABLE_DECLARE(name) extern nbr_table_t *name
|
||||
|
||||
typedef enum {
|
||||
NBR_TABLE_REASON_UNDEFINED,
|
||||
NBR_TABLE_REASON_UNDEFINED,
|
||||
NBR_TABLE_REASON_RPL_DIO,
|
||||
NBR_TABLE_REASON_RPL_DAO,
|
||||
NBR_TABLE_REASON_RPL_DIS,
|
||||
|
@ -86,11 +86,13 @@ typedef enum {
|
|||
NBR_TABLE_REASON_MAC,
|
||||
NBR_TABLE_REASON_LLSEC,
|
||||
NBR_TABLE_REASON_LINK_STATS,
|
||||
NBR_TABLE_REASON_SIXTOP,
|
||||
} nbr_table_reason_t;
|
||||
|
||||
/** \name Neighbor tables: register and loop through table elements */
|
||||
/** @{ */
|
||||
int nbr_table_register(nbr_table_t *table, nbr_table_callback *callback);
|
||||
int nbr_table_is_register(nbr_table_t *table);
|
||||
nbr_table_item_t *nbr_table_head(nbr_table_t *table);
|
||||
nbr_table_item_t *nbr_table_next(nbr_table_t *table, nbr_table_item_t *item);
|
||||
/** @} */
|
||||
|
|
|
@ -219,6 +219,9 @@ enum {
|
|||
PACKETBUF_ATTR_TIMESTAMP,
|
||||
PACKETBUF_ATTR_MAC_SEQNO,
|
||||
PACKETBUF_ATTR_MAC_ACK,
|
||||
PACKETBUF_ATTR_MAC_METADATA,
|
||||
PACKETBUF_ATTR_MAC_NO_SRC_ADDR,
|
||||
PACKETBUF_ATTR_MAC_NO_DEST_ADDR,
|
||||
#if TSCH_WITH_LINK_SELECTOR
|
||||
PACKETBUF_ATTR_TSCH_SLOTFRAME,
|
||||
PACKETBUF_ATTR_TSCH_TIMESLOT,
|
||||
|
|
|
@ -102,6 +102,10 @@
|
|||
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_FRAMER */
|
||||
|
||||
#ifndef LOG_CONF_LEVEL_6TOP
|
||||
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_6TOP */
|
||||
|
||||
#endif /* __LOG_CONF_H__ */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -60,6 +60,7 @@ int curr_log_level_ipv6 = LOG_CONF_LEVEL_IPV6;
|
|||
int curr_log_level_6lowpan = LOG_CONF_LEVEL_6LOWPAN;
|
||||
int curr_log_level_mac = LOG_CONF_LEVEL_MAC;
|
||||
int curr_log_level_framer = LOG_CONF_LEVEL_FRAMER;
|
||||
int curr_log_level_6top = LOG_CONF_LEVEL_6TOP;
|
||||
|
||||
struct log_module all_modules[] = {
|
||||
{"rpl", &curr_log_level_rpl, LOG_CONF_LEVEL_RPL},
|
||||
|
@ -68,6 +69,7 @@ struct log_module all_modules[] = {
|
|||
{"6lowpan", &curr_log_level_6lowpan, LOG_CONF_LEVEL_6LOWPAN},
|
||||
{"mac", &curr_log_level_mac, LOG_CONF_LEVEL_MAC},
|
||||
{"framer", &curr_log_level_framer, LOG_CONF_LEVEL_FRAMER},
|
||||
{"6top", &curr_log_level_6top, LOG_CONF_LEVEL_6TOP},
|
||||
{NULL, NULL, 0},
|
||||
};
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ extern int curr_log_level_ipv6;
|
|||
extern int curr_log_level_6lowpan;
|
||||
extern int curr_log_level_mac;
|
||||
extern int curr_log_level_framer;
|
||||
extern int curr_log_level_6top;
|
||||
|
||||
extern struct log_module all_modules[];
|
||||
|
||||
|
@ -88,6 +89,7 @@ extern struct log_module all_modules[];
|
|||
#define LOG_LEVEL_6LOWPAN MIN((LOG_CONF_LEVEL_6LOWPAN), curr_log_level_6lowpan)
|
||||
#define LOG_LEVEL_MAC MIN((LOG_CONF_LEVEL_MAC), curr_log_level_mac)
|
||||
#define LOG_LEVEL_FRAMER MIN((LOG_CONF_LEVEL_FRAMER), curr_log_level_framer)
|
||||
#define LOG_LEVEL_6TOP MIN((LOG_CONF_LEVEL_6TOP), curr_log_level_6top)
|
||||
|
||||
/* Main log function */
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONFIG_DIR]/js/03-tsch-flush-nbr-queue.js</scriptfile>
|
||||
<scriptfile>[CONFIG_DIR]/js/02-tsch-flush-nbr-queue.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
|
@ -48,6 +48,9 @@
|
|||
#undef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC tschmac_driver
|
||||
|
||||
#undef TSCH_CONF_WITH_SIXTOP
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#define COOJA_CONF_SIMULATE_TURNAROUND 0
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
|
|
|
@ -1,386 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "unit-test/unit-test.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/tsch-asn.h"
|
||||
#include "net/mac/tsch/tsch-packet.h"
|
||||
#include "net/mac/tsch/tsch-schedule.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#ifndef TEST_CONFIG_TYPE
|
||||
#define TEST_CONFIG_TYPE DEFAULT
|
||||
#endif
|
||||
|
||||
typedef enum { SUCCESS, FAILURE } result_t;
|
||||
|
||||
typedef enum { DEFAULT = 0, SECURITY_ON, ALL_ENABLED } config_type_t;
|
||||
|
||||
typedef struct {
|
||||
size_t len;
|
||||
uint8_t buf[TSCH_PACKET_MAX_LEN];
|
||||
} frame_t;
|
||||
|
||||
#define NODE1 {{ 0xc1, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
#define NODE2 {{ 0xc1, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}
|
||||
|
||||
/*
|
||||
* The following vectors are obtained with the former
|
||||
* examples/ipv6/rpl-tsch/rpl-tsch-z1.csc except for the enhanced beacon for
|
||||
* ALL_ENABLED. The raw frame was generated with rpl-tsch-cooja.csc because
|
||||
* there is an issue in TSCH Timeslot IE generated by z1 mote.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
linkaddr_t src;
|
||||
uint64_t asn;
|
||||
uint8_t hdr_len;
|
||||
frame_t frame;
|
||||
} eb_test_vector_t;
|
||||
|
||||
static const eb_test_vector_t eb_test_vectors[] = {
|
||||
{ /* DEFAULT */
|
||||
NODE1, 7, 18,
|
||||
{ 37, { 0x00, 0xeb, 0xcd, 0xab, 0xff, 0xff, 0xcd, 0xab,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xc1,
|
||||
0x00, 0x3f, 0x11, 0x88, 0x06, 0x1a, 0x07, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x1c, 0x00, 0x01,
|
||||
0xc8, 0x00, 0x01, 0x1b, 0x00 }
|
||||
}
|
||||
},
|
||||
{ /* SECURITY_ON */
|
||||
NODE1, 2, 20,
|
||||
{ 43, { 0x08, 0xeb, 0xcd, 0xab, 0xff, 0xff, 0xcd, 0xab,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xc1,
|
||||
0x69, 0x01, 0x00, 0x3f, 0x11, 0x88, 0x06, 0x1a,
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1c,
|
||||
0x00, 0x01, 0xc8, 0x00, 0x01, 0x1b, 0x00, 0x7d,
|
||||
0x3e, 0x39, 0x9a, 0x6f, 0x7b }
|
||||
}
|
||||
},
|
||||
{ /* ALL_ENABLED */
|
||||
NODE1, 12, 18,
|
||||
{ 85, { 0x00, 0xeb, 0xcd, 0xab, 0xff, 0xff, 0xcd, 0xab,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xc1,
|
||||
0x00, 0x3f, 0x41, 0x88, 0x06, 0x1a, 0x0c, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x19, 0x1c, 0x01, 0x08,
|
||||
0x07, 0x80, 0x00, 0x48, 0x08, 0xfc, 0x03, 0x20,
|
||||
0x03, 0xe8, 0x03, 0x98, 0x08, 0x90, 0x01, 0xc0,
|
||||
0x00, 0x60, 0x09, 0xa0, 0x10, 0x10, 0x27, 0x10,
|
||||
0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x04, 0x00, 0x0f, 0x19, 0x1a, 0x14, 0x00,
|
||||
0x00, 0x0a, 0x1b, 0x01, 0x00, 0x07, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0f }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
linkaddr_t src;
|
||||
linkaddr_t dest;
|
||||
uint64_t asn; // used only for the SECURITY_ON case
|
||||
uint8_t seqno;
|
||||
uint16_t drift;
|
||||
uint8_t nack;
|
||||
frame_t frame;
|
||||
} eack_test_vector_t;
|
||||
|
||||
static const eack_test_vector_t eack_test_vectors[] = {
|
||||
{ /* DEFAULT */
|
||||
NODE1, NODE2, 0, 1, 214, 0,
|
||||
{ 17, { 0x02, 0x2e, 0x01, 0xcd, 0xab, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0xc1, 0x02, 0x0f, 0xd6,
|
||||
0x00 }
|
||||
}
|
||||
},
|
||||
{ /* SECURITY_ON */
|
||||
NODE1, NODE2, 108, 1, 214, 0,
|
||||
{ 23, { 0x0a, 0x2e, 0x01, 0xcd, 0xab, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0xc1, 0x6d, 0x02, 0x02,
|
||||
0x0f, 0xd6, 0x00, 0x5e, 0x20, 0x84, 0xda }
|
||||
}
|
||||
},
|
||||
{ /* ALL_ENABLED */
|
||||
NODE1, NODE2, 0, 1, 214, 0,
|
||||
{ 25, { 0x02, 0xee, 0x01, 0xcd, 0xab, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0xc1, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0xc1, 0x02, 0x0f, 0xd6,
|
||||
0x00 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PROCESS(test_process, "tsch-packet-create test");
|
||||
AUTOSTART_PROCESSES(&test_process);
|
||||
|
||||
static void
|
||||
print_hex(const uint8_t *p, size_t len)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < len; i++) {
|
||||
printf("%02x", p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_current_asn(uint64_t asn)
|
||||
{
|
||||
tsch_current_asn.ls4b = (uint32_t)(asn & 0xffffffff);
|
||||
tsch_current_asn.ms1b = (uint8_t)((asn >> 32) & 0xff);
|
||||
}
|
||||
|
||||
static result_t
|
||||
test_create_eb(const eb_test_vector_t *v)
|
||||
{
|
||||
uint8_t buf[TSCH_PACKET_MAX_LEN];
|
||||
int len;
|
||||
uint8_t hdr_len;
|
||||
uint8_t tsch_sync_ie_offset;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
linkaddr_copy(&linkaddr_node_addr, &v->src);
|
||||
update_current_asn(v->asn);
|
||||
|
||||
len = tsch_packet_create_eb(buf, sizeof(buf),
|
||||
&hdr_len, &tsch_sync_ie_offset);
|
||||
tsch_packet_update_eb(buf, len, tsch_sync_ie_offset);
|
||||
#if WITH_SECURITY_ON
|
||||
len += tsch_security_secure_frame(buf, buf,
|
||||
hdr_len, len - hdr_len,
|
||||
&tsch_current_asn);
|
||||
#endif
|
||||
|
||||
printf("%s: len=%u, hdr_len=%u, buf=", __func__, len, hdr_len);
|
||||
print_hex(buf, len);
|
||||
printf("\n");
|
||||
|
||||
if(len != v->frame.len ||
|
||||
hdr_len != v->hdr_len ||
|
||||
memcmp(buf, v->frame.buf, len) != 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static result_t
|
||||
test_parse_eb(const eb_test_vector_t *v)
|
||||
{
|
||||
frame802154_t frame;
|
||||
struct ieee802154_ies ies;
|
||||
uint8_t hdr_len;
|
||||
int frame_without_mic;
|
||||
int len;
|
||||
uint64_t asn;
|
||||
linkaddr_t src_addr;
|
||||
|
||||
#if WITH_SECURITY_ON
|
||||
frame_without_mic = 0;
|
||||
update_current_asn(v->asn);
|
||||
#else
|
||||
frame_without_mic = 1;
|
||||
#endif
|
||||
|
||||
memset(&frame, 0, sizeof(frame));
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
hdr_len = 0;
|
||||
|
||||
len = tsch_packet_parse_eb(v->frame.buf, v->frame.len, &frame, &ies, &hdr_len,
|
||||
frame_without_mic);
|
||||
asn = ((uint64_t)ies.ie_asn.ms1b << 32) + ies.ie_asn.ls4b;
|
||||
printf("%s: len=%u, hdr_len=%u, asn=%llu\n", __func__, len, hdr_len, asn);
|
||||
|
||||
#if WITH_SECURITY_ON
|
||||
/* adjust 'len' with the length of MIC which is included in a raw frame */
|
||||
len += tsch_security_mic_len(&frame);
|
||||
#endif
|
||||
|
||||
if(frame.fcf.frame_type != FRAME802154_BEACONFRAME ||
|
||||
frame.fcf.frame_version != FRAME802154_IEEE802154_2015) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if(len != v->frame.len ||
|
||||
hdr_len != v->hdr_len ||
|
||||
asn != v->asn) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if(frame802154_extract_linkaddr(&frame, &src_addr, NULL) == 0||
|
||||
linkaddr_cmp(&src_addr, &v->src) == 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static result_t
|
||||
test_create_eack(const eack_test_vector_t *v)
|
||||
{
|
||||
uint8_t buf[TSCH_PACKET_MAX_LEN];
|
||||
int len;
|
||||
#if WITH_SECURITY_ON
|
||||
int data_len = 0;
|
||||
#endif
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
linkaddr_copy(&linkaddr_node_addr, &v->src);
|
||||
|
||||
len = tsch_packet_create_eack(buf, sizeof(buf),
|
||||
&v->dest, v->seqno, v->drift, v->nack);
|
||||
#if WITH_SECURITY_ON
|
||||
update_current_asn(v->asn);
|
||||
len += tsch_security_secure_frame(buf, buf,
|
||||
len, data_len,
|
||||
&tsch_current_asn);
|
||||
#endif
|
||||
|
||||
printf("%s: len=%u, buf=", __func__, len);
|
||||
print_hex(buf, len);
|
||||
printf("\n");
|
||||
|
||||
if(len != v->frame.len ||
|
||||
memcmp(buf, v->frame.buf, len) != 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static result_t
|
||||
test_parse_eack(const eack_test_vector_t *v)
|
||||
{
|
||||
frame802154_t frame;
|
||||
struct ieee802154_ies ies;
|
||||
uint8_t hdr_len;
|
||||
int len;
|
||||
#if TSCH_PACKET_EACK_WITH_SRC_ADDR
|
||||
linkaddr_t src_addr;
|
||||
#endif
|
||||
#if TSCH_PACKET_EACK_WITH_DEST_ADDR
|
||||
linkaddr_t dest_addr;
|
||||
#endif
|
||||
|
||||
#if WITH_SECURITY_ON
|
||||
update_current_asn(v->asn);
|
||||
#endif
|
||||
|
||||
memset(&frame, 0, sizeof(frame));
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
hdr_len = 0;
|
||||
|
||||
linkaddr_copy(&linkaddr_node_addr, &v->dest);
|
||||
len = tsch_packet_parse_eack(v->frame.buf, v->frame.len, v->seqno,
|
||||
&frame, &ies, &hdr_len);
|
||||
printf("%s: len=%u, seqno=%u, drift=%u, nack=%u\n",
|
||||
__func__, len, frame.seq, ies.ie_time_correction, ies.ie_is_nack);
|
||||
|
||||
#if WITH_SECURITY_ON
|
||||
/* adjust 'len' with the length of MIC which is included in a raw frame */
|
||||
len += tsch_security_mic_len(&frame);
|
||||
#endif
|
||||
|
||||
if(frame.fcf.frame_type != FRAME802154_ACKFRAME ||
|
||||
frame.fcf.frame_version != FRAME802154_IEEE802154_2015) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if(len != v->frame.len ||
|
||||
frame.seq != v->seqno ||
|
||||
ies.ie_time_correction != v->drift ||
|
||||
ies.ie_is_nack != v->nack) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
#if TSCH_PACKET_EACK_WITH_SRC_ADDR
|
||||
if(frame802154_extract_linkaddr(&frame, &src_addr, NULL) == 0||
|
||||
linkaddr_cmp(&src_addr, &v->src) == 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TSCH_PACKET_EACK_WITH_DEST_ADDR
|
||||
if(frame802154_extract_linkaddr(&frame, NULL, &dest_addr) == 0||
|
||||
linkaddr_cmp(&dest_addr, &v->dest) == 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PROCESS_THREAD(test_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
const eb_test_vector_t *eb_v;
|
||||
const eack_test_vector_t *eack_v;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tsch_set_coordinator(1);
|
||||
|
||||
#if WITH_SECURITY_ON
|
||||
tsch_set_pan_secured(1);
|
||||
#endif
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
/* wait for minimal schedule installed */
|
||||
while(1) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
if(tsch_schedule_get_link_by_handle(0) != NULL) {
|
||||
break;
|
||||
}
|
||||
etimer_reset(&et);
|
||||
}
|
||||
|
||||
eb_v = &eb_test_vectors[TEST_CONFIG_TYPE];
|
||||
printf("==check-me== %s\n",
|
||||
test_create_eb(eb_v) == SUCCESS ? "SUCCEEDED" : "FAILED");
|
||||
printf("==check-me== %s\n",
|
||||
test_parse_eb(eb_v) == SUCCESS ? "SUCCEEDED" : "FAILED");
|
||||
|
||||
eack_v = &eack_test_vectors[TEST_CONFIG_TYPE];
|
||||
printf("==check-me== %s\n",
|
||||
test_create_eack(eack_v) == SUCCESS ? "SUCCEEDED" : "FAILED");
|
||||
printf("==check-me== %s\n",
|
||||
test_parse_eack(eack_v) == SUCCESS ? "SUCCEEDED" : "FAILED");
|
||||
|
||||
printf("==check-me== DONE\n");
|
||||
|
||||
PROCESS_END();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
TIMEOUT(10000, log.testFailed());
|
||||
|
||||
num_of_motes = sim.getMotesCount();
|
||||
|
||||
while(true) {
|
||||
YIELD();
|
||||
|
||||
log.log(time + " node-" + id + ": "+ msg + "\n");
|
||||
|
||||
if(msg.contains("=check-me=") == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(msg.contains("FAILED")) {
|
||||
log.testFailed();
|
||||
break;
|
||||
}
|
||||
|
||||
if(msg.contains("DONE")) {
|
||||
num_of_motes -= 1;
|
||||
if(num_of_motes == 0) {
|
||||
log.testOK();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype382</identifier>
|
||||
<description>Cooja Mote Type #1</description>
|
||||
<source>[CONTIKI_DIR]/tests/16-6tisch/code/test-sixtop.c</source>
|
||||
<commands>make clean TARGET=cooja
|
||||
make test-sixtop.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>47.60131881808453</x>
|
||||
<y>20.028921031789082</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype382</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>5</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 150.72607380174134 154.79188997110083</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>2</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>957</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>0</z>
|
||||
<height>300</height>
|
||||
<location_x>290</location_x>
|
||||
<location_y>422</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONTIKI_DIR]/tests/16-6tisch/js/unit-test.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>0</z>
|
||||
<height>525</height>
|
||||
<location_x>663</location_x>
|
||||
<location_y>105</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype382</identifier>
|
||||
<description>Cooja Mote Type #1</description>
|
||||
<source>[CONTIKI_DIR]/tests/16-6tisch/code/test-sixp-pkt.c</source>
|
||||
<commands>make clean TARGET=cooja
|
||||
make test-sixp-pkt.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>47.60131881808453</x>
|
||||
<y>20.028921031789082</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype382</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>5</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 150.72607380174134 154.79188997110083</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>2</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>957</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>0</z>
|
||||
<height>300</height>
|
||||
<location_x>290</location_x>
|
||||
<location_y>422</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONTIKI_DIR]/tests/16-6tisch/js/unit-test.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>0</z>
|
||||
<height>525</height>
|
||||
<location_x>663</location_x>
|
||||
<location_y>105</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype382</identifier>
|
||||
<description>Cooja Mote Type #1</description>
|
||||
<source>[CONTIKI_DIR]/tests/16-6tisch/code/test-sixp-trans.c</source>
|
||||
<commands>make clean TARGET=cooja
|
||||
make test-sixp-trans.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>47.60131881808453</x>
|
||||
<y>20.028921031789082</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype382</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>5</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 150.72607380174134 154.79188997110083</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>2</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>957</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>0</z>
|
||||
<height>300</height>
|
||||
<location_x>290</location_x>
|
||||
<location_y>422</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONTIKI_DIR]/tests/16-6tisch/js/unit-test.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>0</z>
|
||||
<height>525</height>
|
||||
<location_x>663</location_x>
|
||||
<location_y>105</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype382</identifier>
|
||||
<description>Cooja Mote Type #1</description>
|
||||
<source>[CONTIKI_DIR]/tests/16-6tisch/code/test-sixp-nbr.c</source>
|
||||
<commands>make clean TARGET=cooja
|
||||
make test-sixp-nbr.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>47.60131881808453</x>
|
||||
<y>20.028921031789082</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype382</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>5</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 150.72607380174134 154.79188997110083</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>2</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>957</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>0</z>
|
||||
<height>300</height>
|
||||
<location_x>290</location_x>
|
||||
<location_y>422</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONTIKI_DIR]/tests/16-6tisch/js/unit-test.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>0</z>
|
||||
<height>525</height>
|
||||
<location_x>663</location_x>
|
||||
<location_y>105</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>123456</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.contikimote.ContikiMoteType
|
||||
<identifier>mtype382</identifier>
|
||||
<description>Cooja Mote Type #1</description>
|
||||
<source>[CONTIKI_DIR]/tests/16-6tisch/code/test-sixp.c</source>
|
||||
<commands>make clean TARGET=cooja
|
||||
make test-sixp.cooja TARGET=cooja</commands>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Battery</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiVib</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRS232</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiBeeper</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiIPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiRadio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiPIR</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiCFS</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.contikimote.interfaces.ContikiEEPROM</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<symbols>false</symbols>
|
||||
</motetype>
|
||||
<mote>
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>47.60131881808453</x>
|
||||
<y>20.028921031789082</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiRadio
|
||||
<bitrate>250.0</bitrate>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.contikimote.interfaces.ContikiEEPROM
|
||||
<eeprom>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</eeprom>
|
||||
</interface_config>
|
||||
<motetype_identifier>mtype382</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>280</width>
|
||||
<z>5</z>
|
||||
<height>160</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<moterelations>true</moterelations>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.GridVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.TrafficVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>0.9090909090909091 0.0 0.0 0.9090909090909091 150.72607380174134 154.79188997110083</viewport>
|
||||
</plugin_config>
|
||||
<width>400</width>
|
||||
<z>4</z>
|
||||
<height>400</height>
|
||||
<location_x>1</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>1320</width>
|
||||
<z>3</z>
|
||||
<height>240</height>
|
||||
<location_x>400</location_x>
|
||||
<location_y>160</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<showRadioRXTX />
|
||||
<showRadioHW />
|
||||
<showLEDs />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>1720</width>
|
||||
<z>2</z>
|
||||
<height>166</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>957</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Notes
|
||||
<plugin_config>
|
||||
<notes>Enter notes here</notes>
|
||||
<decorations>true</decorations>
|
||||
</plugin_config>
|
||||
<width>1040</width>
|
||||
<z>1</z>
|
||||
<height>160</height>
|
||||
<location_x>680</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.RadioLogger
|
||||
<plugin_config>
|
||||
<split>150</split>
|
||||
<formatted_time />
|
||||
<showdups>false</showdups>
|
||||
<hidenodests>false</hidenodests>
|
||||
<analyzers name="6lowpan-pcap" />
|
||||
</plugin_config>
|
||||
<width>500</width>
|
||||
<z>0</z>
|
||||
<height>300</height>
|
||||
<location_x>290</location_x>
|
||||
<location_y>422</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<scriptfile>[CONTIKI_DIR]/tests/16-6tisch/js/unit-test.js</scriptfile>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>495</width>
|
||||
<z>0</z>
|
||||
<height>525</height>
|
||||
<location_x>663</location_x>
|
||||
<location_y>105</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -0,0 +1 @@
|
|||
include ../Makefile.simulation-test
|
|
@ -0,0 +1,15 @@
|
|||
all:
|
||||
|
||||
CFLAGS += -D PROJECT_CONF_H=\"project-conf.h\"
|
||||
APPS += unit-test
|
||||
MODULES += os/net/mac/tsch os/net/mac/tsch/sixtop
|
||||
|
||||
PROJECT_SOURCEFILES += common.c
|
||||
|
||||
ifeq ($(TEST_04),1)
|
||||
CFLAGS += -DSIXP_MSG_API_TEST=1
|
||||
endif
|
||||
|
||||
CONTIKI = ../../..
|
||||
CONTIKI_WITH_IPV6 = 1
|
||||
include $(CONTIKI)/Makefile.include
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
|
||||
#include "unit-test/unit-test.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "lib/simEnvChange.h"
|
||||
#include "sys/cooja_mt.h"
|
||||
|
||||
static uint8_t send_is_called;
|
||||
|
||||
void
|
||||
test_print_report(const unit_test_t *utp)
|
||||
{
|
||||
printf("=check-me= ");
|
||||
if(utp->result == unit_test_failure) {
|
||||
printf("FAILED - %s: exit at L%u\n", utp->descr, utp->exit_line);
|
||||
} else {
|
||||
printf("SUCCEEDED - %s\n", utp->descr);
|
||||
}
|
||||
|
||||
/* give up the CPU so that the mote can output messages in the serial buffer */
|
||||
simProcessRunValue = 1;
|
||||
cooja_mt_yield();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
test_mac_send_function_is_called(void)
|
||||
{
|
||||
return send_is_called;
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
send_is_called = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
send(mac_callback_t sent_callback, void *ptr)
|
||||
{
|
||||
send_is_called = 1;
|
||||
}
|
||||
|
||||
const struct mac_driver test_mac_driver = {
|
||||
"Test MAC",
|
||||
init,
|
||||
send,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include "unit-test/unit-test.h"
|
||||
|
||||
void test_print_report(const unit_test_t *utp);
|
||||
uint8_t test_mac_send_function_is_called(void);
|
||||
extern const struct mac_driver test_mac_driver;
|
||||
|
||||
#endif /* !_COMMON_H */
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#ifndef _PROJECT_CONF_H_
|
||||
#define _PROJECT_CONF_H_
|
||||
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#define COOJA_CONF_SIMULATE_TURNAROUND 0
|
||||
#else
|
||||
//#error "This file is intended to be used for Cooja mote."
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
|
||||
#undef SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS
|
||||
#define SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS 2
|
||||
|
||||
#undef SIXTOP_CONF_MAX_TRANSACTIONS
|
||||
#define SIXTOP_CONF_MAX_TRANSACTIONS 2
|
||||
|
||||
#undef SIXP_CONF_WITH_PAYLOAD_TERMINATION_IE
|
||||
#define SIXP_CONF_WITH_PAYLOAD_TERMINATION_IE 1
|
||||
|
||||
#undef NBR_TABLE_CONF_MAX_NEIGHBORS
|
||||
#define NBR_TABLE_CONF_MAX_NEIGHBORS 2
|
||||
|
||||
#define UNIT_TEST_PRINT_FUNCTION test_print_report
|
||||
|
||||
#undef TSCH_CONF_WITH_SIXTOP
|
||||
#define TSCH_CONF_WITH_SIXTOP 1
|
||||
|
||||
#undef TSCH_LOG_CONF_PER_SLOT
|
||||
#define TSCH_LOG_CONF_PER_SLOT 1
|
||||
|
||||
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
|
||||
|
||||
#undef TSCH_CONF_AUTOSTART
|
||||
#define TSCH_CONF_AUTOSTART 0
|
||||
|
||||
#undef IEEE802154_CONF_PANID
|
||||
#define IEEE802154_CONF_PANID 0xabcd
|
||||
|
||||
#undef NETSTACK_CONF_MAC
|
||||
#define NETSTACK_CONF_MAC test_mac_driver
|
||||
|
||||
#undef NETSTACK_CONF_RDC
|
||||
#define NETSTACK_CONF_RDC nordc_driver
|
||||
|
||||
#undef NETSTACK_CONF_FRAMER
|
||||
#define NETSTACK_CONF_FRAMER framer_802154
|
||||
|
||||
#undef FRAME802154_CONF_VERSION
|
||||
#define FRAME802154_CONF_VERSION FRAME802154_IEEE802154_2015
|
||||
|
||||
#endif /* __PROJECT_CONF_H__ */
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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 STEP OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "net/mac/tsch/sixtop/sixp-nbr.h"
|
||||
|
||||
#include "unit-test/unit-test.h"
|
||||
#include "common.h"
|
||||
|
||||
static linkaddr_t peer_addr_1;
|
||||
static linkaddr_t peer_addr_2;
|
||||
static linkaddr_t peer_addr_3;
|
||||
|
||||
PROCESS(test_process, "6P neighbor APIs test");
|
||||
AUTOSTART_PROCESSES(&test_process);
|
||||
|
||||
static void
|
||||
test_setup(void)
|
||||
{
|
||||
sixp_nbr_init();
|
||||
|
||||
memset(&peer_addr_1, 0, sizeof(peer_addr_1));
|
||||
peer_addr_1.u8[0] = 1;
|
||||
|
||||
memset(&peer_addr_2, 0, sizeof(peer_addr_2));
|
||||
peer_addr_2.u8[0] = 2;
|
||||
|
||||
memset(&peer_addr_3, 0, sizeof(peer_addr_3));
|
||||
peer_addr_3.u8[0] = 3;
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_alloc_and_free,
|
||||
"test sixp_nbr_{alloc,free}");
|
||||
UNIT_TEST(test_alloc_and_free)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_1) == NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_2) == NULL);
|
||||
|
||||
/* a valid allocation */
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) != NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_1) == nbr);
|
||||
|
||||
/* another allocation */
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_2)) != NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_2) == nbr);
|
||||
|
||||
/* no available memory because NBR_TABLE_CONF_MAX_NEIGHBORS == 2 */
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_3) == NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_alloc(&peer_addr_3) == NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_3) == NULL);
|
||||
|
||||
/* cannot allocate a duplicate nbr */
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) == NULL);
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_2)) == NULL);
|
||||
|
||||
/* remove allocated nbrs */
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_1) != NULL);
|
||||
sixp_nbr_free(sixp_nbr_find(&peer_addr_1));
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_1) == NULL);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_2) != NULL);
|
||||
sixp_nbr_free(sixp_nbr_find(&peer_addr_2));
|
||||
UNIT_TEST_ASSERT(sixp_nbr_find(&peer_addr_2) == NULL);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_gen_management,
|
||||
"test GEN Management");
|
||||
UNIT_TEST(test_gen_management)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) != NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x00);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x01);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x02);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x03);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x04);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x05);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x06);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x07);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x08);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x09);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_gen(nbr) == 0x01);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_next_seqno,
|
||||
"test next_seqno operation");
|
||||
UNIT_TEST(test_next_seqno)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
test_setup();
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr_1)) != NULL);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 1);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 2);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 3);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 4);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 5);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 6);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 7);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 8);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 9);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 10);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 11);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 12);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 13);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 14);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 15);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_increment_next_seqno(nbr) == 0);
|
||||
UNIT_TEST_ASSERT(sixp_nbr_get_next_seqno(nbr) == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
|
||||
PROCESS_THREAD(test_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
printf("Run unit-test\n");
|
||||
printf("---\n");
|
||||
|
||||
/* alloc / free */
|
||||
UNIT_TEST_RUN(test_alloc_and_free);
|
||||
|
||||
/* GEN */
|
||||
UNIT_TEST_RUN(test_gen_management);
|
||||
|
||||
/* next sequence number */
|
||||
UNIT_TEST_RUN(test_next_seqno);
|
||||
|
||||
printf("=check-me= DONE\n");
|
||||
PROCESS_END();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,589 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/mac/tsch/tsch.h"
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
#include "net/mac/tsch/sixtop/sixp.h"
|
||||
#include "net/mac/tsch/sixtop/sixp-nbr.h"
|
||||
#include "net/mac/tsch/sixtop/sixp-trans.h"
|
||||
|
||||
#include "unit-test/unit-test.h"
|
||||
#include "common.h"
|
||||
|
||||
#define UNKNOWN_SF_SFID 0
|
||||
#define TEST_SF_SFID 0xf1
|
||||
|
||||
static linkaddr_t peer_addr;
|
||||
static uint8_t test_sf_input_is_called = 0;
|
||||
|
||||
static void
|
||||
input(sixp_pkt_type_t type,sixp_pkt_code_t code, const uint8_t *body,
|
||||
uint16_t body_len, const linkaddr_t *peer_addr)
|
||||
{
|
||||
test_sf_input_is_called = 1;
|
||||
}
|
||||
|
||||
static const sixtop_sf_t test_sf = {
|
||||
TEST_SF_SFID,
|
||||
0,
|
||||
NULL,
|
||||
input,
|
||||
NULL
|
||||
};
|
||||
|
||||
PROCESS(test_process, "6top protocol APIs test");
|
||||
AUTOSTART_PROCESSES(&test_process);
|
||||
|
||||
static void
|
||||
test_setup(void)
|
||||
{
|
||||
test_mac_driver.init();
|
||||
sixtop_init();
|
||||
packetbuf_clear();
|
||||
memset(&peer_addr, 0, sizeof(peer_addr));
|
||||
sixtop_add_sf(&test_sf);
|
||||
test_sf_input_is_called = 0;
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_input_no_sf,
|
||||
"sixp_input(no_sf)");
|
||||
UNIT_TEST(test_input_no_sf)
|
||||
{
|
||||
uint32_t body;
|
||||
uint8_t *p;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
memset(&body, 0, sizeof(body));
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
UNKNOWN_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
NULL) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr);
|
||||
|
||||
p = packetbuf_hdrptr();
|
||||
|
||||
/* length */
|
||||
UNIT_TEST_ASSERT(packetbuf_totlen() == 11);
|
||||
|
||||
/* Termination 1 IE */
|
||||
UNIT_TEST_ASSERT(p[0] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[1] == 0x3f);
|
||||
|
||||
/* IETF IE */
|
||||
UNIT_TEST_ASSERT(p[2] == 0x05);
|
||||
UNIT_TEST_ASSERT(p[3] == 0xa8);
|
||||
|
||||
/* 6top IE */
|
||||
UNIT_TEST_ASSERT(p[4] == 0xc9);
|
||||
UNIT_TEST_ASSERT(p[5] == 0x10);
|
||||
UNIT_TEST_ASSERT(p[6] == 0x05);
|
||||
UNIT_TEST_ASSERT(p[7] == UNKNOWN_SF_SFID);
|
||||
UNIT_TEST_ASSERT(p[8] == 0x0a);
|
||||
|
||||
/* Payload Termination IE */
|
||||
UNIT_TEST_ASSERT(p[9] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[10] == 0xf8);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_input_busy,
|
||||
"sixp_input(busy)");
|
||||
UNIT_TEST(test_input_busy)
|
||||
{
|
||||
uint8_t *p;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
/* send a request to the peer first */
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_trans_find(&peer_addr) == NULL);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR,
|
||||
TEST_SF_SFID, NULL, 0, &peer_addr,
|
||||
NULL, NULL, 0) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
UNIT_TEST_ASSERT(sixp_trans_find(&peer_addr) != NULL);
|
||||
|
||||
test_mac_driver.init(); /* clear test_mac_send_is_called status */
|
||||
|
||||
memset(&body, 0, sizeof(body));
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
NULL) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr);
|
||||
|
||||
p = packetbuf_hdrptr();
|
||||
|
||||
/* length */
|
||||
UNIT_TEST_ASSERT(packetbuf_totlen() == 11);
|
||||
|
||||
/* Termination 1 IE */
|
||||
UNIT_TEST_ASSERT(p[0] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[1] == 0x3f);
|
||||
|
||||
/* IETF IE */
|
||||
UNIT_TEST_ASSERT(p[2] == 0x05);
|
||||
UNIT_TEST_ASSERT(p[3] == 0xa8);
|
||||
|
||||
/* 6top IE */
|
||||
UNIT_TEST_ASSERT(p[4] == 0xc9);
|
||||
UNIT_TEST_ASSERT(p[5] == 0x10);
|
||||
UNIT_TEST_ASSERT(p[6] == 0x07);
|
||||
UNIT_TEST_ASSERT(p[7] == TEST_SF_SFID);
|
||||
UNIT_TEST_ASSERT(p[8] == 0x0a);
|
||||
|
||||
/* Payload Termination IE */
|
||||
UNIT_TEST_ASSERT(p[9] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[10] == 0xf8);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_input_no_memory,
|
||||
"sixp_input(no_memory)");
|
||||
UNIT_TEST(test_input_no_memory)
|
||||
{
|
||||
uint32_t body;
|
||||
sixp_pkt_t pkt;
|
||||
uint8_t *p;
|
||||
linkaddr_t addr;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
memset(&body, 0, sizeof(body));
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.u8[0] = 1;
|
||||
UNIT_TEST_ASSERT(sixp_trans_alloc(&pkt, &addr) != NULL);
|
||||
addr.u8[0] = 2;
|
||||
UNIT_TEST_ASSERT(sixp_trans_alloc(&pkt, &addr) != NULL);
|
||||
addr.u8[0] = 3;
|
||||
/* no memory left for another transaction */
|
||||
UNIT_TEST_ASSERT(sixp_trans_alloc(&pkt, &addr) == NULL);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr);
|
||||
|
||||
p = packetbuf_hdrptr();
|
||||
|
||||
/* length */
|
||||
UNIT_TEST_ASSERT(packetbuf_totlen() == 11);
|
||||
|
||||
/* Termination 1 IE */
|
||||
UNIT_TEST_ASSERT(p[0] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[1] == 0x3f);
|
||||
|
||||
/* IETF IE */
|
||||
UNIT_TEST_ASSERT(p[2] == 0x05);
|
||||
UNIT_TEST_ASSERT(p[3] == 0xa8);
|
||||
|
||||
/* 6top IE */
|
||||
UNIT_TEST_ASSERT(p[4] == 0xc9);
|
||||
UNIT_TEST_ASSERT(p[5] == 0x10);
|
||||
UNIT_TEST_ASSERT(p[6] == 0x08);
|
||||
UNIT_TEST_ASSERT(p[7] == TEST_SF_SFID);
|
||||
UNIT_TEST_ASSERT(p[8] == 0x0a);
|
||||
|
||||
/* Payload Termination IE */
|
||||
UNIT_TEST_ASSERT(p[9] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[10] == 0xf8);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_input_schedule_generation,
|
||||
"sixp_input(schedule_generation)");
|
||||
UNIT_TEST(test_input_schedule_generation)
|
||||
{
|
||||
sixp_nbr_t *nbr;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
memset(&body, 0, sizeof(body));
|
||||
|
||||
UNIT_TEST_ASSERT((nbr = sixp_nbr_alloc(&peer_addr)) != NULL);
|
||||
/* nbr has GEN 0 now */
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 1,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
NULL) == 0);
|
||||
|
||||
sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr);
|
||||
UNIT_TEST_ASSERT(test_sf_input_is_called == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_nbr_advance_gen(nbr) == 0);
|
||||
sixp_input(packetbuf_hdrptr(), packetbuf_totlen(), &peer_addr);
|
||||
UNIT_TEST_ASSERT(test_sf_input_is_called == 1);
|
||||
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_find(&peer_addr)) != NULL);
|
||||
UNIT_TEST_ASSERT(sixp_trans_get_state(trans) ==
|
||||
SIXP_TRANS_STATE_REQUEST_RECEIVED);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_request_1,
|
||||
"sixp_output(request_1)");
|
||||
UNIT_TEST(test_output_request_1)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
test_setup();
|
||||
memset(&body, 0, sizeof(body));
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
memset(&body, 0, sizeof(body));
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, (uint8_t *)&body, sizeof(body),
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_request_2,
|
||||
"sixp_output(request_2)");
|
||||
UNIT_TEST(test_output_request_2)
|
||||
{
|
||||
uint32_t body;
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
test_setup();
|
||||
memset(&body, 0, sizeof(body));
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, (uint8_t *)&body, sizeof(body),
|
||||
&peer_addr, NULL, NULL, 0) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_response_1,
|
||||
"sixp_output(response_1)");
|
||||
UNIT_TEST(test_output_response_1)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_response_2,
|
||||
"sixp_output(response_2)");
|
||||
UNIT_TEST(test_output_response_2)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_response_3,
|
||||
"sixp_output(response_3)");
|
||||
UNIT_TEST(test_output_response_3)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_REQUEST_RECEIVED) == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_response_4,
|
||||
"sixp_output(response_4)");
|
||||
UNIT_TEST(test_output_response_4)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_REQUEST_SENT) == 0);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_RESPONSE_RECEIVED) == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_confirmation_1,
|
||||
"sixp_output(confirmation_1)");
|
||||
UNIT_TEST(test_output_confirmation_1)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_confirmation_2,
|
||||
"sixp_output(confirmation_2)");
|
||||
UNIT_TEST(test_output_confirmation_2)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_confirmation_3,
|
||||
"sixp_output(confirmation_3)");
|
||||
UNIT_TEST(test_output_confirmation_3)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_REQUEST_SENT) == 0);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_RESPONSE_RECEIVED) == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == 0);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 1);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output_confirmation_4,
|
||||
"sixp_output(confirmation_4)");
|
||||
UNIT_TEST(test_output_confirmation_4)
|
||||
{
|
||||
sixp_pkt_t pkt;
|
||||
sixp_trans_t *trans;
|
||||
uint32_t body;
|
||||
|
||||
UNIT_TEST_BEGIN();
|
||||
test_setup();
|
||||
|
||||
UNIT_TEST_ASSERT(sixp_pkt_create(SIXP_PKT_TYPE_REQUEST,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD,
|
||||
TEST_SF_SFID, 10, 0,
|
||||
(const uint8_t *)&body, sizeof(body),
|
||||
&pkt) == 0);
|
||||
UNIT_TEST_ASSERT((trans = sixp_trans_alloc(&pkt, &peer_addr)) != NULL);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_REQUEST_SENT) == 0);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans, SIXP_TRANS_STATE_RESPONSE_RECEIVED) == 0);
|
||||
UNIT_TEST_ASSERT(
|
||||
sixp_trans_transit_state(trans,
|
||||
SIXP_TRANS_STATE_CONFIRMATION_SENT) == 0);
|
||||
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
UNIT_TEST_ASSERT(sixp_output(SIXP_PKT_TYPE_CONFIRMATION,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS,
|
||||
TEST_SF_SFID, NULL, 0,
|
||||
&peer_addr, NULL, NULL, 0) == -1);
|
||||
UNIT_TEST_ASSERT(test_mac_send_function_is_called() == 0);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
PROCESS_THREAD(test_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* wait until the sixtop module gets ready */
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
tschmac_driver.init();
|
||||
tschmac_driver.on();
|
||||
tsch_set_coordinator(1);
|
||||
while(tsch_is_associated == 0) {
|
||||
PROCESS_YIELD_UNTIL(etimer_expired(&et));
|
||||
etimer_reset(&et);
|
||||
}
|
||||
|
||||
printf("Run unit-test\n");
|
||||
printf("---\n");
|
||||
|
||||
UNIT_TEST_RUN(test_input_no_sf);
|
||||
UNIT_TEST_RUN(test_input_busy);
|
||||
UNIT_TEST_RUN(test_input_no_memory);
|
||||
UNIT_TEST_RUN(test_input_schedule_generation);
|
||||
|
||||
UNIT_TEST_RUN(test_output_request_1);
|
||||
UNIT_TEST_RUN(test_output_request_2);
|
||||
UNIT_TEST_RUN(test_output_response_1);
|
||||
UNIT_TEST_RUN(test_output_response_2);
|
||||
UNIT_TEST_RUN(test_output_response_3);
|
||||
UNIT_TEST_RUN(test_output_response_4);
|
||||
UNIT_TEST_RUN(test_output_confirmation_1);
|
||||
UNIT_TEST_RUN(test_output_confirmation_2);
|
||||
UNIT_TEST_RUN(test_output_confirmation_3);
|
||||
UNIT_TEST_RUN(test_output_confirmation_4);
|
||||
|
||||
printf("=check-me= DONE\n");
|
||||
PROCESS_END();
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Yasuyuki Tanaka
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "lib/assert.h"
|
||||
|
||||
#include "net/packetbuf.h"
|
||||
#include "net/mac/tsch/sixtop/sixtop.h"
|
||||
#include "net/mac/tsch/sixtop/sixtop-conf.h"
|
||||
|
||||
#include "unit-test/unit-test.h"
|
||||
#include "common.h"
|
||||
|
||||
#if SIXTOP_MAX_SCHEDULING_FUNCTIONS != 2
|
||||
#error SIXTOP_CONF_MAX_SCHEDULING_FUNCTIONS must be set with 2 for this test
|
||||
#endif
|
||||
|
||||
#define TEST_SF1_SFID 0xf1
|
||||
#define TEST_SF2_SFID 0xf2
|
||||
#define TEST_SF3_SFID 0xf3
|
||||
|
||||
static uint8_t sf_init_vector;
|
||||
static void test_sf1_init(void);
|
||||
static void test_sf2_init(void);
|
||||
static void test_sf3_init(void);
|
||||
static void reset_sf_init_vector(void);
|
||||
|
||||
static const sixtop_sf_t test_sf1 = {
|
||||
TEST_SF1_SFID,
|
||||
0,
|
||||
test_sf1_init,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const sixtop_sf_t test_sf2 = {
|
||||
TEST_SF2_SFID,
|
||||
0,
|
||||
test_sf2_init,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const sixtop_sf_t test_sf3 = {
|
||||
TEST_SF3_SFID,
|
||||
0,
|
||||
test_sf3_init,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
test_sf1_init(void)
|
||||
{
|
||||
sf_init_vector |= TEST_SF1_SFID;
|
||||
}
|
||||
|
||||
static void
|
||||
test_sf2_init(void)
|
||||
{
|
||||
sf_init_vector |= TEST_SF2_SFID;
|
||||
}
|
||||
|
||||
static void
|
||||
test_sf3_init(void)
|
||||
{
|
||||
sf_init_vector |= TEST_SF3_SFID;
|
||||
}
|
||||
|
||||
void
|
||||
reset_sf_init_vector(void)
|
||||
{
|
||||
sf_init_vector = 0;
|
||||
}
|
||||
|
||||
PROCESS(test_process, "6top module APIs test");
|
||||
AUTOSTART_PROCESSES(&test_process);
|
||||
|
||||
UNIT_TEST_REGISTER(test_add_sf,
|
||||
"sixtop_add_sf() should add a SF");
|
||||
UNIT_TEST(test_add_sf)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
/* confirm any of test_sf{1,2,3} is not added yet. */
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF1_SFID) == NULL);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF2_SFID) == NULL);
|
||||
|
||||
/* add test_sf1 */
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf1) == 0);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF1_SFID) == &test_sf1);
|
||||
|
||||
/* add test_sf2 */
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf2) == 0);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF2_SFID) == &test_sf2);
|
||||
|
||||
/*
|
||||
* add test_sf3; should fail because of lack of memory.
|
||||
* SIXTOP_MAX_SCHEDULING_FUNCTIONS is set with two.
|
||||
*/
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf3) == -1);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF3_SFID) == NULL);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_find_sf,
|
||||
"sixtop_find_sf() should find a SF which has been added");
|
||||
UNIT_TEST(test_find_sf)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
/*
|
||||
* See test_add_sf(); sixtop_find_sf() is tested together with sixtop_add_sf()
|
||||
* in it.
|
||||
*/
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_init,
|
||||
"sixtop_init() should remove all SFs in the 6top module");
|
||||
UNIT_TEST(test_init)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
/* set up a precondition where some SFs has been added */
|
||||
if(sixtop_find_sf(TEST_SF1_SFID) == NULL) {
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf1) == 0);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF1_SFID) != NULL);
|
||||
}
|
||||
|
||||
if(sixtop_find_sf(TEST_SF2_SFID) == NULL) {
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf2) == 0);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF2_SFID) != NULL);
|
||||
}
|
||||
|
||||
/* call sixtop_init() which removes all the SFs in the module */
|
||||
sixtop_init();
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF1_SFID) == NULL);
|
||||
UNIT_TEST_ASSERT(sixtop_find_sf(TEST_SF2_SFID) == NULL);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_output,
|
||||
"test sixtop_output()");
|
||||
UNIT_TEST(test_output)
|
||||
{
|
||||
linkaddr_t peer_addr;
|
||||
uint8_t *p;
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
packetbuf_clear();
|
||||
UNIT_TEST_ASSERT(packetbuf_hdralloc(1) > 0);
|
||||
p = packetbuf_hdrptr();
|
||||
p[0] = 0xca; // header
|
||||
p = packetbuf_dataptr();
|
||||
p[0] = 0xfe; // data
|
||||
packetbuf_set_datalen(1);
|
||||
|
||||
sixtop_output(&peer_addr, NULL, NULL);
|
||||
|
||||
p = packetbuf_hdrptr();
|
||||
|
||||
/* Length */
|
||||
UNIT_TEST_ASSERT(packetbuf_totlen() == 9);
|
||||
|
||||
/* Termination 1 IE */
|
||||
UNIT_TEST_ASSERT(p[0] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[1] == 0x3f);
|
||||
|
||||
/* IETF IE */
|
||||
UNIT_TEST_ASSERT(p[2] == 0x03);
|
||||
UNIT_TEST_ASSERT(p[3] == 0xa8);
|
||||
|
||||
/* 6top IE Sub-ID */
|
||||
UNIT_TEST_ASSERT(p[4] == 0xc9);
|
||||
/* test data set above */
|
||||
UNIT_TEST_ASSERT(p[5] == 0xca);
|
||||
UNIT_TEST_ASSERT(p[6] == 0xfe);
|
||||
|
||||
/* Payload Termination IE */
|
||||
UNIT_TEST_ASSERT(p[7] == 0x00);
|
||||
UNIT_TEST_ASSERT(p[8] == 0xf8);
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
UNIT_TEST_REGISTER(test_init_sf,
|
||||
"sixtop_init_sf() should invoke every SF->init()");
|
||||
UNIT_TEST(test_init_sf)
|
||||
{
|
||||
UNIT_TEST_BEGIN();
|
||||
|
||||
/* remove all the SFs in the 6top module */
|
||||
sixtop_init();
|
||||
|
||||
/* add test_sf1 */
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf1) == 0);
|
||||
reset_sf_init_vector();
|
||||
sixtop_init_sf();
|
||||
UNIT_TEST_ASSERT(sf_init_vector == TEST_SF1_SFID);
|
||||
|
||||
/* add test_sf2 */
|
||||
UNIT_TEST_ASSERT(sixtop_add_sf(&test_sf2) == 0);
|
||||
reset_sf_init_vector();
|
||||
sixtop_init_sf();
|
||||
UNIT_TEST_ASSERT(sf_init_vector == (TEST_SF1_SFID | TEST_SF2_SFID));
|
||||
|
||||
UNIT_TEST_END();
|
||||
}
|
||||
|
||||
PROCESS_THREAD(test_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Run unit-test\n");
|
||||
printf("---\n");
|
||||
|
||||
UNIT_TEST_RUN(test_add_sf);
|
||||
UNIT_TEST_RUN(test_find_sf);
|
||||
UNIT_TEST_RUN(test_init);
|
||||
UNIT_TEST_RUN(test_init_sf);
|
||||
UNIT_TEST_RUN(test_output);
|
||||
|
||||
printf("=check-me= DONE\n");
|
||||
PROCESS_END();
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
TIMEOUT(10000, log.testFailed());
|
||||
|
||||
var failed = false;
|
||||
var done = 0;
|
||||
|
||||
while(done < sim.getMotes().length) {
|
||||
YIELD();
|
||||
|
||||
log.log(time + " " + "node-" + id + " "+ msg + "\n");
|
||||
|
||||
if(msg.contains("=check-me=") == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(msg.contains("FAILED")) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if(msg.contains("DONE")) {
|
||||
done++;
|
||||
}
|
||||
}
|
||||
if(failed) {
|
||||
log.testFailed();
|
||||
}
|
||||
log.testOK();
|
||||
|
Loading…
Reference in New Issue