int main(void) { tlsf_create_with_pool(_tlsf_heap, sizeof(_tlsf_heap)); msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("Basic CCN-Lite example"); ccnl_core_init(); ccnl_start(); /* get the default interface */ gnrc_netif_t *netif = gnrc_netif_iter(NULL); /* set the relay's PID, configure the interface to interface to use CCN * nettype */ if ((netif == NULL) || (ccnl_open_netif(netif->pid, GNRC_NETTYPE_CCN) < 0)) { puts("Error registering at network interface!"); return -1; } char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }
int main(void) { #ifndef BOARD_NATIVE tlsf_add_pool(_tlsf_heap, sizeof(_tlsf_heap)); #endif msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("Basic CCN-Lite example"); ccnl_core_init(); char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }
int main(int argc, char **argv) { int opt; int max_cache_entries = CCNL_DEFAULT_MAX_CACHE_ENTRIES; // srand(time(NULL)); srandom(time(NULL)); while ((opt = getopt(argc, argv, "hc:g:i:s:v:")) != -1) { switch (opt) { case 'c': max_cache_entries = atoi(optarg); break; case 'g': inter_packet_interval = atoi(optarg); break; case 'i': inter_ccn_interval = atoi(optarg); break; case 'v': if (isdigit(optarg[0])) debug_level = atoi(optarg); else debug_level = ccnl_debug_str2level(optarg); break; case 's': theSuite = ccnl_str2suite(optarg); if (theSuite >= 0 && theSuite < CCNL_SUITE_LAST) break; case 'h': default: fprintf(stderr, "Xusage: %s [-h] [-c MAX_CONTENT_ENTRIES] " "[-g MIN_INTER_PACKET_INTERVAL] " "[-i MIN_INTER_CCNMSG_INTERVAL] " "[-s SUITE (ccnb, ccnx2014, iot2014, ndn2013)] " "[-v DEBUG_LEVEL]\n", argv[0]); exit(EXIT_FAILURE); } } time(&relays[0].startup_time); ccnl_core_init(); DEBUGMSG(INFO, "This is ccn-lite-simu, starting at %s", ctime(&relays[0].startup_time) + 4); DEBUGMSG(INFO, " ccnl-core: %s\n", CCNL_VERSION); DEBUGMSG(INFO, " compile time: %s %s\n", __DATE__, __TIME__); DEBUGMSG(INFO, " compile options: %s\n", compile_string()); DEBUGMSG(INFO, "using suite %s\n", ccnl_suite2str(theSuite)); ccnl_simu_init(max_cache_entries); DEBUGMSG(INFO, "simulation starts\n"); simu_eventloop(); DEBUGMSG(INFO, "simulation ends\n"); return -1; }
int main(int argc, char **argv) { int opt; int udpport = 0; char *prefix, *defaultgw; struct ccnl_if_s *i; struct ccnl_forward_s *fwd; sockunion sun; srandom(time(NULL)); int suite = CCNL_SUITE_NDNTLV; while ((opt = getopt(argc, argv, "hs:u:v:")) != -1) { switch (opt) { case 's': opt = ccnl_str2suite(optarg); if (opt >= 0 && opt < CCNL_SUITE_LAST) suite = opt; else fprintf(stderr, "Suite parameter <%s> ignored.\n", optarg); break; case 'u': udpport = atoi(optarg); break; case 'v': debug_level = atoi(optarg); break; case 'h': default: usage: fprintf(stderr, "usage: %s [options] PREFIX DGWIP/DGWUDPPORT\n" "options: [-h] [-s SUITE] [-u udpport] [-v debuglevel]\n" "example: %s /ndn 128.252.153.194/6363\n", argv[0], argv[0]); exit(EXIT_FAILURE); } } if ((optind+1) >= argc) goto usage; prefix = argv[optind]; defaultgw = argv[optind+1]; ccnl_core_init(); // if (theRelay.suite == CCNL_SUITE_NDNTLV && !udpport) udpport = NDN_UDP_PORT; i = &theRelay.ifs[0]; i->mtu = NDN_DEFAULT_MTU; i->fwdalli = 1; i->sock = ccnl_open_udpdev(udpport); if (i->sock < 0) exit(-1); theRelay.ifcount++; fprintf(stderr, "NDN minimalrelay started, listening on UDP port %d\n", udpport); inet_aton(strtok(defaultgw,"/"), &sun.ip4.sin_addr); sun.ip4.sin_port = atoi(strtok(NULL, "")); fwd = (struct ccnl_forward_s *) ccnl_calloc(1, sizeof(*fwd)); fwd->prefix = ccnl_URItoPrefix(prefix, suite, NULL, NULL); fwd->suite = suite; fwd->face = ccnl_get_face_or_create(&theRelay, 0, &sun.sa, sizeof(sun.ip4)); fwd->face->flags |= CCNL_FACE_FLAGS_STATIC; theRelay.fib = fwd; ccnl_set_timer(1000000, ccnl_minimalrelay_ageing, &theRelay, 0); ccnl_io_loop(&theRelay); return 0; }
int main(int argc, char **argv) { int opt, max_cache_entries = -1, httpport = -1; int udpport1 = -1, udpport2 = -1; char *datadir = NULL, *ethdev = NULL, *crypto_sock_path = NULL; #ifdef USE_UNIXSOCKET char *uxpath = CCNL_DEFAULT_UNIXSOCKNAME; #else char *uxpath = NULL; #endif #ifdef USE_ECHO char *echopfx = NULL; #endif time(&theRelay.startup_time); srandom(time(NULL)); while ((opt = getopt(argc, argv, "hc:d:e:g:i:o:p:s:t:u:v:x:")) != -1) { switch (opt) { case 'c': max_cache_entries = atoi(optarg); break; case 'd': datadir = optarg; break; case 'e': ethdev = optarg; break; case 'g': inter_pkt_interval = atoi(optarg); break; case 'i': inter_ccn_interval = atoi(optarg); break; #ifdef USE_ECHO case 'o': echopfx = optarg; break; #endif case 'p': crypto_sock_path = optarg; break; case 's': suite = ccnl_str2suite(optarg); if (!ccnl_isSuite(suite)) goto usage; break; case 't': httpport = atoi(optarg); break; case 'u': if (udpport1 == -1) udpport1 = atoi(optarg); else udpport2 = atoi(optarg); break; case 'v': #ifdef USE_LOGGING if (isdigit(optarg[0])) debug_level = atoi(optarg); else debug_level = ccnl_debug_str2level(optarg); #endif break; case 'x': uxpath = optarg; break; case 'h': default: usage: fprintf(stderr, "usage: %s [options]\n" " -c MAX_CONTENT_ENTRIES\n" " -d databasedir\n" " -e ethdev\n" " -g MIN_INTER_PACKET_INTERVAL\n" " -h\n" " -i MIN_INTER_CCNMSG_INTERVAL\n" #ifdef USE_ECHO " -o echo_prefix\n" #endif " -p crypto_face_ux_socket\n" " -s SUITE (ccnb, ccnx2015, cisco2015, iot2014, ndn2013)\n" " -t tcpport (for HTML status page)\n" " -u udpport (can be specified twice)\n" #ifdef USE_LOGGING " -v DEBUG_LEVEL (fatal, error, warning, info, debug, verbose, trace)\n" #endif #ifdef USE_UNIXSOCKET " -x unixpath\n" #endif , argv[0]); exit(EXIT_FAILURE); } } opt = ccnl_suite2defaultPort(suite); if (udpport1 < 0) udpport1 = opt; if (httpport < 0) httpport = opt; ccnl_core_init(); DEBUGMSG(INFO, "This is ccn-lite-relay, starting at %s", ctime(&theRelay.startup_time) + 4); DEBUGMSG(INFO, " ccnl-core: %s\n", CCNL_VERSION); DEBUGMSG(INFO, " compile time: %s %s\n", __DATE__, __TIME__); DEBUGMSG(INFO, " compile options: %s\n", compile_string); DEBUGMSG(INFO, "Abhinav - Modified CCN lite"); // DEBUGMSG(INFO, "using suite %s\n", ccnl_suite2str(suite)); ccnl_relay_config(&theRelay, ethdev, udpport1, udpport2, httpport, uxpath, suite, max_cache_entries, crypto_sock_path); if (datadir) ccnl_populate_cache(&theRelay, datadir); #ifdef USE_ECHO if (echopfx) { struct ccnl_prefix_s *pfx; char *dup = ccnl_strdup(echopfx); pfx = ccnl_URItoPrefix(dup, suite, NULL, NULL); if (pfx) ccnl_echo_add(&theRelay, pfx); ccnl_free(dup); } #endif ccnl_io_loop(&theRelay); while (eventqueue) ccnl_rem_timer(eventqueue); ccnl_core_cleanup(&theRelay); #ifdef USE_HTTP_STATUS theRelay.http = ccnl_http_cleanup(theRelay.http); #endif #ifdef USE_DEBUG_MALLOC debug_memdump(); #endif return 0; }