/* original parser id follows */
/* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */

#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9

#define YYEMPTY        (-1)
#define yyclearin      (yychar = YYEMPTY)
#define yyerrok        (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#define YYENOMEM       (-2)
#define YYEOF          0
#undef YYBTYACC
#define YYBTYACC 0
#define YYDEBUGSTR YYPREFIX "debug"
#define YYPREFIX "yy"

#define YYPURE 0

#line 42 "grammar.y"

#include "config.h"

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

#include "nf_common.h"
#include "rbtree.h"
#include "nfdump.h"
#include "nffile.h"
#include "nftree.h"
#include "ipconv.h"
#include "util.h"

/*
 * function prototypes
 */
static void  yyerror(char *msg);

static uint32_t ChainHosts(uint64_t *offsets, uint64_t *hostlist, int num_records, int type);

static uint64_t VerifyMac(char *s);

enum { DIR_UNSPEC = 1, 
	   SOURCE, DESTINATION, SOURCE_AND_DESTINATION, SOURCE_OR_DESTINATION, 
	   DIR_IN, DIR_OUT, 
	   IN_SRC, IN_DST, OUT_SRC, OUT_DST, 
	   ADJ_PREV, ADJ_NEXT };

/* var defs */
extern int 			lineno;
extern char 		*yytext;
extern uint64_t		*IPstack;
extern uint32_t	StartNode;
extern uint16_t	Extended;
extern int (*FilterEngine)(uint32_t *);
extern char	*FilterFilename;

static uint32_t num_ip;

char yyerror_buff[256];

