From: Josh Date: Thu, 28 Aug 2014 16:47:12 +0000 (-0400) Subject: moving SO_PUBLIC into header files X-Git-Tag: 3.0.0-233~1417^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c89ba3f6250cfa7193860ccc2b9f4df337fc147d;p=thirdparty%2Fsnort3.git moving SO_PUBLIC into header files --- diff --git a/src/flow/flow.cc b/src/flow/flow.cc index 499f47aa0..627479077 100644 --- a/src/flow/flow.cc +++ b/src/flow/flow.cc @@ -34,14 +34,14 @@ unsigned FlowData:: flow_id = 0; -SO_PUBLIC FlowData::FlowData(unsigned u, Inspector* ph) +FlowData::FlowData(unsigned u, Inspector* ph) { assert(u > 0); id = u; handler = ph; if ( handler ) handler->add_ref(); } -SO_PUBLIC FlowData::~FlowData() +FlowData::~FlowData() { if ( handler ) handler->rem_ref(); } Flow::Flow () diff --git a/src/flow/flow.h b/src/flow/flow.h index c4322caae..8c01fda20 100644 --- a/src/flow/flow.h +++ b/src/flow/flow.h @@ -90,7 +90,7 @@ struct StreamFlowData unsigned char flowb[1]; }; -class FlowData +class SO_PUBLIC FlowData { public: FlowData(unsigned u, Inspector* = nullptr); diff --git a/src/framework/counts.h b/src/framework/counts.h index 0626f72b3..d52574afe 100644 --- a/src/framework/counts.h +++ b/src/framework/counts.h @@ -31,7 +31,7 @@ struct SimpleStats PegCount total_packets; }; -extern const char* simple_pegs[]; +SO_PUBLIC extern const char* simple_pegs[]; #define array_size(a) (sizeof(a)/sizeof(a[0])) diff --git a/src/framework/inspector.cc b/src/framework/inspector.cc index 7319b9fb9..baf06c005 100644 --- a/src/framework/inspector.cc +++ b/src/framework/inspector.cc @@ -29,10 +29,10 @@ // packet handler stuff //------------------------------------------------------------------------- -SO_PUBLIC unsigned THREAD_LOCAL Inspector::slot = 0; +unsigned THREAD_LOCAL Inspector::slot = 0; unsigned Inspector::max_slots = 1; -SO_PUBLIC Inspector::Inspector() +Inspector::Inspector() { unsigned max = get_instance_max(); assert(slot < max); @@ -42,7 +42,7 @@ SO_PUBLIC Inspector::Inspector() ref_count[i] = 0; } -SO_PUBLIC Inspector::~Inspector() +Inspector::~Inspector() { unsigned total = 0; @@ -54,7 +54,7 @@ SO_PUBLIC Inspector::~Inspector() delete[] ref_count; } -SO_PUBLIC bool Inspector::is_inactive() +bool Inspector::is_inactive() { for (unsigned i = 0; i < get_instance_max(); ++i ) if ( ref_count[i] ) @@ -63,7 +63,7 @@ SO_PUBLIC bool Inspector::is_inactive() return true; } -SO_PUBLIC unsigned Inspector::get_buf_id(const char* key) +unsigned Inspector::get_buf_id(const char* key) { const char** p = api->buffers; unsigned id = 0; @@ -77,7 +77,7 @@ SO_PUBLIC unsigned Inspector::get_buf_id(const char* key) return p[id] ? id+1 : 0; } -SO_PUBLIC bool Inspector::get_buf(const char* key, Packet* p, InspectionBuffer& b) +bool Inspector::get_buf(const char* key, Packet* p, InspectionBuffer& b) { unsigned id = get_buf_id(key); @@ -87,7 +87,7 @@ SO_PUBLIC bool Inspector::get_buf(const char* key, Packet* p, InspectionBuffer& return get_buf(id, p, b); } -SO_PUBLIC StreamSplitter* Inspector::get_splitter(bool to_server) +StreamSplitter* Inspector::get_splitter(bool to_server) { if ( !api || api->type != IT_SERVICE ) return nullptr; diff --git a/src/framework/ips_option.cc b/src/framework/ips_option.cc index 7612eaaf7..75b0f8cac 100644 --- a/src/framework/ips_option.cc +++ b/src/framework/ips_option.cc @@ -34,7 +34,7 @@ //------------------------------------------------------------------------- -SO_PUBLIC uint32_t IpsOption::hash() const +uint32_t IpsOption::hash() const { uint32_t a=0, b=0, c=0; mix_str(a,b,c,get_name()); @@ -42,6 +42,6 @@ SO_PUBLIC uint32_t IpsOption::hash() const return c; } -SO_PUBLIC bool IpsOption::operator==(const IpsOption& ips) const +bool IpsOption::operator==(const IpsOption& ips) const { return !strcmp(get_name(), ips.get_name()); } diff --git a/src/framework/module.cc b/src/framework/module.cc index 459cc5249..60d5e2e8f 100644 --- a/src/framework/module.cc +++ b/src/framework/module.cc @@ -37,19 +37,17 @@ void Module::init(const char* s) num_counts = -1; } -SO_PUBLIC Module::Module(const char* s) -{ - init(s); -} +Module::Module(const char* s) +{ init(s); } -SO_PUBLIC Module::Module(const char* s, const Parameter* p, bool is_list) +Module::Module(const char* s, const Parameter* p, bool is_list) { init(s); params = p; list = is_list; } -SO_PUBLIC void Module::sum_stats() +void Module::sum_stats() { if ( num_counts < 0 ) reset_stats(); @@ -66,13 +64,13 @@ SO_PUBLIC void Module::sum_stats() } } -SO_PUBLIC void Module::show_stats() +void Module::show_stats() { if ( num_counts > 0 ) ::show_stats(&counts[0], get_pegs(), num_counts, get_name()); } -SO_PUBLIC void Module::reset_stats() +void Module::reset_stats() { num_counts = 0; const char** pegs = get_pegs(); @@ -89,7 +87,7 @@ SO_PUBLIC void Module::reset_stats() counts[i] = 0; } -SO_PUBLIC const char* simple_pegs[] = +const char* simple_pegs[] = { "packets", nullptr diff --git a/src/hash/sfxhash.cc b/src/hash/sfxhash.cc index de3e305a5..ac11faa03 100644 --- a/src/hash/sfxhash.cc +++ b/src/hash/sfxhash.cc @@ -125,11 +125,11 @@ static inline void s_free( SFXHASH * t, void * p ) /* * User access to the memory management, do they need it ? WaitAndSee */ -SO_PUBLIC void * sfxhash_alloc( SFXHASH * t, unsigned nbytes ) +void * sfxhash_alloc( SFXHASH * t, unsigned nbytes ) { return s_alloc( t, nbytes ); } -SO_PUBLIC void sfxhash_free( SFXHASH * t, void * p ) +void sfxhash_free( SFXHASH * t, void * p ) { s_free( t, p ); } @@ -146,7 +146,7 @@ static int sfxhash_nearest_powerof2(int nrows) return nrows; } -SO_PUBLIC int sfxhash_calcrows(int num) +int sfxhash_calcrows(int num) { return sfxhash_nearest_powerof2(num); // return sf_nearest_prime( nrows ); @@ -179,7 +179,7 @@ SO_PUBLIC int sfxhash_calcrows(int num) maxmem of 0 indicates no memory limits. */ -SO_PUBLIC SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, unsigned long maxmem, +SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, unsigned long maxmem, int anr_flag, int (*anrfree)(void * key, void * data), int (*usrfree)(void * key, void * data), @@ -268,7 +268,7 @@ SO_PUBLIC SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, unsigned * @param max_nodes maximum nodes to allow. * */ -SO_PUBLIC void sfxhash_set_max_nodes( SFXHASH *h, int max_nodes ) +void sfxhash_set_max_nodes( SFXHASH *h, int max_nodes ) { if (h) { @@ -283,7 +283,7 @@ SO_PUBLIC void sfxhash_set_max_nodes( SFXHASH *h, int max_nodes ) * @param n boolean flag toggles splaying of hash nodes * */ -SO_PUBLIC void sfxhash_splaymode( SFXHASH * t, int n ) +void sfxhash_splaymode( SFXHASH * t, int n ) { t->splay = n; } @@ -327,7 +327,7 @@ static void sfxhash_delete_free_list(SFXHASH *t) * @param h SFXHASH table pointer * */ -SO_PUBLIC void sfxhash_delete( SFXHASH * h ) +void sfxhash_delete( SFXHASH * h ) { unsigned i; SFXHASH_NODE * node, * onode; @@ -368,7 +368,7 @@ SO_PUBLIC void sfxhash_delete( SFXHASH * h ) * * @return -1 on error */ -SO_PUBLIC int sfxhash_make_empty(SFXHASH *h) +int sfxhash_make_empty(SFXHASH *h) { SFXHASH_NODE *n = NULL; SFXHASH_NODE *tmp = NULL; @@ -485,7 +485,7 @@ static void sfxhash_gunlink_node( SFXHASH *t, SFXHASH_NODE * hnode ) /**Move node to the front of global list. Node movement is application specific. */ -SO_PUBLIC void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode ) +void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode ) { if( hnode != t->ghead ) { @@ -682,7 +682,7 @@ static SFXHASH_NODE * sfxhash_find_node_row( SFXHASH * t, const void * key, int * @retval SFXHASH_INTABLE already in the table, t->cnode points to the node * @retval SFXHASH_NOMEM not enough memory */ -SO_PUBLIC int sfxhash_add( SFXHASH * t, void * key, void * data ) +int sfxhash_add( SFXHASH * t, void * key, void * data ) { int index; SFXHASH_NODE * hnode; @@ -761,7 +761,7 @@ SO_PUBLIC int sfxhash_add( SFXHASH * t, void * key, void * data ) * @retval SFXHASH_INTABLE already in the table, t->cnode points to the node * @retval SFXHASH_NOMEM not enough memory */ -SO_PUBLIC SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const void * key ) +SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const void * key ) { int index; SFXHASH_NODE * hnode; @@ -828,7 +828,7 @@ SO_PUBLIC SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const void * key ) * @retval 0 node not found * */ -SO_PUBLIC SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, const void * key) +SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, const void * key) { int rindex; @@ -845,7 +845,7 @@ SO_PUBLIC SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, const void * key) * @retval 0 node not found * */ -SO_PUBLIC void * sfxhash_find( SFXHASH * t, void * key) +void * sfxhash_find( SFXHASH * t, void * key) { SFXHASH_NODE * hnode; int rindex; @@ -865,7 +865,7 @@ SO_PUBLIC void * sfxhash_find( SFXHASH * t, void * key) * * @return the head of the list or NULL */ -SO_PUBLIC SFXHASH_NODE *sfxhash_ghead( SFXHASH * t ) +SFXHASH_NODE *sfxhash_ghead( SFXHASH * t ) { if(t) { @@ -883,7 +883,7 @@ SO_PUBLIC SFXHASH_NODE *sfxhash_ghead( SFXHASH * t ) * * @return the next node in the list or NULL when at the end */ -SO_PUBLIC SFXHASH_NODE *sfxhash_gnext( SFXHASH_NODE *n ) +SFXHASH_NODE *sfxhash_gnext( SFXHASH_NODE *n ) { if(n) { @@ -903,7 +903,7 @@ SO_PUBLIC SFXHASH_NODE *sfxhash_gnext( SFXHASH_NODE *n ) * @retval 0 node not found * */ -SO_PUBLIC void * sfxhash_mru( SFXHASH * t ) +void * sfxhash_mru( SFXHASH * t ) { SFXHASH_NODE * hnode; @@ -924,7 +924,7 @@ SO_PUBLIC void * sfxhash_mru( SFXHASH * t ) * @retval 0 node not found * */ -SO_PUBLIC void * sfxhash_lru( SFXHASH * t ) +void * sfxhash_lru( SFXHASH * t ) { SFXHASH_NODE * hnode; @@ -944,7 +944,7 @@ SO_PUBLIC void * sfxhash_lru( SFXHASH * t ) * @retval 0 node not found * */ -SO_PUBLIC SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t ) +SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t ) { SFXHASH_NODE * hnode; @@ -986,7 +986,7 @@ SFXHASH_NODE * sfxhash_lru_node( SFXHASH * t ) * @return max depth of the table * */ -SO_PUBLIC unsigned sfxhash_maxdepth( SFXHASH * t ) +unsigned sfxhash_maxdepth( SFXHASH * t ) { unsigned i; unsigned max_depth = 0; @@ -1012,7 +1012,7 @@ SO_PUBLIC unsigned sfxhash_maxdepth( SFXHASH * t ) /* * Unlink and free the node */ -SO_PUBLIC int sfxhash_free_node( SFXHASH * t, SFXHASH_NODE * hnode) +int sfxhash_free_node( SFXHASH * t, SFXHASH_NODE * hnode) { sfxhash_unlink_node( t, hnode ); /* unlink from the hash table row list */ @@ -1047,7 +1047,7 @@ SO_PUBLIC int sfxhash_free_node( SFXHASH * t, SFXHASH_NODE * hnode) * @retval !0 failed * */ -SO_PUBLIC int sfxhash_remove( SFXHASH * t, void * key) +int sfxhash_remove( SFXHASH * t, void * key) { SFXHASH_NODE * hnode; unsigned hashkey, index; @@ -1106,7 +1106,7 @@ static void sfxhash_next( SFXHASH * t ) * @retval !0 valid SFXHASH_NODE * * */ -SO_PUBLIC SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t ) +SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t ) { SFXHASH_NODE * n; @@ -1138,7 +1138,7 @@ SO_PUBLIC SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t ) * @retval !0 valid SFXHASH_NODE * * */ -SO_PUBLIC SFXHASH_NODE * sfxhash_findnext( SFXHASH * t ) +SFXHASH_NODE * sfxhash_findnext( SFXHASH * t ) { SFXHASH_NODE * n; @@ -1165,7 +1165,7 @@ SO_PUBLIC SFXHASH_NODE * sfxhash_findnext( SFXHASH * t ) * @param keycmp_fcn user specified key comparisoin function */ -SO_PUBLIC int sfxhash_set_keyops( SFXHASH *h , +int sfxhash_set_keyops( SFXHASH *h , unsigned (*hash_fcn)( SFHASHFCN * p, unsigned char *d, int n), diff --git a/src/hash/sfxhash.h b/src/hash/sfxhash.h index 3c23657b3..b18465d1e 100644 --- a/src/hash/sfxhash.h +++ b/src/hash/sfxhash.h @@ -39,6 +39,7 @@ #include #include "utils/sfmemcap.h" +#include "main/snort_types.h" struct SFHASHFCN; @@ -107,21 +108,21 @@ struct SFXHASH /* * HASH PROTOTYPES */ -int sfxhash_calcrows(int num); -SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, unsigned long memcap, +SO_PUBLIC int sfxhash_calcrows(int num); +SO_PUBLIC SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, unsigned long memcap, int anr_flag, int (*anrfunc)(void *key, void * data), int (*usrfunc)(void *key, void * data), int recycle_flag ); -void sfxhash_set_max_nodes( SFXHASH *h, int max_nodes ); +SO_PUBLIC void sfxhash_set_max_nodes( SFXHASH *h, int max_nodes ); -void sfxhash_delete( SFXHASH * h ); -int sfxhash_make_empty(SFXHASH *); +SO_PUBLIC void sfxhash_delete( SFXHASH * h ); +SO_PUBLIC int sfxhash_make_empty(SFXHASH *); -int sfxhash_add ( SFXHASH * h, void * key, void * data ); -SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const void * key ); -int sfxhash_remove( SFXHASH * h, void * key ); +SO_PUBLIC int sfxhash_add ( SFXHASH * h, void * key, void * data ); +SO_PUBLIC SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const void * key ); +SO_PUBLIC int sfxhash_remove( SFXHASH * h, void * key ); /*! * Get the # of Nodes in HASH the table @@ -200,31 +201,31 @@ static inline unsigned sfxhash_overhead_blocks( SFXHASH * t ) return t->overhead_blocks; } -void * sfxhash_mru( SFXHASH * t ); -void * sfxhash_lru( SFXHASH * t ); -SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t ); -SFXHASH_NODE * sfxhash_lru_node( SFXHASH * t ); -void * sfxhash_find( SFXHASH * h, void * key ); -SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, const void * key); +SO_PUBLIC void * sfxhash_mru( SFXHASH * t ); +SO_PUBLIC void * sfxhash_lru( SFXHASH * t ); +SO_PUBLIC SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t ); +SO_PUBLIC SFXHASH_NODE * sfxhash_lru_node( SFXHASH * t ); +SO_PUBLIC void * sfxhash_find( SFXHASH * h, void * key ); +SO_PUBLIC SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, const void * key); -SFXHASH_NODE * sfxhash_findfirst( SFXHASH * h ); -SFXHASH_NODE * sfxhash_findnext ( SFXHASH * h ); +SO_PUBLIC SFXHASH_NODE * sfxhash_findfirst( SFXHASH * h ); +SO_PUBLIC SFXHASH_NODE * sfxhash_findnext ( SFXHASH * h ); -SFXHASH_NODE * sfxhash_ghead( SFXHASH * h ); -SFXHASH_NODE * sfxhash_gnext( SFXHASH_NODE * n ); -void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode ); +SO_PUBLIC SFXHASH_NODE * sfxhash_ghead( SFXHASH * h ); +SO_PUBLIC SFXHASH_NODE * sfxhash_gnext( SFXHASH_NODE * n ); +SO_PUBLIC void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode ); -void sfxhash_splaymode( SFXHASH * h, int mode ); +SO_PUBLIC void sfxhash_splaymode( SFXHASH * h, int mode ); -void * sfxhash_alloc( SFXHASH * t, unsigned nbytes ); -void sfxhash_free( SFXHASH * t, void * p ); -int sfxhash_free_node(SFXHASH *t, SFXHASH_NODE *node); +SO_PUBLIC void * sfxhash_alloc( SFXHASH * t, unsigned nbytes ); +SO_PUBLIC void sfxhash_free( SFXHASH * t, void * p ); +SO_PUBLIC int sfxhash_free_node(SFXHASH *t, SFXHASH_NODE *node); -unsigned sfxhash_maxdepth( SFXHASH * t ); +SO_PUBLIC unsigned sfxhash_maxdepth( SFXHASH * t ); -int sfxhash_set_keyops( SFXHASH *h , +SO_PUBLIC int sfxhash_set_keyops( SFXHASH *h , unsigned (*hash_fcn)( SFHASHFCN * p, unsigned char *d, int n), diff --git a/src/log/text_log.h b/src/log/text_log.h index 7bfb7f4ef..6575efdef 100644 --- a/src/log/text_log.h +++ b/src/log/text_log.h @@ -53,7 +53,7 @@ * DO NOT ACCESS STRUCT MEMBERS DIRECTLY * EXCEPT FROM WITHIN THE IMPLEMENTATION! */ -typedef struct _TextLog +struct TextLog { /* private: */ /* file attributes: */ @@ -68,7 +68,7 @@ typedef struct _TextLog unsigned int maxBuf; char buf[1]; -} TextLog; +}; TextLog* TextLog_Init ( const char* name, unsigned int maxBuf = 0, size_t maxFile = 0 diff --git a/src/main/snort_debug.cc b/src/main/snort_debug.cc index ccc7a0e90..afe1cc6c9 100644 --- a/src/main/snort_debug.cc +++ b/src/main/snort_debug.cc @@ -41,8 +41,8 @@ #include "snort.h" #ifdef DEBUG_MSGS -SO_PUBLIC const char *DebugMessageFile = NULL; // FIXIT-M use access methods -SO_PUBLIC int DebugMessageLine = 0; // FIXIT-M use access methods +const char *DebugMessageFile = NULL; // FIXIT-M use access methods +int DebugMessageLine = 0; // FIXIT-M use access methods int DebugThis(uint64_t level) { @@ -79,7 +79,7 @@ uint64_t GetDebugLevel(void) return debug_level; } -SO_PUBLIC void DebugMessageFunc(uint64_t level, const char *fmt, ...) +void DebugMessageFunc(uint64_t level, const char *fmt, ...) { va_list ap; diff --git a/src/main/snort_debug.h b/src/main/snort_debug.h index b2d6208ba..3e3b70058 100644 --- a/src/main/snort_debug.h +++ b/src/main/snort_debug.h @@ -85,7 +85,7 @@ #define DEBUG_SMTP 0x0001000000000000LL #define DEBUG_PP_EXP 0x8000000000000000LL -void DebugMessageFunc(uint64_t dbg, const char *fmt, ...); +SO_PUBLIC void DebugMessageFunc(uint64_t dbg, const char *fmt, ...); #ifdef SF_WCHAR void DebugWideMessageFunc(uint64_t dbg, const wchar_t *fmt, ...); #endif @@ -105,9 +105,9 @@ int DebugThis(uint64_t level); #ifdef DEBUG_MSGS #define DEBUG_WRAP(code) code -void DebugMessageFunc(uint64_t dbg, const char *fmt, ...); +SO_PUBLIC void DebugMessageFunc(uint64_t dbg, const char *fmt, ...); #ifdef SF_WCHAR -void DebugWideMessageFunc(uint64_t dbg, const wchar_t *fmt, ...); +SO_PUBLIC void DebugWideMessageFunc(uint64_t dbg, const wchar_t *fmt, ...); #endif #else /* DEBUG_MSGS */ #define DEBUG_WRAP(code) diff --git a/src/managers/packet_manager.cc b/src/managers/packet_manager.cc index aeeb8a834..6c286d660 100644 --- a/src/managers/packet_manager.cc +++ b/src/managers/packet_manager.cc @@ -32,14 +32,12 @@ #include "protocols/packet.h" #include "protocols/protocol_ids.h" -#include "time/profiler.h" #include "parser/parser.h" +#include "time/profiler.h" -#include "protocols/ipv4.h" -#include "protocols/ipv6.h" #include "codecs/ip/ip_util.h" -#include "codecs/codec_events.h" #include "codecs/decode_module.h" +#include "codecs/codec_events.h" // Encoder FOO #ifdef HAVE_DUMBNET_H @@ -353,7 +351,7 @@ void PacketManager::thread_term() } } -SO_PUBLIC Packet* PacketManager::encode_new () +Packet* PacketManager::encode_new() { Packet* p = (Packet*)SnortAlloc(sizeof(*p)); uint8_t* b = (uint8_t*)SnortAlloc(sizeof(*p->pkth) + Codec::PKT_MAX + SPARC_TWIDDLE); @@ -369,7 +367,7 @@ SO_PUBLIC Packet* PacketManager::encode_new () return p; } -SO_PUBLIC void PacketManager::encode_delete (Packet* p) +void PacketManager::encode_delete (Packet* p) { free((void*)p->pkth); // cast away const! free(p); @@ -528,7 +526,7 @@ bool PacketManager::has_codec(uint16_t cd_id) // * if next layer is tcp, it becomes a tcp rst or tcp fin w/opt data //------------------------------------------------------------------------- -SO_PUBLIC const uint8_t* PacketManager::encode_response( +const uint8_t* PacketManager::encode_response( EncodeType type, EncodeFlags flags, const Packet* p, uint32_t* len, const uint8_t* payLoad, uint32_t payLen) { @@ -555,7 +553,7 @@ SO_PUBLIC const uint8_t* PacketManager::encode_response( // - inner layer header is very similar but payload differs // - original ttl is always used //------------------------------------------------------------------------- -SO_PUBLIC int PacketManager::encode_format_with_daq_info ( +int PacketManager::encode_format_with_daq_info ( EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type, const DAQ_PktHdr_t* phdr, uint32_t opaque) { @@ -643,17 +641,17 @@ SO_PUBLIC int PacketManager::encode_format_with_daq_info ( #ifdef HAVE_DAQ_ADDRESS_SPACE_ID -SO_PUBLIC int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) +int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) { return encode_format_with_daq_info(f, p, c, type, p->pkth, p->pkth->opaque); } #elif defined(HAVE_DAQ_ACQUIRE_WITH_META) -SO_PUBLIC int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) +int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) { return encode_format_with_daq_info(f, p, c, type, nullptr, p->pkth->opaque); } #else -SO_PUBLIC int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) +int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packet* c, PseudoPacketType type) { return encode_format_with_daq_info(f, p, c, type, nullptr, 0); } @@ -666,7 +664,7 @@ SO_PUBLIC int PacketManager::encode_format(EncodeFlags f, const Packet* p, Packe // checking each time if needed. //------------------------------------------------------------------------- -SO_PUBLIC void PacketManager::encode_update (Packet* p) +void PacketManager::encode_update (Packet* p) { int i; uint32_t len = 0; @@ -718,22 +716,14 @@ void PacketManager::dump_stats() "codec"); } -SO_PUBLIC void PacketManager::encode_set_dst_mac(uint8_t *mac) -{ - dst_mac = mac; -} +void PacketManager::encode_set_dst_mac(uint8_t *mac) +{ dst_mac = mac; } -SO_PUBLIC uint8_t *PacketManager::encode_get_dst_mac() -{ - return dst_mac; -} +uint8_t *PacketManager::encode_get_dst_mac() +{ return dst_mac; } uint64_t PacketManager::get_rebuilt_packet_count(void) -{ - return total_rebuilt_pkts; -} +{ return total_rebuilt_pkts; } void PacketManager::encode_set_pkt(Packet* p) -{ - encode_pkt = p; -} +{ encode_pkt = p; } diff --git a/src/managers/packet_manager.h b/src/managers/packet_manager.h index 76a10f8ba..fce9ea2aa 100644 --- a/src/managers/packet_manager.h +++ b/src/managers/packet_manager.h @@ -42,23 +42,23 @@ extern THREAD_LOCAL ProfileStats decodePerfStats; /* * PacketManager class */ -class PacketManager +class SO_PUBLIC PacketManager { public: /* constructors, destructors, and statistics */ // global plugin initializer. Called by LUA to add register codecs - static void add_plugin(const struct CodecApi*); + SO_PRIVATE static void add_plugin(const struct CodecApi*); // instantiate a specific codec with a codec specific Module - static void instantiate(const CodecApi*, Module*, SnortConfig*); + SO_PRIVATE static void instantiate(const CodecApi*, Module*, SnortConfig*); // instantiate any codec for which a module has not been provided. - static void instantiate(); + SO_PRIVATE static void instantiate(); // destroy all global codec related information - static void release_plugins(); + SO_PRIVATE static void release_plugins(); // initialize the current threads codecs - static void thread_init(); + SO_PRIVATE static void thread_init(); // destroy thread_local data - static void thread_term(); + SO_PRIVATE static void thread_term(); // allocate a Packet for later formatting (cloning) static Packet* encode_new(void); // release the allocated Packet @@ -119,9 +119,7 @@ public: // reset the current 'clone' packet static inline void encode_reset(void) - { - encode_set_pkt(NULL); - } + { encode_set_pkt(NULL); } }; #endif diff --git a/src/parser/mstring.cc b/src/parser/mstring.cc index a3c750a71..bae27962f 100644 --- a/src/parser/mstring.cc +++ b/src/parser/mstring.cc @@ -113,7 +113,7 @@ int main() * array. * ****************************************************************/ -SO_PUBLIC char ** mSplit(const char *str, const char *sep_chars, const int max_toks, +char ** mSplit(const char *str, const char *sep_chars, const int max_toks, int *num_toks, const char meta_char) { size_t cur_tok = 0; /* current token index into array of strings */ @@ -462,7 +462,7 @@ static char * mSplitAddTok(const char *str, const int len, const char *sep_chars * At this point, toks is again NULL. * ****************************************************************/ -SO_PUBLIC void mSplitFree(char ***pbuf, int num_toks) +void mSplitFree(char ***pbuf, int num_toks) { int i; char** buf; /* array of string pointers */ @@ -505,7 +505,7 @@ SO_PUBLIC void mSplitFree(char ***pbuf, int num_toks) * failure (substr not in str) * ****************************************************************/ -SO_PUBLIC int mContainsSubstr(const char *buf, int b_len, const char *pat, int p_len) +int mContainsSubstr(const char *buf, int b_len, const char *pat, int p_len) { const char *b_idx; /* index ptr into the data buffer */ const char *p_idx; /* index ptr into the pattern buffer */ diff --git a/src/parser/mstring.h b/src/parser/mstring.h index c3de46db8..10de22be7 100644 --- a/src/parser/mstring.h +++ b/src/parser/mstring.h @@ -23,13 +23,15 @@ #ifndef MSTRING_H #define MSTRING_H +#include "main/snort_types.h" + /* D E F I N E S *******************************************************/ #define TOKS_BUF_SIZE 100 /* P R O T O T Y P E S *************************************************/ -char ** mSplit(const char *, const char *, const int, int *, const char); -void mSplitFree(char ***toks, int numtoks); -int mContainsSubstr(const char *, int, const char *, int); +SO_PUBLIC char ** mSplit(const char *, const char *, const int, int *, const char); +SO_PUBLIC void mSplitFree(char ***toks, int numtoks); +SO_PUBLIC int mContainsSubstr(const char *, int, const char *, int); #endif /* MSTRING_H */ diff --git a/src/parser/parser.cc b/src/parser/parser.cc index 487561578..cc2f093a3 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -1044,7 +1044,7 @@ void OrderRuleLists(SnortConfig *sc, const char *order) sc->rule_lists = ordered_list; } -SO_PUBLIC NORETURN void ParseAbort(const char *format, ...) +NORETURN void ParseAbort(const char *format, ...) { char buf[STD_BUF+1]; va_list ap; @@ -1065,7 +1065,7 @@ SO_PUBLIC NORETURN void ParseAbort(const char *format, ...) FatalError("%s\n", buf); } -SO_PUBLIC void ParseError(const char *format, ...) +void ParseError(const char *format, ...) { char buf[STD_BUF+1]; va_list ap; @@ -1088,7 +1088,7 @@ SO_PUBLIC void ParseError(const char *format, ...) parse_errors++; } -SO_PUBLIC void ParseWarning(const char *format, ...) +void ParseWarning(const char *format, ...) { char buf[STD_BUF+1]; va_list ap; @@ -1109,7 +1109,7 @@ SO_PUBLIC void ParseWarning(const char *format, ...) LogMessage("%s\n", buf); } -SO_PUBLIC void ParseMessage(const char *format, ...) +void ParseMessage(const char *format, ...) { char buf[STD_BUF+1]; va_list ap; diff --git a/src/parser/parser.h b/src/parser/parser.h index c640197dd..507a008e8 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -64,10 +64,10 @@ void parser_append_rules(const char*); void ConfigureSideChannelModules(SnortConfig *); -NORETURN void ParseAbort(const char *, ...); -void ParseError(const char *, ...); -void ParseWarning(const char *, ...); -void ParseMessage(const char *, ...); +SO_PUBLIC NORETURN void ParseAbort(const char *, ...); +SO_PUBLIC void ParseError(const char *, ...); +SO_PUBLIC void ParseWarning(const char *, ...); +SO_PUBLIC void ParseMessage(const char *, ...); int ParseBool(const char *arg); diff --git a/src/sfip/Makefile.am b/src/sfip/Makefile.am index 8be5e7a32..8d73dea7c 100644 --- a/src/sfip/Makefile.am +++ b/src/sfip/Makefile.am @@ -19,4 +19,3 @@ sf_vartable.h libsfip_a_CXXFLAGS = $(AM_CXXFLAGS) -fvisibility=default AM_CXXFLAGS = @AM_CXXFLAGS@ - diff --git a/src/stream/stream_api.cc b/src/stream/stream_api.cc index 94178aad4..1014ddc05 100644 --- a/src/stream/stream_api.cc +++ b/src/stream/stream_api.cc @@ -58,9 +58,6 @@ #include "target_based/sftarget_protocol_reference.h" #include "target_based/sftarget_hostentry.h" -//------------------------------------------------------------------------- -// public methods other than ctor / dtor must all be declared SO_PUBLIC -//------------------------------------------------------------------------- Stream stream; // FIXIT-L global for SnortContext diff --git a/src/stream/stream_api.h b/src/stream/stream_api.h index 57bfbc3d8..6fc36f49d 100644 --- a/src/stream/stream_api.h +++ b/src/stream/stream_api.h @@ -81,11 +81,15 @@ typedef void (*Stream_Callback)(Packet *); #define MAX_EVT_CB 32 #define MAX_LOG_FN 32 +//------------------------------------------------------------------------- +// public methods other than ctor / dtor must all be declared SO_PUBLIC +//------------------------------------------------------------------------- + class SO_PUBLIC Stream { public: - Stream(); - ~Stream(); + SO_PRIVATE Stream(); + SO_PRIVATE ~Stream(); static Flow* get_session(const FlowKey*); static Flow* new_session(const FlowKey*); diff --git a/src/stream/stream_splitter.cc b/src/stream/stream_splitter.cc index 3d581e56d..38272cf4b 100644 --- a/src/stream/stream_splitter.cc +++ b/src/stream/stream_splitter.cc @@ -29,10 +29,10 @@ static THREAD_LOCAL uint8_t pdu_buf[65536]; static THREAD_LOCAL StreamBuffer str_buf; -SO_PUBLIC uint32_t StreamSplitter::max() +uint32_t StreamSplitter::max() { return 16384; } // FIXIT-H make default configurable -SO_PUBLIC const StreamBuffer* StreamSplitter::reassemble( +const StreamBuffer* StreamSplitter::reassemble( Flow*, unsigned, unsigned offset, const uint8_t* p, unsigned n, uint32_t flags, unsigned& copied) { diff --git a/src/utils/boyer_moore.cc b/src/utils/boyer_moore.cc index 7c9067fdc..bbfae43ec 100644 --- a/src/utils/boyer_moore.cc +++ b/src/utils/boyer_moore.cc @@ -178,7 +178,7 @@ int *make_shift(char *ptrn, int plen) * -1 if not found or offset >= 0 if found * ****************************************************************/ -SO_PUBLIC int mSearch( +int mSearch( const char *buf, int blen, const char *ptrn, int plen, int *skip, int *shift) { DEBUG_WRAP(DebugMessage(DEBUG_PATTERN_MATCH,"buf: %p blen: %d ptrn: %p " @@ -227,7 +227,7 @@ SO_PUBLIC int mSearch( * -1 if not found or offset >= 0 if found * ****************************************************************/ -SO_PUBLIC int mSearchCI( +int mSearchCI( const char *buf, int blen, const char *ptrn, int plen, int *skip, int *shift) { int b_idx = plen; @@ -273,7 +273,7 @@ SO_PUBLIC int mSearchCI( * 1 = found, 0 = not found * ****************************************************************/ -SO_PUBLIC int mSearchREG( +int mSearchREG( const char *buf, int blen, const char *ptrn, int plen, int *skip, int *shift) { int b_idx = plen; diff --git a/src/utils/boyer_moore.h b/src/utils/boyer_moore.h index 518bff49f..95d52ac5f 100644 --- a/src/utils/boyer_moore.h +++ b/src/utils/boyer_moore.h @@ -22,6 +22,7 @@ #ifndef BOYER_MOORE_H #define BOYER_MOORE_H +#include "main/snort_types.h" // boyer_moore.h was split out of mstring.h int *make_skip(char *, int); diff --git a/tools/snort2lua/snort2lua.cc b/tools/snort2lua/snort2lua.cc index d0b3e21b6..6056fc144 100644 --- a/tools/snort2lua/snort2lua.cc +++ b/tools/snort2lua/snort2lua.cc @@ -74,12 +74,7 @@ int main (int argc, char* argv[]) // keep track whether we're printing rules into a seperate file. bool rule_file_specifed = false; -// why print variable if there are no rules? -#if 1 - // FIXIT-H - // if no rule file is specified (or the same output and rule file specified), - // rules will be printed in the 'default_rules' variable. Set that up - // now. Otherwise, set up the include file. + if (!rule_api.empty()) { if (rule_file.empty() || !rule_file.compare(output_file)) @@ -100,7 +95,7 @@ int main (int argc, char* argv[]) table_api.close_table(); } } -#endif + // Snort++ requires a binder table to be instantiated, // although not necessarily filled. So, just add this table. @@ -109,7 +104,6 @@ int main (int argc, char* argv[]) table_api.close_table(); // finally, lets print the converter to file - std::ofstream out; out.open(output_file, std::ifstream::out); out << "require(\"snort_config\") -- for loading\n\n"; diff --git a/tools/snort2lua/utils/converter.cc b/tools/snort2lua/utils/converter.cc index 5e4e19513..5d0168322 100644 --- a/tools/snort2lua/utils/converter.cc +++ b/tools/snort2lua/utils/converter.cc @@ -50,7 +50,7 @@ bool Converter::initialize(conv_new_f func) if (state == nullptr) { - std::cout << "Failed Converter initialization!" << std::endl; + data_api.developer_error("Failed Converter initialization!"); return false; } @@ -96,24 +96,10 @@ void Converter::parse_include_file(std::string input_file) if (convert_rules_mult_files) rule_api.swap_rules(rules); - if (convert_file(input_file) < 0) - { - error = true; - if (convert_conf_mult_files) - { - // FIXIT: This needs to tables, and data_api - data_api.swap_conf_data(vars, includes, comments); - table_api.swap_tables(tables); - delete comments; - } - if (convert_rules_mult_files) - rule_api.swap_rules(rules); - - // add this new file as a snort style rule - rule_api.add_hdr_data("include " + input_file); - return; - } + // MAIN CONVERSION!! + if (convert_file(input_file) < 0) + error = true; // return a negative number to main snort2lua method if (convert_conf_mult_files) @@ -128,32 +114,29 @@ void Converter::parse_include_file(std::string input_file) data_api.print_comments(out); out << std::endl; out.close(); + + data_api.add_include_file(input_file + ".lua"); } data_api.swap_conf_data(vars, includes, comments); - data_api.add_include_file(input_file + ".lua"); table_api.swap_tables(tables); delete comments; } + if (convert_rules_mult_files) { - bool include_rule_file = false; - if (!rule_api.empty()) { std::ofstream out; out.open(input_file + ".rules"); rule_api.print_rules(out, true); // true == output to rule file, NOT lua file out.close(); - include_rule_file = true; + + rule_api.add_hdr_data("include " + input_file + ".rules"); } rule_api.swap_rules(rules); - - // add this new file as a snort style rule - if (include_rule_file) - rule_api.add_hdr_data("include " + input_file + ".rules"); } }