-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8edc94d
commit 0578680
Showing
5 changed files
with
351 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# name of your application | ||
APPLICATION = task-09 | ||
|
||
# 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 | ||
|
||
BOARD_INSUFFICIENT_MEMORY := airfy-beacon chronos msb-430 msb-430h nrf51dongle \ | ||
nrf6310 nucleo-f103 nucleo-f334 pca10000 pca10005 spark-core \ | ||
stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \ | ||
yunjia-nrf51822 z1 nucleo-f072 | ||
|
||
# Include packages that pull up and auto-init the link layer. | ||
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present | ||
USEMODULE += gnrc_netdev_default | ||
USEMODULE += auto_init_gnrc_netif | ||
# Specify the mandatory networking modules for IPv6 and UDP | ||
USEMODULE += gnrc_ipv6_router_default | ||
USEMODULE += gnrc_udp | ||
# Add a routing protocol | ||
USEMODULE += gnrc_rpl | ||
USEMODULE += auto_init_gnrc_rpl | ||
# This application dumps received packets to STDIO using the pktdump module | ||
USEMODULE += gnrc_pktdump | ||
# Additional networking modules that can be dropped if not needed | ||
USEMODULE += gnrc_icmpv6_echo | ||
# Add also the shell, some shell commands | ||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
USEMODULE += ps | ||
USEMODULE += netstats_l2 | ||
USEMODULE += netstats_ipv6 | ||
USEMODULE += netstats_rpl | ||
|
||
# Set a custom 802.15.4 channel if needed | ||
DEFAULT_CHANNEL ?= 26 | ||
CFLAGS += -DDEFAULT_CHANNEL=$(DEFAULT_CHANNEL) | ||
|
||
CFLAGS += -DGNRC_RPL_LIFETIME_UNIT=1 -DGNRC_RPL_DEFAULT_LIFETIME=32 | ||
CFLAGS += -DGNRC_RPL_REGULAR_DAO_INTERVAL=13 | ||
CFLAGS += -DGNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS=13 | ||
|
||
# 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: | ||
CFLAGS += -DDEVELHELP | ||
|
||
# Comment this out to join RPL DODAGs even if DIOs do not contain | ||
# DODAG Configuration Options (see the doc for more info) | ||
# CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (C) 2015 Freie Universität Berlin | ||
* Copyright (C) 2016 Hochschule für Angewandte Wissenschaften Hamburg | ||
* | ||
* 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 Example application for demonstrating the RIOT network stack | ||
* | ||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> | ||
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "shell.h" | ||
#include "msg.h" | ||
#include "thread.h" | ||
|
||
#include "net/gnrc.h" | ||
#include "net/gnrc/ipv6/netif.h" | ||
#include "net/gnrc/ipv6.h" | ||
|
||
#define MAIN_QUEUE_SIZE (8) | ||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; | ||
|
||
extern int udp_cmd(int argc, char **argv); | ||
|
||
static const shell_command_t shell_commands[] = { | ||
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd }, | ||
{ NULL, NULL, NULL } | ||
}; | ||
|
||
#ifdef MODULE_GNRC_SIXLOWPAN | ||
static char _stack[THREAD_STACKSIZE_MAIN]; | ||
|
||
static void *_ipv6_fwd_eventloop(void *arg) | ||
{ | ||
(void)arg; | ||
|
||
msg_t msg, msg_q[8]; | ||
gnrc_netreg_entry_t me_reg; | ||
|
||
msg_init_queue(msg_q, 8); | ||
|
||
me_reg.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL; | ||
me_reg.pid = thread_getpid(); | ||
|
||
gnrc_netreg_register(GNRC_NETTYPE_SIXLOWPAN, &me_reg); | ||
|
||
while(1) { | ||
msg_receive(&msg); | ||
gnrc_pktsnip_t *pkt = msg.content.ptr; | ||
if(msg.type == GNRC_NETAPI_MSG_TYPE_SND) { | ||
gnrc_pktsnip_t *ipv6 = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_IPV6); | ||
ipv6 = ipv6->data; | ||
|
||
ipv6_hdr_t *ipv6_hdr =(ipv6_hdr_t *)ipv6; | ||
|
||
/* get the first IPv6 interface and prints its address */ | ||
kernel_pid_t ifs[GNRC_NETIF_NUMOF]; | ||
gnrc_netif_get(ifs); | ||
gnrc_ipv6_netif_t *entry = gnrc_ipv6_netif_get(ifs[0]); | ||
for (int i = 0; i < GNRC_IPV6_NETIF_ADDR_NUMOF; i++) { | ||
if ( (!ipv6_addr_is_link_local(&entry->addrs[i].addr)) && (!ipv6_addr_is_link_local(&ipv6_hdr->src)) | ||
&& (!ipv6_addr_is_link_local(&ipv6_hdr->dst)) && !(entry->addrs[i].flags & GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST) | ||
&& (!ipv6_addr_is_unspecified(&entry->addrs[i].addr)) ) { | ||
|
||
if(!ipv6_addr_equal(&entry->addrs[i].addr, &(ipv6_hdr->src))){ | ||
|
||
char addr_str[IPV6_ADDR_MAX_STR_LEN]; | ||
printf("IPv6 ROUTER: forward from src = %s ", ipv6_addr_to_str(addr_str, &(ipv6_hdr->src), sizeof(addr_str)) ); | ||
printf("to dst = %s\n",ipv6_addr_to_str(addr_str, &(ipv6_hdr->dst), sizeof(addr_str))); | ||
} | ||
} | ||
} | ||
} | ||
gnrc_pktbuf_release(pkt); | ||
} | ||
/* never reached */ | ||
return NULL; | ||
} | ||
#endif | ||
|
||
int main(void) | ||
{ | ||
/* we need a message queue for the thread running the shell in order to | ||
* receive potentially fast incoming networking packets */ | ||
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); | ||
puts("RIOT network stack example application"); | ||
|
||
#ifdef MODULE_GNRC_SIXLOWPAN | ||
thread_create(_stack, sizeof(_stack), (THREAD_PRIORITY_MAIN - 4), | ||
THREAD_CREATE_STACKTEST, _ipv6_fwd_eventloop, NULL, "ipv6_fwd"); | ||
#endif | ||
/* 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; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.