-- fixed segfaults due to unitialized cleanup_pkt and unset stream_tcp
-- matched up stream_tcp.policy enum with defines
-- tweaked S5_TRACE output
+-- streamlined session restart handling
+-- changed #begin & #end to have to start beginning of line
125
-- discovered can't catch exceptions thrown from Lua to C++; need to
virtual bool setup(Packet*) { return true; };
virtual void update_direction(char /*dir*/, const sfip_t*, uint16_t /*port*/) { };
virtual int process(Packet*) { return 0; };
+ virtual void restart(Packet*) { };
virtual void clear() = 0;
virtual void cleanup() { clear(); };
#include "module_manager.h"
#include "flow/flow.h"
+#include "flow/session.h"
#include "framework/inspector.h"
#include "detection/detection_util.h"
#include "obfuscation.h"
if ( !flow->gadget || flow->protocol != PktType::TCP )
return;
- ins = get_inspector("stream_tcp");
-
- if ( ins )
- ins->exec(0, p);
+ if ( flow->session )
+ flow->session->restart(p);
}
void InspectorManager::execute (Packet* p)
// called on reassembled packets
::execute(p, fp->packet.vec, fp->packet.num);
::execute(p, fp->session.vec, fp->session.num);
- ::execute(p, fp->network.vec, fp->network.num);
Flow* flow = p->flow;
- if ( flow && flow->clouseau && flow->service )
+ if ( !flow || !flow->service )
+ ::execute(p, fp->network.vec, fp->network.num);
+
+ else if ( flow->clouseau )
bumble(p);
- if ( p->dsize )
- {
- if ( !flow )
- return;
+ if ( !p->dsize )
+ DisableDetect(p);
- // FIXIT-M need more than one service inspector?
- // (should be daisy chained since inspector1 will generate PDUs for
- // inspector2)
- //::execute(p, fp->service.vec, fp->service.num);
- if ( flow->gadget && ((unsigned)p->type() & flow->gadget->get_api()->proto_bits) )
+ // FIXIT-M need more than one service inspector?
+ else if ( flow && flow->gadget )
+ {
+ if ( ((unsigned)p->type() & flow->gadget->get_api()->proto_bits) )
flow->gadget->eval(p);
}
- else
- DisableDetect(p);
::execute(p, fp->probe.vec, fp->probe.num);
}
int c, list = 0, state = 0;
s.clear();
bool inc = true;
+ static int pos = 1;
if ( prev != EOF )
{
if ( c == '\n' )
{
lines++;
+ pos = 0;
+
if ( inc )
inc_parse_position();
else
inc = true;
}
+ else
+ pos++;
switch ( state )
{
else if ( s.size() < 6 )
{
s += c;
- if ( s == "#begin" )
+ if ( pos == 6 && !strcasecmp(s.c_str(), "#begin") )
state = 8;
}
break;
else if ( s.size() < 4 )
{
s += c;
- if ( s == "#end" )
+ if ( !strcasecmp(s.c_str(), "#end") )
state = 1;
}
break;
void tterm() override;
void eval(Packet*) override;
- int exec(int, void*) override;
public:
StreamTcpConfig* config;
assert(false);
}
-int StreamTcp::exec(int, void* v)
-{
- Packet* p = (Packet*)v;
- assert(p && p->flow);
-
- TcpSession* ssn = (TcpSession*)p->flow->session;
- assert(ssn);
-
- ssn->restart_paf(p);
- return 0;
-}
-
StreamTcpConfig* get_tcp_cfg(Inspector* ins)
{
assert(ins);