jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_main.c |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 23 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | |
| 25 | #include "getopt.h" |
| 26 | #include "thread.h" |
| 27 | #include "log.h" |
gdt | 5e4fa16 | 2004-03-16 14:38:36 +0000 | [diff] [blame] | 28 | #include <lib/version.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 29 | #include "command.h" |
| 30 | #include "vty.h" |
| 31 | #include "memory.h" |
| 32 | #include "stream.h" |
| 33 | #include "if.h" |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 34 | #include "privs.h" |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 35 | #include "sigevent.h" |
hasso | c729c65 | 2004-10-13 08:36:47 +0000 | [diff] [blame] | 36 | #include "filter.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 37 | |
| 38 | #include "isisd/dict.h" |
| 39 | #include "include-netbsd/iso.h" |
| 40 | #include "isisd/isis_constants.h" |
| 41 | #include "isisd/isis_common.h" |
| 42 | #include "isisd/isis_flags.h" |
| 43 | #include "isisd/isis_circuit.h" |
| 44 | #include "isisd/isisd.h" |
| 45 | #include "isisd/isis_dynhn.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 46 | #include "isisd/isis_spf.h" |
| 47 | #include "isisd/isis_route.h" |
| 48 | #include "isisd/isis_zebra.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 49 | |
| 50 | /* Default configuration file name */ |
| 51 | #define ISISD_DEFAULT_CONFIG "isisd.conf" |
| 52 | /* Default vty port */ |
jardin | fc58e87 | 2003-12-23 10:42:45 +0000 | [diff] [blame] | 53 | #define ISISD_VTY_PORT 2608 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 54 | |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 55 | /* isisd privileges */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 56 | zebra_capabilities_t _caps_p[] = { |
paul | ceacedb | 2005-09-29 14:39:32 +0000 | [diff] [blame] | 57 | ZCAP_NET_RAW, |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 58 | ZCAP_BIND |
| 59 | }; |
| 60 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 61 | struct zebra_privs_t isisd_privs = { |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 62 | #if defined(QUAGGA_USER) |
| 63 | .user = QUAGGA_USER, |
| 64 | #endif |
| 65 | #if defined QUAGGA_GROUP |
| 66 | .group = QUAGGA_GROUP, |
| 67 | #endif |
| 68 | #ifdef VTY_GROUP |
| 69 | .vty_group = VTY_GROUP, |
| 70 | #endif |
| 71 | .caps_p = _caps_p, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 72 | .cap_num_p = sizeof (_caps_p) / sizeof (*_caps_p), |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 73 | .cap_num_i = 0 |
| 74 | }; |
| 75 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 76 | /* isisd options */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 77 | struct option longopts[] = { |
| 78 | {"daemon", no_argument, NULL, 'd'}, |
| 79 | {"config_file", required_argument, NULL, 'f'}, |
| 80 | {"pid_file", required_argument, NULL, 'i'}, |
| 81 | {"vty_addr", required_argument, NULL, 'A'}, |
| 82 | {"vty_port", required_argument, NULL, 'P'}, |
| 83 | {"user", required_argument, NULL, 'u'}, |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 84 | {"group", required_argument, NULL, 'g'}, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 85 | {"version", no_argument, NULL, 'v'}, |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 86 | {"dryrun", no_argument, NULL, 'C'}, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 87 | {"help", no_argument, NULL, 'h'}, |
| 88 | {0} |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | /* Configuration file and directory. */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 92 | char config_default[] = SYSCONFDIR ISISD_DEFAULT_CONFIG; |
| 93 | char *config_file = NULL; |
| 94 | |
| 95 | /* isisd program name. */ |
| 96 | char *progname; |
| 97 | |
| 98 | int daemon_mode = 0; |
| 99 | |
| 100 | /* Master of threads. */ |
| 101 | struct thread_master *master; |
| 102 | |
hasso | c3aac6f | 2004-02-20 18:44:21 +0000 | [diff] [blame] | 103 | /* Process ID saved for use by init system */ |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 104 | const char *pid_file = PATH_ISISD_PID; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 105 | |
| 106 | /* for reload */ |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 107 | char _cwd[MAXPATHLEN]; |
| 108 | char _progpath[MAXPATHLEN]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 109 | int _argc; |
| 110 | char **_argv; |
| 111 | char **_envp; |
| 112 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 113 | /* |
| 114 | * Prototypes. |
| 115 | */ |
| 116 | void reload(void); |
| 117 | void sighup(void); |
| 118 | void sigint(void); |
| 119 | void sigterm(void); |
| 120 | void sigusr1(void); |
| 121 | |
| 122 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 123 | /* Help information display. */ |
| 124 | static void |
| 125 | usage (int status) |
| 126 | { |
| 127 | if (status != 0) |
| 128 | fprintf (stderr, "Try `%s --help' for more information.\n", progname); |
| 129 | else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 130 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 131 | printf ("Usage : %s [OPTION...]\n\n\ |
| 132 | Daemon which manages IS-IS routing\n\n\ |
| 133 | -d, --daemon Runs in daemon mode\n\ |
| 134 | -f, --config_file Set configuration file name\n\ |
hasso | c3aac6f | 2004-02-20 18:44:21 +0000 | [diff] [blame] | 135 | -i, --pid_file Set process identifier file name\n\ |
| 136 | -A, --vty_addr Set vty's bind address\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 137 | -P, --vty_port Set vty's port number\n\ |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 138 | -u, --user User to run as\n\ |
| 139 | -g, --group Group to run as\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 140 | -v, --version Print program version\n\ |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 141 | -C, --dryrun Check configuration for validity and exit\n\ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 142 | -h, --help Display this help and exit\n\ |
| 143 | \n\ |
hasso | aa0b9f9 | 2004-09-28 15:05:56 +0000 | [diff] [blame] | 144 | Report bugs to http://bugzilla.quagga.net\n", progname); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | exit (status); |
| 148 | } |
| 149 | |
| 150 | |
| 151 | void |
| 152 | reload () |
| 153 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 154 | zlog_debug ("Reload"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 155 | /* FIXME: Clean up func call here */ |
ajs | cdb6ee9 | 2005-02-23 15:48:32 +0000 | [diff] [blame] | 156 | vty_reset (); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 157 | (void) isisd_privs.change (ZPRIVS_RAISE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 158 | execve (_progpath, _argv, _envp); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 159 | zlog_err ("Reload failed: cannot exec %s: %s", _progpath, |
| 160 | safe_strerror (errno)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 161 | } |
| 162 | |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 163 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 164 | terminate (int i) |
| 165 | { |
| 166 | exit (i); |
| 167 | } |
| 168 | |
| 169 | /* |
| 170 | * Signal handlers |
| 171 | */ |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 172 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 173 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 174 | sighup (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 175 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 176 | zlog_debug ("SIGHUP received"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 177 | reload (); |
| 178 | |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 183 | sigint (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 184 | { |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 185 | zlog_notice ("Terminating on signal SIGINT"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 186 | terminate (0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 190 | sigterm (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 191 | { |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 192 | zlog_notice ("Terminating on signal SIGTERM"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 193 | terminate (0); |
| 194 | } |
| 195 | |
| 196 | void |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 197 | sigusr1 (void) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 198 | { |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 199 | zlog_debug ("SIGUSR1 received"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 200 | zlog_rotate (NULL); |
| 201 | } |
| 202 | |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 203 | struct quagga_signal_t isisd_signals[] = |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 204 | { |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 205 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 206 | .signal = SIGHUP, |
| 207 | .handler = &sighup, |
| 208 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 209 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 210 | .signal = SIGUSR1, |
| 211 | .handler = &sigusr1, |
| 212 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 213 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 214 | .signal = SIGINT, |
| 215 | .handler = &sigint, |
| 216 | }, |
| 217 | { |
| 218 | .signal = SIGTERM, |
| 219 | .handler = &sigterm, |
| 220 | }, |
paul | 2d75d05 | 2004-01-19 21:31:15 +0000 | [diff] [blame] | 221 | }; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 222 | |
| 223 | /* |
| 224 | * Main routine of isisd. Parse arguments and handle IS-IS state machine. |
| 225 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 226 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 227 | main (int argc, char **argv, char **envp) |
| 228 | { |
| 229 | char *p; |
| 230 | int opt, vty_port = ISISD_VTY_PORT; |
| 231 | struct thread thread; |
| 232 | char *config_file = NULL; |
| 233 | char *vty_addr = NULL; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 234 | int dryrun = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 235 | |
| 236 | /* Get the programname without the preceding path. */ |
| 237 | progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); |
| 238 | |
ajs | 274a4a4 | 2004-12-07 15:39:31 +0000 | [diff] [blame] | 239 | zlog_default = openzlog (progname, ZLOG_ISIS, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 240 | LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 241 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 242 | /* for reload */ |
| 243 | _argc = argc; |
| 244 | _argv = argv; |
| 245 | _envp = envp; |
| 246 | getcwd (_cwd, sizeof (_cwd)); |
| 247 | if (*argv[0] == '.') |
| 248 | snprintf (_progpath, sizeof (_progpath), "%s/%s", _cwd, _argv[0]); |
| 249 | else |
| 250 | snprintf (_progpath, sizeof (_progpath), "%s", argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 251 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 252 | /* Command line argument treatment. */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 253 | while (1) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 254 | { |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 255 | opt = getopt_long (argc, argv, "df:i:hA:p:P:u:g:vC", longopts, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 256 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 257 | if (opt == EOF) |
| 258 | break; |
| 259 | |
| 260 | switch (opt) |
| 261 | { |
| 262 | case 0: |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 263 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 264 | case 'd': |
| 265 | daemon_mode = 1; |
| 266 | break; |
| 267 | case 'f': |
| 268 | config_file = optarg; |
| 269 | break; |
| 270 | case 'i': |
| 271 | pid_file = optarg; |
| 272 | break; |
| 273 | case 'A': |
| 274 | vty_addr = optarg; |
| 275 | break; |
| 276 | case 'P': |
| 277 | /* Deal with atoi() returning 0 on failure, and isisd not |
| 278 | listening on isisd port... */ |
| 279 | if (strcmp (optarg, "0") == 0) |
| 280 | { |
| 281 | vty_port = 0; |
| 282 | break; |
| 283 | } |
| 284 | vty_port = atoi (optarg); |
| 285 | vty_port = (vty_port ? vty_port : ISISD_VTY_PORT); |
| 286 | break; |
| 287 | case 'u': |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 288 | isisd_privs.user = optarg; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 289 | break; |
hasso | c065230 | 2004-11-25 19:33:48 +0000 | [diff] [blame] | 290 | case 'g': |
| 291 | isisd_privs.group = optarg; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 292 | break; |
| 293 | case 'v': |
| 294 | printf ("ISISd version %s\n", ISISD_VERSION); |
| 295 | printf ("Copyright (c) 2001-2002 Sampo Saaristo," |
| 296 | " Ofer Wald and Hannes Gredler\n"); |
| 297 | print_version ("Zebra"); |
| 298 | exit (0); |
| 299 | break; |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 300 | case 'C': |
| 301 | dryrun = 1; |
| 302 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 303 | case 'h': |
| 304 | usage (0); |
| 305 | break; |
| 306 | default: |
| 307 | usage (1); |
| 308 | break; |
| 309 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 310 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 311 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 312 | /* thread master */ |
| 313 | master = thread_master_create (); |
| 314 | |
| 315 | /* random seed from time */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 316 | srand (time (NULL)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 317 | |
| 318 | /* |
| 319 | * initializations |
| 320 | */ |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 321 | zprivs_init (&isisd_privs); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 322 | signal_init (master, Q_SIGC (isisd_signals), isisd_signals); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 323 | cmd_init (1); |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 324 | vty_init (master); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 325 | memory_init (); |
hasso | c729c65 | 2004-10-13 08:36:47 +0000 | [diff] [blame] | 326 | access_list_init(); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 327 | isis_init (); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 328 | isis_circuit_init (); |
| 329 | isis_spf_cmds_init (); |
| 330 | |
| 331 | /* create the global 'isis' instance */ |
| 332 | isis_new (1); |
| 333 | |
| 334 | isis_zebra_init (); |
| 335 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 336 | sort_node (); |
| 337 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 338 | /* parse config file */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 339 | /* this is needed three times! because we have interfaces before the areas */ |
hasso | 320ec10 | 2004-06-20 19:54:37 +0000 | [diff] [blame] | 340 | vty_read_config (config_file, config_default); |
hasso | 00995cf | 2004-05-19 13:43:50 +0000 | [diff] [blame] | 341 | |
Paul Jakma | 876b8be | 2006-10-15 23:35:57 +0000 | [diff] [blame] | 342 | /* Start execution only if not in dry-run mode */ |
| 343 | if (dryrun) |
| 344 | return(0); |
| 345 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 346 | /* demonize */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 347 | if (daemon_mode) |
| 348 | daemon (0, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 349 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 350 | /* Process ID file creation. */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame^] | 351 | if (pid_file[0] != '\0') |
| 352 | pid_output (pid_file); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 353 | |
| 354 | /* Make isis vty socket. */ |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 355 | vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 356 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 357 | /* Print banner. */ |
ajs | 887c44a | 2004-12-03 16:36:46 +0000 | [diff] [blame] | 358 | zlog_notice ("Quagga-ISISd %s starting: vty@%d", QUAGGA_VERSION, vty_port); |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 359 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 360 | /* Start finite state machine. */ |
| 361 | while (thread_fetch (master, &thread)) |
| 362 | thread_call (&thread); |
| 363 | |
| 364 | /* Not reached. */ |
| 365 | exit (0); |
| 366 | } |