1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

remove apps belonging to the old network stack

This commit is contained in:
Oleg Hahm 2015-08-23 23:41:35 +02:00
parent 10cad08a77
commit 017cbf190c
11 changed files with 0 additions and 747 deletions

View File

@ -1,36 +0,0 @@
# name of your application
APPLICATION = sixlowapp
# 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)/../../RIOT
# Uncomment this to enable scheduler statistics for ps:
#CFLAGS += -DSCHEDSTATISTICS
# Uncomment this to enable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -DDEVELHELP
# Change this to 0 show compiler invocation lines by default:
export QUIET ?= 1
# Modules to include:
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += uart0
USEMODULE += ps
USEMODULE += defaulttransceiver
USEMODULE += udp
ifneq (,$(filter iot-lab_M3,$(BOARD)))
USEMODULE += isl29020
USEMODULE += lps331ap
USEMODULE += l3g4200d
USEMODULE += lsm303dlhc
endif
include $(RIOTBASE)/Makefile.include

View File

@ -1,11 +0,0 @@
Usage of sixlowapp - 6LoWPAN example
====================================
* set up two nodes
* for nativenet:
* run `${RIOTBASE}/cpu/native/tapsetup.sh create`
* run `PORT=tap0 make term`
* run `PORT=tap1 make term` (from another terminal)
* type `ifconfig` on both nodes
* type `ping <IPv6 address>` on node 1, using one of node 2's IPv6 addresses
* type `nc -l <PORT>` to start a UDP server listening on `<PORT>` on of the nodes
* type `nc <IPv6 address> <PORT> <TEXT>` on the other node to send `<TEXT>` to the first node

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2014 INRIA
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @file
* @brief 6LoWPAN example application helper functions
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include "msg.h"
#include "sixlowpan/ip.h"
#include "sixlowapp.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
void sixlowapp_ndp_workaround(ipv6_addr_t *dest)
{
/* add the destination to the neighbor cache if is not already in it */
if (!ndp_neighbor_cache_search(dest)) {
DEBUGF("XXX: Adding %s to neighbor cache.\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest));
ndp_neighbor_cache_add(IF_ID, dest, &(dest->uint16[7]), 2, 0,
NDP_NCE_STATUS_REACHABLE,
NDP_NCE_TYPE_TENTATIVE, 0xffff);
}
}
uint64_t sixlowapp_wait_for_msg_type(msg_t *m, timex_t timeout, uint16_t mtype)
{
timex_t t1, t2, delta;
delta = timex_set(0, 0);
vtimer_now(&t1);
while (timex_cmp(delta, timeout) < 0) {
if (vtimer_msg_receive_timeout(m, timeout) < 0) {
return 0;
}
vtimer_now(&t2);
delta = timex_sub(t2, t1);
if (m->type == mtype) {
return timex_uint64(delta);
}
timeout = timex_sub(timeout, delta);
}
return 0;
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2014 INRIA
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @file
* @brief 6LoWPAN example application - main function
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include <stdio.h>
#include "kernel.h"
#include "thread.h"
#include "net_if.h"
#include "posix_io.h"
#include "shell.h"
#include "shell_commands.h"
#include "board_uart0.h"
#include "sixlowapp.h"
kernel_pid_t sixlowapp_udp_server_pid = KERNEL_PID_UNDEF;
char addr_str[IPV6_MAX_ADDR_STR_LEN];
char monitor_stack_buffer[THREAD_STACKSIZE_MAIN];
char udp_server_stack_buffer[THREAD_STACKSIZE_MAIN];
const shell_command_t shell_commands[] = {
{"ping", "Send an ICMPv6 echo request to another node", sixlowapp_send_ping},
{"nc", "RIOT netcat - arbitrary UDP connections and listens", sixlowapp_netcat},
{NULL, NULL, NULL}
};
int main(void)
{
puts("RIOT 6LoWPAN example v"APP_VERSION);
sixlowpan_lowpan_init_interface(IF_ID);
/* start thread for monitor mode */
kernel_pid_t monitor_pid = thread_create(monitor_stack_buffer,
sizeof(monitor_stack_buffer),
THREAD_PRIORITY_MAIN - 2,
CREATE_STACKTEST,
sixlowapp_monitor, NULL,
"monitor");
ipv6_register_packet_handler(monitor_pid);
/* Start the UDP server thread */
sixlowapp_udp_server_pid = thread_create(udp_server_stack_buffer,
sizeof(udp_server_stack_buffer),
THREAD_PRIORITY_MAIN, CREATE_STACKTEST,
sixlowapp_udp_server_loop, NULL,
"UDP receiver");
/* Open the UART0 for the shell */
posix_open(uart0_handler_pid, 0);
/* initialize the shell */
shell_t shell;
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
/* start the shell loop */
shell_run(&shell);
return 0;
}

View File

@ -1,71 +0,0 @@
/*
* Copyright (C) 2014 INRIA
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @file
* @brief 6LoWPAN example application IPv6 monitor
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include "msg.h"
#include "sixlowpan/ip.h"
#include "sixlowapp.h"
#define RCV_BUFFER_SIZE (32)
#define IPV6_HDR_LEN (0x28)
#define ENABLE_DEBUG (0)
#include "debug.h"
msg_t msg_q[RCV_BUFFER_SIZE];
void *sixlowapp_monitor(void *unused)
{
(void) unused;
msg_t m;
ipv6_hdr_t *ipv6_buf;
msg_init_queue(msg_q, RCV_BUFFER_SIZE);
while (1) {
msg_receive(&m);
if (m.type == IPV6_PACKET_RECEIVED) {
ipv6_buf = (ipv6_hdr_t *) m.content.ptr;
if (ipv6_buf->nextheader == IPV6_PROTO_NUM_ICMPV6) {
icmpv6_hdr_t *icmpv6_buf = (icmpv6_hdr_t *) &((uint8_t*)ipv6_buf)[(IPV6_HDR_LEN)];
if (icmpv6_buf->type == ICMPV6_TYPE_ECHO_REPLY) {
if (sixlowapp_waiting_for_pong) {
msg_t m;
m.type = ICMP_ECHO_REPLY_RCVD;
sixlowapp_waiting_for_pong = 0;
msg_send(&m, sixlowapp_waiter_pid);
}
}
}
/* add the destination to the neighbor cache if is not already in it */
if (!ndp_neighbor_cache_search(&(ipv6_buf->srcaddr))) {
ndp_neighbor_cache_add(IF_ID, &(ipv6_buf->srcaddr),
&(ipv6_buf->srcaddr.uint16[7]), 2,
0, NDP_NCE_STATUS_REACHABLE,
NDP_NCE_TYPE_TENTATIVE, 0xffff);
}
DEBUGF("IPv6 datagram received (next header: %02X)", ipv6_buf->nextheader);
DEBUG(" from %s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
&ipv6_buf->srcaddr));
}
else {
printf("! Unknown message received, type %04X\n", m.type);
}
}
}

