Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,26 @@ ifneq (,$(filter destiny,$(USEMODULE)))
endif
endif

ifneq (,$(filter sixlowborder,$(USEMODULE)))
ifeq (,$(filter sixlowpan,$(USEMODULE)))
USEMODULE += sixlowpan
endif
endif

ifneq (,$(filter sixlowpan,$(USEMODULE)))
ifeq (,$(filter ieee802154,$(USEMODULE)))
USEMODULE += ieee802154
endif
ifeq (,$(filter net_help,$(USEMODULE)))
USEMODULE += net_help
endif
ifeq (,$(filter semaphore,$(USEMODULE)))
USEMODULE += semaphore
ifeq (,$(filter net_if,$(USEMODULE)))
USEMODULE += net_if
endif
ifeq (,$(filter transceiver,$(USEMODULE)))
USEMODULE += transceiver
ifeq (,$(filter semaphore, $(USEMODULE)))
USEMODULE += semaphore
endif
ifeq (,$(filter vtimer,$(USEMODULE)))
ifeq (,$(filter vtimer, $(USEMODULE)))
USEMODULE += vtimer
endif
endif
Expand All @@ -102,3 +108,15 @@ ifneq (,$(filter vtimer,$(USEMODULE)))
USEMODULE += timex
endif
endif

ifneq (,$(filter net_if,$(USEMODULE)))
ifeq (,$(filter transceiver,$(USEMODULE)))
USEMODULE += transceiver
endif
endif

ifneq (,$(filter shell_commands,$(USEMODULE)))
ifneq (,$(filter net_if,$(USEMODULE)))
USEMODULE += net_help
endif
endif
12 changes: 2 additions & 10 deletions examples/rpl_udp/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ extern uint8_t ipv6_ext_hdr_len;

msg_t msg_q[RCV_BUFFER_SIZE];

/* prints current IPv6 adresses */
void rpl_udp_ip(int argc, char **argv)
{
(void) argc;
(void) argv;

ipv6_iface_print_addrs();
}

void rpl_udp_set_id(int argc, char **argv)
{
if (argc != 2) {
Expand Down Expand Up @@ -95,7 +86,8 @@ void rpl_udp_monitor(void)
else if (m.type == IPV6_PACKET_RECEIVED) {
ipv6_buf = (ipv6_hdr_t *) m.content.ptr;
printf("IPv6 datagram received (next header: %02X)", ipv6_buf->nextheader);
printf(" from %s ", ipv6_addr_to_str(addr_str, &ipv6_buf->srcaddr));
printf(" from %s ", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
&ipv6_buf->srcaddr));

if (ipv6_buf->nextheader == IPV6_PROTO_NUM_ICMPV6) {
icmpv6_buf = (icmpv6_hdr_t *) &ipv6_buf[(LL_HDR_LEN + IPV6_HDR_LEN) + ipv6_ext_hdr_len];
Expand Down
3 changes: 2 additions & 1 deletion examples/rpl_udp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <stdio.h>

#include "net_if.h"
#include "posix_io.h"
#include "shell.h"
#include "shell_commands.h"
Expand All @@ -37,7 +38,6 @@ const shell_command_t shell_commands[] = {
{"loop", "", rpl_udp_loop},
{"server", "Starts a UDP server", udp_server},
{"send", "Send a UDP datagram", udp_send},
{"ip", "Print all assigned IP addresses", rpl_udp_ip},
{"ign", "ignore node", rpl_udp_ignore},
{NULL, NULL, NULL}
};
Expand All @@ -48,6 +48,7 @@ int main(void)

/* start shell */
posix_open(uart0_handler_pid, 0);
net_if_set_src_address_mode(0, NET_IF_TRANS_ADDR_M_SHORT);

shell_t shell;
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
Expand Down
33 changes: 22 additions & 11 deletions examples/rpl_udp/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>
#include "vtimer.h"
#include "thread.h"
#include "net_if.h"
#include "sixlowpan.h"
#include "destiny.h"
#include "rpl.h"
Expand Down Expand Up @@ -64,7 +65,9 @@ void rpl_udp_init(int argc, char **argv)
return;
}

state = rpl_init(TRANSCEIVER, id);
net_if_set_hardware_address(0, id);

state = rpl_init(0);

if (state != SIXLOWERROR_SUCCESS) {
printf("Error initializing RPL\n");
Expand Down Expand Up @@ -95,11 +98,13 @@ void rpl_udp_init(int argc, char **argv)
ipv6_addr_t prefix, tmp;
ipv6_addr_init(&std_addr, 0xABCD, 0xEF12, 0, 0, 0x1034, 0x00FF, 0xFE00, id);
ipv6_addr_init_prefix(&prefix, &std_addr, 64);
plist_add(&prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE, 0, 1, ICMPV6_NDP_OPT_PI_FLAG_AUTONOM);
ipv6_init_iface_as_router();
ndp_add_prefix_info(0, &prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE,
NDP_OPT_PI_PLIFETIME_INFINITE, 1,
ICMPV6_NDP_OPT_PI_FLAG_AUTONOM);
ipv6_init_as_router();
/* add global address */
ipv6_addr_set_by_eui64(&tmp, &std_addr);
ipv6_iface_add_addr(&tmp, IPV6_ADDR_TYPE_GLOBAL, NDP_ADDR_STATE_PREFERRED, 0, 0);
ipv6_addr_set_by_eui64(&tmp, 0, &std_addr);
ipv6_net_if_add_addr(0, &tmp, NDP_ADDR_STATE_PREFERRED, 0, 0, 0);

/* set channel to 10 */
tcmd.transceivers = TRANSCEIVER;
Expand Down Expand Up @@ -134,17 +139,20 @@ void rpl_udp_loop(int argc, char **argv)

if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->my_preferred_parent->addr)));
printf("parent lifetime: %d\n", mydodag->my_preferred_parent->lifetime);
}

