]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #74 in SNORT/snort3 from crc/targets2 to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 9 Oct 2015 20:54:16 +0000 (16:54 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 9 Oct 2015 20:54:16 +0000 (16:54 -0400)
Squashed commit of the following:

commit a7572c544b28d325ae4949e77424596c9b024577
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Oct 9 15:59:55 2015 -0400

    remove cruft pending rewrite
    replace defines with bool

src/target_based/sftarget_data.h
src/target_based/sftarget_hostentry.cc
src/target_based/sftarget_hostentry.h
src/target_based/sftarget_reader.cc
src/target_based/sftarget_reader.h
src/target_based/snort_protocols.cc
src/target_based/snort_protocols.h

index 89a219de0f9777c39f6206eedd8bc4e62109316e..e51763b16e2abcd1caedb21e35a45a646f7276a0 100644 (file)
 #define SFAT_ERROR -1
 #define SFAT_BUFSZ 1024
 
-typedef enum
+enum ServiceClient
 {
     ATTRIBUTE_SERVICE,
     ATTRIBUTE_CLIENT
-} ServiceClient;
+};
 
 #define APPLICATION_ENTRY_PORT 0x01
 #define APPLICATION_ENTRY_IPPROTO 0x02
@@ -40,18 +40,16 @@ typedef enum
 #define APPLICATION_ENTRY_APPLICATION 0x08
 #define APPLICATION_ENTRY_VERSION 0x10
 
-typedef struct _ApplicationEntry
+struct ApplicationEntry
 {
-    struct _ApplicationEntry* next;
+    ApplicationEntry* next;
 
     uint16_t port;
     uint16_t ipproto;
     uint16_t protocol;
 
     uint8_t fields;
-} ApplicationEntry;
-
-typedef ApplicationEntry ApplicationList;
+};
 
 #define HOST_INFO_OS 1
 #define HOST_INFO_VENDOR 2
@@ -72,8 +70,8 @@ struct HostAttributeEntry
 {
     sfip_t ipAddr;
     HostInfo hostInfo;
-    ApplicationList* services;
-    ApplicationList* clients;
+    ApplicationEntry* services;
+    ApplicationEntry* clients;
 };
 
 int SFAT_AddHost(HostAttributeEntry*);
@@ -83,5 +81,5 @@ int SFAT_AddHostEntryToMap(HostAttributeEntry*);
 HostAttributeEntry* SFAT_CreateHostEntry(void);
 ApplicationEntry* SFAT_CreateApplicationEntry(void);
 
-#endif /* SFTARGET_DATA_H */
+#endif
 
index 8361831d7b03edc524f1a42c078bbab71edcea92..ecfafacdc15cf20f674040e6b04767ea4a9a5cc0 100644 (file)
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-/*
- * Author: Steven Sturges
- * sftarget_hostentry.c
- */
+// sftarget_hostentry.c author Steven Sturges
 
 #include "sftarget_hostentry.h"
 
-int hasService(const HostAttributeEntry* host_entry,
-    int ipprotocol,
-    int protocol,
-    int application)
+#if 0
+static bool hasService(const HostAttributeEntry* host_entry,
+    int ipprotocol, int protocol, int application)
 {
     ApplicationEntry* service;
 
     if (!host_entry)
-        return SFTARGET_NOMATCH;
+        return false;
 
     for (service = host_entry->services; service; service = service->next)
     {
@@ -42,33 +38,29 @@ int hasService(const HostAttributeEntry* host_entry,
             {
                 if (!application)
                 {
-                    /* match of ipproto, proto.
-                     * application not speicifed */
-                    return SFTARGET_MATCH;
+                    /* match of ipproto, proto.  application not speicifed */
+                    return true;
                 }
             }
             else if (!protocol)
             {
-                /* match of ipproto.
-                 * protocol not speicifed */
-                return SFTARGET_MATCH;
+                /* match of ipproto.  protocol not speicifed */
+                return true;
             }
         }
         /* No ipprotocol specified, huh? */
     }
 
-    return SFTARGET_NOMATCH;
+    return false;
 }
 
