1 //--------------------------------------------------------------------------
2 // Copyright (C) 2015-2021 Cisco and/or its affiliates. All rights reserved.
3 //
4 // This program is free software; you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License Version 2 as published
6 // by the Free Software Foundation.  You may not use, modify or distribute
7 // this program under any other version of the GNU General Public License.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 //--------------------------------------------------------------------------
18 
19 // tcp_stream_config.h author davis mcpherson <davmcphe@cisco.com>
20 // Created on: Oct 22, 2015
21 
22 #ifndef TCP_STREAM_CONFIG_H
23 #define TCP_STREAM_CONFIG_H
24 
25 #include "protocols/packet.h"
26 #include "stream/tcp/tcp_defs.h"
27 #include "time/packet_time.h"
28 
29 #define STREAM_CONFIG_SHOW_PACKETS             0x00000001
30 #define STREAM_CONFIG_NO_ASYNC_REASSEMBLY      0x00000002
31 #define STREAM_CONFIG_NO_REASSEMBLY            0x00000004
32 
33 #define STREAM_DEFAULT_SSN_TIMEOUT  30
34 
35 class TcpStreamConfig
36 {
37 public:
38     TcpStreamConfig();
39 
require_3whs()40     bool require_3whs()
41     {
42         return hs_timeout >= 0;
43     }
44 
midstream_allowed(snort::Packet * p)45     bool midstream_allowed(snort::Packet* p)
46     {
47         if ( ( hs_timeout < 0 ) || ( p->pkth->ts.tv_sec - packet_first_time() < hs_timeout ) )
48             return true;
49 
50         return false;
51     }
52 
53     void show() const;
54 
55     StreamPolicy policy = StreamPolicy::OS_DEFAULT;
56 
57     uint16_t flags = 0;
58     uint16_t flush_factor = 0;
59 
60     uint32_t session_timeout = STREAM_DEFAULT_SSN_TIMEOUT;
61     uint32_t max_window = 0;
62     uint32_t overlap_limit = 0;
63 
64     uint32_t max_queued_bytes = 4194304;
65     uint32_t max_queued_segs = 3072;
66 
67     uint32_t max_consec_small_segs = STREAM_DEFAULT_CONSEC_SMALL_SEGS;
68     uint32_t max_consec_small_seg_size = STREAM_DEFAULT_MAX_SMALL_SEG_SIZE;
69 
70     uint32_t paf_max = 16384;
71     int hs_timeout = -1;
72 
73     bool no_ack;
74 };
75 
76 #endif
77 
78