+
+ /* Construct key. */
+ memset(&key, 0, sizeof key);
+ key.nw_src = flow->nw_src;
+ key.nw_dst = flow->nw_dst;
+ key.tp_src = flow->tp_src;
+ key.tp_dst = flow->tp_dst;
+ hash = hash_bytes(&key, sizeof key, 0);
+
+ /* Find existing stream or start a new one for a SYN or if there's data. */
+ stream = tcp_stream_lookup(r, &key, hash);
+ if (!stream) {
+ if (flags & TCP_SYN || l7_length) {
+ stream = tcp_stream_new(r, &key, hash);
+ stream->seq_no = flags & TCP_SYN ? seq + 1 : seq;
+ } else {
+ return NULL;
+ }
+ }
+
+ payload = &stream->payload;
+ if (flags & TCP_SYN || !stream->seq_no) {
+ dp_packet_clear(payload);