Build filter using CMake
This commit is contained in:
parent
9df8f678a3
commit
f6ea0a79a8
@ -17,7 +17,7 @@ if(ENABLE_DEVELOPMENT)
|
|||||||
"-Wnested-externs -Wbad-function-cast -Winit-self"
|
"-Wnested-externs -Wbad-function-cast -Winit-self"
|
||||||
"-Wmissing-noreturn -Wnormalized=id"
|
"-Wmissing-noreturn -Wnormalized=id"
|
||||||
"-Wstack-protector"
|
"-Wstack-protector"
|
||||||
"-Werror"
|
#"-Werror"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Fix line breaks
|
# Fix line breaks
|
||||||
|
4
src/.gitignore
vendored
Normal file
4
src/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
lexer.c
|
||||||
|
lexer.h
|
||||||
|
parser.c
|
||||||
|
parser.h
|
@ -11,6 +11,7 @@ SET(LIB_SOURCES
|
|||||||
${PROJECT_SOURCE_DIR}/lib/logger.c
|
${PROJECT_SOURCE_DIR}/lib/logger.c
|
||||||
${PROJECT_SOURCE_DIR}/lib/random.c
|
${PROJECT_SOURCE_DIR}/lib/random.c
|
||||||
${PROJECT_SOURCE_DIR}/lib/rijndael-alg-fst.c
|
${PROJECT_SOURCE_DIR}/lib/rijndael-alg-fst.c
|
||||||
|
${PROJECT_SOURCE_DIR}/lib/xalloc.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# ADD YOUR PROBE MODULE HERE
|
# ADD YOUR PROBE MODULE HERE
|
||||||
@ -41,16 +42,21 @@ SET(PROBE_MODULE_SOURCES
|
|||||||
SET(SOURCES
|
SET(SOURCES
|
||||||
aesrand.c
|
aesrand.c
|
||||||
cyclic.c
|
cyclic.c
|
||||||
|
expression.c
|
||||||
fieldset.c
|
fieldset.c
|
||||||
|
filter.c
|
||||||
get_gateway.c
|
get_gateway.c
|
||||||
monitor.c
|
monitor.c
|
||||||
recv.c
|
recv.c
|
||||||
send.c
|
send.c
|
||||||
|
stack.c
|
||||||
state.c
|
state.c
|
||||||
validate.c
|
validate.c
|
||||||
zmap.c
|
zmap.c
|
||||||
zopt_compat.c
|
zopt_compat.c
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/zopt.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/zopt.h"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/lexer.c"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/parser.c"
|
||||||
${EXTRA_PROBE_MODULES}
|
${EXTRA_PROBE_MODULES}
|
||||||
${EXTRA_OUTPUT_MODULES}
|
${EXTRA_OUTPUT_MODULES}
|
||||||
${PROBE_MODULE_SOURCES}
|
${PROBE_MODULE_SOURCES}
|
||||||
@ -70,6 +76,14 @@ add_custom_command(OUTPUT zopt.h
|
|||||||
COMMAND gengetopt -C --no-help --no-version -i "${CMAKE_CURRENT_SOURCE_DIR}/zopt.ggo" -F "${CMAKE_CURRENT_BINARY_DIR}/zopt"
|
COMMAND gengetopt -C --no-help --no-version -i "${CMAKE_CURRENT_SOURCE_DIR}/zopt.ggo" -F "${CMAKE_CURRENT_BINARY_DIR}/zopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT lexer.c
|
||||||
|
COMMAND flex -o "${CMAKE_CURRENT_BINARY_DIR}/lexer.c" --header-file="${CMAKE_CURRENT_BINARY_DIR}/lexer.h" lexer.l
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT parser.c
|
||||||
|
COMMAND byacc -d -o parser.c parser.y
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(zmap ${SOURCES})
|
add_executable(zmap ${SOURCES})
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
@ -45,4 +45,6 @@ node_t* make_int_node(int literal);
|
|||||||
|
|
||||||
int evaluate_expression(node_t *root, fieldset_t *fields);
|
int evaluate_expression(node_t *root, fieldset_t *fields);
|
||||||
|
|
||||||
|
void print_expression(node_t *root);
|
||||||
|
|
||||||
#endif /* ZMAP_TREE_H */
|
#endif /* ZMAP_TREE_H */
|
@ -1,7 +1,8 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "y.tab.h"
|
#include "parser.h"
|
||||||
|
#include "expression.h"
|
||||||
#include "../lib/logger.h"
|
#include "../lib/logger.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
11
src/lexer.c
11
src/lexer.c
@ -1,5 +1,6 @@
|
|||||||
|
#line 2 "/home/david/mac/SourceCode/zmap/src/lexer.c"
|
||||||
|
|
||||||
#line 3 "<stdout>"
|
#line 4 "/home/david/mac/SourceCode/zmap/src/lexer.c"
|
||||||
|
|
||||||
#define YY_INT_ALIGNED short int
|
#define YY_INT_ALIGNED short int
|
||||||
|
|
||||||
@ -469,10 +470,10 @@ char *yytext;
|
|||||||
#line 1 "lexer.l"
|
#line 1 "lexer.l"
|
||||||
#line 2 "lexer.l"
|
#line 2 "lexer.l"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "y.tab.h"
|
#include "parser.h"
|
||||||
|
|
||||||
#define YY_NO_INPUT 1
|
#define YY_NO_INPUT 1
|
||||||
#line 476 "<stdout>"
|
#line 477 "/home/david/mac/SourceCode/zmap/src/lexer.c"
|
||||||
|
|
||||||
#define INITIAL 0
|
#define INITIAL 0
|
||||||
|
|
||||||
@ -659,7 +660,7 @@ YY_DECL
|
|||||||
|
|
||||||
#line 9 "lexer.l"
|
#line 9 "lexer.l"
|
||||||
|
|
||||||
#line 663 "<stdout>"
|
#line 664 "/home/david/mac/SourceCode/zmap/src/lexer.c"
|
||||||
|
|
||||||
if ( !(yy_init) )
|
if ( !(yy_init) )
|
||||||
{
|
{
|
||||||
@ -818,7 +819,7 @@ YY_RULE_SETUP
|
|||||||
#line 25 "lexer.l"
|
#line 25 "lexer.l"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 822 "<stdout>"
|
#line 823 "/home/david/mac/SourceCode/zmap/src/lexer.c"
|
||||||
case YY_STATE_EOF(INITIAL):
|
case YY_STATE_EOF(INITIAL):
|
||||||
yyterminate();
|
yyterminate();
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#define yyHEADER_H 1
|
#define yyHEADER_H 1
|
||||||
#define yyIN_HEADER 1
|
#define yyIN_HEADER 1
|
||||||
|
|
||||||
#line 6 "lexer.h"
|
#line 6 "/home/david/mac/SourceCode/zmap/src/lexer.h"
|
||||||
|
|
||||||
|
#line 8 "/home/david/mac/SourceCode/zmap/src/lexer.h"
|
||||||
|
|
||||||
#define YY_INT_ALIGNED short int
|
#define YY_INT_ALIGNED short int
|
||||||
|
|
||||||
@ -325,6 +327,6 @@ extern int yylex (void);
|
|||||||
#line 25 "lexer.l"
|
#line 25 "lexer.l"
|
||||||
|
|
||||||
|
|
||||||
#line 329 "lexer.h"
|
#line 331 "/home/david/mac/SourceCode/zmap/src/lexer.h"
|
||||||
#undef yyIN_HEADER
|
#undef yyIN_HEADER
|
||||||
#endif /* yyHEADER_H */
|
#endif /* yyHEADER_H */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%{
|
%{
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "y.tab.h"
|
#include "parser.h"
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ typedef union {
|
|||||||
struct node *expr;
|
struct node *expr;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
#endif /* !YYSTYPE_IS_DECLARED */
|
#endif /* !YYSTYPE_IS_DECLARED */
|
||||||
#line 52 "y.tab.c"
|
#line 52 "parser.c"
|
||||||
|
|
||||||
/* compatibility with bison */
|
/* compatibility with bison */
|
||||||
#ifdef YYPARSE_PARAM
|
#ifdef YYPARSE_PARAM
|
||||||
@ -250,7 +250,7 @@ static YYSTACKDATA yystack;
|
|||||||
#line 144 "parser.y"
|
#line 144 "parser.y"
|
||||||
|
|
||||||
|
|
||||||
#line 253 "y.tab.c"
|
#line 253 "parser.c"
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
#include <stdio.h> /* needed for printf */
|
#include <stdio.h> /* needed for printf */
|
||||||
@ -566,7 +566,7 @@ case 15:
|
|||||||
yyval.expr->right_child = make_field_node(yystack.l_mark[0].string_literal);
|
yyval.expr->right_child = make_field_node(yystack.l_mark[0].string_literal);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#line 569 "y.tab.c"
|
#line 569 "parser.c"
|
||||||
}
|
}
|
||||||
yystack.s_mark -= yym;
|
yystack.s_mark -= yym;
|
||||||
yystate = *yystack.s_mark;
|
yystate = *yystack.s_mark;
|
||||||
|
20
src/y.tab.h
20
src/y.tab.h
@ -1,20 +0,0 @@
|
|||||||
#define T_AND 257
|
|
||||||
#define T_OR 258
|
|
||||||
#define T_NUMBER 259
|
|
||||||
#define T_FIELD 260
|
|
||||||
#define T_NOT_EQ 261
|
|
||||||
#define T_GT_EQ 262
|
|
||||||
#define T_LT_EQ 263
|
|
||||||
#ifdef YYSTYPE
|
|
||||||
#undef YYSTYPE_IS_DECLARED
|
|
||||||
#define YYSTYPE_IS_DECLARED 1
|
|
||||||
#endif
|
|
||||||
#ifndef YYSTYPE_IS_DECLARED
|
|
||||||
#define YYSTYPE_IS_DECLARED 1
|
|
||||||
typedef union {
|
|
||||||
int int_literal;
|
|
||||||
char *string_literal;
|
|
||||||
struct node *expr;
|
|
||||||
} YYSTYPE;
|
|
||||||
#endif /* !YYSTYPE_IS_DECLARED */
|
|
||||||
extern YYSTYPE yylval;
|
|
Loading…
Reference in New Issue
Block a user