void ccnl_relay_config(struct ccnl_relay_s *relay, char *ethdev, int udpport, int tcpport, char *uxpath, int max_cache_entries, char *crypto_face_path) { struct ccnl_if_s *i; char h[1024]; DEBUGMSG(99, "ccnl_relay_config\n"); relay->max_cache_entries = max_cache_entries; #ifdef USE_SCHEDULER relay->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler; relay->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler; #endif #ifdef USE_ETHERNET // add (real) eth0 interface with index 0: if (ethdev) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_ethdev(ethdev, &i->addr.eth, CCNL_ETH_TYPE); i->mtu = 1500; i->reflect = 1; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new ETH interface (%s %s) configured\n", ethdev, ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open eth device\n"); } #endif // USE_ETHERNET if (udpport > 0) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_udpdev(udpport, &i->addr.ip4); // i->frag = CCNL_DGRAM_FRAG_NONE; i->mtu = CCN_DEFAULT_MTU; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UDP interface (ip4 %s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open udp device\n"); } #ifdef USE_HTTP_STATUS if (tcpport) { relay->http = ccnl_http_new(relay, tcpport); } #endif // USE_HTTP_STATUS #ifdef USE_UNIXSOCKET if (uxpath) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(uxpath, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open unix datagram device\n"); } #ifdef USE_SIGNATURES if(crypto_face_path) { //sending interface + face i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); ccnl_crypto_create_ccnl_crypto_face(relay, crypto_face_path); relay->crypto_path = crypto_face_path; } else fprintf(stderr, "sorry, could not open unix datagram device\n"); //receiving interface memset(h,0,sizeof(h)); sprintf(h,"%s-2",crypto_face_path); i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(h, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); //create_ccnl_crypto_face(relay, crypto_face_path); } else fprintf(stderr, "sorry, could not open unix datagram device\n"); } #endif //USE_SIGNATURES #endif // USE_UNIXSOCKET ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
void ccnl_relay_config(struct ccnl_relay_s *relay, char *ethdev, int udpport1, int udpport2, int httpport, char *uxpath, int suite, int max_cache_entries, char *crypto_face_path) { #if defined(USE_LINKLAYER) || defined(USE_UNIXSOCKET) struct ccnl_if_s *i; #endif DEBUGMSG(INFO, "configuring relay\n"); relay->max_cache_entries = max_cache_entries; #ifdef USE_SCHEDULER relay->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler; relay->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler; #endif #ifdef USE_LINKLAYER // add (real) eth0 interface with index 0: if (ethdev) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_ethdev(ethdev, &i->addr.linklayer, CCNL_ETH_TYPE); i->mtu = 1500; i->reflect = 1; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "ETH interface (%s %s) configured\n", ethdev, ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else DEBUGMSG(WARNING, "sorry, could not open eth device\n"); } #endif // USE_LINKLAYER #ifdef USE_IPV4 ccnl_relay_udp(relay, udpport1); ccnl_relay_udp(relay, udpport2); #endif #ifdef USE_HTTP_STATUS if (httpport > 0) { relay->http = ccnl_http_new(relay, httpport); } #endif // USE_HTTP_STATUS #ifdef USE_NFN relay->km = ccnl_calloc(1, sizeof(struct ccnl_krivine_s)); relay->km->configid = -1; #endif #ifdef USE_UNIXSOCKET if (uxpath) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(uxpath, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); } #ifdef USE_SIGNATURES if(crypto_face_path) { char h[1024]; //sending interface + face i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); ccnl_crypto_create_ccnl_crypto_face(relay, crypto_face_path); relay->crypto_path = crypto_face_path; } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); //receiving interface memset(h,0,sizeof(h)); sprintf(h,"%s-2",crypto_face_path); i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(h, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); //create_ccnl_crypto_face(relay, crypto_face_path); } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); } #endif //USE_SIGNATURES #endif // USE_UNIXSOCKET ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }