diff options
Diffstat (limited to 'pimd')
| -rw-r--r-- | pimd/pim_main.c | 151 | ||||
| -rw-r--r-- | pimd/pim_signals.c | 10 | ||||
| -rw-r--r-- | pimd/pim_signals.h | 3 | ||||
| -rw-r--r-- | pimd/pim_zebra.c | 5 | ||||
| -rw-r--r-- | pimd/pim_zebra.h | 2 | ||||
| -rw-r--r-- | pimd/pimd.c | 2 |
6 files changed, 25 insertions, 148 deletions
diff --git a/pimd/pim_main.c b/pimd/pim_main.c index 2e81ac53fd..ba1c511d16 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -38,7 +38,7 @@ #include "prefix.h" #include "plist.h" #include "vrf.h" -#include "sockopt.h" +#include "libfrr.h" #include "pimd.h" #include "pim_version.h" @@ -50,27 +50,10 @@ extern struct host host; -char config_default[] = SYSCONFDIR PIMD_DEFAULT_CONFIG; - -/* pimd options */ -#define OPTION_VTYSOCK 1000 struct option longopts[] = { - { "daemon", no_argument, NULL, 'd'}, - { "config_file", required_argument, NULL, 'f'}, - { "pid_file", required_argument, NULL, 'i'}, - { "socket", required_argument, NULL, 'z'}, - { "vty_addr", required_argument, NULL, 'A'}, - { "vty_port", required_argument, NULL, 'P'}, - { "vty_socket", required_argument, NULL, OPTION_VTYSOCK}, - { "version", no_argument, NULL, 'v'}, - { "debug_zclient", no_argument, NULL, 'Z'}, - { "help", no_argument, NULL, 'h'}, { 0 } }; -/* VTY Socket prefix */ -char vty_sock_path[MAXPATHLEN] = PIM_VTYSH_PATH; - /* pimd privileges */ zebra_capabilities_t _caps_p [] = { @@ -95,101 +78,40 @@ struct zebra_privs_t pimd_privs = .cap_num_i = 0 }; -char* progname; -const char *pid_file = PATH_PIMD_PID; +FRR_DAEMON_INFO(pimd, PIM, + .vty_port = PIMD_VTY_PORT, -static void usage(int status) -{ - if (status != 0) - fprintf (stderr, "Try `%s --help' for more information.\n", progname); - else { - printf ("Usage : %s [OPTION...]\n\ -Daemon which manages PIM.\n\n\ --d, --daemon Run in daemon mode\n\ --f, --config_file Set configuration file name\n\ --i, --pid_file Set process identifier file name\n\ --z, --socket Set path of zebra socket\n\ --A, --vty_addr Set vty's bind address\n\ --P, --vty_port Set vty's port number\n\ - --vty_socket Override vty socket path\n\ --v, --version Print program version\n\ --h, --help Display this help and exit\n\ -\n\ -Report bugs to %s\n", progname, PACKAGE_BUGREPORT); - } + .proghelp = "Implementation of the PIM routing protocol.", - exit (status); -} + .signals = pimd_signals, + .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/, + .privs = &pimd_privs, +) int main(int argc, char** argv, char** envp) { - char *p; - char *vty_addr = NULL; - int vty_port = -1; - int daemon_mode = 0; - char *config_file = NULL; - char *zebra_sock_path = NULL; - struct thread thread; - - umask(0027); - - progname = ((p = strrchr(argv[0], '/')) ? ++p : argv[0]); - - zlog_default = openzlog(progname, ZLOG_PIM, 0, - LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); - zprivs_init (&pimd_privs); -#if defined(HAVE_CUMULUS) - zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl); -#endif + frr_preinit(&pimd_di, argc, argv); + frr_opt_add("", longopts, ""); - /* this while just reads the options */ + /* this while just reads the options */ while (1) { int opt; - - opt = getopt_long (argc, argv, "df:i:z:A:P:vZh", longopts, 0); - + + opt = frr_getopt(argc, argv, NULL); + if (opt == EOF) break; switch (opt) { case 0: break; - case 'd': - daemon_mode = 1; - break; - case 'f': - config_file = optarg; - break; - case 'i': - pid_file = optarg; - break; - case 'z': - zebra_sock_path = optarg; - break; - case 'A': - vty_addr = optarg; - break; - case 'P': - vty_port = atoi (optarg); - break; - case OPTION_VTYSOCK: - set_socket_path(vty_sock_path, PIM_VTYSH_PATH, optarg, sizeof (vty_sock_path)); - break; - case 'v': - printf(PIMD_PROGNAME " version %s\n", PIMD_VERSION); - print_version(progname); - exit (0); - break; - case 'h': - usage (0); - break; default: - usage (1); + frr_help_exit (1); break; } } - master = thread_master_create(); + master = frr_init(); zlog_notice("Quagga %s " PIMD_PROGNAME " %s starting", FRR_VERSION, PIMD_VERSION); @@ -197,10 +119,6 @@ int main(int argc, char** argv, char** envp) { /* * Initializations */ - pim_signals_init(); - cmd_init(1); - vty_init(master); - memory_init(); vrf_init (); access_list_init(); prefix_list_init (); @@ -214,36 +132,9 @@ int main(int argc, char** argv, char** envp) { /* * Initialize zclient "update" and "lookup" sockets */ - pim_zebra_init(zebra_sock_path); - - zlog_notice("Loading configuration - begin"); - - /* Get configuration file. */ - vty_read_config(config_file, config_default); - - /* - Starting from here zlog_* functions will log according configuration - */ + pim_zebra_init(); - zlog_notice("Loading configuration - end"); - - /* Change to the daemon program. */ - if (daemon_mode) { - if (daemon(0, 0)) { - zlog_warn("failed to daemonize"); - } - } - - /* Process ID file creation. */ - pid_output(pid_file); - - /* Create pimd VTY socket */ - if (vty_port < 0) - vty_port = PIMD_VTY_PORT; - vty_serv_sock(vty_addr, vty_port, vty_sock_path); - - zlog_notice("Quagga %s " PIMD_PROGNAME " %s starting, VTY interface at port TCP %d", - FRR_VERSION, PIMD_VERSION, vty_port); + frr_config_fork(); #ifdef PIM_DEBUG_BYDEFAULT zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands"); @@ -267,11 +158,7 @@ int main(int argc, char** argv, char** envp) { zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall"); #endif - while (thread_fetch(master, &thread)) - thread_call(&thread); - - zlog_err("%s %s: thread_fetch() returned NULL, exiting", - __FILE__, __PRETTY_FUNCTION__); + frr_run(master); /* never reached */ return 0; diff --git a/pimd/pim_signals.c b/pimd/pim_signals.c index bd4d9e4857..053ef6a67b 100644 --- a/pimd/pim_signals.c +++ b/pimd/pim_signals.c @@ -55,10 +55,10 @@ static void pim_sigterm() static void pim_sigusr1() { - zlog_rotate (NULL); + zlog_rotate(); } -static struct quagga_signal_t pimd_signals[] = +struct quagga_signal_t pimd_signals[] = { { .signal = SIGHUP, @@ -77,9 +77,3 @@ static struct quagga_signal_t pimd_signals[] = .handler = &pim_sigterm, }, }; - -void pim_signals_init() -{ - signal_init(master, array_size(pimd_signals), pimd_signals); -} - diff --git a/pimd/pim_signals.h b/pimd/pim_signals.h index 7b25608c10..d7a4926d4d 100644 --- a/pimd/pim_signals.h +++ b/pimd/pim_signals.h @@ -21,6 +21,7 @@ #ifndef PIM_SIGNALS_H #define PIM_SIGNALS_H -void pim_signals_init(void); +#include "sigevent.h" +extern struct quagga_signal_t pimd_signals[]; #endif /* PIM_SIGNALS_H */ diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 70b0302806..1db6616c58 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -721,13 +721,10 @@ pim_zebra_connected (struct zclient *zclient) zclient_send_reg_requests (zclient, VRF_DEFAULT); } -void pim_zebra_init(char *zebra_sock_path) +void pim_zebra_init(void) { int i; - if (zebra_sock_path) - zclient_serv_path_set(zebra_sock_path); - #ifdef HAVE_TCP_ZEBRA zlog_notice("zclient update contacting ZEBRA daemon at socket TCP %s,%d", "127.0.0.1", ZEBRA_PORT); #else diff --git a/pimd/pim_zebra.h b/pimd/pim_zebra.h index 476185def1..751a7be25d 100644 --- a/pimd/pim_zebra.h +++ b/pimd/pim_zebra.h @@ -24,7 +24,7 @@ #include "pim_igmp.h" #include "pim_ifchannel.h" -void pim_zebra_init(char *zebra_sock_path); +void pim_zebra_init(void); void pim_zebra_zclient_update (struct vty *vty); void pim_scan_individual_oil (struct channel_oil *c_oil); diff --git a/pimd/pimd.c b/pimd/pimd.c index aa863fd47f..c8a0efc401 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -98,8 +98,6 @@ static void pim_free() void pim_init() { - srandom(time(NULL)); - qpim_rp_keep_alive_time = PIM_RP_KEEPALIVE_PERIOD; pim_rp_init (); |