View File

@ -1,111 +0,0 @@
#ifndef SIXLOWAPP_H
#define SIXLOWAPP_H
#include "kernel.h"
#include "ipv6.h"
/**
* @brief The application version number
*/
#define APP_VERSION "1.3"
/**
* @brief Which interface should be used for 6LoWPAN
*/
#define IF_ID (0)
/**
* @brief Define a IPC message type for ICMP echo reply handling
*/
#define ICMP_ECHO_REPLY_RCVD (4444)
/**
* @brief PID for UDP server thread
*/
extern kernel_pid_t sixlowapp_udp_server_pid;
/**
* @brief UDP port number that netcat uses to listen at
*/
extern uint16_t sixlowapp_netcat_listen_port;
/**
* @brief Marker if we're waiting for an ICMP echo reply
*/
extern unsigned sixlowapp_waiting_for_pong;
/**
* @brief The PID of the thread waiting for the ICMP echo reply
*/
extern kernel_pid_t sixlowapp_waiter_pid;
/**
* @brief Helper variable for IP address printing
*/
extern char addr_str[IPV6_MAX_ADDR_STR_LEN];
/**
* @brief Shell command to send an ICMPv6 echo request
*
* @param[in] argc Number of arguments supplied to the function invocation.
* @param[in] argv The supplied argument list.
*
* @returns 0 on success, error code on invalide parameters
*/
int sixlowapp_send_ping(int argc, char **argv);
/**
* @brief Shell command for netcat
*
* @param[in] argc Number of arguments supplied to the function invocation.
* @param[in] argv The supplied argument list.
*
* @returns 0 on success, error code on invalide parameters
*/
int sixlowapp_netcat(int argc, char **argv);
/**
* @brief Wrapper function for sending data of UDP
*
* @param[in] dest Destination IPv6 address
* @param[in] port Destination UDP port
* @param[in] payload Data to send
* @param[in] len Size of data to send
*/
void sixlowapp_udp_send(ipv6_addr_t *dest, uint16_t port, char *payload, size_t len);
/**
* @brief Monitoring thread
*
* @param[in] unused Obsolete
*/
void *sixlowapp_monitor(void *unused);
/**
* @brief UDP server thread
*
* @param[in] arg Obsolete
*/
void *sixlowapp_udp_server_loop(void *arg);
/**
* @brief Provides a workaround for currently broken 6LoWPAN ND
*
* @param[in] dest The IPv6 address to add to the neighbor cache
*/
void sixlowapp_ndp_workaround(ipv6_addr_t *dest);
/**
* @brief Waits for a certain message type for a given time span
*
* @param[out] m Pointer to preallocated ``msg_t`` structure, must not
* be NULL
* @param[in] timeout The maximum interval to wait
* @param[in] mtype The message type to wait for
*
* @return 0 if no message of type @p mtype was received
* @return The number of microseconds before the message was received
*/
uint64_t sixlowapp_wait_for_msg_type(msg_t *m, timex_t timeout, uint16_t mtype);
#endif /* SIXLOWAPP_H */

