suricata
util-running-modes.c
Go to the documentation of this file.
1 /* Copyright (C) 2013 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 /** \file
19  *
20  * \author Eric Leblond <eric@regit.org>
21  */
22 
23 #include "suricata-common.h"
24 #include "app-layer-detect-proto.h"
25 #include "app-layer.h"
26 #include "app-layer-parser.h"
27 #include "detect-engine.h"
28 #include "util-unittest.h"
29 #include "util-debug.h"
30 #include "conf-yaml-loader.h"
31 #include "util-running-modes.h"
32 
33 int ListKeywords(const char *keyword_info)
34 {
36  SCLogLoadConfig(0, 0, 0, 0);
37  MpmTableSetup();
38  SpmTableSetup();
39  AppLayerSetup();
40  SigTableInit();
41  SigTableSetup(); /* load the rule keywords */
42  return SigTableList(keyword_info);
43 }
44 
45 int ListAppLayerProtocols(const char *conf_filename)
46 {
48  if (SCConfYamlLoadFile(conf_filename) != -1)
49  SCLogLoadConfig(0, 0, 0, 0);
50  MpmTableSetup();
51  SpmTableSetup();
52  AppLayerSetup();
54 
55  return TM_ECODE_DONE;
56 }
57 
58 static bool IsBuiltIn(const char *n)
59 {
60  if (strcmp(n, "request_started") == 0 || strcmp(n, "response_started") == 0) {
61  return true;
62  }
63  if (strcmp(n, "request_complete") == 0 || strcmp(n, "response_complete") == 0) {
64  return true;
65  }
66  return false;
67 }
68 
69 int ListAppLayerHooks(const char *conf_filename)
70 {
72  if (SCConfYamlLoadFile(conf_filename) != -1)
73  SCLogLoadConfig(0, 0, 0, 0);
74  MpmTableSetup();
75  SpmTableSetup();
76  AppLayerSetup();
77 
78  AppProto alprotos[g_alproto_max];
80 
81  printf("=========Supported App Layer Hooks=========\n");
82  for (AppProto a = 0; a < g_alproto_max; a++) {
83  if (alprotos[a] != 1)
84  continue;
85 
86  const char *alproto_name = AppProtoToString(a);
87  if (strcmp(alproto_name, "http") == 0)
88  alproto_name = "http1";
89  SCLogDebug("alproto %u/%s", a, alproto_name);
90 
91  const int max_progress_ts =
93  const int max_progress_tc =
95 
96  printf("%s:%s\n", alproto_name, "request_started");
97  for (int p = 0; p <= max_progress_ts; p++) {
99  IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOSERVER);
100  if (name != NULL && !IsBuiltIn(name)) {
101  printf("%s:%s\n", alproto_name, name);
102  }
103  }
104  printf("%s:%s\n", alproto_name, "request_complete");
105 
106  printf("%s:%s\n", alproto_name, "response_started");
107  for (int p = 0; p <= max_progress_tc; p++) {
108  const char *name = AppLayerParserGetStateNameById(
109  IPPROTO_TCP /* TODO no ipproto */, a, p, STREAM_TOCLIENT);
110  if (name != NULL && !IsBuiltIn(name)) {
111  printf("%s:%s\n", alproto_name, name);
112  }
113  }
114  printf("%s:%s\n", alproto_name, "response_complete");
115  }
116  return TM_ECODE_DONE;
117 }
detect-engine.h
AppLayerParserGetStateNameById
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
Definition: app-layer-parser.c:1616
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:270
SigTableSetup
void SigTableSetup(void)
Definition: detect-engine-register.c:522
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:86
TM_ECODE_DONE
@ TM_ECODE_DONE
Definition: tm-threads-common.h:83
AppProtoToString
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
Definition: app-layer-protos.c:40
SigTableInit
void SigTableInit(void)
Definition: detect-engine-register.c:510
AppLayerParserGetStateProgressCompletionStatus
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
Definition: app-layer-parser.c:1115
AppLayerListSupportedProtocols
void AppLayerListSupportedProtocols(void)
Definition: app-layer.c:1015
SCConfYamlLoadFile
int SCConfYamlLoadFile(const char *filename)
Load configuration from a YAML file.
Definition: conf-yaml-loader.c:477
util-unittest.h
AppLayerSetup
int AppLayerSetup(void)
Setup the app layer.
Definition: app-layer.c:1077
app-layer-detect-proto.h
util-debug.h
g_alproto_max
AppProto g_alproto_max
Definition: app-layer-protos.c:29
EngineModeSetIDS
void EngineModeSetIDS(void)
Definition: suricata.c:251
SpmTableSetup
void SpmTableSetup(void)
Definition: util-spm.c:122
app-layer-parser.h
ListAppLayerHooks
int ListAppLayerHooks(const char *conf_filename)
Definition: util-running-modes.c:69
ListAppLayerProtocols
int ListAppLayerProtocols(const char *conf_filename)
Definition: util-running-modes.c:45
conf-yaml-loader.h
name
const char * name
Definition: tm-threads.c:2123
MpmTableSetup
void MpmTableSetup(void)
Definition: util-mpm.c:224
suricata-common.h
AppLayerProtoDetectSupportedAppProtocols
void AppLayerProtoDetectSupportedAppProtocols(AppProto *alprotos)
Definition: app-layer-detect-proto.c:2110
util-running-modes.h
SCLogLoadConfig
void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid)
Definition: util-debug.c:1420
ListKeywords
int ListKeywords(const char *keyword_info)
Definition: util-running-modes.c:33
SigTableList
int SigTableList(const char *keyword)
Definition: detect-engine-register.c:383
app-layer.h