| File: | src/usr.sbin/ripd/obj/parse.c |
| Warning: | line 912, 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 26 "/usr/src/usr.sbin/ripd/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 <limits.h> | |||
| 24 | #include <stdarg.h> | |||
| 25 | #include <stdio.h> | |||
| 26 | #include <string.h> | |||
| 27 | #include <syslog.h> | |||
| 28 | ||||
| 29 | #include "ripd.h" | |||
| 30 | #include "rip.h" | |||
| 31 | #include "ripe.h" | |||
| 32 | #include "log.h" | |||
| 33 | ||||
| 34 | TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last ; } files = TAILQ_HEAD_INITIALIZER(files){ ((void *)0), &(files).tqh_first }; | |||
| 35 | static struct file { | |||
| 36 | TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry; | |||
| 37 | FILE *stream; | |||
| 38 | char *name; | |||
| 39 | int lineno; | |||
| 40 | int errors; | |||
| 41 | } *file, *topfile; | |||
| 42 | struct file *pushfile(const char *, int); | |||
| 43 | int popfile(void); | |||
| 44 | int yyparse(void); | |||
| 45 | int yylex(void); | |||
| 46 | int yyerror(const char *, ...) | |||
| 47 | __attribute__((__format__ (printf, 1, 2))) | |||
| 48 | __attribute__((__nonnull__ (1))); | |||
| 49 | int kw_cmp(const void *, const void *); | |||
| 50 | int lookup(char *); | |||
| 51 | int lgetc(int); | |||
| 52 | int lungetc(int); | |||
| 53 | int findeol(void); | |||
| 54 | ||||
| 55 | TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last ; } symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void *)0), &(symhead).tqh_first }; | |||
| 56 | struct sym { | |||
| 57 | TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry; | |||
| 58 | int used; | |||
| 59 | int persist; | |||
| 60 | char *nam; | |||
| 61 | char *val; | |||
| 62 | }; | |||
| 63 | int symset(const char *, const char *, int); | |||
| 64 | char *symget(const char *); | |||
| 65 | ||||
| 66 | static struct { | |||
| 67 | u_int8_t auth_key[MAX_SIMPLE_AUTH_LEN16]; | |||
| 68 | struct auth_md_head md_list; | |||
| 69 | enum auth_type auth_type; | |||
| 70 | u_int8_t auth_keyid; | |||
| 71 | u_int8_t cost; | |||
| 72 | } *defs, globaldefs, ifacedefs; | |||
| 73 | ||||
| 74 | struct iface *iface = NULL((void *)0); | |||
| 75 | static struct ripd_conf *conf; | |||
| 76 | static int errors = 0; | |||
| 77 | ||||
| 78 | struct iface *conf_get_if(struct kif *); | |||
| 79 | void clear_config(struct ripd_conf *); | |||
| 80 | int check_file_secrecy(int, const char *); | |||
| 81 | u_int32_t get_rtr_id(void); | |||
| 82 | int host(const char *, struct in_addr *, struct in_addr *); | |||
| 83 | ||||
| 84 | typedef struct { | |||
| 85 | union { | |||
| 86 | int64_t number; | |||
| 87 | char *string; | |||
| 88 | } v; | |||
| 89 | int lineno; | |||
| 90 | } YYSTYPE; | |||
| 91 | ||||
| 92 | #line 93 "parse.c" | |||
| 93 | #define SPLIT_HORIZON257 257 | |||
| 94 | #define TRIGGERED_UPDATES258 258 | |||
| 95 | #define FIBPRIORITY259 259 | |||
| 96 | #define FIBUPDATE260 260 | |||
| 97 | #define REDISTRIBUTE261 261 | |||
| 98 | #define RDOMAIN262 262 | |||
| 99 | #define AUTHKEY263 263 | |||
| 100 | #define AUTHTYPE264 264 | |||
| 101 | #define AUTHMD265 265 | |||
| 102 | #define AUTHMDKEYID266 266 | |||
| 103 | #define INTERFACE267 267 | |||
| 104 | #define RTLABEL268 268 | |||
| 105 | #define COST269 269 | |||
| 106 | #define PASSIVE270 270 | |||
| 107 | #define YES271 271 | |||
| 108 | #define NO272 272 | |||
| 109 | #define DEMOTE273 273 | |||
| 110 | #define ERROR274 274 | |||
| 111 | #define STRING275 275 | |||
| 112 | #define NUMBER276 276 | |||
| 113 | #define YYERRCODE256 256 | |||
| 114 | const short yylhs[] = | |||
| 115 | { -1, | |||
| 116 | 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, | |||
| 117 | 2, 2, 5, 4, 4, 4, 4, 4, 4, 4, | |||
| 118 | 4, 8, 9, 10, 11, 7, 7, 7, 7, 7, | |||
| 119 | 12, 12, 13, 15, 6, 14, 14, 14, 16, 16, | |||
| 120 | 17, 17, 17, | |||
| 121 | }; | |||
| 122 | const short yylen[] = | |||
| 123 | { 2, | |||
| 124 | 0, 2, 3, 3, 3, 3, 2, 1, 1, 1, | |||
| 125 | 0, 1, 3, 2, 2, 2, 2, 2, 3, 4, | |||
| 126 | 1, 3, 2, 2, 2, 2, 1, 1, 1, 1, | |||
| 127 | 2, 0, 2, 0, 4, 0, 4, 3, 3, 2, | |||
| 128 | 1, 2, 1, | |||
| 129 | }; | |||
| 130 | const short yydefred[] = | |||
| 131 | { 1, | |||
| 132 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 133 | 0, 0, 0, 12, 0, 2, 0, 0, 0, 0, | |||
| 134 | 21, 30, 29, 27, 28, 6, 14, 9, 10, 15, | |||
| 135 | 17, 18, 16, 25, 24, 0, 23, 34, 26, 0, | |||
| 136 | 0, 3, 4, 5, 22, 0, 8, 0, 0, 19, | |||
| 137 | 0, 35, 7, 20, 0, 0, 31, 41, 0, 38, | |||
| 138 | 43, 0, 0, 42, 37, 0, 40, 0, 39, 33, | |||
| 139 | }; | |||
| 140 | const short yydgoto[] = | |||
| 141 | { 1, | |||
| 142 | 30, 17, 48, 18, 19, 20, 61, 22, 23, 24, | |||
| 143 | 25, 56, 69, 52, 46, 62, 63, | |||
| 144 | }; | |||
| 145 | const short yysindex[] = | |||
| 146 | { 0, | |||
| 147 | -10, -7, -268, -266, -267, -266, -263, -261, -259, -258, | |||
| 148 | -257, -255, -254, 0, -44, 0, -253, 11, 14, 15, | |||
| 149 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 150 | 0, 0, 0, 0, 0, -249, 0, 0, 0, -248, | |||
| 151 | -264, 0, 0, 0, 0, -95, 0, -246, -245, 0, | |||
| 152 | 21, 0, 0, 0, 21, -124, 0, 0, -243, 0, | |||
| 153 | 0, -113, 21, 0, 0, 23, 0, 21, 0, 0,}; | |||
| 154 | const short yyrindex[] = | |||
| 155 | { 0, | |||
| 156 | -227, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 157 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 158 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 159 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 160 | 0, 0, 0, 0, 0, 25, 0, 26, 0, 0, | |||
| 161 | -102, 0, 0, 0, -102, 0, 0, 0, 0, 0, | |||
| 162 | 0, 0, -102, 0, 0, 0, 0, -102, 0, 0,}; | |||
| 163 | const short yygindex[] = | |||
| 164 | { 0, | |||
| 165 | 31, 0, 0, 0, 0, 0, 37, 0, 0, 0, | |||
| 166 | 0, -53, 0, 0, 0, 0, -23, | |||
| 167 | }; | |||
| 168 | #define YYTABLESIZE265 265 | |||
| 169 | const short yytable[] = | |||
| 170 | { 16, | |||
| 171 | 60, 57, 26, 49, 28, 29, 27, 41, 31, 67, | |||
| 172 | 50, 65, 33, 34, 70, 35, 40, 36, 37, 38, | |||
| 173 | 42, 39, 32, 43, 44, 45, 47, 51, 53, 54, | |||
| 174 | 55, 64, 68, 11, 36, 13, 32, 21, 66, 0, | |||
| 175 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 176 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 177 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 178 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 180 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 181 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 182 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 183 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 184 | 0, 0, 0, 0, 0, 0, 0, 0, 8, 9, | |||
| 185 | 10, 11, 0, 0, 13, 58, 0, 0, 59, 8, | |||
| 186 | 9, 10, 11, 0, 0, 13, 58, 0, 0, 59, | |||
| 187 | 32, 32, 32, 32, 0, 0, 32, 32, 0, 0, | |||
| 188 | 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 189 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 190 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 191 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 192 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 193 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 194 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 195 | 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, | |||
| 196 | 0, 7, 8, 9, 10, 11, 12, 0, 13, 0, | |||
| 197 | 0, 14, 0, 0, 15, | |||
| 198 | }; | |||
| 199 | const short yycheck[] = | |||
| 200 | { 10, | |||
| 201 | 125, 55, 10, 268, 271, 272, 275, 261, 276, 63, | |||
| 202 | 275, 125, 276, 275, 68, 275, 61, 276, 276, 275, | |||
| 203 | 10, 276, 125, 10, 10, 275, 275, 123, 275, 275, | |||
| 204 | 10, 275, 10, 261, 10, 10, 6, 1, 62, -1, | |||
| 205 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 206 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 207 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 208 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 209 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 210 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 211 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 212 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 213 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 214 | -1, -1, -1, -1, -1, -1, -1, -1, 263, 264, | |||
| 215 | 265, 266, -1, -1, 269, 270, -1, -1, 273, 263, | |||
| 216 | 264, 265, 266, -1, -1, 269, 270, -1, -1, 273, | |||
| 217 | 263, 264, 265, 266, -1, -1, 269, 270, -1, -1, | |||
| 218 | 273, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 219 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 220 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 221 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 222 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 223 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 224 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 225 | -1, -1, -1, -1, -1, 256, 257, 258, 259, 260, | |||
| 226 | -1, 262, 263, 264, 265, 266, 267, -1, 269, -1, | |||
| 227 | -1, 272, -1, -1, 275, | |||
| 228 | }; | |||
| 229 | #define YYFINAL1 1 | |||
| 230 | #ifndef YYDEBUG0 | |||
| 231 | #define YYDEBUG0 0 | |||
| 232 | #endif | |||
| 233 | #define YYMAXTOKEN276 276 | |||
| 234 | #if YYDEBUG0 | |||
| 235 | const char * const yyname[] = | |||
| 236 | { | |||
| 237 | "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, | |||
| 238 | 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, | |||
| 239 | 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, | |||
| 240 | 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, | |||
| 241 | 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, | |||
| 242 | 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, | |||
| 243 | 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,"SPLIT_HORIZON", | |||
| 244 | "TRIGGERED_UPDATES","FIBPRIORITY","FIBUPDATE","REDISTRIBUTE","RDOMAIN", | |||
| 245 | "AUTHKEY","AUTHTYPE","AUTHMD","AUTHMDKEYID","INTERFACE","RTLABEL","COST", | |||
| 246 | "PASSIVE","YES","NO","DEMOTE","ERROR","STRING","NUMBER", | |||
| 247 | }; | |||
| 248 | const char * const yyrule[] = | |||
| 249 | {"$accept : grammar", | |||
| 250 | "grammar :", | |||
| 251 | "grammar : grammar '\\n'", | |||
| 252 | "grammar : grammar conf_main '\\n'", | |||
| 253 | "grammar : grammar varset '\\n'", | |||
| 254 | "grammar : grammar interface '\\n'", | |||
| 255 | "grammar : grammar error '\\n'", | |||
| 256 | "string : string STRING", | |||
| 257 | "string : STRING", | |||
| 258 | "yesno : YES", | |||
| 259 | "yesno : NO", | |||
| 260 | "no :", | |||
| 261 | "no : NO", | |||
| 262 | "varset : STRING '=' string", | |||
| 263 | "conf_main : SPLIT_HORIZON STRING", | |||
| 264 | "conf_main : TRIGGERED_UPDATES yesno", | |||
| 265 | "conf_main : RDOMAIN NUMBER", | |||
| 266 | "conf_main : FIBPRIORITY NUMBER", | |||
| 267 | "conf_main : FIBUPDATE yesno", | |||
| 268 | "conf_main : no REDISTRIBUTE STRING", | |||
| 269 | "conf_main : no REDISTRIBUTE RTLABEL STRING", | |||
| 270 | "conf_main : defaults", | |||
| 271 | "authmd : AUTHMD NUMBER STRING", | |||
| 272 | "authmdkeyid : AUTHMDKEYID NUMBER", | |||
| 273 | "authtype : AUTHTYPE STRING", | |||
| 274 | "authkey : AUTHKEY STRING", | |||
| 275 | "defaults : COST NUMBER", | |||
| 276 | "defaults : authtype", | |||
| 277 | "defaults : authkey", | |||
| 278 | "defaults : authmdkeyid", | |||
| 279 | "defaults : authmd", | |||
| 280 | "optnl : '\\n' optnl", | |||
| 281 | "optnl :", | |||
| 282 | "nl : '\\n' optnl", | |||
| 283 | "$$1 :", | |||
| 284 | "interface : INTERFACE STRING $$1 interface_block", | |||
| 285 | "interface_block :", | |||
| 286 | "interface_block : '{' optnl interfaceopts_l '}'", | |||
| 287 | "interface_block : '{' optnl '}'", | |||
| 288 | "interfaceopts_l : interfaceopts_l interfaceoptsl nl", | |||
| 289 | "interfaceopts_l : interfaceoptsl optnl", | |||
| 290 | "interfaceoptsl : PASSIVE", | |||
| 291 | "interfaceoptsl : DEMOTE STRING", | |||
| 292 | "interfaceoptsl : defaults", | |||
| 293 | }; | |||
| 294 | #endif | |||
| 295 | #ifdef YYSTACKSIZE10000 | |||
| 296 | #undef YYMAXDEPTH10000 | |||
| 297 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | |||
| 298 | #else | |||
| 299 | #ifdef YYMAXDEPTH10000 | |||
| 300 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | |||
| 301 | #else | |||
| 302 | #define YYSTACKSIZE10000 10000 | |||
| 303 | #define YYMAXDEPTH10000 10000 | |||
| 304 | #endif | |||
| 305 | #endif | |||
| 306 | #define YYINITSTACKSIZE200 200 | |||
| 307 | /* LINTUSED */ | |||
| 308 | int yydebug; | |||
| 309 | int yynerrs; | |||
| 310 | int yyerrflag; | |||
| 311 | int yychar; | |||
| 312 | short *yyssp; | |||
| 313 | YYSTYPE *yyvsp; | |||
| 314 | YYSTYPE yyval; | |||
| 315 | YYSTYPE yylval; | |||
| 316 | short *yyss; | |||
| 317 | short *yysslim; | |||
| 318 | YYSTYPE *yyvs; | |||
| 319 | unsigned int yystacksize; | |||
| 320 | int yyparse(void); | |||
| 321 | #line 395 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 322 | ||||
| 323 | struct keywords { | |||
| 324 | const char *k_name; | |||
| 325 | int k_val; | |||
| 326 | }; | |||
| 327 | ||||
| 328 | int | |||
| 329 | yyerror(const char *fmt, ...) | |||
| 330 | { | |||
| 331 | va_list ap; | |||
| 332 | char *msg; | |||
| 333 | ||||
| 334 | file->errors++; | |||
| 335 | va_start(ap, fmt)__builtin_va_start(ap, fmt); | |||
| 336 | if (vasprintf(&msg, fmt, ap) == -1) | |||
| 337 | fatalx("yyerror vasprintf"); | |||
| 338 | va_end(ap)__builtin_va_end(ap); | |||
| 339 | logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg); | |||
| 340 | free(msg); | |||
| 341 | return (0); | |||
| 342 | } | |||
| 343 | ||||
| 344 | int | |||
| 345 | kw_cmp(const void *k, const void *e) | |||
| 346 | { | |||
| 347 | return (strcmp(k, ((const struct keywords *)e)->k_name)); | |||
| 348 | } | |||
| 349 | ||||
| 350 | int | |||
| 351 | lookup(char *s) | |||
| 352 | { | |||
| 353 | /* this has to be sorted always */ | |||
| 354 | static const struct keywords keywords[] = { | |||
| 355 | {"auth-key", AUTHKEY263}, | |||
| 356 | {"auth-md", AUTHMD265}, | |||
| 357 | {"auth-md-keyid", AUTHMDKEYID266}, | |||
| 358 | {"auth-type", AUTHTYPE264}, | |||
| 359 | {"cost", COST269}, | |||
| 360 | {"demote", DEMOTE273}, | |||
| 361 | {"fib-priority", FIBPRIORITY259}, | |||
| 362 | {"fib-update", FIBUPDATE260}, | |||
| 363 | {"interface", INTERFACE267}, | |||
| 364 | {"no", NO272}, | |||
| 365 | {"passive", PASSIVE270}, | |||
| 366 | {"rdomain", RDOMAIN262}, | |||
| 367 | {"redistribute", REDISTRIBUTE261}, | |||
| 368 | {"rtlabel", RTLABEL268}, | |||
| 369 | {"split-horizon", SPLIT_HORIZON257}, | |||
| 370 | {"triggered-updates", TRIGGERED_UPDATES258}, | |||
| 371 | {"yes", YES271} | |||
| 372 | }; | |||
| 373 | const struct keywords *p; | |||
| 374 | ||||
| 375 | p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]), | |||
| 376 | sizeof(keywords[0]), kw_cmp); | |||
| 377 | ||||
| 378 | if (p) | |||
| 379 | return (p->k_val); | |||
| 380 | else | |||
| 381 | return (STRING275); | |||
| 382 | } | |||
| 383 | ||||
| 384 | #define MAXPUSHBACK128 128 | |||
| 385 | ||||
| 386 | char *parsebuf; | |||
| 387 | int parseindex; | |||
| 388 | char pushback_buffer[MAXPUSHBACK128]; | |||
| 389 | int pushback_index = 0; | |||
| 390 | ||||
| 391 | int | |||
| 392 | lgetc(int quotec) | |||
| 393 | { | |||
| 394 | int c, next; | |||
| 395 | ||||
| 396 | if (parsebuf) { | |||
| 397 | /* Read character from the parsebuffer instead of input. */ | |||
| 398 | if (parseindex >= 0) { | |||
| 399 | c = (unsigned char)parsebuf[parseindex++]; | |||
| 400 | if (c != '\0') | |||
| 401 | return (c); | |||
| 402 | parsebuf = NULL((void *)0); | |||
| 403 | } else | |||
| 404 | parseindex++; | |||
| 405 | } | |||
| 406 | ||||
| 407 | if (pushback_index) | |||
| 408 | return ((unsigned char)pushback_buffer[--pushback_index]); | |||
| 409 | ||||
| 410 | if (quotec) { | |||
| 411 | if ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream))) == EOF(-1)) { | |||
| 412 | yyerror("reached end of file while parsing " | |||
| 413 | "quoted string"); | |||
| 414 | if (file == topfile || popfile() == EOF(-1)) | |||
| 415 | return (EOF(-1)); | |||
| 416 | return (quotec); | |||
| 417 | } | |||
| 418 | return (c); | |||
| 419 | } | |||
| 420 | ||||
| 421 | while ((c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream))) == '\\') { | |||
| 422 | next = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
| 423 | if (next != '\n') { | |||
| 424 | c = next; | |||
| 425 | break; | |||
| 426 | } | |||
| 427 | yylval.lineno = file->lineno; | |||
| 428 | file->lineno++; | |||
| 429 | } | |||
| 430 | ||||
| 431 | while (c == EOF(-1)) { | |||
| 432 | if (file == topfile || popfile() == EOF(-1)) | |||
| 433 | return (EOF(-1)); | |||
| 434 | c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
| 435 | } | |||
| 436 | return (c); | |||
| 437 | } | |||
| 438 | ||||
| 439 | int | |||
| 440 | lungetc(int c) | |||
| 441 | { | |||
| 442 | if (c == EOF(-1)) | |||
| 443 | return (EOF(-1)); | |||
| 444 | if (parsebuf) { | |||
| 445 | parseindex--; | |||
| 446 | if (parseindex >= 0) | |||
| 447 | return (c); | |||
| 448 | } | |||
| 449 | if (pushback_index + 1 >= MAXPUSHBACK128) | |||
| 450 | return (EOF(-1)); | |||
| 451 | pushback_buffer[pushback_index++] = c; | |||
| 452 | return (c); | |||
| 453 | } | |||
| 454 | ||||
| 455 | int | |||
| 456 | findeol(void) | |||
| 457 | { | |||
| 458 | int c; | |||
| 459 | ||||
| 460 | parsebuf = NULL((void *)0); | |||
| 461 | ||||
| 462 | /* skip to either EOF or the first real EOL */ | |||
| 463 | while (1) { | |||
| 464 | if (pushback_index) | |||
| 465 | c = (unsigned char)pushback_buffer[--pushback_index]; | |||
| 466 | else | |||
| 467 | c = lgetc(0); | |||
| 468 | if (c == '\n') { | |||
| 469 | file->lineno++; | |||
| 470 | break; | |||
| 471 | } | |||
| 472 | if (c == EOF(-1)) | |||
| 473 | break; | |||
| 474 | } | |||
| 475 | return (ERROR274); | |||
| 476 | } | |||
| 477 | ||||
| 478 | int | |||
| 479 | yylex(void) | |||
| 480 | { | |||
| 481 | char buf[8096]; | |||
| 482 | char *p, *val; | |||
| 483 | int quotec, next, c; | |||
| 484 | int token; | |||
| 485 | ||||
| 486 | top: | |||
| 487 | p = buf; | |||
| 488 | while ((c = lgetc(0)) == ' ' || c == '\t') | |||
| 489 | ; /* nothing */ | |||
| 490 | ||||
| 491 | yylval.lineno = file->lineno; | |||
| 492 | if (c == '#') | |||
| 493 | while ((c = lgetc(0)) != '\n' && c != EOF(-1)) | |||
| 494 | ; /* nothing */ | |||
| 495 | if (c == '$' && parsebuf == NULL((void *)0)) { | |||
| 496 | while (1) { | |||
| 497 | if ((c = lgetc(0)) == EOF(-1)) | |||
| 498 | return (0); | |||
| 499 | ||||
| 500 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 501 | yyerror("string too long"); | |||
| 502 | return (findeol()); | |||
| 503 | } | |||
| 504 | if (isalnum(c) || c == '_') { | |||
| 505 | *p++ = c; | |||
| 506 | continue; | |||
| 507 | } | |||
| 508 | *p = '\0'; | |||
| 509 | lungetc(c); | |||
| 510 | break; | |||
| 511 | } | |||
| 512 | val = symget(buf); | |||
| 513 | if (val == NULL((void *)0)) { | |||
| 514 | yyerror("macro '%s' not defined", buf); | |||
| 515 | return (findeol()); | |||
| 516 | } | |||
| 517 | parsebuf = val; | |||
| 518 | parseindex = 0; | |||
| 519 | goto top; | |||
| 520 | } | |||
| 521 | ||||
| 522 | switch (c) { | |||
| 523 | case '\'': | |||
| 524 | case '"': | |||
| 525 | quotec = c; | |||
| 526 | while (1) { | |||
| 527 | if ((c = lgetc(quotec)) == EOF(-1)) | |||
| 528 | return (0); | |||
| 529 | if (c == '\n') { | |||
| 530 | file->lineno++; | |||
| 531 | continue; | |||
| 532 | } else if (c == '\\') { | |||
| 533 | if ((next = lgetc(quotec)) == EOF(-1)) | |||
| 534 | return (0); | |||
| 535 | if (next == quotec || next == ' ' || | |||
| 536 | next == '\t') | |||
| 537 | c = next; | |||
| 538 | else if (next == '\n') { | |||
| 539 | file->lineno++; | |||
| 540 | continue; | |||
| 541 | } else | |||
| 542 | lungetc(next); | |||
| 543 | } else if (c == quotec) { | |||
| 544 | *p = '\0'; | |||
| 545 | break; | |||
| 546 | } else if (c == '\0') { | |||
| 547 | yyerror("syntax error"); | |||
| 548 | return (findeol()); | |||
| 549 | } | |||
| 550 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 551 | yyerror("string too long"); | |||
| 552 | return (findeol()); | |||
| 553 | } | |||
| 554 | *p++ = c; | |||
| 555 | } | |||
| 556 | yylval.v.string = strdup(buf); | |||
| 557 | if (yylval.v.string == NULL((void *)0)) | |||
| 558 | err(1, "%s", __func__); | |||
| 559 | return (STRING275); | |||
| 560 | } | |||
| 561 | ||||
| 562 | #define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') \ | |||
| 563 | (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') | |||
| 564 | ||||
| 565 | if (c == '-' || isdigit(c)) { | |||
| 566 | do { | |||
| 567 | *p++ = c; | |||
| 568 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 569 | yyerror("string too long"); | |||
| 570 | return (findeol()); | |||
| 571 | } | |||
| 572 | } while ((c = lgetc(0)) != EOF(-1) && isdigit(c)); | |||
| 573 | lungetc(c); | |||
| 574 | if (p == buf + 1 && buf[0] == '-') | |||
| 575 | goto nodigits; | |||
| 576 | if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' || c == '=')) { | |||
| 577 | const char *errstr = NULL((void *)0); | |||
| 578 | ||||
| 579 | *p = '\0'; | |||
| 580 | yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL), | |||
| 581 | LLONG_MAX9223372036854775807LL, &errstr); | |||
| 582 | if (errstr) { | |||
| 583 | yyerror("\"%s\" invalid number: %s", | |||
| 584 | buf, errstr); | |||
| 585 | return (findeol()); | |||
| 586 | } | |||
| 587 | return (NUMBER276); | |||
| 588 | } else { | |||
| 589 | nodigits: | |||
| 590 | while (p > buf + 1) | |||
| 591 | lungetc((unsigned char)*--p); | |||
| 592 | c = (unsigned char)*--p; | |||
| 593 | if (c == '-') | |||
| 594 | return (c); | |||
| 595 | } | |||
| 596 | } | |||
| 597 | ||||
| 598 | #define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && x != '{' && x != '}' && x != '!' && x != '=' && x != '#' && x != ',') ) \ | |||
| 599 | (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \ | |||
| 600 | x != '{' && x != '}' && \ | |||
| 601 | x != '!' && x != '=' && x != '#' && \ | |||
| 602 | x != ',')) | |||
| 603 | ||||
| 604 | if (isalnum(c) || c == ':' || c == '_') { | |||
| 605 | do { | |||
| 606 | *p++ = c; | |||
| 607 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 608 | yyerror("string too long"); | |||
| 609 | return (findeol()); | |||
| 610 | } | |||
| 611 | } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c != ')' && c != '{' && c != '}' && c != '!' && c != '=' && c != '#' && c != ',') ))); | |||
| 612 | lungetc(c); | |||
| 613 | *p = '\0'; | |||
| 614 | if ((token = lookup(buf)) == STRING275) | |||
| 615 | if ((yylval.v.string = strdup(buf)) == NULL((void *)0)) | |||
| 616 | err(1, "%s", __func__); | |||
| 617 | return (token); | |||
| 618 | } | |||
| 619 | if (c == '\n') { | |||
| 620 | yylval.lineno = file->lineno; | |||
| 621 | file->lineno++; | |||
| 622 | } | |||
| 623 | if (c == EOF(-1)) | |||
| 624 | return (0); | |||
| 625 | return (c); | |||
| 626 | } | |||
| 627 | ||||
| 628 | int | |||
| 629 | check_file_secrecy(int fd, const char *fname) | |||
| 630 | { | |||
| 631 | struct stat st; | |||
| 632 | ||||
| 633 | if (fstat(fd, &st)) { | |||
| 634 | log_warn("cannot stat %s", fname); | |||
| 635 | return (-1); | |||
| 636 | } | |||
| 637 | if (st.st_uid != 0 && st.st_uid != getuid()) { | |||
| 638 | log_warnx("%s: owner not root or current user", fname); | |||
| 639 | return (-1); | |||
| 640 | } | |||
| 641 | if (st.st_mode & (S_IWGRP0000020 | S_IXGRP0000010 | S_IRWXO0000007)) { | |||
| 642 | log_warnx("%s: group writable or world read/writable", fname); | |||
| 643 | return (-1); | |||
| 644 | } | |||
| 645 | return (0); | |||
| 646 | } | |||
| 647 | ||||
| 648 | struct file * | |||
| 649 | pushfile(const char *name, int secret) | |||
| 650 | { | |||
| 651 | struct file *nfile; | |||
| 652 | ||||
| 653 | if ((nfile = calloc(1, sizeof(struct file))) == NULL((void *)0)) { | |||
| 654 | log_warn("%s", __func__); | |||
| 655 | return (NULL((void *)0)); | |||
| 656 | } | |||
| 657 | if ((nfile->name = strdup(name)) == NULL((void *)0)) { | |||
| 658 | log_warn("%s", __func__); | |||
| 659 | free(nfile); | |||
| 660 | return (NULL((void *)0)); | |||
| 661 | } | |||
| 662 | if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void *)0)) { | |||
| 663 | log_warn("%s: %s", __func__, nfile->name); | |||
| 664 | free(nfile->name); | |||
| 665 | free(nfile); | |||
| 666 | return (NULL((void *)0)); | |||
| 667 | } else if (secret && | |||
| 668 | check_file_secrecy(fileno(nfile->stream)(!__isthreaded ? ((nfile->stream)->_file) : (fileno)(nfile ->stream)), nfile->name)) { | |||
| 669 | fclose(nfile->stream); | |||
| 670 | free(nfile->name); | |||
| 671 | free(nfile); | |||
| 672 | return (NULL((void *)0)); | |||
| 673 | } | |||
| 674 | nfile->lineno = 1; | |||
| 675 | 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); | |||
| 676 | return (nfile); | |||
| 677 | } | |||
| 678 | ||||
| 679 | int | |||
| 680 | popfile(void) | |||
| 681 | { | |||
| 682 | struct file *prev; | |||
| 683 | ||||
| 684 | if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last ))) != NULL((void *)0)) | |||
| 685 | prev->errors += file->errors; | |||
| 686 | ||||
| 687 | 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); | |||
| 688 | fclose(file->stream); | |||
| 689 | free(file->name); | |||
| 690 | free(file); | |||
| 691 | file = prev; | |||
| 692 | return (file ? 0 : EOF(-1)); | |||
| 693 | } | |||
| 694 | ||||
| 695 | struct ripd_conf * | |||
| 696 | parse_config(char *filename, int opts) | |||
| 697 | { | |||
| 698 | struct sym *sym, *next; | |||
| 699 | ||||
| 700 | if ((conf = calloc(1, sizeof(struct ripd_conf))) == NULL((void *)0)) | |||
| 701 | fatal("parse_config"); | |||
| 702 | ||||
| 703 | bzero(&globaldefs, sizeof(globaldefs)); | |||
| 704 | defs = &globaldefs; | |||
| 705 | 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); | |||
| 706 | defs->cost = DEFAULT_COST1; | |||
| 707 | defs->auth_type = AUTH_NONE; | |||
| 708 | conf->opts = opts; | |||
| 709 | conf->options = OPT_SPLIT_POISONED0x02; | |||
| 710 | conf->fib_priority = RTP_RIP40; | |||
| 711 | 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); | |||
| 712 | ||||
| 713 | if ((file = pushfile(filename, !(conf->opts & RIPD_OPT_NOACTION0x00000004))) == NULL((void *)0)) { | |||
| 714 | free(conf); | |||
| 715 | return (NULL((void *)0)); | |||
| 716 | } | |||
| 717 | topfile = file; | |||
| 718 | ||||
| 719 | yyparse(); | |||
| 720 | errors = file->errors; | |||
| 721 | popfile(); | |||
| 722 | ||||
| 723 | /* Free macros and check which have not been used. */ | |||
| 724 | TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0) && ((next) = ((sym)->entry.tqe_next), 1); (sym ) = (next)) { | |||
| 725 | if ((conf->opts & RIPD_OPT_VERBOSE20x00000002) && !sym->used) | |||
| 726 | fprintf(stderr(&__sF[2]), "warning: macro '%s' not " | |||
| 727 | "used\n", sym->nam); | |||
| 728 | if (!sym->persist) { | |||
| 729 | free(sym->nam); | |||
| 730 | free(sym->val); | |||
| 731 | 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); | |||
| 732 | free(sym); | |||
| 733 | } | |||
| 734 | } | |||
| 735 | ||||
| 736 | /* free global config defaults */ | |||
| 737 | md_list_clr(&globaldefs.md_list); | |||
| 738 | ||||
| 739 | if (errors) { | |||
| 740 | clear_config(conf); | |||
| 741 | return (NULL((void *)0)); | |||
| 742 | } | |||
| 743 | ||||
| 744 | return (conf); | |||
| 745 | } | |||
| 746 | ||||
| 747 | int | |||
| 748 | symset(const char *nam, const char *val, int persist) | |||
| 749 | { | |||
| 750 | struct sym *sym; | |||
| 751 | ||||
| 752 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 753 | if (strcmp(nam, sym->nam) == 0) | |||
| 754 | break; | |||
| 755 | } | |||
| 756 | ||||
| 757 | if (sym != NULL((void *)0)) { | |||
| 758 | if (sym->persist == 1) | |||
| 759 | return (0); | |||
| 760 | else { | |||
| 761 | free(sym->nam); | |||
| 762 | free(sym->val); | |||
| 763 | 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); | |||
| 764 | free(sym); | |||
| 765 | } | |||
| 766 | } | |||
| 767 | if ((sym = calloc(1, sizeof(*sym))) == NULL((void *)0)) | |||
| 768 | return (-1); | |||
| 769 | ||||
| 770 | sym->nam = strdup(nam); | |||
| 771 | if (sym->nam == NULL((void *)0)) { | |||
| 772 | free(sym); | |||
| 773 | return (-1); | |||
| 774 | } | |||
| 775 | sym->val = strdup(val); | |||
| 776 | if (sym->val == NULL((void *)0)) { | |||
| 777 | free(sym->nam); | |||
| 778 | free(sym); | |||
| 779 | return (-1); | |||
| 780 | } | |||
| 781 | sym->used = 0; | |||
| 782 | sym->persist = persist; | |||
| 783 | 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); | |||
| 784 | return (0); | |||
| 785 | } | |||
| 786 | ||||
| 787 | int | |||
| 788 | cmdline_symset(char *s) | |||
| 789 | { | |||
| 790 | char *sym, *val; | |||
| 791 | int ret; | |||
| 792 | ||||
| 793 | if ((val = strrchr(s, '=')) == NULL((void *)0)) | |||
| 794 | return (-1); | |||
| 795 | sym = strndup(s, val - s); | |||
| 796 | if (sym == NULL((void *)0)) | |||
| 797 | errx(1, "%s: strndup", __func__); | |||
| 798 | ret = symset(sym, val + 1, 1); | |||
| 799 | free(sym); | |||
| 800 | ||||
| 801 | return (ret); | |||
| 802 | } | |||
| 803 | ||||
| 804 | char * | |||
| 805 | symget(const char *nam) | |||
| 806 | { | |||
| 807 | struct sym *sym; | |||
| 808 | ||||
| 809 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 810 | if (strcmp(nam, sym->nam) == 0) { | |||
| 811 | sym->used = 1; | |||
| 812 | return (sym->val); | |||
| 813 | } | |||
| 814 | } | |||
| 815 | return (NULL((void *)0)); | |||
| 816 | } | |||
| 817 | ||||
| 818 | struct iface * | |||
| 819 | conf_get_if(struct kif *kif) | |||
| 820 | { | |||
| 821 | struct iface *i; | |||
| 822 | ||||
| 823 | LIST_FOREACH(i, &conf->iface_list, entry)for((i) = ((&conf->iface_list)->lh_first); (i)!= (( void *)0); (i) = ((i)->entry.le_next)) | |||
| 824 | if (i->ifindex == kif->ifindex) { | |||
| 825 | yyerror("interface %s already configured", | |||
| 826 | kif->ifname); | |||
| 827 | return (NULL((void *)0)); | |||
| 828 | } | |||
| 829 | ||||
| 830 | i = if_new(kif); | |||
| 831 | i->auth_keyid = 1; | |||
| 832 | i->passive = 0; | |||
| 833 | ||||
| 834 | return (i); | |||
| 835 | } | |||
| 836 | ||||
| 837 | void | |||
| 838 | clear_config(struct ripd_conf *xconf) | |||
| 839 | { | |||
| 840 | struct iface *i; | |||
| 841 | ||||
| 842 | while ((i = LIST_FIRST(&conf->iface_list)((&conf->iface_list)->lh_first)) != NULL((void *)0)) { | |||
| 843 | LIST_REMOVE(i, entry)do { if ((i)->entry.le_next != ((void *)0)) (i)->entry. le_next->entry.le_prev = (i)->entry.le_prev; *(i)->entry .le_prev = (i)->entry.le_next; ; ; } while (0); | |||
| 844 | if_del(i); | |||
| 845 | } | |||
| 846 | ||||
| 847 | free(xconf); | |||
| 848 | } | |||
| 849 | ||||
| 850 | int | |||
| 851 | host(const char *s, struct in_addr *addr, struct in_addr *mask) | |||
| 852 | { | |||
| 853 | struct in_addr ina; | |||
| 854 | int bits = 32; | |||
| 855 | ||||
| 856 | bzero(&ina, sizeof(struct in_addr)); | |||
| 857 | if (strrchr(s, '/') != NULL((void *)0)) { | |||
| 858 | if ((bits = inet_net_pton(AF_INET2, s, &ina, sizeof(ina))) == -1) | |||
| 859 | return (0); | |||
| 860 | } else { | |||
| 861 | if (inet_pton(AF_INET2, s, &ina) != 1) | |||
| 862 | return (0); | |||
| 863 | } | |||
| 864 | ||||
| 865 | addr->s_addr = ina.s_addr; | |||
| 866 | mask->s_addr = prefixlen2mask(bits); | |||
| 867 | ||||
| 868 | return (1); | |||
| 869 | } | |||
| 870 | #line 863 "parse.c" | |||
| 871 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | |||
| 872 | static int yygrowstack(void) | |||
| 873 | { | |||
| 874 | unsigned int newsize; | |||
| 875 | long sslen; | |||
| 876 | short *newss; | |||
| 877 | YYSTYPE *newvs; | |||
| 878 | ||||
| 879 | if ((newsize = yystacksize) == 0) | |||
| 880 | newsize = YYINITSTACKSIZE200; | |||
| 881 | else if (newsize >= YYMAXDEPTH10000) | |||
| 882 | return -1; | |||
| 883 | else if ((newsize *= 2) > YYMAXDEPTH10000) | |||
| 884 | newsize = YYMAXDEPTH10000; | |||
| 885 | sslen = yyssp - yyss; | |||
| 886 | #ifdef SIZE_MAX0xffffffffffffffffUL | |||
| 887 | #define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL | |||
| 888 | #else | |||
| 889 | #define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU | |||
| 890 | #endif | |||
| 891 | if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss) | |||
| 892 | goto bail; | |||
| 893 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | |||
| 894 | if (newss == NULL((void *)0)) | |||
| 895 | goto bail; | |||
| 896 | yyss = newss; | |||
| 897 | yyssp = newss + sslen; | |||
| 898 | if (newsize
| |||
| 899 | goto bail; | |||
| 900 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | |||
| 901 | if (newvs == NULL((void *)0)) | |||
| 902 | goto bail; | |||
| 903 | yyvs = newvs; | |||
| 904 | yyvsp = newvs + sslen; | |||
| 905 | yystacksize = newsize; | |||
| 906 | yysslim = yyss + newsize - 1; | |||
| 907 | return 0; | |||
| 908 | bail: | |||
| 909 | if (yyss
| |||
| 910 | free(yyss); | |||
| 911 | if (yyvs) | |||
| 912 | free(yyvs); | |||
| ||||
| 913 | yyss = yyssp = NULL((void *)0); | |||
| 914 | yyvs = yyvsp = NULL((void *)0); | |||
| 915 | yystacksize = 0; | |||
| 916 | return -1; | |||
| 917 | } | |||
| 918 | ||||
| 919 | #define YYABORTgoto yyabort goto yyabort | |||
| 920 | #define YYREJECTgoto yyabort goto yyabort | |||
| 921 | #define YYACCEPTgoto yyaccept goto yyaccept | |||
| 922 | #define YYERRORgoto yyerrlab goto yyerrlab | |||
| 923 | int | |||
| 924 | yyparse(void) | |||
| 925 | { | |||
| 926 | int yym, yyn, yystate; | |||
| 927 | #if YYDEBUG0 | |||
| 928 | const char *yys; | |||
| 929 | ||||
| 930 | if ((yys = getenv("YYDEBUG"))) | |||
| 931 | { | |||
| 932 | yyn = *yys; | |||
| 933 | if (yyn >= '0' && yyn <= '9') | |||
| 934 | yydebug = yyn - '0'; | |||
| 935 | } | |||
| 936 | #endif /* YYDEBUG */ | |||
| 937 | ||||
| 938 | yynerrs = 0; | |||
| 939 | yyerrflag = 0; | |||
| 940 | yychar = (-1); | |||
| 941 | ||||
| 942 | if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow; | |||
| ||||
| 943 | yyssp = yyss; | |||
| 944 | yyvsp = yyvs; | |||
| 945 | *yyssp = yystate = 0; | |||
| 946 | ||||
| 947 | yyloop: | |||
| 948 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | |||
| 949 | if (yychar < 0) | |||
| 950 | { | |||
| 951 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 952 | #if YYDEBUG0 | |||
| 953 | if (yydebug) | |||
| 954 | { | |||
| 955 | yys = 0; | |||
| 956 | if (yychar <= YYMAXTOKEN276) yys = yyname[yychar]; | |||
| 957 | if (!yys) yys = "illegal-symbol"; | |||
| 958 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 959 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 960 | } | |||
| 961 | #endif | |||
| 962 | } | |||
| 963 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 964 | yyn <= YYTABLESIZE265 && yycheck[yyn] == yychar) | |||
| 965 | { | |||
| 966 | #if YYDEBUG0 | |||
| 967 | if (yydebug) | |||
| 968 | printf("%sdebug: state %d, shifting to state %d\n", | |||
| 969 | YYPREFIX"yy", yystate, yytable[yyn]); | |||
| 970 | #endif | |||
| 971 | if (yyssp >= yysslim && yygrowstack()) | |||
| 972 | { | |||
| 973 | goto yyoverflow; | |||
| 974 | } | |||
| 975 | *++yyssp = yystate = yytable[yyn]; | |||
| 976 | *++yyvsp = yylval; | |||
| 977 | yychar = (-1); | |||
| 978 | if (yyerrflag > 0) --yyerrflag; | |||
| 979 | goto yyloop; | |||
| 980 | } | |||
| 981 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 982 | yyn <= YYTABLESIZE265 && yycheck[yyn] == yychar) | |||
| 983 | { | |||
| 984 | yyn = yytable[yyn]; | |||
| 985 | goto yyreduce; | |||
| 986 | } | |||
| 987 | if (yyerrflag) goto yyinrecovery; | |||
| 988 | #if defined(__GNUC__4) | |||
| 989 | goto yynewerror; | |||
| 990 | #endif | |||
| 991 | yynewerror: | |||
| 992 | yyerror("syntax error"); | |||
| 993 | #if defined(__GNUC__4) | |||
| 994 | goto yyerrlab; | |||
| 995 | #endif | |||
| 996 | yyerrlab: | |||
| 997 | ++yynerrs; | |||
| 998 | yyinrecovery: | |||
| 999 | if (yyerrflag < 3) | |||
| 1000 | { | |||
| 1001 | yyerrflag = 3; | |||
| 1002 | for (;;) | |||
| 1003 | { | |||
| 1004 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | |||
| 1005 | yyn <= YYTABLESIZE265 && yycheck[yyn] == YYERRCODE256) | |||
| 1006 | { | |||
| 1007 | #if YYDEBUG0 | |||
| 1008 | if (yydebug) | |||
| 1009 | printf("%sdebug: state %d, error recovery shifting\ | |||
| 1010 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | |||
| 1011 | #endif | |||
| 1012 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1013 | { | |||
| 1014 | goto yyoverflow; | |||
| 1015 | } | |||
| 1016 | *++yyssp = yystate = yytable[yyn]; | |||
| 1017 | *++yyvsp = yylval; | |||
| 1018 | goto yyloop; | |||
| 1019 | } | |||
| 1020 | else | |||
| 1021 | { | |||
| 1022 | #if YYDEBUG0 | |||
| 1023 | if (yydebug) | |||
| 1024 | printf("%sdebug: error recovery discarding state %d\n", | |||
| 1025 | YYPREFIX"yy", *yyssp); | |||
| 1026 | #endif | |||
| 1027 | if (yyssp <= yyss) goto yyabort; | |||
| 1028 | --yyssp; | |||
| 1029 | --yyvsp; | |||
| 1030 | } | |||
| 1031 | } | |||
| 1032 | } | |||
| 1033 | else | |||
| 1034 | { | |||
| 1035 | if (yychar == 0) goto yyabort; | |||
| 1036 | #if YYDEBUG0 | |||
| 1037 | if (yydebug) | |||
| 1038 | { | |||
| 1039 | yys = 0; | |||
| 1040 | if (yychar <= YYMAXTOKEN276) yys = yyname[yychar]; | |||
| 1041 | if (!yys) yys = "illegal-symbol"; | |||
| 1042 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | |||
| 1043 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1044 | } | |||
| 1045 | #endif | |||
| 1046 | yychar = (-1); | |||
| 1047 | goto yyloop; | |||
| 1048 | } | |||
| 1049 | yyreduce: | |||
| 1050 | #if YYDEBUG0 | |||
| 1051 | if (yydebug) | |||
| 1052 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | |||
| 1053 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | |||
| 1054 | #endif | |||
| 1055 | yym = yylen[yyn]; | |||
| 1056 | if (yym) | |||
| 1057 | yyval = yyvsp[1-yym]; | |||
| 1058 | else | |||
| 1059 | memset(&yyval, 0, sizeof yyval); | |||
| 1060 | switch (yyn) | |||
| 1061 | { | |||
| 1062 | case 6: | |||
| 1063 | #line 127 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1064 | { file->errors++; } | |||
| 1065 | break; | |||
| 1066 | case 7: | |||
| 1067 | #line 130 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1068 | { | |||
| 1069 | if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1) { | |||
| 1070 | free(yyvsp[-1].v.string); | |||
| 1071 | free(yyvsp[0].v.string); | |||
| 1072 | yyerror("string: asprintf"); | |||
| 1073 | YYERRORgoto yyerrlab; | |||
| 1074 | } | |||
| 1075 | free(yyvsp[-1].v.string); | |||
| 1076 | free(yyvsp[0].v.string); | |||
| 1077 | } | |||
| 1078 | break; | |||
| 1079 | case 9: | |||
| 1080 | #line 143 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1081 | { yyval.v.number = 1; } | |||
| 1082 | break; | |||
| 1083 | case 10: | |||
| 1084 | #line 144 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1085 | { yyval.v.number = 0; } | |||
| 1086 | break; | |||
| 1087 | case 11: | |||
| 1088 | #line 147 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1089 | { yyval.v.number = 0; } | |||
| 1090 | break; | |||
| 1091 | case 12: | |||
| 1092 | #line 148 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1093 | { yyval.v.number = 1; } | |||
| 1094 | break; | |||
| 1095 | case 13: | |||
| 1096 | #line 150 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1097 | { | |||
| 1098 | char *s = yyvsp[-2].v.string; | |||
| 1099 | if (conf->opts & RIPD_OPT_VERBOSE0x00000001) | |||
| 1100 | printf("%s = \"%s\"\n", yyvsp[-2].v.string, yyvsp[0].v.string); | |||
| 1101 | while (*s++) { | |||
| 1102 | if (isspace((unsigned char)*s)) { | |||
| 1103 | yyerror("macro name cannot contain " | |||
| 1104 | "whitespace"); | |||
| 1105 | free(yyvsp[-2].v.string); | |||
| 1106 | free(yyvsp[0].v.string); | |||
| 1107 | YYERRORgoto yyerrlab; | |||
| 1108 | } | |||
| 1109 | } | |||
| 1110 | if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1) | |||
| 1111 | fatal("cannot store variable"); | |||
| 1112 | free(yyvsp[-2].v.string); | |||
| 1113 | free(yyvsp[0].v.string); | |||
| 1114 | } | |||
| 1115 | break; | |||
| 1116 | case 14: | |||
| 1117 | #line 170 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1118 | { | |||
| 1119 | /* clean flags first */ | |||
| 1120 | conf->options &= ~(OPT_SPLIT_HORIZON0x01 | | |||
| 1121 | OPT_SPLIT_POISONED0x02); | |||
| 1122 | if (!strcmp(yyvsp[0].v.string, "none")) | |||
| 1123 | /* nothing */ ; | |||
| 1124 | else if (!strcmp(yyvsp[0].v.string, "simple")) | |||
| 1125 | conf->options |= OPT_SPLIT_HORIZON0x01; | |||
| 1126 | else if (!strcmp(yyvsp[0].v.string, "poisoned")) | |||
| 1127 | conf->options |= OPT_SPLIT_POISONED0x02; | |||
| 1128 | else { | |||
| 1129 | yyerror("unknown split horizon type"); | |||
| 1130 | free(yyvsp[0].v.string); | |||
| 1131 | YYERRORgoto yyerrlab; | |||
| 1132 | } | |||
| 1133 | free(yyvsp[0].v.string); | |||
| 1134 | } | |||
| 1135 | break; | |||
| 1136 | case 15: | |||
| 1137 | #line 187 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1138 | { | |||
| 1139 | if (yyvsp[0].v.number == 1) | |||
| 1140 | conf->options |= OPT_TRIGGERED_UPDATES0x04; | |||
| 1141 | else | |||
| 1142 | conf->options &= ~OPT_TRIGGERED_UPDATES0x04; | |||
| 1143 | } | |||
| 1144 | break; | |||
| 1145 | case 16: | |||
| 1146 | #line 193 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1147 | { | |||
| 1148 | if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > RT_TABLEID_MAX255) { | |||
| 1149 | yyerror("invalid rdomain"); | |||
| 1150 | YYERRORgoto yyerrlab; | |||
| 1151 | } | |||
| 1152 | conf->rdomain = yyvsp[0].v.number; | |||
| 1153 | } | |||
| 1154 | break; | |||
| 1155 | case 17: | |||
| 1156 | #line 200 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1157 | { | |||
| 1158 | if (yyvsp[0].v.number <= RTP_NONE0 || yyvsp[0].v.number > RTP_MAX63) { | |||
| 1159 | yyerror("invalid fib-priority"); | |||
| 1160 | YYERRORgoto yyerrlab; | |||
| 1161 | } | |||
| 1162 | conf->fib_priority = yyvsp[0].v.number; | |||
| 1163 | } | |||
| 1164 | break; | |||
| 1165 | case 18: | |||
| 1166 | #line 207 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1167 | { | |||
| 1168 | if (yyvsp[0].v.number == 0) | |||
| 1169 | conf->flags |= RIPD_FLAG_NO_FIB_UPDATE0x0001; | |||
| 1170 | else | |||
| 1171 | conf->flags &= ~RIPD_FLAG_NO_FIB_UPDATE0x0001; | |||
| 1172 | } | |||
| 1173 | break; | |||
| 1174 | case 19: | |||
| 1175 | #line 213 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1176 | { | |||
| 1177 | struct redistribute *r; | |||
| 1178 | ||||
| 1179 | if ((r = calloc(1, sizeof(*r))) == NULL((void *)0)) | |||
| 1180 | fatal(NULL((void *)0)); | |||
| 1181 | if (!strcmp(yyvsp[0].v.string, "static")) | |||
| 1182 | r->type = REDIST_STATIC0x02; | |||
| 1183 | else if (!strcmp(yyvsp[0].v.string, "connected")) | |||
| 1184 | r->type = REDIST_CONNECTED0x01; | |||
| 1185 | else if (!strcmp(yyvsp[0].v.string, "default")) | |||
| 1186 | r->type = REDIST_DEFAULT0x10; | |||
| 1187 | else if (host(yyvsp[0].v.string, &r->addr, &r->mask)) | |||
| 1188 | r->type = REDIST_ADDR0x08; | |||
| 1189 | else { | |||
| 1190 | yyerror("unknown redistribute type"); | |||
| 1191 | free(yyvsp[0].v.string); | |||
| 1192 | free(r); | |||
| 1193 | YYERRORgoto yyerrlab; | |||
| 1194 | } | |||
| 1195 | ||||
| 1196 | if (yyvsp[-2].v.number) | |||
| 1197 | r->type |= REDIST_NO0x20; | |||
| 1198 | ||||
| 1199 | SIMPLEQ_INSERT_TAIL(&conf->redist_list, r,do { (r)->entry.sqe_next = ((void *)0); *(&conf->redist_list )->sqh_last = (r); (&conf->redist_list)->sqh_last = &(r)->entry.sqe_next; } while (0) | |||
| 1200 | entry)do { (r)->entry.sqe_next = ((void *)0); *(&conf->redist_list )->sqh_last = (r); (&conf->redist_list)->sqh_last = &(r)->entry.sqe_next; } while (0); | |||
| 1201 | ||||
| 1202 | conf->redistribute |= REDISTRIBUTE_ON0x01; | |||
| 1203 | free(yyvsp[0].v.string); | |||
| 1204 | } | |||
| 1205 | break; | |||
| 1206 | case 20: | |||
| 1207 | #line 242 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1208 | { | |||
| 1209 | struct redistribute *r; | |||
| 1210 | ||||
| 1211 | if ((r = calloc(1, sizeof(*r))) == NULL((void *)0)) | |||
| 1212 | fatal(NULL((void *)0)); | |||
| 1213 | r->type = REDIST_LABEL0x04; | |||
| 1214 | r->label = rtlabel_name2id(yyvsp[0].v.string); | |||
| 1215 | if (yyvsp[-3].v.number) | |||
| 1216 | r->type |= REDIST_NO0x20; | |||
| 1217 | free(yyvsp[0].v.string); | |||
| 1218 | ||||
| 1219 | SIMPLEQ_INSERT_TAIL(&conf->redist_list, r, entry)do { (r)->entry.sqe_next = ((void *)0); *(&conf->redist_list )->sqh_last = (r); (&conf->redist_list)->sqh_last = &(r)->entry.sqe_next; } while (0); | |||
| 1220 | conf->redistribute |= REDISTRIBUTE_ON0x01; | |||
| 1221 | } | |||
| 1222 | break; | |||
| 1223 | case 22: | |||
| 1224 | #line 259 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1225 | { | |||
| 1226 | if (yyvsp[-1].v.number < MIN_MD_ID0 || yyvsp[-1].v.number > MAX_MD_ID255) { | |||
| 1227 | yyerror("auth-md key-id out of range " | |||
| 1228 | "(%d-%d)", MIN_MD_ID0, MAX_MD_ID255); | |||
| 1229 | free(yyvsp[0].v.string); | |||
| 1230 | YYERRORgoto yyerrlab; | |||
| 1231 | } | |||
| 1232 | if (md_list_add(&defs->md_list, yyvsp[-1].v.number, yyvsp[0].v.string) == -1) { | |||
| 1233 | yyerror("auth-md key length out of range " | |||
| 1234 | "(max length %d)", MD5_DIGEST_LENGTH16); | |||
| 1235 | free(yyvsp[0].v.string); | |||
| 1236 | YYERRORgoto yyerrlab; | |||
| 1237 | } | |||
| 1238 | free(yyvsp[0].v.string); | |||
| 1239 | } | |||
| 1240 | break; | |||
| 1241 | case 23: | |||
| 1242 | #line 275 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1243 | { | |||
| 1244 | if (yyvsp[0].v.number < MIN_MD_ID0 || yyvsp[0].v.number > MAX_MD_ID255) { | |||
| 1245 | yyerror("auth-md-keyid out of range " | |||
| 1246 | "(%d-%d)", MIN_MD_ID0, MAX_MD_ID255); | |||
| 1247 | YYERRORgoto yyerrlab; | |||
| 1248 | } | |||
| 1249 | defs->auth_keyid = yyvsp[0].v.number; | |||
| 1250 | } | |||
| 1251 | break; | |||
| 1252 | case 24: | |||
| 1253 | #line 284 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1254 | { | |||
| 1255 | enum auth_type type; | |||
| 1256 | ||||
| 1257 | if (!strcmp(yyvsp[0].v.string, "none")) | |||
| 1258 | type = AUTH_NONE; | |||
| 1259 | else if (!strcmp(yyvsp[0].v.string, "simple")) | |||
| 1260 | type = AUTH_SIMPLE; | |||
| 1261 | else if (!strcmp(yyvsp[0].v.string, "crypt")) | |||
| 1262 | type = AUTH_CRYPT; | |||
| 1263 | else { | |||
| 1264 | yyerror("unknown auth-type"); | |||
| 1265 | free(yyvsp[0].v.string); | |||
| 1266 | YYERRORgoto yyerrlab; | |||
| 1267 | } | |||
| 1268 | free(yyvsp[0].v.string); | |||
| 1269 | defs->auth_type = type; | |||
| 1270 | } | |||
| 1271 | break; | |||
| 1272 | case 25: | |||
| 1273 | #line 303 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1274 | { | |||
| 1275 | if (strlen(yyvsp[0].v.string) > MAX_SIMPLE_AUTH_LEN16) { | |||
| 1276 | yyerror("auth-key too long (max length %d)", | |||
| 1277 | MAX_SIMPLE_AUTH_LEN16); | |||
| 1278 | free(yyvsp[0].v.string); | |||
| 1279 | YYERRORgoto yyerrlab; | |||
| 1280 | } | |||
| 1281 | bzero(defs->auth_key, MAX_SIMPLE_AUTH_LEN16); | |||
| 1282 | memcpy(defs->auth_key, yyvsp[0].v.string, strlen(yyvsp[0].v.string)); | |||
| 1283 | free(yyvsp[0].v.string); | |||
| 1284 | } | |||
| 1285 | break; | |||
| 1286 | case 26: | |||
| 1287 | #line 316 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1288 | { | |||
| 1289 | if (yyvsp[0].v.number < 1 || yyvsp[0].v.number > INFINITY16) { | |||
| 1290 | yyerror("cost out of range (%d-%d)", 1, | |||
| 1291 | INFINITY16); | |||
| 1292 | YYERRORgoto yyerrlab; | |||
| 1293 | } | |||
| 1294 | defs->cost = yyvsp[0].v.number; | |||
| 1295 | } | |||
| 1296 | break; | |||
| 1297 | case 34: | |||
| 1298 | #line 337 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1299 | { | |||
| 1300 | struct kif *kif; | |||
| 1301 | ||||
| 1302 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
| 1303 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 1304 | free(yyvsp[0].v.string); | |||
| 1305 | YYERRORgoto yyerrlab; | |||
| 1306 | } | |||
| 1307 | free(yyvsp[0].v.string); | |||
| 1308 | iface = conf_get_if(kif); | |||
| 1309 | if (iface == NULL((void *)0)) | |||
| 1310 | YYERRORgoto yyerrlab; | |||
| 1311 | LIST_INSERT_HEAD(&conf->iface_list, iface, entry)do { if (((iface)->entry.le_next = (&conf->iface_list )->lh_first) != ((void *)0)) (&conf->iface_list)-> lh_first->entry.le_prev = &(iface)->entry.le_next; ( &conf->iface_list)->lh_first = (iface); (iface)-> entry.le_prev = &(&conf->iface_list)->lh_first; } while (0); | |||
| 1312 | memcpy(&ifacedefs, defs, sizeof(ifacedefs)); | |||
| 1313 | md_list_copy(&ifacedefs.md_list, &defs->md_list); | |||
| 1314 | defs = &ifacedefs; | |||
| 1315 | } | |||
| 1316 | break; | |||
| 1317 | case 35: | |||
| 1318 | #line 353 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1319 | { | |||
| 1320 | iface->cost = defs->cost; | |||
| 1321 | iface->auth_type = defs->auth_type; | |||
| 1322 | iface->auth_keyid = defs->auth_keyid; | |||
| 1323 | memcpy(iface->auth_key, defs->auth_key, | |||
| 1324 | sizeof(iface->auth_key)); | |||
| 1325 | md_list_copy(&iface->auth_md_list, &defs->md_list); | |||
| 1326 | md_list_clr(&defs->md_list); | |||
| 1327 | defs = &globaldefs; | |||
| 1328 | } | |||
| 1329 | break; | |||
| 1330 | case 41: | |||
| 1331 | #line 374 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1332 | { iface->passive = 1; } | |||
| 1333 | break; | |||
| 1334 | case 42: | |||
| 1335 | #line 375 "/usr/src/usr.sbin/ripd/parse.y" | |||
| 1336 | { | |||
| 1337 | if (strlcpy(iface->demote_group, yyvsp[0].v.string, | |||
| 1338 | sizeof(iface->demote_group)) >= | |||
| 1339 | sizeof(iface->demote_group)) { | |||
| 1340 | yyerror("demote group name \"%s\" too long", | |||
| 1341 | yyvsp[0].v.string); | |||
| 1342 | free(yyvsp[0].v.string); | |||
| 1343 | YYERRORgoto yyerrlab; | |||
| 1344 | } | |||
| 1345 | free(yyvsp[0].v.string); | |||
| 1346 | if (carp_demote_init(iface->demote_group, | |||
| 1347 | conf->opts & RIPD_OPT_FORCE_DEMOTE0x00000008) == -1) { | |||
| 1348 | yyerror("error initializing group \"%s\"", | |||
| 1349 | iface->demote_group); | |||
| 1350 | YYERRORgoto yyerrlab; | |||
| 1351 | } | |||
| 1352 | } | |||
| 1353 | break; | |||
| 1354 | #line 1347 "parse.c" | |||
| 1355 | } | |||
| 1356 | yyssp -= yym; | |||
| 1357 | yystate = *yyssp; | |||
| 1358 | yyvsp -= yym; | |||
| 1359 | yym = yylhs[yyn]; | |||
| 1360 | if (yystate == 0 && yym == 0) | |||
| 1361 | { | |||
| 1362 | #if YYDEBUG0 | |||
| 1363 | if (yydebug) | |||
| 1364 | printf("%sdebug: after reduction, shifting from state 0 to\ | |||
| 1365 | state %d\n", YYPREFIX"yy", YYFINAL1); | |||
| 1366 | #endif | |||
| 1367 | yystate = YYFINAL1; | |||
| 1368 | *++yyssp = YYFINAL1; | |||
| 1369 | *++yyvsp = yyval; | |||
| 1370 | if (yychar < 0) | |||
| 1371 | { | |||
| 1372 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 1373 | #if YYDEBUG0 | |||
| 1374 | if (yydebug) | |||
| 1375 | { | |||
| 1376 | yys = 0; | |||
| 1377 | if (yychar <= YYMAXTOKEN276) yys = yyname[yychar]; | |||
| 1378 | if (!yys) yys = "illegal-symbol"; | |||
| 1379 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 1380 | YYPREFIX"yy", YYFINAL1, yychar, yys); | |||
| 1381 | } | |||
| 1382 | #endif | |||
| 1383 | } | |||
| 1384 | if (yychar == 0) goto yyaccept; | |||
| 1385 | goto yyloop; | |||
| 1386 | } | |||
| 1387 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | |||
| 1388 | yyn <= YYTABLESIZE265 && yycheck[yyn] == yystate) | |||
| 1389 | yystate = yytable[yyn]; | |||
| 1390 | else | |||
| 1391 | yystate = yydgoto[yym]; | |||
| 1392 | #if YYDEBUG0 | |||
| 1393 | if (yydebug) | |||
| 1394 | printf("%sdebug: after reduction, shifting from state %d \ | |||
| 1395 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | |||
| 1396 | #endif | |||
| 1397 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1398 | { | |||
| 1399 | goto yyoverflow; | |||
| 1400 | } | |||
| 1401 | *++yyssp = yystate; | |||
| 1402 | *++yyvsp = yyval; | |||
| 1403 | goto yyloop; | |||
| 1404 | yyoverflow: | |||
| 1405 | yyerror("yacc stack overflow"); | |||
| 1406 | yyabort: | |||
| 1407 | if (yyss) | |||
| 1408 | free(yyss); | |||
| 1409 | if (yyvs) | |||
| 1410 | free(yyvs); | |||
| 1411 | yyss = yyssp = NULL((void *)0); | |||
| 1412 | yyvs = yyvsp = NULL((void *)0); | |||
| 1413 | yystacksize = 0; | |||
| 1414 | return (1); | |||
| 1415 | yyaccept: | |||
| 1416 | if (yyss) | |||
| 1417 | free(yyss); | |||
| 1418 | if (yyvs) | |||
| 1419 | free(yyvs); | |||
| 1420 | yyss = yyssp = NULL((void *)0); | |||
| 1421 | yyvs = yyvsp = NULL((void *)0); | |||
| 1422 | yystacksize = 0; | |||
| 1423 | return (0); | |||
| 1424 | } |