81static inline Packet *FlowPseudoPacketSetup(
84 const int orig_dir = direction;
87 p->
proto = IPPROTO_TCP;
88 FlowReference(&p->
flow, f);
97 DecodeSetNoPayloadInspectionFlag(p);
112 if (direction == 0) {
143 if (direction == 0) {
144 ip4h->s_ip_src.s_addr = f->src.addr_data32[0];
145 ip4h->s_ip_dst.s_addr = f->dst.addr_data32[0];
147 ip4h->s_ip_src.s_addr = f->dst.addr_data32[0];
148 ip4h->s_ip_dst.s_addr = f->src.addr_data32[0];
157 if (direction == 0) {
180 ip6h->s_ip6_vfc = 0x60;
181 ip6h->s_ip6_flow = 0;
182 ip6h->s_ip6_nxt = IPPROTO_TCP;
183 ip6h->s_ip6_plen = htons(20);
184 ip6h->s_ip6_hlim = 64;
185 if (direction == 0) {
186 ip6h->s_ip6_src[0] = f->src.addr_data32[0];
187 ip6h->s_ip6_src[1] = f->src.addr_data32[1];
188 ip6h->s_ip6_src[2] = f->src.addr_data32[2];
189 ip6h->s_ip6_src[3] = f->src.addr_data32[3];
190 ip6h->s_ip6_dst[0] = f->dst.addr_data32[0];
191 ip6h->s_ip6_dst[1] = f->dst.addr_data32[1];
192 ip6h->s_ip6_dst[2] = f->dst.addr_data32[2];
193 ip6h->s_ip6_dst[3] = f->dst.addr_data32[3];
195 ip6h->s_ip6_src[0] = f->dst.addr_data32[0];
196 ip6h->s_ip6_src[1] = f->dst.addr_data32[1];
197 ip6h->s_ip6_src[2] = f->dst.addr_data32[2];
198 ip6h->s_ip6_src[3] = f->dst.addr_data32[3];
199 ip6h->s_ip6_dst[0] = f->src.addr_data32[0];
200 ip6h->s_ip6_dst[1] = f->src.addr_data32[1];
201 ip6h->s_ip6_dst[2] = f->src.addr_data32[2];
202 ip6h->s_ip6_dst[3] = f->src.addr_data32[3];
211 p->l4.hdrs.tcph->th_offx2 = 0x50;
212 p->l4.hdrs.tcph->th_flags = 0;
213 p->l4.hdrs.tcph->th_win = 10;
214 p->l4.hdrs.tcph->th_urp = 0;
218 p->l4.hdrs.tcph->th_sport = htons(f->sp);
219 p->l4.hdrs.tcph->th_dport = htons(f->dp);
221 p->l4.hdrs.tcph->th_seq = htonl(ssn->client.next_seq);
222 p->l4.hdrs.tcph->th_ack = 0;
226 p->l4.hdrs.tcph->th_sport = htons(f->dp);
227 p->l4.hdrs.tcph->th_dport = htons(f->sp);
229 p->l4.hdrs.tcph->th_seq = htonl(ssn->server.next_seq);
230 p->l4.hdrs.tcph->th_ack = 0;
234 IPV4Hdr *ip4h = p->l3.hdrs.ip4h;
235 p->l4.hdrs.tcph->th_sum = TCPChecksum(ip4h->s_ip_addrs, (uint16_t *)p->l4.hdrs.tcph, 20, 0);
240 const IPV6Hdr *ip6h = PacketGetIPv6(p);
241 p->l4.hdrs.tcph->th_sum =
242 TCPChecksum(ip6h->s_ip6_addrs, (uint16_t *)p->l4.hdrs.tcph, 20, 0);
247 if (direction == 0) {
260 FlowDeReference(&p->flow);
274 return FlowPseudoPacketSetup(p, direction, f, ssn);
287 if (f == NULL || f->
protoctx == NULL) {
319 if (frames_container) {
371static inline void FlowRemoveHash(
void)
399 RemoveFromHash(f, prev_f);
FramesContainer * AppLayerFramesGetContainer(Flow *f)
uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState *pstate, uint8_t direction)
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
void SCAppLayerParserStateSetFlag(AppLayerParserState *pstate, uint16_t flag)
#define APP_LAYER_PARSER_EOF_TC
#define APP_LAYER_PARSER_EOF_TS
#define IPV4_GET_RAW_HLEN(ip4h)
#define GET_PKT_DIRECT_MAX_SIZE(p)
#define SET_PKT_LEN(p, len)
#define PKT_PSEUDO_STREAM_END
Data structures and function prototypes for keeping state for the detection engine.
#define FBLOCK_UNLOCK(fb)
Packet * FlowPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
void FlowWorkToDoCleanup(void)
Clean up all the flows that have unprocessed segments and have some work to do in the detection engin...
void FlowSendToLocalThread(Flow *f)
bool FlowNeedsReassembly(Flow *f)
Check if a flow needs forced reassembly, or any other processing.
#define FLOW_NOPAYLOAD_INSPECTION
#define FLOW_PKT_TOSERVER
#define FLOW_DIR_REVERSED
#define FLOW_COPY_IPV4_ADDR_TO_PACKET(fa, pa)
#define FLOW_COPY_IPV6_ADDR_TO_PACKET(fa, pa)
#define FLOW_END_FLAG_SHUTDOWN
#define FLOW_PKT_ESTABLISHED
#define FLOWLOCK_UNLOCK(fb)
#define FLOW_PKT_TOCLIENT
#define FLOWLOCK_WRLOCK(fb)
int PacketCallocExtPkt(Packet *p, int datalen)
#define STREAM_HAS_SEEN_DATA(stream)
uint8_t StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction)
see what if any work the TCP session still needs
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NONE
AppProto alproto
application level protocol
uint16_t vlan_id[VLAN_MAX_LAYERS]
AppLayerParserState * alparser
struct LiveDevice_ * livedev
FlowThreadId thread_id[2]
uint16_t vlan_id[VLAN_MAX_LAYERS]
struct LiveDevice_ * livedev
void TmThreadsInjectFlowById(Flow *f, const int id)
inject a flow into a threads flow queue
void PacketPoolWait(void)
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
int DatalinkGetGlobalType(void)
#define PACKET_PROFILING_START(p)