1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Fix apps for previous changes

This commit is contained in:
Martin Lenders 2014-02-13 16:06:25 +01:00
parent 6c9578c028
commit 3a8c1770b1
5 changed files with 38 additions and 28 deletions

View File

@ -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) {
@ -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];

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include "net_if.h"
#include "posix_io.h"
#include "shell.h"
#include "shell_commands.h"
@ -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}
};
@ -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);

View File

@ -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"
@ -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");
@ -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;
@ -134,7 +139,8 @@ 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);
}
@ -142,9 +148,11 @@ void rpl_udp_loop(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)));
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)) {
@ -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)) {
@ -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");

View File

@ -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);

View File

@ -27,7 +27,7 @@
#include <netinet/in.h>
#include <unistd.h>
#include "transceiver.h"
#include "net_if.h"
#include "ipv6.h"
#ifdef MODULE_NATIVENET
@ -42,12 +42,13 @@
#define PORT (1234)
void init_local_address(uint16_t r_addr)
int init_local_address(uint16_t r_addr)
{
ipv6_addr_t std_addr;
ipv6_addr_init(&std_addr, 0xabcd, 0xef12, 0, 0, 0x1034, 0x00ff, 0xfe00,
r_addr);
sixlowpan_lowpan_adhoc_init(TRANSCEIVER, &std_addr, r_addr);
0);
return net_if_set_hardware_address(r_addr) &&
sixlowpan_lowpan_adhoc_init(0, &std_addr);
}
int main(void)
@ -80,7 +81,10 @@ int main(void)
};
char buffer[14];
init_local_address(R_ADDR);
if (!init_local_address(R_ADDR)) {
fprintf(stderr, "Can not initialize IP for hardware address %d.", R_ADDR);
return 1;
}
memcpy(buffer, "Hello, World!", 14);
memcpy(&my_addr, &in6addr_any, sizeof(my_addr));