#define MPLSMAX 0x00ffffff
#ifdef YYSTYPE
#undef  YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#line 97 "grammar.y"
typedef union {
	uint64_t		value;
	char			*s;
	FilterParam_t	param;
	void			*list;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
#line 91 "grammar.c"

/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif

/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif

#if !(defined(yylex) || defined(YYSTATE))
int YYLEX_DECL();
#endif

/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif

extern int YYPARSE_DECL();

#define ANY 257
#define IP 258
#define IF 259
#define MAC 260
#define MPLS 261
#define TOS 262
#define DIR 263
#define FLAGS 264
#define PROTO 265
#define MASK 266
#define HOSTNAME 267
#define NET 268
#define PORT 269
#define FWDSTAT 270
#define IN 271
#define OUT 272
#define SRC 273
#define DST 274
#define EQ 275
#define LT 276
#define GT 277
#define PREV 278
#define NEXT 279
#define NUMBER 280
#define STRING 281
#define IDENT 282
#define PORTNUM 283
#define ICMP_TYPE 284
#define ICMP_CODE 285
#define ENGINE_TYPE 286
#define ENGINE_ID 287
#define AS 288
#define PACKETS 289
#define BYTES 290
#define FLOWS 291
#define PPS 292
#define BPS 293
#define BPP 294
#define DURATION 295
#define NOT 296
#define IPV4 297
#define IPV6 298
#define BGPNEXTHOP 299
#define ROUTER 300
#define VLAN 301
#define CLIENT 302
#define SERVER 303
#define APP 304
#define LATENCY 305
#define SYSID 306
#define ASA 307
#define REASON 308
#define DENIED 309
#define XEVENT 310
#define XIP 311
#define XNET 312
#define XPORT 313
#define INGRESS 314
#define EGRESS 315
#define ACL 316
#define ACE 317
#define XACE 318
#define NAT 319
#define ADD 320
#define EVENT 321
#define VRF 322
#define NPORT 323
#define NIP 324
#define PBLOCK 325
#define START 326
#define END 327
#define STEP 328
#define SIZE 329
#define OR 330
#define AND 331
#define NEGATE 332
#define YYERRCODE 256
typedef int YYINT;
static const YYINT yylhs[] = {                           -1,
    0,    0,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    3,    3,    3,    3,    3,    3,    3,    7,    7,    7,
    7,    7,    8,    8,    8,    4,    4,    4,    4,    2,
    2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
    2,    2,    2,    2,    6,    6,    5,    5,    5,    1,
    1,    1,    1,    1,
};
static const YYINT yylen[] = {                            2,
    0,    1,    1,    2,    1,    1,    2,    2,    4,    4,
    3,    3,    3,    3,    3,    4,    3,    2,    3,    6,
    3,    6,    3,    3,    4,    4,    4,    2,    4,    6,
    2,    2,    3,    3,    3,    4,    4,    4,    4,    3,
    5,    4,    4,    3,    4,    4,    4,    4,    4,    4,
    4,    4,    3,    4,    6,    3,    4,    5,    3,    3,
    3,    4,    3,    2,    2,    2,    2,    1,    3,    2,
    3,    4,    1,    2,    3,    0,    1,    1,    1,    0,
    1,    1,    3,    3,    3,    3,    1,    1,    2,    2,
    2,    2,    1,    1,    1,    1,    1,    1,    1,    1,
    3,    3,    2,    3,
};
static const YYINT yydefred[] = {                         0,
    3,    0,    0,    0,    0,    0,    0,    0,    0,    0,
   93,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    5,    6,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  100,    0,    0,    0,   66,   95,   96,   67,   77,   78,
   79,   18,    0,    7,    8,   64,   65,   89,   90,   91,
   92,    0,    0,    0,    0,    0,    4,   31,   32,    0,
    0,    0,    0,    0,    0,    0,  103,    0,    0,    0,
    0,    0,   28,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,   97,   98,   99,    0,   63,    0,   17,   83,   85,
   84,   86,    0,   21,   33,   34,   11,   12,   13,   14,
   15,   23,   24,    0,    0,    0,    0,   35,    0,    0,
    0,    0,   44,    0,    0,    0,    0,    0,  104,    0,
  102,    0,   19,   59,   61,    0,   56,    0,    0,    0,
    0,    0,    0,    0,   60,   40,    0,    0,    0,   53,
    0,   62,    0,   25,   26,   27,   39,   38,   37,   36,
   46,   47,   45,   48,   49,   50,   51,    0,   16,   57,
    0,    0,   29,    0,   54,    9,   10,    0,   42,   52,
   43,    0,    0,    0,   58,   73,    0,    0,   41,    0,
    0,   22,    0,   20,   74,   30,    0,   55,   69,    0,
   71,   75,   72,
};
#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
static const YYINT yystos[] = {                           0,
  257,  261,  263,  264,  265,  270,  271,  272,  273,  274,
  278,  279,  282,  284,  285,  286,  287,  291,  292,  293,
  294,  295,  296,  297,  298,  299,  300,  302,  303,  304,
  306,  307,  314,  315,  319,  325,   40,  334,  335,  336,
  337,  340,  257,  281,  280,  314,  315,  340,  275,  276,
  277,  281,  338,  280,  281,  280,  281,  273,  274,  273,
  274,  330,  331,  330,  331,  258,  281,  280,  280,  338,
  338,  338,  338,  338,  338,  338,  335,  258,  258,  305,
  305,  305,  280,  310,  321,  322,  322,  321,  326,  327,
  328,  329,  335,  330,  331,  258,  259,  260,  262,  266,
  268,  269,  288,  289,  290,  301,  311,  312,  313,  323,
  324,  316,  317,  318,  339,  280,  338,  280,  274,  274,
  273,  273,  271,  281,  280,  280,  280,  280,  280,  280,
  280,  281,  281,  338,  338,  338,  338,  308,  309,  338,
  338,  338,  308,  338,  338,  338,  338,  338,   41,  335,
  335,  271,  281,  280,  281,  338,  280,  281,  271,  338,
  271,  338,  338,  338,  280,  281,  281,  338,  338,  281,
  338,  280,   91,  280,  280,  280,  280,  281,  340,  280,
  280,  280,  280,  280,  280,  280,  280,   91,  280,  281,
   47,   91,  280,   91,  280,  280,  280,   47,  280,  280,
  280,  281,  341,  341,  280,  280,  342,  342,  280,   47,
  281,   93,   44,   93,  280,   93,   44,   93,  280,   47,
  281,  280,  280,
};
#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
static const YYINT yydgoto[] = {                         38,
   39,   40,   41,   53,  115,   42,  203,  207,
};
static const YYINT yysindex[] = {                        71,
    0, -237, -255, -230, -240, -212, -200, -185, -238, -235,
    0, -232, -231, -227, -224, -174, -174, -174, -174, -174,
 -174, -174,   71,    0,    0, -215, -195, -190, -179, -165,
 -202, -289, -198, -177, -180, -220,   71,    0, -192, -146,
    0, -187, -130, -174,    0,    0,    0,    0,    0,    0,
    0,    0, -129,    0,    0,    0,    0,    0,    0,    0,
    0, -122, -121, -119, -117, -244,    0,    0,    0, -123,
 -118, -116, -112, -111, -107, -106,    0, -120, -105, -174,
 -174, -174,    0, -174, -247, -174, -174, -241, -174, -174,
 -174, -174,  -37,   71,   71, -233, -101, -100, -174,  -96,
  -95, -253, -205, -174, -174,  -93,  -92,  -91, -174, -174,
  -90,    0,    0,    0, -174,    0,  -88,    0,    0,    0,
    0,    0,   67,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,  -84,  -82,  -81,  -80,    0, -250,  -78,
  -75,  -74,    0,  -73,  -72,  -71,  -70,  -69,    0, -172,
    0,   72,    0,    0,    0,  -68,    0,  -40,   84,  -67,
   89,  -66,  -64,  -63,    0,    0,  138,  -62,  -61,    0,
  -60,    0,  -59,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,  -59,    0,    0,
  -54,  -53,    0,  -53,    0,    0,    0,  -52,    0,    0,
    0,  141,  -44,  -41,    0,    0,  -36,  -35,    0,  -51,
  168,    0,  -50,    0,    0,    0,  -48,    0,    0,  -47,
    0,    0,    0,
};
static const YYINT yyrindex[] = {                         2,
    0,    0,    0,  -46,    0,    0, -141,  -65,  129,  143,
    0,  216,    0,    0,    0,  -46,  -46,  -46,  -46,  -46,
  -46,  -46,  202,    0,    0,    0,    0,    0,    0,    0,
    0,    0, -184, -181,    0,    0,  202,    0,  221,    0,
    0,    0,    0,  -46,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  -46,
  -46,  -46,    0,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
  -46,  -46,    0,  202,  202,    0,    0,    0,  -46,    0,
    0,  -46,  -46,  -46,  -46,    0,    0,    0,  -46,  -46,
    0,    0,    0,    0,  -46,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    1,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  -39,    0,    0,    0,    0,    0,    0,    0,    0,
  -38,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,
};
#if YYBTYACC
static const YYINT yycindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,
};
#endif
static const YYINT yygindex[] = {                         0,
   -4,    0,    0,   -5,    0,    7,   42,   41,
};
#define YYTABLESIZE 540
static const YYINT yytable[] = {                        213,
  101,    1,  213,  149,   68,   70,  191,  217,  217,   48,
   70,   71,   72,   73,   74,   75,   76,  159,   77,   43,
   84,   49,   50,   51,   45,   66,  123,   49,   50,   51,
  178,   85,   93,   49,   50,   51,  124,  152,  117,   54,
   55,  101,   78,   44,   49,   50,   51,  153,  212,   67,
   52,  214,   68,   68,   70,   69,  216,  218,   46,   47,
  138,  139,   79,   46,   47,  161,  143,   56,   57,   49,
   50,   51,   58,   59,  134,  135,  136,   83,  137,  140,
  141,  142,  144,  145,  146,  147,  148,   60,   61,  150,
  151,   62,   63,  156,   64,   65,  160,  162,  163,  164,
   49,   50,   51,  168,  169,   89,   90,   91,   92,  171,
   37,   96,   97,   98,   80,   99,   87,   87,   87,  100,
   87,  101,  102,   86,   87,   81,   87,   87,  112,  113,
  114,   95,   95,   95,   96,   96,   96,   94,   95,   82,
   88,  103,  104,  105,   87,  179,   87,   87,   87,  116,
  118,  119,  120,  121,  106,  122,  125,  173,   95,   87,
  132,  126,  188,  127,  107,  108,  109,  128,  129,   87,
   87,   87,  130,  131,  192,  133,  110,  111,  154,  194,
  155,   87,   87,  157,  198,  158,  165,  210,  166,  167,
  170,  172,   88,   88,   88,  174,   88,  175,  176,  177,
   88,  180,   88,   88,  181,  182,  183,  184,  185,  186,
  187,  189,  193,  195,  220,  196,  197,  199,  200,  201,
    2,  202,   88,   88,   88,  205,  206,  209,  219,  204,
  221,  222,  223,   76,  208,   88,  211,    0,    0,  211,
  190,   68,   70,  215,  215,   88,   88,   88,    0,    0,
    0,    0,    0,    0,    0,    0,    0,   88,   88,   80,
   80,   80,    0,   80,    0,    0,    0,   80,    0,   80,
   80,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   80,
   80,   80,   94,   95,    0,    0,    0,    0,    0,    0,
    0,    0,   80,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   80,   80,   80,    0,    0,    0,    0,    0,
    0,    0,    0,    0,   80,   80,    0,    1,    0,    0,
  101,    2,    0,    3,    4,    5,    0,    0,    0,    0,
    6,    7,    8,    9,   10,    0,    0,    0,   11,   12,
    0,    0,   13,    0,   14,   15,   16,   17,    0,    0,
    0,   18,   19,   20,   21,   22,   23,   24,   25,   26,
   27,    0,   28,   29,   30,    0,   31,   32,    0,    0,
    0,    0,    0,    0,   33,   34,   81,   81,   81,   35,
   81,    0,    0,    0,   81,   36,   81,   81,    0,    0,
   82,   82,   82,    0,   82,    0,    0,    0,   82,    0,
   82,   82,    0,    0,    0,    0,   81,   81,   81,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   81,
   82,   82,   82,    0,    0,    0,    0,    0,    0,   81,
   81,   81,    0,   82,    0,    0,    0,    0,    0,    0,
    0,   81,   81,   82,   82,   82,    0,    0,    0,   80,
   80,   80,    0,   80,    0,   82,   82,   80,    0,   80,
   80,    0,    0,    0,   94,   94,    0,   94,    0,    0,
    0,   94,    0,   94,   94,    0,    0,    0,    0,   80,
   80,   80,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   80,   94,   94,   94,    0,    0,    0,    0,
    0,    0,   80,   80,   80,    0,   94,    0,    0,    0,
    0,    0,    0,    0,   80,   80,   94,   94,   94,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   94,   94,
};
static const YYINT yycheck[] = {                         44,
    0,    0,   44,   41,   44,   44,   47,   44,   44,    3,
   16,   17,   18,   19,   20,   21,   22,  271,   23,  257,
  310,  275,  276,  277,  280,  258,  271,  275,  276,  277,
  281,  321,   37,  275,  276,  277,  281,  271,   44,  280,
  281,   41,  258,  281,  275,  276,  277,  281,   93,  281,
  281,   93,  280,   93,   93,  280,   93,   93,  314,  315,
  308,  309,  258,  314,  315,  271,  308,  280,  281,  275,
  276,  277,  273,  274,   80,   81,   82,  280,   84,   85,
   86,   87,   88,   89,   90,   91,   92,  273,  274,   94,
   95,  330,  331,   99,  330,  331,  102,  103,  104,  105,
  275,  276,  277,  109,  110,  326,  327,  328,  329,  115,
   40,  258,  259,  260,  305,  262,  258,  259,  260,  266,
  262,  268,  269,  322,  266,  305,  268,  269,  316,  317,
  318,  316,  317,  318,  316,  317,  318,  330,  331,  305,
  321,  288,  289,  290,  322,  139,  288,  289,  290,  280,
  280,  274,  274,  273,  301,  273,  280,   91,  331,  301,
  281,  280,   91,  280,  311,  312,  313,  280,  280,  311,
  312,  313,  280,  280,   91,  281,  323,  324,  280,   91,
  281,  323,  324,  280,   47,  281,  280,   47,  281,  281,
  281,  280,  258,  259,  260,  280,  262,  280,  280,  280,
  266,  280,  268,  269,  280,  280,  280,  280,  280,  280,
  280,  280,  280,  280,   47,  280,  280,  280,  280,  280,
    0,  281,  288,  289,  290,  280,  280,  280,  280,  188,
  281,  280,  280,  280,  194,  301,  281,   -1,   -1,  281,
  281,  281,  281,  280,  280,  311,  312,  313,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  323,  324,  258,
  259,  260,   -1,  262,   -1,   -1,   -1,  266,   -1,  268,
  269,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  288,
  289,  290,  330,  331,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,  301,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,  311,  312,  313,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  323,  324,   -1,  257,   -1,   -1,
  330,  261,   -1,  263,  264,  265,   -1,   -1,   -1,   -1,
  270,  271,  272,  273,  274,   -1,   -1,   -1,  278,  279,
   -1,   -1,  282,   -1,  284,  285,  286,  287,   -1,   -1,
   -1,  291,  292,  293,  294,  295,  296,  297,  298,  299,
  300,   -1,  302,  303,  304,   -1,  306,  307,   -1,   -1,
   -1,   -1,   -1,   -1,  314,  315,  258,  259,  260,  319,
  262,   -1,   -1,   -1,  266,  325,  268,  269,   -1,   -1,
  258,  259,  260,   -1,  262,   -1,   -1,   -1,  266,   -1,
  268,  269,   -1,   -1,   -1,   -1,  288,  289,  290,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  301,
  288,  289,  290,   -1,   -1,   -1,   -1,   -1,   -1,  311,
  312,  313,   -1,  301,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,  323,  324,  311,  312,  313,   -1,   -1,   -1,  258,
  259,  260,   -1,  262,   -1,  323,  324,  266,   -1,  268,
  269,   -1,   -1,   -1,  259,  260,   -1,  262,   -1,   -1,
   -1,  266,   -1,  268,  269,   -1,   -1,   -1,   -1,  288,
  289,  290,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,  301,  288,  289,  290,   -1,   -1,   -1,   -1,
   -1,   -1,  311,  312,  313,   -1,  301,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  323,  324,  311,  312,  313,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  323,  324,
};
#if YYBTYACC
static const YYINT yyctable[] = {                        -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,   -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,
};
#endif
#define YYFINAL 38
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 332
#define YYUNDFTOKEN 343
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
#if YYDEBUG
static const char *const yyname[] = {

"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,"'('","')'","'*'","'+'","','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error",
"ANY","IP","IF","MAC","MPLS","TOS","DIR","FLAGS","PROTO","MASK","HOSTNAME",
"NET","PORT","FWDSTAT","IN","OUT","SRC","DST","EQ","LT","GT","PREV","NEXT",
"NUMBER","STRING","IDENT","PORTNUM","ICMP_TYPE","ICMP_CODE","ENGINE_TYPE",
"ENGINE_ID","AS","PACKETS","BYTES","FLOWS","PPS","BPS","BPP","DURATION","NOT",
"IPV4","IPV6","BGPNEXTHOP","ROUTER","VLAN","CLIENT","SERVER","APP","LATENCY",
"SYSID","ASA","REASON","DENIED","XEVENT","XIP","XNET","XPORT","INGRESS",
"EGRESS","ACL","ACE","XACE","NAT","ADD","EVENT","VRF","NPORT","NIP","PBLOCK",
"START","END","STEP","SIZE","OR","AND","NEGATE","$accept","prog","expr","dqual",
"term","comp","acl","inout","iplist","ullist","illegal-symbol",
};
static const char *const yyrule[] = {
"$accept : prog",
"prog :",
"prog : expr",
"term : ANY",
"term : IDENT STRING",
"term : IPV4",
"term : IPV6",
"term : PROTO NUMBER",
"term : PROTO STRING",
"term : dqual PACKETS comp NUMBER",
"term : dqual BYTES comp NUMBER",
"term : FLOWS comp NUMBER",
"term : PPS comp NUMBER",
"term : BPS comp NUMBER",
"term : BPP comp NUMBER",
"term : DURATION comp NUMBER",
"term : dqual TOS comp NUMBER",
"term : FLAGS comp NUMBER",
"term : FLAGS STRING",
"term : dqual IP STRING",
"term : dqual IP IN '[' iplist ']'",
"term : NEXT IP STRING",
"term : NEXT IP IN '[' iplist ']'",
"term : BGPNEXTHOP IP STRING",
"term : ROUTER IP STRING",
"term : CLIENT LATENCY comp NUMBER",
"term : SERVER LATENCY comp NUMBER",
"term : APP LATENCY comp NUMBER",
"term : SYSID NUMBER",
"term : dqual PORT comp NUMBER",
"term : dqual PORT IN '[' ullist ']'",
"term : ICMP_TYPE NUMBER",
"term : ICMP_CODE NUMBER",
"term : ENGINE_TYPE comp NUMBER",
"term : ENGINE_ID comp NUMBER",
"term : ASA EVENT REASON",
"term : ASA EVENT comp NUMBER",
"term : ASA EVENT DENIED inout",
"term : ASA EVENT DENIED STRING",
"term : ASA XEVENT comp NUMBER",
"term : dqual XIP STRING",
"term : dqual XNET STRING '/' NUMBER",
"term : dqual XPORT comp NUMBER",
"term : inout acl comp NUMBER",
"term : NAT EVENT REASON",
"term : NAT EVENT comp NUMBER",
"term : INGRESS VRF comp NUMBER",
"term : EGRESS VRF comp NUMBER",
"term : PBLOCK START comp NUMBER",
"term : PBLOCK END comp NUMBER",
"term : PBLOCK STEP comp NUMBER",
"term : PBLOCK SIZE comp NUMBER",
"term : dqual NPORT comp NUMBER",
"term : dqual NIP STRING",
"term : dqual AS comp NUMBER",
"term : dqual AS IN '[' ullist ']'",
"term : dqual MASK NUMBER",
"term : dqual NET STRING STRING",
"term : dqual NET STRING '/' NUMBER",
"term : dqual IF NUMBER",
"term : dqual VLAN NUMBER",
"term : dqual MAC STRING",
"term : MPLS STRING comp NUMBER",
"term : MPLS ANY NUMBER",
"term : FWDSTAT NUMBER",
"term : FWDSTAT STRING",
"term : DIR NUMBER",
"term : DIR inout",
"iplist : STRING",
"iplist : STRING '/' NUMBER",
"iplist : iplist STRING",
"iplist : iplist ',' STRING",
"iplist : iplist STRING '/' NUMBER",
"ullist : NUMBER",
"ullist : ullist NUMBER",
"ullist : ullist ',' NUMBER",
"comp :",
"comp : EQ",
"comp : LT",
"comp : GT",
"dqual :",
"dqual : SRC",
"dqual : DST",
"dqual : SRC OR DST",
"dqual : DST OR SRC",
"dqual : SRC AND DST",
"dqual : DST AND SRC",
"dqual : IN",
"dqual : OUT",
"dqual : IN SRC",
"dqual : IN DST",
"dqual : OUT SRC",
"dqual : OUT DST",
"dqual : PREV",
"dqual : NEXT",
"inout : INGRESS",
"inout : EGRESS",
"acl : ACL",
"acl : ACE",
"acl : XACE",
"expr : term",
"expr : expr OR expr",
"expr : expr AND expr",
"expr : NOT expr",
"expr : '(' expr ')'",

};
#endif

#if YYDEBUG
int      yydebug;
#endif

