examples: open first interface automatically

This commit is contained in:
Oleg Hahm 2016-07-19 20:35:14 +02:00
parent 8ebdf39d14
commit 99e3a22d63
2 changed files with 18 additions and 13 deletions

View File

@ -8,14 +8,6 @@ use only one packet format, `ndn2013`, and only relay over the link-layer
## The shell commands ## The shell commands
RIOT provides three shell to interact with the CCN-Lite stack: RIOT provides three shell to interact with the CCN-Lite stack:
* `ccnl_open` - opens and configures a network device to be used for CCN-Lite.
It expects one parameter specifying the PID of the network
device. (You can figure out the PID of your network device(s)
by calling `ifconfig`.) In this example, this should always be
3, hence, calling `ccnl_open 3` should work. (If you specify an
incorrect ID, you should get an error message.) You have to
call this command, before you can actually send or receive
anything.
* `ccnl_int` - generates and sends out an Interest. The command expects one * `ccnl_int` - generates and sends out an Interest. The command expects one
mandatory and one optional parameter. The first parameter mandatory and one optional parameter. The first parameter
specifies the exact name (or a prefix) to request, the second specifies the exact name (or a prefix) to request, the second
@ -51,13 +43,12 @@ An example usage of this application could be setup like this:
windows. windows.
3. Call `make -B clean all term` in the first terminal and `PORT=tap1 make 3. Call `make -B clean all term` in the first terminal and `PORT=tap1 make
term` in the second one. term` in the second one.
4. Enter `ccnl_open 3` in both terminals. 4. Enter `ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!` on the first
5. Enter `ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!` on the first
terminal. terminal.
6. Add a FIB entry for this prefix on the second node, e.g. using the broadcast 5. Add a FIB entry for this prefix on the second node, e.g. using the broadcast
address: `ccnl_fib add /riot/peter/schmerzl ff:ff:ff:ff:ff:ff` address: `ccnl_fib add /riot/peter/schmerzl ff:ff:ff:ff:ff:ff`
7. Enter `ccnl_int /riot/peter/schmerzl` in the second terminal. 6. Enter `ccnl_int /riot/peter/schmerzl` in the second terminal.
8. See the content being displayed. Be happy! 7. See the content being displayed. Be happy!
## Makefile configuration ## Makefile configuration

View File

@ -24,6 +24,7 @@
#include "msg.h" #include "msg.h"
#include "shell.h" #include "shell.h"
#include "ccn-lite-riot.h" #include "ccn-lite-riot.h"
#include "net/gnrc/netif.h"
/* main thread's message queue */ /* main thread's message queue */
#define MAIN_QUEUE_SIZE (8) #define MAIN_QUEUE_SIZE (8)
@ -42,6 +43,19 @@ int main(void)
ccnl_core_init(); ccnl_core_init();
ccnl_start();
/* get the default interface */
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
/* set the relay's PID, configure the interface to interface to use CCN
* nettype */
if ((ifnum <= 0) || (ccnl_open_netif(ifs[0], GNRC_NETTYPE_CCN) < 0)) {
puts("Error registering at network interface!");
return -1;
}
char line_buf[SHELL_DEFAULT_BUFSIZE]; char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0; return 0;