printf("---------------------------$\n");

for (int i = 0; i < RPL_MAX_ROUTING_ENTRIES; i++) {
if (rtable[i].used) {
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].address)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].address)));
puts("next hop");
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].next_hop)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].next_hop)));
printf("entry %d lifetime %d\n", i, rtable[i].lifetime);

if (!rpl_equal_id(&rtable[i].address, &rtable[i].next_hop)) {
Expand All @@ -171,7 +179,8 @@ void rpl_udp_table(int argc, char **argv)

for (int i = 0; i < RPL_MAX_ROUTING_ENTRIES; i++) {
if (rtable[i].used) {
printf("%s\n", ipv6_addr_to_str(addr_str, (&rtable[i].address)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&rtable[i].address)));
printf("entry %d lifetime %d\n", i, rtable[i].lifetime);

if (!rpl_equal_id(&rtable[i].address, &rtable[i].next_hop)) {
Expand Down Expand Up @@ -200,12 +209,14 @@ void rpl_udp_dodag(int argc, char **argv)
}

printf("Part of Dodag:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->dodag_id)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->dodag_id)));
printf("my rank: %d\n", mydodag->my_rank);

if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
printf("%s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
(&mydodag->my_preferred_parent->addr)));
}

printf("---------------------------\n");
Expand Down
4 changes: 3 additions & 1 deletion examples/rpl_udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ void udp_send(int argc, char **argv)
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, &ipaddr));
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,
&ipaddr));
}

destiny_socket_close(sock);
Expand Down
6 changes: 6 additions & 0 deletions sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ endif
ifneq (,$(filter vtimer,$(USEMODULE)))
DIRS += vtimer
endif
ifneq (,$(filter net_if,$(USEMODULE)))
DIRS += net/link_layer/net_if
endif
ifneq (,$(filter destiny,$(USEMODULE)))
DIRS += net/transport_layer/destiny
endif
Expand All @@ -54,6 +57,9 @@ endif
ifneq (,$(filter sixlowpan,$(USEMODULE)))
DIRS += net/network_layer/sixlowpan
endif
ifneq (,$(filter sixlowborder,$(USEMODULE)))
DIRS += net/network_layer/sixlowpan/border
endif
ifneq (,$(filter rpl,$(USEMODULE)))
DIRS += net/routing/rpl
endif
Expand Down
4 changes: 4 additions & 0 deletions sys/auto_init/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MODULE = auto_init