int      yyerrflag;
int      yychar;
YYSTYPE  yyval;
YYSTYPE  yylval;
int      yynerrs;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
YYLTYPE  yyloc; /* position returned by actions */
YYLTYPE  yylloc; /* position from the lexer */
#endif

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
#ifndef YYLLOC_DEFAULT
#define YYLLOC_DEFAULT(loc, rhs, n) \
do \
{ \
    if (n == 0) \
    { \
        (loc).first_line   = YYRHSLOC(rhs, 0).last_line; \
        (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
        (loc).last_line    = YYRHSLOC(rhs, 0).last_line; \
        (loc).last_column  = YYRHSLOC(rhs, 0).last_column; \
    } \
    else \
    { \
        (loc).first_line   = YYRHSLOC(rhs, 1).first_line; \
        (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
        (loc).last_line    = YYRHSLOC(rhs, n).last_line; \
        (loc).last_column  = YYRHSLOC(rhs, n).last_column; \
    } \
} while (0)
#endif /* YYLLOC_DEFAULT */
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#if YYBTYACC

#ifndef YYLVQUEUEGROWTH
#define YYLVQUEUEGROWTH 32
#endif
#endif /* YYBTYACC */

/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH  YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 10000
#define YYMAXDEPTH  10000
#endif
#endif

#ifndef YYINITSTACKSIZE
#define YYINITSTACKSIZE 200
#endif

typedef struct {
    unsigned stacksize;
    YYINT    *s_base;
    YYINT    *s_mark;
    YYINT    *s_last;
    YYSTYPE  *l_base;
    YYSTYPE  *l_mark;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE  *p_base;
    YYLTYPE  *p_mark;
#endif
} YYSTACKDATA;
#if YYBTYACC

struct YYParseState_s
{
    struct YYParseState_s *save;    /* Previously saved parser state */
    YYSTACKDATA            yystack; /* saved parser stack */
    int                    state;   /* saved parser state */
    int                    errflag; /* saved error recovery status */
    int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
    YYINT                  ctry;    /* saved index in yyctable[] for this conflict */
};
typedef struct YYParseState_s YYParseState;
#endif /* YYBTYACC */
/* variables for the parser stack */
static YYSTACKDATA yystack;
#if YYBTYACC

/* Current parser state */
static YYParseState *yyps = 0;

/* yypath != NULL: do the full parse, starting at *yypath parser state. */
static YYParseState *yypath = 0;

/* Base of the lexical value queue */
static YYSTYPE *yylvals = 0;

/* Current position at lexical value queue */
static YYSTYPE *yylvp = 0;

/* End position of lexical value queue */
static YYSTYPE *yylve = 0;

/* The last allocated position at the lexical value queue */
static YYSTYPE *yylvlim = 0;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
/* Base of the lexical position queue */
static YYLTYPE *yylpsns = 0;

/* Current position at lexical position queue */
static YYLTYPE *yylpp = 0;

/* End position of lexical position queue */
static YYLTYPE *yylpe = 0;

/* The last allocated position at the lexical position queue */
static YYLTYPE *yylplim = 0;
#endif

/* Current position at lexical token queue */
static YYINT  *yylexp = 0;

static YYINT  *yylexemes = 0;
#endif /* YYBTYACC */
#line 2080 "grammar.y"

static void  yyerror(char *msg) {

	if ( FilterFilename )
		snprintf(yyerror_buff, 255 ,"File '%s' line %d: %s at '%s'", FilterFilename, lineno, msg, yytext);
	else 
		snprintf(yyerror_buff, 255, "Line %d: %s at '%s'", lineno, msg, yytext);

	yyerror_buff[255] = '\0';
	fprintf(stderr, "%s\n", yyerror_buff);

} /* End of yyerror */

static uint32_t ChainHosts(uint64_t *offsets, uint64_t *hostlist, int num_records, int type) {
uint32_t offset_a, offset_b, i, j, block;
	if ( type == SOURCE ) {
		offset_a = offsets[0];
		offset_b = offsets[1];
	} else {
		offset_a = offsets[2];
		offset_b = offsets[3];
	}

	i = 0;
	block = Connect_AND(
				NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
				NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
			);
	i += 2;
	for ( j=1; j<num_records; j++ ) {
		uint32_t b = Connect_AND(
				NewBlock(offset_b, MaskIPv6, hostlist[i+1] , CMP_EQ, FUNC_NONE, NULL ),
				NewBlock(offset_a, MaskIPv6, hostlist[i] , CMP_EQ, FUNC_NONE, NULL )
			);
		block = Connect_OR(block, b);
		i += 2;
	}

	return block;

} // End of ChainHosts

uint64_t VerifyMac(char *s) {
uint64_t mac;
size_t slen = strlen(s);
long l;
char *p, *q, *r;
int i;

	if ( slen > 17 )
		return 0; 

	for (i=0; i<slen; i++ ) {
		if ( !isxdigit(s[i]) && s[i] != ':' ) 
			return 0;
	}

	p = strdup(s);
	if ( !p ) {
		yyerror("malloc() error");
		return 0;
	}

	mac = 0;
	i = 0;	// number of MAC octets must be 6
	r = p;
	q = strchr(r, ':');
	while ( r && i < 6 ) {
		if ( q ) 
			*q = '\0';
		l = strtol(r, NULL, 16);
		if ( (i == 0 && errno == EINVAL) ) {
			free(p);
			return 0;
		}
		if ( l > 255 ) {
			free(p);
			return 0;
		}

		mac = ( mac << 8 ) | (l & 0xFF );
		i++;

		if ( q ) {
			r = ++q;
			q = strchr(r, ':');
		} else 
			r = NULL;
	}

	if ( i != 6 )
		return 0;

	return mac;

} // End of VerifyMac
#line 899 "grammar.c"

/* For use in generated program */
#define yydepth (int)(yystack.s_mark - yystack.s_base)
#if YYBTYACC
#define yytrial (yyps->save)
#endif /* YYBTYACC */

#if YYDEBUG
#include <stdio.h>	/* needed for printf */
#endif

#include <stdlib.h>	/* needed for malloc, etc */
#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
    int i;
    unsigned newsize;
    YYINT *newss;
    YYSTYPE *newvs;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE *newps;
#endif

    if ((newsize = data->stacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return YYENOMEM;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;

    i = (int) (data->s_mark - data->s_base);
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    if (newss == 0)
        return YYENOMEM;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    if (newvs == 0)
        return YYENOMEM;

    data->l_base = newvs;
    data->l_mark = newvs + i;

#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
    if (newps == 0)
        return YYENOMEM;

    data->p_base = newps;
    data->p_mark = newps + i;
#endif

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;

#if YYDEBUG
    if (yydebug)
        fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
#endif
    return 0;
}

#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    free(data->p_base);
#endif
    memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif /* YYPURE || defined(YY_NO_LEAKS) */
#if YYBTYACC

static YYParseState *
yyNewState(unsigned size)
{
    YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
    if (p == NULL) return NULL;

    p->yystack.stacksize = size;
    if (size == 0)
    {
        p->yystack.s_base = NULL;
        p->yystack.l_base = NULL;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        p->yystack.p_base = NULL;
#endif
        return p;
    }
    p->yystack.s_base    = (YYINT *) malloc(size * sizeof(YYINT));
    if (p->yystack.s_base == NULL) return NULL;
    p->yystack.l_base    = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
    if (p->yystack.l_base == NULL) return NULL;
    memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    p->yystack.p_base    = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
    if (p->yystack.p_base == NULL) return NULL;
    memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
#endif

    return p;
}

static void
yyFreeState(YYParseState *p)
{
    yyfreestack(&p->yystack);
    free(p);
}
#endif /* YYBTYACC */

#define YYABORT  goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR  goto yyerrlab
#if YYBTYACC
#define YYVALID        do { if (yyps->save)            goto yyvalid; } while(0)
#define YYVALID_NESTED do { if (yyps->save && \
                                yyps->save->save == 0) goto yyvalid; } while(0)
#endif /* YYBTYACC */

int
YYPARSE_DECL()
{
    int yym, yyn, yystate, yyresult;
#if YYBTYACC
    int yynewerrflag;
    YYParseState *yyerrctx = NULL;
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    YYLTYPE  yyerror_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")) != 0)
    {
        yyn = *yys;
        if (yyn >= '0' && yyn <= '9')
            yydebug = yyn - '0';
    }
    if (yydebug)
        fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
#endif
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
#endif

#if YYBTYACC
    yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
    yyps->save = 0;
#endif /* YYBTYACC */
    yym = 0;
    yyn = 0;
    yynerrs = 0;
    yyerrflag = 0;
    yychar = YYEMPTY;
    yystate = 0;

#if YYPURE
    memset(&yystack, 0, sizeof(yystack));
#endif

    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    yystack.s_mark = yystack.s_base;
    yystack.l_mark = yystack.l_base;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark = yystack.p_base;
#endif
    yystate = 0;
    *yystack.s_mark = 0;

yyloop:
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    if (yychar < 0)
    {
#if YYBTYACC
        do {
        if (yylvp < yylve)
        {
            /* we're currently re-reading tokens */
            yylval = *yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylloc = *yylpp++;
#endif
            yychar = *yylexp++;
            break;
        }
        if (yyps->save)
        {
            /* in trial mode; save scanner results for future parse attempts */
            if (yylvp == yylvlim)
            {   /* Enlarge lexical value queue */
                size_t p = (size_t) (yylvp - yylvals);
                size_t s = (size_t) (yylvlim - yylvals);

                s += YYLVQUEUEGROWTH;
                if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
                if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
#endif
                yylvp   = yylve = yylvals + p;
                yylvlim = yylvals + s;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp   = yylpe = yylpsns + p;
                yylplim = yylpsns + s;
#endif
                yylexp  = yylexemes + p;
            }
            *yylexp = (YYINT) YYLEX;
            *yylvp++ = yylval;
            yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            *yylpp++ = yylloc;
            yylpe++;
#endif
            yychar = *yylexp++;
            break;
        }
        /* normal operation, no conflict encountered */
#endif /* YYBTYACC */
        yychar = YYLEX;
#if YYBTYACC
        } while (0);
#endif /* YYBTYACC */
        if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
        if (yydebug)
        {
            if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
                            YYDEBUGSTR, yydepth, yystate, yychar, yys);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
            if (!yytrial)
#endif /* YYBTYACC */
                fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
#endif
            fputc('\n', stderr);
        }
#endif
    }
#if YYBTYACC

    /* Do we have a conflict? */
    if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
        yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
        YYINT ctry;

        if (yypath)
        {
            YYParseState *save;
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
                                YYDEBUGSTR, yydepth, yystate);
#endif
            /* Switch to the next conflict context */
            save = yypath;
            yypath = save->save;
            save->save = NULL;
            ctry = save->ctry;
            if (save->state != yystate) YYABORT;
            yyFreeState(save);

        }
        else
        {

            /* Unresolved conflict - start/continue trial parse */
            YYParseState *save;
#if YYDEBUG
            if (yydebug)
            {
                fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
                if (yyps->save)
                    fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
                else
                    fputs("Starting trial parse.\n", stderr);
            }
#endif
            save                  = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
            if (save == NULL) goto yyenomem;
            save->save            = yyps->save;
            save->state           = yystate;
            save->errflag         = yyerrflag;
            save->yystack.s_mark  = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
            memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            save->yystack.l_mark  = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
            memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            save->yystack.p_mark  = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
            memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            ctry                  = yytable[yyn];
            if (yyctable[ctry] == -1)
            {
#if YYDEBUG
                if (yydebug && yychar >= YYEOF)
                    fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
#endif
                ctry++;
            }
            save->ctry = ctry;
            if (yyps->save == NULL)
            {
                /* If this is a first conflict in the stack, start saving lexemes */
                if (!yylexemes)
                {
                    yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
                    if (yylexemes == NULL) goto yyenomem;
                    yylvals   = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
                    if (yylvals == NULL) goto yyenomem;
                    yylvlim   = yylvals + YYLVQUEUEGROWTH;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpsns   = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
                    if (yylpsns == NULL) goto yyenomem;
                    yylplim   = yylpsns + YYLVQUEUEGROWTH;
#endif
                }
                if (yylvp == yylve)
                {
                    yylvp  = yylve = yylvals;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpp  = yylpe = yylpsns;
#endif
                    yylexp = yylexemes;
                    if (yychar >= YYEOF)
                    {
                        *yylve++ = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                        *yylpe++ = yylloc;
#endif
                        *yylexp  = (YYINT) yychar;
                        yychar   = YYEMPTY;
                    }
                }
            }
            if (yychar >= YYEOF)
            {
                yylvp--;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp--;
#endif
                yylexp--;
                yychar = YYEMPTY;
            }
            save->lexeme = (int) (yylvp - yylvals);
            yyps->save   = save;
        }
        if (yytable[yyn] == ctry)
        {
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                                YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
#endif
            if (yychar < 0)
            {
                yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylpp++;
#endif
                yylexp++;
            }
            if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
                goto yyoverflow;
            yystate = yyctable[ctry];
            *++yystack.s_mark = (YYINT) yystate;
            *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            *++yystack.p_mark = yylloc;
#endif
            yychar  = YYEMPTY;
            if (yyerrflag > 0) --yyerrflag;
            goto yyloop;
        }
        else
        {
            yyn = yyctable[ctry];
            goto yyreduce;
        }
    } /* End of code dealing with conflicts */
