From: Russ Combs (rucombs) Date: Fri, 9 Oct 2015 20:54:16 +0000 (-0400) Subject: Merge pull request #74 in SNORT/snort3 from crc/targets2 to master X-Git-Tag: 3.0.0-233~791 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a14634feb07ce964501210ffe924eecf0a89ccb9;p=thirdparty%2Fsnort3.git Merge pull request #74 in SNORT/snort3 from crc/targets2 to master Squashed commit of the following: commit a7572c544b28d325ae4949e77424596c9b024577 Author: Russ Combs Date: Fri Oct 9 15:59:55 2015 -0400 remove cruft pending rewrite replace defines with bool --- diff --git a/src/target_based/sftarget_data.h b/src/target_based/sftarget_data.h index 89a219de0..e51763b16 100644 --- a/src/target_based/sftarget_data.h +++ b/src/target_based/sftarget_data.h @@ -28,11 +28,11 @@ #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 diff --git a/src/target_based/sftarget_hostentry.cc b/src/target_based/sftarget_hostentry.cc index 8361831d7..ecfafacdc 100644 --- a/src/target_based/sftarget_hostentry.cc +++ b/src/target_based/sftarget_hostentry.cc @@ -17,22 +17,18 @@ // 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, diff --git a/src/target_based/sftarget_hostentry.h b/src/target_based/sftarget_hostentry.h index 397b7bba3..3744fed6e 100644 --- a/src/target_based/sftarget_hostentry.h +++ b/src/target_based/sftarget_hostentry.h @@ -25,44 +25,14 @@ #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 diff --git a/src/target_based/sftarget_reader.cc b/src/target_based/sftarget_reader.cc index 201bf0a54..4b2ef9e1d 100644 --- a/src/target_based/sftarget_reader.cc +++ b/src/target_based/sftarget_reader.cc @@ -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) diff --git a/src/target_based/sftarget_reader.h b/src/target_based/sftarget_reader.h index 8f4bcb691..3edbe878b 100644 --- a/src/target_based/sftarget_reader.h +++ b/src/target_based/sftarget_reader.h @@ -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; diff --git a/src/target_based/snort_protocols.cc b/src/target_based/snort_protocols.cc index 162fc1708..8302f151f 100644 --- a/src/target_based/snort_protocols.cc +++ b/src/target_based/snort_protocols.cc @@ -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 diff --git a/src/target_based/snort_protocols.h b/src/target_based/snort_protocols.h index 33f1d5651..ca80da9a4 100644 --- a/src/target_based/snort_protocols.h +++ b/src/target_based/snort_protocols.h @@ -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