ifneq (,$(filter net_if,$(USEMODULE)))
INCLUDES += -I$(RIOTBASE)/sys/net/include/
endif

include $(RIOTBASE)/Makefile.base
71 changes: 71 additions & 0 deletions sys/auto_init/auto_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,30 @@
#include "rtc.h"
#endif

#ifdef MODULE_SIXLOWPAN
#include "sixlowpan.h"
#endif

#ifdef MODULE_DESTINY
#include "destiny.h"
#endif

#ifdef MODULE_NET_IF
#include "net_if.h"
#include "transceiver.h"
#endif

#define ENABLE_DEBUG (0)
#include "debug.h"

#ifndef CONF_RADIO_ADDR
#define CONF_RADIO_ADDR (1)
#endif

#ifndef CONF_PAN_ID
#define CONF_PAN_ID (0xabcd)
#endif

extern int main(void);

void auto_init(void)
Expand Down Expand Up @@ -97,6 +114,60 @@ void auto_init(void)
DEBUG("Auto init mci module.\n");
MCI_initialize();
#endif
#ifdef MODULE_NET_IF
int iface;
DEBUG("Auto init net_if module.\n");
transceiver_type_t transceivers = 0;
#ifdef MODULE_AT86RF231
transceivers |= TRANSCEIVER_AT86RF231;
#endif
#ifdef MODULE_CC1020
transceivers |= TRANSCEIVER_CC1020;
#endif
#if MODULE_CC110X || MODULE_CC110X_NG
transceivers |= TRANSCEIVER_CC1100;
#endif
#ifdef MODULE_CC2420
transceivers |= TRANSCEIVER_CC2420;
#endif
#ifdef MODULE_MC1322X
transceivers |= TRANSCEIVER_MC1322X;
#endif
#ifdef MODULE_NATIVENET
transceivers |= TRANSCEIVER_NATIVE;
#endif
net_if_init();

if (transceivers != 0) {
transceiver_init(transceivers);
transceiver_start();
iface = net_if_init_interface(0, transceivers);

if (!net_if_get_hardware_address(iface)) {
DEBUG("Auto init radio address on interface %d to 0x%04x\n", iface, CONF_RADIO_ADDR);
DEBUG("Change this value at compile time with macro CONF_RADIO_ADDR\n");
net_if_set_hardware_address(iface, CONF_RADIO_ADDR);
}

if (net_if_get_pan_id(iface) <= 0) {
DEBUG("Auto init PAN ID on interface %d to 0x%04x\n", iface, CONF_PAN_ID);
DEBUG("Change this value at compile time with macro CONF_PAN_ID\n");
net_if_set_pan_id(iface, CONF_PAN_ID);
}

if (iface >= 0) {
DEBUG("Auto init interface %d\n", iface);
}
}
else {
iface = -1;
}

#ifdef MODULE_SIXLOWPAN
DEBUG("Auto init 6LoWPAN module.\n");
sixlowpan_lowpan_init();
#endif
#endif
#ifdef MODULE_PROFILING
extern void profiling_init(void);
profiling_init();
Expand Down
7 changes: 7 additions & 0 deletions sys/include/transceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
*/
typedef uint16_t transceiver_type_t;

/**
* @brief Data type to represent the transceiver's EUI-64.
*/
typedef uint64_t transceiver_eui64_t;

/**
* @brief Message types for transceiver interface
*/
Expand All @@ -129,6 +134,8 @@ enum transceiver_msg_type_t {
SET_CHANNEL, ///< Set a new channel
GET_ADDRESS, ///< Get the radio address
SET_ADDRESS, ///< Set the radio address
GET_LONG_ADDR, ///< Get the long radio address, if existing
SET_LONG_ADDR, ///< Set the long radio address, if supported by hardware
SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking)
GET_PAN, ///< Get current pan
SET_PAN, ///< Set a new pan
Expand Down
Loading