--- /dev/null
--- /dev/null
++/*
++** 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
++
service_inspectors
search_engines
parser
++ codecs
++ basic_codecs
)
install (FILES ${LUA_INCLUDES}
#include "protocols/packet.h"
#include "protocols/undefined_protocols.h"
#include "time/profiler.h"
++#include "parser/parser.h"
namespace
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
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();
}
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
//-------------------------------------------------------------------------
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();
}
}
#include "framework/codec.h"
#include "time/profiler.h"
#include "utils/stats.h"
++#include "snort_config.h"
#include <array>
#include <list>
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);
break;
case PT_CODEC:
-- //PacketManager::instantiate((IpsApi*)api, mod, sc);
++ PacketManager::instantiate((CodecApi*)api, mod, sc);
break;
case PT_LOGGER: