virtual ~Session() = default;
virtual bool setup(snort::Packet*) { return true; }
- virtual void update_direction(char /*dir*/, const snort::SfIp*, uint16_t /*port*/) { }
+ virtual void update_direction(char /*dir*/, const snort::SfIp*, uint16_t /*port*/)
+ {
+ // UDP is currently the only stream that implements this. Others should not be calling.
+ assert(false);
+ }
virtual int process(snort::Packet*) { return 0; }
virtual void restart(snort::Packet*) { }
Session *ssn = new DummySession(nullptr);
CHECK(true == ssn->setup(nullptr));
- ssn->update_direction(1, nullptr, 1234);
CHECK(0 == ssn->process(nullptr));
ssn->restart(nullptr);
ssn->flush_client(nullptr);
return status;
}
-#define icmp_sender_ip flow->client_ip
-#define icmp_responder_ip flow->server_ip
-
-void IcmpSession::update_direction(char dir, const SfIp* ip, uint16_t)
-{
- if (icmp_sender_ip.equals(*ip))
- {
- if ((dir == SSN_DIR_FROM_CLIENT) && (flow->ssn_state.direction == FROM_CLIENT))
- {
- /* Direction already set as SENDER */
- return;
- }
- }
- else if (icmp_responder_ip.equals(*ip))
- {
- if ((dir == SSN_DIR_FROM_SERVER) && (flow->ssn_state.direction == FROM_SERVER))
- {
- /* Direction already set as RESPONDER */
- return;
- }
- }
-
- /* Swap them -- leave ssn->ssn_state.direction the same */
- SfIp tmpIp = icmp_sender_ip;
- icmp_sender_ip = icmp_responder_ip;
- icmp_responder_ip = tmpIp;
-}
-
~IcmpSession() override;
bool setup(snort::Packet*) override;
- void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
int process(snort::Packet*) override;
void clear() override;
return false;
}
-void TcpStreamSession::update_direction(char dir, const SfIp* ip, uint16_t port)
-{
- SfIp tmpIp;
- uint16_t tmpPort;
-
- if (flow->client_ip.equals(*ip) && (flow->client_port == port))
- {
- if ((dir == SSN_DIR_FROM_CLIENT) && (flow->ssn_state.direction == FROM_CLIENT))
- {
- /* Direction already set as client */
- return;
- }
- }
- else if (flow->server_ip.equals(*ip) && (flow->server_port == port))
- {
- if ((dir == SSN_DIR_FROM_SERVER) && (flow->ssn_state.direction == FROM_SERVER))
- {
- /* Direction already set as server */
- return;
- }
- }
-
- /* Swap them -- leave flow->ssn_state.direction the same */
- tmpIp = flow->client_ip;
- tmpPort = flow->client_port;
- flow->client_ip = flow->server_ip;
- flow->client_port = flow->server_port;
- flow->server_ip = tmpIp;
- flow->server_port = tmpPort;
-
- SwapPacketHeaderFoo( );
- TcpStreamTracker tracker = client;
- client = server;
- server = tracker;
-}
-
// FIXIT-H add alert and check alerted go away when we finish
// packet / PDU split because PDU rules won't run on raw packets
bool TcpStreamSession::add_alert(Packet* p, uint32_t gid, uint32_t sid)
bool are_packets_missing(uint8_t /*dir*/) override;
uint8_t get_reassembly_direction() override;
uint8_t missing_in_reassembled(uint8_t /*dir*/) override;
- void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
bool add_alert(snort::Packet*, uint32_t gid, uint32_t sid) override;
bool check_alerted(snort::Packet*, uint32_t gid, uint32_t sid) override;
int update_alert(snort::Packet*, uint32_t /*gid*/, uint32_t /*sid*/,
}
}
-void Stream::update_direction(
- Flow* flow, char dir, const SfIp* ip, uint16_t port)
-{
- if (!flow)
- return;
-
- flow->session->update_direction(dir, ip, port);
-}
-
uint32_t Stream::get_packet_direction(Packet* p)
{
if (!p || !(p->flow))
// Populate a session key from the Packet
static void populate_flow_key(Packet*, FlowKey*);
- static void update_direction(Flow*, char dir, const snort::SfIp* ip, uint16_t port);
-
static void set_snort_protocol_id(
Flow*, const HostAttributeEntry*, int direction);
// some will be deleted, some refactored, some implemented
//-------------------------------------------------------------------------
-void UserSession::update_direction(char /*dir*/, const SfIp*, uint16_t /*port*/) { }
-
bool UserSession::add_alert(Packet*, uint32_t /*gid*/, uint32_t /*sid*/) { return true; }
bool UserSession::check_alerted(Packet*, uint32_t /*gid*/, uint32_t /*sid*/) { return false; }
void update(snort::Packet*, snort::Flow*);
void end(snort::Packet*, snort::Flow*);
- void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
-
bool add_alert(snort::Packet*, uint32_t gid, uint32_t sid) override;
bool check_alerted(snort::Packet*, uint32_t gid, uint32_t sid) override;