View File

@ -1,128 +0,0 @@
/*
* Copyright (C) 2014 INRIA
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @file
* @brief 6LoWPAN example application shell functions
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include <stdio.h>
#include <errno.h>
#include "msg.h"
#include "thread.h"
#include "sched.h"
#include "sixlowpan/ip.h"
#include "inet_pton.h"
#include "sixlowapp.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
#define ICMP_DATA "RIOT"
#define ICMP_TIMEOUT (100)
#define MAX_PAYLOAD_SIZE (32)
extern uint8_t ipv6_ext_hdr_len;
static char payload[MAX_PAYLOAD_SIZE];
unsigned sixlowapp_waiting_for_pong;
kernel_pid_t sixlowapp_waiter_pid;
int sixlowapp_send_ping(int argc, char **argv)
{
ipv6_addr_t dest;
const char *icmp_data = ICMP_DATA;
if (argc != 2) {
puts("! Invalid number of parameters");
printf(" usage: %s destination\n", argv[0]);
return EINVAL;
}
if (!inet_pton(AF_INET6, argv[1], &dest)) {
printf("! %s is not a valid IPv6 address\n", argv[1]);
return EFAULT;
}
sixlowapp_ndp_workaround(&dest);
/* send an echo request */
icmpv6_send_echo_request(&dest, 1, 1, (uint8_t *) icmp_data, sizeof(icmp_data));
sixlowapp_waiting_for_pong = 1;
sixlowapp_waiter_pid = sched_active_pid;
uint64_t rtt;
msg_t m;
m.type = 0;
rtt = sixlowapp_wait_for_msg_type(&m, timex_set(0, ICMP_TIMEOUT * 1000), ICMP_ECHO_REPLY_RCVD);
if (sixlowapp_waiting_for_pong == 0) {
char ts[TIMEX_MAX_STR_LEN];
printf("Echo reply from %s received, rtt: %s\n", inet_ntop(AF_INET6, &dest,
addr_str,
IPV6_MAX_ADDR_STR_LEN),
timex_to_str(timex_from_uint64(rtt), ts));
}
else {
printf("! Destination %s is unreachable\n", inet_ntop(AF_INET6,
&dest,
addr_str,
IPV6_MAX_ADDR_STR_LEN));
}
return 0;
}
int sixlowapp_netcat(int argc, char **argv)
{
ipv6_addr_t dest;
if (argc < 3) {
puts("! Not enough parameters");
puts(" usage: nc [-l] [destination] [port] [text]");
return EINVAL;
}
if (strlen(argv[1]) == 2) {
if (strncmp(argv[1], "-l", 2)) {
puts("! Invalid parameter");
puts(" usage: nc [-l] [destination] [port] [text]");
return EINVAL;
}
else {
sixlowapp_netcat_listen_port = atoi(argv[2]);
thread_wakeup(sixlowapp_udp_server_pid);
}
}
else if (!inet_pton(AF_INET6, argv[1], &dest)) {
printf("! %s is not a valid IPv6 address\n", argv[1]);
}
else {
sixlowapp_ndp_workaround(&dest);
size_t plen;
if (argc > 3 ) {
plen = (strlen(argv[3]) > MAX_PAYLOAD_SIZE) ? MAX_PAYLOAD_SIZE : strlen(argv[3]) + 1;
memcpy(payload, argv[3], plen);
payload[plen - 1] = 0;
}
else {
plen = 5;
strncpy(payload, "RIOT", plen);
}
sixlowapp_udp_send(&dest, atoi(argv[2]), payload, plen);
}
return 0;
}

