//-------------------------------------------------------------------------
- static THREAD_LOCAL Packet s_packet; // runtime variable.
++static THREAD_LOCAL Packet* s_packet; // runtime variable.
THREAD_LOCAL SnortConfig* snort_conf = nullptr;
static SnortConfig* snort_cmd_line_conf = nullptr;
{ main_hook = f; }
Packet* get_current_packet()
--{ return &s_packet; }
++{ return s_packet; }
// FIXIT-J for multiple packet threads
// using thread locals for s_pkth and s_data won't work
// capture all if it is not clear which thread crashed
void CapturePacket()
{
-- if ( s_packet.pkth )
++ if ( s_packet->pkth )
{
-- s_pkth = *s_packet.pkth;
++ s_pkth = *(s_packet->pkth);
-- if ( s_packet.pkt )
- memcpy(s_data, s_packet.pkt, 0xFFFF & s_packet.pkth->caplen);
++ if ( s_packet->pkt )
+ {
- memcpy(s_data, s_packet.pkt, 0xFFFF & s_packet.pkth->caplen);
- s_packet.pkt = s_data;
++ memcpy(s_data, s_packet->pkt, 0xFFFF & s_packet->pkth->caplen);
++ s_packet->pkt = s_data;
+ }
}
}
ActionManager::reset_queue();
-- verdict = ProcessPacket(&s_packet, pkthdr, pkt);
++ verdict = ProcessPacket(s_packet, pkthdr, pkt);
-- ActionManager::execute(&s_packet);
++ ActionManager::execute(s_packet);
if ( Active_PacketWasDropped() )
{
}
else
{
-- Packet* p = &s_packet;
-- if ( s_packet.packet_flags & PKT_MODIFIED )
++ if ( s_packet->packet_flags & PKT_MODIFIED )
{
// this packet was normalized and/or has replacements
-- PacketManager::encode_update(&s_packet);
++ PacketManager::encode_update(s_packet);
verdict = DAQ_VERDICT_REPLACE;
}
-- else if ( p->packet_flags & PKT_RESIZED )
++ else if ( s_packet->packet_flags & PKT_RESIZED )
{
-- printf("packet flags = 0x%X\n", p->packet_flags);
++ printf("packet flags = 0x%X\n", s_packet->packet_flags);
// we never increase, only trim, but
// daq doesn't support resizing wire packet
-- if ( !DAQ_Inject(s_packet.pkth, 0, s_packet.pkt, s_packet.pkth->pktlen) )
++ if ( !DAQ_Inject(s_packet->pkth, 0, s_packet->pkt, s_packet->pkth->pktlen) )
{
verdict = DAQ_VERDICT_BLOCK;
inject = 1;
}
else
{
-- if ( (s_packet.packet_flags & PKT_IGNORE) ||
-- (stream.get_ignore_direction(s_packet.flow) == SSN_DIR_BOTH) )
++ if ( (s_packet->packet_flags & PKT_IGNORE) ||
++ (stream.get_ignore_direction(s_packet->flow) == SSN_DIR_BOTH) )
{
if ( !Active_GetTunnelBypass() )
{
pc.internal_whitelist++;
}
}
-- else if ( s_packet.ptrs.decode_flags & DECODE_PKT_TRUST )
++ else if ( s_packet->ptrs.decode_flags & DECODE_PKT_TRUST )
{
-- stream.set_ignore_direction(s_packet.flow, SSN_DIR_BOTH);
++ stream.set_ignore_direction(s_packet->flow, SSN_DIR_BOTH);
verdict = DAQ_VERDICT_WHITELIST;
}
flow_con->timeout_flows(4, pkthdr->ts.tv_sec);
}
-- s_packet.pkth = NULL; // no longer avail on segv
++ s_packet->pkth = NULL; // no longer avail on segv
if ( snort_conf->pkt_cnt && pc.total_from_daq >= snort_conf->pkt_cnt )
DAQ_BreakLoop(-1);
DAQ_New(snort_conf, intf);
DAQ_Start();
- CodecManager::thread_init(snort_conf, s_packet);
++ s_packet = PacketManager::encode_new();
+ CodecManager::thread_init();
FileAPIPostInit();
// this depends on instantiated daq capabilities
ActionManager::thread_term(snort_conf);
IpsManager::clear_options();
EventManager::close_outputs();
- CodecManager::thread_term(s_packet);
++ CodecManager::thread_term();
++
++ if (s_packet)
++ {
++ PacketManager::encode_delete(s_packet);
++ s_packet = nullptr;
++ }
if ( DAQ_WasStarted() )
DAQ_Stop();
bool unit_test;
#endif
- InspectionPolicy* get_inspection_policy() const
- { return policy_map->get_inspection_policy(); };
+ InspectionPolicy* get_inspection_policy()
+ { return policy_map->inspection_policy[0]; };
- IpsPolicy* get_ips_policy() const
- { return policy_map->get_ips_policy(); };
+ IpsPolicy* get_ips_policy()
+ { return policy_map->ips_policy[0]; };
- NetworkPolicy* get_network_policy() const
- { return policy_map->get_network_policy(); };
+ NetworkPolicy* get_network_policy()
+ { return policy_map->network_policy[0]; };
+
+ inline uint8_t get_num_layers() const
+ { return num_layers; }
+
+ inline uint8_t get_ip6_maxopts() const
+ { return max_ip6_options; }
+
+ inline uint8_t get_ip_maxlayers() const
+ { return max_ip_layers; }
};
SnortConfig* SnortConfNew(void);