syntax:
free(free_me);
+ // ensure integrity from parse error to fatal error
+ if ( !pcre_data->expression )
+ pcre_data->expression = SnortStrdup("");
+
ParseError("unable to parse pcre regex %s", data);
}
using namespace std;
#include "binder.h"
+#include "protocols/packet.h"
THREAD_LOCAL SimpleStats bstats;
work->nets = v.get_string();
else if ( v.is("proto") )
- work->proto = (BindProto)v.get_long();
-
+ {
+ const unsigned mask[] =
+ {
+ PROTO_BIT__ALL, PROTO_BIT__IP, PROTO_BIT__ICMP, PROTO_BIT__TCP, PROTO_BIT__UDP
+ };
+ work->protos = mask[v.get_long()];
+ }
else if ( v.is("ports") )
v.get_bits(work->ports);
Binding::Binding()
{
role = BR_EITHER;
- proto = BP_ANY;
+ protos = PROTO_BIT__ALL;
action = BA_INSPECT;
ports.set();
}
flow->clouseau = nullptr;
}
-// FIXIT-H use IPPROTO_* directly (any == 0)
-static bool check_proto(const Flow* flow, BindProto bp)
+static bool check_proto(const Flow* flow, unsigned mask)
{
- switch ( bp )
+ unsigned bit = 0;
+
+ switch ( flow->protocol )
{
- case BP_ANY: return true;
- case BP_IP: return flow->protocol == IPPROTO_IP;
- case BP_ICMP:return flow->protocol == IPPROTO_ICMP;
- case BP_TCP: return flow->protocol == IPPROTO_TCP;
- case BP_UDP: return flow->protocol == IPPROTO_UDP;
+ case IPPROTO_IP: bit = PROTO_BIT__IP; break;
+ case IPPROTO_ICMP: bit = PROTO_BIT__ICMP; break;
+ case IPPROTO_TCP: bit = PROTO_BIT__TCP; break;
+ case IPPROTO_UDP: bit = PROTO_BIT__UDP; break;
}
- return false;
+ return ( mask & bit ) != 0;
}
//-------------------------------------------------------------------------
{
pb = bindings[i];
- if ( !check_proto(flow, pb->proto) )
+ if ( !check_proto(flow, pb->protos) )
continue;
if ( pb->ports.test(port) )