Ejemplo n.º 1
0
int main(int argc, char **argv) 
{

    /*
     *  Check for superuser privileges
     */

    if (geteuid()) {
        printf("Running %s requires superuser privileges! Exiting...\n", LISPD);
        exit(EXIT_FAILURE);
    }

    /*
     *  Initialize the random number generator
     */
     
    iseed = (unsigned int) time (NULL);
    srandom(iseed);

    /*
     * Set up signal handlers
     */

    signal(SIGHUP,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGQUIT, signal_handler);

    /*
     *  set up syslog now, checking to see if we're daemonizing...
     */

    set_up_syslog();

    /*
     *  Unload/load LISP kernel modules
     */

    system("/sbin/modprobe -r lisp lisp_int");

    if (system("/sbin/modprobe lisp")) {
        syslog(LOG_DAEMON, "Loading the 'lisp' kernel module failed! Exiting...");
        exit(EXIT_FAILURE);
    }
    syslog(LOG_DAEMON, "Loaded the 'lisp' kernel module");
    sleep(1);

    if (system("/sbin/modprobe lisp_int")) {
        syslog(LOG_DAEMON, "Loading the 'lisp_int' kernel module failed! Exiting...");
        exit(EXIT_FAILURE);
    }
    syslog(LOG_DAEMON, "Loaded the 'lisp_int' kernel module");
    sleep(1);

    /*
     *  Setup LISP and routing netlink sockets
     */

    if (!setup_netlink()) {
        syslog(LOG_DAEMON, "Can't set up netlink socket for lisp_mod communication");
        exit(EXIT_FAILURE);
    }

    if (!setup_netlink_iface()) {
        syslog(LOG_DAEMON, "Can't set up netlink socket for interface events");
        exit(EXIT_FAILURE);
    }

    syslog(LOG_DAEMON, "Netlink sockets created");

    /*
     *  set up databases
     */

    AF4_database  = New_Patricia(sizeof(struct in_addr)  * 8);
    AF6_database  = New_Patricia(sizeof(struct in6_addr) * 8);

    /*
     *  Parse command line options
     */

    handle_lispd_command_line(argc, argv);

    // Modified by acabello
    // init_datacache has the following parameters:
    // void (*cbk)(datacache_elt_t*); -> callback function (see example in lispd_lib.c)
    if (!init_datacache(callback_elt)) {
        syslog(LOG_DAEMON, "malloc (datacache): %s", strerror(errno));
        exit(EXIT_FAILURE);
    }

    /*
     *  Now do the config file
     */

    handle_lispd_config_file();

    /*
     * now build the v4/v6 receive sockets
     */

    if (build_receive_sockets() == 0) 
        exit(EXIT_FAILURE);

    /*
     *  create timers
     */

    if ((map_register_timer_fd = timerfd_create(CLOCK_REALTIME, 0)) == -1)
        syslog(LOG_INFO, "Could not create periodic map register timer");

    /*
     *  see if we need to daemonize, and if so, do it
     */

    if (daemonize) {
        syslog(LOG_INFO, "Starting the daemonizing process");
        if ((pid = fork()) < 0) {
            exit(EXIT_FAILURE);
        } 
        umask(0);
        if (pid > 0)
            exit(EXIT_SUCCESS);
        if ((sid = setsid()) < 0)
            exit(EXIT_FAILURE);
        if ((chdir("/")) < 0)
            exit(EXIT_FAILURE);
        close(STDIN_FILENO);
        close(STDOUT_FILENO);
        close(STDERR_FILENO);
    }

    /* PN XXX
     * comment out test definition to avoid any
     * interactions with the data plane
     */



#define test
#ifdef test

    int ret = register_lispd_process();
    if (ret < 0) {
        syslog(LOG_INFO, "Couldn't register lispd process, err: %d", ret);
        exit(EXIT_FAILURE);
    }
    syslog(LOG_DAEMON, "Registered lispd with kernel module");

    ret = install_database_mappings();
    if (ret < 0) {
        syslog(LOG_INFO, "Could not install database mappings, err: %d", ret);
        exit(EXIT_FAILURE);
    }
    syslog(LOG_DAEMON, "Installed database mappings");

    ret = install_map_cache_entries();
    if (ret < 0) {
        syslog(LOG_INFO, "Could not install static map-cache entries, err: %d", ret);
    }

#endif

    /*
     *  Dump routing table so we can get the gateway address for source routing
     */

    if (!dump_routing_table(AF_INET, RT_TABLE_MAIN))
        syslog(LOG_INFO, "Dumping main routing table failed");

    /*
     *  Register to the Map-Server(s)
     */

    if (!map_register(AF6_database))
        syslog(LOG_INFO, "Could not map register AF_INET6 with Map Servers");

    if (!map_register(AF4_database))
        syslog(LOG_INFO, "Could not map register AF_INET with Map Servers");

    event_loop();
    syslog(LOG_INFO, "Exiting...");         /* event_loop returned bad */
    closelog();
    return(0);
}
Ejemplo n.º 2
0
JNIEXPORT jintArray JNICALL Java_org_lispmob_noroot_LISPmob_1JNI_startLispd
  (JNIEnv *env, jclass cl, jint vpn_tun_fd, jstring storage_path)
{
    jintArray           fd_list;
    jint                sockets_fds[4];
    uint32_t            iseed         = 0;  /* initial random number generator */
    pid_t               pid           = 0;    /* child pid */
    pid_t               sid           = 0;
    char                log_file[1024];
    const char          *path         = NULL;

    memset (log_file,0,sizeof(char)*1024);
    init_globales();

    path = (*env)->GetStringUTFChars(env, storage_path, 0);
    config_file = calloc(1024, sizeof(char));
    strcat(config_file,path);
    strcat(config_file,CONF_FILE_NAME);
    strcat(log_file,path);
    strcat(log_file,LOG_FILE_NAME);
    (*env)->ReleaseStringUTFChars(env, storage_path, path);

    open_log_file(log_file);


    lispd_log_msg(LISP_LOG_INFO,"LISPmob %s compiled for not rooted Android", LISPD_VERSION);



    /*
     *  Initialize the random number generator
     */

    iseed = (unsigned int) time (NULL);
    srandom(iseed);

    /*
     * Set up signal handlers
     */
    signal(SIGHUP,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGQUIT, signal_handler);

    /*
     *  set up databases
     */
    if (db_init() != GOOD ||
            map_cache_init() != GOOD ||
            init_referral_cache() != GOOD){
        exit_cleanup();
    }

    /*
     *  create timers
     */

    if (build_timers_event_socket(&timers_fd) == 0)
    {
        lispd_log_msg(LISP_LOG_CRIT, " Error programing the timer signal. Exiting...");
        exit_cleanup();
        return (NULL);
    }
    init_timers();

    /*
     * Create net_link socket to receive notifications of changes of RLOC status.
     */
    if ((netlink_fd = opent_netlink_socket()) == -1){
        lispd_log_msg(LISP_LOG_CRIT, " Error programing netlink socket. Exiting...");
        exit_cleanup();
        return (NULL);
    }

    if ((ipc_control_fd    = open_ipc_socket(IPC_CONTROL_RX_PORT)) == -1){
        lispd_log_msg(LISP_LOG_CRIT, " Error programing IPC socket. Exiting...");
        exit_cleanup();
        return (NULL);
    }

    err = handle_lispd_config_file(config_file);


    if (err != GOOD){
        lispd_log_msg(LISP_LOG_CRIT,"Wrong configurationn.");
        ipc_send_log_msg(WRONG_CONF);
        sleep(2);
        exit_cleanup();
        return (NULL);
    }

    if (nat_aware == TRUE){
        nat_set_xTR_ID();
    }

    /*
     * Select the default rlocs for output data packets and output control packets
     */

    set_default_output_ifaces();

    set_default_ctrl_ifaces();

    /*
     * Generate receive sockets for control (4342) and data port (4341)
     */

    if (default_rloc_afi == AF_UNSPEC || default_rloc_afi == AF_INET){
        ipv4_control_input_fd = open_control_input_socket(AF_INET);
        ipv4_data_input_fd = open_data_input_socket(AF_INET);
        if (ipv4_control_input_fd == -1 || ipv4_data_input_fd == -1){
            lispd_log_msg(LISP_LOG_CRIT, " Error programing IPv4 sockets. Exiting...");
            exit_cleanup();
            return (NULL);
        }
    }
    if (default_rloc_afi == AF_UNSPEC || default_rloc_afi == AF_INET6){
        ipv6_control_input_fd = open_control_input_socket(AF_INET6);
        ipv6_data_input_fd = open_data_input_socket(AF_INET6);
        if (ipv6_control_input_fd == -1 || ipv6_data_input_fd == -1){
            lispd_log_msg(LISP_LOG_CRIT, " Error programing IPv6 sockets. Exiting...");
            exit_cleanup();
            return (NULL);
        }
    }

    tun_fd = vpn_tun_fd;





    lispd_log_msg(LISP_LOG_INFO,"LISPmob (%s): 'lispd' started...", LISPD_VERSION);
    if (router_mode == TRUE){
        lispd_log_msg(LISP_LOG_INFO,"Running as an xTR router");
    }else{
        lispd_log_msg(LISP_LOG_INFO,"Running as a LISP mobile node");
    }


    fd_list = (*env)->NewIntArray(env, 4);
    if (fd_list == NULL) {
        return NULL; /* out of memory error thrown */
    }

    if (default_ctrl_iface_v4 != NULL ||  default_ctrl_iface_v6 != NULL){
        sockets_fds[0] = ipv4_control_input_fd;
        sockets_fds[1] = ipv4_data_input_fd;
        sockets_fds[2] = ipv6_control_input_fd;
        sockets_fds[3] = ipv6_data_input_fd;
    }else{ // We started LISPmob without any interface UP */
        ipc_send_log_msg(NO_NETWORK);
        sockets_fds[0] = -1;
        sockets_fds[1] = -1;
        sockets_fds[2] = -1;
        sockets_fds[3] = -1;
    }

    (*env)->SetIntArrayRegion(env, fd_list, 0, 4, sockets_fds);
    return fd_list;
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    int    fd                           = 0;
    pid_t  pid				= 0;	/* child pid */
    pid_t  sid				= 0;

    init();

    /*
     *	set up databases
     */
    if (!db_init()) {
        log_msg(INFO, "Couldn't create databases");
        exit(EXIT_FAILURE);
    }

    /*
     *	Parse command line options
     */
    handle_lispd_command_line(argc, argv);

    /*
     *	see if we need to daemonize, and if so, do it
     */
    if (lispd_config.daemonize) {
        log_msg(INFO, "lispd is backgrounding...");
        if ((pid = fork()) < 0) {
            exit(EXIT_FAILURE);
        }

        if (pid > 0) {
            log_msg(INFO, "done. Running as PID %d", pid);
            exit(EXIT_SUCCESS);
        }
        umask(0);
        if ((sid = setsid()) < 0)
            exit(EXIT_FAILURE);
        if ((chdir("/")) < 0)
            exit(EXIT_FAILURE);

        /*
         * Redirect standard files to /dev/null save fd in
         * case we need to get back to stdout later
         */
        fd = dup(fileno(stdout));
    }

    signal(SIGHUP,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGQUIT, signal_handler);

    init_timers();

    /*
     * Check if lispd is already running. Only allow one instance!
     */
    if (!get_process_lock(getpid())) {
        log_msg(FATAL, "lispd already running, please stop before restarting. If this seems wrong"
                " remove %s.", LISPD_LOCKFILE);


        printf("lispd already running, please stop before restarting.\n If this appears wrong,"
               " remove %s.\n", LISPD_LOCKFILE);
        exit(EXIT_FAILURE);
    }

    if (!setup_netlink()) {
        log_msg(FATAL, "Can't set up netlink socket (is the kernel module loaded?), exiting...");
        die(EXIT_FAILURE);
    }
    if (!setup_rtnetlink()) {
        log_msg(FATAL, "Can't setup rtnetlink socket, exiting...");
        die(EXIT_FAILURE);
    }

    if (!register_lispd_process()) {
        log_msg(FATAL, "Couldn't register lispd process, exiting...");
        die(EXIT_FAILURE);
    }

    log_msg(INFO, "Version %d.%d.%d starting up...",
            MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION);

    /*
     * now build the v4/v6 receive sockets
     */
    if (build_receive_sockets() == 0) {
        log_msg(FATAL, "  exiting...");
        die(EXIT_FAILURE);
    }

    if (build_event_socket() == 0)
    {
        log_msg(FATAL, "  exiting...");
        die(EXIT_FAILURE);
    }
    log_msg(INFO, "Built receive/event sockets");

    /*
     *	Now do the config file
     */
    if (handle_lispd_config_file()) {
        log_msg(FATAL, "Fatal error parsing config file.");
        dump_fatal_error();
        die(EXIT_FAILURE);
    }

    /*
     *	set up syslog now, checking to see if we're daemonizing...
     */
    setup_log();

    log_msg(INFO, "Read config file");

    if (!install_database_mappings()) {
        log_msg(FATAL, "  exiting...");
        die(EXIT_FAILURE);
    }
#ifdef DEADCODE
    if (!install_map_cache_entries())
        log_msg(INFO, "Could not install static map-cache entries");
#endif
    if (!map_register())
        log_msg(INFO, "Could not map register.");

    set_timer(RLOCProbeScan, RLOC_PROBE_CHECK_INTERVAL);

    clear_map_cache();

    listen_on_well_known_port();

    dump_info_file();
    event_loop();
    log_msg(INFO, "exiting...");		/* event_loop returned bad */
    remove_process_lock();
    exit(0);
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    uint32_t            iseed         = 0;  /* initial random number generator */
    pid_t               pid           = 0;    /* child pid */
    pid_t               sid           = 0;


    init_globales();

    /*
     *  Parse command line options
     */

    handle_lispd_command_line(argc, argv);

#ifndef ANDROID
    /*
     *  Check for required capabilities and drop unnecssary privileges
     */

    if(check_capabilities() != GOOD) {
        exit_cleanup();
    }
#else

    /*
     * Check for superuser privileges
     */
    if (geteuid() != 0) {
        lispd_log_msg(LISP_LOG_INFO,"Running %s requires superuser privileges! Exiting...\n", LISPD);
        exit_cleanup();
    }
#endif

    /*
     *  Initialize the random number generator
     */

    iseed = (unsigned int) time (NULL);
    srandom(iseed);

    /*
     * Set up signal handlers
     */
    signal(SIGHUP,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGQUIT, signal_handler);


    /*
     *  set up databases
     */
    if (db_init() != GOOD ||
            map_cache_init() != GOOD ||
            init_referral_cache() != GOOD){
        exit_cleanup();
    }


    /*
     *  see if we need to daemonize, and if so, do it
     */

    if (daemonize) {
        lispd_log_msg(LISP_LOG_DEBUG_1, "Starting the daemonizing process1");
        if ((pid = fork()) < 0) {
            exit_cleanup();
        }
        umask(0);
        if (pid > 0){
            exit(EXIT_SUCCESS);
        }
        if ((sid = setsid()) < 0){
            exit_cleanup();
        }
        if ((chdir("/")) < 0){
            exit_cleanup();
        }
    }



    /*
     *  create timers
     */

    if (build_timers_event_socket(&timers_fd) != GOOD)
    {
        lispd_log_msg(LISP_LOG_CRIT, " Error programing the timer signal. Exiting...");
        exit_cleanup();
    }
    init_timers();



    /*
     * Create net_link socket to receive notifications of changes of RLOC status.
     */
    if ((netlink_fd = opent_netlink_socket()) == -1){
        lispd_log_msg(LISP_LOG_CRIT, " Error programing netlink socket. Exiting...");
        exit_cleanup();
    }

    /*
     *  Parse config file. Format of the file depends on the node: Linux Box or OpenWRT router
     */

#ifdef OPENWRT
    if (config_file == NULL){
        config_file = strdup("/etc/config/lispd");
    }
    err = handle_uci_lispd_config_file(config_file);
#else
    if (config_file == NULL){
        config_file = strdup("/etc/lispd.conf");
    }
    err = handle_lispd_config_file(config_file);
#endif

    if (err != GOOD){
        lispd_log_msg(LISP_LOG_CRIT,"Wrong configuration.");
        exit_cleanup();
    }

    if (ddt_client == FALSE){
        drop_referral_cache();
    }

    if (nat_aware == TRUE){
        nat_set_xTR_ID();
    }
    /*
     * Select the default rlocs for output data packets and output control packets
     */
    set_default_output_ifaces();

    set_default_ctrl_ifaces();

    /*
     * Create tun interface
     */

    if (create_tun(TUN_IFACE_NAME,
            TUN_RECEIVE_SIZE,
            TUN_MTU) != GOOD){
        exit_cleanup();
    }

    /*
     * Assign address to the tun interface and add routing to this interface
     */
    if (configure_routing_to_tun() != GOOD){
        exit_cleanup();
    }

    /*
     * Generate receive sockets for control (4342) and data port (4341)
     */

    if (default_rloc_afi == AF_UNSPEC || default_rloc_afi == AF_INET){
        ipv4_control_input_fd = open_control_input_socket(AF_INET);
        ipv4_data_input_fd = open_data_input_socket(AF_INET);
    }

    if (default_rloc_afi == AF_UNSPEC || default_rloc_afi == AF_INET6){
        ipv6_control_input_fd = open_control_input_socket(AF_INET6);
        ipv6_data_input_fd = open_data_input_socket(AF_INET6);
    }



    /*
     * Request to dump the routing tables to obtain the gatways when processing the netlink messages
     */

    request_route_table(RT_TABLE_MAIN, AF_INET);
    process_netlink_msg(netlink_fd);
    request_route_table(RT_TABLE_MAIN, AF_INET6);
    process_netlink_msg(netlink_fd);


#ifdef OPENWRT
    lispd_log_msg(LISP_LOG_INFO,"LISPmob %s compiled for openWRT\n", LISPD_VERSION);
#else
#ifdef ANDROID
    lispd_log_msg(LISP_LOG_INFO,"LISPmob %s compiled for Android\n", LISPD_VERSION);
#else
    lispd_log_msg(LISP_LOG_INFO,"LISPmob %s compiled for Linux\n", LISPD_VERSION);
#endif
#endif

    lispd_log_msg(LISP_LOG_INFO,"LISPmob (%s): 'lispd' started...", LISPD_VERSION);
    if (router_mode == TRUE){
        lispd_log_msg(LISP_LOG_INFO,"Running as an xTR router");
    }else{
        lispd_log_msg(LISP_LOG_INFO,"Running as a LISP mobile node");
    }



    /*
     *  Register to the Map-Server(s)
     */

    if (nat_aware == TRUE){
        initial_info_request_process();
    }else{
        initial_map_register_process();
        /*
         * SMR proxy-ITRs list to be updated with new mappings
         */

        init_smr(NULL,NULL);
    }


    /*
     * RLOC Probing proxy ETRs
     */
    programming_petr_rloc_probing();


    event_loop();

    lispd_log_msg(LISP_LOG_INFO, "Exiting...");         /* event_loop returned bad */
    closelog();
    return(0);
}
Ejemplo n.º 5
0
int main(int argc, char **argv) 
{
    lisp_addr_t *tun_v4_addr;
    lisp_addr_t *tun_v6_addr;
    char *tun_dev_name = TUN_IFACE_NAME;

#ifdef ROUTER
#ifdef OPENWRT
    lispd_log_msg(LISP_LOG_INFO,"LISPmob compiled for openWRT xTR\n");
#else
    lispd_log_msg(LISP_LOG_INFO,"LISPmob compiled for linux xTR\n");
#endif
#else
    lispd_log_msg(LISP_LOG_INFO,"LISPmob compiled for mobile node\n");
#endif


    /*
     *  Check for superuser privileges
     */

    if (geteuid()) {
        lispd_log_msg(LISP_LOG_INFO,"Running %s requires superuser privileges! Exiting...\n", LISPD);
        exit_cleanup();
    }

    /*
     *  Initialize the random number generator
     */

    iseed = (unsigned int) time (NULL);
    srandom(iseed);

    /*
     * Set up signal handlers
     */

    signal(SIGHUP,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGQUIT, signal_handler);


    /*
     *  set up databases
     */

    db_init();
    map_cache_init();


    /*
     *  Parse command line options
     */

    handle_lispd_command_line(argc, argv);



    /*
     *  see if we need to daemonize, and if so, do it
     */

    if (daemonize) {
        lispd_log_msg(LISP_LOG_DEBUG_1, "Starting the daemonizing process");
        if ((pid = fork()) < 0) {
            exit_cleanup();
        }
        umask(0);
        if (pid > 0)
            exit_cleanup();
        if ((sid = setsid()) < 0)
            exit_cleanup();
        if ((chdir("/")) < 0)
            exit_cleanup();
        close(STDIN_FILENO);
        close(STDOUT_FILENO);
        close(STDERR_FILENO);
    }


    /*
     *  create timers
     */

    if (build_timers_event_socket(&timers_fd) == 0)
    {
        lispd_log_msg(LISP_LOG_CRIT, " Error programing the timer signal. Exiting...");
        exit_cleanup();
    }
    init_timers();




    /*
     *  Parse config file. Format of the file depends on the node: Linux Box or OpenWRT router
     */

#ifdef OPENWRT
    if (config_file == NULL){
        config_file = "/etc/config/lispd";
    }
    handle_uci_lispd_config_file(config_file);
#else
    if (config_file == NULL){
        config_file = "/etc/lispd.conf";
    }
    handle_lispd_config_file(config_file);
#endif

    if (map_servers == NULL){
        lispd_log_msg(LISP_LOG_CRIT, "No Map Server configured. Exiting...");
        exit_cleanup();
    }

    if (map_resolvers == NULL){
        lispd_log_msg(LISP_LOG_CRIT, "No Map Resolver configured. Exiting...");
        exit_cleanup();
    }

    if (proxy_etrs == NULL){
        lispd_log_msg(LISP_LOG_WARNING, "No Proxy-ETR defined. Packets to non-LISP destinations will be "
                "forwarded natively (no LISP encapsulation). This may prevent mobility in some scenarios.");
        sleep(3);
    }else{
        calculate_balancing_vectors (
                proxy_etrs->mapping,
                &(((rmt_mapping_extended_info *)(proxy_etrs->mapping->extended_info))->rmt_balancing_locators_vecs));
    }


    /*
     * Select the default rlocs for output data packets and output control packets
     */

    set_default_output_ifaces();

    set_default_ctrl_ifaces();


    /*
     * Create tun interface
     */

    create_tun(tun_dev_name,
            TUN_RECEIVE_SIZE,
            TUN_MTU,
            &tun_receive_fd,
            &tun_ifindex,
            &tun_receive_buf);


    /*
     * Assign address to the tun interface
     * Assign route to 0.0.0.0/1 and 128.0.0.0/1 via tun interface
     *                 ::/1      and 8000::/1
     */

#ifdef ROUTER
    tun_v4_addr = get_main_eid(AF_INET);
    if (tun_v4_addr != NULL){
        tun_v4_addr = (lisp_addr_t *)malloc(sizeof(lisp_addr_t));
        get_lisp_addr_from_char(TUN_LOCAL_V4_ADDR,tun_v4_addr);
    }
    tun_v6_addr = get_main_eid(AF_INET6);
    if (tun_v6_addr != NULL){
        tun_v6_addr = (lisp_addr_t *)malloc(sizeof(lisp_addr_t));
        get_lisp_addr_from_char(TUN_LOCAL_V6_ADDR,tun_v6_addr);
    }
#else
    tun_v4_addr = get_main_eid(AF_INET);
    tun_v6_addr = get_main_eid(AF_INET6);
#endif

    tun_bring_up_iface(tun_dev_name);
    if (tun_v4_addr != NULL){
        tun_add_eid_to_iface(*tun_v4_addr,tun_dev_name);
        set_tun_default_route_v4();
    }
    if (tun_v6_addr != NULL){
        tun_add_eid_to_iface(*tun_v6_addr,tun_dev_name);
        set_tun_default_route_v6();
    }
#ifdef ROUTER
    if (tun_v4_addr != NULL){
        free(tun_v4_addr);
    }
    if (tun_v6_addr != NULL){
        free(tun_v6_addr);
    }
#endif
    /*
     * Generate receive sockets for control (4342) and data port (4341)
     */

    if (default_rloc_afi == -1 || default_rloc_afi == AF_INET){
        ipv4_control_input_fd = open_control_input_socket(AF_INET);
        ipv4_data_input_fd = open_data_input_socket(AF_INET);
    }

    if (default_rloc_afi == -1 || default_rloc_afi == AF_INET6){
        ipv6_control_input_fd = open_control_input_socket(AF_INET6);
        ipv6_data_input_fd = open_data_input_socket(AF_INET6);
    }

    /*
     * Create net_link socket to receive notifications of changes of RLOC status.
     */
    netlink_fd = opent_netlink_socket();

    lispd_log_msg(LISP_LOG_INFO,"LISPmob (0.3.3): 'lispd' started...");

    /*
     * Request to dump the routing tables to obtain the gatways when processing the netlink messages
     */

    request_route_table(RT_TABLE_MAIN, AF_INET);
    process_netlink_msg(netlink_fd);
    request_route_table(RT_TABLE_MAIN, AF_INET6);
    process_netlink_msg(netlink_fd);

    /*
     *  Register to the Map-Server(s)
     */

    map_register (NULL,NULL);

    /*
     * SMR proxy-ITRs list to be updated with new mappings
     */

    init_smr(NULL,NULL);

    /*
     * RLOC Probing proxy ETRs
     */
    programming_petr_rloc_probing();


    event_loop();

    lispd_log_msg(LISP_LOG_INFO, "Exiting...");         /* event_loop returned bad */
    closelog();
    return(0);
}