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