Пример #1
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;
}
Пример #2
0
int
main(int argc, char **argv)
{
    int opt;
    int max_cache_entries = -1;
    int udpport = CCN_UDP_PORT;
    int tcpport = CCN_UDP_PORT;
    char *datadir = NULL;
    char *ethdev = NULL;
    char *crypto_sock_path = 0;
#ifdef USE_UNIXSOCKET
    char *uxpath = CCNL_DEFAULT_UNIXSOCKNAME;
#else
    char *uxpath = NULL;
#endif

    time(&theRelay.startup_time);
    srandom(time(NULL));

    while ((opt = getopt(argc, argv, "hc:d:e:g:i:s:u:v:x:p:")) != -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;
        case 's':
            tcpport = atoi(optarg);
            break;
        case 'u':
            udpport = atoi(optarg);
            break;
        case 'v':
            debug_level = atoi(optarg);
            break;
        case 'x':
            uxpath = optarg;
            break;
        case 'p':
            crypto_sock_path = optarg;
            break;
        case 'h':
        default:
            fprintf(stderr,
		    "usage: %s [-h] [-c MAX_CONTENT_ENTRIES]"
		    " [-d databasedir]"
		    " [-e ethdev]"
		    " [-g MIN_INTER_PACKET_INTERVAL]"
		    " [-i MIN_INTER_CCNMSG_INTERVAL]"
		    " [-s tcpport]"
		    " [-u udpport]"
		    " [-v DEBUG_LEVEL]"

#ifdef USE_UNIXSOCKET
                    " [-p crypto_face_ux_socket]"
		    " [-x unixpath]"
#endif
		    "\n", argv[0]);
            exit(EXIT_FAILURE);
        }
    }

    DEBUGMSG(1, "This is ccn-lite-relay, starting at %s", ctime(&theRelay.startup_time) + 4);
    DEBUGMSG(1, "  ccnl-core: %s\n", CCNL_VERSION);
    DEBUGMSG(1, "  compile time: %s %s\n", __DATE__, __TIME__);
    DEBUGMSG(1, "  compile options: %s\n", compile_string());

    ccnl_relay_config(&theRelay, ethdev, udpport, tcpport,
		      uxpath, max_cache_entries, crypto_sock_path);
    if (datadir)
	ccnl_populate_cache(&theRelay, datadir);
    
    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;
}
Пример #3
0
void handle_populate_cache(struct ccnl_relay_s *ccnl)
{
    DEBUGMSG(1, "ccnl_populate_cache with: text_txt_ccnb\n");
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_0, (int) text_txt_ccnb_0_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_1, (int) text_txt_ccnb_1_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_2, (int) text_txt_ccnb_2_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_3, (int) text_txt_ccnb_3_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_4, (int) text_txt_ccnb_4_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_5, (int) text_txt_ccnb_5_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_6, (int) text_txt_ccnb_6_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_7, (int) text_txt_ccnb_7_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_8, (int) text_txt_ccnb_8_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_9, (int) text_txt_ccnb_9_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_10, (int) text_txt_ccnb_10_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_11, (int) text_txt_ccnb_11_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_12, (int) text_txt_ccnb_12_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_13, (int) text_txt_ccnb_13_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_14, (int) text_txt_ccnb_14_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_15, (int) text_txt_ccnb_15_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_16, (int) text_txt_ccnb_16_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_17, (int) text_txt_ccnb_17_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_18, (int) text_txt_ccnb_18_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_19, (int) text_txt_ccnb_19_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_20, (int) text_txt_ccnb_20_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_21, (int) text_txt_ccnb_21_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_22, (int) text_txt_ccnb_22_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_23, (int) text_txt_ccnb_23_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_24, (int) text_txt_ccnb_24_len);
    ccnl_populate_cache(ccnl, (unsigned char *) text_txt_ccnb_25, (int) text_txt_ccnb_25_len);
}