mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Infrastructure for modularizing protocol analyzers.
There's now a new directory "src/protocols/", and the plan is for each protocol analyzer to eventually have its own subdirectory in there that contains everything it defines (C++/pac/bif). The infrastructure to make that happen is in place, and two analyzers have been converted to the new model, HTTP and SSL; there's no further HTTP/SSL-specific code anywhere else in the core anymore (I believe :-) Further changes: - -N lists available plugins, -NN lists more details on what these plugins provide (analyzers, bif elements). (The latter does not work for analyzers that haven't been converted yet). - *.bif.bro files now go into scripts/base/bif/; and scripts/base/bif/plugins/ for bif files provided by plugins. - I've factored out the bifcl/binpac CMake magic from src/CMakeLists.txt to cmake/{BifCl,Binpac} - There's a new cmake/BroPlugin that contains magic to allow plugins to have a simple CMakeLists.txt. The hope is that eventually the same CMakeLists.txt can be used for compiling a plugin either statically or dynamically. - bifcl has a new option -c that changes the code it generates so that it can be used with a plugin. TODOs: - "make install" is probably broken. - Broxygen is probably broken for plugin-defined events. - event groups are broken (do we want to keep them?)
This commit is contained in:
parent
2be985433c
commit
19c1816ebb
44 changed files with 974 additions and 663 deletions
|
@ -15,6 +15,7 @@ using namespace std;
|
|||
|
||||
extern int line_number;
|
||||
extern char* input_filename;
|
||||
extern char* plugin;
|
||||
|
||||
#define print_line_directive(fp) fprintf(fp, "\n#line %d \"%s\"\n", line_number, input_filename)
|
||||
|
||||
|
@ -265,6 +266,15 @@ void print_event_c_body(FILE *fp)
|
|||
fprintf(fp, "\t} // event generation\n");
|
||||
//fprintf(fp, "%s // end namespace\n", decl.generate_c_namespace_end.c_str());
|
||||
}
|
||||
|
||||
void record_bif_item(const char* id, int type)
|
||||
{
|
||||
if ( ! plugin )
|
||||
return;
|
||||
|
||||
fprintf(fp_func_init, "\tbifs.push_back(std::make_pair(\"%s\", %d));\n", id, type);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%token TOK_LPP TOK_RPP TOK_LPB TOK_RPB TOK_LPPB TOK_RPPB TOK_VAR_ARG
|
||||
|
@ -304,21 +314,6 @@ definitions: definitions definition opt_ws
|
|||
}
|
||||
| opt_ws
|
||||
{
|
||||
int n = 1024 + strlen(input_filename);
|
||||
char auto_gen_comment[n];
|
||||
|
||||
snprintf(auto_gen_comment, n,
|
||||
"This file was automatically generated by bifcl from %s.",
|
||||
input_filename);
|
||||
|
||||
fprintf(fp_bro_init, "# %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_func_def, "// %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_func_h, "// %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_func_init, "// %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_netvar_def, "// %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_netvar_h, "// %s\n\n", auto_gen_comment);
|
||||
fprintf(fp_netvar_init, "// %s\n\n", auto_gen_comment);
|
||||
|
||||
fprintf(fp_bro_init, "%s", $1);
|
||||
fprintf(fp_bro_init, "export {\n");
|
||||
}
|
||||
|
@ -362,6 +357,8 @@ type_def: TOK_TYPE opt_ws TOK_ID opt_ws ':' opt_ws type_def_types opt_ws ';'
|
|||
"\t%s = internal_type(\"%s\")->As%sType();\n",
|
||||
decl.c_fullname.c_str(), decl.bro_fullname.c_str(),
|
||||
type_name.c_str());
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), 5);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -402,6 +399,8 @@ enum_def: enum_def_1 enum_list TOK_RPB
|
|||
fprintf(fp_netvar_init,
|
||||
"\t%s = internal_type(\"%s\")->AsEnumType();\n",
|
||||
decl.c_fullname.c_str(), decl.bro_fullname.c_str());
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), 5);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -456,6 +455,8 @@ const_def: TOK_CONST opt_ws TOK_ID opt_ws ':' opt_ws TOK_ID opt_ws ';'
|
|||
fprintf(fp_netvar_init, "\t%s = internal_const_val(\"%s\")%s;\n",
|
||||
decl.c_fullname.c_str(), decl.bro_fullname.c_str(),
|
||||
accessor);
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), 3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -545,6 +546,8 @@ head_1: TOK_ID opt_ws arg_begin
|
|||
fprintf(fp_func_def,
|
||||
"Val* %s(Frame* frame, val_list* %s)",
|
||||
decl.c_fullname.c_str(), arg_list_name);
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), 1);
|
||||
}
|
||||
else if ( definition_type == EVENT_DEF )
|
||||
{
|
||||
|
@ -561,6 +564,8 @@ head_1: TOK_ID opt_ws arg_begin
|
|||
"\t%s = internal_handler(\"%s\");\n",
|
||||
decl.c_fullname.c_str(), decl.bro_fullname.c_str());
|
||||
|
||||
record_bif_item(decl.bro_fullname.c_str(), 2);
|
||||
|
||||
// C++ prototypes of bro_event_* functions will
|
||||
// be generated later.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue