| File: | src/usr.sbin/mrouted/obj/cfparse.c |
| Warning: | line 1018, column 14 Null pointer passed as 2nd argument to string comparison function |
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 2 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 13 | /* $NetBSD: cfparse.y,v 1.4 1995/12/10 10:06:57 mycroft Exp $ */ | ||||
| 14 | |||||
| 15 | /* | ||||
| 16 | * Configuration file parser for mrouted. | ||||
| 17 | * | ||||
| 18 | * Written by Bill Fenner, NRL, 1994 | ||||
| 19 | * Copyright (c) 1994 | ||||
| 20 | * Naval Research Laboratory (NRL/CCS) | ||||
| 21 | * and the | ||||
| 22 | * Defense Advanced Research Projects Agency (DARPA) | ||||
| 23 | * | ||||
| 24 | * All Rights Reserved. | ||||
| 25 | * | ||||
| 26 | * Permission to use, copy, modify and distribute this software and its | ||||
| 27 | * documentation is hereby granted, provided that both the copyright notice and | ||||
| 28 | * this permission notice appear in all copies of the software, derivative | ||||
| 29 | * works or modified versions, and any portions thereof, and that both notices | ||||
| 30 | * appear in supporting documentation. | ||||
| 31 | * | ||||
| 32 | * NRL AND DARPA ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND | ||||
| 33 | * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM | ||||
| 34 | * THE USE OF THIS SOFTWARE. | ||||
| 35 | */ | ||||
| 36 | #include <stdio.h> | ||||
| 37 | #include <string.h> | ||||
| 38 | #include <stdarg.h> | ||||
| 39 | #include "defs.h" | ||||
| 40 | #include <netdb.h> | ||||
| 41 | #include <ifaddrs.h> | ||||
| 42 | |||||
| 43 | /* | ||||
| 44 | * Local function declarations | ||||
| 45 | */ | ||||
| 46 | static void fatal(const char *fmt, ...) | ||||
| 47 | __attribute__((__format__ (printf, 1, 2))) | ||||
| 48 | __attribute__((__nonnull__ (1))); | ||||
| 49 | static void warn(const char *fmt, ...) | ||||
| 50 | __attribute__((__format__ (printf, 1, 2))) | ||||
| 51 | __attribute__((__nonnull__ (1))); | ||||
| 52 | static void yyerror(char *s); | ||||
| 53 | static char * next_word(void); | ||||
| 54 | static int yylex(void); | ||||
| 55 | static u_int32_t valid_if(char *s); | ||||
| 56 | static const char * ifconfaddr(u_int32_t a); | ||||
| 57 | int yyparse(void); | ||||
| 58 | |||||
| 59 | static FILE *f; | ||||
| 60 | |||||
| 61 | extern int udp_socket; | ||||
| 62 | char *configfilename = _PATH_MROUTED_CONF"/etc/mrouted.conf"; | ||||
| 63 | |||||
| 64 | extern int cache_lifetime; | ||||
| 65 | extern int max_prune_lifetime; | ||||
| 66 | |||||
| 67 | static int lineno; | ||||
| 68 | |||||
| 69 | static struct uvif *v; | ||||
| 70 | |||||
| 71 | static int order; | ||||
| 72 | |||||
| 73 | struct addrmask { | ||||
| 74 | u_int32_t addr; | ||||
| 75 | int mask; | ||||
| 76 | }; | ||||
| 77 | |||||
| 78 | struct boundnam { | ||||
| 79 | char *name; | ||||
| 80 | struct addrmask bound; | ||||
| 81 | }; | ||||
| 82 | |||||
| 83 | #define MAXBOUNDS20 20 | ||||
| 84 | |||||
| 85 | struct boundnam boundlist[MAXBOUNDS20]; /* Max. of 20 named boundaries */ | ||||
| 86 | int numbounds = 0; /* Number of named boundaries */ | ||||
| 87 | |||||
| 88 | #line 79 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 89 | #ifndef YYSTYPE_DEFINED | ||||
| 90 | #define YYSTYPE_DEFINED | ||||
| 91 | typedef union | ||||
| 92 | { | ||||
| 93 | int num; | ||||
| 94 | char *ptr; | ||||
| 95 | struct addrmask addrmask; | ||||
| 96 | u_int32_t addr; | ||||
| 97 | } YYSTYPE; | ||||
| 98 | #endif /* YYSTYPE_DEFINED */ | ||||
| 99 | #line 100 "cfparse.c" | ||||
| 100 | #define CACHE_LIFETIME257 257 | ||||
| 101 | #define PRUNING258 258 | ||||
| 102 | #define PHYINT259 259 | ||||
| 103 | #define TUNNEL260 260 | ||||
| 104 | #define NAME261 261 | ||||
| 105 | #define DISABLE262 262 | ||||
| 106 | #define IGMPV1263 263 | ||||
| 107 | #define SRCRT264 264 | ||||
| 108 | #define METRIC265 265 | ||||
| 109 | #define THRESHOLD266 266 | ||||
| 110 | #define RATE_LIMIT267 267 | ||||
| 111 | #define BOUNDARY268 268 | ||||
| 112 | #define NETMASK269 269 | ||||
| 113 | #define ALTNET270 270 | ||||
| 114 | #define BOOLEAN271 271 | ||||
| 115 | #define NUMBER272 272 | ||||
| 116 | #define STRING273 273 | ||||
| 117 | #define ADDRMASK274 274 | ||||
| 118 | #define ADDR275 275 | ||||
| 119 | #define YYERRCODE256 256 | ||||
| 120 | const short yylhs[] = | ||||
| 121 | { -1, | ||||
| 122 | 0, 6, 6, 7, 9, 7, 11, 7, 7, 7, | ||||
| 123 | 7, 10, 10, 12, 12, 8, 8, 14, 14, 14, | ||||
| 124 | 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, | ||||
| 125 | 13, 13, 1, 1, 2, 2, 3, 3, 4, 5, | ||||
| 126 | 5, | ||||
| 127 | }; | ||||
| 128 | const short yylen[] = | ||||
| 129 | { 2, | ||||
| 130 | 1, 0, 2, 1, 0, 4, 0, 5, 2, 2, | ||||
| 131 | 3, 0, 2, 1, 1, 0, 2, 1, 1, 1, | ||||
| 132 | 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, | ||||
| 133 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||||
| 134 | 1, | ||||
| 135 | }; | ||||
| 136 | const short yydefred[] = | ||||
| 137 | { 2, | ||||
| 138 | 0, 0, 4, 0, 0, 0, 0, 0, 3, 10, | ||||
| 139 | 9, 34, 33, 5, 0, 0, 16, 36, 35, 7, | ||||
| 140 | 39, 11, 0, 12, 19, 20, 0, 0, 0, 0, | ||||
| 141 | 0, 0, 18, 17, 0, 27, 25, 29, 38, 31, | ||||
| 142 | 37, 21, 40, 41, 23, 15, 13, 14, | ||||
| 143 | }; | ||||
| 144 | const short yydgoto[] = | ||||
| 145 | { 1, | ||||
| 146 | 14, 20, 40, 22, 45, 2, 9, 23, 17, 35, | ||||
| 147 | 24, 47, 33, 34, | ||||
| 148 | }; | ||||
| 149 | const short yysindex[] = | ||||
| 150 | { 0, | ||||
| 151 | 0, -239, 0, -272, -267, -250, -250, -241, 0, 0, | ||||
| 152 | 0, 0, 0, 0, -249, -240, 0, 0, 0, 0, | ||||
| 153 | 0, 0, -260, 0, 0, 0, -237, -236, -235, -246, | ||||
| 154 | -249, -245, 0, 0, -253, 0, 0, 0, 0, 0, | ||||
| 155 | 0, 0, 0, 0, 0, 0, 0, 0,}; | ||||
| 156 | const short yyrindex[] = | ||||
| 157 | { 0, | ||||
| 158 | 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 159 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 160 | 0, 0, 91, 0, 0, 0, 1, 16, 31, 46, | ||||
| 161 | 61, 76, 0, 0, 97, 0, 0, 0, 0, 0, | ||||
| 162 | 0, 0, 0, 0, 0, 0, 0, 0,}; | ||||
| 163 | const short yygindex[] = | ||||
| 164 | { 0, | ||||
| 165 | 32, 7, 0, 10, 0, 0, 0, 0, 0, 0, | ||||
| 166 | 0, 0, 6, 0, | ||||
| 167 | }; | ||||
| 168 | #define YYTABLESIZE358 358 | ||||
| 169 | const short yytable[] = | ||||
| 170 | { 10, | ||||
| 171 | 28, 25, 26, 11, 27, 28, 29, 30, 31, 32, | ||||
| 172 | 46, 27, 28, 29, 30, 26, 3, 4, 5, 6, | ||||
| 173 | 7, 8, 12, 18, 13, 19, 39, 21, 43, 44, | ||||
| 174 | 30, 16, 1, 21, 36, 37, 38, 42, 15, 41, | ||||
| 175 | 48, 0, 0, 0, 0, 32, 0, 0, 0, 0, | ||||
| 176 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 177 | 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 178 | 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, | ||||
| 179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 180 | 6, 0, 0, 0, 0, 0, 8, 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, 0, 0, | ||||
| 185 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 186 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 187 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||||
| 188 | 0, 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, 0, 0, 0, 0, 0, | ||||
| 196 | 0, 0, 0, 0, 0, 0, 28, 28, 28, 28, | ||||
| 197 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | ||||
| 198 | 28, 26, 26, 26, 26, 26, 26, 26, 26, 26, | ||||
| 199 | 26, 26, 26, 26, 26, 26, 30, 30, 30, 30, | ||||
| 200 | 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, | ||||
| 201 | 30, 32, 32, 32, 32, 32, 32, 32, 32, 32, | ||||
| 202 | 32, 32, 32, 32, 32, 32, 22, 22, 22, 22, | ||||
| 203 | 22, 22, 22, 22, 0, 22, 22, 22, 22, 22, | ||||
| 204 | 22, 24, 24, 24, 24, 24, 24, 24, 24, 0, | ||||
| 205 | 24, 24, 24, 24, 24, 24, 6, 6, 6, 6, | ||||
| 206 | 6, 6, 8, 8, 8, 8, 8, 8, | ||||
| 207 | }; | ||||
| 208 | const short yycheck[] = | ||||
| 209 | { 272, | ||||
| 210 | 0, 262, 263, 271, 265, 266, 267, 268, 269, 270, | ||||
| 211 | 264, 265, 266, 267, 268, 0, 256, 257, 258, 259, | ||||
| 212 | 260, 261, 273, 273, 275, 275, 273, 274, 274, 275, | ||||
| 213 | 0, 273, 0, 274, 272, 272, 272, 31, 7, 30, | ||||
| 214 | 35, -1, -1, -1, -1, 0, -1, -1, -1, -1, | ||||
| 215 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 216 | 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 217 | -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, | ||||
| 218 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 219 | 0, -1, -1, -1, -1, -1, 0, -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, -1, -1, -1, -1, -1, | ||||
| 226 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 227 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 228 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 229 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 230 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 231 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 232 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 233 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 234 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | ||||
| 235 | -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, | ||||
| 236 | 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, | ||||
| 237 | 270, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||||
| 238 | 265, 266, 267, 268, 269, 270, 256, 257, 258, 259, | ||||
| 239 | 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, | ||||
| 240 | 270, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||||
| 241 | 265, 266, 267, 268, 269, 270, 256, 257, 258, 259, | ||||
| 242 | 260, 261, 262, 263, -1, 265, 266, 267, 268, 269, | ||||
| 243 | 270, 256, 257, 258, 259, 260, 261, 262, 263, -1, | ||||
| 244 | 265, 266, 267, 268, 269, 270, 256, 257, 258, 259, | ||||
| 245 | 260, 261, 256, 257, 258, 259, 260, 261, | ||||
| 246 | }; | ||||
| 247 | #define YYFINAL1 1 | ||||
| 248 | #ifndef YYDEBUG0 | ||||
| 249 | #define YYDEBUG0 0 | ||||
| 250 | #endif | ||||
| 251 | #define YYMAXTOKEN275 275 | ||||
| 252 | #if YYDEBUG0 | ||||
| 253 | const char * const yyname[] = | ||||
| 254 | { | ||||
| 255 | "end-of-file",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, | ||||
| 256 | 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, | ||||
| 257 | 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, | ||||
| 258 | 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, | ||||
| 259 | 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, | ||||
| 260 | 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, | ||||
| 261 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CACHE_LIFETIME","PRUNING", | ||||
| 262 | "PHYINT","TUNNEL","NAME","DISABLE","IGMPV1","SRCRT","METRIC","THRESHOLD", | ||||
| 263 | "RATE_LIMIT","BOUNDARY","NETMASK","ALTNET","BOOLEAN","NUMBER","STRING", | ||||
| 264 | "ADDRMASK","ADDR", | ||||
| 265 | }; | ||||
| 266 | const char * const yyrule[] = | ||||
| 267 | {"$accept : conf", | ||||
| 268 | "conf : stmts", | ||||
| 269 | "stmts :", | ||||
| 270 | "stmts : stmts stmt", | ||||
| 271 | "stmt : error", | ||||
| 272 | "$$1 :", | ||||
| 273 | "stmt : PHYINT interface $$1 ifmods", | ||||
| 274 | "$$2 :", | ||||
| 275 | "stmt : TUNNEL interface addrname $$2 tunnelmods", | ||||
| 276 | "stmt : PRUNING BOOLEAN", | ||||
| 277 | "stmt : CACHE_LIFETIME NUMBER", | ||||
| 278 | "stmt : NAME STRING boundary", | ||||
| 279 | "tunnelmods :", | ||||
| 280 | "tunnelmods : tunnelmods tunnelmod", | ||||
| 281 | "tunnelmod : mod", | ||||
| 282 | "tunnelmod : SRCRT", | ||||
| 283 | "ifmods :", | ||||
| 284 | "ifmods : ifmods ifmod", | ||||
| 285 | "ifmod : mod", | ||||
| 286 | "ifmod : DISABLE", | ||||
| 287 | "ifmod : IGMPV1", | ||||
| 288 | "ifmod : NETMASK addrname", | ||||
| 289 | "ifmod : NETMASK", | ||||
| 290 | "ifmod : ALTNET addrmask", | ||||
| 291 | "ifmod : ALTNET", | ||||
| 292 | "mod : THRESHOLD NUMBER", | ||||
| 293 | "mod : THRESHOLD", | ||||
| 294 | "mod : METRIC NUMBER", | ||||
| 295 | "mod : METRIC", | ||||
| 296 | "mod : RATE_LIMIT NUMBER", | ||||
| 297 | "mod : RATE_LIMIT", | ||||
| 298 | "mod : BOUNDARY bound", | ||||
| 299 | "mod : BOUNDARY", | ||||
| 300 | "interface : ADDR", | ||||
| 301 | "interface : STRING", | ||||
| 302 | "addrname : ADDR", | ||||
| 303 | "addrname : STRING", | ||||
| 304 | "bound : boundary", | ||||
| 305 | "bound : STRING", | ||||
| 306 | "boundary : ADDRMASK", | ||||
| 307 | "addrmask : ADDRMASK", | ||||
| 308 | "addrmask : ADDR", | ||||
| 309 | }; | ||||
| 310 | #endif | ||||
| 311 | #ifdef YYSTACKSIZE10000 | ||||
| 312 | #undef YYMAXDEPTH10000 | ||||
| 313 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | ||||
| 314 | #else | ||||
| 315 | #ifdef YYMAXDEPTH10000 | ||||
| 316 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | ||||
| 317 | #else | ||||
| 318 | #define YYSTACKSIZE10000 10000 | ||||
| 319 | #define YYMAXDEPTH10000 10000 | ||||
| 320 | #endif | ||||
| 321 | #endif | ||||
| 322 | #define YYINITSTACKSIZE200 200 | ||||
| 323 | /* LINTUSED */ | ||||
| 324 | int yydebug; | ||||
| 325 | int yynerrs; | ||||
| 326 | int yyerrflag; | ||||
| 327 | int yychar; | ||||
| 328 | short *yyssp; | ||||
| 329 | YYSTYPE *yyvsp; | ||||
| 330 | YYSTYPE yyval; | ||||
| 331 | YYSTYPE yylval; | ||||
| 332 | short *yyss; | ||||
| 333 | short *yysslim; | ||||
| 334 | YYSTYPE *yyvs; | ||||
| 335 | unsigned int yystacksize; | ||||
| 336 | int yyparse(void); | ||||
| 337 | #line 374 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 338 | static void | ||||
| 339 | fatal(const char *fmt, ...) | ||||
| 340 | { | ||||
| 341 | va_list ap; | ||||
| 342 | char buf[200]; | ||||
| 343 | |||||
| 344 | va_start(ap, fmt)__builtin_va_start((ap), fmt); | ||||
| 345 | vsnprintf(buf, sizeof buf, fmt, ap); | ||||
| 346 | va_end(ap)__builtin_va_end((ap)); | ||||
| 347 | |||||
| 348 | logit(LOG_ERR3,0,"%s: %s near line %d", configfilename, buf, lineno); | ||||
| 349 | } | ||||
| 350 | |||||
| 351 | static void | ||||
| 352 | warn(const char *fmt, ...) | ||||
| 353 | { | ||||
| 354 | va_list ap; | ||||
| 355 | char buf[200]; | ||||
| 356 | |||||
| 357 | va_start(ap, fmt)__builtin_va_start((ap), fmt); | ||||
| 358 | vsnprintf(buf, sizeof buf, fmt, ap); | ||||
| 359 | va_end(ap)__builtin_va_end((ap)); | ||||
| 360 | |||||
| 361 | logit(LOG_WARNING4,0,"%s: %s near line %d", configfilename, buf, lineno); | ||||
| 362 | } | ||||
| 363 | |||||
| 364 | static void | ||||
| 365 | yyerror(char *s) | ||||
| 366 | { | ||||
| 367 | logit(LOG_ERR3, 0, "%s: %s near line %d", configfilename, s, lineno); | ||||
| 368 | } | ||||
| 369 | |||||
| 370 | static char * | ||||
| 371 | next_word(void) | ||||
| 372 | { | ||||
| 373 | static char buf[1024]; | ||||
| 374 | static char *p=NULL((void *)0); | ||||
| 375 | extern FILE *f; | ||||
| 376 | char *q; | ||||
| 377 | |||||
| 378 | while (1) { | ||||
| 379 | if (!p || !*p) { | ||||
| 380 | lineno++; | ||||
| 381 | if (fgets(buf, sizeof(buf), f) == NULL((void *)0)) | ||||
| 382 | return NULL((void *)0); | ||||
| 383 | p = buf; | ||||
| 384 | } | ||||
| 385 | while (*p && (*p == ' ' || *p == '\t')) /* skip whitespace */ | ||||
| 386 | p++; | ||||
| 387 | if (*p == '#') { | ||||
| 388 | p = NULL((void *)0); /* skip comments */ | ||||
| 389 | continue; | ||||
| 390 | } | ||||
| 391 | q = p; | ||||
| 392 | while (*p && *p != ' ' && *p != '\t' && *p != '\n') | ||||
| 393 | p++; /* find next whitespace */ | ||||
| 394 | *p++ = '\0'; /* null-terminate string */ | ||||
| 395 | |||||
| 396 | if (!*q) { | ||||
| 397 | p = NULL((void *)0); | ||||
| 398 | continue; /* if 0-length string, read another line */ | ||||
| 399 | } | ||||
| 400 | |||||
| 401 | return q; | ||||
| 402 | } | ||||
| 403 | } | ||||
| 404 | |||||
| 405 | static int | ||||
| 406 | yylex(void) | ||||
| 407 | { | ||||
| 408 | int n; | ||||
| 409 | u_int32_t addr; | ||||
| 410 | char *q; | ||||
| 411 | |||||
| 412 | if ((q = next_word()) == NULL((void *)0)) { | ||||
| 413 | return 0; | ||||
| 414 | } | ||||
| 415 | |||||
| 416 | if (!strcmp(q,"cache_lifetime")) | ||||
| 417 | return CACHE_LIFETIME257; | ||||
| 418 | if (!strcmp(q,"pruning")) | ||||
| 419 | return PRUNING258; | ||||
| 420 | if (!strcmp(q,"phyint")) | ||||
| 421 | return PHYINT259; | ||||
| 422 | if (!strcmp(q,"tunnel")) | ||||
| 423 | return TUNNEL260; | ||||
| 424 | if (!strcmp(q,"disable")) | ||||
| 425 | return DISABLE262; | ||||
| 426 | if (!strcmp(q,"metric")) | ||||
| 427 | return METRIC265; | ||||
| 428 | if (!strcmp(q,"threshold")) | ||||
| 429 | return THRESHOLD266; | ||||
| 430 | if (!strcmp(q,"rate_limit")) | ||||
| 431 | return RATE_LIMIT267; | ||||
| 432 | if (!strcmp(q,"srcrt") || !strcmp(q,"sourceroute")) | ||||
| 433 | return SRCRT264; | ||||
| 434 | if (!strcmp(q,"boundary")) | ||||
| 435 | return BOUNDARY268; | ||||
| 436 | if (!strcmp(q,"netmask")) | ||||
| 437 | return NETMASK269; | ||||
| 438 | if (!strcmp(q,"igmpv1")) | ||||
| 439 | return IGMPV1263; | ||||
| 440 | if (!strcmp(q,"altnet")) | ||||
| 441 | return ALTNET270; | ||||
| 442 | if (!strcmp(q,"name")) | ||||
| 443 | return NAME261; | ||||
| 444 | if (!strcmp(q,"on") || !strcmp(q,"yes")) { | ||||
| 445 | yylval.num = 1; | ||||
| 446 | return BOOLEAN271; | ||||
| 447 | } | ||||
| 448 | if (!strcmp(q,"off") || !strcmp(q,"no")) { | ||||
| 449 | yylval.num = 0; | ||||
| 450 | return BOOLEAN271; | ||||
| 451 | } | ||||
| 452 | if (sscanf(q,"%[.0-9]/%d%c",s1,&n,s2) == 2) { | ||||
| 453 | if ((addr = inet_parse(s1)) != 0xffffffff) { | ||||
| 454 | yylval.addrmask.mask = n; | ||||
| 455 | yylval.addrmask.addr = addr; | ||||
| 456 | return ADDRMASK274; | ||||
| 457 | } | ||||
| 458 | /* fall through to returning STRING */ | ||||
| 459 | } | ||||
| 460 | if (sscanf(q,"%[.0-9]%c",s1,s2) == 1) { | ||||
| 461 | if ((addr = inet_parse(s1)) != 0xffffffff && | ||||
| 462 | inet_valid_host(addr)) { | ||||
| 463 | yylval.addr = addr; | ||||
| 464 | return ADDR275; | ||||
| 465 | } | ||||
| 466 | } | ||||
| 467 | if (sscanf(q,"0x%8x%c",&n,s1) == 1) { | ||||
| 468 | yylval.addr = n; | ||||
| 469 | return ADDR275; | ||||
| 470 | } | ||||
| 471 | if (sscanf(q,"%d%c",&n,s1) == 1) { | ||||
| 472 | yylval.num = n; | ||||
| 473 | return NUMBER272; | ||||
| 474 | } | ||||
| 475 | yylval.ptr = q; | ||||
| 476 | return STRING273; | ||||
| 477 | } | ||||
| 478 | |||||
| 479 | void | ||||
| 480 | config_vifs_from_file(void) | ||||
| 481 | { | ||||
| 482 | extern FILE *f; | ||||
| 483 | |||||
| 484 | order = 0; | ||||
| 485 | numbounds = 0; | ||||
| 486 | lineno = 0; | ||||
| 487 | |||||
| 488 | if ((f = fopen(configfilename, "r")) == NULL((void *)0)) { | ||||
| 489 | if (errno(*__errno()) != ENOENT2) | ||||
| 490 | logit(LOG_ERR3, errno(*__errno()), "can't open %s", configfilename); | ||||
| 491 | return; | ||||
| 492 | } | ||||
| 493 | |||||
| 494 | yyparse(); | ||||
| 495 | |||||
| 496 | fclose(f); | ||||
| 497 | } | ||||
| 498 | |||||
| 499 | static u_int32_t | ||||
| 500 | valid_if(char *s) | ||||
| 501 | { | ||||
| 502 | register vifi_t vifi; | ||||
| 503 | register struct uvif *v; | ||||
| 504 | |||||
| 505 | for (vifi=0, v=uvifs; vifi<numvifs; vifi++, v++) | ||||
| 506 | if (!strcmp(v->uv_name, s)) | ||||
| 507 | return v->uv_lcl_addr; | ||||
| 508 | |||||
| 509 | return 0; | ||||
| 510 | } | ||||
| 511 | |||||
| 512 | static const char * | ||||
| 513 | ifconfaddr(u_int32_t a) | ||||
| 514 | { | ||||
| 515 | static char ifname[IFNAMSIZ16]; | ||||
| 516 | struct ifaddrs *ifap, *ifa; | ||||
| 517 | |||||
| 518 | if (getifaddrs(&ifap) != 0) | ||||
| 519 | return (NULL((void *)0)); | ||||
| 520 | |||||
| 521 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { | ||||
| 522 | if (ifa->ifa_addr != NULL((void *)0) && | ||||
| 523 | ifa->ifa_addr->sa_family == AF_INET2 && | ||||
| 524 | ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == a) { | ||||
| 525 | strlcpy(ifname, ifa->ifa_name, sizeof(ifname)); | ||||
| 526 | freeifaddrs(ifap); | ||||
| 527 | return (ifname); | ||||
| 528 | } | ||||
| 529 | } | ||||
| 530 | freeifaddrs(ifap); | ||||
| 531 | return (0); | ||||
| 532 | } | ||||
| 533 | #line 526 "cfparse.c" | ||||
| 534 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | ||||
| 535 | static int yygrowstack(void) | ||||
| 536 | { | ||||
| 537 | unsigned int newsize; | ||||
| 538 | long sslen; | ||||
| 539 | short *newss; | ||||
| 540 | YYSTYPE *newvs; | ||||
| 541 | |||||
| 542 | if ((newsize = yystacksize) == 0) | ||||
| 543 | newsize = YYINITSTACKSIZE200; | ||||
| 544 | else if (newsize >= YYMAXDEPTH10000) | ||||
| 545 | return -1; | ||||
| 546 | else if ((newsize *= 2) > YYMAXDEPTH10000) | ||||
| 547 | newsize = YYMAXDEPTH10000; | ||||
| 548 | sslen = yyssp - yyss; | ||||
| 549 | #ifdef SIZE_MAX | ||||
| 550 | #define YY_SIZE_MAX0xffffffffU SIZE_MAX | ||||
| 551 | #else | ||||
| 552 | #define YY_SIZE_MAX0xffffffffU 0xffffffffU | ||||
| 553 | #endif | ||||
| 554 | if (newsize && YY_SIZE_MAX0xffffffffU / newsize < sizeof *newss) | ||||
| 555 | goto bail; | ||||
| 556 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | ||||
| 557 | if (newss == NULL((void *)0)) | ||||
| 558 | goto bail; | ||||
| 559 | yyss = newss; | ||||
| 560 | yyssp = newss + sslen; | ||||
| 561 | if (newsize && YY_SIZE_MAX0xffffffffU / newsize < sizeof *newvs) | ||||
| 562 | goto bail; | ||||
| 563 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | ||||
| 564 | if (newvs == NULL((void *)0)) | ||||
| 565 | goto bail; | ||||
| 566 | yyvs = newvs; | ||||
| 567 | yyvsp = newvs + sslen; | ||||
| 568 | yystacksize = newsize; | ||||
| 569 | yysslim = yyss + newsize - 1; | ||||
| 570 | return 0; | ||||
| 571 | bail: | ||||
| 572 | if (yyss) | ||||
| 573 | free(yyss); | ||||
| 574 | if (yyvs) | ||||
| 575 | free(yyvs); | ||||
| 576 | yyss = yyssp = NULL((void *)0); | ||||
| 577 | yyvs = yyvsp = NULL((void *)0); | ||||
| 578 | yystacksize = 0; | ||||
| 579 | return -1; | ||||
| 580 | } | ||||
| 581 | |||||
| 582 | #define YYABORTgoto yyabort goto yyabort | ||||
| 583 | #define YYREJECTgoto yyabort goto yyabort | ||||
| 584 | #define YYACCEPTgoto yyaccept goto yyaccept | ||||
| 585 | #define YYERRORgoto yyerrlab goto yyerrlab | ||||
| 586 | int | ||||
| 587 | yyparse(void) | ||||
| 588 | { | ||||
| 589 | int yym, yyn, yystate; | ||||
| 590 | #if YYDEBUG0 | ||||
| 591 | const char *yys; | ||||
| 592 | |||||
| 593 | if ((yys = getenv("YYDEBUG"))) | ||||
| 594 | { | ||||
| 595 | yyn = *yys; | ||||
| 596 | if (yyn >= '0' && yyn <= '9') | ||||
| 597 | yydebug = yyn - '0'; | ||||
| 598 | } | ||||
| 599 | #endif /* YYDEBUG */ | ||||
| 600 | |||||
| 601 | yynerrs = 0; | ||||
| 602 | yyerrflag = 0; | ||||
| 603 | yychar = (-1); | ||||
| 604 | |||||
| 605 | if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow; | ||||
| |||||
| 606 | yyssp = yyss; | ||||
| 607 | yyvsp = yyvs; | ||||
| 608 | *yyssp = yystate = 0; | ||||
| 609 | |||||
| 610 | yyloop: | ||||
| 611 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | ||||
| 612 | if (yychar
| ||||
| 613 | { | ||||
| 614 | if ((yychar = yylex()) < 0) yychar = 0; | ||||
| 615 | #if YYDEBUG0 | ||||
| 616 | if (yydebug) | ||||
| 617 | { | ||||
| 618 | yys = 0; | ||||
| 619 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 620 | if (!yys) yys = "illegal-symbol"; | ||||
| 621 | printf("%sdebug: state %d, reading %d (%s)\n", | ||||
| 622 | YYPREFIX"yy", yystate, yychar, yys); | ||||
| 623 | } | ||||
| 624 | #endif | ||||
| 625 | } | ||||
| 626 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | ||||
| 627 | yyn
| ||||
| 628 | { | ||||
| 629 | #if YYDEBUG0 | ||||
| 630 | if (yydebug) | ||||
| 631 | printf("%sdebug: state %d, shifting to state %d\n", | ||||
| 632 | YYPREFIX"yy", yystate, yytable[yyn]); | ||||
| 633 | #endif | ||||
| 634 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 635 | { | ||||
| 636 | goto yyoverflow; | ||||
| 637 | } | ||||
| 638 | *++yyssp = yystate = yytable[yyn]; | ||||
| 639 | *++yyvsp = yylval; | ||||
| 640 | yychar = (-1); | ||||
| 641 | if (yyerrflag > 0) --yyerrflag; | ||||
| 642 | goto yyloop; | ||||
| 643 | } | ||||
| 644 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | ||||
| 645 | yyn
| ||||
| 646 | { | ||||
| 647 | yyn = yytable[yyn]; | ||||
| 648 | goto yyreduce; | ||||
| 649 | } | ||||
| 650 | if (yyerrflag
| ||||
| 651 | #if defined(__GNUC__4) | ||||
| 652 | goto yynewerror; | ||||
| 653 | #endif | ||||
| 654 | yynewerror: | ||||
| 655 | yyerror("syntax error"); | ||||
| 656 | #if defined(__GNUC__4) | ||||
| 657 | goto yyerrlab; | ||||
| 658 | #endif | ||||
| 659 | yyerrlab: | ||||
| 660 | ++yynerrs; | ||||
| 661 | yyinrecovery: | ||||
| 662 | if (yyerrflag < 3) | ||||
| 663 | { | ||||
| 664 | yyerrflag = 3; | ||||
| 665 | for (;;) | ||||
| 666 | { | ||||
| 667 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | ||||
| 668 | yyn <= YYTABLESIZE358 && yycheck[yyn] == YYERRCODE256) | ||||
| 669 | { | ||||
| 670 | #if YYDEBUG0 | ||||
| 671 | if (yydebug) | ||||
| 672 | printf("%sdebug: state %d, error recovery shifting\ | ||||
| 673 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | ||||
| 674 | #endif | ||||
| 675 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 676 | { | ||||
| 677 | goto yyoverflow; | ||||
| 678 | } | ||||
| 679 | *++yyssp = yystate = yytable[yyn]; | ||||
| 680 | *++yyvsp = yylval; | ||||
| 681 | goto yyloop; | ||||
| 682 | } | ||||
| 683 | else | ||||
| 684 | { | ||||
| 685 | #if YYDEBUG0 | ||||
| 686 | if (yydebug) | ||||
| 687 | printf("%sdebug: error recovery discarding state %d\n", | ||||
| 688 | YYPREFIX"yy", *yyssp); | ||||
| 689 | #endif | ||||
| 690 | if (yyssp <= yyss) goto yyabort; | ||||
| 691 | --yyssp; | ||||
| 692 | --yyvsp; | ||||
| 693 | } | ||||
| 694 | } | ||||
| 695 | } | ||||
| 696 | else | ||||
| 697 | { | ||||
| 698 | if (yychar == 0) goto yyabort; | ||||
| 699 | #if YYDEBUG0 | ||||
| 700 | if (yydebug) | ||||
| 701 | { | ||||
| 702 | yys = 0; | ||||
| 703 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 704 | if (!yys) yys = "illegal-symbol"; | ||||
| 705 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | ||||
| 706 | YYPREFIX"yy", yystate, yychar, yys); | ||||
| 707 | } | ||||
| 708 | #endif | ||||
| 709 | yychar = (-1); | ||||
| 710 | goto yyloop; | ||||
| 711 | } | ||||
| 712 | yyreduce: | ||||
| 713 | #if YYDEBUG0 | ||||
| 714 | if (yydebug) | ||||
| 715 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | ||||
| 716 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | ||||
| 717 | #endif | ||||
| 718 | yym = yylen[yyn]; | ||||
| 719 | if (yym
| ||||
| 720 | yyval = yyvsp[1-yym]; | ||||
| 721 | else | ||||
| 722 | memset(&yyval, 0, sizeof yyval); | ||||
| 723 | switch (yyn) | ||||
| 724 | { | ||||
| 725 | case 5: | ||||
| 726 | #line 112 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 727 | { | ||||
| 728 | |||||
| 729 | vifi_t vifi; | ||||
| 730 | |||||
| 731 | if (order) | ||||
| 732 | fatal("phyints must appear before tunnels"); | ||||
| 733 | |||||
| 734 | for (vifi = 0, v = uvifs; | ||||
| 735 | vifi < numvifs; | ||||
| 736 | ++vifi, ++v) | ||||
| 737 | if (!(v->uv_flags & VIFF_TUNNEL0x1) && | ||||
| 738 | yyvsp[0].addr == v->uv_lcl_addr) | ||||
| 739 | break; | ||||
| 740 | |||||
| 741 | if (vifi == numvifs) | ||||
| 742 | fatal("%s is not a configured interface", | ||||
| 743 | inet_fmt(yyvsp[0].addr,s1)); | ||||
| 744 | |||||
| 745 | } | ||||
| 746 | break; | ||||
| 747 | case 7: | ||||
| 748 | #line 132 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 749 | { | ||||
| 750 | const char *ifname; | ||||
| 751 | struct ifreq ffr; | ||||
| 752 | vifi_t vifi; | ||||
| 753 | |||||
| 754 | order++; | ||||
| 755 | |||||
| 756 | ifname = ifconfaddr(yyvsp[-1].addr); | ||||
| 757 | if (ifname == 0) | ||||
| 758 | fatal("Tunnel local address %s is not mine", | ||||
| 759 | inet_fmt(yyvsp[-1].addr, s1)); | ||||
| 760 | |||||
| 761 | strlcpy(ffr.ifr_name, ifname, sizeof(ffr.ifr_name)); | ||||
| 762 | if (ioctl(udp_socket, SIOCGIFFLAGS(((unsigned long)0x80000000|(unsigned long)0x40000000) | ((sizeof (struct ifreq) & 0x1fff) << 16) | ((('i')) << 8) | ((17))), (char *)&ffr) == -1) | ||||
| 763 | fatal("ioctl SIOCGIFFLAGS on %s",ffr.ifr_name); | ||||
| 764 | if (ffr.ifr_flagsifr_ifru.ifru_flags & IFF_LOOPBACK0x8) | ||||
| 765 | fatal("Tunnel local address %s is a loopback interface", | ||||
| 766 | inet_fmt(yyvsp[-1].addr, s1)); | ||||
| 767 | |||||
| 768 | if (ifconfaddr(yyvsp[0].addr) != 0) | ||||
| 769 | fatal("Tunnel remote address %s is one of mine", | ||||
| 770 | inet_fmt(yyvsp[0].addr, s1)); | ||||
| 771 | |||||
| 772 | for (vifi = 0, v = uvifs; | ||||
| 773 | vifi < numvifs; | ||||
| 774 | ++vifi, ++v) | ||||
| 775 | if (v->uv_flags & VIFF_TUNNEL0x1) { | ||||
| 776 | if (yyvsp[0].addr == v->uv_rmt_addr) | ||||
| 777 | fatal("Duplicate tunnel to %s", | ||||
| 778 | inet_fmt(yyvsp[0].addr, s1)); | ||||
| 779 | } else if (!(v->uv_flags & VIFF_DISABLED0x0200)) { | ||||
| 780 | if ((yyvsp[0].addr & v->uv_subnetmask) == v->uv_subnet) | ||||
| 781 | fatal("Unnecessary tunnel to %s", | ||||
| 782 | inet_fmt(yyvsp[0].addr,s1)); | ||||
| 783 | } | ||||
| 784 | |||||
| 785 | if (numvifs == MAXVIFS32) | ||||
| 786 | fatal("too many vifs"); | ||||
| 787 | |||||
| 788 | v = &uvifs[numvifs]; | ||||
| 789 | v->uv_flags = VIFF_TUNNEL0x1; | ||||
| 790 | v->uv_metric = DEFAULT_METRIC1; | ||||
| 791 | v->uv_rate_limit= DEFAULT_TUN_RATE_LIMIT500; | ||||
| 792 | v->uv_threshold = DEFAULT_THRESHOLD1; | ||||
| 793 | v->uv_lcl_addr = yyvsp[-1].addr; | ||||
| 794 | v->uv_rmt_addr = yyvsp[0].addr; | ||||
| 795 | v->uv_subnet = 0; | ||||
| 796 | v->uv_subnetmask= 0; | ||||
| 797 | v->uv_subnetbcast= 0; | ||||
| 798 | strncpy(v->uv_name, ffr.ifr_name, IFNAMSIZ16); | ||||
| 799 | v->uv_groups = NULL((void *)0); | ||||
| 800 | v->uv_neighbors = NULL((void *)0); | ||||
| 801 | v->uv_acl = NULL((void *)0); | ||||
| 802 | v->uv_addrs = NULL((void *)0); | ||||
| 803 | |||||
| 804 | if (!(ffr.ifr_flagsifr_ifru.ifru_flags & IFF_UP0x1)) { | ||||
| 805 | v->uv_flags |= VIFF_DOWN0x0100; | ||||
| 806 | vifs_down = TRUE1; | ||||
| 807 | } | ||||
| 808 | } | ||||
| 809 | break; | ||||
| 810 | case 8: | ||||
| 811 | #line 193 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 812 | { | ||||
| 813 | logit(LOG_INFO6, 0, | ||||
| 814 | "installing tunnel from %s to %s as vif #%u - rate=%d", | ||||
| 815 | inet_fmt(yyvsp[-3].addr, s1), inet_fmt(yyvsp[-2].addr, s2), | ||||
| 816 | numvifs, v->uv_rate_limit); | ||||
| 817 | |||||
| 818 | ++numvifs; | ||||
| 819 | } | ||||
| 820 | break; | ||||
| 821 | case 9: | ||||
| 822 | #line 201 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 823 | { pruning = yyvsp[0].num; } | ||||
| 824 | break; | ||||
| 825 | case 10: | ||||
| 826 | #line 202 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 827 | { cache_lifetime = yyvsp[0].num; | ||||
| 828 | max_prune_lifetime = cache_lifetime * 2; | ||||
| 829 | } | ||||
| 830 | break; | ||||
| 831 | case 11: | ||||
| 832 | #line 205 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 833 | { if (numbounds >= MAXBOUNDS20) { | ||||
| 834 | fatal("Too many named boundaries (max %d)", MAXBOUNDS20); | ||||
| 835 | } | ||||
| 836 | |||||
| 837 | boundlist[numbounds].name = strdup(yyvsp[-1].ptr); | ||||
| 838 | boundlist[numbounds++].bound = yyvsp[0].addrmask; | ||||
| 839 | } | ||||
| 840 | break; | ||||
| 841 | case 15: | ||||
| 842 | #line 219 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 843 | { fatal("Source-route tunnels not supported"); } | ||||
| 844 | break; | ||||
| 845 | case 19: | ||||
| 846 | #line 227 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 847 | { v->uv_flags |= VIFF_DISABLED0x0200; } | ||||
| 848 | break; | ||||
| 849 | case 20: | ||||
| 850 | #line 228 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 851 | { v->uv_flags |= VIFF_IGMPV10x2000; } | ||||
| 852 | break; | ||||
| 853 | case 21: | ||||
| 854 | #line 229 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 855 | { | ||||
| 856 | u_int32_t subnet, mask; | ||||
| 857 | |||||
| 858 | mask = yyvsp[0].addr; | ||||
| 859 | subnet = v->uv_lcl_addr & mask; | ||||
| 860 | if (!inet_valid_subnet(subnet, mask)) | ||||
| 861 | fatal("Invalid netmask"); | ||||
| 862 | v->uv_subnet = subnet; | ||||
| 863 | v->uv_subnetmask = mask; | ||||
| 864 | v->uv_subnetbcast = subnet | ~mask; | ||||
| 865 | } | ||||
| 866 | break; | ||||
| 867 | case 22: | ||||
| 868 | #line 240 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 869 | { | ||||
| 870 | |||||
| 871 | warn("Expected address after netmask keyword, ignored"); | ||||
| 872 | |||||
| 873 | } | ||||
| 874 | break; | ||||
| 875 | case 23: | ||||
| 876 | #line 245 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 877 | { | ||||
| 878 | |||||
| 879 | struct phaddr *ph; | ||||
| 880 | |||||
| 881 | ph = malloc(sizeof(struct phaddr)); | ||||
| 882 | if (ph == NULL((void *)0)) | ||||
| 883 | fatal("out of memory"); | ||||
| 884 | if (yyvsp[0].addrmask.mask) { | ||||
| 885 | VAL_TO_MASK(ph->pa_subnetmask, yyvsp[0].addrmask.mask){ ph->pa_subnetmask = (__uint32_t)(__builtin_constant_p(~( (1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) ? (__uint32_t )(((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask)) ) - 1)) & 0xff) << 24 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) & 0xff00) << 8 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask ))) - 1)) & 0xff0000) >> 8 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) & 0xff000000) >> 24) : __swap32md(~((1 << (32 - (yyvsp[0].addrmask.mask ))) - 1))); };; | ||||
| 886 | } else | ||||
| 887 | ph->pa_subnetmask = v->uv_subnetmask; | ||||
| 888 | ph->pa_subnet = yyvsp[0].addrmask.addr & ph->pa_subnetmask; | ||||
| 889 | ph->pa_subnetbcast = ph->pa_subnet | ~ph->pa_subnetmask; | ||||
| 890 | if (yyvsp[0].addrmask.addr & ~ph->pa_subnetmask) | ||||
| 891 | warn("Extra subnet %s/%d has host bits set", | ||||
| 892 | inet_fmt(yyvsp[0].addrmask.addr,s1), yyvsp[0].addrmask.mask); | ||||
| 893 | ph->pa_next = v->uv_addrs; | ||||
| 894 | v->uv_addrs = ph; | ||||
| 895 | |||||
| 896 | } | ||||
| 897 | break; | ||||
| 898 | case 24: | ||||
| 899 | #line 265 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 900 | { | ||||
| 901 | |||||
| 902 | warn("Expected address after altnet keyword, ignored"); | ||||
| 903 | |||||
| 904 | } | ||||
| 905 | break; | ||||
| 906 | case 25: | ||||
| 907 | #line 272 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 908 | { if (yyvsp[0].num < 1 || yyvsp[0].num > 255) | ||||
| 909 | fatal("Invalid threshold %d",yyvsp[0].num); | ||||
| 910 | v->uv_threshold = yyvsp[0].num; | ||||
| 911 | } | ||||
| 912 | break; | ||||
| 913 | case 26: | ||||
| 914 | #line 276 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 915 | { | ||||
| 916 | |||||
| 917 | warn("Expected number after threshold keyword, ignored"); | ||||
| 918 | |||||
| 919 | } | ||||
| 920 | break; | ||||
| 921 | case 27: | ||||
| 922 | #line 281 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 923 | { if (yyvsp[0].num < 1 || yyvsp[0].num > UNREACHABLE32) | ||||
| 924 | fatal("Invalid metric %d",yyvsp[0].num); | ||||
| 925 | v->uv_metric = yyvsp[0].num; | ||||
| 926 | } | ||||
| 927 | break; | ||||
| 928 | case 28: | ||||
| 929 | #line 285 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 930 | { | ||||
| 931 | |||||
| 932 | warn("Expected number after metric keyword, ignored"); | ||||
| 933 | |||||
| 934 | } | ||||
| 935 | break; | ||||
| 936 | case 29: | ||||
| 937 | #line 290 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 938 | { if (yyvsp[0].num > MAX_RATE_LIMIT100000) | ||||
| 939 | fatal("Invalid rate_limit %d",yyvsp[0].num); | ||||
| 940 | v->uv_rate_limit = yyvsp[0].num; | ||||
| 941 | } | ||||
| 942 | break; | ||||
| 943 | case 30: | ||||
| 944 | #line 294 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 945 | { | ||||
| 946 | |||||
| 947 | warn("Expected number after rate_limit keyword, ignored"); | ||||
| 948 | |||||
| 949 | } | ||||
| 950 | break; | ||||
| 951 | case 31: | ||||
| 952 | #line 299 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 953 | { | ||||
| 954 | |||||
| 955 | struct vif_acl *v_acl; | ||||
| 956 | |||||
| 957 | v_acl = malloc(sizeof(struct vif_acl)); | ||||
| 958 | if (v_acl == NULL((void *)0)) | ||||
| 959 | fatal("out of memory"); | ||||
| 960 | VAL_TO_MASK(v_acl->acl_mask, yyvsp[0].addrmask.mask){ v_acl->acl_mask = (__uint32_t)(__builtin_constant_p(~((1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) ? (__uint32_t )(((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask)) ) - 1)) & 0xff) << 24 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) & 0xff00) << 8 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask ))) - 1)) & 0xff0000) >> 8 | ((__uint32_t)(~((1 << (32 - (yyvsp[0].addrmask.mask))) - 1)) & 0xff000000) >> 24) : __swap32md(~((1 << (32 - (yyvsp[0].addrmask.mask ))) - 1))); };; | ||||
| 961 | v_acl->acl_addr = yyvsp[0].addrmask.addr & v_acl->acl_mask; | ||||
| 962 | if (yyvsp[0].addrmask.addr & ~v_acl->acl_mask) | ||||
| 963 | warn("Boundary spec %s/%d has host bits set", | ||||
| 964 | inet_fmt(yyvsp[0].addrmask.addr,s1),yyvsp[0].addrmask.mask); | ||||
| 965 | v_acl->acl_next = v->uv_acl; | ||||
| 966 | v->uv_acl = v_acl; | ||||
| 967 | |||||
| 968 | } | ||||
| 969 | break; | ||||
| 970 | case 32: | ||||
| 971 | #line 315 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 972 | { | ||||
| 973 | |||||
| 974 | warn("Expected boundary spec after boundary keyword, ignored"); | ||||
| 975 | |||||
| 976 | } | ||||
| 977 | break; | ||||
| 978 | case 33: | ||||
| 979 | #line 322 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 980 | { yyval.addr = yyvsp[0].addr; } | ||||
| 981 | break; | ||||
| 982 | case 34: | ||||
| 983 | #line 323 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 984 | { | ||||
| 985 | yyval.addr = valid_if(yyvsp[0].ptr); | ||||
| 986 | if (yyval.addr == 0) | ||||
| 987 | fatal("Invalid interface name %s",yyvsp[0].ptr); | ||||
| 988 | } | ||||
| 989 | break; | ||||
| 990 | case 35: | ||||
| 991 | #line 330 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 992 | { yyval.addr = yyvsp[0].addr; } | ||||
| 993 | break; | ||||
| 994 | case 36: | ||||
| 995 | #line 331 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 996 | { struct hostent *hp; | ||||
| 997 | |||||
| 998 | if ((hp = gethostbyname(yyvsp[0].ptr)) == NULL((void *)0)) | ||||
| 999 | fatal("No such host %s", yyvsp[0].ptr); | ||||
| 1000 | |||||
| 1001 | if (hp->h_addr_list[1]) | ||||
| 1002 | fatal("Hostname %s does not %s", | ||||
| 1003 | yyvsp[0].ptr, "map to a unique address"); | ||||
| 1004 | |||||
| 1005 | bcopy(hp->h_addr_list[0], &yyval.addr, | ||||
| 1006 | hp->h_length); | ||||
| 1007 | } | ||||
| 1008 | break; | ||||
| 1009 | case 37: | ||||
| 1010 | #line 344 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1011 | { yyval.addrmask = yyvsp[0].addrmask; } | ||||
| 1012 | break; | ||||
| 1013 | case 38: | ||||
| 1014 | #line 345 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1015 | { int i; | ||||
| 1016 | |||||
| 1017 | for (i=0; i < numbounds; i++) { | ||||
| 1018 | if (!strcmp(boundlist[i].name, yyvsp[0].ptr)) { | ||||
| |||||
| 1019 | yyval.addrmask = boundlist[i].bound; | ||||
| 1020 | break; | ||||
| 1021 | } | ||||
| 1022 | } | ||||
| 1023 | if (i == numbounds) { | ||||
| 1024 | fatal("Invalid boundary name %s",yyvsp[0].ptr); | ||||
| 1025 | } | ||||
| 1026 | } | ||||
| 1027 | break; | ||||
| 1028 | case 39: | ||||
| 1029 | #line 359 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1030 | { | ||||
| 1031 | |||||
| 1032 | if ((ntohl(yyvsp[0].addrmask.addr)(__uint32_t)(__builtin_constant_p(yyvsp[0].addrmask.addr) ? ( __uint32_t)(((__uint32_t)(yyvsp[0].addrmask.addr) & 0xff) << 24 | ((__uint32_t)(yyvsp[0].addrmask.addr) & 0xff00 ) << 8 | ((__uint32_t)(yyvsp[0].addrmask.addr) & 0xff0000 ) >> 8 | ((__uint32_t)(yyvsp[0].addrmask.addr) & 0xff000000 ) >> 24) : __swap32md(yyvsp[0].addrmask.addr)) & 0xff000000) != 0xef000000) { | ||||
| 1033 | fatal("Boundaries must be 239.x.x.x, not %s/%d", | ||||
| 1034 | inet_fmt(yyvsp[0].addrmask.addr, s1), yyvsp[0].addrmask.mask); | ||||
| 1035 | } | ||||
| 1036 | yyval.addrmask = yyvsp[0].addrmask; | ||||
| 1037 | |||||
| 1038 | } | ||||
| 1039 | break; | ||||
| 1040 | case 40: | ||||
| 1041 | #line 370 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1042 | { yyval.addrmask = yyvsp[0].addrmask; } | ||||
| 1043 | break; | ||||
| 1044 | case 41: | ||||
| 1045 | #line 371 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1046 | { yyval.addrmask.addr = yyvsp[0].addr; yyval.addrmask.mask = 0; } | ||||
| 1047 | break; | ||||
| 1048 | #line 1041 "cfparse.c" | ||||
| 1049 | } | ||||
| 1050 | yyssp -= yym; | ||||
| 1051 | yystate = *yyssp; | ||||
| 1052 | yyvsp -= yym; | ||||
| 1053 | yym = yylhs[yyn]; | ||||
| 1054 | if (yystate
| ||||
| 1055 | { | ||||
| 1056 | #if YYDEBUG0 | ||||
| 1057 | if (yydebug) | ||||
| 1058 | printf("%sdebug: after reduction, shifting from state 0 to\ | ||||
| 1059 | state %d\n", YYPREFIX"yy", YYFINAL1); | ||||
| 1060 | #endif | ||||
| 1061 | yystate = YYFINAL1; | ||||
| 1062 | *++yyssp = YYFINAL1; | ||||
| 1063 | *++yyvsp = yyval; | ||||
| 1064 | if (yychar < 0) | ||||
| 1065 | { | ||||
| 1066 | if ((yychar = yylex()) < 0) yychar = 0; | ||||
| 1067 | #if YYDEBUG0 | ||||
| 1068 | if (yydebug) | ||||
| 1069 | { | ||||
| 1070 | yys = 0; | ||||
| 1071 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 1072 | if (!yys) yys = "illegal-symbol"; | ||||
| 1073 | printf("%sdebug: state %d, reading %d (%s)\n", | ||||
| 1074 | YYPREFIX"yy", YYFINAL1, yychar, yys); | ||||
| 1075 | } | ||||
| 1076 | #endif | ||||
| 1077 | } | ||||
| 1078 | if (yychar == 0) goto yyaccept; | ||||
| 1079 | goto yyloop; | ||||
| 1080 | } | ||||
| 1081 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | ||||
| 1082 | yyn <= YYTABLESIZE358 && yycheck[yyn] == yystate) | ||||
| 1083 | yystate = yytable[yyn]; | ||||
| 1084 | else | ||||
| 1085 | yystate = yydgoto[yym]; | ||||
| 1086 | #if YYDEBUG0 | ||||
| 1087 | if (yydebug) | ||||
| 1088 | printf("%sdebug: after reduction, shifting from state %d \ | ||||
| 1089 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | ||||
| 1090 | #endif | ||||
| 1091 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 1092 | { | ||||
| 1093 | goto yyoverflow; | ||||
| 1094 | } | ||||
| 1095 | *++yyssp = yystate; | ||||
| 1096 | *++yyvsp = yyval; | ||||
| 1097 | goto yyloop; | ||||
| 1098 | yyoverflow: | ||||
| 1099 | yyerror("yacc stack overflow"); | ||||
| 1100 | yyabort: | ||||
| 1101 | if (yyss) | ||||
| 1102 | free(yyss); | ||||
| 1103 | if (yyvs) | ||||
| 1104 | free(yyvs); | ||||
| 1105 | yyss = yyssp = NULL((void *)0); | ||||
| 1106 | yyvs = yyvsp = NULL((void *)0); | ||||
| 1107 | yystacksize = 0; | ||||
| 1108 | return (1); | ||||
| 1109 | yyaccept: | ||||
| 1110 | if (yyss) | ||||
| 1111 | free(yyss); | ||||
| 1112 | if (yyvs) | ||||
| 1113 | free(yyvs); | ||||
| 1114 | yyss = yyssp = NULL((void *)0); | ||||
| 1115 | yyvs = yyvsp = NULL((void *)0); | ||||
| 1116 | yystacksize = 0; | ||||
| 1117 | return (0); | ||||
| 1118 | } |