Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1481 lines (1312 sloc) 38.9 KB
--- nfdump-1.6.13/bin/scanner.l 2014-02-16 13:59:29.000000000 +0100
+++ nfdump/bin/scanner.l 2015-03-07 22:36:44.150338300 +0100
@@ -39,6 +39,7 @@
*/
%x incl
+%option reentrant bison-bridge
%{
@@ -60,16 +61,16 @@
#include "nfdump.h"
#include "grammar.h"
-extern char yyerror_buff[256];
+extern __thread char yyerror_buff[256];
-int lineno = 1;
+int __thread lineno = 1;
#ifdef FLEX_SCANNER
#define YY_NO_UNPUT
static YY_BUFFER_STATE in_buffer;
#else
-static char *in_buffer;
+static __thread char *in_buffer;
#undef getc
#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
@@ -83,9 +84,9 @@
int lineno;
} include_stack_info[MAX_INCLUDE_DEPTH];
-int include_stack_ptr = 0;
+int __thread include_stack_ptr = 0;
-char *FilterFilename = NULL;;
+char __thread *FilterFilename = NULL;;
%}
@@ -97,12 +98,12 @@
@include BEGIN(incl);
[0-9]+ {
- yylval.value = (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = (uint64_t) strtoull(yytext,NULL,10);
return NUMBER;
}
(0X|0x)[0-9A-Fa-f]+ {
- yylval.value = (uint64_t) strtoull(yytext,NULL,16);
+ yylval->value = (uint64_t) strtoull(yytext,NULL,16);
return NUMBER;
}
@@ -110,19 +111,19 @@
size_t len = strlen(yytext);
switch (yytext[len-1]) {
case 'k':
- yylval.value = 1000LL * (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = 1000LL * (uint64_t) strtoull(yytext,NULL,10);
break;
case 'm':
- yylval.value = 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
break;
case 'g':
- yylval.value = 1000LL * 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = 1000LL * 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
break;
case 't':
- yylval.value = 1000LL * 1000LL * 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = 1000LL * 1000LL * 1000LL * 1000LL * (uint64_t) strtoull(yytext,NULL,10);
break;
default:
- yylval.value = (uint64_t) strtoull(yytext,NULL,10);
+ yylval->value = (uint64_t) strtoull(yytext,NULL,10);
}
return NUMBER;
}
@@ -178,7 +179,7 @@
asa { return ASA; /* NSEL filter */ }
event { return EVENT; /* NEL/NSEL filter */ }
ignore|invalid|create|add|term|delete|deny { /* NSEL filter */
- yylval.s = strdup(yytext);
+ yylval->s = strdup(yytext);
return REASON;
}
denied { return DENIED; /* NSEL filter */ }
@@ -208,7 +209,7 @@
[ \t] { ; }
[a-zA-Z0-9_:\.\-]+ {
- yylval.s = strdup(yytext);
+ yylval->s = strdup(yytext);
return STRING;
}
\n { lineno++; }
@@ -236,7 +237,7 @@
}
FilterFilename = strdup(yytext);
- yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE ) );
+ yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner ), yyscanner );
BEGIN(INITIAL);
}
@@ -248,8 +249,8 @@
if ( include_stack_info[include_stack_ptr].name )
free(include_stack_info[include_stack_ptr].name);
include_stack_ptr--;
- yy_delete_buffer( YY_CURRENT_BUFFER );
- yy_switch_to_buffer( include_stack[include_stack_ptr] );
+ yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
+ yy_switch_to_buffer( include_stack[include_stack_ptr], yyscanner );
lineno = include_stack_info[include_stack_ptr].lineno;
FilterFilename = include_stack_info[include_stack_ptr].name;
}
@@ -257,9 +258,9 @@
%%
-void lex_init(char *buf) {
+void lex_init(char *buf, yyscan_t yyscanner) {
#ifdef FLEX_SCANNER
- in_buffer = yy_scan_string(buf);
+ in_buffer = yy_scan_string(buf, yyscanner);
#else
in_buffer = buf;
#endif
@@ -270,15 +271,15 @@
/*
* Do any cleanup necessary after parsing.
*/
-void lex_cleanup(void) {
+void lex_cleanup(yyscan_t yyscanner) {
#ifdef FLEX_SCANNER
if (in_buffer != NULL)
- yy_delete_buffer(in_buffer);
+ yy_delete_buffer(in_buffer, yyscanner);
in_buffer = NULL;
#endif
}
-int yywrap(void) {
+int yywrap(yyscan_t yyscanner) {
return 1;
}
--- nfdump-1.6.13/bin/grammar.y 2014-11-23 17:38:07.000000000 +0100
+++ nfdump/bin/grammar.y 2015-03-07 22:37:42.632192628 +0100
@@ -39,6 +39,16 @@
*/
%{
+#define YYPARSE_PARAM scanner
+//#define YYLEX_PARAM scanner
+%}
+
+%pure-parser
+%lex-param { void *scanner }
+%parse-param { void *scanner }
+
+%{
+
#include "config.h"
@@ -66,11 +76,12 @@
/*
* function prototypes
*/
-static void yyerror(char *msg);
+static void yyerror(void * scanner, char *msg);
+char *yyget_text(void * scanner );
static uint32_t ChainHosts(uint64_t *offsets, uint64_t *hostlist, int num_records, int type);
-static uint64_t VerifyMac(char *s);
+static uint64_t VerifyMac(void * scanner, char *s);
enum { DIR_UNSPEC = 1,
SOURCE, DESTINATION, SOURCE_AND_DESTINATION, SOURCE_OR_DESTINATION,
@@ -81,17 +92,19 @@
enum { IS_START = 0, IS_END };
/* var defs */
-extern int lineno;
-extern char *yytext;
+extern __thread int lineno;
+extern __thread char *yytext;
+//extern __thread uint64_t *IPstack;
extern uint64_t *IPstack;
+//extern __thread uint32_t StartNode;
extern uint32_t StartNode;
-extern uint16_t Extended;
-extern int (*FilterEngine)(uint32_t *);
-extern char *FilterFilename;
+extern __thread uint16_t Extended;
+extern __thread int (*FilterEngine)(uint32_t *);
+extern __thread char *FilterFilename;
-static uint32_t num_ip;
+static __thread uint32_t num_ip;
-char yyerror_buff[256];
+char __thread yyerror_buff[256];
#define MPLSMAX 0x00ffffff
%}
@@ -133,7 +146,7 @@
| IDENT STRING {
if ( !ScreenIdentString($2) ) {
- yyerror("Illegal ident string");
+ yyerror(scanner, "Illegal ident string");
YYABORT;
}
@@ -156,11 +169,11 @@
proto = $2;
if ( proto > 255 ) {
- yyerror("Protocol number > 255");
+ yyerror(scanner, "Protocol number > 255");
YYABORT;
}
if ( proto < 0 ) {
- yyerror("Unknown protocol");
+ yyerror(scanner, "Unknown protocol");
YYABORT;
}
$$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
@@ -172,11 +185,11 @@
proto = Proto_num($2);
if ( proto > 255 ) {
- yyerror("Protocol number > 255");
+ yyerror(scanner, "Protocol number > 255");
YYABORT;
}
if ( proto < 0 ) {
- yyerror("Unknown protocol");
+ yyerror(scanner, "Unknown protocol");
YYABORT;
}
$$.self = NewBlock(OffsetProto, MaskProto, (proto << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE, NULL);
@@ -194,7 +207,7 @@
break;
default:
/* should never happen */
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -211,7 +224,7 @@
$$.self = NewBlock(OffsetOutBytes, MaskBytes, $4, $3.comp, FUNC_NONE, NULL);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -239,7 +252,7 @@
| dqual TOS comp NUMBER {
if ( $4 > 255 ) {
- yyerror("TOS must be 0..255");
+ yyerror(scanner, "TOS must be 0..255");
YYABORT;
}
@@ -264,14 +277,14 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
}
}
| FLAGS comp NUMBER {
if ( $3 > 63 ) {
- yyerror("Flags must be 0..63");
+ yyerror(scanner, "Flags must be 0..63");
YYABORT;
}
$$.self = NewBlock(OffsetFlags, MaskFlags, ($3 << ShiftFlags) & MaskFlags, $2.comp, FUNC_NONE, NULL);
@@ -283,7 +296,7 @@
size_t len = strlen($2);
if ( len > 7 ) {
- yyerror("Too many flags");
+ yyerror(scanner, "Too many flags");
YYABORT;
}
@@ -296,7 +309,7 @@
if ( strchr($2, 'X') ) { fl = 63; cnt++; }
if ( cnt != len ) {
- yyerror("Too many flags");
+ yyerror(scanner, "Too many flags");
YYABORT;
}
@@ -310,7 +323,7 @@
ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
@@ -321,7 +334,7 @@
} 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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -342,7 +355,7 @@
$$.self = Connect_AND(src, dst);
} break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -373,7 +386,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
}
}
@@ -384,18 +397,18 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -417,18 +430,18 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -444,18 +457,18 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -479,7 +492,7 @@
| SYSID NUMBER {
if ( $2 > 255 ) {
- yyerror("Router SysID expected between be 1..255");
+ yyerror(scanner, "Router SysID expected between be 1..255");
YYABORT;
}
$$.self = NewBlock(OffsetExporterSysID, MaskExporterSysID, ($2 << ShiftExporterSysID) & MaskExporterSysID, CMP_EQ, FUNC_NONE, NULL);
@@ -487,7 +500,7 @@
| dqual PORT comp NUMBER {
if ( $4 > 65535 ) {
- yyerror("Port outside of range 0..65535");
+ yyerror(scanner, "Port outside of range 0..65535");
YYABORT;
}
@@ -512,7 +525,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End switch
@@ -535,12 +548,12 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End switch
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -556,18 +569,18 @@
struct ULongListNode *n;
if ( root == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
RB_INIT(root);
RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
if ( node->value > 65535 ) {
- yyerror("Port outside of range 0..65535");
+ yyerror(scanner, "Port outside of range 0..65535");
YYABORT;
}
if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
n->value = (node->value << ShiftDstPort) & MaskDstPort;
@@ -603,7 +616,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -611,7 +624,7 @@
| ICMP_TYPE NUMBER {
if ( $2 > 255 ) {
- yyerror("ICMP tpye of range 0..15");
+ yyerror(scanner, "ICMP tpye of range 0..15");
YYABORT;
}
$$.self = Connect_AND(
@@ -627,7 +640,7 @@
| ICMP_CODE NUMBER {
if ( $2 > 255 ) {
- yyerror("ICMP code of range 0..15");
+ yyerror(scanner, "ICMP code of range 0..15");
YYABORT;
}
$$.self = Connect_AND(
@@ -643,7 +656,7 @@
| ENGINE_TYPE comp NUMBER {
if ( $3 > 255 ) {
- yyerror("Engine type of range 0..255");
+ yyerror(scanner, "Engine type of range 0..255");
YYABORT;
}
$$.self = NewBlock(OffsetRouterID, MaskEngineType, ($3 << ShiftEngineType) & MaskEngineType, $2.comp, FUNC_NONE, NULL);
@@ -652,7 +665,7 @@
| ENGINE_ID comp NUMBER {
if ( $3 > 255 ) {
- yyerror("Engine ID of range 0..255");
+ yyerror(scanner, "Engine ID of range 0..255");
YYABORT;
}
$$.self = NewBlock(OffsetRouterID, MaskEngineID, ($3 << ShiftEngineID) & MaskEngineID, $2.comp, FUNC_NONE, NULL);
@@ -674,11 +687,11 @@
} else if (strncasecmp($3,"update", 6) == 0) {
$$.self = NewBlock(OffsetConnID, MaskFWevent, ( NSEL_EVENT_UPDATE << ShiftFWevent) & MaskFWevent, CMP_EQ, FUNC_NONE, NULL );
} else {
- yyerror("Unknown asa event");
+ yyerror(scanner, "Unknown asa event");
YYABORT;
}
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -686,12 +699,12 @@
| ASA EVENT comp NUMBER {
#ifdef NSEL
if ( $4 > 255 ) {
- yyerror("Invalid xevent ID");
+ yyerror(scanner, "Invalid xevent ID");
YYABORT;
}
$$.self = NewBlock(OffsetConnID, MaskFWevent, ( $4 << ShiftFWevent) & MaskFWevent, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -704,7 +717,7 @@
} else if ( $4.inout == EGRESS ) {
xevent = 1002;
} else {
- yyerror("Invalid inout token");
+ yyerror(scanner, "Invalid inout token");
YYABORT;
}
$$.self = Connect_AND(
@@ -712,7 +725,7 @@
NewBlock(OffsetConnID, MaskFWXevent, ( xevent << ShiftFWXevent) & MaskFWXevent, CMP_EQ, FUNC_NONE, NULL )
);
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -726,7 +739,7 @@
} else {
xevent = (uint64_t)strtol($4, (char **)NULL, 10);
if ( (xevent == 0 && errno == EINVAL) || xevent > 65535 ) {
- yyerror("Invalid xevent ID");
+ yyerror(scanner, "Invalid xevent ID");
YYABORT;
}
}
@@ -735,7 +748,7 @@
NewBlock(OffsetConnID, MaskFWXevent, ( xevent << ShiftFWXevent) & MaskFWXevent, CMP_EQ, FUNC_NONE, NULL )
);
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -743,12 +756,12 @@
| ASA XEVENT comp NUMBER {
#ifdef NSEL
if ( $4 > 65535 ) {
- yyerror("Invalid xevent ID");
+ yyerror(scanner, "Invalid xevent ID");
YYABORT;
}
$$.self = NewBlock(OffsetConnID, MaskFWXevent, ( $4 << ShiftFWXevent) & MaskFWXevent, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -760,7 +773,7 @@
ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
@@ -771,7 +784,7 @@
} 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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -792,14 +805,14 @@
$$.self = Connect_AND(src, dst);
} break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
}
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -811,18 +824,18 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "IP address required - hostname not allowed here.");
YYABORT;
}
// ret == -2 will never happen here, as STRICT_IP is set
if ( $5 > (bytes*8) ) {
- yyerror("Too many netbits for this IP addresss");
+ yyerror(scanner, "Too many netbits for this IP addresss");
YYABORT;
}
@@ -884,12 +897,12 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -897,7 +910,7 @@
| dqual XPORT comp NUMBER {
#ifdef NSEL
if ( $4 > 65535 ) {
- yyerror("Port outside of range 0..65535");
+ yyerror(scanner, "Port outside of range 0..65535");
YYABORT;
}
@@ -922,11 +935,11 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End switch
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
@@ -953,7 +966,7 @@
shift = ShiftIngressGrpId;
break;
default:
- yyerror("Invalid ACL specifier");
+ yyerror(scanner, "Invalid ACL specifier");
YYABORT;
}
} else if ( $1.inout == EGRESS && $$.acl == ACL ) {
@@ -961,13 +974,13 @@
mask = MaskEgressAclId;
shift = ShiftEgressAclId;
} else {
- yyerror("ingress/egress syntax error");
+ yyerror(scanner, "ingress/egress syntax error");
YYABORT;
}
$$.self = NewBlock(offset, mask, ($4 << shift) & mask , $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
@@ -981,11 +994,11 @@
} else if( strncasecmp($3,"delete", 6) == 0) {
$$.self = NewBlock(OffsetNATevent, MasNATevent, ( NEL_EVENT_DELETE << ShiftNATevent) & MasNATevent, CMP_EQ, FUNC_NONE, NULL );
} else {
- yyerror("Unknown nat event");
+ yyerror(scanner, "Unknown nat event");
YYABORT;
}
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -993,12 +1006,12 @@
| NAT EVENT comp NUMBER {
#ifdef NSEL
if ( $4 > 255 ) {
- yyerror("Invalid event ID");
+ yyerror(scanner, "Invalid event ID");
YYABORT;
}
$$.self = NewBlock(OffsetNATevent, MasNATevent, ( $4 << ShiftNATevent) & MasNATevent, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1006,12 +1019,12 @@
| INGRESS VRF comp NUMBER {
#ifdef NSEL
if ( $4 > 0xFFFFFFFFLL ) {
- yyerror("Invalid ingress vrf ID");
+ yyerror(scanner, "Invalid ingress vrf ID");
YYABORT;
}
$$.self = NewBlock(OffsetIVRFID, MaskIVRFID, ( $4 << ShiftIVRFID) & MaskIVRFID, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1019,12 +1032,12 @@
| EGRESS VRF comp NUMBER {
#ifdef NSEL
if ( $4 > 0xFFFFFFFFLL ) {
- yyerror("Invalid egress vrf ID");
+ yyerror(scanner, "Invalid egress vrf ID");
YYABORT;
}
$$.self = NewBlock(OffsetEVRFID, MaskEVRFID, ( $4 << ShiftEVRFID) & MaskEVRFID, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1032,12 +1045,12 @@
| PBLOCK START comp NUMBER {
#ifdef NSEL
if ( $4 > 65536 ) {
- yyerror("Invalid port");
+ yyerror(scanner, "Invalid port");
YYABORT;
}
$$.self = NewBlock(OffsetPortBlock, MaskPortBlockStart, ( $4 << ShiftPortBlockStart) & MaskPortBlockStart, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1045,12 +1058,12 @@
| PBLOCK END comp NUMBER {
#ifdef NSEL
if ( $4 > 65536 ) {
- yyerror("Invalid port");
+ yyerror(scanner, "Invalid port");
YYABORT;
}
$$.self = NewBlock(OffsetPortBlock, MaskPortBlockEnd, ( $4 << ShiftPortBlockEnd) & MaskPortBlockEnd, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1058,12 +1071,12 @@
| PBLOCK STEP comp NUMBER {
#ifdef NSEL
if ( $4 > 65536 ) {
- yyerror("Invalid port");
+ yyerror(scanner, "Invalid port");
YYABORT;
}
$$.self = NewBlock(OffsetPortBlock, MaskPortBlockStep, ( $4 << ShiftPortBlockStep) & MaskPortBlockStep, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1071,12 +1084,12 @@
| PBLOCK SIZE comp NUMBER {
#ifdef NSEL
if ( $4 > 65536 ) {
- yyerror("Invalid port");
+ yyerror(scanner, "Invalid port");
YYABORT;
}
$$.self = NewBlock(OffsetPortBlock, MaskPortBlockSize, ( $4 << ShiftPortBlockSize) & MaskPortBlockSize, $3.comp, FUNC_NONE, NULL );
#else
- yyerror("NAT filters not available");
+ yyerror(scanner, "NAT filters not available");
YYABORT;
#endif
}
@@ -1084,7 +1097,7 @@
| dqual NPORT comp NUMBER {
#ifdef NSEL
if ( $4 > 65535 ) {
- yyerror("Port outside of range 0..65535");
+ yyerror(scanner, "Port outside of range 0..65535");
YYABORT;
}
@@ -1109,11 +1122,11 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End switch
#else
- yyerror("NEL/NAT filters not available");
+ yyerror(scanner, "NEL/NAT filters not available");
YYABORT;
#endif
@@ -1126,7 +1139,7 @@
ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Error parsing IP address.");
+ yyerror(scanner, "Error parsing IP address.");
YYABORT;
}
@@ -1137,7 +1150,7 @@
} 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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -1158,21 +1171,21 @@
$$.self = Connect_AND(src, dst);
} break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
}
#else
- yyerror("NSEL/ASA filters not available");
+ yyerror(scanner, "NSEL/ASA filters not available");
YYABORT;
#endif
}
| dqual AS comp NUMBER {
if ( $4 > 0xfFFFFFFF ) {
- yyerror("AS number of range");
+ yyerror(scanner, "AS number of range");
YYABORT;
}
@@ -1203,7 +1216,7 @@
$$.self = NewBlock(OffsetBGPadj, MaskBGPadjNext, ($4 << ShiftBGPadjNext) & MaskBGPadjNext, $3.comp, FUNC_NONE, NULL );
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -1220,18 +1233,18 @@
struct ULongListNode *n;
if ( root == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
RB_INIT(root);
RB_FOREACH(node, ULongtree, (ULongtree_t *)$5) {
if ( node->value > 0xFFFFFFFFLL ) {
- yyerror("AS number of range");
+ yyerror(scanner, "AS number of range");
YYABORT;
}
if ((n = malloc(sizeof(struct ULongListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
n->value = (node->value << ShiftDstAS) & MaskDstAS;
@@ -1267,7 +1280,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
}
@@ -1275,7 +1288,7 @@
| dqual MASK NUMBER {
if ( $3 > 255 ) {
- yyerror("Mask outside of range 0..255");
+ yyerror(scanner, "Mask outside of range 0..255");
YYABORT;
}
@@ -1300,7 +1313,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End switch
@@ -1312,38 +1325,38 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "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");
+ yyerror(scanner, "IP netmask syntax valid only for IPv4");
YYABORT;
}
if ( bytes != 4 ) {
- yyerror("Need complete IP address");
+ yyerror(scanner, "Need complete IP address");
YYABORT;
}
ret = parse_ip(&af, $4, mask, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "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");
+ yyerror(scanner, "Invalid netmask for IPv4 address");
YYABORT;
}
@@ -1390,7 +1403,7 @@
break;
default:
/* should never happen */
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -1402,18 +1415,18 @@
ret = parse_ip(&af, $3, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( ret == -1 ) {
- yyerror("IP address required - hostname not allowed here.");
+ yyerror(scanner, "IP address required - hostname not allowed here.");
YYABORT;
}
// ret == -2 will never happen here, as STRICT_IP is set
if ( $5 > (bytes*8) ) {
- yyerror("Too many netbits for this IP addresss");
+ yyerror(scanner, "Too many netbits for this IP addresss");
YYABORT;
}
@@ -1475,7 +1488,7 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -1483,7 +1496,7 @@
| dqual IF NUMBER {
if ( $3 > 0xffffffffLL ) {
- yyerror("Input interface number must 0..2^32");
+ yyerror(scanner, "Input interface number must 0..2^32");
YYABORT;
}
@@ -1501,7 +1514,7 @@
$$.self = NewBlock(OffsetInOut, MaskOutput, ($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE, NULL);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
@@ -1509,7 +1522,7 @@
| dqual VLAN NUMBER {
if ( $3 > 65535 ) {
- yyerror("VLAN number of range 0..65535");
+ yyerror(scanner, "VLAN number of range 0..65535");
YYABORT;
}
@@ -1534,16 +1547,16 @@
);
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
}
| dqual MAC STRING {
- uint64_t mac = VerifyMac($3);
+ uint64_t mac = VerifyMac(scanner, $3);
if ( mac == 0 ) {
- yyerror("Invalid MAC address format");
+ yyerror(scanner, "Invalid MAC address format");
YYABORT;
}
switch ( $1.direction ) {
@@ -1597,14 +1610,14 @@
break;
break;
default:
- yyerror("This token is not expected here!");
+ yyerror(scanner, "This token is not expected here!");
YYABORT;
} // End of switch
}
| MPLS STRING comp NUMBER {
if ( $4 > MPLSMAX ) {
- yyerror("MPLS value out of range");
+ yyerror(scanner, "MPLS value out of range");
YYABORT;
}
@@ -1614,7 +1627,7 @@
uint32_t offset, shift;
char *s = &$2[5];
if ( s == '\0' ) {
- yyerror("Missing label number");
+ yyerror(scanner, "Missing label number");
YYABORT;
}
int i = (int)strtol(s, (char **)NULL, 10);
@@ -1671,7 +1684,7 @@
shift = ShiftMPLSlabelEven;
break;
default:
- yyerror("MPLS label out of range 1..10");
+ yyerror(scanner, "MPLS label out of range 1..10");
YYABORT;
}
$$.self = NewBlock(offset, mask, ($4 << shift) & mask, $3.comp, FUNC_NONE, NULL );
@@ -1685,13 +1698,13 @@
uint32_t offset, shift;
char *s = &$2[3];
if ( s == '\0' ) {
- yyerror("Missing label number");
+ yyerror(scanner, "Missing label number");
YYABORT;
}
int i = (int)strtol(s, (char **)NULL, 10);
if ( $4 > 7 ) {
- yyerror("MPLS exp value out of range");
+ yyerror(scanner, "MPLS exp value out of range");
YYABORT;
}
@@ -1747,24 +1760,24 @@
shift = ShiftMPLSexpEven;
break;
default:
- yyerror("MPLS label out of range 1..10");
+ yyerror(scanner, "MPLS label out of range 1..10");
YYABORT;
}
$$.self = NewBlock(offset, mask, $4 << shift, $3.comp, FUNC_NONE, NULL );
} else {
- yyerror("Unknown MPLS option");
+ yyerror(scanner, "Unknown MPLS option");
YYABORT;
}
}
| MPLS ANY NUMBER {
uint32_t *opt = malloc(sizeof(uint32_t));
if ( $3 > MPLSMAX ) {
- yyerror("MPLS value out of range");
+ yyerror(scanner, "MPLS value out of range");
YYABORT;
}
if ( opt == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
*opt = $3 << 4;
@@ -1773,7 +1786,7 @@
}
| FWDSTAT NUMBER {
if ( $2 > 255 ) {
- yyerror("Forwarding status of range 0..255");
+ yyerror(scanner, "Forwarding status of range 0..255");
YYABORT;
}
$$.self = NewBlock(OffsetStatus, MaskStatus, ($2 << ShiftStatus) & MaskStatus, CMP_EQ, FUNC_NONE, NULL);
@@ -1782,7 +1795,7 @@
| FWDSTAT STRING {
uint64_t id = Get_fwd_status_id($2);
if (id == 256 ) {
- yyerror("Unknown forwarding status");
+ yyerror(scanner, "Unknown forwarding status");
YYABORT;
}
@@ -1792,7 +1805,7 @@
| DIR NUMBER {
if ( $2 > 2 ) {
- yyerror("Flow direction status of range 0, 1");
+ yyerror(scanner, "Flow direction status of range 0, 1");
YYABORT;
}
$$.self = NewBlock(OffsetDir, MaskDir, ($2 << ShiftDir) & MaskDir, CMP_EQ, FUNC_NONE, NULL);
@@ -1806,7 +1819,7 @@
else if ( $2.inout == EGRESS )
dir = 1;
else {
- yyerror("Flow direction status of range ingress, egress");
+ yyerror(scanner, "Flow direction status of range ingress, egress");
YYABORT;
}
@@ -1822,7 +1835,7 @@
IPlist_t *root = malloc(sizeof(IPlist_t));
if ( root == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
RB_INIT(root);
@@ -1830,20 +1843,20 @@
ret = parse_ip(&af, $1, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
for ( i=0; i<num_ip; i++ ) {
if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->ip[0] = IPstack[2*i];
@@ -1865,7 +1878,7 @@
IPlist_t *root = malloc(sizeof(IPlist_t));
if ( root == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
RB_INIT(root);
@@ -1873,19 +1886,19 @@
ret = parse_ip(&af, $1, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "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");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
@@ -1919,11 +1932,11 @@
ret = parse_ip(&af, $2, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
- yyerror("incomplete IP address");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -1931,7 +1944,7 @@
if ( ret != -2 ) {
for ( i=0; i<num_ip; i++ ) {
if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->ip[0] = IPstack[2*i];
@@ -1950,11 +1963,11 @@
ret = parse_ip(&af, $3, IPstack, &bytes, ALLOW_LOOKUP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
- yyerror("incomplete IP address");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
@@ -1962,7 +1975,7 @@
if ( ret != -2 ) {
for ( i=0; i<num_ip; i++ ) {
if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->ip[0] = IPstack[2*i];
@@ -1982,18 +1995,18 @@
ret = parse_ip(&af, $2, IPstack, &bytes, STRICT_IP, &num_ip);
if ( ret == 0 ) {
- yyerror("Invalid IP address");
+ yyerror(scanner, "Invalid IP address");
YYABORT;
}
if ( af && (( af == PF_INET && bytes != 4 ) || ( af == PF_INET6 && bytes != 16 ))) {
- yyerror("incomplete IP address");
+ yyerror(scanner, "incomplete IP address");
YYABORT;
}
// ret == - 2 means lookup failure
if ( ret != -2 ) {
if ((node = malloc(sizeof(struct IPListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
if ( af == PF_INET ) {
@@ -2025,13 +2038,13 @@
ULongtree_t *root = malloc(sizeof(ULongtree_t));
if ( root == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
RB_INIT(root);
if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->value = $1;
@@ -2044,7 +2057,7 @@
struct ULongListNode *node;
if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->value = $2;
@@ -2055,7 +2068,7 @@
struct ULongListNode *node;
if ((node = malloc(sizeof(struct ULongListNode))) == NULL) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
YYABORT;
}
node->value = $3;
@@ -2107,14 +2120,15 @@
%%
-static void yyerror(char *msg) {
+static void yyerror(void * yyscanner, char *msg) {
if ( FilterFilename )
- snprintf(yyerror_buff, 255 ,"File '%s' line %d: %s at '%s'", FilterFilename, lineno, msg, yytext);
+ snprintf(yyerror_buff, 255 ,"File '%s' line %d: %s at '%s'", FilterFilename, lineno, msg, yyget_text(yyscanner));
else
- snprintf(yyerror_buff, 255, "Line %d: %s at '%s'", lineno, msg, yytext);
+ snprintf(yyerror_buff, 255, "Line %d: %s at '%s'", lineno, msg, yyget_text(yyscanner));
yyerror_buff[255] = '\0';
+ /* xxxx */
fprintf(stderr, "%s\n", yyerror_buff);
} /* End of yyerror */
@@ -2148,7 +2162,7 @@
} // End of ChainHosts
-uint64_t VerifyMac(char *s) {
+uint64_t VerifyMac(void * scanner, char *s) {
uint64_t mac;
size_t slen = strlen(s);
long l;
@@ -2165,7 +2179,7 @@
p = strdup(s);
if ( !p ) {
- yyerror("malloc() error");
+ yyerror(scanner, "malloc() error");
return 0;
}
--- nfdump-1.6.13/bin/nfdump.h 2014-06-15 12:20:04.000000000 +0200
+++ nfdump/bin/nfdump.h 2015-03-07 22:34:38.339513167 +0100
@@ -64,13 +64,15 @@
typedef RB_HEAD(ULongtree, ULongListNode) ULongtree_t;
/* parser/scanner prototypes */
-int yyparse(void);
+//int yyparse(void);
+int yyparse(void * scanner);
-int yylex(void);
+//int yylex(void);
+//int yylex(void *yylval_param, void * scanner);
-void lex_cleanup(void);
+//void lex_cleanup(void);
-void lex_init(char *buf);
+//void lex_init(char *buf);
int ScreenIPString(char *string);
--- nfdump-1.6.13/bin/nffile.c 2014-03-12 10:45:49.000000000 +0100
+++ nfdump/bin/nffile.c 2015-03-08 08:23:26.446789688 +0100
@@ -77,11 +77,11 @@
lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]
static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS);
-static void *lzo_buff;
-static int lzo_initialized = 0;
+static __thread void *lzo_buff;
+static __thread int lzo_initialized = 0;
#define ERR_SIZE 256
-static char error_string[ERR_SIZE];
+static __thread char error_string[ERR_SIZE];
static int LZO_initialize(void);
--- nfdump-1.6.13/bin/nftree.c 2014-11-17 18:57:28.000000000 +0100
+++ nfdump/bin/nftree.c 2015-03-07 21:42:30.951174475 +0100
@@ -173,6 +173,7 @@
FilterEngine_data_t *CompileFilter(char *FilterSyntax) {
FilterEngine_data_t *engine;
int ret;
+void * scanner;
if ( !FilterSyntax )
return NULL;
@@ -186,8 +187,11 @@
if ( !InitSymbols() )
exit(255);
InitTree();
+
lex_init(FilterSyntax);
- ret = yyparse();
+
+ yylex_init(&scanner);
+ ret = yyparse(scanner);
if ( ret != 0 ) {
return NULL;
}