50#include "dev/watchdog.h"
58#if BUILD_WITH_HTTP_SOCKET
59#include "http-socket.h"
71#if ROUTING_CONF_RPL_LITE
72#include "net/routing/rpl-lite/rpl.h"
73#elif ROUTING_CONF_RPL_CLASSIC
74#include "net/routing/rpl-classic/rpl.h"
79#define PING_TIMEOUT (5 * CLOCK_SECOND)
81#if NETSTACK_CONF_WITH_IPV6
82static struct uip_icmp6_echo_reply_notification echo_reply_notification;
83static shell_output_func *curr_ping_output_func = NULL;
84static struct process *curr_ping_process;
85static uint8_t curr_ping_ttl;
86static uint16_t curr_ping_datalen;
89static shell_command_6top_sub_cmd_t sixtop_sub_cmd = NULL;
91static struct shell_command_set_t builtin_shell_command_set;
92LIST(shell_command_sets);
93#if NETSTACK_CONF_WITH_IPV6
96ds6_nbr_state_to_str(uint8_t state)
115echo_reply_handler(uip_ipaddr_t *source, uint8_t ttl, uint8_t *data, uint16_t datalen)
117 if(curr_ping_output_func != NULL) {
118 curr_ping_output_func = NULL;
120 curr_ping_datalen = datalen;
126PT_THREAD(cmd_ping(
struct pt *pt, shell_output_func output,
char *args))
128 static uip_ipaddr_t remote_addr;
129 static struct etimer timeout_timer;
134 SHELL_ARGS_INIT(args, next_args);
137 SHELL_ARGS_NEXT(args, next_args);
139 SHELL_OUTPUT(output,
"Destination IPv6 address is not specified\n");
142 SHELL_OUTPUT(output,
"Invalid IPv6 address: %s\n", args);
146 SHELL_OUTPUT(output,
"Pinging ");
147 shell_output_6addr(output, &remote_addr);
148 SHELL_OUTPUT(output,
"\n");
152 curr_ping_output_func = output;
157 if(curr_ping_output_func != NULL) {
158 SHELL_OUTPUT(output,
"Timeout\n");
159 curr_ping_output_func = NULL;
161 SHELL_OUTPUT(output,
"Received ping reply from ");
162 shell_output_6addr(output, &remote_addr);
163 SHELL_OUTPUT(output,
", len %u, ttl %u, delay %lu ms\n",
164 curr_ping_datalen, curr_ping_ttl,
172#if ROUTING_CONF_RPL_LITE
178 case DAG_INITIALIZED:
179 return "Initialized";
192rpl_mop_to_str(
int mop)
195 case RPL_MOP_NO_DOWNWARD_ROUTES:
196 return "No downward routes";
197 case RPL_MOP_NON_STORING:
198 return "Non-storing";
199 case RPL_MOP_STORING_NO_MULTICAST:
201 case RPL_MOP_STORING_MULTICAST:
202 return "Storing+multicast";
209rpl_ocp_to_str(
int ocp)
222PT_THREAD(cmd_rpl_nbr(
struct pt *pt, shell_output_func output,
char *args))
227 SHELL_OUTPUT(output,
"RPL neighbors: none\n");
230 SHELL_OUTPUT(output,
"RPL neighbors:\n");
234 SHELL_OUTPUT(output,
"%s\n", buf);
235 nbr = nbr_table_next(rpl_neighbors,
nbr);
243PT_THREAD(cmd_rpl_status(
struct pt *pt, shell_output_func output,
char *args))
247 SHELL_OUTPUT(output,
"RPL status:\n");
248 if(!curr_instance.used) {
249 SHELL_OUTPUT(output,
"-- Instance: None\n");
251 SHELL_OUTPUT(output,
"-- Instance: %u\n", curr_instance.instance_id);
253 SHELL_OUTPUT(output,
"-- DAG root\n");
255 SHELL_OUTPUT(output,
"-- DAG node\n");
257 SHELL_OUTPUT(output,
"-- DAG: ");
258 shell_output_6addr(output, &curr_instance.dag.dag_id);
259 SHELL_OUTPUT(output,
", version %u\n", curr_instance.dag.version);
260 SHELL_OUTPUT(output,
"-- Prefix: ");
261 shell_output_6addr(output, &curr_instance.dag.prefix_info.prefix);
262 SHELL_OUTPUT(output,
"/%u\n", curr_instance.dag.prefix_info.length);
263 SHELL_OUTPUT(output,
"-- MOP: %s\n", rpl_mop_to_str(curr_instance.mop));
264 SHELL_OUTPUT(output,
"-- OF: %s\n", rpl_ocp_to_str(curr_instance.of->ocp));
265 SHELL_OUTPUT(output,
"-- Hop rank increment: %u\n", curr_instance.min_hoprankinc);
266 SHELL_OUTPUT(output,
"-- Default lifetime: %lu seconds\n", RPL_LIFETIME(curr_instance.default_lifetime));
268 SHELL_OUTPUT(output,
"-- State: %s\n", rpl_state_to_str(curr_instance.dag.state));
269 SHELL_OUTPUT(output,
"-- Preferred parent: ");
270 if(curr_instance.dag.preferred_parent) {
272 SHELL_OUTPUT(output,
" (last DTSN: %u)\n", curr_instance.dag.preferred_parent->dtsn);
274 SHELL_OUTPUT(output,
"None\n");
276 SHELL_OUTPUT(output,
"-- Rank: %u\n", curr_instance.dag.rank);
277 SHELL_OUTPUT(output,
"-- Lowest rank: %u (%u)\n", curr_instance.dag.lowest_rank, curr_instance.max_rankinc);
278 SHELL_OUTPUT(output,
"-- DTSN out: %u\n", curr_instance.dtsn_out);
279 SHELL_OUTPUT(output,
"-- DAO sequence: last sent %u, last acked %u\n",
280 curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_last_acked_seqno);
281 SHELL_OUTPUT(output,
"-- Trickle timer: current %u, min %u, max %u, redundancy %u\n",
282 curr_instance.dag.dio_intcurrent, curr_instance.dio_intmin,
283 curr_instance.dio_intmin + curr_instance.dio_intdoubl, curr_instance.dio_redundancy);
291PT_THREAD(cmd_rpl_refresh_routes(
struct pt *pt, shell_output_func output,
char *args))
295 SHELL_OUTPUT(output,
"Triggering routes refresh\n");
303shell_output_log_levels(shell_output_func output)
306 SHELL_OUTPUT(output,
"Log levels:\n");
307 while(all_modules[i].name != NULL) {
308 SHELL_OUTPUT(output,
"-- %-10s: %u (%s)\n",
310 *all_modules[i].curr_log_level,
317PT_THREAD(cmd_log(
struct pt *pt, shell_output_func output,
char *args))
319 static int prev_level;
327 SHELL_ARGS_INIT(args, next_args);
330 SHELL_ARGS_NEXT(args, next_args);
333 SHELL_OUTPUT(output,
"Module is not specified\n");
337 if(module == NULL || (strcmp(
"all", module) && prev_level == -1)) {
338 SHELL_OUTPUT(output,
"Invalid first argument: %s\n", module)
339 shell_output_log_levels(output);
344 SHELL_ARGS_NEXT(args, next_args);
348 level = (int)strtol(args, &ptr, 10);
350 if((level == 0 && args == ptr)
351 || level < LOG_LEVEL_NONE || level > LOG_LEVEL_DBG) {
352 SHELL_OUTPUT(output,
"Invalid second argument: %s\n", args);
357 if(level != prev_level) {
359#if MAC_CONF_WITH_TSCH && TSCH_LOG_PER_SLOT
360 if(!strcmp(module,
"mac") || !strcmp(module,
"all")) {
361 if(level >= LOG_LEVEL_DBG) {
363 SHELL_OUTPUT(output,
"TSCH logging started\n");
366 SHELL_OUTPUT(output,
"TSCH logging stopped\n");
372 shell_output_log_levels(output);
378PT_THREAD(cmd_help(
struct pt *pt, shell_output_func output,
char *args))
380 struct shell_command_set_t *set;
381 const struct shell_command_t *cmd;
384 SHELL_OUTPUT(output,
"Available commands:\n");
387 for(cmd = set->commands; cmd->name != NULL; ++cmd) {
388 SHELL_OUTPUT(output,
"%s\n", cmd->help);
397PT_THREAD(cmd_rpl_set_root(
struct pt *pt, shell_output_func output,
char *args))
400 static uip_ipaddr_t prefix;
405 SHELL_ARGS_INIT(args, next_args);
408 SHELL_ARGS_NEXT(args, next_args);
410 SHELL_OUTPUT(output,
"On-flag (0 or 1) is not specified\n");
414 if(!strcmp(args,
"1")) {
416 }
else if(!strcmp(args,
"0")) {
419 SHELL_OUTPUT(output,
"Invalid argument: %s\n", args);
424 SHELL_ARGS_NEXT(args, next_args);
427 SHELL_OUTPUT(output,
"Invalid Prefix: %s\n", args);
432 uip_ip6addr_copy(&prefix, default_prefix);
437 SHELL_OUTPUT(output,
"Setting as DAG root with prefix ");
438 shell_output_6addr(output, &prefix);
439 SHELL_OUTPUT(output,
"/64\n");
443 SHELL_OUTPUT(output,
"Node is already a DAG root\n");
447 SHELL_OUTPUT(output,
"Setting as non-root node: leaving DAG\n");
450 SHELL_OUTPUT(output,
"Node is not a DAG root\n");
458PT_THREAD(cmd_rpl_global_repair(
struct pt *pt, shell_output_func output,
char *args))
462 SHELL_OUTPUT(output,
"Triggering routing global repair\n");
469PT_THREAD(cmd_rpl_local_repair(
struct pt *pt, shell_output_func output,
char *args))
473 SHELL_OUTPUT(output,
"Triggering routing local repair\n");
481PT_THREAD(cmd_macaddr(
struct pt *pt, shell_output_func output,
char *args))
485 SHELL_OUTPUT(output,
"Node MAC address: ");
487 SHELL_OUTPUT(output,
"\n");
491#if NETSTACK_CONF_WITH_IPV6
494PT_THREAD(cmd_ipaddr(
struct pt *pt, shell_output_func output,
char *args))
501 SHELL_OUTPUT(output,
"Node IPv6 addresses:\n");
502 for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
506 SHELL_OUTPUT(output,
"-- ");
507 shell_output_6addr(output, &
uip_ds6_if.addr_list[i].ipaddr);
508 SHELL_OUTPUT(output,
"\n");
516PT_THREAD(cmd_ip_neighbors(
struct pt *pt, shell_output_func output,
char *args))
524 SHELL_OUTPUT(output,
"Node IPv6 neighbors: none\n");
528 SHELL_OUTPUT(output,
"Node IPv6 neighbors:\n");
530 SHELL_OUTPUT(output,
"-- ");
532 SHELL_OUTPUT(output,
" <-> ");
534 SHELL_OUTPUT(output,
", router %u, state %s ",
535 nbr->isrouter, ds6_nbr_state_to_str(
nbr->state));
536 SHELL_OUTPUT(output,
"\n");
544#if MAC_CONF_WITH_TSCH
547PT_THREAD(cmd_tsch_set_coordinator(
struct pt *pt, shell_output_func output,
char *args))
550 static int is_secured;
555 SHELL_ARGS_INIT(args, next_args);
558 SHELL_ARGS_NEXT(args, next_args);
560 SHELL_OUTPUT(output,
"On-flag (0 or 1) is not specified\n");
564 if(!strcmp(args,
"1")) {
566 }
else if(!strcmp(args,
"0")) {
569 SHELL_OUTPUT(output,
"Invalid first argument: %s\n", args);
574 SHELL_ARGS_NEXT(args, next_args);
576 if(!strcmp(args,
"1")) {
577#if LLSEC802154_ENABLED
580 SHELL_OUTPUT(output,
"Security is not compiled in.\n");
583 }
else if(!strcmp(args,
"0")) {
586 SHELL_OUTPUT(output,
"Invalid second argument: %s\n", args);
593 SHELL_OUTPUT(output,
"Setting as TSCH %s (%s)\n",
594 is_on ?
"coordinator" :
"non-coordinator", is_secured ?
"secured" :
"non-secured");
603PT_THREAD(cmd_tsch_status(
struct pt *pt, shell_output_func output,
char *args))
607 SHELL_OUTPUT(output,
"TSCH status:\n");
609 SHELL_OUTPUT(output,
"-- Is coordinator: %u\n", tsch_is_coordinator);
610 SHELL_OUTPUT(output,
"-- Is associated: %u\n", tsch_is_associated);
611 if(tsch_is_associated) {
613 SHELL_OUTPUT(output,
"-- PAN ID: 0x%x\n", frame802154_get_pan_id());
614 SHELL_OUTPUT(output,
"-- Is PAN secured: %u\n", tsch_is_pan_secured);
615 SHELL_OUTPUT(output,
"-- Join priority: %u\n", tsch_join_priority);
616 SHELL_OUTPUT(output,
"-- Time source: ");
619 SHELL_OUTPUT(output,
"\n");
621 SHELL_OUTPUT(output,
"none\n");
623 SHELL_OUTPUT(output,
"-- Last synchronized: %lu seconds ago\n",
625 SHELL_OUTPUT(output,
"-- Drift w.r.t. coordinator: %ld ppm\n",
627 SHELL_OUTPUT(output,
"-- Network uptime: %lu seconds\n",
634#if NETSTACK_CONF_WITH_IPV6
637PT_THREAD(cmd_routes(
struct pt *pt, shell_output_func output,
char *args))
644 SHELL_OUTPUT(output,
"Default route:\n");
645 default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
646 if(default_route != NULL) {
647 SHELL_OUTPUT(output,
"-- ");
648 shell_output_6addr(output, &default_route->ipaddr);
649 if(default_route->lifetime.interval != 0) {
650 SHELL_OUTPUT(output,
" (lifetime: %lu seconds)\n", (
unsigned long)default_route->lifetime.interval);
652 SHELL_OUTPUT(output,
" (lifetime: infinite)\n");
655 SHELL_OUTPUT(output,
"-- None\n");
664 while(link != NULL) {
667 SHELL_OUTPUT(output,
"-- %s\n", buf);
671 SHELL_OUTPUT(output,
"No routing links\n");
675#if (UIP_MAX_ROUTES != 0)
676 if(uip_ds6_route_num_routes() > 0) {
679 SHELL_OUTPUT(output,
"Routing entries (%u in total):\n", uip_ds6_route_num_routes());
680 route = uip_ds6_route_head();
681 while(route != NULL) {
682 SHELL_OUTPUT(output,
"-- ");
683 shell_output_6addr(output, &route->ipaddr);
684 SHELL_OUTPUT(output,
" via ");
685 shell_output_6addr(output, uip_ds6_route_nexthop(route));
686 if((
unsigned long)route->state.lifetime != 0xFFFFFFFF) {
687 SHELL_OUTPUT(output,
" (lifetime: %lu seconds)\n", (
unsigned long)route->state.lifetime);
689 SHELL_OUTPUT(output,
" (lifetime: infinite)\n");
691 route = uip_ds6_route_next(route);
694 SHELL_OUTPUT(output,
"No routing entries\n");
703PT_THREAD(cmd_resolv(
struct pt *pt, shell_output_func output,
char *args))
706 static struct etimer timeout_timer;
707 static int count, ret;
709 static uip_ipaddr_t *remote_addr = NULL;
710 SHELL_ARGS_INIT(args, next_args);
713 SHELL_ARGS_NEXT(args, next_args);
715 SHELL_OUTPUT(output,
"Destination host is not specified\n");
720 SHELL_OUTPUT(output,
"Looking up IPv6 address for host: %s\n", args);
728 printf(
"resoliving again...\n");
735 SHELL_OUTPUT(output,
"Did not find IPv6 address for host: %s\n", args);
737 SHELL_OUTPUT(output,
"Found IPv6 address for host: %s => ", args);
738 shell_output_6addr(output, remote_addr);
739 SHELL_OUTPUT(output,
"\n");
746#if BUILD_WITH_HTTP_SOCKET
747static struct http_socket s;
748static int bytes_received = 0;
751http_callback(
struct http_socket *s,
void *ptr,
752 http_socket_event_t e,
753 const uint8_t *data, uint16_t datalen)
755 if(e == HTTP_SOCKET_ERR) {
756 printf(
"HTTP socket error\n");
757 }
else if(e == HTTP_SOCKET_TIMEDOUT) {
758 printf(
"HTTP socket error: timed out\n");
759 }
else if(e == HTTP_SOCKET_ABORTED) {
760 printf(
"HTTP socket error: aborted\n");
761 }
else if(e == HTTP_SOCKET_HOSTNAME_NOT_FOUND) {
762 printf(
"HTTP socket error: hostname not found\n");
763 }
else if(e == HTTP_SOCKET_CLOSED) {
764 printf(
"HTTP socket closed, %d bytes received\n", bytes_received);
765 }
else if(e == HTTP_SOCKET_DATA) {
767 if(bytes_received == 0) {
768 printf(
"HTTP socket received data, total expects:%d\n", (
int) s->header.content_length);
771 bytes_received += datalen;
772 for(i = 0; i < datalen; i++) {
773 printf(
"%c", data[i]);
779PT_THREAD(cmd_wget(
struct pt *pt, shell_output_func output,
char *args))
783 SHELL_ARGS_INIT(args, next_args);
786 SHELL_ARGS_NEXT(args, next_args);
788 SHELL_OUTPUT(output,
"URL is not specified\n");
792 SHELL_OUTPUT(output,
"Fetching web page at %s\n", args);
793 http_socket_init(&s);
794 http_socket_get(&s, args, 0, 0,
795 http_callback, NULL);
805PT_THREAD(cmd_reboot(
struct pt *pt, shell_output_func output,
char *args))
808 SHELL_OUTPUT(output,
"rebooting\n");
812#if MAC_CONF_WITH_TSCH
815PT_THREAD(cmd_tsch_schedule(
struct pt *pt, shell_output_func output,
char *args))
828 SHELL_OUTPUT(output,
"TSCH schedule: no slotframe\n");
830 SHELL_OUTPUT(output,
"TSCH schedule:\n");
834 SHELL_OUTPUT(output,
"-- Slotframe: handle %u, size %u, links:\n", sf->handle, sf->size.val);
837 SHELL_OUTPUT(output,
"---- Options %02x, type %u, timeslot %u, channel offset %u, address ",
838 l->link_options, l->link_type, l->timeslot, l->channel_offset);
839 shell_output_lladdr(output, &l->addr);
840 SHELL_OUTPUT(output,
"\n");
853shell_commands_set_6top_sub_cmd(shell_command_6top_sub_cmd_t sub_cmd)
855 sixtop_sub_cmd = sub_cmd;
859PT_THREAD(cmd_6top(
struct pt *pt, shell_output_func output,
char *args))
865 SHELL_ARGS_INIT(args, next_args);
867 if(sixtop_sub_cmd == NULL) {
868 SHELL_OUTPUT(output,
"6top command is unavailable:\n");
870 SHELL_OUTPUT(output,
"6top: ");
871 sixtop_sub_cmd(output, args);
873 SHELL_ARGS_NEXT(args, next_args);
879#if LLSEC802154_ENABLED
881PT_THREAD(cmd_llsec_setlv(
struct pt *pt, shell_output_func output,
char *args))
887 SHELL_OUTPUT(output,
"Default LLSEC level is %d\n",
888 uipbuf_get_attr(UIPBUF_ATTR_LLSEC_LEVEL));
892 if(lv < 0 || lv > 7) {
893 SHELL_OUTPUT(output,
"Illegal LLSEC Level %d\n", lv);
896 uipbuf_set_default_attr(UIPBUF_ATTR_LLSEC_LEVEL, lv);
898 SHELL_OUTPUT(output,
"LLSEC default level set %d\n", lv);
906PT_THREAD(cmd_llsec_setkey(
struct pt *pt, shell_output_func output,
char *args))
912 SHELL_ARGS_INIT(args, next_args);
915 SHELL_OUTPUT(output,
"Provide an index and a 16-char string for the key\n");
919 SHELL_ARGS_NEXT(args, next_args);
921 SHELL_OUTPUT(output,
"Key index is not specified\n");
926 SHELL_OUTPUT(output,
"Illegal LLSEC Key index %d\n", key);
929#if MAC_CONF_WITH_CSMA
931 SHELL_ARGS_NEXT(args, next_args);
933 SHELL_OUTPUT(output,
"Provide both an index and a key\n");
934 }
else if(strlen(args) == 16) {
935 csma_security_set_key(key, (
const uint8_t *) args);
936 SHELL_OUTPUT(output,
"Set key for index %d\n", key);
938 SHELL_OUTPUT(output,
"Wrong length of key: '%s' (%d)\n", args, strlen(args));
941 SHELL_OUTPUT(output,
"Set key not supported.\n");
954 list_add(shell_command_sets, &builtin_shell_command_set);
955#if NETSTACK_CONF_WITH_IPV6
963shell_command_set_register(
struct shell_command_set_t *set)
969shell_command_set_deregister(
struct shell_command_set_t *set)
978const struct shell_command_t *
979shell_command_lookup(
const char *name)
981 struct shell_command_set_t *set;
982 const struct shell_command_t *cmd;
987 for(cmd = set->commands; cmd->name != NULL; ++cmd) {
988 if(!strcmp(cmd->name, name)) {
996const struct shell_command_t builtin_shell_commands[] = {
997 {
"help", cmd_help,
"'> help': Shows this help" },
998 {
"reboot", cmd_reboot,
"'> reboot': Reboot the board by watchdog_reboot()" },
999 {
"log", cmd_log,
"'> log module level': Sets log level (0--4) for a given module (or \"all\"). For module \"mac\", level 4 also enables per-slot logging." },
1000 {
"mac-addr", cmd_macaddr,
"'> mac-addr': Shows the node's MAC address" },
1001#if NETSTACK_CONF_WITH_IPV6
1002 {
"ip-addr", cmd_ipaddr,
"'> ip-addr': Shows all IPv6 addresses" },
1003 {
"ip-nbr", cmd_ip_neighbors,
"'> ip-nbr': Shows all IPv6 neighbors" },
1004 {
"ping", cmd_ping,
"'> ping addr': Pings the IPv6 address 'addr'" },
1005 {
"routes", cmd_routes,
"'> routes': Shows the route entries" },
1006#if BUILD_WITH_RESOLV
1007 {
"nslookup", cmd_resolv,
"'> nslookup': Lookup IPv6 address of host" },
1009#if BUILD_WITH_HTTP_SOCKET
1010 {
"wget", cmd_wget,
"'> wget url': get content of URL (only http)." },
1013#if UIP_CONF_IPV6_RPL
1014 {
"rpl-set-root", cmd_rpl_set_root,
"'> rpl-set-root 0/1 [prefix]': Sets node as root (1) or not (0). A /64 prefix can be optionally specified." },
1015 {
"rpl-local-repair", cmd_rpl_local_repair,
"'> rpl-local-repair': Triggers a RPL local repair" },
1016#if ROUTING_CONF_RPL_LITE
1017 {
"rpl-refresh-routes", cmd_rpl_refresh_routes,
"'> rpl-refresh-routes': Refreshes all routes through a DTSN increment" },
1018 {
"rpl-status", cmd_rpl_status,
"'> rpl-status': Shows a summary of the current RPL state" },
1019 {
"rpl-nbr", cmd_rpl_nbr,
"'> rpl-nbr': Shows the RPL neighbor table" },
1021 {
"rpl-global-repair", cmd_rpl_global_repair,
"'> rpl-global-repair': Triggers a RPL global repair" },
1023#if MAC_CONF_WITH_TSCH
1024 {
"tsch-set-coordinator", cmd_tsch_set_coordinator,
"'> tsch-set-coordinator 0/1 [0/1]': Sets node as coordinator (1) or not (0). Second, optional parameter: enable (1) or disable (0) security." },
1025 {
"tsch-schedule", cmd_tsch_schedule,
"'> tsch-schedule': Shows the current TSCH schedule" },
1026 {
"tsch-status", cmd_tsch_status,
"'> tsch-status': Shows a summary of the current TSCH state" },
1029 {
"6top", cmd_6top,
"'> 6top help': Shows 6top command usage" },
1031#if LLSEC802154_ENABLED
1032 {
"llsec-set-level", cmd_llsec_setlv,
"'> llsec-set-level <lv>': Set the level of link layer security (show if no lv argument)"},
1033 {
"llsec-set-key", cmd_llsec_setkey,
"'> llsec-set-key <id> <key>': Set the key of link layer security"},
1035 { NULL, NULL, NULL },
1038static struct shell_command_set_t builtin_shell_command_set = {
1040 .commands = builtin_shell_commands,
The 802.15.4 standard CSMA protocol (nonbeacon-enabled)
clock_time_t clock_time(void)
Get the current clock time.
static volatile uint64_t count
Num.
#define CLOCK_SECOND
A second, measured in system clock time.
static bool etimer_expired(struct etimer *et)
Check if an event timer has expired.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
static void list_init(list_t list)
Initialize a list.
#define LIST(name)
Declare a linked list.
static void * list_item_next(const void *item)
Get the next item following this item.
void list_add(list_t list, void *item)
Add an item at the end of a list.
void list_remove(list_t list, const void *item)
Remove a specific element from a list.
void list_push(list_t list, void *item)
Add an item to the start of the list.
bool list_contains(const_list_t list, const void *item)
Check if the list contains an item.
static void * list_head(const_list_t list)
Get a pointer to the first element of a list.
void log_set_level(const char *module, int level)
Sets a log level at run-time.
const char * log_level_to_str(int level)
Returns a textual description of a log level.
int log_get_level(const char *module)
Returns the current log level.
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
void process_poll(struct process *p)
Request a process to be polled.
#define PT_BEGIN(pt)
Declare the start of a protothread inside the C function implementing the protothread.
#define PT_THREAD(name_args)
Declaration of a protothread.
#define PT_END(pt)
Declare the end of a protothread.
#define PT_EXIT(pt)
Exit the protothread.
#define PT_WAIT_UNTIL(pt, condition)
Block and wait until condition is true.
int rpl_neighbor_snprint(char *buf, int buflen, rpl_nbr_t *nbr)
Print a textual description of RPL neighbor into a string.
rpl_dag_state
RPL DAG states.
uip_ipaddr_t * rpl_neighbor_get_ipaddr(rpl_nbr_t *nbr)
Returns a neighbor's (link-local) IPv6 address.
void rpl_refresh_routes(const char *str)
Triggers a route fresh via DTSN increment.
int rpl_neighbor_count(void)
Returns the number of nodes in the RPL neighbor table.
watchdog_reboot()
Keeps control until the WDT throws a reset signal.
void shell_commands_init(void)
Initializes Shell-commands module.
struct tsch_neighbor * tsch_queue_get_time_source(void)
Get the TSCH time source (we currently assume there is only one)
uint64_t tsch_get_network_uptime_ticks(void)
Get the time, in clock ticks, since the TSCH network was started.
struct tsch_slotframe * tsch_schedule_slotframe_head(void)
Access the first item in the list of slotframes.
void tsch_log_init(void)
Initialize log module.
int tsch_is_locked(void)
Checks if the TSCH lock is set.
void tsch_set_coordinator(int enable)
Set the node as PAN coordinator.
linkaddr_t * tsch_queue_get_nbr_address(const struct tsch_neighbor *n)
Get the address of a neighbor.
void tsch_set_pan_secured(int enable)
Enable/disable security.
long int tsch_adaptive_timesync_get_drift_ppm(void)
Gives the estimated clock drift w.r.t.
void tsch_log_stop(void)
Stop logging module.
struct tsch_slotframe * tsch_schedule_slotframe_next(struct tsch_slotframe *sf)
Access the next item in the list of slotframes.
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
const uip_lladdr_t * uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr)
Get the link-layer address associated with a specified nbr cache.
uip_ds6_nbr_t * uip_ds6_nbr_head(void)
Get the first neighbor cache in nbr_table.
void uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
Send an icmpv6 message.
const uip_ip6addr_t * uip_ds6_default_prefix()
Retrieve the Default IPv6 prefix.
#define NBR_INCOMPLETE
Possible states for the nbr cache entries.
uip_sr_node_t * uip_sr_node_head(void)
Returns the head of the non-storing node list.
int uip_sr_link_snprint(char *buf, int buflen, const uip_sr_node_t *link)
Print a textual description of a source routing link.
const uip_ipaddr_t * uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr)
Get an IPv6 address of a neighbor cache.
int uip_sr_num_nodes(void)
Tells how many nodes are currently stored in the graph.
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
uip_ds6_netif_t uip_ds6_if
The single interface.
uip_sr_node_t * uip_sr_node_next(const uip_sr_node_t *item)
Returns the next element of the non-storing node list.
void uip_icmp6_echo_reply_callback_add(struct uip_icmp6_echo_reply_notification *n, uip_icmp6_echo_reply_callback_t c)
Add a callback function for ping replies.
#define ICMP6_ECHO_REQUEST
Echo request.
uip_ds6_nbr_t * uip_ds6_nbr_next(uip_ds6_nbr_t *nbr)
Get the next neighbor cache of a specified one.
void resolv_query(const char *name)
Queues a name so that a question for the name will be sent out.
resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t **ipaddr)
Look up a hostname in the array of known hostnames.
Linked list manipulation routines.
Common functionality of 802.15.4-compliant llsec_drivers.
Header file for the logging system.
uIP DNS resolver code header file.
@ RESOLV_STATUS_RESOLVING
This hostname is in the process of being resolved.
@ RESOLV_STATUS_NOT_FOUND
The server has returned a not-found response for this domain name.
@ RESOLV_STATUS_CACHED
Hostname is fresh and usable.
@ RESOLV_STATUS_UNCACHED
Hostname was not found in the cache.
Routing driver header file.
Main header file for the Contiki shell.
Main header file for the Contiki shell.
int(* root_start)(void)
Set the node as root and start a network.
void(* leave_network)(void)
Leave the network the node is part of.
void(* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
Set the prefix, for nodes that will operate as root.
void(* global_repair)(const char *str)
Triggers a global topology repair.
void(* local_repair)(const char *str)
Triggers a RPL local topology repair.
int(* node_is_root)(void)
Tells whether the node is a network root or not.
All information related to a RPL neighbor.
An IEEE 802.15.4-2015 TSCH link (also called cell or slot)
TSCH neighbor information.
802.15.4e slotframe (contains links)
An entry in the default router list.
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...
An entry in the routing table.
A node in a source routing graph, stored at the root and representing all child-parent relationship.
Main API declarations for TSCH.
Header file for IPv6-related data structures.
Header file for ICMPv6 message and error handing (RFC 4443)
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Header file for the uIP TCP/IP stack.
Header file for the IP address manipulation library.