suricata
stream.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2017 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  */
23 
24 #include "suricata-common.h"
25 #include "decode.h"
26 #include "threads.h"
27 #include "stream.h"
28 #include "util-pool.h"
29 #include "util-debug.h"
30 #include "stream-tcp.h"
31 #include "flow-util.h"
32 
33 /** \brief Run callback for all segments
34  *
35  * Must be called under flow lock.
36  *
37  * \return -1 in case of error, the number of segment in case of success
38  */
39 int StreamSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
40 {
41  switch(p->proto) {
42  case IPPROTO_TCP:
43  return StreamTcpSegmentForEach(p, flag, CallbackFunc, data);
44  break;
45 #ifdef DEBUG
46  case IPPROTO_UDP:
47  SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "UDP is currently unsupported");
48  break;
49  default:
50  SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "This protocol is currently unsupported");
51  break;
52 #endif
53  }
54  return 0;
55 }
int StreamSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
Run callback for all segments.
Definition: stream.c:39
int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
Run callback function on each TCP segment.
Definition: stream-tcp.c:6227
uint8_t proto
Definition: decode.h:428
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
int(* StreamSegmentCallback)(const Packet *, void *, const uint8_t *, uint32_t)
Definition: stream.h:38