mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-30 08:51:19 +01:00
Merge pull request #8095 from miri64/tests/fix/nib-forw
examples: tests: adapt udp shell commands for new forwarding engine
This commit is contained in:
commit
d8073e9b3d
@ -25,9 +25,12 @@
|
||||
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#include "timex.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
@ -228,9 +231,15 @@ static int peer_verify_ecdsa_key(struct dtls_context_t *ctx,
|
||||
*/
|
||||
static int gnrc_sending(char *addr_str, char *data, size_t data_len )
|
||||
{
|
||||
int iface;
|
||||
ipv6_addr_t addr;
|
||||
gnrc_pktsnip_t *payload, *udp, *ip;
|
||||
|
||||
/* get interface, if available */
|
||||
iface = ipv6_addr_split_iface(addr_str);
|
||||
if ((iface < 0) && (gnrc_netif_numof() == 1)) {
|
||||
iface = gnrc_netif_iter(NULL)->pid;
|
||||
}
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
@ -260,6 +269,13 @@ static int gnrc_sending(char *addr_str, char *data, size_t data_len )
|
||||
gnrc_pktbuf_release(udp);
|
||||
return -1;
|
||||
}
|
||||
/* add netif header, if interface was given */
|
||||
if (iface > 0) {
|
||||
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = (kernel_pid_t)iface;
|
||||
LL_PREPEND(ip, netif);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING: Too fast and the nodes dies in middle of retransmissions.
|
||||
|
||||
@ -26,8 +26,11 @@
|
||||
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "timex.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
#include "msg.h"
|
||||
|
||||
@ -142,10 +145,15 @@ static int read_from_peer(struct dtls_context_t *ctx,
|
||||
*/
|
||||
static int gnrc_sending(char *addr_str, char *data, size_t data_len, unsigned short rem_port )
|
||||
{
|
||||
|
||||
int iface;
|
||||
ipv6_addr_t addr;
|
||||
gnrc_pktsnip_t *payload, *udp, *ip;
|
||||
|
||||
/* get interface, if available */
|
||||
iface = ipv6_addr_split_iface(addr_str);
|
||||
if ((iface < 0) && (gnrc_netif_numof() == 1)) {
|
||||
iface = gnrc_netif_iter(NULL)->pid;
|
||||
}
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
@ -174,6 +182,13 @@ static int gnrc_sending(char *addr_str, char *data, size_t data_len, unsigned sh
|
||||
gnrc_pktbuf_release(udp);
|
||||
return -1;
|
||||
}
|
||||
/* add netif header, if interface was given */
|
||||
if (iface > 0) {
|
||||
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = (kernel_pid_t)iface;
|
||||
LL_PREPEND(ip, netif);
|
||||
}
|
||||
/* send packet */
|
||||
|
||||
DEBUG("DBG-Server: Sending record to peer\n");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freie Universität Berlin
|
||||
* Copyright (C) 2015-17 Freie Universität Berlin
|
||||
*
|
||||
* 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
|
||||
@ -14,6 +14,7 @@
|
||||
* @brief Demonstrating the sending and receiving of UDP data
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
* @author Martine Lenders <m.lenders@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
@ -23,9 +24,12 @@
|
||||
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#include "timex.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
static gnrc_netreg_entry_t server = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
|
||||
@ -35,9 +39,15 @@ static gnrc_netreg_entry_t server = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX
|
||||
static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
||||
unsigned int delay)
|
||||
{
|
||||
int iface;
|
||||
uint16_t port;
|
||||
ipv6_addr_t addr;
|
||||
|
||||
/* get interface, if available */
|
||||
iface = ipv6_addr_split_iface(addr_str);
|
||||
if ((iface < 0) && (gnrc_netif_numof() == 1)) {
|
||||
iface = gnrc_netif_iter(NULL)->pid;
|
||||
}
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
@ -75,6 +85,13 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
||||
gnrc_pktbuf_release(udp);
|
||||
return;
|
||||
}
|
||||
/* add netif header, if interface was given */
|
||||
if (iface > 0) {
|
||||
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = (kernel_pid_t)iface;
|
||||
LL_PREPEND(ip, netif);
|
||||
}
|
||||
/* send packet */
|
||||
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL, ip)) {
|
||||
puts("Error: unable to locate UDP thread");
|
||||
|
||||
@ -23,9 +23,12 @@
|
||||
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#include "timex.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
static gnrc_netreg_entry_t server = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
|
||||
@ -35,9 +38,15 @@ static gnrc_netreg_entry_t server = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX
|
||||
static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
||||
unsigned int delay)
|
||||
{
|
||||
int iface;
|
||||
uint16_t port;
|
||||
ipv6_addr_t addr;
|
||||
|
||||
/* get interface, if available */
|
||||
iface = ipv6_addr_split_iface(addr_str);
|
||||
if ((iface < 0) && (gnrc_netif_numof() == 1)) {
|
||||
iface = gnrc_netif_iter(NULL)->pid;
|
||||
}
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
@ -75,6 +84,13 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
||||
gnrc_pktbuf_release(udp);
|
||||
return;
|
||||
}
|
||||
/* add netif header, if interface was given */
|
||||
if (iface > 0) {
|
||||
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = (kernel_pid_t)iface;
|
||||
LL_PREPEND(ip, netif);
|
||||
}
|
||||
/* send packet */
|
||||
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL, ip)) {
|
||||
puts("Error: unable to locate UDP thread");
|
||||
|
||||
@ -22,9 +22,12 @@
|
||||
#include "msg.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/udp.h"
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#include "timex.h"
|
||||
#include "utlist.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#define SERVER_MSG_QUEUE_SIZE (8U)
|
||||
@ -78,10 +81,16 @@ static void *_eventloop(void *arg)
|
||||
static void send(char *addr_str, char *port_str, char *data_len_str, unsigned int num,
|
||||
unsigned int delay)
|
||||
{
|
||||
int iface;
|
||||
uint16_t port;
|
||||
ipv6_addr_t addr;
|
||||
size_t data_len;
|
||||
|
||||
/* get interface, if available */
|
||||
iface = ipv6_addr_split_iface(addr_str);
|
||||
if ((iface < 0) && (gnrc_netif_numof() == 1)) {
|
||||
iface = gnrc_netif_iter(NULL)->pid;
|
||||
}
|
||||
/* parse destination address */
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
@ -123,6 +132,13 @@ static void send(char *addr_str, char *port_str, char *data_len_str, unsigned in
|
||||
gnrc_pktbuf_release(udp);
|
||||
return;
|
||||
}
|
||||
/* add netif header, if interface was given */
|
||||
if (iface > 0) {
|
||||
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
|
||||
((gnrc_netif_hdr_t *)netif->data)->if_pid = (kernel_pid_t)iface;
|
||||
LL_PREPEND(ip, netif);
|
||||
}
|
||||
/* send packet */
|
||||
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL, ip)) {
|
||||
puts("Error: unable to locate UDP thread");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user