]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merging with Version 75
authorJosh <jrosenba@cisco.com>
Mon, 28 Apr 2014 17:21:51 +0000 (13:21 -0400)
committerJosh <jrosenba@cisco.com>
Mon, 28 Apr 2014 17:21:51 +0000 (13:21 -0400)
1  2 
src/events/codec_events.h
src/events/codec_events.h.bak
src/managers/CMakeLists.txt
src/managers/packet_manager.cc
src/managers/packet_manager.h
src/managers/plugin_manager.cc

index 0000000000000000000000000000000000000000,b9c5a6fe96c380ba3042b14cdce7071d21e56777..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
mode 000000,100644..100644
--- /dev/null
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..b9c5a6fe96c380ba3042b14cdce7071d21e56777
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,54 @@@
++/*
++** Copyright (C) 2002-2013 Sourcefire, Inc.
++** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
++**
++** 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 <array>
++
++// 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
++
index 34a6b4b11876aa75afe25a1a2c3a0634545bf298,34a6b4b11876aa75afe25a1a2c3a0634545bf298..9d0ec7da99bb1c46edb54fd76a2f12d9a67c58d9
@@@ -38,6 -38,6 +38,8 @@@ target_link_libraries(manager
      service_inspectors
      search_engines
      parser
++    codecs
++    basic_codecs
  )
  
  install (FILES ${LUA_INCLUDES}
index 09f12724588968d7776a759bd309263be5f65678,09f12724588968d7776a759bd309263be5f65678..496eafdfc0b295a706a981ddff33a1edcb635cef
@@@ -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<const CodecApi*> s_codecs;
--static std::array<Codec*, max_protocol_id> s_protocols;
++//static std::array<Codec*, max_protocol_id> s_protocols;
  
  // statistics information
  static THREAD_LOCAL std::array<PegCount, max_protocol_id + gen_peg_size> s_stats;
  static std::array<PegCount, max_protocol_id + gen_peg_size> g_stats;
  static THREAD_LOCAL CdGenPegs pkt_cnt;
  
++static std::array<uint8_t, max_protocol_id> s_proto_map;
++static std::array<Codec*, 256> 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<uint16_t> proto;
      std::vector<int> dlt;
      bool codec_registered;
++    uint16_t cd_cnt = 0;
++
  
      int daq_dlt = DAQ_GetBaseProtocol();
  
      {
          codec_registered = false;
  
--        if (p->ginit)
--            p->ginit();
--
--        if (p->tinit)
--            p->tinit();
  
          // TODO:  add module
          // null check performed when plugin added.
  
          if (!codec_registered)
              WarningMessage("The Codec %s is never used\n", cd->get_name());
++
++
++        if (p->tinit)
++            p->tinit();
      }
  }
  
index 4b141629e8680a56af4d7641b02fe0d1e0b38a83,4b141629e8680a56af4d7641b02fe0d1e0b38a83..373b9537716606da37f6d6667850a8a78045f132
@@@ -26,6 -26,6 +26,7 @@@
  #include "framework/codec.h"
  #include "time/profiler.h"
  #include "utils/stats.h"
++#include "snort_config.h"
  
  #include <array>
  #include <list>
@@@ -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);
  
index f578e9fc909ca4932de5a7cf4c895ce39bee189e,f578e9fc909ca4932de5a7cf4c895ce39bee189e..1d093f18b52d8a11c3c2dc9e61afbcac2d07468b
@@@ -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: