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