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"
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
33int ListKeywords(const char *keyword_info)
34{
36 SCLogLoadConfig(0, 0, 0, 0);
41 SigTableSetup(); /* load the rule keywords */
42 return SigTableList(keyword_info);
43}
44
45int ListAppLayerProtocols(const char *conf_filename)
46{
48 if (SCConfYamlLoadFile(conf_filename) != -1)
49 SCLogLoadConfig(0, 0, 0, 0);
54
55 return TM_ECODE_DONE;
56}
57
58static 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
69int ListAppLayerHooks(const char *conf_filename)
70{
72 if (SCConfYamlLoadFile(conf_filename) != -1)
73 SCLogLoadConfig(0, 0, 0, 0);
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++) {
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}
void AppLayerProtoDetectSupportedAppProtocols(AppProto *alprotos)
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
AppProto g_alproto_max
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
uint16_t AppProto
void AppLayerListSupportedProtocols(void)
Definition app-layer.c:1016
int AppLayerSetup(void)
Setup the app layer.
Definition app-layer.c:1078
int SCConfYamlLoadFile(const char *filename)
Load configuration from a YAML file.
void SigTableSetup(void)
int SigTableList(const char *keyword)
void SigTableInit(void)
void EngineModeSetIDS(void)
Definition suricata.c:264
@ TM_ECODE_DONE
const char * name
void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid)
#define SCLogDebug(...)
Definition util-debug.h:275
void MpmTableSetup(void)
Definition util-mpm.c:224
int ListAppLayerProtocols(const char *conf_filename)
int ListAppLayerHooks(const char *conf_filename)
int ListKeywords(const char *keyword_info)
void SpmTableSetup(void)
Definition util-spm.c:122