| File: | src/usr.sbin/ldpd/obj/parse.c |
| Warning: | line 1460, column 13 Attempt to free released memory |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | #include <stdlib.h> | |||
| 2 | #include <string.h> | |||
| 3 | #define YYBYACC1 1 | |||
| 4 | #define YYMAJOR1 1 | |||
| 5 | #define YYMINOR9 9 | |||
| 6 | #define YYLEXyylex() yylex() | |||
| 7 | #define YYEMPTY-1 -1 | |||
| 8 | #define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1)) | |||
| 9 | #define yyerrok(yyerrflag=0) (yyerrflag=0) | |||
| 10 | #define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0) | |||
| 11 | #define YYPREFIX"yy" "yy" | |||
| 12 | #line 26 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 13 | #include <sys/stat.h> | |||
| 14 | #include <sys/types.h> | |||
| 15 | #include <sys/socket.h> | |||
| 16 | #include <arpa/inet.h> | |||
| 17 | #include <ctype.h> | |||
| 18 | #include <err.h> | |||
| 19 | #include <unistd.h> | |||
| 20 | #include <ifaddrs.h> | |||
| 21 | #include <net/if_types.h> | |||
| 22 | #include <limits.h> | |||
| 23 | #include <stdio.h> | |||
| 24 | #include <syslog.h> | |||
| 25 | #include <errno(*__errno()).h> | |||
| 26 | #include <netdb.h> | |||
| 27 | ||||
| 28 | #include "ldpd.h" | |||
| 29 | #include "ldpe.h" | |||
| 30 | #include "lde.h" | |||
| 31 | #include "log.h" | |||
| 32 | ||||
| 33 | struct file { | |||
| 34 | TAILQ_ENTRY(file)struct { struct file *tqe_next; struct file **tqe_prev; } entry; | |||
| 35 | FILE *stream; | |||
| 36 | char *name; | |||
| 37 | size_t ungetpos; | |||
| 38 | size_t ungetsize; | |||
| 39 | u_char *ungetbuf; | |||
| 40 | int eof_reached; | |||
| 41 | int lineno; | |||
| 42 | int errors; | |||
| 43 | }; | |||
| 44 | TAILQ_HEAD(files, file)struct files { struct file *tqh_first; struct file **tqh_last ; }; | |||
| 45 | ||||
| 46 | struct sym { | |||
| 47 | TAILQ_ENTRY(sym)struct { struct sym *tqe_next; struct sym **tqe_prev; } entry; | |||
| 48 | int used; | |||
| 49 | int persist; | |||
| 50 | char *nam; | |||
| 51 | char *val; | |||
| 52 | }; | |||
| 53 | TAILQ_HEAD(symhead, sym)struct symhead { struct sym *tqh_first; struct sym **tqh_last ; }; | |||
| 54 | ||||
| 55 | struct config_defaults { | |||
| 56 | uint16_t keepalive; | |||
| 57 | uint16_t lhello_holdtime; | |||
| 58 | uint16_t lhello_interval; | |||
| 59 | uint16_t thello_holdtime; | |||
| 60 | uint16_t thello_interval; | |||
| 61 | union ldpd_addr trans_addr; | |||
| 62 | int afflags; | |||
| 63 | uint8_t pwflags; | |||
| 64 | }; | |||
| 65 | ||||
| 66 | typedef struct { | |||
| 67 | union { | |||
| 68 | int64_t number; | |||
| 69 | char *string; | |||
| 70 | struct in_addr routerid; | |||
| 71 | struct ldp_auth *auth; | |||
| 72 | } v; | |||
| 73 | int lineno; | |||
| 74 | } YYSTYPE; | |||
| 75 | ||||
| 76 | static int yyerror(const char *, ...) | |||
| 77 | __attribute__((__format__ (printf, 1, 2))) | |||
| 78 | __attribute__((__nonnull__ (1))); | |||
| 79 | static int kw_cmp(const void *, const void *); | |||
| 80 | static int lookup(char *); | |||
| 81 | static int igetc(void); | |||
| 82 | static int lgetc(int); | |||
| 83 | void lungetc(int); | |||
| 84 | static int findeol(void); | |||
| 85 | static int yylex(void); | |||
| 86 | static int check_file_secrecy(int, const char *); | |||
| 87 | static struct file *pushfile(const char *, int); | |||
| 88 | static int popfile(void); | |||
| 89 | static int yyparse(void); | |||
| 90 | static int symset(const char *, const char *, int); | |||
| 91 | static char *symget(const char *); | |||
| 92 | static struct iface *conf_get_if(struct kif *); | |||
| 93 | static struct tnbr *conf_get_tnbr(union ldpd_addr *); | |||
| 94 | static struct nbr_params *conf_get_nbrp(struct in_addr); | |||
| 95 | static struct l2vpn *conf_get_l2vpn(char *); | |||
| 96 | static struct l2vpn_if *conf_get_l2vpn_if(struct l2vpn *, struct kif *); | |||
| 97 | static struct l2vpn_pw *conf_get_l2vpn_pw(struct l2vpn *, struct kif *); | |||
| 98 | int conf_check_rdomain(unsigned int); | |||
| 99 | static void clear_config(struct ldpd_conf *xconf); | |||
| 100 | static uint32_t get_rtr_id(void); | |||
| 101 | static int get_address(const char *, union ldpd_addr *); | |||
| 102 | static int get_af_address(const char *, int *, union ldpd_addr *); | |||
| 103 | static int str2key(char *, const char *, int); | |||
| 104 | ||||
| 105 | static struct file *file, *topfile; | |||
| 106 | static struct files files = TAILQ_HEAD_INITIALIZER(files){ ((void *)0), &(files).tqh_first }; | |||
| 107 | static struct symhead symhead = TAILQ_HEAD_INITIALIZER(symhead){ ((void *)0), &(symhead).tqh_first }; | |||
| 108 | static struct ldpd_conf *conf; | |||
| 109 | static int errors; | |||
| 110 | ||||
| 111 | static int af; | |||
| 112 | static struct ldpd_af_conf *af_conf; | |||
| 113 | static struct iface *iface; | |||
| 114 | static struct iface_af *ia; | |||
| 115 | static struct tnbr *tnbr; | |||
| 116 | static struct nbr_params *nbrp; | |||
| 117 | static struct l2vpn *l2vpn; | |||
| 118 | static struct l2vpn_pw *pw; | |||
| 119 | ||||
| 120 | static struct config_defaults globaldefs; | |||
| 121 | static struct config_defaults afdefs; | |||
| 122 | static struct config_defaults ifacedefs; | |||
| 123 | static struct config_defaults tnbrdefs; | |||
| 124 | static struct config_defaults pwdefs; | |||
| 125 | static struct config_defaults *defs; | |||
| 126 | ||||
| 127 | #line 128 "parse.c" | |||
| 128 | #define INTERFACE257 257 | |||
| 129 | #define TNEIGHBOR258 258 | |||
| 130 | #define ROUTERID259 259 | |||
| 131 | #define FIBUPDATE260 260 | |||
| 132 | #define RDOMAIN261 261 | |||
| 133 | #define EXPNULL262 262 | |||
| 134 | #define LHELLOHOLDTIME263 263 | |||
| 135 | #define LHELLOINTERVAL264 264 | |||
| 136 | #define THELLOHOLDTIME265 265 | |||
| 137 | #define THELLOINTERVAL266 266 | |||
| 138 | #define THELLOACCEPT267 267 | |||
| 139 | #define AF268 268 | |||
| 140 | #define IPV4269 269 | |||
| 141 | #define IPV6270 270 | |||
| 142 | #define INET271 271 | |||
| 143 | #define INET6272 272 | |||
| 144 | #define GTSMENABLE273 273 | |||
| 145 | #define GTSMHOPS274 274 | |||
| 146 | #define KEEPALIVE275 275 | |||
| 147 | #define TRANSADDRESS276 276 | |||
| 148 | #define TRANSPREFERENCE277 277 | |||
| 149 | #define DSCISCOINTEROP278 278 | |||
| 150 | #define NEIGHBOR279 279 | |||
| 151 | #define TCP280 280 | |||
| 152 | #define MD5SIG281 281 | |||
| 153 | #define PASSWORD282 282 | |||
| 154 | #define KEY283 283 | |||
| 155 | #define L2VPN284 284 | |||
| 156 | #define TYPE285 285 | |||
| 157 | #define VPLS286 286 | |||
| 158 | #define PWTYPE287 287 | |||
| 159 | #define MTU288 288 | |||
| 160 | #define BRIDGE289 289 | |||
| 161 | #define ETHERNET290 290 | |||
| 162 | #define ETHERNETTAGGED291 291 | |||
| 163 | #define STATUSTLV292 292 | |||
| 164 | #define CONTROLWORD293 293 | |||
| 165 | #define PSEUDOWIRE294 294 | |||
| 166 | #define NEIGHBORID295 295 | |||
| 167 | #define NEIGHBORADDR296 296 | |||
| 168 | #define PWID297 297 | |||
| 169 | #define EXTTAG298 298 | |||
| 170 | #define YES299 299 | |||
| 171 | #define NO300 300 | |||
| 172 | #define INCLUDE301 301 | |||
| 173 | #define ERROR302 302 | |||
| 174 | #define STRING303 303 | |||
| 175 | #define NUMBER304 304 | |||
| 176 | #define YYERRCODE256 256 | |||
| 177 | const short yylhs[] = | |||
| 178 | { -1, | |||
| 179 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, | |||
| 180 | 5, 5, 6, 1, 1, 2, 2, 3, 4, 4, | |||
| 181 | 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |||
| 182 | 20, 13, 19, 19, 19, 22, 22, 23, 23, 23, | |||
| 183 | 23, 23, 23, 23, 16, 16, 16, 17, 17, 18, | |||
| 184 | 18, 8, 8, 8, 9, 9, 7, 27, 27, 27, | |||
| 185 | 27, 28, 28, 29, 29, 29, 29, 32, 30, 31, | |||
| 186 | 31, 31, 33, 33, 34, 34, 34, 34, 34, 34, | |||
| 187 | 21, 21, 24, 36, 25, 35, 35, 35, 37, 37, | |||
| 188 | 39, 26, 38, 38, 38, 40, 40, 42, 14, 41, | |||
| 189 | 41, 41, 43, 43, 45, 15, 44, 44, 44, 46, | |||
| 190 | 46, | |||
| 191 | }; | |||
| 192 | const short yylen[] = | |||
| 193 | { 2, | |||
| 194 | 0, 3, 2, 3, 3, 3, 3, 3, 3, 2, | |||
| 195 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |||
| 196 | 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, | |||
| 197 | 0, 4, 4, 3, 0, 3, 2, 2, 2, 1, | |||
| 198 | 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, | |||
| 199 | 2, 4, 4, 3, 1, 0, 2, 2, 1, 2, | |||
| 200 | 2, 2, 2, 2, 2, 2, 1, 0, 4, 4, | |||
| 201 | 3, 0, 3, 2, 2, 2, 1, 2, 2, 1, | |||
| 202 | 2, 0, 2, 0, 4, 4, 3, 0, 3, 2, | |||
| 203 | 0, 4, 4, 3, 0, 3, 2, 0, 4, 4, | |||
| 204 | 3, 0, 3, 2, 0, 6, 4, 3, 0, 3, | |||
| 205 | 2, | |||
| 206 | }; | |||
| 207 | const short yydefred[] = | |||
| 208 | { 1, | |||
| 209 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 210 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 211 | 0, 3, 27, 0, 0, 0, 0, 0, 0, 0, | |||
| 212 | 28, 29, 30, 9, 13, 22, 14, 15, 23, 24, | |||
| 213 | 46, 48, 49, 50, 51, 45, 16, 17, 31, 47, | |||
| 214 | 25, 26, 98, 0, 0, 0, 10, 0, 55, 57, | |||
| 215 | 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, | |||
| 216 | 0, 54, 12, 0, 0, 32, 0, 99, 52, 53, | |||
| 217 | 18, 105, 11, 0, 0, 0, 0, 81, 0, 0, | |||
| 218 | 0, 0, 34, 40, 41, 42, 0, 0, 43, 44, | |||
| 219 | 0, 0, 0, 101, 59, 0, 0, 0, 106, 84, | |||
| 220 | 91, 39, 38, 33, 0, 37, 60, 61, 58, 104, | |||
| 221 | 100, 0, 0, 0, 0, 0, 36, 103, 0, 0, | |||
| 222 | 0, 0, 0, 0, 0, 108, 77, 80, 0, 0, | |||
| 223 | 0, 85, 0, 92, 83, 79, 19, 20, 75, 76, | |||
| 224 | 78, 62, 63, 68, 111, 107, 0, 0, 0, 0, | |||
| 225 | 110, 87, 0, 0, 94, 0, 0, 0, 69, 90, | |||
| 226 | 86, 0, 97, 93, 0, 0, 89, 96, 0, 0, | |||
| 227 | 0, 71, 67, 0, 0, 65, 66, 64, 74, 70, | |||
| 228 | 0, 73, | |||
| 229 | }; | |||
| 230 | const short yydgoto[] = | |||
| 231 | { 1, | |||
| 232 | 39, 49, 82, 149, 74, 36, 23, 105, 60, 25, | |||
| 233 | 26, 27, 28, 29, 30, 94, 95, 96, 76, 67, | |||
| 234 | 85, 97, 98, 127, 99, 100, 106, 137, 184, 138, | |||
| 235 | 169, 160, 185, 139, 142, 124, 164, 144, 125, 167, | |||
| 236 | 78, 68, 107, 109, 87, 140, | |||
| 237 | }; | |||
| 238 | const short yysindex[] = | |||
| 239 | { 0, | |||
| 240 | -10, 1, -280, -285, -279, -285, -277, -276, -275, -272, | |||
| 241 | -285, -253, -271, -253, -285, -280, -247, -268, -244, -266, | |||
| 242 | -21, 0, 0, -262, 32, 33, 34, 36, 38, 39, | |||
| 243 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 244 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 245 | 0, 0, 0, -263, -235, -230, 0, -250, 0, 0, | |||
| 246 | 0, 0, 0, 0, 0, 0, -69, -68, -246, -245, | |||
| 247 | -227, 0, 0, -242, 46, 0, 46, 0, 0, 0, | |||
| 248 | 0, 0, 0, 46, 79, -119, -61, 0, -239, -237, | |||
| 249 | -285, -234, 0, 0, 0, 0, 99, 46, 0, 0, | |||
| 250 | -285, -236, -233, 0, 0, 46, -95, 46, 0, 0, | |||
| 251 | 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, | |||
| 252 | 0, 60, -73, -51, -50, 46, 0, 0, -229, -269, | |||
| 253 | -226, -228, -285, -285, -223, 0, 0, 0, 46, -60, | |||
| 254 | 46, 0, 46, 0, 0, 0, 0, 0, 0, 0, | |||
| 255 | 0, 0, 0, 0, 0, 0, 60, -41, -118, -42, | |||
| 256 | 0, 0, 46, -38, 0, 46, -107, 46, 0, 0, | |||
| 257 | 0, 60, 0, 0, 60, -101, 0, 0, -280, -221, | |||
| 258 | -219, 0, 0, 46, -94, 0, 0, 0, 0, 0, | |||
| 259 | 60, 0,}; | |||
| 260 | const short yyrindex[] = | |||
| 261 | { 0, | |||
| 262 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 263 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 264 | 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, | |||
| 265 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 266 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 267 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 268 | 0, 0, 0, 0, 0, 0, 76, 80, 0, 0, | |||
| 269 | 0, 0, 0, 81, 122, 0, -87, 0, 0, 0, | |||
| 270 | 0, 0, 0, -123, 0, 0, 83, 0, 0, 0, | |||
| 271 | 0, 0, 0, 0, 0, 0, 0, 122, 0, 0, | |||
| 272 | 0, 0, 0, 0, 0, -87, 0, -49, 0, 0, | |||
| 273 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 274 | 0, 0, 0, 37, 57, -123, 0, 0, 0, 0, | |||
| 275 | 0, 0, 0, 0, 0, 0, 0, 0, -49, 0, | |||
| 276 | -33, 0, -48, 0, 0, 0, 0, 0, 0, 0, | |||
| 277 | 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, | |||
| 278 | 0, 0, -33, 0, 0, -48, 0, -86, 0, 0, | |||
| 279 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 280 | 0, 0, 0, -86, 0, 0, 0, 0, 0, 0, | |||
| 281 | 0, 0,}; | |||
| 282 | const short yygindex[] = | |||
| 283 | { 0, | |||
| 284 | -3, 75, 0, 0, 0, -11, 0, 93, 0, 0, | |||
| 285 | 0, 0, 0, 0, 0, 94, 25, 8, 0, 0, | |||
| 286 | 293, 0, -1, -112, 0, 0, -8, -172, -88, 0, | |||
| 287 | 0, 0, 0, -40, 0, 0, 0, 0, 0, 0, | |||
| 288 | 0, 0, 0, 0, 0, 0, | |||
| 289 | }; | |||
| 290 | #define YYTABLESIZE477 477 | |||
| 291 | const short yytable[] = | |||
| 292 | { 22, | |||
| 293 | 72, 82, 41, 183, 53, 104, 165, 46, 33, 128, | |||
| 294 | 34, 52, 183, 37, 38, 47, 48, 174, 69, 70, | |||
| 295 | 147, 148, 35, 182, 40, 32, 42, 43, 44, 121, | |||
| 296 | 190, 45, 50, 54, 55, 56, 57, 82, 82, 58, | |||
| 297 | 59, 61, 62, 63, 161, 64, 88, 65, 66, 71, | |||
| 298 | 72, 136, 73, 75, 77, 84, 79, 80, 81, 177, | |||
| 299 | 83, 108, 178, 110, 156, 111, 95, 118, 113, 126, | |||
| 300 | 119, 141, 143, 146, 151, 82, 82, 150, 192, 154, | |||
| 301 | 168, 187, 56, 162, 188, 35, 171, 112, 51, 102, | |||
| 302 | 21, 82, 109, 24, 31, 115, 191, 117, 122, 157, | |||
| 303 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 304 | 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, | |||
| 305 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, | |||
| 306 | 153, 0, 0, 82, 82, 0, 0, 0, 82, 82, | |||
| 307 | 82, 82, 82, 82, 0, 0, 9, 10, 0, 82, | |||
| 308 | 82, 82, 82, 101, 102, 103, 82, 9, 10, 0, | |||
| 309 | 17, 88, 0, 82, 82, 82, 166, 186, 82, 82, | |||
| 310 | 82, 82, 82, 82, 175, 0, 82, 101, 102, 103, | |||
| 311 | 19, 95, 163, 129, 17, 82, 82, 82, 172, 0, | |||
| 312 | 133, 134, 82, 179, 180, 181, 129, 133, 134, 0, | |||
| 313 | 179, 180, 181, 93, 19, 82, 82, 82, 82, 82, | |||
| 314 | 82, 0, 82, 130, 131, 132, 82, 82, 133, 134, | |||
| 315 | 135, 7, 8, 114, 7, 8, 130, 131, 132, 82, | |||
| 316 | 82, 133, 134, 135, 0, 0, 0, 82, 82, 82, | |||
| 317 | 0, 0, 82, 82, 82, 2, 82, 72, 3, 4, | |||
| 318 | 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, | |||
| 319 | 0, 0, 0, 0, 13, 0, 14, 15, 16, 17, | |||
| 320 | 0, 0, 0, 18, 0, 0, 0, 72, 72, 72, | |||
| 321 | 0, 0, 72, 72, 72, 0, 0, 0, 0, 19, | |||
| 322 | 20, 0, 21, 88, 88, 0, 0, 0, 88, 88, | |||
| 323 | 88, 88, 88, 88, 0, 0, 0, 0, 0, 88, | |||
| 324 | 0, 88, 88, 95, 95, 0, 0, 0, 95, 95, | |||
| 325 | 95, 95, 95, 95, 0, 0, 0, 0, 0, 95, | |||
| 326 | 0, 95, 95, 0, 0, 89, 90, 0, 0, 0, | |||
| 327 | 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, | |||
| 328 | 0, 91, 0, 13, 92, 89, 90, 0, 0, 0, | |||
| 329 | 6, 7, 8, 9, 10, 11, 0, 0, 0, 86, | |||
| 330 | 0, 91, 0, 13, 92, 0, 88, 0, 82, 82, | |||
| 331 | 0, 0, 0, 82, 82, 82, 82, 82, 82, 0, | |||
| 332 | 116, 0, 0, 0, 82, 0, 82, 82, 120, 0, | |||
| 333 | 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 334 | 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, | |||
| 335 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 336 | 0, 155, 0, 158, 0, 159, 0, 0, 0, 0, | |||
| 337 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 338 | 0, 0, 0, 0, 0, 170, 0, 0, 173, 0, | |||
| 339 | 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||
| 340 | 0, 0, 0, 0, 0, 0, 189, | |||
| 341 | }; | |||
| 342 | const short yycheck[] = | |||
| 343 | { 10, | |||
| 344 | 10, 125, 6, 176, 16, 125, 125, 11, 1, 122, | |||
| 345 | 10, 15, 185, 299, 300, 269, 270, 125, 282, 283, | |||
| 346 | 290, 291, 303, 125, 304, 1, 304, 304, 304, 125, | |||
| 347 | 125, 304, 304, 281, 303, 280, 303, 125, 125, 61, | |||
| 348 | 303, 10, 10, 10, 157, 10, 10, 10, 10, 285, | |||
| 349 | 281, 125, 303, 123, 123, 10, 303, 303, 286, 172, | |||
| 350 | 303, 123, 175, 303, 125, 303, 10, 304, 303, 10, | |||
| 351 | 304, 123, 123, 303, 303, 125, 125, 304, 191, 303, | |||
| 352 | 123, 303, 10, 125, 304, 10, 125, 91, 14, 10, | |||
| 353 | 10, 125, 10, 1, 1, 97, 185, 101, 107, 140, | |||
| 354 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 355 | -1, -1, -1, -1, -1, 125, -1, -1, -1, -1, | |||
| 356 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 133, | |||
| 357 | 134, -1, -1, 257, 258, -1, -1, -1, 262, 263, | |||
| 358 | 264, 265, 266, 267, -1, -1, 265, 266, -1, 273, | |||
| 359 | 274, 275, 276, 273, 274, 275, 280, 265, 266, -1, | |||
| 360 | 280, 125, -1, 287, 288, 289, 159, 179, 292, 293, | |||
| 361 | 294, 295, 296, 297, 167, -1, 300, 273, 274, 275, | |||
| 362 | 300, 125, 158, 257, 280, 273, 274, 275, 164, -1, | |||
| 363 | 292, 293, 280, 295, 296, 297, 257, 292, 293, -1, | |||
| 364 | 295, 296, 297, 125, 300, 292, 293, 257, 295, 296, | |||
| 365 | 297, -1, 300, 287, 288, 289, 265, 266, 292, 293, | |||
| 366 | 294, 263, 264, 125, 263, 264, 287, 288, 289, 263, | |||
| 367 | 264, 292, 293, 294, -1, -1, -1, 287, 288, 289, | |||
| 368 | -1, -1, 292, 293, 294, 256, 125, 257, 259, 260, | |||
| 369 | 261, 262, 263, 264, 265, 266, 267, 268, -1, -1, | |||
| 370 | -1, -1, -1, -1, 275, -1, 277, 278, 279, 280, | |||
| 371 | -1, -1, -1, 284, -1, -1, -1, 287, 288, 289, | |||
| 372 | -1, -1, 292, 293, 294, -1, -1, -1, -1, 300, | |||
| 373 | 301, -1, 303, 257, 258, -1, -1, -1, 262, 263, | |||
| 374 | 264, 265, 266, 267, -1, -1, -1, -1, -1, 273, | |||
| 375 | -1, 275, 276, 257, 258, -1, -1, -1, 262, 263, | |||
| 376 | 264, 265, 266, 267, -1, -1, -1, -1, -1, 273, | |||
| 377 | -1, 275, 276, -1, -1, 257, 258, -1, -1, -1, | |||
| 378 | 262, 263, 264, 265, 266, 267, -1, -1, -1, -1, | |||
| 379 | -1, 273, -1, 275, 276, 257, 258, -1, -1, -1, | |||
| 380 | 262, 263, 264, 265, 266, 267, -1, -1, -1, 77, | |||
| 381 | -1, 273, -1, 275, 276, -1, 84, -1, 257, 258, | |||
| 382 | -1, -1, -1, 262, 263, 264, 265, 266, 267, -1, | |||
| 383 | 98, -1, -1, -1, 273, -1, 275, 276, 106, -1, | |||
| 384 | 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 385 | -1, -1, -1, -1, -1, -1, -1, -1, 126, -1, | |||
| 386 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 387 | -1, 139, -1, 141, -1, 143, -1, -1, -1, -1, | |||
| 388 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 389 | -1, -1, -1, -1, -1, 163, -1, -1, 166, -1, | |||
| 390 | 168, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 391 | -1, -1, -1, -1, -1, -1, 184, | |||
| 392 | }; | |||
| 393 | #define YYFINAL1 1 | |||
| 394 | #ifndef YYDEBUG0 | |||
| 395 | #define YYDEBUG0 0 | |||
| 396 | #endif | |||
| 397 | #define YYMAXTOKEN304 304 | |||
| 398 | #if YYDEBUG0 | |||
| 399 | const char * const yyname[] = | |||
| 400 | { | |||
| 401 | "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, | |||
| 402 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0,0,0,0,0, | |||
| 403 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 404 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 405 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 406 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
| 407 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTERFACE", | |||
| 408 | "TNEIGHBOR","ROUTERID","FIBUPDATE","RDOMAIN","EXPNULL","LHELLOHOLDTIME", | |||
| 409 | "LHELLOINTERVAL","THELLOHOLDTIME","THELLOINTERVAL","THELLOACCEPT","AF","IPV4", | |||
| 410 | "IPV6","INET","INET6","GTSMENABLE","GTSMHOPS","KEEPALIVE","TRANSADDRESS", | |||
| 411 | "TRANSPREFERENCE","DSCISCOINTEROP","NEIGHBOR","TCP","MD5SIG","PASSWORD","KEY", | |||
| 412 | "L2VPN","TYPE","VPLS","PWTYPE","MTU","BRIDGE","ETHERNET","ETHERNETTAGGED", | |||
| 413 | "STATUSTLV","CONTROLWORD","PSEUDOWIRE","NEIGHBORID","NEIGHBORADDR","PWID", | |||
| 414 | "EXTTAG","YES","NO","INCLUDE","ERROR","STRING","NUMBER", | |||
| 415 | }; | |||
| 416 | const char * const yyrule[] = | |||
| 417 | {"$accept : grammar", | |||
| 418 | "grammar :", | |||
| 419 | "grammar : grammar include '\\n'", | |||
| 420 | "grammar : grammar '\\n'", | |||
| 421 | "grammar : grammar conf_main '\\n'", | |||
| 422 | "grammar : grammar varset '\\n'", | |||
| 423 | "grammar : grammar af '\\n'", | |||
| 424 | "grammar : grammar neighbor '\\n'", | |||
| 425 | "grammar : grammar l2vpn '\\n'", | |||
| 426 | "grammar : grammar error '\\n'", | |||
| 427 | "include : INCLUDE STRING", | |||
| 428 | "string : string STRING", | |||
| 429 | "string : STRING", | |||
| 430 | "routerid : STRING", | |||
| 431 | "yesno : YES", | |||
| 432 | "yesno : NO", | |||
| 433 | "ldp_af : IPV4", | |||
| 434 | "ldp_af : IPV6", | |||
| 435 | "l2vpn_type : VPLS", | |||
| 436 | "pw_type : ETHERNET", | |||
| 437 | "pw_type : ETHERNETTAGGED", | |||
| 438 | "varset : STRING '=' string", | |||
| 439 | "conf_main : ROUTERID routerid", | |||
| 440 | "conf_main : FIBUPDATE yesno", | |||
| 441 | "conf_main : RDOMAIN NUMBER", | |||
| 442 | "conf_main : TRANSPREFERENCE ldp_af", | |||
| 443 | "conf_main : DSCISCOINTEROP yesno", | |||
| 444 | "conf_main : auth", | |||
| 445 | "conf_main : af_defaults", | |||
| 446 | "conf_main : iface_defaults", | |||
| 447 | "conf_main : tnbr_defaults", | |||
| 448 | "$$1 :", | |||
| 449 | "af : AF ldp_af $$1 af_block", | |||
| 450 | "af_block : '{' optnl afopts_l '}'", | |||
| 451 | "af_block : '{' optnl '}'", | |||
| 452 | "af_block :", | |||
| 453 | "afopts_l : afopts_l afoptsl nl", | |||
| 454 | "afopts_l : afoptsl optnl", | |||
| 455 | "afoptsl : TRANSADDRESS STRING", | |||
| 456 | "afoptsl : GTSMENABLE yesno", | |||
| 457 | "afoptsl : af_defaults", | |||
| 458 | "afoptsl : iface_defaults", | |||
| 459 | "afoptsl : tnbr_defaults", | |||
| 460 | "afoptsl : interface", | |||
| 461 | "afoptsl : tneighbor", | |||
| 462 | "af_defaults : THELLOACCEPT yesno", | |||
| 463 | "af_defaults : EXPNULL yesno", | |||
| 464 | "af_defaults : KEEPALIVE NUMBER", | |||
| 465 | "iface_defaults : LHELLOHOLDTIME NUMBER", | |||
| 466 | "iface_defaults : LHELLOINTERVAL NUMBER", | |||
| 467 | "tnbr_defaults : THELLOHOLDTIME NUMBER", | |||
| 468 | "tnbr_defaults : THELLOINTERVAL NUMBER", | |||
| 469 | "tcpmd5 : TCP MD5SIG PASSWORD STRING", | |||
| 470 | "tcpmd5 : TCP MD5SIG KEY STRING", | |||
| 471 | "tcpmd5 : NO TCP MD5SIG", | |||
| 472 | "optnbrprefix : STRING", | |||
| 473 | "optnbrprefix :", | |||
| 474 | "auth : tcpmd5 optnbrprefix", | |||
| 475 | "nbr_opts : KEEPALIVE NUMBER", | |||
| 476 | "nbr_opts : tcpmd5", | |||
| 477 | "nbr_opts : GTSMENABLE yesno", | |||
| 478 | "nbr_opts : GTSMHOPS NUMBER", | |||
| 479 | "pw_defaults : STATUSTLV yesno", | |||
| 480 | "pw_defaults : CONTROLWORD yesno", | |||
| 481 | "pwopts : PWID NUMBER", | |||
| 482 | "pwopts : NEIGHBORID routerid", | |||
| 483 | "pwopts : NEIGHBORADDR STRING", | |||
| 484 | "pwopts : pw_defaults", | |||
| 485 | "$$2 :", | |||
| 486 | "pseudowire : PSEUDOWIRE STRING $$2 pw_block", | |||
| 487 | "pw_block : '{' optnl pwopts_l '}'", | |||
| 488 | "pw_block : '{' optnl '}'", | |||
| 489 | "pw_block :", | |||
| 490 | "pwopts_l : pwopts_l pwopts nl", | |||
| 491 | "pwopts_l : pwopts optnl", | |||
| 492 | "l2vpnopts : PWTYPE pw_type", | |||
| 493 | "l2vpnopts : MTU NUMBER", | |||
| 494 | "l2vpnopts : pw_defaults", | |||
| 495 | "l2vpnopts : BRIDGE STRING", | |||
| 496 | "l2vpnopts : INTERFACE STRING", | |||
| 497 | "l2vpnopts : pseudowire", | |||
| 498 | "optnl : '\\n' optnl", | |||
| 499 | "optnl :", | |||
| 500 | "nl : '\\n' optnl", | |||
| 501 | "$$3 :", | |||
| 502 | "interface : INTERFACE STRING $$3 interface_block", | |||
| 503 | "interface_block : '{' optnl interfaceopts_l '}'", | |||
| 504 | "interface_block : '{' optnl '}'", | |||
| 505 | "interface_block :", | |||
| 506 | "interfaceopts_l : interfaceopts_l iface_defaults nl", | |||
| 507 | "interfaceopts_l : iface_defaults optnl", | |||
| 508 | "$$4 :", | |||
| 509 | "tneighbor : TNEIGHBOR STRING $$4 tneighbor_block", | |||
| 510 | "tneighbor_block : '{' optnl tneighboropts_l '}'", | |||
| 511 | "tneighbor_block : '{' optnl '}'", | |||
| 512 | "tneighbor_block :", | |||
| 513 | "tneighboropts_l : tneighboropts_l tnbr_defaults nl", | |||
| 514 | "tneighboropts_l : tnbr_defaults optnl", | |||
| 515 | "$$5 :", | |||
| 516 | "neighbor : NEIGHBOR routerid $$5 neighbor_block", | |||
| 517 | "neighbor_block : '{' optnl neighboropts_l '}'", | |||
| 518 | "neighbor_block : '{' optnl '}'", | |||
| 519 | "neighbor_block :", | |||
| 520 | "neighboropts_l : neighboropts_l nbr_opts nl", | |||
| 521 | "neighboropts_l : nbr_opts optnl", | |||
| 522 | "$$6 :", | |||
| 523 | "l2vpn : L2VPN STRING TYPE l2vpn_type $$6 l2vpn_block", | |||
| 524 | "l2vpn_block : '{' optnl l2vpnopts_l '}'", | |||
| 525 | "l2vpn_block : '{' optnl '}'", | |||
| 526 | "l2vpn_block :", | |||
| 527 | "l2vpnopts_l : l2vpnopts_l l2vpnopts nl", | |||
| 528 | "l2vpnopts_l : l2vpnopts optnl", | |||
| 529 | }; | |||
| 530 | #endif | |||
| 531 | #ifdef YYSTACKSIZE10000 | |||
| 532 | #undef YYMAXDEPTH10000 | |||
| 533 | #define YYMAXDEPTH10000 YYSTACKSIZE10000 | |||
| 534 | #else | |||
| 535 | #ifdef YYMAXDEPTH10000 | |||
| 536 | #define YYSTACKSIZE10000 YYMAXDEPTH10000 | |||
| 537 | #else | |||
| 538 | #define YYSTACKSIZE10000 10000 | |||
| 539 | #define YYMAXDEPTH10000 10000 | |||
| 540 | #endif | |||
| 541 | #endif | |||
| 542 | #define YYINITSTACKSIZE200 200 | |||
| 543 | /* LINTUSED */ | |||
| 544 | int yydebug; | |||
| 545 | int yynerrs; | |||
| 546 | int yyerrflag; | |||
| 547 | int yychar; | |||
| 548 | short *yyssp; | |||
| 549 | YYSTYPE *yyvsp; | |||
| 550 | YYSTYPE yyval; | |||
| 551 | YYSTYPE yylval; | |||
| 552 | short *yyss; | |||
| 553 | short *yysslim; | |||
| 554 | YYSTYPE *yyvs; | |||
| 555 | unsigned int yystacksize; | |||
| 556 | int yyparse(void); | |||
| 557 | #line 880 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 558 | ||||
| 559 | struct keywords { | |||
| 560 | const char *k_name; | |||
| 561 | int k_val; | |||
| 562 | }; | |||
| 563 | ||||
| 564 | static int | |||
| 565 | yyerror(const char *fmt, ...) | |||
| 566 | { | |||
| 567 | va_list ap; | |||
| 568 | char *msg; | |||
| 569 | ||||
| 570 | file->errors++; | |||
| 571 | va_start(ap, fmt)__builtin_va_start(ap, fmt); | |||
| 572 | if (vasprintf(&msg, fmt, ap) == -1) | |||
| 573 | fatalx("yyerror vasprintf"); | |||
| 574 | va_end(ap)__builtin_va_end(ap); | |||
| 575 | logit(LOG_CRIT2, "%s:%d: %s", file->name, yylval.lineno, msg); | |||
| 576 | free(msg); | |||
| 577 | return (0); | |||
| 578 | } | |||
| 579 | ||||
| 580 | static int | |||
| 581 | kw_cmp(const void *k, const void *e) | |||
| 582 | { | |||
| 583 | return (strcmp(k, ((const struct keywords *)e)->k_name)); | |||
| 584 | } | |||
| 585 | ||||
| 586 | static int | |||
| 587 | lookup(char *s) | |||
| 588 | { | |||
| 589 | /* this has to be sorted always */ | |||
| 590 | static const struct keywords keywords[] = { | |||
| 591 | {"address-family", AF268}, | |||
| 592 | {"bridge", BRIDGE289}, | |||
| 593 | {"control-word", CONTROLWORD293}, | |||
| 594 | {"ds-cisco-interop", DSCISCOINTEROP278}, | |||
| 595 | {"ethernet", ETHERNET290}, | |||
| 596 | {"ethernet-tagged", ETHERNETTAGGED291}, | |||
| 597 | {"explicit-null", EXPNULL262}, | |||
| 598 | {"fib-update", FIBUPDATE260}, | |||
| 599 | {"gtsm-enable", GTSMENABLE273}, | |||
| 600 | {"gtsm-hops", GTSMHOPS274}, | |||
| 601 | {"include", INCLUDE301}, | |||
| 602 | {"inet", INET271}, | |||
| 603 | {"inet6", INET6272}, | |||
| 604 | {"interface", INTERFACE257}, | |||
| 605 | {"ipv4", IPV4269}, | |||
| 606 | {"ipv6", IPV6270}, | |||
| 607 | {"keepalive", KEEPALIVE275}, | |||
| 608 | {"key", KEY283}, | |||
| 609 | {"l2vpn", L2VPN284}, | |||
| 610 | {"link-hello-holdtime", LHELLOHOLDTIME263}, | |||
| 611 | {"link-hello-interval", LHELLOINTERVAL264}, | |||
| 612 | {"md5sig", MD5SIG281}, | |||
| 613 | {"mtu", MTU288}, | |||
| 614 | {"neighbor", NEIGHBOR279}, | |||
| 615 | {"neighbor-addr", NEIGHBORADDR296}, | |||
| 616 | {"neighbor-id", NEIGHBORID295}, | |||
| 617 | {"no", NO300}, | |||
| 618 | {"password", PASSWORD282}, | |||
| 619 | {"pseudowire", PSEUDOWIRE294}, | |||
| 620 | {"pw-id", PWID297}, | |||
| 621 | {"pw-type", PWTYPE287}, | |||
| 622 | {"rdomain", RDOMAIN261}, | |||
| 623 | {"router-id", ROUTERID259}, | |||
| 624 | {"status-tlv", STATUSTLV292}, | |||
| 625 | {"targeted-hello-accept", THELLOACCEPT267}, | |||
| 626 | {"targeted-hello-holdtime", THELLOHOLDTIME265}, | |||
| 627 | {"targeted-hello-interval", THELLOINTERVAL266}, | |||
| 628 | {"targeted-neighbor", TNEIGHBOR258}, | |||
| 629 | {"tcp", TCP280}, | |||
| 630 | {"transport-address", TRANSADDRESS276}, | |||
| 631 | {"transport-preference", TRANSPREFERENCE277}, | |||
| 632 | {"type", TYPE285}, | |||
| 633 | {"vpls", VPLS286}, | |||
| 634 | {"yes", YES299} | |||
| 635 | }; | |||
| 636 | const struct keywords *p; | |||
| 637 | ||||
| 638 | p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]), | |||
| 639 | sizeof(keywords[0]), kw_cmp); | |||
| 640 | ||||
| 641 | if (p) | |||
| 642 | return (p->k_val); | |||
| 643 | else | |||
| 644 | return (STRING303); | |||
| 645 | } | |||
| 646 | ||||
| 647 | #define START_EXPAND1 1 | |||
| 648 | #define DONE_EXPAND2 2 | |||
| 649 | ||||
| 650 | static int expanding; | |||
| 651 | ||||
| 652 | int | |||
| 653 | igetc(void) | |||
| 654 | { | |||
| 655 | int c; | |||
| 656 | ||||
| 657 | while (1) { | |||
| 658 | if (file->ungetpos > 0) | |||
| 659 | c = file->ungetbuf[--file->ungetpos]; | |||
| 660 | else | |||
| 661 | c = getc(file->stream)(!__isthreaded ? (--(file->stream)->_r < 0 ? __srget (file->stream) : (int)(*(file->stream)->_p++)) : (getc )(file->stream)); | |||
| 662 | ||||
| 663 | if (c == START_EXPAND1) | |||
| 664 | expanding = 1; | |||
| 665 | else if (c == DONE_EXPAND2) | |||
| 666 | expanding = 0; | |||
| 667 | else | |||
| 668 | break; | |||
| 669 | } | |||
| 670 | return (c); | |||
| 671 | } | |||
| 672 | ||||
| 673 | static int | |||
| 674 | lgetc(int quotec) | |||
| 675 | { | |||
| 676 | int c, next; | |||
| 677 | ||||
| 678 | if (quotec) { | |||
| 679 | if ((c = igetc()) == EOF(-1)) { | |||
| 680 | yyerror("reached end of file while parsing " | |||
| 681 | "quoted string"); | |||
| 682 | if (file == topfile || popfile() == EOF(-1)) | |||
| 683 | return (EOF(-1)); | |||
| 684 | return (quotec); | |||
| 685 | } | |||
| 686 | return (c); | |||
| 687 | } | |||
| 688 | ||||
| 689 | while ((c = igetc()) == '\\') { | |||
| 690 | next = igetc(); | |||
| 691 | if (next != '\n') { | |||
| 692 | c = next; | |||
| 693 | break; | |||
| 694 | } | |||
| 695 | yylval.lineno = file->lineno; | |||
| 696 | file->lineno++; | |||
| 697 | } | |||
| 698 | ||||
| 699 | if (c == EOF(-1)) { | |||
| 700 | /* | |||
| 701 | * Fake EOL when hit EOF for the first time. This gets line | |||
| 702 | * count right if last line in included file is syntactically | |||
| 703 | * invalid and has no newline. | |||
| 704 | */ | |||
| 705 | if (file->eof_reached == 0) { | |||
| 706 | file->eof_reached = 1; | |||
| 707 | return ('\n'); | |||
| 708 | } | |||
| 709 | while (c == EOF(-1)) { | |||
| 710 | if (file == topfile || popfile() == EOF(-1)) | |||
| 711 | return (EOF(-1)); | |||
| 712 | c = igetc(); | |||
| 713 | } | |||
| 714 | } | |||
| 715 | return (c); | |||
| 716 | } | |||
| 717 | ||||
| 718 | void | |||
| 719 | lungetc(int c) | |||
| 720 | { | |||
| 721 | if (c == EOF(-1)) | |||
| 722 | return; | |||
| 723 | ||||
| 724 | if (file->ungetpos >= file->ungetsize) { | |||
| 725 | void *p = reallocarray(file->ungetbuf, file->ungetsize, 2); | |||
| 726 | if (p == NULL((void *)0)) | |||
| 727 | err(1, "%s", __func__); | |||
| 728 | file->ungetbuf = p; | |||
| 729 | file->ungetsize *= 2; | |||
| 730 | } | |||
| 731 | file->ungetbuf[file->ungetpos++] = c; | |||
| 732 | } | |||
| 733 | ||||
| 734 | static int | |||
| 735 | findeol(void) | |||
| 736 | { | |||
| 737 | int c; | |||
| 738 | ||||
| 739 | /* skip to either EOF or the first real EOL */ | |||
| 740 | while (1) { | |||
| 741 | c = lgetc(0); | |||
| 742 | if (c == '\n') { | |||
| 743 | file->lineno++; | |||
| 744 | break; | |||
| 745 | } | |||
| 746 | if (c == EOF(-1)) | |||
| 747 | break; | |||
| 748 | } | |||
| 749 | return (ERROR302); | |||
| 750 | } | |||
| 751 | ||||
| 752 | static int | |||
| 753 | yylex(void) | |||
| 754 | { | |||
| 755 | char buf[8096]; | |||
| 756 | char *p, *val; | |||
| 757 | int quotec, next, c; | |||
| 758 | int token; | |||
| 759 | ||||
| 760 | top: | |||
| 761 | p = buf; | |||
| 762 | while ((c = lgetc(0)) == ' ' || c == '\t') | |||
| 763 | ; /* nothing */ | |||
| 764 | ||||
| 765 | yylval.lineno = file->lineno; | |||
| 766 | if (c == '#') | |||
| 767 | while ((c = lgetc(0)) != '\n' && c != EOF(-1)) | |||
| 768 | ; /* nothing */ | |||
| 769 | if (c == '$' && !expanding) { | |||
| 770 | while (1) { | |||
| 771 | if ((c = lgetc(0)) == EOF(-1)) | |||
| 772 | return (0); | |||
| 773 | ||||
| 774 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 775 | yyerror("string too long"); | |||
| 776 | return (findeol()); | |||
| 777 | } | |||
| 778 | if (isalnum(c) || c == '_') { | |||
| 779 | *p++ = c; | |||
| 780 | continue; | |||
| 781 | } | |||
| 782 | *p = '\0'; | |||
| 783 | lungetc(c); | |||
| 784 | break; | |||
| 785 | } | |||
| 786 | val = symget(buf); | |||
| 787 | if (val == NULL((void *)0)) { | |||
| 788 | yyerror("macro '%s' not defined", buf); | |||
| 789 | return (findeol()); | |||
| 790 | } | |||
| 791 | p = val + strlen(val) - 1; | |||
| 792 | lungetc(DONE_EXPAND2); | |||
| 793 | while (p >= val) { | |||
| 794 | lungetc((unsigned char)*p); | |||
| 795 | p--; | |||
| 796 | } | |||
| 797 | lungetc(START_EXPAND1); | |||
| 798 | goto top; | |||
| 799 | } | |||
| 800 | ||||
| 801 | switch (c) { | |||
| 802 | case '\'': | |||
| 803 | case '"': | |||
| 804 | quotec = c; | |||
| 805 | while (1) { | |||
| 806 | if ((c = lgetc(quotec)) == EOF(-1)) | |||
| 807 | return (0); | |||
| 808 | if (c == '\n') { | |||
| 809 | file->lineno++; | |||
| 810 | continue; | |||
| 811 | } else if (c == '\\') { | |||
| 812 | if ((next = lgetc(quotec)) == EOF(-1)) | |||
| 813 | return (0); | |||
| 814 | if (next == quotec || next == ' ' || | |||
| 815 | next == '\t') | |||
| 816 | c = next; | |||
| 817 | else if (next == '\n') { | |||
| 818 | file->lineno++; | |||
| 819 | continue; | |||
| 820 | } else | |||
| 821 | lungetc(next); | |||
| 822 | } else if (c == quotec) { | |||
| 823 | *p = '\0'; | |||
| 824 | break; | |||
| 825 | } else if (c == '\0') { | |||
| 826 | yyerror("syntax error"); | |||
| 827 | return (findeol()); | |||
| 828 | } | |||
| 829 | if (p + 1 >= buf + sizeof(buf) - 1) { | |||
| 830 | yyerror("string too long"); | |||
| 831 | return (findeol()); | |||
| 832 | } | |||
| 833 | *p++ = c; | |||
| 834 | } | |||
| 835 | yylval.v.string = strdup(buf); | |||
| 836 | if (yylval.v.string == NULL((void *)0)) | |||
| 837 | err(1, "%s", __func__); | |||
| 838 | return (STRING303); | |||
| 839 | } | |||
| 840 | ||||
| 841 | #define allowed_to_end_number(x)(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') \ | |||
| 842 | (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=') | |||
| 843 | ||||
| 844 | if (c == '-' || isdigit(c)) { | |||
| 845 | do { | |||
| 846 | *p++ = c; | |||
| 847 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 848 | yyerror("string too long"); | |||
| 849 | return (findeol()); | |||
| 850 | } | |||
| 851 | } while ((c = lgetc(0)) != EOF(-1) && isdigit(c)); | |||
| 852 | lungetc(c); | |||
| 853 | if (p == buf + 1 && buf[0] == '-') | |||
| 854 | goto nodigits; | |||
| 855 | if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c ==',' || c == '/' || c == '}' || c == '=')) { | |||
| 856 | const char *errstr = NULL((void *)0); | |||
| 857 | ||||
| 858 | *p = '\0'; | |||
| 859 | yylval.v.number = strtonum(buf, LLONG_MIN(-9223372036854775807LL -1LL), | |||
| 860 | LLONG_MAX9223372036854775807LL, &errstr); | |||
| 861 | if (errstr) { | |||
| 862 | yyerror("\"%s\" invalid number: %s", | |||
| 863 | buf, errstr); | |||
| 864 | return (findeol()); | |||
| 865 | } | |||
| 866 | return (NUMBER304); | |||
| 867 | } else { | |||
| 868 | nodigits: | |||
| 869 | while (p > buf + 1) | |||
| 870 | lungetc((unsigned char)*--p); | |||
| 871 | c = (unsigned char)*--p; | |||
| 872 | if (c == '-') | |||
| 873 | return (c); | |||
| 874 | } | |||
| 875 | } | |||
| 876 | ||||
| 877 | #define allowed_in_string(x)(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && x != '{' && x != '}' && x != '!' && x != '=' && x != '#' && x != ',') ) \ | |||
| 878 | (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \ | |||
| 879 | x != '{' && x != '}' && \ | |||
| 880 | x != '!' && x != '=' && x != '#' && \ | |||
| 881 | x != ',')) | |||
| 882 | ||||
| 883 | if (isalnum(c) || c == ':' || c == '_') { | |||
| 884 | do { | |||
| 885 | *p++ = c; | |||
| 886 | if ((size_t)(p-buf) >= sizeof(buf)) { | |||
| 887 | yyerror("string too long"); | |||
| 888 | return (findeol()); | |||
| 889 | } | |||
| 890 | } while ((c = lgetc(0)) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || (ispunct(c) && c != '(' && c != ')' && c != '{' && c != '}' && c != '!' && c != '=' && c != '#' && c != ',') ))); | |||
| 891 | lungetc(c); | |||
| 892 | *p = '\0'; | |||
| 893 | if ((token = lookup(buf)) == STRING303) | |||
| 894 | if ((yylval.v.string = strdup(buf)) == NULL((void *)0)) | |||
| 895 | err(1, "%s", __func__); | |||
| 896 | return (token); | |||
| 897 | } | |||
| 898 | if (c == '\n') { | |||
| 899 | yylval.lineno = file->lineno; | |||
| 900 | file->lineno++; | |||
| 901 | } | |||
| 902 | if (c == EOF(-1)) | |||
| 903 | return (0); | |||
| 904 | return (c); | |||
| 905 | } | |||
| 906 | ||||
| 907 | static int | |||
| 908 | check_file_secrecy(int fd, const char *fname) | |||
| 909 | { | |||
| 910 | struct stat st; | |||
| 911 | ||||
| 912 | if (fstat(fd, &st)) { | |||
| 913 | log_warn("cannot stat %s", fname); | |||
| 914 | return (-1); | |||
| 915 | } | |||
| 916 | if (st.st_uid != 0 && st.st_uid != getuid()) { | |||
| 917 | log_warnx("%s: owner not root or current user", fname); | |||
| 918 | return (-1); | |||
| 919 | } | |||
| 920 | if (st.st_mode & (S_IWGRP0000020 | S_IXGRP0000010 | S_IRWXO0000007)) { | |||
| 921 | log_warnx("%s: group writable or world read/writable", fname); | |||
| 922 | return (-1); | |||
| 923 | } | |||
| 924 | return (0); | |||
| 925 | } | |||
| 926 | ||||
| 927 | static struct file * | |||
| 928 | pushfile(const char *name, int secret) | |||
| 929 | { | |||
| 930 | struct file *nfile; | |||
| 931 | ||||
| 932 | if ((nfile = calloc(1, sizeof(struct file))) == NULL((void *)0)) { | |||
| 933 | log_warn("%s", __func__); | |||
| 934 | return (NULL((void *)0)); | |||
| 935 | } | |||
| 936 | if ((nfile->name = strdup(name)) == NULL((void *)0)) { | |||
| 937 | log_warn("%s", __func__); | |||
| 938 | free(nfile); | |||
| 939 | return (NULL((void *)0)); | |||
| 940 | } | |||
| 941 | if ((nfile->stream = fopen(nfile->name, "r")) == NULL((void *)0)) { | |||
| 942 | log_warn("%s: %s", __func__, nfile->name); | |||
| 943 | free(nfile->name); | |||
| 944 | free(nfile); | |||
| 945 | return (NULL((void *)0)); | |||
| 946 | } else if (secret && | |||
| 947 | check_file_secrecy(fileno(nfile->stream)(!__isthreaded ? ((nfile->stream)->_file) : (fileno)(nfile ->stream)), nfile->name)) { | |||
| 948 | fclose(nfile->stream); | |||
| 949 | free(nfile->name); | |||
| 950 | free(nfile); | |||
| 951 | return (NULL((void *)0)); | |||
| 952 | } | |||
| 953 | nfile->lineno = TAILQ_EMPTY(&files)(((&files)->tqh_first) == ((void *)0)) ? 1 : 0; | |||
| 954 | nfile->ungetsize = 16; | |||
| 955 | nfile->ungetbuf = malloc(nfile->ungetsize); | |||
| 956 | if (nfile->ungetbuf == NULL((void *)0)) { | |||
| 957 | log_warn("%s", __func__); | |||
| 958 | fclose(nfile->stream); | |||
| 959 | free(nfile->name); | |||
| 960 | free(nfile); | |||
| 961 | return (NULL((void *)0)); | |||
| 962 | } | |||
| 963 | 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); | |||
| 964 | return (nfile); | |||
| 965 | } | |||
| 966 | ||||
| 967 | static int | |||
| 968 | popfile(void) | |||
| 969 | { | |||
| 970 | struct file *prev; | |||
| 971 | ||||
| 972 | if ((prev = TAILQ_PREV(file, files, entry)(*(((struct files *)((file)->entry.tqe_prev))->tqh_last ))) != NULL((void *)0)) | |||
| 973 | prev->errors += file->errors; | |||
| 974 | ||||
| 975 | 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); | |||
| 976 | fclose(file->stream); | |||
| 977 | free(file->name); | |||
| 978 | free(file->ungetbuf); | |||
| 979 | free(file); | |||
| 980 | file = prev; | |||
| 981 | return (file ? 0 : EOF(-1)); | |||
| 982 | } | |||
| 983 | ||||
| 984 | struct ldpd_conf * | |||
| 985 | parse_config(char *filename) | |||
| 986 | { | |||
| 987 | struct sym *sym, *next; | |||
| 988 | ||||
| 989 | conf = config_new_empty(); | |||
| 990 | conf->rdomain = 0; | |||
| 991 | conf->trans_pref = DUAL_STACK_LDPOV66; | |||
| 992 | ||||
| 993 | defs = &globaldefs; | |||
| 994 | defs->keepalive = DEFAULT_KEEPALIVE180; | |||
| 995 | defs->lhello_holdtime = LINK_DFLT_HOLDTIME15; | |||
| 996 | defs->lhello_interval = DEFAULT_HELLO_INTERVAL5; | |||
| 997 | defs->thello_holdtime = TARGETED_DFLT_HOLDTIME45; | |||
| 998 | defs->thello_interval = DEFAULT_HELLO_INTERVAL5; | |||
| 999 | defs->pwflags = F_PW_STATUSTLV_CONF0x01|F_PW_CWORD_CONF0x04; | |||
| 1000 | ||||
| 1001 | if ((file = pushfile(filename, | |||
| 1002 | !(global.cmd_opts & LDPD_OPT_NOACTION0x00000004))) == NULL((void *)0)) { | |||
| 1003 | free(conf); | |||
| 1004 | return (NULL((void *)0)); | |||
| 1005 | } | |||
| 1006 | topfile = file; | |||
| 1007 | ||||
| 1008 | yyparse(); | |||
| 1009 | errors = file->errors; | |||
| 1010 | popfile(); | |||
| 1011 | ||||
| 1012 | /* Free macros and check which have not been used. */ | |||
| 1013 | TAILQ_FOREACH_SAFE(sym, &symhead, entry, next)for ((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0) && ((next) = ((sym)->entry.tqe_next), 1); (sym ) = (next)) { | |||
| 1014 | if ((global.cmd_opts & LDPD_OPT_VERBOSE20x00000002) && !sym->used) | |||
| 1015 | fprintf(stderr(&__sF[2]), "warning: macro '%s' not " | |||
| 1016 | "used\n", sym->nam); | |||
| 1017 | if (!sym->persist) { | |||
| 1018 | free(sym->nam); | |||
| 1019 | free(sym->val); | |||
| 1020 | 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); | |||
| 1021 | free(sym); | |||
| 1022 | } | |||
| 1023 | } | |||
| 1024 | ||||
| 1025 | /* check that all interfaces belong to the configured rdomain */ | |||
| 1026 | errors += conf_check_rdomain(conf->rdomain); | |||
| 1027 | ||||
| 1028 | /* free global config defaults */ | |||
| 1029 | if (errors) { | |||
| 1030 | clear_config(conf); | |||
| 1031 | return (NULL((void *)0)); | |||
| 1032 | } | |||
| 1033 | ||||
| 1034 | if (conf->rtr_id.s_addr == INADDR_ANY((u_int32_t)(0x00000000))) | |||
| 1035 | conf->rtr_id.s_addr = get_rtr_id(); | |||
| 1036 | ||||
| 1037 | /* if the ipv4 transport-address is not set, use the router-id */ | |||
| 1038 | if ((conf->ipv4.flags & F_LDPD_AF_ENABLED0x0001) && | |||
| 1039 | conf->ipv4.trans_addr.v4.s_addr == INADDR_ANY((u_int32_t)(0x00000000))) | |||
| 1040 | conf->ipv4.trans_addr.v4 = conf->rtr_id; | |||
| 1041 | ||||
| 1042 | return (conf); | |||
| 1043 | } | |||
| 1044 | ||||
| 1045 | static int | |||
| 1046 | symset(const char *nam, const char *val, int persist) | |||
| 1047 | { | |||
| 1048 | struct sym *sym; | |||
| 1049 | ||||
| 1050 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 1051 | if (strcmp(nam, sym->nam) == 0) | |||
| 1052 | break; | |||
| 1053 | } | |||
| 1054 | ||||
| 1055 | if (sym != NULL((void *)0)) { | |||
| 1056 | if (sym->persist == 1) | |||
| 1057 | return (0); | |||
| 1058 | else { | |||
| 1059 | free(sym->nam); | |||
| 1060 | free(sym->val); | |||
| 1061 | 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); | |||
| 1062 | free(sym); | |||
| 1063 | } | |||
| 1064 | } | |||
| 1065 | if ((sym = calloc(1, sizeof(*sym))) == NULL((void *)0)) | |||
| 1066 | return (-1); | |||
| 1067 | ||||
| 1068 | sym->nam = strdup(nam); | |||
| 1069 | if (sym->nam == NULL((void *)0)) { | |||
| 1070 | free(sym); | |||
| 1071 | return (-1); | |||
| 1072 | } | |||
| 1073 | sym->val = strdup(val); | |||
| 1074 | if (sym->val == NULL((void *)0)) { | |||
| 1075 | free(sym->nam); | |||
| 1076 | free(sym); | |||
| 1077 | return (-1); | |||
| 1078 | } | |||
| 1079 | sym->used = 0; | |||
| 1080 | sym->persist = persist; | |||
| 1081 | 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); | |||
| 1082 | return (0); | |||
| 1083 | } | |||
| 1084 | ||||
| 1085 | int | |||
| 1086 | cmdline_symset(char *s) | |||
| 1087 | { | |||
| 1088 | char *sym, *val; | |||
| 1089 | int ret; | |||
| 1090 | ||||
| 1091 | if ((val = strrchr(s, '=')) == NULL((void *)0)) | |||
| 1092 | return (-1); | |||
| 1093 | sym = strndup(s, val - s); | |||
| 1094 | if (sym == NULL((void *)0)) | |||
| 1095 | errx(1, "%s: strndup", __func__); | |||
| 1096 | ret = symset(sym, val + 1, 1); | |||
| 1097 | free(sym); | |||
| 1098 | ||||
| 1099 | return (ret); | |||
| 1100 | } | |||
| 1101 | ||||
| 1102 | static char * | |||
| 1103 | symget(const char *nam) | |||
| 1104 | { | |||
| 1105 | struct sym *sym; | |||
| 1106 | ||||
| 1107 | TAILQ_FOREACH(sym, &symhead, entry)for((sym) = ((&symhead)->tqh_first); (sym) != ((void * )0); (sym) = ((sym)->entry.tqe_next)) { | |||
| 1108 | if (strcmp(nam, sym->nam) == 0) { | |||
| 1109 | sym->used = 1; | |||
| 1110 | return (sym->val); | |||
| 1111 | } | |||
| 1112 | } | |||
| 1113 | return (NULL((void *)0)); | |||
| 1114 | } | |||
| 1115 | ||||
| 1116 | static struct iface * | |||
| 1117 | conf_get_if(struct kif *kif) | |||
| 1118 | { | |||
| 1119 | struct iface *i; | |||
| 1120 | struct l2vpn *l; | |||
| 1121 | ||||
| 1122 | if (kif->if_type == IFT_LOOP0x18 || | |||
| 1123 | kif->if_type == IFT_CARP0xf7 || | |||
| 1124 | kif->if_type == IFT_BRIDGE0xd1 || | |||
| 1125 | kif->if_type == IFT_MPLSTUNNEL0x96) { | |||
| 1126 | yyerror("unsupported interface type on interface %s", | |||
| 1127 | kif->ifname); | |||
| 1128 | return (NULL((void *)0)); | |||
| 1129 | } | |||
| 1130 | ||||
| 1131 | LIST_FOREACH(l, &conf->l2vpn_list, entry)for((l) = ((&conf->l2vpn_list)->lh_first); (l)!= (( void *)0); (l) = ((l)->entry.le_next)) | |||
| 1132 | if (l2vpn_if_find(l, kif->ifindex)) { | |||
| 1133 | yyerror("interface %s already configured under " | |||
| 1134 | "l2vpn %s", kif->ifname, l->name); | |||
| 1135 | return (NULL((void *)0)); | |||
| 1136 | } | |||
| 1137 | ||||
| 1138 | LIST_FOREACH(i, &conf->iface_list, entry)for((i) = ((&conf->iface_list)->lh_first); (i)!= (( void *)0); (i) = ((i)->entry.le_next)) | |||
| 1139 | if (i->ifindex == kif->ifindex) | |||
| 1140 | return (i); | |||
| 1141 | ||||
| 1142 | i = if_new(kif); | |||
| 1143 | LIST_INSERT_HEAD(&conf->iface_list, i, entry)do { if (((i)->entry.le_next = (&conf->iface_list)-> lh_first) != ((void *)0)) (&conf->iface_list)->lh_first ->entry.le_prev = &(i)->entry.le_next; (&conf-> iface_list)->lh_first = (i); (i)->entry.le_prev = & (&conf->iface_list)->lh_first; } while (0); | |||
| 1144 | return (i); | |||
| 1145 | } | |||
| 1146 | ||||
| 1147 | static struct tnbr * | |||
| 1148 | conf_get_tnbr(union ldpd_addr *addr) | |||
| 1149 | { | |||
| 1150 | struct tnbr *t; | |||
| 1151 | ||||
| 1152 | t = tnbr_find(conf, af, addr); | |||
| 1153 | if (t) { | |||
| 1154 | yyerror("targeted neighbor %s already configured", | |||
| 1155 | log_addr(af, addr)); | |||
| 1156 | return (NULL((void *)0)); | |||
| 1157 | } | |||
| 1158 | ||||
| 1159 | t = tnbr_new(conf, af, addr); | |||
| 1160 | t->flags |= F_TNBR_CONFIGURED0x01; | |||
| 1161 | LIST_INSERT_HEAD(&conf->tnbr_list, t, entry)do { if (((t)->entry.le_next = (&conf->tnbr_list)-> lh_first) != ((void *)0)) (&conf->tnbr_list)->lh_first ->entry.le_prev = &(t)->entry.le_next; (&conf-> tnbr_list)->lh_first = (t); (t)->entry.le_prev = &( &conf->tnbr_list)->lh_first; } while (0); | |||
| 1162 | return (t); | |||
| 1163 | } | |||
| 1164 | ||||
| 1165 | static struct nbr_params * | |||
| 1166 | conf_get_nbrp(struct in_addr lsr_id) | |||
| 1167 | { | |||
| 1168 | struct nbr_params *n; | |||
| 1169 | ||||
| 1170 | LIST_FOREACH(n, &conf->nbrp_list, entry)for((n) = ((&conf->nbrp_list)->lh_first); (n)!= ((void *)0); (n) = ((n)->entry.le_next)) { | |||
| 1171 | if (n->lsr_id.s_addr == lsr_id.s_addr) { | |||
| 1172 | yyerror("neighbor %s already configured", | |||
| 1173 | inet_ntoa(lsr_id)); | |||
| 1174 | return (NULL((void *)0)); | |||
| 1175 | } | |||
| 1176 | } | |||
| 1177 | ||||
| 1178 | n = nbr_params_new(lsr_id); | |||
| 1179 | LIST_INSERT_HEAD(&conf->nbrp_list, n, entry)do { if (((n)->entry.le_next = (&conf->nbrp_list)-> lh_first) != ((void *)0)) (&conf->nbrp_list)->lh_first ->entry.le_prev = &(n)->entry.le_next; (&conf-> nbrp_list)->lh_first = (n); (n)->entry.le_prev = &( &conf->nbrp_list)->lh_first; } while (0); | |||
| 1180 | return (n); | |||
| 1181 | } | |||
| 1182 | ||||
| 1183 | static struct l2vpn * | |||
| 1184 | conf_get_l2vpn(char *name) | |||
| 1185 | { | |||
| 1186 | struct l2vpn *l; | |||
| 1187 | ||||
| 1188 | if (l2vpn_find(conf, name)) { | |||
| 1189 | yyerror("l2vpn %s already configured", name); | |||
| 1190 | return (NULL((void *)0)); | |||
| 1191 | } | |||
| 1192 | ||||
| 1193 | l = l2vpn_new(name); | |||
| 1194 | LIST_INSERT_HEAD(&conf->l2vpn_list, l, entry)do { if (((l)->entry.le_next = (&conf->l2vpn_list)-> lh_first) != ((void *)0)) (&conf->l2vpn_list)->lh_first ->entry.le_prev = &(l)->entry.le_next; (&conf-> l2vpn_list)->lh_first = (l); (l)->entry.le_prev = & (&conf->l2vpn_list)->lh_first; } while (0); | |||
| 1195 | return (l); | |||
| 1196 | } | |||
| 1197 | ||||
| 1198 | static struct l2vpn_if * | |||
| 1199 | conf_get_l2vpn_if(struct l2vpn *l, struct kif *kif) | |||
| 1200 | { | |||
| 1201 | struct iface *i; | |||
| 1202 | struct l2vpn *ltmp; | |||
| 1203 | struct l2vpn_if *f; | |||
| 1204 | ||||
| 1205 | if (kif->if_type == IFT_LOOP0x18 || | |||
| 1206 | kif->if_type == IFT_CARP0xf7 || | |||
| 1207 | kif->if_type == IFT_BRIDGE0xd1 || | |||
| 1208 | kif->if_type == IFT_MPLSTUNNEL0x96) { | |||
| 1209 | yyerror("unsupported interface type on interface %s", | |||
| 1210 | kif->ifname); | |||
| 1211 | return (NULL((void *)0)); | |||
| 1212 | } | |||
| 1213 | ||||
| 1214 | LIST_FOREACH(ltmp, &conf->l2vpn_list, entry)for((ltmp) = ((&conf->l2vpn_list)->lh_first); (ltmp )!= ((void *)0); (ltmp) = ((ltmp)->entry.le_next)) | |||
| 1215 | if (l2vpn_if_find(ltmp, kif->ifindex)) { | |||
| 1216 | yyerror("interface %s already configured under " | |||
| 1217 | "l2vpn %s", kif->ifname, ltmp->name); | |||
| 1218 | return (NULL((void *)0)); | |||
| 1219 | } | |||
| 1220 | ||||
| 1221 | LIST_FOREACH(i, &conf->iface_list, entry)for((i) = ((&conf->iface_list)->lh_first); (i)!= (( void *)0); (i) = ((i)->entry.le_next)) { | |||
| 1222 | if (i->ifindex == kif->ifindex) { | |||
| 1223 | yyerror("interface %s already configured", | |||
| 1224 | kif->ifname); | |||
| 1225 | return (NULL((void *)0)); | |||
| 1226 | } | |||
| 1227 | } | |||
| 1228 | ||||
| 1229 | f = l2vpn_if_new(l, kif); | |||
| 1230 | LIST_INSERT_HEAD(&l2vpn->if_list, f, entry)do { if (((f)->entry.le_next = (&l2vpn->if_list)-> lh_first) != ((void *)0)) (&l2vpn->if_list)->lh_first ->entry.le_prev = &(f)->entry.le_next; (&l2vpn-> if_list)->lh_first = (f); (f)->entry.le_prev = &(& l2vpn->if_list)->lh_first; } while (0); | |||
| 1231 | return (f); | |||
| 1232 | } | |||
| 1233 | ||||
| 1234 | static struct l2vpn_pw * | |||
| 1235 | conf_get_l2vpn_pw(struct l2vpn *l, struct kif *kif) | |||
| 1236 | { | |||
| 1237 | struct l2vpn *ltmp; | |||
| 1238 | struct l2vpn_pw *p; | |||
| 1239 | ||||
| 1240 | LIST_FOREACH(ltmp, &conf->l2vpn_list, entry)for((ltmp) = ((&conf->l2vpn_list)->lh_first); (ltmp )!= ((void *)0); (ltmp) = ((ltmp)->entry.le_next)) { | |||
| 1241 | if (l2vpn_pw_find(ltmp, kif->ifindex)) { | |||
| 1242 | yyerror("pseudowire %s is already being " | |||
| 1243 | "used by l2vpn %s", kif->ifname, ltmp->name); | |||
| 1244 | return (NULL((void *)0)); | |||
| 1245 | } | |||
| 1246 | } | |||
| 1247 | ||||
| 1248 | p = l2vpn_pw_new(l, kif); | |||
| 1249 | LIST_INSERT_HEAD(&l2vpn->pw_list, p, entry)do { if (((p)->entry.le_next = (&l2vpn->pw_list)-> lh_first) != ((void *)0)) (&l2vpn->pw_list)->lh_first ->entry.le_prev = &(p)->entry.le_next; (&l2vpn-> pw_list)->lh_first = (p); (p)->entry.le_prev = &(& l2vpn->pw_list)->lh_first; } while (0); | |||
| 1250 | return (p); | |||
| 1251 | } | |||
| 1252 | ||||
| 1253 | int | |||
| 1254 | conf_check_rdomain(unsigned int rdomain) | |||
| 1255 | { | |||
| 1256 | struct iface *i; | |||
| 1257 | int errs = 0; | |||
| 1258 | ||||
| 1259 | LIST_FOREACH(i, &conf->iface_list, entry)for((i) = ((&conf->iface_list)->lh_first); (i)!= (( void *)0); (i) = ((i)->entry.le_next)) { | |||
| 1260 | if (i->rdomain != rdomain) { | |||
| 1261 | logit(LOG_CRIT2, "interface %s not in rdomain %u", | |||
| 1262 | i->name, rdomain); | |||
| 1263 | errs++; | |||
| 1264 | } | |||
| 1265 | } | |||
| 1266 | ||||
| 1267 | return (errs); | |||
| 1268 | } | |||
| 1269 | ||||
| 1270 | static void | |||
| 1271 | clear_config(struct ldpd_conf *xconf) | |||
| 1272 | { | |||
| 1273 | struct iface *i; | |||
| 1274 | struct tnbr *t; | |||
| 1275 | struct nbr_params *n; | |||
| 1276 | struct l2vpn *l; | |||
| 1277 | struct l2vpn_if *f; | |||
| 1278 | struct l2vpn_pw *p; | |||
| 1279 | ||||
| 1280 | while ((i = LIST_FIRST(&xconf->iface_list)((&xconf->iface_list)->lh_first)) != NULL((void *)0)) { | |||
| 1281 | LIST_REMOVE(i, entry)do { if ((i)->entry.le_next != ((void *)0)) (i)->entry. le_next->entry.le_prev = (i)->entry.le_prev; *(i)->entry .le_prev = (i)->entry.le_next; ; ; } while (0); | |||
| 1282 | free(i); | |||
| 1283 | } | |||
| 1284 | ||||
| 1285 | while ((t = LIST_FIRST(&xconf->tnbr_list)((&xconf->tnbr_list)->lh_first)) != NULL((void *)0)) { | |||
| 1286 | LIST_REMOVE(t, entry)do { if ((t)->entry.le_next != ((void *)0)) (t)->entry. le_next->entry.le_prev = (t)->entry.le_prev; *(t)->entry .le_prev = (t)->entry.le_next; ; ; } while (0); | |||
| 1287 | free(t); | |||
| 1288 | } | |||
| 1289 | ||||
| 1290 | while ((n = LIST_FIRST(&xconf->nbrp_list)((&xconf->nbrp_list)->lh_first)) != NULL((void *)0)) { | |||
| 1291 | LIST_REMOVE(n, entry)do { if ((n)->entry.le_next != ((void *)0)) (n)->entry. le_next->entry.le_prev = (n)->entry.le_prev; *(n)->entry .le_prev = (n)->entry.le_next; ; ; } while (0); | |||
| 1292 | free(n); | |||
| 1293 | } | |||
| 1294 | ||||
| 1295 | while ((l = LIST_FIRST(&xconf->l2vpn_list)((&xconf->l2vpn_list)->lh_first)) != NULL((void *)0)) { | |||
| 1296 | while ((f = LIST_FIRST(&l->if_list)((&l->if_list)->lh_first)) != NULL((void *)0)) { | |||
| 1297 | LIST_REMOVE(f, entry)do { if ((f)->entry.le_next != ((void *)0)) (f)->entry. le_next->entry.le_prev = (f)->entry.le_prev; *(f)->entry .le_prev = (f)->entry.le_next; ; ; } while (0); | |||
| 1298 | free(f); | |||
| 1299 | } | |||
| 1300 | while ((p = LIST_FIRST(&l->pw_list)((&l->pw_list)->lh_first)) != NULL((void *)0)) { | |||
| 1301 | LIST_REMOVE(p, entry)do { if ((p)->entry.le_next != ((void *)0)) (p)->entry. le_next->entry.le_prev = (p)->entry.le_prev; *(p)->entry .le_prev = (p)->entry.le_next; ; ; } while (0); | |||
| 1302 | free(p); | |||
| 1303 | } | |||
| 1304 | LIST_REMOVE(l, entry)do { if ((l)->entry.le_next != ((void *)0)) (l)->entry. le_next->entry.le_prev = (l)->entry.le_prev; *(l)->entry .le_prev = (l)->entry.le_next; ; ; } while (0); | |||
| 1305 | free(l); | |||
| 1306 | } | |||
| 1307 | ||||
| 1308 | free(xconf); | |||
| 1309 | } | |||
| 1310 | ||||
| 1311 | static uint32_t | |||
| 1312 | get_rtr_id(void) | |||
| 1313 | { | |||
| 1314 | struct ifaddrs *ifap, *ifa; | |||
| 1315 | uint32_t ip = 0, cur, localnet; | |||
| 1316 | ||||
| 1317 | 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)))); | |||
| 1318 | ||||
| 1319 | if (getifaddrs(&ifap) == -1) { | |||
| 1320 | log_warn("getifaddrs"); | |||
| 1321 | return (0); | |||
| 1322 | } | |||
| 1323 | ||||
| 1324 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { | |||
| 1325 | if (strncmp(ifa->ifa_name, "carp", 4) == 0) | |||
| 1326 | continue; | |||
| 1327 | if (ifa->ifa_addr->sa_family != AF_INET2) | |||
| 1328 | continue; | |||
| 1329 | cur = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr; | |||
| 1330 | if ((cur & localnet) == localnet) /* skip 127/8 */ | |||
| 1331 | continue; | |||
| 1332 | 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) | |||
| 1333 | ip = cur; | |||
| 1334 | } | |||
| 1335 | freeifaddrs(ifap); | |||
| 1336 | ||||
| 1337 | return (ip); | |||
| 1338 | } | |||
| 1339 | ||||
| 1340 | static int | |||
| 1341 | get_address(const char *s, union ldpd_addr *addr) | |||
| 1342 | { | |||
| 1343 | switch (af) { | |||
| 1344 | case AF_INET2: | |||
| 1345 | if (inet_pton(AF_INET2, s, &addr->v4) != 1) | |||
| 1346 | return (-1); | |||
| 1347 | break; | |||
| 1348 | case AF_INET624: | |||
| 1349 | if (inet_pton(AF_INET624, s, &addr->v6) != 1) | |||
| 1350 | return (-1); | |||
| 1351 | break; | |||
| 1352 | default: | |||
| 1353 | return (-1); | |||
| 1354 | } | |||
| 1355 | ||||
| 1356 | return (0); | |||
| 1357 | } | |||
| 1358 | ||||
| 1359 | static int | |||
| 1360 | get_af_address(const char *s, int *family, union ldpd_addr *addr) | |||
| 1361 | { | |||
| 1362 | if (inet_pton(AF_INET2, s, &addr->v4) == 1) { | |||
| 1363 | *family = AF_INET2; | |||
| 1364 | return (0); | |||
| 1365 | } | |||
| 1366 | ||||
| 1367 | if (inet_pton(AF_INET624, s, &addr->v6) == 1) { | |||
| 1368 | *family = AF_INET624; | |||
| 1369 | return (0); | |||
| 1370 | } | |||
| 1371 | ||||
| 1372 | return (-1); | |||
| 1373 | } | |||
| 1374 | ||||
| 1375 | static int | |||
| 1376 | hexchar(int ch) | |||
| 1377 | { | |||
| 1378 | if (ch >= '0' && ch <= '9') | |||
| 1379 | return (ch - '0'); | |||
| 1380 | if (ch >= 'a' && ch <= 'f') | |||
| 1381 | return (ch - 'a'); | |||
| 1382 | if (ch >= 'A' && ch <= 'F') | |||
| 1383 | return (ch - 'A'); | |||
| 1384 | ||||
| 1385 | return (-1); | |||
| 1386 | } | |||
| 1387 | ||||
| 1388 | static int | |||
| 1389 | str2key(char *dst, const char *src, int dstlen) | |||
| 1390 | { | |||
| 1391 | int i = 0; | |||
| 1392 | int digit; | |||
| 1393 | ||||
| 1394 | while (*src != '\0') { | |||
| 1395 | digit = hexchar(*src); | |||
| 1396 | if (digit == -1) | |||
| 1397 | return (-1); | |||
| 1398 | ||||
| 1399 | if (i < dstlen) | |||
| 1400 | *dst = digit << 4; | |||
| 1401 | ||||
| 1402 | src++; | |||
| 1403 | if (*src == '\0') | |||
| 1404 | return (-1); | |||
| 1405 | digit = hexchar(*src); | |||
| 1406 | if (digit == -1) | |||
| 1407 | return (-1); | |||
| 1408 | ||||
| 1409 | if (i < dstlen) | |||
| 1410 | *dst |= digit; | |||
| 1411 | ||||
| 1412 | src++; | |||
| 1413 | i++; | |||
| 1414 | } | |||
| 1415 | ||||
| 1416 | return (i); | |||
| 1417 | } | |||
| 1418 | #line 1411 "parse.c" | |||
| 1419 | /* allocate initial stack or double stack size, up to YYMAXDEPTH */ | |||
| 1420 | static int yygrowstack(void) | |||
| 1421 | { | |||
| 1422 | unsigned int newsize; | |||
| 1423 | long sslen; | |||
| 1424 | short *newss; | |||
| 1425 | YYSTYPE *newvs; | |||
| 1426 | ||||
| 1427 | if ((newsize = yystacksize) == 0) | |||
| 1428 | newsize = YYINITSTACKSIZE200; | |||
| 1429 | else if (newsize >= YYMAXDEPTH10000) | |||
| 1430 | return -1; | |||
| 1431 | else if ((newsize *= 2) > YYMAXDEPTH10000) | |||
| 1432 | newsize = YYMAXDEPTH10000; | |||
| 1433 | sslen = yyssp - yyss; | |||
| 1434 | #ifdef SIZE_MAX0xffffffffffffffffUL | |||
| 1435 | #define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL | |||
| 1436 | #else | |||
| 1437 | #define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU | |||
| 1438 | #endif | |||
| 1439 | if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss) | |||
| 1440 | goto bail; | |||
| 1441 | newss = (short *)realloc(yyss, newsize * sizeof *newss); | |||
| 1442 | if (newss == NULL((void *)0)) | |||
| 1443 | goto bail; | |||
| 1444 | yyss = newss; | |||
| 1445 | yyssp = newss + sslen; | |||
| 1446 | if (newsize
| |||
| 1447 | goto bail; | |||
| 1448 | newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs); | |||
| 1449 | if (newvs == NULL((void *)0)) | |||
| 1450 | goto bail; | |||
| 1451 | yyvs = newvs; | |||
| 1452 | yyvsp = newvs + sslen; | |||
| 1453 | yystacksize = newsize; | |||
| 1454 | yysslim = yyss + newsize - 1; | |||
| 1455 | return 0; | |||
| 1456 | bail: | |||
| 1457 | if (yyss
| |||
| 1458 | free(yyss); | |||
| 1459 | if (yyvs) | |||
| 1460 | free(yyvs); | |||
| ||||
| 1461 | yyss = yyssp = NULL((void *)0); | |||
| 1462 | yyvs = yyvsp = NULL((void *)0); | |||
| 1463 | yystacksize = 0; | |||
| 1464 | return -1; | |||
| 1465 | } | |||
| 1466 | ||||
| 1467 | #define YYABORTgoto yyabort goto yyabort | |||
| 1468 | #define YYREJECTgoto yyabort goto yyabort | |||
| 1469 | #define YYACCEPTgoto yyaccept goto yyaccept | |||
| 1470 | #define YYERRORgoto yyerrlab goto yyerrlab | |||
| 1471 | int | |||
| 1472 | yyparse(void) | |||
| 1473 | { | |||
| 1474 | int yym, yyn, yystate; | |||
| 1475 | #if YYDEBUG0 | |||
| 1476 | const char *yys; | |||
| 1477 | ||||
| 1478 | if ((yys = getenv("YYDEBUG"))) | |||
| 1479 | { | |||
| 1480 | yyn = *yys; | |||
| 1481 | if (yyn >= '0' && yyn <= '9') | |||
| 1482 | yydebug = yyn - '0'; | |||
| 1483 | } | |||
| 1484 | #endif /* YYDEBUG */ | |||
| 1485 | ||||
| 1486 | yynerrs = 0; | |||
| 1487 | yyerrflag = 0; | |||
| 1488 | yychar = (-1); | |||
| 1489 | ||||
| 1490 | if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow; | |||
| ||||
| 1491 | yyssp = yyss; | |||
| 1492 | yyvsp = yyvs; | |||
| 1493 | *yyssp = yystate = 0; | |||
| 1494 | ||||
| 1495 | yyloop: | |||
| 1496 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; | |||
| 1497 | if (yychar < 0) | |||
| 1498 | { | |||
| 1499 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 1500 | #if YYDEBUG0 | |||
| 1501 | if (yydebug) | |||
| 1502 | { | |||
| 1503 | yys = 0; | |||
| 1504 | if (yychar <= YYMAXTOKEN304) yys = yyname[yychar]; | |||
| 1505 | if (!yys) yys = "illegal-symbol"; | |||
| 1506 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 1507 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1508 | } | |||
| 1509 | #endif | |||
| 1510 | } | |||
| 1511 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 1512 | yyn <= YYTABLESIZE477 && yycheck[yyn] == yychar) | |||
| 1513 | { | |||
| 1514 | #if YYDEBUG0 | |||
| 1515 | if (yydebug) | |||
| 1516 | printf("%sdebug: state %d, shifting to state %d\n", | |||
| 1517 | YYPREFIX"yy", yystate, yytable[yyn]); | |||
| 1518 | #endif | |||
| 1519 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1520 | { | |||
| 1521 | goto yyoverflow; | |||
| 1522 | } | |||
| 1523 | *++yyssp = yystate = yytable[yyn]; | |||
| 1524 | *++yyvsp = yylval; | |||
| 1525 | yychar = (-1); | |||
| 1526 | if (yyerrflag > 0) --yyerrflag; | |||
| 1527 | goto yyloop; | |||
| 1528 | } | |||
| 1529 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | |||
| 1530 | yyn <= YYTABLESIZE477 && yycheck[yyn] == yychar) | |||
| 1531 | { | |||
| 1532 | yyn = yytable[yyn]; | |||
| 1533 | goto yyreduce; | |||
| 1534 | } | |||
| 1535 | if (yyerrflag) goto yyinrecovery; | |||
| 1536 | #if defined(__GNUC__4) | |||
| 1537 | goto yynewerror; | |||
| 1538 | #endif | |||
| 1539 | yynewerror: | |||
| 1540 | yyerror("syntax error"); | |||
| 1541 | #if defined(__GNUC__4) | |||
| 1542 | goto yyerrlab; | |||
| 1543 | #endif | |||
| 1544 | yyerrlab: | |||
| 1545 | ++yynerrs; | |||
| 1546 | yyinrecovery: | |||
| 1547 | if (yyerrflag < 3) | |||
| 1548 | { | |||
| 1549 | yyerrflag = 3; | |||
| 1550 | for (;;) | |||
| 1551 | { | |||
| 1552 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 && | |||
| 1553 | yyn <= YYTABLESIZE477 && yycheck[yyn] == YYERRCODE256) | |||
| 1554 | { | |||
| 1555 | #if YYDEBUG0 | |||
| 1556 | if (yydebug) | |||
| 1557 | printf("%sdebug: state %d, error recovery shifting\ | |||
| 1558 | to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]); | |||
| 1559 | #endif | |||
| 1560 | if (yyssp >= yysslim && yygrowstack()) | |||
| 1561 | { | |||
| 1562 | goto yyoverflow; | |||
| 1563 | } | |||
| 1564 | *++yyssp = yystate = yytable[yyn]; | |||
| 1565 | *++yyvsp = yylval; | |||
| 1566 | goto yyloop; | |||
| 1567 | } | |||
| 1568 | else | |||
| 1569 | { | |||
| 1570 | #if YYDEBUG0 | |||
| 1571 | if (yydebug) | |||
| 1572 | printf("%sdebug: error recovery discarding state %d\n", | |||
| 1573 | YYPREFIX"yy", *yyssp); | |||
| 1574 | #endif | |||
| 1575 | if (yyssp <= yyss) goto yyabort; | |||
| 1576 | --yyssp; | |||
| 1577 | --yyvsp; | |||
| 1578 | } | |||
| 1579 | } | |||
| 1580 | } | |||
| 1581 | else | |||
| 1582 | { | |||
| 1583 | if (yychar == 0) goto yyabort; | |||
| 1584 | #if YYDEBUG0 | |||
| 1585 | if (yydebug) | |||
| 1586 | { | |||
| 1587 | yys = 0; | |||
| 1588 | if (yychar <= YYMAXTOKEN304) yys = yyname[yychar]; | |||
| 1589 | if (!yys) yys = "illegal-symbol"; | |||
| 1590 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n", | |||
| 1591 | YYPREFIX"yy", yystate, yychar, yys); | |||
| 1592 | } | |||
| 1593 | #endif | |||
| 1594 | yychar = (-1); | |||
| 1595 | goto yyloop; | |||
| 1596 | } | |||
| 1597 | yyreduce: | |||
| 1598 | #if YYDEBUG0 | |||
| 1599 | if (yydebug) | |||
| 1600 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | |||
| 1601 | YYPREFIX"yy", yystate, yyn, yyrule[yyn]); | |||
| 1602 | #endif | |||
| 1603 | yym = yylen[yyn]; | |||
| 1604 | if (yym) | |||
| 1605 | yyval = yyvsp[1-yym]; | |||
| 1606 | else | |||
| 1607 | memset(&yyval, 0, sizeof yyval); | |||
| 1608 | switch (yyn) | |||
| 1609 | { | |||
| 1610 | case 9: | |||
| 1611 | #line 173 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1612 | { file->errors++; } | |||
| 1613 | break; | |||
| 1614 | case 10: | |||
| 1615 | #line 176 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1616 | { | |||
| 1617 | struct file *nfile; | |||
| 1618 | ||||
| 1619 | if ((nfile = pushfile(yyvsp[0].v.string, | |||
| 1620 | !(global.cmd_opts & LDPD_OPT_NOACTION0x00000004))) == NULL((void *)0)) { | |||
| 1621 | yyerror("failed to include file %s", yyvsp[0].v.string); | |||
| 1622 | free(yyvsp[0].v.string); | |||
| 1623 | YYERRORgoto yyerrlab; | |||
| 1624 | } | |||
| 1625 | free(yyvsp[0].v.string); | |||
| 1626 | ||||
| 1627 | file = nfile; | |||
| 1628 | lungetc('\n'); | |||
| 1629 | } | |||
| 1630 | break; | |||
| 1631 | case 11: | |||
| 1632 | #line 192 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1633 | { | |||
| 1634 | if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1) { | |||
| 1635 | free(yyvsp[-1].v.string); | |||
| 1636 | free(yyvsp[0].v.string); | |||
| 1637 | yyerror("string: asprintf"); | |||
| 1638 | YYERRORgoto yyerrlab; | |||
| 1639 | } | |||
| 1640 | free(yyvsp[-1].v.string); | |||
| 1641 | free(yyvsp[0].v.string); | |||
| 1642 | } | |||
| 1643 | break; | |||
| 1644 | case 13: | |||
| 1645 | #line 205 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1646 | { | |||
| 1647 | if (!inet_aton(yyvsp[0].v.string, &yyval.v.routerid)) { | |||
| 1648 | yyerror("%s: error parsing router id", yyvsp[0].v.string); | |||
| 1649 | free(yyvsp[0].v.string); | |||
| 1650 | YYERRORgoto yyerrlab; | |||
| 1651 | } | |||
| 1652 | if (bad_addr_v4(yyval.v.routerid)) { | |||
| 1653 | yyerror("%s: invalid router id", yyvsp[0].v.string); | |||
| 1654 | free(yyvsp[0].v.string); | |||
| 1655 | YYERRORgoto yyerrlab; | |||
| 1656 | } | |||
| 1657 | free(yyvsp[0].v.string); | |||
| 1658 | ||||
| 1659 | break; | |||
| 1660 | } | |||
| 1661 | break; | |||
| 1662 | case 14: | |||
| 1663 | #line 222 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1664 | { yyval.v.number = 1; } | |||
| 1665 | break; | |||
| 1666 | case 15: | |||
| 1667 | #line 223 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1668 | { yyval.v.number = 0; } | |||
| 1669 | break; | |||
| 1670 | case 16: | |||
| 1671 | #line 226 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1672 | { yyval.v.number = AF_INET2; } | |||
| 1673 | break; | |||
| 1674 | case 17: | |||
| 1675 | #line 227 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1676 | { yyval.v.number = AF_INET624; } | |||
| 1677 | break; | |||
| 1678 | case 18: | |||
| 1679 | #line 230 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1680 | { yyval.v.number = L2VPN_TYPE_VPLS2; } | |||
| 1681 | break; | |||
| 1682 | case 19: | |||
| 1683 | #line 233 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1684 | { yyval.v.number = PW_TYPE_ETHERNET0x0005; } | |||
| 1685 | break; | |||
| 1686 | case 20: | |||
| 1687 | #line 234 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1688 | { yyval.v.number = PW_TYPE_ETHERNET_TAGGED0x0004; } | |||
| 1689 | break; | |||
| 1690 | case 21: | |||
| 1691 | #line 237 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1692 | { | |||
| 1693 | char *s = yyvsp[-2].v.string; | |||
| 1694 | if (global.cmd_opts & LDPD_OPT_VERBOSE0x00000001) | |||
| 1695 | printf("%s = \"%s\"\n", yyvsp[-2].v.string, yyvsp[0].v.string); | |||
| 1696 | while (*s++) { | |||
| 1697 | if (isspace((unsigned char)*s)) { | |||
| 1698 | yyerror("macro name cannot contain " | |||
| 1699 | "whitespace"); | |||
| 1700 | free(yyvsp[-2].v.string); | |||
| 1701 | free(yyvsp[0].v.string); | |||
| 1702 | YYERRORgoto yyerrlab; | |||
| 1703 | } | |||
| 1704 | } | |||
| 1705 | if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1) | |||
| 1706 | fatal("cannot store variable"); | |||
| 1707 | free(yyvsp[-2].v.string); | |||
| 1708 | free(yyvsp[0].v.string); | |||
| 1709 | } | |||
| 1710 | break; | |||
| 1711 | case 22: | |||
| 1712 | #line 257 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1713 | { | |||
| 1714 | conf->rtr_id = yyvsp[0].v.routerid; | |||
| 1715 | } | |||
| 1716 | break; | |||
| 1717 | case 23: | |||
| 1718 | #line 260 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1719 | { | |||
| 1720 | if (yyvsp[0].v.number == 0) | |||
| 1721 | conf->flags |= F_LDPD_NO_FIB_UPDATE0x0001; | |||
| 1722 | else | |||
| 1723 | conf->flags &= ~F_LDPD_NO_FIB_UPDATE0x0001; | |||
| 1724 | } | |||
| 1725 | break; | |||
| 1726 | case 24: | |||
| 1727 | #line 266 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1728 | { | |||
| 1729 | if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > RT_TABLEID_MAX255) { | |||
| 1730 | yyerror("invalid rdomain"); | |||
| 1731 | YYERRORgoto yyerrlab; | |||
| 1732 | } | |||
| 1733 | conf->rdomain = yyvsp[0].v.number; | |||
| 1734 | } | |||
| 1735 | break; | |||
| 1736 | case 25: | |||
| 1737 | #line 273 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1738 | { | |||
| 1739 | conf->trans_pref = yyvsp[0].v.number; | |||
| 1740 | ||||
| 1741 | switch (conf->trans_pref) { | |||
| 1742 | case AF_INET2: | |||
| 1743 | conf->trans_pref = DUAL_STACK_LDPOV44; | |||
| 1744 | break; | |||
| 1745 | case AF_INET624: | |||
| 1746 | conf->trans_pref = DUAL_STACK_LDPOV66; | |||
| 1747 | break; | |||
| 1748 | default: | |||
| 1749 | yyerror("invalid address-family"); | |||
| 1750 | YYERRORgoto yyerrlab; | |||
| 1751 | } | |||
| 1752 | } | |||
| 1753 | break; | |||
| 1754 | case 26: | |||
| 1755 | #line 288 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1756 | { | |||
| 1757 | if (yyvsp[0].v.number == 1) | |||
| 1758 | conf->flags |= F_LDPD_DS_CISCO_INTEROP0x0002; | |||
| 1759 | else | |||
| 1760 | conf->flags &= ~F_LDPD_DS_CISCO_INTEROP0x0002; | |||
| 1761 | } | |||
| 1762 | break; | |||
| 1763 | case 27: | |||
| 1764 | #line 294 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1765 | { | |||
| 1766 | LIST_INSERT_HEAD(&conf->auth_list, yyvsp[0].v.auth, entry)do { if (((yyvsp[0].v.auth)->entry.le_next = (&conf-> auth_list)->lh_first) != ((void *)0)) (&conf->auth_list )->lh_first->entry.le_prev = &(yyvsp[0].v.auth)-> entry.le_next; (&conf->auth_list)->lh_first = (yyvsp [0].v.auth); (yyvsp[0].v.auth)->entry.le_prev = &(& conf->auth_list)->lh_first; } while (0); | |||
| 1767 | } | |||
| 1768 | break; | |||
| 1769 | case 31: | |||
| 1770 | #line 302 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1771 | { | |||
| 1772 | af = yyvsp[0].v.number; | |||
| 1773 | switch (af) { | |||
| 1774 | case AF_INET2: | |||
| 1775 | af_conf = &conf->ipv4; | |||
| 1776 | break; | |||
| 1777 | case AF_INET624: | |||
| 1778 | af_conf = &conf->ipv6; | |||
| 1779 | break; | |||
| 1780 | default: | |||
| 1781 | yyerror("invalid address-family"); | |||
| 1782 | YYERRORgoto yyerrlab; | |||
| 1783 | } | |||
| 1784 | ||||
| 1785 | afdefs = *defs; | |||
| 1786 | defs = &afdefs; | |||
| 1787 | } | |||
| 1788 | break; | |||
| 1789 | case 32: | |||
| 1790 | #line 318 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1791 | { | |||
| 1792 | af_conf->keepalive = defs->keepalive; | |||
| 1793 | af_conf->thello_holdtime = defs->thello_holdtime; | |||
| 1794 | af_conf->thello_interval = defs->thello_interval; | |||
| 1795 | af_conf->flags = defs->afflags; | |||
| 1796 | af_conf->flags |= F_LDPD_AF_ENABLED0x0001; | |||
| 1797 | af_conf = NULL((void *)0); | |||
| 1798 | af = AF_UNSPEC0; | |||
| 1799 | defs = &globaldefs; | |||
| 1800 | } | |||
| 1801 | break; | |||
| 1802 | case 38: | |||
| 1803 | #line 339 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1804 | { | |||
| 1805 | if (get_address(yyvsp[0].v.string, &af_conf->trans_addr) == -1) { | |||
| 1806 | yyerror("error parsing transport-address"); | |||
| 1807 | free(yyvsp[0].v.string); | |||
| 1808 | YYERRORgoto yyerrlab; | |||
| 1809 | } | |||
| 1810 | free(yyvsp[0].v.string); | |||
| 1811 | if (bad_addr(af, &af_conf->trans_addr)) { | |||
| 1812 | yyerror("invalid transport-address"); | |||
| 1813 | YYERRORgoto yyerrlab; | |||
| 1814 | } | |||
| 1815 | if (af == AF_INET624 && | |||
| 1816 | IN6_IS_SCOPE_EMBED(&af_conf->trans_addr.v6)(((((&af_conf->trans_addr.v6)->__u6_addr.__u6_addr8 [0] == 0xfe) && (((&af_conf->trans_addr.v6)-> __u6_addr.__u6_addr8[1] & 0xc0) == 0x80))) || ((((&af_conf ->trans_addr.v6)->__u6_addr.__u6_addr8[0] == 0xff) && (((&af_conf->trans_addr.v6)->__u6_addr.__u6_addr8[ 1] & 0x0f) == 0x02))) || ((((&af_conf->trans_addr. v6)->__u6_addr.__u6_addr8[0] == 0xff) && (((&af_conf ->trans_addr.v6)->__u6_addr.__u6_addr8[1] & 0x0f) == 0x01))))) { | |||
| 1817 | yyerror("ipv6 transport-address can not be " | |||
| 1818 | "link-local"); | |||
| 1819 | YYERRORgoto yyerrlab; | |||
| 1820 | } | |||
| 1821 | } | |||
| 1822 | break; | |||
| 1823 | case 39: | |||
| 1824 | #line 357 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1825 | { | |||
| 1826 | if (yyvsp[0].v.number == 0) | |||
| 1827 | defs->afflags |= F_LDPD_AF_NO_GTSM0x0008; | |||
| 1828 | } | |||
| 1829 | break; | |||
| 1830 | case 45: | |||
| 1831 | #line 368 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1832 | { | |||
| 1833 | if (yyvsp[0].v.number == 0) | |||
| 1834 | defs->afflags &= ~F_LDPD_AF_THELLO_ACCEPT0x0002; | |||
| 1835 | else | |||
| 1836 | defs->afflags |= F_LDPD_AF_THELLO_ACCEPT0x0002; | |||
| 1837 | } | |||
| 1838 | break; | |||
| 1839 | case 46: | |||
| 1840 | #line 374 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1841 | { | |||
| 1842 | if (yyvsp[0].v.number == 0) | |||
| 1843 | defs->afflags &= ~F_LDPD_AF_EXPNULL0x0004; | |||
| 1844 | else | |||
| 1845 | defs->afflags |= F_LDPD_AF_EXPNULL0x0004; | |||
| 1846 | } | |||
| 1847 | break; | |||
| 1848 | case 47: | |||
| 1849 | #line 380 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1850 | { | |||
| 1851 | if (yyvsp[0].v.number < MIN_KEEPALIVE3 || yyvsp[0].v.number > MAX_KEEPALIVE0xffff) { | |||
| 1852 | yyerror("keepalive out of range (%d-%d)", | |||
| 1853 | MIN_KEEPALIVE3, MAX_KEEPALIVE0xffff); | |||
| 1854 | YYERRORgoto yyerrlab; | |||
| 1855 | } | |||
| 1856 | defs->keepalive = yyvsp[0].v.number; | |||
| 1857 | } | |||
| 1858 | break; | |||
| 1859 | case 48: | |||
| 1860 | #line 390 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1861 | { | |||
| 1862 | if (yyvsp[0].v.number < MIN_HOLDTIME3 || yyvsp[0].v.number > MAX_HOLDTIME0xffff) { | |||
| 1863 | yyerror("hello-holdtime out of range (%d-%d)", | |||
| 1864 | MIN_HOLDTIME3, MAX_HOLDTIME0xffff); | |||
| 1865 | YYERRORgoto yyerrlab; | |||
| 1866 | } | |||
| 1867 | defs->lhello_holdtime = yyvsp[0].v.number; | |||
| 1868 | } | |||
| 1869 | break; | |||
| 1870 | case 49: | |||
| 1871 | #line 398 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1872 | { | |||
| 1873 | if (yyvsp[0].v.number < MIN_HELLO_INTERVAL1 || | |||
| 1874 | yyvsp[0].v.number > MAX_HELLO_INTERVAL0xffff) { | |||
| 1875 | yyerror("hello-interval out of range (%d-%d)", | |||
| 1876 | MIN_HELLO_INTERVAL1, MAX_HELLO_INTERVAL0xffff); | |||
| 1877 | YYERRORgoto yyerrlab; | |||
| 1878 | } | |||
| 1879 | defs->lhello_interval = yyvsp[0].v.number; | |||
| 1880 | } | |||
| 1881 | break; | |||
| 1882 | case 50: | |||
| 1883 | #line 409 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1884 | { | |||
| 1885 | if (yyvsp[0].v.number < MIN_HOLDTIME3 || yyvsp[0].v.number > MAX_HOLDTIME0xffff) { | |||
| 1886 | yyerror("hello-holdtime out of range (%d-%d)", | |||
| 1887 | MIN_HOLDTIME3, MAX_HOLDTIME0xffff); | |||
| 1888 | YYERRORgoto yyerrlab; | |||
| 1889 | } | |||
| 1890 | defs->thello_holdtime = yyvsp[0].v.number; | |||
| 1891 | } | |||
| 1892 | break; | |||
| 1893 | case 51: | |||
| 1894 | #line 417 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1895 | { | |||
| 1896 | if (yyvsp[0].v.number < MIN_HELLO_INTERVAL1 || | |||
| 1897 | yyvsp[0].v.number > MAX_HELLO_INTERVAL0xffff) { | |||
| 1898 | yyerror("hello-interval out of range (%d-%d)", | |||
| 1899 | MIN_HELLO_INTERVAL1, MAX_HELLO_INTERVAL0xffff); | |||
| 1900 | YYERRORgoto yyerrlab; | |||
| 1901 | } | |||
| 1902 | defs->thello_interval = yyvsp[0].v.number; | |||
| 1903 | } | |||
| 1904 | break; | |||
| 1905 | case 52: | |||
| 1906 | #line 428 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1907 | { | |||
| 1908 | size_t len; | |||
| 1909 | ||||
| 1910 | yyval.v.auth = calloc(1, sizeof(*yyval.v.auth)); | |||
| 1911 | if (yyval.v.auth == NULL((void *)0)) { | |||
| 1912 | free(yyvsp[0].v.string); | |||
| 1913 | yyerror("unable to allocate md5 key"); | |||
| 1914 | YYERRORgoto yyerrlab; | |||
| 1915 | } | |||
| 1916 | ||||
| 1917 | len = strlen(yyvsp[0].v.string); | |||
| 1918 | if (len > sizeof(yyval.v.auth->md5key)) { | |||
| 1919 | free(yyval.v.auth); | |||
| 1920 | free(yyvsp[0].v.string); | |||
| 1921 | yyerror("tcp md5sig password too long: " | |||
| 1922 | "max %zu", sizeof(yyval.v.auth->md5key)); | |||
| 1923 | YYERRORgoto yyerrlab; | |||
| 1924 | } | |||
| 1925 | ||||
| 1926 | memcpy(yyval.v.auth->md5key, yyvsp[0].v.string, len); | |||
| 1927 | yyval.v.auth->md5key_len = len; | |||
| 1928 | ||||
| 1929 | free(yyvsp[0].v.string); | |||
| 1930 | } | |||
| 1931 | break; | |||
| 1932 | case 53: | |||
| 1933 | #line 452 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1934 | { | |||
| 1935 | int len; | |||
| 1936 | ||||
| 1937 | yyval.v.auth = calloc(1, sizeof(*yyval.v.auth)); | |||
| 1938 | if (yyval.v.auth == NULL((void *)0)) { | |||
| 1939 | free(yyvsp[0].v.string); | |||
| 1940 | yyerror("unable to allocate md5 key"); | |||
| 1941 | YYERRORgoto yyerrlab; | |||
| 1942 | } | |||
| 1943 | ||||
| 1944 | len = str2key(yyval.v.auth->md5key, yyvsp[0].v.string, sizeof(yyval.v.auth->md5key)); | |||
| 1945 | if (len == -1) { | |||
| 1946 | free(yyval.v.auth); | |||
| 1947 | free(yyvsp[0].v.string); | |||
| 1948 | yyerror("invalid hex string"); | |||
| 1949 | YYERRORgoto yyerrlab; | |||
| 1950 | } | |||
| 1951 | if ((size_t)len > sizeof(yyval.v.auth->md5key_len)) { | |||
| 1952 | free(yyval.v.auth); | |||
| 1953 | free(yyvsp[0].v.string); | |||
| 1954 | yyerror("tcp md5sig key too long: %d " | |||
| 1955 | "max %zu", len, sizeof(yyval.v.auth->md5key)); | |||
| 1956 | YYERRORgoto yyerrlab; | |||
| 1957 | } | |||
| 1958 | ||||
| 1959 | yyval.v.auth->md5key_len = len; | |||
| 1960 | ||||
| 1961 | free(yyvsp[0].v.string); | |||
| 1962 | } | |||
| 1963 | break; | |||
| 1964 | case 54: | |||
| 1965 | #line 481 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1966 | { | |||
| 1967 | yyval.v.auth = calloc(1, sizeof(*yyval.v.auth)); | |||
| 1968 | if (yyval.v.auth == NULL((void *)0)) { | |||
| 1969 | yyerror("unable to allocate no md5 key"); | |||
| 1970 | YYERRORgoto yyerrlab; | |||
| 1971 | } | |||
| 1972 | yyval.v.auth->md5key_len = 0; | |||
| 1973 | } | |||
| 1974 | break; | |||
| 1975 | case 55: | |||
| 1976 | #line 491 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1977 | { | |||
| 1978 | yyval.v.auth = calloc(1, sizeof(*yyval.v.auth)); | |||
| 1979 | if (yyval.v.auth == NULL((void *)0)) { | |||
| 1980 | yyerror("unable to allocate auth"); | |||
| 1981 | free(yyvsp[0].v.string); | |||
| 1982 | YYERRORgoto yyerrlab; | |||
| 1983 | } | |||
| 1984 | ||||
| 1985 | yyval.v.auth->idlen = inet_net_pton(AF_INET2, yyvsp[0].v.string, | |||
| 1986 | &yyval.v.auth->id, sizeof(yyval.v.auth->id)); | |||
| 1987 | if (yyval.v.auth->idlen == -1) { | |||
| 1988 | yyerror("%s: %s", yyvsp[0].v.string, strerror(errno(*__errno()))); | |||
| 1989 | free(yyvsp[0].v.string); | |||
| 1990 | YYERRORgoto yyerrlab; | |||
| 1991 | } | |||
| 1992 | } | |||
| 1993 | break; | |||
| 1994 | case 56: | |||
| 1995 | #line 507 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 1996 | { | |||
| 1997 | yyval.v.auth = NULL((void *)0); | |||
| 1998 | } | |||
| 1999 | break; | |||
| 2000 | case 57: | |||
| 2001 | #line 512 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2002 | { | |||
| 2003 | yyval.v.auth = yyvsp[-1].v.auth; | |||
| 2004 | if (yyvsp[0].v.auth != NULL((void *)0)) { | |||
| 2005 | yyval.v.auth->id = yyvsp[0].v.auth->id; | |||
| 2006 | yyval.v.auth->idlen = yyvsp[0].v.auth->idlen; | |||
| 2007 | free(yyvsp[0].v.auth); | |||
| 2008 | } else { | |||
| 2009 | yyval.v.auth->id.s_addr = 0; | |||
| 2010 | yyval.v.auth->idlen = 0; | |||
| 2011 | } | |||
| 2012 | } | |||
| 2013 | break; | |||
| 2014 | case 58: | |||
| 2015 | #line 525 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2016 | { | |||
| 2017 | if (yyvsp[0].v.number < MIN_KEEPALIVE3 || yyvsp[0].v.number > MAX_KEEPALIVE0xffff) { | |||
| 2018 | yyerror("keepalive out of range (%d-%d)", | |||
| 2019 | MIN_KEEPALIVE3, MAX_KEEPALIVE0xffff); | |||
| 2020 | YYERRORgoto yyerrlab; | |||
| 2021 | } | |||
| 2022 | nbrp->keepalive = yyvsp[0].v.number; | |||
| 2023 | nbrp->flags |= F_NBRP_KEEPALIVE0x01; | |||
| 2024 | } | |||
| 2025 | break; | |||
| 2026 | case 59: | |||
| 2027 | #line 534 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2028 | { | |||
| 2029 | /* this is syntactic sugar... */ | |||
| 2030 | yyvsp[0].v.auth->id = nbrp->lsr_id; | |||
| 2031 | yyvsp[0].v.auth->idlen = 32; | |||
| 2032 | LIST_INSERT_HEAD(&conf->auth_list, yyvsp[0].v.auth, entry)do { if (((yyvsp[0].v.auth)->entry.le_next = (&conf-> auth_list)->lh_first) != ((void *)0)) (&conf->auth_list )->lh_first->entry.le_prev = &(yyvsp[0].v.auth)-> entry.le_next; (&conf->auth_list)->lh_first = (yyvsp [0].v.auth); (yyvsp[0].v.auth)->entry.le_prev = &(& conf->auth_list)->lh_first; } while (0); | |||
| 2033 | } | |||
| 2034 | break; | |||
| 2035 | case 60: | |||
| 2036 | #line 540 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2037 | { | |||
| 2038 | nbrp->flags |= F_NBRP_GTSM0x02; | |||
| 2039 | nbrp->gtsm_enabled = yyvsp[0].v.number; | |||
| 2040 | } | |||
| 2041 | break; | |||
| 2042 | case 61: | |||
| 2043 | #line 544 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2044 | { | |||
| 2045 | if (yyvsp[0].v.number < 1 || yyvsp[0].v.number > 255) { | |||
| 2046 | yyerror("invalid number of hops %lld", yyvsp[0].v.number); | |||
| 2047 | YYERRORgoto yyerrlab; | |||
| 2048 | } | |||
| 2049 | nbrp->gtsm_hops = yyvsp[0].v.number; | |||
| 2050 | nbrp->flags |= F_NBRP_GTSM_HOPS0x04; | |||
| 2051 | } | |||
| 2052 | break; | |||
| 2053 | case 62: | |||
| 2054 | #line 554 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2055 | { | |||
| 2056 | if (yyvsp[0].v.number == 1) | |||
| 2057 | defs->pwflags |= F_PW_STATUSTLV_CONF0x01; | |||
| 2058 | else | |||
| 2059 | defs->pwflags &= ~F_PW_STATUSTLV_CONF0x01; | |||
| 2060 | } | |||
| 2061 | break; | |||
| 2062 | case 63: | |||
| 2063 | #line 560 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2064 | { | |||
| 2065 | if (yyvsp[0].v.number == 1) | |||
| 2066 | defs->pwflags |= F_PW_CWORD_CONF0x04; | |||
| 2067 | else | |||
| 2068 | defs->pwflags &= ~F_PW_CWORD_CONF0x04; | |||
| 2069 | } | |||
| 2070 | break; | |||
| 2071 | case 64: | |||
| 2072 | #line 568 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2073 | { | |||
| 2074 | if (yyvsp[0].v.number < MIN_PWID_ID1 || | |||
| 2075 | yyvsp[0].v.number > MAX_PWID_ID0xffffffff) { | |||
| 2076 | yyerror("pw-id out of range (%d-%d)", | |||
| 2077 | MIN_PWID_ID1, MAX_PWID_ID0xffffffff); | |||
| 2078 | YYERRORgoto yyerrlab; | |||
| 2079 | } | |||
| 2080 | ||||
| 2081 | pw->pwid = yyvsp[0].v.number; | |||
| 2082 | } | |||
| 2083 | break; | |||
| 2084 | case 65: | |||
| 2085 | #line 578 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2086 | { | |||
| 2087 | pw->lsr_id = yyvsp[0].v.routerid; | |||
| 2088 | } | |||
| 2089 | break; | |||
| 2090 | case 66: | |||
| 2091 | #line 581 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2092 | { | |||
| 2093 | int family; | |||
| 2094 | union ldpd_addr addr; | |||
| 2095 | ||||
| 2096 | if (get_af_address(yyvsp[0].v.string, &family, &addr) == -1) { | |||
| 2097 | yyerror("error parsing neighbor address"); | |||
| 2098 | free(yyvsp[0].v.string); | |||
| 2099 | YYERRORgoto yyerrlab; | |||
| 2100 | } | |||
| 2101 | free(yyvsp[0].v.string); | |||
| 2102 | if (bad_addr(family, &addr)) { | |||
| 2103 | yyerror("invalid neighbor address"); | |||
| 2104 | YYERRORgoto yyerrlab; | |||
| 2105 | } | |||
| 2106 | if (family == AF_INET624 && | |||
| 2107 | IN6_IS_SCOPE_EMBED(&addr.v6)(((((&addr.v6)->__u6_addr.__u6_addr8[0] == 0xfe) && (((&addr.v6)->__u6_addr.__u6_addr8[1] & 0xc0) == 0x80 ))) || ((((&addr.v6)->__u6_addr.__u6_addr8[0] == 0xff) && (((&addr.v6)->__u6_addr.__u6_addr8[1] & 0x0f) == 0x02))) || ((((&addr.v6)->__u6_addr.__u6_addr8 [0] == 0xff) && (((&addr.v6)->__u6_addr.__u6_addr8 [1] & 0x0f) == 0x01))))) { | |||
| 2108 | yyerror("neighbor address can not be " | |||
| 2109 | "link-local"); | |||
| 2110 | YYERRORgoto yyerrlab; | |||
| 2111 | } | |||
| 2112 | ||||
| 2113 | pw->af = family; | |||
| 2114 | pw->addr = addr; | |||
| 2115 | } | |||
| 2116 | break; | |||
| 2117 | case 68: | |||
| 2118 | #line 608 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2119 | { | |||
| 2120 | struct kif *kif; | |||
| 2121 | ||||
| 2122 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
| 2123 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 2124 | free(yyvsp[0].v.string); | |||
| 2125 | YYERRORgoto yyerrlab; | |||
| 2126 | } | |||
| 2127 | free(yyvsp[0].v.string); | |||
| 2128 | ||||
| 2129 | if (kif->if_type != IFT_MPLSTUNNEL0x96 && | |||
| 2130 | kmpw_find(kif->ifname) == -1) { | |||
| 2131 | yyerror("unsupported interface type on " | |||
| 2132 | "interface %s", kif->ifname); | |||
| 2133 | YYERRORgoto yyerrlab; | |||
| 2134 | } | |||
| 2135 | ||||
| 2136 | pw = conf_get_l2vpn_pw(l2vpn, kif); | |||
| 2137 | if (pw == NULL((void *)0)) | |||
| 2138 | YYERRORgoto yyerrlab; | |||
| 2139 | ||||
| 2140 | pwdefs = *defs; | |||
| 2141 | defs = &pwdefs; | |||
| 2142 | } | |||
| 2143 | break; | |||
| 2144 | case 69: | |||
| 2145 | #line 631 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2146 | { | |||
| 2147 | struct l2vpn *l; | |||
| 2148 | struct l2vpn_pw *p; | |||
| 2149 | ||||
| 2150 | /* check for errors */ | |||
| 2151 | if (pw->pwid == 0) { | |||
| 2152 | yyerror("missing pseudowire id"); | |||
| 2153 | YYERRORgoto yyerrlab; | |||
| 2154 | } | |||
| 2155 | if (pw->lsr_id.s_addr == INADDR_ANY((u_int32_t)(0x00000000))) { | |||
| 2156 | yyerror("missing pseudowire neighbor-id"); | |||
| 2157 | YYERRORgoto yyerrlab; | |||
| 2158 | } | |||
| 2159 | LIST_FOREACH(l, &conf->l2vpn_list, entry)for((l) = ((&conf->l2vpn_list)->lh_first); (l)!= (( void *)0); (l) = ((l)->entry.le_next)) { | |||
| 2160 | LIST_FOREACH(p, &l->pw_list, entry)for((p) = ((&l->pw_list)->lh_first); (p)!= ((void * )0); (p) = ((p)->entry.le_next)) { | |||
| 2161 | if (pw != p && | |||
| 2162 | pw->pwid == p->pwid && | |||
| 2163 | pw->af == p->af && | |||
| 2164 | pw->lsr_id.s_addr == | |||
| 2165 | p->lsr_id.s_addr) { | |||
| 2166 | yyerror("pseudowire already " | |||
| 2167 | "configured"); | |||
| 2168 | YYERRORgoto yyerrlab; | |||
| 2169 | } | |||
| 2170 | } | |||
| 2171 | } | |||
| 2172 | ||||
| 2173 | /* | |||
| 2174 | * If the neighbor address is not specified, use the | |||
| 2175 | * neighbor id. | |||
| 2176 | */ | |||
| 2177 | if (pw->af == AF_UNSPEC0) { | |||
| 2178 | pw->af = AF_INET2; | |||
| 2179 | pw->addr.v4 = pw->lsr_id; | |||
| 2180 | } | |||
| 2181 | ||||
| 2182 | pw->flags = defs->pwflags; | |||
| 2183 | pw = NULL((void *)0); | |||
| 2184 | defs = &globaldefs; | |||
| 2185 | } | |||
| 2186 | break; | |||
| 2187 | case 75: | |||
| 2188 | #line 682 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2189 | { | |||
| 2190 | l2vpn->pw_type = yyvsp[0].v.number; | |||
| 2191 | } | |||
| 2192 | break; | |||
| 2193 | case 76: | |||
| 2194 | #line 685 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2195 | { | |||
| 2196 | if (yyvsp[0].v.number < MIN_L2VPN_MTU512 || | |||
| 2197 | yyvsp[0].v.number > MAX_L2VPN_MTU0xffff) { | |||
| 2198 | yyerror("l2vpn mtu out of range (%d-%d)", | |||
| 2199 | MIN_L2VPN_MTU512, MAX_L2VPN_MTU0xffff); | |||
| 2200 | YYERRORgoto yyerrlab; | |||
| 2201 | } | |||
| 2202 | l2vpn->mtu = yyvsp[0].v.number; | |||
| 2203 | } | |||
| 2204 | break; | |||
| 2205 | case 78: | |||
| 2206 | #line 695 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2207 | { | |||
| 2208 | struct l2vpn *l; | |||
| 2209 | struct kif *kif; | |||
| 2210 | ||||
| 2211 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
| 2212 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 2213 | free(yyvsp[0].v.string); | |||
| 2214 | YYERRORgoto yyerrlab; | |||
| 2215 | } | |||
| 2216 | free(yyvsp[0].v.string); | |||
| 2217 | ||||
| 2218 | if (l2vpn->br_ifindex != 0) { | |||
| 2219 | yyerror("bridge interface cannot be " | |||
| 2220 | "redefined on l2vpn %s", l2vpn->name); | |||
| 2221 | YYERRORgoto yyerrlab; | |||
| 2222 | } | |||
| 2223 | ||||
| 2224 | if (kif->if_type != IFT_BRIDGE0xd1) { | |||
| 2225 | yyerror("unsupported interface type on " | |||
| 2226 | "interface %s", kif->ifname); | |||
| 2227 | YYERRORgoto yyerrlab; | |||
| 2228 | } | |||
| 2229 | ||||
| 2230 | LIST_FOREACH(l, &conf->l2vpn_list, entry)for((l) = ((&conf->l2vpn_list)->lh_first); (l)!= (( void *)0); (l) = ((l)->entry.le_next)) { | |||
| 2231 | if (l->br_ifindex == kif->ifindex) { | |||
| 2232 | yyerror("bridge %s is already being " | |||
| 2233 | "used by l2vpn %s", kif->ifname, | |||
| 2234 | l->name); | |||
| 2235 | YYERRORgoto yyerrlab; | |||
| 2236 | } | |||
| 2237 | } | |||
| 2238 | ||||
| 2239 | l2vpn->br_ifindex = kif->ifindex; | |||
| 2240 | strlcpy(l2vpn->br_ifname, kif->ifname, | |||
| 2241 | sizeof(l2vpn->br_ifname)); | |||
| 2242 | } | |||
| 2243 | break; | |||
| 2244 | case 79: | |||
| 2245 | #line 731 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2246 | { | |||
| 2247 | struct kif *kif; | |||
| 2248 | struct l2vpn_if *lif; | |||
| 2249 | ||||
| 2250 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
| 2251 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 2252 | free(yyvsp[0].v.string); | |||
| 2253 | YYERRORgoto yyerrlab; | |||
| 2254 | } | |||
| 2255 | free(yyvsp[0].v.string); | |||
| 2256 | ||||
| 2257 | lif = conf_get_l2vpn_if(l2vpn, kif); | |||
| 2258 | if (lif == NULL((void *)0)) | |||
| 2259 | YYERRORgoto yyerrlab; | |||
| 2260 | } | |||
| 2261 | break; | |||
| 2262 | case 84: | |||
| 2263 | #line 756 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2264 | { | |||
| 2265 | struct kif *kif; | |||
| 2266 | ||||
| 2267 | if ((kif = kif_findname(yyvsp[0].v.string)) == NULL((void *)0)) { | |||
| 2268 | yyerror("unknown interface %s", yyvsp[0].v.string); | |||
| 2269 | free(yyvsp[0].v.string); | |||
| 2270 | YYERRORgoto yyerrlab; | |||
| 2271 | } | |||
| 2272 | free(yyvsp[0].v.string); | |||
| 2273 | ||||
| 2274 | iface = conf_get_if(kif); | |||
| 2275 | if (iface == NULL((void *)0)) | |||
| 2276 | YYERRORgoto yyerrlab; | |||
| 2277 | ||||
| 2278 | ia = iface_af_get(iface, af); | |||
| 2279 | if (ia->enabled) { | |||
| 2280 | yyerror("interface %s already configured for " | |||
| 2281 | "address-family %s", kif->ifname, | |||
| 2282 | af_name(af)); | |||
| 2283 | YYERRORgoto yyerrlab; | |||
| 2284 | } | |||
| 2285 | ia->enabled = 1; | |||
| 2286 | ||||
| 2287 | ifacedefs = *defs; | |||
| 2288 | defs = &ifacedefs; | |||
| 2289 | } | |||
| 2290 | break; | |||
| 2291 | case 85: | |||
| 2292 | #line 781 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2293 | { | |||
| 2294 | ia->hello_holdtime = defs->lhello_holdtime; | |||
| 2295 | ia->hello_interval = defs->lhello_interval; | |||
| 2296 | iface = NULL((void *)0); | |||
| 2297 | defs = &afdefs; | |||
| 2298 | } | |||
| 2299 | break; | |||
| 2300 | case 91: | |||
| 2301 | #line 798 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2302 | { | |||
| 2303 | union ldpd_addr addr; | |||
| 2304 | ||||
| 2305 | if (get_address(yyvsp[0].v.string, &addr) == -1) { | |||
| 2306 | yyerror("error parsing targeted-neighbor " | |||
| 2307 | "address"); | |||
| 2308 | free(yyvsp[0].v.string); | |||
| 2309 | YYERRORgoto yyerrlab; | |||
| 2310 | } | |||
| 2311 | free(yyvsp[0].v.string); | |||
| 2312 | if (bad_addr(af, &addr)) { | |||
| 2313 | yyerror("invalid targeted-neighbor address"); | |||
| 2314 | YYERRORgoto yyerrlab; | |||
| 2315 | } | |||
| 2316 | if (af == AF_INET624 && | |||
| 2317 | IN6_IS_SCOPE_EMBED(&addr.v6)(((((&addr.v6)->__u6_addr.__u6_addr8[0] == 0xfe) && (((&addr.v6)->__u6_addr.__u6_addr8[1] & 0xc0) == 0x80 ))) || ((((&addr.v6)->__u6_addr.__u6_addr8[0] == 0xff) && (((&addr.v6)->__u6_addr.__u6_addr8[1] & 0x0f) == 0x02))) || ((((&addr.v6)->__u6_addr.__u6_addr8 [0] == 0xff) && (((&addr.v6)->__u6_addr.__u6_addr8 [1] & 0x0f) == 0x01))))) { | |||
| 2318 | yyerror("targeted-neighbor address can not be " | |||
| 2319 | "link-local"); | |||
| 2320 | YYERRORgoto yyerrlab; | |||
| 2321 | } | |||
| 2322 | ||||
| 2323 | tnbr = conf_get_tnbr(&addr); | |||
| 2324 | if (tnbr == NULL((void *)0)) | |||
| 2325 | YYERRORgoto yyerrlab; | |||
| 2326 | ||||
| 2327 | tnbrdefs = *defs; | |||
| 2328 | defs = &tnbrdefs; | |||
| 2329 | } | |||
| 2330 | break; | |||
| 2331 | case 92: | |||
| 2332 | #line 825 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2333 | { | |||
| 2334 | tnbr->hello_holdtime = defs->thello_holdtime; | |||
| 2335 | tnbr->hello_interval = defs->thello_interval; | |||
| 2336 | tnbr = NULL((void *)0); | |||
| 2337 | defs = &afdefs; | |||
| 2338 | } | |||
| 2339 | break; | |||
| 2340 | case 98: | |||
| 2341 | #line 842 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2342 | { | |||
| 2343 | nbrp = conf_get_nbrp(yyvsp[0].v.routerid); | |||
| 2344 | if (nbrp == NULL((void *)0)) | |||
| 2345 | YYERRORgoto yyerrlab; | |||
| 2346 | } | |||
| 2347 | break; | |||
| 2348 | case 99: | |||
| 2349 | #line 846 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2350 | { | |||
| 2351 | nbrp = NULL((void *)0); | |||
| 2352 | } | |||
| 2353 | break; | |||
| 2354 | case 105: | |||
| 2355 | #line 860 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2356 | { | |||
| 2357 | l2vpn = conf_get_l2vpn(yyvsp[-2].v.string); | |||
| 2358 | if (l2vpn == NULL((void *)0)) | |||
| 2359 | YYERRORgoto yyerrlab; | |||
| 2360 | l2vpn->type = yyvsp[0].v.number; | |||
| 2361 | } | |||
| 2362 | break; | |||
| 2363 | case 106: | |||
| 2364 | #line 865 "/usr/src/usr.sbin/ldpd/parse.y" | |||
| 2365 | { | |||
| 2366 | l2vpn = NULL((void *)0); | |||
| 2367 | } | |||
| 2368 | break; | |||
| 2369 | #line 2362 "parse.c" | |||
| 2370 | } | |||
| 2371 | yyssp -= yym; | |||
| 2372 | yystate = *yyssp; | |||
| 2373 | yyvsp -= yym; | |||
| 2374 | yym = yylhs[yyn]; | |||
| 2375 | if (yystate == 0 && yym == 0) | |||
| 2376 | { | |||
| 2377 | #if YYDEBUG0 | |||
| 2378 | if (yydebug) | |||
| 2379 | printf("%sdebug: after reduction, shifting from state 0 to\ | |||
| 2380 | state %d\n", YYPREFIX"yy", YYFINAL1); | |||
| 2381 | #endif | |||
| 2382 | yystate = YYFINAL1; | |||
| 2383 | *++yyssp = YYFINAL1; | |||
| 2384 | *++yyvsp = yyval; | |||
| 2385 | if (yychar < 0) | |||
| 2386 | { | |||
| 2387 | if ((yychar = yylex()) < 0) yychar = 0; | |||
| 2388 | #if YYDEBUG0 | |||
| 2389 | if (yydebug) | |||
| 2390 | { | |||
| 2391 | yys = 0; | |||
| 2392 | if (yychar <= YYMAXTOKEN304) yys = yyname[yychar]; | |||
| 2393 | if (!yys) yys = "illegal-symbol"; | |||
| 2394 | printf("%sdebug: state %d, reading %d (%s)\n", | |||
| 2395 | YYPREFIX"yy", YYFINAL1, yychar, yys); | |||
| 2396 | } | |||
| 2397 | #endif | |||
| 2398 | } | |||
| 2399 | if (yychar == 0) goto yyaccept; | |||
| 2400 | goto yyloop; | |||
| 2401 | } | |||
| 2402 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && | |||
| 2403 | yyn <= YYTABLESIZE477 && yycheck[yyn] == yystate) | |||
| 2404 | yystate = yytable[yyn]; | |||
| 2405 | else | |||
| 2406 | yystate = yydgoto[yym]; | |||
| 2407 | #if YYDEBUG0 | |||
| 2408 | if (yydebug) | |||
| 2409 | printf("%sdebug: after reduction, shifting from state %d \ | |||
| 2410 | to state %d\n", YYPREFIX"yy", *yyssp, yystate); | |||
| 2411 | #endif | |||
| 2412 | if (yyssp >= yysslim && yygrowstack()) | |||
| 2413 | { | |||
| 2414 | goto yyoverflow; | |||
| 2415 | } | |||
| 2416 | *++yyssp = yystate; | |||
| 2417 | *++yyvsp = yyval; | |||
| 2418 | goto yyloop; | |||
| 2419 | yyoverflow: | |||
| 2420 | yyerror("yacc stack overflow"); | |||
| 2421 | yyabort: | |||
| 2422 | if (yyss) | |||
| 2423 | free(yyss); | |||
| 2424 | if (yyvs) | |||
| 2425 | free(yyvs); | |||
| 2426 | yyss = yyssp = NULL((void *)0); | |||
| 2427 | yyvs = yyvsp = NULL((void *)0); | |||
| 2428 | yystacksize = 0; | |||
| 2429 | return (1); | |||
| 2430 | yyaccept: | |||
| 2431 | if (yyss) | |||
| 2432 | free(yyss); | |||
| 2433 | if (yyvs) | |||
| 2434 | free(yyvs); | |||
| 2435 | yyss = yyssp = NULL((void *)0); | |||
| 2436 | yyvs = yyvsp = NULL((void *)0); | |||
| 2437 | yystacksize = 0; | |||
| 2438 | return (0); | |||
| 2439 | } |