1 /*
2 ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 ** Copyright (C) 2005-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 __COMMON_APP_MATCHER_H__
23 #define __COMMON_APP_MATCHER_H__
24 
25 #include <stdbool.h>
26 #include <stdint.h>
27 #include <strings.h>
28 
29 #include "sf_snort_packet.h"
30 #include "sf_dynamic_preprocessor.h"
31 #include "sflsq.h"
32 #include "service_state.h"
33 #include "flow.h"
34 #include "appId.h"
35 #include "NetworkSet.h"
36 
37 struct AppIdData;
38 struct AppidStaticConfig;
39 
40 typedef struct _appRegistryEntry
41 {
42     tAppId appId;
43     uint32_t  additionalInfo;
44 } tAppRegistryEntry;
45 
46 extern unsigned appIdPolicyId;
47 extern uint32_t app_id_netmasks[];
48 
49 int appMatcherIsAppDetected(void *appSet, tAppId app);
50 int AppIdCommonInit(struct AppidStaticConfig *config);
51 int AppIdCommonFini(void);
52 
53 /**
54  * \brief Reload AppId configuration
55  *
56  * This function reloads AppId configuration. It is used both in the cases of Snort reload
57  * and AppId reconfiguration.
58  *
59  * @param rnaConf - RNA configuration file name with full path
60  * @param new_context - return reference that points to new AppId configuration
61  * @return 0 on success, -1 on failure
62  */
63 int AppIdCommonReload(struct AppidStaticConfig* appidSC, void **new_context);
64 
65 /**
66  * \brief Swap AppId configuration
67  *
68  * This function swaps AppId configuration. This function is called after AppIdCommonReload().
69  *
70  * @param swap_config - Pointer to new configuration. This pointer is returned by AppIdCommonReload().
71  * @return Pointer to old configuration
72  */
73 void *AppIdCommonReloadSwap(void *new_context);
74 
75 /**
76  * \brief Clean up AppId configuration
77  *
78  * This function cleans up all the data structures in an AppId configuration. It does not clean up
79  * any global data structures that are used by AppId and are outside the configuration. This
80  * function is called after AppIdCommonReloadSwap().
81  *
82  * @param old_context - Pointer to old configuration. This pointer is returned by AppIdCommonReloadSwap().
83  * @return None
84  */
85 void AppIdCommonUnload(void *old_context);
86 
87 void *AppIDFlowdataGet(struct AppIdData *flow, unsigned id);
88 
89 #endif  /* __COMMON_APP_MATCHER_H__ */
90 
91