-int hasClient(const HostAttributeEntry* host_entry,
-    int ipprotocol,
-    int protocol,
-    int application)
+static bool hasClient(const HostAttributeEntry* host_entry,
+    int ipprotocol, int protocol, int application)
 {
     ApplicationEntry* client;
 
     if (!host_entry)
-        return SFTARGET_NOMATCH;
+        return false;
 
     for (client = host_entry->clients; client; client = client->next)
     {
@@ -78,57 +70,34 @@ int hasClient(const HostAttributeEntry* host_entry,
             {
                 if (!application)
                 {
-                    /* match of ipproto, proto.
-                     * application not speicifed */
-                    return SFTARGET_MATCH;
+                    /* match of ipproto, proto.  application not speicifed */
+                    return true;
                 }
             }
             else if (!protocol)
             {
-                /* match of ipproto.
-                 * protocol not speicifed */
-                return SFTARGET_MATCH;
+                /* match of ipproto.  protocol not speicifed */
+                return true;
             }
         }
         /* No ipprotocol specified, huh? */
     }
 
-    return SFTARGET_NOMATCH;
-}
-
-int hasProtocol(const HostAttributeEntry* host_entry,
-    int ipprotocol,
-    int protocol,
-    int application)
-{
-    int ret = SFTARGET_NOMATCH;
-
-    ret = hasService(host_entry, ipprotocol, protocol, application);
-    if (ret == SFTARGET_MATCH)
-        return ret;
-
-    ret = hasClient(host_entry, ipprotocol, protocol, application);
-    if (ret == SFTARGET_MATCH)
-        return ret;
-
-    return ret;
+    return false;
 }
 
-uint16_t getFragPolicy(const HostAttributeEntry* host_entry)
+bool hasProtocol(const HostAttributeEntry* host_entry,
+    int ipprotocol, int protocol, int application)
 {
-    if (!host_entry)
-        return SFAT_UNKNOWN_FRAG_POLICY;
+    if ( hasService(host_entry, ipprotocol, protocol, application) )
+        return true;
 
-    return host_entry->hostInfo.fragPolicy;
-}
-
-uint16_t getStreamPolicy(const HostAttributeEntry* host_entry)
-{
-    if (!host_entry)
-        return SFAT_UNKNOWN_STREAM_POLICY;
+    if ( hasClient(host_entry, ipprotocol, protocol, application) )
+        return true;
 
-    return host_entry->hostInfo.streamPolicy;
+    return false;
 }
+#endif
 
 int getApplicationProtocolId(const HostAttributeEntry* host_entry,
     int ipprotocol,
index 397b7bba39ba8e6241bc021fb56996b59b0c67d9..3744fed6eba880f30a530ead6db2a44bf03e57cf 100644 (file)
 #include "target_based/sftarget_reader.h"
 #include "target_based/sftarget_data.h"
 
-#define SFTARGET_MATCH 1
-#define SFTARGET_NOMATCH 0
-
 /* API for HostAttributeEntry 'class' */
 
-// FIXIT-L used locally only
-int hasService(const HostAttributeEntry* hostEntry,
-    int ipprotocol,
-    int protocol,
-    int application);
-
-// FIXIT-L used locally only
-int hasClient(const HostAttributeEntry* hostEntry,
-    int ipprotocol,
-    int protocol,
-    int application);
-
-// FIXIT-L not used anywhere
-int hasProtocol(const HostAttributeEntry* hostEntry,
-    int ipprotocol,
-    int protocol,
-    int application);
-
-// FIXIT-L not used anywhere
-int getProtocol(const HostAttributeEntry* hostEntry,
-    int ipprotocol,
-    uint16_t port);
-
-int getApplicationProtocolId(const HostAttributeEntry* host_entry,
-    int ipprotocol,
-    uint16_t port,
-    char direction);
+#if 0
+bool hasProtocol(const HostAttributeEntry*, int ipprotocol, int protocol, int application);
+#endif
 
-// FIXIT-L not used anywhere
-#define SFAT_UNKNOWN_STREAM_POLICY 0
-uint16_t getStreamPolicy(const HostAttributeEntry* host_entry);
-#define SFAT_UNKNOWN_FRAG_POLICY 0
-uint16_t getFragPolicy(const HostAttributeEntry* host_entry);
+int getApplicationProtocolId(
+    const HostAttributeEntry*, int ipprotocol, uint16_t port, char direction);
 
 #endif
 
index 201bf0a547c91269474a80be494c067e0a33d198..4b2ef9e1dd79a2177431be9be86bb4067224df64 100644 (file)
@@ -157,7 +157,7 @@ void FreeHostEntry(HostAttributeEntry* host)
     free(host);
 }
 
