| File: | src/usr.sbin/ospfd/obj/parse.c |
| Warning: | line 1222, column 13 Attempt to free released memory |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | #include <stdlib.h> | |||
| 2 | #include <string.h> | |||
| 3 | #define YYBYACC1 1 | |||
| 4 | #define YYMAJOR1 1 | |||
| 5 | #define YYMINOR9 9 | |||
| 6 | #define YYLEXyylex() yylex() | |||
| 7 | #define YYEMPTY-1 -1 | |||
| 8 | #define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1)) | |||
| 9 | #define yyerrok(yyerrflag=0) (yyerrflag=0) | |||
| 10 | #define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0) | |||
| 11 | #define YYPREFIX"yy" "yy" | |||
| 12 | #line 25 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 13 | #include <sys/types.h> | |||
| 14 | #include <sys/socket.h> | |||
| 15 | #include <sys/stat.h> | |||
| 16 | #include <net/route.h> | |||
| 17 | #include <netinet/in.h> | |||
| 18 | #include <arpa/inet.h> | |||
| 19 | #include <ctype.h> | |||
| 20 | #include <err.h> | |||
| 21 | #include <errno(*__errno()).h> | |||
| 22 | #include <unistd.h> | |||
| 23 | #include <ifaddrs.h> | |||
| 24 | #include <limits.h> | |||
| 25 | #include <stdarg.h> | |||
| 26 | #include <stdio.h> | |||
| 27 | #include <string.h> | |||
| 28 | #include <syslog.h> | |||
| 29 | ||||
| 30 | #include "ospf.h" | |||
| 31 | #include "ospfd.h" | |||
| 32 | #include "ospfe.h" | |||
| 33 | #include "log.h" | |||
| 34 | ||||
| 35 | TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last ; } files = TAILQ_HEAD_INITIALIZER(files){ ((void*)0), &(files).tqh_first }; | |||
| 36 | static struct file { | |||
| 37 | TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry; | |||
| 38 | FILE *stream; | |||
| 39 | char *name; | |||
| 40 | size_t ungetpos; | |||
| 41 | size_t ungetsize; | |||
| 42 | u_char *ungetbuf; | |||
| 43 | int eof_reached; | |||
| 44 | int lineno; | |||
| 45 | int errors; | |||
| 46 | } *file, *topfile; | |||
| 47 | struct file *pushfile(const char *, int); | |||
| 48 | int popfile(void); | |||
| 49 | int check_file_secrecy(int, const char *); | |||
| 50 | int yyparse(void); | |||
| 51 | int yylex(void); | |||
| 52 | int yyerror(const char *, ...) | |||
| 53 | __attribute__((__format__ (printf, 1, 2))) | |||
| 54 | __attribute__((__nonnull__ (1))); | |||
| 55 | int kw_cmp(const void *, const void *); | |||
| 56 | int lookup(char *); | |||
| 57 | int igetc(void); | |||
| 58 | int lgetc(int); | |||
| 59 | void lungetc(int); | |||
| 60 | int findeol(void); | |||
| 61 | ||||
| 62 | TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last ; } symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void*)0), &(symhead).tqh_first }; | |||
| 63 | struct sym { | |||
| 64 | TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry; | |||
| 65 | int used; | |||
| 66 | int persist; | |||
| 67 | char *nam; | |||
| 68 | char *val; | |||
| 69 | }; | |||
| 70 | int symset(const char *, const char *, int); | |||
| 71 | char *symget(const char *); | |||
| 72 | ||||
| 73 | void clear_config(struct ospfd_conf *xconf); | |||
| 74 | int host(const char *, struct in_addr *, struct in_addr *); | |||
| 75 | ||||
| 76 | static struct ospfd_conf *conf; | |||
| 77 | static int errors = 0; | |||
| 78 | ||||
| 79 | struct area *area = NULL((void*)0); | |||
| 80 | struct iface *iface = NULL((void*)0); | |||
| 81 | ||||
| 82 | struct config_defaults { | |||
| 83 | char auth_key[MAX_SIMPLE_AUTH_LEN8]; | |||
| 84 | struct auth_md_head md_list; | |||
| 85 | u_int32_t dead_interval; | |||
| 86 | u_int32_t fast_hello_interval; | |||
| 87 | u_int16_t transmit_delay; | |||
| 88 | u_int16_t hello_interval; | |||
| 89 | u_int16_t rxmt_interval; | |||
| 90 | u_int16_t metric; | |||
| 91 | enum auth_type auth_type; | |||
| 92 | u_int8_t auth_keyid; | |||
| 93 | u_int8_t priority; | |||
| 94 | u_int8_t p2p; | |||
| 95 | }; | |||
| 96 | ||||
| 97 | struct config_defaults globaldefs; | |||
| 98 | struct config_defaults areadefs; | |||
| 99 | struct config_defaults ifacedefs; | |||
| 100 | struct config_defaults *defs; | |||
| 101 | ||||
| 102 | struct area *conf_get_area(struct in_addr); | |||
| 103 | struct iface *conf_get_if(struct kif *, struct kif_addr *); | |||
| 104 | int conf_check_rdomain(unsigned int); | |||
| 105 | ||||
| 106 | typedef struct { | |||
| 107 | union { | |||
| 108 | int64_t number; | |||
| 109 | char *string; | |||
| 110 | struct redistribute *redist; | |||
| 111 | struct in_addr id; | |||
| 112 | } v; | |||
| 113 | int lineno; | |||
| 114 | } YYSTYPE; | |||
| 115 | ||||
| 116 | #line 117 "parse.c" | |||
| 117 | #define AREA257 257 | |||
| 118 | #define INTERFACE258 258 | |||
| 119 | #define ROUTERID259 259 | |||
| 120 | #define FIBPRIORITY260 260 | |||
| 121 | #define FIBUPDATE261 261 | |||
| 122 | #define REDISTRIBUTE262 262 | |||
| 123 | #define RTLABEL263 263 | |||
| 124 | #define RDOMAIN264 264 | |||
| 125 | #define RFC1583COMPAT265 265 | |||
| 126 | #define STUB266 266 | |||
| 127 | #define ROUTER267 267 | |||
| 128 | #define SPFDELAY268 268 | |||
| 129 | #define SPFHOLDTIME269 269 | |||
| 130 | #define EXTTAG270 270 | |||
| 131 | #define AUTHKEY271 271 | |||
| 132 | #define AUTHTYPE272 272 | |||
| 133 | #define AUTHMD273 273 | |||
| 134 | #define AUTHMDKEYID274 274 | |||
| 135 | #define METRIC275 275 | |||
| 136 | #define P2P276 276 | |||
| 137 | #define PASSIVE277 277 | |||
| 138 | #define HELLOINTERVAL278 278 | |||
| 139 | #define FASTHELLOINTERVAL279 279 | |||
| 140 | #define TRANSMITDELAY280 280 | |||
| 141 | #define RETRANSMITINTERVAL281 281 | |||
| 142 | #define ROUTERDEADTIME282 282 | |||
| 143 | #define ROUTERPRIORITY283 283 | |||
| 144 | #define SET284 284 | |||
| 145 | #define TYPE285 285 | |||
| 146 | #define YES286 286 | |||
| 147 | #define NO287 287 | |||
| 148 | #define MSEC288 288 | |||
| 149 | #define MINIMAL289 289 | |||
| 150 | #define DEMOTE290 290 | |||
| 151 | #define INCLUDE291 291 | |||
| 152 | #define ERROR292 292 | |||
| 153 | #define DEPEND293 293 | |||
| 154 | #define ON294 294 | |||
| 155 | #define STRING295 295 | |||
| 156 | #define NUMBER296 296 | |||
| 157 | #define YYERRCODE256 256 | |||
| 158 | const short yylhs[] = | |||
| 159 | { -1, | |||
| 160 | 0, 0, 0, 0, 0, 0, 0, 14, 9, 9, | |||
| 161 | 1, 1, 2, 2, 7, 7, 16, 15, 15, 15, | |||
| 162 | 15, 15, 15, 15, 15, 15, 15, 15, 12, 12, | |||
| 163 | 12, 3, 3, 3, 4, 4, 5, 5, 11, 11, | |||
| 164 | 10, 21, 22, 23, 24, 18, 18, 18, 18, 18, | |||
| 165 | 18, 18, 18, 18, 18, 18, 18, 8, 8, 19, | |||
| 166 | 19, 25, 20, 20, 26, 17, 6, 6, 13, 13, | |||
| 167 | 27, 27, 28, 28, 28, 28, 28, 31, 29, 30, | |||
| 168 | 30, 30, 32, 32, 33, 33, 33, 33, | |||
| 169 | }; | |||
| 170 | const short yylen[] = | |||
| 171 | { 2, | |||
| 172 | 0, 3, 2, 3, 3, 3, 3, 2, 2, 1, | |||
| 173 | 1, 1, 0, 1, 2, 1, 3, 2, 2, 2, | |||
| 174 | 1, 4, 2, 2, 2, 2, 3, 1, 7, 5, | |||
| 175 | 6, 0, 2, 7, 3, 1, 2, 2, 0, 1, | |||
| 176 | 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, | |||
| 177 | 3, 2, 2, 1, 1, 1, 1, 1, 1, 2, | |||
| 178 | 0, 2, 1, 0, 0, 8, 1, 0, 1, 1, | |||
| 179 | 3, 1, 1, 3, 1, 1, 2, 0, 4, 5, | |||
| 180 | 3, 0, 3, 1, 1, 2, 1, 1, | |||
| 181 | }; | |||
| 182 | const short yydefred[] = | |||
| 183 | { 1, | |||
| 184 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 185 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 186 | 0, 0, 0, 0, 14, 0, 0, 3, 0, 21, | |||
| 187 | 0, 0, 0, 0, 28, 57, 56, 54, 55, 7, | |||
| 188 | 70, 69, 65, 18, 19, 11, 12, 20, 0, 23, | |||
| 189 | 24, 0, 0, 16, 25, 26, 45, 44, 0, 43, | |||
| 190 | 46, 50, 0, 49, 52, 59, 58, 48, 47, 53, | |||
| 191 | 8, 0, 0, 2, 4, 5, 6, 0, 0, 27, | |||
| 192 | 15, 42, 51, 10, 0, 0, 0, 0, 0, 22, | |||
| 193 | 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 194 | 33, 0, 0, 40, 30, 0, 60, 0, 0, 0, | |||
| 195 | 75, 0, 72, 73, 31, 37, 38, 0, 0, 0, | |||
| 196 | 78, 77, 0, 0, 0, 0, 0, 41, 29, 0, | |||
| 197 | 67, 74, 0, 66, 71, 0, 36, 0, 79, 63, | |||
| 198 | 0, 0, 0, 34, 35, 85, 0, 81, 87, 88, | |||
| 199 | 0, 84, 86, 0, 0, 80, 83, | |||
| 200 | }; | |||
| 201 | const short yydgoto[] = | |||
| 202 | { 1, | |||
| 203 | 48, 29, 94, 136, 101, 132, 55, 68, 85, 104, | |||
| 204 | 105, 30, 43, 31, 32, 33, 34, 111, 97, 142, | |||
| 205 | 36, 37, 38, 39, 126, 78, 112, 113, 114, 139, | |||
| 206 | 130, 151, 152, | |||
| 207 | }; | |||
| 208 | const short yysindex[] = | |||
| 209 | { 0, | |||
| 210 | -10, 17, -274, -269, -259, -263, -254, -257, -263, -222, | |||
| 211 | -252, -252, -248, -245, -241, -238, -237, -236, -227, -228, | |||
| 212 | -219, -243, -218, -197, 0, -213, 23, 0, -177, 0, | |||
| 213 | 76, 77, 83, 84, 0, 0, 0, 0, 0, 0, | |||
| 214 | 0, 0, 0, 0, 0, 0, 0, 0, -169, 0, | |||
| 215 | 0, -263, -193, 0, 0, 0, 0, 0, -191, 0, | |||
| 216 | 0, 0, -190, 0, 0, 0, 0, 0, 0, 0, | |||
| 217 | 0, -187, -253, 0, 0, 0, 0, -18, -186, 0, | |||
| 218 | 0, 0, 0, 0, -184, -182, -175, 65, 104, 0, | |||
| 219 | 0, -175, 1, -178, -179, 104, -209, -178, -173, -167, | |||
| 220 | 0, 19, -155, 0, 0, -175, 0, -176, -143, -148, | |||
| 221 | 0, 130, 0, 0, 0, 0, 0, 104, -146, -178, | |||
| 222 | 0, 0, -130, 104, 43, -209, -256, 0, 0, 25, | |||
| 223 | 0, 0, 0, 0, 0, 4, 0, 104, 0, 0, | |||
| 224 | 45, -256, -45, 0, 0, 0, -122, 0, 0, 0, | |||
| 225 | 130, 0, 0, 49, -147, 0, 0,}; | |||
| 226 | const short yyrindex[] = | |||
| 227 | { 0, | |||
| 228 | -81, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 229 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 230 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 231 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 232 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 233 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 234 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 235 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 236 | 0, 0, 0, 0, 181, 0, -9, 0, -183, 0, | |||
| 237 | 0, -9, 69, -7, 0, -121, 0, -7, 0, 0, | |||
| 238 | 0, 0, 0, 0, 0, -9, 0, 0, -5, 0, | |||
| 239 | 0, 68, 0, 0, 0, 0, 0, -250, 0, -7, | |||
| 240 | 0, 0, -4, -95, 0, 0, 0, 0, 0, -3, | |||
| 241 | 0, 0, -69, 0, 0, -110, 0, 16, 0, 0, | |||
| 242 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 243 | 68, 0, 0, 0, 0, 0, 0,}; | |||
| 244 | const short yygindex[] = | |||
| 245 | { 0, | |||
| 246 | -1, 0, -75, 0, -109, 0, 182, 0, 0, -123, | |||
| 247 | -82, 87, 0, 0, 0, 0, 0, 12, -84, 0, | |||
| 248 | 0, 0, 0, 0, 48, 0, 0, 74, 0, 0, | |||
| 249 | 0, 0, 46, | |||
| 250 | }; | |||
| 251 | #define YYTABLESIZE309 309 | |||
| 252 | const short yytable[] = | |||
| 253 | { 28, | |||
| 254 | 32, 61, 39, 61, 76, 68, 82, 51, 102, 86, | |||
| 255 | 96, 107, 35, 96, 61, 115, 98, 137, 99, 149, | |||
| 256 | 41, 42, 46, 47, 61, 44, 40, 125, 100, 61, | |||
| 257 | 120, 149, 145, 127, 61, 53, 45, 129, 50, 133, | |||
| 258 | 49, 87, 88, 54, 52, 66, 57, 140, 108, 58, | |||
| 259 | 80, 141, 67, 143, 59, 60, 109, 60, 61, 62, | |||
| 260 | 63, 13, 14, 15, 16, 17, 154, 64, 18, 19, | |||
| 261 | 20, 21, 22, 23, 61, 24, 65, 69, 70, 148, | |||
| 262 | 110, 71, 61, 72, 73, 74, 75, 61, 61, 61, | |||
| 263 | 61, 61, 76, 77, 61, 61, 61, 61, 61, 61, | |||
| 264 | 79, 61, 81, 82, 89, 83, 61, 84, 93, 90, | |||
| 265 | 91, 95, 92, 96, 103, 32, 106, 39, 121, 76, | |||
| 266 | 68, 82, 116, 13, 14, 15, 16, 17, 117, 146, | |||
| 267 | 18, 19, 20, 21, 22, 23, 61, 24, 119, 124, | |||
| 268 | 61, 118, 147, 25, 61, 103, 123, 138, 128, 61, | |||
| 269 | 61, 61, 61, 61, 150, 61, 61, 61, 61, 61, | |||
| 270 | 61, 61, 61, 61, 64, 131, 150, 134, 61, 144, | |||
| 271 | 61, 61, 153, 156, 64, 61, 61, 61, 61, 61, | |||
| 272 | 13, 61, 61, 61, 61, 61, 61, 61, 62, 61, | |||
| 273 | 17, 61, 61, 56, 61, 122, 62, 61, 155, 135, | |||
| 274 | 157, 62, 62, 62, 62, 62, 0, 62, 62, 62, | |||
| 275 | 62, 62, 62, 62, 0, 62, 0, 0, 0, 0, | |||
| 276 | 62, 0, 0, 62, 0, 13, 14, 15, 16, 17, | |||
| 277 | 0, 146, 18, 19, 20, 21, 22, 23, 0, 24, | |||
| 278 | 0, 0, 0, 0, 147, 2, 3, 103, 4, 5, | |||
| 279 | 6, 0, 7, 8, 9, 10, 13, 11, 12, 0, | |||
| 280 | 13, 14, 15, 16, 17, 0, 0, 18, 19, 20, | |||
| 281 | 21, 22, 23, 0, 24, 99, 25, 0, 0, 0, | |||
| 282 | 26, 0, 0, 32, 27, 100, 61, 61, 61, 61, | |||
| 283 | 61, 0, 61, 61, 61, 61, 61, 61, 61, 0, | |||
| 284 | 61, 0, 0, 0, 0, 61, 0, 0, 61, | |||
| 285 | }; | |||
| 286 | const short yycheck[] = | |||
| 287 | { 10, | |||
| 288 | 10, 123, 10, 125, 10, 10, 10, 9, 93, 263, | |||
| 289 | 10, 96, 1, 10, 125, 98, 92, 127, 275, 143, | |||
| 290 | 295, 296, 286, 287, 275, 295, 10, 112, 285, 125, | |||
| 291 | 106, 155, 142, 118, 285, 288, 296, 120, 296, 124, | |||
| 292 | 295, 295, 296, 296, 267, 289, 295, 44, 258, 295, | |||
| 293 | 52, 136, 296, 138, 296, 125, 266, 296, 296, 296, | |||
| 294 | 288, 271, 272, 273, 274, 275, 151, 296, 278, 279, | |||
| 295 | 280, 281, 282, 283, 258, 285, 296, 296, 276, 125, | |||
| 296 | 290, 295, 266, 61, 262, 10, 10, 271, 272, 273, | |||
| 297 | 274, 275, 10, 10, 278, 279, 280, 281, 282, 283, | |||
| 298 | 270, 285, 296, 295, 123, 296, 290, 295, 284, 296, | |||
| 299 | 295, 47, 295, 10, 293, 125, 296, 125, 295, 125, | |||
| 300 | 125, 125, 296, 271, 272, 273, 274, 275, 296, 277, | |||
| 301 | 278, 279, 280, 281, 282, 283, 258, 285, 294, 10, | |||
| 302 | 125, 123, 290, 287, 266, 293, 295, 123, 295, 271, | |||
| 303 | 272, 273, 274, 275, 143, 277, 278, 279, 280, 281, | |||
| 304 | 282, 283, 258, 285, 275, 296, 155, 125, 290, 125, | |||
| 305 | 266, 293, 295, 125, 285, 271, 272, 273, 274, 275, | |||
| 306 | 262, 277, 278, 279, 280, 281, 282, 283, 258, 285, | |||
| 307 | 10, 123, 125, 12, 290, 109, 266, 293, 151, 126, | |||
| 308 | 155, 271, 272, 273, 274, 275, -1, 277, 278, 279, | |||
| 309 | 280, 281, 282, 283, -1, 285, -1, -1, -1, -1, | |||
| 310 | 290, -1, -1, 293, -1, 271, 272, 273, 274, 275, | |||
| 311 | -1, 277, 278, 279, 280, 281, 282, 283, -1, 285, | |||
| 312 | -1, -1, -1, -1, 290, 256, 257, 293, 259, 260, | |||
| 313 | 261, -1, 263, 264, 265, 266, 262, 268, 269, -1, | |||
| 314 | 271, 272, 273, 274, 275, -1, -1, 278, 279, 280, | |||
| 315 | 281, 282, 283, -1, 285, 275, 287, -1, -1, -1, | |||
| 316 | 291, -1, -1, 293, 295, 285, 271, 272, 273, 274, | |||
| 317 | 275, -1, 277, 278, 279, 280, 281, 282, 283, -1, | |||
| 318 | 285, -1, -1, -1, -1, 290, -1, -1, 293, | |||
| 319 | }; | |||
| 320 | #define YYFINAL1 1 | |||
| 321 | #ifndef YYDEBUG0 | |||
| 322 | #define YYDEBUG0 0 | |||
| 323 | #endif | |||
| 324 | #define YYMAXTOKEN296 296 | |||
| 325 | #if YYDEBUG0 | |||
| 326 | const char * const yyname[] = | |||
| 327 | { | |||
| 328 | "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 329 | 0,0,0,0,0,0,0,0,0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0, | |||
| 330 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 331 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 332 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 333 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 334 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"AREA", | |||
| 335 | "INTERFACE","ROUTERID","FIBPRIORITY","FIBUPDATE","REDISTRIBUTE","RTLABEL", | |||
| 336 | "RDOMAIN","RFC1583COMPAT","STUB","ROUTER","SPFDELAY","SPFHOLDTIME","EXTTAG", | |||
| 337 | "AUTHKEY","AUTHTYPE","AUTHMD","AUTHMDKEYID","METRIC","P2P","PASSIVE", | |||
| 338 | "HELLOINTERVAL","FASTHELLOINTERVAL","TRANSMITDELAY","RETRANSMITINTERVAL", | |||
| 339 | "ROUTERDEADTIME","ROUTERPRIORITY","SET","TYPE","YES","NO","MSEC","MINIMAL", | |||
| 340 | "DEMOTE","INCLUDE","ERROR","DEPEND","ON","STRING","NUMBER", | |||
| 341 | }; | |||
| 342 | const char * const yyrule[] = | |||
| 343 | {"$accept : grammar", | |||
| 344 | "grammar :", | |||
| 345 | "grammar : grammar include '\\n'", | |||
| 346 | "grammar : grammar '\\n'", | |||
| 347 | "grammar : grammar conf_main '\\n'", | |||
| 348 | "grammar : grammar varset '\\n'", | |||
| 349 | "grammar : grammar area '\\n'", | |||
| 350 | "grammar : grammar error '\\n'", | |||
| 351 | "include : INCLUDE STRING", | |||
| 352 | "string : string STRING", | |||
| 353 | "string : STRING", | |||
| 354 | "yesno : YES", | |||
| 355 | "yesno : NO", | |||
| 356 | "no :", | |||
| 357 | "no : NO", | |||
| 358 | "msec : MSEC NUMBER", | |||
| 359 | "msec : NUMBER", | |||
| 360 | "varset : STRING '=' string", | |||
| 361 | "conf_main : ROUTERID STRING", | |||
| 362 | "conf_main : FIBPRIORITY NUMBER", | |||
| 363 | "conf_main : FIBUPDATE yesno", | |||
| 364 | "conf_main : redistribute", | |||
| 365 | "conf_main : RTLABEL STRING EXTTAG NUMBER", | |||
| 366 | "conf_main : RDOMAIN NUMBER", | |||
| 367 | "conf_main : RFC1583COMPAT yesno", | |||
| 368 | "conf_main : SPFDELAY msec", | |||
| 369 | "conf_main : SPFHOLDTIME msec", | |||
| 370 | "conf_main : STUB ROUTER yesno", | |||
| 371 | "conf_main : defaults", | |||
| 372 | "redistribute : no REDISTRIBUTE NUMBER '/' NUMBER optlist dependonopt", | |||
| 373 | "redistribute : no REDISTRIBUTE STRING optlist dependonopt", | |||
| 374 | "redistribute : no REDISTRIBUTE RTLABEL STRING optlist dependonopt", | |||
| 375 | "optlist :", | |||
| 376 | "optlist : SET option", | |||
| 377 | "optlist : SET optnl '{' optnl optlist_l optnl '}'", | |||
| 378 | "optlist_l : optlist_l comma option", | |||
| 379 | "optlist_l : option", | |||
| 380 | "option : METRIC NUMBER", | |||
| 381 | "option : TYPE NUMBER", | |||
| 382 | "dependonopt :", | |||
| 383 | "dependonopt : dependon", | |||
| 384 | "dependon : DEPEND ON STRING", | |||
| 385 | "authmd : AUTHMD NUMBER STRING", | |||
| 386 | "authmdkeyid : AUTHMDKEYID NUMBER", | |||
| 387 | "authtype : AUTHTYPE STRING", | |||
| 388 | "authkey : AUTHKEY STRING", | |||
| 389 | "defaults : METRIC NUMBER", | |||
| 390 | "defaults : ROUTERPRIORITY NUMBER", | |||
| 391 | "defaults : ROUTERDEADTIME deadtime", | |||
| 392 | "defaults : TRANSMITDELAY NUMBER", | |||
| 393 | "defaults : HELLOINTERVAL NUMBER", | |||
| 394 | "defaults : FASTHELLOINTERVAL MSEC NUMBER", | |||
| 395 | "defaults : RETRANSMITINTERVAL NUMBER", | |||
| 396 | "defaults : TYPE P2P", | |||
| 397 | "defaults : authtype", | |||
| 398 | "defaults : authkey", | |||
| 399 | "defaults : authmdkeyid", | |||
| 400 | "defaults : authmd", | |||
| 401 | "deadtime : NUMBER", | |||
| 402 | "deadtime : MINIMAL", | |||
| 403 | "optnl : '\\n' optnl", | |||
| 404 | "optnl :", | |||
| 405 | "nl : '\\n' optnl", | |||
| 406 | "comma : ','", | |||
| 407 | "comma :", | |||
| 408 | "$$1 :", | |||
| 409 | "area : AREA areaid $$1 '{' optnl areaopts_l optnl '}'", | |||
| 410 | "demotecount : NUMBER", | |||
| 411 | "demotecount :", | |||
| 412 | "areaid : NUMBER", | |||
| 413 | "areaid : STRING", | |||
| 414 | "areaopts_l : areaopts_l nl areaoptsl", | |||
| 415 | "areaopts_l : areaoptsl", | |||
| 416 | "areaoptsl : interface", | |||
| 417 | "areaoptsl : DEMOTE STRING demotecount", | |||
| 418 | "areaoptsl : defaults", | |||
| 419 | "areaoptsl : STUB", | |||
| 420 | "areaoptsl : STUB redistribute", | |||
| 421 | "$$2 :", | |||
| 422 | "interface : INTERFACE STRING $$2 interface_block", | |||
| 423 | "interface_block : '{' optnl interfaceopts_l optnl '}'", | |||
| 424 | "interface_block : '{' optnl '}'", | |||
| 425 | "interface_block :", | |||
| 426 | "interfaceopts_l : interfaceopts_l nl interfaceoptsl", | |||
| 427 | "interfaceopts_l : interfaceoptsl", | |||
| 428 | "interfaceoptsl : PASSIVE", | |||
| 429 | "interfaceoptsl : DEMOTE STRING", | |||
| 430 | "interfaceoptsl : dependon", | |||
| 431 | "interfaceoptsl : defaults", | |||
| 432 | }; | |||
| 433 | #endif | |||
| 434 | #ifdef YYSTACKSIZE10000 | |||
| 435 | #undef YYMAXDEPTH10000 | |||
| 436 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | |||
| 437 | #else | |||
| 438 | #ifdef YYMAXDEPTH10000 | |||
| 439 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | |||
| 440 | #else | |||
| 441 | #define YYSTACKSIZE10000 10000 | |||
| 442 | #define YYMAXDEPTH10000 10000 | |||
| 443 | #endif | |||
| 444 | #endif | |||
| 445 | #define YYINITSTACKSIZE200 200 | |||
| 446 | /* LINTUSED */ | |||
| 447 | int yydebug; | |||
| 448 | int yynerrs; | |||
| 449 | int yyerrflag; | |||
| 450 | int yychar; | |||
| 451 | short *yyssp; | |||
| 452 | YYSTYPE *yyvsp; | |||
| 453 | YYSTYPE yyval; | |||
| 454 | YYSTYPE yylval; | |||
| 455 | short *yyss; | |||
| 456 | short *yysslim; | |||
| 457 | YYSTYPE *yyvs; | |||
| 458 | unsigned int yystacksize; | |||
| 459 | int yyparse(void); | |||
| 460 | #line 792 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 461 | ||||
| 462 | struct keywords { | |||
| 463 | const char *k_name; | |||
| 464 | int k_val; | |||
| 465 | }; | |||
| 466 | ||||
| 467 | int | |||
| 468 | yyerror(const char *fmt, ...) | |||
| 469 | { | |||
| 470 | va_list ap; | |||
| 471 | char *msg; | |||
| 472 | ||||
| 473 | file->errors++; | |||
| 474 | va_start(ap, fmt)__builtin_va_start(ap, fmt); | |||
| 475 | if (vasprintf(&msg, fmt, ap) == -1) | |||
| 476 | fatalx("yyerror vasprintf"); | |||
| 477 | va_end(ap)__builtin_va_end(ap); | |||
| 478 | logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg); | |||
| 479 | free(msg); | |||
| 480 | return (0); | |||
| 481 | } | |||
| 482 | ||||
| 483 | int | |||
| 484 | kw_cmp(const void *k, const void *e) | |||
| 485 | { | |||
| 486 | return (strcmp(k, ((const struct keywords *)e)->k_name)); | |||
| 487 | } | |||
| 488 | ||||
| 489 | int | |||
| 490 | lookup(char *s) | |||
| 491 | { | |||
| 492 | /* this has to be sorted always */ | |||
| 493 | static const struct keywords keywords[] = { | |||
| 494 | {"area", AREA257}, | |||
| 495 | {"auth-key", AUTHKEY271}, | |||
| 496 | {"auth-md", AUTHMD273}, | |||
| 497 | {"auth-md-keyid", AUTHMDKEYID274}, | |||
| 498 | {"auth-type", AUTHTYPE272}, | |||
| 499 | {"demote", DEMOTE290}, | |||
| 500 | {"depend", DEPEND293}, | |||
| 501 | {"external-tag", EXTTAG270}, | |||
| 502 | {"fast-hello-interval", FASTHELLOINTERVAL279}, | |||
| 503 | {"fib-priority", FIBPRIORITY260}, | |||
| 504 | {"fib-update", FIBUPDATE261}, | |||
| 505 | {"hello-interval", HELLOINTERVAL278}, | |||
| 506 | {"include", INCLUDE291}, | |||
| 507 | {"interface", INTERFACE258}, | |||
| 508 | {"metric", METRIC275}, | |||
| 509 | {"minimal", MINIMAL289}, | |||
| 510 | {"msec", MSEC288}, | |||
| 511 | {"no", NO287}, | |||
| 512 | {"on", ON294}, | |||
| 513 | {"p2p", P2P276}, | |||
| 514 | {"passive", PASSIVE277}, | |||
| 515 | {"rdomain", RDOMAIN264}, | |||
| 516 | {"redistribute", REDISTRIBUTE262}, | |||
| 517 | {"retransmit-interval", RETRANSMITINTERVAL281}, | |||
| 518 | {"rfc1583compat", RFC1583COMPAT265}, | |||
| 519 | {"router", ROUTER267}, | |||
| 520 | {"router-dead-time", ROUTERDEADTIME282}, | |||
| 521 | {"router-id", ROUTERID259}, | |||
| 522 | {"router-priority", ROUTERPRIORITY283}, | |||
| 523 | {"rtlabel", RTLABEL263}, | |||
| 524 | {"set", SET284}, | |||
| 525 | {"spf-delay", SPFDELAY268}, | |||
| 526 | {"spf-holdtime", SPFHOLDTIME269}, | |||
| 527 | {"stub", STUB266}, | |||
| 528 | {"transmit-delay", TRANSMITDELAY280}, | |||
| 529 | {"type", TYPE285}, | |||
| 530 | {"yes", YES286} | |||
| 531 | }; | |||
| 532 | const struct keywords *p; | |||
| 533 | ||||
| 534 | p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]), | |||
| 535 | sizeof(keywords[0]), kw_cmp); | |||
| 536 | ||||
| 537 | if (p) | |||
| 538 | return (p->k_val); | |||
| 539 | else | |||
| 540 | return (STRING295); | |||
| 541 | } | |||
| 542 | ||||
| 543 | #define START_EXPAND1 1 | |||
| 544 | #define DONE_EXPAND2 2 | |||
| 545 | ||||
| 546 | static int expanding; | |||
| 547 | ||||
| 548 | int | |||
| 549 | igetc(void) | |||
| 550 | { | |||
| 551 | int c; | |||
| 552 | ||||
| 553 | while (1) { | |||
| 554 | if (file->ungetpos > 0) | |||
| 555 | c = file->ungetbuf[--file->ungetpos]; | |||
| 556 | else | |||
| 557 | c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
| 558 | ||||
| 559 | if (c == START_EXPAND1) | |||
| 560 | expanding = 1; | |||
| 561 | else if (c == DONE_EXPAND2) | |||
| 562 | expanding = 0; | |||
| 563 | else | |||
| 564 | break; | |||
| 565 | } | |||
| 566 | return (c); | |||
| 567 | } | |||
| 568 | ||||
| 569 | int | |||
| 570 | lgetc(int quotec) | |||
| 571 | { | |||
| 572 | int c, next; | |||
| 573 | ||||
| 574 | if (quotec) { | |||
| 575 | if ((c = igetc()) == EOF(-1)) { | |||
| 576 | yyerror("reached end of file while parsing " | |||
| 577 | "quoted string"); | |||
| 578 | if (file == topfile || popfile() == EOF(-1)) | |||
| 579 | return (EOF(-1)); | |||
| 580 | return (quotec); | |||
| 581 | } | |||
| 582 | return (c); | |||
| 583 | } | |||
| 584 | ||||
| 585 | while ((c = igetc()) == '\\') { | |||
| 586 | next = igetc(); | |||
| 587 | if (next != '\n') { | |||
| 588 | c = next; | |||
| 589 | break; | |||
| 590 | } | |||
| 591 | yylval.lineno = file->lineno; | |||
| 592 | file->lineno++; | |||
| 593 | } | |||
| 594 | ||||
| 595 | if (c == EOF(-1)) { | |||
| 596 | /* | |||
| 597 | * Fake EOL when hit EOF for the first time. This gets line | |||
| 598 | * count right if last line in included file is syntactically | |||
| 599 | * invalid and has no newline. | |||
| 600 | */ | |||
| 601 | if (file->eof_reached == 0) { | |||
| 602 | file->eof_reached = 1; | |||
| 603 | return ('\n'); | |||
| 604 | } | |||
| 605 | while (c == EOF(-1)) { | |||
| 606 | if (file == topfile || popfile() == EOF(-1)) | |||
| 607 | return (EOF(-1)); | |||
| 608 | c = igetc(); | |||
| 609 | } | |||
| 610 | } | |||
| 611 | return (c); | |||
| 612 | } | |||
| 613 | ||||
| 614 | void | |||
| 615 | lungetc(int c) | |||
| 616 | { | |||
| 617 | if (c == EOF(-1)) | |||
| 618 | return; | |||
| 619 | ||||
| 620 | if (file->ungetpos >= file->ungetsize) { | |||
| 621 | void *p = reallocarray(file->ungetbuf, file->ungetsize, 2); | |||
| 622 | if (p == NULL((void*)0)) | |||
| 623 | err(1, "%s", __func__); | |||
| 624 | file->ungetbuf = p; | |||
| 625 | file->ungetsize *= 2; | |||
| 626 | } | |||
| 627 | file->ungetbuf[file->ungetpos++] = c; | |||
| 628 | } | |||
| 629 | ||||
| 630 | int | |||
| 631 | findeol(void) | |||
| 632 | { | |||
| 633 | int c; | |||
| 634 | ||||
| 635 | /* skip to either EOF or the first real EOL */ | |||
| 636 | while (1) { | |||
| 637 | c = lgetc(0); | |||
| 638 | if (c == '\n') { | |||
| 639 | file->lineno++; | |||
| 640 | break; | |||
| 641 | } | |||
| 642 | if (c == EOF(-1)) | |||
| 643 | break; | |||
| 644 | } | |||
| 645 | return (ERROR292); | |||
| 646 | } | |||
| 647 | ||||
| 648 | int | |||
| 649 | yylex(void) | |||
| 650 | { | |||
| 651 | char buf[8096]; | |||
| 652 | char *p, *val; | |||
| 653 | int quotec, next, c; | |||
| 654 | int token; | |||
| 655 | ||||
| 656 | top: | |||
| 657 | p = buf; | |||
| 658 | while ((c = lgetc(0)) == ' ' || c == '\t') | |||
| 659 | ; /* nothing */ | |||
| 660 | ||||
| 661 | yylval.lineno = file->lineno; | |||
| 662 | if (c == '#') | |||
| 663 | while ((c = lgetc(0)) != '\n' && c != EOF(-1)) | |||
| 664 | ; /* nothing */ | |||
| 665 | if (c == '$' && !expanding) { | |||
| 666 | while (1) { | |||
| 667 | if ((c = lgetc(0)) == EOF(-1)) | |||
| 668 | return (0); | |||
| 669 | ||||
| 670 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 671 | yyerror("string too long"); | |||
| 672 | return (findeol()); | |||
| 673 | } | |||
| 674 | if (isalnum(c) || c == '_') { | |||
| 675 | *p++ = c; | |||
| 676 | continue; | |||
| 677 | } | |||
| 678 | *p = '\0'; | |||
| 679 | lungetc(c); | |||
| 680 | break; | |||
| 681 | } | |||
| 682 | val = symget(buf); | |||
| 683 | if (val == NULL((void*)0)) { | |||
| 684 | yyerror("macro '%s' not defined", buf); | |||
| 685 | return (findeol()); | |||
| 686 | } | |||
| 687 | p = val + strlen(val) - 1; | |||
| 688 | lungetc(DONE_EXPAND2); | |||
| 689 | while (p >= val) { | |||
| 690 | lungetc((unsigned char)*p); | |||
| 691 | p--; | |||
| 692 | } | |||
| 693 | lungetc(START_EXPAND1); | |||
| 694 | goto top; | |||
| 695 | } | |||
| 696 | ||||
| 697 | switch (c) { | |||
| 698 | case '\'': | |||
| 699 | case '"': | |||
| 700 | quotec = c; | |||
| 701 | while (1) { | |||
| 702 | if ((c = lgetc(quotec)) == EOF(-1)) | |||
| 703 | return (0); | |||
| 704 | if (c == '\n') { | |||
| 705 | file->lineno++; | |||
| 706 | continue; | |||
| 707 | } else if (c == '\\') { | |||
| 708 | if ((next = lgetc(quotec)) == EOF(-1)) | |||
| 709 | return (0); | |||
| 710 | if (next == quotec || next == ' ' || | |||
| 711 | next == '\t') | |||
| 712 | c = next; | |||
| 713 | else if (next == '\n') { | |||
| 714 | file->lineno++; | |||
| 715 | continue; | |||
| 716 | } else | |||
| 717 | lungetc(next); | |||
| 718 | } else if (c == quotec) { | |||
| 719 | *p = '\0'; | |||
| 720 | break; | |||
| 721 | } else if (c == '\0') { | |||
| 722 | yyerror("syntax error"); | |||
| 723 | return (findeol()); | |||
| 724 | } | |||
| 725 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 726 | yyerror("string too long"); | |||
| 727 | return (findeol()); | |||
| 728 | } | |||
| 729 | *p++ = c; | |||
| 730 | } | |||
| 731 | yylval.v.string = strdup(buf); | |||
| 732 | if (yylval.v.string == NULL((void*)0)) | |||
| 733 | err(1, "%s", __func__); | |||
| 734 | return (STRING295); | |||
| 735 | } | |||
| 736 | ||||
| 737 | #define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') \ | |||
| 738 | (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') | |||
| 739 | ||||
| 740 | if (c == '-' || isdigit(c)) { | |||
| 741 | do { | |||
| 742 | *p++ = c; | |||
| 743 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 744 | yyerror("string too long"); | |||
| 745 | return (findeol()); | |||
| 746 | } | |||
| 747 | } while ((c = lgetc(0)) != EOF(-1) && isdigit(c)); | |||
| 748 | lungetc(c); | |||
| 749 | if (p == buf + 1 && buf[0] == '-') | |||
| 750 | goto nodigits; | |||
| 751 | if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' || c == '=')) { | |||
| 752 | const char *errstr = NULL((void*)0); | |||
| 753 | ||||
| 754 | *p = '\0'; | |||
| 755 | yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL), | |||
| 756 | LLONG_MAX9223372036854775807LL, &errstr); | |||
| 757 | if (errstr) { | |||
| 758 | yyerror("\"%s\" invalid number: %s", | |||
| 759 | buf, errstr); | |||
| 760 | return (findeol()); | |||
| 761 | } | |||
| 762 | return (NUMBER296); | |||
| 763 | } else { | |||
| 764 | nodigits: | |||
| 765 | while (p > buf + 1) | |||
| 766 | lungetc((unsigned char)*--p); | |||
| 767 | c = (unsigned char)*--p; | |||
| 768 | if (c == '-') | |||
| 769 | return (c); | |||
| 770 | } | |||
| 771 | } | |||
| 772 | ||||
| 773 | #define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && x != '{' && x != '}' && x != '!' && x != '=' && x != '#' && x != ',') ) \ | |||
| 774 | (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \ | |||
| 775 | x != '{' && x != '}' && \ | |||
| 776 | x != '!' && x != '=' && x != '#' && \ | |||
| 777 | x != ',')) | |||
| 778 | ||||
| 779 | if (isalnum(c) || c == ':' || c == '_') { | |||
| 780 | do { | |||
| 781 | *p++ = c; | |||
| 782 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 783 | yyerror("string too long"); | |||
| 784 | return (findeol()); | |||
| 785 | } | |||
| 786 | } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c != ')' && c != '{' && c != '}' && c != '!' && c != '=' && c != '#' && c != ',') ))); | |||
| 787 | lungetc(c); | |||
| 788 | *p = '\0'; | |||
| 789 | if ((token = lookup(buf)) == STRING295) | |||
| 790 | if ((yylval.v.string = strdup(buf)) == NULL((void*)0)) | |||
| 791 | err(1, "%s", __func__); | |||
| 792 | return (token); | |||
| 793 | } | |||
| 794 | if (c == '\n') { | |||
| 795 | yylval.lineno = file->lineno; | |||
| 796 | file->lineno++; | |||
| 797 | } | |||
| 798 | if (c == EOF(-1)) | |||
| 799 | return (0); | |||
| 800 | return (c); | |||
| 801 | } | |||
| 802 | ||||
| 803 | int | |||
| 804 | check_file_secrecy(int fd, const char *fname) | |||
| 805 | { | |||
| 806 | struct stat st; | |||
| 807 | ||||
| 808 | if (fstat(fd, &st)) { | |||
| 809 | log_warn("cannot stat %s", fname); | |||
| 810 | return (-1); | |||
| 811 | } | |||
| 812 | if (st.st_uid != 0 && st.st_uid != getuid()) { | |||
| 813 | log_warnx("%s: owner not root or current user", fname); | |||
| 814 | return (-1); | |||
| 815 | } | |||
| 816 | if (st.st_mode & (S_IWGRP0000020 | S_IXGRP0000010 | S_IRWXO0000007)) { | |||
| 817 | log_warnx("%s: group writable or world read/writable", fname); | |||
| 818 | return (-1); | |||
| 819 | } | |||
| 820 | return (0); | |||
| 821 | } | |||
| 822 | ||||
| 823 | struct file * | |||
| 824 | pushfile(const char *name, int secret) | |||
| 825 | { | |||
| 826 | struct file *nfile; | |||
| 827 | ||||
| 828 | if ((nfile = calloc(1, sizeof(struct file))) == NULL((void*)0)) { | |||
| 829 | log_warn("%s", __func__); | |||
| 830 | return (NULL((void*)0)); | |||
| 831 | } | |||
| 832 | if ((nfile->name = strdup(name)) == NULL((void*)0)) { | |||
| 833 | log_warn("%s", __func__); | |||
| 834 | free(nfile); | |||
| 835 | return (NULL((void*)0)); | |||
| 836 | } | |||
| 837 | if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void*)0)) { | |||
| 838 | log_warn("%s: %s", __func__, nfile->name); | |||
| 839 | free(nfile->name); | |||
| 840 | free(nfile); | |||
| 841 | return (NULL((void*)0)); | |||
| 842 | } else if (secret && | |||
| 843 | check_file_secrecy(fileno(nfile->stream)(!__isthreaded ? ((nfile->stream)->_file) : (fileno)(nfile ->stream)), nfile->name)) { | |||
| 844 | fclose(nfile->stream); | |||
| 845 | free(nfile->name); | |||
| 846 | free(nfile); | |||
| 847 | return (NULL((void*)0)); | |||
| 848 | } | |||
| 849 | nfile->lineno = TAILQ_EMPTY(&files)(((&files)->tqh_first) == ((void*)0)) ? 1 : 0; | |||
| 850 | nfile->ungetsize = 16; | |||
| 851 | nfile->ungetbuf = malloc(nfile->ungetsize); | |||
| 852 | if (nfile->ungetbuf == NULL((void*)0)) { | |||
| 853 | log_warn("%s", __func__); | |||
| 854 | fclose(nfile->stream); | |||
| 855 | free(nfile->name); | |||
| 856 | free(nfile); | |||
| 857 | return (NULL((void*)0)); | |||
| 858 | } | |||
| 859 | TAILQ_INSERT_TAIL(&files, nfile, entry)do { (nfile)->entry.tqe_next = ((void*)0); (nfile)->entry .tqe_prev = (&files)->tqh_last; *(&files)->tqh_last = (nfile); (&files)->tqh_last = &(nfile)->entry .tqe_next; } while (0); | |||
| 860 | return (nfile); | |||
| 861 | } | |||
| 862 | ||||
| 863 | int | |||
| 864 | popfile(void) | |||
| 865 | { | |||
| 866 | struct file *prev; | |||
| 867 | ||||
| 868 | if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last ))) != NULL((void*)0)) | |||
| 869 | prev->errors += file->errors; | |||
| 870 | ||||
| 871 | TAILQ_REMOVE(&files, file, entry)do { if (((file)->entry.tqe_next) != ((void*)0)) (file)-> entry.tqe_next->entry.tqe_prev = (file)->entry.tqe_prev ; else (&files)->tqh_last = (file)->entry.tqe_prev; *(file)->entry.tqe_prev = (file)->entry.tqe_next; ; ; } while (0); | |||
| 872 | fclose(file->stream); | |||
| 873 | free(file->name); | |||
| 874 | free(file->ungetbuf); | |||
| 875 | free(file); | |||
| 876 | file = prev; | |||
| 877 | return (file ? 0 : EOF(-1)); | |||
| 878 | } | |||
| 879 | ||||
| 880 | struct ospfd_conf * | |||
| 881 | parse_config(char *filename, int opts) | |||
| 882 | { | |||
| 883 | struct sym *sym, *next; | |||
| 884 | ||||
| 885 | if ((conf = calloc(1, sizeof(struct ospfd_conf))) == NULL((void*)0)) | |||
| 886 | fatal("parse_config"); | |||
| 887 | conf->opts = opts; | |||
| 888 | if (conf->opts & OSPFD_OPT_STUB_ROUTER0x00000008) | |||
| 889 | conf->flags |= OSPFD_FLAG_STUB_ROUTER0x0002; | |||
| 890 | ||||
| 891 | bzero(&globaldefs, sizeof(globaldefs)); | |||
| 892 | defs = &globaldefs; | |||
| 893 | TAILQ_INIT(&defs->md_list)do { (&defs->md_list)->tqh_first = ((void*)0); (& defs->md_list)->tqh_last = &(&defs->md_list) ->tqh_first; } while (0); | |||
| 894 | defs->dead_interval = DEFAULT_RTR_DEAD_TIME40; | |||
| 895 | defs->fast_hello_interval = DEFAULT_FAST_INTERVAL333; | |||
| 896 | defs->transmit_delay = DEFAULT_TRANSMIT_DELAY1; | |||
| 897 | defs->hello_interval = DEFAULT_HELLO_INTERVAL10; | |||
| 898 | defs->rxmt_interval = DEFAULT_RXMT_INTERVAL5; | |||
| 899 | defs->metric = DEFAULT_METRIC10; | |||
| 900 | defs->priority = DEFAULT_PRIORITY1; | |||
| 901 | defs->p2p = 0; | |||
| 902 | ||||
| 903 | conf->spf_delay = DEFAULT_SPF_DELAY1000; | |||
| 904 | conf->spf_hold_time = DEFAULT_SPF_HOLDTIME5000; | |||
| 905 | conf->spf_state = SPF_IDLE; | |||
| 906 | conf->fib_priority = RTP_OSPF32; | |||
| 907 | ||||
| 908 | if ((file = pushfile(filename, | |||
| 909 | !(conf->opts & OSPFD_OPT_NOACTION0x00000004))) == NULL((void*)0)) { | |||
| 910 | free(conf); | |||
| 911 | return (NULL((void*)0)); | |||
| 912 | } | |||
| 913 | topfile = file; | |||
| 914 | ||||
| 915 | LIST_INIT(&conf->area_list)do { ((&conf->area_list)->lh_first) = ((void*)0); } while (0); | |||
| 916 | LIST_INIT(&conf->cand_list)do { ((&conf->cand_list)->lh_first) = ((void*)0); } while (0); | |||
| 917 | SIMPLEQ_INIT(&conf->redist_list)do { (&conf->redist_list)->sqh_first = ((void*)0); ( &conf->redist_list)->sqh_last = &(&conf-> redist_list)->sqh_first; } while (0); | |||
| 918 | ||||
| 919 | yyparse(); | |||
| 920 | errors = file->errors; | |||
| 921 | popfile(); | |||
| 922 | ||||
| 923 | /* Free macros and check which have not been used. */ | |||
| 924 | TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void* )0) && ((next) = ((sym)->entry.tqe_next), 1); (sym ) = (next)) { | |||
| 925 | if ((conf->opts & OSPFD_OPT_VERBOSE20x00000002) && !sym->used) | |||
| 926 | fprintf(stderr(&__sF[2]), "warning: macro '%s' not " | |||
| 927 | "used\n", sym->nam); | |||
| 928 | if (!sym->persist) { | |||
| 929 | free(sym->nam); | |||
| 930 | free(sym->val); | |||
| 931 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void*)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
| 932 | free(sym); | |||
| 933 | } | |||
| 934 | } | |||
| 935 | ||||
| 936 | /* free global config defaults */ | |||
| 937 | md_list_clr(&globaldefs.md_list); | |||
| 938 | ||||
| 939 | /* check that all interfaces belong to the configured rdomain */ | |||
| 940 | errors += conf_check_rdomain(conf->rdomain); | |||
| 941 | ||||
| 942 | if (errors) { | |||
| 943 | clear_config(conf); | |||
| 944 | return (NULL((void*)0)); | |||
| 945 | } | |||
| 946 | ||||
| 947 | return (conf); | |||
| 948 | } | |||
| 949 | ||||
| 950 | int | |||
| 951 | symset(const char *nam, const char *val, int persist) | |||
| 952 | { | |||
| 953 | struct sym *sym; | |||
| 954 | ||||
| 955 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void*) 0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 956 | if (strcmp(nam, sym->nam) == 0) | |||
| 957 | break; | |||
| 958 | } | |||
| 959 | ||||
| 960 | if (sym != NULL((void*)0)) { | |||
| 961 | if (sym->persist == 1) | |||
| 962 | return (0); | |||
| 963 | else { | |||
| 964 | free(sym->nam); | |||
| 965 | free(sym->val); | |||
| 966 | TAILQ_REMOVE(&symhead, sym, entry)do { if (((sym)->entry.tqe_next) != ((void*)0)) (sym)-> entry.tqe_next->entry.tqe_prev = (sym)->entry.tqe_prev; else (&symhead)->tqh_last = (sym)->entry.tqe_prev; *(sym)->entry.tqe_prev = (sym)->entry.tqe_next; ; ; } while (0); | |||
| 967 | free(sym); | |||
| 968 | } | |||
| 969 | } | |||
| 970 | if ((sym = calloc(1, sizeof(*sym))) == NULL((void*)0)) | |||
| 971 | return (-1); | |||
| 972 | ||||
| 973 | sym->nam = strdup(nam); | |||
| 974 | if (sym->nam == NULL((void*)0)) { | |||
| 975 | free(sym); | |||
| 976 | return (-1); | |||
| 977 | } | |||
| 978 | sym->val = strdup(val); | |||
| 979 | if (sym->val == NULL((void*)0)) { | |||
| 980 | free(sym->nam); | |||
| 981 | free(sym); | |||
| 982 | return (-1); | |||
| 983 | } | |||
| 984 | sym->used = 0; | |||
| 985 | sym->persist = persist; | |||
| 986 | TAILQ_INSERT_TAIL(&symhead, sym, entry)do { (sym)->entry.tqe_next = ((void*)0); (sym)->entry.tqe_prev = (&symhead)->tqh_last; *(&symhead)->tqh_last = (sym); (&symhead)->tqh_last = &(sym)->entry.tqe_next ; } while (0); | |||
| 987 | return (0); | |||
| 988 | } | |||
| 989 | ||||
| 990 | int | |||
| 991 | cmdline_symset(char *s) | |||
| 992 | { | |||
| 993 | char *sym, *val; | |||
| 994 | int ret; | |||
| 995 | ||||
| 996 | if ((val = strrchr(s, '=')) == NULL((void*)0)) | |||
| 997 | return (-1); | |||
| 998 | sym = strndup(s, val - s); | |||
| 999 | if (sym == NULL((void*)0)) | |||
| 1000 | errx(1, "%s: strndup", __func__); | |||
| 1001 | ret = symset(sym, val + 1, 1); | |||
| 1002 | free(sym); | |||
| 1003 | ||||
| 1004 | return (ret); | |||
| 1005 | } | |||
| 1006 | ||||
| 1007 | char * | |||
| 1008 | symget(const char *nam) | |||
| 1009 | { | |||
| 1010 | struct sym *sym; | |||
| 1011 | ||||
| 1012 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void*) 0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 1013 | if (strcmp(nam, sym->nam) == 0) { | |||
| 1014 | sym->used = 1; | |||
| 1015 | return (sym->val); | |||
| 1016 | } | |||
| 1017 | } | |||
| 1018 | return (NULL((void*)0)); | |||
| 1019 | } | |||
| 1020 | ||||
| 1021 | struct area * | |||
| 1022 | conf_get_area(struct in_addr id) | |||
| 1023 | { | |||
| 1024 | struct area *a; | |||
| 1025 | ||||
| 1026 | a = area_find(conf, id); | |||
| 1027 | if (a) | |||
| 1028 | return (a); | |||
| 1029 | a = area_new(); | |||
| 1030 | LIST_INSERT_HEAD(&conf->area_list, a, entry)do { if (((a)->entry.le_next = (&conf->area_list)-> lh_first) != ((void*)0)) (&conf->area_list)->lh_first ->entry.le_prev = &(a)->entry.le_next; (&conf-> area_list)->lh_first = (a); (a)->entry.le_prev = &( &conf->area_list)->lh_first; } while (0); | |||
| 1031 | ||||
| 1032 | a->id.s_addr = id.s_addr; | |||
| 1033 | ||||
| 1034 | return (a); | |||
| 1035 | } | |||
| 1036 | ||||
| 1037 | struct iface * | |||
| 1038 | conf_get_if(struct kif *kif, struct kif_addr *ka) | |||
| 1039 | { | |||
| 1040 | struct area *a; | |||
| 1041 | struct iface *i; | |||
| 1042 | ||||
| 1043 | LIST_FOREACH(a, &conf->area_list, entry)for((a) = ((&conf->area_list)->lh_first); (a)!= ((void *)0); (a) = ((a)->entry.le_next)) | |||
| 1044 | LIST_FOREACH(i, &a->iface_list, entry)for((i) = ((&a->iface_list)->lh_first); (i)!= ((void *)0); (i) = ((i)->entry.le_next)) | |||
| 1045 | if (i->ifindex == kif->ifindex && | |||
| 1046 | i->addr.s_addr == ka->addr.s_addr) { | |||
| 1047 | yyerror("interface %s already configured", | |||
| 1048 | kif->ifname); | |||
| 1049 | return (NULL((void*)0)); | |||
| 1050 | } | |||
| 1051 | ||||
| 1052 | i = if_new(kif, ka); | |||
| 1053 | i->auth_keyid = 1; | |||
| 1054 | ||||
| 1055 | return (i); | |||
| 1056 | } | |||
| 1057 | ||||
| 1058 | int | |||
| 1059 | conf_check_rdomain(unsigned int rdomain) | |||
| 1060 | { | |||
| 1061 | struct area *a; | |||
| 1062 | struct iface *i; | |||
| 1063 | struct in_addr addr; | |||
| 1064 | struct kif *kif; | |||
| 1065 | struct redistribute *r; | |||
| 1066 | int errs = 0; | |||
| 1067 | ||||
| 1068 | SIMPLEQ_FOREACH(r, &conf->redist_list, entry)for((r) = ((&conf->redist_list)->sqh_first); (r) != ((void*)0); (r) = ((r)->entry.sqe_next)) | |||
| 1069 | if (r->dependon[0] != '\0') { | |||
| 1070 | bzero(&addr, sizeof(addr)); | |||
| 1071 | kif = kif_findname(r->dependon, addr, NULL((void*)0)); | |||
| 1072 | if (kif->rdomain != rdomain) { | |||
| 1073 | logit(LOG_CRIT2, | |||
| 1074 | "depend on %s: interface not in rdomain %u", | |||
| 1075 | kif->ifname, rdomain); | |||
| 1076 | errs++; | |||
| 1077 | } | |||
| 1078 | } | |||
| 1079 | ||||
| 1080 | LIST_FOREACH(a, &conf->area_list, entry)for((a) = ((&conf->area_list)->lh_first); (a)!= ((void *)0); (a) = ((a)->entry.le_next)) | |||
| 1081 | LIST_FOREACH(i, &a->iface_list, entry)for((i) = ((&a->iface_list)->lh_first); (i)!= ((void *)0); (i) = ((i)->entry.le_next)) { | |||
| 1082 | if (i->rdomain != rdomain) { | |||
| 1083 | logit(LOG_CRIT2, | |||
| 1084 | "interface %s not in rdomain %u", | |||
| 1085 | i->name, rdomain); | |||
| 1086 | errs++; | |||
| 1087 | } | |||
| 1088 | if (i->dependon[0] != '\0') { | |||
| 1089 | bzero(&addr, sizeof(addr)); | |||
| 1090 | kif = kif_findname(i->dependon, addr, NULL((void*)0)); | |||
| 1091 | if (kif->rdomain != rdomain) { | |||
| 1092 | logit(LOG_CRIT2, | |||
| 1093 | "depend on %s: interface not in " | |||
| 1094 | "rdomain %u", | |||
| 1095 | kif->ifname, rdomain); | |||
| 1096 | errs++; | |||
| 1097 | } | |||
| 1098 | } | |||
| 1099 | } | |||
| 1100 | ||||
| 1101 | return (errs); | |||
| 1102 | } | |||
| 1103 | ||||
| 1104 | void | |||
| 1105 | conf_clear_redist_list(struct redist_list *rl) | |||
| 1106 | { | |||
| 1107 | struct redistribute *r; | |||
| 1108 | while ((r = SIMPLEQ_FIRST(rl)((rl)->sqh_first)) != NULL((void*)0)) { | |||
| 1109 | SIMPLEQ_REMOVE_HEAD(rl, entry)do { if (((rl)->sqh_first = (rl)->sqh_first->entry.sqe_next ) == ((void*)0)) (rl)->sqh_last = &(rl)->sqh_first; } while (0); | |||
| 1110 | free(r); | |||
| 1111 | } | |||
| 1112 | } | |||
| 1113 | ||||
| 1114 | void | |||
| 1115 | clear_config(struct ospfd_conf *xconf) | |||
| 1116 | { | |||
| 1117 | struct area *a; | |||
| 1118 | ||||
| 1119 | while ((a = LIST_FIRST(&xconf->area_list)((&xconf->area_list)->lh_first)) != NULL((void*)0)) { | |||
| 1120 | LIST_REMOVE(a, entry)do { if ((a)->entry.le_next != ((void*)0)) (a)->entry.le_next ->entry.le_prev = (a)->entry.le_prev; *(a)->entry.le_prev = (a)->entry.le_next; ; ; } while (0); | |||
| 1121 | area_del(a); | |||
| 1122 | } | |||
| 1123 | ||||
| 1124 | conf_clear_redist_list(&xconf->redist_list); | |||
| 1125 | ||||
| 1126 | free(xconf); | |||
| 1127 | } | |||
| 1128 | ||||
| 1129 | u_int32_t | |||
| 1130 | get_rtr_id(void) | |||
| 1131 | { | |||
| 1132 | struct ifaddrs *ifap, *ifa; | |||
| 1133 | u_int32_t ip = 0, cur, localnet; | |||
| 1134 | ||||
| 1135 | localnet = htonl(INADDR_LOOPBACK & IN_CLASSA_NET)(__uint32_t)(__builtin_constant_p(((u_int32_t)(0x7f000001)) & ((u_int32_t)(0xff000000))) ? (__uint32_t)(((__uint32_t)(((u_int32_t )(0x7f000001)) & ((u_int32_t)(0xff000000))) & 0xff) << 24 | ((__uint32_t)(((u_int32_t)(0x7f000001)) & ((u_int32_t )(0xff000000))) & 0xff00) << 8 | ((__uint32_t)(((u_int32_t )(0x7f000001)) & ((u_int32_t)(0xff000000))) & 0xff0000 ) >> 8 | ((__uint32_t)(((u_int32_t)(0x7f000001)) & ( (u_int32_t)(0xff000000))) & 0xff000000) >> 24) : __swap32md (((u_int32_t)(0x7f000001)) & ((u_int32_t)(0xff000000)))); | |||
| 1136 | ||||
| 1137 | if (getifaddrs(&ifap) == -1) | |||
| 1138 | fatal("getifaddrs"); | |||
| 1139 | ||||
| 1140 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { | |||
| 1141 | if (strncmp(ifa->ifa_name, "carp", 4) == 0) | |||
| 1142 | continue; | |||
| 1143 | if (ifa->ifa_addr == NULL((void*)0) || | |||
| 1144 | ifa->ifa_addr->sa_family != AF_INET2) | |||
| 1145 | continue; | |||
| 1146 | cur = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr; | |||
| 1147 | if ((cur & localnet) == localnet) /* skip 127/8 */ | |||
| 1148 | continue; | |||
| 1149 | if (ntohl(cur)(__uint32_t)(__builtin_constant_p(cur) ? (__uint32_t)(((__uint32_t )(cur) & 0xff) << 24 | ((__uint32_t)(cur) & 0xff00 ) << 8 | ((__uint32_t)(cur) & 0xff0000) >> 8 | ((__uint32_t)(cur) & 0xff000000) >> 24) : __swap32md (cur)) < ntohl(ip)(__uint32_t)(__builtin_constant_p(ip) ? (__uint32_t)(((__uint32_t )(ip) & 0xff) << 24 | ((__uint32_t)(ip) & 0xff00 ) << 8 | ((__uint32_t)(ip) & 0xff0000) >> 8 | ((__uint32_t)(ip) & 0xff000000) >> 24) : __swap32md (ip)) || ip == 0) | |||
| 1150 | ip = cur; | |||
| 1151 | } | |||
| 1152 | freeifaddrs(ifap); | |||
| 1153 | ||||
| 1154 | if (ip == 0) | |||
| 1155 | fatal("router-id is 0.0.0.0"); | |||
| 1156 | ||||
| 1157 | return (ip); | |||
| 1158 | } | |||
| 1159 | ||||
| 1160 | int | |||
| 1161 | host(const char *s, struct in_addr *addr, struct in_addr *mask) | |||
| 1162 | { | |||
| 1163 | struct in_addr ina; | |||
| 1164 | int bits = 32; | |||
| 1165 | ||||
| 1166 | bzero(&ina, sizeof(struct in_addr)); | |||
| 1167 | if (strrchr(s, '/') != NULL((void*)0)) { | |||
| 1168 | if ((bits = inet_net_pton(AF_INET2, s, &ina, sizeof(ina))) == -1) | |||
| 1169 | return (0); | |||
| 1170 | } else { | |||
| 1171 | if (inet_pton(AF_INET2, s, &ina) != 1) | |||
| 1172 | return (0); | |||
| 1173 | } | |||
| 1174 | ||||
| 1175 | addr->s_addr = ina.s_addr; | |||
| 1176 | mask->s_addr = prefixlen2mask(bits); | |||
| 1177 | ||||
| 1178 | return (1); | |||
| 1179 | } | |||
| 1180 | #line 1173 "parse.c" | |||
| 1181 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | |||
| 1182 | static int yygrowstack(void) | |||
| 1183 | { | |||
| 1184 | unsigned int newsize; | |||
| 1185 | long sslen; | |||
| 1186 | short *newss; | |||
| 1187 | YYSTYPE *newvs; | |||
| 1188 | ||||
| 1189 | if ((newsize = yystacksize) == 0) | |||
| 1190 | newsize = YYINITSTACKSIZE200; | |||
| 1191 | else if (newsize >= YYMAXDEPTH10000) | |||
| 1192 | return -1; | |||
| 1193 | else if ((newsize *= 2) > YYMAXDEPTH10000) | |||
| 1194 | newsize = YYMAXDEPTH10000; | |||
| 1195 | sslen = yyssp - yyss; | |||
| 1196 | #ifdef SIZE_MAX0xffffffffffffffffUL | |||
| 1197 | #define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL | |||
| 1198 | #else | |||
| 1199 | #define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU | |||
| 1200 | #endif | |||
| 1201 | if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss) | |||
| 1202 | goto bail; | |||
| 1203 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | |||
| 1204 | if (newss == NULL((void*)0)) | |||
| 1205 | goto bail; | |||
| 1206 | yyss = newss; | |||
| 1207 | yyssp = newss + sslen; | |||
| 1208 | if (newsize
| |||
| 1209 | goto bail; | |||
| 1210 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | |||
| 1211 | if (newvs == NULL((void*)0)) | |||
| 1212 | goto bail; | |||
| 1213 | yyvs = newvs; | |||
| 1214 | yyvsp = newvs + sslen; | |||
| 1215 | yystacksize = newsize; | |||
| 1216 | yysslim = yyss + newsize - 1; | |||
| 1217 | return 0; | |||
| 1218 | bail: | |||
| 1219 | if (yyss
| |||
| 1220 | free(yyss); | |||
| 1221 | if (yyvs) | |||
| 1222 | free(yyvs); | |||
| ||||
| 1223 | yyss = yyssp = NULL((void*)0); | |||
| 1224 | yyvs = yyvsp = NULL((void*)0); | |||
| 1225 | yystacksize = 0; | |||
| 1226 | return -1; | |||
| 1227 | } | |||
| 1228 | ||||
| 1229 | #define YYABORTgoto yyabort goto yyabort | |||
| 1230 | #define YYREJECTgoto yyabort goto yyabort | |||
| 1231 | #define YYACCEPTgoto yyaccept goto yyaccept | |||
| 1232 | #define YYERRORgoto yyerrlab goto yyerrlab | |||
| 1233 | int | |||
| 1234 | yyparse(void) | |||
| 1235 | { | |||
| 1236 | int yym, yyn, yystate; | |||
| 1237 | #if YYDEBUG0 | |||
| 1238 | const char *yys; | |||
| 1239 | ||||
| 1240 | if ((yys = getenv("YYDEBUG"))) | |||
| 1241 | { | |||
| 1242 | yyn = *yys; | |||
| 1243 | if (yyn >= '0' && yyn <= '9') | |||
| 1244 | yydebug = yyn - '0'; | |||
| 1245 | } | |||
| 1246 | #endif /* YYDEBUG */ | |||
| 1247 | ||||
| 1248 | yynerrs = 0; | |||
| 1249 | yyerrflag = 0; | |||
| 1250 | yychar = (-1); | |||
| 1251 | ||||
| 1252 | if (yyss == NULL((void*)0) && yygrowstack()) goto yyoverflow; | |||
| ||||
| 1253 | yyssp = yyss; | |||
| 1254 | yyvsp = yyvs; | |||
| 1255 | *yyssp = yystate = 0; | |||
| 1256 | ||||
| 1257 | yyloop: | |||
| 1258 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | |||
| 1259 | if (yychar < 0) | |||
| 1260 | { | |||
| 1261 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 1262 | #if YYDEBUG0 | |||
| 1263 | if (yydebug) | |||
| 1264 | { | |||
| 1265 | yys = 0; | |||
| 1266 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 1267 | if (!yys) yys = "illegal-symbol"; | |||
| 1268 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 1269 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1270 | } | |||
| 1271 | #endif | |||
| 1272 | } | |||
| 1273 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 1274 | yyn <= YYTABLESIZE309 && yycheck[yyn] == yychar) | |||
| 1275 | { | |||
| 1276 | #if YYDEBUG0 | |||
| 1277 | if (yydebug) | |||
| 1278 | printf("%sdebug: state %d, shifting to state %d\n", | |||
| 1279 | YYPREFIX"yy", yystate, yytable[yyn]); | |||
| 1280 | #endif | |||
| 1281 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1282 | { | |||
| 1283 | goto yyoverflow; | |||
| 1284 | } | |||
| 1285 | *++yyssp = yystate = yytable[yyn]; | |||
| 1286 | *++yyvsp = yylval; | |||
| 1287 | yychar = (-1); | |||
| 1288 | if (yyerrflag > 0) --yyerrflag; | |||
| 1289 | goto yyloop; | |||
| 1290 | } | |||
| 1291 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 1292 | yyn <= YYTABLESIZE309 && yycheck[yyn] == yychar) | |||
| 1293 | { | |||
| 1294 | yyn = yytable[yyn]; | |||
| 1295 | goto yyreduce; | |||
| 1296 | } | |||
| 1297 | if (yyerrflag) goto yyinrecovery; | |||
| 1298 | #if defined(__GNUC__4) | |||
| 1299 | goto yynewerror; | |||
| 1300 | #endif | |||
| 1301 | yynewerror: | |||
| 1302 | yyerror("syntax error"); | |||
| 1303 | #if defined(__GNUC__4) | |||
| 1304 | goto yyerrlab; | |||
| 1305 | #endif | |||
| 1306 | yyerrlab: | |||
| 1307 | ++yynerrs; | |||
| 1308 | yyinrecovery: | |||
| 1309 | if (yyerrflag < 3) | |||
| 1310 | { | |||
| 1311 | yyerrflag = 3; | |||
| 1312 | for (;;) | |||
| 1313 | { | |||
| 1314 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | |||
| 1315 | yyn <= YYTABLESIZE309 && yycheck[yyn] == YYERRCODE256) | |||
| 1316 | { | |||
| 1317 | #if YYDEBUG0 | |||
| 1318 | if (yydebug) | |||
| 1319 | printf("%sdebug: state %d, error recovery shifting\ | |||
| 1320 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | |||
| 1321 | #endif | |||
| 1322 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1323 | { | |||
| 1324 | goto yyoverflow; | |||
| 1325 | } | |||
| 1326 | *++yyssp = yystate = yytable[yyn]; | |||
| 1327 | *++yyvsp = yylval; | |||
| 1328 | goto yyloop; | |||
| 1329 | } | |||
| 1330 | else | |||
| 1331 | { | |||
| 1332 | #if YYDEBUG0 | |||
| 1333 | if (yydebug) | |||
| 1334 | printf("%sdebug: error recovery discarding state %d\n", | |||
| 1335 | YYPREFIX"yy", *yyssp); | |||
| 1336 | #endif | |||
| 1337 | if (yyssp <= yyss) goto yyabort; | |||
| 1338 | --yyssp; | |||
| 1339 | --yyvsp; | |||
| 1340 | } | |||
| 1341 | } | |||
| 1342 | } | |||
| 1343 | else | |||
| 1344 | { | |||
| 1345 | if (yychar == 0) goto yyabort; | |||
| 1346 | #if YYDEBUG0 | |||
| 1347 | if (yydebug) | |||
| 1348 | { | |||
| 1349 | yys = 0; | |||
| 1350 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 1351 | if (!yys) yys = "illegal-symbol"; | |||
| 1352 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | |||
| 1353 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1354 | } | |||
| 1355 | #endif | |||
| 1356 | yychar = (-1); | |||
| 1357 | goto yyloop; | |||
| 1358 | } | |||
| 1359 | yyreduce: | |||
| 1360 | #if YYDEBUG0 | |||
| 1361 | if (yydebug) | |||
| 1362 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | |||
| 1363 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | |||
| 1364 | #endif | |||
| 1365 | yym = yylen[yyn]; | |||
| 1366 | if (yym) | |||
| 1367 | yyval = yyvsp[1-yym]; | |||
| 1368 | else | |||
| 1369 | memset(&yyval, 0, sizeof yyval); | |||
| 1370 | switch (yyn) | |||
| 1371 | { | |||
| 1372 | case 7: | |||
| 1373 | #line 159 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1374 | { file->errors++; } | |||
| 1375 | break; | |||
| 1376 | case 8: | |||
| 1377 | #line 162 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1378 | { | |||
| 1379 | struct file *nfile; | |||
| 1380 | ||||
| 1381 | if ((nfile = pushfile(yyvsp[0].v.string, | |||
| 1382 | !(conf->opts & OSPFD_OPT_NOACTION0x00000004))) == NULL((void*)0)) { | |||
| 1383 | yyerror("failed to include file %s", yyvsp[0].v.string); | |||
| 1384 | free(yyvsp[0].v.string); | |||
| 1385 | YYERRORgoto yyerrlab; | |||
| 1386 | } | |||
| 1387 | free(yyvsp[0].v.string); | |||
| 1388 | ||||
| 1389 | file = nfile; | |||
| 1390 | lungetc('\n'); | |||
| 1391 | } | |||
| 1392 | break; | |||
| 1393 | case 9: | |||
| 1394 | #line 178 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1395 | { | |||
| 1396 | if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1) { | |||
| 1397 | free(yyvsp[-1].v.string); | |||
| 1398 | free(yyvsp[0].v.string); | |||
| 1399 | yyerror("string: asprintf"); | |||
| 1400 | YYERRORgoto yyerrlab; | |||
| 1401 | } | |||
| 1402 | free(yyvsp[-1].v.string); | |||
| 1403 | free(yyvsp[0].v.string); | |||
| 1404 | } | |||
| 1405 | break; | |||
| 1406 | case 11: | |||
| 1407 | #line 191 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1408 | { yyval.v.number = 1; } | |||
| 1409 | break; | |||
| 1410 | case 12: | |||
| 1411 | #line 192 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1412 | { yyval.v.number = 0; } | |||
| 1413 | break; | |||
| 1414 | case 13: | |||
| 1415 | #line 195 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1416 | { yyval.v.number = 0; } | |||
| 1417 | break; | |||
| 1418 | case 14: | |||
| 1419 | #line 196 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1420 | { yyval.v.number = 1; } | |||
| 1421 | break; | |||
| 1422 | case 15: | |||
| 1423 | #line 199 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1424 | { | |||
| 1425 | yyval.v.number = yyvsp[0].v.number; | |||
| 1426 | } | |||
| 1427 | break; | |||
| 1428 | case 16: | |||
| 1429 | #line 202 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1430 | { | |||
| 1431 | yyval.v.number = yyvsp[0].v.number * 1000; | |||
| 1432 | } | |||
| 1433 | break; | |||
| 1434 | case 17: | |||
| 1435 | #line 207 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1436 | { | |||
| 1437 | char *s = yyvsp[-2].v.string; | |||
| 1438 | if (conf->opts & OSPFD_OPT_VERBOSE0x00000001) | |||
| 1439 | printf("%s = \"%s\"\n", yyvsp[-2].v.string, yyvsp[0].v.string); | |||
| 1440 | while (*s++) { | |||
| 1441 | if (isspace((unsigned char)*s)) { | |||
| 1442 | yyerror("macro name cannot contain " | |||
| 1443 | "whitespace"); | |||
| 1444 | free(yyvsp[-2].v.string); | |||
| 1445 | free(yyvsp[0].v.string); | |||
| 1446 | YYERRORgoto yyerrlab; | |||
| 1447 | } | |||
| 1448 | } | |||
| 1449 | if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1) | |||
| 1450 | fatal("cannot store variable"); | |||
| 1451 | free(yyvsp[-2].v.string); | |||
| 1452 | free(yyvsp[0].v.string); | |||
| 1453 | } | |||
| 1454 | break; | |||
| 1455 | case 18: | |||
| 1456 | #line 227 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1457 | { | |||
| 1458 | if (!inet_aton(yyvsp[0].v.string, &conf->rtr_id)) { | |||
| 1459 | yyerror("error parsing router-id"); | |||
| 1460 | free(yyvsp[0].v.string); | |||
| 1461 | YYERRORgoto yyerrlab; | |||
| 1462 | } | |||
| 1463 | free(yyvsp[0].v.string); | |||
| 1464 | } | |||
| 1465 | break; | |||
| 1466 | case 19: | |||
| 1467 | #line 235 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1468 | { | |||
| 1469 | if (yyvsp[0].v.number <= RTP_NONE0 || yyvsp[0].v.number > RTP_MAX63) { | |||
| 1470 | yyerror("invalid fib-priority"); | |||
| 1471 | YYERRORgoto yyerrlab; | |||
| 1472 | } | |||
| 1473 | conf->fib_priority = yyvsp[0].v.number; | |||
| 1474 | } | |||
| 1475 | break; | |||
| 1476 | case 20: | |||
| 1477 | #line 242 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1478 | { | |||
| 1479 | if (yyvsp[0].v.number == 0) | |||
| 1480 | conf->flags |= OSPFD_FLAG_NO_FIB_UPDATE0x0001; | |||
| 1481 | else | |||
| 1482 | conf->flags &= ~OSPFD_FLAG_NO_FIB_UPDATE0x0001; | |||
| 1483 | } | |||
| 1484 | break; | |||
| 1485 | case 21: | |||
| 1486 | #line 248 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1487 | { | |||
| 1488 | SIMPLEQ_INSERT_TAIL(&conf->redist_list, yyvsp[0].v.redist, entry)do { (yyvsp[0].v.redist)->entry.sqe_next = ((void*)0); *(& conf->redist_list)->sqh_last = (yyvsp[0].v.redist); (& conf->redist_list)->sqh_last = &(yyvsp[0].v.redist) ->entry.sqe_next; } while (0); | |||
| 1489 | conf->redistribute = 1; | |||
| 1490 | } | |||
| 1491 | break; | |||
| 1492 | case 22: | |||
| 1493 | #line 252 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1494 | { | |||
| 1495 | if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > UINT_MAX(2147483647 *2U +1U)) { | |||
| 1496 | yyerror("invalid external route tag"); | |||
| 1497 | free(yyvsp[-2].v.string); | |||
| 1498 | YYERRORgoto yyerrlab; | |||
| 1499 | } | |||
| 1500 | rtlabel_tag(rtlabel_name2id(yyvsp[-2].v.string), yyvsp[0].v.number); | |||
| 1501 | free(yyvsp[-2].v.string); | |||
| 1502 | } | |||
| 1503 | break; | |||
| 1504 | case 23: | |||
| 1505 | #line 261 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1506 | { | |||
| 1507 | if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > RT_TABLEID_MAX255) { | |||
| 1508 | yyerror("invalid rdomain"); | |||
| 1509 | YYERRORgoto yyerrlab; | |||
| 1510 | } | |||
| 1511 | conf->rdomain = yyvsp[0].v.number; | |||
| 1512 | } | |||
| 1513 | break; | |||
| 1514 | case 24: | |||
| 1515 | #line 268 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1516 | { | |||
| 1517 | conf->rfc1583compat = yyvsp[0].v.number; | |||
| 1518 | } | |||
| 1519 | break; | |||
| 1520 | case 25: | |||
| 1521 | #line 271 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1522 | { | |||
| 1523 | if (yyvsp[0].v.number < MIN_SPF_DELAY10 || yyvsp[0].v.number > MAX_SPF_DELAY10000) { | |||
| 1524 | yyerror("spf-delay out of range " | |||
| 1525 | "(%d-%d)", MIN_SPF_DELAY10, | |||
| 1526 | MAX_SPF_DELAY10000); | |||
| 1527 | YYERRORgoto yyerrlab; | |||
| 1528 | } | |||
| 1529 | conf->spf_delay = yyvsp[0].v.number; | |||
| 1530 | } | |||
| 1531 | break; | |||
| 1532 | case 26: | |||
| 1533 | #line 280 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1534 | { | |||
| 1535 | if (yyvsp[0].v.number < MIN_SPF_HOLDTIME10 || yyvsp[0].v.number > MAX_SPF_HOLDTIME5000) { | |||
| 1536 | yyerror("spf-holdtime out of range " | |||
| 1537 | "(%d-%d)", MIN_SPF_HOLDTIME10, | |||
| 1538 | MAX_SPF_HOLDTIME5000); | |||
| 1539 | YYERRORgoto yyerrlab; | |||
| 1540 | } | |||
| 1541 | conf->spf_hold_time = yyvsp[0].v.number; | |||
| 1542 | } | |||
| 1543 | break; | |||
| 1544 | case 27: | |||
| 1545 | #line 289 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1546 | { | |||
| 1547 | if (yyvsp[0].v.number) | |||
| 1548 | conf->flags |= OSPFD_FLAG_STUB_ROUTER0x0002; | |||
| 1549 | else | |||
| 1550 | /* allow to force non stub mode */ | |||
| 1551 | conf->flags &= ~OSPFD_FLAG_STUB_ROUTER0x0002; | |||
| 1552 | } | |||
| 1553 | break; | |||
| 1554 | case 29: | |||
| 1555 | #line 300 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1556 | { | |||
| 1557 | struct redistribute *r; | |||
| 1558 | ||||
| 1559 | if ((r = calloc(1, sizeof(*r))) == NULL((void*)0)) | |||
| 1560 | fatal(NULL((void*)0)); | |||
| 1561 | r->type = REDIST_ADDR0x08; | |||
| 1562 | if (yyvsp[-4].v.number < 0 || yyvsp[-4].v.number > 255 || yyvsp[-2].v.number < 1 || yyvsp[-2].v.number > 32) { | |||
| 1563 | yyerror("bad network: %llu/%llu", yyvsp[-4].v.number, yyvsp[-2].v.number); | |||
| 1564 | free(r); | |||
| 1565 | YYERRORgoto yyerrlab; | |||
| 1566 | } | |||
| 1567 | r->addr.s_addr = htonl(yyvsp[-4].v.number << IN_CLASSA_NSHIFT)(__uint32_t)(__builtin_constant_p(yyvsp[-4].v.number << 24) ? (__uint32_t)(((__uint32_t)(yyvsp[-4].v.number << 24) & 0xff) << 24 | ((__uint32_t)(yyvsp[-4].v.number << 24) & 0xff00) << 8 | ((__uint32_t)(yyvsp[ -4].v.number << 24) & 0xff0000) >> 8 | ((__uint32_t )(yyvsp[-4].v.number << 24) & 0xff000000) >> 24 ) : __swap32md(yyvsp[-4].v.number << 24)); | |||
| 1568 | r->mask.s_addr = prefixlen2mask(yyvsp[-2].v.number); | |||
| 1569 | ||||
| 1570 | if (yyvsp[-6].v.number) | |||
| 1571 | r->type |= REDIST_NO0x10; | |||
| 1572 | else | |||
| 1573 | conf->redist_label_or_prefix = 1; | |||
| 1574 | r->metric = yyvsp[-1].v.number; | |||
| 1575 | if (yyvsp[0].v.string) | |||
| 1576 | strlcpy(r->dependon, yyvsp[0].v.string, sizeof(r->dependon)); | |||
| 1577 | else | |||
| 1578 | r->dependon[0] = '\0'; | |||
| 1579 | free(yyvsp[0].v.string); | |||
| 1580 | yyval.v.redist = r; | |||
| 1581 | } | |||
| 1582 | break; | |||
| 1583 | case 30: | |||
| 1584 | #line 326 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1585 | { | |||
| 1586 | struct redistribute *r; | |||
| 1587 | ||||
| 1588 | if ((r = calloc(1, sizeof(*r))) == NULL((void*)0)) | |||
| 1589 | fatal(NULL((void*)0)); | |||
| 1590 | if (!strcmp(yyvsp[-2].v.string, "default")) | |||
| 1591 | r->type = REDIST_DEFAULT0x20; | |||
| 1592 | else if (!strcmp(yyvsp[-2].v.string, "static")) | |||
| 1593 | r->type = REDIST_STATIC0x02; | |||
| 1594 | else if (!strcmp(yyvsp[-2].v.string, "connected")) | |||
| 1595 | r->type = REDIST_CONNECTED0x01; | |||
| 1596 | else if (host(yyvsp[-2].v.string, &r->addr, &r->mask)) { | |||
| 1597 | r->type = REDIST_ADDR0x08; | |||
| 1598 | conf->redist_label_or_prefix = !yyvsp[-4].v.number; | |||
| 1599 | } else { | |||
| 1600 | yyerror("unknown redistribute type"); | |||
| 1601 | free(yyvsp[-2].v.string); | |||
| 1602 | free(r); | |||
| 1603 | YYERRORgoto yyerrlab; | |||
| 1604 | } | |||
| 1605 | ||||
| 1606 | if (yyvsp[-4].v.number) | |||
| 1607 | r->type |= REDIST_NO0x10; | |||
| 1608 | r->metric = yyvsp[-1].v.number; | |||
| 1609 | if (yyvsp[0].v.string) | |||
| 1610 | strlcpy(r->dependon, yyvsp[0].v.string, sizeof(r->dependon)); | |||
| 1611 | else | |||
| 1612 | r->dependon[0] = '\0'; | |||
| 1613 | free(yyvsp[-2].v.string); | |||
| 1614 | free(yyvsp[0].v.string); | |||
| 1615 | yyval.v.redist = r; | |||
| 1616 | } | |||
| 1617 | break; | |||
| 1618 | case 31: | |||
| 1619 | #line 358 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1620 | { | |||
| 1621 | struct redistribute *r; | |||
| 1622 | ||||
| 1623 | if ((r = calloc(1, sizeof(*r))) == NULL((void*)0)) | |||
| 1624 | fatal(NULL((void*)0)); | |||
| 1625 | r->type = REDIST_LABEL0x04; | |||
| 1626 | r->label = rtlabel_name2id(yyvsp[-2].v.string); | |||
| 1627 | if (yyvsp[-5].v.number) | |||
| 1628 | r->type |= REDIST_NO0x10; | |||
| 1629 | else | |||
| 1630 | conf->redist_label_or_prefix = 1; | |||
| 1631 | r->metric = yyvsp[-1].v.number; | |||
| 1632 | if (yyvsp[0].v.string) | |||
| 1633 | strlcpy(r->dependon, yyvsp[0].v.string, sizeof(r->dependon)); | |||
| 1634 | else | |||
| 1635 | r->dependon[0] = '\0'; | |||
| 1636 | free(yyvsp[-2].v.string); | |||
| 1637 | free(yyvsp[0].v.string); | |||
| 1638 | yyval.v.redist = r; | |||
| 1639 | } | |||
| 1640 | break; | |||
| 1641 | case 32: | |||
| 1642 | #line 380 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1643 | { yyval.v.number = DEFAULT_REDIST_METRIC100; } | |||
| 1644 | break; | |||
| 1645 | case 33: | |||
| 1646 | #line 381 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1647 | { | |||
| 1648 | yyval.v.number = yyvsp[0].v.number; | |||
| 1649 | if ((yyval.v.number & LSA_METRIC_MASK0x00ffffff) == 0) | |||
| 1650 | yyval.v.number |= DEFAULT_REDIST_METRIC100; | |||
| 1651 | } | |||
| 1652 | break; | |||
| 1653 | case 34: | |||
| 1654 | #line 386 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1655 | { | |||
| 1656 | yyval.v.number = yyvsp[-2].v.number; | |||
| 1657 | if ((yyval.v.number & LSA_METRIC_MASK0x00ffffff) == 0) | |||
| 1658 | yyval.v.number |= DEFAULT_REDIST_METRIC100; | |||
| 1659 | } | |||
| 1660 | break; | |||
| 1661 | case 35: | |||
| 1662 | #line 393 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1663 | { | |||
| 1664 | if (yyvsp[-2].v.number & LSA_ASEXT_E_FLAG0x80000000 && yyvsp[0].v.number & LSA_ASEXT_E_FLAG0x80000000) { | |||
| 1665 | yyerror("redistribute type already defined"); | |||
| 1666 | YYERRORgoto yyerrlab; | |||
| 1667 | } | |||
| 1668 | if (yyvsp[-2].v.number & LSA_METRIC_MASK0x00ffffff && yyvsp[0].v.number & LSA_METRIC_MASK0x00ffffff) { | |||
| 1669 | yyerror("redistribute metric already defined"); | |||
| 1670 | YYERRORgoto yyerrlab; | |||
| 1671 | } | |||
| 1672 | yyval.v.number = yyvsp[-2].v.number | yyvsp[0].v.number; | |||
| 1673 | } | |||
| 1674 | break; | |||
| 1675 | case 36: | |||
| 1676 | #line 404 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1677 | { yyval.v.number = yyvsp[0].v.number; } | |||
| 1678 | break; | |||
| 1679 | case 37: | |||
| 1680 | #line 407 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1681 | { | |||
| 1682 | if (yyvsp[0].v.number == 0 || yyvsp[0].v.number > MAX_METRIC65535) { | |||
| 1683 | yyerror("invalid redistribute metric"); | |||
| 1684 | YYERRORgoto yyerrlab; | |||
| 1685 | } | |||
| 1686 | yyval.v.number = yyvsp[0].v.number; | |||
| 1687 | } | |||
| 1688 | break; | |||
| 1689 | case 38: | |||
| 1690 | #line 414 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1691 | { | |||
| 1692 | switch (yyvsp[0].v.number) { | |||
| 1693 | case 1: | |||
| 1694 | yyval.v.number = 0; | |||
| 1695 | break; | |||
| 1696 | case 2: | |||
| 1697 | yyval.v.number = LSA_ASEXT_E_FLAG0x80000000; | |||
| 1698 | break; | |||
| 1699 | default: | |||
| 1700 | yyerror("only external type 1 and 2 allowed"); | |||
| 1701 | YYERRORgoto yyerrlab; | |||
| 1702 | } | |||
| 1703 | } | |||
| 1704 | break; | |||
| 1705 | case 39: | |||
| 1706 | #line 429 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1707 | { yyval.v.string = NULL((void*)0); } | |||
| 1708 | break; | |||
| 1709 | case 41: | |||
| 1710 | #line 432 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1711 | { | |||
| 1712 | struct in_addr addr; | |||
| 1713 | struct kif *kif; | |||
| 1714 | ||||
| 1715 | if (strlen(yyvsp[0].v.string) >= IFNAMSIZ16) { | |||
| 1716 | yyerror("interface name %s too long", yyvsp[0].v.string); | |||
| 1717 | free(yyvsp[0].v.string); | |||
| 1718 | YYERRORgoto yyerrlab; | |||
| 1719 | } | |||
| 1720 | bzero(&addr, sizeof(addr)); | |||
| 1721 | if ((kif = kif_findname(yyvsp[0].v.string, addr, NULL((void*)0))) == NULL((void*)0)) { | |||
| 1722 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 1723 | free(yyvsp[0].v.string); | |||
| 1724 | YYERRORgoto yyerrlab; | |||
| 1725 | } | |||
| 1726 | yyval.v.string = yyvsp[0].v.string; | |||
| 1727 | } | |||
| 1728 | break; | |||
| 1729 | case 42: | |||
| 1730 | #line 451 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1731 | { | |||
| 1732 | if (yyvsp[-1].v.number < MIN_MD_ID0 || yyvsp[-1].v.number > MAX_MD_ID255) { | |||
| 1733 | yyerror("auth-md key-id out of range " | |||
| 1734 | "(%d-%d)", MIN_MD_ID0, MAX_MD_ID255); | |||
| 1735 | free(yyvsp[0].v.string); | |||
| 1736 | YYERRORgoto yyerrlab; | |||
| 1737 | } | |||
| 1738 | if (strlen(yyvsp[0].v.string) > MD5_DIGEST_LENGTH16) { | |||
| 1739 | yyerror("auth-md key length out of range " | |||
| 1740 | "(max length %d)", | |||
| 1741 | MD5_DIGEST_LENGTH16); | |||
| 1742 | free(yyvsp[0].v.string); | |||
| 1743 | YYERRORgoto yyerrlab; | |||
| 1744 | } | |||
| 1745 | md_list_add(&defs->md_list, yyvsp[-1].v.number, yyvsp[0].v.string); | |||
| 1746 | free(yyvsp[0].v.string); | |||
| 1747 | } | |||
| 1748 | break; | |||
| 1749 | case 43: | |||
| 1750 | #line 469 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1751 | { | |||
| 1752 | if (yyvsp[0].v.number < MIN_MD_ID0 || yyvsp[0].v.number > MAX_MD_ID255) { | |||
| 1753 | yyerror("auth-md-keyid out of range " | |||
| 1754 | "(%d-%d)", MIN_MD_ID0, MAX_MD_ID255); | |||
| 1755 | YYERRORgoto yyerrlab; | |||
| 1756 | } | |||
| 1757 | defs->auth_keyid = yyvsp[0].v.number; | |||
| 1758 | } | |||
| 1759 | break; | |||
| 1760 | case 44: | |||
| 1761 | #line 478 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1762 | { | |||
| 1763 | enum auth_type type; | |||
| 1764 | ||||
| 1765 | if (!strcmp(yyvsp[0].v.string, "none")) | |||
| 1766 | type = AUTH_NONE; | |||
| 1767 | else if (!strcmp(yyvsp[0].v.string, "simple")) | |||
| 1768 | type = AUTH_SIMPLE; | |||
| 1769 | else if (!strcmp(yyvsp[0].v.string, "crypt")) | |||
| 1770 | type = AUTH_CRYPT; | |||
| 1771 | else { | |||
| 1772 | yyerror("unknown auth-type"); | |||
| 1773 | free(yyvsp[0].v.string); | |||
| 1774 | YYERRORgoto yyerrlab; | |||
| 1775 | } | |||
| 1776 | free(yyvsp[0].v.string); | |||
| 1777 | defs->auth_type = type; | |||
| 1778 | } | |||
| 1779 | break; | |||
| 1780 | case 45: | |||
| 1781 | #line 497 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1782 | { | |||
| 1783 | if (strlen(yyvsp[0].v.string) > MAX_SIMPLE_AUTH_LEN8) { | |||
| 1784 | yyerror("auth-key too long (max length %d)", | |||
| 1785 | MAX_SIMPLE_AUTH_LEN8); | |||
| 1786 | free(yyvsp[0].v.string); | |||
| 1787 | YYERRORgoto yyerrlab; | |||
| 1788 | } | |||
| 1789 | strncpy(defs->auth_key, yyvsp[0].v.string, | |||
| 1790 | sizeof(defs->auth_key)); | |||
| 1791 | free(yyvsp[0].v.string); | |||
| 1792 | } | |||
| 1793 | break; | |||
| 1794 | case 46: | |||
| 1795 | #line 510 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1796 | { | |||
| 1797 | if (yyvsp[0].v.number < MIN_METRIC1 || yyvsp[0].v.number > MAX_METRIC65535) { | |||
| 1798 | yyerror("metric out of range (%d-%d)", | |||
| 1799 | MIN_METRIC1, MAX_METRIC65535); | |||
| 1800 | YYERRORgoto yyerrlab; | |||
| 1801 | } | |||
| 1802 | defs->metric = yyvsp[0].v.number; | |||
| 1803 | } | |||
| 1804 | break; | |||
| 1805 | case 47: | |||
| 1806 | #line 518 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1807 | { | |||
| 1808 | if (yyvsp[0].v.number < MIN_PRIORITY0 || yyvsp[0].v.number > MAX_PRIORITY255) { | |||
| 1809 | yyerror("router-priority out of range (%d-%d)", | |||
| 1810 | MIN_PRIORITY0, MAX_PRIORITY255); | |||
| 1811 | YYERRORgoto yyerrlab; | |||
| 1812 | } | |||
| 1813 | defs->priority = yyvsp[0].v.number; | |||
| 1814 | } | |||
| 1815 | break; | |||
| 1816 | case 48: | |||
| 1817 | #line 526 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1818 | { | |||
| 1819 | defs->dead_interval = yyvsp[0].v.number; | |||
| 1820 | } | |||
| 1821 | break; | |||
| 1822 | case 49: | |||
| 1823 | #line 529 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1824 | { | |||
| 1825 | if (yyvsp[0].v.number < MIN_TRANSMIT_DELAY1 || | |||
| 1826 | yyvsp[0].v.number > MAX_TRANSMIT_DELAY3600) { | |||
| 1827 | yyerror("transmit-delay out of range (%d-%d)", | |||
| 1828 | MIN_TRANSMIT_DELAY1, MAX_TRANSMIT_DELAY3600); | |||
| 1829 | YYERRORgoto yyerrlab; | |||
| 1830 | } | |||
| 1831 | defs->transmit_delay = yyvsp[0].v.number; | |||
| 1832 | } | |||
| 1833 | break; | |||
| 1834 | case 50: | |||
| 1835 | #line 538 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1836 | { | |||
| 1837 | if (yyvsp[0].v.number < MIN_HELLO_INTERVAL1 || | |||
| 1838 | yyvsp[0].v.number > MAX_HELLO_INTERVAL65535) { | |||
| 1839 | yyerror("hello-interval out of range (%d-%d)", | |||
| 1840 | MIN_HELLO_INTERVAL1, MAX_HELLO_INTERVAL65535); | |||
| 1841 | YYERRORgoto yyerrlab; | |||
| 1842 | } | |||
| 1843 | defs->hello_interval = yyvsp[0].v.number; | |||
| 1844 | } | |||
| 1845 | break; | |||
| 1846 | case 51: | |||
| 1847 | #line 547 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1848 | { | |||
| 1849 | if (yyvsp[0].v.number < MIN_FAST_INTERVAL50 || | |||
| 1850 | yyvsp[0].v.number > MAX_FAST_INTERVAL333) { | |||
| 1851 | yyerror("fast-hello-interval msec out of " | |||
| 1852 | "range (%d-%d)", MIN_FAST_INTERVAL50, | |||
| 1853 | MAX_FAST_INTERVAL333); | |||
| 1854 | YYERRORgoto yyerrlab; | |||
| 1855 | } | |||
| 1856 | defs->fast_hello_interval = yyvsp[0].v.number; | |||
| 1857 | } | |||
| 1858 | break; | |||
| 1859 | case 52: | |||
| 1860 | #line 557 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1861 | { | |||
| 1862 | if (yyvsp[0].v.number < MIN_RXMT_INTERVAL5 || yyvsp[0].v.number > MAX_RXMT_INTERVAL3600) { | |||
| 1863 | yyerror("retransmit-interval out of range " | |||
| 1864 | "(%d-%d)", MIN_RXMT_INTERVAL5, | |||
| 1865 | MAX_RXMT_INTERVAL3600); | |||
| 1866 | YYERRORgoto yyerrlab; | |||
| 1867 | } | |||
| 1868 | defs->rxmt_interval = yyvsp[0].v.number; | |||
| 1869 | } | |||
| 1870 | break; | |||
| 1871 | case 53: | |||
| 1872 | #line 566 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1873 | { | |||
| 1874 | defs->p2p = 1; | |||
| 1875 | } | |||
| 1876 | break; | |||
| 1877 | case 58: | |||
| 1878 | #line 575 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1879 | { | |||
| 1880 | if (yyvsp[0].v.number < MIN_RTR_DEAD_TIME2 || yyvsp[0].v.number > MAX_RTR_DEAD_TIME2147483647) { | |||
| 1881 | yyerror("router-dead-time out of range (%d-%d)", | |||
| 1882 | MIN_RTR_DEAD_TIME2, MAX_RTR_DEAD_TIME2147483647); | |||
| 1883 | YYERRORgoto yyerrlab; | |||
| 1884 | } | |||
| 1885 | yyval.v.number = yyvsp[0].v.number; | |||
| 1886 | } | |||
| 1887 | break; | |||
| 1888 | case 59: | |||
| 1889 | #line 583 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1890 | { | |||
| 1891 | yyval.v.number = FAST_RTR_DEAD_TIME1; | |||
| 1892 | } | |||
| 1893 | break; | |||
| 1894 | case 65: | |||
| 1895 | #line 598 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1896 | { | |||
| 1897 | area = conf_get_area(yyvsp[0].v.id); | |||
| 1898 | ||||
| 1899 | memcpy(&areadefs, defs, sizeof(areadefs)); | |||
| 1900 | md_list_copy(&areadefs.md_list, &defs->md_list); | |||
| 1901 | defs = &areadefs; | |||
| 1902 | } | |||
| 1903 | break; | |||
| 1904 | case 66: | |||
| 1905 | #line 604 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1906 | { | |||
| 1907 | area = NULL((void*)0); | |||
| 1908 | md_list_clr(&defs->md_list); | |||
| 1909 | defs = &globaldefs; | |||
| 1910 | } | |||
| 1911 | break; | |||
| 1912 | case 67: | |||
| 1913 | #line 611 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1914 | { yyval.v.number = yyvsp[0].v.number; } | |||
| 1915 | break; | |||
| 1916 | case 68: | |||
| 1917 | #line 612 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1918 | { yyval.v.number = 1; } | |||
| 1919 | break; | |||
| 1920 | case 69: | |||
| 1921 | #line 615 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1922 | { | |||
| 1923 | if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > 0xffffffff) { | |||
| 1924 | yyerror("invalid area id"); | |||
| 1925 | YYERRORgoto yyerrlab; | |||
| 1926 | } | |||
| 1927 | yyval.v.id.s_addr = htonl(yyvsp[0].v.number)(__uint32_t)(__builtin_constant_p(yyvsp[0].v.number) ? (__uint32_t )(((__uint32_t)(yyvsp[0].v.number) & 0xff) << 24 | ( (__uint32_t)(yyvsp[0].v.number) & 0xff00) << 8 | (( __uint32_t)(yyvsp[0].v.number) & 0xff0000) >> 8 | ( (__uint32_t)(yyvsp[0].v.number) & 0xff000000) >> 24 ) : __swap32md(yyvsp[0].v.number)); | |||
| 1928 | } | |||
| 1929 | break; | |||
| 1930 | case 70: | |||
| 1931 | #line 622 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1932 | { | |||
| 1933 | if (inet_aton(yyvsp[0].v.string, &yyval.v.id) == 0) { | |||
| 1934 | yyerror("error parsing area"); | |||
| 1935 | free(yyvsp[0].v.string); | |||
| 1936 | YYERRORgoto yyerrlab; | |||
| 1937 | } | |||
| 1938 | free(yyvsp[0].v.string); | |||
| 1939 | } | |||
| 1940 | break; | |||
| 1941 | case 74: | |||
| 1942 | #line 637 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1943 | { | |||
| 1944 | if (yyvsp[0].v.number < 1 || yyvsp[0].v.number > 255) { | |||
| 1945 | yyerror("demote count out of range (1-255)"); | |||
| 1946 | free(yyvsp[-1].v.string); | |||
| 1947 | YYERRORgoto yyerrlab; | |||
| 1948 | } | |||
| 1949 | area->demote_level = yyvsp[0].v.number; | |||
| 1950 | if (strlcpy(area->demote_group, yyvsp[-1].v.string, | |||
| 1951 | sizeof(area->demote_group)) >= | |||
| 1952 | sizeof(area->demote_group)) { | |||
| 1953 | yyerror("demote group name \"%s\" too long", | |||
| 1954 | yyvsp[-1].v.string); | |||
| 1955 | free(yyvsp[-1].v.string); | |||
| 1956 | YYERRORgoto yyerrlab; | |||
| 1957 | } | |||
| 1958 | free(yyvsp[-1].v.string); | |||
| 1959 | if (carp_demote_init(area->demote_group, | |||
| 1960 | conf->opts & OSPFD_OPT_FORCE_DEMOTE0x00000010) == -1) { | |||
| 1961 | yyerror("error initializing group \"%s\"", | |||
| 1962 | area->demote_group); | |||
| 1963 | YYERRORgoto yyerrlab; | |||
| 1964 | } | |||
| 1965 | } | |||
| 1966 | break; | |||
| 1967 | case 76: | |||
| 1968 | #line 661 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1969 | { area->stub = 1; } | |||
| 1970 | break; | |||
| 1971 | case 77: | |||
| 1972 | #line 662 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1973 | { | |||
| 1974 | area->stub = 1; | |||
| 1975 | if (yyvsp[0].v.redist->type != REDIST_DEFAULT0x20) { | |||
| 1976 | yyerror("bad redistribute option"); | |||
| 1977 | YYERRORgoto yyerrlab; | |||
| 1978 | } | |||
| 1979 | if (!SIMPLEQ_EMPTY(&area->redist_list)(((&area->redist_list)->sqh_first) == ((void*)0))) { | |||
| 1980 | yyerror("area redistribute option only " | |||
| 1981 | "allowed once"); | |||
| 1982 | YYERRORgoto yyerrlab; | |||
| 1983 | } | |||
| 1984 | SIMPLEQ_INSERT_TAIL(&area->redist_list, yyvsp[0].v.redist, entry)do { (yyvsp[0].v.redist)->entry.sqe_next = ((void*)0); *(& area->redist_list)->sqh_last = (yyvsp[0].v.redist); (& area->redist_list)->sqh_last = &(yyvsp[0].v.redist) ->entry.sqe_next; } while (0); | |||
| 1985 | } | |||
| 1986 | break; | |||
| 1987 | case 78: | |||
| 1988 | #line 677 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 1989 | { | |||
| 1990 | struct kif *kif; | |||
| 1991 | struct kif_addr *ka = NULL((void*)0); | |||
| 1992 | char *s; | |||
| 1993 | struct in_addr addr; | |||
| 1994 | ||||
| 1995 | s = strchr(yyvsp[0].v.string, ':'); | |||
| 1996 | if (s) { | |||
| 1997 | *s++ = '\0'; | |||
| 1998 | if (inet_aton(s, &addr) == 0) { | |||
| 1999 | yyerror( | |||
| 2000 | "error parsing interface address"); | |||
| 2001 | free(yyvsp[0].v.string); | |||
| 2002 | YYERRORgoto yyerrlab; | |||
| 2003 | } | |||
| 2004 | } else | |||
| 2005 | addr.s_addr = 0; | |||
| 2006 | ||||
| 2007 | if ((kif = kif_findname(yyvsp[0].v.string, addr, &ka)) == NULL((void*)0)) { | |||
| 2008 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 2009 | free(yyvsp[0].v.string); | |||
| 2010 | YYERRORgoto yyerrlab; | |||
| 2011 | } | |||
| 2012 | if (ka == NULL((void*)0)) { | |||
| 2013 | if (s) | |||
| 2014 | yyerror("address %s not configured on " | |||
| 2015 | "interface %s", s, yyvsp[0].v.string); | |||
| 2016 | else | |||
| 2017 | yyerror("unnumbered interface %s", yyvsp[0].v.string); | |||
| 2018 | free(yyvsp[0].v.string); | |||
| 2019 | YYERRORgoto yyerrlab; | |||
| 2020 | } | |||
| 2021 | free(yyvsp[0].v.string); | |||
| 2022 | iface = conf_get_if(kif, ka); | |||
| 2023 | if (iface == NULL((void*)0)) | |||
| 2024 | YYERRORgoto yyerrlab; | |||
| 2025 | iface->area = area; | |||
| 2026 | LIST_INSERT_HEAD(&area->iface_list, iface, entry)do { if (((iface)->entry.le_next = (&area->iface_list )->lh_first) != ((void*)0)) (&area->iface_list)-> lh_first->entry.le_prev = &(iface)->entry.le_next; ( &area->iface_list)->lh_first = (iface); (iface)-> entry.le_prev = &(&area->iface_list)->lh_first; } while (0); | |||
| 2027 | ||||
| 2028 | memcpy(&ifacedefs, defs, sizeof(ifacedefs)); | |||
| 2029 | md_list_copy(&ifacedefs.md_list, &defs->md_list); | |||
| 2030 | defs = &ifacedefs; | |||
| 2031 | } | |||
| 2032 | break; | |||
| 2033 | case 79: | |||
| 2034 | #line 719 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 2035 | { | |||
| 2036 | iface->dead_interval = defs->dead_interval; | |||
| 2037 | iface->fast_hello_interval = defs->fast_hello_interval; | |||
| 2038 | iface->transmit_delay = defs->transmit_delay; | |||
| 2039 | if (iface->dead_interval == FAST_RTR_DEAD_TIME1) | |||
| 2040 | iface->hello_interval = 0; | |||
| 2041 | else | |||
| 2042 | iface->hello_interval = defs->hello_interval; | |||
| 2043 | iface->rxmt_interval = defs->rxmt_interval; | |||
| 2044 | iface->metric = defs->metric; | |||
| 2045 | iface->priority = defs->priority; | |||
| 2046 | iface->auth_type = defs->auth_type; | |||
| 2047 | iface->auth_keyid = defs->auth_keyid; | |||
| 2048 | if (defs->p2p == 1) | |||
| 2049 | iface->type = IF_TYPE_POINTOPOINT; | |||
| 2050 | memcpy(iface->auth_key, defs->auth_key, | |||
| 2051 | sizeof(iface->auth_key)); | |||
| 2052 | md_list_copy(&iface->auth_md_list, &defs->md_list); | |||
| 2053 | md_list_clr(&defs->md_list); | |||
| 2054 | iface = NULL((void*)0); | |||
| 2055 | /* interface is always part of an area */ | |||
| 2056 | defs = &areadefs; | |||
| 2057 | } | |||
| 2058 | break; | |||
| 2059 | case 85: | |||
| 2060 | #line 753 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 2061 | { iface->passive = 1; } | |||
| 2062 | break; | |||
| 2063 | case 86: | |||
| 2064 | #line 754 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 2065 | { | |||
| 2066 | if (strlcpy(iface->demote_group, yyvsp[0].v.string, | |||
| 2067 | sizeof(iface->demote_group)) >= | |||
| 2068 | sizeof(iface->demote_group)) { | |||
| 2069 | yyerror("demote group name \"%s\" too long", | |||
| 2070 | yyvsp[0].v.string); | |||
| 2071 | free(yyvsp[0].v.string); | |||
| 2072 | YYERRORgoto yyerrlab; | |||
| 2073 | } | |||
| 2074 | free(yyvsp[0].v.string); | |||
| 2075 | if (carp_demote_init(iface->demote_group, | |||
| 2076 | conf->opts & OSPFD_OPT_FORCE_DEMOTE0x00000010) == -1) { | |||
| 2077 | yyerror("error initializing group \"%s\"", | |||
| 2078 | iface->demote_group); | |||
| 2079 | YYERRORgoto yyerrlab; | |||
| 2080 | } | |||
| 2081 | } | |||
| 2082 | break; | |||
| 2083 | case 87: | |||
| 2084 | #line 771 "/usr/src/usr.sbin/ospfd/parse.y" | |||
| 2085 | { | |||
| 2086 | struct in_addr addr; | |||
| 2087 | struct kif *kif; | |||
| 2088 | ||||
| 2089 | if (yyvsp[0].v.string) { | |||
| 2090 | strlcpy(iface->dependon, yyvsp[0].v.string, | |||
| 2091 | sizeof(iface->dependon)); | |||
| 2092 | bzero(&addr, sizeof(addr)); | |||
| 2093 | kif = kif_findname(yyvsp[0].v.string, addr, NULL((void*)0)); | |||
| 2094 | iface->depend_ok = ifstate_is_up(kif); | |||
| 2095 | } else { | |||
| 2096 | iface->dependon[0] = '\0'; | |||
| 2097 | iface->depend_ok = 1; | |||
| 2098 | } | |||
| 2099 | ||||
| 2100 | free(yyvsp[0].v.string); | |||
| 2101 | } | |||
| 2102 | break; | |||
| 2103 | #line 2096 "parse.c" | |||
| 2104 | } | |||
| 2105 | yyssp -= yym; | |||
| 2106 | yystate = *yyssp; | |||
| 2107 | yyvsp -= yym; | |||
| 2108 | yym = yylhs[yyn]; | |||
| 2109 | if (yystate == 0 && yym == 0) | |||
| 2110 | { | |||
| 2111 | #if YYDEBUG0 | |||
| 2112 | if (yydebug) | |||
| 2113 | printf("%sdebug: after reduction, shifting from state 0 to\ | |||
| 2114 | state %d\n", YYPREFIX"yy", YYFINAL1); | |||
| 2115 | #endif | |||
| 2116 | yystate = YYFINAL1; | |||
| 2117 | *++yyssp = YYFINAL1; | |||
| 2118 | *++yyvsp = yyval; | |||
| 2119 | if (yychar < 0) | |||
| 2120 | { | |||
| 2121 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 2122 | #if YYDEBUG0 | |||
| 2123 | if (yydebug) | |||
| 2124 | { | |||
| 2125 | yys = 0; | |||
| 2126 | if (yychar <= YYMAXTOKEN296) yys = yyname[yychar]; | |||
| 2127 | if (!yys) yys = "illegal-symbol"; | |||
| 2128 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 2129 | YYPREFIX"yy", YYFINAL1, yychar, yys); | |||
| 2130 | } | |||
| 2131 | #endif | |||
| 2132 | } | |||
| 2133 | if (yychar == 0) goto yyaccept; | |||
| 2134 | goto yyloop; | |||
| 2135 | } | |||
| 2136 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | |||
| 2137 | yyn <= YYTABLESIZE309 && yycheck[yyn] == yystate) | |||
| 2138 | yystate = yytable[yyn]; | |||
| 2139 | else | |||
| 2140 | yystate = yydgoto[yym]; | |||
| 2141 | #if YYDEBUG0 | |||
| 2142 | if (yydebug) | |||
| 2143 | printf("%sdebug: after reduction, shifting from state %d \ | |||
| 2144 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | |||
| 2145 | #endif | |||
| 2146 | if (yyssp >= yysslim && yygrowstack()) | |||
| 2147 | { | |||
| 2148 | goto yyoverflow; | |||
| 2149 | } | |||
| 2150 | *++yyssp = yystate; | |||
| 2151 | *++yyvsp = yyval; | |||
| 2152 | goto yyloop; | |||
| 2153 | yyoverflow: | |||
| 2154 | yyerror("yacc stack overflow"); | |||
| 2155 | yyabort: | |||
| 2156 | if (yyss) | |||
| 2157 | free(yyss); | |||
| 2158 | if (yyvs) | |||
| 2159 | free(yyvs); | |||
| 2160 | yyss = yyssp = NULL((void*)0); | |||
| 2161 | yyvs = yyvsp = NULL((void*)0); | |||
| 2162 | yystacksize = 0; | |||
| 2163 | return (1); | |||
| 2164 | yyaccept: | |||
| 2165 | if (yyss) | |||
| 2166 | free(yyss); | |||
| 2167 | if (yyvs) | |||
| 2168 | free(yyvs); | |||
| 2169 | yyss = yyssp = NULL((void*)0); | |||
| 2170 | yyvs = yyvsp = NULL((void*)0); | |||
| 2171 | yystacksize = 0; | |||
| 2172 | return (0); | |||
| 2173 | } |