From: Josh Date: Mon, 28 Apr 2014 17:21:51 +0000 (-0400) Subject: Merging with Version 75 X-Git-Tag: 3.0.0-233~1545 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9dcc19c4ae987c1f29da7a35e405bb48dfac46eb;p=thirdparty%2Fsnort3.git Merging with Version 75 --- 9dcc19c4ae987c1f29da7a35e405bb48dfac46eb diff --cc src/events/codec_events.h index 000000000,b9c5a6fe9..e69de29bb mode 000000,100644..100644 --- a/src/events/codec_events.h +++ b/src/events/codec_events.h diff --cc src/events/codec_events.h.bak index 000000000,000000000..b9c5a6fe9 new file mode 100644 --- /dev/null +++ b/src/events/codec_events.h.bak @@@ -1,0 -1,0 +1,54 @@@ ++/* ++** Copyright (C) 2002-2013 Sourcefire, Inc. ++** Copyright (C) 1998-2002 Martin Roesch ++** ++** This program is free software; you can redistribute it and/or modify ++** it under the terms of the GNU General Public License Version 2 as ++** published by the Free Software Foundation. You may not use, modify or ++** distribute this program under any other version of the GNU General ++** Public License. ++** ++** This program is distributed in the hope that it will be useful, ++** but WITHOUT ANY WARRANTY; without even the implied warranty of ++** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++** GNU General Public License for more details. ++** ++** You should have received a copy of the GNU General Public License ++** along with this program; if not, write to the Free Software ++** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++*/ ++ ++#ifndef CODEC_EVENTS_H ++#define CODEC_EVENTS_H ++ ++#include ++ ++// included for DECODE_INDEX_MAX ++#include "detection/generators.h" ++//#include "utils/sfActionQueue.h" ++#include "network_inspectors/normalize/normalize.h" ++#include "protocols/packet.h" ++#include "time/profiler.h" ++#include "codecs/decode_module.h" ++ ++namespace codec_events ++{ ++ ++ void exec_ip_chksm_drop(Packet*); ++ void exec_udp_chksm_drop (Packet *); ++ void exec_tcp_chksm_drop (Packet*); ++ void exec_hop_drop(Packet* p, int sid); ++ void exec_ttl_drop (Packet *data, int sid); ++ void exec_icmp_chksm_drop (Packet*); ++ ++ void decoder_event (Packet *, int); ++ void decoder_alert_encapsulated( ++ Packet *p, int sid, const uint8_t *pkt, uint32_t len); ++ ++ int ScNormalDrop (NormFlags nf); ++ ++} //namespace codec_events ++ ++ ++#endif ++ diff --cc src/managers/CMakeLists.txt index 34a6b4b11,34a6b4b11..9d0ec7da9 --- a/src/managers/CMakeLists.txt +++ b/src/managers/CMakeLists.txt @@@ -38,6 -38,6 +38,8 @@@ target_link_libraries(manager service_inspectors search_engines parser ++ codecs ++ basic_codecs ) install (FILES ${LUA_INCLUDES} diff --cc src/managers/packet_manager.cc index 09f127245,09f127245..496eafdfc --- a/src/managers/packet_manager.cc +++ b/src/managers/packet_manager.cc @@@ -32,6 -32,6 +32,7 @@@ #include "protocols/packet.h" #include "protocols/undefined_protocols.h" #include "time/profiler.h" ++#include "parser/parser.h" namespace @@@ -61,13 -61,13 +62,36 @@@ THREAD_LOCAL PreprocStats decodePerfSta static const uint16_t max_protocol_id = 65535; static std::list s_codecs; --static std::array s_protocols; ++//static std::array s_protocols; // statistics information static THREAD_LOCAL std::array s_stats; static std::array g_stats; static THREAD_LOCAL CdGenPegs pkt_cnt; ++static std::array s_proto_map; ++static std::array s_protocols; ++ ++extern const BaseApi* cd_unimplemented; ++static THREAD_LOCAL uint8_t grinder; ++static bool initial_instatiation = true; ++ ++//------------------------------------------------------------------------- ++// helper functions ++//------------------------------------------------------------------------- ++ ++// note that we now have multiple preproc configs saved by parser ++// (s5-global, s5-tcp, ..., etc.) but just one ppapi. that means ++// we must call the config func multiple times but add only the 1st ++// instance to the policy list. ++static inline const CodecApi* GetApi(const char* keyword) ++{ ++ for ( auto* p : s_codecs ) ++ if ( !strncasecmp(p->base.name, keyword, strlen(p->base.name)) ) ++ return p; ++ return NULL; ++} ++ //------------------------------------------------------------------------- // plugins @@@ -93,15 -93,15 +117,23 @@@ void PacketManager::add_plugin(const Co api->base.name); s_codecs.push_back(api); ++ ++ if (api->ginit) ++ api->ginit(); } void PacketManager::release_plugins() { ++ // loop through classes ++ // find corresponding api ++ // delete class using api and module ++ // delete class from codecs_array ++ // remove api pointer for ( auto* p : s_codecs ) { ++// p->dtor(); if(p->gterm) p->gterm(); --// p->dtor(); } s_codecs.clear(); } @@@ -114,6 -114,6 +146,22 @@@ void PacketManager::dump_plugins( d.dump(p->base.name, p->base.version); } ++void PacketManager::instantiate(const CodecApi* cd_api, Module* m, SnortConfig* sc) ++{ ++ const CodecApi *p = GetApi(cd_api->base.name); ++ ++ if(!p) ++ { ++ ParseError("Unknown codec: '%s'.", cd_api->base.name); ++ } ++ else ++ { ++ p->ctor(); ++ } ++} ++ ++ ++ //------------------------------------------------------------------------- // grinder //------------------------------------------------------------------------- @@@ -169,6 -169,6 +217,8 @@@ void PacketManager::set_grinder(void std::vector proto; std::vector dlt; bool codec_registered; ++ uint16_t cd_cnt = 0; ++ int daq_dlt = DAQ_GetBaseProtocol(); @@@ -176,11 -176,11 +226,6 @@@ { codec_registered = false; -- if (p->ginit) -- p->ginit(); -- -- if (p->tinit) -- p->tinit(); // TODO: add module // null check performed when plugin added. @@@ -224,6 -224,6 +269,10 @@@ if (!codec_registered) WarningMessage("The Codec %s is never used\n", cd->get_name()); ++ ++ ++ if (p->tinit) ++ p->tinit(); } } diff --cc src/managers/packet_manager.h index 4b141629e,4b141629e..373b95377 --- a/src/managers/packet_manager.h +++ b/src/managers/packet_manager.h @@@ -26,6 -26,6 +26,7 @@@ #include "framework/codec.h" #include "time/profiler.h" #include "utils/stats.h" ++#include "snort_config.h" #include #include @@@ -47,11 -47,11 +48,16 @@@ public static void dump_plugins(); static void release_plugins(); -- static void set_grinder(); -- static void decode(Packet*, const struct _daq_pkthdr*, const uint8_t*); ++ static void instantiate(const CodecApi*, Module*, SnortConfig*); ++ ++ static void set_grinder(); // thread_init ++ static void thread_term(); ++ static void init_codecs(); ++ static void term_codecs(); ++ ++ static void decode(Packet*, const struct _daq_pkthdr*, const uint8_t*); static void dump_stats(); -- static void thread_term(); static bool has_codec(uint16_t); diff --cc src/managers/plugin_manager.cc index f578e9fc9,f578e9fc9..1d093f18b --- a/src/managers/plugin_manager.cc +++ b/src/managers/plugin_manager.cc @@@ -352,7 -352,7 +352,7 @@@ void PluginManager::instantiate break; case PT_CODEC: -- //PacketManager::instantiate((IpsApi*)api, mod, sc); ++ PacketManager::instantiate((CodecApi*)api, mod, sc); break; case PT_LOGGER: