mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 09:33:50 +01:00
19335: ipv6/nib: 6LBR should not send RS on their downstream interface r=fabian18 a=fabian18
19581: cpu/samd5x: enable FDPLL1 at 200MHz r=benpicco a=dylad
### Contribution description
This PR allows to use the second FDPLL (the first one is used to generated the 120MHz frequency used by the core and some peripherals). The second FDPLL is setup to run at 200MHz which is the maximum allowed by this MCU.
In fact, I reused the existing function which setup FDPLL0 so it can be used in a generic way for both PLL (since they are the same IP).
I change the way the computation offset (left shift by 5) is done because 200MHz << 5 wouldn't fit inside an `uint32_t` and I wanted to avoid using an `uint64_t` here
Two additional commits are present for a small cleanup and a fix.
This is currently unused in our codebase, so it shouldn't impact this platform too much as the `ONDEMAND` bit is set. the FDPLL will not be running out of the box. But `@gschorcht` might need it pretty soon.
### Testing procedure
This PR can be tested on a `same54-xpro` and an oscilloscope using the following the patch:
```
From 76490845ec72387b24116bdd364a61365c186aa1 Mon Sep 17 00:00:00 2001
From: Dylan Laduranty <dylan.laduranty@mesotic.com>
Date: Thu, 11 May 2023 17:42:16 +0200
Subject: [PATCH] removeme! for debug purpose
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
---
cpu/samd5x/cpu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cpu/samd5x/cpu.c b/cpu/samd5x/cpu.c
index f778991a5b..2866c8c9e5 100644
--- a/cpu/samd5x/cpu.c
+++ b/cpu/samd5x/cpu.c
`@@` -220,7 +220,7 `@@` static void fdpll_init(uint8_t idx, uint32_t f_cpu)
}
static void gclk_connect(uint8_t id, uint8_t src, uint32_t flags) {
- GCLK->GENCTRL[id].reg = GCLK_GENCTRL_SRC(src) | GCLK_GENCTRL_GENEN | flags | GCLK_GENCTRL_IDC;
+ GCLK->GENCTRL[id].reg = GCLK_GENCTRL_SRC(src) | GCLK_GENCTRL_GENEN | flags | GCLK_GENCTRL_OE | GCLK_GENCTRL_IDC;
while (GCLK->SYNCBUSY.reg & GCLK_SYNCBUSY_GENCTRL(id)) {}
}
`@@` -384,6 +384,12 `@@` void cpu_init(void)
dma_init();
#endif
+ sam0_gclk_enable(SAM0_GCLK_200MHZ);
+ /* output both FDPLL (GCLK0 and GCLK4) to gpios */
+ gpio_init_mux(GPIO_PIN(PB, 14), GPIO_MUX_M);
+ gpio_init_mux(GPIO_PIN(PB, 10), GPIO_MUX_M);
+ /* PB14 -> EXT2 PB10 -> QSPI SCK */
+
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
early_init();
--
2.35.3
```
It will output both FDPLLs to PB14 and PB10. Their frequency can then be measured using an oscilloscope.
### Issues/PRs references
None.
19612: pkg/ndn-riot: drop unmaintained pkg r=benpicco a=maribu
### Contribution description
Upstream [1] has seen no activity since 2018, so it safe to assume this is dead. It is reasonable to assume that any users - if there ever were any - have moved on.
Fixes https://github.com/RIOT-OS/RIOT/issues/15638
[1]: https://github.com/named-data-iot/ndn-riot
19643: examples/suit_update: some test fixes r=aabadie a=kaspar030
19655: net/ipv6: make use of clz in ipv6_addr_match_prefix() r=benpicco a=benpicco
Co-authored-by: Fabian Hüßler <fabian.huessler@st.ovgu.de>
Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
This commit is contained in:
commit
3469fce248
@ -165,6 +165,30 @@ static inline unsigned bitarithm_msb(unsigned v)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of leading 0-bits in @p x, starting at the most
|
||||
* significant bit position.
|
||||
* If x is 0, the result is undefined.
|
||||
*
|
||||
* @param[in] x Input value
|
||||
* @return Number of leading zero bits
|
||||
*/
|
||||
static inline uint8_t bitarithm_clzb(uint8_t x)
|
||||
{
|
||||
#if defined(BITARITHM_HAS_CLZ)
|
||||
/* clz operates on `unsigned int`, so `x` will be promoted to the size
|
||||
of an `unsigned int` */
|
||||
return __builtin_clz(x) - 8 * (sizeof(unsigned) - 1);
|
||||
#else
|
||||
uint8_t l = 0;
|
||||
while (!(x & 0x80)) {
|
||||
++l;
|
||||
x <<= 1;
|
||||
}
|
||||
return l;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
|
||||
@ -34,14 +34,6 @@
|
||||
#define USE_VREG_BUCK (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* An external inductor needs to be present on the board,
|
||||
* so the feature can only be enabled by the board configuration.
|
||||
*/
|
||||
#ifndef USE_VREG_BUCK
|
||||
#define USE_VREG_BUCK (0)
|
||||
#endif
|
||||
|
||||
#if CLOCK_CORECLOCK == 0
|
||||
#error Please select CLOCK_CORECLOCK
|
||||
#endif
|
||||
@ -191,37 +183,43 @@ static void dfll_init(void)
|
||||
while (!OSCCTRL->STATUS.bit.DFLLRDY) {}
|
||||
}
|
||||
|
||||
static void fdpll0_init(uint32_t f_cpu)
|
||||
static void fdpll_init_nolock(uint8_t idx, uint32_t f_cpu, uint8_t flags)
|
||||
{
|
||||
/* Trigger assertion if not using FDPLL0 or FDPLL1 */
|
||||
assert(idx == 0 || idx == 1);
|
||||
|
||||
if (!USE_DPLL) {
|
||||
OSCCTRL->Dpll[0].DPLLCTRLA.reg = 0;
|
||||
OSCCTRL->Dpll[idx].DPLLCTRLA.reg = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* We source the DPLL from 32kHz GCLK1 */
|
||||
const uint32_t LDR = ((f_cpu << 5) / 32768);
|
||||
/* Source the DPLL from 32kHz GCLK1 ( equivalent to ((f_cpu << 5) / 32768) ) */
|
||||
const uint32_t LDR = (f_cpu >> 10);
|
||||
|
||||
/* disable the DPLL before changing the configuration */
|
||||
OSCCTRL->Dpll[0].DPLLCTRLA.bit.ENABLE = 0;
|
||||
while (OSCCTRL->Dpll[0].DPLLSYNCBUSY.reg) {}
|
||||
OSCCTRL->Dpll[idx].DPLLCTRLA.bit.ENABLE = 0;
|
||||
while (OSCCTRL->Dpll[idx].DPLLSYNCBUSY.reg) {}
|
||||
|
||||
/* set DPLL clock source */
|
||||
GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL0].reg = GCLK_PCHCTRL_GEN(1) | GCLK_PCHCTRL_CHEN;
|
||||
while (!(GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL0].reg & GCLK_PCHCTRL_CHEN)) {}
|
||||
GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL0 + idx].reg = GCLK_PCHCTRL_GEN(1) | GCLK_PCHCTRL_CHEN;
|
||||
while (!(GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL0 + idx].reg & GCLK_PCHCTRL_CHEN)) {}
|
||||
|
||||
OSCCTRL->Dpll[0].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(LDR & 0x1F)
|
||||
| OSCCTRL_DPLLRATIO_LDR((LDR >> 5) - 1);
|
||||
OSCCTRL->Dpll[idx].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(LDR & 0x1F)
|
||||
| OSCCTRL_DPLLRATIO_LDR((LDR >> 5) - 1);
|
||||
|
||||
/* Without LBYPASS, startup takes very long, see errata section 2.13. */
|
||||
OSCCTRL->Dpll[0].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK_GCLK
|
||||
| OSCCTRL_DPLLCTRLB_WUF
|
||||
| OSCCTRL_DPLLCTRLB_LBYPASS;
|
||||
OSCCTRL->Dpll[idx].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK_GCLK
|
||||
| OSCCTRL_DPLLCTRLB_WUF
|
||||
| OSCCTRL_DPLLCTRLB_LBYPASS;
|
||||
|
||||
OSCCTRL->Dpll[0].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_ENABLE;
|
||||
OSCCTRL->Dpll[idx].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_ENABLE | flags;
|
||||
|
||||
while (OSCCTRL->Dpll[0].DPLLSYNCBUSY.reg) {}
|
||||
while (!(OSCCTRL->Dpll[0].DPLLSTATUS.bit.CLKRDY &&
|
||||
OSCCTRL->Dpll[0].DPLLSTATUS.bit.LOCK)) {}
|
||||
while (OSCCTRL->Dpll[idx].DPLLSYNCBUSY.reg) {}
|
||||
}
|
||||
|
||||
static void fdpll_lock(uint8_t idx) {
|
||||
while (!(OSCCTRL->Dpll[idx].DPLLSTATUS.bit.CLKRDY &&
|
||||
OSCCTRL->Dpll[idx].DPLLSTATUS.bit.LOCK)) {}
|
||||
}
|
||||
|
||||
static void gclk_connect(uint8_t id, uint8_t src, uint32_t flags) {
|
||||
@ -256,7 +254,11 @@ void sam0_gclk_enable(uint8_t id)
|
||||
} else if (USE_XOSC) {
|
||||
gclk_connect(SAM0_GCLK_PERIPH, GCLK_SOURCE_ACTIVE_XOSC, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case SAM0_GCLK_200MHZ:
|
||||
fdpll_init_nolock(1, MHZ(200), OSCCTRL_DPLLCTRLA_ONDEMAND);
|
||||
gclk_connect(SAM0_GCLK_200MHZ, GCLK_SOURCE_DPLL1, 0);
|
||||
fdpll_lock(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -279,6 +281,8 @@ uint32_t sam0_gclk_freq(uint8_t id)
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
case SAM0_GCLK_200MHZ:
|
||||
return MHZ(200);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -354,12 +358,13 @@ void cpu_init(void)
|
||||
|
||||
xosc_init(0);
|
||||
xosc_init(1);
|
||||
fdpll0_init(CLOCK_CORECLOCK * DPLL_DIV);
|
||||
|
||||
/* select the source of the main clock */
|
||||
if (USE_DPLL) {
|
||||
fdpll_init_nolock(0, CLOCK_CORECLOCK * DPLL_DIV, OSCCTRL_DPLLCTRLA_ONDEMAND);
|
||||
gclk_connect(SAM0_GCLK_MAIN, GCLK_SOURCE_DPLL0,
|
||||
GCLK_GENCTRL_DIV(DPLL_DIV));
|
||||
fdpll_lock(0);
|
||||
} else if (USE_DFLL) {
|
||||
gclk_connect(SAM0_GCLK_MAIN, GCLK_SOURCE_DFLL,
|
||||
GCLK_GENCTRL_DIV(SAM0_DFLL_FREQ_HZ / CLOCK_CORECLOCK));
|
||||
|
||||
@ -47,7 +47,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief DPLL frequency must not exceed 200 MHz
|
||||
*/
|
||||
#define SAM0_DPLL_FREQ_MAX_HZ MHZ(20)
|
||||
#define SAM0_DPLL_FREQ_MAX_HZ MHZ(200)
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
@ -65,6 +65,7 @@ enum {
|
||||
SAM0_GCLK_32KHZ, /**< 32 kHz clock */
|
||||
SAM0_GCLK_TIMER, /**< 4-8 MHz clock for xTimer */
|
||||
SAM0_GCLK_PERIPH, /**< 12-48 MHz (DFLL) clock */
|
||||
SAM0_GCLK_200MHZ, /**< 200MHz FDPLL clock */
|
||||
};
|
||||
/** @} */
|
||||
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
# name of your application
|
||||
APPLICATION = ndn_ping
|
||||
|
||||
# If no BOARD is found in the environment, use this default:
|
||||
BOARD ?= native
|
||||
|
||||
# This has to be the absolute path to the RIOT base directory:
|
||||
RIOTBASE ?= $(CURDIR)/../../
|
||||
|
||||
# Include packages that pull up and auto-init the link layer.
|
||||
USEMODULE += netdev_default
|
||||
USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += random
|
||||
USEMODULE += shell_cmds_default
|
||||
|
||||
USEPKG += ndn-riot
|
||||
|
||||
# Comment this out to disable code in RIOT that does safety checking
|
||||
# which is not needed in a production environment but helps in the
|
||||
# development process:
|
||||
DEVELHELP ?= 1
|
||||
|
||||
# Change this to 0 show compiler invocation lines by default:
|
||||
QUIET ?= 1
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
@ -1,32 +0,0 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atxmega-a3bu-xplained \
|
||||
bluepill-stm32f030c8 \
|
||||
i-nucleo-lrwan1 \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
nucleo-f030r8 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
samd10-xmini \
|
||||
slstk3400a \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32g0316-disco \
|
||||
stm32l0538-disco \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
weio \
|
||||
z1 \
|
||||
zigduino \
|
||||
#
|
||||
@ -1,49 +0,0 @@
|
||||
# ndn-ping
|
||||
|
||||
This application demonstrates the usage of the package ndn-riot.
|
||||
This example basically enables the user to setup a ndn data server, and a ndn client that can request the data.
|
||||
Any board with a default netdev can be used to run this example.
|
||||
|
||||
# Setting up for native
|
||||
|
||||
Create `tap` and `tapbr` devices using RIOT's `tapsetup` script before stating the application:
|
||||
```bash
|
||||
sudo ./RIOTDIR/dist/tools/tapsetup/tapsetup
|
||||
```
|
||||
|
||||
Then run the application on 2 different terminals :
|
||||
```bash
|
||||
# on the first terminal
|
||||
make PORT=tap0 term
|
||||
# on the second terminal
|
||||
make PORT=tap1 term
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
The user can run shell commands (type "help" to see the list).
|
||||
Only one command is relative to ndn : `ndnping`.
|
||||
|
||||
## Start a server
|
||||
|
||||
```
|
||||
ndnping server name_uri server_id
|
||||
```
|
||||
|
||||
Replace `name_uri` by a ndn name (for example `/test`), and `server_id` by a number.
|
||||
`server_id` will be appended to the name of the data sent by the server.
|
||||
This can help when several servers are running using the same `name_uri`, but is not useful in our example.
|
||||
|
||||
A server will start and answer to any interest message matching the name.
|
||||
|
||||
## Start a client
|
||||
|
||||
```
|
||||
ndnping client name_uri max_count
|
||||
```
|
||||
|
||||
Replace `name_uri` by a ndn name, and `max_count` by a number.
|
||||
`max_count` is the number of interest message that will be sent.
|
||||
|
||||
A client will start, send a first interest message and wait for a data message.
|
||||
Once data is received or timeout is reached, the client can send the next interest message, or stop when the last interest have been sent.
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Wentao Shang
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief NDN ping application
|
||||
*
|
||||
* @author Wentao Shang <wentaoshang@gmail.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ndn-riot/ndn.h"
|
||||
#include "shell.h"
|
||||
#include "msg.h"
|
||||
|
||||
extern int ndn_ping(int argc, char **argv);
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "ndnping", "start ndn-ping client and server", ndn_ping },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* start shell */
|
||||
puts("All up, running the shell now");
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
/* should be never reached */
|
||||
return 0;
|
||||
}
|
||||
@ -1,328 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Wentao Shang
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup examples
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief NDN ping client and server implementation
|
||||
*
|
||||
* @author Wentao Shang <wentaoshang@gmail.com>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "random.h"
|
||||
#include "test_utils/expect.h"
|
||||
|
||||
#include "ndn-riot/app.h"
|
||||
#include "ndn-riot/ndn.h"
|
||||
#include "ndn-riot/encoding/name.h"
|
||||
#include "ndn-riot/encoding/interest.h"
|
||||
#include "ndn-riot/encoding/data.h"
|
||||
#include "ndn-riot/msg-type.h"
|
||||
|
||||
static ndn_app_t* handle = NULL;
|
||||
|
||||
static const uint8_t ecc_key_pri[] = {
|
||||
0x38, 0x67, 0x54, 0x73, 0x8B, 0x72, 0x4C, 0xD6,
|
||||
0x3E, 0xBD, 0x52, 0xF3, 0x64, 0xD8, 0xF5, 0x7F,
|
||||
0xB5, 0xE6, 0xF2, 0x9F, 0xC2, 0x7B, 0xD6, 0x90,
|
||||
0x42, 0x9D, 0xC8, 0xCE, 0xF0, 0xDE, 0x75, 0xB3
|
||||
};
|
||||
|
||||
static const uint8_t ecc_key_pub[] = {
|
||||
0x2C, 0x3C, 0x18, 0xCB, 0x31, 0x88, 0x0B, 0xC3,
|
||||
0x73, 0xF4, 0x4A, 0xD4, 0x3F, 0x8C, 0x80, 0x24,
|
||||
0xD4, 0x8E, 0xBE, 0xB4, 0xAD, 0xF0, 0x69, 0xA6,
|
||||
0xFE, 0x29, 0x12, 0xAC, 0xC1, 0xE1, 0x26, 0x7E,
|
||||
0x2B, 0x25, 0x69, 0x02, 0xD5, 0x85, 0x51, 0x4B,
|
||||
0x91, 0xAC, 0xB9, 0xD1, 0x19, 0xE9, 0x5E, 0x97,
|
||||
0x20, 0xBB, 0x16, 0x2A, 0xD3, 0x2F, 0xB5, 0x11,
|
||||
0x1B, 0xD1, 0xAF, 0x76, 0xDB, 0xAD, 0xB8, 0xCE
|
||||
};
|
||||
|
||||
static int on_data(ndn_block_t* interest, ndn_block_t* data)
|
||||
{
|
||||
(void)interest;
|
||||
|
||||
ndn_block_t name;
|
||||
int r = ndn_data_get_name(data, &name);
|
||||
expect(r == 0);
|
||||
printf("client (pid=%" PRIkernel_pid "): data received, name=",
|
||||
handle->id);
|
||||
ndn_name_print(&name);
|
||||
putchar('\n');
|
||||
|
||||
ndn_block_t content;
|
||||
r = ndn_data_get_content(data, &content);
|
||||
expect(r == 0);
|
||||
expect(content.len == 6);
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): content=%02X%02X%02X%02X\n",
|
||||
handle->id, *(content.buf + 2), *(content.buf + 3),
|
||||
*(content.buf + 4), *(content.buf + 5));
|
||||
|
||||
r = ndn_data_verify_signature(data, ecc_key_pub, sizeof(ecc_key_pub));
|
||||
|
||||
if (r != 0) {
|
||||
printf("client (pid=%" PRIkernel_pid "): fail to verify signature\n",
|
||||
handle->id);
|
||||
}
|
||||
else {
|
||||
printf("client (pid=%" PRIkernel_pid "): signature valid\n",
|
||||
handle->id);
|
||||
}
|
||||
|
||||
return NDN_APP_CONTINUE;
|
||||
}
|
||||
|
||||
static int on_timeout(ndn_block_t* interest)
|
||||
{
|
||||
ndn_block_t name;
|
||||
int r = ndn_interest_get_name(interest, &name);
|
||||
expect(r == 0);
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): interest timeout, name=",
|
||||
handle->id);
|
||||
ndn_name_print(&name);
|
||||
putchar('\n');
|
||||
|
||||
return NDN_APP_CONTINUE;
|
||||
}
|
||||
|
||||
static uint16_t count = 0;
|
||||
static uint16_t max_count;
|
||||
|
||||
static int send_interest(void* context)
|
||||
{
|
||||
const char* uri = (const char*)context;
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): in sched callback, count=%d\n",
|
||||
handle->id, ++count);
|
||||
if (count > max_count) {
|
||||
/* This is pure hack: ideally should wait for all pending I/O requests
|
||||
* to finish before stopping the app. However, this may cause the app
|
||||
* to block forever if not implemented very carefully. */
|
||||
printf("client (pid=%" PRIkernel_pid "): stop the app\n", handle->id);
|
||||
return NDN_APP_STOP;
|
||||
}
|
||||
|
||||
ndn_shared_block_t* sn = ndn_name_from_uri(uri, strlen(uri));
|
||||
if (sn == NULL) {
|
||||
printf("client (pid=%" PRIkernel_pid "): cannot create name from uri "
|
||||
"\"%s\"\n", handle->id, uri);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
uint32_t rand = random_uint32();
|
||||
ndn_shared_block_t* sin = ndn_name_append_uint32(&sn->block, rand);
|
||||
ndn_shared_block_release(sn);
|
||||
if (sin == NULL) {
|
||||
printf("client (pid=%" PRIkernel_pid "): cannot append component to "
|
||||
"name \"%s\"\n", handle->id, uri);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
uint32_t lifetime = 1000; // 1 sec
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): express interest, name=",
|
||||
handle->id);
|
||||
ndn_name_print(&sin->block);
|
||||
putchar('\n');
|
||||
|
||||
if (ndn_app_express_interest(handle, &sin->block, NULL, lifetime,
|
||||
on_data, on_timeout) != 0) {
|
||||
printf("client (pid=%" PRIkernel_pid "): failed to express interest\n",
|
||||
handle->id);
|
||||
ndn_shared_block_release(sin);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
ndn_shared_block_release(sin);
|
||||
|
||||
if (ndn_app_schedule(handle, send_interest, context, 2000000) != 0) {
|
||||
printf("client (pid=%" PRIkernel_pid "): cannot schedule next interest"
|
||||
"\n", handle->id);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
printf("client (pid=%" PRIkernel_pid "): schedule next interest in 2 sec"
|
||||
"\n", handle->id);
|
||||
|
||||
return NDN_APP_CONTINUE;
|
||||
}
|
||||
|
||||
static void run_client(const char* uri, int max_cnt)
|
||||
{
|
||||
printf("client (pid=%" PRIkernel_pid "): start\n", thread_getpid());
|
||||
|
||||
handle = ndn_app_create();
|
||||
if (handle == NULL) {
|
||||
printf("client (pid=%" PRIkernel_pid "): cannot create app handle\n",
|
||||
thread_getpid());
|
||||
return;
|
||||
}
|
||||
|
||||
max_count = max_cnt;
|
||||
count = 0;
|
||||
|
||||
if (ndn_app_schedule(handle, send_interest, (void*)uri, 1000000) != 0) {
|
||||
printf("client (pid=%" PRIkernel_pid "): cannot schedule first "
|
||||
"interest\n", handle->id);
|
||||
ndn_app_destroy(handle);
|
||||
return;
|
||||
}
|
||||
printf("client (pid=%" PRIkernel_pid "): schedule first interest in 1 sec"
|
||||
"\n", handle->id);
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): enter app run loop\n",
|
||||
handle->id);
|
||||
|
||||
ndn_app_run(handle);
|
||||
|
||||
printf("client (pid=%" PRIkernel_pid "): returned from app run loop\n",
|
||||
handle->id);
|
||||
|
||||
ndn_app_destroy(handle);
|
||||
}
|
||||
|
||||
static uint8_t sid = 0;
|
||||
|
||||
static int on_interest(ndn_block_t* interest)
|
||||
{
|
||||
ndn_block_t in;
|
||||
if (ndn_interest_get_name(interest, &in) != 0) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot get name from interest"
|
||||
"\n", handle->id);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): interest received, name=",
|
||||
handle->id);
|
||||
ndn_name_print(&in);
|
||||
putchar('\n');
|
||||
|
||||
ndn_shared_block_t* sdn = ndn_name_append_uint8(&in, sid);
|
||||
if (sdn == NULL) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot append component to "
|
||||
"name\n", handle->id);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
ndn_metainfo_t meta = { NDN_CONTENT_TYPE_BLOB, -1 };
|
||||
|
||||
uint32_t rand = random_uint32();
|
||||
uint8_t* buf = (uint8_t*)(&rand);
|
||||
ndn_block_t content = { buf, sizeof(rand) };
|
||||
|
||||
ndn_shared_block_t* sd =
|
||||
ndn_data_create(&sdn->block, &meta, &content,
|
||||
NDN_SIG_TYPE_ECDSA_SHA256, NULL,
|
||||
ecc_key_pri, sizeof(ecc_key_pri));
|
||||
if (sd == NULL) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot create data block\n",
|
||||
handle->id);
|
||||
ndn_shared_block_release(sdn);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): send data to NDN thread, name=",
|
||||
handle->id);
|
||||
ndn_name_print(&sdn->block);
|
||||
putchar('\n');
|
||||
ndn_shared_block_release(sdn);
|
||||
|
||||
/* pass ownership of "sd" to the API */
|
||||
if (ndn_app_put_data(handle, sd) != 0) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot put data\n",
|
||||
handle->id);
|
||||
return NDN_APP_ERROR;
|
||||
}
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): return to the app\n", handle->id);
|
||||
return NDN_APP_CONTINUE;
|
||||
}
|
||||
|
||||
static void run_server(const char* prefix, int id)
|
||||
{
|
||||
printf("server (pid=%" PRIkernel_pid "): start\n", thread_getpid());
|
||||
|
||||
handle = ndn_app_create();
|
||||
if (handle == NULL) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot create app handle\n",
|
||||
thread_getpid());
|
||||
return;
|
||||
}
|
||||
sid = (uint8_t)id;
|
||||
|
||||
ndn_shared_block_t* sp = ndn_name_from_uri(prefix, strlen(prefix));
|
||||
if (sp == NULL) {
|
||||
printf("server (pid=%" PRIkernel_pid "): cannot create name from uri "
|
||||
"\"%s\"\n", handle->id, prefix);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): register prefix \"%s\"\n",
|
||||
handle->id, prefix);
|
||||
/* pass ownership of "sp" to the API */
|
||||
if (ndn_app_register_prefix(handle, sp, on_interest) != 0) {
|
||||
printf("server (pid=%" PRIkernel_pid "): failed to register prefix\n",
|
||||
handle->id);
|
||||
ndn_app_destroy(handle);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): enter app run loop\n",
|
||||
handle->id);
|
||||
|
||||
ndn_app_run(handle);
|
||||
|
||||
printf("server (pid=%" PRIkernel_pid "): returned from app run loop\n",
|
||||
handle->id);
|
||||
|
||||
ndn_app_destroy(handle);
|
||||
}
|
||||
|
||||
int ndn_ping(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: %s [client|server]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "client") == 0) {
|
||||
if (argc < 4) {
|
||||
printf("usage: %s client _name_uri_ _max_count_\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int max_cnt = atoi(argv[3]);
|
||||
if (max_cnt == 0) {
|
||||
printf("invalid max count number: %s\n", argv[3]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
run_client(argv[2], max_cnt);
|
||||
}
|
||||
else if (strcmp(argv[1], "server") == 0) {
|
||||
if (argc < 4) {
|
||||
printf("usage: %s server _prefix_ _server_id_\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
run_server(argv[2], atoi(argv[3]));
|
||||
}
|
||||
else {
|
||||
puts("error: invalid command");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -31,6 +31,9 @@ USE_ETHOS = int(os.getenv("USE_ETHOS", "1"))
|
||||
IFACE = os.getenv("IFACE", "tapbr0")
|
||||
TMPDIR = tempfile.TemporaryDirectory()
|
||||
|
||||
TRIGGER_RECEIVED_MSG = "suit_worker: started."
|
||||
REBOOTING_MSG = "suit_worker: rebooting..."
|
||||
|
||||
|
||||
def get_iface_addr(iface):
|
||||
out = subprocess.check_output(["ip", "a", "s", "dev", iface]).decode()
|
||||
@ -94,6 +97,8 @@ def wait_for_update(child):
|
||||
|
||||
def get_ipv6_addr(child):
|
||||
child.expect_exact(">")
|
||||
# give the stack some time to make the address non-tentataive
|
||||
time.sleep(2)
|
||||
child.sendline("ifconfig")
|
||||
if USE_ETHOS == 0:
|
||||
# Get device global address
|
||||
@ -176,7 +181,7 @@ def running_slot(child):
|
||||
def _test_invalid_version(child, client, app_ver):
|
||||
publish(TMPDIR.name, COAP_HOST, app_ver)
|
||||
notify(COAP_HOST, client, app_ver)
|
||||
child.expect_exact("suit_coap: trigger received")
|
||||
child.expect_exact(TRIGGER_RECEIVED_MSG)
|
||||
child.expect_exact("suit: verifying manifest signature")
|
||||
child.expect_exact("seq_nr <= running image")
|
||||
|
||||
@ -184,7 +189,7 @@ def _test_invalid_version(child, client, app_ver):
|
||||
def _test_invalid_signature(child, client, app_ver):
|
||||
publish(TMPDIR.name, COAP_HOST, app_ver + 1, "invalid_keys")
|
||||
notify(COAP_HOST, client, app_ver + 1)
|
||||
child.expect_exact("suit_coap: trigger received")
|
||||
child.expect_exact(TRIGGER_RECEIVED_MSG)
|
||||
child.expect_exact("suit: verifying manifest signature")
|
||||
child.expect_exact("Unable to validate signature")
|
||||
|
||||
@ -194,7 +199,7 @@ def _test_successful_update(child, client, app_ver):
|
||||
# Trigger update process, verify it validates manifest correctly
|
||||
publish(TMPDIR.name, COAP_HOST, version)
|
||||
notify(COAP_HOST, client, version)
|
||||
child.expect_exact("suit_coap: trigger received")
|
||||
child.expect_exact(TRIGGER_RECEIVED_MSG)
|
||||
child.expect_exact("suit: verifying manifest signature")
|
||||
child.expect(
|
||||
r"SUIT policy check OK.\r\n",
|
||||
@ -205,11 +210,10 @@ def _test_successful_update(child, client, app_ver):
|
||||
pass
|
||||
# Check successful install
|
||||
child.expect_exact("Install correct payload")
|
||||
child.expect_exact("Install correct payload")
|
||||
|
||||
# Wait for reboot on non-native BOARDs
|
||||
if BOARD != "native":
|
||||
child.expect_exact("suit_coap: rebooting...")
|
||||
child.expect_exact(REBOOTING_MSG)
|
||||
# Verify client is reachable and get address
|
||||
client = get_reachable_addr(child)
|
||||
assert seq_no(child) == version
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
PKG_NAME=ndn-riot
|
||||
PKG_URL=https://github.com/named-data-iot/ndn-riot
|
||||
PKG_VERSION=34c5eb8adf198049f0a56048825b505c561a8874
|
||||
PKG_LICENSE=LGPLv2.1
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
CFLAGS += -Wno-cast-align
|
||||
|
||||
all:
|
||||
$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)
|
||||
@ -1,12 +0,0 @@
|
||||
USEMODULE += ndn-encoding
|
||||
USEMODULE += gnrc
|
||||
USEMODULE += gnrc_nettype_ndn
|
||||
USEMODULE += ztimer_usec
|
||||
USEMODULE += random
|
||||
USEMODULE += hashes
|
||||
USEPKG += micro-ecc
|
||||
|
||||
# Blacklist platforms using nimble_netif with gnrc netif, e.g providing
|
||||
# ble_nimble: NimBLE and ndn-riot use different crypto libraries that have
|
||||
# name clashes (tinycrypt vs uECC)
|
||||
FEATURES_BLACKLIST += ble_nimble
|
||||
@ -1 +0,0 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)
|
||||
@ -1,53 +0,0 @@
|
||||
From 1534f82714a2a11bb338e14ed9dd18a24799cd38 Mon Sep 17 00:00:00 2001
|
||||
From: Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
|
||||
Date: Thu, 9 Jan 2020 11:16:38 +0100
|
||||
Subject: [PATCH] update xtimer_t struct clearing
|
||||
|
||||
---
|
||||
app.c | 2 +-
|
||||
l2.c | 2 +-
|
||||
pit.c | 2 +-
|
||||
3 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/app.c b/app.c
|
||||
index 8d37bd970af..bc4718d31b9 100644
|
||||
--- a/app.c
|
||||
+++ b/app.c
|
||||
@@ -380,7 +380,7 @@ int ndn_app_schedule(ndn_app_t* handle, ndn_app_sched_cb_t cb, void* context,
|
||||
if (entry == NULL) return -1;
|
||||
|
||||
// initialize the timer
|
||||
- entry->timer.target = entry->timer.long_target = 0;
|
||||
+ entry->timer = (xtimer_t) {0};
|
||||
|
||||
// initialize the msg struct
|
||||
entry->timer_msg.type = MSG_XTIMER;
|
||||
diff --git a/l2.c b/l2.c
|
||||
index 77d6be49cd9..a0546b5e4a2 100644
|
||||
--- a/l2.c
|
||||
+++ b/l2.c
|
||||
@@ -155,7 +155,7 @@ ndn_shared_block_t* ndn_l2_frag_receive(kernel_pid_t iface,
|
||||
entry->id = id;
|
||||
|
||||
// initialize timer
|
||||
- entry->timer.target = entry->timer.long_target = 0;
|
||||
+ entry->timer = (xtimer_t) {0};
|
||||
entry->timer_msg.type = NDN_L2_FRAG_MSG_TYPE_TIMEOUT;
|
||||
entry->timer_msg.content.ptr = (char*)(&entry->timer_msg);
|
||||
|
||||
diff --git a/pit.c b/pit.c
|
||||
index 644cf089d9c..692105ea1ed 100644
|
||||
--- a/pit.c
|
||||
+++ b/pit.c
|
||||
@@ -155,7 +155,7 @@ int ndn_pit_add(kernel_pid_t face_id, int face_type, ndn_shared_block_t* si,
|
||||
*pit_entry = entry;
|
||||
|
||||
/* initialize the timer */
|
||||
- entry->timer.target = entry->timer.long_target = 0;
|
||||
+ entry->timer = (xtimer_t) {0};
|
||||
|
||||
/* initialize the msg struct */
|
||||
entry->timer_msg.type = NDN_PIT_MSG_TYPE_TIMEOUT;
|
||||
--
|
||||
2.25.0
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
From 43da6ef67dea118695d6b1dd2542ce1f199956e8 Mon Sep 17 00:00:00 2001
|
||||
From: Jose Alamos <jose.alamos@haw-hamburg.de>
|
||||
Date: Tue, 24 Mar 2020 14:29:26 +0100
|
||||
Subject: [PATCH] ndn-riot: add MAX_GNRC_NETIFS macro
|
||||
|
||||
---
|
||||
netif.c | 6 +++---
|
||||
netif.h | 7 +++++++
|
||||
2 files changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/netif.c b/netif.c
|
||||
index 5e24c6d..7e3edb9 100644
|
||||
--- a/netif.c
|
||||
+++ b/netif.c
|
||||
@@ -29,12 +29,12 @@
|
||||
#include <random.h>
|
||||
#include <thread.h>
|
||||
|
||||
-static ndn_netif_t _netif_table[GNRC_NETIF_NUMOF];
|
||||
+static ndn_netif_t _netif_table[MAX_GNRC_NETIFS];
|
||||
|
||||
void ndn_netif_auto_add(void)
|
||||
{
|
||||
/* initialize the netif table entry */
|
||||
- for (int i = 0; i < GNRC_NETIF_NUMOF; ++i) {
|
||||
+ for (int i = 0; i < MAX_GNRC_NETIFS; ++i) {
|
||||
_netif_table[i].iface = KERNEL_PID_UNDEF;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ static ndn_netif_t* _ndn_netif_find(kernel_pid_t iface)
|
||||
{
|
||||
if (iface == KERNEL_PID_UNDEF) return NULL;
|
||||
|
||||
- for (int i = 0; i < GNRC_NETIF_NUMOF; ++i) {
|
||||
+ for (int i = 0; i < MAX_GNRC_NETIFS; ++i) {
|
||||
if (_netif_table[i].iface == iface)
|
||||
return &_netif_table[i];
|
||||
}
|
||||
diff --git a/netif.h b/netif.h
|
||||
index 1e7fbdc..2175858 100644
|
||||
--- a/netif.h
|
||||
+++ b/netif.h
|
||||
@@ -24,6 +24,13 @@
|
||||
|
||||
#include "encoding/block.h"
|
||||
|
||||
+/**
|
||||
+ * @brief Max number of GNRC network interfaces
|
||||
+ */
|
||||
+#ifndef MAX_GNRC_NETIFS
|
||||
+#define MAX_GNRC_NETIFS (1)
|
||||
+#endif
|
||||
+
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
--
|
||||
2.25.0
|
||||
|
||||
@ -1,140 +0,0 @@
|
||||
From 17b6e4d2da20af995e914c8650ee825d052c5bc6 Mon Sep 17 00:00:00 2001
|
||||
From: Kaspar Schleiser <kaspar@schleiser.de>
|
||||
Date: Mon, 23 Nov 2020 12:44:54 +0100
|
||||
Subject: [PATCH] adapt to moved kernel_pid_t location
|
||||
|
||||
---
|
||||
app.h | 2 +-
|
||||
cs.h | 1 -
|
||||
face-table.h | 2 +-
|
||||
fib.h | 2 +-
|
||||
forwarding-strategy.h | 2 +-
|
||||
l2.h | 2 +-
|
||||
ndn.h | 2 +-
|
||||
netif.h | 2 +-
|
||||
pit.h | 2 +-
|
||||
9 files changed, 8 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/app.h b/app.h
|
||||
index 6428921acf..c357692a38 100644
|
||||
--- a/app.h
|
||||
+++ b/app.h
|
||||
@@ -23,9 +23,9 @@
|
||||
#include "encoding/name.h"
|
||||
#include "forwarding-strategy.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
#include <xtimer.h>
|
||||
#include <net/gnrc/pktbuf.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/cs.h b/cs.h
|
||||
index 36bf38d82a..01edf2bbc1 100644
|
||||
--- a/cs.h
|
||||
+++ b/cs.h
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "encoding/shared-block.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
//#include <xtimer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
diff --git a/face-table.h b/face-table.h
|
||||
index 28b44a5c02..fb0c39b083 100644
|
||||
--- a/face-table.h
|
||||
+++ b/face-table.h
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef NDN_FACE_TABLE_H_
|
||||
#define NDN_FACE_TABLE_H_
|
||||
|
||||
-#include <kernel_types.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/fib.h b/fib.h
|
||||
index 8d5f01ab79..5e190d283a 100644
|
||||
--- a/fib.h
|
||||
+++ b/fib.h
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "encoding/shared-block.h"
|
||||
#include "face-table.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
#include <xtimer.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/forwarding-strategy.h b/forwarding-strategy.h
|
||||
index 43ad66c276..15fdc5b8c7 100644
|
||||
--- a/forwarding-strategy.h
|
||||
+++ b/forwarding-strategy.h
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "encoding/shared-block.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/l2.h b/l2.h
|
||||
index 2dc1dad986..6322276f10 100644
|
||||
--- a/l2.h
|
||||
+++ b/l2.h
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "encoding/shared-block.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
#include <net/gnrc/pktbuf.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/ndn.h b/ndn.h
|
||||
index d8d148c7f7..47d2032301 100644
|
||||
--- a/ndn.h
|
||||
+++ b/ndn.h
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef NDN_H_
|
||||
#define NDN_H_
|
||||
|
||||
-#include <kernel_types.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/netif.h b/netif.h
|
||||
index 2175858fbd..4cf3c9bd54 100644
|
||||
--- a/netif.h
|
||||
+++ b/netif.h
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef NDN_NETIF_H_
|
||||
#define NDN_NETIF_H_
|
||||
|
||||
-#include <kernel_types.h>
|
||||
+#include "sched.h"
|
||||
|
||||
#include "encoding/block.h"
|
||||
|
||||
diff --git a/pit.h b/pit.h
|
||||
index dbe433eeda..3384a4c887 100644
|
||||
--- a/pit.h
|
||||
+++ b/pit.h
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "encoding/shared-block.h"
|
||||
#include "face-table.h"
|
||||
|
||||
-#include <kernel_types.h>
|
||||
+#include "sched.h"
|
||||
#include <xtimer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
--
|
||||
2.29.2
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
From ea398bfa1e15313860cf170c280932361c256449 Mon Sep 17 00:00:00 2001
|
||||
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
Date: Thu, 25 Feb 2021 11:17:54 +0100
|
||||
Subject: [PATCH] replace use of deprecated netopt
|
||||
|
||||
Use NETOPT_MAX_PDU_SIZE instead of NETOPT_MAX_PACKET_SIZE
|
||||
---
|
||||
netif.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/netif.c b/netif.c
|
||||
index 5e24c6d..ed1e973 100644
|
||||
--- a/netif.c
|
||||
+++ b/netif.c
|
||||
@@ -55,7 +55,7 @@ void ndn_netif_auto_add(void)
|
||||
gnrc_nettype_t proto;
|
||||
|
||||
// get device mtu
|
||||
- if (gnrc_netapi_get(iface, NETOPT_MAX_PACKET_SIZE, 0,
|
||||
+ if (gnrc_netapi_get(iface, NETOPT_MAX_PDU_SIZE, 0,
|
||||
&_netif_table[i].mtu,
|
||||
sizeof(uint16_t)) < 0) {
|
||||
DEBUG("ndn: cannot get device mtu (pid=%"
|
||||
--
|
||||
2.30.1
|
||||
|
||||
@ -1,256 +0,0 @@
|
||||
From b5cf1b1f24584666df472166104139f7627424e9 Mon Sep 17 00:00:00 2001
|
||||
From: Francisco Molina <femolina@uc.cl>
|
||||
Date: Thu, 9 Dec 2021 15:17:13 +0100
|
||||
Subject: [PATCH] use ztimer_msec instead of xtimer
|
||||
|
||||
---
|
||||
app.c | 12 ++++++------
|
||||
app.h | 4 ++--
|
||||
cs.h | 2 --
|
||||
fib.h | 1 -
|
||||
l2.c | 13 +++++++------
|
||||
ndn.c | 1 -
|
||||
pit.c | 12 +++++++-----
|
||||
pit.h | 4 ++--
|
||||
8 files changed, 24 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/app.c b/app.c
|
||||
index bc4718d..8e5598a 100644
|
||||
--- a/app.c
|
||||
+++ b/app.c
|
||||
@@ -225,8 +225,8 @@ int ndn_app_run(ndn_app_t* handle)
|
||||
msg.sender_pid, handle->id);
|
||||
return NDN_APP_STOP;
|
||||
|
||||
- case MSG_XTIMER:
|
||||
- DEBUG("ndn_app: XTIMER msg received from thread %"
|
||||
+ case MSG_ZTIMER:
|
||||
+ DEBUG("ndn_app: ZTIMER msg received from thread %"
|
||||
PRIkernel_pid " (pid=%" PRIkernel_pid ")\n",
|
||||
msg.sender_pid, handle->id);
|
||||
|
||||
@@ -299,7 +299,7 @@ static inline void _release_sched_cb_table(ndn_app_t* handle)
|
||||
DEBUG("ndn_app: remove scheduler cb entry (pid=%"
|
||||
PRIkernel_pid ")\n", handle->id);
|
||||
DL_DELETE(handle->_scb_table, entry);
|
||||
- xtimer_remove(&entry->timer);
|
||||
+ ztimer_remove(ZTIMER_USEC, &entry->timer);
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
@@ -380,14 +380,14 @@ int ndn_app_schedule(ndn_app_t* handle, ndn_app_sched_cb_t cb, void* context,
|
||||
if (entry == NULL) return -1;
|
||||
|
||||
// initialize the timer
|
||||
- entry->timer = (xtimer_t) {0};
|
||||
+ entry->timer = (ztimer_t) {0};
|
||||
|
||||
// initialize the msg struct
|
||||
- entry->timer_msg.type = MSG_XTIMER;
|
||||
+ entry->timer_msg.type = MSG_ZTIMER;
|
||||
entry->timer_msg.content.ptr = (char*)(&entry->timer_msg);
|
||||
|
||||
// set a timer to send a message to the app thread
|
||||
- xtimer_set_msg(&entry->timer, timeout, &entry->timer_msg, handle->id);
|
||||
+ ztimer_set_msg(ZTIMER_USEC, &entry->timer, timeout, &entry->timer_msg, handle->id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/app.h b/app.h
|
||||
index c357692..21666d9 100644
|
||||
--- a/app.h
|
||||
+++ b/app.h
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "encoding/name.h"
|
||||
#include "forwarding-strategy.h"
|
||||
|
||||
-#include <xtimer.h>
|
||||
+#include <ztimer.h>
|
||||
#include <net/gnrc/pktbuf.h>
|
||||
#include "sched.h"
|
||||
|
||||
@@ -95,7 +95,7 @@ typedef struct _sched_cb_entry {
|
||||
struct _sched_cb_entry *next;
|
||||
ndn_app_sched_cb_t cb;
|
||||
void* context;
|
||||
- xtimer_t timer;
|
||||
+ ztimer_t timer;
|
||||
msg_t timer_msg;
|
||||
} _sched_cb_entry_t;
|
||||
|
||||
diff --git a/cs.h b/cs.h
|
||||
index 01edf2b..c544cf8 100644
|
||||
--- a/cs.h
|
||||
+++ b/cs.h
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "encoding/shared-block.h"
|
||||
|
||||
-//#include <xtimer.h>
|
||||
-
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
diff --git a/fib.h b/fib.h
|
||||
index 5e190d2..cdf70aa 100644
|
||||
--- a/fib.h
|
||||
+++ b/fib.h
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "encoding/shared-block.h"
|
||||
#include "face-table.h"
|
||||
|
||||
-#include <xtimer.h>
|
||||
#include "sched.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
diff --git a/l2.c b/l2.c
|
||||
index a0546b5..817c210 100644
|
||||
--- a/l2.c
|
||||
+++ b/l2.c
|
||||
@@ -20,7 +20,8 @@
|
||||
#include "encoding/shared-block.h"
|
||||
#include "ndn.h"
|
||||
|
||||
-#include <xtimer.h>
|
||||
+#include <timex.h>
|
||||
+#include <ztimer.h>
|
||||
#include <net/gnrc/netif/hdr.h>
|
||||
#include <debug.h>
|
||||
|
||||
@@ -59,7 +60,7 @@ typedef struct _l2_frag_block {
|
||||
typedef struct _l2_frag_entry {
|
||||
struct _l2_frag_entry* prev;
|
||||
struct _l2_frag_entry* next;
|
||||
- xtimer_t timer;
|
||||
+ ztimer_t timer;
|
||||
msg_t timer_msg;
|
||||
uint8_t* netif_hdr;
|
||||
size_t netif_hdr_len;
|
||||
@@ -69,13 +70,13 @@ typedef struct _l2_frag_entry {
|
||||
} _l2_frag_entry_t;
|
||||
|
||||
//TODO: use larger timeout value in non-test environment
|
||||
-#define NDN_L2_FRAG_MAX_LIFETIME (10U * US_PER_SEC)
|
||||
+#define NDN_L2_FRAG_MAX_LIFETIME (10U * MS_PER_SEC)
|
||||
|
||||
static _l2_frag_entry_t* _l2_frag_list;
|
||||
|
||||
static void _release_l2_frag_entry(_l2_frag_entry_t* entry) {
|
||||
DL_DELETE(_l2_frag_list, entry);
|
||||
- xtimer_remove(&entry->timer);
|
||||
+ ztimer_remove(ZTIMER_USEC, &entry->timer);
|
||||
_l2_frag_block_t *blk, *tmp;
|
||||
LL_FOREACH_SAFE(entry->frags, blk, tmp) {
|
||||
free(blk->data);
|
||||
@@ -155,7 +156,7 @@ ndn_shared_block_t* ndn_l2_frag_receive(kernel_pid_t iface,
|
||||
entry->id = id;
|
||||
|
||||
// initialize timer
|
||||
- entry->timer = (xtimer_t) {0};
|
||||
+ entry->timer = (ztimer_t) {0};
|
||||
entry->timer_msg.type = NDN_L2_FRAG_MSG_TYPE_TIMEOUT;
|
||||
entry->timer_msg.content.ptr = (char*)(&entry->timer_msg);
|
||||
|
||||
@@ -166,7 +167,7 @@ ndn_shared_block_t* ndn_l2_frag_receive(kernel_pid_t iface,
|
||||
assert(entry != NULL);
|
||||
|
||||
// set (reset) timer
|
||||
- xtimer_set_msg(&entry->timer, NDN_L2_FRAG_MAX_LIFETIME,
|
||||
+ ztimer_set_msg(ZTIMER_USEC, &entry->timer, NDN_L2_FRAG_MAX_LIFETIME,
|
||||
&entry->timer_msg, ndn_pid);
|
||||
|
||||
if ((entry->frags_map & seq_map) != 0) {
|
||||
diff --git a/ndn.c b/ndn.c
|
||||
index 3db7411..d370d0b 100644
|
||||
--- a/ndn.c
|
||||
+++ b/ndn.c
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <net/gnrc/netreg.h>
|
||||
#include <thread.h>
|
||||
#include <timex.h>
|
||||
-#include <xtimer.h>
|
||||
|
||||
#define GNRC_NDN_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#define GNRC_NDN_PRIO (THREAD_PRIORITY_MAIN - 3)
|
||||
diff --git a/pit.c b/pit.c
|
||||
index 692105e..dc1698c 100644
|
||||
--- a/pit.c
|
||||
+++ b/pit.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#define ENABLE_DEBUG 1
|
||||
#include <debug.h>
|
||||
#include <utlist.h>
|
||||
+#include <timex.h>
|
||||
+#include <ztimer.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@@ -120,7 +122,7 @@ int ndn_pit_add(kernel_pid_t face_id, int face_type, ndn_shared_block_t* si,
|
||||
DEBUG("ndn: add to existing pit entry (face=%"
|
||||
PRIkernel_pid ")\n", face_id);
|
||||
/* reset timer */
|
||||
- xtimer_set_msg(&entry->timer, lifetime, &entry->timer_msg,
|
||||
+ ztimer_set_msg(ZTIMER_USEC, &entry->timer, lifetime, &entry->timer_msg,
|
||||
ndn_pid);
|
||||
// overwrite forwarding strategy
|
||||
entry->forwarding_strategy = strategy;
|
||||
@@ -155,14 +157,14 @@ int ndn_pit_add(kernel_pid_t face_id, int face_type, ndn_shared_block_t* si,
|
||||
*pit_entry = entry;
|
||||
|
||||
/* initialize the timer */
|
||||
- entry->timer = (xtimer_t) {0};
|
||||
+ entry->timer = (ztimer_t) {0};
|
||||
|
||||
/* initialize the msg struct */
|
||||
entry->timer_msg.type = NDN_PIT_MSG_TYPE_TIMEOUT;
|
||||
entry->timer_msg.content.ptr = (char*)(&entry->timer_msg);
|
||||
|
||||
/* set a timer to send a message to ndn thread */
|
||||
- xtimer_set_msg(&entry->timer, lifetime, &entry->timer_msg, ndn_pid);
|
||||
+ ztimer_set_msg(ZTIMER_USEC, &entry->timer, lifetime, &entry->timer_msg, ndn_pid);
|
||||
|
||||
// set forwarding strategy
|
||||
entry->forwarding_strategy = strategy;
|
||||
@@ -175,7 +177,7 @@ void ndn_pit_release(ndn_pit_entry_t *entry)
|
||||
{
|
||||
assert(_pit != NULL);
|
||||
DL_DELETE(_pit, entry);
|
||||
- xtimer_remove(&entry->timer);
|
||||
+ ztimer_remove(ZTIMER_USEC, &entry->timer);
|
||||
ndn_shared_block_release(entry->shared_pi);
|
||||
free(entry->face_list);
|
||||
free(entry);
|
||||
@@ -253,7 +255,7 @@ int ndn_pit_match_data(ndn_shared_block_t* sd, kernel_pid_t iface)
|
||||
DEBUG("ndn: found matching pit entry for data\n");
|
||||
|
||||
DL_DELETE(_pit, entry);
|
||||
- xtimer_remove(&entry->timer);
|
||||
+ ztimer_remove(ZTIMER_USEC, &entry->timer);
|
||||
|
||||
// invoke forwarding strategy trigger if available
|
||||
if (entry->forwarding_strategy->before_satisfy_interest) {
|
||||
diff --git a/pit.h b/pit.h
|
||||
index 3384a4c..91664e0 100644
|
||||
--- a/pit.h
|
||||
+++ b/pit.h
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "face-table.h"
|
||||
|
||||
#include "sched.h"
|
||||
-#include <xtimer.h>
|
||||
+#include <ztimer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -39,7 +39,7 @@ typedef struct ndn_pit_entry {
|
||||
struct ndn_pit_entry *prev;
|
||||
struct ndn_pit_entry *next;
|
||||
ndn_shared_block_t *shared_pi; /**< shared TLV block of the pending interest */
|
||||
- xtimer_t timer; /**< xtimer struct */
|
||||
+ ztimer_t timer; /**< ztimer struct */
|
||||
msg_t timer_msg; /**< special message to indicate timeout event */
|
||||
|
||||
// List of incoming faces
|
||||
--
|
||||
2.30.2
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
From a69fe71eb8e915db21bda6879ce0f8b768e5982d Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
Date: Fri, 7 Jan 2022 17:20:46 +0100
|
||||
Subject: [PATCH] replace deprecated CIPHER_AES_128 by CIPHER_AES
|
||||
|
||||
---
|
||||
encoding/data.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/encoding/data.c b/encoding/data.c
|
||||
index 6abf186..afebde4 100644
|
||||
--- a/encoding/data.c
|
||||
+++ b/encoding/data.c
|
||||
@@ -437,7 +437,7 @@ ndn_shared_block_t* ndn_data_encrypt_with_ccm(ndn_block_t* name,
|
||||
|
||||
// Initiate cipher
|
||||
cipher_t cipher;
|
||||
- if (cipher_init(&cipher, CIPHER_AES_128, key, key_len) < 0) {
|
||||
+ if (cipher_init(&cipher, CIPHER_AES, key, key_len) < 0) {
|
||||
DEBUG("ndn_encoding: cannot init ccm cipher for encryption\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1027,7 +1027,7 @@ ndn_shared_block_t* ndn_data_decrypt_with_ccm(ndn_block_t* block,
|
||||
|
||||
// Initiate cipher
|
||||
cipher_t cipher;
|
||||
- if (cipher_init(&cipher, CIPHER_AES_128, key, key_len) < 0) {
|
||||
+ if (cipher_init(&cipher, CIPHER_AES, key, key_len) < 0) {
|
||||
DEBUG("ndn_encoding: cannot init ccm cipher for decryption\n");
|
||||
return NULL;
|
||||
}
|
||||
--
|
||||
2.32.0
|
||||
|
||||
@ -90,6 +90,15 @@ static void _handle_rdnss_timeout(sock_udp_ep_t *dns_server);
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
static inline bool _should_search_rtr(const gnrc_netif_t *netif)
|
||||
{
|
||||
/* 6LBR interface does not send RS.
|
||||
A non-advertising router sends RS or a 6LN that is advertising or not
|
||||
has to refetch router information */
|
||||
return !gnrc_netif_is_6lbr(netif) &&
|
||||
(!gnrc_netif_is_rtr_adv(netif) || gnrc_netif_is_6ln(netif));
|
||||
}
|
||||
|
||||
void gnrc_ipv6_nib_init(void)
|
||||
{
|
||||
evtimer_event_t *tmp;
|
||||
@ -137,8 +146,7 @@ void gnrc_ipv6_nib_iface_up(gnrc_netif_t *netif)
|
||||
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
|
||||
netif->ipv6.na_sent = 0;
|
||||
_auto_configure_addr(netif, &ipv6_addr_link_local_prefix, 64U);
|
||||
if (!(gnrc_netif_is_rtr_adv(netif)) ||
|
||||
(gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif))) {
|
||||
if (_should_search_rtr(netif)) {
|
||||
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);
|
||||
|
||||
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR, &netif->ipv6.search_rtr,
|
||||
@ -160,8 +168,7 @@ void gnrc_ipv6_nib_iface_down(gnrc_netif_t *netif, bool send_final_ra)
|
||||
gnrc_netif_acquire(netif);
|
||||
|
||||
_deinit_iface_arsm(netif);
|
||||
if (!(gnrc_netif_is_rtr_adv(netif)) ||
|
||||
(gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif))) {
|
||||
if (_should_search_rtr(netif)) {
|
||||
_evtimer_del(&netif->ipv6.search_rtr);
|
||||
}
|
||||
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
|
||||
@ -482,8 +489,10 @@ void gnrc_ipv6_nib_change_rtr_adv_iface(gnrc_netif_t *netif, bool enable)
|
||||
netif->flags &= ~GNRC_NETIF_FLAGS_IPV6_RTR_ADV;
|
||||
/* send final router advertisements */
|
||||
_handle_snd_mc_ra(netif);
|
||||
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR, &netif->ipv6.search_rtr,
|
||||
next_rs_time);
|
||||
if (!gnrc_netif_is_6lbr(netif)) {
|
||||
_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR,
|
||||
&netif->ipv6.search_rtr, next_rs_time);
|
||||
}
|
||||
}
|
||||
gnrc_netif_release(netif);
|
||||
}
|
||||
@ -858,7 +867,9 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
|
||||
|
||||
/* stop sending router solicitations
|
||||
* see https://tools.ietf.org/html/rfc4861#section-6.3.7 */
|
||||
evtimer_del(&_nib_evtimer, &netif->ipv6.search_rtr.event);
|
||||
if (!gnrc_netif_is_6lbr(netif)) {
|
||||
evtimer_del(&_nib_evtimer, &netif->ipv6.search_rtr.event);
|
||||
}
|
||||
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
|
||||
if (gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif)) {
|
||||
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)) {
|
||||
@ -1461,7 +1472,7 @@ void _handle_search_rtr(gnrc_netif_t *netif)
|
||||
{
|
||||
#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_NO_RTR_SOL)
|
||||
gnrc_netif_acquire(netif);
|
||||
if (!(gnrc_netif_is_rtr_adv(netif)) || gnrc_netif_is_6ln(netif)) {
|
||||
if (_should_search_rtr(netif)) {
|
||||
uint32_t next_rs = _evtimer_lookup(netif, GNRC_IPV6_NIB_SEARCH_RTR);
|
||||
uint32_t interval = _get_next_rs_interval(netif);
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "bitarithm.h"
|
||||
#include "kernel_defines.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
@ -52,25 +53,15 @@ uint8_t ipv6_addr_match_prefix(const ipv6_addr_t *a, const ipv6_addr_t *b)
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
/* if bytes are equal add 8 */
|
||||
if (a->u8[i] == b->u8[i]) {
|
||||
prefix_len += 8;
|
||||
uint8_t xor = a->u8[i] ^ b->u8[i];
|
||||
if (xor) {
|
||||
/* if bytes aren't equal count matching leading bits */
|
||||
prefix_len += bitarithm_clzb(xor);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
uint8_t xor = (a->u8[i] ^ b->u8[i]);
|
||||
|
||||
/* while bits from byte equal add 1 */
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if ((xor & 0x80) == 0) {
|
||||
prefix_len++;
|
||||
xor = xor << 1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
/* if bytes are equal add 8 */
|
||||
prefix_len += 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user