#endif /* YYBTYACC */
    if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
#if YYDEBUG
        if (yydebug)
            fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                            YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
#endif
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
        yystate = yytable[yyn];
        *++yystack.s_mark = yytable[yyn];
        *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        *++yystack.p_mark = yylloc;
#endif
        yychar = YYEMPTY;
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    {
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag != 0) goto yyinrecovery;
#if YYBTYACC

    yynewerrflag = 1;
    goto yyerrhandler;
    goto yyerrlab; /* redundant goto avoids 'unused label' warning */

yyerrlab:
    /* explicit YYERROR from an action -- pop the rhs of the rule reduced
     * before looking for error recovery */
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark -= yym;
#endif

    yynewerrflag = 0;
yyerrhandler:
    while (yyps->save)
    {
        int ctry;
        YYParseState *save = yyps->save;
#if YYDEBUG
        if (yydebug)
            fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
                            YYDEBUGSTR, yydepth, yystate, yyps->save->state,
                    (int)(yylvp - yylvals - yyps->save->lexeme));
#endif
        /* Memorize most forward-looking error state in case it's really an error. */
        if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
        {
            /* Free old saved error context state */
            if (yyerrctx) yyFreeState(yyerrctx);
            /* Create and fill out new saved error context state */
            yyerrctx                 = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
            if (yyerrctx == NULL) goto yyenomem;
            yyerrctx->save           = yyps->save;
            yyerrctx->state          = yystate;
            yyerrctx->errflag        = yyerrflag;
            yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
            memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
            memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
            memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            yyerrctx->lexeme         = (int) (yylvp - yylvals);
        }
        yylvp          = yylvals   + save->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        yylpp          = yylpsns   + save->lexeme;
#endif
        yylexp         = yylexemes + save->lexeme;
        yychar         = YYEMPTY;
        yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
        memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
        yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
        memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
        memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
        ctry           = ++save->ctry;
        yystate        = save->state;
        /* We tried shift, try reduce now */
        if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
        yyps->save     = save->save;
        save->save     = NULL;
        yyFreeState(save);

        /* Nothing left on the stack -- error */
        if (!yyps->save)
        {
#if YYDEBUG
            if (yydebug)
                fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
                                YYPREFIX, yydepth);
#endif
            /* Restore state as it was in the most forward-advanced error */
            yylvp          = yylvals   + yyerrctx->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylpp          = yylpsns   + yyerrctx->lexeme;
#endif
            yylexp         = yylexemes + yyerrctx->lexeme;
            yychar         = yylexp[-1];
            yylval         = yylvp[-1];
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yylloc         = yylpp[-1];
#endif
            yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
            memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
            yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
            memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
            memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
            yystate        = yyerrctx->state;
            yyFreeState(yyerrctx);
            yyerrctx       = NULL;
        }
        yynewerrflag = 1;
    }
    if (yynewerrflag == 0) goto yyinrecovery;
#endif /* YYBTYACC */

    YYERROR_CALL("syntax error");
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
#endif

#if !YYBTYACC
    goto yyerrlab; /* redundant goto avoids 'unused label' warning */
yyerrlab:
#endif
    ++yynerrs;

yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
                                    YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
#endif
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
                yystate = yytable[yyn];
                *++yystack.s_mark = yytable[yyn];
                *++yystack.l_mark = yylval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                /* lookahead position is error end position */
                yyerror_loc_range[2] = yylloc;
                YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
                *++yystack.p_mark = yyloc;
#endif
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
                                    YYDEBUGSTR, yydepth, *yystack.s_mark);
#endif
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                /* the current TOS position is the error start position */
                yyerror_loc_range[1] = *yystack.p_mark;
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
                if (!yytrial)
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    YYDESTRUCT_CALL("error: discarding state",
                                    yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
#else
                    YYDESTRUCT_CALL("error: discarding state",
                                    yystos[*yystack.s_mark], yystack.l_mark);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#endif /* defined(YYDESTRUCT_CALL) */
                --yystack.s_mark;
                --yystack.l_mark;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                --yystack.p_mark;
#endif
            }
        }
    }
    else
    {
        if (yychar == YYEOF) goto yyabort;
#if YYDEBUG
        if (yydebug)
        {
            if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
                            YYDEBUGSTR, yydepth, yystate, yychar, yys);
        }
#endif
#if defined(YYDESTRUCT_CALL)
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
            YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
#else
            YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
#endif /* defined(YYDESTRUCT_CALL) */
        yychar = YYEMPTY;
        goto yyloop;
    }

yyreduce:
    yym = yylen[yyn];
#if YYDEBUG
    if (yydebug)
    {
        fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
                        YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
            if (yym > 0)
            {
                int i;
                fputc('<', stderr);
                for (i = yym; i > 0; i--)
                {
                    if (i != yym) fputs(", ", stderr);
                    fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
                                           yystack.l_mark[1-i]), stderr);
                }
                fputc('>', stderr);
            }
#endif
        fputc('\n', stderr);
    }
#endif
    if (yym > 0)
        yyval = yystack.l_mark[1-yym];
    else
        memset(&yyval, 0, sizeof yyval);
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)

    /* Perform position reduction */
    memset(&yyloc, 0, sizeof(yyloc));
#if YYBTYACC
    if (!yytrial)
#endif /* YYBTYACC */
    {
        YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
        /* just in case YYERROR is invoked within the action, save
           the start of the rhs as the error start position */
        yyerror_loc_range[1] = yystack.p_mark[1-yym];
    }
#endif

    switch (yyn)
    {
case 2:
#line 123 "grammar.y"
	{   
		StartNode = yystack.l_mark[0].value; 
	}
break;
case 3:
#line 128 "grammar.y"
	{ /* this is an unconditionally true expression, as a filter applies in any case */
		yyval.param.self = NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL ); 
	}
break;
case 4:
#line 132 "grammar.y"
	{	
		if ( !ScreenIdentString(yystack.l_mark[0].s) ) {
			yyerror("Illegal ident string");
			YYABORT;
		}

		uint32_t	index = AddIdent(yystack.l_mark[0].s);
		yyval.param.self = NewBlock(0, 0, index, CMP_IDENT, FUNC_NONE, NULL ); 
	}
break;
case 5:
#line 142 "grammar.y"
	{ 
		yyval.param.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags)  & MaskRecordFlags, 
					(0LL << ShiftRecordFlags)  & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL); 
	}
break;
case 6:
#line 147 "grammar.y"
	{ 
		yyval.param.self = NewBlock(OffsetRecordFlags, (1LL << ShiftRecordFlags)  & MaskRecordFlags, 
					(1LL << ShiftRecordFlags)  & MaskRecordFlags, CMP_EQ, FUNC_NONE, NULL); 
	}
break;
case 7:
#line 152 "grammar.y"
	{ 
		int64_t	proto;
		proto = yystack.l_mark[0].value;

		if ( proto > 255 ) {
			yyerror("Protocol number > 255");
			YYABORT;
		}
		if ( proto < 0 ) {
			yyerror("Unknown protocol");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL); 

	}
break;
case 8:
#line 168 "grammar.y"
	{ 
		int64_t	proto;
		proto = Proto_num(yystack.l_mark[0].s);

		if ( proto > 255 ) {
			yyerror("Protocol number > 255");
			YYABORT;
		}
		if ( proto < 0 ) {
			yyerror("Unknown protocol");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL); 
	}
break;
case 9:
#line 183 "grammar.y"
	{ 

		switch ( yystack.l_mark[-3].param.direction ) {
			case DIR_UNSPEC:
			case DIR_IN: 
				yyval.param.self = NewBlock(OffsetPackets, MaskPackets, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			case DIR_OUT: 
				yyval.param.self = NewBlock(OffsetOutPackets, MaskPackets, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			default:
				/* should never happen */
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 10:
#line 201 "grammar.y"
	{	

		switch ( yystack.l_mark[-3].param.direction ) {
			case DIR_UNSPEC:
			case DIR_IN: 
				yyval.param.self = NewBlock(OffsetBytes, MaskBytes, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			case DIR_OUT: 
				yyval.param.self = NewBlock(OffsetOutBytes, MaskBytes, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 11:
#line 218 "grammar.y"
	{	
			yyval.param.self = NewBlock(OffsetAggrFlows, MaskFlows, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
	}
break;
case 12:
#line 222 "grammar.y"
	{	
		yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_PPS, NULL); 
	}
break;
case 13:
#line 226 "grammar.y"
	{	
		yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_BPS, NULL); 
	}
break;
case 14:
#line 230 "grammar.y"
	{	
		yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_BPP, NULL); 
	}
break;
case 15:
#line 234 "grammar.y"
	{	
		yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_DURATION, NULL); 
	}
break;
case 16:
#line 238 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("TOS must be 0..255");
			YYABORT;
		}

		switch ( yystack.l_mark[-3].param.direction ) {
			case DIR_UNSPEC:
			case SOURCE:
				yyval.param.self = NewBlock(OffsetTos, MaskTos, (yystack.l_mark[0].value << ShiftTos) & MaskTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetDstTos, MaskDstTos, (yystack.l_mark[0].value << ShiftDstTos) & MaskDstTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
				break;
			case SOURCE_OR_DESTINATION: 
				yyval.param.self = Connect_OR(
					NewBlock(OffsetTos, MaskTos, (yystack.l_mark[0].value << ShiftTos) & MaskTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL),
					NewBlock(OffsetDstTos, MaskDstTos, (yystack.l_mark[0].value << ShiftDstTos) & MaskDstTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL)
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetTos, MaskTos, (yystack.l_mark[0].value << ShiftTos) & MaskTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL),
					NewBlock(OffsetDstTos, MaskDstTos, (yystack.l_mark[0].value << ShiftDstTos) & MaskDstTos, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL)
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
			}
	}
break;
case 17:
#line 270 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 63 ) {
			yyerror("Flags must be 0..63");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetFlags, MaskFlags, (yystack.l_mark[0].value << ShiftFlags) & MaskFlags, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
	}
break;
case 18:
#line 278 "grammar.y"
	{	
		uint64_t fl = 0;
		int cnt     = 0;
		size_t		len = strlen(yystack.l_mark[0].s);

		if ( len > 7 ) {
			yyerror("Too many flags");
			YYABORT;
		}

		if ( strchr(yystack.l_mark[0].s, 'F') ) { fl |=  1; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'S') ) { fl |=  2; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'R') ) { fl |=  4; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'P') ) { fl |=  8; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'A') ) { fl |=  16; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'U') ) { fl |=  32; cnt++; }
		if ( strchr(yystack.l_mark[0].s, 'X') ) { fl =  63; cnt++; }

		if ( cnt != len ) {
			yyerror("Too many flags");
			YYABORT;
		}

		yyval.param.self = NewBlock(OffsetFlags, (fl << ShiftFlags) & MaskFlags, 
					(fl << ShiftFlags) & MaskFlags, CMP_FLAGS, FUNC_NONE, NULL); 
	}
break;
case 19:
#line 305 "grammar.y"
	{ 	
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		/* ret == -1 will never happen here, as ALLOW_LOOKUP is set*/
		if ( ret == -2 ) {
			/* could not resolv host => 'not any'*/
			yyval.param.self = Invert(NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL )); 
		} else {
			uint64_t offsets[4] = {OffsetSrcIPv6a, OffsetSrcIPv6b, OffsetDstIPv6a, OffsetDstIPv6b };
			if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
				yyerror("incomplete IP address");
				YYABORT;
			}

			switch ( yystack.l_mark[-2].param.direction ) {
				case SOURCE:
				case DESTINATION:
					yyval.param.self = ChainHosts(offsets, IPstack, num_ip, yystack.l_mark[-2].param.direction);
					break;
				case DIR_UNSPEC:
				case SOURCE_OR_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_OR(src, dst);
					} break;
				case SOURCE_AND_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_AND(src, dst);
					} break;
				default:
					yyerror("This token is not expected here!");
					YYABORT;
	
			} /* End of switch*/

		}
	}
