| File: | src/usr.sbin/mrouted/obj/cfparse.c |
| Warning: | line 890, column 22 Access to field 'pa_subnetmask' results in a dereference of a null pointer (loaded from variable 'ph') |
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(s) | ||||
| 366 | char *s; | ||||
| 367 | { | ||||
| 368 | logit(LOG_ERR3, 0, "%s: %s near line %d", configfilename, s, lineno); | ||||
| 369 | } | ||||
| 370 | |||||
| 371 | static char * | ||||
| 372 | next_word() | ||||
| 373 | { | ||||
| 374 | static char buf[1024]; | ||||
| 375 | static char *p=NULL((void *)0); | ||||
| 376 | extern FILE *f; | ||||
| 377 | char *q; | ||||
| 378 | |||||
| 379 | while (1) { | ||||
| 380 | if (!p || !*p) { | ||||
| 381 | lineno++; | ||||
| 382 | if (fgets(buf, sizeof(buf), f) == NULL((void *)0)) | ||||
| 383 | return NULL((void *)0); | ||||
| 384 | p = buf; | ||||
| 385 | } | ||||
| 386 | while (*p && (*p == ' ' || *p == '\t')) /* skip whitespace */ | ||||
| 387 | p++; | ||||
| 388 | if (*p == '#') { | ||||
| 389 | p = NULL((void *)0); /* skip comments */ | ||||
| 390 | continue; | ||||
| 391 | } | ||||
| 392 | q = p; | ||||
| 393 | while (*p && *p != ' ' && *p != '\t' && *p != '\n') | ||||
| 394 | p++; /* find next whitespace */ | ||||
| 395 | *p++ = '\0'; /* null-terminate string */ | ||||
| 396 | |||||
| 397 | if (!*q) { | ||||
| 398 | p = NULL((void *)0); | ||||
| 399 | continue; /* if 0-length string, read another line */ | ||||
| 400 | } | ||||
| 401 | |||||
| 402 | return q; | ||||
| 403 | } | ||||
| 404 | } | ||||
| 405 | |||||
| 406 | static int | ||||
| 407 | yylex() | ||||
| 408 | { | ||||
| 409 | int n; | ||||
| 410 | u_int32_t addr; | ||||
| 411 | char *q; | ||||
| 412 | |||||
| 413 | if ((q = next_word()) == NULL((void *)0)) { | ||||
| 414 | return 0; | ||||
| 415 | } | ||||
| 416 | |||||
| 417 | if (!strcmp(q,"cache_lifetime")) | ||||
| 418 | return CACHE_LIFETIME257; | ||||
| 419 | if (!strcmp(q,"pruning")) | ||||
| 420 | return PRUNING258; | ||||
| 421 | if (!strcmp(q,"phyint")) | ||||
| 422 | return PHYINT259; | ||||
| 423 | if (!strcmp(q,"tunnel")) | ||||
| 424 | return TUNNEL260; | ||||
| 425 | if (!strcmp(q,"disable")) | ||||
| 426 | return DISABLE262; | ||||
| 427 | if (!strcmp(q,"metric")) | ||||
| 428 | return METRIC265; | ||||
| 429 | if (!strcmp(q,"threshold")) | ||||
| 430 | return THRESHOLD266; | ||||
| 431 | if (!strcmp(q,"rate_limit")) | ||||
| 432 | return RATE_LIMIT267; | ||||
| 433 | if (!strcmp(q,"srcrt") || !strcmp(q,"sourceroute")) | ||||
| 434 | return SRCRT264; | ||||
| 435 | if (!strcmp(q,"boundary")) | ||||
| 436 | return BOUNDARY268; | ||||
| 437 | if (!strcmp(q,"netmask")) | ||||
| 438 | return NETMASK269; | ||||
| 439 | if (!strcmp(q,"igmpv1")) | ||||
| 440 | return IGMPV1263; | ||||
| 441 | if (!strcmp(q,"altnet")) | ||||
| 442 | return ALTNET270; | ||||
| 443 | if (!strcmp(q,"name")) | ||||
| 444 | return NAME261; | ||||
| 445 | if (!strcmp(q,"on") || !strcmp(q,"yes")) { | ||||
| 446 | yylval.num = 1; | ||||
| 447 | return BOOLEAN271; | ||||
| 448 | } | ||||
| 449 | if (!strcmp(q,"off") || !strcmp(q,"no")) { | ||||
| 450 | yylval.num = 0; | ||||
| 451 | return BOOLEAN271; | ||||
| 452 | } | ||||
| 453 | if (sscanf(q,"%[.0-9]/%d%c",s1,&n,s2) == 2) { | ||||
| 454 | if ((addr = inet_parse(s1)) != 0xffffffff) { | ||||
| 455 | yylval.addrmask.mask = n; | ||||
| 456 | yylval.addrmask.addr = addr; | ||||
| 457 | return ADDRMASK274; | ||||
| 458 | } | ||||
| 459 | /* fall through to returning STRING */ | ||||
| 460 | } | ||||
| 461 | if (sscanf(q,"%[.0-9]%c",s1,s2) == 1) { | ||||
| 462 | if ((addr = inet_parse(s1)) != 0xffffffff && | ||||
| 463 | inet_valid_host(addr)) { | ||||
| 464 | yylval.addr = addr; | ||||
| 465 | return ADDR275; | ||||
| 466 | } | ||||
| 467 | } | ||||
| 468 | if (sscanf(q,"0x%8x%c",&n,s1) == 1) { | ||||
| 469 | yylval.addr = n; | ||||
| 470 | return ADDR275; | ||||
| 471 | } | ||||
| 472 | if (sscanf(q,"%d%c",&n,s1) == 1) { | ||||
| 473 | yylval.num = n; | ||||
| 474 | return NUMBER272; | ||||
| 475 | } | ||||
| 476 | yylval.ptr = q; | ||||
| 477 | return STRING273; | ||||
| 478 | } | ||||
| 479 | |||||
| 480 | void | ||||
| 481 | config_vifs_from_file() | ||||
| 482 | { | ||||
| 483 | extern FILE *f; | ||||
| 484 | |||||
| 485 | order = 0; | ||||
| 486 | numbounds = 0; | ||||
| 487 | lineno = 0; | ||||
| 488 | |||||
| 489 | if ((f = fopen(configfilename, "r")) == NULL((void *)0)) { | ||||
| 490 | if (errno(*__errno()) != ENOENT2) | ||||
| 491 | logit(LOG_ERR3, errno(*__errno()), "can't open %s", configfilename); | ||||
| 492 | return; | ||||
| 493 | } | ||||
| 494 | |||||
| 495 | yyparse(); | ||||
| 496 | |||||
| 497 | fclose(f); | ||||
| 498 | } | ||||
| 499 | |||||
| 500 | static u_int32_t | ||||
| 501 | valid_if(s) | ||||
| 502 | char *s; | ||||
| 503 | { | ||||
| 504 | register vifi_t vifi; | ||||
| 505 | register struct uvif *v; | ||||
| 506 | |||||
| 507 | for (vifi=0, v=uvifs; vifi<numvifs; vifi++, v++) | ||||
| 508 | if (!strcmp(v->uv_name, s)) | ||||
| 509 | return v->uv_lcl_addr; | ||||
| 510 | |||||
| 511 | return 0; | ||||
| 512 | } | ||||
| 513 | |||||
| 514 | static const char * | ||||
| 515 | ifconfaddr(a) | ||||
| 516 | u_int32_t a; | ||||
| 517 | { | ||||
| 518 | static char ifname[IFNAMSIZ16]; | ||||
| 519 | struct ifaddrs *ifap, *ifa; | ||||
| 520 | |||||
| 521 | if (getifaddrs(&ifap) != 0) | ||||
| 522 | return (NULL((void *)0)); | ||||
| 523 | |||||
| 524 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { | ||||
| 525 | if (ifa->ifa_addr != NULL((void *)0) && | ||||
| 526 | ifa->ifa_addr->sa_family == AF_INET2 && | ||||
| 527 | ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == a) { | ||||
| 528 | strlcpy(ifname, ifa->ifa_name, sizeof(ifname)); | ||||
| 529 | freeifaddrs(ifap); | ||||
| 530 | return (ifname); | ||||
| 531 | } | ||||
| 532 | } | ||||
| 533 | freeifaddrs(ifap); | ||||
| 534 | return (0); | ||||
| 535 | } | ||||
| 536 | #line 529 "cfparse.c" | ||||
| 537 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | ||||
| 538 | static int yygrowstack(void) | ||||
| 539 | { | ||||
| 540 | unsigned int newsize; | ||||
| 541 | long sslen; | ||||
| 542 | short *newss; | ||||
| 543 | YYSTYPE *newvs; | ||||
| 544 | |||||
| 545 | if ((newsize = yystacksize) == 0) | ||||
| 546 | newsize = YYINITSTACKSIZE200; | ||||
| 547 | else if (newsize >= YYMAXDEPTH10000) | ||||
| 548 | return -1; | ||||
| 549 | else if ((newsize *= 2) > YYMAXDEPTH10000) | ||||
| 550 | newsize = YYMAXDEPTH10000; | ||||
| 551 | sslen = yyssp - yyss; | ||||
| 552 | #ifdef SIZE_MAX | ||||
| 553 | #define YY_SIZE_MAX0xffffffffU SIZE_MAX | ||||
| 554 | #else | ||||
| 555 | #define YY_SIZE_MAX0xffffffffU 0xffffffffU | ||||
| 556 | #endif | ||||
| 557 | if (newsize && YY_SIZE_MAX0xffffffffU / newsize < sizeof *newss) | ||||
| 558 | goto bail; | ||||
| 559 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | ||||
| 560 | if (newss == NULL((void *)0)) | ||||
| 561 | goto bail; | ||||
| 562 | yyss = newss; | ||||
| 563 | yyssp = newss + sslen; | ||||
| 564 | if (newsize && YY_SIZE_MAX0xffffffffU / newsize < sizeof *newvs) | ||||
| 565 | goto bail; | ||||
| 566 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | ||||
| 567 | if (newvs == NULL((void *)0)) | ||||
| 568 | goto bail; | ||||
| 569 | yyvs = newvs; | ||||
| 570 | yyvsp = newvs + sslen; | ||||
| 571 | yystacksize = newsize; | ||||
| 572 | yysslim = yyss + newsize - 1; | ||||
| 573 | return 0; | ||||
| 574 | bail: | ||||
| 575 | if (yyss) | ||||
| 576 | free(yyss); | ||||
| 577 | if (yyvs) | ||||
| 578 | free(yyvs); | ||||
| 579 | yyss = yyssp = NULL((void *)0); | ||||
| 580 | yyvs = yyvsp = NULL((void *)0); | ||||
| 581 | yystacksize = 0; | ||||
| 582 | return -1; | ||||
| 583 | } | ||||
| 584 | |||||
| 585 | #define YYABORTgoto yyabort goto yyabort | ||||
| 586 | #define YYREJECTgoto yyabort goto yyabort | ||||
| 587 | #define YYACCEPTgoto yyaccept goto yyaccept | ||||
| 588 | #define YYERRORgoto yyerrlab goto yyerrlab | ||||
| 589 | int | ||||
| 590 | yyparse(void) | ||||
| 591 | { | ||||
| 592 | int yym, yyn, yystate; | ||||
| 593 | #if YYDEBUG0 | ||||
| 594 | const char *yys; | ||||
| 595 | |||||
| 596 | if ((yys = getenv("YYDEBUG"))) | ||||
| 597 | { | ||||
| 598 | yyn = *yys; | ||||
| 599 | if (yyn >= '0' && yyn <= '9') | ||||
| 600 | yydebug = yyn - '0'; | ||||
| 601 | } | ||||
| 602 | #endif /* YYDEBUG */ | ||||
| 603 | |||||
| 604 | yynerrs = 0; | ||||
| 605 | yyerrflag = 0; | ||||
| 606 | yychar = (-1); | ||||
| 607 | |||||
| 608 | if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow; | ||||
| |||||
| 609 | yyssp = yyss; | ||||
| 610 | yyvsp = yyvs; | ||||
| 611 | *yyssp = yystate = 0; | ||||
| 612 | |||||
| 613 | yyloop: | ||||
| 614 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | ||||
| 615 | if (yychar
| ||||
| 616 | { | ||||
| 617 | if ((yychar = yylex()) < 0) yychar = 0; | ||||
| 618 | #if YYDEBUG0 | ||||
| 619 | if (yydebug) | ||||
| 620 | { | ||||
| 621 | yys = 0; | ||||
| 622 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 623 | if (!yys) yys = "illegal-symbol"; | ||||
| 624 | printf("%sdebug: state %d, reading %d (%s)\n", | ||||
| 625 | YYPREFIX"yy", yystate, yychar, yys); | ||||
| 626 | } | ||||
| 627 | #endif | ||||
| 628 | } | ||||
| 629 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | ||||
| 630 | yyn
| ||||
| 631 | { | ||||
| 632 | #if YYDEBUG0 | ||||
| 633 | if (yydebug) | ||||
| 634 | printf("%sdebug: state %d, shifting to state %d\n", | ||||
| 635 | YYPREFIX"yy", yystate, yytable[yyn]); | ||||
| 636 | #endif | ||||
| 637 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 638 | { | ||||
| 639 | goto yyoverflow; | ||||
| 640 | } | ||||
| 641 | *++yyssp = yystate = yytable[yyn]; | ||||
| 642 | *++yyvsp = yylval; | ||||
| 643 | yychar = (-1); | ||||
| 644 | if (yyerrflag > 0) --yyerrflag; | ||||
| 645 | goto yyloop; | ||||
| 646 | } | ||||
| 647 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | ||||
| 648 | yyn
| ||||
| 649 | { | ||||
| 650 | yyn = yytable[yyn]; | ||||
| 651 | goto yyreduce; | ||||
| 652 | } | ||||
| 653 | if (yyerrflag
| ||||
| 654 | #if defined(__GNUC__4) | ||||
| 655 | goto yynewerror; | ||||
| 656 | #endif | ||||
| 657 | yynewerror: | ||||
| 658 | yyerror("syntax error"); | ||||
| 659 | #if defined(__GNUC__4) | ||||
| 660 | goto yyerrlab; | ||||
| 661 | #endif | ||||
| 662 | yyerrlab: | ||||
| 663 | ++yynerrs; | ||||
| 664 | yyinrecovery: | ||||
| 665 | if (yyerrflag < 3) | ||||
| 666 | { | ||||
| 667 | yyerrflag = 3; | ||||
| 668 | for (;;) | ||||
| 669 | { | ||||
| 670 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | ||||
| 671 | yyn <= YYTABLESIZE358 && yycheck[yyn] == YYERRCODE256) | ||||
| 672 | { | ||||
| 673 | #if YYDEBUG0 | ||||
| 674 | if (yydebug) | ||||
| 675 | printf("%sdebug: state %d, error recovery shifting\ | ||||
| 676 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | ||||
| 677 | #endif | ||||
| 678 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 679 | { | ||||
| 680 | goto yyoverflow; | ||||
| 681 | } | ||||
| 682 | *++yyssp = yystate = yytable[yyn]; | ||||
| 683 | *++yyvsp = yylval; | ||||
| 684 | goto yyloop; | ||||
| 685 | } | ||||
| 686 | else | ||||
| 687 | { | ||||
| 688 | #if YYDEBUG0 | ||||
| 689 | if (yydebug) | ||||
| 690 | printf("%sdebug: error recovery discarding state %d\n", | ||||
| 691 | YYPREFIX"yy", *yyssp); | ||||
| 692 | #endif | ||||
| 693 | if (yyssp <= yyss) goto yyabort; | ||||
| 694 | --yyssp; | ||||
| 695 | --yyvsp; | ||||
| 696 | } | ||||
| 697 | } | ||||
| 698 | } | ||||
| 699 | else | ||||
| 700 | { | ||||
| 701 | if (yychar == 0) goto yyabort; | ||||
| 702 | #if YYDEBUG0 | ||||
| 703 | if (yydebug) | ||||
| 704 | { | ||||
| 705 | yys = 0; | ||||
| 706 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 707 | if (!yys) yys = "illegal-symbol"; | ||||
| 708 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | ||||
| 709 | YYPREFIX"yy", yystate, yychar, yys); | ||||
| 710 | } | ||||
| 711 | #endif | ||||
| 712 | yychar = (-1); | ||||
| 713 | goto yyloop; | ||||
| 714 | } | ||||
| 715 | yyreduce: | ||||
| 716 | #if YYDEBUG0 | ||||
| 717 | if (yydebug) | ||||
| 718 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | ||||
| 719 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | ||||
| 720 | #endif | ||||
| 721 | yym = yylen[yyn]; | ||||
| 722 | if (yym
| ||||
| 723 | yyval = yyvsp[1-yym]; | ||||
| 724 | else | ||||
| 725 | memset(&yyval, 0, sizeof yyval); | ||||
| 726 | switch (yyn) | ||||
| 727 | { | ||||
| 728 | case 5: | ||||
| 729 | #line 112 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 730 | { | ||||
| 731 | |||||
| 732 | vifi_t vifi; | ||||
| 733 | |||||
| 734 | if (order) | ||||
| 735 | fatal("phyints must appear before tunnels"); | ||||
| 736 | |||||
| 737 | for (vifi = 0, v = uvifs; | ||||
| 738 | vifi < numvifs; | ||||
| 739 | ++vifi, ++v) | ||||
| 740 | if (!(v->uv_flags & VIFF_TUNNEL0x1) && | ||||
| 741 | yyvsp[0].addr == v->uv_lcl_addr) | ||||
| 742 | break; | ||||
| 743 | |||||
| 744 | if (vifi == numvifs) | ||||
| 745 | fatal("%s is not a configured interface", | ||||
| 746 | inet_fmt(yyvsp[0].addr,s1)); | ||||
| 747 | |||||
| 748 | } | ||||
| 749 | break; | ||||
| 750 | case 7: | ||||
| 751 | #line 132 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 752 | { | ||||
| 753 | const char *ifname; | ||||
| 754 | struct ifreq ffr; | ||||
| 755 | vifi_t vifi; | ||||
| 756 | |||||
| 757 | order++; | ||||
| 758 | |||||
| 759 | ifname = ifconfaddr(yyvsp[-1].addr); | ||||
| 760 | if (ifname == 0) | ||||
| 761 | fatal("Tunnel local address %s is not mine", | ||||
| 762 | inet_fmt(yyvsp[-1].addr, s1)); | ||||
| 763 | |||||
| 764 | strlcpy(ffr.ifr_name, ifname, sizeof(ffr.ifr_name)); | ||||
| 765 | if (ioctl(udp_socket, SIOCGIFFLAGS(((unsigned long)0x80000000|(unsigned long)0x40000000) | ((sizeof (struct ifreq) & 0x1fff) << 16) | ((('i')) << 8) | ((17))), (char *)&ffr) == -1) | ||||
| 766 | fatal("ioctl SIOCGIFFLAGS on %s",ffr.ifr_name); | ||||
| 767 | if (ffr.ifr_flagsifr_ifru.ifru_flags & IFF_LOOPBACK0x8) | ||||
| 768 | fatal("Tunnel local address %s is a loopback interface", | ||||
| 769 | inet_fmt(yyvsp[-1].addr, s1)); | ||||
| 770 | |||||
| 771 | if (ifconfaddr(yyvsp[0].addr) != 0) | ||||
| 772 | fatal("Tunnel remote address %s is one of mine", | ||||
| 773 | inet_fmt(yyvsp[0].addr, s1)); | ||||
| 774 | |||||
| 775 | for (vifi = 0, v = uvifs; | ||||
| 776 | vifi < numvifs; | ||||
| 777 | ++vifi, ++v) | ||||
| 778 | if (v->uv_flags & VIFF_TUNNEL0x1) { | ||||
| 779 | if (yyvsp[0].addr == v->uv_rmt_addr) | ||||
| 780 | fatal("Duplicate tunnel to %s", | ||||
| 781 | inet_fmt(yyvsp[0].addr, s1)); | ||||
| 782 | } else if (!(v->uv_flags & VIFF_DISABLED0x0200)) { | ||||
| 783 | if ((yyvsp[0].addr & v->uv_subnetmask) == v->uv_subnet) | ||||
| 784 | fatal("Unnecessary tunnel to %s", | ||||
| 785 | inet_fmt(yyvsp[0].addr,s1)); | ||||
| 786 | } | ||||
| 787 | |||||
| 788 | if (numvifs == MAXVIFS32) | ||||
| 789 | fatal("too many vifs"); | ||||
| 790 | |||||
| 791 | v = &uvifs[numvifs]; | ||||
| 792 | v->uv_flags = VIFF_TUNNEL0x1; | ||||
| 793 | v->uv_metric = DEFAULT_METRIC1; | ||||
| 794 | v->uv_rate_limit= DEFAULT_TUN_RATE_LIMIT500; | ||||
| 795 | v->uv_threshold = DEFAULT_THRESHOLD1; | ||||
| 796 | v->uv_lcl_addr = yyvsp[-1].addr; | ||||
| 797 | v->uv_rmt_addr = yyvsp[0].addr; | ||||
| 798 | v->uv_subnet = 0; | ||||
| 799 | v->uv_subnetmask= 0; | ||||
| 800 | v->uv_subnetbcast= 0; | ||||
| 801 | strncpy(v->uv_name, ffr.ifr_name, IFNAMSIZ16); | ||||
| 802 | v->uv_groups = NULL((void *)0); | ||||
| 803 | v->uv_neighbors = NULL((void *)0); | ||||
| 804 | v->uv_acl = NULL((void *)0); | ||||
| 805 | v->uv_addrs = NULL((void *)0); | ||||
| 806 | |||||
| 807 | if (!(ffr.ifr_flagsifr_ifru.ifru_flags & IFF_UP0x1)) { | ||||
| 808 | v->uv_flags |= VIFF_DOWN0x0100; | ||||
| 809 | vifs_down = TRUE1; | ||||
| 810 | } | ||||
| 811 | } | ||||
| 812 | break; | ||||
| 813 | case 8: | ||||
| 814 | #line 193 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 815 | { | ||||
| 816 | logit(LOG_INFO6, 0, | ||||
| 817 | "installing tunnel from %s to %s as vif #%u - rate=%d", | ||||
| 818 | inet_fmt(yyvsp[-3].addr, s1), inet_fmt(yyvsp[-2].addr, s2), | ||||
| 819 | numvifs, v->uv_rate_limit); | ||||
| 820 | |||||
| 821 | ++numvifs; | ||||
| 822 | } | ||||
| 823 | break; | ||||
| 824 | case 9: | ||||
| 825 | #line 201 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 826 | { pruning = yyvsp[0].num; } | ||||
| 827 | break; | ||||
| 828 | case 10: | ||||
| 829 | #line 202 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 830 | { cache_lifetime = yyvsp[0].num; | ||||
| 831 | max_prune_lifetime = cache_lifetime * 2; | ||||
| 832 | } | ||||
| 833 | break; | ||||
| 834 | case 11: | ||||
| 835 | #line 205 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 836 | { if (numbounds >= MAXBOUNDS20) { | ||||
| 837 | fatal("Too many named boundaries (max %d)", MAXBOUNDS20); | ||||
| 838 | } | ||||
| 839 | |||||
| 840 | boundlist[numbounds].name = strdup(yyvsp[-1].ptr); | ||||
| 841 | boundlist[numbounds++].bound = yyvsp[0].addrmask; | ||||
| 842 | } | ||||
| 843 | break; | ||||
| 844 | case 15: | ||||
| 845 | #line 219 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 846 | { fatal("Source-route tunnels not supported"); } | ||||
| 847 | break; | ||||
| 848 | case 19: | ||||
| 849 | #line 227 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 850 | { v->uv_flags |= VIFF_DISABLED0x0200; } | ||||
| 851 | break; | ||||
| 852 | case 20: | ||||
| 853 | #line 228 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 854 | { v->uv_flags |= VIFF_IGMPV10x2000; } | ||||
| 855 | break; | ||||
| 856 | case 21: | ||||
| 857 | #line 229 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 858 | { | ||||
| 859 | u_int32_t subnet, mask; | ||||
| 860 | |||||
| 861 | mask = yyvsp[0].addr; | ||||
| 862 | subnet = v->uv_lcl_addr & mask; | ||||
| 863 | if (!inet_valid_subnet(subnet, mask)) | ||||
| 864 | fatal("Invalid netmask"); | ||||
| 865 | v->uv_subnet = subnet; | ||||
| 866 | v->uv_subnetmask = mask; | ||||
| 867 | v->uv_subnetbcast = subnet | ~mask; | ||||
| 868 | } | ||||
| 869 | break; | ||||
| 870 | case 22: | ||||
| 871 | #line 240 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 872 | { | ||||
| 873 | |||||
| 874 | warn("Expected address after netmask keyword, ignored"); | ||||
| 875 | |||||
| 876 | } | ||||
| 877 | break; | ||||
| 878 | case 23: | ||||
| 879 | #line 245 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 880 | { | ||||
| 881 | |||||
| 882 | struct phaddr *ph; | ||||
| 883 | |||||
| 884 | ph = malloc(sizeof(struct phaddr)); | ||||
| 885 | if (ph == NULL((void *)0)) | ||||
| 886 | fatal("out of memory"); | ||||
| 887 | if (yyvsp[0].addrmask.mask) { | ||||
| 888 | 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))); };; | ||||
| 889 | } else | ||||
| 890 | ph->pa_subnetmask = v->uv_subnetmask; | ||||
| |||||
| 891 | ph->pa_subnet = yyvsp[0].addrmask.addr & ph->pa_subnetmask; | ||||
| 892 | ph->pa_subnetbcast = ph->pa_subnet | ~ph->pa_subnetmask; | ||||
| 893 | if (yyvsp[0].addrmask.addr & ~ph->pa_subnetmask) | ||||
| 894 | warn("Extra subnet %s/%d has host bits set", | ||||
| 895 | inet_fmt(yyvsp[0].addrmask.addr,s1), yyvsp[0].addrmask.mask); | ||||
| 896 | ph->pa_next = v->uv_addrs; | ||||
| 897 | v->uv_addrs = ph; | ||||
| 898 | |||||
| 899 | } | ||||
| 900 | break; | ||||
| 901 | case 24: | ||||
| 902 | #line 265 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 903 | { | ||||
| 904 | |||||
| 905 | warn("Expected address after altnet keyword, ignored"); | ||||
| 906 | |||||
| 907 | } | ||||
| 908 | break; | ||||
| 909 | case 25: | ||||
| 910 | #line 272 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 911 | { if (yyvsp[0].num < 1 || yyvsp[0].num > 255) | ||||
| 912 | fatal("Invalid threshold %d",yyvsp[0].num); | ||||
| 913 | v->uv_threshold = yyvsp[0].num; | ||||
| 914 | } | ||||
| 915 | break; | ||||
| 916 | case 26: | ||||
| 917 | #line 276 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 918 | { | ||||
| 919 | |||||
| 920 | warn("Expected number after threshold keyword, ignored"); | ||||
| 921 | |||||
| 922 | } | ||||
| 923 | break; | ||||
| 924 | case 27: | ||||
| 925 | #line 281 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 926 | { if (yyvsp[0].num < 1 || yyvsp[0].num > UNREACHABLE32) | ||||
| 927 | fatal("Invalid metric %d",yyvsp[0].num); | ||||
| 928 | v->uv_metric = yyvsp[0].num; | ||||
| 929 | } | ||||
| 930 | break; | ||||
| 931 | case 28: | ||||
| 932 | #line 285 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 933 | { | ||||
| 934 | |||||
| 935 | warn("Expected number after metric keyword, ignored"); | ||||
| 936 | |||||
| 937 | } | ||||
| 938 | break; | ||||
| 939 | case 29: | ||||
| 940 | #line 290 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 941 | { if (yyvsp[0].num > MAX_RATE_LIMIT100000) | ||||
| 942 | fatal("Invalid rate_limit %d",yyvsp[0].num); | ||||
| 943 | v->uv_rate_limit = yyvsp[0].num; | ||||
| 944 | } | ||||
| 945 | break; | ||||
| 946 | case 30: | ||||
| 947 | #line 294 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 948 | { | ||||
| 949 | |||||
| 950 | warn("Expected number after rate_limit keyword, ignored"); | ||||
| 951 | |||||
| 952 | } | ||||
| 953 | break; | ||||
| 954 | case 31: | ||||
| 955 | #line 299 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 956 | { | ||||
| 957 | |||||
| 958 | struct vif_acl *v_acl; | ||||
| 959 | |||||
| 960 | v_acl = malloc(sizeof(struct vif_acl)); | ||||
| 961 | if (v_acl == NULL((void *)0)) | ||||
| 962 | fatal("out of memory"); | ||||
| 963 | 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))); };; | ||||
| 964 | v_acl->acl_addr = yyvsp[0].addrmask.addr & v_acl->acl_mask; | ||||
| 965 | if (yyvsp[0].addrmask.addr & ~v_acl->acl_mask) | ||||
| 966 | warn("Boundary spec %s/%d has host bits set", | ||||
| 967 | inet_fmt(yyvsp[0].addrmask.addr,s1),yyvsp[0].addrmask.mask); | ||||
| 968 | v_acl->acl_next = v->uv_acl; | ||||
| 969 | v->uv_acl = v_acl; | ||||
| 970 | |||||
| 971 | } | ||||
| 972 | break; | ||||
| 973 | case 32: | ||||
| 974 | #line 315 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 975 | { | ||||
| 976 | |||||
| 977 | warn("Expected boundary spec after boundary keyword, ignored"); | ||||
| 978 | |||||
| 979 | } | ||||
| 980 | break; | ||||
| 981 | case 33: | ||||
| 982 | #line 322 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 983 | { yyval.addr = yyvsp[0].addr; } | ||||
| 984 | break; | ||||
| 985 | case 34: | ||||
| 986 | #line 323 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 987 | { | ||||
| 988 | yyval.addr = valid_if(yyvsp[0].ptr); | ||||
| 989 | if (yyval.addr == 0) | ||||
| 990 | fatal("Invalid interface name %s",yyvsp[0].ptr); | ||||
| 991 | } | ||||
| 992 | break; | ||||
| 993 | case 35: | ||||
| 994 | #line 330 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 995 | { yyval.addr = yyvsp[0].addr; } | ||||
| 996 | break; | ||||
| 997 | case 36: | ||||
| 998 | #line 331 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 999 | { struct hostent *hp; | ||||
| 1000 | |||||
| 1001 | if ((hp = gethostbyname(yyvsp[0].ptr)) == NULL((void *)0)) | ||||
| 1002 | fatal("No such host %s", yyvsp[0].ptr); | ||||
| 1003 | |||||
| 1004 | if (hp->h_addr_list[1]) | ||||
| 1005 | fatal("Hostname %s does not %s", | ||||
| 1006 | yyvsp[0].ptr, "map to a unique address"); | ||||
| 1007 | |||||
| 1008 | bcopy(hp->h_addr_list[0], &yyval.addr, | ||||
| 1009 | hp->h_length); | ||||
| 1010 | } | ||||
| 1011 | break; | ||||
| 1012 | case 37: | ||||
| 1013 | #line 344 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1014 | { yyval.addrmask = yyvsp[0].addrmask; } | ||||
| 1015 | break; | ||||
| 1016 | case 38: | ||||
| 1017 | #line 345 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1018 | { int i; | ||||
| 1019 | |||||
| 1020 | for (i=0; i < numbounds; i++) { | ||||
| 1021 | if (!strcmp(boundlist[i].name, yyvsp[0].ptr)) { | ||||
| 1022 | yyval.addrmask = boundlist[i].bound; | ||||
| 1023 | break; | ||||
| 1024 | } | ||||
| 1025 | } | ||||
| 1026 | if (i == numbounds) { | ||||
| 1027 | fatal("Invalid boundary name %s",yyvsp[0].ptr); | ||||
| 1028 | } | ||||
| 1029 | } | ||||
| 1030 | break; | ||||
| 1031 | case 39: | ||||
| 1032 | #line 359 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1033 | { | ||||
| 1034 | |||||
| 1035 | 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) { | ||||
| 1036 | fatal("Boundaries must be 239.x.x.x, not %s/%d", | ||||
| 1037 | inet_fmt(yyvsp[0].addrmask.addr, s1), yyvsp[0].addrmask.mask); | ||||
| 1038 | } | ||||
| 1039 | yyval.addrmask = yyvsp[0].addrmask; | ||||
| 1040 | |||||
| 1041 | } | ||||
| 1042 | break; | ||||
| 1043 | case 40: | ||||
| 1044 | #line 370 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1045 | { yyval.addrmask = yyvsp[0].addrmask; } | ||||
| 1046 | break; | ||||
| 1047 | case 41: | ||||
| 1048 | #line 371 "/usr/src/usr.sbin/mrouted/cfparse.y" | ||||
| 1049 | { yyval.addrmask.addr = yyvsp[0].addr; yyval.addrmask.mask = 0; } | ||||
| 1050 | break; | ||||
| 1051 | #line 1044 "cfparse.c" | ||||
| 1052 | } | ||||
| 1053 | yyssp -= yym; | ||||
| 1054 | yystate = *yyssp; | ||||
| 1055 | yyvsp -= yym; | ||||
| 1056 | yym = yylhs[yyn]; | ||||
| 1057 | if (yystate
| ||||
| 1058 | { | ||||
| 1059 | #if YYDEBUG0 | ||||
| 1060 | if (yydebug) | ||||
| 1061 | printf("%sdebug: after reduction, shifting from state 0 to\ | ||||
| 1062 | state %d\n", YYPREFIX"yy", YYFINAL1); | ||||
| 1063 | #endif | ||||
| 1064 | yystate = YYFINAL1; | ||||
| 1065 | *++yyssp = YYFINAL1; | ||||
| 1066 | *++yyvsp = yyval; | ||||
| 1067 | if (yychar < 0) | ||||
| 1068 | { | ||||
| 1069 | if ((yychar = yylex()) < 0) yychar = 0; | ||||
| 1070 | #if YYDEBUG0 | ||||
| 1071 | if (yydebug) | ||||
| 1072 | { | ||||
| 1073 | yys = 0; | ||||
| 1074 | if (yychar <= YYMAXTOKEN275) yys = yyname[yychar]; | ||||
| 1075 | if (!yys) yys = "illegal-symbol"; | ||||
| 1076 | printf("%sdebug: state %d, reading %d (%s)\n", | ||||
| 1077 | YYPREFIX"yy", YYFINAL1, yychar, yys); | ||||
| 1078 | } | ||||
| 1079 | #endif | ||||
| 1080 | } | ||||
| 1081 | if (yychar == 0) goto yyaccept; | ||||
| 1082 | goto yyloop; | ||||
| 1083 | } | ||||
| 1084 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | ||||
| 1085 | yyn <= YYTABLESIZE358 && yycheck[yyn] == yystate) | ||||
| 1086 | yystate = yytable[yyn]; | ||||
| 1087 | else | ||||
| 1088 | yystate = yydgoto[yym]; | ||||
| 1089 | #if YYDEBUG0 | ||||
| 1090 | if (yydebug) | ||||
| 1091 | printf("%sdebug: after reduction, shifting from state %d \ | ||||
| 1092 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | ||||
| 1093 | #endif | ||||
| 1094 | if (yyssp >= yysslim && yygrowstack()) | ||||
| 1095 | { | ||||
| 1096 | goto yyoverflow; | ||||
| 1097 | } | ||||
| 1098 | *++yyssp = yystate; | ||||
| 1099 | *++yyvsp = yyval; | ||||
| 1100 | goto yyloop; | ||||
| 1101 | yyoverflow: | ||||
| 1102 | yyerror("yacc stack overflow"); | ||||
| 1103 | yyabort: | ||||
| 1104 | if (yyss) | ||||
| 1105 | free(yyss); | ||||
| 1106 | if (yyvs) | ||||
| 1107 | free(yyvs); | ||||
| 1108 | yyss = yyssp = NULL((void *)0); | ||||
| 1109 | yyvs = yyvsp = NULL((void *)0); | ||||
| 1110 | yystacksize = 0; | ||||
| 1111 | return (1); | ||||
| 1112 | yyaccept: | ||||
| 1113 | if (yyss) | ||||
| 1114 | free(yyss); | ||||
| 1115 | if (yyvs) | ||||
| 1116 | free(yyvs); | ||||
| 1117 | yyss = yyssp = NULL((void *)0); | ||||
| 1118 | yyvs = yyvsp = NULL((void *)0); | ||||
| 1119 | yystacksize = 0; | ||||
| 1120 | return (0); | ||||
| 1121 | } |