From: Josh Date: Mon, 21 Apr 2014 16:59:43 +0000 (-0400) Subject: Added static/dynamic build api to all plugins X-Git-Tag: 3.0.0-233~1559^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9e50b9514ac87f5eabd9fc0867b4c3fe7ab0fac;p=thirdparty%2Fsnort3.git Added static/dynamic build api to all plugins --- diff --git a/src/codecs/codec_api.cc b/src/codecs/codec_api.cc index d29484d7d..ee50e0b3c 100644 --- a/src/codecs/codec_api.cc +++ b/src/codecs/codec_api.cc @@ -38,8 +38,23 @@ const BaseApi* codecs[] = cd_esp, #ifdef STATIC_DECODERS + cd_ah, + cd_arp, + cd_erspan2, + cd_erspan3, + cd_ethloopback, + cd_gre, + cd_gtp, + cd_mpls, + cd_pppencap, + cd_pppoe, + cd_swipe, + cd_teredo, + cd_transbridge, + cd_vlan, #endif + nullptr }; diff --git a/src/codecs/codec_api.h b/src/codecs/codec_api.h index dc53e292d..45aa8f8d0 100644 --- a/src/codecs/codec_api.h +++ b/src/codecs/codec_api.h @@ -33,6 +33,20 @@ extern const BaseApi* cd_udp; extern const BaseApi* cd_esp; #ifdef STATIC_DECODERS +extern const BaseApi* cd_ah; +extern const BaseApi* cd_arp; +extern const BaseApi* cd_erspan2; +extern const BaseApi* cd_erspan3; +extern const BaseApi* cd_ethloopback; +extern const BaseApi* cd_gre; +extern const BaseApi* cd_gtp; +extern const BaseApi* cd_mpls; +extern const BaseApi* cd_pppencap; +extern const BaseApi* cd_pppoe; +extern const BaseApi* cd_swipe; +extern const BaseApi* cd_teredo; +extern const BaseApi* cd_transbridge; +extern const BaseApi* cd_vlan; #endif diff --git a/src/codecs/plugins/cd_ah.cc b/src/codecs/plugins/cd_ah.cc index b4ccea9a1..f591c2f70 100644 --- a/src/codecs/plugins/cd_ah.cc +++ b/src/codecs/plugins/cd_ah.cc @@ -38,7 +38,7 @@ class AhCodec : public Codec { public: AhCodec() : Codec("ah"){}; - ~AhCodec(); + ~AhCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -101,7 +101,7 @@ static void stats() -static const char* name = "ah_decode"; +static const char* name = "ah_codec"; static const CodecApi ah_api = { @@ -117,3 +117,15 @@ static const CodecApi ah_api = }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &ah_api.base, + nullptr +}; +#else +const BaseApi* cd_ah = &ah_api.base; +#endif + + + diff --git a/src/codecs/plugins/cd_arp.cc b/src/codecs/plugins/cd_arp.cc index bfef8b374..65e655978 100644 --- a/src/codecs/plugins/cd_arp.cc +++ b/src/codecs/plugins/cd_arp.cc @@ -36,15 +36,14 @@ namespace class ArpCodec : public Codec { public: - ArpCodec() : Codec("NAME"){}; - ~ArpCodec(); + ArpCodec() : Codec("Arp"){}; + ~ArpCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; @@ -131,7 +130,7 @@ static void stats() static const char* name = "arp_codec"; -static const CodecApi codec_api = +static const CodecApi arp_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -144,4 +143,16 @@ static const CodecApi codec_api = stats // stats }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &arp_api.base, + nullptr +}; +#else +const BaseApi* cd_arp = &arp_api.base; +#endif + + + diff --git a/src/codecs/plugins/cd_dstopts.cc b/src/codecs/plugins/cd_dstopts.cc index 2043d945a..295a314c8 100644 --- a/src/codecs/plugins/cd_dstopts.cc +++ b/src/codecs/plugins/cd_dstopts.cc @@ -44,7 +44,7 @@ namespace class NameCodec : public Codec { public: - NameCodec() : Codec("NAME"){}; + NameCodec() : Codec("dstopts"){}; ~NameCodec(); diff --git a/src/codecs/plugins/cd_erspan2.cc b/src/codecs/plugins/cd_erspan2.cc index b754e5ab9..dbea43c88 100644 --- a/src/codecs/plugins/cd_erspan2.cc +++ b/src/codecs/plugins/cd_erspan2.cc @@ -33,14 +33,13 @@ class Erspan2Codec : public Codec { public: Erspan2Codec() : Codec("ERSPAN_2"){}; - ~Erspan2Codec(); + ~Erspan2Codec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; @@ -140,7 +139,7 @@ static void stats() static const char* name = "erspan2_codec"; -static const CodecApi codec_api = +static const CodecApi erspan2_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -152,3 +151,13 @@ static const CodecApi codec_api = sum, // sum stats // stats }; + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &erspan2_api.base, + nullptr +}; +#else +const BaseApi* cd_erspan2 = &erspan2_api.base; +#endif diff --git a/src/codecs/plugins/cd_erspan3.cc b/src/codecs/plugins/cd_erspan3.cc index af30e3d53..71014aa02 100644 --- a/src/codecs/plugins/cd_erspan3.cc +++ b/src/codecs/plugins/cd_erspan3.cc @@ -35,14 +35,13 @@ class Erspan3Codec : public Codec { public: Erspan3Codec() : Codec("ERSPAN_3"){}; - ~Erspan3Codec(); + ~Erspan3Codec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; @@ -143,7 +142,7 @@ static void stats() static const char* name = "erspan3_codec"; -static const CodecApi codec_api = +static const CodecApi erspan3_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -156,3 +155,14 @@ static const CodecApi codec_api = stats // stats }; + + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &erspan3_api.base, + nullptr +}; +#else +const BaseApi* cd_erspan3 = &erspan3_api.base; +#endif diff --git a/src/codecs/plugins/cd_ethloopback.cc b/src/codecs/plugins/cd_ethloopback.cc index ae3439b41..c160238df 100644 --- a/src/codecs/plugins/cd_ethloopback.cc +++ b/src/codecs/plugins/cd_ethloopback.cc @@ -32,7 +32,7 @@ class EthLoopbackCodec : public Codec { public: EthLoopbackCodec() : Codec("Ethloopback"){}; - ~EthLoopbackCodec(); + ~EthLoopbackCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -100,7 +100,7 @@ static void stats() static const char* name = "ethloopback_codec"; -static const CodecApi codec_api = +static const CodecApi ethloopback_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -112,3 +112,16 @@ static const CodecApi codec_api = sum, // sum stats // stats }; + + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + ðloopback_api.base, + nullptr +}; +#else +const BaseApi* cd_ethloopback = ðloopback_api.base; +#endif + + diff --git a/src/codecs/plugins/cd_fragment.cc b/src/codecs/plugins/cd_fragment.cc index 2043d945a..16233519c 100644 --- a/src/codecs/plugins/cd_fragment.cc +++ b/src/codecs/plugins/cd_fragment.cc @@ -52,7 +52,6 @@ public: Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; diff --git a/src/codecs/plugins/cd_gre.cc b/src/codecs/plugins/cd_gre.cc index 74ee495bf..486e4e7ce 100644 --- a/src/codecs/plugins/cd_gre.cc +++ b/src/codecs/plugins/cd_gre.cc @@ -35,7 +35,7 @@ class GreCodec : public Codec { public: GreCodec() : Codec("GRE"){}; - ~GreCodec(); + ~GreCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -279,7 +279,7 @@ static void stats() static const char* name = "gre_codec"; -static const CodecApi codec_api = +static const CodecApi gre_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -292,4 +292,14 @@ static const CodecApi codec_api = stats // stats }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &gre_api.base, + nullptr +}; +#else +const BaseApi* cd_gre = &gre_api.base; +#endif + diff --git a/src/codecs/plugins/cd_gtp.cc b/src/codecs/plugins/cd_gtp.cc index e159dbb31..ded90aa18 100644 --- a/src/codecs/plugins/cd_gtp.cc +++ b/src/codecs/plugins/cd_gtp.cc @@ -46,15 +46,13 @@ class GtpCodec : public Codec { public: GtpCodec() : Codec("GTP"){}; - ~GtpCodec(); + ~GtpCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); - virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; - + virtual void get_protocol_ids(std::vector&); }; } // anonymous namespace @@ -68,7 +66,7 @@ public: * */ -bool decode(const uint8_t *raw_pkt, const uint32_t len, +bool GtpCodec::decode(const uint8_t *raw_pkt, const uint32_t len, Packet *p, uint16_t &p_hdr_len, int &next_prot_id) { uint32_t header_len; @@ -291,7 +289,7 @@ static void dtor(Codec *cd) static const char* name = "gtp_codec"; -static const CodecApi ipv6_api = +static const CodecApi gtp_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -303,3 +301,14 @@ static const CodecApi ipv6_api = NULL, // sum NULL // stats }; + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + >p_api.base, + nullptr +}; +#else +const BaseApi* cd_gtp = >p_api.base; +#endif + diff --git a/src/codecs/plugins/cd_mpls.cc b/src/codecs/plugins/cd_mpls.cc index 43e60685a..05822c073 100644 --- a/src/codecs/plugins/cd_mpls.cc +++ b/src/codecs/plugins/cd_mpls.cc @@ -41,7 +41,7 @@ class MplsCodec : public Codec { public: MplsCodec() : Codec("MPLS"){}; - ~MplsCodec(); + ~MplsCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -287,7 +287,7 @@ static void stats() static const char* name = "mpls_codec"; -static const CodecApi codec_api = +static const CodecApi mpls_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -300,6 +300,17 @@ static const CodecApi codec_api = stats // stats }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &mpls_api.base, + nullptr +}; +#else +const BaseApi* cd_mpls = &mpls_api.base; +#endif + + diff --git a/src/codecs/plugins/cd_pppencap.cc b/src/codecs/plugins/cd_pppencap.cc index 27bf5ffe5..d4996de93 100644 --- a/src/codecs/plugins/cd_pppencap.cc +++ b/src/codecs/plugins/cd_pppencap.cc @@ -40,14 +40,13 @@ class PppEncap : public Codec { public: PppEncap() : Codec("PPPEncapsulation"){}; - ~PppEncap(); + ~PppEncap(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; @@ -204,7 +203,7 @@ static void stats() static const char* name = "pppencap_codec"; -static const CodecApi codec_api = +static const CodecApi pppencap_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -218,3 +217,16 @@ static const CodecApi codec_api = }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &pppencap_api.base, + nullptr +}; +#else +const BaseApi* cd_pppencap = &pppencap_api.base; +#endif + + + + diff --git a/src/codecs/plugins/cd_pppoepkt.cc b/src/codecs/plugins/cd_pppoepkt.cc index 0a3d5b3e1..e24c6ff30 100644 --- a/src/codecs/plugins/cd_pppoepkt.cc +++ b/src/codecs/plugins/cd_pppoepkt.cc @@ -34,14 +34,13 @@ class PPPoEPkt : public Codec { public: PPPoEPkt() : Codec("PPP_over_Eth"){}; - ~PPPoEPkt(); + ~PPPoEPkt(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; @@ -317,7 +316,7 @@ static void stats() static const char* name = "pppoe_codec"; -static const CodecApi codec_api = +static const CodecApi pppoe_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -330,3 +329,16 @@ static const CodecApi codec_api = stats // stats }; + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &pppoe_api.base, + nullptr +}; +#else +const BaseApi* cd_pppoe = &pppoe_api.base; +#endif + + + diff --git a/src/codecs/plugins/cd_swipe.cc b/src/codecs/plugins/cd_swipe.cc index 7955351e4..b24034eaa 100644 --- a/src/codecs/plugins/cd_swipe.cc +++ b/src/codecs/plugins/cd_swipe.cc @@ -40,7 +40,7 @@ class SwipeCodec : public Codec{ public: SwipeCodec() : Codec("swipe"){}; - virtual ~SwipeCodec(); + virtual ~SwipeCodec(){}; virtual bool decode(const uint8_t* raw_packet, const uint32_t raw_len, Packet *p, uint16_t &p_hdr_len, int &next_prot_id); @@ -82,7 +82,7 @@ static void dtor(Codec *cd) delete cd; } -static const CodecApi udp_api = +static const CodecApi swipe_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -96,3 +96,15 @@ static const CodecApi udp_api = }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &swipe_api.base, + nullptr +}; +#else +const BaseApi* cd_swipe = &swipe_api.base; +#endif + + + diff --git a/src/codecs/plugins/cd_teredo.cc b/src/codecs/plugins/cd_teredo.cc index 18bff15e8..99f29dfdc 100644 --- a/src/codecs/plugins/cd_teredo.cc +++ b/src/codecs/plugins/cd_teredo.cc @@ -48,7 +48,7 @@ class TeredoCodec : public Codec { public: TeredoCodec() : Codec("teredo"){}; - ~TeredoCodec(); + ~TeredoCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -132,9 +132,9 @@ static void dtor(Codec *cd) delete cd; } -static const char* name = "teredo_codec"; +static const char* name = "teredo"; -static const CodecApi ipv6_api = +static const CodecApi teredo_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -143,6 +143,22 @@ static const CodecApi ipv6_api = NULL, // tterm ctor, // ctor dtor, // dtor + NULL, + NULL }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &teredo_api.base, + nullptr +}; +#else +const BaseApi* cd_teredo = &teredo_api.base; +#endif + + + + + diff --git a/src/codecs/plugins/cd_transbridge.cc b/src/codecs/plugins/cd_transbridge.cc index 068726f44..f71820aa7 100644 --- a/src/codecs/plugins/cd_transbridge.cc +++ b/src/codecs/plugins/cd_transbridge.cc @@ -41,7 +41,7 @@ class TransbridgeCodec : public Codec { public: TransbridgeCodec() : Codec("Transbridge"){}; - ~TransbridgeCodec(); + ~TransbridgeCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -126,7 +126,7 @@ static void stats() -static const char* name = "transbridge_codec"; +static const char* name = "transbridge"; static const CodecApi transbridge_api = { @@ -142,5 +142,16 @@ static const CodecApi transbridge_api = }; +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &transbridge_api.base, + nullptr +}; +#else +const BaseApi* cd_transbridge = &transbridge_api.base; +#endif + + diff --git a/src/codecs/plugins/cd_vlan.cc b/src/codecs/plugins/cd_vlan.cc index d9d31a637..b89574508 100644 --- a/src/codecs/plugins/cd_vlan.cc +++ b/src/codecs/plugins/cd_vlan.cc @@ -48,7 +48,7 @@ class VlanCodec : public Codec { public: VlanCodec() : Codec("vlan"){}; - ~VlanCodec(); + ~VlanCodec(){}; virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, @@ -201,7 +201,7 @@ static void stats() -static const char* name = "VLAN"; +static const char* name = "vlan"; static const CodecApi vlan_api = { @@ -216,3 +216,14 @@ static const CodecApi vlan_api = stats // stats }; + +#ifdef BUILDING_SO +SO_PUBLIC const BaseApi* snort_plugins[] = +{ + &vlan_api.base, + nullptr +}; +#else +const BaseApi* cd_vlan = &vlan_api.base; +#endif +