View File

@ -1,107 +0,0 @@
/*
* Copyright (C) 2013, 2014 INRIA
*
* 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.
*/
/**
* @file
*
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
#include "thread.h"
#include "socket_base/socket.h"
#include "net_help.h"
#include "sixlowapp.h"
#define UDP_BUFFER_SIZE (128)
uint16_t sixlowapp_netcat_listen_port;
/* UDP server thread */
void *sixlowapp_udp_server_loop(void *arg)
{
(void) arg;
sockaddr6_t sa;
char buffer_main[UDP_BUFFER_SIZE];
uint32_t fromlen;
int sock;
fromlen = sizeof(sa);
while (1) {
while(!sixlowapp_netcat_listen_port) {
thread_sleep();
}
sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
memset(&sa, 0, sizeof(sa));
sa.sin6_family = AF_INET;
sa.sin6_port = HTONS(sixlowapp_netcat_listen_port);
if (-1 == socket_base_bind(sock, &sa, sizeof(sa))) {
printf("Error bind failed!\n");
socket_base_close(sock);
sixlowapp_netcat_listen_port = 0;
continue;
}
printf("Listening for incoming UDP connection at port %" PRIu16 "\n", sixlowapp_netcat_listen_port);
int32_t recsize = socket_base_recvfrom(sock, (void *)buffer_main, UDP_BUFFER_SIZE, 0, &sa, &fromlen);
if (recsize < 0) {
printf("ERROR: recsize < 0!\n");
}
printf("UDP packet received, payload: %s\n", buffer_main);
socket_base_close(sock);
sixlowapp_netcat_listen_port = 0;
}
return NULL;
}
/* UDP send command */
void sixlowapp_udp_send(ipv6_addr_t *dest, uint16_t port, char *payload, size_t len)
{
int sock;
sockaddr6_t sa;
int bytes_sent;
sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (-1 == sock) {
printf("Error Creating Socket!");
return;
}
memset(&sa, 0, sizeof(sa));
sa.sin6_family = AF_INET;
memcpy(&sa.sin6_addr, dest, 16);
sa.sin6_port = HTONS(port);
printf("Trying to send %i bytes to %s:%" PRIu16 "\n", len,
ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest), port);
bytes_sent = socket_base_sendto(sock, payload, len, 0, &sa, sizeof(sa));
if (bytes_sent < 0) {
printf("Error sending packet!\n");
}
else {
printf("Successful deliverd %i bytes over UDP to %s to 6LoWPAN\n",
bytes_sent, ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
dest));
}
socket_base_close(sock);
}