break;
case 20:
#line 351 "grammar.y"
	{ 	

		switch ( yystack.l_mark[-5].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetSrcIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetDstIPv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		}
	}
break;
case 21:
#line 379 "grammar.y"
	{ 	
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/

		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		yyval.param.self = Connect_AND(
			NewBlock(OffsetNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
			NewBlock(OffsetNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
		);
	}
break;
case 22:
#line 406 "grammar.y"
	{ 	

		yyval.param.self = NewBlock(OffsetNexthopv6a, MaskIPv6, 0 , CMP_IPLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );

	}
break;
case 23:
#line 412 "grammar.y"
	{ 	
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/

		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		yyval.param.self = Connect_AND(
			NewBlock(OffsetBGPNexthopv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
			NewBlock(OffsetBGPNexthopv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
		);
	}
break;
case 24:
#line 439 "grammar.y"
	{ 	
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/

		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		yyval.param.self = Connect_AND(
			NewBlock(OffsetRouterv6b, MaskIPv6, IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
			NewBlock(OffsetRouterv6a, MaskIPv6, IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
		);
	}
break;
case 25:
#line 466 "grammar.y"
	{ 	
		yyval.param.self = NewBlock(OffsetClientLatency, MaskLatency, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
	}
break;
case 26:
#line 470 "grammar.y"
	{ 	
		yyval.param.self = NewBlock(OffsetServerLatency, MaskLatency, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
	}
break;
case 27:
#line 474 "grammar.y"
	{ 	
		yyval.param.self = NewBlock(OffsetAppLatency, MaskLatency, yystack.l_mark[0].value, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL); 
	}
break;
case 28:
#line 478 "grammar.y"
	{ 	
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Router SysID expected between be 1..255");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetExporterSysID, MaskExporterSysID, (yystack.l_mark[0].value << ShiftExporterSysID) & MaskExporterSysID, CMP_EQ, FUNC_NONE, NULL); 
	}
break;
case 29:
#line 486 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 65535 ) {
			yyerror("Port outside of range 0..65535");
			YYABORT;
		}

		switch ( yystack.l_mark[-3].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetPort, MaskSrcPort, (yystack.l_mark[0].value << ShiftSrcPort) & MaskSrcPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetPort, MaskDstPort, (yystack.l_mark[0].value << ShiftDstPort) & MaskDstPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetPort, MaskSrcPort, (yystack.l_mark[0].value << ShiftSrcPort) & MaskSrcPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetPort, MaskDstPort, (yystack.l_mark[0].value << ShiftDstPort) & MaskDstPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetPort, MaskSrcPort, (yystack.l_mark[0].value << ShiftSrcPort) & MaskSrcPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetPort, MaskDstPort, (yystack.l_mark[0].value << ShiftDstPort) & MaskDstPort, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End switch*/

	}
break;
case 30:
#line 519 "grammar.y"
	{ 	
		struct ULongListNode *node;
		ULongtree_t *root = NULL;

		if ( yystack.l_mark[-5].param.direction == DIR_UNSPEC || yystack.l_mark[-5].param.direction == SOURCE_OR_DESTINATION || yystack.l_mark[-5].param.direction == SOURCE_AND_DESTINATION ) {
			/* src and/or dst port*/
			/* we need a second rbtree due to different shifts for src and dst ports*/
			root = malloc(sizeof(ULongtree_t));

			struct ULongListNode *n;
			if ( root == NULL) {
				yyerror("malloc() error");
				YYABORT;
			}
			RB_INIT(root);

			RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
				if ( node->value > 65535 ) {
					yyerror("Port outside of range 0..65535");
					YYABORT;
				}
				if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
					yyerror("malloc() error");
					YYABORT;
				}
				n->value 	= (node->value << ShiftDstPort) & MaskDstPort;
				node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
				RB_INSERT(ULongtree, root, n);
			}
		}

		switch ( yystack.l_mark[-5].param.direction ) {
			case SOURCE:
				RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
					node->value = (node->value << ShiftSrcPort) & MaskSrcPort;
				}
				yyval.param.self = NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DESTINATION:
				RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
					node->value = (node->value << ShiftDstPort) & MaskDstPort;
				}
				yyval.param.self = NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetPort, MaskSrcPort, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetPort, MaskDstPort, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 31:
#line 583 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("ICMP tpye of range 0..15");
			YYABORT;
		}
		yyval.param.self = Connect_AND(
			/* imply proto ICMP with a proto ICMP block*/
			Connect_OR (
				NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL), 
				NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL)
			),
			NewBlock(OffsetPort, MaskICMPtype, (yystack.l_mark[0].value << ShiftICMPtype) & MaskICMPtype, CMP_EQ, FUNC_NONE, NULL )
		);

	}
break;
case 32:
#line 599 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("ICMP code of range 0..15");
			YYABORT;
		}
		yyval.param.self = Connect_AND(
			/* imply proto ICMP with a proto ICMP block*/
			Connect_OR (
				NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMP << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL), 
				NewBlock(OffsetProto, MaskProto, ((uint64_t)IPPROTO_ICMPV6 << ShiftProto)  & MaskProto, CMP_EQ, FUNC_NONE, NULL)
			),
			NewBlock(OffsetPort, MaskICMPcode, (yystack.l_mark[0].value << ShiftICMPcode) & MaskICMPcode, CMP_EQ, FUNC_NONE, NULL )
		);

	}
break;
case 33:
#line 615 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Engine type of range 0..255");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetRouterID, MaskEngineType, (yystack.l_mark[0].value << ShiftEngineType) & MaskEngineType, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL);

	}
break;
case 34:
#line 624 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Engine ID of range 0..255");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetRouterID, MaskEngineID, (yystack.l_mark[0].value << ShiftEngineID) & MaskEngineID, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL);

	}
