examples: cleanup for rpl_udp
* removed unnecessary shell commands * updated documentation * Unified global default IP address
This commit is contained in:
parent
ea1d1d68b6
commit
4e39f68dd4
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 INRIA
|
* Copyright (C) 2013, 2014 INRIA
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 INRIA
|
* Copyright (C) 2013. 2014 INRIA
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -32,12 +32,10 @@
|
|||||||
const shell_command_t shell_commands[] = {
|
const shell_command_t shell_commands[] = {
|
||||||
{"init", "Initialize network", rpl_udp_init},
|
{"init", "Initialize network", rpl_udp_init},
|
||||||
{"set", "Set ID", rpl_udp_set_id},
|
{"set", "Set ID", rpl_udp_set_id},
|
||||||
{"table", "Shows the routing table", rpl_udp_table},
|
|
||||||
{"dodag", "Shows the dodag", rpl_udp_dodag},
|
{"dodag", "Shows the dodag", rpl_udp_dodag},
|
||||||
{"loop", "", rpl_udp_loop},
|
|
||||||
{"server", "Starts a UDP server", udp_server},
|
{"server", "Starts a UDP server", udp_server},
|
||||||
{"send", "Send a UDP datagram", udp_send},
|
{"send", "Send a UDP datagram", udp_send},
|
||||||
{"ign", "ignore node", rpl_udp_ignore},
|
{"ign", "Ignore a node", rpl_udp_ignore},
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 INRIA
|
* Copyright (C) 2013, 2014 INRIA
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -106,7 +106,7 @@ void rpl_udp_init(int argc, char **argv)
|
|||||||
|
|
||||||
/* TODO: check if this works as intended */
|
/* TODO: check if this works as intended */
|
||||||
ipv6_addr_t prefix, tmp;
|
ipv6_addr_t prefix, tmp;
|
||||||
ipv6_addr_init(&std_addr, 0xABCD, 0xEF12, 0, 0, 0x1034, 0x00FF, 0xFE00, id);
|
ipv6_addr_init(&std_addr, 0xabcd, 0x0, 0x0, 0x0, 0x3612, 0x00ff, 0xfe00, id);
|
||||||
ipv6_addr_init_prefix(&prefix, &std_addr, 64);
|
ipv6_addr_init_prefix(&prefix, &std_addr, 64);
|
||||||
ndp_add_prefix_info(0, &prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE,
|
ndp_add_prefix_info(0, &prefix, 64, NDP_OPT_PI_VLIFETIME_INFINITE,
|
||||||
NDP_OPT_PI_PLIFETIME_INFINITE, 1,
|
NDP_OPT_PI_PLIFETIME_INFINITE, 1,
|
||||||
@ -129,81 +129,6 @@ void rpl_udp_init(int argc, char **argv)
|
|||||||
/* start transceiver watchdog */
|
/* start transceiver watchdog */
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpl_udp_loop(int argc, char **argv)
|
|
||||||
{
|
|
||||||
(void) argc;
|
|
||||||
(void) argv;
|
|
||||||
|
|
||||||
rpl_routing_entry_t *rtable;
|
|
||||||
|
|
||||||
rtable = rpl_get_routing_table();
|
|
||||||
rpl_dodag_t *mydodag = rpl_get_my_dodag();
|
|
||||||
|
|
||||||
if (mydodag == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("---------------------------\n");
|
|
||||||
printf("OUTPUT\n");
|
|
||||||
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, 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, IPV6_MAX_ADDR_STR_LEN,
|
|
||||||
(&rtable[i].address)));
|
|
||||||
puts("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)) {
|
|
||||||
puts("multi-hop");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("---------------------------$\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("########################\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void rpl_udp_table(int argc, char **argv)
|
|
||||||
{
|
|
||||||
(void) argc;
|
|
||||||
(void) argv;
|
|
||||||
|
|
||||||
rpl_routing_entry_t *rtable;
|
|
||||||
rtable = rpl_get_routing_table();
|
|
||||||
printf("---------------------------\n");
|
|
||||||
printf("OUTPUT\n");
|
|
||||||
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, 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)) {
|
|
||||||
puts("multi-hop");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("--------------\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("$\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void rpl_udp_dodag(int argc, char **argv)
|
void rpl_udp_dodag(int argc, char **argv)
|
||||||
{
|
{
|
||||||
(void) argc;
|
(void) argc;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef RPL_UDP_H
|
#ifndef RPL_UDP_H
|
||||||
#define RPL_UDP_H
|
#define RPL_UDP_H
|
||||||
|
|
||||||
#define APP_VERSION "1.1"
|
#define APP_VERSION "1.2"
|
||||||
|
|
||||||
#define RADIO_CHANNEL (10)
|
#define RADIO_CHANNEL (10)
|
||||||
|
|
||||||
@ -10,43 +10,85 @@
|
|||||||
|
|
||||||
/* RPL shell command handlers */
|
/* RPL shell command handlers */
|
||||||
/**
|
/**
|
||||||
* @brief Shell command to initializes RPL and Destiny
|
* @brief Shell command to initializes RPL and UDP
|
||||||
|
*
|
||||||
|
* @details Usage: init <r|n>
|
||||||
|
* `init r` will initialize the node as a RPL root node,
|
||||||
|
* `init n` as a RPL node.
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
*/
|
*/
|
||||||
void rpl_udp_init(int argc, char **argv);
|
void rpl_udp_init(int argc, char **argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shell command to set node's ID
|
* @brief Shell command to set node's ID
|
||||||
|
*
|
||||||
|
* @details Usage: set <ID>
|
||||||
|
* Set the node address
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
*/
|
*/
|
||||||
void rpl_udp_set_id(int argc, char **argv);
|
void rpl_udp_set_id(int argc, char **argv);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Loops through the routing table
|
|
||||||
*/
|
|
||||||
void rpl_udp_loop(int argc, char **argv);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Shows the routing table
|
|
||||||
*/
|
|
||||||
void rpl_udp_table(int argc, char **argv);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shows the dodag
|
* @brief Shows the dodag
|
||||||
|
*
|
||||||
|
* @details No parameters required
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
*/
|
*/
|
||||||
void rpl_udp_dodag(int argc, char **argv);
|
void rpl_udp_dodag(int argc, char **argv);
|
||||||
|
|
||||||
/* UDP shell command handlers */
|
/**
|
||||||
|
* @brief Command handler to start a UDP server
|
||||||
|
*
|
||||||
|
* @details No parameters required
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
|
*/
|
||||||
void udp_server(int argc, char **argv);
|
void udp_server(int argc, char **argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sends a UDP datagram
|
||||||
|
*
|
||||||
|
* @details Usage: send <ID> <TEXT>
|
||||||
|
* Sends TEXT to the node with IP address:
|
||||||
|
* fe80::ff:fe00:<ID>
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
|
*/
|
||||||
void udp_send(int argc, char **argv);
|
void udp_send(int argc, char **argv);
|
||||||
|
|
||||||
/* helper command handlers */
|
/**
|
||||||
void rpl_udp_ip(int argc, char **argv);
|
* @brief Ignore a certain node
|
||||||
|
*
|
||||||
|
* @details Usage: ignore <ID>
|
||||||
|
* Ignore the node with IP address:
|
||||||
|
* fe80::ff:fe00:<ID>
|
||||||
|
*
|
||||||
|
* @param[in] argc Argument count
|
||||||
|
* @param[in] argv Arguments
|
||||||
|
*/
|
||||||
void rpl_udp_ignore(int argc, char **argv);
|
void rpl_udp_ignore(int argc, char **argv);
|
||||||
|
|
||||||
/* monitoring thread */
|
/**
|
||||||
|
* @brief monitoring thread start function
|
||||||
|
*
|
||||||
|
* @param arg Unused
|
||||||
|
*/
|
||||||
void *rpl_udp_monitor(void *arg);
|
void *rpl_udp_monitor(void *arg);
|
||||||
|
|
||||||
|
/** @brief The nodes radio address */
|
||||||
extern radio_address_t id;
|
extern radio_address_t id;
|
||||||
|
|
||||||
|
/** @brief The node's default IP address */
|
||||||
extern ipv6_addr_t std_addr;
|
extern ipv6_addr_t std_addr;
|
||||||
|
|
||||||
|
/** @brief Char array for IP address printing */
|
||||||
extern char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
extern char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
||||||
#endif /* RPL_UDP_H */
|
#endif /* RPL_UDP_H */
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 INRIA
|
* Copyright (C) 2013, 2014 INRIA
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU Lesser
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user