]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Use a typdef AppProto <-> uint16_t for representing app layer protocol.
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Fri, 6 Dec 2013 11:51:57 +0000 (17:21 +0530)
committerAnoop Saldanha <anoopsaldanha@gmail.com>
Sun, 29 Dec 2013 06:55:44 +0000 (12:25 +0530)
Some minor refactoring/cleanup, including renaming functions.

src/app-layer-protos.c
src/app-layer-protos.h
src/detect-engine-analyzer.c
src/detect-parse.c
src/util-profiling.c

index a68e407f2ab146558f28f85206b90dd63bef985a..5d62875c07226a613f83f8a376827cd311dfaf26 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2011 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
  * \file
  *
  * \author Victor Julien <victor@inliniac.net>
+ * \author Anoop Saldanha <anoopsaldanha@gmail.com>
  */
 
 #include "suricata-common.h"
+#include "app-layer-protos.h"
 
 #define CASE_CODE(E)  case E: return #E
 
 /**
- * \brief Maps the ALPROTO_*, to its string equivalent
+ * \brief Maps the ALPROTO_*, to its string equivalent.
  *
- * \param proto app layer protocol id
+ * \param alproto App layer protocol id.
  *
- * \retval string equivalent for the alproto
+ * \retval String equivalent for the alproto.
  */
-const char *TmModuleAlprotoToString(enum AppProto proto)
+const char *AppProtoToString(AppProto alproto)
 {
     const char *proto_name = NULL;
 
-    switch (proto) {
+    switch (alproto) {
         case ALPROTO_HTTP:
             proto_name = "http";
             break;
@@ -96,4 +98,3 @@ const char *TmModuleAlprotoToString(enum AppProto proto)
 
     return proto_name;
 }
-
index 409d8814e5ad0a07a2997200b213ee8270099c6d..1d5f45161c1791753133ef3695d0c33be11bb00a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
  * \file
  *
  * \author Victor Julien <victor@inliniac.net>
+ * \author Anoop Saldanha <anoopsaldanha@gmail.com>
  */
 
-#ifndef __APP_LAYER_PROTOS_H__
-#define __APP_LAYER_PROTOS_H__
+#ifndef __APP_LAYER_PROTOS__H__
+#define __APP_LAYER_PROTOS__H__
 
-enum AppProto {
+enum {
     ALPROTO_UNKNOWN = 0,
     ALPROTO_HTTP,
     ALPROTO_FTP,
@@ -54,7 +55,9 @@ enum AppProto {
     ALPROTO_MAX,
 };
 
-const char *TmModuleAlprotoToString(enum AppProto proto);
+typedef uint16_t AppProto;
 
-#endif /* __APP_LAYER_PROTOS_H__ */
+const char *AppProtoToString(AppProto alproto);
+
+#endif /* __APP_LAYER_PROTOS__H__ */
 
index 052b5bab8ed7b035b89244d33ce4cf7eca1b72a7..436f0fb54c2b2ef1d792ed5afebbf8eef6e844e4 100644 (file)
@@ -785,7 +785,7 @@ void EngineAnalysisRules(Signature *s, char *line)
         if (http_stat_code_buf) fprintf(rule_engine_analysis_FD, "    Rule matches on http stat code buffer.\n");
         if (http_ua_buf) fprintf(rule_engine_analysis_FD, "    Rule matches on http user agent buffer.\n");
         if (s->alproto != ALPROTO_UNKNOWN) {
-            fprintf(rule_engine_analysis_FD, "    App layer protocol is %s.\n", TmModuleAlprotoToString(s->alproto));
+            fprintf(rule_engine_analysis_FD, "    App layer protocol is %s.\n", AppProtoToString(s->alproto));
         }
         if (rule_content || rule_content_http || rule_pcre || rule_pcre_http) {
             fprintf(rule_engine_analysis_FD, "    Rule contains %d content options, %d http content options, %d pcre options, and %d pcre options with http modifiers.\n", rule_content, rule_content_http, rule_pcre, rule_pcre_http);
index 626af959e6492a8838794581ae509b25f41ecd69..78e1bd5e0a594c92cd8a7a1eeea7396b7c81382c 100644 (file)
@@ -1238,7 +1238,7 @@ int SigValidate(DetectEngineCtx *de_ctx, Signature *s) {
             } else {
                 if (al_proto_table[s->alproto].to_server == 0 ||
                     al_proto_table[s->alproto].to_client == 0) {
-                    const char *proto_name = TmModuleAlprotoToString(s->alproto);
+                    const char *proto_name = AppProtoToString(s->alproto);
                     SCLogInfo("Signature uses options that need the app layer "
                               "parser for \"%s\", but the parser's disabled "
                               "for the protocol.  Please check if you have "
index ecfcb5b2f8466349608fb36a804641809376cf9c..89eceecd59d9b6b299aae62cbbb9da1b0a02681b 100644 (file)
@@ -199,7 +199,7 @@ SCProfilingInit(void)
                 }
                 fprintf(packet_profile_csv_fp, "threading,");
                 for (i = 0; i < ALPROTO_MAX; i++) {
-                    fprintf(packet_profile_csv_fp, "%s,", TmModuleAlprotoToString(i));
+                    fprintf(packet_profile_csv_fp, "%s,", AppProtoToString(i));
                 }
                 fprintf(packet_profile_csv_fp, "STREAM (no app),proto detect,");
                 for (i = 0; i < PROF_DETECT_SIZE; i++) {
@@ -455,7 +455,7 @@ void SCProfilingDumpPacketStats(void) {
                 (long double)total * 100;
 
             fprintf(fp, "%-20s    IPv4     %3d  %12"PRIu64"     %12"PRIu64"   %12"PRIu64"  %12"PRIu64"  %12s  %-6.2f\n",
-                    TmModuleAlprotoToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent);
+                    AppProtoToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent);
         }
     }
 
@@ -473,7 +473,7 @@ void SCProfilingDumpPacketStats(void) {
                 (long double)total * 100;
 
             fprintf(fp, "%-20s    IPv6     %3d  %12"PRIu64"     %12"PRIu64"   %12"PRIu64"  %12"PRIu64"  %12s  %-6.2f\n",
-                    TmModuleAlprotoToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent);
+                    AppProtoToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent);
         }
     }