2015-10-26 17:41:52 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Inria
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup examples
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Basic ccn-lite relay example (produce and consumer via shell)
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "msg.h"
|
2015-12-06 17:12:40 +01:00
|
|
|
#include "shell.h"
|
2015-10-26 17:41:52 +01:00
|
|
|
#include "ccn-lite-riot.h"
|
2017-11-16 18:06:46 +01:00
|
|
|
#include "net/gnrc/netif.h"
|
2017-11-27 21:40:54 +01:00
|
|
|
#include "net/gnrc/pktdump.h"
|
2015-10-26 17:41:52 +01:00
|
|
|
|
|
|
|
/* main thread's message queue */
|
|
|
|
#define MAIN_QUEUE_SIZE (8)
|
|
|
|
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
|
|
|
|
|
|
|
|
puts("Basic CCN-Lite example");
|
|
|
|
|
|
|
|
ccnl_core_init();
|
|
|
|
|
2016-07-19 20:35:14 +02:00
|
|
|
ccnl_start();
|
|
|
|
|
|
|
|
/* get the default interface */
|
2017-11-16 18:06:46 +01:00
|
|
|
gnrc_netif_t *netif;
|
2016-07-19 20:35:14 +02:00
|
|
|
|
2016-09-11 22:37:38 +02:00
|
|
|
/* set the relay's PID, configure the interface to use CCN nettype */
|
2017-11-16 18:06:46 +01:00
|
|
|
if (((netif = gnrc_netif_iter(NULL)) == NULL) ||
|
2017-07-27 15:26:49 +02:00
|
|
|
(ccnl_open_netif(netif->pid, GNRC_NETTYPE_CCN) < 0)) {
|
2016-07-19 20:35:14 +02:00
|
|
|
puts("Error registering at network interface!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-11-27 21:40:54 +01:00
|
|
|
#ifdef MODULE_NETIF
|
|
|
|
gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
|
|
|
|
gnrc_pktdump_pid);
|
|
|
|
gnrc_netreg_register(GNRC_NETTYPE_CCN_CHUNK, &dump);
|
|
|
|
#endif
|
|
|
|
|
2015-10-26 17:41:52 +01:00
|
|
|
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
2015-12-06 17:12:40 +01:00
|
|
|
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
2015-10-26 17:41:52 +01:00
|
|
|
return 0;
|
|
|
|
}
|