-static void AppendApplicationData(ApplicationList** list, ApplicationEntry* app)
+static void AppendApplicationData(ApplicationEntry** list, ApplicationEntry* app)
 {
     if (!list)
         return;
@@ -175,6 +175,7 @@ int SFAT_AddService(HostAttributeEntry* host, ApplicationEntry* app)
     return SFAT_OK;
 }
 
+#if 0
 int SFAT_AddApplicationData(HostAttributeEntry* host, ApplicationEntry* app)
 {
     uint8_t required_fields =
@@ -191,6 +192,7 @@ int SFAT_AddApplicationData(HostAttributeEntry* host, ApplicationEntry* app)
 
     return SFAT_OK;
 }
+#endif
 
 #ifdef DEBUG_MSGS
 void PrintHostAttributeEntry(HostAttributeEntry* host)
index 8f4bcb69130bf263d62b7b9c9a93933a7a3e2b17..3edbe878b4c8866a6b989706b050ac718ee19752 100644 (file)
@@ -52,8 +52,11 @@ uint32_t SFAT_NumberOfHosts(void);
 HostAttributeEntry* SFAT_LookupHostEntryByIP(const sfip_t* ipAddr);
 HostAttributeEntry* SFAT_LookupHostEntryBySrc(Packet* p);
 HostAttributeEntry* SFAT_LookupHostEntryByDst(Packet* p);
-void SFAT_UpdateApplicationProtocol(
-    sfip_t* ipAddr, uint16_t port, uint16_t protocol, uint16_t id);
+
+#if 0
+int SFAT_AddApplicationData(HostAttributeEntry*, struct ApplicationEntry*);
+#endif
+void SFAT_UpdateApplicationProtocol(sfip_t*, uint16_t port, uint16_t protocol, uint16_t id);
 
 // reload functions
 struct tTargetBasedConfig;
index 162fc170899819ce0661dfe5eab579976cdccd42..8302f151fd67952413487fc92f165ac62784c0d0 100644 (file)
@@ -165,6 +165,7 @@ void FreeProtoocolReferenceTable(void)
     proto_reference_table = NULL;
 }
 
+#if 0
 int16_t GetProtocolReference(Packet* p)
 {
     int16_t protocol = 0;
@@ -230,4 +231,5 @@ int16_t GetProtocolReference(Packet* p)
 
     return protocol;
 }
+#endif
 
index 33f1d5651ccb9ec59684cc55349445b9a608592f..ca80da9a4be94a7cdb32972a6dd16953d2bc05c3 100644 (file)
@@ -61,7 +61,9 @@ const char* get_protocol_name_sorted(uint16_t id);
 int16_t AddProtocolReference(const char* protocol);
 SO_PUBLIC int16_t FindProtocolReference(const char* protocol);
 
+#if 0
 int16_t GetProtocolReference(struct Packet*);
+#endif
 
 #endif