1 /****************************************************************************
2 * Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 * Copyright (C) 2008-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 _SF_POLICY_DATA_H_
23 #define _SF_POLICY_DATA_H_
24
25 #include "generators.h"
26 #include "sfPolicy.h"
27
28 extern tSfPolicyId napRuntimePolicyId;
29 extern tSfPolicyId ipsRuntimePolicyId;
30 extern uint8_t iprep_current_update_counter;
31
getNapRuntimePolicy(void)32 static inline tSfPolicyId getNapRuntimePolicy(void)
33 {
34 return napRuntimePolicyId;
35 }
36
getIpsRuntimePolicy(void)37 static inline tSfPolicyId getIpsRuntimePolicy(void)
38 {
39 return ipsRuntimePolicyId;
40 }
41
getApplicableRuntimePolicy(uint32_t gid)42 static inline tSfPolicyId getApplicableRuntimePolicy(uint32_t gid)
43 {
44 if (gid == GENERATOR_INTERNAL)
45 return getNapRuntimePolicy();
46 else
47 return getIpsRuntimePolicy();
48 }
49
setNapRuntimePolicy(tSfPolicyId id)50 static inline void setNapRuntimePolicy(tSfPolicyId id)
51 {
52 napRuntimePolicyId = id;
53 }
54
setIpsRuntimePolicy(tSfPolicyId id)55 static inline void setIpsRuntimePolicy(tSfPolicyId id)
56 {
57 ipsRuntimePolicyId = id;
58 }
59
isNapRuntimePolicyDefault(void)60 static inline int isNapRuntimePolicyDefault(void)
61 {
62 return ( napRuntimePolicyId == SF_DEFAULT_POLICY_ID );
63 }
64
isIpsRuntimePolicyDefault(void)65 static inline int isIpsRuntimePolicyDefault(void)
66 {
67 return ( ipsRuntimePolicyId == SF_DEFAULT_POLICY_ID );
68 }
69
getParserPolicy(SnortConfig * sc)70 static inline tSfPolicyId getParserPolicy(SnortConfig *sc)
71 {
72 return sc ? sc->parserPolicyId : snort_conf->parserPolicyId;
73 }
74
setParserPolicy(SnortConfig * sc,tSfPolicyId id)75 static inline void setParserPolicy(SnortConfig *sc, tSfPolicyId id)
76 {
77 if (sc)
78 sc->parserPolicyId = id;
79 else
80 snort_conf->parserPolicyId = id;
81 }
82
isParserPolicyDefault(SnortConfig * sc)83 static inline int isParserPolicyDefault(SnortConfig *sc)
84 {
85 return ( ( sc ? sc->parserPolicyId : snort_conf->parserPolicyId ) == SF_DEFAULT_POLICY_ID );
86 }
87
setIPRepUpdateCount(uint8_t count)88 static inline void setIPRepUpdateCount(uint8_t count)
89 {
90 iprep_current_update_counter = count;
91 }
92
getIPRepUpdateCount(void)93 static inline uint8_t getIPRepUpdateCount(void)
94 {
95 return iprep_current_update_counter;
96 }
97 #endif
98
99