Contiki-NG
shell-commands.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Inria.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * The Contiki shell commands
36  * \author
37  * Simon Duquennoy <simon.duquennoy@inria.fr>
38  */
39 
40 /**
41  * \addtogroup shell
42  * @{
43  */
44 
45 #include "contiki.h"
46 #include "shell.h"
47 #include "shell-commands.h"
48 #include "lib/list.h"
49 #include "sys/log.h"
50 #include "dev/watchdog.h"
51 #include "net/ipv6/uip.h"
52 #include "net/ipv6/uiplib.h"
53 #include "net/ipv6/uip-icmp6.h"
54 #include "net/ipv6/uip-ds6.h"
55 #if BUILD_WITH_RESOLV
56 #include "resolv.h"
57 #endif /* BUILD_WITH_RESOLV */
58 #if BUILD_WITH_HTTP_SOCKET
59 #include "http-socket.h"
60 #endif /* BUILD_WITH_HTTP_SOCKET */
61 #if MAC_CONF_WITH_TSCH
62 #include "net/mac/tsch/tsch.h"
63 #endif /* MAC_CONF_WITH_TSCH */
64 #if MAC_CONF_WITH_CSMA
65 #include "net/mac/csma/csma.h"
66 #endif
67 #include "net/routing/routing.h"
68 #include "net/mac/llsec802154.h"
69 
70 /* For RPL-specific commands */
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"
75 #endif
76 
77 #include <stdlib.h>
78 
79 #define PING_TIMEOUT (5 * CLOCK_SECOND)
80 
81 #if NETSTACK_CONF_WITH_IPV6
82 static struct uip_icmp6_echo_reply_notification echo_reply_notification;
83 static shell_output_func *curr_ping_output_func = NULL;
84 static struct process *curr_ping_process;
85 static uint8_t curr_ping_ttl;
86 static uint16_t curr_ping_datalen;
87 #endif /* NETSTACK_CONF_WITH_IPV6 */
88 #if TSCH_WITH_SIXTOP
89 static shell_command_6top_sub_cmd_t sixtop_sub_cmd = NULL;
90 #endif /* TSCH_WITH_SIXTOP */
91 static struct shell_command_set_t builtin_shell_command_set;
92 LIST(shell_command_sets);
93 #if NETSTACK_CONF_WITH_IPV6
94 /*---------------------------------------------------------------------------*/
95 static const char *
96 ds6_nbr_state_to_str(uint8_t state)
97 {
98  switch(state) {
99  case NBR_INCOMPLETE:
100  return "Incomplete";
101  case NBR_REACHABLE:
102  return "Reachable";
103  case NBR_STALE:
104  return "Stale";
105  case NBR_DELAY:
106  return "Delay";
107  case NBR_PROBE:
108  return "Probe";
109  default:
110  return "Unknown";
111  }
112 }
113 /*---------------------------------------------------------------------------*/
114 static void
115 echo_reply_handler(uip_ipaddr_t *source, uint8_t ttl, uint8_t *data, uint16_t datalen)
116 {
117  if(curr_ping_output_func != NULL) {
118  curr_ping_output_func = NULL;
119  curr_ping_ttl = ttl;
120  curr_ping_datalen = datalen;
121  process_poll(curr_ping_process);
122  }
123 }
124 /*---------------------------------------------------------------------------*/
125 static
126 PT_THREAD(cmd_ping(struct pt *pt, shell_output_func output, char *args))
127 {
128  static uip_ipaddr_t remote_addr;
129  static struct etimer timeout_timer;
130  char *next_args;
131 
132  PT_BEGIN(pt);
133 
134  SHELL_ARGS_INIT(args, next_args);
135 
136  /* Get argument (remote IPv6) */
137  SHELL_ARGS_NEXT(args, next_args);
138  if(args == NULL) {
139  SHELL_OUTPUT(output, "Destination IPv6 address is not specified\n");
140  PT_EXIT(pt);
141  } else if(uiplib_ipaddrconv(args, &remote_addr) == 0) {
142  SHELL_OUTPUT(output, "Invalid IPv6 address: %s\n", args);
143  PT_EXIT(pt);
144  }
145 
146  SHELL_OUTPUT(output, "Pinging ");
147  shell_output_6addr(output, &remote_addr);
148  SHELL_OUTPUT(output, "\n");
149 
150  /* Send ping request */
151  curr_ping_process = PROCESS_CURRENT();
152  curr_ping_output_func = output;
153  etimer_set(&timeout_timer, PING_TIMEOUT);
154  uip_icmp6_send(&remote_addr, ICMP6_ECHO_REQUEST, 0, 4);
155  PT_WAIT_UNTIL(pt, curr_ping_output_func == NULL || etimer_expired(&timeout_timer));
156 
157  if(curr_ping_output_func != NULL) {
158  SHELL_OUTPUT(output, "Timeout\n");
159  curr_ping_output_func = NULL;
160  } else {
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, (1000*(clock_time() - timeout_timer.timer.start))/CLOCK_SECOND);
165  }
166 
167  PT_END(pt);
168 }
169 #endif /* NETSTACK_CONF_WITH_IPV6 */
170 
171 #if ROUTING_CONF_RPL_LITE
172 /*---------------------------------------------------------------------------*/
173 static const char *
174 rpl_state_to_str(enum rpl_dag_state state)
175 {
176  switch(state) {
177  case DAG_INITIALIZED:
178  return "Initialized";
179  case DAG_JOINED:
180  return "Joined";
181  case DAG_REACHABLE:
182  return "Reachable";
183  case DAG_POISONING:
184  return "Poisoning";
185  default:
186  return "Unknown";
187  }
188 }
189 /*---------------------------------------------------------------------------*/
190 static const char *
191 rpl_mop_to_str(int mop)
192 {
193  switch(mop) {
194  case RPL_MOP_NO_DOWNWARD_ROUTES:
195  return "No downward routes";
196  case RPL_MOP_NON_STORING:
197  return "Non-storing";
198  case RPL_MOP_STORING_NO_MULTICAST:
199  return "Storing";
200  case RPL_MOP_STORING_MULTICAST:
201  return "Storing+multicast";
202  default:
203  return "Unknown";
204  }
205 }
206 /*---------------------------------------------------------------------------*/
207 static const char *
208 rpl_ocp_to_str(int ocp)
209 {
210  switch(ocp) {
211  case RPL_OCP_OF0:
212  return "OF0";
213  case RPL_OCP_MRHOF:
214  return "MRHOF";
215  default:
216  return "Unknown";
217  }
218 }
219 /*---------------------------------------------------------------------------*/
220 static
221 PT_THREAD(cmd_rpl_nbr(struct pt *pt, shell_output_func output, char *args))
222 {
223  PT_BEGIN(pt);
224 
225  if(!curr_instance.used || rpl_neighbor_count() == 0) {
226  SHELL_OUTPUT(output, "RPL neighbors: none\n");
227  } else {
228  rpl_nbr_t *nbr = nbr_table_head(rpl_neighbors);
229  SHELL_OUTPUT(output, "RPL neighbors:\n");
230  while(nbr != NULL) {
231  char buf[120];
232  rpl_neighbor_snprint(buf, sizeof(buf), nbr);
233  SHELL_OUTPUT(output, "%s\n", buf);
234  nbr = nbr_table_next(rpl_neighbors, nbr);
235  }
236  }
237 
238  PT_END(pt);
239 }
240 /*---------------------------------------------------------------------------*/
241 static
242 PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args))
243 {
244  PT_BEGIN(pt);
245 
246  SHELL_OUTPUT(output, "RPL status:\n");
247  if(!curr_instance.used) {
248  SHELL_OUTPUT(output, "-- Instance: None\n");
249  } else {
250  SHELL_OUTPUT(output, "-- Instance: %u\n", curr_instance.instance_id);
251  if(NETSTACK_ROUTING.node_is_root()) {
252  SHELL_OUTPUT(output, "-- DAG root\n");
253  } else {
254  SHELL_OUTPUT(output, "-- DAG node\n");
255  }
256  SHELL_OUTPUT(output, "-- DAG: ");
257  shell_output_6addr(output, &curr_instance.dag.dag_id);
258  SHELL_OUTPUT(output, ", version %u\n", curr_instance.dag.version);
259  SHELL_OUTPUT(output, "-- Prefix: ");
260  shell_output_6addr(output, &curr_instance.dag.prefix_info.prefix);
261  SHELL_OUTPUT(output, "/%u\n", curr_instance.dag.prefix_info.length);
262  SHELL_OUTPUT(output, "-- MOP: %s\n", rpl_mop_to_str(curr_instance.mop));
263  SHELL_OUTPUT(output, "-- OF: %s\n", rpl_ocp_to_str(curr_instance.of->ocp));
264  SHELL_OUTPUT(output, "-- Hop rank increment: %u\n", curr_instance.min_hoprankinc);
265  SHELL_OUTPUT(output, "-- Default lifetime: %lu seconds\n", RPL_LIFETIME(curr_instance.default_lifetime));
266 
267  SHELL_OUTPUT(output, "-- State: %s\n", rpl_state_to_str(curr_instance.dag.state));
268  SHELL_OUTPUT(output, "-- Preferred parent: ");
269  if(curr_instance.dag.preferred_parent) {
270  shell_output_6addr(output, rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent));
271  SHELL_OUTPUT(output, " (last DTSN: %u)\n", curr_instance.dag.preferred_parent->dtsn);
272  } else {
273  SHELL_OUTPUT(output, "None\n");
274  }
275  SHELL_OUTPUT(output, "-- Rank: %u\n", curr_instance.dag.rank);
276  SHELL_OUTPUT(output, "-- Lowest rank: %u (%u)\n", curr_instance.dag.lowest_rank, curr_instance.max_rankinc);
277  SHELL_OUTPUT(output, "-- DTSN out: %u\n", curr_instance.dtsn_out);
278  SHELL_OUTPUT(output, "-- DAO sequence: last sent %u, last acked %u\n",
279  curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_last_acked_seqno);
280  SHELL_OUTPUT(output, "-- Trickle timer: current %u, min %u, max %u, redundancy %u\n",
281  curr_instance.dag.dio_intcurrent, curr_instance.dio_intmin,
282  curr_instance.dio_intmin + curr_instance.dio_intdoubl, curr_instance.dio_redundancy);
283 
284  }
285 
286  PT_END(pt);
287 }
288 /*---------------------------------------------------------------------------*/
289 static
290 PT_THREAD(cmd_rpl_refresh_routes(struct pt *pt, shell_output_func output, char *args))
291 {
292  PT_BEGIN(pt);
293 
294  SHELL_OUTPUT(output, "Triggering routes refresh\n");
295  rpl_refresh_routes("Shell");
296 
297  PT_END(pt);
298 }
299 #endif /* ROUTING_CONF_RPL_LITE */
300 /*---------------------------------------------------------------------------*/
301 static void
302 shell_output_log_levels(shell_output_func output)
303 {
304  int i = 0;
305  SHELL_OUTPUT(output, "Log levels:\n");
306  while(all_modules[i].name != NULL) {
307  SHELL_OUTPUT(output, "-- %-10s: %u (%s)\n",
308  all_modules[i].name,
309  *all_modules[i].curr_log_level,
310  log_level_to_str(*all_modules[i].curr_log_level));
311  i++;
312  }
313 }
314 /*---------------------------------------------------------------------------*/
315 static
316 PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
317 {
318  static int prev_level;
319  static int level;
320  char *next_args;
321  char *ptr;
322  char *module;
323 
324  PT_BEGIN(pt);
325 
326  SHELL_ARGS_INIT(args, next_args);
327 
328  /* Get and parse argument: module name */
329  SHELL_ARGS_NEXT(args, next_args);
330  module = args;
331  prev_level = log_get_level(module);
332  if(module == NULL || (strcmp("all", module) && prev_level == -1)) {
333  SHELL_OUTPUT(output, "Invalid first argument: %s\n", module)
334  shell_output_log_levels(output);
335  PT_EXIT(pt);
336  }
337 
338  /* Get and parse argument: log level */
339  SHELL_ARGS_NEXT(args, next_args);
340  if(args == NULL) {
341  level = -1;
342  } else {
343  level = (int)strtol(args, &ptr, 10);
344  }
345  if((level == 0 && args == ptr)
346  || level < LOG_LEVEL_NONE || level > LOG_LEVEL_DBG) {
347  SHELL_OUTPUT(output, "Invalid second argument: %s\n", args);
348  PT_EXIT(pt);
349  }
350 
351  /* Set log level */
352  if(level != prev_level) {
353  log_set_level(module, level);
354 #if MAC_CONF_WITH_TSCH && TSCH_LOG_PER_SLOT
355  if(!strcmp(module, "mac") || !strcmp(module, "all")) {
356  if(level >= LOG_LEVEL_DBG) {
357  tsch_log_init();
358  SHELL_OUTPUT(output, "TSCH logging started\n");
359  } else {
360  tsch_log_stop();
361  SHELL_OUTPUT(output, "TSCH logging stopped\n");
362  }
363  }
364 #endif /* MAC_CONF_WITH_TSCH && TSCH_LOG_PER_SLOT */
365  }
366 
367  shell_output_log_levels(output);
368 
369  PT_END(pt);
370 }
371 /*---------------------------------------------------------------------------*/
372 static
373 PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args))
374 {
375  struct shell_command_set_t *set;
376  const struct shell_command_t *cmd;
377  PT_BEGIN(pt);
378 
379  SHELL_OUTPUT(output, "Available commands:\n");
380  /* Note: we explicitly don't expend any code space to deal with shadowing */
381  for(set = list_head(shell_command_sets); set != NULL; set = list_item_next(set)) {
382  for(cmd = set->commands; cmd->name != NULL; ++cmd) {
383  SHELL_OUTPUT(output, "%s\n", cmd->help);
384  }
385  }
386 
387  PT_END(pt);
388 }
389 #if UIP_CONF_IPV6_RPL
390 /*---------------------------------------------------------------------------*/
391 static
392 PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
393 {
394  static int is_on;
395  static uip_ipaddr_t prefix;
396  char *next_args;
397 
398  PT_BEGIN(pt);
399 
400  SHELL_ARGS_INIT(args, next_args);
401 
402  /* Get first arg (0/1) */
403  SHELL_ARGS_NEXT(args, next_args);
404 
405  if(!strcmp(args, "1")) {
406  is_on = 1;
407  } else if(!strcmp(args, "0")) {
408  is_on = 0;
409  } else {
410  SHELL_OUTPUT(output, "Invalid argument: %s\n", args);
411  PT_EXIT(pt);
412  }
413 
414  /* Get first second arg (prefix) */
415  SHELL_ARGS_NEXT(args, next_args);
416  if(args != NULL) {
417  if(uiplib_ipaddrconv(args, &prefix) == 0) {
418  SHELL_OUTPUT(output, "Invalid Prefix: %s\n", args);
419  PT_EXIT(pt);
420  }
421  } else {
422  const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix();
423  uip_ip6addr_copy(&prefix, default_prefix);
424  }
425 
426  if(is_on) {
427  if(!NETSTACK_ROUTING.node_is_root()) {
428  SHELL_OUTPUT(output, "Setting as DAG root with prefix ");
429  shell_output_6addr(output, &prefix);
430  SHELL_OUTPUT(output, "/64\n");
431  NETSTACK_ROUTING.root_set_prefix(&prefix, NULL);
432  NETSTACK_ROUTING.root_start();
433  } else {
434  SHELL_OUTPUT(output, "Node is already a DAG root\n");
435  }
436  } else {
437  if(NETSTACK_ROUTING.node_is_root()) {
438  SHELL_OUTPUT(output, "Setting as non-root node: leaving DAG\n");
439  NETSTACK_ROUTING.leave_network();
440  } else {
441  SHELL_OUTPUT(output, "Node is not a DAG root\n");
442  }
443  }
444 
445  PT_END(pt);
446 }
447 /*---------------------------------------------------------------------------*/
448 static
449 PT_THREAD(cmd_rpl_global_repair(struct pt *pt, shell_output_func output, char *args))
450 {
451  PT_BEGIN(pt);
452 
453  SHELL_OUTPUT(output, "Triggering routing global repair\n");
454  NETSTACK_ROUTING.global_repair("Shell");
455 
456  PT_END(pt);
457 }
458 /*---------------------------------------------------------------------------*/
459 static
460 PT_THREAD(cmd_rpl_local_repair(struct pt *pt, shell_output_func output, char *args))
461 {
462  PT_BEGIN(pt);
463 
464  SHELL_OUTPUT(output, "Triggering routing local repair\n");
465  NETSTACK_ROUTING.local_repair("Shell");
466 
467  PT_END(pt);
468 }
469 #endif /* UIP_CONF_IPV6_RPL */
470 /*---------------------------------------------------------------------------*/
471 static
472 PT_THREAD(cmd_macaddr(struct pt *pt, shell_output_func output, char *args))
473 {
474  PT_BEGIN(pt);
475 
476  SHELL_OUTPUT(output, "Node MAC address: ");
478  SHELL_OUTPUT(output, "\n");
479 
480  PT_END(pt);
481 }
482 #if NETSTACK_CONF_WITH_IPV6
483 /*---------------------------------------------------------------------------*/
484 static
485 PT_THREAD(cmd_ipaddr(struct pt *pt, shell_output_func output, char *args))
486 {
487  int i;
488  uint8_t state;
489 
490  PT_BEGIN(pt);
491 
492  SHELL_OUTPUT(output, "Node IPv6 addresses:\n");
493  for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
494  state = uip_ds6_if.addr_list[i].state;
495  if(uip_ds6_if.addr_list[i].isused &&
496  (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
497  SHELL_OUTPUT(output, "-- ");
498  shell_output_6addr(output, &uip_ds6_if.addr_list[i].ipaddr);
499  SHELL_OUTPUT(output, "\n");
500  }
501  }
502 
503  PT_END(pt);
504 }
505 /*---------------------------------------------------------------------------*/
506 static
507 PT_THREAD(cmd_ip_neighbors(struct pt *pt, shell_output_func output, char *args))
508 {
510 
511  PT_BEGIN(pt);
512 
513  nbr = uip_ds6_nbr_head();
514  if(nbr == NULL) {
515  SHELL_OUTPUT(output, "Node IPv6 neighbors: none\n");
516  PT_EXIT(pt);
517  }
518 
519  SHELL_OUTPUT(output, "Node IPv6 neighbors:\n");
520  while(nbr != NULL) {
521  SHELL_OUTPUT(output, "-- ");
523  SHELL_OUTPUT(output, " <-> ");
524  shell_output_lladdr(output, (linkaddr_t *)uip_ds6_nbr_get_ll(nbr));
525  SHELL_OUTPUT(output, ", router %u, state %s ",
526  nbr->isrouter, ds6_nbr_state_to_str(nbr->state));
527  SHELL_OUTPUT(output, "\n");
528  nbr = uip_ds6_nbr_next(nbr);
529  }
530 
531  PT_END(pt);
532 
533 }
534 #endif /* NETSTACK_CONF_WITH_IPV6 */
535 #if MAC_CONF_WITH_TSCH
536 /*---------------------------------------------------------------------------*/
537 static
538 PT_THREAD(cmd_tsch_set_coordinator(struct pt *pt, shell_output_func output, char *args))
539 {
540  static int is_on;
541  static int is_secured;
542  char *next_args;
543 
544  PT_BEGIN(pt);
545 
546  SHELL_ARGS_INIT(args, next_args);
547 
548  /* Get first arg (0/1) */
549  SHELL_ARGS_NEXT(args, next_args);
550 
551  if(!strcmp(args, "1")) {
552  is_on = 1;
553  } else if(!strcmp(args, "0")) {
554  is_on = 0;
555  } else {
556  SHELL_OUTPUT(output, "Invalid first argument: %s\n", args);
557  PT_EXIT(pt);
558  }
559 
560  /* Get first second arg (prefix) */
561  SHELL_ARGS_NEXT(args, next_args);
562  if(args != NULL) {
563  if(!strcmp(args, "1")) {
564 #if LLSEC802154_ENABLED
565  is_secured = 1;
566 #else /* LLSEC802154_ENABLED */
567  SHELL_OUTPUT(output, "Security is not compiled in.\n");
568  is_secured = 0;
569 #endif /* LLSEC802154_ENABLED */
570  } else if(!strcmp(args, "0")) {
571  is_secured = 0;
572  } else {
573  SHELL_OUTPUT(output, "Invalid second argument: %s\n", args);
574  PT_EXIT(pt);
575  }
576  } else {
577  is_secured = 0;
578  }
579 
580  SHELL_OUTPUT(output, "Setting as TSCH %s (%s)\n",
581  is_on ? "coordinator" : "non-coordinator", is_secured ? "secured" : "non-secured");
582 
583  tsch_set_pan_secured(is_secured);
584  tsch_set_coordinator(is_on);
585 
586  PT_END(pt);
587 }
588 /*---------------------------------------------------------------------------*/
589 static
590 PT_THREAD(cmd_tsch_status(struct pt *pt, shell_output_func output, char *args))
591 {
592  PT_BEGIN(pt);
593 
594  SHELL_OUTPUT(output, "TSCH status:\n");
595 
596  SHELL_OUTPUT(output, "-- Is coordinator: %u\n", tsch_is_coordinator);
597  SHELL_OUTPUT(output, "-- Is associated: %u\n", tsch_is_associated);
598  if(tsch_is_associated) {
600  SHELL_OUTPUT(output, "-- PAN ID: 0x%x\n", frame802154_get_pan_id());
601  SHELL_OUTPUT(output, "-- Is PAN secured: %u\n", tsch_is_pan_secured);
602  SHELL_OUTPUT(output, "-- Join priority: %u\n", tsch_join_priority);
603  SHELL_OUTPUT(output, "-- Time source: ");
604  if(n != NULL) {
606  SHELL_OUTPUT(output, "\n");
607  } else {
608  SHELL_OUTPUT(output, "none\n");
609  }
610  SHELL_OUTPUT(output, "-- Last synchronized: %lu seconds ago\n",
611  (clock_time() - tsch_last_sync_time) / CLOCK_SECOND);
612  SHELL_OUTPUT(output, "-- Drift w.r.t. coordinator: %ld ppm\n",
614  SHELL_OUTPUT(output, "-- Network uptime: %lu seconds\n",
615  (unsigned long)(tsch_get_network_uptime_ticks() / CLOCK_SECOND));
616  }
617 
618  PT_END(pt);
619 }
620 #endif /* MAC_CONF_WITH_TSCH */
621 #if NETSTACK_CONF_WITH_IPV6
622 /*---------------------------------------------------------------------------*/
623 static
624 PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args))
625 {
626  uip_ds6_defrt_t *default_route;
627 
628  PT_BEGIN(pt);
629 
630  /* Our default route */
631  SHELL_OUTPUT(output, "Default route:\n");
632  default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
633  if(default_route != NULL) {
634  SHELL_OUTPUT(output, "-- ");
635  shell_output_6addr(output, &default_route->ipaddr);
636  if(default_route->lifetime.interval != 0) {
637  SHELL_OUTPUT(output, " (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval);
638  } else {
639  SHELL_OUTPUT(output, " (lifetime: infinite)\n");
640  }
641  } else {
642  SHELL_OUTPUT(output, "-- None\n");
643  }
644 
645 #if UIP_CONF_IPV6_RPL
646  if(uip_sr_num_nodes() > 0) {
647  uip_sr_node_t *link;
648  /* Our routing links */
649  SHELL_OUTPUT(output, "Routing links (%u in total):\n", uip_sr_num_nodes());
650  link = uip_sr_node_head();
651  while(link != NULL) {
652  char buf[100];
653  uip_sr_link_snprint(buf, sizeof(buf), link);
654  SHELL_OUTPUT(output, "-- %s\n", buf);
655  link = uip_sr_node_next(link);
656  }
657  } else {
658  SHELL_OUTPUT(output, "No routing links\n");
659  }
660 #endif /* UIP_CONF_IPV6_RPL */
661 
662 #if (UIP_MAX_ROUTES != 0)
663  if(uip_ds6_route_num_routes() > 0) {
664  uip_ds6_route_t *route;
665  /* Our routing entries */
666  SHELL_OUTPUT(output, "Routing entries (%u in total):\n", uip_ds6_route_num_routes());
667  route = uip_ds6_route_head();
668  while(route != NULL) {
669  SHELL_OUTPUT(output, "-- ");
670  shell_output_6addr(output, &route->ipaddr);
671  SHELL_OUTPUT(output, " via ");
672  shell_output_6addr(output, uip_ds6_route_nexthop(route));
673  if((unsigned long)route->state.lifetime != 0xFFFFFFFF) {
674  SHELL_OUTPUT(output, " (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime);
675  } else {
676  SHELL_OUTPUT(output, " (lifetime: infinite)\n");
677  }
678  route = uip_ds6_route_next(route);
679  }
680  } else {
681  SHELL_OUTPUT(output, "No routing entries\n");
682  }
683 #endif /* (UIP_MAX_ROUTES != 0) */
684 
685  PT_END(pt);
686 }
687 /*---------------------------------------------------------------------------*/
688 #if BUILD_WITH_RESOLV
689 static
690 PT_THREAD(cmd_resolv(struct pt *pt, shell_output_func output, char *args))
691 {
692  PT_BEGIN(pt);
693  static struct etimer timeout_timer;
694  static int count, ret;
695  char *next_args;
696  static uip_ipaddr_t *remote_addr = NULL;
697  SHELL_ARGS_INIT(args, next_args);
698 
699  /* Get argument (remote hostname) */
700  SHELL_ARGS_NEXT(args, next_args);
701  if(args == NULL) {
702  SHELL_OUTPUT(output, "Destination host is not specified\n");
703  PT_EXIT(pt);
704  } else {
705  ret = resolv_lookup(args, &remote_addr);
706  if(ret == RESOLV_STATUS_UNCACHED || ret == RESOLV_STATUS_RESOLVING) {
707  SHELL_OUTPUT(output, "Looking up IPv6 address for host: %s\n", args);
708  if(ret != RESOLV_STATUS_RESOLVING) {
709  resolv_query(args);
710  }
711  /* Poll 10 times for resolve results (5 seconds max)*/
712  for(count = 0; count < 10; count++) {
713  etimer_set(&timeout_timer, CLOCK_SECOND / 2);
714  PT_WAIT_UNTIL(pt, etimer_expired(&timeout_timer));
715  printf("resoliving again...\n");
716  if((ret = resolv_lookup(args, &remote_addr)) != RESOLV_STATUS_RESOLVING) {
717  break;
718  }
719  }
720  }
721  if(ret == RESOLV_STATUS_NOT_FOUND) {
722  SHELL_OUTPUT(output, "Did not find IPv6 address for host: %s\n", args);
723  } else if(ret == RESOLV_STATUS_CACHED) {
724  SHELL_OUTPUT(output, "Found IPv6 address for host: %s => ", args);
725  shell_output_6addr(output, remote_addr);
726  SHELL_OUTPUT(output, "\n");
727  }
728  }
729  PT_END(pt);
730 }
731 #endif /* BUILD_WITH_RESOLV */
732 /*---------------------------------------------------------------------------*/
733 #if BUILD_WITH_HTTP_SOCKET
734 static struct http_socket s;
735 static int bytes_received = 0;
736 
737 static void
738 http_callback(struct http_socket *s, void *ptr,
739  http_socket_event_t e,
740  const uint8_t *data, uint16_t datalen)
741 {
742  if(e == HTTP_SOCKET_ERR) {
743  printf("HTTP socket error\n");
744  } else if(e == HTTP_SOCKET_TIMEDOUT) {
745  printf("HTTP socket error: timed out\n");
746  } else if(e == HTTP_SOCKET_ABORTED) {
747  printf("HTTP socket error: aborted\n");
748  } else if(e == HTTP_SOCKET_HOSTNAME_NOT_FOUND) {
749  printf("HTTP socket error: hostname not found\n");
750  } else if(e == HTTP_SOCKET_CLOSED) {
751  printf("HTTP socket closed, %d bytes received\n", bytes_received);
752  } else if(e == HTTP_SOCKET_DATA) {
753  int i;
754  if(bytes_received == 0) {
755  printf("HTTP socket received data, total expects:%d\n", (int) s->header.content_length);
756  }
757 
758  bytes_received += datalen;
759  for(i = 0; i < datalen; i++) {
760  printf("%c", data[i]);
761  }
762  }
763 }
764 /*---------------------------------------------------------------------------*/
765 static
766 PT_THREAD(cmd_wget(struct pt *pt, shell_output_func output, char *args))
767 {
768  PT_BEGIN(pt);
769  char *next_args;
770  SHELL_ARGS_INIT(args, next_args);
771 
772  /* Get argument (remote hostname and url (http://host/url) */
773  SHELL_ARGS_NEXT(args, next_args);
774  if(args == NULL) {
775  SHELL_OUTPUT(output, "URL is not specified\n");
776  PT_EXIT(pt);
777  } else {
778  bytes_received = 0;
779  SHELL_OUTPUT(output, "Fetching web page at %s\n", args);
780  http_socket_init(&s);
781  http_socket_get(&s, args, 0, 0,
782  http_callback, NULL);
783  }
784 
785  PT_END(pt);
786 }
787 #endif /* BUILD_WITH_HTTP_SOCKET */
788 /*---------------------------------------------------------------------------*/
789 #endif /* NETSTACK_CONF_WITH_IPV6 */
790 /*---------------------------------------------------------------------------*/
791 static
792 PT_THREAD(cmd_reboot(struct pt *pt, shell_output_func output, char *args))
793 {
794  PT_BEGIN(pt);
795  SHELL_OUTPUT(output, "rebooting\n");
796  watchdog_reboot();
797  PT_END(pt);
798 }
799 #if MAC_CONF_WITH_TSCH
800 /*---------------------------------------------------------------------------*/
801 static
802 PT_THREAD(cmd_tsch_schedule(struct pt *pt, shell_output_func output, char *args))
803 {
804  struct tsch_slotframe *sf;
805 
806  PT_BEGIN(pt);
807 
808  if(tsch_is_locked()) {
809  PT_EXIT(pt);
810  }
811 
813 
814  if(sf == NULL) {
815  SHELL_OUTPUT(output, "TSCH schedule: no slotframe\n");
816  } else {
817  SHELL_OUTPUT(output, "TSCH schedule:\n");
818  while(sf != NULL) {
819  struct tsch_link *l = list_head(sf->links_list);
820 
821  SHELL_OUTPUT(output, "-- Slotframe: handle %u, size %u, links:\n", sf->handle, sf->size.val);
822 
823  while(l != NULL) {
824  SHELL_OUTPUT(output, "---- Options %02x, type %u, timeslot %u, channel offset %u, address ",
825  l->link_options, l->link_type, l->timeslot, l->channel_offset);
826  shell_output_lladdr(output, &l->addr);
827  SHELL_OUTPUT(output, "\n");
828  l = list_item_next(l);
829  }
830 
832  }
833  }
834  PT_END(pt);
835 }
836 #endif /* MAC_CONF_WITH_TSCH */
837 /*---------------------------------------------------------------------------*/
838 #if TSCH_WITH_SIXTOP
839 void
840 shell_commands_set_6top_sub_cmd(shell_command_6top_sub_cmd_t sub_cmd)
841 {
842  sixtop_sub_cmd = sub_cmd;
843 }
844 /*---------------------------------------------------------------------------*/
845 static
846 PT_THREAD(cmd_6top(struct pt *pt, shell_output_func output, char *args))
847 {
848  char *next_args;
849 
850  PT_BEGIN(pt);
851 
852  SHELL_ARGS_INIT(args, next_args);
853 
854  if(sixtop_sub_cmd == NULL) {
855  SHELL_OUTPUT(output, "6top command is unavailable:\n");
856  } else {
857  SHELL_OUTPUT(output, "6top: ");
858  sixtop_sub_cmd(output, args);
859  }
860  SHELL_ARGS_NEXT(args, next_args);
861 
862  PT_END(pt);
863 }
864 #endif /* TSCH_WITH_SIXTOP */
865 /*---------------------------------------------------------------------------*/
866 #if LLSEC802154_ENABLED
867 static
868 PT_THREAD(cmd_llsec_setlv(struct pt *pt, shell_output_func output, char *args))
869 {
870 
871  PT_BEGIN(pt);
872 
873  if(args == NULL) {
874  SHELL_OUTPUT(output, "Default LLSEC level is %d\n",
875  uipbuf_get_attr(UIPBUF_ATTR_LLSEC_LEVEL));
876  PT_EXIT(pt);
877  } else {
878  int lv = atoi(args);
879  if(lv < 0 || lv > 7) {
880  SHELL_OUTPUT(output, "Illegal LLSEC Level %d\n", lv);
881  PT_EXIT(pt);
882  } else {
883  uipbuf_set_default_attr(UIPBUF_ATTR_LLSEC_LEVEL, lv);
884  uipbuf_clear_attr();
885  SHELL_OUTPUT(output, "LLSEC default level set %d\n", lv);
886  }
887  }
888 
889  PT_END(pt);
890 }
891 /*---------------------------------------------------------------------------*/
892 static
893 PT_THREAD(cmd_llsec_setkey(struct pt *pt, shell_output_func output, char *args))
894 {
895  char *next_args;
896 
897  PT_BEGIN(pt);
898 
899  SHELL_ARGS_INIT(args, next_args);
900 
901  if(args == NULL) {
902  SHELL_OUTPUT(output, "Provide an index and a 16-char string for the key\n");
903  PT_EXIT(pt);
904  } else {
905  int key;
906  SHELL_ARGS_NEXT(args, next_args);
907  key = atoi(args);
908  if(key < 0) {
909  SHELL_OUTPUT(output, "Illegal LLSEC Key index %d\n", key);
910  PT_EXIT(pt);
911  } else {
912 #if MAC_CONF_WITH_CSMA
913  /* Get next arg (key-string) */
914  SHELL_ARGS_NEXT(args, next_args);
915  if(args == NULL) {
916  SHELL_OUTPUT(output, "Provide both an index and a key\n");
917  } else if(strlen(args) == 16) {
918  csma_security_set_key(key, (const uint8_t *) args);
919  SHELL_OUTPUT(output, "Set key for index %d\n", key);
920  } else {
921  SHELL_OUTPUT(output, "Wrong length of key: '%s' (%d)\n", args, strlen(args));
922  }
923 #else
924  SHELL_OUTPUT(output, "Set key not supported.\n");
925  PT_EXIT(pt);
926 #endif
927  }
928  }
929  PT_END(pt);
930 }
931 #endif /* LLSEC802154_ENABLED */
932 /*---------------------------------------------------------------------------*/
933 void
935 {
936  list_init(shell_command_sets);
937  list_add(shell_command_sets, &builtin_shell_command_set);
938 #if NETSTACK_CONF_WITH_IPV6
939  /* Set up Ping Reply callback */
940  uip_icmp6_echo_reply_callback_add(&echo_reply_notification,
941  echo_reply_handler);
942 #endif /* NETSTACK_CONF_WITH_IPV6 */
943 }
944 /*---------------------------------------------------------------------------*/
945 void
946 shell_command_set_register(struct shell_command_set_t *set)
947 {
948  list_push(shell_command_sets, set);
949 }
950 /*---------------------------------------------------------------------------*/
951 int
952 shell_command_set_deregister(struct shell_command_set_t *set)
953 {
954  if(!list_contains(shell_command_sets, set)) {
955  return !0;
956  }
957  list_remove(shell_command_sets, set);
958  return 0;
959 }
960 /*---------------------------------------------------------------------------*/
961 const struct shell_command_t *
962 shell_command_lookup(const char *name)
963 {
964  struct shell_command_set_t *set;
965  const struct shell_command_t *cmd;
966 
967  for(set = list_head(shell_command_sets);
968  set != NULL;
969  set = list_item_next(set)) {
970  for(cmd = set->commands; cmd->name != NULL; ++cmd) {
971  if(!strcmp(cmd->name, name)) {
972  return cmd;
973  }
974  }
975  }
976  return NULL;
977 }
978 /*---------------------------------------------------------------------------*/
979 const struct shell_command_t builtin_shell_commands[] = {
980  { "help", cmd_help, "'> help': Shows this help" },
981  { "reboot", cmd_reboot, "'> reboot': Reboot the board by watchdog_reboot()" },
982  { "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." },
983  { "mac-addr", cmd_macaddr, "'> mac-addr': Shows the node's MAC address" },
984 #if NETSTACK_CONF_WITH_IPV6
985  { "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
986  { "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" },
987  { "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" },
988  { "routes", cmd_routes, "'> routes': Shows the route entries" },
989 #if BUILD_WITH_RESOLV
990  { "nslookup", cmd_resolv, "'> nslookup': Lookup IPv6 address of host" },
991 #endif /* BUILD_WITH_RESOLV */
992 #if BUILD_WITH_HTTP_SOCKET
993  { "wget", cmd_wget, "'> wget url': get content of URL (only http)." },
994 #endif /* BUILD_WITH_HTTP_SOCKET */
995 #endif /* NETSTACK_CONF_WITH_IPV6 */
996 #if UIP_CONF_IPV6_RPL
997  { "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." },
998  { "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" },
999 #if ROUTING_CONF_RPL_LITE
1000  { "rpl-refresh-routes", cmd_rpl_refresh_routes, "'> rpl-refresh-routes': Refreshes all routes through a DTSN increment" },
1001  { "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" },
1002  { "rpl-nbr", cmd_rpl_nbr, "'> rpl-nbr': Shows the RPL neighbor table" },
1003 #endif /* ROUTING_CONF_RPL_LITE */
1004  { "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" },
1005 #endif /* UIP_CONF_IPV6_RPL */
1006 #if MAC_CONF_WITH_TSCH
1007  { "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." },
1008  { "tsch-schedule", cmd_tsch_schedule, "'> tsch-schedule': Shows the current TSCH schedule" },
1009  { "tsch-status", cmd_tsch_status, "'> tsch-status': Shows a summary of the current TSCH state" },
1010 #endif /* MAC_CONF_WITH_TSCH */
1011 #if TSCH_WITH_SIXTOP
1012  { "6top", cmd_6top, "'> 6top help': Shows 6top command usage" },
1013 #endif /* TSCH_WITH_SIXTOP */
1014 #if LLSEC802154_ENABLED
1015  { "llsec-set-level", cmd_llsec_setlv, "'> llsec-set-level <lv>': Set the level of link layer security (show if no lv argument)"},
1016  { "llsec-set-key", cmd_llsec_setkey, "'> llsec-set-key <id> <key>': Set the key of link layer security"},
1017 #endif /* LLSEC802154_ENABLED */
1018  { NULL, NULL, NULL },
1019 };
1020 
1021 static struct shell_command_set_t builtin_shell_command_set = {
1022  .next = NULL,
1023  .commands = builtin_shell_commands,
1024 };
1025 /** @} */
An entry in the default router list.
Header file for ICMPv6 message and error handing (RFC 4443)
Main header file for the Contiki shell
static volatile uint64_t count
Num.
Definition: clock.c:50
uip_ipaddr_t * rpl_neighbor_get_ipaddr(rpl_nbr_t *nbr)
Returns a neighbor&#39;s (link-local) IPv6 address.
Definition: rpl-neighbor.c:252
void shell_commands_init(void)
Initializes Shell-commands module.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:106
struct tsch_slotframe * tsch_schedule_slotframe_next(struct tsch_slotframe *sf)
Access the next item in the list of slotframes.
Hostname was not found in the cache.
Definition: resolv.h:66
int uip_sr_num_nodes(void)
Tells how many nodes are currently stored in the graph.
Definition: uip-sr.c:63
void list_push(list_t list, void *item)
Add an item to the start of the list.
Definition: list.c:164
void shell_output_lladdr(shell_output_func output, const linkaddr_t *lladdr)
Prints a link-layer address.
Definition: shell.c:64
uIP DNS resolver code header file.
The 802.15.4 standard CSMA protocol (nonbeacon-enabled)
uip_ds6_nbr_t * uip_ds6_nbr_head(void)
Get the first neighbor cache in nbr_table.
Definition: uip-ds6-nbr.c:429
void tsch_log_init(void)
Initialize log module.
watchdog_reboot()
Keeps control until the WDT throws a reset signal.
Definition: watchdog.c:94
bool list_contains(list_t list, void *item)
Check if the list contains an item.
Definition: list.c:338
TSCH neighbor information.
Definition: tsch-types.h:109
802.15.4e slotframe (contains links)
Definition: tsch-types.h:84
Main header file for the Contiki shell
#define PT_BEGIN(pt)
Declare the start of a protothread inside the C function implementing the protothread.
Definition: pt.h:280
struct tsch_neighbor * tsch_queue_get_time_source(void)
Get the TSCH time source (we currently assume there is only one)
Definition: tsch-queue.c:120
Common functionality of 802.15.4-compliant llsec_drivers.
#define PT_WAIT_UNTIL(pt, condition)
Block and wait until condition is true.
Definition: pt.h:313
#define RPL_LIFETIME(lifetime)
Compute lifetime, accounting for the lifetime unit.
Definition: rpl-types.h:72
#define ICMP6_ECHO_REQUEST
Echo request.
Definition: uip-icmp6.h:57
int(* root_start)(void)
Set the node as root and start a network.
Definition: routing.h:76
int rpl_neighbor_count(void)
Returns the number of nodes in the RPL neighbor table.
Definition: rpl-neighbor.c:168
static uint8_t output(const linkaddr_t *localdest)
Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.
Definition: sicslowpan.c:1610
void(* global_repair)(const char *str)
Triggers a global topology repair.
Definition: routing.h:120
Header file for IPv6-related data structures.
void tsch_log_stop(void)
Stop logging module.
void(* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
Set the prefix, for nodes that will operate as root.
Definition: routing.h:70
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
Definition: linkaddr.c:48
uip_sr_node_t * uip_sr_node_next(uip_sr_node_t *item)
Returns the next element of the non-storing node list.
Definition: uip-sr.c:200
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
Definition: process.h:402
An entry in the routing table.
void log_set_level(const char *module, int level)
Sets a log level at run-time.
Definition: log.c:173
#define CLOCK_SECOND
A second, measured in system clock time.
Definition: clock.h:82
Header file for the IP address manipulation library.
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.
Definition: uip-icmp6.c:302
const uip_ip6addr_t * uip_ds6_default_prefix()
Retrieve the Default IPv6 prefix.
Definition: uip-ds6.c:104
#define PT_END(pt)
Declare the end of a protothread.
Definition: pt.h:292
resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t **ipaddr)
Look up a hostname in the array of known hostnames.
Definition: resolv.c:1277
linkaddr_t * tsch_queue_get_nbr_address(const struct tsch_neighbor *n)
Get the address of a neighbor.
Definition: tsch-queue.c:135
Linked list manipulation routines.
int(* node_is_root)(void)
Tells whether the node is a network root or not.
Definition: routing.h:82
void process_poll(struct process *p)
Request a process to be polled.
Definition: process.c:371
const uip_ipaddr_t * uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr)
Get an IPv6 address of a neighbor cache.
Definition: uip-ds6-nbr.c:385
void * list_head(list_t list)
Get a pointer to the first element of a list.
Definition: list.c:82
uip_sr_node_t * uip_sr_node_head(void)
Returns the head of the non-storing node list.
Definition: uip-sr.c:194
rpl_dag_state
RPL DAG states.
Definition: rpl-types.h:177
Routing driver header file
All information related to a RPL neighbor.
Definition: rpl-types.h:136
Main API declarations for TSCH.
clock_time_t clock_time(void)
Get the current clock time.
Definition: clock.c:118
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
Definition: etimer.c:213
The server has returned a not-found response for this domain name.
Definition: resolv.h:79
int tsch_is_locked(void)
Checks if the TSCH lock is set.
struct tsch_slotframe * tsch_schedule_slotframe_head(void)
Access the first item in the list of slotframes.
long int tsch_adaptive_timesync_get_drift_ppm(void)
Gives the estimated clock drift w.r.t.
#define PT_EXIT(pt)
Exit the protothread.
Definition: pt.h:411
#define ADDR_TENTATIVE
Possible states for the an address (RFC 4862)
Definition: uip-ds6.h:156
This hostname is in the process of being resolved.
Definition: resolv.h:82
#define PT_THREAD(name_args)
Declaration of a protothread.
Definition: pt.h:265
#define NBR_INCOMPLETE
Possible states for the nbr cache entries.
Definition: uip-ds6-nbr.h:64
void(* leave_network)(void)
Leave the network the node is part of.
Definition: routing.h:102
A timer.
Definition: etimer.h:76
uint64_t tsch_get_network_uptime_ticks(void)
Get the time, in clock ticks, since the TSCH network was started.
void list_add(list_t list, void *item)
Add an item at the end of a list.
Definition: list.c:142
void list_init(list_t list)
Initialize a list.
Definition: list.c:65
int uip_sr_link_snprint(char *buf, int buflen, uip_sr_node_t *link)
Print a textual description of a source routing link.
Definition: uip-sr.c:252
Header file for the uIP TCP/IP stack.
const char * log_level_to_str(int level)
Returns a textual description of a log level.
Definition: log.c:204
int log_get_level(const char *module)
Returns the current log level.
Definition: log.c:188
#define LIST(name)
Declare a linked list.
Definition: list.h:89
uip_ds6_netif_t uip_ds6_if
The single interface.
Definition: uip-ds6.c:75
void rpl_refresh_routes(const char *str)
Triggers a route fresh via DTSN increment.
Definition: rpl-dag.c:189
uip_ds6_nbr_t * uip_ds6_nbr_next(uip_ds6_nbr_t *nbr)
Get the next neighbor cache of a specified one.
Definition: uip-ds6-nbr.c:444
void(* local_repair)(const char *str)
Triggers a RPL local topology repair.
Definition: routing.h:126
void tsch_set_pan_secured(int enable)
Enable/disable security.
Definition: tsch.c:179
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.
Definition: uip-ds6-nbr.c:392
void uip_icmp6_send(const uip_ipaddr_t *dest, int type, int code, int payload_len)
Send an icmpv6 message.
Definition: uip-icmp6.c:230
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
Definition: uiplib.h:71
Header file for the logging system
Hostname is fresh and usable.
Definition: resolv.h:63
void resolv_query(const char *name)
Queues a name so that a question for the name will be sent out.
Definition: resolv.c:1198
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
Definition: etimer.c:177
void list_remove(list_t list, void *item)
Remove a specific element from a list.
Definition: list.c:237
void shell_output_6addr(shell_output_func output, const uip_ipaddr_t *ipaddr)
Prints an IPv6 address.
Definition: shell.c:55
void * list_item_next(void *item)
Get the next item following this item.
Definition: list.c:322
int rpl_neighbor_snprint(char *buf, int buflen, rpl_nbr_t *nbr)
Print a textual description of RPL neighbor into a string.
Definition: rpl-neighbor.c:90
A node in a source routing graph, stored at the root and representing all child-parent relationship...
Definition: uip-sr.h:92
void tsch_set_coordinator(int enable)
Set the node as PAN coordinator.
Definition: tsch.c:168
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...
Definition: uip-ds6-nbr.h:105