break;
case 35:
#line 633 "grammar.y"
	{
#ifdef NSEL
		if ( strncasecmp(yystack.l_mark[0].s,"ignore", 6) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_IGNORE << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else if( strncasecmp(yystack.l_mark[0].s,"create", 6) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_CREATE << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else if( strncasecmp(yystack.l_mark[0].s,"term", 4) == 0 || strncasecmp(yystack.l_mark[0].s,"delete", 6) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_DELETE << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else if  (strncasecmp(yystack.l_mark[0].s,"deny", 4) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_DENIED << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else if  (strncasecmp(yystack.l_mark[0].s,"alert", 5) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_ALERT << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else if  (strncasecmp(yystack.l_mark[0].s,"update", 6) == 0) {
			yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_UPDATE << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
		} else {
			yyerror("Unknown asa event");
			YYABORT;
		}
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 36:
#line 657 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Invalid xevent ID");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetConnID, MaskFWevent, ( yystack.l_mark[0].value << ShiftFWevent) & MaskFWevent, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 37:
#line 670 "grammar.y"
	{
#ifdef NSEL
		uint64_t xevent = 0;
		if ( yystack.l_mark[0].param.inout == INGRESS ) {
			xevent = 1001;
		} else if ( yystack.l_mark[0].param.inout == EGRESS ) {
			xevent = 1002;
		} else {
				yyerror("Invalid inout token");
				YYABORT;
		}
		yyval.param.self = Connect_AND(
			NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_DENIED << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL ),
			NewBlock(OffsetConnID, MaskFWXevent, ( xevent << ShiftFWXevent) & MaskFWXevent, CMP_EQ, FUNC_NONE, NULL )
		);
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 38:
#line 690 "grammar.y"
	{
#ifdef NSEL
		uint64_t xevent = 0;
		if( strncasecmp(yystack.l_mark[0].s,"interface", 6) == 0) {
			xevent = 1003;
		} else if( strncasecmp(yystack.l_mark[0].s,"nosyn", 6) == 0) {
			xevent = 1004;
		} else {
			xevent = (uint64_t)strtol(yystack.l_mark[0].s, (char **)NULL, 10);
			if ( (xevent == 0 && errno == EINVAL) || xevent > 65535 ) {
				yyerror("Invalid xevent ID");
				YYABORT;
			}
		}
		yyval.param.self = Connect_AND(
			NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_DENIED << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL ),
			NewBlock(OffsetConnID, MaskFWXevent, ( xevent << ShiftFWXevent) & MaskFWXevent, CMP_EQ, FUNC_NONE, NULL )
		);
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 39:
#line 714 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65535 ) {
			yyerror("Invalid xevent ID");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetConnID, MaskFWXevent, ( yystack.l_mark[0].value << ShiftFWXevent) & MaskFWXevent, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 40:
#line 727 "grammar.y"
	{ 	
#ifdef NSEL
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		/* ret == -1 will never happen here, as ALLOW_LOOKUP is set*/
		if ( ret == -2 ) {
			/* could not resolv host => 'not any'*/
			yyval.param.self = Invert(NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL )); 
		} else {
			uint64_t offsets[4] = {OffsetXLATESRCv6a, OffsetXLATESRCv6b, OffsetXLATEDSTv6a, OffsetXLATEDSTv6b };
			if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
				yyerror("incomplete IP address");
				YYABORT;
			}

			switch ( yystack.l_mark[-2].param.direction ) {
				case SOURCE:
				case DESTINATION:
					yyval.param.self = ChainHosts(offsets, IPstack, num_ip, yystack.l_mark[-2].param.direction);
					break;
				case DIR_UNSPEC:
				case SOURCE_OR_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_OR(src, dst);
					} break;
				case SOURCE_AND_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_AND(src, dst);
					} break;
				default:
					yyerror("This token is not expected here!");
					YYABORT;
	
			} /* End of switch*/

		}
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 41:
#line 778 "grammar.y"
	{ 
#ifdef NSEL
		int af, bytes, ret;
		uint64_t	mask[2];

		ret = parse_ip(&af, yystack.l_mark[-2].s, IPstack, &bytes, STRICT_IP, &num_ip);
		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/


		if ( yystack.l_mark[0].value > (bytes*8) ) {
			yyerror("Too many netbits for this IP addresss");
			YYABORT;
		}

		if ( af == PF_INET ) {
			mask[0] = 0xffffffffffffffffLL;
			mask[1] = 0xffffffffffffffffLL << ( 32 - yystack.l_mark[0].value );
		} else {	/* PF_INET6*/
			if ( yystack.l_mark[0].value > 64 ) {
				mask[0] = 0xffffffffffffffffLL;
				mask[1] = 0xffffffffffffffffLL << ( 128 - yystack.l_mark[0].value );
			} else {
				mask[0] = 0xffffffffffffffffLL << ( 64 - yystack.l_mark[0].value );
				mask[1] = 0;
			}
		}
		/* IP aadresses are stored in network representation */
		mask[0]	 = mask[0];
		mask[1]	 = mask[1];

		IPstack[0] &= mask[0];
		IPstack[1] &= mask[1];

		switch ( yystack.l_mark[-4].param.direction ) {
			case SOURCE:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetXLATESRCv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATESRCv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetXLATEDSTv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATEDSTv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					Connect_AND(
						NewBlock(OffsetXLATESRCv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetXLATESRCv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetXLATEDSTv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetXLATEDSTv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					Connect_AND(
						NewBlock(OffsetXLATESRCv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetXLATESRCv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetXLATEDSTv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetXLATEDSTv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 42:
#line 868 "grammar.y"
	{	
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65535 ) {
			yyerror("Port outside of range 0..65535");
			YYABORT;
		}

		switch ( yystack.l_mark[-3].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End switch*/
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif

	}
break;
case 43:
#line 906 "grammar.y"
	{
#ifdef NSEL
		uint64_t offset, mask, shift;
		if ( yystack.l_mark[-3].param.inout == INGRESS ) {
			switch (yystack.l_mark[-2].param.acl) {
				case ACL:
					offset = OffsetIngressAclId;
					mask   = MaskIngressAclId;	
					shift  = ShiftIngressAclId;
					break;
				case ACE:
					offset = OffsetIngressAceId;
					mask   = MaskIngressAceId;	
					shift  = ShiftIngressAceId;
					break;
				case XACE:
					offset = OffsetIngressGrpId;
					mask   = MaskIngressGrpId;	
					shift  = ShiftIngressGrpId;
					break;
				default:
					yyerror("Invalid ACL specifier");
					YYABORT;
			}
		} else if ( yystack.l_mark[-3].param.inout == EGRESS && yyval.param.acl == ACL ) {
			offset = OffsetEgressAclId;
			mask   = MaskEgressAclId;	
			shift  = ShiftEgressAclId;
		} else {
			yyerror("ingress/egress syntax error");
			YYABORT;
		}
		yyval.param.self = NewBlock(offset, mask, (yystack.l_mark[0].value << shift) & mask , yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );

#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 44:
#line 946 "grammar.y"
	{
#ifdef NSEL
		if ( strncasecmp(yystack.l_mark[0].s,"invalid", 6) == 0) {
			yyval.param.self = NewBlock(OffsetNATevent, MasNATevent, ( NEL_EVENT_INVALID << ShiftNATevent) & MasNATevent, CMP_EQ, FUNC_NONE, NULL );
		} else if( strncasecmp(yystack.l_mark[0].s,"add", 6) == 0) {
			yyval.param.self = NewBlock(OffsetNATevent, MasNATevent, ( NEL_EVENT_ADD << ShiftNATevent) & MasNATevent, CMP_EQ, FUNC_NONE, NULL );
		} else if( strncasecmp(yystack.l_mark[0].s,"delete", 4) == 0 || strncasecmp(yystack.l_mark[0].s,"delete", 6) == 0) {
			yyval.param.self = NewBlock(OffsetNATevent, MasNATevent, ( NEL_EVENT_DELETE << ShiftNATevent) & MasNATevent, CMP_EQ, FUNC_NONE, NULL );
		} else {
			yyerror("Unknown nat event");
			YYABORT;
		}
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 45:
#line 964 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Invalid event ID");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetNATevent, MasNATevent, ( yystack.l_mark[0].value << ShiftNATevent) & MasNATevent, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 46:
#line 977 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 0xFFFFFFFFLL ) {
			yyerror("Invalid ingress vrf ID");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetIVRFID, MaskIVRFID, ( yystack.l_mark[0].value << ShiftIVRFID) & MaskIVRFID, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 47:
#line 990 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 0xFFFFFFFFLL ) {
			yyerror("Invalid egress vrf ID");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetEVRFID, MaskEVRFID, ( yystack.l_mark[0].value << ShiftEVRFID) & MaskEVRFID, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 48:
#line 1003 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65536 ) {
			yyerror("Invalid port");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetPortBlock, MaskPortBlockStart, ( yystack.l_mark[0].value << ShiftPortBlockStart) & MaskPortBlockStart, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 49:
#line 1016 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65536 ) {
			yyerror("Invalid port");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetPortBlock, MaskPortBlockEnd, ( yystack.l_mark[0].value << ShiftPortBlockEnd) & MaskPortBlockEnd, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 50:
#line 1029 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65536 ) {
			yyerror("Invalid port");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetPortBlock, MaskPortBlockStep, ( yystack.l_mark[0].value << ShiftPortBlockStep) & MaskPortBlockStep, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 51:
#line 1042 "grammar.y"
	{
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65536 ) {
			yyerror("Invalid port");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetPortBlock, MaskPortBlockSize, ( yystack.l_mark[0].value << ShiftPortBlockSize) & MaskPortBlockSize, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
#else
		yyerror("NAT filters not available");
		YYABORT;
#endif
	}
break;
case 52:
#line 1055 "grammar.y"
	{	
#ifdef NSEL
		if ( yystack.l_mark[0].value > 65535 ) {
			yyerror("Port outside of range 0..65535");
			YYABORT;
		}

		switch ( yystack.l_mark[-3].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetXLATEPort, MaskXLATESRCPORT, (yystack.l_mark[0].value << ShiftXLATESRCPORT) & MaskXLATESRCPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetXLATEPort, MaskXLATEDSTPORT, (yystack.l_mark[0].value << ShiftXLATEDSTPORT) & MaskXLATEDSTPORT, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End switch*/
#else
		yyerror("NEL/NAT filters not available");
		YYABORT;
#endif

	}
break;
case 53:
#line 1093 "grammar.y"
	{ 	
#ifdef NSEL
		int af, bytes, ret;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Error parsing IP address.");
			YYABORT;
		}

		/* ret == -1 will never happen here, as ALLOW_LOOKUP is set*/
		if ( ret == -2 ) {
			/* could not resolv host => 'not any'*/
			yyval.param.self = Invert(NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE, NULL )); 
		} else {
			uint64_t offsets[4] = {OffsetXLATESRCv6a, OffsetXLATESRCv6b, OffsetXLATEDSTv6a, OffsetXLATEDSTv6b };
			if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
				yyerror("incomplete IP address");
				YYABORT;
			}

			switch ( yystack.l_mark[-2].param.direction ) {
				case SOURCE:
				case DESTINATION:
					yyval.param.self = ChainHosts(offsets, IPstack, num_ip, yystack.l_mark[-2].param.direction);
					break;
				case DIR_UNSPEC:
				case SOURCE_OR_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_OR(src, dst);
					} break;
				case SOURCE_AND_DESTINATION: {
					uint32_t src = ChainHosts(offsets, IPstack, num_ip, SOURCE);
					uint32_t dst = ChainHosts(offsets, IPstack, num_ip, DESTINATION);
					yyval.param.self = Connect_AND(src, dst);
					} break;
				default:
					yyerror("This token is not expected here!");
					YYABORT;
	
			} /* End of switch*/

		}
#else
		yyerror("NSEL/ASA filters not available");
		YYABORT;
#endif
	}
break;
case 54:
#line 1144 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 0xfFFFFFFF ) {
			yyerror("AS number of range");
			YYABORT;
		}

		switch ( yystack.l_mark[-3].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetAS, MaskSrcAS, (yystack.l_mark[0].value << ShiftSrcAS) & MaskSrcAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetAS, MaskDstAS, (yystack.l_mark[0].value << ShiftDstAS) & MaskDstAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL);
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetAS, MaskSrcAS, (yystack.l_mark[0].value << ShiftSrcAS) & MaskSrcAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetAS, MaskDstAS, (yystack.l_mark[0].value << ShiftDstAS) & MaskDstAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL)
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetAS, MaskSrcAS, (yystack.l_mark[0].value << ShiftSrcAS) & MaskSrcAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL ),
					NewBlock(OffsetAS, MaskDstAS, (yystack.l_mark[0].value << ShiftDstAS) & MaskDstAS, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL)
				);
				break;
			case ADJ_PREV:
				yyval.param.self = NewBlock(OffsetBGPadj, MaskBGPadjPrev, (yystack.l_mark[0].value << ShiftBGPadjPrev) & MaskBGPadjPrev, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			case ADJ_NEXT:
				yyval.param.self = NewBlock(OffsetBGPadj, MaskBGPadjNext, (yystack.l_mark[0].value << ShiftBGPadjNext) & MaskBGPadjNext, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 55:
#line 1183 "grammar.y"
	{ 	
		struct ULongListNode *node;
		ULongtree_t *root = NULL;

		if ( yystack.l_mark[-5].param.direction == DIR_UNSPEC || yystack.l_mark[-5].param.direction == SOURCE_OR_DESTINATION || yystack.l_mark[-5].param.direction == SOURCE_AND_DESTINATION ) {
			/* src and/or dst AS*/
			/* we need a second rbtree due to different shifts for src and dst AS*/
			root = malloc(sizeof(ULongtree_t));

			struct ULongListNode *n;
			if ( root == NULL) {
				yyerror("malloc() error");
				YYABORT;
			}
			RB_INIT(root);

			RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
				if ( node->value > 0xFFFFFFFFLL ) {
					yyerror("AS number of range");
					YYABORT;
				}
				if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
					yyerror("malloc() error");
					YYABORT;
				}
				n->value 	= (node->value << ShiftDstAS) & MaskDstAS;
				node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
				RB_INSERT(ULongtree, root, n);
			}
		}

		switch ( yystack.l_mark[-5].param.direction ) {
			case SOURCE:
				RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
					node->value = (node->value << ShiftSrcAS) & MaskSrcAS;
				}
				yyval.param.self = NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DESTINATION:
				RB_FOREACH(node, ULongtree, (ULongtree_t *)yystack.l_mark[-1].list) {
					node->value = (node->value << ShiftDstAS) & MaskDstAS;
				}
				yyval.param.self = NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetAS, MaskSrcAS, 0, CMP_ULLIST, FUNC_NONE, (void *)yystack.l_mark[-1].list ),
					NewBlock(OffsetAS, MaskDstAS, 0, CMP_ULLIST, FUNC_NONE, (void *)root )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		}

	}
break;
case 56:
#line 1247 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Mask outside of range 0..255");
			YYABORT;
		}

		switch ( yystack.l_mark[-2].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetMask, MaskSrcMask, (yystack.l_mark[0].value << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetMask, MaskDstMask, (yystack.l_mark[0].value << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL );
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetMask, MaskSrcMask, (yystack.l_mark[0].value << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetMask, MaskDstMask, (yystack.l_mark[0].value << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetMask, MaskSrcMask, (yystack.l_mark[0].value << ShiftSrcMask) & MaskSrcMask, CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetMask, MaskDstMask, (yystack.l_mark[0].value << ShiftDstMask) & MaskDstMask, CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End switch*/

	}
break;
case 57:
#line 1280 "grammar.y"
	{ 
		int af, bytes, ret;
		uint64_t	mask[2];
		ret = parse_ip(&af, yystack.l_mark[-1].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		
		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/

		if ( af != PF_INET ) {
			yyerror("IP netmask syntax valid only for IPv4");
			YYABORT;
		}
		if ( bytes != 4 ) {
			yyerror("Need complete IP address");
			YYABORT;
		}

		ret = parse_ip(&af, yystack.l_mark[0].s, mask, &bytes, STRICT_IP, &num_ip);
		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/

		if ( af != PF_INET || bytes != 4 ) {
			yyerror("Invalid netmask for IPv4 address");
			YYABORT;
		}

		IPstack[0] &= mask[0];
		IPstack[1] &= mask[1];

		switch ( yystack.l_mark[-3].param.direction ) {
			case SOURCE:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					Connect_AND(
						NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);		
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					Connect_AND(
						NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);
				break;
			default:
				/* should never happen */
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 58:
#line 1370 "grammar.y"
	{ 
		int af, bytes, ret;
		uint64_t	mask[2];

		ret = parse_ip(&af, yystack.l_mark[-2].s, IPstack, &bytes, STRICT_IP, &num_ip);
		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( ret == -1 ) {
			yyerror("IP address required - hostname not allowed here.");
			YYABORT;
		}
		/* ret == -2 will never happen here, as STRICT_IP is set*/


		if ( yystack.l_mark[0].value > (bytes*8) ) {
			yyerror("Too many netbits for this IP addresss");
			YYABORT;
		}

		if ( af == PF_INET ) {
			mask[0] = 0xffffffffffffffffLL;
			mask[1] = 0xffffffffffffffffLL << ( 32 - yystack.l_mark[0].value );
		} else {	/* PF_INET6*/
			if ( yystack.l_mark[0].value > 64 ) {
				mask[0] = 0xffffffffffffffffLL;
				mask[1] = 0xffffffffffffffffLL << ( 128 - yystack.l_mark[0].value );
			} else {
				mask[0] = 0xffffffffffffffffLL << ( 64 - yystack.l_mark[0].value );
				mask[1] = 0;
			}
		}
		/* IP aadresses are stored in network representation */
		mask[0]	 = mask[0];
		mask[1]	 = mask[1];

		IPstack[0] &= mask[0];
		IPstack[1] &= mask[1];

		switch ( yystack.l_mark[-4].param.direction ) {
			case SOURCE:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
				);
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					Connect_AND(
						NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					Connect_AND(
						NewBlock(OffsetSrcIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetSrcIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					),
					Connect_AND(
						NewBlock(OffsetDstIPv6b, mask[1], IPstack[1] , CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetDstIPv6a, mask[0], IPstack[0] , CMP_EQ, FUNC_NONE, NULL )
					)
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 59:
#line 1455 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 0xffffffffLL ) {
			yyerror("Input interface number must 0..2^32");
			YYABORT;
		}

		switch ( yystack.l_mark[-2].param.direction ) {
			case DIR_UNSPEC:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetInOut, MaskInput, (yystack.l_mark[0].value << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL),
					NewBlock(OffsetInOut, MaskOutput, (yystack.l_mark[0].value << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL)
				);
				break;
			case DIR_IN: 
				yyval.param.self = NewBlock(OffsetInOut, MaskInput, (yystack.l_mark[0].value << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE, NULL); 
				break;
			case DIR_OUT: 
				yyval.param.self = NewBlock(OffsetInOut, MaskOutput, (yystack.l_mark[0].value << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL); 
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 60:
#line 1481 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > 65535 ) {
			yyerror("VLAN number of range 0..65535");
			YYABORT;
		}

		switch ( yystack.l_mark[-2].param.direction ) {
			case SOURCE:
				yyval.param.self = NewBlock(OffsetVlan, MaskSrcVlan, (yystack.l_mark[0].value << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL );
				break;
			case DESTINATION:
				yyval.param.self = NewBlock(OffsetVlan, MaskDstVlan, (yystack.l_mark[0].value << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL);
				break;
			case DIR_UNSPEC:
			case SOURCE_OR_DESTINATION:
				yyval.param.self = Connect_OR(
					NewBlock(OffsetVlan, MaskSrcVlan, (yystack.l_mark[0].value << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetVlan, MaskDstVlan, (yystack.l_mark[0].value << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
				);
				break;
			case SOURCE_AND_DESTINATION:
				yyval.param.self = Connect_AND(
					NewBlock(OffsetVlan, MaskSrcVlan, (yystack.l_mark[0].value << ShiftSrcVlan) & MaskSrcVlan, CMP_EQ, FUNC_NONE, NULL ),
					NewBlock(OffsetVlan, MaskDstVlan, (yystack.l_mark[0].value << ShiftDstVlan) & MaskDstVlan, CMP_EQ, FUNC_NONE, NULL)
				);
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/

	}
break;
case 61:
#line 1514 "grammar.y"
	{
		uint64_t	mac = VerifyMac(yystack.l_mark[0].s);
		if ( mac == 0 ) {
			yyerror("Invalid MAC address format");
			YYABORT;
		}
		switch ( yystack.l_mark[-2].param.direction ) {
			case DIR_UNSPEC: {
					uint32_t in, out;
					in  = Connect_OR(
						NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					out  = Connect_OR(
						NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					yyval.param.self = Connect_OR(in, out);
					} break;
			case DIR_IN:
					yyval.param.self = Connect_OR(
						NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					break;
			case DIR_OUT:
					yyval.param.self = Connect_OR(
						NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					break;
			case SOURCE:
					yyval.param.self = Connect_OR(
						NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					break;
			case DESTINATION:
					yyval.param.self = Connect_OR(
						NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL ),
						NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL )
					);
					break;
			case IN_SRC: 
					yyval.param.self = NewBlock(OffsetInSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
					break;
			case IN_DST: 
					yyval.param.self = NewBlock(OffsetInDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
					break;
			case OUT_SRC: 
					yyval.param.self = NewBlock(OffsetOutSrcMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
					break;
			case OUT_DST:
					yyval.param.self = NewBlock(OffsetOutDstMAC, MaskMac, mac, CMP_EQ, FUNC_NONE, NULL );
					break;
				break;
			default:
				yyerror("This token is not expected here!");
				YYABORT;
		} /* End of switch*/
	}
break;
case 62:
#line 1576 "grammar.y"
	{	
		if ( yystack.l_mark[0].value > MPLSMAX ) {
			yyerror("MPLS value out of range");
			YYABORT;
		}

		/* search for label1 - label10*/
		if ( strncasecmp(yystack.l_mark[-2].s, "label", 5) == 0 ) {
			uint64_t mask;
			uint32_t offset, shift;
			char *s = &yystack.l_mark[-2].s[5];
			if ( s == '\0' ) {
				yyerror("Missing label number");
				YYABORT;
			}
			int i = (int)strtol(s, (char **)NULL, 10);

			switch (i) {
				case 1:
					offset	= OffsetMPLS12;
					mask	= MaskMPLSlabelOdd;
					shift	= ShiftMPLSlabelOdd;
					break;
				case 2:
					offset	= OffsetMPLS12;
					mask	= MaskMPLSlabelEven;
					shift	= ShiftMPLSlabelEven;
					break;
				case 3:
					offset	= OffsetMPLS34;
					mask	= MaskMPLSlabelOdd;
					shift	= ShiftMPLSlabelOdd;
					break;
				case 4:
					offset	= OffsetMPLS34;
					mask	= MaskMPLSlabelEven;
					shift	= ShiftMPLSlabelEven;
					break;
				case 5:
					offset	= OffsetMPLS56;
					mask	= MaskMPLSlabelOdd;
					shift	= ShiftMPLSlabelOdd;
					break;
				case 6:
					offset	= OffsetMPLS56;
					mask	= MaskMPLSlabelEven;
					shift	= ShiftMPLSlabelEven;
					break;
				case 7:
					offset	= OffsetMPLS78;
					mask	= MaskMPLSlabelOdd;
					shift	= ShiftMPLSlabelOdd;
					break;
				case 8:
					offset	= OffsetMPLS78;
					mask	= MaskMPLSlabelEven;
					shift	= ShiftMPLSlabelEven;
					break;
				case 9:
					offset	= OffsetMPLS910;
					mask	= MaskMPLSlabelOdd;
					shift	= ShiftMPLSlabelOdd;
					break;
				case 10:
					offset	= OffsetMPLS910;
					mask	= MaskMPLSlabelEven;
					shift	= ShiftMPLSlabelEven;
					break;
				default: 
					yyerror("MPLS label out of range 1..10");
					YYABORT;
			}
			yyval.param.self = NewBlock(offset, mask, (yystack.l_mark[0].value << shift) & mask, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );

		} else if ( strcasecmp(yystack.l_mark[-2].s, "eos") == 0 ) {
			/* match End of Stack label */
			yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value << 4, yystack.l_mark[-1].param.comp, FUNC_MPLS_EOS, NULL );

		} else if ( strncasecmp(yystack.l_mark[-2].s, "exp", 3) == 0 ) {
			uint64_t mask;
			uint32_t offset, shift;
			char *s = &yystack.l_mark[-2].s[3];
			if ( s == '\0' ) {
				yyerror("Missing label number");
				YYABORT;
			}
			int i = (int)strtol(s, (char **)NULL, 10);

			if ( yystack.l_mark[0].value > 7 ) {
				yyerror("MPLS exp value out of range");
				YYABORT;
			}

			switch (i) {
				case 1:
					offset	= OffsetMPLS12;
					mask	= MaskMPLSexpOdd;
					shift	= ShiftMPLSexpOdd;
					break;
				case 2:
					offset	= OffsetMPLS12;
					mask	= MaskMPLSexpEven;
					shift	= ShiftMPLSexpEven;
					break;
				case 3:
					offset	= OffsetMPLS34;
					mask	= MaskMPLSexpOdd;
					shift	= ShiftMPLSexpOdd;
					break;
				case 4:
					offset	= OffsetMPLS34;
					mask	= MaskMPLSexpEven;
					shift	= ShiftMPLSexpEven;
					break;
				case 5:
					offset	= OffsetMPLS56;
					mask	= MaskMPLSexpOdd;
					shift	= ShiftMPLSexpOdd;
					break;
				case 6:
					offset	= OffsetMPLS56;
					mask	= MaskMPLSexpEven;
					shift	= ShiftMPLSexpEven;
					break;
				case 7:
					offset	= OffsetMPLS78;
					mask	= MaskMPLSexpOdd;
					shift	= ShiftMPLSexpOdd;
					break;
				case 8:
					offset	= OffsetMPLS78;
					mask	= MaskMPLSexpEven;
					shift	= ShiftMPLSexpEven;
					break;
				case 9:
					offset	= OffsetMPLS910;
					mask	= MaskMPLSexpOdd;
					shift	= ShiftMPLSexpOdd;
					break;
				case 10:
					offset	= OffsetMPLS910;
					mask	= MaskMPLSexpEven;
					shift	= ShiftMPLSexpEven;
					break;
				default: 
					yyerror("MPLS label out of range 1..10");
					YYABORT;
			}
			yyval.param.self = NewBlock(offset, mask, yystack.l_mark[0].value << shift, yystack.l_mark[-1].param.comp, FUNC_NONE, NULL );

		} else {
			yyerror("Unknown MPLS option");
			YYABORT;
		}
	}
break;
case 63:
#line 1731 "grammar.y"
	{	
		uint32_t *opt = malloc(sizeof(uint32_t));
		if ( yystack.l_mark[0].value > MPLSMAX ) {
			yyerror("MPLS value out of range");
			YYABORT;
		}
		if ( opt == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		*opt = yystack.l_mark[0].value << 4;
		yyval.param.self = NewBlock(0, AnyMask, yystack.l_mark[0].value << 4, CMP_EQ, FUNC_MPLS_ANY, opt );

	}
break;
case 64:
#line 1745 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 255 ) {
			yyerror("Forwarding status of range 0..255");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetStatus, MaskStatus, (yystack.l_mark[0].value << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
	}
break;
case 65:
#line 1753 "grammar.y"
	{
		uint64_t id = Get_fwd_status_id(yystack.l_mark[0].s);
		if (id == 256 ) {
			yyerror("Unknown forwarding status");
			YYABORT;
		}

		yyval.param.self = NewBlock(OffsetStatus, MaskStatus, (id << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);

	}
break;
case 66:
#line 1764 "grammar.y"
	{
		if ( yystack.l_mark[0].value > 2 ) {
			yyerror("Flow direction status of range 0, 1");
			YYABORT;
		}
		yyval.param.self = NewBlock(OffsetDir, MaskDir, (yystack.l_mark[0].value << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);

	}
break;
case 67:
#line 1773 "grammar.y"
	{
		uint64_t dir = 0xFF;
		if ( yystack.l_mark[0].param.inout == INGRESS )
			dir = 0;
		else if ( yystack.l_mark[0].param.inout == EGRESS )
			dir = 1;
		else {
			yyerror("Flow direction status of range ingress, egress");
			YYABORT;
		}

		yyval.param.self = NewBlock(OffsetDir, MaskDir, (dir << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);

	}
break;
case 68:
#line 1789 "grammar.y"
	{ 
		int i, af, bytes, ret;
		struct IPListNode *node;

		IPlist_t *root = malloc(sizeof(IPlist_t));

		if ( root == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		RB_INIT(root);

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		/* ret == -1 will never happen here, as ALLOW_LOOKUP is set*/
		
		if ( ret != -2 ) {
			if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
				yyerror("incomplete IP address");
				YYABORT;
			}

			for ( i=0; i<num_ip; i++ ) {
				if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
					yyerror("malloc() error");
					YYABORT;
				}
				node->ip[0] = IPstack[2*i];
				node->ip[1] = IPstack[2*i+1];
				node->mask[0] = 0xffffffffffffffffLL;
				node->mask[1] = 0xffffffffffffffffLL;
				RB_INSERT(IPtree, root, node);
			}

		}
		yyval.list = (void *)root;

	}
break;
case 69:
#line 1832 "grammar.y"
	{ 
		int af, bytes, ret;
		struct IPListNode *node;

		IPlist_t *root = malloc(sizeof(IPlist_t));

		if ( root == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		RB_INIT(root);

		ret = parse_ip(&af, yystack.l_mark[-2].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		/* ret == -1 will never happen here, as ALLOW_LOOKUP is set*/
		
		if ( ret != -2 ) {
			if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
				yyerror("incomplete IP address");
				YYABORT;
			}

			if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
				yyerror("malloc() error");
				YYABORT;
			}

			if ( af == PF_INET ) {
				node->mask[0] = 0xffffffffffffffffLL;
				node->mask[1] = 0xffffffffffffffffLL << ( 32 - yystack.l_mark[0].value );
			} else {	/* PF_INET6*/
				if ( yystack.l_mark[0].value > 64 ) {
					node->mask[0] = 0xffffffffffffffffLL;
					node->mask[1] = 0xffffffffffffffffLL << ( 128 - yystack.l_mark[0].value );
				} else {
					node->mask[0] = 0xffffffffffffffffLL << ( 64 - yystack.l_mark[0].value );
					node->mask[1] = 0;
				}
			}

			node->ip[0] = IPstack[0] & node->mask[0];
			node->ip[1] = IPstack[1] & node->mask[1];

			RB_INSERT(IPtree, root, node);

		}
		yyval.list = (void *)root;

	}
break;
case 70:
#line 1886 "grammar.y"
	{ 
		int i, af, bytes, ret;
		struct IPListNode *node;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		/* ret == - 2 means lookup failure*/
		if ( ret != -2 ) {
			for ( i=0; i<num_ip; i++ ) {
				if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
					yyerror("malloc() error");
					YYABORT;
				}
				node->ip[0] = IPstack[2*i];
				node->ip[1] = IPstack[2*i+1];
				node->mask[0] = 0xffffffffffffffffLL;
				node->mask[1] = 0xffffffffffffffffLL;
	
				RB_INSERT(IPtree, (IPlist_t *)yyval.list, node);
			}
		}
	}
break;
case 71:
#line 1917 "grammar.y"
	{ 
		int i, af, bytes, ret;
		struct IPListNode *node;

		ret = parse_ip(&af, yystack.l_mark[0].s, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		/* ret == - 2 means lookup failure*/
		if ( ret != -2 ) {
			for ( i=0; i<num_ip; i++ ) {
				if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
					yyerror("malloc() error");
					YYABORT;
				}
				node->ip[0] = IPstack[2*i];
				node->ip[1] = IPstack[2*i+1];
				node->mask[0] = 0xffffffffffffffffLL;
				node->mask[1] = 0xffffffffffffffffLL;
	
				RB_INSERT(IPtree, (IPlist_t *)yyval.list, node);
			}
		}
	}
break;
case 72:
#line 1949 "grammar.y"
	{ 
		int af, bytes, ret;
		struct IPListNode *node;

		ret = parse_ip(&af, yystack.l_mark[-2].s, IPstack, &bytes, STRICT_IP, &num_ip);

		if ( ret == 0 ) {
			yyerror("Invalid IP address");
			YYABORT;
		}
		if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
			yyerror("incomplete IP address");
			YYABORT;
		}

		/* ret == - 2 means lookup failure*/
		if ( ret != -2 ) {
			if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
				yyerror("malloc() error");
				YYABORT;
			}
			if ( af == PF_INET ) {
				node->mask[0] = 0xffffffffffffffffLL;
				node->mask[1] = 0xffffffffffffffffLL << ( 32 - yystack.l_mark[0].value );
			} else {	/* PF_INET6*/
				if ( yystack.l_mark[0].value > 64 ) {
					node->mask[0] = 0xffffffffffffffffLL;
					node->mask[1] = 0xffffffffffffffffLL << ( 128 - yystack.l_mark[0].value );
				} else {
					node->mask[0] = 0xffffffffffffffffLL << ( 64 - yystack.l_mark[0].value );
					node->mask[1] = 0;
				}
			}

			node->ip[0] = IPstack[0] & node->mask[0];
			node->ip[1] = IPstack[1] & node->mask[1];

			RB_INSERT(IPtree, (IPlist_t *)yyval.list, node);
		}
	}
break;
case 73:
#line 1993 "grammar.y"
	{ 
		struct ULongListNode *node;

		ULongtree_t *root = malloc(sizeof(ULongtree_t));

		if ( root == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		RB_INIT(root);

		if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		node->value = yystack.l_mark[0].value;

		RB_INSERT(ULongtree, root, node);
		yyval.list = (void *)root;
	}
break;
case 74:
#line 2014 "grammar.y"
	{ 
		struct ULongListNode *node;

		if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		node->value = yystack.l_mark[0].value;
		RB_INSERT(ULongtree, (ULongtree_t *)yyval.list, node);
	}
break;
case 75:
#line 2025 "grammar.y"
	{ 
		struct ULongListNode *node;

		if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
			yyerror("malloc() error");
			YYABORT;
		}
		node->value = yystack.l_mark[0].value;
		RB_INSERT(ULongtree, (ULongtree_t *)yyval.list, node);
	}
break;
case 76:
#line 2039 "grammar.y"
	{ yyval.param.comp = CMP_EQ; }
break;
case 77:
#line 2040 "grammar.y"
	{ yyval.param.comp = CMP_EQ; }
break;
case 78:
#line 2041 "grammar.y"
	{ yyval.param.comp = CMP_LT; }
break;
case 79:
#line 2042 "grammar.y"
	{ yyval.param.comp = CMP_GT; }
break;
case 80:
#line 2046 "grammar.y"
	{ yyval.param.direction = DIR_UNSPEC;  			 }
break;
case 81:
#line 2047 "grammar.y"
	{ yyval.param.direction = SOURCE;				 }
break;
case 82:
#line 2048 "grammar.y"
	{ yyval.param.direction = DESTINATION;			 }
break;
case 83:
#line 2049 "grammar.y"
	{ yyval.param.direction = SOURCE_OR_DESTINATION;  }
break;
case 84:
#line 2050 "grammar.y"
	{ yyval.param.direction = SOURCE_OR_DESTINATION;  }
break;
case 85:
#line 2051 "grammar.y"
	{ yyval.param.direction = SOURCE_AND_DESTINATION; }
break;
case 86:
#line 2052 "grammar.y"
	{ yyval.param.direction = SOURCE_AND_DESTINATION; }
break;
case 87:
#line 2053 "grammar.y"
	{ yyval.param.direction = DIR_IN;				 }
break;
case 88:
#line 2054 "grammar.y"
	{ yyval.param.direction = DIR_OUT;				 }
break;
case 89:
#line 2055 "grammar.y"
	{ yyval.param.direction = IN_SRC;				 }
break;
case 90:
#line 2056 "grammar.y"
	{ yyval.param.direction = IN_DST;				 }
break;
case 91:
#line 2057 "grammar.y"
	{ yyval.param.direction = OUT_SRC;				 }
break;
case 92:
#line 2058 "grammar.y"
	{ yyval.param.direction = OUT_DST;				 }
break;
case 93:
#line 2059 "grammar.y"
	{ yyval.param.direction = ADJ_PREV;				 }
break;
case 94:
#line 2060 "grammar.y"
	{ yyval.param.direction = ADJ_NEXT;				 }
break;
case 95:
#line 2063 "grammar.y"
	{ yyval.param.inout	= INGRESS;	}
break;
case 96:
#line 2064 "grammar.y"
	{ yyval.param.inout	= EGRESS;   }
break;
case 97:
#line 2067 "grammar.y"
	{ yyval.param.acl = ACL; 	}
break;
case 98:
#line 2068 "grammar.y"
	{ yyval.param.acl = ACE;		}
break;
case 99:
#line 2069 "grammar.y"
	{ yyval.param.acl = XACE;	}
break;
case 100:
#line 2072 "grammar.y"
	{ yyval.value = yystack.l_mark[0].param.self;        }
break;
case 101:
#line 2073 "grammar.y"
	{ yyval.value = Connect_OR(yystack.l_mark[-2].value, yystack.l_mark[0].value);  }
break;
case 102:
#line 2074 "grammar.y"
	{ yyval.value = Connect_AND(yystack.l_mark[-2].value, yystack.l_mark[0].value); }
break;
case 103:
#line 2075 "grammar.y"
	{ yyval.value = Invert(yystack.l_mark[0].value);			}
break;
case 104:
#line 2076 "grammar.y"
	{ yyval.value = yystack.l_mark[-1].value; }
break;
#line 3745 "grammar.c"
    default:
        break;
    }
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark -= yym;
#endif
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
        {
            fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
            if (!yytrial)
#endif /* YYBTYACC */
                fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
#endif
            fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
        }
#endif
        yystate = YYFINAL;
        *++yystack.s_mark = YYFINAL;
        *++yystack.l_mark = yyval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        *++yystack.p_mark = yyloc;
#endif
        if (yychar < 0)
        {
#if YYBTYACC
            do {
            if (yylvp < yylve)
            {
                /* we're currently re-reading tokens */
                yylval = *yylvp++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                yylloc = *yylpp++;
#endif
                yychar = *yylexp++;
                break;
            }
            if (yyps->save)
            {
                /* in trial mode; save scanner results for future parse attempts */
                if (yylvp == yylvlim)
                {   /* Enlarge lexical value queue */
                    size_t p = (size_t) (yylvp - yylvals);
                    size_t s = (size_t) (yylvlim - yylvals);

                    s += YYLVQUEUEGROWTH;
                    if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
                        goto yyenomem;
                    if ((yylvals   = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
                        goto yyenomem;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    if ((yylpsns   = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
                        goto yyenomem;
#endif
                    yylvp   = yylve = yylvals + p;
                    yylvlim = yylvals + s;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                    yylpp   = yylpe = yylpsns + p;
                    yylplim = yylpsns + s;
#endif
                    yylexp  = yylexemes + p;
                }
                *yylexp = (YYINT) YYLEX;
                *yylvp++ = yylval;
                yylve++;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
                *yylpp++ = yylloc;
                yylpe++;
#endif
                yychar = *yylexp++;
                break;
            }
            /* normal operation, no conflict encountered */
#endif /* YYBTYACC */
            yychar = YYLEX;
#if YYBTYACC
            } while (0);
#endif /* YYBTYACC */
            if (yychar < 0) yychar = YYEOF;
#if YYDEBUG
            if (yydebug)
            {
                if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
                fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
                                YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
            }
#endif
        }
        if (yychar == YYEOF) goto yyaccept;
        goto yyloop;
    }
    if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
    {
        fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
#ifdef YYSTYPE_TOSTRING
#if YYBTYACC
        if (!yytrial)
#endif /* YYBTYACC */
            fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
#endif
        fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
    }
#endif
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    *++yystack.s_mark = (YYINT) yystate;
    *++yystack.l_mark = yyval;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    *++yystack.p_mark = yyloc;
#endif
    goto yyloop;
#if YYBTYACC

    /* Reduction declares that this path is valid. Set yypath and do a full parse */
yyvalid:
    if (yypath) YYABORT;
    while (yyps->save)
    {
        YYParseState *save = yyps->save;
        yyps->save = save->save;
        save->save = yypath;
        yypath = save;
    }
#if YYDEBUG
    if (yydebug)
        fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
                        YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
#endif
    if (yyerrctx)
    {
        yyFreeState(yyerrctx);
        yyerrctx = NULL;
    }
    yylvp          = yylvals + yypath->lexeme;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yylpp          = yylpsns + yypath->lexeme;
#endif
    yylexp         = yylexemes + yypath->lexeme;
    yychar         = YYEMPTY;
    yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
    memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
    yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
    memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
    yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
    memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
#endif
    yystate        = yypath->state;
    goto yyloop;
#endif /* YYBTYACC */

yyoverflow:
    YYERROR_CALL("yacc stack overflow");
#if YYBTYACC
    goto yyabort_nomem;
yyenomem:
    YYERROR_CALL("memory exhausted");
yyabort_nomem:
#endif /* YYBTYACC */
    yyresult = 2;
    goto yyreturn;

yyabort:
    yyresult = 1;
    goto yyreturn;

yyaccept:
#if YYBTYACC
    if (yyps->save) goto yyvalid;
#endif /* YYBTYACC */
    yyresult = 0;

yyreturn:
#if defined(YYDESTRUCT_CALL)
    if (yychar != YYEOF && yychar != YYEMPTY)
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
#else
        YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */

    {
        YYSTYPE *pv;
#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
        YYLTYPE *pp;

        for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
             YYDESTRUCT_CALL("cleanup: discarding state",
                             yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
#else
        for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
             YYDESTRUCT_CALL("cleanup: discarding state",
                             yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
    }
#endif /* defined(YYDESTRUCT_CALL) */

#if YYBTYACC
    if (yyerrctx)
    {
        yyFreeState(yyerrctx);
        yyerrctx = NULL;
    }
    while (yyps)
    {
        YYParseState *save = yyps;
        yyps = save->save;
        save->save = NULL;
        yyFreeState(save);
    }
    while (yypath)
    {
        YYParseState *save = yypath;
        yypath = save->save;
        save->save = NULL;
        yyFreeState(save);
    }
#endif /* YYBTYACC */
    yyfreestack(&yystack);
    return (yyresult);
}
