/* To indicate that no thread has run yet. */ return (0); } #else /* ! RTOS_EXECUTE_ONE_THREAD */ int lib_tic (struct thread_master *master, struct thread *thread) { while (thread_fetch (master, thread)) thread_call(thread); return(0); }
int main(int argc, char **argv) { struct thread thread; struct addrinfo *ai; if(optind != argc-1) { printf("usage: punter <hostname>\n"); exit(1); } /* thread master */ master = thread_master_create(); host = argv[optind]; api_init(); punter_ctrl_init(host); while(thread_fetch(master, &thread)) { thread_call(&thread); } }
int main(int argc, char **argv) { struct thread thread; master = thread_master_create(NULL); openzlog("grammar_sandbox", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED); zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG); zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED); /* Library inits. */ cmd_init(1); host.name = strdup("test"); host.domainname = strdup("testdomainname"); vty_init(master, true); memory_init(); yang_init(); nb_init(master, NULL, 0); vty_stdio(vty_do_exit); /* Fetch next active thread. */ while (thread_fetch(master, &thread)) thread_call(&thread); /* Not reached. */ exit(0); }
int main(int argc, char **argv) { thread thread_obj; /* Allocate the room */ req = (REQ *) MALLOC(sizeof (REQ)); /* Command line parser */ if (!parse_cmdline(argc, argv, req)) { FREE(req); exit(0); } /* Check minimum configuration need */ if (!req->addr_ip && !req->addr_port && !req->url) { FREE(req); exit(0); } /* Init the reference timer */ req->ref_time = timer_tol(timer_now()); DBG("Reference timer = %lu\n", req->ref_time); /* Init SSL context */ init_ssl(); /* Signal handling initialization */ signal_init(); /* Create the master thread */ master = thread_make_master(); /* Register the GET request */ init_sock(); /* * Processing the master thread queues, * return and execute one ready thread. * Run until error, used for debuging only. * Note that not calling launch_scheduler() does * not activate SIGCHLD handling, however, this * is no issue here. */ while (thread_fetch(master, &thread_obj)) thread_call(&thread_obj); /* Finalize output informations */ if (req->verbose) printf("Global response time for [%s] =%lu\n", req->url, req->response_time - req->ref_time); /* exit cleanly */ SSL_CTX_free(req->ctx); free_sock(sock); FREE(req); exit(0); }
void smart_link_master() { struct thread thread; while (thread_fetch(sl_master, &thread)) { thread_call (&thread); } }
int lib_tic (struct thread_master *master, struct thread *thread) { if (thread_fetch (master, thread)) { thread_call(thread); /* To indicate that a thread has run. */ return(1); } /* To indicate that no thread has run yet. */ return (0); }
int main (int argc, char **argv) { (void) argv; (void) argc; int32_t ret = ERROR_SUCCESS; cfc_show_status_info_t cfc_flux_info; struct thread thread; master = thread_master_create (); cmd_init (1); vty_init (); cfc_vty_init (); daemon (0,1); vty_set_vrf_info(); vty_serv_sock (0, 0, CFC_VTYSH_PATH); if(ERR_FILE_OPEN == cfc_get_config(&cfc_flux_info)) { ret = ERR_FILE_OPEN; goto label_ret; } if(CFC_MODULE_ACTIVE == cfc_flux_info.module_stat) { cfc_cf_set_tot_flux(cfc_flux_info.tot_flux); } if(ERR_FILE_OPEN == cfc_get_limit_config()) { ret = ERR_FILE_OPEN; } cfc_cf_set_privatenet(); while(thread_fetch (master, &thread)) { thread_call (&thread); } label_ret: return ret; }
int main (void) { master = thread_master_create (); signal_init (master, array_size(sigs), sigs); zlog_default = openzlog("testsig", ZLOG_NONE, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED); zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG); zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); while (thread_fetch (master, &t)) thread_call (&t); exit (0); }
int main(void) { int ret=0; struct thread thread; int sock; pthread_t packet_thread_id; rte_backtrace_init(); if(!access(SHOW_PACKET_FLILE, F_OK)){ // file exist, will show packet vsecplat_show_packet = 1; } if(!access(SHOW_RECORD_FLILE, F_OK)){ // file exist, will show packet vsecplat_show_record = 1; } ret = nm_log_init(); if(ret<0){ printf("failed to init log.\n"); return -1; } ret = init_disp_type(); if(ret<0){ printf("failed to init disp type array.\n"); return -1; } // parse configfile and init global descriptor: global_vsecplat_config ret = parse_vsecplat_config(); if(ret<0){ printf("Failed to parse vsecplat config.\n"); return -1; } ret = init_recurs_dst_mac_list(); if(ret<0){ printf("Failed to init recursive dstmac list.\n"); return -1; } // Init forward policy desc: fw_policy_list ret = init_policy_list(); if(ret<0){ printf("Failed to init policy descriptor.\n"); return -1; } // init global interface list: vsecplat_interface_list ret = init_vsecplat_interface_list(); if(ret<0){ printf("Failed to get interface.\n"); return -1; } #if 1 // Disable to test function on host // setup mgt interface ip address and set it to up ret = setup_mgt_interface(); if(ret<0){ printf("Failed to setup mgt interface.\n"); return -1; } #endif // set dataplane interface to netmap mode ret = setup_dp_interfaces(); if(ret<0){ printf("Failed to setup dataplane interface.\n"); return -1; } // init connection descriptor: conn_desc ret = init_conn_desc(); if(ret<0){ printf("Failed to init vsecplat status.\n"); return -1; } // init record bucket: record_bucket_hash ret = vsecplat_init_record_bucket(); if(ret<0){ printf("Failed to init record bucket.\n"); return -1; } ret = vsecplat_load_duplicate_rule(); if(ret<0){ printf("Failed to load duplicate rules.\n"); return -1; } ret = vsecplat_load_policy(); if(ret<0){ printf("Failed to load policy.\n"); return -1; } #if 0// For test test_packet_match_policy(); vsecplat_test_record(); packet_handle_thread(NULL); #endif #if 1 /* 创建处理数据包的线程 */ ret = pthread_create(&packet_thread_id, NULL, &packet_handle_thread, NULL); if(ret<0){ nm_log("failed to create packet thread.\n"); return -1; } #endif #if 1 // manage thread master = thread_master_create(); if(NULL==master){ nm_log("failed to alloc master.\n"); return -1; } /* 报告统计数据的线程 */ nm_log("Add report stats thread.\n"); thread_add_timer(master, vsecplat_report_stats, NULL, global_vsecplat_config->time_interval); sock = create_listen_socket(); if(sock<0){ nm_log("failed to create socket.\n"); return -1; } thread_add_read(master, vsecplat_listen_func, NULL, sock); memset(&thread, 0, sizeof(struct thread)); while(thread_fetch(master, &thread)){ thread_call(&thread); } #endif return 0; }
/* Main startup routine. */ int main (int argc, char **argv) { char *p; char *vty_addr = NULL; int vty_port = ZEBRA_VTY_PORT; int dryrun = 0; int batch_mode = 0; int daemon_mode = 0; char *config_file = NULL; char *progname; struct thread thread; char *zserv_path = NULL; /* Set umask before anything for security */ umask (0027); /* preserve my name */ progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); zlog_default = openzlog (progname, ZLOG_ZEBRA, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); while (1) { int opt; #ifdef HAVE_NETLINK opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vs:C", longopts, 0); #else opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vC", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) break; switch (opt) { case 0: break; case 'b': batch_mode = 1; case 'd': daemon_mode = 1; break; case 'k': keep_kernel_mode = 1; break; case 'C': dryrun = 1; break; case 'f': config_file = optarg; break; case 'A': vty_addr = optarg; break; case 'i': pid_file = optarg; break; case 'z': zserv_path = optarg; break; case 'P': /* Deal with atoi() returning 0 on failure, and zebra not listening on zebra port... */ if (strcmp(optarg, "0") == 0) { vty_port = 0; break; } vty_port = atoi (optarg); if (vty_port <= 0 || vty_port > 0xffff) vty_port = ZEBRA_VTY_PORT; break; case 'r': retain_mode = 1; break; #ifdef HAVE_NETLINK case 's': nl_rcvbufsize = atoi (optarg); break; #endif /* HAVE_NETLINK */ case 'u': zserv_privs.user = optarg; break; case 'g': zserv_privs.group = optarg; break; case 'v': print_version (progname); exit (0); break; case 'h': usage (progname, 0); break; default: usage (progname, 1); break; } } /* Make master thread emulator. */ zebrad.master = thread_master_create (); /* privs initialise */ zprivs_init (&zserv_privs); /* Vty related initialize. */ signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); cmd_init (1); vty_init (zebrad.master); memory_init (); /* Zebra related initialize. */ zebra_init (); rib_init (); zebra_if_init (); zebra_debug_init (); router_id_init(); zebra_vty_init (); access_list_init (); prefix_list_init (); rtadv_init (); #ifdef HAVE_IRDP irdp_init(); #endif /* For debug purpose. */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ /* Make kernel routing socket. */ kernel_init (); interface_list (); route_read (); /* Sort VTY commands. */ sort_node (); #ifdef HAVE_SNMP zebra_snmp_init (); #endif /* HAVE_SNMP */ /* Process the configuration file. Among other configuration * directives we can meet those installing static routes. Such * requests will not be executed immediately, but queued in * zebra->ribq structure until we enter the main execution loop. * The notifications from kernel will show originating PID equal * to that after daemon() completes (if ever called). */ vty_read_config (config_file, config_default); /* Don't start execution if we are in dry-run mode */ if (dryrun) return(0); /* Clean up rib. */ rib_weed_tables (); /* Exit when zebra is working in batch mode. */ if (batch_mode) exit (0); /* Daemonize. */ if (daemon_mode && daemon (0, 0) < 0) { zlog_err("Zebra daemon failed: %s", strerror(errno)); exit (1); } /* Output pid of zebra. */ pid_output (pid_file); /* After we have successfully acquired the pidfile, we can be sure * about being the only copy of zebra process, which is submitting * changes to the FIB. * Clean up zebra-originated routes. The requests will be sent to OS * immediately, so originating PID in notifications from kernel * will be equal to the current getpid(). To know about such routes, * we have to have route_read() called before. */ if (! keep_kernel_mode) rib_sweep_route (); /* Needed for BSD routing socket. */ pid = getpid (); /* This must be done only after locking pidfile (bug #403). */ zebra_zserv_socket_init (zserv_path); /* Make vty server socket. */ vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); /* Print banner. */ zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); /* Not reached... */ return 0; }
int main (int argc, char *argv[]) { struct thread thread; args = argv; /* ospfclient should be started with the following arguments: * * (1) host (2) lsa_type (3) opaque_type (4) opaque_id (5) if_addr * (6) area_id * * host: name or IP of host where ospfd is running * lsa_type: 9, 10, or 11 * opaque_type: 0-255 (e.g., experimental applications use > 128) * opaque_id: arbitrary application instance (24 bits) * if_addr: interface IP address (for type 9) otherwise ignored * area_id: area in IP address format (for type 10) otherwise ignored */ if (argc != 7) { usage(); } /* Initialization */ zprivs_init (&ospfd_privs); master = thread_master_create (); /* Open connection to OSPF daemon */ oclient = ospf_apiclient_connect (args[1], ASYNCPORT); if (!oclient) { printf ("Connecting to OSPF daemon on %s failed!\n", args[1]); exit (1); } /* Register callback functions. */ ospf_apiclient_register_callback (oclient, ready_callback, new_if_callback, del_if_callback, ism_change_callback, nsm_change_callback, lsa_update_callback, lsa_delete_callback); /* Register LSA type and opaque type. */ ospf_apiclient_register_opaque_type (oclient, atoi (args[2]), atoi (args[3])); /* Synchronize database with OSPF daemon. */ ospf_apiclient_sync_lsdb (oclient); /* Schedule thread that handles asynchronous messages */ thread_add_read (master, lsa_read, oclient, oclient->fd_async); /* Now connection is established, run loop */ while (1) { thread_fetch (master, &thread); thread_call (&thread); } /* Never reached */ return 0; }
/* Main startup routine. */ int rtm_init (int argc, char **argv) { char *p; char *vty_addr = NULL; int vty_port = ZEBRA_VTY_PORT; int dryrun = 0; int batch_mode = 0; int daemon_mode = 0; char *config_file = NULL; char *progname; struct thread thread; char *zserv_path = NULL; /* Set umask before anything for security */ umask (0027); /* preserve my name */ progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); zlog_default = openzlog (progname, ZLOG_ZEBRA, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); /* Make master thread emulator. */ zebrad.master = thread_master_create (); /* privs initialise */ zprivs_init (&zserv_privs); /* Vty related initialize. */ signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); #if 0 /* * All CLI command registrations commented out */ cmd_init (1); vty_init (zebrad.master); memory_init (); zebra_init (); zebra_if_init (); zebra_vty_init (); /* Sort VTY commands. */ sort_node (); #endif /* Zebra related initialize. */ rib_init (); zebra_debug_init (); router_id_init(); access_list_init (); prefix_list_init (); rtadv_init (); #ifdef HAVE_IRDP irdp_init(); #endif /* For debug purpose. */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ #if 0 /* * The Kernel FIB Interface is no longer needed */ /* Make kernel routing socket. */ kernel_init (); interface_list (); route_read (); #endif #ifdef HAVE_SNMP zebra_snmp_init (); #endif /* HAVE_SNMP */ /* Process the configuration file. Among other configuration * directives we can meet those installing static routes. Such * requests will not be executed immediately, but queued in * zebra->ribq structure until we enter the main execution loop. * The notifications from kernel will show originating PID equal * to that after daemon() completes (if ever called). */ vty_read_config (config_file, config_default); /* Don't start execution if we are in dry-run mode */ if (dryrun) return(0); /* Clean up rib. */ rib_weed_tables (); /* Exit when zebra is working in batch mode. */ if (batch_mode) exit (0); #if 0 /* Daemonize. */ if (daemon_mode && daemon (0, 0) < 0) { zlog_err("Zebra daemon failed: %s", strerror(errno)); exit (1); } /* Output pid of zebra. */ pid_output (pid_file); #endif /* After we have successfully acquired the pidfile, we can be sure * about being the only copy of zebra process, which is submitting * changes to the FIB. * Clean up zebra-originated routes. The requests will be sent to OS * immediately, so originating PID in notifications from kernel * will be equal to the current getpid(). To know about such routes, * we have to have route_read() called before. */ if (! keep_kernel_mode) rib_sweep_route (); #if 0 /* Needed for BSD routing socket. */ pid = getpid (); /* This must be done only after locking pidfile (bug #403). */ zebra_zserv_socket_init (zserv_path); /* Make vty server socket. */ vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); #endif /* Print banner. */ zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); /* Not reached... */ return 0; }
int main(int argc, char *argv[]) { int opt; char * config_file = "/etc/zebralite/ospf6_sibling.conf"; char * sisis_addr; struct in6_addr * sibling_addr; struct list * replicas; struct vconn * vconn; int retval; struct rfpbuf * buffer; struct thread thread; struct in6_addr * ctrl_addr; int sisis_fd; uint64_t host_num = 1; bool restart_mode = false; struct sigaction sa; /* Command line argument treatment. */ while(1) { opt = getopt_long(argc, argv, "rf:", longopts, 0); if(opt == EOF) break; switch(opt) { case 'f': config_file = optarg; break; case 'r': restart_mode = true; break; } } zlog_default = openzlog(argv[0], ZLOG_OSPF6_SIBLING, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); cmd_init(1); vty_init(master); ospf6_sibling_debug_init(); // signal_init - use sigaction sa.sa_handler = terminate; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGABRT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); /* thread master */ master = thread_master_create(); /* initialize ospf6 */ ospf6_top_init(restart_mode); ospf6_area_init(); sisis_addr = calloc(INET6_ADDRSTRLEN, sizeof(char)); if((sisis_fd = sisis_init(sisis_addr, host_num, SISIS_PTYPE_OSPF6_SBLING) < 0)) { printf("sisis_init error\n"); exit(1); } sibling_addr = calloc(1, sizeof(struct in6_addr)); inet_pton(AF_INET6, sisis_addr, sibling_addr); replicas = get_ospf6_sibling_addrs(); ospf6_replicas_init(sibling_addr, replicas); // init ctrl clients and restart msg queue sibling_ctrl_init(); // this is where the command actually gets executed vty_read_config(config_file, config_default); if(restart_mode) { zlog_notice("<---- OSPF6 Sibling starting in restart mode: %d ---->", getpid()); } else { zlog_notice("<---- OSPF6 Sibling starting in normal mode: %d ---->", getpid()); } zlog_debug("sibling sisis addr: %s", sisis_addr); free(sisis_addr); unsigned int num_of_controllers = number_of_sisis_addrs_for_process_type(SISIS_PTYPE_CTRL); if(IS_OSPF6_SIBLING_DEBUG_SISIS) { zlog_debug("num of controllers: %d", num_of_controllers); } sibling_ctrl_set_addresses(sibling_addr); // Monitor rib changes in the case that we need to restart it struct subscribe_to_rib_changes_info info; info.rib_add_ipv4_route = rib_monitor_add_ipv4_route; info.rib_remove_ipv4_route = rib_monitor_remove_ipv4_route; info.rib_add_ipv6_route = rib_monitor_add_ipv6_route; info.rib_remove_ipv6_route = rib_monitor_remove_ipv6_route; subscribe_to_rib_changes(&info); /* Start finite state machine, here we go! */ while(thread_fetch(master, &thread)) thread_call(&thread); }
int main(int argc, char **argv) { int i, j; struct thread t; struct timeval **alarms; master = thread_master_create(); log_buf_len = SCHEDULE_TIMERS * (TIMESTR_LEN + 1) + 1; log_buf_pos = 0; log_buf = XMALLOC(MTYPE_TMP, log_buf_len); expected_buf_len = SCHEDULE_TIMERS * (TIMESTR_LEN + 1) + 1; expected_buf_pos = 0; expected_buf = XMALLOC(MTYPE_TMP, expected_buf_len); prng = prng_new(0); timers = XMALLOC(MTYPE_TMP, SCHEDULE_TIMERS * sizeof(*timers)); for (i = 0; i < SCHEDULE_TIMERS; i++) { long interval_msec; int ret; char *arg; /* Schedule timers to expire in 0..5 seconds */ interval_msec = prng_rand(prng) % 5000; arg = XMALLOC(MTYPE_TMP, TIMESTR_LEN + 1); timers[i] = thread_add_timer_msec(master, timer_func, arg, interval_msec); ret = snprintf(arg, TIMESTR_LEN + 1, "%ld.%06ld", timers[i]->u.sands.tv_sec, timers[i]->u.sands.tv_usec); assert(ret > 0); assert((size_t)ret < TIMESTR_LEN + 1); timers_pending++; } for (i = 0; i < REMOVE_TIMERS; i++) { int index; index = prng_rand(prng) % SCHEDULE_TIMERS; if (!timers[index]) continue; XFREE(MTYPE_TMP, timers[index]->arg); thread_cancel(timers[index]); timers[index] = NULL; timers_pending--; } /* We create an array of pointers to the alarm times and sort * that array. That sorted array is used to generate a string * representing the expected "output" of the timers when they * are run. */ j = 0; alarms = XMALLOC(MTYPE_TMP, timers_pending * sizeof(*alarms)); for (i = 0; i < SCHEDULE_TIMERS; i++) { if (!timers[i]) continue; alarms[j++] = &timers[i]->u.sands; } qsort(alarms, j, sizeof(*alarms), cmp_timeval); for (i = 0; i < j; i++) { int ret; ret = snprintf(expected_buf + expected_buf_pos, expected_buf_len - expected_buf_pos, "%ld.%06ld\n", alarms[i]->tv_sec, alarms[i]->tv_usec); assert(ret > 0); expected_buf_pos += ret; assert(expected_buf_pos < expected_buf_len); } XFREE(MTYPE_TMP, alarms); while (thread_fetch(master, &t)) thread_call(&t); return 0; }
/* Main startup routine. */ int main (int argc, char **argv) { char *p; char *vty_addr = NULL; int vty_port = ZEBRA_VTY_PORT; int batch_mode = 0; int daemon_mode = 0; char *config_file = NULL; char *progname; struct thread thread; void rib_weed_tables (); void zebra_vty_init (); /* Set umask before anything for security */ umask (0027); /* preserve my name */ progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); zlog_default = openzlog (progname, ZLOG_ZEBRA, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); while (1) { int opt; #ifdef HAVE_NETLINK opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:", longopts, 0); #else opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:v", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) break; switch (opt) { case 0: break; case 'b': batch_mode = 1; case 'd': daemon_mode = 1; break; case 'k': keep_kernel_mode = 1; break; case 'l': /* log_mode = 1; */ break; case 'f': config_file = optarg; break; case 'A': vty_addr = optarg; break; case 'i': pid_file = optarg; break; case 'P': /* Deal with atoi() returning 0 on failure, and zebra not listening on zebra port... */ if (strcmp(optarg, "0") == 0) { vty_port = 0; break; } vty_port = atoi (optarg); vty_port = (vty_port ? vty_port : ZEBRA_VTY_PORT); break; case 'r': retain_mode = 1; break; #ifdef HAVE_NETLINK case 's': nl_rcvbufsize = atoi (optarg); break; #endif /* HAVE_NETLINK */ case 'u': zserv_privs.user = optarg; break; case 'g': zserv_privs.group = optarg; break; case 'v': print_version (progname); exit (0); break; case 'h': usage (progname, 0); break; default: usage (progname, 1); break; } } /* Make master thread emulator. */ zebrad.master = thread_master_create (); /* privs initialise */ zprivs_init (&zserv_privs); /* Vty related initialize. */ signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); cmd_init (1); vty_init (zebrad.master); memory_init (); /* Zebra related initialize. */ zebra_init (); rib_init (); zebra_if_init (); zebra_debug_init (); router_id_init(); zebra_vty_init (); access_list_init (); rtadv_init (); #ifdef HAVE_IRDP irdp_init(); #endif /* For debug purpose. */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ /* Make kernel routing socket. */ kernel_init (); interface_list (); route_read (); /* Sort VTY commands. */ sort_node (); #ifdef HAVE_SNMP zebra_snmp_init (); #endif /* HAVE_SNMP */ /* Clean up self inserted route. */ if (! keep_kernel_mode) rib_sweep_route (); /* Configuration file read*/ vty_read_config (config_file, config_default); /* Clean up rib. */ rib_weed_tables (); /* Exit when zebra is working in batch mode. */ if (batch_mode) exit (0); /* Needed for BSD routing socket. */ old_pid = getpid (); /* Daemonize. */ if (daemon_mode) daemon (0, 0); /* Output pid of zebra. */ pid_output (pid_file); /* Needed for BSD routing socket. */ pid = getpid (); /* Make vty server socket. */ vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); /* Print banner. */ zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); /* Not reached... */ exit (0); }