1 /****************************************************************************
2 * Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 * Copyright (C) 2007-2013 Sourcefire, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License Version 2 as
7 * published by the Free Software Foundation. You may not use, modify or
8 * distribute this program under any other version of the GNU General
9 * Public License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 ****************************************************************************/
21
22 #ifndef DYN_PP_PARSER_H
23 #define DYN_PP_PARSER_H
24
25 #include "snort_bounds.h"
26 #include "snort_debug.h"
27
28 #define SFP_MIN_ERR_STR 128
29
30 /* Convert port value into an index */
31 #define PORT_INDEX(port) port/8
32
33 /* Convert port value into a value for bitwise operations */
34 #define CONV_PORT(port) 1<<(port%8)
35
36 typedef enum _SFP_ret {
37 SFP_SUCCESS,
38 SFP_ERROR
39 } SFP_ret_t;
40
41 typedef uint8_t ports_tbl_t[MAXPORTS/8];
42
43 typedef char SFP_errstr_t[SFP_MIN_ERR_STR + 1];
44
SFP_GET_ERR(SFP_errstr_t err)45 static inline char *SFP_GET_ERR(SFP_errstr_t err)
46 {
47 return (char*)err;
48 }
49
50 SFP_ret_t SFP_ports(ports_tbl_t ports, char *str, SFP_errstr_t errstr);
51
52 SFP_ret_t SFP_snprintfa(char *buf, size_t buf_size, const char *format, ...);
53
54 #endif
55