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 ()
unsigned char flowb[1];
};
-class FlowData
+class SO_PUBLIC FlowData
{
public:
FlowData(unsigned u, Inspector* = nullptr);
PegCount total_packets;
};
-extern const char* simple_pegs[];
+SO_PUBLIC extern const char* simple_pegs[];
#define array_size(a) (sizeof(a)/sizeof(a[0]))
// 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);
ref_count[i] = 0;
}
-SO_PUBLIC Inspector::~Inspector()
+Inspector::~Inspector()
{
unsigned total = 0;
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] )
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;
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);
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;
//-------------------------------------------------------------------------
-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());
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()); }
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();
}
}
-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();
counts[i] = 0;
}
-SO_PUBLIC const char* simple_pegs[] =
+const char* simple_pegs[] =
{
"packets",
nullptr
/*
* 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 );
}
return nrows;
}
-SO_PUBLIC int sfxhash_calcrows(int num)
+int sfxhash_calcrows(int num)
{
return sfxhash_nearest_powerof2(num);
// return sf_nearest_prime( nrows );
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),
* @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)
{
* @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;
}
* @param h SFXHASH table pointer
*
*/
-SO_PUBLIC void sfxhash_delete( SFXHASH * h )
+void sfxhash_delete( SFXHASH * h )
{
unsigned i;
SFXHASH_NODE * node, * onode;
*
* @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;
/**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 )
{
* @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;
* @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;
* @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;
* @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;
*
* @return the head of the list or NULL
*/
-SO_PUBLIC SFXHASH_NODE *sfxhash_ghead( SFXHASH * t )
+SFXHASH_NODE *sfxhash_ghead( SFXHASH * t )
{
if(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)
{
* @retval 0 node not found
*
*/
-SO_PUBLIC void * sfxhash_mru( SFXHASH * t )
+void * sfxhash_mru( SFXHASH * t )
{
SFXHASH_NODE * hnode;
* @retval 0 node not found
*
*/
-SO_PUBLIC void * sfxhash_lru( SFXHASH * t )
+void * sfxhash_lru( SFXHASH * t )
{
SFXHASH_NODE * hnode;
* @retval 0 node not found
*
*/
-SO_PUBLIC SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t )
+SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t )
{
SFXHASH_NODE * hnode;
* @return max depth of the table
*
*/
-SO_PUBLIC unsigned sfxhash_maxdepth( SFXHASH * t )
+unsigned sfxhash_maxdepth( SFXHASH * t )
{
unsigned i;
unsigned max_depth = 0;
/*
* 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 */
* @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;
* @retval !0 valid SFXHASH_NODE *
*
*/
-SO_PUBLIC SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t )
+SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t )
{
SFXHASH_NODE * n;
* @retval !0 valid SFXHASH_NODE *
*
*/
-SO_PUBLIC SFXHASH_NODE * sfxhash_findnext( SFXHASH * t )
+SFXHASH_NODE * sfxhash_findnext( SFXHASH * t )
{
SFXHASH_NODE * n;
* @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),
#include <time.h>
#include "utils/sfmemcap.h"
+#include "main/snort_types.h"
struct SFHASHFCN;
/*
* 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
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),
* DO NOT ACCESS STRUCT MEMBERS DIRECTLY
* EXCEPT FROM WITHIN THE IMPLEMENTATION!
*/
-typedef struct _TextLog
+struct TextLog
{
/* private: */
/* file attributes: */
unsigned int maxBuf;
char buf[1];
-} TextLog;
+};
TextLog* TextLog_Init (
const char* name, unsigned int maxBuf = 0, size_t maxFile = 0
#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)
{
return debug_level;
}
-SO_PUBLIC void DebugMessageFunc(uint64_t level, const char *fmt, ...)
+void DebugMessageFunc(uint64_t level, const char *fmt, ...)
{
va_list ap;
#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
#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)
#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
}
}
-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);
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);
// * 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)
{
// - 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)
{
#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);
}
// 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;
"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; }
/*
* 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
// reset the current 'clone' packet
static inline void encode_reset(void)
- {
- encode_set_pkt(NULL);
- }
+ { encode_set_pkt(NULL); }
};
#endif
* 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 */
* 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 */
* 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 */
#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 */
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;
FatalError("%s\n", buf);
}
-SO_PUBLIC void ParseError(const char *format, ...)
+void ParseError(const char *format, ...)
{
char buf[STD_BUF+1];
va_list ap;
parse_errors++;
}
-SO_PUBLIC void ParseWarning(const char *format, ...)
+void ParseWarning(const char *format, ...)
{
char buf[STD_BUF+1];
va_list ap;
LogMessage("%s\n", buf);
}
-SO_PUBLIC void ParseMessage(const char *format, ...)
+void ParseMessage(const char *format, ...)
{
char buf[STD_BUF+1];
va_list ap;
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);
libsfip_a_CXXFLAGS = $(AM_CXXFLAGS) -fvisibility=default
AM_CXXFLAGS = @AM_CXXFLAGS@
-
#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
#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*);
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)
{
* -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 "
* -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;
* 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;
#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);
// 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))
table_api.close_table();
}
}
-#endif
+
// Snort++ requires a binder table to be instantiated,
// although not necessarily filled. So, just add this table.
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";
if (state == nullptr)
{
- std::cout << "Failed Converter initialization!" << std::endl;
+ data_api.developer_error("Failed Converter initialization!");
return false;
}
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)
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");
}
}