Use namespaces for NetVar type pointers.

Enums defined in bifs and records declared in bifs are now available
in the C++ layer in namespaces (before they were in the global namespace
with enum_* and rectype_* prefixes).

Namespaces are now BroTypePtr::Enum::<name-of-enum> and
BroTypePtr::Record::<name-of-record>
This commit is contained in:
Gregor Maier 2011-02-10 14:11:33 -08:00
parent 43a84866a0
commit 9c39abffef
4 changed files with 10 additions and 10 deletions

View file

@ -234,7 +234,7 @@ void DCE_RPC_Session::DeliverPDU(int is_orig, int len, const u_char* data)
val_list* vl = new val_list; val_list* vl = new val_list;
vl->append(analyzer->BuildConnVal()); vl->append(analyzer->BuildConnVal());
vl->append(new Val(is_orig, TYPE_BOOL)); vl->append(new Val(is_orig, TYPE_BOOL));
vl->append(new EnumVal(data[2], enum_dce_rpc_ptype)); vl->append(new EnumVal(data[2], BroTypePtr::Enum::dce_rpc_ptype));
vl->append(new StringVal(len, (const char*) data)); vl->append(new StringVal(len, (const char*) data));
analyzer->ConnectionEvent(dce_rpc_message, vl); analyzer->ConnectionEvent(dce_rpc_message, vl);
@ -296,7 +296,7 @@ void DCE_RPC_Session::DeliverBind(const binpac::DCE_RPC_Simple::DCE_RPC_PDU* pdu
val_list* vl = new val_list; val_list* vl = new val_list;
vl->append(analyzer->BuildConnVal()); vl->append(analyzer->BuildConnVal());
vl->append(new StringVal(if_uuid.to_string())); vl->append(new StringVal(if_uuid.to_string()));
// vl->append(new EnumVal(if_id, enum_dce_rpc_if_id)); // vl->append(new EnumVal(if_id, BroTypePtr::Enum::dce_rpc_if_id));
analyzer->ConnectionEvent(dce_rpc_bind, vl); analyzer->ConnectionEvent(dce_rpc_bind, vl);
} }

View file

@ -288,7 +288,7 @@ void PortmapperInterp::Event(EventHandlerPtr f, Val* request, int status, Val* r
} }
else else
{ {
vl->append(new EnumVal(status, enum_rpc_status)); vl->append(new EnumVal(status, BroTypePtr::Enum::rpc_status));
if ( request ) if ( request )
vl->append(request); vl->append(request);
} }

View file

@ -214,11 +214,11 @@ definition: event_def
type_def: TOK_TYPE opt_ws TOK_ID opt_ws ':' opt_ws TOK_RECORD opt_ws ';' type_def: TOK_TYPE opt_ws TOK_ID opt_ws ':' opt_ws TOK_RECORD opt_ws ';'
{ {
fprintf(fp_netvar_h, fprintf(fp_netvar_h,
"extern RecordType* rectype_%s;\n", $3); "namespace BroTypePtr { namespace Record { extern RecordType* %s; } }\n", $3);
fprintf(fp_netvar_def, fprintf(fp_netvar_def,
"RecordType* rectype_%s;\n", $3); "namespace BroTypePtr { namespace Record { RecordType* %s; } }\n", $3);
fprintf(fp_netvar_init, fprintf(fp_netvar_init,
"\trectype_%s = internal_type(\"%s\")->AsRecordType();\n", "\tBroTypePtr::Record::%s = internal_type(\"%s\")->AsRecordType();\n",
$3, $3); $3, $3);
} }
; ;
@ -247,11 +247,11 @@ enum_def: enum_def_1 enum_list TOK_RPB
// Now generate the netvar's. // Now generate the netvar's.
fprintf(fp_netvar_h, fprintf(fp_netvar_h,
"extern EnumType* enum_%s;\n", decl_name); "namespace BroTypePtr { namespace Enum { extern EnumType* %s;\n } }", decl_name);
fprintf(fp_netvar_def, fprintf(fp_netvar_def,
"EnumType* enum_%s;\n", decl_name); "namespace BroTypePtr { namespace Enum { EnumType* %s; } }\n", decl_name);
fprintf(fp_netvar_init, fprintf(fp_netvar_init,
"\tenum_%s = internal_type(\"%s\")->AsEnumType();\n", "\tBroTypePtr::Enum::%s = internal_type(\"%s\")->AsEnumType();\n",
decl_name, decl_name); decl_name, decl_name);
} }
; ;

View file

@ -150,7 +150,7 @@ function PortmapCallFailed(connection: RPC_Conn,
status: EnumRPCStatus): bool status: EnumRPCStatus): bool
%{ %{
// BroEnum::rpc_status st = static_cast<BroEnum::rpc_status>(status); // BroEnum::rpc_status st = static_cast<BroEnum::rpc_status>(status);
Val *st = new EnumVal((BroEnum::rpc_status) status, enum_rpc_status); Val *st = new EnumVal(status, BroTypePtr::Enum::rpc_status);
switch ( call->proc() ) { switch ( call->proc() ) {
case PMAPPROC_NULL: case PMAPPROC_NULL: