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