View File

@ -1,20 +0,0 @@
# Set the name of your application:
APPLICATION = sniffer
# 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)/../../RIOT
# Define modules that are used
USEMODULE += ng_netif_default
USEMODULE += auto_init_ng_netif
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1
include $(RIOTBASE)/Makefile.include

View File

@ -1,12 +0,0 @@
About
=====
This application is build to run together with the script `RIOTBASE/dist/tools/sniffer/sniffer.py` as sniffer for (wireless) data traffic. This application works with any board with any network device that supports the gnrc network stack (or precisely the gnrc parts up to the link-layer). Further the network device (and it's driver) needs to support promiscuous and raw mode for usable output. Finally the board needs to include auto-initialization code for the targeted network device.
Usage
=====
Compile and flash this application to the board of your choice. You can check if everything on the RIOT side works by connecting to the board via UART and by checking with `ifconfig` if a network device is available. Further you can check with `ifconfig 4 promisc` if promiscuous mode is supported and with `ifconfig 4 raw` if raw mode is supported by the driver/network device.
For further information on setting up the host part, see `RIOTBASE/dist/tools/sniffer/README.md`.

View File

@ -1,127 +0,0 @@
/*
* Copyright (C) 2015 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
* directory for more details.
*/
/**
* @defgroup app_sniffer
* @brief Sniffer application based on the new network stack
* @{
*
* @file
* @brief Sniffer application for RIOT
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "thread.h"
#include "hwtimer.h"
#include "shell.h"
#include "shell_commands.h"
#ifdef MODULE_NEWLIB
# include "uart_stdio.h"
#else
# include "posix_io.h"
# include "board_uart0.h"
#endif
#include "net/ng_netbase.h"
/**
* @brief Buffer size used by the shell
*/
#define SHELL_BUFSIZE (64U)
/**
* @brief Priority of the RAW dump thread
*/
#define RAWDUMP_PRIO (THREAD_PRIORITY_MAIN - 1)
/**
* @brief Stack for the raw dump thread
*/
static char rawdmp_stack[THREAD_STACKSIZE_MAIN];
/**
* @brief Make a raw dump of the given packet contents
*/
void dump_pkt(ng_pktsnip_t *pkt)
{
ng_pktsnip_t *snip = pkt;
printf("rftest-rx --- len 0x%02x lqi 0x%02x rx_time 0x%08lx\n\n",
ng_pkt_len(pkt), 0, hwtimer_now());
while (snip) {
for (size_t i = 0; i < snip->size; i++) {
printf("0x%02x ", ((uint8_t *)(snip->data))[i]);
}
snip = snip->next;
}
puts("\n");
ng_pktbuf_release(pkt);
}
/**
* @brief Event loop of the RAW dump thread
*
* @param[in] arg unused parameter
*/
void *rawdump(void *arg)
{
(void)arg;
msg_t msg;
while (1) {
msg_receive(&msg);
switch (msg.type) {
case NG_NETAPI_MSG_TYPE_RCV:
dump_pkt((ng_pktsnip_t *)msg.content.ptr);
break;
default:
/* do nothing */
break;
}
}
/* never reached */
return NULL;
}
/**
* @brief Maybe you are a golfer?!
*/
int main(void)
{
shell_t shell;
ng_netreg_entry_t dump;
puts("RIOT sniffer application");
/* start and register rawdump thread */
puts("Run the rawdump thread and register it");
dump.pid = thread_create(rawdmp_stack, sizeof(rawdmp_stack), RAWDUMP_PRIO,
CREATE_STACKTEST, rawdump, NULL, "rawdump");
dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
ng_netreg_register(NG_NETTYPE_UNDEF, &dump);
/* start the shell */
puts("All ok, starting the shell now");
#ifndef MODULE_NEWLIB
(void) posix_open(uart0_handler_pid, 0);
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
#else
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
#endif
shell_run(&shell);
return 0;
}