#include #ifndef lint #if 0 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #else __IDSTRING(yyrcsid, "$NetBSD: skeleton.c,v 1.14 1997/10/20 03:41:16 lukem Exp $"); #endif #endif #include #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 #define YYLEX yylex() #define YYEMPTY -1 #define yyclearin (yychar=(YYEMPTY)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" #line 2 "grammar.y" /* extract - A network log processor Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford Please see the file `COPYING' for the complete copyright notice. grammar.y - 03/20/93 */ #include #include #include #include #include #include #include "lex.h" #include "chario.h" #include "parser.h" #include "builder.h" #include "timesub.h" #include "stdunix.h" extern int parse_error; #define TCPDATA 6 #define UDPDATA 17 #define ICMPDATA 1 extern int protoflag; struct icmptypes { char *name; unsigned short type; }; static struct icmptypes icmptbl[] = { { "echorep", 0x0000 }, { "netunreach", 0x0300 }, { "hostunreach", 0x0301 }, { "protounreach", 0x0302 }, { "portunreach", 0x0303 }, { "fraglost", 0x0304 }, { "badsrcroute", 0x0305 }, { "srcquench", 0x0400 }, { "netredir", 0x0500 }, { "hostredir", 0x0501 }, { "tosnetredir", 0x0502 }, { "toshostredir", 0x0503 }, { "echoreq", 0x0800 }, { "tstampreq", 0x0d00 }, { "tstamprep", 0x0e00 }, { "inforeq", 0x0f00 }, { "inforep", 0x1000 }, { "maskreq", 0x1100 }, { "maskrep", 0x1200 }, { 0, 0 } }; #line 60 "grammar.y" typedef union { unsigned int intval; unsigned long *intpval; char *strval; } YYSTYPE; #line 83 "y.tab.c" #define DSTPORT 257 #define SRCPORT 258 #define DSTADDR 259 #define SRCADDR 260 #define SRCNET 261 #define DSTNET 262 #define DATE 263 #define TIME 264 #define PORT 265 #define HOST 266 #define NET 267 #define PROTO 268 #define PKTS 269 #define OCTETS 270 #define FLAG 271 #define FLAGS 272 #define DSTIFACE 273 #define SRCIFACE 274 #define IFACE 275 #define NEXTHOP 276 #define SRCHP 277 #define DSTHP 278 #define HP 279 #define TODAY 280 #define YEST 281 #define INCLUDE 282 #define OR 283 #define AND 284 #define MASKOPER 285 #define NOT 286 #define SINCE 287 #define BEFORE 288 #define NEQ 289 #define LEQ 290 #define GEQ 291 #define INTEGER 292 #define BYTEVAL 293 #define STRING 294 #define PRINT 295 #define NEXT 296 #define PRINTALL 297 #define RANGE 298 #define YYERRCODE 256 short yylhs[] = { -1, 0, 0, 10, 10, 11, 11, 11, 11, 12, 12, 12, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 7, 7, 7, 7, 7, 7, 8, 8, 8, 6, 6, 6, 5, 5, 9, 9, 9, 4, 3, }; short yylen[] = { 2, 2, 1, 4, 3, 0, 3, 3, 1, 3, 2, 1, 1, 1, 1, 1, 3, 4, 3, 4, 3, 4, 3, 4, 3, 3, 4, 3, 4, 3, 5, 3, 4, 3, 4, 3, 4, 2, 2, 4, 3, 3, 5, 5, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 7, 2, 5, 7, 2, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 5, 1, 1, 1, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, }; short yydefred[] = { 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 67, 68, 69, 86, 87, 84, 64, 66, 65, 0, 83, 0, 0, 0, 70, 0, 0, 73, 72, 71, 0, 0, 0, 77, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 79, 0, 0, 61, 0, 1, 0, 0, 0, 85, 20, 0, 18, 0, 90, 0, 89, 88, 27, 25, 0, 0, 0, 50, 0, 0, 0, 82, 52, 0, 16, 0, 22, 0, 31, 0, 33, 0, 35, 0, 0, 48, 0, 46, 0, 44, 0, 24, 0, 0, 0, 4, 0, 0, 60, 0, 7, 15, 12, 13, 14, 0, 0, 21, 19, 0, 0, 0, 0, 0, 51, 0, 53, 17, 0, 32, 34, 36, 39, 49, 47, 45, 26, 28, 23, 0, 0, 3, 0, 0, 91, 42, 43, 0, 0, 0, 30, 0, 0, 9, 0, 75, 76, 81, 0, 0, 0, 55, 58, 0, 92, }; short yydgoto[] = { 31, 45, 56, 110, 184, 46, 47, 64, 68, 111, 32, 33, 154, 34, 155, }; short yysindex[] = { 4, 0, 70, 70, 92, 92, -58, -58, 77, 87, 70, 92, -58, 82, 82, 82, -270, -265, 82, 82, 82, 92, 92, 92, 92, -260, 37, -173, -173, 37, 37, 0, 4, -118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -159, 0, -263, -159, -259, 0, -228, -228, 0, 0, 0, -228, -228, 0, 0, 0, -14, -173, -7, -258, 0, -16, -246, -257, -159, -255, -228, -228, -261, -253, -261, -248, -261, -241, 0, 29, -261, -218, -261, -217, -261, -204, -228, -228, -228, -228, 41, 0, 0, -197, -194, 0, 46, 0, 37, 37, -185, 0, 0, -159, 0, -159, 0, 55, 0, 0, 0, 0, 56, 57, -187, 0, -184, -173, -179, 0, 0, -246, 0, -159, 0, 69, 0, -261, 0, -261, 0, -261, -176, 0, -261, 0, -261, 0, -261, 0, -159, -159, -159, 0, 64, 68, 0, -157, 0, 0, 0, 0, 0, 11, 81, 0, 0, -164, -152, -152, 98, 101, 0, 93, 0, 0, -152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -143, -138, 0, -185, 110, 0, 0, 0, -261, -134, -133, 0, 104, 105, 0, -129, 0, 0, 0, -122, -117, 132, 0, 0, -111, 0, }; short yyrindex[] = { -103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 1, 0, 0, -220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -229, 0, 0, 138, 0, 0, 0, -237, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -35, -33, 0, 0, 0, -30, -30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -28, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -25, 0, 0, 0, 0, 0, 0, 59, 0, 0, 0, 0, 0, -41, 0, 0, -39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; short yygindex[] = { 154, 214, 14, -142, -137, 40, 339, -13, -60, 117, 0, -8, 6, -17, 0, }; #define YYTABLESIZE 482 short yytable[] = { 74, 2, 80, 55, 38, 101, 56, 121, 59, 92, 120, 5, 96, 40, 94, 95, 6, 183, 183, 70, 5, 57, 97, 185, 79, 183, 72, 70, 107, 80, 189, 39, 40, 115, 91, 104, 70, 29, 117, 106, 118, 122, 119, 124, 30, 128, 41, 66, 63, 116, 130, 70, 70, 74, 76, 78, 70, 132, 82, 84, 86, 82, 165, 70, 70, 108, 109, 63, 63, 79, 29, 150, 70, 70, 70, 29, 133, 30, 85, 54, 135, 137, 74, 93, 80, 57, 38, 147, 56, 5, 59, 148, 149, 5, 139, 40, 145, 102, 6, 146, 144, 158, 63, 159, 160, 163, 161, 59, 60, 162, 151, 152, 153, 127, 164, 129, 167, 131, 171, 39, 61, 134, 178, 136, 5, 138, 179, 100, 41, 182, 43, 42, 44, 39, 40, 41, 180, 43, 42, 44, 181, 108, 43, 42, 44, 186, 187, 43, 42, 44, 190, 188, 43, 42, 44, 191, 193, 29, 63, 195, 196, 54, 197, 198, 199, 99, 100, 57, 168, 112, 169, 200, 170, 113, 114, 172, 201, 173, 202, 174, 5, 5, 203, 87, 11, 10, 98, 192, 125, 126, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 51, 52, 0, 0, 62, 67, 69, 71, 194, 73, 75, 77, 0, 54, 81, 83, 85, 87, 88, 89, 90, 0, 0, 0, 74, 74, 80, 80, 38, 38, 56, 56, 59, 59, 74, 5, 5, 40, 40, 74, 6, 80, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 5, 5, 25, 0, 41, 41, 26, 27, 28, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 29, 0, 0, 54, 54, 26, 27, 28, 35, 57, 57, 99, 100, 5, 5, 58, 0, 0, 0, 0, 50, 0, 0, 0, 49, 65, 0, 0, 0, 0, 50, 70, 0, 0, 0, 0, 0, 0, 0, 59, 60, 36, 37, 38, 39, 40, 41, 0, 36, 37, 38, 39, 61, 36, 37, 38, 39, 40, 36, 37, 38, 0, 66, 36, 37, 38, 103, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, 157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 176, 177, }; short yycheck[] = { 41, 0, 41, 61, 41, 123, 41, 67, 41, 26, 256, 41, 29, 41, 27, 28, 41, 159, 160, 256, 123, 7, 30, 160, 294, 167, 12, 256, 256, 294, 167, 292, 293, 47, 294, 298, 256, 33, 45, 298, 298, 298, 58, 298, 40, 298, 41, 293, 8, 62, 298, 280, 281, 13, 14, 15, 293, 298, 18, 19, 20, 298, 122, 292, 293, 293, 294, 27, 28, 298, 33, 256, 292, 293, 294, 41, 47, 40, 298, 41, 298, 298, 123, 256, 123, 41, 123, 41, 123, 41, 123, 99, 100, 123, 298, 123, 293, 256, 123, 293, 59, 46, 62, 47, 47, 118, 293, 280, 281, 293, 295, 296, 297, 73, 293, 75, 47, 77, 294, 292, 293, 81, 58, 83, 123, 85, 58, 284, 123, 293, 60, 61, 62, 292, 293, 294, 125, 60, 61, 62, 59, 293, 60, 61, 62, 47, 45, 60, 61, 62, 293, 58, 60, 61, 62, 293, 46, 123, 118, 293, 293, 123, 58, 58, 293, 283, 284, 123, 128, 52, 130, 293, 132, 56, 57, 135, 293, 137, 46, 139, 283, 284, 293, 45, 125, 125, 32, 181, 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, -1, -1, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 5, -1, -1, 8, 9, 10, 11, 186, 13, 14, 15, -1, 289, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, 283, 284, 283, 284, 283, 284, 283, 284, 283, 284, 293, 283, 284, 283, 284, 298, 283, 298, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 283, 284, 282, -1, 283, 284, 286, 287, 288, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 283, 284, -1, -1, 283, 284, 286, 287, 288, 256, 283, 284, 283, 284, 283, 284, 256, -1, -1, -1, -1, 256, -1, -1, -1, 3, 256, -1, -1, -1, -1, 256, 10, -1, -1, -1, -1, -1, -1, -1, 280, 281, 289, 290, 291, 292, 293, 294, -1, 289, 290, 291, 292, 293, 289, 290, 291, 292, 293, 289, 290, 291, -1, 293, 289, 290, 291, 45, -1, -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 69, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, -1, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, 142, 143, }; #define YYFINAL 31 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 298 #if YYDEBUG char *yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "'!'",0,0,0,0,0,0,"'('","')'",0,0,0,"'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,"':'", "';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,"DSTPORT","SRCPORT","DSTADDR","SRCADDR","SRCNET","DSTNET", "DATE","TIME","PORT","HOST","NET","PROTO","PKTS","OCTETS","FLAG","FLAGS", "DSTIFACE","SRCIFACE","IFACE","NEXTHOP","SRCHP","DSTHP","HP","TODAY","YEST", "INCLUDE","OR","AND","MASKOPER","NOT","SINCE","BEFORE","NEQ","LEQ","GEQ", "INTEGER","BYTEVAL","STRING","PRINT","NEXT","PRINTALL","RANGE", }; char *yyrule[] = { "$accept : file", "file : stmt file", "file : stmt", "stmt : cond '{' actionset '}'", "stmt : INCLUDE STRING ';'", "cond :", "cond : cond OR cond", "cond : cond AND cond", "cond : term", "actionset : action ';' actionset", "actionset : action ';'", "actionset : action", "action : PRINT", "action : NEXT", "action : PRINTALL", "action : error", "term : PORT oper tcpport", "term : PORT tcpport RANGE tcpport", "term : SRCPORT oper tcpport", "term : SRCPORT tcpport RANGE tcpport", "term : DSTPORT oper tcpport", "term : DSTPORT tcpport RANGE tcpport", "term : HOST oper hostspec", "term : HP oper hostspec tcpport", "term : NEXTHOP oper hostspec", "term : SRCADDR oper hostspec", "term : SRCHP oper hostspec tcpport", "term : DSTADDR oper hostspec", "term : DSTHP oper hostspec tcpport", "term : NET netop hostspec", "term : NET netop hostspec '/' netmask", "term : PROTO oper integer", "term : PROTO integer RANGE integer", "term : PKTS oper integer", "term : PKTS integer RANGE integer", "term : OCTETS oper integer", "term : OCTETS integer RANGE integer", "term : FLAG STRING", "term : FLAGS STRING", "term : FLAGS STRING '/' STRING", "term : SRCNET netop hostspec", "term : DSTNET netop hostspec", "term : SRCNET netop hostspec '/' netmask", "term : DSTNET netop hostspec '/' netmask", "term : IFACE oper integer", "term : IFACE integer RANGE integer", "term : SRCIFACE oper integer", "term : SRCIFACE integer RANGE integer", "term : DSTIFACE oper integer", "term : DSTIFACE integer RANGE integer", "term : DATE oper datespec", "term : DATE datespec RANGE datespec", "term : TIME oper timespec", "term : TIME timespec RANGE timespec", "term : SINCE datespec BYTEVAL ':' BYTEVAL", "term : SINCE datespec BYTEVAL ':' BYTEVAL ':' BYTEVAL", "term : SINCE datespec", "term : BEFORE datespec BYTEVAL ':' BYTEVAL", "term : BEFORE datespec BYTEVAL ':' BYTEVAL ':' BYTEVAL", "term : BEFORE datespec", "term : '(' cond ')'", "term : '!' term", "term : NOT term", "term : error", "oper : '='", "oper : '>'", "oper : '<'", "oper : NEQ", "oper : LEQ", "oper : GEQ", "oper : error", "netop : '='", "netop : NEQ", "netop : error", "datespec : BYTEVAL '/' BYTEVAL", "datespec : BYTEVAL '/' BYTEVAL '/' integer", "datespec : integer '-' BYTEVAL '-' BYTEVAL", "datespec : TODAY", "datespec : YEST", "datespec : error", "timespec : BYTEVAL ':' BYTEVAL", "timespec : BYTEVAL ':' BYTEVAL ':' BYTEVAL", "timespec : error", "tcpport : integer", "tcpport : STRING", "tcpport : error", "integer : INTEGER", "integer : BYTEVAL", "hostspec : ip_address", "hostspec : STRING", "hostspec : error", "netmask : ip_address", "ip_address : BYTEVAL '.' BYTEVAL '.' BYTEVAL '.' BYTEVAL", }; #endif #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 int yydebug; int yynerrs; int yyerrflag; int yychar; short *yyssp; YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; short *yyss; short *yysslim; YYSTYPE *yyvs; int yystacksize; #line 1118 "grammar.y" struct keywords keywords[] = { { "dstport", DSTPORT }, { "srcport", SRCPORT }, { "srchost", SRCADDR }, { "dsthost", DSTADDR }, { "srchp", SRCHP }, { "dsthp", DSTHP }, { "hp", HP }, { "srcnet", SRCNET }, { "dstnet", DSTNET }, { "port", PORT }, { "host", HOST }, { "net", NET }, { "nexthop", NEXTHOP }, { "proto", PROTO }, { "pkts", PKTS }, { "octets", OCTETS }, { "flag", FLAG }, { "flags", FLAGS }, { "dstiface", DSTIFACE }, { "srciface", SRCIFACE }, { "iface", IFACE }, { "time", TIME }, { "date", DATE }, { "since", SINCE }, { "before", BEFORE }, { "today", TODAY }, { "yesterday", YEST }, { "include", INCLUDE }, { "or", OR }, { "and", AND }, { "not", NOT }, { "print", PRINT }, { "next", NEXT }, { "printall", PRINTALL }, { (char *)0, 0 } }; void yyerror() { fprintf(stderr, "\"%s\", line %d: syntax error.\n", getfilename(), getlinenum()); parse_error = 1; } unsigned long getmask(unsigned long addr) { if(IN_CLASSA(addr)) return IN_CLASSA_NET; else if(IN_CLASSB(addr)) return IN_CLASSB_NET; else if(IN_CLASSC(addr)) return IN_CLASSC_NET; else return 0xffffffff; } #line 532 "y.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ int yyparse __P((void)); static int yygrowstack __P((void)); static int yygrowstack() { int newsize, i; short *newss; YYSTYPE *newvs; if ((newsize = yystacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return -1; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = yyssp - yyss; if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL) return -1; yyss = newss; yyssp = newss + i; if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL) return -1; yyvs = newvs; yyvsp = newvs + i; yystacksize = newsize; yysslim = yyss + newsize - 1; return 0; } #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int yyparse() { int yym, yyn, yystate; #if YYDEBUG char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); if (yyss == NULL && yygrowstack()) goto yyoverflow; yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; goto yynewerror; yynewerror: yyerror("syntax error"); goto yyerrlab; yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yyssp); #endif if (yyssp <= yyss) goto yyabort; --yyssp; --yyvsp; } } } else { if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { case 3: #line 94 "grammar.y" { queuestmt(); } break; case 4: #line 97 "grammar.y" { if(includefile(yyvsp[-1].strval) != 0){ fprintf(stderr, "\"%s\", line %d: include file error.\n", getfilename(), getlinenum()); parse_error = 1; } } break; case 6: #line 108 "grammar.y" { pushoper(yyvsp[-1].intval); } break; case 7: #line 111 "grammar.y" { pushoper(yyvsp[-1].intval); } break; case 12: #line 124 "grammar.y" { queueact(yyvsp[0].intval); } break; case 13: #line 127 "grammar.y" { queueact(yyvsp[0].intval); } break; case 14: #line 130 "grammar.y" { queueact(yyvsp[0].intval); } break; case 16: #line 137 "grammar.y" { pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); } break; case 17: #line 149 "grammar.y" { pushkey(SRCPORT); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); pushkey(DSTPORT); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); pushoper(OR); } break; case 18: #line 166 "grammar.y" { pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 19: #line 171 "grammar.y" { pushkey(SRCPORT); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 20: #line 180 "grammar.y" { pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 21: #line 185 "grammar.y" { pushkey(DSTPORT); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 22: #line 194 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { pushkey(SRCADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-1].intval); pushkey(DSTADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-1].intval); if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); if(i) if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 23: #line 228 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[-1].intpval; if(addrp){ i = 0; do { pushkey(SRCADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-2].intval); if(i) pushoper(OR); } while(addrp[++i]); } else switch(yyvsp[-2].intval){ case '=': pushval(0); break; default: pushval(1); break; } pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-2].intval); if (yyvsp[-2].intval == NEQ) pushoper(OR); else pushoper(AND); if(addrp){ i = 0; do { pushkey(DSTADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-2].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-2].intval){ case '=': pushval(0); break; default: pushval(1); break; } pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-2].intval); if (yyvsp[-2].intval == NEQ) pushoper(OR); else pushoper(AND); if (yyvsp[-2].intval == NEQ) pushoper(AND); else pushoper(OR); } break; case 24: #line 291 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { pushkey(NEXTHOP); pushval(ntohl(addrp[i])); pushoper(yyvsp[-1].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 25: #line 315 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { pushkey(SRCADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-1].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 26: #line 340 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[-1].intpval; if(addrp){ i = 0; do { pushkey(SRCADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-2].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-2].intval){ case '=': pushval(0); break; default: pushval(1); break; } pushkey(SRCPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-2].intval); if (yyvsp[-2].intval == NEQ) pushoper(OR); else pushoper(AND); } break; case 27: #line 372 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { pushkey(DSTADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-1].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 28: #line 397 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[-1].intpval; if(addrp){ i = 0; do { pushkey(DSTADDR); pushval(ntohl(addrp[i])); pushoper(yyvsp[-2].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-2].intval){ case '=': pushval(0); break; default: pushval(1); break; } pushkey(DSTPORT); pushval(yyvsp[0].intval); pushoper(yyvsp[-2].intval); if (yyvsp[-2].intval == NEQ) pushoper(OR); else pushoper(AND); } break; case 29: #line 429 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { unsigned long mask = getmask(ntohl(addrp[i])); pushval(addrp[i]); pushval(mask); pushoper(MASKOPER); /* net & mask */ pushkey(SRCNET); pushval(mask); pushoper(MASKOPER); /* SRCADDR & mask */ pushoper(yyvsp[-1].intval); pushval(ntohl(addrp[i])); pushval(mask); pushoper(MASKOPER); /* net & mask */ pushkey(DSTNET); pushval(mask); /* dstaddr & mask */ pushoper(MASKOPER); pushoper(yyvsp[-1].intval); if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); if(i) if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 30: #line 473 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[-2].intpval; if(addrp){ i = 0; do { pushval(ntohl(addrp[i])); pushval(yyvsp[0].intval); pushoper(MASKOPER); /* net & mask */ pushkey(SRCNET); pushval(yyvsp[0].intval); pushoper(MASKOPER); /* srcaddr & mask */ pushoper(yyvsp[-3].intval); pushval(ntohl(addrp[i])); pushval(yyvsp[0].intval); pushoper(MASKOPER); /* net & mask */ pushkey(DSTNET); pushval(yyvsp[0].intval); pushoper(MASKOPER); /* dstaddr & mask */ pushoper(yyvsp[-3].intval); pushoper(OR); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-3].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 31: #line 511 "grammar.y" { pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 32: #line 516 "grammar.y" { pushkey(yyvsp[-3].intval); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(yyvsp[-3].intval); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 33: #line 525 "grammar.y" { pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 34: #line 530 "grammar.y" { pushkey(yyvsp[-3].intval); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(yyvsp[-3].intval); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 35: #line 539 "grammar.y" { pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 36: #line 544 "grammar.y" { pushkey(yyvsp[-3].intval); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(yyvsp[-3].intval); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 37: #line 553 "grammar.y" { if (strcasecmp(yyvsp[0].strval, "FIN") == 0) { pushval(0x01); pushkey(FLAG); pushoper(MASKOPER); } else if (strcasecmp(yyvsp[0].strval, "SYN") == 0) { pushval(0x02); pushkey(FLAG); pushoper(MASKOPER); } else if (strcasecmp(yyvsp[0].strval, "RST") == 0) { pushval(0x04); pushkey(FLAG); pushoper(MASKOPER); } else if (strcasecmp(yyvsp[0].strval, "PUSH") == 0) { pushval(0x08); pushkey(FLAG); pushoper(MASKOPER); } else if (strcasecmp(yyvsp[0].strval, "ACK") == 0) { pushval(0x10); pushkey(FLAG); pushoper(MASKOPER); } else if (strcasecmp(yyvsp[0].strval, "URG") == 0) { pushval(0x20); pushkey(FLAG); pushoper(MASKOPER); } else { fprintf(stderr, "\"%s\", line %d: unknown tcp flag.\n", getfilename(), getlinenum()); parse_error = 1; } } break; case 38: #line 584 "grammar.y" { int flags; int mask; char *two; int i; i = 0; flags = 0; mask = 0x3f; two = yyvsp[0].strval; while (two[i] != '\0') { if (two[i] == 'F' || two[i] == 'f') { flags += 0x01; } else if (two[i] == 'S' || two[i] == 's') { flags += 0x02; } else if (two[i] == 'R' || two[i] == 'r') { flags += 0x04; } else if (two[i] == 'P' || two[i] == 'p') { flags += 0x08; } else if (two[i] == 'A' || two[i] == 'a') { flags += 0x10; } else if (two[i] == 'U' || two[i] == 'u') { flags += 0x20; } else { fprintf(stderr, "\"%s\", line %d: unknown tcp flag.\n", getfilename(), getlinenum()); parse_error = 1; } i++; } pushval(mask); pushkey(FLAG); pushoper(MASKOPER); pushval(flags); pushoper('='); } break; case 39: #line 616 "grammar.y" { int flags; int mask; int i; char *two; char *four; i = flags = mask = 0; two = yyvsp[-2].strval; four = yyvsp[0].strval; while (two[i] != '\0') { if (two[i] == 'F' || two[i] == 'f') { flags += 0x01; } else if (two[i] == 'S' || two[i] == 's') { flags += 0x02; } else if (two[i] == 'R' || two[i] == 'r') { flags += 0x04; } else if (two[i] == 'P' || two[i] == 'p') { flags += 0x08; } else if (two[i] == 'A' || two[i] == 'a') { flags += 0x10; } else if (two[i] == 'U' || two[i] == 'u') { flags += 0x20; } else { fprintf(stderr, "\"%s\", line %d: unknown tcp flag.\n", getfilename(), getlinenum()); parse_error = 1; } i++; } i = 0; while (four[i] != '\0') { if (four[i] == 'F' || four[i] == 'f') { mask += 0x01; } else if (four[i] == 'S' || four[i] == 's') { mask += 0x02; } else if (four[i] == 'R' || four[i] == 'r') { mask += 0x04; } else if (four[i] == 'P' || four[i] == 'p') { mask += 0x08; } else if (four[i] == 'A' || four[i] == 'a') { mask += 0x10; } else if (four[i] == 'U' || four[i] == 'u') { mask += 0x20; } else { fprintf(stderr, "\"%s\", line %d: unknown tcp flag in mask.\n", getfilename(), getlinenum()); parse_error = 1; } i++; } if (!(flags & mask)) { fprintf(stderr, "\"%s\", line %d: tcp flag not in mask.\n", getfilename(), getlinenum()); parse_error = 1; } pushval(mask); pushkey(FLAG); pushoper(MASKOPER); pushval(flags); pushoper('='); } break; case 40: #line 671 "grammar.y" { unsigned long *addrp; int i; addrp=yyvsp[0].intpval; if(addrp){ i = 0; do { unsigned long mask = getmask(ntohl(addrp[i])); pushval(ntohl(addrp[i])); pushval(mask); pushoper(MASKOPER); pushkey(SRCNET); pushval(mask); pushoper(MASKOPER); pushoper(yyvsp[-1].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 41: #line 701 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[0].intpval; if(addrp){ i = 0; do { unsigned long mask = getmask(ntohl(addrp[i])); pushval(ntohl(addrp[i])); pushval(mask); pushoper(MASKOPER); pushkey(DSTNET); pushval(mask); pushoper(MASKOPER); pushoper(yyvsp[-1].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-1].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 42: #line 731 "grammar.y" { unsigned long *addrp; int i; addrp = yyvsp[-2].intpval; if(addrp){ i = 0; do { pushval(ntohl(addrp[i])); pushval(yyvsp[0].intval); pushoper(MASKOPER); pushkey(SRCNET); pushval(yyvsp[0].intval); pushoper(MASKOPER); pushoper(yyvsp[-3].intval); if(i) pushoper(OR); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-3].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 43: #line 760 "grammar.y" { unsigned long *addrp; int i; addrp=yyvsp[-2].intpval; if(addrp){ i = 0; do { pushval(ntohl(addrp[i])); pushval(yyvsp[0].intval); pushoper(MASKOPER); pushkey(DSTNET); pushval(yyvsp[0].intval); pushoper(MASKOPER); pushoper(yyvsp[-3].intval); if(i) pushoper(i); } while(addrp[++i]); free(addrp); } else switch(yyvsp[-3].intval){ case '=': pushval(0); break; default: pushval(1); break; } } break; case 44: #line 789 "grammar.y" { pushkey(SRCIFACE); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); pushkey(DSTIFACE); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); if (yyvsp[-1].intval == NEQ) pushoper(AND); else pushoper(OR); } break; case 45: #line 801 "grammar.y" { pushkey(SRCIFACE); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(SRCIFACE); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); pushkey(DSTIFACE); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(DSTIFACE); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); pushoper(OR); } break; case 46: #line 818 "grammar.y" { pushkey(SRCIFACE); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 47: #line 823 "grammar.y" { pushkey(SRCIFACE); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(SRCIFACE); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 48: #line 832 "grammar.y" { pushkey(DSTIFACE); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 49: #line 837 "grammar.y" { pushkey(DSTIFACE); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(DSTIFACE); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 50: #line 846 "grammar.y" { switch(yyvsp[-1].intval){ case '>': case LEQ: case '<': case GEQ: pushkey(yyvsp[-2].intval); pushval(timeofday(yyvsp[0].intval, 23, 59, 59)); pushoper(yyvsp[-1].intval); break; case '=': pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(GEQ); pushkey(yyvsp[-2].intval); pushval(timeofday(yyvsp[0].intval, 23, 59, 59)); pushoper(LEQ); pushoper(AND); break; case NEQ: pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper('<'); pushkey(yyvsp[-2].intval); pushval(timeofday(yyvsp[0].intval, 23, 59, 59)); pushoper('>'); pushoper(OR); break; default: pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); break; } } break; case 51: #line 881 "grammar.y" { pushkey(yyvsp[-3].intval); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(yyvsp[-3].intval); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 52: #line 890 "grammar.y" { pushkey(yyvsp[-2].intval); pushval(yyvsp[0].intval); pushoper(yyvsp[-1].intval); } break; case 53: #line 895 "grammar.y" { pushkey(yyvsp[-3].intval); pushval(yyvsp[-2].intval); pushoper('>'); pushkey(yyvsp[-3].intval); pushval(yyvsp[0].intval); pushoper('<'); pushoper(AND); } break; case 54: #line 904 "grammar.y" { pushkey(DATE); pushval(timeofday(yyvsp[-3].intval, yyvsp[-2].intval, yyvsp[0].intval, 0)); pushoper(GEQ); } break; case 55: #line 909 "grammar.y" { pushkey(DATE); pushval(timeofday(yyvsp[-5].intval, yyvsp[-4].intval, yyvsp[-2].intval, yyvsp[0].intval)); pushoper(GEQ); } break; case 56: #line 914 "grammar.y" { pushkey(DATE); pushval(yyvsp[0].intval); pushoper(GEQ); } break; case 57: #line 919 "grammar.y" { pushkey(DATE); pushval(timeofday(yyvsp[-3].intval, yyvsp[-2].intval, yyvsp[0].intval, 0)); pushoper('<'); } break; case 58: #line 924 "grammar.y" { pushkey(DATE); pushval(timeofday(yyvsp[-5].intval, yyvsp[-4].intval, yyvsp[-2].intval, yyvsp[0].intval)); pushoper('<'); } break; case 59: #line 929 "grammar.y" { pushkey(DATE); pushval(yyvsp[0].intval); pushoper('<'); } break; case 61: #line 935 "grammar.y" { pushuoper(yyvsp[-1].intval); } break; case 62: #line 936 "grammar.y" { pushuoper('!'); } break; case 63: #line 937 "grammar.y" { pushval(0); } break; case 64: #line 941 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 65: #line 942 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 66: #line 943 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 67: #line 944 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 68: #line 945 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 69: #line 946 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 70: #line 947 "grammar.y" { pushoper(0); } break; case 71: #line 951 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 72: #line 952 "grammar.y" {yyval.intval = yyvsp[0].intval;} break; case 73: #line 953 "grammar.y" { pushoper(0); } break; case 74: #line 957 "grammar.y" { int year = getyear(); year += 1900; if(yyvsp[-2].intval < 1 || yyvsp[-2].intval > 12 || !validmday(yyvsp[-2].intval, yyvsp[0].intval, year)){ fprintf(stderr, "\"%s\", line %d: malformed date.\n", getfilename(), getlinenum()); parse_error = 1; } else yyval.intval = makedate(yyvsp[-2].intval, yyvsp[0].intval, year); } break; case 75: #line 969 "grammar.y" { int year = yyvsp[0].intval; if(year < 38) year += 2000; if(year < 100) year += 1900; if(!checkyear(year)) { fprintf(stderr, "\"%s\", line %d: year out of range %d.\n", getfilename(), getlinenum(), year); parse_error = 1; } else if(yyvsp[-4].intval < 1 || yyvsp[-4].intval > 12 || !validmday(yyvsp[-4].intval, yyvsp[-2].intval, year)){ fprintf(stderr, "\"%s\", line %d: malformed date.\n", getfilename(), getlinenum()); parse_error = 1; } else yyval.intval = makedate(yyvsp[-4].intval, yyvsp[-2].intval, year); } break; case 76: #line 988 "grammar.y" { int year = yyvsp[-4].intval; if(year < 38) year += 2000; if(year < 100) year += 1900; if(!checkyear(year)) { fprintf(stderr, "\"%s\", line %d: year out of range %d.\n", getfilename(), getlinenum(), year); parse_error = 1; } else if(yyvsp[-2].intval < 1 || yyvsp[-2].intval > 12 || !validmday(yyvsp[-2].intval, yyvsp[0].intval, year)){ fprintf(stderr, "\"%s\", line %d: malformed date.\n", getfilename(), getlinenum()); parse_error = 1; } else yyval.intval = makedate(yyvsp[-2].intval, yyvsp[0].intval, year); } break; case 77: #line 1008 "grammar.y" { yyval.intval = today(); } break; case 78: #line 1011 "grammar.y" { yyval.intval = yesterday(); } break; case 79: #line 1014 "grammar.y" { yyval.intval = 0; } break; case 80: #line 1018 "grammar.y" { yyval.intval = yyvsp[-2].intval*3600 + yyvsp[0].intval*60; } break; case 81: #line 1021 "grammar.y" { yyval.intval = yyvsp[-4].intval*3600 + yyvsp[-2].intval*60 + yyvsp[0].intval; } break; case 82: #line 1024 "grammar.y" { yyval.intval = 0; } break; case 83: #line 1029 "grammar.y" { yyval.intval = yyvsp[0].intval; } break; case 84: #line 1030 "grammar.y" { if(protoflag != ICMPDATA){ struct servent *se; if((se = getservbyname(yyvsp[0].strval, protoflag == TCPDATA ? "tcp" : "udp"))){ yyval.intval = ntohs(se->s_port); } else { fprintf(stderr, "\"%s\", line %d: unknown service: %s\n", getfilename(), getlinenum(),yyvsp[0].strval); parse_error = 1; yyval.intval = 0; } } else { int i; for(i=0;icmptbl[i].name;i++) if(strcasecmp(icmptbl[i].name, yyvsp[0].strval) == 0) break; if(icmptbl[i].name) yyval.intval = icmptbl[i].type; else { fprintf(stderr, "\"%s\", line %d: unknown ICMP type: %s\n", getfilename(), getlinenum(), yyvsp[0].strval); parse_error = 1; yyval.intval = 0xffff; } } free(yyvsp[0].strval); } break; case 85: #line 1060 "grammar.y" {yyval.intval = 0;} break; case 86: #line 1064 "grammar.y" { yyval.intval = yyvsp[0].intval; } break; case 87: #line 1067 "grammar.y" { yyval.intval = yyvsp[0].intval; } break; case 88: #line 1073 "grammar.y" { unsigned long *addrp; addrp = (unsigned long *)malloc(sizeof(unsigned long) * 2); addrp[0] = ntohl(yyvsp[0].intval); addrp[1] = 0; yyval.intpval = addrp; } break; case 89: #line 1080 "grammar.y" { struct hostent *he; struct { int ipaddr:32; } host; if((he = gethostbyname(yyvsp[0].strval))){ int num; unsigned long *addrp; for(num=0;he->h_addr_list[num];num++) ; addrp = (unsigned long *)malloc((num+1)*sizeof(unsigned long)); addrp[num] = 0; for(num--;num>=0;num--) memcpy(&addrp[num], he->h_addr_list[num], 4); yyval.intpval = addrp; } else { fprintf(stderr, "\"%s\", line %d: unknown host: %s\n", getfilename(), getlinenum(), yyvsp[0].strval); yyval.intpval = 0; } free(yyvsp[0].strval); } break; case 90: #line 1103 "grammar.y" { yyval.intpval = 0; } break; case 91: #line 1107 "grammar.y" { yyval.intval=yyvsp[0].intval;} break; case 92: #line 1112 "grammar.y" { yyval.intval = ((yyvsp[-6].intval << 24 | yyvsp[-4].intval << 16 | yyvsp[-2].intval << 8 | yyvsp[0].intval)); } break; #line 1919 "y.tab.c" } yyssp -= yym; yystate = *yyssp; yyvsp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yyssp = YYFINAL; *++yyvsp = yyval; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate; *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); }