author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
491,595
11.05.2017 18:19:58
-7,200
941d48bf49c6f1b8b441db85b57a2d8945502ad6
port for samr21_xpro port for sctimer
[ { "change_type": "MODIFY", "old_path": "bsp/boards/samr21_xpro/SConscript", "new_path": "bsp/boards/samr21_xpro/SConscript", "diff": "@@ -18,13 +18,12 @@ rf231 = localEnv.SConscript(\nsource = [\n'board.c',\n- 'bsp_timer.c',\n+ 'sctimer.c',\n'debug_pins.c',\n'eui64.c',\n'flash.c',\n'gpio.c',\n'leds.c',\n- 'radio_timer.c',\n'spi_drv.c',\n'uart.c',\n'drivers/src/cm0_handler.c',\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/samr21_xpro/board.c", "new_path": "bsp/boards/samr21_xpro/board.c", "diff": "#include \"board.h\"\n#include \"uart.h\"\n#include \"opentimers.h\"\n-#include \"radiotimer.h\"\n#include \"radio.h\"\n-#include \"bsp_timer.h\"\n+#include \"sctimer.h\"\n#include \"spi.h\"\n#include \"debugpins.h\"\n#include \"leds.h\"\n@@ -130,12 +129,8 @@ void board_init(void)\n/* UART Init */\nuart_init();\n- /* BSP Timer Init --Init the RTC before BSP Timer*/\n- bsp_timer_init();\n-\n-\n- /* Radio Timer Init */\n- radiotimer_init();\n+ /* BSP Timer Init*/\n+ sctimer_init();\n/* Clear the Radio Interrupt */\nextint_enable_irq(TRX_EXT_INT_CH);\n" }, { "change_type": "DELETE", "old_path": "bsp/boards/samr21_xpro/bsp_timer.c", "new_path": null, "diff": "-/**\n-* Copyright (c) 2014 Atmel Corporation. All rights reserved.\n-*\n-* Redistribution and use in source and binary forms, with or without\n-* modification, are permitted provided that the following conditions are met:\n-*\n-* 1. Redistributions of source code must retain the above copyright notice, this\n-* list of conditions and the following disclaimer.\n-*\n-* 2. Redistributions in binary form must reproduce the above copyright notice,\n-* this list of conditions and the following disclaimer in the documentation\n-* and/or other materials provided with the distribution.\n-*\n-* 3. The name of Atmel may not be used to endorse or promote products derived\n-* from this software without specific prior written permission.\n-*\n-* 4. This software may only be redistributed and used in connection with an\n-* Atmel microcontroller product.\n-*\n-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n-* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-*\n-*\n-*\n-*/\n-\n-/* === INCLUDES ============================================================ */\n-\n-#include \"bsp_timer.h\"\n-#include \"debugpins.h\"\n-#include \"samr21_timer.h\"\n-#include \"board_info.h\"\n-\n-/* === MACROS ============================================================== */\n-\n-#define TIMER_PERIOD UINT16_MAX\n-/* === Typedef ============================================================= */\n-/* Structure to hold the bsp timer related functionalities */\n-typedef struct\n-{\n- bsp_timer_cbt cb;\n- PORT_TIMER_WIDTH last_compare_value;\n-} bsp_timer_vars_t;\n-\n-/* This variables keeps information about bsp timer and callbacks */\n-bsp_timer_vars_t bsp_timer_vars;\n-\n-/* === GLOBALS ============================================================= */\n-\n-/* === PROTOTYPE ============================================================= */\n-/* Call back handler for capture compare */\n-\n-/*\n- * @brief bsp_timer_init will Initialize the BSP Timer with default configuration\n- *\n- * @param None\n- */\n-void bsp_timer_init(void)\n-{\n- timer3_init();\n-}\n-\n-/*\n- * @brief bsp_timer_set_callback Register the call back for bsp timer\n- *\n- * @param cb function pointer to the bsp_timer call back function\n- */\n-void bsp_timer_set_callback(bsp_timer_cbt cb)\n-{\n- bsp_timer_vars.cb = cb;\n- tc3_irq_enable();\n-}\n-\n-/*\n- * @brief tc3_cca0_callback call back function for bsp_timer called from ISR\n- *\n- * @param module_instance - timer module instance from interrupt\n- */\n-void tc3_cca0_callback(void)\n-{\n- /* Capture Compare 0 callback */\n- debugpins_isr_set();\n- if(bsp_timer_vars.cb != NULL)\n- {\n- bsp_timer_vars.cb();\n- }\n- debugpins_isr_clr();\n-}\n-\n-/*\n- * @brief bsp_timer_reset reset the bsp timer to default but do not stop the timer\n- *\n- * @param None\n- */\n-void bsp_timer_reset(void)\n-{\n- //disable will clears the compare interrupt\n- tc3_disable_compare0_isr();\n- tc3_set_compare0(TIMER_PERIOD);\n- // reset timer -- set counter to 0\n- tc3_set_count(0);\n- // record last timer compare value\n- bsp_timer_vars.last_compare_value = 0;\n-}\n-\n-/**\n-\\brief Schedule the callback to be called in some specified time.\n-\n-The delay is expressed relative to the last compare event. It doesn't matter\n-how long it took to call this function after the last compare, the timer will\n-expire precisely delayTicks after the last one.\n-\n-The only possible problem is that it took so long to call this function that\n-the delay specified is shorter than the time already elapsed since the last\n-compare. In that case, this function triggers the interrupt to fire right away.\n-\n-This means that the interrupt may fire a bit off, but this inaccuracy does not\n-propagate to subsequent timers.\n-\n-\\param delayTicks Number of ticks before the timer expired, relative to the\n- last compare event.\n-*/\n-void bsp_timer_scheduleIn(PORT_TIMER_WIDTH delayTicks)\n-{\n- PORT_TIMER_WIDTH newCompareValue;\n- PORT_TIMER_WIDTH temp_last_compare_value;\n- PORT_TIMER_WIDTH current_value;\n-\n- temp_last_compare_value = bsp_timer_vars.last_compare_value;\n- newCompareValue = bsp_timer_vars.last_compare_value+delayTicks+1;\n- bsp_timer_vars.last_compare_value = newCompareValue;\n- current_value = (PORT_TIMER_WIDTH)tc3_get_count();\n-\n- if (delayTicks < (current_value-temp_last_compare_value))\n- {\n- /* This needs to be fixed */\n- tc3_enable_compare0_isr();\n- }\n- else\n- {\n- /* this is the normal case, have timer expire at newCompareValue */\n- tc3_disable_compare0_isr();\n- tc3_set_compare0(newCompareValue);\n- tc3_enable_compare0_isr();\n- }\n-}\n-\n-/*\n- * @brief bsp_timer_cancel_schedule Cancel the running compare\n- *\n- * @param None\n- */\n-void bsp_timer_cancel_schedule(void)\n-{\n- tc3_disable_compare0_isr();\n- tc3_set_compare0(TIMER_PERIOD);\n-}\n-\n-/*\n- * @brief bsp_timer_get_currentValue Get current timer counter value\n- *\n- * @param PORT_TIMER_WIDTH return current bsp timer counter value\n- */\n-PORT_TIMER_WIDTH bsp_timer_get_currentValue(void)\n-{\n- return ((PORT_TIMER_WIDTH)tc3_get_count());\n-}\n" }, { "change_type": "DELETE", "old_path": "bsp/boards/samr21_xpro/radio_timer.c", "new_path": null, "diff": "-/**\n-* Copyright (c) 2014 Atmel Corporation. All rights reserved.\n-*\n-* Redistribution and use in source and binary forms, with or without\n-* modification, are permitted provided that the following conditions are met:\n-*\n-* 1. Redistributions of source code must retain the above copyright notice, this\n-* list of conditions and the following disclaimer.\n-*\n-* 2. Redistributions in binary form must reproduce the above copyright notice,\n-* this list of conditions and the following disclaimer in the documentation\n-* and/or other materials provided with the distribution.\n-*\n-* 3. The name of Atmel may not be used to endorse or promote products derived\n-* from this software without specific prior written permission.\n-*\n-* 4. This software may only be redistributed and used in connection with an\n-* Atmel microcontroller product.\n-*\n-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n-* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-*\n-*\n-*\n-*/\n-\n-/* === INCLUDES ============================================================ */\n-#include \"samr21_timer.h\"\n-#include \"radiotimer.h\"\n-#include \"board_info.h\"\n-#include \"leds.h\"\n-#include \"debugpins.h\"\n-#include \"gpio.h\"\n-\n-/* === MACROS ============================================================== */\n-#define RADIO_TIMER_PERIOD UINT16_MAX\n-/* === PROTOTYPE ============================================================== */\n-\n-/* === GLOBALS ============================================================= */\n-\n-\n-typedef struct {\n- radiotimer_compare_cbt overflow_cb;\n- radiotimer_compare_cbt compare_cb;\n-} radiotimer_vars_t;\n-\n-radiotimer_vars_t radiotimer_vars;\n-\n-/*\n- * @brief radiotimer_init Initialize the radio timer\n- * with 32.768KHz input clock\n- *\n- * @param None\n- *\n- */\n-void radiotimer_init(void)\n-{\n- memset(&radiotimer_vars,0,sizeof(radiotimer_vars_t));\n- timer4_init();\n- tc4_irq_enable();\n-}\n-\n-/*\n- * @brief tc4_ovf_callback Timer module overflow or\n- * match frequency callback\n- *\n- * @param module_instance stored timer module instance\n- *\n- */\n-void tc4_ovf_callback(void)\n-{\n- debugpins_isr_set();\n- if (radiotimer_vars.overflow_cb != NULL)\n- {\n- // call the callback\n- radiotimer_vars.overflow_cb();\n- }\n- debugpins_isr_clr();\n-}\n-\n-/*\n- * @brief tc4_cca1_callback Timer module compare call back\n- *\n- * @param module_instance stored timer module instance\n- *\n- */\n-void tc4_cca1_callback(void)\n-{\n- debugpins_isr_set();\n- if (radiotimer_vars.compare_cb != NULL)\n- {\n- radiotimer_vars.compare_cb();\n- }\n- debugpins_isr_clr();\n-}\n-\n-/*\n- * @brief tc2_cca1_callback Register the radio timer\n- * overflow callback\n- *\n- * @param cb callback address pointer\n- *\n- */\n-void radiotimer_setOverflowCb(radiotimer_compare_cbt cb)\n-{\n- radiotimer_vars.overflow_cb = cb;\n-}\n-\n-/*\n- * @brief radiotimer_setCompareCb Register the radio timer\n- * compare callback\n- *\n- * @param cb callback address pointer\n- *\n- */\n-void radiotimer_setCompareCb(radiotimer_compare_cbt cb)\n-{\n- radiotimer_vars.compare_cb = cb;\n-}\n-\n-/*\n- * @brief radiotimer_setStartFrameCb This should not happen\n- *\n- * @param cb callback address pointer\n- *\n- */\n-void radiotimer_setStartFrameCb(radiotimer_capture_cbt cb)\n-{\n- while(1);\n-}\n-\n-/*\n- * @brief radiotimer_setEndFrameCb This should not happen\n- *\n- * @param cb callback address pointer\n- *\n- */\n-void radiotimer_setEndFrameCb(radiotimer_capture_cbt cb)\n-{\n- while(1);\n-}\n-\n-/*\n- * @brief radiotimer_start Start the radio timer,\n- * set the radio timer overflow value\n- *\n- * @param period set the period value to radio timer\n- *\n- */\n-void radiotimer_start(PORT_RADIOTIMER_WIDTH period)\n-{\n- tc4_disable_overflow_isr();\n- tc4_disable_compare1_isr();\n- tc4_set_count(0);\n- tc4_set_compare0(period);\n- tc4_enable_overflow_isr();\n-}\n-\n-/*\n- * @brief radiotimer_getValue Get the current timer\n- * counter value\n- *\n- * @param return PORT_RADIOTIMER_WIDTH counter value\n- *\n- */\n-PORT_RADIOTIMER_WIDTH radiotimer_getValue(void)\n-{\n- PORT_RADIOTIMER_WIDTH time_val;\n- dbg_pin1_set();\n- time_val = (PORT_RADIOTIMER_WIDTH)tc4_get_count();\n- dbg_pin1_clr();\n- return (time_val);\n-}\n-\n-/*\n- * @brief radiotimer_setPeriod Set the radio timer period value.\n- * This will call radio timer overflow\n- *\n- * @param period set the period value to the radio timer top\n- *\n- */\n-void radiotimer_setPeriod(PORT_RADIOTIMER_WIDTH period)\n-{\n- tc4_disable_overflow_isr();\n- tc4_set_compare0(period);\n- tc4_enable_overflow_isr();\n-}\n-\n-/*\n- * @brief radiotimer_getPeriod Read the radio timer period value\n- *\n- * @param return PORT_RADIOTIMER_WIDTH capture value\n- *\n- */\n-PORT_RADIOTIMER_WIDTH radiotimer_getPeriod(void)\n-{\n- PORT_RADIOTIMER_WIDTH timer_period_val;\n- timer_period_val = (PORT_RADIOTIMER_WIDTH)tc4_get_capture0_val();\n- return timer_period_val;\n-}\n-\n-/*\n- * @brief radiotimer_schedule set the next interrupt fire offset from\n- * current counter value\n- *\n- * @param offset PORT_RADIOTIMER_WIDTH set the compare value\n- *\n- */\n-void radiotimer_schedule(PORT_RADIOTIMER_WIDTH offset)\n-{\n- tc4_disable_compare1_isr();\n- tc4_set_compare1((offset));\n- tc4_enable_compare1_isr();\n-}\n-\n-/*\n- * @brief radiotimer_cancel cancel the running radio timer\n- * But this will not stop the radio timer\n- *\n- * @param None\n- *\n- */\n-void radiotimer_cancel(void)\n-{\n- tc4_disable_compare1_isr();\n- tc4_set_compare1(RADIO_TIMER_PERIOD);\n-}\n-\n-/*\n- * @brief radiotimer_getCapturedTime Read the radio timer current count value\n- *\n- * @param return PORT_RADIOTIMER_WIDTH count value\n- *\n- */\n-inline PORT_RADIOTIMER_WIDTH radiotimer_getCapturedTime(void)\n-{\n- return ((PORT_RADIOTIMER_WIDTH)tc4_get_count());\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "bsp/boards/samr21_xpro/sctimer.c", "diff": "+/**\n+* Copyright (c) 2014 Atmel Corporation. All rights reserved.\n+*\n+* Redistribution and use in source and binary forms, with or without\n+* modification, are permitted provided that the following conditions are met:\n+*\n+* 1. Redistributions of source code must retain the above copyright notice, this\n+* list of conditions and the following disclaimer.\n+*\n+* 2. Redistributions in binary form must reproduce the above copyright notice,\n+* this list of conditions and the following disclaimer in the documentation\n+* and/or other materials provided with the distribution.\n+*\n+* 3. The name of Atmel may not be used to endorse or promote products derived\n+* from this software without specific prior written permission.\n+*\n+* 4. This software may only be redistributed and used in connection with an\n+* Atmel microcontroller product.\n+*\n+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n+* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+*\n+*\n+*\n+*/\n+\n+/* === INCLUDES ============================================================ */\n+#include \"samr21_timer.h\"\n+#include \"sctimer.h\"\n+#include \"board_info.h\"\n+#include \"leds.h\"\n+#include \"debugpins.h\"\n+#include \"gpio.h\"\n+\n+/* === MACROS ============================================================== */\n+#define RADIO_TIMER_PERIOD UINT16_MAX\n+\n+#define TIMERLOOP_THRESHOLD 0x4000 // 0.5 seconds @ 32768Hz clock\n+#define MINIMUM_COMPAREVALE_ADVANCE 10\n+/* === PROTOTYPE ============================================================== */\n+\n+/* === GLOBALS ============================================================= */\n+\n+typedef struct {\n+ sctimer_cbt sctimer_cb;\n+} sctimer_vars_t;\n+\n+sctimer_vars_t sctimer_vars;\n+\n+/*\n+ * @brief radiotimer_init Initialize the radio timer\n+ * with 32.768KHz input clock\n+ *\n+ * @param None\n+ *\n+ */\n+void sctimer_init(void)\n+{\n+ memset(&sctimer_vars,0,sizeof(sctimer_vars_t));\n+ timer4_init();\n+ tc4_irq_enable();\n+ tc4_disable_overflow_isr();\n+ tc4_disable_compare1_isr();\n+ tc4_set_count(0);\n+}\n+\n+/*\n+ * @brief sctimer_set_callback Register the sc timer\n+ * compare callback\n+ *\n+ * @param cb callback address pointer\n+ *\n+ */\n+void sctimer_set_callback(sctimer_cbt cb)\n+{\n+ sctimer_vars.sctimer_cb = cb;\n+}\n+\n+/*\n+ * @brief sctimer_readCounter Get the current timer\n+ * counter value\n+ *\n+ * @param return PORT_RADIOTIMER_WIDTH counter value\n+ *\n+ */\n+PORT_RADIOTIMER_WIDTH sctimer_readCounter(void)\n+{\n+ PORT_RADIOTIMER_WIDTH time_val;\n+ dbg_pin1_set();\n+ time_val = (PORT_RADIOTIMER_WIDTH)tc4_get_count();\n+ dbg_pin1_clr();\n+ return (time_val);\n+}\n+\n+void sctimer_setCompare(PORT_TIMER_WIDTH val){\n+ tc4_enable_compare1_isr();\n+ if (tc4_get_count() - val < TIMERLOOP_THRESHOLD){\n+ // the timer is already late, schedule the ISR right now manually\n+ // to do\n+ } else {\n+ if (val-tc4_get_count()<MINIMUM_COMPAREVALE_ADVANCE){\n+ // there is hardware limitation to schedule the timer within TIMERTHRESHOLD ticks\n+ // schedule ISR right now manually\n+ // to do\n+ } else {\n+ // schedule the timer at val\n+ tc4_set_compare1((val));\n+ }\n+ }\n+}\n+\n+/*\n+ * @brief sctimer_disable cancel the running radio timer\n+ * But this will not stop the timer\n+ *\n+ * @param None\n+ *\n+ */\n+void sctimer_disable(void)\n+{\n+ tc4_disable_compare1_isr();\n+}\n+\n+/*\n+ * @brief sctimer_enable enable the running radio timer\n+ *\n+ * @param None\n+ *\n+ */\n+void sctimer_enable(void){\n+ tc4_enable_compare1_isr();\n+}\n+\n+\n+/*\n+ * @brief tc4_cca1_callback Timer module compare call back\n+ *\n+ * @param module_instance stored timer module instance\n+ *\n+ */\n+void tc4_cca1_callback(void)\n+{\n+ debugpins_isr_set();\n+ if (sctimer_vars.sctimer_cb != NULL)\n+ {\n+ // clear flag?\n+ sctimer_vars.sctimer_cb();\n+ }\n+ debugpins_isr_clr();\n+}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-635. port for samr21_xpro port for sctimer
491,595
12.05.2017 13:42:41
-7,200
e8efd47592d708a11f67286b0b62f6b1c285fb57
revert 01bsp_uart.c file.
[ { "change_type": "MODIFY", "old_path": "projects/common/01bsp_uart/01bsp_uart.c", "new_path": "projects/common/01bsp_uart/01bsp_uart.c", "diff": "@@ -20,90 +20,20 @@ TeraTerm):\n// bsp modules required\n#include \"board.h\"\n#include \"uart.h\"\n+#include \"bsp_timer.h\"\n#include \"leds.h\"\n-#include \"radio.h\"\n//=========================== defines =========================================\n-#define CHANNEL 26\n-\n-#define FRAME_START 0x7E\n-#define FRAME_END 0xE7\n-\n-\n-#define FRAME_LENGTH 13\n-#define PACKAGE_LENGTH 256\n-\n-#define LENGTH_CRC 2\n-#define LENGTH_PACKET 125+LENGTH_CRC ///< maximum length is 127 bytes\n-\n-#define PAYLOAD_SIZE 90\n-\n-static const uint8_t c_readConfig[] = {\n- 0x7e,0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0xe7\n-};\n-\n-// configure baudrate 115200, ID (not set), packet content 256 bytes\n-static const uint8_t c_configParameter[] = {\n- 0x7e,0x00,0x08,0x00,0x03,0x05,0xff,0x01,0x00,0x00,0x00,0x10,0xe7\n-};\n-\n-// auto focus once\n-static const uint8_t c_configfocus[] = {\n- 0x7e,0x00,0x08,0x00,0x09,0x01,0x00,0x00,0x00,0x00,0x00,0x12,0xe7\n-};\n-\n-// picture: 800*600, grey, quality middle\n-static const uint8_t c_takePicture[] = {\n- 0x7e,0x00,0x08,0x00,0x05,0x03,0x13,0x01,0x00,0x00,0x00,0x24,0xe7\n-};\n-\n-// could be changed\n-uint8_t c_uploadPic[] = {\n- 0x7e,0x00,0x08,0x00,0x07,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0xe7\n-};\n-\n-static const uint8_t c_admin_restoreFactorySetting[] = {\n- 0x7e,0x00,0x08,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xe7\n-};\n-\n-static const uint8_t c_admin_reset[] = {\n- 0x7e,0x00,0x08,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xe7\n-};\n-\n-typedef enum {\n- S_IDLE = 0,\n- S_CONFIG = 1,\n- S_FOCUS = 2,\n- S_TAKEPIC = 3,\n- S_UPLOAD = 4,\n- S_TRANSMIT_1 = 5,\n- S_TRANSMIT_2 = 6,\n- S_TRANSMIT_3 = 7,\n-} next_action_t;\n-\n-#define S_MAXACTION 8\n-#define PIC_TO_TAKE 1\n-\n-#define INDEX_PACKET_SEG_1 11\n-#define INDEX_PACKET_SEG_2 11+PAYLOAD_SIZE\n-#define INDEX_PACKET_SEG_3 11+PAYLOAD_SIZE+PAYLOAD_SIZE\n+#define BSP_TIMER_PERIOD 0xffff // 0xffff@32kHz = 2s\n+uint8_t stringToSend[] = \"Hello, World!\\r\\n\";\n//=========================== variables =======================================\ntypedef struct {\nuint8_t uart_lastTxByteIndex;\n- uint16_t uart_lastRxByteIndex;\nvolatile uint8_t uartDone;\nvolatile uint8_t uartSendNow;\n- uint8_t uartReceiveBytes[FRAME_LENGTH];\n- uint8_t uartReceiveBytesWithPackage[PACKAGE_LENGTH+FRAME_LENGTH];\n- next_action_t nextAction;\n- uint8_t packageNumberL;\n- uint8_t packageNumberH;\n- uint8_t packet[LENGTH_PACKET];\n- uint16_t currentPackageSize;\n- uint16_t currentpackageIndex;\n} app_vars_t;\napp_vars_t app_vars;\n@@ -114,13 +44,6 @@ void cb_compare(void);\nvoid cb_uartTxDone(void);\nvoid cb_uartRxCb(void);\n-void cb_startFrame(PORT_RADIOTIMER_WIDTH timestamp);\n-void cb_endFrame(PORT_RADIOTIMER_WIDTH timestamp);\n-\n-//==== helper ====\n-uint16_t findCharAtEndOfBuffer(uint8_t* buffer,uint16_t length,uint8_t target);\n-uint8_t checksum(uint8_t* buffer, uint8_t length);\n-\n//=========================== main ============================================\n/**\n@@ -128,9 +51,6 @@ uint8_t checksum(uint8_t* buffer, uint8_t length);\n*/\nint mote_main(void) {\n- uint16_t i,j,temp;\n-\n-\n// clear local variable\nmemset(&app_vars,0,sizeof(app_vars_t));\n@@ -143,224 +63,53 @@ int mote_main(void) {\nuart_setCallbacks(cb_uartTxDone,cb_uartRxCb);\nuart_enableInterrupts();\n- // set up radio\n- radio_setStartFrameCb(cb_startFrame);\n- radio_setEndFrameCb(cb_endFrame);\n-\n- // prepare radio\n- radio_rfOn();\n- radio_setFrequency(CHANNEL);\n+ // setup BSP timer\n+ bsp_timer_set_callback(cb_compare);\n+ bsp_timer_scheduleIn(BSP_TIMER_PERIOD);\nwhile(1) {\n// wait for timer to elapse\nwhile (app_vars.uartSendNow==0);\napp_vars.uartSendNow = 0;\n- leds_sync_off();\n// send string over UART\napp_vars.uartDone = 0;\napp_vars.uart_lastTxByteIndex = 0;\n- if (app_vars.nextAction==S_IDLE){\n- app_vars.nextAction++;\n- }\n- switch (app_vars.nextAction){\n- case S_IDLE :\n- // do nothing\n- break;\n- case S_CONFIG :\n- uart_writeByte(c_configParameter[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_FOCUS :\n- uart_writeByte(c_configfocus[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_TAKEPIC :\n- uart_writeByte(c_takePicture[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_UPLOAD :\n- if (app_vars.currentpackageIndex == app_vars.packageNumberH*256+app_vars.packageNumberL){\n- // Done!!!\n- return 0;\n- } else {\n- app_vars.currentpackageIndex++;\n- }\n- // upload package 01\n- c_uploadPic[6] = (uint8_t)((app_vars.currentpackageIndex>>8) & 0xff);\n- c_uploadPic[7] = (uint8_t)(app_vars.currentpackageIndex & 0xff);\n- // total number packet\n- c_uploadPic[8] = app_vars.packageNumberH;\n- c_uploadPic[9] = app_vars.packageNumberL;\n- // checksum\n- c_uploadPic[11] = checksum(&c_uploadPic[1],11);\n- memset(&app_vars.uartReceiveBytesWithPackage[0],0,PACKAGE_LENGTH+FRAME_LENGTH);\n- uart_writeByte(c_uploadPic[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_TRANSMIT_1:\n- // reset radio status\n- radio_rfOff();\n-\n- temp = findCharAtEndOfBuffer(&app_vars.uartReceiveBytesWithPackage[0],PACKAGE_LENGTH+FRAME_LENGTH,FRAME_END);\n- if (temp > 12 && temp <PACKAGE_LENGTH+FRAME_LENGTH){\n- app_vars.currentPackageSize = temp - 1 - 11; // checksum+header and parameters\n- } else {\n- app_vars.currentPackageSize = 0;\n- return 0;\n- }\n-\n- // prepare packet\n- if (app_vars.currentPackageSize/PAYLOAD_SIZE>0){\n- for (i=0;i<PAYLOAD_SIZE;i++) {\n- app_vars.packet[i] = app_vars.uartReceiveBytesWithPackage[i+INDEX_PACKET_SEG_1];\n- }\n- radio_loadPacket(app_vars.packet,PAYLOAD_SIZE);\n- } else {\n- for (i=0;i<app_vars.currentPackageSize;i++) {\n- app_vars.packet[i] = app_vars.uartReceiveBytesWithPackage[i+INDEX_PACKET_SEG_1];\n- }\n- radio_loadPacket(app_vars.packet,app_vars.currentPackageSize);\n- }\n-\n- // start transmitting packet\n- radio_txEnable();\n- radio_txNow();\n- break;\n- case S_TRANSMIT_2:\n- // reset radio status\n- radio_rfOff();\n- if (app_vars.currentPackageSize==0){\n- return 0;\n- }\n-\n- if (app_vars.currentPackageSize/PAYLOAD_SIZE>1){\n- for (i=0;i<PAYLOAD_SIZE;i++) {\n- app_vars.packet[i] = app_vars.uartReceiveBytesWithPackage[i+INDEX_PACKET_SEG_2];\n- }\n- radio_loadPacket(app_vars.packet,PAYLOAD_SIZE);\n- } else {\n- for (i=0;i<app_vars.currentPackageSize-PAYLOAD_SIZE;i++) {\n- app_vars.packet[i] = app_vars.uartReceiveBytesWithPackage[i+INDEX_PACKET_SEG_2];\n- }\n- radio_loadPacket(app_vars.packet,app_vars.currentPackageSize-PAYLOAD_SIZE);\n- }\n- // start transmitting packet\n- radio_txEnable();\n- radio_txNow();\n- break;\n- case S_TRANSMIT_3:\n- // reset radio status\n- radio_rfOff();\n- if (app_vars.currentPackageSize==0){\n- return 0;\n- }\n-\n- if (app_vars.currentPackageSize/PAYLOAD_SIZE>2){\n- // something wrong\n- return 0;\n- } else {\n- for (i=0;i<app_vars.currentPackageSize-2*PAYLOAD_SIZE;i++) {\n- app_vars.packet[i] = app_vars.uartReceiveBytesWithPackage[i+INDEX_PACKET_SEG_3];\n- }\n- radio_loadPacket(app_vars.packet,app_vars.currentPackageSize-2*PAYLOAD_SIZE);\n- }\n- // start transmitting packet\n- radio_txEnable();\n- radio_txNow();\n- break;\n- }\n+ uart_writeByte(stringToSend[app_vars.uart_lastTxByteIndex]);\nwhile(app_vars.uartDone==0);\n- // a little delay\n- for (i=0;i<0xfff;i++){\n- for (j=0;j<0xff;j++);\n}\n}\n- return 0;\n-}\n-//=========================== helper ==========================================\n+//=========================== callbacks =======================================\n-uint16_t findCharAtEndOfBuffer(uint8_t* buffer,uint16_t length,uint8_t target){\n- uint16_t i;\n- for (i=length-1;i>0;i--){\n- if (target == buffer[i]){\n- break;\n- }\n- }\n- return i;\n-}\n+void cb_compare(void) {\n-uint8_t checksum(uint8_t* buffer, uint8_t length){\n- uint8_t i;\n- uint8_t checksum = 0;\n- for (i=0;i<length;i++){\n- checksum += buffer[i];\n- }\n- return checksum;\n-}\n+ // have main \"task\" send over UART\n+ app_vars.uartSendNow = 1;\n-//=========================== callbacks =======================================\n+ // schedule again\n+ bsp_timer_scheduleIn(BSP_TIMER_PERIOD);\n+}\nvoid cb_uartTxDone(void) {\napp_vars.uart_lastTxByteIndex++;\n- if (app_vars.uart_lastTxByteIndex<FRAME_LENGTH) {\n- switch (app_vars.nextAction){\n- case S_IDLE :\n- // do nothing\n- break;\n- case S_CONFIG :\n- uart_writeByte(c_configParameter[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_FOCUS :\n- uart_writeByte(c_configfocus[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_TAKEPIC :\n- uart_writeByte(c_takePicture[app_vars.uart_lastTxByteIndex]);\n- break;\n- case S_UPLOAD :\n- uart_writeByte(c_uploadPic[app_vars.uart_lastTxByteIndex]);\n- break;\n- }\n+ if (app_vars.uart_lastTxByteIndex<sizeof(stringToSend)) {\n+ uart_writeByte(stringToSend[app_vars.uart_lastTxByteIndex]);\n} else {\napp_vars.uartDone = 1;\n}\n}\nvoid cb_uartRxCb(void) {\n- uint16_t byteLengthToRead = FRAME_LENGTH;\n+ uint8_t byte;\n+\n// toggle LED\nleds_error_toggle();\n// read received byte\n- if (app_vars.nextAction==S_UPLOAD){\n- byteLengthToRead += PACKAGE_LENGTH;\n- app_vars.uartReceiveBytesWithPackage[app_vars.uart_lastRxByteIndex] = uart_readByte();\n- } else {\n- app_vars.uartReceiveBytes[app_vars.uart_lastRxByteIndex] = uart_readByte();\n- }\n- app_vars.uart_lastRxByteIndex++;\n+ byte = uart_readByte();\n// echo that byte over serial\n- if (app_vars.uart_lastRxByteIndex==byteLengthToRead){\n- leds_sync_on();\n- app_vars.uart_lastRxByteIndex = 0;\n- if (app_vars.nextAction==S_TAKEPIC){\n- app_vars.packageNumberL = app_vars.uartReceiveBytes[10];\n- app_vars.packageNumberH |= app_vars.uartReceiveBytes[9];\n- }\n- app_vars.nextAction = (app_vars.nextAction+1)%S_MAXACTION;\n- app_vars.uartSendNow = 1;\n- }\n-}\n-\n-void cb_startFrame(PORT_RADIOTIMER_WIDTH timestamp) {\n-\n-}\n-\n-void cb_endFrame(PORT_RADIOTIMER_WIDTH timestamp) {\n- if (app_vars.nextAction == S_TRANSMIT_3){\n- app_vars.nextAction = S_UPLOAD;\n- } else {\n- app_vars.nextAction = (app_vars.nextAction+1)%S_MAXACTION;\n- }\n- app_vars.uartSendNow = 1;\n- app_vars.uartDone = 1;\n+ uart_writeByte(byte);\n}\n\\ No newline at end of file\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-635. revert 01bsp_uart.c file.
491,595
16.05.2017 21:29:42
-7,200
a91adb208e3a7e9800f13b57cc167ea25880723f
radio has higher priority than timer but not embedded interrupt.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/iot-lab_A8-M3/nvic.c", "new_path": "bsp/boards/iot-lab_A8-M3/nvic.c", "diff": "@@ -53,7 +53,7 @@ void NVIC_sctimer(void) {\n//Configure NVIC: Preemption Priority = 0 and Sub Priority = 1\nNVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel;\nNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;\n- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\n+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\nNVIC_Init(&NVIC_InitStructure);\n}\n@@ -65,7 +65,7 @@ void NVIC_radio(void)\nNVIC_InitTypeDef NVIC_InitStructure;\nNVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;\nNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;\n- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;\n+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\nNVIC_Init(&NVIC_InitStructure);\n}\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/iot-lab_M3/nvic.c", "new_path": "bsp/boards/iot-lab_M3/nvic.c", "diff": "@@ -54,7 +54,7 @@ void NVIC_sctimer(void) {\n//Configure NVIC: Preemption Priority = 0 and Sub Priority = 1\nNVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;\nNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;\n- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\n+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\nNVIC_Init(&NVIC_InitStructure);\n}\n@@ -64,8 +64,8 @@ void NVIC_radio(void){\n//Configure NVIC: Preemption Priority = 2 and Sub Priority = 0\nNVIC_InitTypeDef NVIC_InitStructure;\nNVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;\n- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;\n- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;\n+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;\n+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\nNVIC_Init(&NVIC_InitStructure);\n}\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/openmotestm/nvic.c", "new_path": "bsp/boards/openmotestm/nvic.c", "diff": "@@ -64,7 +64,7 @@ void NVIC_radio(void){\n//Configure NVIC: Preemption Priority = 0 and Sub Priority = 0\nNVIC_InitTypeDef NVIC_InitStructure;\nNVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;\n- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;\n+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;\nNVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\nNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\nNVIC_Init(&NVIC_InitStructure);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-635. radio has higher priority than timer but not embedded interrupt.
491,595
17.05.2017 20:03:56
-7,200
66c4d23c21e6bc005013b3fd3eee4b770fda5aa4
change opencoap as an application.
[ { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -41,8 +41,10 @@ else:\nuserApps = []\n# union of default and additional apps (without duplicates)\n-apps = sorted(list(set(defaultApps+userApps)))\n-appsInit = sorted(list(set(defaultAppsInit+userApps)))\n+apps = ['opencoap']\n+apps += sorted(list(set(defaultApps+userApps)))\n+appsInit = ['opencoap'] # make sure opencoap is initialized first\n+appsInit += sorted(list(set(defaultAppsInit+userApps)))\n#===== rule to create a (temporary) openapps_dyn.c file\n" }, { "change_type": "MODIFY", "old_path": "openapps/openapps.c", "new_path": "openapps/openapps.c", "diff": "#include \"opendefs.h\"\n// CoAP\n+#include \"opencoap.h\"\n#include \"c6t.h\"\n#include \"cinfo.h\"\n#include \"cleds.h\"\n" }, { "change_type": "RENAME", "old_path": "openstack/04-TRAN/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "" }, { "change_type": "RENAME", "old_path": "openstack/04-TRAN/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "" }, { "change_type": "MODIFY", "old_path": "openstack/04-TRAN/openudp.c", "new_path": "openstack/04-TRAN/openudp.c", "diff": "@@ -227,11 +227,11 @@ void openudp_receive(OpenQueueEntry_t* msg) {\n(errorparameter_t)msg->l4_destination_port,\n(errorparameter_t)6);\nopenqueue_freePacketBuffer(msg);\n- }\n-\n+ } else {\n// forward message to resource\nudp_receive_done_callback_ptr(msg);\n}\n+}\nbool openudp_debugPrint() {\nreturn FALSE;\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -29,7 +29,6 @@ sources_c = [\nos.path.join('03b-IPv6','icmpv6echo.c'),\nos.path.join('03b-IPv6','icmpv6rpl.c'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','opencoap.c'),\nos.path.join('04-TRAN','opentcp.c'),\nos.path.join('04-TRAN','openudp.c'),\n#=== cross-layers\n@@ -63,7 +62,6 @@ sources_h = [\nos.path.join('03b-IPv6','icmpv6echo.h'),\nos.path.join('03b-IPv6','icmpv6rpl.h'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','opencoap.h'),\nos.path.join('04-TRAN','opentcp.h'),\nos.path.join('04-TRAN','openudp.h'),\n#=== cross-layers\n@@ -110,6 +108,7 @@ else:\nos.path.join('#','openstack','cross-layers'),\n# openapps\n# TODO: remove once cleaned-up?\n+ os.path.join('#','openapps','opencoap'),\nos.path.join('#','openapps','c6t'),\nos.path.join('#','openapps','cexample'),\nos.path.join('#','openapps','cinfo'),\n" }, { "change_type": "MODIFY", "old_path": "openstack/openstack.c", "new_path": "openstack/openstack.c", "diff": "//-- 04-TRAN\n#include \"opentcp.h\"\n#include \"openudp.h\"\n-#include \"opencoap.h\"\n//===== applications\n#include \"openapps.h\"\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -74,6 +74,7 @@ buildEnv.Append(\nos.path.join('#','build','python_gcc','openstack','cross-layers'),\n# openapps\nos.path.join('#','build','python_gcc','openapps'),\n+ os.path.join('#','build','python_gcc','openapps','opencoap'),\nos.path.join('#','build','python_gcc','openapps','c6t'),\nos.path.join('#','build','python_gcc','openapps','rrt'),\nos.path.join('#','build','python_gcc','openapps','cexample'),\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-637. change opencoap as an application.
491,595
23.05.2017 18:45:52
-7,200
c545a8fbea4ce7694ec2c0d42955d64225f15dc6
correct duty cycle calculation.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -448,6 +448,9 @@ port_INLINE void activity_synchronize_newSlot() {\nreturn;\n}\n+ ieee154e_vars.radioOnInit=sctimer_readCounter();\n+ ieee154e_vars.radioOnThisSlot=TRUE;\n+\n// if this is the first time I call this function while not synchronized,\n// switch on the radio in Rx mode\nif (ieee154e_vars.state!=S_SYNCLISTEN) {\n@@ -465,9 +468,11 @@ port_INLINE void activity_synchronize_newSlot() {\n// switch on the radio in Rx mode.\nradio_rxEnable();\n- ieee154e_vars.radioOnInit=sctimer_readCounter();\n- ieee154e_vars.radioOnThisSlot=TRUE;\nradio_rxNow();\n+ } else {\n+ // I'm listening last slot\n+ ieee154e_stats.numTicsOn += ieee154e_vars.slotDuration;\n+ ieee154e_stats.numTicsTotal += ieee154e_vars.slotDuration;\n}\n// if I'm already in S_SYNCLISTEN, while not synchronized,\n@@ -485,8 +490,6 @@ port_INLINE void activity_synchronize_newSlot() {\n// switch on the radio in Rx mode.\nradio_rxEnable();\n- ieee154e_vars.radioOnInit=sctimer_readCounter();\n- ieee154e_vars.radioOnThisSlot=TRUE;\nradio_rxNow();\nieee154e_vars.singleChannelChanged = FALSE;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-635. correct duty cycle calculation.
491,595
29.05.2017 11:22:09
-7,200
915dfd5d50fc2c5470678119db332fed02535e58
send time correction through serial port always (will be controlled to print out in OV).
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -2226,11 +2226,7 @@ void synchronizePacket(PORT_RADIOTIMER_WIDTH timeReceived) {\n// log a large timeCorrection\nif (\n- ieee154e_vars.isSync==TRUE &&\n- (\n- timeCorrection<-LIMITLARGETIMECORRECTION ||\n- timeCorrection> LIMITLARGETIMECORRECTION\n- )\n+ ieee154e_vars.isSync==TRUE\n) {\nopenserial_printError(COMPONENT_IEEE802154E,ERR_LARGE_TIMECORRECTION,\n(errorparameter_t)timeCorrection,\n@@ -2266,11 +2262,7 @@ void synchronizeAck(PORT_SIGNED_INT_WIDTH timeCorrection) {\n#endif\n// log a large timeCorrection\nif (\n- ieee154e_vars.isSync==TRUE &&\n- (\n- timeCorrection<-LIMITLARGETIMECORRECTION ||\n- timeCorrection> LIMITLARGETIMECORRECTION\n- )\n+ ieee154e_vars.isSync==TRUE\n) {\nopenserial_printError(COMPONENT_IEEE802154E,ERR_LARGE_TIMECORRECTION,\n(errorparameter_t)timeCorrection,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-647. send time correction through serial port always (will be controlled to print out in OV).
491,595
01.06.2017 19:36:35
-7,200
0726471e3d94e206465ac6d9d9d3fc6972716cc3
implement additional functions for sixtop process.
[ { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -363,6 +363,8 @@ typedef struct {\nasn_t asn;\nuint8_t joinPrio;\nbool f6PNORES;\n+ uint8_t generation;\n+ uint8_t sequenceNumber;\n} neighborRow_t;\nEND_PACK\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/neighbors.c", "new_path": "openstack/02b-MAChigh/neighbors.c", "diff": "@@ -98,6 +98,30 @@ bool neighbors_getNeighborNoResource(uint8_t index){\nreturn neighbors_vars.neighbors[index].f6PNORES;\n}\n+uint8_t neighbors_getGeneration(open_addr_t* address){\n+ uint8_t i;\n+ for (i=0;i<MAXNUMNEIGHBORS;i++){\n+ if (packetfunctions_sameAddress(address, &neighbors_vars.neighbors[i].addr_64b)){\n+ break;\n+ }\n+ }\n+ if (i!=MAXNUMNEIGHBORS){\n+ return neighbors_vars.neighbors[i].generation;\n+ }\n+}\n+\n+uint8_t neighbors_getSequenceNumber(open_addr_t* address){\n+ uint8_t i;\n+ for (i=0;i<MAXNUMNEIGHBORS;i++){\n+ if (packetfunctions_sameAddress(address, &neighbors_vars.neighbors[i].addr_64b)){\n+ break;\n+ }\n+ }\n+ if (i!=MAXNUMNEIGHBORS){\n+ return neighbors_vars.neighbors[i].sequenceNumber;\n+ }\n+}\n+\n//===== interrogators\n/**\n@@ -331,6 +355,36 @@ void neighbors_indicateTx(open_addr_t* l2_dest,\n}\n}\n+void neighbors_updateSequenceNumber(open_addr_t* address){\n+ uint8_t i;\n+ for (i=0;i<MAXNUMNEIGHBORS;i++){\n+ if (packetfunctions_sameAddress(address, &neighbors_vars.neighbors[i].addr_64b)){\n+ neighbors_vars.neighbors[i].sequenceNumber = (neighbors_vars.neighbors[i].sequenceNumber+1) & 0x0F;\n+ break;\n+ }\n+ }\n+}\n+\n+void neighbors_updateGeneration(open_addr_t* address){\n+ uint8_t i;\n+ for (i=0;i<MAXNUMNEIGHBORS;i++){\n+ if (packetfunctions_sameAddress(address, &neighbors_vars.neighbors[i].addr_64b)){\n+ neighbors_vars.neighbors[i].generation = (neighbors_vars.neighbors[i].generation+1)%9;\n+ break;\n+ }\n+ }\n+}\n+\n+void neighbors_resetGeneration(open_addr_t* address){\n+ uint8_t i;\n+ for (i=0;i<MAXNUMNEIGHBORS;i++){\n+ if (packetfunctions_sameAddress(address, &neighbors_vars.neighbors[i].addr_64b)){\n+ neighbors_vars.neighbors[i].generation = 0;\n+ break;\n+ }\n+ }\n+}\n+\n//===== write addresses\n/**\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/neighbors.h", "new_path": "openstack/02b-MAChigh/neighbors.h", "diff": "@@ -60,11 +60,12 @@ uint8_t neighbors_getNumNeighbors(void);\nuint16_t neighbors_getLinkMetric(uint8_t index);\nopen_addr_t* neighbors_getKANeighbor(uint16_t kaPeriod);\nbool neighbors_getNeighborNoResource(uint8_t index);\n+uint8_t neighbors_getGeneration(open_addr_t* address);\n+uint8_t neighbors_getSequenceNumber(open_addr_t* address);\n// setters\nvoid neighbors_setNeighborRank(uint8_t index, dagrank_t rank);\nvoid neighbors_setNeighborNoResource(open_addr_t* address);\nvoid neighbors_setPreferredParent(uint8_t index, bool isPreferred);\n-\n// interrogators\nbool neighbors_isStableNeighbor(open_addr_t* address);\nbool neighbors_isStableNeighborByIndex(uint8_t index);\n@@ -85,6 +86,9 @@ void neighbors_indicateTx(\nbool was_finally_acked,\nasn_t* asnTimestamp\n);\n+void neighbors_updateSequenceNumber(open_addr_t* address);\n+void neighbors_updateGeneration(open_addr_t* address);\n+void neighbors_resetGeneration(open_addr_t* address);\n// get addresses\nbool neighbors_getNeighborEui64(open_addr_t* address,uint8_t addr_type,uint8_t index);\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/schedule.c", "new_path": "openstack/02b-MAChigh/schedule.c", "diff": "@@ -853,6 +853,40 @@ void schedule_housekeeping(){\nENABLE_INTERRUPTS();\n}\n+bool schedule_getOneCellAfterOffset(uint8_t metadata,uint8_t offset,open_addr_t* neighbor, uint8_t cellOptions, uint16_t* slotoffset, uint16_t* channeloffset){\n+ bool returnVal;\n+ scheduleEntry_t* scheduleWalker;\n+ cellType_t type;\n+ INTERRUPT_DECLARATION();\n+ DISABLE_INTERRUPTS();\n+\n+ // translate cellOptions to cell type\n+ if (cellOptions == LINKOPTIONS_TX){\n+ type = CELLTYPE_TX;\n+ }\n+ if (cellOptions == LINKOPTIONS_RX){\n+ type = CELLTYPE_RX;\n+ }\n+ if (cellOptions == LINKOPTIONS_TX | LINKOPTIONS_RX | LINKOPTIONS_SHARED){\n+ type = CELLTYPE_TXRX;\n+ }\n+\n+ scheduleWalker = &schedule_vars.scheduleBuf[0]; // fisrt entry record slotoffset 0\n+ do {\n+ if(type == scheduleWalker->type && scheduleWalker->slotOffset >= offset){\n+ *slotoffset = scheduleWalker->slotOffset;\n+ *channeloffset = scheduleWalker->channelOffset;\n+ returnVal = TRUE;\n+ break;\n+ }\n+ scheduleWalker = scheduleWalker->next;\n+ }while(scheduleWalker!=schedule_vars.scheduleBuf[0]);\n+\n+ ENABLE_INTERRUPTS();\n+\n+ return returnVal;\n+}\n+\n//=========================== private =========================================\n/**\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/schedule.h", "new_path": "openstack/02b-MAChigh/schedule.h", "diff": "@@ -76,11 +76,11 @@ See MINBE for an explanation of backoff.\n#define MIN_NUMTX_FOR_PDR 50 // don't calculate PDR when numTx is lower than this value\ntypedef enum{\n- LINKOPTIONS_TX = 1<<0;\n- LINKOPTIONS_RX = 1<<1;\n- LINKOPTIONS_SHARED = 1<<2;\n- LINKOPTIONS_TIMEKEPPING = 1<<3;\n- LINKOPTIONS_PRIORITY = 1<<4;\n+ LINKOPTIONS_TX = 1<<0,\n+ LINKOPTIONS_RX = 1<<1,\n+ LINKOPTIONS_SHARED = 1<<2,\n+ LINKOPTIONS_TIMEKEPPING = 1<<3,\n+ LINKOPTIONS_PRIORITY = 1<<4\n}linkOptions_t;\n//=========================== typedef =========================================\n@@ -210,8 +210,16 @@ void schedule_indicateTx(\nasn_t* asnTimestamp,\nbool succesfullTx\n);\n-\n+// from sixtop\nvoid schedule_housekeeping(void);\n+bool schedule_getOneCellAfterOffset(\n+ uint8_t metadata,\n+ uint8_t offset,\n+ open_addr_t* neighbor,\n+ uint8_t cellOptions,\n+ uint16_t* slotoffset,\n+ uint16_t* channeloffset\n+);\n/**\n\\}\n\\}\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sf0.c", "new_path": "openstack/02b-MAChigh/sf0.c", "diff": "#include \"schedule.h\"\n#include \"idmanager.h\"\n#include \"openapps.h\"\n+#include \"openrandom.h\"\n//=========================== definition =====================================\n+#define SF0_ID 0\n#define SF0THRESHOLD 2\n//=========================== variables =======================================\n@@ -20,12 +22,18 @@ sf0_vars_t sf0_vars;\nvoid sf0_addCell_task(void);\nvoid sf0_removeCell_task(void);\nvoid sf0_bandwidthEstimate_task(void);\n+// sixtop callback\n+uint8_t sf0_getsfid(void);\n+uint16_t sf0_getMetadata(void);\n+metadata_t sf0_translateMetadata(void);\n+void sf0_handleRCError(uint8_t code);\n//=========================== public ==========================================\nvoid sf0_init(void) {\nmemset(&sf0_vars,0,sizeof(sf0_vars_t));\nsf0_vars.numAppPacketsPerSlotFrame = 0;\n+ sixtop_setSFcallback(sf0_getsfid,sf0_getMetadata,sf0_translateMetadata,sf0_handleRCError);\n}\nvoid sf0_notif_addedCell(void) {\n@@ -45,17 +53,28 @@ void sf0_setBackoff(uint8_t value){\nsf0_vars.backoff = value;\n}\n+\n+\n+//=========================== callback =========================================\n+\n+uint8_t sf0_getsfid(void){\n+ return SF0_ID;\n+}\n+\n+uint16_t sf0_getMetadata(void){\n+ return SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE;\n+}\n+\n+metadata_t sf0_translateMetadata(void){\n+ return METADATA_TYPE_FRAMEID;\n+}\n+\nvoid sf0_handleRCError(uint8_t code){\nif (code==IANA_6TOP_RC_BUSY){\n// disable sf0 for [0...2^4] slotframe long time\nsf0_setBackoff(openrandom_get16b()%(1<<4));\n}\n- if (code==IANA_6TOP_RC_NORES){\n- // mark this neighbor as no resource for future processing\n- neighbors_setNeighborNoResource(&(pkt->l2_nextORpreviousHop));\n- }\n-\nif (code==IANA_6TOP_RC_RESET){\n// TBD: the neighbor can't statisfy the 6p request with given cells, call sf0 to make a decision\n// (e.g. issue another 6p request with different cell list)\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sf0.h", "new_path": "openstack/02b-MAChigh/sf0.h", "diff": "@@ -33,8 +33,6 @@ void sf0_notifyNewSlotframe(void);\nvoid sf0_appPktPeriod(uint8_t numAppPacketsPerSlotFrame);\nvoid sf0_setBackoff(uint8_t value);\n-\n-void sf0_handleRCError(uint8_t code);\n/**\n\\}\n\\}\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -91,13 +91,13 @@ bool sixtop_candidateRemoveCellList(\nopen_addr_t* neighbor,\nuint8_t requiredCells\n);\n-void sixtop_addCellsByState(\n+void sixtop_addCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\n- uint8_t state\n+ uint8_t cellOptions\n);\n-void sixtop_removeCellsByState(\n+void sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop\n@@ -180,6 +180,16 @@ bool sixtop_setHandler(six2six_handler_t handler) {\n}\n}\n+void sixtop_setSFcallback(\n+ sixtop_sf_get_callback cb1,\n+ sixtop_sf_get_callback cb2,\n+ sixtop_sf_handle_callback cb3\n+){\n+ sixtop_vars.cb_sf_getMetadata = cb1;\n+ sixtop_vars.cb_sf_translateMetadata = cb2;\n+ sixtop_vars.cb_sf_handleRCError = cb3\n+}\n+\n//======= scheduling\nvoid sixtop_request(\n@@ -231,7 +241,7 @@ void sixtop_request(\npkt->owner = COMPONENT_SIXTOP_RES;\nmemcpy(&(pkt->l2_nextORpreviousHop),neighbor,sizeof(open_addr_t));\n- memcpy(sixtop_vars.celllist_toRemove,celllist_toBeRemoved,sizeof(celllist_toBeRemoved));\n+ memcpy(sixtop_vars.celllist_toDelete,celllist_toDelete,sizeof(celllist_toDelete));\nsixtop_vars.cellOptions = cellOptions;\nlen = 0;\n@@ -306,14 +316,14 @@ void sixtop_request(\n// append 6p metadata\npacketfunctions_reserveHeaderSize(pkt,sizeof(uint16_t));\n- *((uint8_t*)(pkt->payload)) = sixtop_getMetadata(sfid);\n+ *((uint8_t*)(pkt->payload)) = sixtop_vars.cb_sf_getMetadata();\nlen += 2;\n// append 6p Seqnum and schedule Generation\npacketfunctions_reserveHeaderSize(pkt,sizeof(uint8_t));\n- scheduleGeneration = schedule_getGeneration();\n+ scheduleGeneration = neighbors_getGeneration(neighbor);\nsequenceNumber = neighbors_getSequenceNumber(neighbor);\n- *((uint8_t*)(pkt->payload)) = sequenceNumber | scheduleGeneration<<IANA_6TOP_GEN_SHIFT;\n+ *((uint8_t*)(pkt->payload)) = sequenceNumber | (scheduleGeneration<<IANA_6TOP_GEN_SHIFT);\nlen += 1;\n// append 6p sfid\n@@ -352,6 +362,7 @@ void sixtop_request(\n// send packet\nsixtop_send(pkt);\n+ neighbors_updateSequenceNumber(neighbor);\n//update states\nswitch(code){\n@@ -373,90 +384,6 @@ void sixtop_request(\n}\n}\n-void sixtop_addORremoveCellByInfo(uint8_t code,open_addr_t* neighbor,cellInfo_ht* cellInfo){\n- OpenQueueEntry_t* pkt;\n- uint8_t len;\n- uint8_t frameID;\n- uint8_t container;\n- cellInfo_ht cellList[CELLLIST_MAX_LEN];\n-\n- memset(cellList,0,sizeof(cellList));\n-\n- // filter parameters: handler, status and neighbor\n- if(\n- sixtop_vars.handler == SIX_HANDLER_NONE ||\n- sixtop_vars.six2six_state != SIX_STATE_IDLE ||\n- neighbor == NULL\n- ){\n- // parameters are wrong\n- // DONOT change sixtop status for the new transaction\n- return;\n- }\n-\n- // new transaction parameter checking passed.\n-\n- // set cell list (only first one is to be removed)\n- frameID = SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE;\n- container = frameID;\n- memcpy(&(cellList[0]),cellInfo,sizeof(cellList));\n-\n-\n- // get a free packet buffer\n- pkt = openqueue_getFreePacketBuffer(COMPONENT_SIXTOP_RES);\n- if(pkt==NULL) {\n- sixtop_vars.handler = SIX_HANDLER_NONE;\n- openserial_printError(\n- COMPONENT_SIXTOP_RES,\n- ERR_NO_FREE_PACKET_BUFFER,\n- (errorparameter_t)0,\n- (errorparameter_t)0\n- );\n- return;\n- }\n-\n- // update state\n- sixtop_vars.six2six_state = SIX_STATE_SENDING_REQUEST;\n-\n- // declare ownership over that packet\n- pkt->creator = COMPONENT_SIXTOP_RES;\n- pkt->owner = COMPONENT_SIXTOP_RES;\n-\n- memcpy(&(pkt->l2_nextORpreviousHop),neighbor,sizeof(open_addr_t));\n-\n- len = 0;\n- len += processIE_prepend_sixCelllist(pkt,cellList);\n- // reserve space for container\n- packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t));\n- // write header\n- *((uint8_t*)(pkt->payload)) = container;\n- len+=1;\n- // reserve space for numCells\n- packetfunctions_reserveHeaderSize(pkt,sizeof(uint8_t));\n- // write header\n- *((uint8_t*)(pkt->payload)) = 1;\n- len+=1;\n-\n- len += processIE_prepend_sixGeneralMessage(pkt,code);\n- len += processIE_prepend_sixSubID(pkt);\n- processIE_prepend_sixtopIE(pkt,len);\n-\n- // indicate IEs present\n- pkt->l2_payloadIEpresent = TRUE;\n-\n- // send packet\n- sixtop_send(pkt);\n-\n- //update states\n- switch(code){\n- case IANA_6TOP_CMD_ADD:\n- sixtop_vars.six2six_state = SIX_STATE_WAIT_ADDREQUEST_SENDDONE;\n- break;\n- case IANA_6TOP_CMD_DELETE:\n- sixtop_vars.six2six_state = SIX_STATE_WAIT_DELETEREQUEST_SENDDONE;\n- break;\n- }\n-}\n-\n//======= from upper layer\nowerror_t sixtop_send(OpenQueueEntry_t *msg) {\n@@ -981,36 +908,37 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\n// in case a response is sent out, check the return code\nif (msg->l2_sixtop_returnCode == IANA_6TOP_RC_SUCCESS){\nif (msg->l2_sixtop_command == IANA_6TOP_CMD_ADD){\n- sixtop_addCellsByState(\n+ sixtop_addCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_cellList_add,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n);\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\nif (msg->l2_sixtop_command == IANA_6TOP_CMD_DELETE){\n- sixtop_removeCellsByState(\n+ sixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_cellList_delete,\n- &(msg->l2_nextORpreviousHop),\n- msg->l2_sixtop_cellOptions\n+ &(msg->l2_nextORpreviousHop)\n);\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\nif ( msg->l2_sixtop_command == IANA_6TOP_CMD_RELOCATE){\n- sixtop_removeCellsByState(\n+ sixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_cellList_delete,\n- &(msg->l2_nextORpreviousHop),\n- msg->l2_sixtop_cellOptions\n+ &(msg->l2_nextORpreviousHop)\n);\n- sixtop_addCellsByState(\n+ sixtop_addCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_cellList_add,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n);\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\nif ( msg->l2_sixtop_command == IANA_6TOP_CMD_CLEAR){\n@@ -1018,15 +946,22 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\nmsg->l2_sixtop_frameID,\n&(msg->l2_nextORpreviousHop)\n);\n+ neighbors_resetGeneration(&(msg->l2_nextORpreviousHop));\n}\n} else {\n// the return code is not SUCCESS, nothing require to do on response side\n}\n} else {\n+\n+ if (code==IANA_6TOP_RC_NORES){\n+ // mark this neighbor as no resource for future processing\n+ neighbors_setNeighborNoResource(&(pkt->l2_nextORpreviousHop));\n+ } else {\n// the 6p response failed to send out, should inform sf0\nsixtop_vars.sf_response_failure();\n}\n}\n+ }\n// free the buffer\nopenqueue_freePacketBuffer(msg);\n}\n@@ -1113,7 +1048,8 @@ void sixtop_six2six_notifyReceive(\nuint16_t count;\nuint16_t metadata;\nuint8_t cellOptions;\n- uint8_t offset;\n+ uint16_t offset;\n+ uint16_t startingOffset;\nuint8_t maxNumCells;\nuint16_t i;\nuint16_t slotoffset;\n@@ -1157,7 +1093,7 @@ void sixtop_six2six_notifyReceive(\nbreak;\n}\n// sfid check\n- if (sfId != sixtop_vars.registeredSFID){\n+ if (sfId != sixtop_vars.sixtop_sf_getsfid()){\nreturnCode = IANA_6TOP_RC_SFID_ERR;\nbreak;\n}\n@@ -1212,15 +1148,25 @@ void sixtop_six2six_notifyReceive(\nptr += 2;\nreturnCode = IANA_6TOP_RC_SUCCESS;\n+ startingOffset = offset;\nfor(i=0; i<maxNumCells; i++) {\n- if (schedule_getOneCellAfterOffset(metadata,offset+i,&(pkt->l2_nextORpreviousHop),&slotoffset,&channeloffset)){\n- // found one cell after slot: offset+i\n+ if (\n+ schedule_getOneCellAfterOffset(\n+ metadata,\n+ startingOffset,\n+ &(pkt->l2_nextORpreviousHop),\n+ cellOptions ^ (LINKOPTIONS_TX | LINKOPTIONS_RX),\n+ &slotoffset,\n+ &channeloffset)\n+ ){\n+ // found one cell after slot offset+i\npacketfunctions_reserveHeaderSize(response_pkt,4);\nresponse_pkt->payload[0] = slotoffset & 0x00FF;\nresponse_pkt->payload[1] = (slotoffset & 0xFF00)>>8);\nresponse_pkt->payload[2] = channeloffset & 0x00FF;\nresponse_pkt->payload[3] = (channeloffset & 0xFF00)>>8);\nresponse_pktLen += 4;\n+ startingOffset = slotoffset+1;\n} else {\n// no more cell after offset\nreturnCode = IANA_6TOP_RC_EOL;\n@@ -1233,10 +1179,20 @@ void sixtop_six2six_notifyReceive(\n// count command\nif (code == IANA_6TOP_CMD_LIST){\nnumCells = 0;\n+ startingOffset = 0;\nfor(i=0; i<schedule_getFrameLength(); i++) {\n- if (schedule_getOneCellAfterOffset(metadata,i,&(pkt->l2_nextORpreviousHop),&slotoffset,&channeloffset)){\n- // found one cell after slot: offset+i\n+ if (\n+ schedule_getOneCellAfterOffset(\n+ metadata,\n+ startingOffset,\n+ &(pkt->l2_nextORpreviousHop),\n+ cellOptions ^ (LINKOPTIONS_TX | LINKOPTIONS_RX),\n+ &slotoffset,\n+ &channeloffset)\n+ )){\n+ // found one cell after slot i\nnumCells++;\n+ startingOffset = slotoffset+1;\n}\n}\nreturnCode = IANA_6TOP_RC_SUCCESS;\n@@ -1270,7 +1226,7 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n- if (sixtop_areAvailableCellsToBeScheduled(metadata,numCells,response_pkt->l2_sixtop_cellList_add[i])){\n+ if (sixtop_areAvailableCellsToBeScheduled(metadata,numCells,response_pkt->l2_sixtop_cellList_add)){\nreturnCode = IANA_6TOP_RC_SUCCESS;\nfor(i=0;i<CELLLIST_MAX_LEN;i++) {\nif(response_pkt->l2_sixtop_cellList_add[i].isUsed){\n@@ -1301,7 +1257,7 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n- if (sixtop_areAvailableCellsToBeRemoved(metadata,numCells,response_pkt->l2_sixtop_cellList_delete,&(pkt->l2_nextORpreviousHop))){\n+ if (sixtop_areAvailableCellsToBeRemoved(metadata,numCells,response_pkt->l2_sixtop_cellList_delete,&(pkt->l2_nextORpreviousHop),cellOptions)){\nreturnCode = IANA_6TOP_RC_SUCCESS;\nfor(i=0;i<CELLLIST_MAX_LEN;i++) {\nif(response_pkt->l2_sixtop_cellList_delete[i].isUsed){\n@@ -1366,14 +1322,14 @@ void sixtop_six2six_notifyReceive(\n// append 6p Seqnum and schedule Generation\npacketfunctions_reserveHeaderSize(response_pkt,sizeof(uint8_t));\n- scheduleGeneration = schedule_getGeneration();\n- sequenceNumber = neighbors_getSequenceNumber(neighbor);\n+ scheduleGeneration = gen;\n+ sequenceNumber = seqNum;\n*((uint8_t*)(response_pkt->payload)) = sequenceNumber | scheduleGeneration<<IANA_6TOP_GEN_SHIFT;\nresponse_pktLen += 1;\n// append 6p sfid\npacketfunctions_reserveHeaderSize(response_pkt,sizeof(uint8_t));\n- *((uint8_t*)(response_pkt->payload)) = sixtop_vars.registeredSFID;\n+ *((uint8_t*)(response_pkt->payload)) = sixtop_vars.sixtop_sf_getsfid();\nresponse_pktLen += 1;\n// append 6p code\n@@ -1429,17 +1385,19 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n- sixtop_addCellsByState(\n+ sixtop_addCells(\nsixtop_getMetadata(sfId), // frame id\npkt->l2_sixtop_cellList_add, // celllist to be added\n&(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to\nsixtop_vars.cellOptions // cell options\n);\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\ncase SIX_STATE_WAIT_DELETERESPONSE:\n- sixtop_removeCellsByState(\n+ sixtop_removeCells(\nsixtop_getMetadata(sfId),\nsixtop_vars.celllist,\n&(pkt->l2_nextORpreviousHop));\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\nbreak;\ncase SIX_STATE_WAIT_RELOCATERESPONSE:\nmemset(pkt->l2_sixtop_cellList_add,0,sizeof(pkt->l2_sixtop_cellList_add));\n@@ -1453,17 +1411,18 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n- sixtop_removeCellsByState(\n+ sixtop_removeCells(\nsixtop_getMetadata(sfId),\nsixtop_vars.celllist,\n&(pkt->l2_nextORpreviousHop)\n);\n- sixtop_addCellsByState(\n+ sixtop_addCells(\nsixtop_getMetadata(sfId), // frame id\npkt->l2_sixtop_cellList_add, // celllist to be added\n&(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to\nsixtop_vars.cellOptions // cell options\n);\n+ neighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\nbreak;\ncase SIX_STATE_WAIT_COUNTRESPONSE:\nnumCells = *((uint8_t*)(pkt->payload)+ptr);\n@@ -1495,6 +1454,7 @@ void sixtop_six2six_notifyReceive(\nsixtop_getMetadata(sfId),\n&(pkt->l2_nextORpreviousHop)\n);\n+ neighbors_resetGeneration(&(msg->l2_nextORpreviousHop));\nbreak;\ndefault:\n// should neven happen\n@@ -1536,8 +1496,8 @@ uint8_t sixtop_getCelllist(\ncurrentEntry = scheduleWalker;\ndo {\nif(packetfunctions_sameAddress(&(scheduleWalker->neighbor),neighbor)){\n- cellList[i].tsNum = scheduleWalker->slotOffset;\n- cellList[i].choffset = scheduleWalker->channelOffset;\n+ cellList[i].slotoffset = scheduleWalker->slotOffset;\n+ cellList[i].channeloffset = scheduleWalker->channelOffset;\ncellList[i].linkoptions = scheduleWalker->type;\ni++;\n}\n@@ -1565,8 +1525,8 @@ bool sixtop_candidateAddCellList(\nfor(counter=0;counter<CELLLIST_MAX_LEN;counter++){\ni = openrandom_get16b()%schedule_getFrameLength();\nif(schedule_isSlotOffsetAvailable(i)==TRUE){\n- cellList[numCandCells].tsNum = i;\n- cellList[numCandCells].choffset = openrandom_get16b()%16;\n+ cellList[numCandCells].slotoffset = i;\n+ cellList[numCandCells].channeloffset = openrandom_get16b()%16;\ncellList[numCandCells].linkoptions = CELLTYPE_TX;\nnumCandCells++;\n}\n@@ -1595,8 +1555,8 @@ bool sixtop_candidateRemoveCellList(\nfor(i=0;i<schedule_getFrameLength();i++){\nschedule_getSlotInfo(i,neighbor,&info);\nif(info.link_type == CELLTYPE_TX){\n- cellList[numCandCells].tsNum = i;\n- cellList[numCandCells].choffset = info.channelOffset;\n+ cellList[numCandCells].slotoffset = i;\n+ cellList[numCandCells].channeloffset = info.channelOffset;\ncellList[numCandCells].linkoptions = CELLTYPE_TX;\nnumCandCells++;\nif (numCandCells==CELLLIST_MAX_LEN){\n@@ -1612,48 +1572,62 @@ bool sixtop_candidateRemoveCellList(\n}\n}\n-void sixtop_addCellsByState(\n+void sixtop_addCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\n- uint8_t state\n+ uint8_t cellOptions\n){\nuint8_t i;\n+ bool isShared;\nopen_addr_t temp_neighbor;\n- //set schedule according links\n+ // translate cellOptions to cell type\n+ if (cellOptions == LINKOPTIONS_TX){\n+ type = CELLTYPE_TX;\n+ isShared = FALSE;\n+ }\n+ if (cellOptions == LINKOPTIONS_RX){\n+ type = CELLTYPE_RX;\n+ isShared = FALSE;\n+ }\n+ if (cellOptions == LINKOPTIONS_TX | LINKOPTIONS_RX | LINKOPTIONS_SHARED){\n+ type = CELLTYPE_TXRX;\n+ isShared = TRUE;\n+ }\n+ // add cells to schedule\nfor(i = 0;i<CELLLIST_MAX_LEN;i++){\n- if(cellList[i].linkoptions != CELLTYPE_OFF){\n+ if (isShared){\n+ memset(&temp_neighbor,0,sizeof(temp_neighbor));\n+ temp_neighbor.type = ADDR_ANYCAST;\n+ } else {\nmemcpy(&temp_neighbor,previousHop,sizeof(open_addr_t));\n- //add a RX link\n+ }\nschedule_addActiveSlot(\n- cellList[i].tsNum,\n- cellList[i].linkoptions,\n- FALSE,\n- cellList[i].choffset,\n+ cellList[i].slotoffset,\n+ type,\n+ isShared,\n+ cellList[i].channeloffset,\n&temp_neighbor\n);\n}\n}\n-}\n-void sixtop_removeCellsByState(\n+void sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop\n){\nuint8_t i;\n-\n+ // delete cells from schedule\nfor(i=0;i<CELLLIST_MAX_LEN;i++){\n- if(cellList[i].linkoptions != CELLTYPE_OFF){\nschedule_removeActiveSlot(\n- cellList[i].tsNum,\n+ cellList[i].slotoffset,\npreviousHop\n);\n}\n}\n-}\nbool sixtop_areAvailableCellsToBeScheduled(\nuint8_t frameID,\n@@ -1661,37 +1635,38 @@ bool sixtop_areAvailableCellsToBeScheduled(\ncellInfo_ht* cellList\n){\nuint8_t i;\n- uint8_t bw;\n+ uint8_t numbOfavailableCells;\nbool available;\ni = 0;\n- bw = numOfCells;\n+ numbOfavailableCells = 0;\navailable = FALSE;\n- if(bw == 0 || bw>CELLLIST_MAX_LEN){\n+ if(numOfCells == 0 || numOfCells>CELLLIST_MAX_LEN){\n// log wrong parameter error TODO\navailable = FALSE;\n} else {\ndo {\n- if(schedule_isSlotOffsetAvailable(cellList[i].tsNum) == TRUE){\n- bw--;\n+ if(schedule_isSlotOffsetAvailable(cellList[i].slotffset) == TRUE){\n+ numbOfavailableCells++;\n} else {\n- cellList[i].linkoptions = CELLTYPE_OFF;\n+ // mark the cell\n+ cellList[i].isUsed = FALSE;\n}\ni++;\n- }while(i<CELLLIST_MAX_LEN && bw>0);\n+ }while(i<CELLLIST_MAX_LEN && numbOfavailableCells!=numOfCells);\n- if(bw==0){\n- //the rest link will not be scheduled, mark them as off type\n+ if(numbOfavailableCells>0){\n+ // there are more than one cell can be added.\n+ // the rest cells in the list will not be used\nwhile(i<CELLLIST_MAX_LEN){\n- cellList[i].linkoptions = CELLTYPE_OFF;\n+ cellList[i].isUsed = FALSE;\ni++;\n}\n- // local schedule can statisfy the bandwidth of cell request.\navailable = TRUE;\n} else {\n- // local schedule can't statisfy the bandwidth of cell request\n+ // No cell in the list is able to be added\navailable = FALSE;\n}\n}\n@@ -1703,35 +1678,50 @@ bool sixtop_areAvailableCellsToBeRemoved(\nuint8_t frameID,\nuint8_t numOfCells,\ncellInfo_ht* cellList,\n- open_addr_t* neighbor\n+ open_addr_t* neighbor,\n+ uint8_t cellOptions\n){\nuint8_t i;\n- uint8_t bw;\n+ uint8_t numOfavailableCells;\nbool available;\nslotinfo_element_t info;\ni = 0;\n- bw = numOfCells;\n+ numOfavailableCells = 0;\navailable = FALSE;\n- if(bw == 0 || bw>CELLLIST_MAX_LEN){\n+ // translate cellOptions to cell type\n+ if (cellOptions == LINKOPTIONS_TX){\n+ type = CELLTYPE_TX;\n+ }\n+ if (cellOptions == LINKOPTIONS_RX){\n+ type = CELLTYPE_RX;\n+ }\n+ if (cellOptions == LINKOPTIONS_TX | LINKOPTIONS_RX | LINKOPTIONS_SHARED){\n+ type = CELLTYPE_TXRX;\n+ }\n+\n+ if(numOfCells == 0 || numOfCells>CELLLIST_MAX_LEN){\n// log wrong parameter error TODO\navailable = FALSE;\n} else {\ndo {\n- schedule_getSlotInfo(cellList[i].tsNum,neighbor,&info);\n- if(info.link_type == CELLTYPE_RX){\n- bw--;\n+ if (cellList[i].isUsed){\n+ schedule_getSlotInfo(cellList[i].slotoffset,neighbor,&info);\n+ if(info.link_type != type){\n+ available = FALSE;\n+ break;\n} else {\n- cellList[i].linkoptions = CELLTYPE_OFF;\n+ numOfavailableCells++;\n+ }\n}\ni++;\n- }while(i<CELLLIST_MAX_LEN && bw>0);\n+ }while(i<CELLLIST_MAX_LEN && numOfavailableCells<numOfCells);\n- if(bw==0){\n+ if(numOfavailableCells>0){\n//the rest link will not be scheduled, mark them as off type\nwhile(i<CELLLIST_MAX_LEN){\n- cellList[i].linkoptions = CELLTYPE_OFF;\n+ cellList[i].isUsed = FALSE;\ni++;\n}\n// local schedule can statisfy the bandwidth of cell request.\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.h", "new_path": "openstack/02b-MAChigh/sixtop.h", "diff": "@@ -82,9 +82,16 @@ typedef enum {\nSIX_HANDLER_SF0 = 0x02 // the handler is otf\n} six2six_handler_t;\n+typedef enum {\n+ METADATA_TYPE_FRAMEID = 0\n+}metadata_t;\n//=========================== typedef =========================================\n#define SIX2SIX_TIMEOUT_MS 4000\n+typedef uint8_t (*sixtop_sf_getsfid)(void);\n+typedef uint16_t (*sixtop_sf_getmetadata)(void);\n+typedef metadata_t (*sixtop_sf_translatemetadata)(void);\n+typedef void (*sixtop_sf_handle_callback)(uint8_t arg);\n//=========================== module variables ================================\n@@ -103,6 +110,12 @@ typedef struct {\nuint8_t commandID;\nsix2six_handler_t handler;\nbool isResponseEnabled;\n+ uint8_t cellOptions;\n+ cellInfo_ht celllist_toDelete[CELLLIST_MAX_LEN];\n+ sixtop_sf_getsfid cb_sf_getsfid;\n+ sixtop_sf_getmetadata cb_sf_getMetadata;\n+ sixtop_sf_translatemetadata cb_sf_translateMetadata;\n+ sixtop_sf_handle_callback cb_sf_handleRCError;\n} sixtop_vars_t;\n//=========================== prototypes ======================================\n@@ -112,6 +125,12 @@ void sixtop_init(void);\nvoid sixtop_setKaPeriod(uint16_t kaPeriod);\nvoid sixtop_setEBPeriod(uint8_t ebPeriod);\nbool sixtop_setHandler(six2six_handler_t handler);\n+void sixtop_setSFcallback(\n+ sixtop_sf_getsfid cb0,\n+ sixtop_sf_getmetadata cb1,\n+ sixtop_sf_translatemetadata cb2,\n+ sixtop_sf_handle_callback cb3\n+);\n// scheduling\nvoid sixtop_request(\nuint8_t code,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. implement additional functions for sixtop process.
491,595
06.06.2017 19:47:13
-7,200
55d9e06e6351b45a0d7e7562bfac0f617fe108d6
no parameter in opentimers_getValue() function.
[ { "change_type": "MODIFY", "old_path": "openapps/csensors/csensors.c", "new_path": "openapps/csensors/csensors.c", "diff": "@@ -390,7 +390,7 @@ void csensors_setPeriod(uint32_t period,\nopentimers_scheduleAbsolute(\ncsensors_vars.csensors_resource[id].timerId,\n(uint32_t)((period*openrandom_get16b())/0xffff),\n- opentimers_getValue(csensors_vars.csensors_resource[id].timerId),\n+ opentimers_getValue(),\nTIME_MS,\ncsensors_timer_cb\n);\n@@ -400,7 +400,7 @@ void csensors_setPeriod(uint32_t period,\nopentimers_scheduleAbsolute(\ncsensors_vars.csensors_resource[id].timerId,\n(uint32_t)((period*openrandom_get16b())/0xffff),\n- opentimers_getValue(csensors_vars.csensors_resource[id].timerId),\n+ opentimers_getValue(),\nTIME_MS,\ncsensors_timer_cb\n);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-635. no parameter in opentimers_getValue() function.
491,595
07.06.2017 18:43:25
-7,200
e6a35fc27a57ba81e18c6c9b3730c3ea724552e7
update serial 6p commands.
[ { "change_type": "MODIFY", "old_path": "drivers/common/openserial.c", "new_path": "drivers/common/openserial.c", "diff": "@@ -41,6 +41,7 @@ owerror_t openserial_printInfoErrorCritical(\n// command handlers\nvoid openserial_handleEcho(uint8_t* but, uint8_t bufLen);\n+void openserial_get6pInfo(uint8_t commandId, uint8_t* code,uint8_t* slotframeId,uint8_t* cellOptions,uint8_t* numCells,cellInfo_ht* celllist_add,cellInfo_ht* celllist_delete,uint8_t* listOffset,uint8_t* maxListLen,uint8_t ptr, uint8_t commandLen);\nvoid openserial_handleCommands(void);\n// misc\n@@ -529,7 +530,6 @@ owerror_t openserial_printInfoErrorCritical(\n//===== command handlers\nvoid openserial_handleEcho(uint8_t* buf, uint8_t bufLen){\n-\n// echo back what you received\nopenserial_printData(\nbuf,\n@@ -537,6 +537,112 @@ void openserial_handleEcho(uint8_t* buf, uint8_t bufLen){\n);\n}\n+void openserial_get6pInfo(uint8_t commandId, uint8_t* code,uint8_t* slotframeId,uint8_t* cellOptions,uint8_t* numCells,cellInfo_ht* celllist_add,cellInfo_ht* celllist_delete,uint8_t* listOffset,uint8_t* maxListLen,uint8_t ptr, uint8_t commandLen){\n+ uint8_t i;\n+ // get metadata, metadata indicates frame id\n+ *slotframeId = openserial_vars.inputBuf[ptr];\n+ *slotframeId |= openserial_vars.inputBuf[ptr+1]<<8;\n+ ptr += 2;\n+ commandLen -= 2;\n+\n+ // clear command\n+ if (commandId == COMMAND_SET_6P_CLEAR){\n+ *code = IANA_6TOP_CMD_CLEAR;\n+ return;\n+ }\n+\n+ *cellOptions = openserial_vars.inputBuf[ptr];\n+ ptr += 1;\n+ commandLen -= 1;\n+\n+ // list command\n+ if (commandId == COMMAND_SET_6P_LIST){\n+ *code = IANA_6TOP_CMD_LIST;\n+ *listOffset = openserial_vars.inputBuf[ptr];\n+ *listOffset |= openserial_vars.inputBuf[ptr+1]<<8;\n+ ptr += 2;\n+ *maxListLen = openserial_vars.inputBuf[ptr];\n+ *maxListLen |= openserial_vars.inputBuf[ptr+1]<<8;\n+ ptr += 2;\n+ return;\n+ }\n+\n+ // count command\n+ if (commandId == COMMAND_SET_6P_COUNT){\n+ *code = IANA_6TOP_CMD_COUNT;\n+ return;\n+ }\n+\n+ *numCells = openserial_vars.inputBuf[ptr];\n+ ptr += 1;\n+ commandLen -= 1;\n+\n+ // add command\n+ if (commandId == COMMAND_SET_6P_ADD){\n+ *code = IANA_6TOP_CMD_ADD;\n+ // retrieve cell list\n+ i = 0;\n+ while(commandLen>0){\n+ celllist_add[i].slotoffset = openserial_vars.inputBuf[ptr];\n+ celllist_add[i].slotoffset |= openserial_vars.inputBuf[ptr+1]<<8;\n+ celllist_add[i].channeloffset = openserial_vars.inputBuf[ptr+2];\n+ celllist_add[i].channeloffset |= openserial_vars.inputBuf[ptr+3]<<8;\n+ celllist_add[i].isUsed = TRUE;\n+ ptr += 4;\n+ commandLen -= 4;\n+ i++;\n+ }\n+ return;\n+ }\n+\n+ // delete command\n+ if (commandId == COMMAND_SET_6P_DELETE){\n+ *code = IANA_6TOP_CMD_DELETE;\n+ i = 0;\n+ while(commandLen>0){\n+ celllist_delete[i].slotoffset = openserial_vars.inputBuf[ptr];\n+ celllist_delete[i].slotoffset |= openserial_vars.inputBuf[ptr+1]<<8;\n+ celllist_delete[i].channeloffset = openserial_vars.inputBuf[ptr+2];\n+ celllist_delete[i].channeloffset |= openserial_vars.inputBuf[ptr+3]<<8;\n+ celllist_delete[i].isUsed = TRUE;\n+ ptr += 4;\n+ commandLen -= 4;\n+ i++;\n+ }\n+ return;\n+ }\n+\n+ // relocate command\n+ if (commandId == COMMAND_SET_6P_RELOCATE){\n+ *code = IANA_6TOP_CMD_RELOCATE;\n+ // retrieve cell list to be relocated\n+ i = 0;\n+ while(commandLen>0){\n+ celllist_delete[i].slotoffset = openserial_vars.inputBuf[ptr];\n+ celllist_delete[i].slotoffset |= openserial_vars.inputBuf[ptr+1]<<8;\n+ celllist_delete[i].channeloffset = openserial_vars.inputBuf[ptr+2];\n+ celllist_delete[i].channeloffset |= openserial_vars.inputBuf[ptr+3]<<8;\n+ celllist_delete[i].isUsed = TRUE;\n+ ptr += 4;\n+ commandLen -= 4;\n+ i++;\n+ }\n+ // retrieve cell list to be relocated\n+ i = 0;\n+ while(commandLen>0){\n+ celllist_add[i].slotoffset = openserial_vars.inputBuf[ptr];\n+ celllist_add[i].slotoffset |= openserial_vars.inputBuf[ptr+1]<<8;\n+ celllist_add[i].channeloffset = openserial_vars.inputBuf[ptr+2];\n+ celllist_add[i].channeloffset |= openserial_vars.inputBuf[ptr+3]<<8;\n+ celllist_add[i].isUsed = TRUE;\n+ ptr += 4;\n+ commandLen -= 4;\n+ i++;\n+ }\n+ return;\n+ }\n+}\n+\nvoid openserial_handleCommands(void){\nuint8_t input_buffer[10];\nuint8_t numDataBytes;\n@@ -544,81 +650,70 @@ void openserial_handleCommands(void){\nuint8_t commandLen;\nuint8_t comandParam_8;\nuint16_t comandParam_16;\n- cellInfo_ht cellList[CELLLIST_MAX_LEN];\n- uint8_t i;\n+\n+ uint8_t code,slotframeId,cellOptions,numCell,listOffset,maxListLen;\n+ uint8_t ptr;\n+ cellInfo_ht celllist_add[CELLLIST_MAX_LEN];\n+ cellInfo_ht celllist_delete[CELLLIST_MAX_LEN];\nopen_addr_t neighbor;\nbool foundNeighbor;\n- memset(cellList,0,sizeof(cellList));\n+ ptr = 0;\n+ memset(celllist_add,0,sizeof(celllist_add));\n+ memset(celllist_delete,0,sizeof(celllist_delete));\nnumDataBytes = openserial_getInputBufferFilllevel();\n//copying the buffer\n- openserial_getInputBuffer(&(input_buffer[0]),numDataBytes);\n- commandId = openserial_vars.inputBuf[1];\n- commandLen = openserial_vars.inputBuf[2];\n-\n- if (commandLen>3) {\n- // the max command Len is 2, except ping commands\n- return;\n- } else {\n- if (commandLen == 1) {\n- comandParam_8 = openserial_vars.inputBuf[3];\n- } else {\n- // commandLen == 2\n- comandParam_16 = (openserial_vars.inputBuf[3] & 0x00ff) | \\\n- ((openserial_vars.inputBuf[4]<<8) & 0xff00);\n- }\n- }\n+ openserial_getInputBuffer(&(input_buffer[ptr]),numDataBytes);\n+ ptr++;\n+ commandId = openserial_vars.inputBuf[ptr];\n+ ptr++;\n+ commandLen = openserial_vars.inputBuf[ptr];\n+ ptr++;\nswitch(commandId) {\ncase COMMAND_SET_EBPERIOD:\n+ comandParam_8 = openserial_vars.inputBuf[ptr];\nsixtop_setEBPeriod(comandParam_8); // one byte, in seconds\nbreak;\ncase COMMAND_SET_CHANNEL:\n+ comandParam_8 = openserial_vars.inputBuf[ptr];\n// set communication channel for protocol stack\nieee154e_setSingleChannel(comandParam_8); // one byte\n// set listenning channel for sniffer\nsniffer_setListeningChannel(comandParam_8); // one byte\nbreak;\ncase COMMAND_SET_KAPERIOD: // two bytes, in slots\n+ comandParam_16 = (openserial_vars.inputBuf[ptr] & 0x00ff) | \\\n+ ((openserial_vars.inputBuf[ptr+1]<<8) & 0xff00);\nsixtop_setKaPeriod(comandParam_16);\nbreak;\ncase COMMAND_SET_DIOPERIOD: // two bytes, in mili-seconds\n+ comandParam_16 = (openserial_vars.inputBuf[ptr] & 0x00ff) | \\\n+ ((openserial_vars.inputBuf[ptr+1]<<8) & 0xff00);\nicmpv6rpl_setDIOPeriod(comandParam_16);\nbreak;\ncase COMMAND_SET_DAOPERIOD: // two bytes, in mili-seconds\n+ comandParam_16 = (openserial_vars.inputBuf[ptr] & 0x00ff) | \\\n+ ((openserial_vars.inputBuf[ptr+1]<<8) & 0xff00);\nicmpv6rpl_setDAOPeriod(comandParam_16);\nbreak;\ncase COMMAND_SET_DAGRANK: // two bytes\n+ comandParam_16 = (openserial_vars.inputBuf[ptr] & 0x00ff) | \\\n+ ((openserial_vars.inputBuf[ptr+1]<<8) & 0xff00);\nicmpv6rpl_setMyDAGrank(comandParam_16);\nbreak;\ncase COMMAND_SET_SECURITY_STATUS: // one byte\n- if (comandParam_8 ==1) {\n- ieee154e_setIsSecurityEnabled(TRUE);\n- } else {\n- if (comandParam_8 == 0) {\n- ieee154e_setIsSecurityEnabled(FALSE);\n- } else {\n- // security only can be 1 or 0\n- break;\n- }\n- }\n+ ieee154e_setIsSecurityEnabled(comandParam_8);\nbreak;\ncase COMMAND_SET_SLOTFRAMELENGTH: // two bytes\n+ comandParam_16 = (openserial_vars.inputBuf[ptr] & 0x00ff) | \\\n+ ((openserial_vars.inputBuf[ptr+1]<<8) & 0xff00);\nschedule_setFrameLength(comandParam_16);\nbreak;\ncase COMMAND_SET_ACK_STATUS:\n- if (comandParam_8 == 1) {\n- ieee154e_setIsAckEnabled(TRUE);\n- } else {\n- if (comandParam_8 == 0) {\n- ieee154e_setIsAckEnabled(FALSE);\n- } else {\n- // ack reply\n- break;\n- }\n- }\n+ ieee154e_setIsAckEnabled(comandParam_8);\nbreak;\ncase COMMAND_SET_6P_ADD:\ncase COMMAND_SET_6P_DELETE:\n@@ -630,34 +725,23 @@ void openserial_handleCommands(void){\nif (foundNeighbor==FALSE) {\nbreak;\n}\n-\nif (sixtop_setHandler(SIX_HANDLER_SF0)==FALSE){\n// one sixtop transcation is happening, only one instance at one time\nreturn;\n}\n- if (\n- (\n- commandId != COMMAND_SET_6P_ADD &&\n- commandId != COMMAND_SET_6P_DELETE\n- ) ||\n- (\n- (\n- commandId == COMMAND_SET_6P_ADD ||\n- commandId == COMMAND_SET_6P_DELETE\n- ) &&\n- commandLen == 0\n- )\n- ){\n- // randomly select cell\n-// sixtop_request(commandId-8,&neighbor,1);\n- } else {\n-// for (i=0;i<commandLen;i++){\n-// cellList[i].tsNum = openserial_vars.inputBuf[3+i];\n-// cellList[i].choffset = DEFAULT_CHANNEL_OFFSET;\n-// cellList[i].linkoptions = CELLTYPE_TX;\n-// }\n-// sixtop_addORremoveCellByInfo(commandId-8,&neighbor,cellList);\n- }\n+ // the following sequence of bytes are, slotframe, cellOption, numCell, celllist\n+ openserial_get6pInfo(commandId,&code,&slotframeId,&cellOptions,&numCell,celllist_add,celllist_delete,&listOffset,&maxListLen,ptr,commandLen);\n+ sixtop_request(\n+ code, // code\n+ &neighbor, // neighbor\n+ numCell, // number cells\n+ cellOptions, // cellOptions\n+ celllist_add, // celllist to add\n+ celllist_delete, // celllist to delete (not used)\n+ sf0_getsfid(), // sfid\n+ listOffset, // list command offset (not used)\n+ maxListLen // list command maximum celllist (not used)\n+ );\nbreak;\ncase COMMAND_SET_SLOTDURATION:\nieee154e_setSlotDuration(comandParam_16);\n" }, { "change_type": "MODIFY", "old_path": "drivers/common/openserial.h", "new_path": "drivers/common/openserial.h", "diff": "@@ -73,14 +73,15 @@ enum {\nCOMMAND_SET_ACK_STATUS = 8,\nCOMMAND_SET_6P_ADD = 9,\nCOMMAND_SET_6P_DELETE = 10,\n- COMMAND_SET_6P_COUNT = 11,\n- COMMAND_SET_6P_LIST = 12,\n- COMMAND_SET_6P_CLEAR = 13,\n- COMMAND_SET_SLOTDURATION = 14,\n- COMMAND_SET_6PRESPONSE = 15,\n- COMMAND_SET_UINJECTPERIOD = 16,\n- COMMAND_SET_ECHO_REPLY_STATUS = 17,\n- COMMAND_MAX = 18,\n+ COMMAND_SET_6P_RELOCATE = 11,\n+ COMMAND_SET_6P_COUNT = 12,\n+ COMMAND_SET_6P_LIST = 13,\n+ COMMAND_SET_6P_CLEAR = 14,\n+ COMMAND_SET_SLOTDURATION = 15,\n+ COMMAND_SET_6PRESPONSE = 16,\n+ COMMAND_SET_UINJECTPERIOD = 17,\n+ COMMAND_SET_ECHO_REPLY_STATUS = 18,\n+ COMMAND_MAX = 19,\n};\n//=========================== variables =======================================\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/schedule.c", "new_path": "openstack/02b-MAChigh/schedule.c", "diff": "@@ -578,11 +578,6 @@ void schedule_advanceSlot() {\nINTERRUPT_DECLARATION();\nDISABLE_INTERRUPTS();\n- if (schedule_vars.currentScheduleEntry->slotOffset >= ((scheduleEntry_t*)schedule_vars.currentScheduleEntry->next)->slotOffset\n- ) {\n- // one slotframe has elapsed\n- sf0_notifyNewSlotframe();\n- }\nschedule_vars.currentScheduleEntry = schedule_vars.currentScheduleEntry->next;\nENABLE_INTERRUPTS();\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. update serial 6p commands.
491,595
08.06.2017 17:04:11
-7,200
ca7a08dcda7dd406d9282cb6a8c615baa29d1fee
support adding/deleting shared cell.
[ { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -83,7 +83,8 @@ void sixtop_addCells(\nvoid sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\n- open_addr_t* previousHop\n+ open_addr_t* previousHop,\n+ uint8_t cellOptions\n);\nbool sixtop_areAvailableCellsToBeScheduled(\nuint8_t frameID,\n@@ -899,7 +900,8 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\nsixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_delete,\n- &(msg->l2_nextORpreviousHop)\n+ &(msg->l2_nextORpreviousHop),\n+ msg->l2_sixtop_cellOptions\n);\nneighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\n@@ -908,7 +910,8 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\nsixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_delete,\n- &(msg->l2_nextORpreviousHop)\n+ &(msg->l2_nextORpreviousHop),\n+ msg->l2_sixtop_cellOptions\n);\nsixtop_addCells(\nmsg->l2_sixtop_frameID,\n@@ -1413,7 +1416,8 @@ void sixtop_six2six_notifyReceive(\nsixtop_removeCells(\nsixtop_vars.cb_sf_getMetadata(),\nsixtop_vars.celllist_toDelete,\n- &(pkt->l2_nextORpreviousHop));\n+ &(pkt->l2_nextORpreviousHop),\n+ sixtop_vars.cellOptions);\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\nbreak;\ncase SIX_STATE_WAIT_RELOCATERESPONSE:\n@@ -1431,7 +1435,8 @@ void sixtop_six2six_notifyReceive(\nsixtop_removeCells(\nsixtop_vars.cb_sf_getMetadata(),\nsixtop_vars.celllist_toDelete,\n- &(pkt->l2_nextORpreviousHop)\n+ &(pkt->l2_nextORpreviousHop),\n+ sixtop_vars.cellOptions\n);\nsixtop_addCells(\nsixtop_vars.cb_sf_getMetadata(), // frame id\n@@ -1540,15 +1545,35 @@ void sixtop_addCells(\nvoid sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\n- open_addr_t* previousHop\n+ open_addr_t* previousHop,\n+ uint8_t cellOptions\n){\nuint8_t i;\n+ bool isShared;\n+ open_addr_t temp_neighbor;\n+ // translate cellOptions to cell type\n+ if (cellOptions == LINKOPTIONS_TX){\n+ isShared = FALSE;\n+ }\n+ if (cellOptions == LINKOPTIONS_RX){\n+ isShared = FALSE;\n+ }\n+ if (cellOptions == (LINKOPTIONS_TX | LINKOPTIONS_RX | LINKOPTIONS_SHARED)){\n+ isShared = TRUE;\n+ }\n+\n+ if (isShared){\n+ memset(&temp_neighbor,0,sizeof(temp_neighbor));\n+ temp_neighbor.type = ADDR_ANYCAST;\n+ } else {\n+ memcpy(&temp_neighbor,previousHop,sizeof(open_addr_t));\n+ }\n// delete cells from schedule\nfor(i=0;i<CELLLIST_MAX_LEN;i++){\nif (cellList[i].isUsed){\nschedule_removeActiveSlot(\ncellList[i].slotoffset,\n- previousHop\n+ &temp_neighbor\n);\n}\n}\n@@ -1611,6 +1636,7 @@ bool sixtop_areAvailableCellsToBeRemoved(\nbool available;\nslotinfo_element_t info;\ncellType_t type;\n+ open_addr_t anycastAddr;\ni = 0;\nnumOfavailableCells = 0;\n@@ -1625,6 +1651,8 @@ bool sixtop_areAvailableCellsToBeRemoved(\n}\nif (cellOptions == (LINKOPTIONS_TX | LINKOPTIONS_RX | LINKOPTIONS_SHARED)){\ntype = CELLTYPE_TXRX;\n+ memset(&anycastAddr,0,sizeof(open_addr_t));\n+ anycastAddr.type = ADDR_ANYCAST;\n}\nif(numOfCells == 0 || numOfCells>CELLLIST_MAX_LEN){\n@@ -1633,7 +1661,11 @@ bool sixtop_areAvailableCellsToBeRemoved(\n} else {\ndo {\nif (cellList[i].isUsed){\n+ if (type==CELLTYPE_TXRX){\n+ schedule_getSlotInfo(cellList[i].slotoffset,&anycastAddr,&info);\n+ } else {\nschedule_getSlotInfo(cellList[i].slotoffset,neighbor,&info);\n+ }\nif(info.link_type != type){\navailable = FALSE;\nbreak;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. support adding/deleting shared cell.
491,595
10.06.2017 08:30:21
-7,200
f0bb3a091a5b7639094cfbb134129f2d8386257c
update simulation port.
[ { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/processIE.h", "new_path": "openstack/02b-MAChigh/processIE.h", "diff": "@@ -76,105 +76,5 @@ typedef struct {\nuint8_t join_priority;\n} sync_IE_ht;\n-/**\n-\\brief TSCH Slotframe and Link IE\n-\n-http://tools.ietf.org/html/draft-wang-6tisch-6top-sublayer-01#section-4.1.1.2\n-*/\n-typedef struct {\n- uint8_t slotframehandle;\n- uint16_t slotframesize;\n- uint8_t numlinks;\n-} slotframeLink_IE_ht;\n-\n-/**\n-\\brief 6top Opcode IE\n-\n-http://tools.ietf.org/html/draft-wang-6tisch-6top-sublayer-01#section-4.1.1.5\n-*/\n-typedef struct {\n- uint8_t opcode;\n-} opcode_IE_ht;\n-\n-/**\n-\\brief 6top Bandwidth IE\n-\n-http://tools.ietf.org/html/draft-wang-6tisch-6top-sublayer-01#section-4.1.1.6\n-*/\n-typedef struct{\n- uint8_t slotframeID;\n- uint8_t numOfLinks;\n-} bandwidth_IE_ht;\n-\n-/**\n-\\brief 6top Generic Schedule IE\n-\n-http://tools.ietf.org/html/draft-wang-6tisch-6top-sublayer-01#section-4.1.1.8\n-*/\n-typedef struct{\n- uint8_t type;\n- uint8_t length;\n- uint8_t frameID;\n- uint8_t numberOfcells;\n- bool flag;\n- cellInfo_ht cellList[CELLLIST_MAX_LEN];\n-} schedule_IE_ht;\n-\nEND_PACK\n-\n-//=========================== variables =======================================\n-\n-//=========================== prototypes ======================================\n-\n-void processIE_prependMLMEIE(\n- OpenQueueEntry_t* pkt,\n- uint8_t len\n-);\n-void processIE_prepend_sixtopIE(\n- OpenQueueEntry_t* pkt,\n- uint8_t len\n-);\n-//===== prepend IEs\n-\n-uint8_t processIE_prependSyncIE(\n- OpenQueueEntry_t* pkt\n-);\n-uint8_t processIE_prependSlotframeLinkIE(\n- OpenQueueEntry_t* pkt\n-);\n-uint8_t processIE_prependTSCHTimeslotIE(\n- OpenQueueEntry_t* pkt\n-);\n-uint8_t processIE_prependChannelHoppingIE(\n- OpenQueueEntry_t* pkt\n-);\n-uint8_t processIE_prepend_sixSubIEHeader(\n- OpenQueueEntry_t* pkt,\n- uint8_t len\n-);\n-uint8_t processIE_prepend_sixGeneralMessage(\n- OpenQueueEntry_t* pkt,\n- uint8_t code\n-);\n-uint8_t processIE_prepend_sixSubID(\n- OpenQueueEntry_t* pkt\n-);\n-uint8_t processIE_prepend_sixCelllist(\n- OpenQueueEntry_t* pkt,\n- cellInfo_ht* cellList\n-);\n-\n-//===== retrieve IEs\n-\n-void processIE_retrieveSlotframeLinkIE(\n- OpenQueueEntry_t* pkt,\n- uint8_t * ptr\n-);\n-void processIE_retrieve_sixCelllist(\n- OpenQueueEntry_t* pkt,\n- uint8_t ptr,\n- uint8_t length,\n- cellInfo_ht* cellList\n-);\n-\n#endif\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -1238,6 +1238,7 @@ void sixtop_six2six_notifyReceive(\n// delete command\nif (code == IANA_6TOP_CMD_DELETE){\n+ i = 0;\nmemset(response_pkt->l2_sixtop_celllist_delete,0,sizeof(response_pkt->l2_sixtop_celllist_delete));\nwhile(pktLen>0){\nresponse_pkt->l2_sixtop_celllist_delete[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr);\n@@ -1393,6 +1394,7 @@ void sixtop_six2six_notifyReceive(\nif (code == IANA_6TOP_RC_SUCCESS || code == IANA_6TOP_RC_EOL){\nswitch(sixtop_vars.six2six_state){\ncase SIX_STATE_WAIT_ADDRESPONSE:\n+ i = 0;\nmemset(pkt->l2_sixtop_celllist_add,0,sizeof(pkt->l2_sixtop_celllist_add));\nwhile(pktLen>0){\npkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr);\n@@ -1421,6 +1423,7 @@ void sixtop_six2six_notifyReceive(\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\nbreak;\ncase SIX_STATE_WAIT_RELOCATERESPONSE:\n+ i = 0;\nmemset(pkt->l2_sixtop_celllist_add,0,sizeof(pkt->l2_sixtop_celllist_add));\nwhile(pktLen>0){\npkt->l2_sixtop_celllist_add[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr);\n@@ -1455,6 +1458,7 @@ void sixtop_six2six_notifyReceive(\n(errorparameter_t)sixtop_vars.six2six_state);\nbreak;\ncase SIX_STATE_WAIT_LISTRESPONSE:\n+ i = 0;\nmemset(celllist_list,0,CELLLIST_MAX_LEN*sizeof(cellInfo_ht));\nwhile(pktLen>0){\ncelllist_list[i].slotoffset = *((uint8_t*)(pkt->payload)+ptr);\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.h", "new_path": "openstack/02b-MAChigh/sixtop.h", "diff": "@@ -144,7 +144,6 @@ void sixtop_request(\nuint16_t listingOffset,\nuint16_t listingMaxNumCells\n);\n-void sixtop_addORremoveCellByInfo(uint8_t command,open_addr_t* neighbor,cellInfo_ht* cellInfo);\n// from upper layer\nowerror_t sixtop_send(OpenQueueEntry_t *msg);\n// from lower layer\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -403,6 +403,7 @@ functionsToChange = [\n'openserial_handleCommands',\n'debugPrint_outBufferIndexes',\n'openserial_handleEcho',\n+ 'openserial_get6pInfo',\n'outputHdlcOpen',\n'outputHdlcWrite',\n'outputHdlcClose',\n@@ -525,6 +526,8 @@ functionsToChange = [\n'neighbors_getNumNeighbors',\n'neighbors_getLinkMetric',\n'neighbors_getKANeighbor',\n+ 'neighbors_getGeneration',\n+ 'neighbors_getSequenceNumber',\n'neighbors_setNeighborRank',\n'neighbors_setPreferredParent',\n'neighbors_isStableNeighbor',\n@@ -533,6 +536,9 @@ functionsToChange = [\n'neighbors_isNeighborWithHigherDAGrank',\n'neighbors_indicateRx',\n'neighbors_indicateTx',\n+ 'neighbors_updateSequenceNumber',\n+ 'neighbors_updateGeneration',\n+ 'neighbors_resetGeneration',\n'neighbors_indicateRxDIO',\n'neighbors_getNeighborEui64',\n'neighbors_removeOld',\n@@ -543,20 +549,6 @@ functionsToChange = [\n'isNeighbor',\n'removeNeighbor',\n'isThisRowMatching',\n- # processIE\n- 'processIE_prependMLMEIE',\n- 'processIE_prepend_sixtopIE',\n- 'processIE_prependSyncIE',\n- 'processIE_prependSlotframeLinkIE',\n- 'processIE_prependTSCHTimeslotIE',\n- 'processIE_prependChannelHoppingIE',\n- 'processIE_prepend_sixSubIEHeader',\n- 'processIE_prepend_sixGeneralMessage',\n- 'processIE_prepend_sixSubID',\n- 'processIE_prepend_sixCelllist',\n- 'processIE_prepend_sixResponse',\n- 'processIE_retrieveSlotframeLinkIE',\n- 'processIE_retrieve_sixCelllist',\n# schedule\n'schedule_init',\n'schedule_startDAGroot',\n@@ -590,23 +582,26 @@ functionsToChange = [\n'schedule_getNumOfSlotsByType',\n'schedule_getNumberOfFreeEntries',\n'schedule_housekeeping',\n+ 'schedule_getOneCellAfterOffset',\n# sf0\n'sf0_init',\n- 'sf0_notif_addedCell',\n- 'sf0_notif_removedCell',\n- 'sf0_addCell_task',\n- 'sf0_removeCell_task',\n'sf0_bandwidthEstimate_task',\n'sf0_notifyNewSlotframe',\n+ 'sf0_appPktPeriod',\n'sf0_setBackoff',\n- 'sf0_setSelfBandwidth',\n+ 'sf0_getsfid',\n+ 'sf0_candidateAddCellList',\n+ 'sf0_candidateRemoveCellList',\n+ 'sf0_getMetadata',\n+ 'sf0_translateMetadata',\n+ 'sf0_handleRCError',\n# sixtop\n'sixtop_init',\n'sixtop_setKaPeriod',\n'sixtop_setEBPeriod',\n'sixtop_setHandler',\n+ 'sixtop_setSFcallback',\n'sixtop_request',\n- 'sixtop_addORremoveCellByInfo',\n'sixtop_send',\n'task_sixtopNotifSendDone',\n'task_sixtopNotifReceive',\n@@ -624,12 +619,10 @@ functionsToChange = [\n'timer_sixtop_six2six_timeout_fired',\n'sixtop_six2six_sendDone',\n'sixtop_processIEs',\n- 'sixtop_notifyReceiveCommand',\n+ 'sixtop_six2six_notifyReceive',\n'sixtop_getCelllist',\n- 'sixtop_candidateAddCellList',\n- 'sixtop_candidateRemoveCellList',\n- 'sixtop_addCellsByState',\n- 'sixtop_removeCellsByState',\n+ 'sixtop_addCells',\n+ 'sixtop_removeCells',\n'sixtop_areAvailableCellsToBeScheduled',\n'sixtop_areAvailableCellsToBeRemoved',\n# iphc\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. update simulation port.
491,595
10.06.2017 08:35:08
-7,200
dd8d6ec5b1b33ecb8c8fbf29704910530941f4e5
fix sniffer project.
[ { "change_type": "MODIFY", "old_path": "projects/common/03oos_sniffer/03oos_sniffer.c", "new_path": "projects/common/03oos_sniffer/03oos_sniffer.c", "diff": "@@ -176,12 +176,22 @@ void schedule_startDAGroot(void) {return;}\nvoid schedule_setFrameLength(uint16_t frameLength) {return;}\nvoid sixtop_setEBPeriod(uint8_t ebPeriod) {return;}\n-void sixtop_addORremoveCellByInfo(uint8_t code,open_addr_t* neighbor,cellInfo_ht* cellInfo){return;}\n-void sixtop_request(uint8_t code,open_addr_t* neighbor, uint8_t numCells) {return;}\n+void sixtop_request(\n+ uint8_t code,\n+ open_addr_t* neighbor,\n+ uint8_t numCells,\n+ uint8_t cellOptions,\n+ cellInfo_ht* celllist_toBeAdded,\n+ cellInfo_ht* celllist_toBeRemoved,\n+ uint8_t sfid,\n+ uint16_t listingOffset,\n+ uint16_t listingMaxNumCells\n+) {return;}\nbool sixtop_setHandler(six2six_handler_t handler) {return TRUE;}\nvoid sixtop_setIsResponseEnabled(bool isEnabled) {return;}\nvoid sixtop_setKaPeriod(uint16_t kaPeriod) {return;}\nvoid sf0_appPktPeriod(uint8_t numAppPacketsPerSlotFrame) {return;}\n+uint8_t sf0_getsfid(void) {return 0;}\nvoid openbridge_triggerData(void) {return;}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. fix sniffer project.
491,595
11.06.2017 08:40:12
-7,200
75383adec2b79a219e2e2df57cf038cef4acb19c
formatting sixtop.c
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "@@ -24,14 +24,15 @@ static const uint8_t chTemplate_default[] = {\n// refer to RFC8180: https://tools.ietf.org/html/rfc8180#appendix-A.1\n// ASN and join Metric are replaced later when sending an EB\nstatic const uint8_t ebIEsBytestream[] = {\n- 0x00,0x3F,0x1A,0x88,0x06,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1C,0x00,\n+ 0x1A,0x88,0x06,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1C,0x00,\n0x01,0xC8,0x00,0x0A,0x1B,0x01,0x00,SLOTFRAME_LENGTH,0x00,0x01,0x00,0x00,0x00,0x00,0x0F\n};\n-#define EB_ASN0_OFFSET 6\n-#define EB_JP_OFFSET 11\n-\n//=========================== define ==========================================\n+#define EB_ASN0_OFFSET 4\n+#define EB_JP_OFFSET 9\n+#define EB_IE_LEN 28\n+\n#define SYNCHRONIZING_CHANNEL 20 // channel the mote listens on to synchronize\n#define TXRETRIES 3 // number of MAC retries before declaring failed\n#define TX_POWER 31 // 1=-25dBm, 31=0dBm (max value)\n@@ -44,9 +45,6 @@ static const uint8_t ebIEsBytestream[] = {\n#define LENGTH_IEEE154_MAX 128 // max length of a valid radio packet\n#define DUTY_CYCLE_WINDOW_LIMIT (0xFFFFFFFF>>1) // limit of the dutycycle window\n-// asdf\n-#define EB_IE_LEN 30\n-\n//15.4e information elements related\n#define IEEE802154E_PAYLOAD_DESC_LEN_SHIFT 0x04\n#define IEEE802154E_PAYLOAD_DESC_GROUP_ID_MLME (1<<11)\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -428,14 +428,12 @@ void task_sixtopNotifSendDone() {\n// send the packet to where it belongs\nswitch (msg->creator) {\n-\ncase COMPONENT_SIXTOP:\nif (msg->l2_frameType==IEEE154_TYPE_BEACON) {\n// this is a EB\n// not busy sending EB anymore\nsixtop_vars.busySendingEB = FALSE;\n-\n} else {\n// this is a KA\n@@ -444,13 +442,10 @@ void task_sixtopNotifSendDone() {\n}\n// discard packets\nopenqueue_freePacketBuffer(msg);\n-\nbreak;\n-\ncase COMPONENT_SIXTOP_RES:\nsixtop_six2six_sendDone(msg,msg->l2_sendDoneError);\nbreak;\n-\ndefault:\n// send the rest up the stack\niphc_sendDone(msg,msg->l2_sendDoneError);\n@@ -546,7 +541,6 @@ bool debugPrint_myDAGrank() {\nuint16_t output;\noutput = 0;\n-\noutput = icmpv6rpl_getMyDAGrank();\nopenserial_printStatus(STATUS_DAGRANK,(uint8_t*)&output,sizeof(uint16_t));\nreturn TRUE;\n@@ -564,7 +558,6 @@ bool debugPrint_kaPeriod() {\nuint16_t output;\noutput = sixtop_vars.kaPeriod;\n-\nopenserial_printStatus(\nSTATUS_KAPERIOD,\n(uint8_t*)&output,\n@@ -612,7 +605,8 @@ owerror_t sixtop_send_internal(\n// transmit with the default TX power\nmsg->l1_txPower = TX_POWER;\n// add a IEEE802.15.4 header\n- ieee802154_prependHeader(msg,\n+ ieee802154_prependHeader(\n+ msg,\nmsg->l2_frameType,\npayloadIEPresent,\nmsg->l2_dsn,\n@@ -723,9 +717,12 @@ port_INLINE void sixtop_sendEB() {\n// get a free packet buffer\neb = openqueue_getFreePacketBuffer(COMPONENT_SIXTOP);\nif (eb==NULL) {\n- openserial_printError(COMPONENT_SIXTOP,ERR_NO_FREE_PACKET_BUFFER,\n+ openserial_printError(\n+ COMPONENT_SIXTOP,\n+ ERR_NO_FREE_PACKET_BUFFER,\n(errorparameter_t)0,\n- (errorparameter_t)0);\n+ (errorparameter_t)0\n+ );\nreturn;\n}\n@@ -805,9 +802,12 @@ port_INLINE void sixtop_sendKA() {\n// get a free packet buffer\nkaPkt = openqueue_getFreePacketBuffer(COMPONENT_SIXTOP);\nif (kaPkt==NULL) {\n- openserial_printError(COMPONENT_SIXTOP,ERR_NO_FREE_PACKET_BUFFER,\n+ openserial_printError(\n+ COMPONENT_SIXTOP,\n+ ERR_NO_FREE_PACKET_BUFFER,\n(errorparameter_t)1,\n- (errorparameter_t)0);\n+ (errorparameter_t)0\n+ );\nreturn;\n}\n@@ -881,12 +881,13 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\nbreak;\n}\n// start timeout timer if I am waiting for a response\n- opentimers_setPeriod(\n+ opentimers_scheduleAbsolute(\nsixtop_vars.timeoutTimerId,\n+ SIX2SIX_TIMEOUT_MS,\n+ opentimers_getValue(),\nTIME_MS,\n- SIX2SIX_TIMEOUT_MS\n+ timer_sixtop_six2six_timeout_fired\n);\n- opentimers_restart(sixtop_vars.timeoutTimerId);\n}\n}\n@@ -939,17 +940,12 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\nneighbors_resetGeneration(&(msg->l2_nextORpreviousHop));\n}\n} else {\n- // the return code is not SUCCESS, nothing require to do on response side\n+ // the return code doesn't end up with SUCCESS\n+ // The return code will be processed on request side.\n}\n} else {\n-\n- if (msg->l2_sixtop_returnCode==IANA_6TOP_RC_NORES){\n- // mark this neighbor as no resource for future processing\n- neighbors_setNeighborNoResource(&(msg->l2_nextORpreviousHop));\n- } else {\n- // the 6p response failed to send out, should inform sf0\n- sixtop_vars.cb_sf_handleRCError(msg->l2_sixtop_returnCode);\n- }\n+ // doesn't receive the ACK of response packet from request side.\n+ // Do nothing, request side will timeout when it doesn't receive the response packet.\n}\n}\n// free the buffer\n@@ -1100,10 +1096,12 @@ void sixtop_six2six_notifyReceive(\n}\n// metadata meaning check\nif (sixtop_vars.cb_sf_translateMetadata()!=METADATA_TYPE_FRAMEID){\n- openserial_printError(COMPONENT_SIXTOP,\n+ openserial_printError(\n+ COMPONENT_SIXTOP,\nERR_UNSUPPORTED_METADATA,\nsixtop_vars.cb_sf_translateMetadata(),\n- 0);\n+ 0\n+ );\nreturnCode = IANA_6TOP_RC_ERROR;\nbreak;\n}\n@@ -1428,7 +1426,8 @@ void sixtop_six2six_notifyReceive(\nsixtop_vars.cb_sf_getMetadata(),\nsixtop_vars.celllist_toDelete,\n&(pkt->l2_nextORpreviousHop),\n- sixtop_vars.cellOptions);\n+ sixtop_vars.cellOptions\n+ );\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\nbreak;\ncase SIX_STATE_WAIT_RELOCATERESPONSE:\n@@ -1462,9 +1461,12 @@ void sixtop_six2six_notifyReceive(\nnumCells = *((uint8_t*)(pkt->payload)+ptr);\nnumCells |= (*((uint8_t*)(pkt->payload)+ptr+1))<<8;\nptr += 2;\n- openserial_printInfo(COMPONENT_SIXTOP,ERR_SIXTOP_COUNT,\n+ openserial_printInfo(\n+ COMPONENT_SIXTOP,\n+ ERR_SIXTOP_COUNT,\n(errorparameter_t)numCells,\n- (errorparameter_t)sixtop_vars.six2six_state);\n+ (errorparameter_t)sixtop_vars.six2six_state\n+ );\nbreak;\ncase SIX_STATE_WAIT_LISTRESPONSE:\ni = 0;\n@@ -1480,9 +1482,12 @@ void sixtop_six2six_notifyReceive(\ni++;\n}\n// print out first two cells in the list\n- openserial_printInfo(COMPONENT_SIXTOP,ERR_SIXTOP_LIST,\n+ openserial_printInfo(\n+ COMPONENT_SIXTOP,\n+ ERR_SIXTOP_LIST,\n(errorparameter_t)celllist_list[0].slotoffset,\n- (errorparameter_t)celllist_list[1].slotoffset);\n+ (errorparameter_t)celllist_list[1].slotoffset\n+ );\nbreak;\ncase SIX_STATE_WAIT_CLEARRESPONSE:\nschedule_removeAllCells(\n@@ -1498,9 +1503,12 @@ void sixtop_six2six_notifyReceive(\n} else {\nsixtop_vars.cb_sf_handleRCError(code);\n}\n- openserial_printInfo(COMPONENT_SIXTOP,ERR_SIXTOP_RETURNCODE,\n+ openserial_printInfo(\n+ COMPONENT_SIXTOP,\n+ ERR_SIXTOP_RETURNCODE,\n(errorparameter_t)code,\n- (errorparameter_t)sixtop_vars.six2six_state);\n+ (errorparameter_t)sixtop_vars.six2six_state\n+ );\nsixtop_vars.six2six_state = SIX_STATE_IDLE;\nsixtop_vars.handler = SIX_HANDLER_NONE;\nopentimers_cancel(sixtop_vars.timeoutTimerId);\n@@ -1633,7 +1641,6 @@ bool sixtop_areAvailableCellsToBeScheduled(\navailable = FALSE;\n}\n}\n-\nreturn available;\n}\n@@ -1702,6 +1709,5 @@ bool sixtop_areAvailableCellsToBeRemoved(\navailable = FALSE;\n}\n}\n-\nreturn available;\n}\n" }, { "change_type": "MODIFY", "old_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "new_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "diff": "<group>\n<name>headers</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_aes.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ana_regs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ana_regs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_cctest.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_cctest.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_flash_ctrl.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ints.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ints.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ioc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_memmap.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_memmap.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_nvic.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_ffsm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_sfr.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_sfr.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_xreg.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_xreg.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_smwdthrosc.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_soc_adc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ssi.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ssi.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_sys_ctrl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_types.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\aes.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\aes.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\bl_commands.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ccm.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ccm.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ccm.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\cpu.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\flash.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\flash.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\flash.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gpio.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gpio.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\i2c_lib.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ioc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ioc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\pka.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sleepmode.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sleepmode.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sleepmode.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ssi.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sys_ctrl.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sys_ctrl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\systick.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\uarthal.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\uarthal.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\uarthal.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\udma.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\adc_sensor.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\board.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\board_info.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\bsp_timer.c</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\bsp_timer.c</name>\n+ <excluded>\n+ <configuration>Debug</configuration>\n+ </excluded>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538_crypto_engine.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538rf.h</name>\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. formatting sixtop.c
491,595
12.06.2017 10:50:50
-7,200
b0b12643194d882ece47da1db64d0f4e4c7510bf
remove processIE.h file.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/python/openwsnmodule_obj.h", "new_path": "bsp/boards/python/openwsnmodule_obj.h", "diff": "#include \"IEEE802154_security_obj.h\"\n#include \"adaptive_sync_obj.h\"\n#include \"neighbors_obj.h\"\n-#include \"processIE_obj.h\"\n#include \"sixtop_obj.h\"\n#include \"sf0_obj.h\"\n#include \"schedule_obj.h\"\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154.c", "new_path": "openstack/02a-MAClow/IEEE802154.c", "diff": "#include \"opendefs.h\"\n#include \"IEEE802154.h\"\n#include \"IEEE802154E.h\"\n-#include \"processIE.h\"\n#include \"packetfunctions.h\"\n#include \"idmanager.h\"\n#include \"openserial.h\"\n@@ -37,7 +36,7 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,\nbool securityEnabled;\nint16_t timeCorrection;\nuint16_t timeSyncInfo;\n- header_IE_ht header_desc;\n+ uint16_t length_elementid_type;\nbool headerIEPresent = FALSE;\nuint8_t destAddrMode;\n@@ -83,7 +82,7 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,\nif (frameType == IEEE154_TYPE_ACK) {\ntimeCorrection = (int16_t)(ieee154e_getTimeCorrection());\n// add the payload to the ACK (i.e. the timeCorrection)\n- packetfunctions_reserveHeaderSize(msg,sizeof(timecorrection_IE_ht));\n+ packetfunctions_reserveHeaderSize(msg,sizeof(uint16_t));\ntimeCorrection *= US_PER_TICK;\ntimeSyncInfo = ((uint16_t)timeCorrection) & 0x0fff;\nif (msg->l2_isNegativeACK){\n@@ -93,13 +92,13 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,\nmsg->payload[1] = (uint8_t)(((timeSyncInfo)>>8) & 0xff);\n// add header IE header -- xv poipoi -- pkt is filled in reverse order..\n- packetfunctions_reserveHeaderSize(msg,sizeof(header_IE_ht));\n+ packetfunctions_reserveHeaderSize(msg,sizeof(uint16_t));\n//create the header for ack IE\n- header_desc.length_elementid_type=sizeof(timecorrection_IE_ht)|\n+ length_elementid_type=sizeof(uint16_t)|\n(IEEE802154E_ACK_NACK_TIMECORRECTION_ELEMENTID << IEEE802154E_DESC_ELEMENTID_HEADER_IE_SHIFT)|\n(IEEE802154E_DESC_TYPE_SHORT << IEEE802154E_DESC_TYPE_IE_SHIFT);\n- msg->payload[0] = (header_desc.length_elementid_type) & 0xFF;\n- msg->payload[1] = ((header_desc.length_elementid_type) >> 8) & 0xFF;\n+ msg->payload[0] = (length_elementid_type) & 0xFF;\n+ msg->payload[1] = ((length_elementid_type) >> 8) & 0xFF;\n}\n//if security is enabled, the Auxiliary Security Header need to be added to the IEEE802.15.4 MAC header\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "#include \"debugpins.h\"\n#include \"sixtop.h\"\n#include \"adaptive_sync.h\"\n-#include \"processIE.h\"\n#include \"sctimer.h\"\n//=========================== variables =======================================\n@@ -746,7 +745,8 @@ port_INLINE void activity_ti1ORri1() {\ncellType_t cellType;\nopen_addr_t neighbor;\nuint8_t i;\n- sync_IE_ht sync_IE;\n+ uint8_t asn[5];\n+ uint8_t join_priority;\nbool changeToRX=FALSE;\nbool couldSendEB=FALSE;\n@@ -879,9 +879,10 @@ port_INLINE void activity_ti1ORri1() {\nif (couldSendEB==TRUE) { // I will be sending an EB\n//copy synch IE -- should be Little endian???\n// fill in the ASN field of the EB\n- ieee154e_getAsn(sync_IE.asn);\n- sync_IE.join_priority = (icmpv6rpl_getMyDAGrank()/MINHOPRANKINCREASE)-1; //poipoi -- use dagrank(rank)-1\n- memcpy(ieee154e_vars.dataToSend->l2_ASNpayload,&sync_IE,sizeof(sync_IE_ht));\n+ ieee154e_getAsn(asn);\n+ join_priority = (icmpv6rpl_getMyDAGrank()/MINHOPRANKINCREASE)-1; //poipoi -- use dagrank(rank)-1\n+ memcpy(ieee154e_vars.dataToSend->l2_ASNpayload,&asn[0],sizeof(asn_t));\n+ memcpy(ieee154e_vars.dataToSend->l2_ASNpayload+sizeof(asn_t),&join_priority,sizeof(uint8_t));\n}\n// record that I attempt to transmit this packet\nieee154e_vars.dataToSend->l2_numTxAttempts++;\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "#include \"board.h\"\n#include \"opentimers.h\"\n#include \"schedule.h\"\n-#include \"processIE.h\"\n//=========================== debug define ====================================\n@@ -219,11 +218,6 @@ typedef struct {\nPORT_SIGNED_INT_WIDTH timeCorrection;\n} IEEE802154E_ACK_ht;\n-// includes payload header IE short + MLME short Header + Sync IE\n-#define EB_PAYLOAD_LENGTH sizeof(payload_IE_ht) + \\\n- sizeof(mlme_IE_ht) + \\\n- sizeof(sync_IE_ht)\n-\n//=========================== module variables ================================\ntypedef struct {\n" }, { "change_type": "DELETE", "old_path": "openstack/02b-MAChigh/processIE.h", "new_path": null, "diff": "-#ifndef __PROCESSIE_H\n-#define __PROCESSIE_H\n-\n-#include \"opendefs.h\"\n-\n-//=========================== define ==========================================\n-\n-// subIE shift\n-#define MLME_IE_SUBID_SHIFT 8\n-\n-// subIEs identifier\n-#define MLME_IE_SUBID_SYNC 0x1A\n-#define MLME_IE_SUBID_SLOTFRAME_LINK 0x1B\n-#define MLME_IE_SUBID_TIMESLOT 0x1c\n-#define MLME_IE_SUBID_CHANNELHOPPING 0x09\n-#define MLME_IE_SUBID_LINKTYPE 0x40\n-#define MLME_IE_SUBID_OPCODE 0x41\n-#define MLME_IE_SUBID_BANDWIDTH 0x42\n-#define MLME_IE_SUBID_TRACKID 0x43\n-#define MLME_IE_SUBID_SCHEDULE 0x44\n-\n-// 201 is the first available subIE ID for experimental use:\n-// https://tools.ietf.org/html/draft-kivinen-802-15-ie-06#section-7\n-#define IANA_6TOP_SUBIE_ID 201\n-// 05 indicates IETF IE ID\n-// https://mentor.ieee.org/802.15/documents?is_dcn=257&is_group=0000\n-#define SIXTOP_IE_GROUPID 0x05\n-\n-// ========================== typedef =========================================\n-\n-BEGIN_PACK\n-\n-/**\n-\\brief Header of header IEs.\n-*/\n-typedef struct{\n- uint16_t length_elementid_type;\n-} header_IE_ht;\n-\n-/**\n-\\brief Header of payload IEs.\n-*/\n-typedef struct{\n- uint16_t length_groupid_type;\n-} payload_IE_ht;\n-\n-//======= header IEs\n-\n-/**\n-\\brief TSCH ACK/NACK TimeCorrection IE\n-\n-IEEE802.15.4e-2012, Section 5.2.4.11, p. 88.\n-*/\n-typedef struct {\n- int16_t timesync_info;\n-} timecorrection_IE_ht;\n-\n-//======= payload IEs\n-\n-/**\n-\\brief MLME IE common header\n-\n-IEEE802.15.4e-2012, Section 5.2.4.5, p. 82.\n-*/\n-typedef struct{\n- uint16_t length_subID_type;\n-} mlme_IE_ht;\n-\n-/**\n-\\brief TSCH Synchronization IE\n-\n-http://tools.ietf.org/html/draft-wang-6tisch-6top-sublayer-01#section-4.1.1.1\n-*/\n-typedef struct {\n- uint8_t asn[5];\n- uint8_t join_priority;\n-} sync_IE_ht;\n-\n-END_PACK\n-#endif\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "#include \"opentimers.h\"\n#include \"debugpins.h\"\n#include \"leds.h\"\n-#include \"processIE.h\"\n#include \"IEEE802154.h\"\n#include \"IEEE802154_security.h\"\n#include \"idmanager.h\"\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.h", "new_path": "openstack/02b-MAChigh/sixtop.h", "diff": "#include \"opentimers.h\"\n#include \"opendefs.h\"\n-#include \"processIE.h\"\n+\n//=========================== define ==========================================\n+// 201 is the first available subIE ID for experimental use:\n+// https://tools.ietf.org/html/draft-kivinen-802-15-ie-06#section-7\n+#define IANA_6TOP_SUBIE_ID 201\n// 6P version\n#define IANA_6TOP_6P_VERSION 0x00\n#define IANA_6TOP_VESION_MASK 0x0F\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -49,7 +49,6 @@ sources_h = [\n#=== 02b-MAChigh\nos.path.join('02b-MAChigh','neighbors.h'),\nos.path.join('02b-MAChigh','sf0.h'),\n- os.path.join('02b-MAChigh','processIE.h'),\nos.path.join('02b-MAChigh','schedule.h'),\nos.path.join('02b-MAChigh','sixtop.h'),\n#=== 03a-IPHC\n" }, { "change_type": "MODIFY", "old_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "new_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "diff": "<group>\n<name>headers</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_aes.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ana_regs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ana_regs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_cctest.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_cctest.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_flash_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_flash_ctrl.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gpio.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gptimer.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cm.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ints.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ints.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ioc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_memmap.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_memmap.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_nvic.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_nvic.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_pka.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_pka.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_ffsm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_sfr.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_sfr.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_xreg.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_xreg.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_smwdthrosc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_smwdthrosc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_soc_adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_soc_adc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ssi.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ssi.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_sys_ctrl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_types.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_uart.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_uart.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udma.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udma.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udmachctl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udmachctl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_usb.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\adc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\aes.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gpio.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gpio.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ioc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ioc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\pka.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sys_ctrl.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sys_ctrl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\systick.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\adc_sensor.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\board.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538_crypto_engine.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538rf.h</name>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\neighbors.h</name>\n</file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\processIE.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\schedule.c</name>\n</file>\n" }, { "change_type": "MODIFY", "old_path": "projects/openmote-cc2538/OpenMote-CC2538.eww", "new_path": "projects/openmote-cc2538/OpenMote-CC2538.eww", "diff": "<project>\n<path>$WS_DIR$\\01bsp_sctimer\\01bsp_sctimer.ewp</path>\n</project>\n- <project>\n- <path>$WS_DIR$\\01bsp_uart\\01bsp_uart.ewp</path>\n- </project>\n<project>\n<path>$WS_DIR$\\02drv_opentimers2\\02drv_opentimers2.ewp</path>\n</project>\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -874,7 +874,6 @@ headerFiles = [\n'ieee802154_security_driver',\n# 02b-MAChigh\n'neighbors',\n- 'processIE',\n'schedule',\n'sixtop',\n'sf0',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. remove processIE.h file.
491,609
04.11.2016 17:20:39
-3,600
429f70ae97aec1888e49de276e4d2c72ece16145
Add initial templates for cjoin app.
[ { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -167,6 +167,7 @@ enum {\nCOMPONENT_RRT = 0x25,\nCOMPONENT_SECURITY = 0x26,\nCOMPONENT_USERIALBRIDGE = 0x27,\n+ COMPONENT_CJOIN = 0x28,\n};\n/**\n" }, { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -17,6 +17,7 @@ defaultApps = [\n'uinject',\n'userialbridge',\n'rrt',\n+ 'cjoin',\n]\nif localEnv['board']=='python':\ndefaultApps += [\n@@ -33,6 +34,7 @@ defaultAppsInit = [\n'techo',\n'uecho',\n'rrt',\n+ 'cjoin',\n]\n# additional apps the user wants to build\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openapps/cjoin/cjoin.c", "diff": "+/**\n+\\brief An example CoAP application.\n+*/\n+\n+#include \"opendefs.h\"\n+#include \"cjoin.h\"\n+#include \"opencoap.h\"\n+#include \"opentimers.h\"\n+#include \"openqueue.h\"\n+#include \"packetfunctions.h\"\n+#include \"openserial.h\"\n+#include \"openrandom.h\"\n+#include \"scheduler.h\"\n+//#include \"ADC_Channel.h\"\n+#include \"idmanager.h\"\n+#include \"IEEE802154E.h\"\n+\n+//=========================== defines =========================================\n+\n+/// inter-packet period (in ms)\n+#define CJOINPERIOD 30000\n+#define NUMBER_OF_EXCHANGES 6\n+\n+const uint8_t cjoin_path0[] = \"j\";\n+\n+static const uint8_t ipAddr_jce[] = {0xbb, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \\\n+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};\n+\n+\n+//=========================== variables =======================================\n+\n+cjoin_vars_t cjoin_vars;\n+\n+//=========================== prototypes ======================================\n+\n+owerror_t cjoin_receive(OpenQueueEntry_t* msg,\n+ coap_header_iht* coap_header,\n+ coap_option_iht* coap_options);\n+void cjoin_timer_cb(opentimer_id_t id);\n+void cjoin_task_cb(void);\n+void cjoin_sendDone(OpenQueueEntry_t* msg,\n+ owerror_t error);\n+\n+//=========================== public ==========================================\n+\n+void cjoin_init() {\n+\n+ // prepare the resource descriptor for the /j path\n+ cjoin_vars.desc.path0len = sizeof(cjoin_path0)-1;\n+ cjoin_vars.desc.path0val = (uint8_t*)(&cjoin_path0);\n+ cjoin_vars.desc.path1len = 0;\n+ cjoin_vars.desc.path1val = NULL;\n+ cjoin_vars.desc.componentID = COMPONENT_CJOIN;\n+ cjoin_vars.desc.discoverable = TRUE;\n+ cjoin_vars.desc.callbackRx = &cjoin_receive;\n+ cjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\n+\n+\n+ opencoap_register(&cjoin_vars.desc);\n+ cjoin_vars.timerId = opentimers_start(CJOINPERIOD,\n+ TIMER_PERIODIC,TIME_MS,\n+ cjoin_timer_cb);\n+}\n+\n+//=========================== private =========================================\n+\n+owerror_t cjoin_receive(OpenQueueEntry_t* msg,\n+ coap_header_iht* coap_header,\n+ coap_option_iht* coap_options) {\n+\n+ if (msg->payload[0] == 0) {\n+ // join is over\n+ }\n+ else {\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n+ (errorparameter_t)ieee154e_vars.state,\n+ (errorparameter_t)msg->payload[0]);\n+ }\n+\n+ return E_SUCCESS;\n+}\n+\n+//timer fired, but we don't want to execute task in ISR mode\n+//instead, push task to scheduler with COAP priority, and let scheduler take care of it\n+void cjoin_timer_cb(opentimer_id_t id){\n+ scheduler_push_task(cjoin_task_cb,TASKPRIO_COAP);\n+}\n+\n+void cjoin_task_cb() {\n+ OpenQueueEntry_t* pkt;\n+ owerror_t outcome;\n+\n+ // don't run if not synch\n+ if (ieee154e_isSynch() == FALSE) return;\n+\n+ // don't run on dagroot\n+ if (idmanager_getIsDAGroot()) {\n+ opentimers_stop(cjoin_vars.timerId);\n+ return;\n+ }\n+\n+\n+ // create a CoAP RD packet\n+ pkt = openqueue_getFreePacketBuffer(COMPONENT_CJOIN);\n+ if (pkt==NULL) {\n+ openserial_printError(\n+ COMPONENT_CJOIN,\n+ ERR_NO_FREE_PACKET_BUFFER,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0\n+ );\n+ openqueue_freePacketBuffer(pkt);\n+ return;\n+ }\n+ // take ownership over that packet\n+ pkt->creator = COMPONENT_CJOIN;\n+ pkt->owner = COMPONENT_CJOIN;\n+ // CoAP payload\n+ packetfunctions_reserveHeaderSize(pkt,1);\n+ pkt->payload[0] = NUMBER_OF_EXCHANGES - 1;\n+\n+ packetfunctions_reserveHeaderSize(pkt,1);\n+ pkt->payload[0] = COAP_PAYLOAD_MARKER;\n+\n+ // content-type option\n+ packetfunctions_reserveHeaderSize(pkt,2);\n+ pkt->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT - COAP_OPTION_NUM_URIPATH) << 4\n+ | 1;\n+ pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n+ // location-path option\n+ packetfunctions_reserveHeaderSize(pkt,sizeof(cjoin_path0)-1);\n+ memcpy(&pkt->payload[0],cjoin_path0,sizeof(cjoin_path0)-1);\n+ packetfunctions_reserveHeaderSize(pkt,1);\n+ pkt->payload[0] = ((COAP_OPTION_NUM_URIPATH) << 4) | (sizeof(cjoin_path0)-1);\n+\n+ // metadata\n+ pkt->l4_destination_port = WKP_UDP_COAP;\n+ pkt->l3_destinationAdd.type = ADDR_128B;\n+ memcpy(&pkt->l3_destinationAdd.addr_128b[0],&ipAddr_jce,16);\n+\n+ // send\n+ outcome = opencoap_send(\n+ pkt,\n+ COAP_TYPE_NON,\n+ COAP_CODE_REQ_PUT,\n+ 1,\n+ &cjoin_vars.desc\n+ );\n+\n+ // avoid overflowing the queue if fails\n+ if (outcome==E_FAIL) {\n+ openqueue_freePacketBuffer(pkt);\n+ }\n+\n+ return;\n+}\n+\n+void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) {\n+ openqueue_freePacketBuffer(msg);\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openapps/cjoin/cjoin.h", "diff": "+#ifndef __CJOIN_H\n+#define __CJOIN_H\n+\n+/**\n+\\addtogroup AppUdp\n+\\{\n+\\addtogroup cjoin\n+\\{\n+*/\n+#include \"opencoap.h\"\n+//=========================== define ==========================================\n+\n+//=========================== typedef =========================================\n+\n+typedef struct {\n+ coap_resource_desc_t desc;\n+ opentimer_id_t timerId;\n+} cjoin_vars_t;\n+\n+//=========================== variables =======================================\n+\n+//=========================== prototypes ======================================\n+\n+void cjoin_init(void);\n+\n+/**\n+\\}\n+\\}\n+*/\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "openapps/openapps.c", "new_path": "openapps/openapps.c", "diff": "#include \"cleds.h\"\n#include \"cexample.h\"\n#include \"cstorm.h\"\n+#include \"cjoin.h\"\n#include \"cwellknown.h\"\n#include \"rrt.h\"\n// TCP\n@@ -35,6 +36,7 @@ void openapps_init(void) {\n//cexample_init();\ncleds__init();\ncstorm_init();\n+ cjoin_init();\ncwellknown_init();\nrrt_init();\n// TCP\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -122,6 +122,7 @@ else:\nos.path.join('#','openapps','uecho'),\nos.path.join('#','openapps','uinject'),\nos.path.join('#','openapps','userialbridge'),\n+ os.path.join('#','openapps','cjoin'),\n],\n)\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -86,6 +86,7 @@ buildEnv.Append(\nos.path.join('#','build','python_gcc','openapps','uecho'),\nos.path.join('#','build','python_gcc','openapps','uinject'),\nos.path.join('#','build','python_gcc','openapps','userialbridge'),\n+ os.path.join('#','build','python_gcc','openapps','cjoin'),\n]\n)\n@@ -842,6 +843,12 @@ functionsToChange = [\n'rrt_sendDone',\n'rrt_setGETRespMsg',\n'rrt_sendCoAPMsg',\n+ # cjoin\n+ 'cjoin_init',\n+ 'cjoin_receive',\n+ 'cjoin_timer_cb',\n+ 'cjoin_task_cb',\n+ 'cjoin_sendDone',\n]\nheaderFiles = [\n@@ -912,6 +919,7 @@ headerFiles = [\n'uinject',\n'userialbridge',\n'rrt',\n+ 'cjoin',\n]\ndef objectify(env,target,source):\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add initial templates for cjoin app.
491,609
04.11.2016 17:45:54
-3,600
c2061cf7289eefa4d74beafd6a8f6f2d7a2edcdf
Add code to bounce back and forth with CoAP payload.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "//=========================== defines =========================================\n/// inter-packet period (in ms)\n-#define CJOINPERIOD 30000\n+#define CJOINPERIOD 300000\n#define NUMBER_OF_EXCHANGES 6\nconst uint8_t cjoin_path0[] = \"j\";\n@@ -40,7 +40,7 @@ void cjoin_timer_cb(opentimer_id_t id);\nvoid cjoin_task_cb(void);\nvoid cjoin_sendDone(OpenQueueEntry_t* msg,\nowerror_t error);\n-\n+owerror_t cjoin_sendPut(uint8_t payload);\n//=========================== public ==========================================\nvoid cjoin_init() {\n@@ -75,6 +75,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\nopenserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n(errorparameter_t)ieee154e_vars.state,\n(errorparameter_t)msg->payload[0]);\n+ cjoin_sendPut(msg->payload[0]--);\n}\nreturn E_SUCCESS;\n@@ -87,8 +88,6 @@ void cjoin_timer_cb(opentimer_id_t id){\n}\nvoid cjoin_task_cb() {\n- OpenQueueEntry_t* pkt;\n- owerror_t outcome;\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n@@ -99,6 +98,18 @@ void cjoin_task_cb() {\nreturn;\n}\n+ cjoin_sendPut(NUMBER_OF_EXCHANGES-1);\n+\n+ return;\n+}\n+\n+void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) {\n+ openqueue_freePacketBuffer(msg);\n+}\n+\n+owerror_t cjoin_sendPut(uint8_t payload) {\n+ OpenQueueEntry_t* pkt;\n+ owerror_t outcome;\n// create a CoAP RD packet\npkt = openqueue_getFreePacketBuffer(COMPONENT_CJOIN);\n@@ -110,14 +121,14 @@ void cjoin_task_cb() {\n(errorparameter_t)0\n);\nopenqueue_freePacketBuffer(pkt);\n- return;\n+ return E_FAIL;\n}\n// take ownership over that packet\npkt->creator = COMPONENT_CJOIN;\npkt->owner = COMPONENT_CJOIN;\n// CoAP payload\npacketfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = NUMBER_OF_EXCHANGES - 1;\n+ pkt->payload[0] = payload;\npacketfunctions_reserveHeaderSize(pkt,1);\npkt->payload[0] = COAP_PAYLOAD_MARKER;\n@@ -150,11 +161,8 @@ void cjoin_task_cb() {\n// avoid overflowing the queue if fails\nif (outcome==E_FAIL) {\nopenqueue_freePacketBuffer(pkt);\n+ return E_FAIL;\n}\n- return;\n-}\n-\n-void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) {\n- openqueue_freePacketBuffer(msg);\n+ return E_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -849,6 +849,7 @@ functionsToChange = [\n'cjoin_timer_cb',\n'cjoin_task_cb',\n'cjoin_sendDone',\n+ 'cjoin_sendPut',\n]\nheaderFiles = [\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add code to bounce back and forth with CoAP payload.
491,609
07.11.2016 15:56:56
-3,600
99090185d72eea57fb25ed241eb231d3c099a909
Add daoSent function to icmpv6rpl module.
[ { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/icmpv6rpl.c", "new_path": "openstack/03b-IPv6/icmpv6rpl.c", "diff": "@@ -45,6 +45,7 @@ void icmpv6rpl_init() {\n//=== routing\nicmpv6rpl_vars.haveParent=FALSE;\n+ icmpv6rpl_vars.daoSent=FALSE;\nif (idmanager_getIsDAGroot()==TRUE) {\nicmpv6rpl_vars.myDAGrank=MINHOPRANKINCREASE;\n} else {\n@@ -643,6 +644,8 @@ void icmpv6rpl_timer_DAO_task() {\n// send DAO\nsendDAO();\n+ icmpv6rpl_vars.daoSent = TRUE;\n+\n// arm the DAO timer with this new value\ndaoPeriod = icmpv6rpl_vars.daoPeriod - 0x80 + (openrandom_get16b()&0xff);\nopentimers_setPeriod(\n@@ -839,3 +842,8 @@ void icmpv6rpl_setDAOPeriod(uint16_t daoPeriod){\ndaoPeriodRandom\n);\n}\n+\n+bool icmpv6rpl_daoSent(void) {\n+ return icmpv6rpl_vars.daoSent;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/icmpv6rpl.h", "new_path": "openstack/03b-IPv6/icmpv6rpl.h", "diff": "@@ -161,6 +161,7 @@ typedef struct {\nuint8_t ParentIndex; ///< index of Parent in neighbor table (iff haveParent==TRUE)\n// actually only here for debug\nicmpv6rpl_dio_ht* incomingDio; //keep it global to be able to debug correctly.\n+ bool daoSent;\n} icmpv6rpl_vars_t;\n//=========================== prototypes ======================================\n@@ -181,6 +182,7 @@ void icmpv6rpl_setMyDAGrank(dagrank_t rank); // new\nvoid icmpv6rpl_killPreferredParent(void); // new DB\nvoid icmpv6rpl_updateMyDAGrankAndParentSelection(void); // new DB\nvoid icmpv6rpl_indicateRxDIO(OpenQueueEntry_t* msg); // new DB\n+bool icmpv6rpl_daoSent(void);\n/**\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -691,6 +691,7 @@ functionsToChange = [\n'sendDAO',\n'icmpv6rpl_setDIOPeriod',\n'icmpv6rpl_setDAOPeriod',\n+ 'icmpv6rpl_daoSent',\n# opencoap\n'opencoap_init',\n'opencoap_receive',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add daoSent function to icmpv6rpl module.
491,609
07.11.2016 15:59:39
-3,600
c8311957365ff8a2a87451d40c0eb1c82c77986c
Split init function. Do not initiate unless there is a route created.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "//#include \"ADC_Channel.h\"\n#include \"idmanager.h\"\n#include \"IEEE802154E.h\"\n+#include \"icmpv6rpl.h\"\n//=========================== defines =========================================\n/// inter-packet period (in ms)\n-#define CJOINPERIOD 300000\n#define NUMBER_OF_EXCHANGES 6\nconst uint8_t cjoin_path0[] = \"j\";\n@@ -54,12 +54,27 @@ void cjoin_init() {\ncjoin_vars.desc.discoverable = TRUE;\ncjoin_vars.desc.callbackRx = &cjoin_receive;\ncjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\n+ cjoin_vars.joined = 0;\nopencoap_register(&cjoin_vars.desc);\n- cjoin_vars.timerId = opentimers_start(CJOINPERIOD,\n+\n+ cjoin_schedule();\n+}\n+\n+void cjoin_schedule() {\n+ uint16_t delay;\n+\n+ if (cjoin_vars.joined == 0) {\n+ delay = openrandom_get16b();\n+ cjoin_vars.timerId = opentimers_start((uint32_t) delay, // random wait from 0 to 65535ms\nTIMER_PERIODIC,TIME_MS,\ncjoin_timer_cb);\n+\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_WDRADIO_OVERFLOWS,\n+ (errorparameter_t)ieee154e_vars.state,\n+ (errorparameter_t)delay);\n+ }\n}\n//=========================== private =========================================\n@@ -68,8 +83,10 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\ncoap_option_iht* coap_options) {\n+\nif (msg->payload[0] == 0) {\n- // join is over\n+ cjoin_vars.joined = 1; // declare join is over\n+ opentimers_stop(cjoin_vars.timerId); // stop the timer\n}\nelse {\nopenserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n@@ -88,10 +105,21 @@ void cjoin_timer_cb(opentimer_id_t id){\n}\nvoid cjoin_task_cb() {\n+ uint8_t temp;\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n+ // don't run if no route to DAG root\n+ if (icmpv6rpl_getPreferredParentIndex(&temp) == FALSE) {\n+ return;\n+ }\n+\n+/* if (icmpv6rpl_daoSent() == FALSE) {\n+ return;\n+ }\n+*/\n+\n// don't run on dagroot\nif (idmanager_getIsDAGroot()) {\nopentimers_stop(cjoin_vars.timerId);\n@@ -99,6 +127,9 @@ void cjoin_task_cb() {\n}\ncjoin_sendPut(NUMBER_OF_EXCHANGES-1);\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n+ (errorparameter_t)ieee154e_vars.state,\n+ (errorparameter_t)NUMBER_OF_EXCHANGES-1);\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "typedef struct {\ncoap_resource_desc_t desc;\nopentimer_id_t timerId;\n+ uint8_t joined;\n} cjoin_vars_t;\n//=========================== variables =======================================\n@@ -22,6 +23,7 @@ typedef struct {\n//=========================== prototypes ======================================\nvoid cjoin_init(void);\n+void cjoin_schedule(void);\n/**\n\\}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -846,6 +846,7 @@ functionsToChange = [\n'rrt_sendCoAPMsg',\n# cjoin\n'cjoin_init',\n+ 'cjoin_schedule',\n'cjoin_receive',\n'cjoin_timer_cb',\n'cjoin_task_cb',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Split init function. Do not initiate unless there is a route created.
491,609
10.11.2016 15:31:16
-3,600
dac366274f2f66e92a3b738f591afcb487822f5a
Add getters and setters on isJoined variable. Use two different timers.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -41,6 +41,10 @@ void cjoin_task_cb(void);\nvoid cjoin_sendDone(OpenQueueEntry_t* msg,\nowerror_t error);\nowerror_t cjoin_sendPut(uint8_t payload);\n+void cjoin_retransmission_cb(opentimer_id_t id);\n+void cjoin_retransmission_task_cb(void);\n+bool cjoin_getIsJoined(void);\n+void cjoin_setIsJoined(bool newValue);\n//=========================== public ==========================================\nvoid cjoin_init() {\n@@ -54,8 +58,9 @@ void cjoin_init() {\ncjoin_vars.desc.discoverable = TRUE;\ncjoin_vars.desc.callbackRx = &cjoin_receive;\ncjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\n- cjoin_vars.joined = 0;\n+ cjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1;\n+ cjoin_setIsJoined(FALSE);\nopencoap_register(&cjoin_vars.desc);\n@@ -65,15 +70,11 @@ void cjoin_init() {\nvoid cjoin_schedule() {\nuint16_t delay;\n- if (cjoin_vars.joined == 0) {\n+ if (cjoin_getIsJoined() == FALSE) {\ndelay = openrandom_get16b();\n- cjoin_vars.timerId = opentimers_start((uint32_t) delay, // random wait from 0 to 65535ms\n+ cjoin_vars.startupTimerId = opentimers_start((uint32_t) delay, // random wait from 0 to 65535ms\nTIMER_PERIODIC,TIME_MS,\ncjoin_timer_cb);\n-\n- openserial_printError(COMPONENT_IEEE802154E,ERR_WDRADIO_OVERFLOWS,\n- (errorparameter_t)ieee154e_vars.state,\n- (errorparameter_t)delay);\n}\n}\n@@ -83,16 +84,29 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\ncoap_option_iht* coap_options) {\n+ uint8_t asn[5];\n+ uint32_t asnCropped;\n+\n+\n+ opentimers_stop(cjoin_vars.retransmissionTimerId); // stop the timer\n+\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_WDRADIO_OVERFLOWS,\n+ (errorparameter_t)0,\n+ (errorparameter_t)msg->payload[0]);\nif (msg->payload[0] == 0) {\n- cjoin_vars.joined = 1; // declare join is over\n- opentimers_stop(cjoin_vars.timerId); // stop the timer\n+ cjoin_setIsJoined(TRUE); // declare join is over\n+ ieee154e_getAsn(asn);\n+ asnCropped = ((uint32_t) asn[3] << 24) | ((uint32_t) asn[2] << 16) | ((uint32_t) asn[1] << 8) | ((uint32_t) asn[0]);\n+ printf(\"JOIN ASN: %u\\n\", asnCropped);\n+ }\n+ else if (msg->payload[0] == cjoin_vars.lastPayload - 1) {\n+ cjoin_sendPut(msg->payload[0] - 1);\n}\nelse {\n- openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n- (errorparameter_t)ieee154e_vars.state,\n- (errorparameter_t)msg->payload[0]);\n- cjoin_sendPut(msg->payload[0]--);\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_WDDATADURATION_OVERFLOWS,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0);\n}\nreturn E_SUCCESS;\n@@ -104,6 +118,16 @@ void cjoin_timer_cb(opentimer_id_t id){\nscheduler_push_task(cjoin_task_cb,TASKPRIO_COAP);\n}\n+void cjoin_retransmission_cb(opentimer_id_t id) {\n+\n+ scheduler_push_task(cjoin_retransmission_task_cb, TASKPRIO_COAP);\n+}\n+\n+void cjoin_retransmission_task_cb() {\n+ cjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1; // get around the bug of starting with 1 after retransmit\n+ cjoin_sendPut(cjoin_vars.lastPayload);\n+}\n+\nvoid cjoin_task_cb() {\nuint8_t temp;\n@@ -142,6 +166,11 @@ owerror_t cjoin_sendPut(uint8_t payload) {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\n+ cjoin_vars.lastPayload = payload;\n+\n+ openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n+ (errorparameter_t)0,\n+ (errorparameter_t)payload);\n// create a CoAP RD packet\npkt = openqueue_getFreePacketBuffer(COMPONENT_CJOIN);\nif (pkt==NULL) {\n@@ -195,5 +224,35 @@ owerror_t cjoin_sendPut(uint8_t payload) {\nreturn E_FAIL;\n}\n+ cjoin_vars.retransmissionTimerId = opentimers_start((uint32_t) TIMEOUT,\n+ TIMER_ONESHOT,TIME_MS,\n+ cjoin_retransmission_cb);\nreturn E_SUCCESS;\n}\n+\n+bool cjoin_getIsJoined() {\n+ bool res;\n+ INTERRUPT_DECLARATION();\n+\n+ DISABLE_INTERRUPTS();\n+ res=cjoin_vars.isJoined;\n+ ENABLE_INTERRUPTS();\n+\n+ return res;\n+}\n+\n+void cjoin_setIsJoined(bool newValue) {\n+ INTERRUPT_DECLARATION();\n+ DISABLE_INTERRUPTS();\n+\n+ cjoin_vars.isJoined = newValue;\n+\n+ ENABLE_INTERRUPTS();\n+\n+ if (newValue == TRUE) {\n+ // log the info\n+ openserial_printInfo(COMPONENT_CJOIN, ERR_JOINED,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0);\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "typedef struct {\ncoap_resource_desc_t desc;\n- opentimer_id_t timerId;\n- uint8_t joined;\n+ opentimer_id_t startupTimerId;\n+ opentimer_id_t retransmissionTimerId;\n+ uint8_t lastPayload;\n+ bool isJoined;\n} cjoin_vars_t;\n//=========================== variables =======================================\n@@ -24,6 +26,8 @@ typedef struct {\nvoid cjoin_init(void);\nvoid cjoin_schedule(void);\n+bool cjoin_getIsJoined(void);\n+void cjoin_setIsJoined(bool newValue);\n/**\n\\}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add getters and setters on isJoined variable. Use two different timers.
491,609
10.11.2016 15:34:28
-3,600
ec5bb740dfc66c2a97894d1cd06e5f51398f6351
Don't run if DAG root.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -134,6 +134,11 @@ void cjoin_task_cb() {\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n+ // don't run if DAG root\n+ if (idmanager_getIsDAGroot() == TRUE) {\n+ return;\n+ }\n+\n// don't run if no route to DAG root\nif (icmpv6rpl_getPreferredParentIndex(&temp) == FALSE) {\nreturn;\n@@ -144,16 +149,9 @@ void cjoin_task_cb() {\n}\n*/\n- // don't run on dagroot\n- if (idmanager_getIsDAGroot()) {\n- opentimers_stop(cjoin_vars.timerId);\n- return;\n- }\n+ opentimers_stop(cjoin_vars.startupTimerId);\ncjoin_sendPut(NUMBER_OF_EXCHANGES-1);\n- openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n- (errorparameter_t)ieee154e_vars.state,\n- (errorparameter_t)NUMBER_OF_EXCHANGES-1);\nreturn;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Don't run if DAG root.
491,609
10.11.2016 15:36:44
-3,600
cae7be9af4422e4b231a054dfc11519d433be0bd
Wait until DAO has been sent.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -144,11 +144,9 @@ void cjoin_task_cb() {\nreturn;\n}\n-/* if (icmpv6rpl_daoSent() == FALSE) {\n+ if (icmpv6rpl_daoSent() == FALSE) {\nreturn;\n}\n-*/\n-\nopentimers_stop(cjoin_vars.startupTimerId);\ncjoin_sendPut(NUMBER_OF_EXCHANGES-1);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Wait until DAO has been sent.
491,609
10.11.2016 15:38:38
-3,600
217081fd69b2f349ec14afadf0bc34fba60d66b9
Add JOIN-related status and error codes.
[ { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -108,6 +108,7 @@ enum {\nSTATUS_NEIGHBORS = 9,\nSTATUS_KAPERIOD = 10,\nSTATUS_MAX = 11,\n+ STATUS_ISJOINED = 12,\n};\n//component identifiers\n@@ -247,6 +248,7 @@ enum {\nERR_SIXTOP_COUNT = 0x3d, // there are {0} cells to request mote\nERR_SIXTOP_LIST = 0x3e, // the cells reserved to request mote contains slot {0} and slot {1}\nERR_SCHEDULE_ADDDUPLICATESLOT = 0x3f, // the slot {0} to be added is already in schedule\n+ ERR_JOINED = 0x40, // node joined\n};\n//=========================== typedef =========================================\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -852,6 +852,10 @@ functionsToChange = [\n'cjoin_task_cb',\n'cjoin_sendDone',\n'cjoin_sendPut',\n+ 'cjoin_retransmission_cb',\n+ 'cjoin_retransmission_task_cb',\n+ 'cjoin_getIsJoined',\n+ 'cjoin_setIsJoined',\n]\nheaderFiles = [\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add JOIN-related status and error codes.
491,609
10.11.2016 15:39:14
-3,600
44a429a3a403edf84adf1a6244f27221624c682c
Do not send EBs unless joined.
[ { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "#include \"IEEE802154_security.h\"\n#include \"idmanager.h\"\n#include \"schedule.h\"\n+#include \"cjoin.h\"\n//=========================== define ==========================================\n@@ -709,8 +710,8 @@ port_INLINE void sixtop_sendEB() {\nlen = 0;\n- if ((ieee154e_isSynch()==FALSE) || (icmpv6rpl_getMyDAGrank()==DEFAULTDAGRANK)){\n- // I'm not sync'ed or I did not acquire a DAGrank\n+ if ((ieee154e_isSynch()==FALSE) || (icmpv6rpl_getMyDAGrank()==DEFAULTDAGRANK) || (cjoin_getIsJoined()==FALSE)){\n+ // I'm not sync'ed or I did not acquire a DAGrank or I did not join yet\n// delete packets genereted by this module (EB and KA) from openqueue\nopenqueue_removeAllCreatedBy(COMPONENT_SIXTOP);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Do not send EBs unless joined.
491,609
10.11.2016 15:39:48
-3,600
16bd543af7d9316f9c2af03d0e456b91a6a4acd2
Bug fix for daoSent update.
[ { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/icmpv6rpl.c", "new_path": "openstack/03b-IPv6/icmpv6rpl.c", "diff": "@@ -644,7 +644,6 @@ void icmpv6rpl_timer_DAO_task() {\n// send DAO\nsendDAO();\n- icmpv6rpl_vars.daoSent = TRUE;\n// arm the DAO timer with this new value\ndaoPeriod = icmpv6rpl_vars.daoPeriod - 0x80 + (openrandom_get16b()&0xff);\n@@ -814,6 +813,7 @@ void sendDAO() {\n//===== send\nif (icmpv6_send(msg)==E_SUCCESS) {\nicmpv6rpl_vars.busySendingDAO = TRUE;\n+ icmpv6rpl_vars.daoSent = TRUE;\n} else {\nopenqueue_freePacketBuffer(msg);\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Bug fix for daoSent update.
491,609
10.11.2016 15:40:47
-3,600
45807406dce0b982cf39fd0985b3e70389424db1
Force isJoined to FALSE after synchronization.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -637,6 +637,8 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_RADIOTIMER_WIDTH capturedT\n// declare synchronized\nchangeIsSync(TRUE);\n+ // force isJoined to FALSE\n+ cjoin_setIsJoined(FALSE);\n// log the info\nopenserial_printInfo(COMPONENT_IEEE802154E,ERR_SYNCHRONIZED,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Force isJoined to FALSE after synchronization.
491,609
10.11.2016 15:41:22
-3,600
df0bab4cf982e844a77711fcf980458d6535bb76
Set DAGroot to be joined by default.
[ { "change_type": "MODIFY", "old_path": "openstack/cross-layers/idmanager.c", "new_path": "openstack/cross-layers/idmanager.c", "diff": "#include \"openserial.h\"\n#include \"neighbors.h\"\n#include \"schedule.h\"\n+#include \"cjoin.h\"\n//=========================== variables =======================================\n@@ -77,6 +78,7 @@ void idmanager_setIsDAGroot(bool newRole) {\nDISABLE_INTERRUPTS();\nidmanager_vars.isDAGroot = newRole;\nicmpv6rpl_updateMyDAGrankAndParentSelection();\n+ cjoin_setIsJoined(TRUE);\nschedule_startDAGroot();\nENABLE_INTERRUPTS();\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Set DAGroot to be joined by default.
491,609
10.11.2016 16:28:26
-3,600
9dfc9f5d0f77de825bea93bd3b333d3faa2feadb
Init isJoined directly.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -60,8 +60,7 @@ void cjoin_init() {\ncjoin_vars.desc.callbackRx = &cjoin_receive;\ncjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\ncjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1;\n-\n- cjoin_setIsJoined(FALSE);\n+ cjoin_vars.isJoined = FALSE;\nopencoap_register(&cjoin_vars.desc);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Init isJoined directly.
491,609
10.11.2016 17:57:28
-3,600
5f05ef978b16ecb5c874973e42c65972044e9c2d
Add missing global variables to python processing.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/python/openwsnmodule_obj.h", "new_path": "bsp/boards/python/openwsnmodule_obj.h", "diff": "// applications\n#include \"c6t_obj.h\"\n#include \"cexample_obj.h\"\n+#include \"cjoin_obj.h\"\n#include \"cinfo_obj.h\"\n#include \"cleds_obj.h\"\n#include \"cstorm_obj.h\"\n@@ -249,6 +250,7 @@ struct OpenMote {\ncwellknown_vars_t cwellknown_vars;\nrrt_vars_t rrt_vars;\n//tohlone_vars_t tohlone_vars;\n+ cjoin_vars_t cjoin_vars;\n};\n#endif\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -153,6 +153,7 @@ varsToChange = [\n'r6t_vars',\n'rinfo_vars',\n'rrt_vars',\n+ 'cjoin_vars',\n]\nreturnTypes = [\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add missing global variables to python processing.
491,609
10.11.2016 17:58:11
-3,600
4f3e26526be9de4de35abcec7dbc7210e3335503
Remove forcing isJoined to false.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -637,9 +637,6 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_RADIOTIMER_WIDTH capturedT\n// declare synchronized\nchangeIsSync(TRUE);\n- // force isJoined to FALSE\n- cjoin_setIsJoined(FALSE);\n-\n// log the info\nopenserial_printInfo(COMPONENT_IEEE802154E,ERR_SYNCHRONIZED,\n(errorparameter_t)ieee154e_vars.slotOffset,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Remove forcing isJoined to false.
491,609
11.11.2016 15:40:00
-3,600
fbc7f26d8cf13b61e9d9de543300682543a4de0b
Remove CoAP resource descriptor from the cjoin_vars struct.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -27,7 +27,7 @@ const uint8_t cjoin_path0[] = \"j\";\nstatic const uint8_t ipAddr_jce[] = {0xbb, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \\\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};\n-\n+coap_resource_desc_t desc;\n//=========================== variables =======================================\ncjoin_vars_t cjoin_vars;\n@@ -51,18 +51,18 @@ void cjoin_setIsJoined(bool newValue);\nvoid cjoin_init() {\n// prepare the resource descriptor for the /j path\n- cjoin_vars.desc.path0len = sizeof(cjoin_path0)-1;\n- cjoin_vars.desc.path0val = (uint8_t*)(&cjoin_path0);\n- cjoin_vars.desc.path1len = 0;\n- cjoin_vars.desc.path1val = NULL;\n- cjoin_vars.desc.componentID = COMPONENT_CJOIN;\n- cjoin_vars.desc.discoverable = TRUE;\n- cjoin_vars.desc.callbackRx = &cjoin_receive;\n- cjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\n+ desc.path0len = sizeof(cjoin_path0)-1;\n+ desc.path0val = (uint8_t*)(&cjoin_path0);\n+ desc.path1len = 0;\n+ desc.path1val = NULL;\n+ desc.componentID = COMPONENT_CJOIN;\n+ desc.discoverable = TRUE;\n+ desc.callbackRx = &cjoin_receive;\n+ desc.callbackSendDone = &cjoin_sendDone;\ncjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1;\ncjoin_vars.isJoined = FALSE;\n- opencoap_register(&cjoin_vars.desc);\n+ opencoap_register(&desc);\ncjoin_schedule();\n}\n@@ -211,7 +211,7 @@ owerror_t cjoin_sendPut(uint8_t payload) {\nCOAP_TYPE_NON,\nCOAP_CODE_REQ_PUT,\n1,\n- &cjoin_vars.desc\n+ &desc\n);\n// avoid overflowing the queue if fails\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "//=========================== typedef =========================================\ntypedef struct {\n- coap_resource_desc_t desc;\nopentimer_id_t startupTimerId;\nopentimer_id_t retransmissionTimerId;\nuint8_t lastPayload;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Remove CoAP resource descriptor from the cjoin_vars struct.
491,609
11.11.2016 16:02:06
-3,600
a177ce5f922890cb0e540eb8de6a99e8baa6b3e1
Retransmit lastPayload instead of resetting the whole process.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -124,7 +124,6 @@ void cjoin_retransmission_cb(opentimer_id_t id) {\n}\nvoid cjoin_retransmission_task_cb() {\n- cjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1; // get around the bug of starting with 1 after retransmit\ncjoin_sendPut(cjoin_vars.lastPayload);\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Retransmit lastPayload instead of resetting the whole process.
491,609
12.11.2016 16:42:36
-3,600
d5612a3695f64851ee5cd8748badce377028a13a
Add printDebug_joined function to print join ASN on the serial port.
[ { "change_type": "MODIFY", "old_path": "drivers/common/openserial.c", "new_path": "drivers/common/openserial.c", "diff": "#include \"icmpv6rpl.h\"\n#include \"icmpv6echo.h\"\n#include \"sf0.h\"\n+#include \"cjoin.h\"\n//=========================== variables =======================================\n@@ -369,6 +370,10 @@ void openserial_startOutput() {\nif (debugPrint_kaPeriod()==TRUE) {\nbreak;\n}\n+ case STATUS_JOINED:\n+ if (debugPrint_joined()==TRUE) {\n+ break;\n+ }\ndefault:\nDISABLE_INTERRUPTS();\nopenserial_vars.debugPrintCounter=0;\n" }, { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -107,8 +107,8 @@ enum {\nSTATUS_QUEUE = 8,\nSTATUS_NEIGHBORS = 9,\nSTATUS_KAPERIOD = 10,\n- STATUS_MAX = 11,\n- STATUS_ISJOINED = 12,\n+ STATUS_JOINED = 11,\n+ STATUS_MAX = 12,\n};\n//component identifiers\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -62,6 +62,8 @@ void cjoin_init() {\ncjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1;\ncjoin_vars.isJoined = FALSE;\n+ memset(&cjoin_vars.joinAsn, 0x00, sizeof(asn_t));\n+\nopencoap_register(&desc);\ncjoin_schedule();\n@@ -251,3 +253,20 @@ void cjoin_setIsJoined(bool newValue) {\n(errorparameter_t)0);\n}\n}\n+\n+/**\n+\\brief Trigger this module to print status information, over serial.\n+\n+debugPrint_* functions are used by the openserial module to continuously print\n+status information about several modules in the OpenWSN stack.\n+\n+\\returns TRUE if this function printed something, FALSE otherwise.\n+*/\n+bool debugPrint_joined() {\n+ asn_t output;\n+ output.byte4 = cjoin_vars.joinAsn.byte4;\n+ output.bytes2and3 = cjoin_vars.joinAsn.bytes2and3;\n+ output.bytes0and1 = cjoin_vars.joinAsn.bytes0and1;\n+ openserial_printStatus(STATUS_JOINED,(uint8_t*)&output,sizeof(output));\n+ return TRUE;\n+}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "\\{\n*/\n#include \"opencoap.h\"\n+#include \"opendefs.h\"\n//=========================== define ==========================================\n//=========================== typedef =========================================\n@@ -17,6 +18,7 @@ typedef struct {\nopentimer_id_t retransmissionTimerId;\nuint8_t lastPayload;\nbool isJoined;\n+ asn_t joinAsn;\n} cjoin_vars_t;\n//=========================== variables =======================================\n@@ -27,6 +29,7 @@ void cjoin_init(void);\nvoid cjoin_schedule(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n+bool debugPrint_joined(void);\n/**\n\\}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -857,6 +857,7 @@ functionsToChange = [\n'cjoin_retransmission_task_cb',\n'cjoin_getIsJoined',\n'cjoin_setIsJoined',\n+ 'debugPrint_joined',\n]\nheaderFiles = [\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add printDebug_joined function to print join ASN on the serial port.
491,609
13.11.2016 11:07:27
-3,600
6784222805a5f3aa4b42040c6ae03149b48a00bf
Update joinASN value upon successful join.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -239,11 +239,22 @@ bool cjoin_getIsJoined() {\n}\nvoid cjoin_setIsJoined(bool newValue) {\n+ uint8_t array[5];\nINTERRUPT_DECLARATION();\nDISABLE_INTERRUPTS();\ncjoin_vars.isJoined = newValue;\n+ // Update Join ASN value\n+ if (idmanager_getIsDAGroot() == FALSE) {\n+ ieee154e_getAsn(array);\n+ cjoin_vars.joinAsn.bytes0and1 = ((uint16_t) array[1] << 8) | ((uint16_t) array[0]);\n+ cjoin_vars.joinAsn.bytes2and3 = ((uint16_t) array[3] << 8) | ((uint16_t) array[2]);\n+ cjoin_vars.joinAsn.byte4 = array[4];\n+ } else {\n+ // Dag root resets the ASN value to zero\n+ memset(&cjoin_vars.joinAsn, 0x00, sizeof(asn_t));\n+ }\nENABLE_INTERRUPTS();\nif (newValue == TRUE) {\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Update joinASN value upon successful join.
491,609
13.11.2016 11:08:12
-3,600
77f7458926ee437a2108a3be84d1a819708ba026
If join duplicate is received, ignore it.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -95,7 +95,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\nopenserial_printError(COMPONENT_IEEE802154E,ERR_WDRADIO_OVERFLOWS,\n(errorparameter_t)0,\n(errorparameter_t)msg->payload[0]);\n-\n+ if (cjoin_getIsJoined() == FALSE) {\nif (msg->payload[0] == 0) {\ncjoin_setIsJoined(TRUE); // declare join is over\nieee154e_getAsn(asn);\n@@ -110,6 +110,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\n(errorparameter_t)0,\n(errorparameter_t)0);\n}\n+ }\nreturn E_SUCCESS;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. If join duplicate is received, ignore it.
491,609
11.04.2017 18:36:17
-7,200
165d2fa815186f67b328950badfd22618a261875
Send GET instead of PUT as part of the Join Request.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -41,7 +41,7 @@ void cjoin_timer_cb(opentimer_id_t id);\nvoid cjoin_task_cb(void);\nvoid cjoin_sendDone(OpenQueueEntry_t* msg,\nowerror_t error);\n-owerror_t cjoin_sendPut(uint8_t payload);\n+owerror_t cjoin_sendJoinRequest(void);\nvoid cjoin_retransmission_cb(opentimer_id_t id);\nvoid cjoin_retransmission_task_cb(void);\nbool cjoin_getIsJoined(void);\n@@ -59,7 +59,6 @@ void cjoin_init() {\ndesc.discoverable = TRUE;\ndesc.callbackRx = &cjoin_receive;\ndesc.callbackSendDone = &cjoin_sendDone;\n- cjoin_vars.lastPayload = NUMBER_OF_EXCHANGES - 1;\ncjoin_vars.isJoined = FALSE;\nmemset(&cjoin_vars.joinAsn, 0x00, sizeof(asn_t));\n@@ -92,23 +91,9 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\nopentimers_stop(cjoin_vars.retransmissionTimerId); // stop the timer\n- openserial_printError(COMPONENT_IEEE802154E,ERR_WDRADIO_OVERFLOWS,\n- (errorparameter_t)0,\n- (errorparameter_t)msg->payload[0]);\n+ if (coap_header->Code == COAP_CODE_RESP_CONTENT) {\nif (cjoin_getIsJoined() == FALSE) {\n- if (msg->payload[0] == 0) {\ncjoin_setIsJoined(TRUE); // declare join is over\n- ieee154e_getAsn(asn);\n- asnCropped = ((uint32_t) asn[3] << 24) | ((uint32_t) asn[2] << 16) | ((uint32_t) asn[1] << 8) | ((uint32_t) asn[0]);\n- printf(\"JOIN ASN: %u\\n\", asnCropped);\n- }\n- else if (msg->payload[0] == cjoin_vars.lastPayload - 1) {\n- cjoin_sendPut(msg->payload[0] - 1);\n- }\n- else {\n- openserial_printError(COMPONENT_IEEE802154E,ERR_WDDATADURATION_OVERFLOWS,\n- (errorparameter_t)0,\n- (errorparameter_t)0);\n}\n}\n@@ -127,7 +112,7 @@ void cjoin_retransmission_cb(opentimer_id_t id) {\n}\nvoid cjoin_retransmission_task_cb() {\n- cjoin_sendPut(cjoin_vars.lastPayload);\n+ cjoin_sendJoinRequest();\n}\nvoid cjoin_task_cb() {\n@@ -151,7 +136,7 @@ void cjoin_task_cb() {\n}\nopentimers_stop(cjoin_vars.startupTimerId);\n- cjoin_sendPut(NUMBER_OF_EXCHANGES-1);\n+ cjoin_sendJoinRequest();\nreturn;\n}\n@@ -160,15 +145,15 @@ void cjoin_sendDone(OpenQueueEntry_t* msg, owerror_t error) {\nopenqueue_freePacketBuffer(msg);\n}\n-owerror_t cjoin_sendPut(uint8_t payload) {\n+owerror_t cjoin_sendJoinRequest(void) {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\n- cjoin_vars.lastPayload = payload;\n+ // immediately arm the retransmission timer\n+ cjoin_vars.retransmissionTimerId = opentimers_start((uint32_t) TIMEOUT,\n+ TIMER_ONESHOT,TIME_MS,\n+ cjoin_retransmission_cb);\n- openserial_printError(COMPONENT_IEEE802154E,ERR_MAXRXACKPREPARE_OVERFLOWS,\n- (errorparameter_t)0,\n- (errorparameter_t)payload);\n// create a CoAP RD packet\npkt = openqueue_getFreePacketBuffer(COMPONENT_CJOIN);\nif (pkt==NULL) {\n@@ -184,18 +169,7 @@ owerror_t cjoin_sendPut(uint8_t payload) {\n// take ownership over that packet\npkt->creator = COMPONENT_CJOIN;\npkt->owner = COMPONENT_CJOIN;\n- // CoAP payload\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = payload;\n-\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = COAP_PAYLOAD_MARKER;\n- // content-type option\n- packetfunctions_reserveHeaderSize(pkt,2);\n- pkt->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT - COAP_OPTION_NUM_URIPATH) << 4\n- | 1;\n- pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n// location-path option\npacketfunctions_reserveHeaderSize(pkt,sizeof(cjoin_path0)-1);\nmemcpy(&pkt->payload[0],cjoin_path0,sizeof(cjoin_path0)-1);\n@@ -210,8 +184,8 @@ owerror_t cjoin_sendPut(uint8_t payload) {\n// send\noutcome = opencoap_send(\npkt,\n- COAP_TYPE_NON,\n- COAP_CODE_REQ_PUT,\n+ COAP_TYPE_CON,\n+ COAP_CODE_REQ_GET,\n1,\n&desc\n);\n@@ -222,9 +196,6 @@ owerror_t cjoin_sendPut(uint8_t payload) {\nreturn E_FAIL;\n}\n- cjoin_vars.retransmissionTimerId = opentimers_start((uint32_t) TIMEOUT,\n- TIMER_ONESHOT,TIME_MS,\n- cjoin_retransmission_cb);\nreturn E_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "typedef struct {\nopentimer_id_t startupTimerId;\nopentimer_id_t retransmissionTimerId;\n- uint8_t lastPayload;\nbool isJoined;\nasn_t joinAsn;\n} cjoin_vars_t;\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -852,7 +852,7 @@ functionsToChange = [\n'cjoin_timer_cb',\n'cjoin_task_cb',\n'cjoin_sendDone',\n- 'cjoin_sendPut',\n+ 'cjoin_sendJoinRequest',\n'cjoin_retransmission_cb',\n'cjoin_retransmission_task_cb',\n'cjoin_getIsJoined',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Send GET instead of PUT as part of the Join Request.
491,609
13.04.2017 18:19:33
-7,200
1774ccfe27636e022264ecf02b88702c1dae38b7
Add placeholders for CBOR minimal parsing.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -46,6 +46,11 @@ void cjoin_retransmission_cb(opentimer_id_t id);\nvoid cjoin_retransmission_task_cb(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n+\n+owerror_t cjoin_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t);\n+owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t);\n+\n//=========================== public ==========================================\nvoid cjoin_init() {\n@@ -80,21 +85,39 @@ void cjoin_schedule() {\n}\n//=========================== private =========================================\n-\nowerror_t cjoin_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\ncoap_option_iht* coap_options) {\n-\n- uint8_t asn[5];\n- uint32_t asnCropped;\n-\n+ uint8_t i;\n+ join_response_t join_response;\n+ COSE_keyset_t keyset;\n+ short_address_t short_address;\nopentimers_stop(cjoin_vars.retransmissionTimerId); // stop the timer\nif (coap_header->Code == COAP_CODE_RESP_CONTENT) {\n- if (cjoin_getIsJoined() == FALSE) {\n+ // loop through the options and look for content format\n+ i = 0;\n+ while(coap_options[i].type != COAP_OPTION_NONE) {\n+ if (coap_options[i].type == COAP_OPTION_NUM_CONTENTFORMAT) {\n+ if (*(coap_options[i].pValue) == COAP_MEDTYPE_APPCBOR) {\n+ // parse join response\n+ printf_hex(msg->payload,msg->length);\n+ cjoin_parse_join_response(&join_response, msg->payload,\n+ msg->length);\n+ cjoin_parse_keyset(&keyset, join_response.COSE_keyset,\n+ join_response.COSE_keyset_len);\n+\n+ cjoin_parse_short_address(&short_address, join_response.short_address,\n+ join_response.short_address_len);\n+\n+ // set the internal keys as per the parsed values\ncjoin_setIsJoined(TRUE); // declare join is over\n}\n+ break;\n+ }\n+ i++;\n+ }\n}\nreturn E_SUCCESS;\n@@ -215,6 +238,11 @@ void cjoin_setIsJoined(bool newValue) {\nINTERRUPT_DECLARATION();\nDISABLE_INTERRUPTS();\n+ if (cjoin_vars.isJoined == newValue) {\n+ ENABLE_INTERRUPTS();\n+ return;\n+ }\n+\ncjoin_vars.isJoined = newValue;\n// Update Join ASN value\n@@ -253,3 +281,45 @@ bool debugPrint_joined() {\nopenserial_printStatus(STATUS_JOINED,(uint8_t*)&output,sizeof(output));\nreturn TRUE;\n}\n+\n+/**\n+\\brief Parse the received join response.\n+\n+This function expects the join response structure from minimal-security-02 draft.\n+\n+\\param[out] response The join_response_t structure containing parsed info.\n+\\param[in] buf The received join response.\n+\\param[in] len Length of the payload.\n+*/\n+owerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Parse the received COSE_Keyset.\n+\n+The function expects COSE_Keyset with symmetric keys as per minimal-security-02 draft\n+and parses it into COSE_symmetric_key_t structure.\n+\n+\\param[out] keyset The COSE_keyset_t structure containing parsed keys.\n+\\param[in] buf Input buffer.\n+\\param[in] len Length.\n+*/\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t len) {\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Parse the received short address.\n+\n+The function expects short_address as per minimal-security-02 draft\n+and parses it into short_address_t structure.\n+\n+\\param[out] address The short_address_t structure containing parsed short_address and lease time.\n+\\param[in] buf Input buffer.\n+\\param[in] len Length.\n+*/\n+owerror_t cjoin_parse_short_address(short_address_t *address, uint8_t *buf, uint8_t len) {\n+ return E_SUCCESS;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "\\addtogroup cjoin\n\\{\n*/\n-#include \"opencoap.h\"\n#include \"opendefs.h\"\n//=========================== define ==========================================\n-\n+// number of bytes in 802.15.4 short address\n+#define CJOIN_SHORT_ADDRESS_LENGTH 2\n+// max number of keys supported in COSE_KeySet\n+#define CJOIN_MAX_NUM_KEYS 2\n+// max supported number of bytes in key id field of COSE_Key\n+#define CJOIN_MAX_KEYID_LENGTH 2\n//=========================== typedef =========================================\n+typedef struct {\n+ uint8_t* address;\n+ asn_t lease_asn;\n+} short_address_t;\n+\n+typedef struct {\n+ uint8_t kty;\n+ uint8_t* kid;\n+ uint8_t kid_len;\n+ uint8_t* k;\n+ uint8_t k_len;\n+} COSE_symmetric_key_t;\n+\n+typedef struct {\n+ COSE_symmetric_key_t key[CJOIN_MAX_NUM_KEYS];\n+} COSE_keyset_t;\n+\n+typedef struct {\n+ uint8_t* COSE_keyset;\n+ uint8_t COSE_keyset_len;\n+ uint8_t* short_address;\n+ uint8_t short_address_len;\n+} join_response_t;\n+\ntypedef struct {\nopentimer_id_t startupTimerId;\nopentimer_id_t retransmissionTimerId;\n" }, { "change_type": "MODIFY", "old_path": "openstack/04-TRAN/opencoap.h", "new_path": "openstack/04-TRAN/opencoap.h", "diff": "@@ -102,6 +102,7 @@ typedef enum {\nCOAP_MEDTYPE_APPOCTETSTREAM = 42,\nCOAP_MEDTYPE_APPEXI = 47,\nCOAP_MEDTYPE_APPJSON = 50,\n+ COAP_MEDTYPE_APPCBOR = 60,\n} coap_media_type_t;\n//=========================== typedef =========================================\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add placeholders for CBOR minimal parsing.
491,609
19.04.2017 14:35:29
-7,200
daec167d8ad5d371cf7f48f78a1a948bc07be9c1
Add initial implementation of CBOR parser for minimal security.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "/// inter-packet period (in ms)\n#define NUMBER_OF_EXCHANGES 6\n#define TIMEOUT 60000\n+#define ASN_LENGTH 5\nconst uint8_t cjoin_path0[] = \"j\";\n@@ -48,8 +49,9 @@ bool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\nowerror_t cjoin_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t);\n-owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t);\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t *);\n+owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t *);\n+owerror_t cjoin_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n//=========================== public ==========================================\n@@ -90,35 +92,28 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\ncoap_option_iht* coap_options) {\nuint8_t i;\njoin_response_t join_response;\n- COSE_keyset_t keyset;\n- short_address_t short_address;\n+ owerror_t ret;\nopentimers_stop(cjoin_vars.retransmissionTimerId); // stop the timer\n- if (coap_header->Code == COAP_CODE_RESP_CONTENT) {\n+ if (coap_header->Code != COAP_CODE_RESP_CONTENT) {\n+ return E_FAIL;\n+ }\n+\n// loop through the options and look for content format\ni = 0;\nwhile(coap_options[i].type != COAP_OPTION_NONE) {\n- if (coap_options[i].type == COAP_OPTION_NUM_CONTENTFORMAT) {\n- if (*(coap_options[i].pValue) == COAP_MEDTYPE_APPCBOR) {\n- // parse join response\n- printf_hex(msg->payload,msg->length);\n- cjoin_parse_join_response(&join_response, msg->payload,\n- msg->length);\n- cjoin_parse_keyset(&keyset, join_response.COSE_keyset,\n- join_response.COSE_keyset_len);\n-\n- cjoin_parse_short_address(&short_address, join_response.short_address,\n- join_response.short_address_len);\n+ if (coap_options[i].type == COAP_OPTION_NUM_CONTENTFORMAT &&\n+ *(coap_options[i].pValue) == COAP_MEDTYPE_APPCBOR) {\n+ ret = cjoin_parse_join_response(&join_response, msg->payload, msg->length);\n+ if (ret == E_FAIL) { return E_FAIL; }\n// set the internal keys as per the parsed values\ncjoin_setIsJoined(TRUE); // declare join is over\n- }\nbreak;\n}\ni++;\n}\n- }\nreturn E_SUCCESS;\n}\n@@ -292,6 +287,44 @@ This function expects the join response structure from minimal-security-02 draft\n\\param[in] len Length of the payload.\n*/\nowerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t ret;\n+ uint8_t *tmp;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > 2 || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ if (cjoin_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+\n+ tmp += ret;\n+\n+ if (additional_info == 2) { // short address present\n+ if (cjoin_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+ tmp += ret;\n+ }\n+\n+ if ( (uint8_t)(tmp - buf) != len) { // final check that everything has been parsed\n+ memset(response, 0x00, sizeof(join_response_t)); // invalidate join response\n+ return E_FAIL;\n+ }\n+\nreturn E_SUCCESS;\n}\n@@ -303,9 +336,119 @@ and parses it into COSE_symmetric_key_t structure.\n\\param[out] keyset The COSE_keyset_t structure containing parsed keys.\n\\param[in] buf Input buffer.\n-\\param[in] len Length.\n+\\param[out] len Processed length.\n+*/\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t i;\n+ uint8_t ret;\n+ uint8_t *tmp;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > CJOIN_MAX_NUM_KEYS || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ for(i = 0; i < additional_info; i++) {\n+ // parse symmetric key map\n+ if (cjoin_parse_key(&keyset->key[i], tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+ tmp += ret;\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Parse a COSE symmetric key.\n+\n+The function expects COSE symmetric key as per minimal-security-02 draft\n+and parses it into COSE_symmetric_key_t structure.\n+\n+\\param[out] key The COSE_symmetric_ket_t structure containing parsed key.\n+\\param[in] buf Input buffer.\n+\\param[out] len Processed length.\n*/\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t len) {\n+owerror_t cjoin_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t i;\n+ uint8_t *tmp;\n+ uint8_t l;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_MAP) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > COSE_SYMKEY_MAXNUMPAIRS || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ for (i = 0; i < additional_info; i++) {\n+ switch((cose_key_label_t) *tmp) {\n+ case COSE_KEY_LABEL_KTY:\n+ tmp++;\n+ key->kty = (cose_key_value_t) *tmp;\n+ tmp++;\n+ break;\n+ case COSE_KEY_LABEL_ALG: // step by key alg\n+ tmp++;\n+ tmp++;\n+ break;\n+ case COSE_KEY_LABEL_KID:\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ key->kid = tmp;\n+ key->kid_len = l;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_K:\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ key->k = tmp;\n+ key->k_len = l;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_BASEIV: // step by base iv\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_KEYOPS: // step by key ops\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ tmp += l;\n+ break;\n+ default:\n+ return E_FAIL;\n+ }\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\nreturn E_SUCCESS;\n}\n@@ -317,9 +460,54 @@ and parses it into short_address_t structure.\n\\param[out] address The short_address_t structure containing parsed short_address and lease time.\n\\param[in] buf Input buffer.\n-\\param[in] len Length.\n+\\param[out] len Processed length.\n*/\n-owerror_t cjoin_parse_short_address(short_address_t *address, uint8_t *buf, uint8_t len) {\n+owerror_t cjoin_parse_short_address(short_address_t *short_address, uint8_t *buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t *tmp;\n+ uint8_t l;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > 2 || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+\n+ if (l != CJOIN_SHORT_ADDRESS_LENGTH) {\n+ return E_FAIL;\n+ }\n+\n+ tmp++;\n+ short_address->address = tmp;\n+\n+ tmp += l;\n+\n+ if (additional_info == 2) { // lease time present\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ if (l != ASN_LENGTH) { // 5 byte ASN expected\n+ return E_FAIL;\n+ }\n+ tmp++;\n+\n+ (short_address->lease_asn).bytes0and1 = ((uint16_t) tmp[1] << 8) | ((uint16_t) tmp[0]);\n+ (short_address->lease_asn).bytes2and3 = ((uint16_t) tmp[3] << 8) | ((uint16_t) tmp[2]);\n+ (short_address->lease_asn).byte4 = tmp[4];\n+\n+ tmp += ASN_LENGTH;\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\nreturn E_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "#define CJOIN_MAX_NUM_KEYS 2\n// max supported number of bytes in key id field of COSE_Key\n#define CJOIN_MAX_KEYID_LENGTH 2\n+\n+\n+// CBOR additional info mask\n+#define CBOR_ADDINFO_MASK 0x1F\n+\n+// max number of pairs in COSE symmetric key struct\n+#define COSE_SYMKEY_MAXNUMPAIRS 6\n+\n+// CBOR major types\n+typedef enum {\n+ CBOR_MAJORTYPE_UINT = 0,\n+ CBOR_MAJORTYPE_NINT = 1,\n+ CBOR_MAJORTYPE_BSTR = 2,\n+ CBOR_MAJORTYPE_TSTR = 3,\n+ CBOR_MAJORTYPE_ARRAY = 4,\n+ CBOR_MAJORTYPE_MAP = 5,\n+} cbor_majortype_t;\n+\n+// COSE key map labels\n+typedef enum {\n+ COSE_KEY_LABEL_KTY = 1,\n+ COSE_KEY_LABEL_KID = 2,\n+ COSE_KEY_LABEL_ALG = 3,\n+ COSE_KEY_LABEL_KEYOPS = 4,\n+ COSE_KEY_LABEL_BASEIV = 5,\n+ COSE_KEY_LABEL_K = 32, // -1\n+} cose_key_label_t;\n+\n+// COSE key type values\n+typedef enum {\n+ COSE_KEY_VALUE_OKP = 1,\n+ COSE_KEY_VALUE_EC2 = 2,\n+ COSE_KEY_VALUE_SYMMETRIC = 4,\n+} cose_key_value_t;\n+\n//=========================== typedef =========================================\ntypedef struct {\n@@ -23,7 +58,7 @@ typedef struct {\n} short_address_t;\ntypedef struct {\n- uint8_t kty;\n+ cose_key_value_t kty;\nuint8_t* kid;\nuint8_t kid_len;\nuint8_t* k;\n@@ -35,10 +70,8 @@ typedef struct {\n} COSE_keyset_t;\ntypedef struct {\n- uint8_t* COSE_keyset;\n- uint8_t COSE_keyset_len;\n- uint8_t* short_address;\n- uint8_t short_address_len;\n+ COSE_keyset_t keyset;\n+ short_address_t short_address;\n} join_response_t;\ntypedef struct {\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add initial implementation of CBOR parser for minimal security.
491,609
20.04.2017 17:01:52
-7,200
c413f0ab96a534dfb7cb964173dbb06a54278512
Refactor CBOR code into cbor.[ch] files.
[ { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -37,6 +37,18 @@ defaultAppsInit = [\n'cjoin',\n]\n+# source files that should be included in the build other than\n+# those with default application name (application.c)\n+additionalSourceFiles = [\n+ 'cjoin/cbor.c'\n+]\n+\n+# header files that should be included in the build other than\n+# those with default application name (application.h)\n+additionalHeaderFiles = [\n+ 'cjoin/cbor.h'\n+]\n+\n# additional apps the user wants to build\nif localEnv['apps']:\nuserApps = localEnv['apps'].split(',')\n@@ -105,6 +117,9 @@ for a in apps:\nsources_c += [os.path.join(a,a+'.c')]\nsources_h += [os.path.join(a,a+'.h')]\n+sources_c += additionalSourceFiles\n+sources_h += additionalHeaderFiles\n+\n#===== build the openapps library\nif localEnv['board']=='python':\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openapps/cjoin/cbor.c", "diff": "+/*e\n+\\brief A minimal CBOR parser implementation of draft-6tisch-minimal-security-02.\n+*/\n+#include \"cbor.h\"\n+//=========================== defines =========================================\n+// number of bytes in 802.15.4 short address\n+#define SHORT_ADDRESS_LENGTH 2\n+#define ASN_LENGTH 5\n+//=========================== variables =======================================\n+\n+//=========================== prototypes ======================================\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t *);\n+owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t *);\n+owerror_t cjoin_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n+\n+\n+//=========================== public ==========================================\n+\n+/**\n+\\brief Parse the received join response.\n+\n+This function expects the join response structure from minimal-security-02 draft.\n+\n+\\param[out] response The join_response_t structure containing parsed info.\n+\\param[in] buf The received join response.\n+\\param[in] len Length of the payload.\n+*/\n+owerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t ret;\n+ uint8_t *tmp;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > 2 || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ if (cjoin_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+\n+ tmp += ret;\n+\n+ if (additional_info == 2) { // short address present\n+ if (cjoin_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+ tmp += ret;\n+ }\n+\n+ if ( (uint8_t)(tmp - buf) != len) { // final check that everything has been parsed\n+ memset(response, 0x00, sizeof(join_response_t)); // invalidate join response\n+ return E_FAIL;\n+ }\n+\n+ return E_SUCCESS;\n+}\n+\n+\n+//=========================== private =========================================\n+\n+/**\n+\\brief Parse the received COSE_Keyset.\n+\n+The function expects COSE_Keyset with symmetric keys as per minimal-security-02 draft\n+and parses it into COSE_symmetric_key_t structure.\n+\n+\\param[out] keyset The COSE_keyset_t structure containing parsed keys.\n+\\param[in] buf Input buffer.\n+\\param[out] len Processed length.\n+*/\n+owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t i;\n+ uint8_t ret;\n+ uint8_t *tmp;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > COSE_KEYSET_MAX_NUM_KEYS || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ for(i = 0; i < additional_info; i++) {\n+ // parse symmetric key map\n+ if (cjoin_parse_key(&keyset->key[i], tmp, &ret) == E_FAIL) {\n+ return E_FAIL;\n+ }\n+ tmp += ret;\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Parse a COSE symmetric key.\n+\n+The function expects COSE symmetric key as per minimal-security-02 draft\n+and parses it into COSE_symmetric_key_t structure.\n+\n+\\param[out] key The COSE_symmetric_ket_t structure containing parsed key.\n+\\param[in] buf Input buffer.\n+\\param[out] len Processed length.\n+*/\n+owerror_t cjoin_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t i;\n+ uint8_t *tmp;\n+ uint8_t l;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_MAP) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > COSE_SYMKEY_MAXNUMPAIRS || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+\n+ for (i = 0; i < additional_info; i++) {\n+ switch((cose_key_label_t) *tmp) {\n+ case COSE_KEY_LABEL_KTY:\n+ tmp++;\n+ key->kty = (cose_key_value_t) *tmp;\n+ tmp++;\n+ break;\n+ case COSE_KEY_LABEL_ALG: // step by key alg\n+ tmp++;\n+ tmp++;\n+ break;\n+ case COSE_KEY_LABEL_KID:\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ key->kid = tmp;\n+ key->kid_len = l;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_K:\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ key->k = tmp;\n+ key->k_len = l;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_BASEIV: // step by base iv\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ tmp += l;\n+ break;\n+ case COSE_KEY_LABEL_KEYOPS: // step by key ops\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ tmp++;\n+ tmp += l;\n+ break;\n+ default:\n+ return E_FAIL;\n+ }\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Parse the received short address.\n+\n+The function expects short_address as per minimal-security-02 draft\n+and parses it into short_address_t structure.\n+\n+\\param[out] address The short_address_t structure containing parsed short_address and lease time.\n+\\param[in] buf Input buffer.\n+\\param[out] len Processed length.\n+*/\n+owerror_t cjoin_parse_short_address(short_address_t *short_address, uint8_t *buf, uint8_t* len) {\n+\n+ cbor_majortype_t major_type;\n+ uint8_t additional_info;\n+ uint8_t *tmp;\n+ uint8_t l;\n+\n+ tmp = buf;\n+ major_type = (cbor_majortype_t) *buf >> 5;\n+ additional_info = *buf & CBOR_ADDINFO_MASK;\n+\n+ if (major_type != CBOR_MAJORTYPE_ARRAY) {\n+ return E_FAIL;\n+ }\n+\n+ if (additional_info > 2 || additional_info == 0) {\n+ return E_FAIL; // unsupported join response structure\n+ }\n+\n+ tmp++;\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+\n+ if (l != SHORT_ADDRESS_LENGTH) {\n+ return E_FAIL;\n+ }\n+\n+ tmp++;\n+ short_address->address = tmp;\n+\n+ tmp += l;\n+\n+ if (additional_info == 2) { // lease time present\n+ l = *tmp & CBOR_ADDINFO_MASK;\n+ if (l != ASN_LENGTH) { // 5 byte ASN expected\n+ return E_FAIL;\n+ }\n+ tmp++;\n+\n+ (short_address->lease_asn).bytes0and1 = ((uint16_t) tmp[1] << 8) | ((uint16_t) tmp[0]);\n+ (short_address->lease_asn).bytes2and3 = ((uint16_t) tmp[3] << 8) | ((uint16_t) tmp[2]);\n+ (short_address->lease_asn).byte4 = tmp[4];\n+\n+ tmp += ASN_LENGTH;\n+ }\n+\n+ *len = (uint8_t) (tmp - buf);\n+ return E_SUCCESS;\n+}\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openapps/cjoin/cbor.h", "diff": "+#ifndef __CBOR_H\n+#define __CBOR_H\n+\n+/**\n+\\addtogroup AppUdp\n+\\{\n+\\addtogroup cjoin\n+\\{\n+*/\n+#include \"opendefs.h\"\n+//=========================== define ==========================================\n+\n+// max number of keys supported in COSE_KeySet\n+#define COSE_KEYSET_MAX_NUM_KEYS 2\n+// CBOR additional info mask\n+#define CBOR_ADDINFO_MASK 0x1F\n+// max number of pairs in COSE symmetric key struct\n+#define COSE_SYMKEY_MAXNUMPAIRS 6\n+\n+//=========================== typedef =========================================\n+\n+// CBOR major types\n+typedef enum {\n+ CBOR_MAJORTYPE_UINT = 0,\n+ CBOR_MAJORTYPE_NINT = 1,\n+ CBOR_MAJORTYPE_BSTR = 2,\n+ CBOR_MAJORTYPE_TSTR = 3,\n+ CBOR_MAJORTYPE_ARRAY = 4,\n+ CBOR_MAJORTYPE_MAP = 5,\n+} cbor_majortype_t;\n+\n+// COSE key map labels\n+typedef enum {\n+ COSE_KEY_LABEL_KTY = 1,\n+ COSE_KEY_LABEL_KID = 2,\n+ COSE_KEY_LABEL_ALG = 3,\n+ COSE_KEY_LABEL_KEYOPS = 4,\n+ COSE_KEY_LABEL_BASEIV = 5,\n+ COSE_KEY_LABEL_K = 32, // -1\n+} cose_key_label_t;\n+\n+// COSE key type values\n+typedef enum {\n+ COSE_KEY_VALUE_OKP = 1,\n+ COSE_KEY_VALUE_EC2 = 2,\n+ COSE_KEY_VALUE_SYMMETRIC = 4,\n+} cose_key_value_t;\n+\n+typedef struct {\n+ uint8_t* address;\n+ asn_t lease_asn;\n+} short_address_t;\n+\n+typedef struct {\n+ cose_key_value_t kty;\n+ uint8_t* kid;\n+ uint8_t kid_len;\n+ uint8_t* k;\n+ uint8_t k_len;\n+} COSE_symmetric_key_t;\n+\n+typedef struct {\n+ COSE_symmetric_key_t key[COSE_KEYSET_MAX_NUM_KEYS];\n+} COSE_keyset_t;\n+\n+typedef struct {\n+ COSE_keyset_t keyset;\n+ short_address_t short_address;\n+} join_response_t;\n+\n+\n+//=========================== variables =======================================\n+\n+//=========================== prototypes ======================================\n+\n+owerror_t cjoin_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n+\n+/**\n+\\}\n+\\}\n+*/\n+\n+#endif\n+\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "/**\n-\\brief An example CoAP application.\n+\\brief CoAP application implementing Simple Join Protocol from minimal-security-02 draft.\n*/\n#include \"opendefs.h\"\n#include \"openserial.h\"\n#include \"openrandom.h\"\n#include \"scheduler.h\"\n-//#include \"ADC_Channel.h\"\n#include \"idmanager.h\"\n#include \"IEEE802154E.h\"\n#include \"icmpv6rpl.h\"\n+#include \"cbor.h\"\n//=========================== defines =========================================\n/// inter-packet period (in ms)\n#define NUMBER_OF_EXCHANGES 6\n#define TIMEOUT 60000\n-#define ASN_LENGTH 5\nconst uint8_t cjoin_path0[] = \"j\";\n@@ -47,12 +46,6 @@ void cjoin_retransmission_cb(opentimer_id_t id);\nvoid cjoin_retransmission_task_cb(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n-\n-owerror_t cjoin_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t *);\n-owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t *);\n-owerror_t cjoin_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n-\n//=========================== public ==========================================\nvoid cjoin_init() {\n@@ -277,237 +270,4 @@ bool debugPrint_joined() {\nreturn TRUE;\n}\n-/**\n-\\brief Parse the received join response.\n-\n-This function expects the join response structure from minimal-security-02 draft.\n-\n-\\param[out] response The join_response_t structure containing parsed info.\n-\\param[in] buf The received join response.\n-\\param[in] len Length of the payload.\n-*/\n-owerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\n-\n- cbor_majortype_t major_type;\n- uint8_t additional_info;\n- uint8_t ret;\n- uint8_t *tmp;\n-\n- tmp = buf;\n- major_type = (cbor_majortype_t) *buf >> 5;\n- additional_info = *buf & CBOR_ADDINFO_MASK;\n-\n- if (major_type != CBOR_MAJORTYPE_ARRAY) {\n- return E_FAIL;\n- }\n-\n- if (additional_info > 2 || additional_info == 0) {\n- return E_FAIL; // unsupported join response structure\n- }\n-\n- tmp++;\n-\n- if (cjoin_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\n- return E_FAIL;\n- }\n-\n- tmp += ret;\n-\n- if (additional_info == 2) { // short address present\n- if (cjoin_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\n- return E_FAIL;\n- }\n- tmp += ret;\n- }\n-\n- if ( (uint8_t)(tmp - buf) != len) { // final check that everything has been parsed\n- memset(response, 0x00, sizeof(join_response_t)); // invalidate join response\n- return E_FAIL;\n- }\n-\n- return E_SUCCESS;\n-}\n-\n-/**\n-\\brief Parse the received COSE_Keyset.\n-\n-The function expects COSE_Keyset with symmetric keys as per minimal-security-02 draft\n-and parses it into COSE_symmetric_key_t structure.\n-\n-\\param[out] keyset The COSE_keyset_t structure containing parsed keys.\n-\\param[in] buf Input buffer.\n-\\param[out] len Processed length.\n-*/\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len) {\n-\n- cbor_majortype_t major_type;\n- uint8_t additional_info;\n- uint8_t i;\n- uint8_t ret;\n- uint8_t *tmp;\n-\n- tmp = buf;\n- major_type = (cbor_majortype_t) *buf >> 5;\n- additional_info = *buf & CBOR_ADDINFO_MASK;\n-\n- if (major_type != CBOR_MAJORTYPE_ARRAY) {\n- return E_FAIL;\n- }\n-\n- if (additional_info > CJOIN_MAX_NUM_KEYS || additional_info == 0) {\n- return E_FAIL; // unsupported join response structure\n- }\n-\n- tmp++;\n-\n- for(i = 0; i < additional_info; i++) {\n- // parse symmetric key map\n- if (cjoin_parse_key(&keyset->key[i], tmp, &ret) == E_FAIL) {\n- return E_FAIL;\n- }\n- tmp += ret;\n- }\n-\n- *len = (uint8_t) (tmp - buf);\n- return E_SUCCESS;\n-}\n-\n-/**\n-\\brief Parse a COSE symmetric key.\n-\n-The function expects COSE symmetric key as per minimal-security-02 draft\n-and parses it into COSE_symmetric_key_t structure.\n-\n-\\param[out] key The COSE_symmetric_ket_t structure containing parsed key.\n-\\param[in] buf Input buffer.\n-\\param[out] len Processed length.\n-*/\n-owerror_t cjoin_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len) {\n-\n- cbor_majortype_t major_type;\n- uint8_t additional_info;\n- uint8_t i;\n- uint8_t *tmp;\n- uint8_t l;\n-\n- tmp = buf;\n- major_type = (cbor_majortype_t) *buf >> 5;\n- additional_info = *buf & CBOR_ADDINFO_MASK;\n-\n- if (major_type != CBOR_MAJORTYPE_MAP) {\n- return E_FAIL;\n- }\n-\n- if (additional_info > COSE_SYMKEY_MAXNUMPAIRS || additional_info == 0) {\n- return E_FAIL; // unsupported join response structure\n- }\n-\n- tmp++;\n-\n- for (i = 0; i < additional_info; i++) {\n- switch((cose_key_label_t) *tmp) {\n- case COSE_KEY_LABEL_KTY:\n- tmp++;\n- key->kty = (cose_key_value_t) *tmp;\n- tmp++;\n- break;\n- case COSE_KEY_LABEL_ALG: // step by key alg\n- tmp++;\n- tmp++;\n- break;\n- case COSE_KEY_LABEL_KID:\n- tmp++;\n- l = *tmp & CBOR_ADDINFO_MASK;\n- tmp++;\n- key->kid = tmp;\n- key->kid_len = l;\n- tmp += l;\n- break;\n- case COSE_KEY_LABEL_K:\n- tmp++;\n- l = *tmp & CBOR_ADDINFO_MASK;\n- tmp++;\n- key->k = tmp;\n- key->k_len = l;\n- tmp += l;\n- break;\n- case COSE_KEY_LABEL_BASEIV: // step by base iv\n- tmp++;\n- l = *tmp & CBOR_ADDINFO_MASK;\n- tmp++;\n- tmp += l;\n- break;\n- case COSE_KEY_LABEL_KEYOPS: // step by key ops\n- tmp++;\n- l = *tmp & CBOR_ADDINFO_MASK;\n- tmp++;\n- tmp += l;\n- break;\n- default:\n- return E_FAIL;\n- }\n- }\n-\n- *len = (uint8_t) (tmp - buf);\n- return E_SUCCESS;\n-}\n-\n-/**\n-\\brief Parse the received short address.\n-\n-The function expects short_address as per minimal-security-02 draft\n-and parses it into short_address_t structure.\n-\n-\\param[out] address The short_address_t structure containing parsed short_address and lease time.\n-\\param[in] buf Input buffer.\n-\\param[out] len Processed length.\n-*/\n-owerror_t cjoin_parse_short_address(short_address_t *short_address, uint8_t *buf, uint8_t* len) {\n-\n- cbor_majortype_t major_type;\n- uint8_t additional_info;\n- uint8_t *tmp;\n- uint8_t l;\n-\n- tmp = buf;\n- major_type = (cbor_majortype_t) *buf >> 5;\n- additional_info = *buf & CBOR_ADDINFO_MASK;\n-\n- if (major_type != CBOR_MAJORTYPE_ARRAY) {\n- return E_FAIL;\n- }\n-\n- if (additional_info > 2 || additional_info == 0) {\n- return E_FAIL; // unsupported join response structure\n- }\n-\n- tmp++;\n- l = *tmp & CBOR_ADDINFO_MASK;\n-\n- if (l != CJOIN_SHORT_ADDRESS_LENGTH) {\n- return E_FAIL;\n- }\n-\n- tmp++;\n- short_address->address = tmp;\n-\n- tmp += l;\n-\n- if (additional_info == 2) { // lease time present\n- l = *tmp & CBOR_ADDINFO_MASK;\n- if (l != ASN_LENGTH) { // 5 byte ASN expected\n- return E_FAIL;\n- }\n- tmp++;\n-\n- (short_address->lease_asn).bytes0and1 = ((uint16_t) tmp[1] << 8) | ((uint16_t) tmp[0]);\n- (short_address->lease_asn).bytes2and3 = ((uint16_t) tmp[3] << 8) | ((uint16_t) tmp[2]);\n- (short_address->lease_asn).byte4 = tmp[4];\n-\n- tmp += ASN_LENGTH;\n- }\n-\n- *len = (uint8_t) (tmp - buf);\n- return E_SUCCESS;\n-}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "*/\n#include \"opendefs.h\"\n//=========================== define ==========================================\n-// number of bytes in 802.15.4 short address\n-#define CJOIN_SHORT_ADDRESS_LENGTH 2\n-// max number of keys supported in COSE_KeySet\n-#define CJOIN_MAX_NUM_KEYS 2\n-// max supported number of bytes in key id field of COSE_Key\n-#define CJOIN_MAX_KEYID_LENGTH 2\n-\n-\n-// CBOR additional info mask\n-#define CBOR_ADDINFO_MASK 0x1F\n-\n-// max number of pairs in COSE symmetric key struct\n-#define COSE_SYMKEY_MAXNUMPAIRS 6\n-\n-// CBOR major types\n-typedef enum {\n- CBOR_MAJORTYPE_UINT = 0,\n- CBOR_MAJORTYPE_NINT = 1,\n- CBOR_MAJORTYPE_BSTR = 2,\n- CBOR_MAJORTYPE_TSTR = 3,\n- CBOR_MAJORTYPE_ARRAY = 4,\n- CBOR_MAJORTYPE_MAP = 5,\n-} cbor_majortype_t;\n-\n-// COSE key map labels\n-typedef enum {\n- COSE_KEY_LABEL_KTY = 1,\n- COSE_KEY_LABEL_KID = 2,\n- COSE_KEY_LABEL_ALG = 3,\n- COSE_KEY_LABEL_KEYOPS = 4,\n- COSE_KEY_LABEL_BASEIV = 5,\n- COSE_KEY_LABEL_K = 32, // -1\n-} cose_key_label_t;\n-\n-// COSE key type values\n-typedef enum {\n- COSE_KEY_VALUE_OKP = 1,\n- COSE_KEY_VALUE_EC2 = 2,\n- COSE_KEY_VALUE_SYMMETRIC = 4,\n-} cose_key_value_t;\n//=========================== typedef =========================================\n-typedef struct {\n- uint8_t* address;\n- asn_t lease_asn;\n-} short_address_t;\n-\n-typedef struct {\n- cose_key_value_t kty;\n- uint8_t* kid;\n- uint8_t kid_len;\n- uint8_t* k;\n- uint8_t k_len;\n-} COSE_symmetric_key_t;\n-\n-typedef struct {\n- COSE_symmetric_key_t key[CJOIN_MAX_NUM_KEYS];\n-} COSE_keyset_t;\n-\n-typedef struct {\n- COSE_keyset_t keyset;\n- short_address_t short_address;\n-} join_response_t;\n-\ntypedef struct {\nopentimer_id_t startupTimerId;\nopentimer_id_t retransmissionTimerId;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Refactor CBOR code into cbor.[ch] files.
491,609
20.04.2017 17:26:56
-7,200
94eb95f83deddebfa4405dab0c6ebab8689fe8ee
Rename CBOR functions.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.c", "new_path": "openapps/cjoin/cbor.c", "diff": "//=========================== variables =======================================\n//=========================== prototypes ======================================\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t *);\n-owerror_t cjoin_parse_short_address(short_address_t *, uint8_t *, uint8_t *);\n-owerror_t cjoin_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n+owerror_t cbor_parse_keyset(COSE_keyset_t *, uint8_t *, uint8_t *);\n+owerror_t cbor_parse_short_address(short_address_t *, uint8_t *, uint8_t *);\n+owerror_t cbor_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n//=========================== public ==========================================\n@@ -25,7 +25,7 @@ This function expects the join response structure from minimal-security-02 draft\n\\param[in] buf The received join response.\n\\param[in] len Length of the payload.\n*/\n-owerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\n+owerror_t cbor_parse_join_response(join_response_t *response, uint8_t *buf, uint8_t len) {\ncbor_majortype_t major_type;\nuint8_t additional_info;\n@@ -46,14 +46,14 @@ owerror_t cjoin_parse_join_response(join_response_t *response, uint8_t *buf, uin\ntmp++;\n- if (cjoin_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\n+ if (cbor_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\nreturn E_FAIL;\n}\ntmp += ret;\nif (additional_info == 2) { // short address present\n- if (cjoin_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\n+ if (cbor_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\nreturn E_FAIL;\n}\ntmp += ret;\n@@ -80,7 +80,7 @@ and parses it into COSE_symmetric_key_t structure.\n\\param[in] buf Input buffer.\n\\param[out] len Processed length.\n*/\n-owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len) {\n+owerror_t cbor_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len) {\ncbor_majortype_t major_type;\nuint8_t additional_info;\n@@ -104,7 +104,7 @@ owerror_t cjoin_parse_keyset(COSE_keyset_t *keyset, uint8_t *buf, uint8_t* len)\nfor(i = 0; i < additional_info; i++) {\n// parse symmetric key map\n- if (cjoin_parse_key(&keyset->key[i], tmp, &ret) == E_FAIL) {\n+ if (cbor_parse_key(&keyset->key[i], tmp, &ret) == E_FAIL) {\nreturn E_FAIL;\n}\ntmp += ret;\n@@ -124,7 +124,7 @@ and parses it into COSE_symmetric_key_t structure.\n\\param[in] buf Input buffer.\n\\param[out] len Processed length.\n*/\n-owerror_t cjoin_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len) {\n+owerror_t cbor_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len) {\ncbor_majortype_t major_type;\nuint8_t additional_info;\n@@ -204,7 +204,7 @@ and parses it into short_address_t structure.\n\\param[in] buf Input buffer.\n\\param[out] len Processed length.\n*/\n-owerror_t cjoin_parse_short_address(short_address_t *short_address, uint8_t *buf, uint8_t* len) {\n+owerror_t cbor_parse_short_address(short_address_t *short_address, uint8_t *buf, uint8_t* len) {\ncbor_majortype_t major_type;\nuint8_t additional_info;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.h", "new_path": "openapps/cjoin/cbor.h", "diff": "@@ -73,7 +73,7 @@ typedef struct {\n//=========================== prototypes ======================================\n-owerror_t cjoin_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n+owerror_t cbor_parse_join_response(join_response_t *, uint8_t *, uint8_t);\n/**\n\\}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -98,7 +98,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\nwhile(coap_options[i].type != COAP_OPTION_NONE) {\nif (coap_options[i].type == COAP_OPTION_NUM_CONTENTFORMAT &&\n*(coap_options[i].pValue) == COAP_MEDTYPE_APPCBOR) {\n- ret = cjoin_parse_join_response(&join_response, msg->payload, msg->length);\n+ ret = cbor_parse_join_response(&join_response, msg->payload, msg->length);\nif (ret == E_FAIL) { return E_FAIL; }\n// set the internal keys as per the parsed values\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Rename CBOR functions.
491,609
25.04.2017 16:47:28
-7,200
9496397035ebe61051c3d012847131d7e0478c51
Fix byte order in ASN.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.c", "new_path": "openapps/cjoin/cbor.c", "diff": "@@ -242,9 +242,10 @@ owerror_t cbor_parse_short_address(short_address_t *short_address, uint8_t *buf,\n}\ntmp++;\n- (short_address->lease_asn).bytes0and1 = ((uint16_t) tmp[1] << 8) | ((uint16_t) tmp[0]);\n- (short_address->lease_asn).bytes2and3 = ((uint16_t) tmp[3] << 8) | ((uint16_t) tmp[2]);\n- (short_address->lease_asn).byte4 = tmp[4];\n+ // ASN is in network byte order\n+ (short_address->lease_asn).byte4 = tmp[0];\n+ (short_address->lease_asn).bytes2and3 = ((uint16_t) tmp[1] << 8) | ((uint16_t) tmp[2]);\n+ (short_address->lease_asn).bytes0and1 = ((uint16_t) tmp[3] << 8) | ((uint16_t) tmp[4]);\ntmp += ASN_LENGTH;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Fix byte order in ASN.
491,609
25.04.2017 16:49:06
-7,200
7c2cee335e0549c9c292f35c8282a7da0e2ecb40
Explicitly reserve bytes for kid and key in COSE structs.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.c", "new_path": "openapps/cjoin/cbor.c", "diff": "#include \"cbor.h\"\n//=========================== defines =========================================\n// number of bytes in 802.15.4 short address\n-#define SHORT_ADDRESS_LENGTH 2\n#define ASN_LENGTH 5\n//=========================== variables =======================================\n@@ -15,7 +14,6 @@ owerror_t cbor_parse_key(COSE_symmetric_key_t *, uint8_t *, uint8_t *);\n//=========================== public ==========================================\n-\n/**\n\\brief Parse the received join response.\n@@ -160,17 +158,21 @@ owerror_t cbor_parse_key(COSE_symmetric_key_t *key, uint8_t* buf, uint8_t* len)\ncase COSE_KEY_LABEL_KID:\ntmp++;\nl = *tmp & CBOR_ADDINFO_MASK;\n+ if (l != COSE_SYMKEY_KEYID_LENGTH) {\n+ return E_FAIL;\n+ }\ntmp++;\n- key->kid = tmp;\n- key->kid_len = l;\n+ memcpy(key->kid, tmp, COSE_SYMKEY_KEYID_LENGTH);\ntmp += l;\nbreak;\ncase COSE_KEY_LABEL_K:\ntmp++;\nl = *tmp & CBOR_ADDINFO_MASK;\n+ if (l!= COSE_SYMKEY_LENGTH) {\n+ return E_FAIL;\n+ }\ntmp++;\n- key->k = tmp;\n- key->k_len = l;\n+ memcpy(key->k, tmp, COSE_SYMKEY_LENGTH);\ntmp += l;\nbreak;\ncase COSE_KEY_LABEL_BASEIV: // step by base iv\n@@ -231,7 +233,7 @@ owerror_t cbor_parse_short_address(short_address_t *short_address, uint8_t *buf,\n}\ntmp++;\n- short_address->address = tmp;\n+ memcpy(short_address->address, tmp, SHORT_ADDRESS_LENGTH);\ntmp += l;\n@@ -254,3 +256,4 @@ owerror_t cbor_parse_short_address(short_address_t *short_address, uint8_t *buf,\nreturn E_SUCCESS;\n}\n+\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.h", "new_path": "openapps/cjoin/cbor.h", "diff": "#define CBOR_ADDINFO_MASK 0x1F\n// max number of pairs in COSE symmetric key struct\n#define COSE_SYMKEY_MAXNUMPAIRS 6\n-\n+// 802.15.4 short address\n+#define SHORT_ADDRESS_LENGTH 2\n+// symmetric key length\n+#define COSE_SYMKEY_LENGTH 16\n+// key id length\n+#define COSE_SYMKEY_KEYID_LENGTH 1\n//=========================== typedef =========================================\n// CBOR major types\n@@ -47,16 +52,14 @@ typedef enum {\n} cose_key_value_t;\ntypedef struct {\n- uint8_t* address;\n+ uint8_t address[SHORT_ADDRESS_LENGTH];\nasn_t lease_asn;\n} short_address_t;\ntypedef struct {\ncose_key_value_t kty;\n- uint8_t* kid;\n- uint8_t kid_len;\n- uint8_t* k;\n- uint8_t k_len;\n+ uint8_t kid[COSE_SYMKEY_KEYID_LENGTH];\n+ uint8_t k[COSE_SYMKEY_LENGTH];\n} COSE_symmetric_key_t;\ntypedef struct {\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Explicitly reserve bytes for kid and key in COSE structs.
491,609
25.04.2017 17:23:35
-7,200
01a40f73a5529958362e8bbabe47f7736529fdb9
Rewrite the top parse function to make sure to zero out invalid responses.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.c", "new_path": "openapps/cjoin/cbor.c", "diff": "@@ -29,40 +29,51 @@ owerror_t cbor_parse_join_response(join_response_t *response, uint8_t *buf, uint\nuint8_t additional_info;\nuint8_t ret;\nuint8_t *tmp;\n+ owerror_t error;\n+ error = E_SUCCESS;\ntmp = buf;\nmajor_type = (cbor_majortype_t) *buf >> 5;\nadditional_info = *buf & CBOR_ADDINFO_MASK;\n+ do {\nif (major_type != CBOR_MAJORTYPE_ARRAY) {\n- return E_FAIL;\n+ error = E_FAIL;\n+ break;\n}\nif (additional_info > 2 || additional_info == 0) {\n- return E_FAIL; // unsupported join response structure\n+ error = E_FAIL; // unsupported join response structure\n+ break;\n}\ntmp++;\nif (cbor_parse_keyset(&(response->keyset), tmp, &ret) == E_FAIL) {\n- return E_FAIL;\n+ error = E_FAIL;\n+ break;\n}\ntmp += ret;\nif (additional_info == 2) { // short address present\nif (cbor_parse_short_address(&(response->short_address), tmp, &ret) == E_FAIL) {\n- return E_FAIL;\n+ error = E_FAIL;\n+ break;\n}\ntmp += ret;\n}\nif ( (uint8_t)(tmp - buf) != len) { // final check that everything has been parsed\n- memset(response, 0x00, sizeof(join_response_t)); // invalidate join response\n- return E_FAIL;\n+ error = E_FAIL;\n+ break;\n}\n+ } while(0); // while loop that gets executed only once\n- return E_SUCCESS;\n+ if (error == E_FAIL) {\n+ memset(response, 0x00, sizeof(join_response_t)); // invalidate join response\n+ }\n+ return error;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Rewrite the top parse function to make sure to zero out invalid responses.
491,609
25.04.2017 18:15:26
-7,200
2e8a28e4a6753bd45baa6a9c2d54a9626145a8a6
Add unit tests for the parser in Python.
[ { "change_type": "ADD", "old_path": null, "new_path": "openapps/cjoin/tests/test_parseDumps.py", "diff": "+import ctypes\n+import cbor\n+\n+import pytest\n+\n+#============================ defines ===============================\n+\n+COSE_KEYSET_MAX_NUM_KEYS = 2\n+SHORT_ADDRESS_LENGTH = 2\n+COSE_SYMKEY_LENGTH = 16\n+COSE_SYMKEY_KEYID_LENGTH = 1\n+\n+# from http://stackoverflow.com/questions/24307022/how-to-compare-two-ctypes-objects-for-equality\n+class CtStruct(ctypes.Structure):\n+ def __eq__(self, other):\n+ for field in self._fields_:\n+ attr_name = field[0]\n+ a, b = getattr(self, attr_name), getattr(other, attr_name)\n+ is_array = isinstance(a, ctypes.Array)\n+ if is_array and a[:] != b[:] or not is_array and a != b:\n+ return False\n+ return True\n+\n+ def __ne__(self, other):\n+ for field in self._fields_:\n+ attr_name = field[0]\n+ a, b = getattr(self, attr_name), getattr(other, attr_name)\n+ is_array = isinstance(a, ctypes.Array)\n+ if is_array and a[:] != b[:] or not is_array and a != b:\n+ return True\n+ return False\n+\n+class asn_t(CtStruct):\n+ _pack_ = 1\n+ _fields_ = [\n+ (\"byte4\", ctypes.c_uint8),\n+ (\"bytes2and3\", ctypes.c_uint16),\n+ (\"bytes0and1\", ctypes.c_uint16),\n+ ]\n+\n+ def print_values(self):\n+ print(format(self.byte4,'02x'), format(self.bytes2and3, '02x'), format(self.bytes0and1,'02x'))\n+\n+class short_address_t(CtStruct):\n+ _fields_ = [\n+ (\"address\", ctypes.c_uint8 * SHORT_ADDRESS_LENGTH),\n+ (\"lease_asn\", asn_t),\n+ ]\n+\n+ def print_values(self):\n+ print(\"short address: \" + ''.join(format(x, '02x') for x in self.address))\n+ self.lease_asn.print_values()\n+\n+class COSE_symmetric_key_t(CtStruct):\n+ _fields_ = [\n+ (\"kty\", ctypes.c_int), # enum\n+ (\"kid\", ctypes.c_uint8 * COSE_SYMKEY_KEYID_LENGTH),\n+ (\"k\", ctypes.c_uint8 * COSE_SYMKEY_LENGTH),\n+ ]\n+\n+ def print_values(self):\n+ print \"kty: \" + str(self.kty)\n+ print \"kid: \" + ''.join(format(x, '02x') for x in self.kid)\n+ print \"k: \" + ''.join(format(x, '02x') for x in self.k)\n+\n+class COSE_keyset_t(CtStruct):\n+ _fields_ = [\n+ (\"key\", COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS),\n+ ]\n+\n+ def print_values(self):\n+ for key in self.key:\n+ print \"================\"\n+ key.print_values()\n+\n+class join_response_t(CtStruct):\n+ _fields_ = [\n+ (\"keyset\", COSE_keyset_t),\n+ (\"short_address\", short_address_t),\n+ ]\n+ def print_values(self):\n+ self.keyset.print_values()\n+ print \"================\"\n+ self.short_address.print_values()\n+\n+#============================ fixtures ==============================\n+\n+CBORDUMPSANDPARSED = [\n+ (\n+ '8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'.decode('hex'),\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(),\n+ )\n+ ),\n+ short_address_t(\n+ (ctypes.c_uint8 * SHORT_ADDRESS_LENGTH)(0xaf, 0x93)\n+ )\n+ ),\n+ )\n+ ),\n+ (\n+ '8181a301040241012050e6bf4287c2d7618d6a9687445ffd33e6'.decode('hex'),\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(),\n+ )\n+ ),\n+ ),\n+ )\n+ ),\n+ (\n+ '8181a60104024101030c04840304090a0550abcdabcdabcdabcdabcdabcdabcdabcd2050e6bf4287c2d7618d6a9687445ffd33e6'.decode('hex'), # key ops, alg and base iv present but ignored\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(),\n+ )\n+ ),\n+ ),\n+ )\n+ ),\n+ (\n+ '8182a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef'.decode('hex'),\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x02),\n+ k = (ctypes.c_uint8 * 16) (0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef),\n+ ),\n+ )\n+ ),\n+ ),\n+ )\n+ ),\n+ (\n+ '8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8142af93'.decode('hex'),\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x02),\n+ k = (ctypes.c_uint8 * 16) (0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef),\n+ ),\n+ )\n+ ),\n+ short_address_t(\n+ (ctypes.c_uint8 * SHORT_ADDRESS_LENGTH)(0xaf, 0x93)\n+ )\n+ ),\n+ )\n+ ),\n+ (\n+ '8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8242af9345deadbeefab'.decode('hex'),\n+ ( 0, # return from parsing (success)\n+ join_response_t( # parsed object\n+ COSE_keyset_t(\n+ (COSE_symmetric_key_t * COSE_KEYSET_MAX_NUM_KEYS) (\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x01),\n+ k = (ctypes.c_uint8 * 16) (0xe6, 0xbf, 0x42, 0x87, 0xc2, 0xd7, 0x61, 0x8d, 0x6a, 0x96, 0x87, 0x44, 0x5f, 0xfd, 0x33, 0xe6),\n+ ),\n+ COSE_symmetric_key_t(\n+ kty = 4,\n+ kid = (ctypes.c_uint8 * 1)(0x02),\n+ k = (ctypes.c_uint8 * 16) (0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef),\n+ ),\n+ )\n+ ),\n+ short_address_t(\n+ (ctypes.c_uint8 * SHORT_ADDRESS_LENGTH)(0xaf, 0x93),\n+ (asn_t)(ctypes.c_uint8(0xde),ctypes.c_uint16(0xadbe),ctypes.c_uint16(0xefab))\n+ )\n+ ),\n+ )\n+ ),\n+ (\n+ '8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142'.decode('hex'),\n+ ( 1, # return from parsing (fail)\n+ join_response_t(), # parsed object (zeroed out)\n+ )\n+ ),\n+ (\n+ '81a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'.decode('hex'),\n+ ( 1, # return from parsing (fail)\n+ join_response_t(), # parsed object (zeroed out)\n+ )\n+ ),\n+ (\n+ '8281a3010402410120508142af93'.decode('hex'),\n+ ( 1, # return from parsing (fail)\n+ join_response_t(), # parsed object (zeroed out)\n+ )\n+ ),\n+ (\n+ '8281a3010402410120508142af93'.decode('hex'),\n+ ( 1, # return from parsing (fail)\n+ join_response_t(), # parsed object (zeroed out)\n+ )\n+ ),\n+\n+]\n+\n+@pytest.fixture(params=CBORDUMPSANDPARSED)\n+def cborDumpsAndParsed(request):\n+ return request.param\n+\n+#============================ tests =================================\n+\n+def test_parseCborDumps(cborDumpsAndParsed):\n+\n+ (input, output) = cborDumpsAndParsed\n+\n+ test_lib = ctypes.cdll.LoadLibrary('libcbor.so')\n+\n+ dump = [ord(b) for b in input]\n+ arr = (ctypes.c_uint8 * len(dump))(*dump)\n+ plen = ctypes.c_uint8(len(dump))\n+\n+ result = join_response_t()\n+\n+ ret = test_lib.cbor_parse_join_response(ctypes.byref(result), ctypes.byref(arr), plen)\n+\n+ assert ret == output[0]\n+ assert result == output[1]\n+\n+\n+def main():\n+ lib = ctypes.cdll.LoadLibrary('libcbor.so')\n+ join_response_parsed = join_response_t()\n+\n+ join_response_serialized = '8281a3010402410120508142af93'.decode('hex')\n+\n+ respPayload = [ord(b) for b in join_response_serialized]\n+ arr = (ctypes.c_uint8 * len(respPayload))(*respPayload)\n+ plen = ctypes.c_uint8(len(respPayload))\n+\n+ print lib.cbor_parse_join_response(ctypes.byref(join_response_parsed), ctypes.byref(arr), plen)\n+\n+ #test_jr.print_values()\n+ join_response_parsed.print_values()\n+\n+\n+if __name__ == '__main__':\n+ main()\n+\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add unit tests for the parser in Python.
491,609
05.05.2017 15:10:35
-7,200
55b6f8267d9164b71ad875cbd35245e8718b2734
Invalidate join response struct before beginning.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cbor.c", "new_path": "openapps/cjoin/cbor.c", "diff": "@@ -31,6 +31,8 @@ owerror_t cbor_parse_join_response(join_response_t *response, uint8_t *buf, uint\nuint8_t *tmp;\nowerror_t error;\n+ memset(response, 0x00, sizeof(join_response_t));\n+\nerror = E_SUCCESS;\ntmp = buf;\nmajor_type = (cbor_majortype_t) *buf >> 5;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Invalidate join response struct before beginning.
491,609
09.05.2017 16:04:39
-7,200
5cec9ada3f58017fe5454b20cdd2edcc7a85b9eb
Use binascii unhexlify instead of decode.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/tests/test_parseDumps.py", "new_path": "openapps/cjoin/tests/test_parseDumps.py", "diff": "import ctypes\nimport cbor\n+import binascii\nimport pytest\n@@ -87,7 +88,7 @@ class join_response_t(CtStruct):\nCBORDUMPSANDPARSED = [\n(\n- '8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'.decode('hex'),\n+ binascii.unhexlify('8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'),\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -107,7 +108,7 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8181a301040241012050e6bf4287c2d7618d6a9687445ffd33e6'.decode('hex'),\n+ binascii.unhexlify('8181a301040241012050e6bf4287c2d7618d6a9687445ffd33e6'),\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -124,7 +125,7 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8181a60104024101030c04840304090a0550abcdabcdabcdabcdabcdabcdabcdabcd2050e6bf4287c2d7618d6a9687445ffd33e6'.decode('hex'), # key ops, alg and base iv present but ignored\n+ binascii.unhexlify('8181a60104024101030c04840304090a0550abcdabcdabcdabcdabcdabcdabcdabcd2050e6bf4287c2d7618d6a9687445ffd33e6'), # key ops, alg and base iv present but ignored\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -141,7 +142,7 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8182a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef'.decode('hex'),\n+ binascii.unhexlify('8182a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef'),\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -162,7 +163,7 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8142af93'.decode('hex'),\n+ binascii.unhexlify('8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8142af93'),\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -186,7 +187,7 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8242af9345deadbeefab'.decode('hex'),\n+ binascii.unhexlify('8282a301040241012050e6bf4287c2d7618d6a9687445ffd33e6a301040241022050deadbeefdeadbeefdeadbeefdeadbeef8242af9345deadbeefab'),\n( 0, # return from parsing (success)\njoin_response_t( # parsed object\nCOSE_keyset_t(\n@@ -211,25 +212,25 @@ CBORDUMPSANDPARSED = [\n)\n),\n(\n- '8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142'.decode('hex'),\n+ binascii.unhexlify('8281a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142'),\n( 1, # return from parsing (fail)\njoin_response_t(), # parsed object (zeroed out)\n)\n),\n(\n- '81a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'.decode('hex'),\n+ binascii.unhexlify('81a301040241012050e6bf4287c2d7618d6a9687445ffd33e68142af93'),\n( 1, # return from parsing (fail)\njoin_response_t(), # parsed object (zeroed out)\n)\n),\n(\n- '8281a3010402410120508142af93'.decode('hex'),\n+ binascii.unhexlify('8281a3010402410120508142af93'),\n( 1, # return from parsing (fail)\njoin_response_t(), # parsed object (zeroed out)\n)\n),\n(\n- '8281a3010402410120508142af93'.decode('hex'),\n+ binascii.unhexlify('8281a3010402410120508142af93'),\n( 1, # return from parsing (fail)\njoin_response_t(), # parsed object (zeroed out)\n)\n@@ -265,7 +266,7 @@ def main():\nlib = ctypes.cdll.LoadLibrary('libcbor.so')\njoin_response_parsed = join_response_t()\n- join_response_serialized = '8281a3010402410120508142af93'.decode('hex')\n+ join_response_serialized = binascii.unhexlify('8281a3010402410120508142af93')\nrespPayload = [ord(b) for b in join_response_serialized]\narr = (ctypes.c_uint8 * len(respPayload))(*respPayload)\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Use binascii unhexlify instead of decode.
491,609
06.06.2017 18:39:15
-7,200
351080e902c0971f2914950f1743db2c81c7e298
Add interface to set the join key.
[ { "change_type": "MODIFY", "old_path": "drivers/common/openserial.c", "new_path": "drivers/common/openserial.c", "diff": "@@ -540,12 +540,13 @@ void openserial_handleEcho(uint8_t* buf, uint8_t bufLen){\n}\nvoid openserial_handleCommands(void){\n- uint8_t input_buffer[10];\n+ uint8_t input_buffer[20];\nuint8_t numDataBytes;\nuint8_t commandId;\nuint8_t commandLen;\nuint8_t comandParam_8;\nuint16_t comandParam_16;\n+ uint8_t* commandPayload;\ncellInfo_ht cellList[SCHEDULEIEMAXNUMCELLS];\nuint8_t i;\n@@ -561,8 +562,7 @@ void openserial_handleCommands(void){\ncommandLen = openserial_vars.inputBuf[2];\nif (commandLen>3) {\n- // the max command Len is 2, except ping commands\n- return;\n+ commandPayload = &openserial_vars.inputBuf[3];\n} else {\nif (commandLen == 1) {\ncomandParam_8 = openserial_vars.inputBuf[3];\n@@ -691,6 +691,9 @@ void openserial_handleCommands(void){\n}\n}\nbreak;\n+ case COMMAND_SET_JOIN_KEY:\n+ cjoin_setJoinKey(commandPayload, commandLen);\n+ break;\ndefault:\n// wrong command ID\nbreak;\n" }, { "change_type": "MODIFY", "old_path": "drivers/common/openserial.h", "new_path": "drivers/common/openserial.h", "diff": "@@ -80,7 +80,8 @@ enum {\nCOMMAND_SET_6PRESPONSE = 15,\nCOMMAND_SET_UINJECTPERIOD = 16,\nCOMMAND_SET_ECHO_REPLY_STATUS = 17,\n- COMMAND_MAX = 18,\n+ COMMAND_SET_JOIN_KEY = 18,\n+ COMMAND_MAX = 19,\n};\n//=========================== variables =======================================\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -47,7 +47,15 @@ void cjoin_retransmission_task_cb(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n//=========================== public ==========================================\n-\n+/* Below is debug functions */\n+void printf_hex(unsigned char *data, unsigned int len){\n+ unsigned int i=0;\n+ for(i=0; i<len; i++)\n+ {\n+ printf(\"%02x \",data[i]);\n+ }\n+ printf(\"\\n\");\n+}\nvoid cjoin_init() {\n// prepare the resource descriptor for the /j path\n@@ -68,6 +76,13 @@ void cjoin_init() {\ncjoin_schedule();\n}\n+\n+\n+void cjoin_setJoinKey(uint8_t *key, uint8_t len) {\n+ memcpy(cjoin_vars.joinKey, key, len);\n+ printf_hex(cjoin_vars.joinKey, len);\n+}\n+\nvoid cjoin_schedule() {\nuint16_t delay;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "@@ -17,6 +17,7 @@ typedef struct {\nopentimer_id_t retransmissionTimerId;\nbool isJoined;\nasn_t joinAsn;\n+ uint8_t joinKey[16];\n} cjoin_vars_t;\n//=========================== variables =======================================\n@@ -27,8 +28,11 @@ void cjoin_init(void);\nvoid cjoin_schedule(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n+void cjoin_setJoinKey(uint8_t *key, uint8_t len);\nbool debugPrint_joined(void);\n+\n+\n/**\n\\}\n\\}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -847,6 +847,7 @@ functionsToChange = [\n'rrt_sendCoAPMsg',\n# cjoin\n'cjoin_init',\n+ 'cjoin_setJoinKey',\n'cjoin_schedule',\n'cjoin_receive',\n'cjoin_timer_cb',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add interface to set the join key.
491,609
13.06.2017 18:24:30
-7,200
9f303992780fb7b1a5ae3cf84eae344872b8e631
Initial commit for implementation.
[ { "change_type": "MODIFY", "old_path": "openstack/04-TRAN/opencoap.h", "new_path": "openstack/04-TRAN/opencoap.h", "diff": "@@ -93,6 +93,7 @@ typedef enum {\nCOAP_OPTION_NUM_LOCATIONQUERY = 20,\nCOAP_OPTION_NUM_PROXYURI = 35,\nCOAP_OPTION_NUM_PROXYSCHEME = 39,\n+ COAP_OPTION_NUM_OBJECTSECURITY = 21,\n} coap_option_t;\ntypedef enum {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openstack/04-TRAN/oscoap.c", "diff": "+#include \"opendefs.h\"\n+#include \"oscoap.h\"\n+\n+/**\n+\\brief Initialize OSCOAP security context.\n+\n+This function will derive the parameters needed to initialize OSCOAP\n+security context.\n+\n+\\param[out] ctx OSCOAP security context structure.\n+\\param[in] senderID Pointer to the Byte array containing Sender ID.\n+\\param[in] senderIDLen Length of the Sender ID byte array in bytes.\n+\\param[in] recipientID Pointer to the Byte array contaning Recipient ID.\n+\\param[in] recipientIDLen Length of the Recipient ID byte array in bytes.\n+\\param[in] Pointer to the byte array contaning the Master Secret.\n+\\param[in] Length of the Master Secret byte array in bytes.\n+\\param[in] Pointer to the byte array contaning Master Salt.\n+\\param[in] Length of the Master Salt byte array in bytes.\n+*/\n+\n+void oscoap_init_security_context(oscoap_security_context_t *ctx,\n+ uint8_t* senderID,\n+ uint8_t senderIDLen,\n+ uint8_t* recipientID,\n+ uint8_t recipientIDLen,\n+ uint8_t* masterSecret,\n+ uint8_t masterSecretLen,\n+ uint8_t* masterSalt,\n+ uint8_t masterSaltLen) {\n+ // common context\n+ ctx->aeadAlgorithm = AES_CCM_16_64_128;\n+\n+ // sender context\n+ memcpy(ctx->senderID, senderID, senderIDLen);\n+ ctx->senderIDLen = senderIDLen;\n+ // invoke HKDF to get sender Key\n+ // invoke HKDF to get sender IV\n+ ctx->sequenceNumber = 0;\n+\n+ // recipient context\n+ memcpy(ctx->recipientID, recipientID, recipientIDLen);\n+ ctx->recipientIDLen = recipientIDLen;\n+ // invoke HKDF to get recipient Key\n+ // invoke HKDF to get recipient IV\n+ ctx->window.bitArray = 0;\n+ ctx->window.base = 0;\n+\n+}\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openstack/04-TRAN/oscoap.h", "diff": "+\n+#ifndef __OSCOAP_H\n+#define __OSCOAP_H\n+\n+/**\n+\\addtogroup Transport\n+\\{\n+\\addtogroup openCoap\n+\\{\n+*/\n+\n+//=========================== define ==========================================\n+\n+#define OSCOAP_MAX_ID_LEN 10\n+\n+#define OSCOAP_MASTER_SECRET_LEN 16\n+\n+#define OSCOAP_MAX_MASTER_SALT_LEN 0\n+\n+#define AES_CCM_16_64_128 10 // algorithm value as defined in COSE spec\n+\n+#define AES_CCM_16_64_128_KEY_LEN 16\n+\n+#define AES_CCM_16_64_128_IV_LEN 13\n+\n+#define AES_CCM_16_64_128_TAG_LEN 8\n+\n+//=========================== typedef =========================================\n+typedef struct {\n+ uint32_t bitArray;\n+ uint16_t base;\n+} replay_window_t;\n+\n+typedef struct {\n+ // common context\n+ uint8_t aeadAlgorithm;\n+ // sender context\n+ uint8_t senderID[OSCOAP_MAX_ID_LEN];\n+ uint8_t senderIDLen;\n+ uint8_t senderKey[AES_CCM_16_64_128_KEY_LEN];\n+ uint8_t senderIV[AES_CCM_16_64_128_IV_LEN];\n+ uint16_t sequenceNumber;\n+ // recipient context\n+ uint8_t recipientID[OSCOAP_MAX_ID_LEN];\n+ uint8_t recipientIDLen;\n+ uint8_t* recipientKey[AES_CCM_16_64_128_KEY_LEN];\n+ uint8_t* recipientIV[AES_CCM_16_64_128_IV_LEN];\n+ replay_window_t window;\n+} oscoap_security_context_t;\n+\n+//=========================== prototypes ======================================\n+\n+void oscoap_init_security_context(oscoap_security_context_t *ctx,\n+ uint8_t* senderID,\n+ uint8_t senderIDLen,\n+ uint8_t* recipientID,\n+ uint8_t recipientIDLen,\n+ uint8_t* masterSecret,\n+ uint8_t masterSecretLen,\n+ uint8_t* masterSalt,\n+ uint8_t masterSaltLen);\n+/**\n+\\}\n+\\}\n+*/\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -30,6 +30,7 @@ sources_c = [\nos.path.join('03b-IPv6','icmpv6rpl.c'),\n#=== 04-TRAN\nos.path.join('04-TRAN','opencoap.c'),\n+ os.path.join('04-TRAN','oscoap.c'),\nos.path.join('04-TRAN','opentcp.c'),\nos.path.join('04-TRAN','openudp.c'),\n#=== cross-layers\n@@ -64,6 +65,7 @@ sources_h = [\nos.path.join('03b-IPv6','icmpv6rpl.h'),\n#=== 04-TRAN\nos.path.join('04-TRAN','opencoap.h'),\n+ os.path.join('04-TRAN','oscoap.h'),\nos.path.join('04-TRAN','opentcp.h'),\nos.path.join('04-TRAN','openudp.h'),\n#=== cross-layers\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -702,6 +702,8 @@ functionsToChange = [\n'opencoap_register',\n'opencoap_send',\n'icmpv6coap_timer_cb',\n+ # oscoap\n+ 'oscoap_init_security_context',\n# opentcp\n'opentcp_init',\n'opentcp_connect',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Initial commit for OSCOAP-03 implementation.
491,595
14.06.2017 17:49:14
-7,200
3b2c59ab53185bb213b9e12e31e76fe763efc156
add timer wrapping and PERIODIC tyupe timer in opentimers.
[ { "change_type": "MODIFY", "old_path": "drivers/common/opentimers.c", "new_path": "drivers/common/opentimers.c", "diff": "@@ -74,13 +74,13 @@ can't be called firstly after the timer is created.\n\\param[in] uint_type indicates the unit type of this schedule: ticks or ms\n\\param[in] cb indicates when this scheduled timer fired, call this callback function.\n*/\n-void opentimers_scheduleRelative(opentimers_id_t id,\n- PORT_TIMER_WIDTH duration,\n+void opentimers_scheduleIn(opentimers_id_t id,\n+ uint32_t duration,\ntime_type_t uint_type,\n+ timer_type_t timer_type,\nopentimers_cbt cb){\nuint8_t i;\nuint8_t idToSchedule;\n- PORT_TIMER_WIDTH durationTicks;\nPORT_TIMER_WIDTH timerGap;\nPORT_TIMER_WIDTH tempTimerGap;\n// 1. make sure the timer exist\n@@ -94,22 +94,26 @@ void opentimers_scheduleRelative(opentimers_id_t id,\nreturn;\n}\n+ opentimers_vars.timersBuf[id].timerType = timer_type;\n+\n// 2. updat the timer content\nswitch (uint_type){\ncase TIME_MS:\n- if (duration>MAX_TICKS_NUMBER/PORT_TICS_PER_MS){\n- // openserail_printError();\n- return;\n- } else {\n- durationTicks = duration*PORT_TICS_PER_MS;\n- }\n+ opentimers_vars.timersBuf[id].totalTimerPeriod = duration*PORT_TICS_PER_MS;\n+ opentimers_vars.timersBuf[id].wraps_remaining = (uint32_t)(duration*PORT_TICS_PER_MS)/MAX_TICKS_IN_SINGLE_CLOCK;\nbreak;\ncase TIME_TICS:\n- durationTicks = duration;\n+ opentimers_vars.timersBuf[id].totalTimerPeriod = duration;\n+ opentimers_vars.timersBuf[id].wraps_remaining = (uint32_t)(duration)/MAX_TICKS_IN_SINGLE_CLOCK;\nbreak;\n}\n- opentimers_vars.timersBuf[id].currentCompareValue = durationTicks+opentimers_vars.timersBuf[id].lastCompareValue;\n+ if (opentimers_vars.timersBuf[id].wraps_remaining==0){\n+ opentimers_vars.timersBuf[id].currentCompareValue = opentimers_vars.timersBuf[id].totalTimerPeriod+sctimer_readCounter();\n+ } else {\n+ opentimers_vars.timersBuf[id].currentCompareValue = MAX_TICKS_IN_SINGLE_CLOCK+sctimer_readCounter();\n+ }\n+\nopentimers_vars.timersBuf[id].isrunning = TRUE;\nopentimers_vars.timersBuf[id].callback = cb;\n@@ -171,13 +175,12 @@ to lastCompareValue + reference.\n\\param[in] cb indicates when this scheduled timer fired, call this callback function.\n*/\nvoid opentimers_scheduleAbsolute(opentimers_id_t id,\n- PORT_TIMER_WIDTH duration,\n+ uint32_t duration,\nPORT_TIMER_WIDTH reference ,\ntime_type_t uint_type,\nopentimers_cbt cb){\nuint8_t i;\nuint8_t idToSchedule;\n- PORT_TIMER_WIDTH durationTicks;\nPORT_TIMER_WIDTH timerGap;\nPORT_TIMER_WIDTH tempTimerGap;\n// 1. make sure the timer exist\n@@ -191,22 +194,27 @@ void opentimers_scheduleAbsolute(opentimers_id_t id,\nreturn;\n}\n+ // absolute scheduling is for one shot timer\n+ opentimers_vars.timersBuf[id].timerType = TIMER_ONESHOT;\n+\n// 2. updat the timer content\nswitch (uint_type){\ncase TIME_MS:\n- if (duration>MAX_TICKS_NUMBER/PORT_TICS_PER_MS){\n- // openserail_printError(\"unsupported large duration\");\n- return;\n- } else {\n- durationTicks = duration*PORT_TICS_PER_MS;\n- }\n+ opentimers_vars.timersBuf[id].totalTimerPeriod = duration*PORT_TICS_PER_MS;\n+ opentimers_vars.timersBuf[id].wraps_remaining = (uint32_t)(duration*PORT_TICS_PER_MS)/MAX_TICKS_IN_SINGLE_CLOCK;;\nbreak;\ncase TIME_TICS:\n- durationTicks = duration;\n+ opentimers_vars.timersBuf[id].totalTimerPeriod = duration;\n+ opentimers_vars.timersBuf[id].wraps_remaining = (uint32_t)duration/MAX_TICKS_IN_SINGLE_CLOCK;\nbreak;\n}\n- opentimers_vars.timersBuf[id].currentCompareValue = durationTicks+reference;\n+ if (opentimers_vars.timersBuf[id].wraps_remaining==0){\n+ opentimers_vars.timersBuf[id].currentCompareValue = opentimers_vars.timersBuf[id].totalTimerPeriod+reference;\n+ } else {\n+ opentimers_vars.timersBuf[id].currentCompareValue = MAX_TICKS_IN_SINGLE_CLOCK+reference;\n+ }\n+\nopentimers_vars.timersBuf[id].isrunning = TRUE;\nopentimers_vars.timersBuf[id].callback = cb;\n@@ -390,17 +398,35 @@ void opentimers_timer_callback(void){\nopentimers_vars.timersBuf[j].hasExpired == TRUE &&\nopentimers_vars.timersBuf[j].priority == opentimers_vars.timersBuf[idToCallCB].priority\n){\n- opentimers_vars.timersBuf[j].isrunning = FALSE;\nopentimers_vars.timersBuf[j].lastCompareValue = opentimers_vars.timersBuf[j].currentCompareValue;\n+ if (opentimers_vars.timersBuf[j].wraps_remaining==0){\n+ opentimers_vars.timersBuf[j].isrunning = FALSE;\nopentimers_vars.timersBuf[j].hasExpired = FALSE;\nopentimers_vars.timersBuf[j].callback();\n+ if (opentimers_vars.timersBuf[j].timerType==TIMER_PERIODIC){\n+ opentimers_scheduleIn(j,\n+ opentimers_vars.timersBuf[j].totalTimerPeriod,\n+ TIME_TICS,\n+ TIMER_PERIODIC,\n+ opentimers_vars.timersBuf[j].callback\n+ );\n+ }\n+ } else {\n+ opentimers_vars.timersBuf[j].wraps_remaining--;\n+ if (opentimers_vars.timersBuf[j].wraps_remaining == 0){\n+ opentimers_vars.timersBuf[j].currentCompareValue = (opentimers_vars.timersBuf[j].totalTimerPeriod+opentimers_vars.timersBuf[j].lastCompareValue) & MAX_TICKS_IN_SINGLE_CLOCK;\n+ } else {\n+ opentimers_vars.timersBuf[j].currentCompareValue = opentimers_vars.timersBuf[j].lastCompareValue + MAX_TICKS_IN_SINGLE_CLOCK;\n+ }\n+ opentimers_vars.timersBuf[j].hasExpired = FALSE;\n+ }\n}\n}\n}\nopentimers_vars.insideISR = FALSE;\n// 3. find the next timer to be fired\n- timerGap = opentimers_vars.timersBuf[0].currentCompareValue-opentimers_vars.lastTimeout;\n+ timerGap = opentimers_vars.timersBuf[0].currentCompareValue+opentimers_vars.timersBuf[0].wraps_remaining*MAX_TICKS_IN_SINGLE_CLOCK-opentimers_vars.lastTimeout;\nidToSchedule = 0;\nfor (i=1;i<MAX_NUM_TIMERS;i++){\nif (opentimers_vars.timersBuf[i].isrunning){\n" }, { "change_type": "MODIFY", "old_path": "drivers/common/opentimers.h", "new_path": "drivers/common/opentimers.h", "diff": "/// Maximum number of timers that can run concurrently\n#define MAX_NUM_TIMERS 10\n-#define MAX_TICKS_NUMBER ((PORT_TIMER_WIDTH)0xFFFFFFFF)\n+#define MAX_TICKS_IN_SINGLE_CLOCK (uint32_t)(((PORT_TIMER_WIDTH)0xFFFFFFFF)>>1)\n+//#define MAX_TICKS_IN_SINGLE_CLOCK 0x7FFF\n#define TOO_MANY_TIMERS_ERROR 255\n#define MAX_DURATION_ISR 33 // 33@32768Hz = 1ms\n#define opentimers_id_t uint8_t\n@@ -39,16 +40,24 @@ typedef void (*opentimers_cbt)(void);\n//=========================== typedef =========================================\n+typedef enum {\n+ TIMER_PERIODIC,\n+ TIMER_ONESHOT,\n+} timer_type_t;\n+\ntypedef enum {\nTIME_MS,\nTIME_TICS,\n} time_type_t;\ntypedef struct {\n- PORT_TIMER_WIDTH currentCompareValue;// total number of clock ticks\n+ uint32_t totalTimerPeriod; // the total period of timer\n+ PORT_TIMER_WIDTH currentCompareValue;// the current compare value\n+ uint16_t wraps_remaining; // the number of wraps timer is going to be fired after\nPORT_TIMER_WIDTH lastCompareValue; // the previous compare value\nbool isrunning; // is running?\nbool isUsed; // true when this entry is occupied\n+ timer_type_t timerType; // the timer type\nbool hasExpired; // in case there are more than one interrupt occur at same time\nuint8_t priority; // high priority timer could take over the compare timer scheduled early than it for TIMERTHRESHOLD ticks.\nopentimers_cbt callback; // function to call when elapses\n@@ -70,12 +79,13 @@ typedef struct {\nvoid opentimers_init(void);\nopentimers_id_t opentimers_create(void);\n-void opentimers_scheduleRelative(opentimers_id_t id,\n- PORT_TIMER_WIDTH duration,\n+void opentimers_scheduleIn(opentimers_id_t id,\n+ uint32_t duration,\ntime_type_t uint_type,\n+ timer_type_t timer_type,\nopentimers_cbt cb);\nvoid opentimers_scheduleAbsolute(opentimers_id_t id,\n- PORT_TIMER_WIDTH duration,\n+ uint32_t duration,\nPORT_TIMER_WIDTH reference ,\ntime_type_t uint_type,\nopentimers_cbt cb);\n" }, { "change_type": "MODIFY", "old_path": "openapps/cexample/cexample.c", "new_path": "openapps/cexample/cexample.c", "diff": "@@ -53,11 +53,13 @@ void cexample_init() {\nopencoap_register(&cexample_vars.desc);\ncexample_vars.timerId = opentimers_create();\n- opentimers_scheduleAbsolute(cexample_vars.timerId,\n+ opentimers_scheduleIn(\n+ cexample_vars.timerId,\nCEXAMPLEPERIOD,\n- opentimers_getValue(),\nTIME_MS,\n- cexample_timer_cb);\n+ TIMER_PERIODIC,\n+ cexample_timer_cb\n+ );\n}\n//=========================== private =========================================\n@@ -84,12 +86,6 @@ void cexample_task_cb() {\nuint16_t avg = 0;\nuint8_t N_avg = 10;\n- // reschedule next time to expire\n- opentimers_scheduleRelative(cexample_vars.timerId,\n- CEXAMPLEPERIOD,\n- TIME_MS,\n- cexample_timer_cb);\n-\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n" }, { "change_type": "MODIFY", "old_path": "openapps/csensors/csensors.c", "new_path": "openapps/csensors/csensors.c", "diff": "@@ -283,10 +283,11 @@ void csensors_timer_cb(){\nif (csensors_vars.csensors_resource[i].timerId == i) {\ncsensors_vars.cb_list[csensors_vars.cb_put] = i;\ncsensors_vars.cb_put = (csensors_vars.cb_put+1)%CSENSORSTASKLIST;\n- opentimers_scheduleRelative(\n+ opentimers_scheduleIn(\ncsensors_vars.csensors_resource[i].timerId,\ncsensors_vars.csensors_resource[i].period,\nTIME_MS,\n+ TIMER_ONESHOT,\ncsensors_timer_cb\n);\nbreak;\n@@ -380,28 +381,29 @@ void csensors_setPeriod(uint32_t period,\nif (period>0) {\ncsensors_vars.csensors_resource[id].period = period;\nif (opentimers_isRunning(csensors_vars.csensors_resource[id].timerId)) {\n- opentimers_scheduleRelative(\n+ opentimers_scheduleIn(\ncsensors_vars.csensors_resource[id].timerId,\n(uint32_t)((period*openrandom_get16b())/0xffff),\nTIME_MS,\n+ TIMER_ONESHOT,\ncsensors_timer_cb\n);\nif (old_period==0) {\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\ncsensors_vars.csensors_resource[id].timerId,\n(uint32_t)((period*openrandom_get16b())/0xffff),\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_ONESHOT,\ncsensors_timer_cb\n);\n}\n} else {\ncsensors_vars.csensors_resource[id].timerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\ncsensors_vars.csensors_resource[id].timerId,\n(uint32_t)((period*openrandom_get16b())/0xffff),\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_ONESHOT,\ncsensors_timer_cb\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cstorm/cstorm.c", "new_path": "openapps/cstorm/cstorm.c", "diff": "@@ -55,11 +55,11 @@ void cstorm_init(void) {\ncstorm_vars.period = 6553;\ncstorm_vars.timerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\ncstorm_vars.timerId,\ncstorm_vars.period,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_PERIODIC,\ncstorm_timer_cb\n);\n@@ -116,11 +116,11 @@ owerror_t cstorm_receive(\nopentimers_cancel(cstorm_vars.timerId);\nif(cstorm_vars.period > 0) {\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\ncstorm_vars.timerId,\ncstorm_vars.period,\n- opentimers_getValue();\nTIME_MS,\n+ TIMER_PERIODIC,\ncstorm_timer_cb\n);\n}\n@@ -157,13 +157,6 @@ void cstorm_task_cb() {\nowerror_t outcome;\nuint8_t numOptions;\n- opentimers_scheduleRelative(\n- cstorm_vars.timerId,\n- cstorm_vars.period,\n- TIME_MS,\n- cstorm_timer_cb\n- );\n-\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n" }, { "change_type": "MODIFY", "old_path": "openapps/uinject/uinject.c", "new_path": "openapps/uinject/uinject.c", "diff": "@@ -37,11 +37,11 @@ void uinject_init() {\nuinject_vars.period = UINJECT_PERIOD_MS;\n// start periodic timer\nuinject_vars.timerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nuinject_vars.period,\nUINJECT_PERIOD_MS,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_PERIODIC,\nuinject_timer_cb\n);\n}\n@@ -77,13 +77,6 @@ void uinject_task_cb() {\nOpenQueueEntry_t* pkt;\nuint8_t asnArray[5];\n- opentimers_scheduleRelative(\n- uinject_vars.period,\n- UINJECT_PERIOD_MS,\n- TIME_MS,\n- uinject_timer_cb\n- );\n-\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -113,7 +113,7 @@ void ieee154e_init() {\nmemset(&ieee154e_vars,0,sizeof(ieee154e_vars_t));\nmemset(&ieee154e_dbg,0,sizeof(ieee154e_dbg_t));\n- ieee154e_vars.singleChannel = 0; // 0 means channel hopping\n+ ieee154e_vars.singleChannel = 26; // 0 means channel hopping\nieee154e_vars.isAckEnabled = TRUE;\nieee154e_vars.isSecurityEnabled = FALSE;\nieee154e_vars.slotDuration = TsSlotDuration;\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "@@ -32,7 +32,7 @@ static const uint8_t ebIEsBytestream[] = {\n#define EB_JP_OFFSET 9\n#define EB_IE_LEN 28\n-#define SYNCHRONIZING_CHANNEL 20 // channel the mote listens on to synchronize\n+#define SYNCHRONIZING_CHANNEL 26 // channel the mote listens on to synchronize\n#define TXRETRIES 3 // number of MAC retries before declaring failed\n#define TX_POWER 31 // 1=-25dBm, 31=0dBm (max value)\n#define RESYNCHRONIZATIONGUARD 5 // in 32kHz ticks. min distance to the end of the slot to successfully synchronize\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "// in seconds: sixtop maintaince is called every 30 seconds\n#define MAINTENANCE_PERIOD 30\n-// in miliseconds: the real EBPERIOD will be randomized chosen between {EBPERIOD-EBPERIOD_RANDOM_RANG, EBPERIOD+EBPERIOD_RANDOM_RANG}\n-#define EBPERIOD_RANDOM_RANG 500\n//=========================== variables =======================================\n@@ -114,20 +112,20 @@ void sixtop_init() {\nsixtop_vars.six2six_state = SIX_STATE_IDLE;\nsixtop_vars.ebSendingTimerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nsixtop_vars.ebSendingTimerId,\nsixtop_vars.periodMaintenance,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_ONESHOT,\nsixtop_sendingEb_timer_cb\n);\nsixtop_vars.maintenanceTimerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nsixtop_vars.maintenanceTimerId,\nsixtop_vars.periodMaintenance,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_PERIODIC,\nsixtop_maintenance_timer_cb\n);\n@@ -145,7 +143,7 @@ void sixtop_setKaPeriod(uint16_t kaPeriod) {\nvoid sixtop_setEBPeriod(uint8_t ebPeriod) {\nif(ebPeriod != 0) {\n// convert parameter to miliseconds\n- sixtop_vars.ebPeriod = ebPeriod*1000;\n+ sixtop_vars.ebPeriod = ebPeriod;\n}\n}\n@@ -619,23 +617,19 @@ owerror_t sixtop_send_internal(\n// timer interrupt callbacks\nvoid sixtop_sendingEb_timer_cb(void){\nscheduler_push_task(timer_sixtop_sendEb_fired,TASKPRIO_SIXTOP);\n- opentimers_scheduleRelative(\n+ // update the period\n+ sixtop_vars.periodMaintenance = 872 +(openrandom_get16b()&0xff);\n+ opentimers_scheduleIn(\nsixtop_vars.ebSendingTimerId,\n- 872+(openrandom_get16b()&0xff),\n+ sixtop_vars.periodMaintenance,\nTIME_MS,\n+ TIMER_ONESHOT,\nsixtop_sendingEb_timer_cb\n);\n}\nvoid sixtop_maintenance_timer_cb(void) {\nscheduler_push_task(timer_sixtop_management_fired,TASKPRIO_SIXTOP);\n- sixtop_vars.periodMaintenance = 872+(openrandom_get16b()&0xff);\n- opentimers_scheduleRelative(\n- sixtop_vars.maintenanceTimerId,\n- sixtop_vars.periodMaintenance,\n- TIME_MS,\n- sixtop_maintenance_timer_cb\n- );\n}\nvoid sixtop_timeout_timer_cb(void) {\n@@ -645,7 +639,7 @@ void sixtop_timeout_timer_cb(void) {\n//======= EB/KA task\nvoid timer_sixtop_sendEb_fired(){\n- sixtop_vars.ebCounter = (sixtop_vars.ebCounter+1)%EBPERIOD;\n+ sixtop_vars.ebCounter = (sixtop_vars.ebCounter+1)%sixtop_vars.ebPeriod;\nswitch (sixtop_vars.ebCounter) {\ncase 0:\n// called every EBPERIOD seconds\n" }, { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/icmpv6rpl.c", "new_path": "openstack/03b-IPv6/icmpv6rpl.c", "diff": "@@ -81,11 +81,11 @@ void icmpv6rpl_init() {\nicmpv6rpl_vars.dioPeriod = TIMER_DIO_TIMEOUT;\nicmpv6rpl_vars.timerIdDIO = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nicmpv6rpl_vars.timerIdDIO,\n- 872 +(openrandom_get16b()&0xff),\n- opentimers_getValue(),\n+ icmpv6rpl_vars.dioPeriod,\nTIME_MS,\n+ TIMER_PERIODIC,\nicmpv6rpl_timer_DIO_cb\n);\n@@ -130,11 +130,11 @@ void icmpv6rpl_init() {\nicmpv6rpl_vars.daoPeriod = TIMER_DAO_TIMEOUT;\nicmpv6rpl_vars.timerIdDAO = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nicmpv6rpl_vars.timerIdDAO,\n- 872 +(openrandom_get16b()&0xff),\n- opentimers_getValue(),\n+ icmpv6rpl_vars.daoPeriod,\nTIME_MS,\n+ TIMER_PERIODIC,\nicmpv6rpl_timer_DAO_cb\n);\n}\n@@ -516,13 +516,6 @@ void icmpv6rpl_killPreferredParent() {\n*/\nvoid icmpv6rpl_timer_DIO_cb(void) {\nscheduler_push_task(icmpv6rpl_timer_DIO_task,TASKPRIO_RPL);\n- // arm the DIO timer with this new value\n- opentimers_scheduleRelative(\n- icmpv6rpl_vars.timerIdDIO,\n- 872 +(openrandom_get16b()&0xff),\n- TIME_MS,\n- icmpv6rpl_timer_DIO_cb\n- );\n}\n/**\n@@ -531,15 +524,7 @@ void icmpv6rpl_timer_DIO_cb(void) {\n\\note This function is executed in task context, called by the scheduler.\n*/\nvoid icmpv6rpl_timer_DIO_task() {\n- icmpv6rpl_vars.dioTimerCounter = (icmpv6rpl_vars.dioTimerCounter+1)%icmpv6rpl_vars.dioPeriod;\n- switch (icmpv6rpl_vars.dioTimerCounter) {\n- case 0:\n- // called every TIMER_DIO_TIMEOUT seconds\nsendDIO();\n- break;\n- default:\n- break;\n- }\n}\n/**\n@@ -634,13 +619,6 @@ void sendDIO() {\n*/\nvoid icmpv6rpl_timer_DAO_cb(void) {\nscheduler_push_task(icmpv6rpl_timer_DAO_task,TASKPRIO_RPL);\n- // arm the DAO timer with this new value\n- opentimers_scheduleRelative(\n- icmpv6rpl_vars.timerIdDAO,\n- 872 +(openrandom_get16b()&0xff),\n- TIME_MS,\n- icmpv6rpl_timer_DAO_cb\n- );\n}\n/**\n@@ -649,15 +627,7 @@ void icmpv6rpl_timer_DAO_cb(void) {\n\\note This function is executed in task context, called by the scheduler.\n*/\nvoid icmpv6rpl_timer_DAO_task() {\n- icmpv6rpl_vars.daoTimerCounter = (icmpv6rpl_vars.daoTimerCounter+1)%icmpv6rpl_vars.daoPeriod;\n- switch (icmpv6rpl_vars.daoTimerCounter) {\n- case 0:\n- // called every TIMER_DAO_TIMEOUT seconds\nsendDAO();\n- break;\n- default:\n- break;\n- }\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/icmpv6rpl.h", "new_path": "openstack/03b-IPv6/icmpv6rpl.h", "diff": "//=========================== define ==========================================\n-#define TIMER_DIO_TIMEOUT 10 // seconds\n-#define TIMER_DAO_TIMEOUT 60 // seconds\n+#define TIMER_DIO_TIMEOUT 10000 // miliseconds\n+#define TIMER_DAO_TIMEOUT 60000 // miliseconds\n// Non-Storing Mode of Operation (1)\n#define MOP_DIO_A 0<<5\n@@ -144,18 +144,16 @@ typedef struct {\n// DIO-related\nicmpv6rpl_dio_ht dio; ///< pre-populated DIO packet.\nopen_addr_t dioDestination; ///< IPv6 destination address for DIOs.\n- uint16_t dioTimerCounter; ///< counter to determine when to send DIO.\n+// uint16_t dioTimerCounter; ///< counter to determine when to send DIO.\nopentimers_id_t timerIdDIO; ///< ID of the timer used to send DIOs.\nuint16_t dioPeriod; ///< dio period in seconds.\n- uint8_t delayDIO; ///< number of timerIdDIO events before actually sending a DIO.\n// DAO-related\nicmpv6rpl_dao_ht dao; ///< pre-populated DAO packet.\nicmpv6rpl_dao_transit_ht dao_transit; ///< pre-populated DAO \"Transit Info\" option header.\nicmpv6rpl_dao_target_ht dao_target; ///< pre-populated DAO \"Transit Info\" option header.\nopentimers_id_t timerIdDAO; ///< ID of the timer used to send DAOs.\n- uint16_t daoTimerCounter; ///< counter to determine when to send DAO.\n+// uint16_t daoTimerCounter; ///< counter to determine when to send DAO.\nuint16_t daoPeriod; ///< dao period in seconds.\n- uint8_t delayDAO; ///< number of timerIdDIO events before actually sending a DAO.\n// routing table\ndagrank_t myDAGrank; ///< rank of this router within DAG.\nuint16_t rankIncrease; ///< the cost of the link to the parent, in units of rank\n" }, { "change_type": "MODIFY", "old_path": "openstack/04-TRAN/opentcp.c", "new_path": "openstack/04-TRAN/opentcp.c", "diff": "@@ -606,10 +606,11 @@ bool tcp_debugPrint(void) {\n//timer used to reset state when TCP state machine is stuck\nvoid timers_tcp_fired(void) {\nopentcp_reset();\n- opentimers_scheduleRelative(\n+ opentimers_scheduleIn(\ntcp_vars.timerId,\nTCP_TIMEOUT,\nTIME_MS,\n+ TIMER_PERIODIC,\nopentcp_timer_cb\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "openstack/cross-layers/idmanager.c", "new_path": "openstack/cross-layers/idmanager.c", "diff": "@@ -30,8 +30,6 @@ void idmanager_init() {\n// myPANID\nidmanager_vars.myPANID.type = ADDR_PANID;\n- idmanager_vars.myPANID.panid[0] = 0xca;\n- idmanager_vars.myPANID.panid[1] = 0xfe;\n#ifdef PANID_DEFINED\nidmanager_vars.myPANID.panid[0] = PANID_DEFINED & 0x00ff;\nidmanager_vars.myPANID.panid[1] =(PANID_DEFINED & 0xff00)>>8;\n" }, { "change_type": "MODIFY", "old_path": "projects/openmote-cc2538/03oos_sniffer/03oos_sniffer.ewp", "new_path": "projects/openmote-cc2538/03oos_sniffer/03oos_sniffer.ewp", "diff": "<group>\n<name>headers</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_aes.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ana_regs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ana_regs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_cctest.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_cctest.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_flash_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_flash_ctrl.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gpio.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gptimer.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cm.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ints.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ints.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ioc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_memmap.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_memmap.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_nvic.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_nvic.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_pka.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_pka.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_ffsm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_sfr.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_sfr.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_xreg.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_rfcore_xreg.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_smwdthrosc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_smwdthrosc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_soc_adc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ssi.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ssi.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_sys_ctrl.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_types.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_types.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_uart.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_uart.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udma.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udma.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udmachctl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udmachctl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_usb.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\adc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\aes.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\aes.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\bl_commands.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\cpu.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\cpu.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\cpu.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\debug.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\debug.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\debug.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ecc_curveinfo.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ecc_curveinfo.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\flash.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\flash.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\flash.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gpio.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gpio.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gptimer.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\i2c_lib.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\i2c_lib.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\i2c_lib.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\interrupt.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\interrupt.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\interrupt.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ioc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ioc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ioc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\pka.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\pka.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\pka.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\rom.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\rom.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sha256.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sha256.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sha256.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sleepmode.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sleepmode.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sleepmode.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ssi.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\ssi.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ssi.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sys_ctrl.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sys_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sys_ctrl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\systick.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\systick.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\systick.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\uarthal.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\uarthal.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\uarthal.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\udma.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\udma.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\udma.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\watchdog.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\watchdog.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\watchdog.h</name>\n</file>\n</group>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\adc_sensor.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\adc_sensor.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\board.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\board.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\board_info.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\board_info.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\bsp_timer.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\bsp_timer.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538rf.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538rf.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\debugpins.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\radio.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\radiotimer.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\radiotimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\sctimer.c</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\sctimer.h</name>\n" }, { "change_type": "MODIFY", "old_path": "projects/telosb/03oos_openwsn/03oos_openwsn.ewp", "new_path": "projects/telosb/03oos_openwsn/03oos_openwsn.ewp", "diff": "<state>$PROJ_DIR$\\..\\..\\..\\openapps\\csensors\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cstorm\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cwellknown\\</state>\n+ <state>$PROJ_DIR$\\..\\..\\..\\openapps\\opencoap\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\rrt\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\techo\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\tohlone\\</state>\n<name>$PROJ_DIR$\\..\\..\\..\\openapps\\cwellknown\\cwellknown.h</name>\n</file>\n</group>\n+ <group>\n+ <name>opencoap</name>\n+ <file>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\opencoap\\opencoap.c</name>\n+ </file>\n+ <file>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\opencoap\\opencoap.h</name>\n+ </file>\n+ </group>\n<group>\n<name>rrt</name>\n<file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\neighbors.h</name>\n</file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\processIE.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\processIE.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\schedule.c</name>\n</file>\n</group>\n<group>\n<name>04-TRAN</name>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\opencoap.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\opencoap.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\opentcp.c</name>\n</file>\n" }, { "change_type": "MODIFY", "old_path": "projects/telosb/telosb.eww", "new_path": "projects/telosb/telosb.eww", "diff": "<project>\n<path>$WS_DIR$\\02drv_opentimers\\02drv_opentimers.ewp</path>\n</project>\n- <project>\n- <path>$WS_DIR$\\02drv_opentimers2\\02drv_opentimers2.ewp</path>\n- </project>\n<project>\n<path>$WS_DIR$\\03oos_macpong\\03oos_macpong.ewp</path>\n</project>\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-652. add timer wrapping and PERIODIC tyupe timer in opentimers.
491,595
14.06.2017 18:28:05
-7,200
ae576a5cf36f9be955441a192e93cfd128dc7a1d
fix the oos_macpong, oos_sniffer project and python platform.
[ { "change_type": "MODIFY", "old_path": "projects/common/03oos_macpong/03oos_macpong.c", "new_path": "projects/common/03oos_macpong/03oos_macpong.c", "diff": "@@ -58,10 +58,11 @@ void macpong_initSend() {\ndefault:\nbreak;\n}\n- opentimers_scheduleRelative(\n+ opentimers_scheduleIn(\nmacpong_vars.timerId, // timerId\n1000, // duration\nTIME_MS, // timetype\n+ TIMER_ONESHOT,\nmacpong_initSend // callback\n);\n" }, { "change_type": "MODIFY", "old_path": "projects/common/03oos_sniffer/03oos_sniffer.c", "new_path": "projects/common/03oos_sniffer/03oos_sniffer.c", "diff": "@@ -154,10 +154,11 @@ void cb_endFrame(PORT_TIMER_WIDTH timestamp) {\nvoid cb_timer(void) {\n// schedule again\n- opentimers_scheduleRelative(\n+ opentimers_scheduleIn(\napp_vars.timerId, // timerId\nTIMER_PERIOD, // duration\nTIME_TICS, // timetype\n+ TIMER_ONESHOT, // timertype\ncb_timer // callback\n);\napp_vars.outputOrInput = (app_vars.outputOrInput+1)%2;\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -413,7 +413,7 @@ functionsToChange = [\n# opentimers\n'opentimers_init',\n'opentimers_create',\n- 'opentimers_scheduleRelative',\n+ 'opentimers_scheduleIn',\n'opentimers_scheduleAbsolute',\n'opentimers_cancel',\n'opentimers_destroy',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-652. fix the oos_macpong, oos_sniffer project and python platform.
491,586
15.06.2017 15:11:50
-19,080
0821aee3413daba6357ef9d2aac8e3a4ba6d2a54
disabled some boards due to memory constraint
[ { "change_type": "MODIFY", "old_path": "SConstruct", "new_path": "SConstruct", "diff": "@@ -101,10 +101,10 @@ help-option:\ncommand_line_options = {\n'board': [\n# MSP430\n- 'telosb',\n+ #'telosb',\n'gina',\n- 'wsn430v13b',\n- 'wsn430v14',\n+ #'wsn430v13b',\n+ #'wsn430v14',\n'z1',\n# Cortex-M3\n'openmote-cc2538',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
disabled some boards due to memory constraint
491,595
15.06.2017 15:33:31
-7,200
92fb97cb05b33ce1a7681f9312e4bb61d09ec3c4
rename the interface.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -68,9 +68,14 @@ bool isValidJoin(OpenQueueEntry_t* eb, ieee802154_header_iht *parsedHeader);\nbool isValidEbFormat(OpenQueueEntry_t* pkt);\n// IEs Handling\nbool ieee154e_processIEs(OpenQueueEntry_t* pkt, uint16_t* lenIE);\n+void timeslotTemplateIDStoreFromEB(uint8_t id);\n+void channelhoppingTemplateIDStoreFromEB(uint8_t id);\n// ASN handling\nvoid incrementAsnOffset(void);\nvoid ieee154e_resetAsn(void);\n+void ieee154e_syncSlotOffset(void);\n+void asnStoreFromEB(uint8_t* asn);\n+void joinPriorityStoreFromEB(uint8_t jp);\n// synchronization\nvoid synchronizePacket(PORT_TIMER_WIDTH timeReceived);\nvoid synchronizeAck(PORT_SIGNED_INT_WIDTH timeCorrection);\n@@ -2296,19 +2301,12 @@ uint16_t ieee154e_getSlotDuration(){\n}\n// timeslot template handling\n-port_INLINE void ieee154e_timeslotTemplateIDStoreFromEB(uint8_t* pkt,uint8_t* ptr){\n- ieee154e_vars.tsTemplateId = *pkt;\n- *ptr = *ptr+1;\n- if (ieee154e_vars.tsTemplateId != TIMESLOT_TEMPLATE_ID){\n- ieee154e_vars.slotDuration = (uint16_t)(*((pkt)+*ptr));\n- *ptr = *ptr+1;\n- ieee154e_vars.slotDuration |= (uint16_t)(((*((pkt)+*ptr))<<8) & 0xff00);\n- *ptr = *ptr+1;\n- }\n+port_INLINE void timeslotTemplateIDStoreFromEB(uint8_t id){\n+ ieee154e_vars.tsTemplateId = id;\n}\n// channelhopping template handling\n-port_INLINE void ieee154e_channelhoppingTemplateIDStoreFromEB(uint8_t id){\n+port_INLINE void channelhoppingTemplateIDStoreFromEB(uint8_t id){\nieee154e_vars.chTemplateId = id;\n}\n//======= synchronization\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "@@ -294,17 +294,8 @@ void ieee154e_setSingleChannel(uint8_t channel);\nvoid ieee154e_setIsSecurityEnabled(bool isEnabled);\nvoid ieee154e_setSlotDuration(uint16_t duration);\nuint16_t ieee154e_getSlotDuration(void);\n-void ieee154e_syncSlotOffset(void);\nuint16_t ieee154e_getTimeCorrection(void);\n-\n-void ieee154e_asnStoreFromEB(uint8_t* asn);\n-void ieee154e_joinPriorityStoreFromEB(uint8_t jp);\n-\n-// timeslot template handling\n-void ieee154e_timeslotTemplateIDStoreFromEB(uint8_t* pkt,uint8_t* ptr);\n-// channelhopping template handling\n-void ieee154e_channelhoppingTemplateIDStoreFromEB(uint8_t id);\n// events\nvoid ieee154e_startOfFrame(PORT_TIMER_WIDTH capturedTime);\nvoid ieee154e_endOfFrame(PORT_TIMER_WIDTH capturedTime);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-631. rename the IEEE802154E interface.
491,595
15.06.2017 15:38:20
-7,200
902444bce4f4dcbbeed52c0ff513c7cc079ea5ca
update the comments of opentimers
[ { "change_type": "MODIFY", "old_path": "drivers/common/opentimers.c", "new_path": "drivers/common/opentimers.c", "diff": "@@ -64,14 +64,12 @@ opentimers_id_t opentimers_create(void){\n\\brief schedule a period refer to comparing value set last time.\nThis function will schedule a timer which expires when the timer count reach\n-to lastCompareValue + duration.\n-\n-Note: as this function schedule time depending on last compare value. It\n-can't be called firstly after the timer is created.\n+to current counter + duration.\n\\param[in] id indicates the timer id\n\\param[in] duration indicates the period asked for schedule since last comparing value\n\\param[in] uint_type indicates the unit type of this schedule: ticks or ms\n+\\param[in] timer_type indicates the timer type of this schedule: oneshot or periodic\n\\param[in] cb indicates when this scheduled timer fired, call this callback function.\n*/\nvoid opentimers_scheduleIn(opentimers_id_t id,\n@@ -167,7 +165,8 @@ void opentimers_scheduleIn(opentimers_id_t id,\n\\brief schedule a period refer to given reference.\nThis function will schedule a timer which expires when the timer count reach\n-to lastCompareValue + reference.\n+to duration + reference. This function will be used in the implementation of slot FSM.\n+All timers use this function are ONE_SHOT type timer.\n\\param[in] id indicates the timer id\n\\param[in] duration indicates the period asked for schedule after a given time indicated by reference parameter.\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-631. update the comments of opentimers
491,609
14.06.2017 15:50:05
-7,200
22b003ce4d1ec58315962ce1cd4a81624746b497
Prefix cryptoengine functions.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/common/aes_cbc.c", "new_path": "bsp/boards/common/aes_cbc.c", "diff": "@@ -34,7 +34,7 @@ owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t\nfor (k = 0; k < 16; k++) {\npbuf[k] ^= pxor[k];\n}\n- aes_ecb_enc(pbuf,key);\n+ cryptoengine_aes_ecb_enc(pbuf,key);\npxor = pbuf;\n}\nreturn E_SUCCESS;\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/common/aes_ctr.c", "new_path": "bsp/boards/common/aes_ctr.c", "diff": "@@ -42,7 +42,7 @@ owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t\nfor (n = 0; n < nb; n++) {\npbuf = &buffer[16 * n];\nmemcpy(eiv, iv, 16);\n- aes_ecb_enc(eiv, key);\n+ cryptoengine_aes_ecb_enc(eiv, key);\n// may be faster if vector are aligned to 4 bytes (use long instead char in xor)\nfor (k = 0; k < 16; k++) {\npbuf[k] ^= eiv[k];\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/cryptoengine.h", "new_path": "bsp/boards/cryptoengine.h", "diff": "\\param[in] key Buffer containing the secret key (16 octets).\n\\param[in] len_mac Length of the authentication tag.\n*/\n-owerror_t aes_ccms_enc(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -52,7 +52,7 @@ owerror_t aes_ccms_enc(uint8_t* a,\n\\param[in] key Buffer containing the secret key (16 octets).\n\\param[in] len_mac Length of the authentication tag.\n*/\n-owerror_t aes_ccms_dec(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -66,10 +66,10 @@ owerror_t aes_ccms_dec(uint8_t* a,\n\\param[in,out] buffer Single block plaintext (16 octets). Will be overwritten by ciphertext.\n\\param[in] key Buffer containing the secret key (16 octets).\n*/\n-owerror_t aes_ecb_enc(uint8_t buffer[16], uint8_t key[16]);\n+owerror_t cryptoengine_aes_ecb_enc(uint8_t buffer[16], uint8_t key[16]);\n/**\n-\\brief Initialization of the crypto_engine driver.\n+\\brief Initialization of the cryptoengine module.\n*/\nowerror_t cryptoengine_init(void);\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/openmote-cc2538/cryptoengine.c", "new_path": "bsp/boards/openmote-cc2538/cryptoengine.c", "diff": "@@ -32,7 +32,7 @@ owerror_t cryptoengine_init(void) {\nreturn E_SUCCESS;\n}\n-owerror_t aes_ccms_enc(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -76,7 +76,7 @@ owerror_t aes_ccms_enc(uint8_t* a,\nreturn E_FAIL;\n}\n-owerror_t aes_ccms_dec(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -121,7 +121,7 @@ owerror_t aes_ccms_dec(uint8_t* a,\nreturn E_FAIL;\n}\n-owerror_t aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\n+owerror_t cryptoengine_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\nuint8_t key_location;\nif(load_key(key, &key_location) == E_SUCCESS) {\n// Polling\n" }, { "change_type": "MODIFY", "old_path": "projects/common/01bsp_cryptoengine/01bsp_cryptoengine.c", "new_path": "projects/common/01bsp_cryptoengine/01bsp_cryptoengine.c", "diff": "@@ -86,7 +86,7 @@ static owerror_t run_aes_ecb_suite(aes_ecb_suite_t* suite, uint8_t test_suite_le\nuint8_t success = 0;\nfor(i = 0; i < test_suite_len; i++) {\n- if(aes_ecb_enc(suite[i].buffer, suite[i].key) == E_SUCCESS) {\n+ if(cryptoengine_aes_ecb_enc(suite[i].buffer, suite[i].key) == E_SUCCESS) {\nif (memcmp(suite[i].buffer, suite[i].expected_ciphertext, 16) == 0) {\nsuccess++;\n}\n@@ -103,7 +103,7 @@ static owerror_t run_aes_ccms_enc_suite(aes_ccms_enc_suite_t* suite, uint8_t tes\nuint8_t success = 0;\nfor(i = 0; i < test_suite_len; i++) {\n- if(aes_ccms_enc(suite[i].a,\n+ if(cryptoengine_aes_ccms_enc(suite[i].a,\nsuite[i].len_a,\nsuite[i].m,\n&suite[i].len_m,\n@@ -128,7 +128,7 @@ static owerror_t run_aes_ccms_dec_suite(aes_ccms_dec_suite_t* suite, uint8_t tes\nfor(i = 0; i < test_suite_len; i++) {\n- if(aes_ccms_dec(suite[i].a,\n+ if(cryptoengine_aes_ccms_dec(suite[i].a,\nsuite[i].len_a,\nsuite[i].c,\n&suite[i].len_c,\n@@ -153,7 +153,7 @@ static owerror_t run_aes_ccms_auth_forward_suite(aes_ccms_auth_forward_suite_t*\nuint8_t success = 0;\nfor(i = 0; i < test_suite_len; i++) {\n- if(aes_ccms_enc(suite[i].a,\n+ if(cryptoengine_aes_ccms_enc(suite[i].a,\nsuite[i].len_a,\nsuite[i].m,\n&suite[i].len_m,\n@@ -179,7 +179,7 @@ static owerror_t run_aes_ccms_auth_inverse_suite(aes_ccms_auth_forward_suite_t*\nfor(i = 0; i < test_suite_len; i++) {\n- if(aes_ccms_dec(suite[i].a,\n+ if(cryptoengine_aes_ccms_dec(suite[i].a,\nsuite[i].len_a,\nsuite[i].m,\n&suite[i].len_m,\n@@ -390,7 +390,7 @@ int mote_main(void) {\nPORT_TIMER_WIDTH dec = 0;\ntime1 = bsp_timer_get_currentValue();\n- ret = aes_ccms_enc(a,\n+ ret = cryptoengine_aes_ccms_enc(a,\nA_LEN,\nm,\n&len_m,\n@@ -408,7 +408,7 @@ int mote_main(void) {\n}\ntime1 = bsp_timer_get_currentValue();\n- ret = aes_ccms_dec(a,\n+ ret = cryptoengine_aes_ccms_dec(a,\nA_LEN,\nm,\n&len_m,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Prefix cryptoengine functions.
491,609
14.06.2017 16:01:43
-7,200
7fdef8a48a3902425d8186647a812faa72a54eb3
Use new cryptoengine API in the oos_openwsn project.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.c", "new_path": "openstack/02a-MAClow/IEEE802154_security.c", "diff": "*/\n#include \"packetfunctions.h\"\n-#include \"crypto_engine.h\"\n+#include \"cryptoengine.h\"\n#include \"IEEE802154.h\"\n#include \"IEEE802154E.h\"\n#include \"idmanager.h\"\n@@ -375,8 +375,8 @@ owerror_t IEEE802154_security_outgoingFrameSecurity(OpenQueueEntry_t* msg){\n}\n//Encryption and/or authentication\n- // CRYPTO_ENGINE overwrites m[] with ciphertext and appends the MIC\n- outStatus = CRYPTO_ENGINE.aes_ccms_enc(a,\n+ // cryptoengine overwrites m[] with ciphertext and appends the MIC\n+ outStatus = cryptoengine_aes_ccms_enc(a,\nlen_a,\nm,\n&len_m,\n@@ -622,7 +622,7 @@ owerror_t IEEE802154_security_incomingFrame(OpenQueueEntry_t* msg){\n}\n//decrypt and/or verify authenticity of the frame\n- outStatus = CRYPTO_ENGINE.aes_ccms_dec(a,\n+ outStatus = cryptoengine_aes_ccms_dec(a,\nlen_a,\nc,\n&len_c,\n" }, { "change_type": "MODIFY", "old_path": "projects/common/03oos_openwsn/03oos_openwsn.c", "new_path": "projects/common/03oos_openwsn/03oos_openwsn.c", "diff": "*/\n#include \"board.h\"\n-#include \"crypto_engine.h\"\n#include \"scheduler.h\"\n#include \"openstack.h\"\n#include \"opendefs.h\"\n@@ -14,7 +13,6 @@ int mote_main(void) {\n// initialize\nboard_init();\n- CRYPTO_ENGINE.init();\nscheduler_init();\nopenstack_init();\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Use new cryptoengine API in the oos_openwsn project.
491,609
14.06.2017 16:39:00
-7,200
f88b54d194d48582a24d1954bc4ba7037993e348
Initial commit on refactoring security implementation.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154.c", "new_path": "openstack/02a-MAClow/IEEE802154.c", "diff": "#include \"idmanager.h\"\n#include \"openserial.h\"\n#include \"topology.h\"\n-#include \"ieee802154_security_driver.h\"\n+#include \"IEEE802154_security.h\"\n//=========================== define ==========================================\n@@ -103,7 +103,7 @@ void ieee802154_prependHeader(OpenQueueEntry_t* msg,\n//if security is enabled, the Auxiliary Security Header need to be added to the IEEE802.15.4 MAC header\nif(securityEnabled){\n- IEEE802154_SECURITY.prependAuxiliarySecurityHeader(msg);\n+ IEEE802154_security_prependAuxiliarySecurityHeader(msg);\n}\n// previousHop address (always 64-bit)\n@@ -333,7 +333,7 @@ void ieee802154_retrieveHeader(OpenQueueEntry_t* msg,\n// - received unsecured frame and security disabled locally\n// - received secured frame and security is enabled locally\nif (ieee802514_header->securityEnabled && IEEE802154_SECURITY_SUPPORTED) {\n- IEEE802154_SECURITY.retrieveAuxiliarySecurityHeader(msg,ieee802514_header);\n+ IEEE802154_security_retrieveAuxiliarySecurityHeader(msg,ieee802514_header);\n}\nelse if (ieee802514_header->securityEnabled != IEEE802154_SECURITY_SUPPORTED) { return; }\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "#include \"IEEE802154E.h\"\n#include \"radio.h\"\n#include \"IEEE802154.h\"\n-#include \"ieee802154_security_driver.h\"\n+#include \"IEEE802154_security.h\"\n#include \"openqueue.h\"\n#include \"idmanager.h\"\n#include \"openserial.h\"\n@@ -152,6 +152,8 @@ void ieee154e_init() {\nisr_ieee154e_newSlot // callback\n);\n// radiotimer_start(ieee154e_vars.slotDuration);\n+ //\n+ IEEE802154_security_init();\n}\n//=========================== public ==========================================\n@@ -893,7 +895,7 @@ port_INLINE void activity_ti1ORri1() {\n// check if packet needs to be encrypted/authenticated before transmission\nif (ieee154e_vars.localCopyForTransmission.l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) { // security enabled\n// encrypt in a local copy\n- if (IEEE802154_SECURITY.outgoingFrame(&ieee154e_vars.localCopyForTransmission) != E_SUCCESS) {\n+ if (IEEE802154_security_outgoingFrameSecurity(&ieee154e_vars.localCopyForTransmission) != E_SUCCESS) {\n// keep the frame in the OpenQueue in order to retry later\nendSlot(); // abort\nreturn;\n@@ -1040,7 +1042,7 @@ port_INLINE void activity_ti2() {\n// check if packet needs to be encrypted/authenticated before transmission\nif (ieee154e_vars.localCopyForTransmission.l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) { // security enabled\n// encrypt in a local copy\n- if (IEEE802154_SECURITY.outgoingFrame(&ieee154e_vars.localCopyForTransmission) != E_SUCCESS) {\n+ if (IEEE802154_security_outgoingFrameSecurity(&ieee154e_vars.localCopyForTransmission) != E_SUCCESS) {\n// keep the frame in the OpenQueue in order to retry later\nendSlot(); // abort\nreturn;\n@@ -1454,7 +1456,7 @@ port_INLINE void activity_ti9(PORT_TIMER_WIDTH capturedTime) {\n// check the security level of the ACK frame and decrypt/authenticate\nif (ieee154e_vars.ackReceived->l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) {\n- if (IEEE802154_SECURITY.incomingFrame(ieee154e_vars.ackReceived) != E_SUCCESS) {\n+ if (IEEE802154_security_incomingFrame(ieee154e_vars.ackReceived) != E_SUCCESS) {\nbreak;\n}\n} // checked if unsecured frame should pass during header retrieval\n@@ -1708,7 +1710,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) {\n// if security is enabled, decrypt/authenticate the frame.\nif (ieee154e_vars.dataReceived->l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) {\n- if (IEEE802154_SECURITY.incomingFrame(ieee154e_vars.dataReceived) != E_SUCCESS) {\n+ if (IEEE802154_security_incomingFrame(ieee154e_vars.dataReceived) != E_SUCCESS) {\nbreak;\n}\n} // checked if unsecured frame should pass during header retrieval\n@@ -1790,7 +1792,7 @@ port_INLINE void activity_ri5(PORT_TIMER_WIDTH capturedTime) {\n// if security is enabled, encrypt directly in OpenQueue as there are no retransmissions for ACKs\nif (ieee154e_vars.ackToSend->l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) {\n- if (IEEE802154_SECURITY.outgoingFrame(ieee154e_vars.ackToSend) != E_SUCCESS) {\n+ if (IEEE802154_security_outgoingFrameSecurity(ieee154e_vars.ackToSend) != E_SUCCESS) {\nopenqueue_freePacketBuffer(ieee154e_vars.ackToSend);\nendSlot();\nreturn;\n@@ -1907,7 +1909,7 @@ port_INLINE void activity_ri6() {\n// if security is enabled, encrypt directly in OpenQueue as there are no retransmissions for ACKs\nif (ieee154e_vars.ackToSend->l2_securityLevel != IEEE154_ASH_SLF_TYPE_NOSEC) {\n- if (IEEE802154_SECURITY.outgoingFrame(ieee154e_vars.ackToSend) != E_SUCCESS) {\n+ if (IEEE802154_security_outgoingFrameSecurity(ieee154e_vars.ackToSend) != E_SUCCESS) {\nopenqueue_freePacketBuffer(ieee154e_vars.ackToSend);\nendSlot();\nreturn;\n@@ -2205,7 +2207,7 @@ bool isValidJoin(OpenQueueEntry_t* eb, ieee802154_header_iht *parsedHeader) {\npacketfunctions_reserveHeaderSize(eb, parsedHeader->headerLength);\n// verify EB's authentication tag\n- if (IEEE802154_SECURITY.incomingFrame(eb) == E_SUCCESS) {\n+ if (IEEE802154_security_incomingFrame(eb) == E_SUCCESS) {\nreturn TRUE;\n}\n" }, { "change_type": "DELETE", "old_path": "openstack/02a-MAClow/IEEE802154_dummy_security.c", "new_path": null, "diff": "-/**\n-\\brief Dummy IEEE802154 security implementation that is linked when security is disabled.\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, June 2015.\n-*/\n-\n-#include \"IEEE802154_dummy_security.h\"\n-\n-static void init(void) {\n- return;\n-}\n-\n-static void prependAuxiliarySecurityHeader(OpenQueueEntry_t* msg){\n- return;\n-}\n-\n-static void retrieveAuxiliarySecurityHeader(OpenQueueEntry_t* msg, ieee802154_header_iht* tempheader) {\n- return;\n-}\n-\n-static owerror_t outgoingFrame(OpenQueueEntry_t* msg) {\n- return E_SUCCESS;\n-}\n-\n-static owerror_t incomingFrame(OpenQueueEntry_t* msg) {\n- return E_SUCCESS;\n-}\n-\n-static uint8_t authenticationTagLen(uint8_t sec_level) {\n- return (uint8_t) 0;\n-}\n-\n-static uint8_t auxiliaryHeaderLen(uint8_t kid, uint8_t sup, uint8_t size) {\n- return (uint8_t) 0;\n-}\n-\n-/*---------------------------------------------------------------------------*/\n-const struct ieee802154_security_driver IEEE802154_dummy_security = {\n- init,\n- prependAuxiliarySecurityHeader,\n- retrieveAuxiliarySecurityHeader,\n- outgoingFrame,\n- incomingFrame,\n- authenticationTagLen,\n- auxiliaryHeaderLen,\n-};\n-/*---------------------------------------------------------------------------*/\n-\n" }, { "change_type": "DELETE", "old_path": "openstack/02a-MAClow/IEEE802154_dummy_security.h", "new_path": null, "diff": "-/**\n-\\brief Dummy IEEE802154 security implementation header that is used when security is disabled.\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, June 2015.\n-*/\n-\n-#ifndef __IEEE802154_DUMMY_SECURITY_H__\n-#define __IEEE802154_DUMMY_SECURITY_H__\n-\n-#include \"ieee802154_security_driver.h\"\n-\n-extern const struct ieee802154_security_driver IEEE802154_dummy_security;\n-\n-#endif /* __IEEE802154_DUMMY_SECURITY_H__ */\n-\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.c", "new_path": "openstack/02a-MAClow/IEEE802154_security.c", "diff": "@@ -911,15 +911,3 @@ void IEEE802154_security_getFrameCounter(macFrameCounter_t reference,\narray[4] = reference.byte4;\n}\n-/*---------------------------------------------------------------------------*/\n-const struct ieee802154_security_driver IEEE802154_security = {\n- IEEE802154_security_init,\n- IEEE802154_security_prependAuxiliarySecurityHeader,\n- IEEE802154_security_retrieveAuxiliarySecurityHeader,\n- IEEE802154_security_outgoingFrameSecurity,\n- IEEE802154_security_incomingFrame,\n- IEEE802154_security_authLengthChecking,\n- IEEE802154_security_auxLengthChecking,\n-};\n-/*---------------------------------------------------------------------------*/\n-\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.h", "new_path": "openstack/02a-MAClow/IEEE802154_security.h", "diff": "*/\n#include \"opendefs.h\"\n-#include \"ieee802154_security_driver.h\"\n#include \"neighbors.h\"\n//=========================== define ==========================================\n#define MAXNUMKEYS MAXNUMNEIGHBORS+1\n+#ifdef L2_SECURITY_ACTIVE // Configuring security levels\n+#define IEEE802154_SECURITY_SUPPORTED 1\n+#define IEEE802154_SECURITY_LEVEL IEEE154_ASH_SLF_TYPE_ENC_MIC_32 // encryption + 4 byte authentication tag\n+#define IEEE802154_SECURITY_LEVEL_BEACON IEEE154_ASH_SLF_TYPE_MIC_32 // authentication tag len used for beacons must match the tag len of other frames\n+#define IEEE802154_SECURITY_KEYIDMODE IEEE154_ASH_KEYIDMODE_DEFAULTKEYSOURCE\n+#define IEEE802154_SECURITY_K1_KEY_INDEX 1\n+#define IEEE802154_SECURITY_K2_KEY_INDEX 2\n+#define IEEE802154_SECURITY_TAG_LEN IEEE802154_security_authLengthChecking(IEEE802154_SECURITY_LEVEL)\n+#define IEEE802154_SECURITY_HEADER_LEN IEEE802154_security_auxLengthChecking(IEEE802154_SECURITY_KEYIDMODE, IEEE154_ASH_FRAMECOUNTER_SUPPRESSED, 5) // For TSCH we always use implicit 5 byte ASN as Frame Counter\n+#define IEEE802154_SECURITY_TOTAL_OVERHEAD IEEE802154_SECURITY_TAG_LEN + IEEE802154_SECURITY_HEADER_LEN\n+#define IEEE802154_SECURITY_MINIMAL_PROC 0 // minimal processing for efficiency\n+#else /* L2_SECURITY_ACTIVE */\n+#define IEEE802154_SECURITY_SUPPORTED 0\n+#define IEEE802154_SECURITY_LEVEL IEEE154_ASH_SLF_TYPE_NOSEC\n+#define IEEE802154_SECURITY_LEVEL_BEACON IEEE154_ASH_SLF_TYPE_NOSEC\n+#define IEEE802154_SECURITY_KEYIDMODE 0\n+#define IEEE802154_SECURITY_K1_KEY_INDEX 0\n+#define IEEE802154_SECURITY_K2_KEY_INDEX 0\n+#define IEEE802154_SECURITY_TAG_LEN 0\n+#define IEEE802154_SECURITY_HEADER_LEN 0\n+#define IEEE802154_SECURITY_TOTAL_OVERHEAD 0\n+#define IEEE802154_SECURITY_MINIMAL_PROC 0\n+#endif /* L2_SECURITY_ACTIVE */\n+\n//=========================== typedef =========================================\ntypedef struct{//identifier of the device which is using the key\n@@ -92,10 +115,23 @@ typedef struct{\nuint8_t minimal;\n} ieee802154_security_vars_t;\n-extern const struct ieee802154_security_driver IEEE802154_security;\n-\n//=========================== prototypes ======================================\n+void IEEE802154_security_init(void);\n+\n+void IEEE802154_security_prependAuxiliarySecurityHeader(OpenQueueEntry_t* msg);\n+\n+void IEEE802154_security_retrieveAuxiliarySecurityHeader(OpenQueueEntry_t* msg, ieee802154_header_iht* tempheader);\n+\n+owerror_t IEEE802154_security_outgoingFrameSecurity(OpenQueueEntry_t* msg);\n+\n+owerror_t IEEE802154_security_incomingFrame(OpenQueueEntry_t* msg);\n+\n+uint8_t IEEE802154_security_authLengthChecking(uint8_t);\n+\n+uint8_t IEEE802154_security_auxLengthChecking(uint8_t keyIdMode, uint8_t frameCounterSuppression, uint8_t frameCounterSize);\n+\n+\n/**\n\\}\n\\}\n" }, { "change_type": "DELETE", "old_path": "openstack/02a-MAClow/ieee802154_security_driver.h", "new_path": null, "diff": "-/**\n-\\brief Definitions for IEEE802154_security driver\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, June 2015.\n-*/\n-#ifndef __IEEE802154_SECURITY_DRIVER_H__\n-#define __IEEE802154_SECURITY_DRIVER_H__\n-\n-#include \"opendefs.h\"\n-#include \"IEEE802154.h\"\n-\n-//=========================== define ==========================================\n-#ifdef L2_SECURITY_ACTIVE // Configuring security levels\n-#define IEEE802154_SECURITY IEEE802154_security // implementation\n-#define IEEE802154_SECURITY_SUPPORTED 1\n-#define IEEE802154_SECURITY_LEVEL IEEE154_ASH_SLF_TYPE_ENC_MIC_32 // encryption + 4 byte authentication tag\n-#define IEEE802154_SECURITY_LEVEL_BEACON IEEE154_ASH_SLF_TYPE_MIC_32 // authentication tag len used for beacons must match the tag len of other frames\n-#define IEEE802154_SECURITY_KEYIDMODE IEEE154_ASH_KEYIDMODE_DEFAULTKEYSOURCE\n-#define IEEE802154_SECURITY_K1_KEY_INDEX 1\n-#define IEEE802154_SECURITY_K2_KEY_INDEX 2\n-#define IEEE802154_SECURITY_TAG_LEN IEEE802154_SECURITY.authenticationTagLen(IEEE802154_SECURITY_LEVEL)\n-#define IEEE802154_SECURITY_HEADER_LEN IEEE802154_SECURITY.auxiliaryHeaderLen(IEEE802154_SECURITY_KEYIDMODE, IEEE154_ASH_FRAMECOUNTER_SUPPRESSED, 5) // For TSCH we always use implicit 5 byte ASN as Frame Counter\n-#define IEEE802154_SECURITY_TOTAL_OVERHEAD IEEE802154_SECURITY_TAG_LEN + IEEE802154_SECURITY_HEADER_LEN\n-#define IEEE802154_SECURITY_MINIMAL_PROC 0 // minimal processing for efficiency\n-#else /* L2_SECURITY_ACTIVE */\n-#define IEEE802154_SECURITY IEEE802154_dummy_security // dummy implementation that always returns success\n-#define IEEE802154_SECURITY_SUPPORTED 0\n-#define IEEE802154_SECURITY_LEVEL IEEE154_ASH_SLF_TYPE_NOSEC\n-#define IEEE802154_SECURITY_LEVEL_BEACON IEEE154_ASH_SLF_TYPE_NOSEC\n-#define IEEE802154_SECURITY_KEYIDMODE 0\n-#define IEEE802154_SECURITY_K1_KEY_INDEX 0\n-#define IEEE802154_SECURITY_K2_KEY_INDEX 0\n-#define IEEE802154_SECURITY_TAG_LEN 0\n-#define IEEE802154_SECURITY_HEADER_LEN 0\n-#define IEEE802154_SECURITY_TOTAL_OVERHEAD 0\n-#define IEEE802154_SECURITY_MINIMAL_PROC 0\n-#endif /* L2_SECURITY_ACTIVE */\n-\n-//=========================== module variables ================================\n-\n-struct ieee802154_security_driver {\n-\n- void (* init)(void);\n-\n- void (* prependAuxiliarySecurityHeader)(OpenQueueEntry_t* msg);\n-\n- void (* retrieveAuxiliarySecurityHeader)(OpenQueueEntry_t* msg, ieee802154_header_iht* tempheader);\n-\n- owerror_t (* outgoingFrame)(OpenQueueEntry_t* msg);\n-\n- owerror_t (* incomingFrame)(OpenQueueEntry_t* msg);\n-\n- uint8_t (* authenticationTagLen)(uint8_t);\n-\n- uint8_t (* auxiliaryHeaderLen)(uint8_t keyIdMode, uint8_t frameCounterSuppression, uint8_t frameCounterSize);\n-\n-}; // struct ieee802154_security_driver\n-\n-extern const struct ieee802154_security_driver IEEE802154_SECURITY;\n-\n-#endif /* __IEEE802154_SECURITY_DRIVER_H__ */\n-\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -13,7 +13,6 @@ sources_c = [\nos.path.join('02a-MAClow','IEEE802154E.c'),\n# os.path.join('02a-MAClow','adaptive_sync.c'),\nos.path.join('02a-MAClow','IEEE802154_security.c'),\n- os.path.join('02a-MAClow','IEEE802154_dummy_security.c'),\n#=== 02b-MAChigh\nos.path.join('02b-MAChigh','neighbors.c'),\nos.path.join('02b-MAChigh','sf0.c'),\n@@ -42,9 +41,7 @@ sources_h = [\nos.path.join('02a-MAClow','IEEE802154.h'),\nos.path.join('02a-MAClow','IEEE802154E.h'),\nos.path.join('02a-MAClow','adaptive_sync.h'),\n- os.path.join('02a-MAClow','ieee802154_security_driver.h'),\nos.path.join('02a-MAClow','IEEE802154_security.h'),\n- os.path.join('02a-MAClow','IEEE802154_dummy_security.h'),\n#=== 02b-MAChigh\nos.path.join('02b-MAChigh','neighbors.h'),\nos.path.join('02b-MAChigh','sf0.h'),\n" }, { "change_type": "MODIFY", "old_path": "openstack/cross-layers/openqueue.c", "new_path": "openstack/cross-layers/openqueue.c", "diff": "#include \"openserial.h\"\n#include \"packetfunctions.h\"\n#include \"IEEE802154E.h\"\n-#include \"ieee802154_security_driver.h\"\n-\n+#include \"IEEE802154_security.h\"\n//=========================== defination =====================================\n" }, { "change_type": "MODIFY", "old_path": "openstack/openstack.c", "new_path": "openstack/openstack.c", "diff": "//-- 02a-TSCH\n#include \"adaptive_sync.h\"\n#include \"IEEE802154E.h\"\n-#include \"ieee802154_security_driver.h\"\n//-- 02b-RES\n#include \"schedule.h\"\n#include \"sixtop.h\"\n@@ -59,7 +58,6 @@ void openstack_init(void) {\n//-- 02a-TSCH\n// adaptive_sync_init();\nieee154e_init();\n- IEEE802154_SECURITY.init();\n//-- 02b-RES\nschedule_init();\nsixtop_init();\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Initial commit on refactoring IEEE802154e security implementation.
491,609
14.06.2017 18:09:25
-7,200
41a870e29dcccbc27f58f28575e41ad484f0b153
Update TelosB for new cryptoengine API.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/telosb/SConscript", "new_path": "bsp/boards/telosb/SConscript", "diff": "@@ -30,7 +30,6 @@ source = [\n'leds.c',\n'spi.c',\n'uart.c',\n- 'board_crypto_engine.c',\n'adc_sensor.c',\n'sensors.c'\n]\n" }, { "change_type": "DELETE", "old_path": "bsp/boards/telosb/board_crypto_engine.c", "new_path": null, "diff": "-/**\n-\\brief Crypto engine implementation for TelosB (CC2420)\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, March 2015.\n-*/\n-#include <stdint.h>\n-#include \"board_crypto_engine.h\"\n-#include \"aes_ecb.h\"\n-#include \"aes_ctr.h\"\n-#include \"aes_cbc.h\"\n-#include \"aes_ccms.h\"\n-#include \"cc2420_crypto.h\"\n-#include \"radio.h\"\n-\n-static owerror_t init(void) {\n- radio_rfOn(); // turn the crystal oscillator on in order to access CC2420 RAM\n- return E_SUCCESS;\n-}\n-\n-/*---------------------------------------------------------------------------*/\n-const struct crypto_engine board_crypto_engine = {\n- cc2420_crypto_ccms_enc,\n- cc2420_crypto_ccms_dec,\n- aes_cbc_enc_raw,\n- aes_ctr_enc_raw,\n- cc2420_crypto_aes_ecb_enc, // AES stand-alone encryption\n- init,\n-};\n-/*---------------------------------------------------------------------------*/\n-\n" }, { "change_type": "DELETE", "old_path": "bsp/boards/telosb/board_crypto_engine.h", "new_path": null, "diff": "-/**\n-\\brief TelosB crypto engine implementation header\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, March 2015.\n-*/\n-#ifndef __BOARD_CRYPTO_ENGINE_H__\n-#define __BOARD_CRYPTO_ENGINE_H__\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-#include \"crypto_engine.h\"\n-\n-//=========================== module variables ================================\n-\n-extern const struct crypto_engine board_crypto_engine;\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* __BOARD_CRYPTO_ENGINE_H__ */\n-\n" }, { "change_type": "MODIFY", "old_path": "bsp/chips/cc2420/SConscript", "new_path": "bsp/chips/cc2420/SConscript", "diff": "@@ -7,7 +7,7 @@ Import('env')\nlocalEnv = env.Clone()\n-source = ['radio.c', 'cc2420.c', 'cc2420_crypto.c']\n+source = ['radio.c', 'cc2420.c', 'cryptoengine.c']\ncc2420 = localEnv.Object(\nsource=source,\n)\n" }, { "change_type": "DELETE", "old_path": "bsp/chips/cc2420/cc2420_crypto.h", "new_path": null, "diff": "-/**\n-\\brief CC2420-specific crypto library with hardware acceleration.\n-\n-\\author Malisa Vucinic <malishav@gmail.com>, April 2015.\n-*/\n-#ifndef __CC2420_CRYPTO_H__\n-#define __CC2420_CRYPTO_H__\n-\n-//=========================== SECCTRL0 values =================================\n-// SEC_MODE[1:0]\n-#define CC2420_SECCTRL0_SEC_MODE_DISABLE 0\n-#define CC2420_SECCTRL0_SEC_MODE_CBC_MAC 1\n-#define CC2420_SECCTRL0_SEC_MODE_CTR 2\n-#define CC2420_SECCTRL0_SEC_MODE_CCM 3\n-\n-//=========================== prototypes ======================================\n-\n-owerror_t cc2420_crypto_aes_ecb_enc(uint8_t* buffer, uint8_t* key);\n-\n-owerror_t cc2420_crypto_ccms_enc(uint8_t* a,\n- uint8_t len_a,\n- uint8_t* m,\n- uint8_t* len_m,\n- uint8_t* nonce,\n- uint8_t l,\n- uint8_t key[16],\n- uint8_t len_mac);\n-\n-owerror_t cc2420_crypto_ccms_dec(uint8_t* a,\n- uint8_t len_a,\n- uint8_t* m,\n- uint8_t* len_m,\n- uint8_t* nonce,\n- uint8_t l,\n- uint8_t key[16],\n- uint8_t len_mac);\n-\n-#endif /* __CC2420_CRYPTO_H__ */\n" }, { "change_type": "RENAME", "old_path": "bsp/chips/cc2420/cc2420_crypto.c", "new_path": "bsp/chips/cc2420/cryptoengine.c", "diff": "#include \"spi.h\"\n#include \"debugpins.h\"\n+\n+//=========================== defines =========================================\n+\n#define CC2420_KEY_LEN 16\n#define CC2420_FLAG_MIC_SUCCESS 0x00\n#define CC2420_FLAG_MIC_FAIL 0xFF\n+//=========================== SECCTRL0 values =================================\n+// SEC_MODE[1:0]\n+#define CC2420_SECCTRL0_SEC_MODE_DISABLE 0\n+#define CC2420_SECCTRL0_SEC_MODE_CBC_MAC 1\n+#define CC2420_SECCTRL0_SEC_MODE_CTR 2\n+#define CC2420_SECCTRL0_SEC_MODE_CCM 3\n+\n+\n// type of operation\n#define CC2420_SEC_STANDALONE CC2420_SECCTRL0_SEC_MODE_DISABLE\n#define CC2420_SEC_CBC_MAC CC2420_SECCTRL0_SEC_MODE_CBC_MAC\n#define CC2420_SEC_ENC 1\n#define CC2420_SEC_DEC 2\n+\n//=========================== prototypes ======================================\nstatic owerror_t cc2420_crypto_load_key(uint8_t key[16], uint8_t* /* out */ key_index);\n@@ -47,8 +59,13 @@ static void create_cc2420_nonce(uint8_t l,\nstatic void reverse(uint8_t* in, uint8_t len);\n//=========================== public ==========================================\n+owerror_t cryptoengine_init(void) {\n+ radio_rfOn(); // turn the crystal oscillator on in order to access CC2420 RAM\n+ return E_SUCCESS;\n+}\n+\n-owerror_t cc2420_crypto_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\n+owerror_t cryptoengine_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\ncc2420_status_t status;\nuint8_t key_index;\n@@ -73,7 +90,7 @@ owerror_t cc2420_crypto_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\nreturn E_FAIL;\n}\n-owerror_t cc2420_crypto_ccms_dec(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -148,7 +165,7 @@ owerror_t cc2420_crypto_ccms_dec(uint8_t* a,\n}\n-owerror_t cc2420_crypto_ccms_enc(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Update TelosB for new cryptoengine API.
491,609
14.06.2017 18:09:43
-7,200
12014d2a7d335d489d6da13cec6069d4116b99a4
Update bsp_cryptoengine project to account for the new sctimer.
[ { "change_type": "MODIFY", "old_path": "projects/common/01bsp_cryptoengine/01bsp_cryptoengine.c", "new_path": "projects/common/01bsp_cryptoengine/01bsp_cryptoengine.c", "diff": "@@ -17,7 +17,7 @@ tests passed. If there was an error, we use the Error LED to signal.\n#include \"board.h\"\n#include \"cryptoengine.h\"\n#include \"leds.h\"\n-#include \"bsp_timer.h\"\n+#include \"sctimer.h\"\n#define TEST_AES_ECB 1\n#define TEST_AES_CCMS_ENC 1\n@@ -389,7 +389,7 @@ int mote_main(void) {\nPORT_TIMER_WIDTH enc = 0;\nPORT_TIMER_WIDTH dec = 0;\n- time1 = bsp_timer_get_currentValue();\n+ time1 = sctimer_readCounter();\nret = cryptoengine_aes_ccms_enc(a,\nA_LEN,\nm,\n@@ -398,7 +398,7 @@ int mote_main(void) {\nL,\nkey,\nTAG_LEN);\n- time2 = bsp_timer_get_currentValue();\n+ time2 = sctimer_readCounter();\nif (ret == E_SUCCESS) {\nenc = time2 - time1;\n@@ -407,7 +407,7 @@ int mote_main(void) {\nfail++;\n}\n- time1 = bsp_timer_get_currentValue();\n+ time1 = sctimer_readCounter();\nret = cryptoengine_aes_ccms_dec(a,\nA_LEN,\nm,\n@@ -416,7 +416,7 @@ int mote_main(void) {\nL,\nkey,\nTAG_LEN);\n- time2 = bsp_timer_get_currentValue();\n+ time2 = sctimer_readCounter();\nif (ret == E_SUCCESS) {\ndec = time2 - time1;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Update bsp_cryptoengine project to account for the new sctimer.
491,609
14.06.2017 19:33:59
-7,200
8c32ff8ed8692ecfa2f28d3ba04c7817b639fd95
Update build for python and telosb.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/SConscript", "new_path": "bsp/boards/SConscript", "diff": "@@ -7,7 +7,7 @@ localEnv = env.Clone()\nsources_h = [\n'board.h',\n- 'crypto_engine.h',\n+ 'cryptoengine.h',\n'debugpins.h',\n'eui64.h',\n'leds.h',\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/python/SConscript", "new_path": "bsp/boards/python/SConscript", "diff": "@@ -16,6 +16,7 @@ sources_c = [\n'radio_obj.c',\n'sctimer_obj.c',\n'supply_obj.c',\n+ 'cryptoengine.c',\n]\n#============================ SCons targets ===================================\n" }, { "change_type": "ADD", "old_path": null, "new_path": "bsp/boards/python/cryptoengine.c", "diff": "+/**\n+\\brief Wrapper of software implementation of CCM.\n+\n+\\author Malisa Vucinic <malishav@gmail.com>, March 2015.\n+*/\n+\n+#include <stdint.h>\n+#include <string.h>\n+#include \"cryptoengine.h\"\n+\n+owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\n+ uint8_t len_a,\n+ uint8_t* m,\n+ uint8_t* len_m,\n+ uint8_t* nonce,\n+ uint8_t l,\n+ uint8_t key[16],\n+ uint8_t len_mac) {\n+\n+ return aes_ccms_enc(a,len_a, m, len_m, nonce, l, key, len_mac);\n+}\n+\n+owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\n+ uint8_t len_a,\n+ uint8_t* m,\n+ uint8_t* len_m,\n+ uint8_t* nonce,\n+ uint8_t l,\n+ uint8_t key[16],\n+ uint8_t len_mac) {\n+\n+ return aes_ccms_dec(a, len_a, m, len_m, nonce, l, key, len_mac);\n+}\n+\n+owerror_t cryptoengine_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\n+ return aes_ecb_enc(buffer, key);\n+}\n+\n+owerror_t cryptoengine_init(void) {\n+ return E_SUCCESS;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/telosb/SConscript", "new_path": "bsp/boards/telosb/SConscript", "diff": "@@ -31,7 +31,8 @@ source = [\n'spi.c',\n'uart.c',\n'adc_sensor.c',\n- 'sensors.c'\n+ 'sensors.c',\n+ 'cryptoengine.c'\n]\nlocalEnv.Append(\n" }, { "change_type": "RENAME", "old_path": "bsp/chips/cc2420/cryptoengine.c", "new_path": "bsp/boards/telosb/cryptoengine.c", "diff": "#include \"board.h\"\n#include \"radio.h\"\n#include \"cc2420.h\"\n-#include \"cc2420_crypto.h\"\n#include \"spi.h\"\n#include \"debugpins.h\"\n+#include \"cryptoengine.h\"\n//=========================== defines =========================================\n" }, { "change_type": "MODIFY", "old_path": "bsp/chips/cc2420/SConscript", "new_path": "bsp/chips/cc2420/SConscript", "diff": "@@ -7,7 +7,7 @@ Import('env')\nlocalEnv = env.Clone()\n-source = ['radio.c', 'cc2420.c', 'cryptoengine.c']\n+source = ['radio.c', 'cc2420.c']\ncc2420 = localEnv.Object(\nsource=source,\n)\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.h", "new_path": "openstack/02a-MAClow/IEEE802154_security.h", "diff": "#include \"opendefs.h\"\n#include \"neighbors.h\"\n+#include \"IEEE802154.h\"\n//=========================== define ==========================================\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Update build for python and telosb.
491,609
15.06.2017 15:31:05
-7,200
5a649ceca18c3472b91b50cae4500a710594bdab
Refactor firmware implementation of CCM.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/common/SConscript", "new_path": "bsp/boards/common/SConscript", "diff": "@@ -5,10 +5,10 @@ Import('env')\nlocalEnv = env.Clone()\nsource = [\n- 'aes_cbc.c',\n- 'aes_ccms.c',\n- 'aes_ctr.c',\n- 'aes_ecb.c',\n+ 'firmware_aes_cbc.c',\n+ 'firmware_aes_ccms.c',\n+ 'firmware_aes_ctr.c',\n+ 'firmware_aes_ecb.c',\n]\nlocalEnv.Append(\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_cbc.c", "new_path": "bsp/boards/common/firmware_aes_cbc.c", "diff": "#include <string.h>\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"aes_cbc.h\"\n+#include \"firmware_aes_cbc.h\"\n#include \"cryptoengine.h\"\n/**\n\\returns E_SUCCESS when the encryption was successful.\n*/\n-owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n+owerror_t firmware_aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\nuint8_t n;\nuint8_t k;\nuint8_t nb;\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_cbc.h", "new_path": "bsp/boards/common/firmware_aes_cbc.h", "diff": "@@ -12,7 +12,7 @@ extern \"C\" {\n//=========================== prototypes ======================================\n-owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n+owerror_t firmware_aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n#ifdef __cplusplus\n}\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ccms.c", "new_path": "bsp/boards/common/firmware_aes_ccms.c", "diff": "#include <string.h>\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"aes_ctr.h\"\n-#include \"aes_cbc.h\"\n-#include \"aes_ccms.h\"\n+#include \"firmware_aes_ctr.h\"\n+#include \"firmware_aes_cbc.h\"\n+#include \"firmware_aes_ccms.h\"\n#include \"cryptoengine.h\"\n-static owerror_t aes_cbc_mac(uint8_t* a, uint8_t len_a, uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+static owerror_t firmware_aes_cbc_mac(uint8_t* a, uint8_t len_a, uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n-static owerror_t aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+static owerror_t firmware_aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n/**\n\\brief CCM* forward transformation (i.e. encryption + authentication).\n@@ -32,7 +32,7 @@ static owerror_t aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t\n\\returns E_SUCCESS when the generation was successful, E_FAIL otherwise.\n*/\n-owerror_t aes_ccms_enc(uint8_t* a,\n+owerror_t firmware_aes_ccms_enc(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -47,8 +47,8 @@ owerror_t aes_ccms_enc(uint8_t* a,\nreturn E_FAIL;\n}\n- if (aes_cbc_mac(a, len_a, m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n- if (aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (firmware_aes_cbc_mac(a, len_a, m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (firmware_aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\nmemcpy(&m[*len_m], mac, len_mac);\n*len_m += len_mac;\n@@ -76,7 +76,7 @@ owerror_t aes_ccms_enc(uint8_t* a,\n\\returns E_SUCCESS when decryption and verification were successful, E_FAIL otherwise.\n*/\n-owerror_t aes_ccms_dec(uint8_t* a,\n+owerror_t firmware_aes_ccms_dec(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -95,8 +95,8 @@ owerror_t aes_ccms_dec(uint8_t* a,\n*len_m -= len_mac;\nmemcpy(mac, &m[*len_m], len_mac);\n- if (aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n- if (aes_cbc_mac(a, len_a, m, *len_m, nonce, key, orig_mac, len_mac, l) == E_SUCCESS) {\n+ if (firmware_aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (firmware_aes_cbc_mac(a, len_a, m, *len_m, nonce, key, orig_mac, len_mac, l) == E_SUCCESS) {\nif (memcmp(mac, orig_mac, len_mac) == 0) {\nreturn E_SUCCESS;\n}\n@@ -120,7 +120,7 @@ owerror_t aes_ccms_dec(uint8_t* a,\n\\returns E_SUCCESS when the generation was successful, E_FAIL otherwise.\n*/\n-static owerror_t aes_cbc_mac(uint8_t* a,\n+static owerror_t firmware_aes_cbc_mac(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t len_m,\n@@ -192,7 +192,7 @@ static owerror_t aes_cbc_mac(uint8_t* a,\nmemset(&buffer[len], 0, pad_len);\nlen += pad_len;\n- aes_cbc_enc_raw(buffer, len, key, cbc_mac_iv);\n+ firmware_aes_cbc_enc_raw(buffer, len, key, cbc_mac_iv);\n// copy MAC\nmemcpy(mac, &buffer[len - 16], len_mac);\n@@ -215,7 +215,7 @@ static owerror_t aes_cbc_mac(uint8_t* a,\n\\returns E_SUCCESS when the encryption was successful, E_FAIL otherwise.\n*/\n-static owerror_t aes_ctr_enc(uint8_t* m,\n+static owerror_t firmware_aes_ctr_enc(uint8_t* m,\nuint8_t len_m,\nuint8_t* nonce,\nuint8_t key[16],\n@@ -259,7 +259,7 @@ static owerror_t aes_ctr_enc(uint8_t* m,\nmemset(&buffer[len], 0, pad_len);\nlen += pad_len;\n- aes_ctr_enc_raw(buffer, len, key, iv);\n+ firmware_aes_ctr_enc_raw(buffer, len, key, iv);\nmemcpy(m, &buffer[16], len_m);\nmemcpy(mac, buffer, len_mac);\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ccms.h", "new_path": "bsp/boards/common/firmware_aes_ccms.h", "diff": "@@ -12,8 +12,8 @@ extern \"C\" {\n//=========================== prototypes ======================================\n-owerror_t aes_ccms_enc(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n-owerror_t aes_ccms_dec(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n+owerror_t firmware_aes_ccms_enc(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n+owerror_t firmware_aes_ccms_dec(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n#ifdef __cplusplus\n}\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ctr.c", "new_path": "bsp/boards/common/firmware_aes_ctr.c", "diff": "#include <string.h>\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"aes_ctr.h\"\n+#include \"firmware_aes_ctr.h\"\n#include \"cryptoengine.h\"\n-static void inc_counter(uint8_t* counter) {\n+static void firmware_inc_counter(uint8_t* counter) {\n// from openssl\nuint32_t n = 16;\nuint8_t c;\n@@ -31,7 +31,7 @@ static void inc_counter(uint8_t* counter) {\n\\returns E_SUCCESS when the encryption was successful.\n*/\n-owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n+owerror_t firmware_aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\nuint8_t n;\nuint8_t k;\nuint8_t nb;\n@@ -47,7 +47,7 @@ owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t\nfor (k = 0; k < 16; k++) {\npbuf[k] ^= eiv[k];\n}\n- inc_counter(iv);\n+ firmware_inc_counter(iv);\n}\nreturn E_SUCCESS;\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ctr.h", "new_path": "bsp/boards/common/firmware_aes_ctr.h", "diff": "@@ -12,7 +12,7 @@ extern \"C\" {\n//=========================== prototypes ======================================\n-owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n+owerror_t firmware_aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n#ifdef __cplusplus\n}\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ecb.c", "new_path": "bsp/boards/common/firmware_aes_ecb.c", "diff": "@@ -9,7 +9,7 @@ Source: http://is.gd/o9RSPq\n**************************************************************/\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"aes_ecb.h\"\n+#include \"firmware_aes_ecb.h\"\n// foreward sbox\nconst unsigned char sbox[256] = {\n@@ -30,31 +30,13 @@ const unsigned char sbox[256] = {\n0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D\n0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E\n0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F\n-// inverse sbox\n-const unsigned char rsbox[256] =\n-{ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb\n-, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb\n-, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e\n-, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25\n-, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92\n-, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84\n-, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06\n-, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b\n-, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73\n-, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e\n-, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b\n-, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4\n-, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f\n-, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef\n-, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61\n-, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d };\n// round constant\nconst unsigned char Rcon[11] = {\n0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };\n// expand the key\n-void expandKey(unsigned char *expandedKey,\n+void firmware_expandKey(unsigned char *expandedKey,\nunsigned char *key)\n{\nunsigned short ii, buf1;\n@@ -105,7 +87,7 @@ unsigned char galois_mul2(unsigned char value)\n// after that the 10th round without mixcolums\n// no further subfunctions to save cycles for function calls\n// no structuring with \"for (....)\" to save cycles\n-void aes_encr(unsigned char *state, unsigned char *expandedKey)\n+void firmware_aes_encr(unsigned char *state, unsigned char *expandedKey)\n{\nunsigned char buf1, buf2, buf3, round;\n@@ -211,141 +193,6 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey)\nstate[15] ^= expandedKey[175];\n}\n-// straight foreward aes decryption implementation\n-// the order of substeps is the exact reverse of decryption\n-// inverse functions:\n-// - addRoundKey is its own inverse\n-// - rsbox is inverse of sbox\n-// - rightshift instead of leftshift\n-// - invMixColumns = barreto + mixColumns\n-// no further subfunctions to save cycles for function calls\n-// no structuring with \"for (....)\" to save cycles\n-void aes_decr(unsigned char *state, unsigned char *expandedKey)\n-{\n- unsigned char buf1, buf2, buf3;\n- signed char round;\n- round = 9;\n-\n- // initial addroundkey\n- state[0] ^= expandedKey[160];\n- state[1] ^= expandedKey[161];\n- state[2] ^= expandedKey[162];\n- state[3] ^= expandedKey[163];\n- state[4] ^= expandedKey[164];\n- state[5] ^= expandedKey[165];\n- state[6] ^= expandedKey[166];\n- state[7] ^= expandedKey[167];\n- state[8] ^= expandedKey[168];\n- state[9] ^= expandedKey[169];\n- state[10] ^= expandedKey[170];\n- state[11] ^= expandedKey[171];\n- state[12] ^= expandedKey[172];\n- state[13] ^= expandedKey[173];\n- state[14] ^= expandedKey[174];\n- state[15] ^= expandedKey[175];\n-\n- // 10th round without mixcols\n- state[0] = rsbox[state[0]] ^ expandedKey[(round * 16)];\n- state[4] = rsbox[state[4]] ^ expandedKey[(round * 16) + 4];\n- state[8] = rsbox[state[8]] ^ expandedKey[(round * 16) + 8];\n- state[12] = rsbox[state[12]] ^ expandedKey[(round * 16) + 12];\n- // row 1\n- buf1 = rsbox[state[13]] ^ expandedKey[(round * 16) + 1];\n- state[13] = rsbox[state[9]] ^ expandedKey[(round * 16) + 13];\n- state[9] = rsbox[state[5]] ^ expandedKey[(round * 16) + 9];\n- state[5] = rsbox[state[1]] ^ expandedKey[(round * 16) + 5];\n- state[1] = buf1;\n- // row 2\n- buf1 = rsbox[state[2]] ^ expandedKey[(round * 16) + 10];\n- buf2 = rsbox[state[6]] ^ expandedKey[(round * 16) + 14];\n- state[2] = rsbox[state[10]] ^ expandedKey[(round * 16) + 2];\n- state[6] = rsbox[state[14]] ^ expandedKey[(round * 16) + 6];\n- state[10] = buf1;\n- state[14] = buf2;\n- // row 3\n- buf1 = rsbox[state[3]] ^ expandedKey[(round * 16) + 15];\n- state[3] = rsbox[state[7]] ^ expandedKey[(round * 16) + 3];\n- state[7] = rsbox[state[11]] ^ expandedKey[(round * 16) + 7];\n- state[11] = rsbox[state[15]] ^ expandedKey[(round * 16) + 11];\n- state[15] = buf1;\n-\n- for (round = 8; round >= 0; round--){\n- // barreto\n- //col1\n- buf1 = galois_mul2(galois_mul2(state[0] ^ state[2]));\n- buf2 = galois_mul2(galois_mul2(state[1] ^ state[3]));\n- state[0] ^= buf1; state[1] ^= buf2; state[2] ^= buf1; state[3] ^= buf2;\n- //col2\n- buf1 = galois_mul2(galois_mul2(state[4] ^ state[6]));\n- buf2 = galois_mul2(galois_mul2(state[5] ^ state[7]));\n- state[4] ^= buf1; state[5] ^= buf2; state[6] ^= buf1; state[7] ^= buf2;\n- //col3\n- buf1 = galois_mul2(galois_mul2(state[8] ^ state[10]));\n- buf2 = galois_mul2(galois_mul2(state[9] ^ state[11]));\n- state[8] ^= buf1; state[9] ^= buf2; state[10] ^= buf1; state[11] ^= buf2;\n- //col4\n- buf1 = galois_mul2(galois_mul2(state[12] ^ state[14]));\n- buf2 = galois_mul2(galois_mul2(state[13] ^ state[15]));\n- state[12] ^= buf1; state[13] ^= buf2; state[14] ^= buf1; state[15] ^= buf2;\n- // mixcolums //////////\n- // col1\n- buf1 = state[0] ^ state[1] ^ state[2] ^ state[3];\n- buf2 = state[0];\n- buf3 = state[0] ^ state[1]; buf3 = galois_mul2(buf3); state[0] = state[0] ^ buf3 ^ buf1;\n- buf3 = state[1] ^ state[2]; buf3 = galois_mul2(buf3); state[1] = state[1] ^ buf3 ^ buf1;\n- buf3 = state[2] ^ state[3]; buf3 = galois_mul2(buf3); state[2] = state[2] ^ buf3 ^ buf1;\n- buf3 = state[3] ^ buf2; buf3 = galois_mul2(buf3); state[3] = state[3] ^ buf3 ^ buf1;\n- // col2\n- buf1 = state[4] ^ state[5] ^ state[6] ^ state[7];\n- buf2 = state[4];\n- buf3 = state[4] ^ state[5]; buf3 = galois_mul2(buf3); state[4] = state[4] ^ buf3 ^ buf1;\n- buf3 = state[5] ^ state[6]; buf3 = galois_mul2(buf3); state[5] = state[5] ^ buf3 ^ buf1;\n- buf3 = state[6] ^ state[7]; buf3 = galois_mul2(buf3); state[6] = state[6] ^ buf3 ^ buf1;\n- buf3 = state[7] ^ buf2; buf3 = galois_mul2(buf3); state[7] = state[7] ^ buf3 ^ buf1;\n- // col3\n- buf1 = state[8] ^ state[9] ^ state[10] ^ state[11];\n- buf2 = state[8];\n- buf3 = state[8] ^ state[9]; buf3 = galois_mul2(buf3); state[8] = state[8] ^ buf3 ^ buf1;\n- buf3 = state[9] ^ state[10]; buf3 = galois_mul2(buf3); state[9] = state[9] ^ buf3 ^ buf1;\n- buf3 = state[10] ^ state[11]; buf3 = galois_mul2(buf3); state[10] = state[10] ^ buf3 ^ buf1;\n- buf3 = state[11] ^ buf2; buf3 = galois_mul2(buf3); state[11] = state[11] ^ buf3 ^ buf1;\n- // col4\n- buf1 = state[12] ^ state[13] ^ state[14] ^ state[15];\n- buf2 = state[12];\n- buf3 = state[12] ^ state[13]; buf3 = galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;\n- buf3 = state[13] ^ state[14]; buf3 = galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;\n- buf3 = state[14] ^ state[15]; buf3 = galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;\n- buf3 = state[15] ^ buf2; buf3 = galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;\n-\n- // addroundkey, rsbox and shiftrows\n- // row 0\n- state[0] = rsbox[state[0]] ^ expandedKey[(round * 16)];\n- state[4] = rsbox[state[4]] ^ expandedKey[(round * 16) + 4];\n- state[8] = rsbox[state[8]] ^ expandedKey[(round * 16) + 8];\n- state[12] = rsbox[state[12]] ^ expandedKey[(round * 16) + 12];\n- // row 1\n- buf1 = rsbox[state[13]] ^ expandedKey[(round * 16) + 1];\n- state[13] = rsbox[state[9]] ^ expandedKey[(round * 16) + 13];\n- state[9] = rsbox[state[5]] ^ expandedKey[(round * 16) + 9];\n- state[5] = rsbox[state[1]] ^ expandedKey[(round * 16) + 5];\n- state[1] = buf1;\n- // row 2\n- buf1 = rsbox[state[2]] ^ expandedKey[(round * 16) + 10];\n- buf2 = rsbox[state[6]] ^ expandedKey[(round * 16) + 14];\n- state[2] = rsbox[state[10]] ^ expandedKey[(round * 16) + 2];\n- state[6] = rsbox[state[14]] ^ expandedKey[(round * 16) + 6];\n- state[10] = buf1;\n- state[14] = buf2;\n- // row 3\n- buf1 = rsbox[state[3]] ^ expandedKey[(round * 16) + 15];\n- state[3] = rsbox[state[7]] ^ expandedKey[(round * 16) + 3];\n- state[7] = rsbox[state[11]] ^ expandedKey[(round * 16) + 7];\n- state[11] = rsbox[state[15]] ^ expandedKey[(round * 16) + 11];\n- state[15] = buf1;\n- }\n-\n-\n-}\n/**\n\\brief Basic AES encryption of a single 16-octet block.\n\\param[in,out] buffer Single block plaintext. Will be overwritten by ciphertext.\n@@ -353,12 +200,12 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)\n\\returns E_SUCCESS when the encryption was successful.\n*/\n-owerror_t aes_ecb_enc(uint8_t buffer[16], uint8_t key[16])\n+owerror_t firmware_aes_ecb_enc(uint8_t buffer[16], uint8_t key[16])\n{\nuint8_t expandedKey[176];\n- expandKey(expandedKey, key); // expand the key into 176 bytes\n- aes_encr(buffer, expandedKey);\n+ firmware_expandKey(expandedKey, key); // expand the key into 176 bytes\n+ firmware_aes_encr(buffer, expandedKey);\nreturn E_SUCCESS;\n}\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/aes_ecb.h", "new_path": "bsp/boards/common/firmware_aes_ecb.h", "diff": "@@ -16,7 +16,7 @@ extern \"C\" {\n//=========================== prototypes ======================================\n-owerror_t aes_ecb_enc(uint8_t* buffer, uint8_t* key);\n+owerror_t firmware_aes_ecb_enc(uint8_t* buffer, uint8_t* key);\n#ifdef __cplusplus\n}\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/python/cryptoengine.c", "new_path": "bsp/boards/python/cryptoengine.c", "diff": "#include <stdint.h>\n#include <string.h>\n-#include \"cryptoengine.h\"\n+#include \"cryptoengine_obj.h\"\n-owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_enc(OpenMote *self,\n+ uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -17,10 +18,11 @@ owerror_t cryptoengine_aes_ccms_enc(uint8_t* a,\nuint8_t key[16],\nuint8_t len_mac) {\n- return aes_ccms_enc(a,len_a, m, len_m, nonce, l, key, len_mac);\n+ return firmware_aes_ccms_enc(a,len_a, m, len_m, nonce, l, key, len_mac);\n}\n-owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\n+owerror_t cryptoengine_aes_ccms_dec(OpenMote* self,\n+ uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -28,15 +30,14 @@ owerror_t cryptoengine_aes_ccms_dec(uint8_t* a,\nuint8_t l,\nuint8_t key[16],\nuint8_t len_mac) {\n-\n- return aes_ccms_dec(a, len_a, m, len_m, nonce, l, key, len_mac);\n+ return firmware_aes_ccms_dec(a, len_a, m, len_m, nonce, l, key, len_mac);\n}\n-owerror_t cryptoengine_aes_ecb_enc(uint8_t* buffer, uint8_t* key) {\n- return aes_ecb_enc(buffer, key);\n+owerror_t cryptoengine_aes_ecb_enc(OpenMote* self, uint8_t* buffer, uint8_t* key) {\n+ return firmware_aes_ecb_enc(buffer, key);\n}\n-owerror_t cryptoengine_init(void) {\n+owerror_t cryptoengine_init(OpenMote *self) {\nreturn E_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -371,6 +371,21 @@ functionsToChange = [\n'uart_readByte',\n'uart_tx_isr',\n'uart_rx_isr',\n+ # cryptoengine\n+ 'cryptoengine_aes_ccms_enc',\n+ 'cryptoengine_aes_ccms_dec',\n+ 'cryptoengine_aes_ecb_enc',\n+ 'cryptoengine_init',\n+ 'firmware_aes_cbc_enc_raw',\n+ 'firmware_aes_ccms_enc',\n+ 'firmware_aes_ccms_dec',\n+ 'firmware_aes_ctr_enc_raw',\n+ 'firmware_aes_ecb_enc',\n+ 'firmware_aes_cbc_mac',\n+ 'firmware_aes_ctr_enc',\n+ 'firmware_inc_counter',\n+ 'firmware_expandKey',\n+ 'firmware_aes_encr',\n#===== drivers\n# openserial\n'openserial_init',\n@@ -833,6 +848,7 @@ headerFiles = [\n'leds',\n'radio',\n'uart',\n+ 'cryptoengine',\n#=== libdrivers,\n'openhdlc',\n'openserial',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Refactor firmware implementation of CCM.
491,609
15.06.2017 19:05:24
-7,200
303f840f710dfd743db3f8c5df2c338866b3dea0
Move firmware implementation of crypto functions to drivers.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/common/SConscript", "new_path": "bsp/boards/common/SConscript", "diff": "@@ -5,10 +5,6 @@ Import('env')\nlocalEnv = env.Clone()\nsource = [\n- 'firmware_aes_cbc.c',\n- 'firmware_aes_ccms.c',\n- 'firmware_aes_ctr.c',\n- 'firmware_aes_ecb.c',\n]\nlocalEnv.Append(\n" }, { "change_type": "MODIFY", "old_path": "bsp/boards/python/cryptoengine.c", "new_path": "bsp/boards/python/cryptoengine.c", "diff": "#include <stdint.h>\n#include <string.h>\n#include \"cryptoengine_obj.h\"\n+#include \"firmware_aes_ccms_obj.h\"\n+#include \"firmware_aes_ecb_obj.h\"\nowerror_t cryptoengine_aes_ccms_enc(OpenMote *self,\nuint8_t* a,\n@@ -18,7 +20,8 @@ owerror_t cryptoengine_aes_ccms_enc(OpenMote *self,\nuint8_t key[16],\nuint8_t len_mac) {\n- return firmware_aes_ccms_enc(a,len_a, m, len_m, nonce, l, key, len_mac);\n+ return firmware_aes_ccms_enc(self, a,len_a, m, len_m, nonce, l, key, len_mac);\n+\n}\nowerror_t cryptoengine_aes_ccms_dec(OpenMote* self,\n@@ -30,11 +33,11 @@ owerror_t cryptoengine_aes_ccms_dec(OpenMote* self,\nuint8_t l,\nuint8_t key[16],\nuint8_t len_mac) {\n- return firmware_aes_ccms_dec(a, len_a, m, len_m, nonce, l, key, len_mac);\n+ return firmware_aes_ccms_dec(self, a, len_a, m, len_m, nonce, l, key, len_mac);\n}\nowerror_t cryptoengine_aes_ecb_enc(OpenMote* self, uint8_t* buffer, uint8_t* key) {\n- return firmware_aes_ecb_enc(buffer, key);\n+ return firmware_aes_ecb_enc(self, buffer, key);\n}\nowerror_t cryptoengine_init(OpenMote *self) {\n" }, { "change_type": "MODIFY", "old_path": "drivers/SConscript", "new_path": "drivers/SConscript", "diff": "@@ -11,12 +11,20 @@ sources_c = [\nos.path.join('common','opensensors.c'),\nos.path.join('common','openserial.c'),\nos.path.join('common','opentimers.c'),\n+ os.path.join('common','firmware_aes_cbc.c'),\n+ os.path.join('common','firmware_aes_ccms.c'),\n+ os.path.join('common','firmware_aes_ctr.c'),\n+ os.path.join('common','firmware_aes_ecb.c'),\n]\nsources_h = [\nos.path.join('common','openhdlc.h'),\nos.path.join('common','opensensors.h'),\nos.path.join('common','openserial.h'),\nos.path.join('common','opentimers.h'),\n+ os.path.join('common','firmware_aes_cbc.h'),\n+ os.path.join('common','firmware_aes_ccms.h'),\n+ os.path.join('common','firmware_aes_ctr.h'),\n+ os.path.join('common','firmware_aes_ecb.h'),\n]\nif localEnv['board']=='python':\n" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_cbc.c", "new_path": "drivers/common/firmware_aes_cbc.c", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_cbc.h", "new_path": "drivers/common/firmware_aes_cbc.h", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ccms.c", "new_path": "drivers/common/firmware_aes_ccms.c", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ccms.h", "new_path": "drivers/common/firmware_aes_ccms.h", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ctr.c", "new_path": "drivers/common/firmware_aes_ctr.c", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ctr.h", "new_path": "drivers/common/firmware_aes_ctr.h", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ecb.c", "new_path": "drivers/common/firmware_aes_ecb.c", "diff": "" }, { "change_type": "RENAME", "old_path": "bsp/boards/common/firmware_aes_ecb.h", "new_path": "drivers/common/firmware_aes_ecb.h", "diff": "" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -853,6 +853,10 @@ headerFiles = [\n'openhdlc',\n'openserial',\n'opentimers',\n+ 'firmware_aes_ccms',\n+ 'firmware_aes_cbc',\n+ 'firmware_aes_ctr',\n+ 'firmware_aes_ecb',\n#=== libkernel\n'scheduler',\n#=== libopenstack\n@@ -863,8 +867,6 @@ headerFiles = [\n'IEEE802154',\n'IEEE802154E',\n'IEEE802154_security',\n- 'IEEE802154_dummy_security',\n- 'ieee802154_security_driver',\n# 02b-MAChigh\n'neighbors',\n'schedule',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Move firmware implementation of crypto functions to drivers.
491,586
16.06.2017 10:38:16
-19,080
edb88c0bb2708fa8e61eb66258df0d713ef9d0b6
modified for telosb board
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -203,7 +203,7 @@ int16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn) {\nint16_t diff;\nif (h_asn->byte4 != l_asn->byte4) {\n- return (PORT_RADIOTIMER_WIDTH)0xFFFFFFFF;\n+ return (int16_t)0xFFFFFFFF;\n}\ndiff = 0;\n@@ -214,7 +214,7 @@ int16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn) {\ndiff += 0xffff-l_asn->bytes0and1;\ndiff += 1;\n} else {\n- diff = (PORT_RADIOTIMER_WIDTH)0xFFFFFFFF;\n+ diff = (int16_t)0xFFFFFFFF;\n}\nreturn diff;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
modified for telosb board
491,609
16.06.2017 10:21:21
-7,200
a1390bc044325fc316a66f8e23656e6a2c8e0b89
Seg fault bug fix when isValidJoin fails.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -618,8 +618,6 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_TIMER_WIDTH capturedTime)\n// before authenticating the beacon, because nonce is created from the ASN\nif (!ieee154e_vars.isSync && ieee802514_header.frameType == IEEE154_TYPE_BEACON) {\nif (!isValidJoin(ieee154e_vars.dataReceived, &ieee802514_header)) {\n- // invalidate variables\n- memset(&ieee154e_vars, 0, sizeof(ieee154e_vars_t));\nbreak;\n}\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Seg fault bug fix when isValidJoin fails.
491,609
16.06.2017 11:30:05
-7,200
26ef545b4bd789d2d70d5d18629079d29689586c
Refactor firmware CCM* implementation.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/python/cryptoengine.c", "new_path": "bsp/boards/python/cryptoengine.c", "diff": "#include <stdint.h>\n#include <string.h>\n#include \"cryptoengine_obj.h\"\n-#include \"firmware_aes_ccms_obj.h\"\n-#include \"firmware_aes_ecb_obj.h\"\n+#include \"openccms_obj.h\"\n+#include \"openaes_obj.h\"\nowerror_t cryptoengine_aes_ccms_enc(OpenMote *self,\nuint8_t* a,\n@@ -20,7 +20,7 @@ owerror_t cryptoengine_aes_ccms_enc(OpenMote *self,\nuint8_t key[16],\nuint8_t len_mac) {\n- return firmware_aes_ccms_enc(self, a,len_a, m, len_m, nonce, l, key, len_mac);\n+ return openccms_enc(self, a,len_a, m, len_m, nonce, l, key, len_mac);\n}\n@@ -33,11 +33,11 @@ owerror_t cryptoengine_aes_ccms_dec(OpenMote* self,\nuint8_t l,\nuint8_t key[16],\nuint8_t len_mac) {\n- return firmware_aes_ccms_dec(self, a, len_a, m, len_m, nonce, l, key, len_mac);\n+ return openccms_dec(self, a, len_a, m, len_m, nonce, l, key, len_mac);\n}\nowerror_t cryptoengine_aes_ecb_enc(OpenMote* self, uint8_t* buffer, uint8_t* key) {\n- return firmware_aes_ecb_enc(self, buffer, key);\n+ return openaes_enc(self, buffer, key);\n}\nowerror_t cryptoengine_init(OpenMote *self) {\n" }, { "change_type": "MODIFY", "old_path": "drivers/SConscript", "new_path": "drivers/SConscript", "diff": "@@ -11,20 +11,12 @@ sources_c = [\nos.path.join('common','opensensors.c'),\nos.path.join('common','openserial.c'),\nos.path.join('common','opentimers.c'),\n- os.path.join('common','firmware_aes_cbc.c'),\n- os.path.join('common','firmware_aes_ccms.c'),\n- os.path.join('common','firmware_aes_ctr.c'),\n- os.path.join('common','firmware_aes_ecb.c'),\n]\nsources_h = [\nos.path.join('common','openhdlc.h'),\nos.path.join('common','opensensors.h'),\nos.path.join('common','openserial.h'),\nos.path.join('common','opentimers.h'),\n- os.path.join('common','firmware_aes_cbc.h'),\n- os.path.join('common','firmware_aes_ccms.h'),\n- os.path.join('common','firmware_aes_ctr.h'),\n- os.path.join('common','firmware_aes_ecb.h'),\n]\nif localEnv['board']=='python':\n" }, { "change_type": "DELETE", "old_path": "drivers/common/firmware_aes_cbc.c", "new_path": null, "diff": "-/**\n-\\brief AES CBC implementation\n-\n-\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-\\author Malisa Vucinic <malishav@gmail.com>, March 2015.\n-*/\n-#include <string.h>\n-#include <stdint.h>\n-#include \"opendefs.h\"\n-#include \"firmware_aes_cbc.h\"\n-#include \"cryptoengine.h\"\n-\n-/**\n-\\brief Raw AES-CBC encryption.\n-\\param[in,out] buffer Message to be encrypted. Will be overwritten by ciphertext.\n-\\param[in] len Message length. Must be multiple of 16 octets.\n-\\param[in] key Buffer containing the secret key (16 octets).\n-\\param[in] iv Buffer containing the Initialization Vector (16 octets).\n-\n-\\returns E_SUCCESS when the encryption was successful.\n-*/\n-owerror_t firmware_aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n- uint8_t n;\n- uint8_t k;\n- uint8_t nb;\n- uint8_t* pbuf;\n- uint8_t* pxor;\n-\n- nb = len >> 4;\n- pxor = iv;\n- for (n = 0; n < nb; n++) {\n- pbuf = &buffer[16 * n];\n- // may be faster if vector are aligned to 4 bytes (use long instead char in xor)\n- for (k = 0; k < 16; k++) {\n- pbuf[k] ^= pxor[k];\n- }\n- cryptoengine_aes_ecb_enc(pbuf,key);\n- pxor = pbuf;\n- }\n- return E_SUCCESS;\n-}\n-\n-\n" }, { "change_type": "DELETE", "old_path": "drivers/common/firmware_aes_cbc.h", "new_path": null, "diff": "-/**\n-\\brief Definitions for AES CBC implementation\n-\n-\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-*/\n-#ifndef __AES_CBC_H__\n-#define __AES_CBC_H__\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-//=========================== prototypes ======================================\n-\n-owerror_t firmware_aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* __AES_CBC_H__ */\n" }, { "change_type": "DELETE", "old_path": "drivers/common/firmware_aes_ccms.h", "new_path": null, "diff": "-/**\n-\\brief Definitions for AES CCMS implementation\n-\n-\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-*/\n-#ifndef __AES_CCMS_H__\n-#define __AES_CCMS_H__\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-//=========================== prototypes ======================================\n-\n-owerror_t firmware_aes_ccms_enc(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n-owerror_t firmware_aes_ccms_dec(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* __AES_CCMS_H__ */\n" }, { "change_type": "DELETE", "old_path": "drivers/common/firmware_aes_ctr.c", "new_path": null, "diff": "-/**\n-\\brief AES CTR implementation\n-\n-\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-*/\n-#include <string.h>\n-#include <stdint.h>\n-#include \"opendefs.h\"\n-#include \"firmware_aes_ctr.h\"\n-#include \"cryptoengine.h\"\n-\n-static void firmware_inc_counter(uint8_t* counter) {\n- // from openssl\n- uint32_t n = 16;\n- uint8_t c;\n- do {\n- --n;\n- c = counter[n];\n- ++c;\n- counter[n] = c;\n- if (c) return;\n- } while (n);\n-}\n-\n-/**\n-\\brief Raw AES-CTR encryption.\n-\\param[in,out] buffer Message to be encrypted. Will be overwritten by ciphertext.\n-\\param[in] len Message length. Must be multiple of 16 octets.\n-\\param[in] key Buffer containing the secret key (16 octets).\n-\\param[in] iv Buffer containing the Initialization Vector (16 octets).\n-\n-\\returns E_SUCCESS when the encryption was successful.\n-*/\n-owerror_t firmware_aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n- uint8_t n;\n- uint8_t k;\n- uint8_t nb;\n- uint8_t* pbuf;\n- uint8_t eiv[16];\n-\n- nb = len >> 4;\n- for (n = 0; n < nb; n++) {\n- pbuf = &buffer[16 * n];\n- memcpy(eiv, iv, 16);\n- cryptoengine_aes_ecb_enc(eiv, key);\n- // may be faster if vector are aligned to 4 bytes (use long instead char in xor)\n- for (k = 0; k < 16; k++) {\n- pbuf[k] ^= eiv[k];\n- }\n- firmware_inc_counter(iv);\n- }\n-\n- return E_SUCCESS;\n-}\n-\n" }, { "change_type": "DELETE", "old_path": "drivers/common/firmware_aes_ctr.h", "new_path": null, "diff": "-/**\n-\\brief Definitions for AES CTR implementation\n-\n-\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-*/\n-#ifndef __AES_CTR_H__\n-#define __AES_CTR_H__\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-//=========================== prototypes ======================================\n-\n-owerror_t firmware_aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* __AES_CTR_H__ */\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -33,6 +33,8 @@ sources_c = [\nos.path.join('cross-layers','openqueue.c'),\nos.path.join('cross-layers','openrandom.c'),\nos.path.join('cross-layers','packetfunctions.c'),\n+ os.path.join('cross-layers','openaes.c'),\n+ os.path.join('cross-layers','openccms.c'),\n]\nsources_h = [\n'openstack.h',\n@@ -62,6 +64,8 @@ sources_h = [\nos.path.join('cross-layers','openqueue.h'),\nos.path.join('cross-layers','openrandom.h'),\nos.path.join('cross-layers','packetfunctions.h'),\n+ os.path.join('cross-layers','openaes.h'),\n+ os.path.join('cross-layers','openccms.h'),\n#=== apps\nos.path.join('#','openapps','userialbridge','userialbridge.h'),\n]\n" }, { "change_type": "RENAME", "old_path": "drivers/common/firmware_aes_ecb.c", "new_path": "openstack/cross-layers/openaes.c", "diff": "@@ -9,7 +9,9 @@ Source: http://is.gd/o9RSPq\n**************************************************************/\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"firmware_aes_ecb.h\"\n+#include \"openaes.h\"\n+\n+//=========================== variables =======================================\n// foreward sbox\nconst unsigned char sbox[256] = {\n@@ -34,9 +36,35 @@ const unsigned char sbox[256] = {\nconst unsigned char Rcon[11] = {\n0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };\n+//=========================== prototypes ======================================\n+\n+void expandKey(unsigned char *expandedKey,unsigned char *key);\n+unsigned char galois_mul2(unsigned char value);\n+void aes_encr(unsigned char *state, unsigned char *expandedKey);\n+\n+//=========================== public ==========================================\n+\n+/**\n+\\brief Basic AES encryption of a single 16-octet block.\n+\\param[in,out] buffer Single block plaintext. Will be overwritten by ciphertext.\n+\\param[in] key Buffer containing the secret key (16 octets).\n+\n+\\returns E_SUCCESS when the encryption was successful.\n+*/\n+owerror_t openaes_enc(uint8_t buffer[16], uint8_t key[16])\n+{\n+ uint8_t expandedKey[176];\n+\n+ expandKey(expandedKey, key); // expand the key into 176 bytes\n+ aes_encr(buffer, expandedKey);\n+\n+ return E_SUCCESS;\n+}\n+\n+//=========================== private =========================================\n// expand the key\n-void firmware_expandKey(unsigned char *expandedKey,\n+void expandKey(unsigned char *expandedKey,\nunsigned char *key)\n{\nunsigned short ii, buf1;\n@@ -87,7 +115,7 @@ unsigned char galois_mul2(unsigned char value)\n// after that the 10th round without mixcolums\n// no further subfunctions to save cycles for function calls\n// no structuring with \"for (....)\" to save cycles\n-void firmware_aes_encr(unsigned char *state, unsigned char *expandedKey)\n+void aes_encr(unsigned char *state, unsigned char *expandedKey)\n{\nunsigned char buf1, buf2, buf3, round;\n@@ -193,20 +221,4 @@ void firmware_aes_encr(unsigned char *state, unsigned char *expandedKey)\nstate[15] ^= expandedKey[175];\n}\n-/**\n-\\brief Basic AES encryption of a single 16-octet block.\n-\\param[in,out] buffer Single block plaintext. Will be overwritten by ciphertext.\n-\\param[in] key Buffer containing the secret key (16 octets).\n-\n-\\returns E_SUCCESS when the encryption was successful.\n-*/\n-owerror_t firmware_aes_ecb_enc(uint8_t buffer[16], uint8_t key[16])\n-{\n- uint8_t expandedKey[176];\n-\n- firmware_expandKey(expandedKey, key); // expand the key into 176 bytes\n- firmware_aes_encr(buffer, expandedKey);\n-\n- return E_SUCCESS;\n-}\n" }, { "change_type": "RENAME", "old_path": "drivers/common/firmware_aes_ecb.h", "new_path": "openstack/cross-layers/openaes.h", "diff": "@@ -7,19 +7,11 @@ AES software support for encryption and decryption\nECCN 5D002 TSU - Technology / Software Unrestricted\nSource: http://is.gd/o9RSPq\n**************************************************************/\n-#ifndef __AES_ECB_H__\n-#define __AES_ECB_H__\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n+#ifndef __OPENAES_H__\n+#define __OPENAES_H__\n//=========================== prototypes ======================================\n-owerror_t firmware_aes_ecb_enc(uint8_t* buffer, uint8_t* key);\n-\n-#ifdef __cplusplus\n-}\n-#endif\n+owerror_t openaes_enc(uint8_t* buffer, uint8_t* key);\n-#endif /* __AES_ECB_H__ */\n+#endif /* __OPENAES_H__ */\n" }, { "change_type": "RENAME", "old_path": "drivers/common/firmware_aes_ccms.c", "new_path": "openstack/cross-layers/openccms.c", "diff": "#include <string.h>\n#include <stdint.h>\n#include \"opendefs.h\"\n-#include \"firmware_aes_ctr.h\"\n-#include \"firmware_aes_cbc.h\"\n-#include \"firmware_aes_ccms.h\"\n+#include \"openccms.h\"\n#include \"cryptoengine.h\"\n-static owerror_t firmware_aes_cbc_mac(uint8_t* a, uint8_t len_a, uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+//=========================== defines =========================================\n-static owerror_t firmware_aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+\n+//=========================== prototypes ======================================\n+\n+static owerror_t aes_cbc_mac(uint8_t* a, uint8_t len_a, uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+static owerror_t aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce, uint8_t key[16], uint8_t* mac, uint8_t len_mac, uint8_t l);\n+owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n+owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]);\n+static void inc_counter(uint8_t* counter);\n+\n+//=========================== public ==========================================\n/**\n\\brief CCM* forward transformation (i.e. encryption + authentication).\n@@ -32,7 +39,7 @@ static owerror_t firmware_aes_ctr_enc(uint8_t* m, uint8_t len_m, uint8_t* nonce,\n\\returns E_SUCCESS when the generation was successful, E_FAIL otherwise.\n*/\n-owerror_t firmware_aes_ccms_enc(uint8_t* a,\n+owerror_t openccms_enc(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -47,8 +54,8 @@ owerror_t firmware_aes_ccms_enc(uint8_t* a,\nreturn E_FAIL;\n}\n- if (firmware_aes_cbc_mac(a, len_a, m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n- if (firmware_aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (aes_cbc_mac(a, len_a, m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\nmemcpy(&m[*len_m], mac, len_mac);\n*len_m += len_mac;\n@@ -76,7 +83,7 @@ owerror_t firmware_aes_ccms_enc(uint8_t* a,\n\\returns E_SUCCESS when decryption and verification were successful, E_FAIL otherwise.\n*/\n-owerror_t firmware_aes_ccms_dec(uint8_t* a,\n+owerror_t openccms_dec(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t* len_m,\n@@ -95,8 +102,8 @@ owerror_t firmware_aes_ccms_dec(uint8_t* a,\n*len_m -= len_mac;\nmemcpy(mac, &m[*len_m], len_mac);\n- if (firmware_aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n- if (firmware_aes_cbc_mac(a, len_a, m, *len_m, nonce, key, orig_mac, len_mac, l) == E_SUCCESS) {\n+ if (aes_ctr_enc(m, *len_m, nonce, key, mac, len_mac, l) == E_SUCCESS) {\n+ if (aes_cbc_mac(a, len_a, m, *len_m, nonce, key, orig_mac, len_mac, l) == E_SUCCESS) {\nif (memcmp(mac, orig_mac, len_mac) == 0) {\nreturn E_SUCCESS;\n}\n@@ -106,6 +113,8 @@ owerror_t firmware_aes_ccms_dec(uint8_t* a,\nreturn E_FAIL;\n}\n+//=========================== private =========================================\n+\n/**\n\\brief CBC-MAC generation specific to CCM*.\n\\param[in] a Pointer to the authentication only data.\n@@ -120,7 +129,7 @@ owerror_t firmware_aes_ccms_dec(uint8_t* a,\n\\returns E_SUCCESS when the generation was successful, E_FAIL otherwise.\n*/\n-static owerror_t firmware_aes_cbc_mac(uint8_t* a,\n+static owerror_t aes_cbc_mac(uint8_t* a,\nuint8_t len_a,\nuint8_t* m,\nuint8_t len_m,\n@@ -192,7 +201,7 @@ static owerror_t firmware_aes_cbc_mac(uint8_t* a,\nmemset(&buffer[len], 0, pad_len);\nlen += pad_len;\n- firmware_aes_cbc_enc_raw(buffer, len, key, cbc_mac_iv);\n+ aes_cbc_enc_raw(buffer, len, key, cbc_mac_iv);\n// copy MAC\nmemcpy(mac, &buffer[len - 16], len_mac);\n@@ -215,7 +224,7 @@ static owerror_t firmware_aes_cbc_mac(uint8_t* a,\n\\returns E_SUCCESS when the encryption was successful, E_FAIL otherwise.\n*/\n-static owerror_t firmware_aes_ctr_enc(uint8_t* m,\n+static owerror_t aes_ctr_enc(uint8_t* m,\nuint8_t len_m,\nuint8_t* nonce,\nuint8_t key[16],\n@@ -259,7 +268,7 @@ static owerror_t firmware_aes_ctr_enc(uint8_t* m,\nmemset(&buffer[len], 0, pad_len);\nlen += pad_len;\n- firmware_aes_ctr_enc_raw(buffer, len, key, iv);\n+ aes_ctr_enc_raw(buffer, len, key, iv);\nmemcpy(m, &buffer[16], len_m);\nmemcpy(mac, buffer, len_mac);\n@@ -267,3 +276,78 @@ static owerror_t firmware_aes_ctr_enc(uint8_t* m,\nreturn E_SUCCESS;\n}\n+/**\n+\\brief Raw AES-CBC encryption.\n+\\param[in,out] buffer Message to be encrypted. Will be overwritten by ciphertext.\n+\\param[in] len Message length. Must be multiple of 16 octets.\n+\\param[in] key Buffer containing the secret key (16 octets).\n+\\param[in] iv Buffer containing the Initialization Vector (16 octets).\n+\n+\\returns E_SUCCESS when the encryption was successful.\n+*/\n+owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n+ uint8_t n;\n+ uint8_t k;\n+ uint8_t nb;\n+ uint8_t* pbuf;\n+ uint8_t* pxor;\n+\n+ nb = len >> 4;\n+ pxor = iv;\n+ for (n = 0; n < nb; n++) {\n+ pbuf = &buffer[16 * n];\n+ // may be faster if vector are aligned to 4 bytes (use long instead char in xor)\n+ for (k = 0; k < 16; k++) {\n+ pbuf[k] ^= pxor[k];\n+ }\n+ cryptoengine_aes_ecb_enc(pbuf,key);\n+ pxor = pbuf;\n+ }\n+ return E_SUCCESS;\n+}\n+\n+/**\n+\\brief Raw AES-CTR encryption.\n+\\param[in,out] buffer Message to be encrypted. Will be overwritten by ciphertext.\n+\\param[in] len Message length. Must be multiple of 16 octets.\n+\\param[in] key Buffer containing the secret key (16 octets).\n+\\param[in] iv Buffer containing the Initialization Vector (16 octets).\n+\n+\\returns E_SUCCESS when the encryption was successful.\n+*/\n+owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t iv[16]) {\n+ uint8_t n;\n+ uint8_t k;\n+ uint8_t nb;\n+ uint8_t* pbuf;\n+ uint8_t eiv[16];\n+\n+ nb = len >> 4;\n+ for (n = 0; n < nb; n++) {\n+ pbuf = &buffer[16 * n];\n+ memcpy(eiv, iv, 16);\n+ cryptoengine_aes_ecb_enc(eiv, key);\n+ // may be faster if vector are aligned to 4 bytes (use long instead char in xor)\n+ for (k = 0; k < 16; k++) {\n+ pbuf[k] ^= eiv[k];\n+ }\n+ inc_counter(iv);\n+ }\n+\n+ return E_SUCCESS;\n+}\n+\n+static void inc_counter(uint8_t* counter) {\n+ // from openssl\n+ uint32_t n = 16;\n+ uint8_t c;\n+ do {\n+ --n;\n+ c = counter[n];\n+ ++c;\n+ counter[n] = c;\n+ if (c) return;\n+ } while (n);\n+}\n+\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openstack/cross-layers/openccms.h", "diff": "+/**\n+\\brief Definitions for AES CCMS implementation\n+\n+\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n+*/\n+#ifndef __OPENCCMS_H__\n+#define __OPENCCMS_H__\n+\n+//=========================== prototypes ======================================\n+\n+owerror_t openccms_enc(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n+owerror_t openccms_dec(uint8_t* a,uint8_t len_a,uint8_t* m,uint8_t* len_m,uint8_t* nonce, uint8_t l, uint8_t key[16], uint8_t len_mac);\n+\n+#endif /* __OPENCCMS_H__ */\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -376,16 +376,6 @@ functionsToChange = [\n'cryptoengine_aes_ccms_dec',\n'cryptoengine_aes_ecb_enc',\n'cryptoengine_init',\n- 'firmware_aes_cbc_enc_raw',\n- 'firmware_aes_ccms_enc',\n- 'firmware_aes_ccms_dec',\n- 'firmware_aes_ctr_enc_raw',\n- 'firmware_aes_ecb_enc',\n- 'firmware_aes_cbc_mac',\n- 'firmware_aes_ctr_enc',\n- 'firmware_inc_counter',\n- 'firmware_expandKey',\n- 'firmware_aes_encr',\n#===== drivers\n# openserial\n'openserial_init',\n@@ -766,6 +756,15 @@ functionsToChange = [\n'packetfunctions_htons',\n'packetfunctions_ntohs',\n'packetfunctions_htonl',\n+ # openaes\n+ 'openaes_enc',\n+ # openccms\n+ 'openccms_enc',\n+ 'openccms_dec',\n+ 'aes_cbc_mac',\n+ 'aes_ctr_enc',\n+ 'aes_cbc_enc_raw',\n+ 'aes_ctr_enc_raw',\n#===== openapps\n'openapps_init',\n# c6t\n@@ -853,10 +852,6 @@ headerFiles = [\n'openhdlc',\n'openserial',\n'opentimers',\n- 'firmware_aes_ccms',\n- 'firmware_aes_cbc',\n- 'firmware_aes_ctr',\n- 'firmware_aes_ecb',\n#=== libkernel\n'scheduler',\n#=== libopenstack\n@@ -891,6 +886,8 @@ headerFiles = [\n'openqueue',\n'openrandom',\n'packetfunctions',\n+ 'openaes',\n+ 'openccms',\n#=== openapps\n'openapps',\n'c6t',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Refactor firmware CCM* implementation.
491,609
16.06.2017 11:36:36
-7,200
bfd7482828c88aef9be4b80ffe071453a3f39d32
Use firmware implementation of AES in openccms.
[ { "change_type": "MODIFY", "old_path": "openstack/cross-layers/openccms.c", "new_path": "openstack/cross-layers/openccms.c", "diff": "\\brief AES CCMS implementation\n\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n-\\author Malisa Vucinic <malishav@gmail.com>, March 2015.\n+\\author Malisa Vucinic <malishav@gmail.com>, June 2017.\n*/\n#include <string.h>\n#include <stdint.h>\n#include \"opendefs.h\"\n#include \"openccms.h\"\n+#include \"openaes.h\"\n#include \"cryptoengine.h\"\n//=========================== defines =========================================\n@@ -300,7 +301,7 @@ owerror_t aes_cbc_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t\nfor (k = 0; k < 16; k++) {\npbuf[k] ^= pxor[k];\n}\n- cryptoengine_aes_ecb_enc(pbuf,key);\n+ openaes_enc(pbuf,key);\npxor = pbuf;\n}\nreturn E_SUCCESS;\n@@ -326,7 +327,7 @@ owerror_t aes_ctr_enc_raw(uint8_t* buffer, uint8_t len, uint8_t key[16], uint8_t\nfor (n = 0; n < nb; n++) {\npbuf = &buffer[16 * n];\nmemcpy(eiv, iv, 16);\n- cryptoengine_aes_ecb_enc(eiv, key);\n+ openaes_enc(eiv, key);\n// may be faster if vector are aligned to 4 bytes (use long instead char in xor)\nfor (k = 0; k < 16; k++) {\npbuf[k] ^= eiv[k];\n" }, { "change_type": "MODIFY", "old_path": "openstack/cross-layers/openccms.h", "new_path": "openstack/cross-layers/openccms.h", "diff": "\\brief Definitions for AES CCMS implementation\n\\author Marcelo Barros de Almeida <marcelobarrosalmeida@gmail.com>, March 2015.\n+\\author Malisa Vucinic <malishav@gmail.com>, June 2017.\n*/\n#ifndef __OPENCCMS_H__\n#define __OPENCCMS_H__\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Use firmware implementation of AES in openccms.
491,609
16.06.2017 11:41:43
-7,200
b9e43bcc20112b40386008212c0ea4853e07ffbd
Update doc to specify that openccms invokes software AES.
[ { "change_type": "MODIFY", "old_path": "openstack/cross-layers/openccms.c", "new_path": "openstack/cross-layers/openccms.c", "diff": "@@ -25,7 +25,7 @@ static void inc_counter(uint8_t* counter);\n//=========================== public ==========================================\n/**\n-\\brief CCM* forward transformation (i.e. encryption + authentication).\n+\\brief CCM* forward transformation (i.e. encryption + authentication) implemented in software. Invokes software implementation of AES.\n\\param[in] a Pointer to the authentication only data.\n\\param[in] len_a Length of authentication only data.\n\\param[in,out] m Pointer to the data that is both authenticated and encrypted. Overwritten by\n@@ -68,7 +68,7 @@ owerror_t openccms_enc(uint8_t* a,\n}\n/**\n-\\brief CCM* inverse transformation (i.e. decryption + tag verification).\n+\\brief CCM* inverse transformation (i.e. decryption + tag verification) implemented in software. Invokes software implementation of AES.\n\\param[in] a Pointer to the authentication only data.\n\\param[in] len_a Length of authentication only data.\n\\param[in,out] m Pointer to the data that is both authenticated and encrypted. Overwritten by\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. Update doc to specify that openccms invokes software AES.
491,609
16.06.2017 13:40:34
-7,200
5d5442a5ac4783711cdd022ae706c52e8fcb6117
Reduce memory footprint by including dummy 15.4 security functions when security is not used.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.c", "new_path": "openstack/02a-MAClow/IEEE802154_security.c", "diff": "#include \"IEEE802154_security.h\"\n//=============================define==========================================\n-\n+#ifdef L2_SECURITY_ACTIVE\n//=========================== variables =======================================\nieee802154_security_vars_t ieee802154_security_vars;\n@@ -911,3 +911,35 @@ void IEEE802154_security_getFrameCounter(macFrameCounter_t reference,\narray[4] = reference.byte4;\n}\n+#else /* L2_SECURITY_ACTIVE */\n+\n+void IEEE802154_security_init(void) {\n+ return;\n+}\n+\n+void IEEE802154_security_prependAuxiliarySecurityHeader(OpenQueueEntry_t* msg){\n+ return;\n+}\n+\n+void IEEE802154_security_retrieveAuxiliarySecurityHeader(OpenQueueEntry_t* msg, ieee802154_header_iht* tempheader) {\n+ return;\n+}\n+\n+owerror_t IEEE802154_security_outgoingFrameSecurity(OpenQueueEntry_t* msg) {\n+ return E_SUCCESS;\n+}\n+\n+owerror_t IEEE802154_security_incomingFrame(OpenQueueEntry_t* msg) {\n+ return E_SUCCESS;\n+}\n+\n+uint8_t IEEE802154_security_authLengthChecking(uint8_t sec_level) {\n+ return (uint8_t) 0;\n+}\n+\n+uint8_t IEEE802154_security_auxLengthChecking(uint8_t kid, uint8_t sup, uint8_t size) {\n+ return (uint8_t) 0;\n+}\n+\n+#endif /* L2_SECURITY_ACTIVE */\n+\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
Reduce memory footprint by including dummy 15.4 security functions when security is not used.
491,595
16.06.2017 16:08:27
-7,200
b37d21bf94a36521ce1cf3132d0120589e096518
change the way to assign key1 and key2.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154_security.c", "new_path": "openstack/02a-MAClow/IEEE802154_security.c", "diff": "#ifdef L2_SECURITY_ACTIVE\n//=========================== variables =======================================\n+static const uint8_t key1[] = {\n+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,\n+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11\n+};\n+\n+static const uint8_t key2[] = {\n+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,\n+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22\n+};\n+\nieee802154_security_vars_t ieee802154_security_vars;\n//=========================== prototypes ======================================\n@@ -64,24 +74,9 @@ void IEEE802154_security_init(void) {\n//Setting UP Phase\n- //KEY 1: '6TiSCH minimal15' - used to authenticate beacon frames\n+ // copy key1\nmemset(&ieee802154_security_vars.Key_1[0], 0, 16);\n- ieee802154_security_vars.Key_1[0] = 0x36;\n- ieee802154_security_vars.Key_1[1] = 0x54;\n- ieee802154_security_vars.Key_1[2] = 0x69;\n- ieee802154_security_vars.Key_1[3] = 0x53;\n- ieee802154_security_vars.Key_1[4] = 0x43;\n- ieee802154_security_vars.Key_1[5] = 0x48;\n- ieee802154_security_vars.Key_1[6] = 0x20;\n- ieee802154_security_vars.Key_1[7] = 0x6d;\n- ieee802154_security_vars.Key_1[8] = 0x69;\n- ieee802154_security_vars.Key_1[9] = 0x6e;\n- ieee802154_security_vars.Key_1[10] = 0x69;\n- ieee802154_security_vars.Key_1[11] = 0x6d;\n- ieee802154_security_vars.Key_1[12] = 0x61;\n- ieee802154_security_vars.Key_1[13] = 0x6c;\n- ieee802154_security_vars.Key_1[14] = 0x31;\n- ieee802154_security_vars.Key_1[15] = 0x35;\n+ memcpy(&ieee802154_security_vars.Key_1[0], &key1[0], 16);\n//Initialization of the MAC Security Level Table\nfor (i = 0; i < IEEE154_TYPE_UNDEFINED; i++) { // iterate through all frame types\n@@ -143,24 +138,9 @@ void IEEE802154_security_init(void) {\nieee802154_security_vars.MacDeviceTable.DeviceDescriptorEntry[0].deviceAddress = ieee802154_security_vars.m_macDefaultKeySource;\nieee802154_security_vars.MacKeyTable.KeyDescriptorElement[0].DeviceTable = &ieee802154_security_vars.MacDeviceTable;\n- //KEY 2: 'deadbeeffacecafedeadbeeffacecafe'\n+ //copy key2\nmemset(&ieee802154_security_vars.Key_2[0], 0, 16);\n- ieee802154_security_vars.Key_2[0] = 0xde;\n- ieee802154_security_vars.Key_2[1] = 0xad;\n- ieee802154_security_vars.Key_2[2] = 0xbe;\n- ieee802154_security_vars.Key_2[3] = 0xef;\n- ieee802154_security_vars.Key_2[4] = 0xfa;\n- ieee802154_security_vars.Key_2[5] = 0xce;\n- ieee802154_security_vars.Key_2[6] = 0xca;\n- ieee802154_security_vars.Key_2[7] = 0xfe;\n- ieee802154_security_vars.Key_2[8] = 0xde;\n- ieee802154_security_vars.Key_2[9] = 0xad;\n- ieee802154_security_vars.Key_2[10] = 0xbe;\n- ieee802154_security_vars.Key_2[11] = 0xef;\n- ieee802154_security_vars.Key_2[12] = 0xfa;\n- ieee802154_security_vars.Key_2[13] = 0xce;\n- ieee802154_security_vars.Key_2[14] = 0xca;\n- ieee802154_security_vars.Key_2[15] = 0xfe;\n+ memset(&ieee802154_security_vars.Key_2[0], &key2[0], 16);\n//store the key 2 and related attributes\n//Creation of the KeyDescriptor - Key 2 should be used to encrypt and authenticate data, command and ack frames\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. change the way to assign key1 and key2.
491,595
16.06.2017 16:18:13
-7,200
f424ac0af4337eb60ad1cce6d4960b3492393125
fix the timing issue when l2 security is enabled.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/openmote-cc2538/board_info.h", "new_path": "bsp/boards/openmote-cc2538/board_info.h", "diff": "#define PORT_maxTxAckPrepare 10 // 122us (measured 94us)\n// radio speed related\n#ifdef L2_SECURITY_ACTIVE\n-#define PORT_delayTx 7 // 366us (measured xxxus)\n+#define PORT_delayTx 14 // 366us (measured xxxus)\n#else\n#define PORT_delayTx 12 // 366us (measured xxxus)\n#endif\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-401. fix the timing issue when l2 security is enabled.
491,595
16.06.2017 17:08:47
-7,200
4947ed9e1e19b74285fc03d8b3c44766d4954948
return SUCCESS code even no cells are available to add or be candidate for relocation.
[ { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -71,13 +71,13 @@ void sixtop_six2six_notifyReceive(\n//=== helper functions\n-void sixtop_addCells(\n+bool sixtop_addCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\nuint8_t cellOptions\n);\n-void sixtop_removeCells(\n+bool sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\n@@ -840,6 +840,7 @@ void timer_sixtop_six2six_timeout_fired(void) {\nvoid sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\n+ bool scheduleChanged;\nmsg->owner = COMPONENT_SIXTOP_RES;\n// if this is a request send done\n@@ -890,40 +891,48 @@ void sixtop_six2six_sendDone(OpenQueueEntry_t* msg, owerror_t error){\n// in case a response is sent out, check the return code\nif (msg->l2_sixtop_returnCode == IANA_6TOP_RC_SUCCESS){\nif (msg->l2_sixtop_command == IANA_6TOP_CMD_ADD){\n+ if (\nsixtop_addCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_add,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n- );\n+ ) == TRUE\n+ ) {\nneighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\n+ }\nif (msg->l2_sixtop_command == IANA_6TOP_CMD_DELETE){\n+ if (\nsixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_delete,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n- );\n+ ) == TRUE\n+ ){\nneighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\n+ }\nif ( msg->l2_sixtop_command == IANA_6TOP_CMD_RELOCATE){\n- sixtop_removeCells(\n+ scheduleChanged = sixtop_removeCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_delete,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n);\n- sixtop_addCells(\n+ scheduleChanged |= sixtop_addCells(\nmsg->l2_sixtop_frameID,\nmsg->l2_sixtop_celllist_add,\n&(msg->l2_nextORpreviousHop),\nmsg->l2_sixtop_cellOptions\n);\n+ if (scheduleChanged){\nneighbors_updateGeneration(&(msg->l2_nextORpreviousHop));\n}\n+ }\nif ( msg->l2_sixtop_command == IANA_6TOP_CMD_CLEAR){\nschedule_removeAllCells(\n@@ -1040,6 +1049,7 @@ void sixtop_six2six_notifyReceive(\nuint8_t pktLen = length;\nuint8_t response_pktLen = 0;\ncellInfo_ht celllist_list[CELLLIST_MAX_LEN];\n+ bool scheduleChanged;\nif (type == SIXTOP_CELL_REQUEST){\n// if this is a 6p request message\n@@ -1219,7 +1229,6 @@ void sixtop_six2six_notifyReceive(\ni++;\n}\nif (sixtop_areAvailableCellsToBeScheduled(metadata,numCells,response_pkt->l2_sixtop_celllist_add)){\n- returnCode = IANA_6TOP_RC_SUCCESS;\nfor(i=0;i<CELLLIST_MAX_LEN;i++) {\nif(response_pkt->l2_sixtop_celllist_add[i].isUsed){\npacketfunctions_reserveHeaderSize(response_pkt,4);\n@@ -1230,9 +1239,8 @@ void sixtop_six2six_notifyReceive(\nresponse_pktLen += 4;\n}\n}\n- } else {\n- returnCode = IANA_6TOP_RC_RESET;\n}\n+ returnCode = IANA_6TOP_RC_SUCCESS;\nbreak;\n}\n@@ -1313,7 +1321,6 @@ void sixtop_six2six_notifyReceive(\ni++;\n}\nif (sixtop_areAvailableCellsToBeScheduled(metadata,numCells,response_pkt->l2_sixtop_celllist_add)){\n- returnCode = IANA_6TOP_RC_SUCCESS;\nfor(i=0;i<CELLLIST_MAX_LEN;i++) {\nif(response_pkt->l2_sixtop_celllist_add[i].isUsed){\npacketfunctions_reserveHeaderSize(response_pkt,4);\n@@ -1324,9 +1331,8 @@ void sixtop_six2six_notifyReceive(\nresponse_pktLen += 4;\n}\n}\n- } else {\n- returnCode = IANA_6TOP_RC_RESET;\n}\n+ returnCode = IANA_6TOP_RC_SUCCESS;\nbreak;\n}\n} while(0);\n@@ -1406,22 +1412,28 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n+ if (\nsixtop_addCells(\nsixtop_vars.cb_sf_getMetadata(), // frame id\npkt->l2_sixtop_celllist_add, // celllist to be added\n&(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to\nsixtop_vars.cellOptions // cell options\n- );\n+ ) == TRUE\n+ ) {\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\n+ }\nbreak;\ncase SIX_STATE_WAIT_DELETERESPONSE:\n+ if (\nsixtop_removeCells(\nsixtop_vars.cb_sf_getMetadata(),\nsixtop_vars.celllist_toDelete,\n&(pkt->l2_nextORpreviousHop),\nsixtop_vars.cellOptions\n- );\n+ ) == TRUE\n+ ) {\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\n+ }\nbreak;\ncase SIX_STATE_WAIT_RELOCATERESPONSE:\ni = 0;\n@@ -1436,19 +1448,21 @@ void sixtop_six2six_notifyReceive(\npktLen -= 4;\ni++;\n}\n- sixtop_removeCells(\n+ scheduleChanged = sixtop_removeCells(\nsixtop_vars.cb_sf_getMetadata(),\nsixtop_vars.celllist_toDelete,\n&(pkt->l2_nextORpreviousHop),\nsixtop_vars.cellOptions\n);\n- sixtop_addCells(\n+ scheduleChanged |= sixtop_addCells(\nsixtop_vars.cb_sf_getMetadata(), // frame id\npkt->l2_sixtop_celllist_add, // celllist to be added\n&(pkt->l2_nextORpreviousHop), // neighbor that cells to be added to\nsixtop_vars.cellOptions // cell options\n);\n+ if (scheduleChanged) {\nneighbors_updateGeneration(&(pkt->l2_nextORpreviousHop));\n+ }\nbreak;\ncase SIX_STATE_WAIT_COUNTRESPONSE:\nnumCells = *((uint8_t*)(pkt->payload)+ptr);\n@@ -1510,7 +1524,7 @@ void sixtop_six2six_notifyReceive(\n//======= helper functions\n-void sixtop_addCells(\n+bool sixtop_addCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\n@@ -1520,6 +1534,7 @@ void sixtop_addCells(\nbool isShared;\nopen_addr_t temp_neighbor;\ncellType_t type;\n+ bool hasCellsAdded;\n// translate cellOptions to cell type\nif (cellOptions == LINKOPTIONS_TX){\n@@ -1542,9 +1557,11 @@ void sixtop_addCells(\nmemcpy(&temp_neighbor,previousHop,sizeof(open_addr_t));\n}\n+ hasCellsAdded = FALSE;\n// add cells to schedule\nfor(i = 0;i<CELLLIST_MAX_LEN;i++){\nif (cellList[i].isUsed){\n+ hasCellsAdded = TRUE;\nschedule_addActiveSlot(\ncellList[i].slotoffset,\ntype,\n@@ -1554,9 +1571,11 @@ void sixtop_addCells(\n);\n}\n}\n+\n+ return hasCellsAdded;\n}\n-void sixtop_removeCells(\n+bool sixtop_removeCells(\nuint8_t slotframeID,\ncellInfo_ht* cellList,\nopen_addr_t* previousHop,\n@@ -1565,6 +1584,8 @@ void sixtop_removeCells(\nuint8_t i;\nbool isShared;\nopen_addr_t temp_neighbor;\n+ bool hasCellsRemoved;\n+\n// translate cellOptions to cell type\nif (cellOptions == LINKOPTIONS_TX){\nisShared = FALSE;\n@@ -1582,15 +1603,20 @@ void sixtop_removeCells(\n} else {\nmemcpy(&temp_neighbor,previousHop,sizeof(open_addr_t));\n}\n+\n+ hasCellsRemoved = FALSE;\n// delete cells from schedule\nfor(i=0;i<CELLLIST_MAX_LEN;i++){\nif (cellList[i].isUsed){\n+ hasCellsRemoved = TRUE;\nschedule_removeActiveSlot(\ncellList[i].slotoffset,\n&temp_neighbor\n);\n}\n}\n+\n+ return hasCellsRemoved;\n}\nbool sixtop_areAvailableCellsToBeScheduled(\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. return SUCCESS code even no cells are available to add or be candidate for relocation.
491,595
19.06.2017 11:26:51
-7,200
8431d5139a7bc65afeebfe864a50ed4fb0751d47
allow non-default minimal schedule. (e.g: more than one active cell)
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -693,26 +693,28 @@ port_INLINE bool ieee154e_processIEs(OpenQueueEntry_t* pkt, uint16_t* lenIE) {\nuint16_t oldFrameLength;\nopen_addr_t temp_neighbor;\nif (isValidEbFormat(pkt)==TRUE){\n- *lenIE = sizeof(ebIEsBytestream);\n+ *lenIE = sizeof(ebIEsBytestream)+5*(*((uint8_t*)(pkt->payload)+EB_SLOTFRAME_NUMLINK_OFFSET)-1);\nasnStoreFromEB((uint8_t*)(pkt->payload)+EB_ASN0_OFFSET);\njoinPriorityStoreFromEB(*((uint8_t*)(pkt->payload)+EB_JP_OFFSET));\nschedule_setFrameNumber(1);\noldFrameLength = schedule_getFrameLength();\nif (oldFrameLength==0){\n- schedule_setFrameLength(SLOTFRAME_LENGTH);\n+ schedule_setFrameLength(*((uint8_t*)(pkt->payload)+EB_SLOTFRAME_LEN_OFFSET));\n// shared TXRX anycast slot(s)\nmemset(&temp_neighbor,0,sizeof(temp_neighbor));\ntemp_neighbor.type = ADDR_ANYCAST;\n+ for (i=0;i<*((uint8_t*)(pkt->payload)+EB_SLOTFRAME_NUMLINK_OFFSET);i++){\nschedule_addActiveSlot(\n- 0, // slot offset\n+ i, // slot offset\nCELLTYPE_TXRX, // type of slot\nTRUE, // shared?\n0, // channel offset\n&temp_neighbor // neighbor\n);\n}\n- timeslotTemplateIDStoreFromEB(0);\n- channelhoppingTemplateIDStoreFromEB(0);\n+ }\n+ timeslotTemplateIDStoreFromEB(*((uint8_t*)(pkt->payload)+EB_SLOTFRAME_TS_ID_OFFSET));\n+ channelhoppingTemplateIDStoreFromEB(*((uint8_t*)(pkt->payload)+EB_SLOTFRAME_CH_ID_OFFSET));\n// at this point, ASN and frame length are known\n// the current slotoffset can be inferred\nieee154e_syncSlotOffset();\n@@ -2217,8 +2219,8 @@ bool isValidEbFormat(OpenQueueEntry_t* pkt){\nif (pkt->length<EB_IE_LEN){\nreturn FALSE;\n}\n- for (i=0;i<EB_IE_LEN;i++){\n- if (i>=EB_ASN0_OFFSET && i<=EB_JP_OFFSET){\n+ for (i=2;i<EB_IE_LEN;i++){\n+ if ((i>=EB_ASN0_OFFSET && i<=EB_JP_OFFSET) || i==EB_SLOTFRAME_LEN_OFFSET || i==EB_SLOTFRAME_NUMLINK_OFFSET){\ncontinue;\n} else {\nif (ebIEsBytestream[i]!=pkt->payload[i]){\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "@@ -23,13 +23,18 @@ static const uint8_t chTemplate_default[] = {\n// refer to RFC8180: https://tools.ietf.org/html/rfc8180#appendix-A.1\n// ASN and join Metric are replaced later when sending an EB\nstatic const uint8_t ebIEsBytestream[] = {\n- 0x1A,0x88,0x06,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1C,0x00,\n- 0x01,0xC8,0x00,0x0A,0x1B,0x01,0x00,SLOTFRAME_LENGTH,0x00,0x01,0x00,0x00,0x00,0x00,0x0F\n+ 0x1A,0x88,0x06,0x1A,0x00,0x00, 0x00,0x00, 0x00,0x00,0x01,0x1C,0x00,0x01,\n+ 0xC8,0x00,0x0A,0x1B,0x01,0x00,SLOTFRAME_LENGTH,0x00,SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS,0x00,0x00,0x00,0x00,0x0F\n};\n//=========================== define ==========================================\n#define EB_ASN0_OFFSET 4\n#define EB_JP_OFFSET 9\n+#define EB_SLOTFRAME_TS_ID_OFFSET 12\n+#define EB_SLOTFRAME_CH_ID_OFFSET 15\n+#define EB_SLOTFRAME_LEN_OFFSET 20\n+#define EB_SLOTFRAME_NUMLINK_OFFSET 22\n+\n#define EB_IE_LEN 28\n#define SYNCHRONIZING_CHANNEL 26 // channel the mote listens on to synchronize\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/schedule.h", "new_path": "openstack/02b-MAChigh/schedule.h", "diff": "@@ -23,7 +23,7 @@ The superframe reappears over time and can be arbitrarily long.\n#define SCHEDULE_MINIMAL_6TISCH_ACTIVE_CELLS 1\n#define SCHEDULE_MINIMAL_6TISCH_SLOTOFFSET 0\n#define SCHEDULE_MINIMAL_6TISCH_CHANNELOFFSET 0\n-#define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE 1 //id of slotframe\n+#define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_HANDLE 0 //id of slotframe\n#define SCHEDULE_MINIMAL_6TISCH_DEFAULT_SLOTFRAME_NUMBER 1 //1 slotframe by default.\n#define NUMSERIALRX 3\n" }, { "change_type": "MODIFY", "old_path": "openstack/02b-MAChigh/sixtop.c", "new_path": "openstack/02b-MAChigh/sixtop.c", "diff": "@@ -685,6 +685,8 @@ readability of the code.\nport_INLINE void sixtop_sendEB() {\nOpenQueueEntry_t* eb;\nuint8_t i;\n+ uint8_t eb_len;\n+ uint16_t temp16b;\nif ((ieee154e_isSynch()==FALSE) || (icmpv6rpl_getMyDAGrank()==DEFAULTDAGRANK)){\n// I'm not sync'ed or I did not acquire a DAGrank\n@@ -723,11 +725,32 @@ port_INLINE void sixtop_sendEB() {\neb->creator = COMPONENT_SIXTOP;\neb->owner = COMPONENT_SIXTOP;\n+ // in case we none default number of shared cells defined in minimal configuration\n+ if (ebIEsBytestream[EB_SLOTFRAME_NUMLINK_OFFSET]>1){\n+ for (i=ebIEsBytestream[EB_SLOTFRAME_NUMLINK_OFFSET]-1;i>0;i--){\n+ packetfunctions_reserveHeaderSize(eb,5);\n+ eb->payload[0] = i; // slot offset\n+ eb->payload[1] = 0x00;\n+ eb->payload[2] = 0x00; // channel offset\n+ eb->payload[3] = 0x00;\n+ eb->payload[4] = 0x0F; // link options\n+ }\n+ }\n+\n// reserve space for EB IEs\npacketfunctions_reserveHeaderSize(eb,EB_IE_LEN);\nfor (i=0;i<EB_IE_LEN;i++){\neb->payload[i] = ebIEsBytestream[i];\n}\n+\n+ if (ebIEsBytestream[EB_SLOTFRAME_NUMLINK_OFFSET]>1){\n+ // reconstruct the MLME IE header since length changed\n+ eb_len = EB_IE_LEN-2+5*(ebIEsBytestream[EB_SLOTFRAME_NUMLINK_OFFSET]-1);\n+ temp16b = eb_len | IEEE802154E_PAYLOAD_DESC_GROUP_ID_MLME | IEEE802154E_PAYLOAD_DESC_TYPE_MLME;\n+ eb->payload[0] = (uint8_t)(temp16b & 0x00ff);\n+ eb->payload[1] = (uint8_t)((temp16b & 0xff00)>>8);\n+ }\n+\n// Keep a pointer to where the ASN will be\n// Note: the actual value of the current ASN and JP will be written by the\n// IEEE802.15.4e when transmitting\n" }, { "change_type": "MODIFY", "old_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "new_path": "projects/openmote-cc2538/03oos_openwsn/03oos_openwsn.ewp", "diff": "<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cexample\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cinfo\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cleds\\</state>\n+ <state>$PROJ_DIR$\\..\\..\\..\\openapps\\csensors\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\cwellknown\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\opencoap\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\techo\\</state>\n<name>bsp</name>\n<group>\n<name>boards</name>\n- <group>\n- <name>common</name>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_cbc.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_cbc.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ccms.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ccms.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ctr.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ctr.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ecb.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ecb.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\dummy_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\dummy_crypto_engine.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\firmware_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\firmware_crypto_engine.h</name>\n- </file>\n- </group>\n<group>\n<name>openmote-CC2538</name>\n<group>\n<name>headers</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_aes.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_aes.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ana_regs.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_cctest.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_flash_ctrl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_flash_ctrl.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gpio.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gpio.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_gptimer.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cm.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cm.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_i2cs.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_i2cs.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ints.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_ints.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ioc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_memmap.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_memmap.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_nvic.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_nvic.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_pka.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_pka.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_ffsm.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_rfcore_xreg.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_smwdthrosc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_smwdthrosc.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_soc_adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_soc_adc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_ssi.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_types.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_uart.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_uart.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udma.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udma.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_udmachctl.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\headers\\hw_udmachctl.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\headers\\hw_usb.h</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\adc.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\adc.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\aes.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\gptimer.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\gptimer.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\i2c_lib.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sleepmode.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\sleepmode.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\sleepmode.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\ssi.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\uarthal.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\uarthal.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\source\\uarthal.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\source\\udma.c</name>\n</excluded>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\cc2538_crypto_engine.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538rf.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cc2538rf.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\openmote-cc2538\\cryptoengine.c</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\OpenMote-CC2538\\debugpins.c</name>\n<configuration>Debug</configuration>\n</excluded>\n</file>\n+ <file>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\cryptoengine.h</name>\n+ </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\debugpins.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154.h</name>\n</file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_dummy_security.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_dummy_security.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_security.c</name>\n</file>\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-602. allow non-default minimal schedule. (e.g: more than one active cell)
491,609
19.06.2017 13:02:56
-7,200
cb75a114d43e7813e224b125882527dc244f9324
Move resource descriptor within the module vars.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -27,7 +27,6 @@ const uint8_t cjoin_path0[] = \"j\";\nstatic const uint8_t ipAddr_jce[] = {0xbb, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \\\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};\n-coap_resource_desc_t desc;\n//=========================== variables =======================================\ncjoin_vars_t cjoin_vars;\n@@ -59,19 +58,19 @@ void printf_hex(unsigned char *data, unsigned int len){\nvoid cjoin_init() {\n// prepare the resource descriptor for the /j path\n- desc.path0len = sizeof(cjoin_path0)-1;\n- desc.path0val = (uint8_t*)(&cjoin_path0);\n- desc.path1len = 0;\n- desc.path1val = NULL;\n- desc.componentID = COMPONENT_CJOIN;\n- desc.discoverable = TRUE;\n- desc.callbackRx = &cjoin_receive;\n- desc.callbackSendDone = &cjoin_sendDone;\n+ cjoin_vars.desc.path0len = sizeof(cjoin_path0)-1;\n+ cjoin_vars.desc.path0val = (uint8_t*)(&cjoin_path0);\n+ cjoin_vars.desc.path1len = 0;\n+ cjoin_vars.desc.path1val = NULL;\n+ cjoin_vars.desc.componentID = COMPONENT_CJOIN;\n+ cjoin_vars.desc.discoverable = TRUE;\n+ cjoin_vars.desc.callbackRx = &cjoin_receive;\n+ cjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\ncjoin_vars.isJoined = FALSE;\nmemset(&cjoin_vars.joinAsn, 0x00, sizeof(asn_t));\n- opencoap_register(&desc);\n+ opencoap_register(&cjoin_vars.desc);\ncjoin_schedule();\n}\n@@ -213,7 +212,7 @@ owerror_t cjoin_sendJoinRequest(void) {\nCOAP_TYPE_CON,\nCOAP_CODE_REQ_GET,\n1,\n- &desc\n+ &cjoin_vars.desc\n);\n// avoid overflowing the queue if fails\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "//=========================== typedef =========================================\ntypedef struct {\n+ coap_resource_desc_t desc;\nopentimer_id_t startupTimerId;\nopentimer_id_t retransmissionTimerId;\nbool isJoined;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Move resource descriptor within the module vars.
491,609
19.06.2017 14:25:53
-7,200
22162bc277c99f7d860c68e134eac5a9fc064e1e
Use the new opentimers API in cjoin.
[ { "change_type": "MODIFY", "old_path": "drivers/SConscript", "new_path": "drivers/SConscript", "diff": "@@ -51,6 +51,8 @@ else:\nos.path.join('#','openstack','cross-layers'),\n# openapps\nos.path.join('#','openapps','userialbridge'),\n+ os.path.join('#','openapps','opencoap'),\n+ os.path.join('#','openapps','cjoin'),\n],\n)\n" }, { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -37,13 +37,13 @@ defaultAppsInit = [\n# source files that should be included in the build other than\n# those with default application name (application.c)\nadditionalSourceFiles = [\n- 'cjoin/cbor.c'\n+ os.path.join('cjoin','cbor.c'),\n]\n# header files that should be included in the build other than\n# those with default application name (application.h)\nadditionalHeaderFiles = [\n- 'cjoin/cbor.h'\n+ os.path.join('cjoin','cbor.h'),\n]\n# additional apps the user wants to build\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "@@ -36,12 +36,12 @@ cjoin_vars_t cjoin_vars;\nowerror_t cjoin_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\ncoap_option_iht* coap_options);\n-void cjoin_timer_cb(opentimer_id_t id);\n+void cjoin_timer_cb(void);\nvoid cjoin_task_cb(void);\nvoid cjoin_sendDone(OpenQueueEntry_t* msg,\nowerror_t error);\nowerror_t cjoin_sendJoinRequest(void);\n-void cjoin_retransmission_cb(opentimer_id_t id);\n+void cjoin_retransmission_cb(void);\nvoid cjoin_retransmission_task_cb(void);\nbool cjoin_getIsJoined(void);\nvoid cjoin_setIsJoined(bool newValue);\n@@ -66,12 +66,15 @@ void cjoin_init() {\ncjoin_vars.desc.discoverable = TRUE;\ncjoin_vars.desc.callbackRx = &cjoin_receive;\ncjoin_vars.desc.callbackSendDone = &cjoin_sendDone;\n+\ncjoin_vars.isJoined = FALSE;\nmemset(&cjoin_vars.joinAsn, 0x00, sizeof(asn_t));\nopencoap_register(&cjoin_vars.desc);\n+ cjoin_vars.timerId = opentimers_create();\n+\ncjoin_schedule();\n}\n@@ -87,10 +90,15 @@ void cjoin_schedule() {\nif (cjoin_getIsJoined() == FALSE) {\ndelay = openrandom_get16b();\n- cjoin_vars.startupTimerId = opentimers_start((uint32_t) delay, // random wait from 0 to 65535ms\n- TIMER_PERIODIC,TIME_MS,\n- cjoin_timer_cb);\n+\n+ opentimers_scheduleIn(cjoin_vars.timerId,\n+ (uint32_t) delay, // random wait from 0 to 65535ms\n+ TIME_MS,\n+ TIMER_PERIODIC,\n+ cjoin_timer_cb\n+ );\n}\n+\n}\n//=========================== private =========================================\n@@ -101,7 +109,7 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\njoin_response_t join_response;\nowerror_t ret;\n- opentimers_stop(cjoin_vars.retransmissionTimerId); // stop the timer\n+ opentimers_cancel(cjoin_vars.timerId); // cancel the retransmission timer\nif (coap_header->Code != COAP_CODE_RESP_CONTENT) {\nreturn E_FAIL;\n@@ -127,11 +135,11 @@ owerror_t cjoin_receive(OpenQueueEntry_t* msg,\n//timer fired, but we don't want to execute task in ISR mode\n//instead, push task to scheduler with COAP priority, and let scheduler take care of it\n-void cjoin_timer_cb(opentimer_id_t id){\n+void cjoin_timer_cb(void){\nscheduler_push_task(cjoin_task_cb,TASKPRIO_COAP);\n}\n-void cjoin_retransmission_cb(opentimer_id_t id) {\n+void cjoin_retransmission_cb(void) {\nscheduler_push_task(cjoin_retransmission_task_cb, TASKPRIO_COAP);\n}\n@@ -148,6 +156,7 @@ void cjoin_task_cb() {\n// don't run if DAG root\nif (idmanager_getIsDAGroot() == TRUE) {\n+ opentimers_destroy(cjoin_vars.timerId);\nreturn;\n}\n@@ -159,7 +168,9 @@ void cjoin_task_cb() {\nif (icmpv6rpl_daoSent() == FALSE) {\nreturn;\n}\n- opentimers_stop(cjoin_vars.startupTimerId);\n+\n+ // cancel the startup timer but do not destroy it as we reuse it for retransmissions\n+ opentimers_cancel(cjoin_vars.timerId);\ncjoin_sendJoinRequest();\n@@ -175,9 +186,12 @@ owerror_t cjoin_sendJoinRequest(void) {\nowerror_t outcome;\n// immediately arm the retransmission timer\n- cjoin_vars.retransmissionTimerId = opentimers_start((uint32_t) TIMEOUT,\n- TIMER_ONESHOT,TIME_MS,\n- cjoin_retransmission_cb);\n+ opentimers_scheduleIn(cjoin_vars.timerId,\n+ (uint32_t) TIMEOUT,\n+ TIME_MS,\n+ TIMER_ONESHOT,\n+ cjoin_retransmission_cb\n+ );\n// create a CoAP RD packet\npkt = openqueue_getFreePacketBuffer(COMPONENT_CJOIN);\n" }, { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.h", "new_path": "openapps/cjoin/cjoin.h", "diff": "\\{\n*/\n#include \"opendefs.h\"\n+#include \"opencoap.h\"\n//=========================== define ==========================================\n//=========================== typedef =========================================\ntypedef struct {\ncoap_resource_desc_t desc;\n- opentimer_id_t startupTimerId;\n- opentimer_id_t retransmissionTimerId;\n+ opentimers_id_t timerId;\nbool isJoined;\nasn_t joinAsn;\nuint8_t joinKey[16];\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -27,7 +27,6 @@ sources_c = [\nos.path.join('03b-IPv6','icmpv6echo.c'),\nos.path.join('03b-IPv6','icmpv6rpl.c'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','opencoap.c'),\nos.path.join('04-TRAN','oscoap.c'),\nos.path.join('04-TRAN','openudp.c'),\n#=== cross-layers\n@@ -60,7 +59,6 @@ sources_h = [\nos.path.join('03b-IPv6','icmpv6echo.h'),\nos.path.join('03b-IPv6','icmpv6rpl.h'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','opencoap.h'),\nos.path.join('04-TRAN','oscoap.h'),\nos.path.join('04-TRAN','openudp.h'),\n#=== cross-layers\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Use the new opentimers API in cjoin.
491,609
20.06.2017 10:26:20
-7,200
202c74ae97948976868b2ac33213e289eafc638f
Add all apps to the python objectification process. This avoids the memory bug where all OpenMote instances share the same CoAP resources linked list.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/python/openwsnmodule_obj.h", "new_path": "bsp/boards/python/openwsnmodule_obj.h", "diff": "#include \"cwellknown_obj.h\"\n#include \"rrt_obj.h\"\n#include \"uecho_obj.h\"\n+#include \"uinject_obj.h\"\n+#include \"userialbridge_obj.h\"\n//=========================== prototypes ======================================\n@@ -227,6 +229,9 @@ struct OpenMote {\nrrt_vars_t rrt_vars;\n//tohlone_vars_t tohlone_vars;\ncjoin_vars_t cjoin_vars;\n+ uecho_vars_t uecho_vars;\n+ uinject_vars_t uinject_vars;\n+ userialbridge_vars_t userialbridge_vars;\n};\n#endif\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -149,7 +149,17 @@ varsToChange = [\n'r6t_vars',\n'rinfo_vars',\n'rrt_vars',\n+ 'c6t_vars',\n+ 'cexample_vars',\n+ 'cinfo_vars',\n'cjoin_vars',\n+ 'cleds_vars',\n+ 'csensors_vars',\n+ 'cstorm_vars',\n+ 'cwellknown_vars',\n+ 'uecho_vars',\n+ 'uinject_vars',\n+ 'userialbridge_vars',\n]\nreturnTypes = [\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add all apps to the python objectification process. This avoids the memory bug where all OpenMote instances share the same CoAP resources linked list.
491,609
20.06.2017 10:26:44
-7,200
06464e1f8e7604d0919f860b7687f953585a69de
Remove remnant from simulated join process implementation.
[ { "change_type": "MODIFY", "old_path": "openapps/cjoin/cjoin.c", "new_path": "openapps/cjoin/cjoin.c", "diff": "//=========================== defines =========================================\n/// inter-packet period (in ms)\n-#define NUMBER_OF_EXCHANGES 6\n#define TIMEOUT 60000\nconst uint8_t cjoin_path0[] = \"j\";\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Remove remnant from simulated join process implementation.
491,609
20.06.2017 11:21:56
-7,200
1c21a3850393e4dcfb69a459ddda2005db0ca9c3
Move oscoap to openapps and rework skeleton.
[ { "change_type": "MODIFY", "old_path": "bsp/boards/python/openwsnmodule_obj.h", "new_path": "bsp/boards/python/openwsnmodule_obj.h", "diff": "#include \"icmpv6echo_obj.h\"\n#include \"icmpv6rpl_obj.h\"\n#include \"opencoap_obj.h\"\n+#include \"openoscoap_obj.h\"\n#include \"openudp_obj.h\"\n#include \"idmanager_obj.h\"\n#include \"openqueue_obj.h\"\n@@ -195,7 +196,6 @@ struct OpenMote {\n// l4\nicmpv6echo_vars_t icmpv6echo_vars;\nicmpv6rpl_vars_t icmpv6rpl_vars;\n- opencoap_vars_t opencoap_vars;\nopenudp_vars_t openudp_vars;\n// l3\n// l2b\n@@ -220,6 +220,9 @@ struct OpenMote {\nscheduler_vars_t scheduler_vars;\nscheduler_dbg_t scheduler_dbg;\n//===== openapps\n+ //\n+ opencoap_vars_t opencoap_vars;\n+ openoscoap_vars_t openoscoap_vars;\nc6t_vars_t c6t_vars;\ncexample_vars_t cexample_vars;\ncinfo_vars_t cinfo_vars;\n" }, { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -37,12 +37,14 @@ defaultAppsInit = [\n# source files that should be included in the build other than\n# those with default application name (application.c)\nadditionalSourceFiles = [\n+ os.path.join('opencoap','openoscoap.c'),\nos.path.join('cjoin','cbor.c'),\n]\n# header files that should be included in the build other than\n# those with default application name (application.h)\nadditionalHeaderFiles = [\n+ os.path.join('opencoap','openoscoap.h'),\nos.path.join('cjoin','cbor.h'),\n]\n" }, { "change_type": "RENAME", "old_path": "openstack/04-TRAN/oscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "#include \"opendefs.h\"\n-#include \"oscoap.h\"\n+#include \"openoscoap.h\"\n+\n+\n+//=========================== defines =========================================\n+\n+//=========================== variables =======================================\n+\n+openoscoap_vars_t openoscoap_vars;\n+\n+//=========================== prototype =======================================\n+\n+//=========================== public ==========================================\n+\n/**\n\\brief Initialize OSCOAP security context.\n@@ -18,7 +30,8 @@ security context.\n\\param[in] Length of the Master Salt byte array in bytes.\n*/\n-void oscoap_init_security_context(oscoap_security_context_t *ctx,\n+void openoscoap_init_security_context(oscoap_security_context_t *ctx,\n+\nuint8_t* senderID,\nuint8_t senderIDLen,\nuint8_t* recipientID,\n" }, { "change_type": "RENAME", "old_path": "openstack/04-TRAN/oscoap.h", "new_path": "openapps/opencoap/openoscoap.h", "diff": "-#ifndef __OSCOAP_H\n-#define __OSCOAP_H\n+#ifndef __OPENOSCOAP_H\n+#define __OPENOSCOAP_H\n/**\n\\addtogroup Transport\n@@ -48,9 +48,15 @@ typedef struct {\nreplay_window_t window;\n} oscoap_security_context_t;\n+\n+//=========================== module variables ================================\n+\n+typedef struct {\n+} openoscoap_vars_t;\n+\n//=========================== prototypes ======================================\n-void oscoap_init_security_context(oscoap_security_context_t *ctx,\n+void openoscoap_init_security_context(oscoap_security_context_t *ctx,\nuint8_t* senderID,\nuint8_t senderIDLen,\nuint8_t* recipientID,\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -27,7 +27,6 @@ sources_c = [\nos.path.join('03b-IPv6','icmpv6echo.c'),\nos.path.join('03b-IPv6','icmpv6rpl.c'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','oscoap.c'),\nos.path.join('04-TRAN','openudp.c'),\n#=== cross-layers\nos.path.join('cross-layers','idmanager.c'),\n@@ -59,7 +58,6 @@ sources_h = [\nos.path.join('03b-IPv6','icmpv6echo.h'),\nos.path.join('03b-IPv6','icmpv6rpl.h'),\n#=== 04-TRAN\n- os.path.join('04-TRAN','oscoap.h'),\nos.path.join('04-TRAN','openudp.h'),\n#=== cross-layers\nos.path.join('cross-layers','idmanager.h'),\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -136,7 +136,6 @@ varsToChange = [\n# 03b-IPv6\n'icmpv6echo_vars',\n'icmpv6rpl_vars',\n- 'opencoap_vars',\n#===== applications\n#+++++ UDP\n#- debug\n@@ -144,6 +143,8 @@ varsToChange = [\n'udpstorm_vars',\n'openudp_vars',\n#+++++ CoAP\n+ 'opencoap_vars',\n+ 'openoscoap_vars',\n#- debug\n#- common\n'r6t_vars',\n@@ -705,7 +706,7 @@ functionsToChange = [\n'opencoap_send',\n'icmpv6coap_timer_cb',\n# oscoap\n- 'oscoap_init_security_context',\n+ 'openoscoap_init_security_context',\n# openudp\n'openudp_init',\n'openudp_send',\n@@ -907,7 +908,6 @@ headerFiles = [\n'icmpv6echo',\n'icmpv6rpl',\n# 04-TRAN\n- 'opencoap',\n'openudp',\n'rsvp',\n# cross-layers\n@@ -918,6 +918,8 @@ headerFiles = [\n'openaes',\n'openccms',\n#=== openapps\n+ 'opencoap',\n+ 'openoscoap',\n'openapps',\n'c6t',\n'cexample',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Move oscoap to openapps and rework skeleton.
491,609
20.06.2017 13:56:38
-7,200
d331ec687b7e53d28474d4659a604c4aca45d612
Rename opt-cbor.[ch] to cborencoder.[ch] and integrate with OpenWSN.
[ { "change_type": "RENAME", "old_path": "openstack/cross-layers/opt-cbor.c", "new_path": "openstack/cross-layers/cborencoder.c", "diff": "+/**\n+\\brief CBOR encoder library.\n-#include \"opt-cbor.h\"\n-#include <string.h>\n+\\author Martin Gunnarsson <martin.gunnarsson@ri.se>\n+*/\n-#define DEBUG 0\n-#if DEBUG\n-#include <stdio.h>\n-#define PRINTF(...) printf(__VA_ARGS__)\n-#define PRINTF_HEX(data, len) oscoap_printf_hex(data, len)\n-#else\n-#define PRINTF(...)\n-#define PRINTF_HEX(data, len)\n-#endif\n+#include \"cborencoder.h\"\n-\n-uint8_t OPT_CBOR_put_text(uint8_t **buffer, char *text, uint8_t text_len){\n+uint8_t cborencoder_put_text(uint8_t **buffer, char *text, uint8_t text_len){\nuint8_t ret = 0;\nif(text_len > 23 ){\n@@ -35,9 +28,8 @@ uint8_t OPT_CBOR_put_text(uint8_t **buffer, char *text, uint8_t text_len){\nreturn ret;\n}\n-uint8_t OPT_CBOR_put_array(uint8_t **buffer,uint8_t elements){\n+uint8_t cborencoder_put_array(uint8_t **buffer,uint8_t elements){\nif(elements > 15){\n- PRINTF(\"ERROR! in put array\\n\");\nreturn 0;\n}\n@@ -46,7 +38,7 @@ uint8_t OPT_CBOR_put_array(uint8_t **buffer,uint8_t elements){\nreturn 1;\n}\n-uint8_t OPT_CBOR_put_bytes(uint8_t **buffer, uint8_t bytes_len, uint8_t *bytes){\n+uint8_t cborencoder_put_bytes(uint8_t **buffer, uint8_t bytes_len, uint8_t *bytes){\nuint8_t ret = 0;\nif(bytes_len > 23){\n**buffer = 0x58;\n@@ -64,9 +56,8 @@ uint8_t OPT_CBOR_put_bytes(uint8_t **buffer, uint8_t bytes_len, uint8_t *bytes){\nret += bytes_len;\nreturn ret;\n}\n-uint8_t OPT_CBOR_put_map(uint8_t **buffer, uint8_t elements){\n+uint8_t cborencoder_put_map(uint8_t **buffer, uint8_t elements){\nif(elements > 15){\n- PRINTF(\"ERROR in put map\\n\");\nreturn 0;\n}\n**buffer = (0xa0 | elements);\n@@ -75,7 +66,7 @@ uint8_t OPT_CBOR_put_map(uint8_t **buffer, uint8_t elements){\nreturn 1;\n}\n-uint8_t OPT_CBOR_put_unsigned(uint8_t **buffer, uint8_t value){\n+uint8_t cborencoder_put_unsigned(uint8_t **buffer, uint8_t value){\nif(value > 0x17 ){\n(**buffer) = (0x18);\n(*buffer)++;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "openstack/cross-layers/cborencoder.h", "diff": "+#ifndef _CBORENCODER_H\n+#define _CBORENCODER_H\n+\n+#include \"opendefs.h\"\n+\n+uint8_t cborencoder_put_text(uint8_t **buffer, char *text, uint8_t text_len);\n+\n+uint8_t cborencoder_put_array(uint8_t **buffer,uint8_t elements);\n+\n+uint8_t cborencoder_put_bytes(uint8_t **buffer, uint8_t bytes_len, uint8_t *bytes);\n+\n+uint8_t cborencoder_put_map(uint8_t **buffer, uint8_t elements);\n+\n+uint8_t cborencoder_put_unsigned(uint8_t **buffer, uint8_t value);\n+\n+#endif /* _CBORENCODER_H */\n" }, { "change_type": "DELETE", "old_path": "openstack/cross-layers/opt-cbor.h", "new_path": null, "diff": "-#ifndef _OPT_CBOR_H\n-#define _OPT_CBOR_H\n-#include <stddef.h>\n-#include <inttypes.h>\n-\n-uint8_t OPT_CBOR_put_text(uint8_t **buffer, char *text, uint8_t text_len);\n-\n-uint8_t OPT_CBOR_put_array(uint8_t **buffer,uint8_t elements);\n-\n-uint8_t OPT_CBOR_put_bytes(uint8_t **buffer, uint8_t bytes_len, uint8_t *bytes);\n-\n-uint8_t OPT_CBOR_put_map(uint8_t **buffer, uint8_t elements);\n-\n-uint8_t OPT_CBOR_put_unsigned(uint8_t **buffer, uint8_t value);\n-\n-#endif /* _OPT_CBOR_H */\n\\ No newline at end of file\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Rename opt-cbor.[ch] to cborencoder.[ch] and integrate with OpenWSN.
491,609
20.06.2017 16:08:31
-7,200
b55d8c5f7941e75caf795b36ffba36b8b8b28cb4
Add SHA and CBOR files to build.
[ { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -35,6 +35,11 @@ sources_c = [\nos.path.join('cross-layers','packetfunctions.c'),\nos.path.join('cross-layers','openaes.c'),\nos.path.join('cross-layers','openccms.c'),\n+ os.path.join('cross-layers','usha.c'),\n+ os.path.join('cross-layers','hkdf.c'),\n+ os.path.join('cross-layers','hmac.c'),\n+ os.path.join('cross-layers','sha224-256.c'),\n+ os.path.join('cross-layers','cborencoder.c'),\n]\nsources_h = [\n'openstack.h',\n@@ -66,6 +71,8 @@ sources_h = [\nos.path.join('cross-layers','packetfunctions.h'),\nos.path.join('cross-layers','openaes.h'),\nos.path.join('cross-layers','openccms.h'),\n+ os.path.join('cross-layers','sha.h'),\n+ os.path.join('cross-layers','cborencoder.h'),\n#=== apps\nos.path.join('#','openapps','userialbridge','userialbridge.h'),\n]\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add SHA and CBOR files to build.
491,609
20.06.2017 16:09:00
-7,200
fc2807c58e08337920c80e3e407202d059e54de8
Derive security context using HKDF.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "#include \"opendefs.h\"\n#include \"openoscoap.h\"\n+#include \"cborencoder.h\"\n+#include \"sha.h\"\n//=========================== defines =========================================\nopenoscoap_vars_t openoscoap_vars;\n//=========================== prototype =======================================\n+owerror_t hkdf_derive_parameter(uint8_t* buffer,\n+ uint8_t* masterSecret,\n+ uint8_t masterSecretLen,\n+ uint8_t* masterSalt,\n+ uint8_t masterSaltLen,\n+ uint8_t* identifier,\n+ uint8_t identifierLen,\n+ uint8_t algorithm,\n+ oscoap_derivation_t type,\n+ uint8_t length\n+ );\n//=========================== public ==========================================\n@@ -31,7 +44,6 @@ security context.\n*/\nvoid openoscoap_init_security_context(oscoap_security_context_t *ctx,\n-\nuint8_t* senderID,\nuint8_t senderIDLen,\nuint8_t* recipientID,\n@@ -47,16 +59,107 @@ void openoscoap_init_security_context(oscoap_security_context_t *ctx,\nmemcpy(ctx->senderID, senderID, senderIDLen);\nctx->senderIDLen = senderIDLen;\n// invoke HKDF to get sender Key\n+ hkdf_derive_parameter(ctx->senderKey,\n+ masterSecret,\n+ masterSecretLen,\n+ masterSalt,\n+ masterSaltLen,\n+ senderID,\n+ senderIDLen,\n+ AES_CCM_16_64_128,\n+ OSCOAP_DERIVATION_TYPE_KEY,\n+ AES_CCM_16_64_128_KEY_LEN);\n// invoke HKDF to get sender IV\n+ hkdf_derive_parameter(ctx->senderIV,\n+ masterSecret,\n+ masterSecretLen,\n+ masterSalt,\n+ masterSaltLen,\n+ senderID,\n+ senderIDLen,\n+ AES_CCM_16_64_128,\n+ OSCOAP_DERIVATION_TYPE_IV,\n+ AES_CCM_16_64_128_IV_LEN);\n+\nctx->sequenceNumber = 0;\n// recipient context\nmemcpy(ctx->recipientID, recipientID, recipientIDLen);\nctx->recipientIDLen = recipientIDLen;\n// invoke HKDF to get recipient Key\n+ hkdf_derive_parameter(ctx->recipientKey,\n+ masterSecret,\n+ masterSecretLen,\n+ masterSalt,\n+ masterSaltLen,\n+ recipientID,\n+ recipientIDLen,\n+ AES_CCM_16_64_128,\n+ OSCOAP_DERIVATION_TYPE_KEY,\n+ AES_CCM_16_64_128_KEY_LEN);\n+\n// invoke HKDF to get recipient IV\n+ hkdf_derive_parameter(ctx->recipientIV,\n+ masterSecret,\n+ masterSecretLen,\n+ masterSalt,\n+ masterSaltLen,\n+ recipientID,\n+ recipientIDLen,\n+ AES_CCM_16_64_128,\n+ OSCOAP_DERIVATION_TYPE_IV,\n+ AES_CCM_16_64_128_IV_LEN);\n+\nctx->window.bitArray = 0;\nctx->window.base = 0;\n}\n+//=========================== private =========================================\n+\n+owerror_t hkdf_derive_parameter(uint8_t* buffer,\n+ uint8_t* masterSecret,\n+ uint8_t masterSecretLen,\n+ uint8_t* masterSalt,\n+ uint8_t masterSaltLen,\n+ uint8_t* identifier,\n+ uint8_t identifierLen,\n+ uint8_t algorithm,\n+ oscoap_derivation_t type,\n+ uint8_t length\n+ ){\n+\n+ const uint8_t iv[] = \"IV\";\n+ const uint8_t key[] = \"Key\";\n+ uint8_t info[20];\n+ uint8_t infoLen;\n+ uint8_t *temp;\n+ uint8_t ret;\n+\n+ temp = info;\n+\n+ infoLen = 0;\n+ infoLen += cborencoder_put_array(&temp, 4);\n+ infoLen += cborencoder_put_bytes(&temp, identifierLen, identifier);\n+ infoLen += cborencoder_put_unsigned(&temp, algorithm);\n+\n+ if (type == OSCOAP_DERIVATION_TYPE_KEY) {\n+ infoLen += cborencoder_put_text(&temp, (char *)&key, sizeof(key)-1);\n+ }\n+ else if (type == OSCOAP_DERIVATION_TYPE_IV) {\n+ infoLen += cborencoder_put_text(&temp, (char *) &iv, sizeof(iv)-1);\n+ }\n+ else {\n+ return E_FAIL;\n+ }\n+\n+ infoLen += cborencoder_put_unsigned(&temp, length);\n+\n+ ret = hkdf(SHA256, masterSalt, masterSaltLen, masterSecret, masterSecretLen, info, infoLen, buffer, length);\n+\n+ if (ret == shaSuccess) {\n+ return E_SUCCESS;\n+ }\n+ return E_FAIL;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.h", "new_path": "openapps/opencoap/openoscoap.h", "diff": "#define AES_CCM_16_64_128_TAG_LEN 8\n//=========================== typedef =========================================\n+typedef enum {\n+ OSCOAP_DERIVATION_TYPE_KEY = 0,\n+ OSCOAP_DERIVATION_TYPE_IV = 1,\n+} oscoap_derivation_t;\n+\ntypedef struct {\nuint32_t bitArray;\nuint16_t base;\n@@ -43,8 +48,8 @@ typedef struct {\n// recipient context\nuint8_t recipientID[OSCOAP_MAX_ID_LEN];\nuint8_t recipientIDLen;\n- uint8_t* recipientKey[AES_CCM_16_64_128_KEY_LEN];\n- uint8_t* recipientIV[AES_CCM_16_64_128_IV_LEN];\n+ uint8_t recipientKey[AES_CCM_16_64_128_KEY_LEN];\n+ uint8_t recipientIV[AES_CCM_16_64_128_IV_LEN];\nreplay_window_t window;\n} oscoap_security_context_t;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Derive security context using HKDF.
491,595
21.06.2017 08:59:20
-7,200
57893d715111459e04c913e2a8c76aebe1d84d8a
draft-lijo-6lo-expiration-time. little fix.
[ { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -227,12 +227,14 @@ int16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn) {\n\\param[out] et_asn bigger ASN value\n*/\nvoid ieee154e_calculateExpTime(uint16_t max_delay, uint8_t* et_asn) {\n- uint8_t delay_array[5] = {};\n+ uint8_t delay_array[5];\nuint8_t i =0, carry = 0,slot_time = 0;\nuint16_t sum = 0, delay_in_asn =0;\n+ memset(&delay_array[0],0,5);\n+\n//Slot time = (Duration in ticks * Time equivalent ticks w.r.t 32kHz) in ms\n- slot_time = (ieee154e_getSlotDuration()*30.5)/1000;\n+ slot_time = (ieee154e_getSlotDuration()*305)/10000;\ndelay_in_asn = max_delay / slot_time;\ndelay_array[0] = (delay_in_asn & 0xff);\n" }, { "change_type": "MODIFY", "old_path": "projects/telosb/03oos_openwsn/03oos_openwsn.ewp", "new_path": "projects/telosb/03oos_openwsn/03oos_openwsn.ewp", "diff": "<state>$PROJ_DIR$\\..\\..\\..\\openapps\\uecho\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\uinject\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openapps\\userialbridge\\</state>\n+ <state>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration\\</state>\n+ <state>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration_monitor\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openstack\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\</state>\n<state>$PROJ_DIR$\\..\\..\\..\\openstack\\02b-MAChigh\\</state>\n</option>\n<option>\n<name>ModuleSummary</name>\n- <state>0</state>\n+ <state>1</state>\n</option>\n<option>\n<name>XlinkStackSize</name>\n<name>bsp</name>\n<group>\n<name>boards</name>\n- <group>\n- <name>common</name>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\abstimer.c</name>\n- <excluded>\n- <configuration>Debug</configuration>\n- </excluded>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\abstimers2.c</name>\n- <excluded>\n- <configuration>Debug</configuration>\n- </excluded>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_cbc.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_cbc.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ccms.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ccms.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ctr.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ctr.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ecb.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\aes_ecb.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\dummy_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\dummy_crypto_engine.h</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\firmware_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\common\\firmware_crypto_engine.h</name>\n- </file>\n- </group>\n<group>\n<name>telosb</name>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\board.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\board_crypto_engine.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\board_crypto_engine.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\board_info.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\board_info.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\cryptoengine.c</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\telosb\\debugpins.c</name>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\board.h</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\crypto_engine.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\cryptoengine.h</name>\n</file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\boards\\debugpins.h</name>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\chips\\cc2420\\cc2420.h</name>\n</file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\chips\\cc2420\\cc2420_crypto.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\bsp\\chips\\cc2420\\cc2420_crypto.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\bsp\\chips\\cc2420\\radio.c</name>\n</file>\n</file>\n</group>\n<group>\n- <name>techo</name>\n+ <name>uecho</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\techo\\techo.c</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uecho\\uecho.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\techo\\techo.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uecho\\uecho.h</name>\n</file>\n</group>\n<group>\n- <name>tohlone</name>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\tohlone\\tohlone.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\tohlone\\tohlone.h</name>\n- </file>\n+ <name>uexpiration</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\tohlone\\tohlone_webpages.c</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration\\uexpiration.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\tohlone\\tohlone_webpages.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration\\uexpiration.h</name>\n</file>\n</group>\n<group>\n- <name>uecho</name>\n+ <name>uexpiration_monitor</name>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uecho\\uecho.c</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration_monitor\\uexpiration_monitor.c</name>\n</file>\n<file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uecho\\uecho.h</name>\n+ <name>$PROJ_DIR$\\..\\..\\..\\openapps\\uexpiration_monitor\\uexpiration_monitor.h</name>\n</file>\n</group>\n<group>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154.h</name>\n</file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_dummy_security.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_dummy_security.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\02a-MAClow\\IEEE802154_security.c</name>\n</file>\n</group>\n<group>\n<name>04-TRAN</name>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\opentcp.c</name>\n- </file>\n- <file>\n- <name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\opentcp.h</name>\n- </file>\n<file>\n<name>$PROJ_DIR$\\..\\..\\..\\openstack\\04-TRAN\\openudp.c</name>\n</file>\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
draft-lijo-6lo-expiration-time. little fix.
491,609
21.06.2017 10:38:09
-7,200
313b823f1aea97b9c4d2a1cceeabed934da2d338
Pass the address of the array's first element.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "@@ -144,10 +144,10 @@ owerror_t hkdf_derive_parameter(uint8_t* buffer,\ninfoLen += cborencoder_put_unsigned(&temp, algorithm);\nif (type == OSCOAP_DERIVATION_TYPE_KEY) {\n- infoLen += cborencoder_put_text(&temp, (char *)&key, sizeof(key)-1);\n+ infoLen += cborencoder_put_text(&temp, (char *) key, sizeof(key)-1);\n}\nelse if (type == OSCOAP_DERIVATION_TYPE_IV) {\n- infoLen += cborencoder_put_text(&temp, (char *) &iv, sizeof(iv)-1);\n+ infoLen += cborencoder_put_text(&temp, (char *) iv, sizeof(iv)-1);\n}\nelse {\nreturn E_FAIL;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Pass the address of the array's first element.
491,595
21.06.2017 15:42:05
-7,200
298dbdbc03843fe4b2c037b032f190737223d4bd
draft-lijo-6lo-expiration-time. enable all application in simulation.
[ { "change_type": "MODIFY", "old_path": "openapps/SConscript", "new_path": "openapps/SConscript", "diff": "@@ -16,6 +16,8 @@ if localEnv['board']=='python':\n'uecho',\n'uinject',\n'userialbridge',\n+ 'uexpiration',\n+ 'uexpiration_monitor',\n'rrt',\n'cexample',\n'cstorm',\n" }, { "change_type": "MODIFY", "old_path": "openapps/openapps.c", "new_path": "openapps/openapps.c", "diff": "// CoAP\n#include \"opencoap.h\"\n+#include \"c6t.h\"\n+#include \"cinfo.h\"\n+#include \"cleds.h\"\n+#include \"cwellknown.h\"\n+#include \"rrt.h\"\n+#include \"cexample.h\"\n+#include \"cstorm.h\"\n+\n+// UDP\n+#include \"uecho.h\"\n+#include \"uinject.h\"\n+#include \"userialbridge.h\"\n+#include \"uexpiration.h\"\n+#include \"uexpiration_monitor.h\"\n//=========================== variables =======================================\nvoid openapps_init(void) {\n//-- 04-TRAN\nopencoap_init(); // initialize before any of the CoAP applications\n+\n+ // CoAP\n+ c6t_init();\n+ cinfo_init();\n+ cleds__init();\n+ cwellknown_init();\n+ rrt_init();\n+\n+ // UDP\n+ uecho_init();\n+ uinject_init();\n+ userialbridge_init();\n+ uexpiration_init();\n+ umonitor_init();\n}\n" }, { "change_type": "MODIFY", "old_path": "openstack/SConscript", "new_path": "openstack/SConscript", "diff": "@@ -118,6 +118,9 @@ else:\nos.path.join('#','openapps','uecho'),\nos.path.join('#','openapps','uinject'),\nos.path.join('#','openapps','userialbridge'),\n+ os.path.join('#','openapps','uexpiration'),\n+ os.path.join('#','openapps','uexpiration_monitor'),\n+\n],\n)\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
draft-lijo-6lo-expiration-time. enable all application in simulation.
491,609
21.06.2017 16:03:21
-7,200
ebfc37c315b4244f06e0b38175338270e8c9fa6b
Implement option encoding within the CoAP library.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "opencoap_vars_t opencoap_vars;\n//=========================== prototype =======================================\n+uint8_t opencoap_options_encode(uint8_t* buffer,coap_option_iht* options, uint8_t optionsLen, bool fake);\n//=========================== public ==========================================\n@@ -437,6 +438,8 @@ This function is NOT called for a response.\n\\param[in] type The CoAP type of the message.\n\\param[in] code The CoAP code of the message.\n\\param[in] TKL The Token Length of the message, sanitized to a max of COAP_MAX_TKL (8).\n+\\param[in] options An array of sorted CoAP options.\n+\\param[in] optionsLen The length of the options array.\n\\param[out] descSender A pointer to the description of the calling CoAP\nresource.\n@@ -450,6 +453,8 @@ owerror_t opencoap_send(\ncoap_type_t type,\ncoap_code_t code,\nuint8_t TKL,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\ncoap_resource_desc_t* descSender\n) {\nuint16_t token;\n@@ -480,6 +485,12 @@ owerror_t opencoap_send(\ntokenPos+=2;\n}\n+ // fake run of opencoap_options_encode in order to get the necessary length\n+ packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, options, optionsLen, TRUE));\n+\n+ // once header is reserved, encode the options to the openqueue payload buffer\n+ opencoap_options_encode(msg->payload, options, optionsLen, FALSE);\n+\n// pre-pend CoAP header (version,type,TKL,code,messageID,Token)\npacketfunctions_reserveHeaderSize(msg,4+request->TKL);\nmsg->payload[0] = (COAP_VERSION << 6) |\n@@ -495,3 +506,88 @@ owerror_t opencoap_send(\n}\n//=========================== private =========================================\n+\n+uint8_t opencoap_options_encode(\n+ uint8_t* buffer,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\n+ bool fake\n+ ) {\n+\n+ uint8_t i;\n+ uint32_t delta;\n+ uint8_t optionDelta;\n+ uint8_t optionDeltaExt[2];\n+ uint8_t optionDeltaExtLen;\n+ uint8_t optionLength;\n+ uint8_t optionLengthExt[2];\n+ uint8_t optionLengthExtLen;\n+ uint8_t index;\n+ coap_option_t lastOptionNum;\n+\n+ // encode options\n+ i = 0;\n+ index = 0;\n+ lastOptionNum = COAP_OPTION_NONE;\n+ if (options != NULL) {\n+ for (i = 0; i < optionsLen; i++) {\n+ if (options[i].type < lastOptionNum) {\n+ return 0; // we require the options to be sorted\n+ }\n+ delta = options[i].type - lastOptionNum;\n+\n+ if (delta <= 12) {\n+ optionDelta = (uint8_t) delta;\n+ optionDeltaExtLen = 0;\n+ }\n+ else if (delta <= 0xff + 13) {\n+ optionDelta = 13;\n+ optionDeltaExt[0] = (uint8_t) delta - 13;\n+ optionDeltaExtLen = 1;\n+ }\n+ else if (delta <= 0xffff + 269) {\n+ optionDelta = 14;\n+ packetfunctions_htons((uint16_t) delta - 269, optionDeltaExt);\n+ optionDeltaExtLen = 2;\n+ }\n+ else {\n+ return 0;\n+ }\n+\n+ if (options[i].length <= 12) {\n+ optionLength = options[i].length;\n+ optionLengthExtLen = 0;\n+ }\n+ else {\n+ // we do not support fragmentation so option length cannot be larger\n+ // than 0xff. therefore, we default to the case where optionLength = 13.\n+ // see RFC7252 Section 3.1 for more details.\n+ optionLength = 13;\n+ optionLengthExt[0] = options[i].length - 13;\n+ optionLengthExtLen = 1;\n+ }\n+\n+ // write to buffer if fake is set to FALSE\n+ // otherwise just return the necesasry length\n+ if (fake == FALSE) {\n+ buffer[index] = (optionDelta << 4) | optionLength;\n+ }\n+ index++;\n+ if (fake == FALSE) {\n+ memcpy(&buffer[index], optionDeltaExt, optionDeltaExtLen);\n+ }\n+ index += optionDeltaExtLen;\n+ if (fake == FALSE) {\n+ memcpy(&buffer[index], optionLengthExt, optionLengthExtLen);\n+ }\n+ index += optionLengthExtLen;\n+ if (fake == FALSE) {\n+ memcpy(&buffer[index], options[i].pValue, options[i].length);\n+ }\n+ index += options[i].length;\n+\n+ lastOptionNum = options[i].type;\n+ }\n+ }\n+ return index;\n+}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "@@ -169,7 +169,9 @@ owerror_t opencoap_send(\nOpenQueueEntry_t* msg,\ncoap_type_t type,\ncoap_code_t code,\n- uint8_t numOptions,\n+ uint8_t TKL,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\ncoap_resource_desc_t* descSender\n);\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -704,6 +704,7 @@ functionsToChange = [\n'opencoap_writeLinks',\n'opencoap_register',\n'opencoap_send',\n+ 'opencoap_options_encode',\n'icmpv6coap_timer_cb',\n# oscoap\n'openoscoap_init_security_context',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Implement option encoding within the CoAP library.
491,609
21.06.2017 18:13:17
-7,200
0cee3dd37461dcc7c4d268f760b3dfc0330f1687
Add payload marker within opencoap_send instead of in the app.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -485,6 +485,11 @@ owerror_t opencoap_send(\ntokenPos+=2;\n}\n+ if (msg->length > 0 ) { // contains payload, add payload marker\n+ packetfunctions_reserveHeaderSize(msg,1);\n+ msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ }\n+\n// fake run of opencoap_options_encode in order to get the necessary length\npacketfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, options, optionsLen, TRUE));\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add payload marker within opencoap_send instead of in the app.
491,609
21.06.2017 18:14:20
-7,200
0410dcbb128d6090617f9a53624786ed580241ac
Adapt apps that use the opencoap_send to the new API.
[ { "change_type": "MODIFY", "old_path": "openapps/cexample/cexample.c", "new_path": "openapps/cexample/cexample.c", "diff": "@@ -80,11 +80,13 @@ void cexample_task_cb() {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\nuint8_t i;\n+ coap_option_iht options[2];\nuint16_t x_int = 0;\nuint16_t sum = 0;\nuint16_t avg = 0;\nuint8_t N_avg = 10;\n+ uint8_t medtype;\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n@@ -124,19 +126,16 @@ void cexample_task_cb() {\npkt->payload[0] = (avg>>8)&0xff;\npkt->payload[1] = (avg>>0)&0xff;\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = COAP_PAYLOAD_MARKER;\n+ // set location-path option\n+ options[0].type = COAP_OPTION_NUM_URIPATH;\n+ options[0].length = sizeof(cexample_path0) - 1;\n+ options[0].pValue = (uint8_t *) cexample_path0;\n- // content-type option\n- packetfunctions_reserveHeaderSize(pkt,2);\n- pkt->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT - COAP_OPTION_NUM_URIPATH) << 4\n- | 1;\n- pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n- // location-path option\n- packetfunctions_reserveHeaderSize(pkt,sizeof(cexample_path0)-1);\n- memcpy(&pkt->payload[0],cexample_path0,sizeof(cexample_path0)-1);\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = ((COAP_OPTION_NUM_URIPATH) << 4) | (sizeof(cexample_path0)-1);\n+ // set content-type option\n+ medtype = COAP_MEDTYPE_APPOCTETSTREAM;\n+ options[1].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ options[1].length = 1;\n+ options[1].pValue = &medtype;\n// metadata\npkt->l4_destination_port = WKP_UDP_COAP;\n@@ -148,7 +147,9 @@ void cexample_task_cb() {\npkt,\nCOAP_TYPE_NON,\nCOAP_CODE_REQ_PUT,\n- 1,\n+ 1, // token len\n+ options,\n+ 2, // options len\n&cexample_vars.desc\n);\n" }, { "change_type": "MODIFY", "old_path": "openapps/cstorm/cstorm.c", "new_path": "openapps/cstorm/cstorm.c", "diff": "@@ -155,7 +155,8 @@ void cstorm_timer_cb(){\nvoid cstorm_task_cb() {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\n- uint8_t numOptions;\n+ coap_option_iht options[2];\n+ uint8_t medType;\n// don't run if not synch\nif (ieee154e_isSynch() == FALSE) return;\n@@ -195,29 +196,17 @@ void cstorm_task_cb() {\npacketfunctions_reserveHeaderSize(pkt,sizeof(cstorm_payload)-1);\nmemcpy(&pkt->payload[0],cstorm_payload,sizeof(cstorm_payload)-1);\n- //set the TKL byte as a counter of Options\n- //TODO: This is not conform with RFC7252, but yes with current dissector WS v1.10.6\n- numOptions = 0;\n+ // location-path option\n+ options[0].type = COAP_OPTION_NUM_URIPATH;\n+ options[0].length = sizeof(cstorm_path0) - 1;\n+ options[0].pValue = (uint8_t *) cstorm_path0;\n- //Bigger Options last in message, first in the code (as it is in reverse order)\n- //Deltas are calculated between too consecutive lengthes.\n// content-type option\n- packetfunctions_reserveHeaderSize(pkt,2);\n- pkt->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT-COAP_OPTION_NUM_URIPATH) << 4 | 1;\n- pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n- numOptions++;\n-\n- // location-path option\n- packetfunctions_reserveHeaderSize(pkt,sizeof(cstorm_path0)-1);\n- memcpy(&pkt->payload[0],cstorm_path0,sizeof(cstorm_path0)-1);\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = (COAP_OPTION_NUM_URIPATH-7) << 4 | (sizeof(cstorm_path0)-1);\n- numOptions++;\n-\n- // length of uri-port option added directly by opencoap_send\n- packetfunctions_reserveHeaderSize(pkt,11);\n- numOptions++;\n+ medType = COAP_MEDTYPE_APPOCTETSTREAM;\n+ options[1].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ options[1].length = 1;\n+ options[1].pValue = &medType;\n// metadata\npkt->l4_destination_port = WKP_UDP_COAP;\n@@ -229,7 +218,9 @@ void cstorm_task_cb() {\npkt,\nCOAP_TYPE_NON,\nCOAP_CODE_REQ_PUT,\n- numOptions,\n+ 1, // token len\n+ options,\n+ 2, // options len\n&cstorm_vars.desc\n);\n" }, { "change_type": "MODIFY", "old_path": "openapps/rrt/rrt.c", "new_path": "openapps/rrt/rrt.c", "diff": "@@ -202,7 +202,9 @@ void rrt_setGETRespMsg(OpenQueueEntry_t* msg, uint8_t registered) {\nvoid rrt_sendCoAPMsg(char actionMsg, uint8_t *ipv6mote) {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\n- uint8_t numOptions;\n+ coap_option_iht options[2];\n+ uint8_t medType;\n+\npkt = openqueue_getFreePacketBuffer(COMPONENT_RRT);\nif (pkt == NULL) {\n@@ -220,20 +222,16 @@ void rrt_sendCoAPMsg(char actionMsg, uint8_t *ipv6mote) {\npacketfunctions_reserveHeaderSize(pkt, 1);\npkt->payload[0] = actionMsg;\n- numOptions = 0;\n// location-path option\n- packetfunctions_reserveHeaderSize(pkt,sizeof(rrt_path0)-1);\n- memcpy(&pkt->payload[0],&rrt_path0,sizeof(rrt_path0)-1);\n- packetfunctions_reserveHeaderSize(pkt,1);\n- pkt->payload[0] = (COAP_OPTION_NUM_URIPATH) << 4 |\n- (sizeof(rrt_path0)-1);\n- numOptions++;\n+ options[0].type = COAP_OPTION_NUM_URIPATH;\n+ options[0].length = sizeof(rrt_path0) - 1;\n+ options[0].pValue = (uint8_t *) rrt_path0;\n+\n// content-type option\n- packetfunctions_reserveHeaderSize(pkt,2);\n- pkt->payload[0] = COAP_OPTION_NUM_CONTENTFORMAT << 4 |\n- 1;\n- pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n- numOptions++;\n+ medType = COAP_MEDTYPE_APPOCTETSTREAM;\n+ options[1].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ options[1].length = 1;\n+ options[1].pValue = &medType;\n//metada\npkt->l4_destination_port = WKP_UDP_RINGMASTER;\n@@ -250,7 +248,9 @@ void rrt_sendCoAPMsg(char actionMsg, uint8_t *ipv6mote) {\npkt,\nCOAP_TYPE_NON,\nCOAP_CODE_REQ_PUT,\n- numOptions,\n+ 1, // token len\n+ options,\n+ 2, // options len\n&rrt_vars.desc\n);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Adapt apps that use the opencoap_send to the new API.
491,586
22.06.2017 10:02:13
-19,080
cdfe816d67f88ef04f950139f74f29fa0f2d4443
to mention the flag
[ { "change_type": "MODIFY", "old_path": "openapps/uexpiration/README.md", "new_path": "openapps/uexpiration/README.md", "diff": "@@ -19,6 +19,8 @@ If the drop flag is set to 1, the packet will be dropped in the network if\nthe packet expiration time is reached. Otherwise, the packet will be forwarded\nto the application.\n+Note : Enable the flag 'DEADLINE_OPTION_ENABLED' in opendefs.h.\n+\nUsage : python uexpiration.py <dest_ip> <pkt_interval> <no_of_pkts>\n<delay_in_ms> <drop_flag>\n" }, { "change_type": "MODIFY", "old_path": "openapps/uexpiration_monitor/README.md", "new_path": "openapps/uexpiration_monitor/README.md", "diff": "@@ -19,6 +19,8 @@ The uexpiration_monitor.c responds by sending back the time information of the\nmost recent packet that the mote has forwarded. The time information comprises\ndelay experienced by the packet and the remaining time before its expiry.\n+Note : Enable the flag 'DEADLINE_OPTION_ENABLED' in opendefs.h.\n+\nUsage : python uexpiration_monitor.py <dest_ip> <probe_interval(sec)>\n#python uexpiration_monitor.py bbbb::1415:92cc:0:2 1\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
to mention the flag
491,595
22.06.2017 09:56:22
-7,200
206cc70edddbdf3636367e9b6b1511f8cd5616f8
add deadline_option to scons build.
[ { "change_type": "MODIFY", "old_path": "SConscript", "new_path": "SConscript", "diff": "@@ -46,6 +46,8 @@ if env['noadaptivesync']==1:\nenv.Append(CPPDEFINES = 'NOADAPTIVESYNC')\nif env['l2_security']==1:\nenv.Append(CPPDEFINES = 'L2_SECURITY_ACTIVE')\n+if env['deadline_option']==1:\n+ env.Append(CPPDEFINES = 'DEADLINE_OPTION_ENABLED')\nif env['toolchain']=='mspgcc':\n" }, { "change_type": "MODIFY", "old_path": "SConstruct", "new_path": "SConstruct", "diff": "@@ -137,6 +137,7 @@ command_line_options = {\n'debug': ['0','1'],\n'noadaptivesync': ['0','1'],\n'l2_security': ['0','1'],\n+ 'deadline_option': ['0','1'],\n'ide': ['none','qtcreator'],\n'revision': ['']\n}\n@@ -283,6 +284,13 @@ command_line_vars.AddVariables(\nvalidate_option, # validator\nint, # converter\n),\n+ (\n+ 'deadline_option', # key\n+ '', # help\n+ command_line_options['deadline_option'][1], # default\n+ validate_option, # validator\n+ int, # converter\n+ ),\n(\n'apps', # key\n'comma-separated list of user applications', # help\n" }, { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -38,8 +38,6 @@ static const uint8_t infoStackName[] = \"OpenWSN \";\n#define MAXNUMNEIGHBORS 10\n-#define DEADLINE_OPTION_ENABLED 1\n-\n// maximum celllist length\n#define CELLLIST_MAX_LEN 3\n" }, { "change_type": "MODIFY", "old_path": "openapps/uexpiration_monitor/uexpiration_monitor.c", "new_path": "openapps/uexpiration_monitor/uexpiration_monitor.c", "diff": "#include \"openqueue.h\"\n#include \"openserial.h\"\n#include \"packetfunctions.h\"\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n#include \"iphc.h\"\n#endif\n@@ -28,7 +28,7 @@ void umonitor_init() {\nvoid umonitor_receive(OpenQueueEntry_t* request) {\nuint16_t temp_l4_destination_port;\nOpenQueueEntry_t* reply;\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nmonitor_expiration_vars_t deadline;\n#endif\n@@ -56,7 +56,7 @@ void umonitor_receive(OpenQueueEntry_t* request) {\n/*************** Packet Payload ********************/\n// [Expiration time, Delay]\npacketfunctions_reserveHeaderSize(reply,(2*sizeof(uint16_t)));\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nmemset(&deadline, 0, sizeof(monitor_expiration_vars_t));\niphc_getDeadlineInfo(&deadline);\nmemcpy(&reply->payload[0],&deadline.time_elapsed,sizeof(uint16_t));\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.c", "new_path": "openstack/02a-MAClow/IEEE802154E.c", "diff": "@@ -189,7 +189,7 @@ PORT_TIMER_WIDTH ieee154e_asnDiff(asn_t* someASN) {\nreturn diff;\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n/**\n/brief Difference between two ASN values\n" }, { "change_type": "MODIFY", "old_path": "openstack/02a-MAClow/IEEE802154E.h", "new_path": "openstack/02a-MAClow/IEEE802154E.h", "diff": "@@ -292,7 +292,7 @@ typedef struct {\nvoid ieee154e_init(void);\n// public\nPORT_TIMER_WIDTH ieee154e_asnDiff(asn_t* someASN);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nint16_t ieee154e_computeAsnDiff(asn_t* h_asn, asn_t* l_asn);\nvoid ieee154e_calculateExpTime(uint16_t max_delay, uint8_t* et_asn);\nvoid ieee154e_orderToASNStructure(uint8_t* in,asn_t* val_asn);\n" }, { "change_type": "MODIFY", "old_path": "openstack/03a-IPHC/iphc.c", "new_path": "openstack/03a-IPHC/iphc.c", "diff": "@@ -16,7 +16,7 @@ static const uint8_t dagroot_mac64b[] = {0x02,\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01\n};\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nstatic monitor_expiration_vars_t monitor_expiration_vars;\n#endif\n@@ -49,7 +49,7 @@ void iphc_prependIPv6HopByHopHeader(\nrpl_option_ht* rpl_option\n);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n// IPv6 Deadline hop-by-hop header\nvoid iphc_prependIPv6DeadlineHeader(\nOpenQueueEntry_t* msg\n@@ -71,7 +71,7 @@ owerror_t iphc_sendFromForwarding(\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\nrpl_option_ht* rpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nuint32_t* flow_label,\n@@ -186,7 +186,7 @@ owerror_t iphc_sendFromForwarding(\n}\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nif ( (msg->creator == COMPONENT_UEXPIRATION) && (deadline_option != NULL) ) {\nif (\ndeadline_option->optionType==DEADLINE_HOPBYHOP_HEADER_OPTION_TYPE &&\n@@ -252,7 +252,7 @@ void iphc_receive(OpenQueueEntry_t* msg) {\nuint8_t page_length;\nrpl_option_ht rpl_option;\nuint8_t rpi_length;\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_ptr = NULL;\ndeadline_option_ht curr_deadline_option;\n#endif\n@@ -263,7 +263,7 @@ void iphc_receive(OpenQueueEntry_t* msg) {\nmemset(&ipv6_inner_header,0,sizeof(ipv6_header_iht));\nmemset(&rpl_option,0,sizeof(rpl_option_ht));\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nipv6_outer_header.deadline_option = NULL;\n#endif\n@@ -286,7 +286,7 @@ void iphc_receive(OpenQueueEntry_t* msg) {\n&rpl_option\n);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nif(ipv6_outer_header.deadline_option){\nmemset(&curr_deadline_option,0,sizeof(curr_deadline_option));\n@@ -311,7 +311,7 @@ void iphc_receive(OpenQueueEntry_t* msg) {\nmsg,\n&ipv6_outer_header,\n&ipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_ptr,\n#endif\n&rpl_option\n@@ -739,7 +739,7 @@ void iphc_retrieveIPv6Header(OpenQueueEntry_t* msg, ipv6_header_iht* ipv6_outer_\n}\n}\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nelse if (lorh_type == DEADLINE_6LOTH_TYPE){\nipv6_outer_header->deadline_option = (uint8_t*)(msg->payload) + \\\n*page_length + \\\n@@ -1120,7 +1120,7 @@ void iphc_prependIPv6HopByHopHeader(\n*((uint8_t*)(msg->payload)) = temp_8b;\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n//===== IPv6 Deadline hop-by-hop header\n/**\n\\brief Prepend an IPv6 Deadline hop-by-hop header to a message.\n@@ -1252,7 +1252,7 @@ uint8_t iphc_retrieveIPv6HopByHopHeader(\nreturn length;\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n/**\n\\brief Retrieve a Deadline hop-by-hop header from a message.\n" }, { "change_type": "MODIFY", "old_path": "openstack/03a-IPHC/iphc.h", "new_path": "openstack/03a-IPHC/iphc.h", "diff": "@@ -144,7 +144,7 @@ enum TYPE_6LORH_enums{\nRH3_6LOTH_TYPE_4 = 0x04,\nRPI_6LOTH_TYPE = 0x05,\nIPECAP_6LOTH_TYPE = 0x06,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nDEADLINE_6LOTH_TYPE = 0x07,\n#endif\n};\n@@ -168,7 +168,7 @@ typedef struct {\nuint8_t next_header;\nuint8_t* routing_header[MAXNUM_RH3];\nuint8_t* hopByhop_option;\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nuint8_t* deadline_option;\n#endif\nuint8_t hop_limit;\n@@ -220,7 +220,7 @@ typedef struct {\n} rpl_option_ht;\nEND_PACK\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nBEGIN_PACK\ntypedef struct {\nuint8_t optionType;\n@@ -253,7 +253,7 @@ owerror_t iphc_sendFromForwarding(\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\nrpl_option_ht* rpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nuint32_t* flow_label,\n@@ -288,7 +288,7 @@ uint8_t iphc_retrieveIPv6HopByHopHeader(\nrpl_option_ht* rpl_option\n);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nvoid iphc_retrieveIPv6DeadlineHeader(\nOpenQueueEntry_t* msg,\nuint8_t* deadline_msg_ptr,\n" }, { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/forwarding.c", "new_path": "openstack/03b-IPv6/forwarding.c", "diff": "@@ -25,7 +25,7 @@ owerror_t forwarding_send_internal_RoutingTable(\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\nrpl_option_ht* rpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nuint32_t* flow_label,\n@@ -35,7 +35,7 @@ owerror_t forwarding_send_internal_SourceRouting(\nOpenQueueEntry_t* msg,\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nrpl_option_ht* rpl_option\n@@ -45,7 +45,7 @@ void forwarding_createRplOption(\nuint8_t flags\n);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nvoid forwarding_createDeadlineOption(\ndeadline_option_ht* deadline_option\n);\n@@ -71,7 +71,7 @@ owerror_t forwarding_send(OpenQueueEntry_t* msg) {\nipv6_header_iht ipv6_outer_header;\nipv6_header_iht ipv6_inner_header;\nrpl_option_ht rpl_option;\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht deadline_option;\n#endif\nopen_addr_t* myprefix;\n@@ -120,7 +120,7 @@ owerror_t forwarding_send(OpenQueueEntry_t* msg) {\n0x00 // flags\n);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nforwarding_createDeadlineOption(\n&deadline_option\n);\n@@ -189,7 +189,7 @@ owerror_t forwarding_send(OpenQueueEntry_t* msg) {\n&ipv6_outer_header,\n&ipv6_inner_header,\n&rpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n&deadline_option,\n#endif\n&flow_label,\n@@ -253,7 +253,7 @@ void forwarding_receive(\nOpenQueueEntry_t* msg,\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nrpl_option_ht* rpl_option\n@@ -314,7 +314,7 @@ void forwarding_receive(\n// change the creator of the packet\nmsg->creator = COMPONENT_FORWARDING;\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nif (deadline_option != NULL) {\n// Deadline Option : Drop\nif( (deadline_option->time_left <= 0) && (deadline_option->d_flag == 1) ) { // packet expired\n@@ -366,7 +366,7 @@ void forwarding_receive(\n}\nforwarding_createRplOption(rpl_option, rpl_option->flags);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nif (deadline_option != NULL)\nforwarding_createDeadlineOption(deadline_option);\n#endif\n@@ -378,7 +378,7 @@ void forwarding_receive(\nipv6_outer_header,\nipv6_inner_header,\nrpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option,\n#endif\n&(ipv6_outer_header->flow_label),\n@@ -394,7 +394,7 @@ void forwarding_receive(\nmsg,\nipv6_outer_header,\nipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option,\n#endif\nrpl_option\n@@ -455,7 +455,7 @@ owerror_t forwarding_send_internal_RoutingTable(\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\nrpl_option_ht* rpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nuint32_t* flow_label,\n@@ -484,7 +484,7 @@ owerror_t forwarding_send_internal_RoutingTable(\nipv6_outer_header,\nipv6_inner_header,\nrpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option,\n#endif\nflow_label,\n@@ -511,7 +511,7 @@ owerror_t forwarding_send_internal_SourceRouting(\nOpenQueueEntry_t* msg,\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nrpl_option_ht* rpl_option\n@@ -795,7 +795,7 @@ owerror_t forwarding_send_internal_SourceRouting(\n}\nforwarding_createRplOption(rpl_option, rpl_option->flags);\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\nif (deadline_option != NULL)\nforwarding_createDeadlineOption(deadline_option);\n#endif\n@@ -812,7 +812,7 @@ owerror_t forwarding_send_internal_SourceRouting(\nipv6_outer_header,\nipv6_inner_header,\nrpl_option,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option,\n#endif\n&ipv6_outer_header->flow_label,\n@@ -850,7 +850,7 @@ void forwarding_createRplOption(rpl_option_ht* rpl_option, uint8_t flags) {\nrpl_option->flags = (flags & ~I_FLAG & ~K_FLAG) | (I<<1) | K;\n}\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n/**\n\\brief Create a Deadline-6LoRH .\n" }, { "change_type": "MODIFY", "old_path": "openstack/03b-IPv6/forwarding.h", "new_path": "openstack/03b-IPv6/forwarding.h", "diff": "#define RPL_HOPBYHOP_HEADER_OPTION_TYPE 0x63\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\n#define DEADLINE_HOPBYHOP_HEADER_OPTION_TYPE 0xAB\n#endif\n@@ -62,7 +62,7 @@ void forwarding_receive(\nOpenQueueEntry_t* msg,\nipv6_header_iht* ipv6_outer_header,\nipv6_header_iht* ipv6_inner_header,\n-#if DEADLINE_OPTION_ENABLED\n+#ifdef DEADLINE_OPTION_ENABLED\ndeadline_option_ht* deadline_option,\n#endif\nrpl_option_ht* rpl_option\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
add deadline_option to scons build.
491,595
22.06.2017 10:43:34
-7,200
82526cb17da9834547c04585bdf79b03e498e66f
using opentimers_scheduleIn rather than opentimers_scheduleAbsolute in apps.
[ { "change_type": "MODIFY", "old_path": "openapps/uexpiration/uexpiration.c", "new_path": "openapps/uexpiration/uexpiration.c", "diff": "@@ -71,11 +71,11 @@ void uexpiration_receive(OpenQueueEntry_t* request) {\nuexpiration_vars.period = pkt_interval;\n// start periodic timer\nuexpiration_vars.timerId = opentimers_create();\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nuexpiration_vars.timerId,\nuexpiration_vars.period,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_ONESHOT,\nuexpiration_timer_cb\n);\n}\n@@ -124,11 +124,11 @@ void uexpiration_task_cb() {\nif(++seqno > max_num_pkts) {\nopentimers_destroy(uexpiration_vars.timerId);\n} else {\n- opentimers_scheduleAbsolute(\n+ opentimers_scheduleIn(\nuexpiration_vars.timerId,\nuexpiration_vars.period,\n- opentimers_getValue(),\nTIME_MS,\n+ TIMER_ONESHOT,\nuexpiration_timer_cb\n);\n}\n" }, { "change_type": "MODIFY", "old_path": "openstack/03a-IPHC/iphc.c", "new_path": "openstack/03a-IPHC/iphc.c", "diff": "#include \"packetfunctions.h\"\n#include \"idmanager.h\"\n#include \"openserial.h\"\n-#include \"IEEE802154e.h\"\n+#include \"IEEE802154E.h\"\n#include \"sixtop.h\"\n#include \"forwarding.h\"\n#include \"neighbors.h\"\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
using opentimers_scheduleIn rather than opentimers_scheduleAbsolute in apps.
491,609
22.06.2017 13:19:21
-7,200
2a13f3fb5c0eef3cf3e2d7be7542d319e3a84a31
Change CoAP receive callback API to allow response option setting within the lib.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -59,7 +59,12 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\ncoap_type_t response_type;\n// local variables passed to the handlers (with msg)\ncoap_header_iht coap_header;\n- coap_option_iht coap_options[MAX_COAP_OPTIONS];\n+ coap_option_iht coap_incomingOptions[MAX_COAP_OPTIONS];\n+ coap_option_iht coap_outgoingOptions[MAX_COAP_OPTIONS];\n+ uint8_t coap_outgoingOptionsLen;\n+\n+ // init response options len\n+ coap_outgoingOptionsLen = 0;\n// take ownership over the received packet\nmsg->owner = COMPONENT_OPENCOAP;\n@@ -92,12 +97,12 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\nmemcpy(&coap_header.token[0], &msg->payload[index], coap_header.TKL);\nindex += coap_header.TKL;\n- // initialize the coap_options\n+ // initialize the coap_incomingOptions\nfor (i=0;i<MAX_COAP_OPTIONS;i++) {\n- coap_options[i].type = COAP_OPTION_NONE;\n+ coap_incomingOptions[i].type = COAP_OPTION_NONE;\n}\n- // fill in the coap_options\n+ // fill in the coap_incomingOptions\nlast_option = COAP_OPTION_NONE;\nfor (i=0;i<MAX_COAP_OPTIONS;i++) {\n@@ -113,12 +118,12 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\n}\n// parse this option\n- coap_options[i].type = (coap_option_t)((uint8_t)last_option+(uint8_t)((msg->payload[index] & 0xf0) >> 4));\n- last_option = coap_options[i].type;\n- coap_options[i].length = (msg->payload[index] & 0x0f);\n+ coap_incomingOptions[i].type = (coap_option_t)((uint8_t)last_option+(uint8_t)((msg->payload[index] & 0xf0) >> 4));\n+ last_option = coap_incomingOptions[i].type;\n+ coap_incomingOptions[i].length = (msg->payload[index] & 0x0f);\nindex++;\n- coap_options[i].pValue = &(msg->payload[index]);\n- index += coap_options[i].length; //includes length as well\n+ coap_incomingOptions[i].pValue = &(msg->payload[index]);\n+ index += coap_incomingOptions[i].length; //includes length as well\n}\n// remove the CoAP header+options\n@@ -142,8 +147,8 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\n// iterate until matching resource found, or no match\nwhile (found==FALSE) {\nif (\n- coap_options[0].type==COAP_OPTION_NUM_URIPATH &&\n- coap_options[1].type==COAP_OPTION_NUM_URIPATH &&\n+ coap_incomingOptions[0].type==COAP_OPTION_NUM_URIPATH &&\n+ coap_incomingOptions[1].type==COAP_OPTION_NUM_URIPATH &&\ntemp_desc->path0len>0 &&\ntemp_desc->path0val!=NULL &&\ntemp_desc->path1len>0 &&\n@@ -152,24 +157,24 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\n// resource has a path of form path0/path1\nif (\n- coap_options[0].length==temp_desc->path0len &&\n- memcmp(coap_options[0].pValue,temp_desc->path0val,temp_desc->path0len)==0 &&\n- coap_options[1].length==temp_desc->path1len &&\n- memcmp(coap_options[1].pValue,temp_desc->path1val,temp_desc->path1len)==0\n+ coap_incomingOptions[0].length==temp_desc->path0len &&\n+ memcmp(coap_incomingOptions[0].pValue,temp_desc->path0val,temp_desc->path0len)==0 &&\n+ coap_incomingOptions[1].length==temp_desc->path1len &&\n+ memcmp(coap_incomingOptions[1].pValue,temp_desc->path1val,temp_desc->path1len)==0\n) {\nfound = TRUE;\n};\n} else if (\n- coap_options[0].type==COAP_OPTION_NUM_URIPATH &&\n+ coap_incomingOptions[0].type==COAP_OPTION_NUM_URIPATH &&\ntemp_desc->path0len>0 &&\ntemp_desc->path0val!=NULL\n) {\n// resource has a path of form path0\nif (\n- coap_options[0].length==temp_desc->path0len &&\n- memcmp(coap_options[0].pValue,temp_desc->path0val,temp_desc->path0len)==0\n+ coap_incomingOptions[0].length==temp_desc->path0len &&\n+ memcmp(coap_incomingOptions[0].pValue,temp_desc->path0val,temp_desc->path0len)==0\n) {\nfound = TRUE;\n};\n@@ -211,7 +216,7 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\n// call the resource's callback\nif (found==TRUE && temp_desc->callbackRx!=NULL) {\n- temp_desc->callbackRx(msg,&coap_header,&coap_options[0]);\n+ temp_desc->callbackRx(msg,&coap_header,&coap_incomingOptions[0], NULL, NULL);\n}\n}\n@@ -237,7 +242,8 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\nif (found==TRUE) {\n// call the resource's callback\n- outcome = temp_desc->callbackRx(msg,&coap_header,&coap_options[0]);\n+ outcome = temp_desc->callbackRx(msg,&coap_header,&coap_incomingOptions[0], coap_outgoingOptions, &coap_outgoingOptionsLen);\n+\n} else {\n// reset packet payload (DO NOT DELETE, we will reuse same buffer for response)\nmsg->payload = &(msg->packet[127]);\n@@ -262,7 +268,20 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\nresponse_type = COAP_TYPE_NON;\n}\n- //=== step 4. send that packet back\n+ //=== step 4. add the payload marker and encode options\n+\n+ if (msg->length > 0 ) { // contains payload, add payload marker\n+ packetfunctions_reserveHeaderSize(msg,1);\n+ msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ }\n+\n+ // fake run of opencoap_options_encode in order to get the necessary length\n+ packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, coap_outgoingOptions, coap_outgoingOptionsLen, TRUE));\n+\n+ // once header is reserved, encode the options to the openqueue payload buffer\n+ opencoap_options_encode(msg->payload, coap_outgoingOptions, coap_outgoingOptionsLen, FALSE);\n+\n+ //=== step 5. send that packet back\n// fill in packet metadata\nif (found==TRUE) {\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "@@ -126,7 +126,9 @@ typedef struct {\ntypedef owerror_t (*callbackRx_cbt)(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options);\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen);\ntypedef void (*callbackSendDone_cbt)(OpenQueueEntry_t* msg,\nowerror_t error);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Change CoAP receive callback API to allow response option setting within the lib.
491,609
22.06.2017 13:19:46
-7,200
f0fedcb4e04150811eefb2c7ef326c1472f0b826
Adapt coap apps.
[ { "change_type": "MODIFY", "old_path": "openapps/c6t/c6t.c", "new_path": "openapps/c6t/c6t.c", "diff": "@@ -23,10 +23,11 @@ c6t_vars_t c6t_vars;\n//=========================== prototypes ======================================\n-owerror_t c6t_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t c6t_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n);\nvoid c6t_sendDone(\nOpenQueueEntry_t* msg,\n@@ -63,12 +64,12 @@ void c6t_init() {\n\\return Whether the response is prepared successfully.\n*/\n-owerror_t c6t_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t c6t_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n) {\n-\nowerror_t outcome;\nopen_addr_t neighbor;\nbool foundNeighbor;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cexample/cexample.c", "new_path": "openapps/cexample/cexample.c", "diff": "@@ -30,7 +30,10 @@ cexample_vars_t cexample_vars;\nowerror_t cexample_receive( OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options);\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen);\n+\nvoid cexample_timer_cb(void);\nvoid cexample_task_cb(void);\nvoid cexample_sendDone(OpenQueueEntry_t* msg,\n@@ -66,7 +69,10 @@ void cexample_init() {\nowerror_t cexample_receive( OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options) {\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen) {\n+\nreturn E_FAIL;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/cinfo/cinfo.c", "new_path": "openapps/cinfo/cinfo.c", "diff": "@@ -25,7 +25,9 @@ cinfo_vars_t cinfo_vars;\nowerror_t cinfo_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n);\nvoid cinfo_sendDone(\nOpenQueueEntry_t* msg,\n@@ -70,14 +72,14 @@ void cinfo_init() {\nowerror_t cinfo_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n) {\n-\nowerror_t outcome;\nswitch (coap_header->Code) {\ncase COAP_CODE_REQ_GET:\n-\n//=== reset packet payload (we will reuse this packetBuffer)\nmsg->payload = &(msg->packet[127]);\nmsg->length = 0;\n@@ -111,10 +113,6 @@ owerror_t cinfo_receive(\nmsg->payload[sizeof(infoStackName)-1+5-2] = '.';\nmsg->payload[sizeof(infoStackName)-1+5-1] = '0'+OPENWSN_VERSION_PATCH;\n- // payload marker\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cleds/cleds.c", "new_path": "openapps/cleds/cleds.c", "diff": "@@ -18,11 +18,12 @@ const uint8_t cleds_path0[] = \"l\";\n//=========================== prototypes ======================================\n-owerror_t cleds_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t cleds_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n-);\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen);\n+\nvoid cleds_sendDone(\nOpenQueueEntry_t* msg,\nowerror_t error\n@@ -58,11 +59,11 @@ void cleds__init() {\n\\return Whether the response is prepared successfully.\n*/\n-owerror_t cleds_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t cleds_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n- ) {\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen) {\nowerror_t outcome;\nswitch (coap_header->Code) {\n@@ -72,13 +73,12 @@ owerror_t cleds_receive(\nmsg->length = 0;\n// add CoAP payload\n- packetfunctions_reserveHeaderSize(msg,2);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ packetfunctions_reserveHeaderSize(msg,1);\nif (leds_error_isOn()==1) {\n- msg->payload[1] = '1';\n+ msg->payload[0] = '1';\n} else {\n- msg->payload[1] = '0';\n+ msg->payload[0] = '0';\n}\n// set the CoAP header\n" }, { "change_type": "MODIFY", "old_path": "openapps/csensors/csensors.c", "new_path": "openapps/csensors/csensors.c", "diff": "@@ -42,7 +42,9 @@ void csensors_register(\nowerror_t csensors_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n);\nvoid csensors_timer_cb(void);\n@@ -165,14 +167,16 @@ void csensors_register(\n\\param[in] msg The received message. CoAP header and options already\nparsed.\n\\param[in] coap_header The CoAP header contained in the message.\n-\\param[in] coap_options The CoAP options contained in the message.\n+\\param[in] coap_incomingOptions The CoAP options contained in the message.\n\\return Whether the response is prepared successfully.\n*/\nowerror_t csensors_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n) {\nowerror_t outcome;\nuint8_t id;\n@@ -186,24 +190,22 @@ owerror_t csensors_receive(\nmsg->payload = &(msg->packet[127]);\nmsg->length = 0;\n- if (coap_options[1].type != COAP_OPTION_NUM_URIPATH) {\n+ if (coap_incomingOptions[1].type != COAP_OPTION_NUM_URIPATH) {\n// have CoAP module write links to csensors resources\nopencoap_writeLinks(msg,COMPONENT_CSENSORS);\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n// add return option\n- packetfunctions_reserveHeaderSize(msg,2);\n- msg->payload[0] = COAP_OPTION_NUM_CONTENTFORMAT << 4 | 1;\n- msg->payload[1] = COAP_MEDTYPE_APPLINKFORMAT;\n-\n+ csensors_vars.medType = COAP_MEDTYPE_APPLINKFORMAT;\n+ coap_outgoingOptions[0].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ coap_outgoingOptions[0].length = 1;\n+ coap_outgoingOptions[0].pValue = &csensors_vars.medType;\n+ *coap_outgoingOptionsLen = 1;\n} else {\nfor(id=0;id<csensors_vars.numCsensors;id++) {\nif (\nmemcmp(\n- coap_options[1].pValue,\n+ coap_incomingOptions[1].pValue,\ncsensors_vars.csensors_resource[id].desc.path1val,\ncsensors_vars.csensors_resource[id].desc.path1len\n)==0\n@@ -212,9 +214,12 @@ owerror_t csensors_receive(\n}\n}\ncsensors_fillpayload(msg,id);\n- packetfunctions_reserveHeaderSize(msg,2);\n- msg->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT << 4) | 1;\n- msg->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n+ // add return option\n+ csensor_vars.medType = COAP_MEDTYPE_APPOCTETSTREM;\n+ coap_outgoingOptions[0].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ coap_outgoingOptions[0].length = 1;\n+ coap_outgoingOptions[0].pValue = &csensors_vars.medType;\n+ *coap_outgoingOptionsLen = 1;\n}\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n@@ -233,11 +238,11 @@ owerror_t csensors_receive(\nbreak;\n}\n}\n- if (coap_options[1].type == COAP_OPTION_NUM_URIPATH) {\n+ if (coap_incomingOptions[1].type == COAP_OPTION_NUM_URIPATH) {\nfor(id=0;id<csensors_vars.numCsensors;id++) {\nif (\nmemcmp(\n- coap_options[1].pValue,\n+ coap_incomingOptions[1].pValue,\ncsensors_vars.csensors_resource[id].desc.path1val,\ncsensors_vars.csensors_resource[id].desc.path1len\n)==0\n@@ -303,6 +308,7 @@ void csensors_task_cb() {\nOpenQueueEntry_t* pkt;\nowerror_t outcome;\nuint8_t id;\n+ coap_option_iht options[3];\nid = csensors_vars.cb_list[csensors_vars.cb_get];\n@@ -326,19 +332,21 @@ void csensors_task_cb() {\n// CoAP payload\ncsensors_fillpayload(pkt,id);\n- packetfunctions_reserveHeaderSize(pkt,2);\n- pkt->payload[0] = (COAP_OPTION_NUM_CONTENTFORMAT - COAP_OPTION_NUM_URIPATH) << 4\n- | 1;\n- pkt->payload[1] = COAP_MEDTYPE_APPOCTETSTREAM;\n+ // location-path0 option\n+ options[0].type = COAP_OPTION_NUM_URIPATH;\n+ options[0].length = sizeof(csensors_path0) - 1;\n+ options[0].pValue = csensors_path0;\n// location-path1 option\n- packetfunctions_reserveHeaderSize(pkt,1+csensors_vars.csensors_resource[id].desc.path1len);\n- memcpy(&pkt->payload[1],csensors_vars.csensors_resource[id].desc.path1val,csensors_vars.csensors_resource[id].desc.path1len);\n- pkt->payload[0] = sizeof(csensors_path0)-1;\n- // location-path0 option\n- packetfunctions_reserveHeaderSize(pkt,sizeof(csensors_path0));\n- memcpy(&pkt->payload[1],csensors_path0,sizeof(csensors_path0)-1);\n- pkt->payload[0] = ((COAP_OPTION_NUM_URIPATH) << 4) | (sizeof(csensors_path0)-1);\n+ options[1].type = COAP_OPTION_NUM_URIPATH;\n+ options[1].length = csensors_vars.csensors_resource[id].desc.path1len;\n+ options[1].pValue = csensors_vars.csensors_resource[id].desc.path1val;\n+\n+ // content format option\n+ csensors_vars.medType = COAP_MEDTYPE_APPOCTETSTREM;\n+ options[2].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ options[2].length = 1;\n+ options[2].pValue = &csensors_vars.medType;\n// metadata\npkt->l4_destination_port = WKP_UDP_COAP;\n@@ -350,7 +358,9 @@ void csensors_task_cb() {\npkt,\nCOAP_TYPE_NON,\nCOAP_CODE_REQ_PUT,\n- 2,\n+ 2, // token len\n+ options,\n+ 3, // options len\n&csensors_vars.csensors_resource[id].desc\n);\n@@ -428,14 +438,11 @@ void csensors_fillpayload(OpenQueueEntry_t* msg,\nuint16_t value;\nvalue=csensors_vars.csensors_resource[id].opensensors_resource->callbackRead();\n- packetfunctions_reserveHeaderSize(msg,3);\n-\n- // add CoAP payload\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ packetfunctions_reserveHeaderSize(msg,2);\n// add value\n- msg->payload[1] = (value>>8) & 0x00ff;\n- msg->payload[2] = value & 0x00ff;\n+ msg->payload[0] = (value>>8) & 0x00ff;\n+ msg->payload[1] = value & 0x00ff;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/csensors/csensors.h", "new_path": "openapps/csensors/csensors.h", "diff": "@@ -41,6 +41,7 @@ typedef struct {\nuint8_t cb_list[CSENSORSTASKLIST];\nuint8_t cb_put;\nuint8_t cb_get;\n+ uint8_t medType;\n} csensors_vars_t;\n//=========================== variables =======================================\n" }, { "change_type": "MODIFY", "old_path": "openapps/cstorm/cstorm.c", "new_path": "openapps/cstorm/cstorm.c", "diff": "@@ -28,8 +28,10 @@ cstorm_vars_t cstorm_vars;\nowerror_t cstorm_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n-);\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen);\n+\nvoid cstorm_timer_cb(void);\nvoid cstorm_task_cb(void);\nvoid cstorm_sendDone(OpenQueueEntry_t* msg, owerror_t error);\n@@ -73,7 +75,9 @@ void cstorm_init(void) {\nowerror_t cstorm_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n) {\nowerror_t outcome;\n@@ -86,12 +90,10 @@ owerror_t cstorm_receive(\nmsg->length = 0;\n// add CoAP payload\n- packetfunctions_reserveHeaderSize(msg, 3);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n+ packetfunctions_reserveHeaderSize(msg, 2);\n// return as big endian\n- msg->payload[1] = (uint8_t)(cstorm_vars.period >> 8);\n- msg->payload[2] = (uint8_t)(cstorm_vars.period & 0xff);\n+ msg->payload[0] = (uint8_t)(cstorm_vars.period >> 8);\n+ msg->payload[1] = (uint8_t)(cstorm_vars.period & 0xff);\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cwellknown/cwellknown.c", "new_path": "openapps/cwellknown/cwellknown.c", "diff": "@@ -15,10 +15,11 @@ const uint8_t cwellknown_path1[] = \"core\";\n//=========================== prototypes ======================================\n-owerror_t cwellknown_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t cwellknown_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n);\nvoid cwellknown_sendDone(\n@@ -46,11 +47,12 @@ void cwellknown_init() {\n//=========================== private =========================================\n-owerror_t cwellknown_receive(\n- OpenQueueEntry_t* msg,\n+owerror_t cwellknown_receive(OpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n- ) {\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen) {\n+\nowerror_t outcome;\nswitch(coap_header->Code) {\n@@ -62,13 +64,12 @@ owerror_t cwellknown_receive(\n// have CoAP module write links to all resources\nopencoap_writeLinks(msg,COMPONENT_CWELLKNOWN);\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n// add return option\n- packetfunctions_reserveHeaderSize(msg,2);\n- msg->payload[0] = COAP_OPTION_NUM_CONTENTFORMAT << 4 | 1;\n- msg->payload[1] = COAP_MEDTYPE_APPLINKFORMAT;\n+ cwellknown_vars.medType = COAP_MEDTYPE_APPLINKFORMAT;\n+ coap_outgoingOptions[0].type = COAP_OPTION_NUM_CONTENTFORMAT;\n+ coap_outgoingOptions[0].length = 1;\n+ coap_outgoingOptions[0].pValue = &cwellknown_vars.medType;\n+ *coap_outgoingOptionsLen = 1;\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n" }, { "change_type": "MODIFY", "old_path": "openapps/cwellknown/cwellknown.h", "new_path": "openapps/cwellknown/cwellknown.h", "diff": "typedef struct {\ncoap_resource_desc_t desc;\n+ uint8_t medType;\n} cwellknown_vars_t;\n//=========================== prototypes ======================================\n" }, { "change_type": "MODIFY", "old_path": "openapps/rrt/rrt.c", "new_path": "openapps/rrt/rrt.c", "diff": "@@ -26,7 +26,9 @@ rrt_vars_t rrt_vars;\nowerror_t rrt_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n);\nvoid rrt_sendDone(\nOpenQueueEntry_t* msg,\n@@ -80,9 +82,10 @@ void rrt_init() {\nowerror_t rrt_receive(\nOpenQueueEntry_t* msg,\ncoap_header_iht* coap_header,\n- coap_option_iht* coap_options\n+ coap_option_iht* coap_incomingOptions,\n+ coap_option_iht* coap_outgoingOptions,\n+ uint8_t* coap_outgoingOptionsLen\n) {\n-\nowerror_t outcome;\nuint8_t mssgRecvd;\nuint8_t moteToSendTo[16];\n@@ -98,11 +101,6 @@ owerror_t rrt_receive(\n//=== prepare CoAP response\nrrt_setGETRespMsg(msg, rrt_vars.discovered);\n-\n- // payload marker\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n@@ -130,9 +128,6 @@ owerror_t rrt_receive(\nmsg->payload = &(msg->packet[127]);\nmsg->length = 0;\n- packetfunctions_reserveHeaderSize(msg, 1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n//set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n@@ -146,10 +141,6 @@ owerror_t rrt_receive(\n//unregister the current mote as 'discovered' by ringmaster\nrrt_vars.discovered = 0;\n- // payload marker\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n-\n// set the CoAP header\ncoap_header->Code = COAP_CODE_RESP_CONTENT;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Adapt coap apps.
491,595
22.06.2017 14:15:31
-7,200
2232d3f8a7af05a13f6d9e07afaa8ba3a562d516
Use 15miliseconds slot duration.
[ { "change_type": "MODIFY", "old_path": "openapps/uexpiration_monitor/uexpiration_monitor.py", "new_path": "openapps/uexpiration_monitor/uexpiration_monitor.py", "diff": "@@ -8,6 +8,7 @@ myPort = 21569\nhisAddress = ''\nhisPort = 3\nmonitor_interval = 0\n+slotDuration = 15 # miliseconds\nif len(sys.argv) == 2:\n# log\n@@ -27,6 +28,7 @@ else:\noutput += ['[{0}]:{1}->[{2}]:{3}'.format(myAddress,myPort,hisAddress,hisPort)]\noutput += ['\\nMonitoring node IP : {0} '.format(hisAddress)]\noutput += ['Probe interval : {0} sec '.format(monitor_interval)]\n+ output += ['Slot duration : {0} miliseconds '.format(slotDuration)]\noutput = '\\n'.join(output)\nprint output\nprint \"\\n\"\n@@ -53,9 +55,9 @@ else:\nelse:\nn = map(ord,reply)\ntime_elapsed = n[1] << 8 | n[0]\n- time_elapsed_ms = time_elapsed * 14\n+ time_elapsed_ms = time_elapsed * slotDuration\ntime_left = n[3] << 8 | n[2]\n- time_left_ms = time_left * 14\n+ time_left_ms = time_left * slotDuration\nif(time_elapsed != 0):\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
Use 15miliseconds slot duration.
491,609
22.06.2017 15:47:10
-7,200
1be18e2415e23b8153f43e39036feab5f0d83617
Implement generic option parsing for CoAP to be able to accept longer payload.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -16,6 +16,7 @@ opencoap_vars_t opencoap_vars;\n//=========================== prototype =======================================\nuint8_t opencoap_options_encode(uint8_t* buffer,coap_option_iht* options, uint8_t optionsLen, bool fake);\n+uint8_t opencoap_options_parse(OpenQueueEntry_t* msg, coap_option_iht* options, uint8_t optionsLen);\n//=========================== public ==========================================\n@@ -50,9 +51,7 @@ received packetbuffer is reused to contain the response (or error code).\n*/\nvoid opencoap_receive(OpenQueueEntry_t* msg) {\nuint16_t temp_l4_destination_port;\n- uint8_t i;\nuint8_t index;\n- coap_option_t last_option;\ncoap_resource_desc_t* temp_desc;\nbool found;\nowerror_t outcome = 0;\n@@ -97,36 +96,13 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\nmemcpy(&coap_header.token[0], &msg->payload[index], coap_header.TKL);\nindex += coap_header.TKL;\n- // initialize the coap_incomingOptions\n- for (i=0;i<MAX_COAP_OPTIONS;i++) {\n- coap_incomingOptions[i].type = COAP_OPTION_NONE;\n- }\n-\n- // fill in the coap_incomingOptions\n- last_option = COAP_OPTION_NONE;\n- for (i=0;i<MAX_COAP_OPTIONS;i++) {\n-\n- // detect when done parsing options\n- if (msg->payload[index]==COAP_PAYLOAD_MARKER) {\n- // found the payload marker, done parsing options.\n- index++; // skip marker and stop parsing options\n- break;\n- }\n- if (msg->length<=index) {\n- // end of message, no payload\n- break;\n- }\n+ // remove the CoAP header\n+ packetfunctions_tossHeader(msg,index);\n- // parse this option\n- coap_incomingOptions[i].type = (coap_option_t)((uint8_t)last_option+(uint8_t)((msg->payload[index] & 0xf0) >> 4));\n- last_option = coap_incomingOptions[i].type;\n- coap_incomingOptions[i].length = (msg->payload[index] & 0x0f);\n- index++;\n- coap_incomingOptions[i].pValue = &(msg->payload[index]);\n- index += coap_incomingOptions[i].length; //includes length as well\n- }\n+ // parse options and toss header\n+ index = opencoap_options_parse(msg, coap_incomingOptions, MAX_COAP_OPTIONS);\n- // remove the CoAP header+options\n+ // toss options\npacketfunctions_tossHeader(msg,index);\n//=== step 2. find the resource to handle the packet\n@@ -615,3 +591,83 @@ uint8_t opencoap_options_encode(\n}\nreturn index;\n}\n+\n+uint8_t opencoap_options_parse(\n+ OpenQueueEntry_t* msg,\n+ coap_option_iht* options,\n+ uint8_t optionsLen\n+ ) {\n+\n+ uint8_t index;\n+ uint8_t i;\n+ coap_option_t lastOption;\n+ coap_option_t optionDelta;\n+ uint8_t optionLength;\n+\n+ index = 0;\n+\n+ // initialize the coap_incomingOptions\n+ for (i=0;i<optionsLen;i++) {\n+ options[i].type = COAP_OPTION_NONE;\n+ }\n+\n+ lastOption = COAP_OPTION_NONE;\n+ for (i = 0; i < optionsLen; i++) {\n+\n+ // detect when done parsing options\n+ if (msg->payload[index]==COAP_PAYLOAD_MARKER) {\n+ // found the payload marker, done parsing options.\n+ index++; // skip marker and stop parsing options\n+ break;\n+ }\n+ if (msg->length<=index) {\n+ // end of message, no payload\n+ break;\n+ }\n+\n+ optionDelta = ((msg->payload[index] & 0xf0) >> 4);\n+ optionLength = (msg->payload[index] & 0x0f);\n+\n+ index++;\n+\n+ if (optionDelta <= 12) {\n+ }\n+ else if (optionDelta == 13) {\n+ optionDelta = msg->payload[index] + 13;\n+ index++;\n+ }\n+ else if (optionDelta == 14) {\n+ optionDelta = (coap_option_t) (packetfunctions_ntohs(&msg->payload[index]) + 269);\n+ index += 2;\n+ }\n+ else {\n+ break;\n+ }\n+\n+ if (optionLength <= 12) {\n+\n+ }\n+ else if (optionLength == 13) {\n+ optionLength = msg->payload[index] + 13;\n+ index++;\n+ }\n+ else {\n+ // case 14 not supported\n+ break;\n+ }\n+\n+ if (msg->length <= index) {\n+ break;\n+ }\n+\n+ // create new option\n+ options[i].type = lastOption + optionDelta;\n+ options[i].length = optionLength;\n+ options[i].pValue = &(msg->payload[index]);\n+ index += optionLength;\n+ lastOption = options[i].type;\n+ }\n+ return index;\n+}\n+\n+\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -705,6 +705,7 @@ functionsToChange = [\n'opencoap_register',\n'opencoap_send',\n'opencoap_options_encode',\n+ 'opencoap_options_parse',\n'icmpv6coap_timer_cb',\n# oscoap\n'openoscoap_init_security_context',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Implement generic option parsing for CoAP to be able to accept longer payload.
491,609
23.06.2017 19:01:36
-7,200
5d29c3d92c9413326613b61e7fd7ef37bb7ec577
Add helper functions for OSCOAP.
[ { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -172,6 +172,7 @@ enum {\nCOMPONENT_SECURITY = 0x27,\nCOMPONENT_USERIALBRIDGE = 0x28,\nCOMPONENT_CJOIN = 0x29,\n+ COMPONENT_OPENOSCOAP = 0x30,\n};\n/**\n@@ -254,6 +255,7 @@ enum {\nERR_UNSUPPORTED_FORMAT = 0x40, // the received packet format is not supported {code location {0}}\nERR_UNSUPPORTED_METADATA = 0x41, // the metadata type is not suppored\nERR_JOINED = 0x42, // node joined\n+ ERR_SEQUENCE_NUMBER_OVERFLOW = 0x43, // OSCOAP sequence number reached maximum value\n};\n//=========================== typedef =========================================\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -17,7 +17,7 @@ opencoap_vars_t opencoap_vars;\n//=========================== prototype =======================================\nuint8_t opencoap_options_encode(uint8_t* buffer,coap_option_iht* options, uint8_t optionsLen, bool fake);\nuint8_t opencoap_options_parse(OpenQueueEntry_t* msg, coap_option_iht* options, uint8_t optionsLen);\n-\n+coap_option_iht* opencoap_find_object_security_option(coap_option_iht* array, uint8_t arrayLen);\n//=========================== public ==========================================\n//===== from stack\n@@ -455,6 +455,20 @@ owerror_t opencoap_send(\nuint16_t token;\nuint8_t tokenPos=0;\ncoap_header_iht* request;\n+ coap_option_iht* objectSecurity;\n+ bool securityActivated;\n+ owerror_t ret;\n+\n+ if (descSender->securityContext != NULL) { // security activated for the resource\n+ securityActivated = TRUE;\n+ objectSecurity = opencoap_find_object_security_option(options, optionsLen);\n+ if (objectSecurity == NULL) { // objectSecurity option should be set by the application\n+ return E_FAIL;\n+ }\n+ }\n+ else {\n+ securityActivated = FALSE;\n+ }\n// increment the (global) messageID\nif (opencoap_vars.messageID++ == 0xffff) {\n@@ -485,6 +499,24 @@ owerror_t opencoap_send(\nmsg->payload[0] = COAP_PAYLOAD_MARKER;\n}\n+ if (securityActivated) {\n+ // get new sequence number and save it\n+ request->oscoapSeqNum = openoscoap_get_sequence_number(descSender->securityContext);\n+ // protect the message in the openqueue buffer\n+ ret = openoscoap_protect_message(\n+ descSender->securityContext,\n+ COAP_VERSION,\n+ code,\n+ options,\n+ optionsLen,\n+ msg,\n+ request->oscoapSeqNum);\n+\n+ if (ret != E_SUCCESS) {\n+ return E_FAIL;\n+ }\n+ }\n+\n// fake run of opencoap_options_encode in order to get the necessary length\npacketfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, options, optionsLen, TRUE));\n@@ -505,6 +537,42 @@ owerror_t opencoap_send(\nreturn openudp_send(msg);\n}\n+/**\n+\\brief Lookup the OSCOAP class for a given option.\n+\n+This function is called to resolve the OSCOAP class of the passed option.\n+CLASS_E options get encrypted, CLASS_I options are integrity protected,\n+and CLASS_U options are unprotected by OSCOAP, if security is activated.\n+\n+\\param[in] type The CoAP option type that needs to be resolved.\n+*/\n+coap_option_class_t opencoap_get_option_class(coap_option_t type) {\n+ switch(type) {\n+ // class E options\n+ case COAP_OPTION_NUM_IFMATCH:\n+ case COAP_OPTION_NUM_ETAG:\n+ case COAP_OPTION_NUM_IFNONEMATCH:\n+ case COAP_OPTION_NUM_LOCATIONPATH:\n+ case COAP_OPTION_NUM_URIPATH:\n+ case COAP_OPTION_NUM_CONTENTFORMAT:\n+ case COAP_OPTION_NUM_MAXAGE:\n+ case COAP_OPTION_NUM_URIQUERY:\n+ case COAP_OPTION_NUM_ACCEPT:\n+ case COAP_OPTION_NUM_LOCATIONQUERY:\n+ return COAP_OPTION_CLASS_E;\n+ // class I options none supported\n+\n+ //class U options\n+ case COAP_OPTION_NUM_URIHOST:\n+ case COAP_OPTION_NUM_URIPORT:\n+ case COAP_OPTION_NUM_PROXYURI:\n+ case COAP_OPTION_NUM_PROXYSCHEME:\n+ case COAP_OPTION_NUM_OBJECTSECURITY:\n+ return COAP_OPTION_CLASS_U;\n+ default:\n+ return COAP_OPTION_CLASS_U;\n+ }\n+}\n//=========================== private =========================================\nuint8_t opencoap_options_encode(\n@@ -670,4 +738,19 @@ uint8_t opencoap_options_parse(\nreturn index;\n}\n+coap_option_iht* opencoap_find_object_security_option(coap_option_iht* array, uint8_t arrayLen) {\n+ uint8_t i;\n+\n+ if (array == NULL || arrayLen == 0) {\n+ return NULL;\n+ }\n+\n+ for (i = 0; i < arrayLen; i++) {\n+ if (array[i].type == COAP_OPTION_NUM_OBJECTSECURITY) {\n+ return &array[i];\n+ }\n+ }\n+ return NULL;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "@@ -97,6 +97,12 @@ typedef enum {\nCOAP_OPTION_NUM_OBJECTSECURITY = 21,\n} coap_option_t;\n+typedef enum {\n+ COAP_OPTION_CLASS_E = 0,\n+ COAP_OPTION_CLASS_I = 1,\n+ COAP_OPTION_CLASS_U = 2,\n+} coap_option_class_t;\n+\ntypedef enum {\nCOAP_MEDTYPE_TEXTPLAIN = 0,\nCOAP_MEDTYPE_APPLINKFORMAT = 40,\n@@ -116,6 +122,7 @@ typedef struct {\ncoap_code_t Code;\nuint16_t messageID;\nuint8_t token[COAP_MAX_TKL];\n+ uint16_t oscoapSeqNum;\n} coap_header_iht;\ntypedef struct {\n@@ -140,6 +147,7 @@ struct coap_resource_desc_t {\nuint8_t path1len;\nuint8_t* path1val;\nuint8_t componentID;\n+ void* securityContext;\nbool discoverable;\ncallbackRx_cbt callbackRx;\ncallbackSendDone_cbt callbackSendDone;\n@@ -177,6 +185,9 @@ owerror_t opencoap_send(\ncoap_resource_desc_t* descSender\n);\n+// option handling\n+coap_option_class_t opencoap_get_option_class(coap_option_t type);\n+\n/**\n\\}\n\\}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "#include \"opendefs.h\"\n-#include \"openoscoap.h\"\n+#include \"openserial.h\"\n+#include \"opencoap.h\"\n#include \"cborencoder.h\"\n#include \"sha.h\"\n@@ -23,6 +24,8 @@ owerror_t hkdf_derive_parameter(uint8_t* buffer,\nuint8_t length\n);\n+bool is_request(uint8_t code);\n+\n//=========================== public ==========================================\n@@ -115,6 +118,32 @@ void openoscoap_init_security_context(oscoap_security_context_t *ctx,\n}\n+owerror_t openoscoap_protect_message(\n+ oscoap_security_context_t *context,\n+ uint8_t version,\n+ uint8_t code,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\n+ OpenQueueEntry_t* msg,\n+ uint16_t sequenceNumer) {\n+\n+ return E_SUCCESS;\n+}\n+\n+uint16_t openoscoap_get_sequence_number(oscoap_security_context_t *context) {\n+ if (context->sequenceNumber == 0xffff) {\n+ openserial_printError(\n+ COMPONENT_OPENOSCOAP,ERR_SEQUENCE_NUMBER_OVERFLOW,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0\n+ );\n+ } else {\n+ context->sequenceNumber++;\n+ }\n+ return context->sequenceNumber;\n+}\n+\n+\n//=========================== private =========================================\nowerror_t hkdf_derive_parameter(uint8_t* buffer,\n@@ -163,3 +192,14 @@ owerror_t hkdf_derive_parameter(uint8_t* buffer,\nreturn E_FAIL;\n}\n+bool is_request(uint8_t code) {\n+ if ( code == (uint8_t) COAP_CODE_REQ_GET ||\n+ code == (uint8_t) COAP_CODE_REQ_POST ||\n+ code == (uint8_t) COAP_CODE_REQ_PUT ||\n+ code == (uint8_t) COAP_CODE_REQ_DELETE) {\n+ return TRUE;\n+ }\n+ else {\n+ return FALSE;\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.h", "new_path": "openapps/opencoap/openoscoap.h", "diff": "-\n#ifndef __OPENOSCOAP_H\n#define __OPENOSCOAP_H\n\\{\n*/\n+#include \"opencoap.h\"\n+\n//=========================== define ==========================================\n#define OSCOAP_MAX_ID_LEN 10\n@@ -70,6 +71,18 @@ void openoscoap_init_security_context(oscoap_security_context_t *ctx,\nuint8_t masterSecretLen,\nuint8_t* masterSalt,\nuint8_t masterSaltLen);\n+\n+owerror_t openoscoap_protect_message(\n+ oscoap_security_context_t *context,\n+ uint8_t version,\n+ uint8_t code,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\n+ OpenQueueEntry_t* msg,\n+ uint16_t sequenceNumer);\n+\n+uint16_t openoscoap_get_sequence_number(oscoap_security_context_t *context);\n+\n/**\n\\}\n\\}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -709,6 +709,8 @@ functionsToChange = [\n'icmpv6coap_timer_cb',\n# oscoap\n'openoscoap_init_security_context',\n+ 'openoscoap_find_object_security_option',\n+ 'openoscoap_get_sequence_number',\n# openudp\n'openudp_init',\n'openudp_send',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add helper functions for OSCOAP.
491,609
24.06.2017 17:21:29
-7,200
30da2d7457dfca10540e95cf6aed7bfcfc9d0b71
Add additional helper functions for OSCOAP.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "#include \"opendefs.h\"\n#include \"openserial.h\"\n+#include \"packetfunctions.h\"\n#include \"opencoap.h\"\n#include \"cborencoder.h\"\n+#include \"cryptoengine.h\"\n#include \"sha.h\"\n@@ -26,6 +28,22 @@ owerror_t hkdf_derive_parameter(uint8_t* buffer,\nbool is_request(uint8_t code);\n+uint8_t construct_aad(uint8_t* buffer,\n+ uint8_t version,\n+ uint8_t code,\n+ uint8_t* optionsSerialized,\n+ uint8_t optionsSerializedLen,\n+ uint8_t aeadAlgorithm,\n+ uint8_t* requestKid,\n+ uint8_t requestKidLen,\n+ uint8_t* requestSeq,\n+ uint8_t requestSeqLen\n+ );\n+\n+void xor_arrays(uint8_t* s1, uint8_t* s2, uint8_t* dst, uint8_t len);\n+\n+void flip_first_bit(uint8_t* source, uint8_t* dst, uint8_t len);\n+\n//=========================== public ==========================================\n@@ -203,3 +221,50 @@ bool is_request(uint8_t code) {\nreturn FALSE;\n}\n}\n+\n+uint8_t construct_aad(uint8_t* buffer,\n+ uint8_t version,\n+ uint8_t code,\n+ uint8_t* optionsSerialized,\n+ uint8_t optionsSerializedLen,\n+ uint8_t aeadAlgorithm,\n+ uint8_t* requestKid,\n+ uint8_t requestKidLen,\n+ uint8_t* requestSeq,\n+ uint8_t requestSeqLen\n+ ) {\n+ uint8_t* ptr;\n+ ptr = buffer;\n+ uint8_t ret;\n+ const uint8_t encrypt0[] = \"Encrypt0\";\n+\n+ ret = 0;\n+\n+ ret += cborencoder_put_array(&ptr, 3); // COSE Encrypt0 structure with 3 elements\n+ // first element: \"Encrypt0\"\n+ ret += cborencoder_put_text(&ptr, (char *) encrypt0, sizeof(encrypt0) - 1);\n+ // second element: empty byte string\n+ ret += cborencoder_put_bytes(&ptr, 0, NULL);\n+ // third element: external AAD from OSCOAP\n+ ret += cborencoder_put_array(&ptr, 6);\n+ ret += cborencoder_put_unsigned(&ptr, version);\n+ ret += cborencoder_put_unsigned(&ptr, code);\n+ ret += cborencoder_put_bytes(&ptr, optionsSerializedLen, optionsSerialized);\n+ ret += cborencoder_put_unsigned(&ptr, aeadAlgorithm);\n+ ret += cborencoder_put_bytes(&ptr, requestKidLen, requestKid);\n+ ret += cborencoder_put_bytes(&ptr, requestSeqLen, requestSeq);\n+\n+ return ret;\n+}\n+\n+void xor_arrays(uint8_t* s1, uint8_t* s2, uint8_t* dst, uint8_t len) {\n+ uint8_t i;\n+ for (i = 0; i < len; i++) {\n+ dst[i] = s1[i] ^ s2[i];\n+ }\n+}\n+\n+void flip_first_bit(uint8_t* source, uint8_t* dst, uint8_t len){\n+ memcpy(dst, source, len);\n+ dst[0] = dst[0] ^ 0x80;\n+}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Add additional helper functions for OSCOAP.
491,609
24.06.2017 17:22:59
-7,200
93ce2d994d0daee4e7392090c118701d36a49d9b
Export opencoap_options_encode functions.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "opencoap_vars_t opencoap_vars;\n//=========================== prototype =======================================\n-uint8_t opencoap_options_encode(uint8_t* buffer,coap_option_iht* options, uint8_t optionsLen, bool fake);\n-uint8_t opencoap_options_parse(OpenQueueEntry_t* msg, coap_option_iht* options, uint8_t optionsLen);\n+uint8_t opencoap_options_parse(OpenQueueEntry_t* msg,\n+ coap_option_iht* options,\n+ uint8_t optionsLen);\n+\ncoap_option_iht* opencoap_find_object_security_option(coap_option_iht* array, uint8_t arrayLen);\n//=========================== public ==========================================\n@@ -252,10 +254,14 @@ void opencoap_receive(OpenQueueEntry_t* msg) {\n}\n// fake run of opencoap_options_encode in order to get the necessary length\n- packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, coap_outgoingOptions, coap_outgoingOptionsLen, TRUE));\n+ packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL,\n+ coap_outgoingOptions,\n+ coap_outgoingOptionsLen,\n+ COAP_OPTION_CLASS_ALL,\n+ TRUE));\n// once header is reserved, encode the options to the openqueue payload buffer\n- opencoap_options_encode(msg->payload, coap_outgoingOptions, coap_outgoingOptionsLen, FALSE);\n+ opencoap_options_encode(msg->payload, coap_outgoingOptions, coap_outgoingOptionsLen, COAP_OPTION_CLASS_ALL, FALSE);\n//=== step 5. send that packet back\n@@ -458,6 +464,9 @@ owerror_t opencoap_send(\ncoap_option_iht* objectSecurity;\nbool securityActivated;\nowerror_t ret;\n+ coap_option_class_t class;\n+\n+ class = COAP_OPTION_CLASS_ALL;\nif (descSender->securityContext != NULL) { // security activated for the resource\nsecurityActivated = TRUE;\n@@ -515,13 +524,23 @@ owerror_t opencoap_send(\nif (ret != E_SUCCESS) {\nreturn E_FAIL;\n}\n+\n+ class = COAP_OPTION_CLASS_U;\n}\n// fake run of opencoap_options_encode in order to get the necessary length\n- packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL, options, optionsLen, TRUE));\n+ packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL,\n+ options,\n+ optionsLen,\n+ class,\n+ TRUE));\n// once header is reserved, encode the options to the openqueue payload buffer\n- opencoap_options_encode(msg->payload, options, optionsLen, FALSE);\n+ opencoap_options_encode(msg->payload,\n+ options,\n+ optionsLen,\n+ class,\n+ FALSE);\n// pre-pend CoAP header (version,type,TKL,code,messageID,Token)\npacketfunctions_reserveHeaderSize(msg,4+request->TKL);\n@@ -579,6 +598,7 @@ uint8_t opencoap_options_encode(\nuint8_t* buffer,\ncoap_option_iht* options,\nuint8_t optionsLen,\n+ coap_option_class_t class,\nbool fake\n) {\n@@ -599,6 +619,11 @@ uint8_t opencoap_options_encode(\nlastOptionNum = COAP_OPTION_NONE;\nif (options != NULL) {\nfor (i = 0; i < optionsLen; i++) {\n+ if (class != opencoap_get_option_class(options[i].type) &&\n+ class != COAP_OPTION_CLASS_ALL) {\n+ continue;\n+ }\n+\nif (options[i].type < lastOptionNum) {\nreturn 0; // we require the options to be sorted\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "@@ -101,6 +101,7 @@ typedef enum {\nCOAP_OPTION_CLASS_E = 0,\nCOAP_OPTION_CLASS_I = 1,\nCOAP_OPTION_CLASS_U = 2,\n+ COAP_OPTION_CLASS_ALL = 3,\n} coap_option_class_t;\ntypedef enum {\n@@ -187,6 +188,12 @@ owerror_t opencoap_send(\n// option handling\ncoap_option_class_t opencoap_get_option_class(coap_option_t type);\n+uint8_t opencoap_options_encode(uint8_t* buffer,\n+ coap_option_iht* options,\n+ uint8_t optionsLen,\n+ coap_option_class_t class,\n+ bool fake);\n+\n/**\n\\}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Export opencoap_options_encode functions.
491,609
24.06.2017 17:23:34
-7,200
4df22df7283f11405ee9537834c1d7b6f71c6d4a
First implementation of OSCOAP's protect function.
[ { "change_type": "MODIFY", "old_path": "inc/opendefs.h", "new_path": "inc/opendefs.h", "diff": "@@ -256,6 +256,7 @@ enum {\nERR_UNSUPPORTED_METADATA = 0x41, // the metadata type is not suppored\nERR_JOINED = 0x42, // node joined\nERR_SEQUENCE_NUMBER_OVERFLOW = 0x43, // OSCOAP sequence number reached maximum value\n+ ERR_BUFFER_OVERFLOW = 0x44, // OSCOAP buffer overflow detected\n};\n//=========================== typedef =========================================\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "@@ -143,7 +143,111 @@ owerror_t openoscoap_protect_message(\ncoap_option_iht* options,\nuint8_t optionsLen,\nOpenQueueEntry_t* msg,\n- uint16_t sequenceNumer) {\n+ uint16_t sequenceNumber) {\n+\n+ uint8_t* payload;\n+ uint8_t payloadLen;\n+ uint8_t* aad;\n+ uint8_t aadLen;\n+ uint8_t nonce[AES_CCM_16_64_128_IV_LEN];\n+ uint8_t partialIV[AES_CCM_16_64_128_IV_LEN];\n+ uint8_t* requestSeq;\n+ uint8_t requestSeqLen;\n+ owerror_t encStatus;\n+\n+ // convert sequence number to array and strip leading zeros\n+ memset(partialIV, 0x00, AES_CCM_16_64_128_IV_LEN);\n+ packetfunctions_htons(sequenceNumber, &partialIV[AES_CCM_16_64_128_IV_LEN - 2]);\n+ if (partialIV[AES_CCM_16_64_128_IV_LEN - 2] == 0x00) {\n+ requestSeq = &partialIV[AES_CCM_16_64_128_IV_LEN - 1];\n+ requestSeqLen = 1;\n+ }\n+ else {\n+ requestSeq = &partialIV[AES_CCM_16_64_128_IV_LEN - 2];\n+ requestSeqLen = 2;\n+ }\n+\n+ // fake run of opencoap_options_encode in order to get the necessary length\n+ packetfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL,\n+ options,\n+ optionsLen,\n+ COAP_OPTION_CLASS_E,\n+ TRUE));\n+\n+ // once header is reserved, encode the options to the openqueue payload buffer\n+ opencoap_options_encode(msg->payload,\n+ options,\n+ optionsLen,\n+ COAP_OPTION_CLASS_E,\n+ FALSE);\n+\n+ payload = &msg->payload[0];\n+ payloadLen = msg->length;\n+ // shift payload to the left to leave space for authentication tag\n+ packetfunctions_reserveHeaderSize(msg, AES_CCM_16_64_128_TAG_LEN);\n+ memcpy(&msg->payload[0], payload, payloadLen);\n+ // update payload pointer but leave length intact\n+ payload = &msg->payload[0];\n+\n+ packetfunctions_reserveHeaderSize(msg, 125 - payloadLen - AES_CCM_16_64_128_TAG_LEN);\n+ aad = &msg->payload[0];\n+\n+ aadLen = construct_aad(aad,\n+ version,\n+ code,\n+ NULL,\n+ 0, // TODO do not support Class I options at the moment\n+ AES_CCM_16_64_128,\n+ context->senderID,\n+ context->senderIDLen,\n+ requestSeq,\n+ requestSeqLen);\n+\n+ if (aad + aadLen > payload) {\n+ // corruption\n+ openserial_printError(\n+ COMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0\n+ );\n+ return E_FAIL;\n+ }\n+\n+ // construct nonce\n+ if (is_request(code)) {\n+ xor_arrays(context->senderIV, partialIV, nonce, AES_CCM_16_64_128_IV_LEN);\n+ }\n+ else {\n+ flip_first_bit(context->senderIV, nonce, AES_CCM_16_64_128_IV_LEN);\n+ xor_arrays(nonce, partialIV, nonce, AES_CCM_16_64_128_IV_LEN);\n+ }\n+\n+ encStatus = cryptoengine_aes_ccms_enc(aad,\n+ aadLen,\n+ payload,\n+ &payloadLen,\n+ nonce,\n+ 2, // L=2 in 15.4 std\n+ context->senderKey,\n+ AES_CCM_16_64_128_TAG_LEN);\n+\n+ if (encStatus != E_SUCCESS) {\n+ return E_FAIL;\n+ }\n+\n+ packetfunctions_tossHeader(msg, 125 - payloadLen - AES_CCM_16_64_128_TAG_LEN);\n+\n+ if (payload != &msg->payload[0]) {\n+ // corruption\n+ openserial_printError(\n+ COMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n+ (errorparameter_t)0,\n+ (errorparameter_t)1\n+ );\n+ return E_FAIL;\n+ }\n+\n+ // TODO encode compressed COSE\nreturn E_SUCCESS;\n}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.h", "new_path": "openapps/opencoap/openoscoap.h", "diff": "@@ -79,7 +79,9 @@ owerror_t openoscoap_protect_message(\ncoap_option_iht* options,\nuint8_t optionsLen,\nOpenQueueEntry_t* msg,\n- uint16_t sequenceNumer);\n+ uint16_t sequenceNumber);\n+\n+\nuint16_t openoscoap_get_sequence_number(oscoap_security_context_t *context);\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -711,6 +711,7 @@ functionsToChange = [\n'openoscoap_init_security_context',\n'openoscoap_find_object_security_option',\n'openoscoap_get_sequence_number',\n+ 'openoscoap_protect_message',\n# openudp\n'openudp_init',\n'openudp_send',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. First implementation of OSCOAP's protect function.
491,609
24.06.2017 21:43:05
-7,200
ff30148ebaa2ef8616ccb2936bf6d8076ca7719f
Carry payload as the value of object security option.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -463,10 +463,12 @@ owerror_t opencoap_send(\ncoap_header_iht* request;\ncoap_option_iht* objectSecurity;\nbool securityActivated;\n+ bool payloadPresent;\nowerror_t ret;\ncoap_option_class_t class;\nclass = COAP_OPTION_CLASS_ALL;\n+ payloadPresent = FALSE;\nif (descSender->securityContext != NULL) { // security activated for the resource\nsecurityActivated = TRUE;\n@@ -503,9 +505,8 @@ owerror_t opencoap_send(\ntokenPos+=2;\n}\n- if (msg->length > 0 ) { // contains payload, add payload marker\n- packetfunctions_reserveHeaderSize(msg,1);\n- msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ if (msg->length > 0 ) { // contains payload\n+ payloadPresent = TRUE;\n}\nif (securityActivated) {\n@@ -526,6 +527,18 @@ owerror_t opencoap_send(\n}\nclass = COAP_OPTION_CLASS_U;\n+\n+ if (payloadPresent) {\n+ objectSecurity->length = 0;\n+ objectSecurity->pValue = NULL;\n+ }\n+ else {\n+ objectSecurity->length = msg->length;\n+ // FIXME use the upper bytes in the msg->packet buffer to avoid huge allocation on stack\n+ memcpy(&msg->packet[0], &msg->payload[0], msg->length);\n+ objectSecurity->pValue = &msg->packet[0];\n+ packetfunctions_tossHeader(msg, msg->length); // reset packet to zero as objectSecurity option will cary payload\n+ }\n}\n// fake run of opencoap_options_encode in order to get the necessary length\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "//=========================== defines =========================================\n-\n+#define AAD_CONST_LEN 19\n//=========================== variables =======================================\nopenoscoap_vars_t openoscoap_vars;\n@@ -73,6 +73,12 @@ void openoscoap_init_security_context(oscoap_security_context_t *ctx,\nuint8_t masterSecretLen,\nuint8_t* masterSalt,\nuint8_t masterSaltLen) {\n+\n+ if (senderIDLen > OSCOAP_MAX_ID_LEN ||\n+ recipientIDLen > OSCOAP_MAX_ID_LEN) {\n+ return;\n+ }\n+\n// common context\nctx->aeadAlgorithm = AES_CCM_16_64_128;\n@@ -147,7 +153,7 @@ owerror_t openoscoap_protect_message(\nuint8_t* payload;\nuint8_t payloadLen;\n- uint8_t* aad;\n+ uint8_t aad[AAD_CONST_LEN + OSCOAP_MAX_ID_LEN]; // assumes no CLASS I options\nuint8_t aadLen;\nuint8_t nonce[AES_CCM_16_64_128_IV_LEN];\nuint8_t partialIV[AES_CCM_16_64_128_IV_LEN];\n@@ -167,6 +173,11 @@ owerror_t openoscoap_protect_message(\nrequestSeqLen = 2;\n}\n+ if (msg->length > 0 ) { // contains payload, add payload marker\n+ packetfunctions_reserveHeaderSize(msg,1);\n+ msg->payload[0] = COAP_PAYLOAD_MARKER;\n+ }\n+\n// fake run of opencoap_options_encode in order to get the necessary length\npacketfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL,\noptions,\n@@ -183,27 +194,24 @@ owerror_t openoscoap_protect_message(\npayload = &msg->payload[0];\npayloadLen = msg->length;\n- // shift payload to the left to leave space for authentication tag\n+ // shift payload to leave space for authentication tag\npacketfunctions_reserveHeaderSize(msg, AES_CCM_16_64_128_TAG_LEN);\nmemcpy(&msg->payload[0], payload, payloadLen);\n// update payload pointer but leave length intact\npayload = &msg->payload[0];\n- packetfunctions_reserveHeaderSize(msg, 125 - payloadLen - AES_CCM_16_64_128_TAG_LEN);\n- aad = &msg->payload[0];\n-\naadLen = construct_aad(aad,\nversion,\ncode,\nNULL,\n- 0, // TODO do not support Class I options at the moment\n+ 0, // do not support Class I options at the moment\nAES_CCM_16_64_128,\ncontext->senderID,\ncontext->senderIDLen,\nrequestSeq,\nrequestSeqLen);\n- if (aad + aadLen > payload) {\n+ if (aadLen > AAD_CONST_LEN + OSCOAP_MAX_ID_LEN) {\n// corruption\nopenserial_printError(\nCOMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n@@ -235,18 +243,6 @@ owerror_t openoscoap_protect_message(\nreturn E_FAIL;\n}\n- packetfunctions_tossHeader(msg, 125 - payloadLen - AES_CCM_16_64_128_TAG_LEN);\n-\n- if (payload != &msg->payload[0]) {\n- // corruption\n- openserial_printError(\n- COMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n- (errorparameter_t)0,\n- (errorparameter_t)1\n- );\n- return E_FAIL;\n- }\n-\n// TODO encode compressed COSE\nreturn E_SUCCESS;\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Carry payload as the value of object security option.
491,609
24.06.2017 21:43:43
-7,200
d152d395471b01b56a890f7bcffe0af75918f442
Fix to allow OpenQueueEntry_t reset by calling tossHeader function.
[ { "change_type": "MODIFY", "old_path": "openstack/cross-layers/packetfunctions.c", "new_path": "openstack/cross-layers/packetfunctions.c", "diff": "@@ -276,9 +276,10 @@ void packetfunctions_reserveHeaderSize(OpenQueueEntry_t* pkt, uint8_t header_len\n}\nvoid packetfunctions_tossHeader(OpenQueueEntry_t* pkt, uint8_t header_length) {\n+\npkt->payload += header_length;\npkt->length -= header_length;\n- if ( (uint8_t*)(pkt->payload) > (uint8_t*)(pkt->packet+126) ) {\n+ if ( (uint8_t*)(pkt->payload) > (uint8_t*)(pkt->packet+127) ) {\nopenserial_printError(COMPONENT_PACKETFUNCTIONS,ERR_HEADER_TOO_LONG,\n(errorparameter_t)1,\n(errorparameter_t)pkt->length);\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Fix to allow OpenQueueEntry_t reset by calling tossHeader function.
491,609
25.06.2017 11:11:52
-7,200
e5d5e107b623626c4eeda0ac7fbd0b15e76dbb8e
Implement compressed COSE encoding of OSCOAP.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "@@ -40,6 +40,11 @@ uint8_t construct_aad(uint8_t* buffer,\nuint8_t requestSeqLen\n);\n+void openoscoap_encode_compressed_COSE(OpenQueueEntry_t* msg,\n+ uint8_t* requestSeq, uint8_t requestSeqLen,\n+ uint8_t* requestKid,\n+ uint8_t requestKidLen);\n+\nvoid xor_arrays(uint8_t* s1, uint8_t* s2, uint8_t* dst, uint8_t len);\nvoid flip_first_bit(uint8_t* source, uint8_t* dst, uint8_t len);\n@@ -159,6 +164,8 @@ owerror_t openoscoap_protect_message(\nuint8_t partialIV[AES_CCM_16_64_128_IV_LEN];\nuint8_t* requestSeq;\nuint8_t requestSeqLen;\n+ uint8_t *requestKid;\n+ uint8_t requestKidLen;\nowerror_t encStatus;\n// convert sequence number to array and strip leading zeros\n@@ -173,6 +180,9 @@ owerror_t openoscoap_protect_message(\nrequestSeqLen = 2;\n}\n+ requestKid = context->senderID;\n+ requestKidLen = context->senderIDLen;\n+\nif (msg->length > 0 ) { // contains payload, add payload marker\npacketfunctions_reserveHeaderSize(msg,1);\nmsg->payload[0] = COAP_PAYLOAD_MARKER;\n@@ -206,8 +216,8 @@ owerror_t openoscoap_protect_message(\nNULL,\n0, // do not support Class I options at the moment\nAES_CCM_16_64_128,\n- context->senderID,\n- context->senderIDLen,\n+ requestKid,\n+ requestKidLen,\nrequestSeq,\nrequestSeqLen);\n@@ -228,6 +238,11 @@ owerror_t openoscoap_protect_message(\nelse {\nflip_first_bit(context->senderIV, nonce, AES_CCM_16_64_128_IV_LEN);\nxor_arrays(nonce, partialIV, nonce, AES_CCM_16_64_128_IV_LEN);\n+ // do not encode sequence number and ID in the response\n+ requestSeq = NULL;\n+ requestSeq = 0;\n+ requestKid = NULL;\n+ requestKidLen = 0;\n}\nencStatus = cryptoengine_aes_ccms_enc(aad,\n@@ -244,6 +259,7 @@ owerror_t openoscoap_protect_message(\n}\n// TODO encode compressed COSE\n+ openoscoap_encode_compressed_COSE(msg, requestSeq, requestSeqLen, requestKid, requestKidLen);\nreturn E_SUCCESS;\n}\n@@ -357,6 +373,36 @@ uint8_t construct_aad(uint8_t* buffer,\nreturn ret;\n}\n+void openoscoap_encode_compressed_COSE(OpenQueueEntry_t* msg,\n+ uint8_t* partialIV, uint8_t partialIVLen,\n+ uint8_t* kid,\n+ uint8_t kidLen) {\n+ // ciphertext is already encoded and of length msg->length\n+ uint8_t kidFlag;\n+\n+ if (kidLen != 0) {\n+ kidFlag = 1;\n+ }\n+ else {\n+ kidFlag = 0;\n+ }\n+\n+ if (kidFlag) {\n+ packetfunctions_reserveHeaderSize(msg, kidLen + 1);\n+ msg->payload[0] = kidLen;\n+ memcpy(&msg->payload[1], kid, kidLen);\n+ }\n+\n+ if (partialIVLen) {\n+ packetfunctions_reserveHeaderSize(msg, partialIVLen);\n+ memcpy(&msg->payload[0], partialIV, partialIVLen);\n+ }\n+ // flag byte\n+ packetfunctions_reserveHeaderSize(msg, 1);\n+ msg->payload[0] = ((kidFlag << 3) | partialIVLen);\n+}\n+\n+\nvoid xor_arrays(uint8_t* s1, uint8_t* s2, uint8_t* dst, uint8_t len) {\nuint8_t i;\nfor (i = 0; i < len; i++) {\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -712,6 +712,7 @@ functionsToChange = [\n'openoscoap_find_object_security_option',\n'openoscoap_get_sequence_number',\n'openoscoap_protect_message',\n+ 'openoscoap_encode_compressed_COSE',\n# openudp\n'openudp_init',\n'openudp_send',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Implement compressed COSE encoding of OSCOAP.
491,609
25.06.2017 13:01:58
-7,200
5ed0ae5c9b30fe30b1961d75c20f40299bdff992
Rewrite construct_aad to encode last element of Encrypt0 as byte string.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "//=========================== defines =========================================\n-#define AAD_CONST_LEN 19\n+\n+#define EAAD_MAX_LEN 9 + OSCOAP_MAX_ID_LEN // assumes no Class I options\n+#define AAD_MAX_LEN 12 + EAAD_MAX_LEN\n+\n//=========================== variables =======================================\nopenoscoap_vars_t openoscoap_vars;\n@@ -158,7 +161,7 @@ owerror_t openoscoap_protect_message(\nuint8_t* payload;\nuint8_t payloadLen;\n- uint8_t aad[AAD_CONST_LEN + OSCOAP_MAX_ID_LEN]; // assumes no CLASS I options\n+ uint8_t aad[AAD_MAX_LEN];\nuint8_t aadLen;\nuint8_t nonce[AES_CCM_16_64_128_IV_LEN];\nuint8_t partialIV[AES_CCM_16_64_128_IV_LEN];\n@@ -221,7 +224,7 @@ owerror_t openoscoap_protect_message(\nrequestSeq,\nrequestSeqLen);\n- if (aadLen > AAD_CONST_LEN + OSCOAP_MAX_ID_LEN) {\n+ if (aadLen > AAD_MAX_LEN) {\n// corruption\nopenserial_printError(\nCOMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n@@ -350,25 +353,41 @@ uint8_t construct_aad(uint8_t* buffer,\nuint8_t requestSeqLen\n) {\nuint8_t* ptr;\n- ptr = buffer;\n+ uint8_t externalAAD[EAAD_MAX_LEN];\n+ uint8_t externalAADLen;\nuint8_t ret;\nconst uint8_t encrypt0[] = \"Encrypt0\";\nret = 0;\n+ externalAADLen = 0;\n+\n+ ptr = externalAAD;\n+ externalAADLen += cborencoder_put_array(&ptr, 6);\n+ externalAADLen += cborencoder_put_unsigned(&ptr, version);\n+ externalAADLen += cborencoder_put_unsigned(&ptr, code);\n+ externalAADLen += cborencoder_put_bytes(&ptr, optionsSerializedLen, optionsSerialized);\n+ externalAADLen += cborencoder_put_unsigned(&ptr, aeadAlgorithm);\n+ externalAADLen += cborencoder_put_bytes(&ptr, requestKidLen, requestKid);\n+ externalAADLen += cborencoder_put_bytes(&ptr, requestSeqLen, requestSeq);\n+\n+ if (externalAADLen > EAAD_MAX_LEN) {\n+ // corruption\n+ openserial_printError(\n+ COMPONENT_OPENOSCOAP,ERR_BUFFER_OVERFLOW,\n+ (errorparameter_t)0,\n+ (errorparameter_t)0\n+ );\n+ return 0;\n+ }\n+ ptr = buffer;\nret += cborencoder_put_array(&ptr, 3); // COSE Encrypt0 structure with 3 elements\n// first element: \"Encrypt0\"\nret += cborencoder_put_text(&ptr, (char *) encrypt0, sizeof(encrypt0) - 1);\n// second element: empty byte string\nret += cborencoder_put_bytes(&ptr, 0, NULL);\n// third element: external AAD from OSCOAP\n- ret += cborencoder_put_array(&ptr, 6);\n- ret += cborencoder_put_unsigned(&ptr, version);\n- ret += cborencoder_put_unsigned(&ptr, code);\n- ret += cborencoder_put_bytes(&ptr, optionsSerializedLen, optionsSerialized);\n- ret += cborencoder_put_unsigned(&ptr, aeadAlgorithm);\n- ret += cborencoder_put_bytes(&ptr, requestKidLen, requestKid);\n- ret += cborencoder_put_bytes(&ptr, requestSeqLen, requestSeq);\n+ ret += cborencoder_put_bytes(&ptr, externalAADLen, externalAAD);\nreturn ret;\n}\n" }, { "change_type": "MODIFY", "old_path": "projects/python/SConscript.env", "new_path": "projects/python/SConscript.env", "diff": "@@ -713,6 +713,7 @@ functionsToChange = [\n'openoscoap_get_sequence_number',\n'openoscoap_protect_message',\n'openoscoap_encode_compressed_COSE',\n+ 'construct_aad',\n# openudp\n'openudp_init',\n'openudp_send',\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Rewrite construct_aad to encode last element of Encrypt0 as byte string.
491,609
26.06.2017 10:02:46
-7,200
0bd39b3dd941232df1714a4df71542d6c5c560b5
Move object security option setting to oscoap.
[ { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.c", "new_path": "openapps/opencoap/opencoap.c", "diff": "@@ -461,25 +461,10 @@ owerror_t opencoap_send(\nuint16_t token;\nuint8_t tokenPos=0;\ncoap_header_iht* request;\n- coap_option_iht* objectSecurity;\n- bool securityActivated;\n- bool payloadPresent;\nowerror_t ret;\ncoap_option_class_t class;\nclass = COAP_OPTION_CLASS_ALL;\n- payloadPresent = FALSE;\n-\n- if (descSender->securityContext != NULL) { // security activated for the resource\n- securityActivated = TRUE;\n- objectSecurity = opencoap_find_object_security_option(options, optionsLen);\n- if (objectSecurity == NULL) { // objectSecurity option should be set by the application\n- return E_FAIL;\n- }\n- }\n- else {\n- securityActivated = FALSE;\n- }\n// increment the (global) messageID\nif (opencoap_vars.messageID++ == 0xffff) {\n@@ -505,11 +490,7 @@ owerror_t opencoap_send(\ntokenPos+=2;\n}\n- if (msg->length > 0 ) { // contains payload\n- payloadPresent = TRUE;\n- }\n-\n- if (securityActivated) {\n+ if (descSender->securityContext != NULL) { // security activated for the resource\n// get new sequence number and save it\nrequest->oscoapSeqNum = openoscoap_get_sequence_number(descSender->securityContext);\n// protect the message in the openqueue buffer\n@@ -525,20 +506,7 @@ owerror_t opencoap_send(\nif (ret != E_SUCCESS) {\nreturn E_FAIL;\n}\n-\nclass = COAP_OPTION_CLASS_U;\n-\n- if (payloadPresent) {\n- objectSecurity->length = 0;\n- objectSecurity->pValue = NULL;\n- }\n- else {\n- objectSecurity->length = msg->length;\n- // FIXME use the upper bytes in the msg->packet buffer to avoid huge allocation on stack\n- memcpy(&msg->packet[0], &msg->payload[0], msg->length);\n- objectSecurity->pValue = &msg->packet[0];\n- packetfunctions_tossHeader(msg, msg->length); // reset packet to zero as objectSecurity option will cary payload\n- }\n}\n// fake run of opencoap_options_encode in order to get the necessary length\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/opencoap.h", "new_path": "openapps/opencoap/opencoap.h", "diff": "@@ -193,7 +193,7 @@ uint8_t opencoap_options_encode(uint8_t* buffer,\nuint8_t optionsLen,\ncoap_option_class_t class,\nbool fake);\n-\n+coap_option_iht* opencoap_find_object_security_option(coap_option_iht* array, uint8_t arrayLen);\n/**\n\\}\n" }, { "change_type": "MODIFY", "old_path": "openapps/opencoap/openoscoap.c", "new_path": "openapps/opencoap/openoscoap.c", "diff": "@@ -170,6 +170,14 @@ owerror_t openoscoap_protect_message(\nuint8_t *requestKid;\nuint8_t requestKidLen;\nowerror_t encStatus;\n+ coap_option_iht* objectSecurity;\n+ bool payloadPresent;\n+\n+ // find object security option in the list of passed options\n+ objectSecurity = opencoap_find_object_security_option(options, optionsLen);\n+ if (objectSecurity == NULL) { // objectSecurity option should be set by the application\n+ return E_FAIL;\n+ }\n// convert sequence number to array and strip leading zeros\nmemset(partialIV, 0x00, AES_CCM_16_64_128_IV_LEN);\n@@ -187,9 +195,13 @@ owerror_t openoscoap_protect_message(\nrequestKidLen = context->senderIDLen;\nif (msg->length > 0 ) { // contains payload, add payload marker\n+ payloadPresent = TRUE;\npacketfunctions_reserveHeaderSize(msg,1);\nmsg->payload[0] = COAP_PAYLOAD_MARKER;\n}\n+ else {\n+ payloadPresent = FALSE;\n+ }\n// fake run of opencoap_options_encode in order to get the necessary length\npacketfunctions_reserveHeaderSize(msg, opencoap_options_encode(NULL,\n@@ -261,9 +273,24 @@ owerror_t openoscoap_protect_message(\nreturn E_FAIL;\n}\n- // TODO encode compressed COSE\n+ // encode compressed COSE\nopenoscoap_encode_compressed_COSE(msg, requestSeq, requestSeqLen, requestKid, requestKidLen);\n+\n+ if (payloadPresent) {\n+ // set the object security option to 0 length\n+ // as the value will be carried in message payload\n+ objectSecurity->length = 0;\n+ objectSecurity->pValue = NULL;\n+ }\n+ else {\n+ objectSecurity->length = msg->length;\n+ // FIXME use the upper bytes in the msg->packet buffer\n+ memcpy(&msg->packet[0], &msg->payload[0], msg->length);\n+ objectSecurity->pValue = &msg->packet[0];\n+ packetfunctions_tossHeader(msg, msg->length); // reset packet to zero as objectSecurity option will cary payload\n+ }\n+\nreturn E_SUCCESS;\n}\n" } ]
C
BSD 3-Clause New or Revised License
openwsn-berkeley/openwsn-fw
FW-651. Move object security option setting to oscoap.