Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

util.h File Reference

#include <sys/time.h>
#include <sys/types.h>
#include "strlcatu.h"
#include "strlcpyu.h"
#include "sfsnprintfappend.h"

Go to the source code of this file.

Defines

#define TIMEBUF_SIZE   26

Typedefs

typedef _SPMemControl SPMemControl

Functions

int DisplayBanner ()
void GetTime (char *)
int gmt2local (time_t)
void ts_print (register const struct timeval *, char *)
char * copy_argv (char **)
int strip (char *)
float CalcPct (float, float)
void ReadPacketsFromFile ()
void GenHomenet (char *)
void InitNetmasks ()
void InitBinFrag ()
void GoDaemon ()
void CheckLogDir ()
char * read_infile (char *)
void InitProtoNames ()
void CleanupProtoNames ()
void PrintError (char *)
void ErrorMessage (const char *,...)
void LogMessage (const char *,...)
void FatalError (const char *,...)
void FatalPrintError (char *)
void CreatePidFile (char *)
void SetUidGid (void)
void SetChroot (char *, char **)
void DropStats (int)
void GenObfuscationMask (char *)
void * SPAlloc (unsigned long, struct _SPMemControl *)
void * SnortAlloc (unsigned long)
char * CurrentWorkingDir (void)
char * GetAbsolutePath (char *dir)
char * StripPrefixDir (char *prefix, char *dir)

Variables

u_long netmasks [33]


Define Documentation

#define TIMEBUF_SIZE   26
 

Definition at line 24 of file util.h.


Typedef Documentation

typedef struct _SPMemControl SPMemControl
 


Function Documentation

float CalcPct float  ,
float 
 

Definition at line 242 of file util.c.

Referenced by DropStats().

void CheckLogDir  ) 
 

Definition at line 1296 of file util.c.

References access, FatalError(), _progvars::log_dir, pv, S_ISDIR, snprintf, STD_BUF, and W_OK.

Referenced by CreatePidFile(), and SnortMain().

void CleanupProtoNames  ) 
 

Definition at line 1213 of file util.c.

References NULL, and protocol_names.

char* copy_argv char **   ) 
 

Definition at line 413 of file util.c.

References errno, FatalError(), and NULL.

Referenced by ParseCmdLine().

void CreatePidFile char *   ) 
 

Definition at line 719 of file util.c.

References _PATH_VARRUN, access, CheckLogDir(), ErrorMessage(), FatalError(), int(), _progvars::log_dir, LogMessage(), NULL, _progvars::pid_filename, _progvars::pid_path, _progvars::pidfile_suffix, pv, _progvars::quiet_flag, _progvars::readmode_flag, S_ISDIR, snprintf, STD_BUF, strlcpy, and W_OK.

Referenced by SnortMain().

char* CurrentWorkingDir void   ) 
 

Return a ptr to the absolute pathname of snort. This memory must be copied to another region if you wish to save it for later use.

Definition at line 1538 of file util.c.

References NULL, and PATH_MAX_UTIL.

Referenced by GetAbsolutePath(), and SetChroot().

int DisplayBanner  ) 
 

Definition at line 268 of file util.c.

References BUILD, and VERSION.

Referenced by ParseCmdLine(), and SnortMain().

void DropStats int   ) 
 

Definition at line 998 of file util.c.

References _PacketCount::alert_pkts, _PacketCount::arp, CalcPct(), datalink, _PacketCount::discards, DLT_IEEE802_11, _PacketCount::eapol, _PacketCount::ethloopback, _PacketCount::frag_incomp, _PacketCount::frag_mem_faults, _PacketCount::frag_timeout, _PacketCount::frag_trackers, _PacketCount::frags, _PacketCount::icmp, InlineMode(), _PacketCount::ipv6, _PacketCount::ipx, _PacketCount::log_pkts, LogMessage(), _PacketCount::other, _PacketCount::pass_pkts, pc, pcap_perror(), pcap_stats(), pd, pcap_stat::ps_drop, pcap_stat::ps_recv, pv, _progvars::quiet_flag, _progvars::readmode_flag, _PacketCount::rebuild_element, _PacketCount::rebuilt_frags, _PacketCount::rebuilt_segs, _PacketCount::rebuilt_tcp, _PacketCount::str_mem_faults, _PacketCount::tcp, _PacketCount::tcp_stream_pkts, _PacketCount::tcp_streams, _PacketCount::udp, _PacketCount::wifi_control, _PacketCount::wifi_data, and _PacketCount::wifi_mgmt.

Referenced by CleanExit(), Restart(), and SigUsrHandler().

void ErrorMessage const char *  ,
  ...
 

Definition at line 570 of file util.c.

References _progvars::daemon_flag, LOG_CONS, LOG_DAEMON, LOG_ERR, pv, STD_BUF, syslog(), and vsnprintf.

Referenced by AddReference(), base64(), Connect(), CreatePidFile(), Database(), DatabaseInit(), DecodeARP(), DecodeChdlcPkt(), DecodeEapol(), DecodeEthPkt(), DecodeFDDIPkt(), DecodeICMP(), DecodeIEEE80211Pkt(), DecodeIP(), DecodeIPOnly(), DecodeNullPkt(), DecodeOldPflog(), DecodePflog(), DecodePPPoEPkt(), DecodePppPkt(), DecodePppPktEncapsulated(), DecodePppSerialPkt(), DecodeSlipPkt(), DecodeTCP(), DecodeTRPkt(), DecodeUDP(), DecodeVlan(), ExpandVars(), FlowPreprocessor(), Frag3RemoveTracker(), HttpInspectInit(), InitIgnoreHosts(), InitIgnorePorts(), Insert(), InterfaceThread(), OpenAlertSock(), OpenPcap(), ParseClassificationConfig(), ParseConfig(), ParseDatabaseArgs(), ParseMessage(), ParseOutputPlugin(), ParseStream4Args(), Print2ndHeader(), ReferenceSystemAdd(), ScanParseIp(), Select(), SetPktProcessor(), SetUidGid(), and vsyslog().

void FatalError const char *  ,
  ...
 

Definition at line 677 of file util.c.

References _progvars::daemon_flag, LOG_CONS, LOG_DAEMON, LOG_ERR, pv, STD_BUF, syslog(), and vsnprintf.

void FatalPrintError char *   ) 
 

Definition at line 702 of file util.c.

References PrintError().

void GenHomenet char *   ) 
 

Definition at line 82 of file util.c.

References DEBUG_INIT, DEBUG_WRAP, FatalError(), _progvars::homenet, mSplit(), mSplitFree(), _progvars::netmask, netmasks, and pv.

Referenced by ParseCmdLine(), and ParseConfig().

void GenObfuscationMask char *   ) 
 

Definition at line 143 of file util.c.

References DEBUG_INIT, DEBUG_WRAP, FatalError(), mSplit(), mSplitFree(), netmasks, _progvars::obfuscation_mask, _progvars::obfuscation_net, and pv.

Referenced by ParseCmdLine().

char* GetAbsolutePath char *  dir  ) 
 

Given a directory name, return a ptr to a static

Definition at line 1555 of file util.c.

References CurrentWorkingDir(), LogMessage(), NULL, and PATH_MAX_UTIL.

Referenced by SetChroot().

void GetTime char *   ) 
 

int gmt2local time_t   ) 
 

Definition at line 372 of file util.c.

References NULL.

Referenced by SnortMain().

void GoDaemon  ) 
 

Definition at line 1330 of file util.c.

References LogMessage().

Referenced by SnortMain().

void InitBinFrag  ) 
 

void InitNetmasks  ) 
 

Definition at line 505 of file util.c.

References netmasks.

Referenced by SnortMain().

void InitProtoNames  ) 
 

Definition at line 1174 of file util.c.

References char(), protocol_names, and snprintf.

Referenced by SnortMain().

void LogMessage const char *  ,
  ...
 

Definition at line 599 of file util.c.

References _progvars::daemon_flag, LOG_DAEMON, LOG_NOTICE, pv, _progvars::quiet_flag, STD_BUF, syslog(), and vsnprintf.

Referenced by ActivateAction(), ActivateOutputPlugin(), ascii(), BuildMultiPatGroup(), CleanExit(), CommitTransaction(), ConvInit(), CreatePidFile(), DisplayBasePerfStatsConsole(), DisplayEventPerfStats(), DisplayFlowConfig(), DisplayFlowStats(), DisplayStream4Config(), DropStats(), FlowBitsInit(), FlowBitsVerify(), FlowCleanExit(), fpSetDetectSearchMethod(), Frag2Defrag(), Frag3Defrag(), Frag3Expire(), Frag3GlobalInit(), Frag3Init(), Frag3NewTracker(), Frag3ParseArgs(), Frag3ParseGlobalArgs(), Frag3PrintEngineConfig(), Frag3PrintGlobalConfig(), Frag3PrintStats(), Frag3Prune(), GetAbsolutePath(), GetUniqueName(), GoDaemon(), InitOutputPlugins(), InitPlugIns(), InitPreprocessors(), Insert(), InsertFrag(), IpAddrSetPrint(), LoadStateTable(), NewFragTracker(), OpenPcap(), OrderRuleLists(), ParseClassType(), ParseCmdLine(), ParseConfig(), ParseFrag2Args(), ParsePerfMonitorArgs(), ParsePriority(), ParseReference(), ParseRev(), ParseRulesFile(), ParseScanmungeArgs(), ParseSID(), ParseStream4Args(), ParseSyslogArgs(), PortscanInit(), print_thd_local(), print_thd_node(), print_thresholding(), PrintConfig(), PrintConfOpt(), PrintGlobalConf(), PrintPortscanConf(), printRuleListOrder(), PrintServerConf(), ProcessHeadNode(), ProcessUniqueServerConf(), ReadLine(), RebuildFrag(), Restart(), RollbackTransaction(), Scan2Init(), SetPktProcessor(), SetRpcPorts(), SetTags(), SetTelnetPorts(), SetUseDoePtr(), sfRotatePerformanceStatisticsFile(), SigCantHupHandler(), SnortMain(), StoreStreamPkt(), Stream4InitReassembler(), UnifiedLogData(), UnifiedParseArgs(), and XLINK2STATE_ParseArgs().

void PrintError char *   ) 
 

Definition at line 551 of file util.c.

References _progvars::daemon_flag, LOG_CONS, LOG_DAEMON, LOG_ERR, pv, and syslog().

Referenced by FatalPrintError(), and SnortMain().

char* read_infile char *   ) 
 

Definition at line 1238 of file util.c.

References errno, FatalError(), int(), NULL, and pcap_strerror().

Referenced by ParseCmdLine(), and ParseConfig().

void ReadPacketsFromFile  ) 
 

void SetChroot char *  directory,
char **  logstore
 

Chroot and adjust the pv.log_dir reference

Parameters:
directory directory to chroot to
logdir ptr to pv.log_dir

Definition at line 1435 of file util.c.

References CurrentWorkingDir(), DEBUG_INIT, DEBUG_WRAP, errno, FatalError(), GetAbsolutePath(), NULL, SigCantHupHandler(), and SIGHUP.

Referenced by SnortMain().

void SetUidGid void   ) 
 

just to be on a safe side...

Definition at line 813 of file util.c.

References DEBUG_INIT, DEBUG_WRAP, ErrorMessage(), FatalError(), groupid, groupname, InlineMode(), NULL, userid, and username.

Referenced by SnortMain().

void* SnortAlloc unsigned  long  ) 
 

Definition at line 1415 of file util.c.

References FatalError(), and NULL.

Referenced by AddFragNode(), AlertCSVParseArgs(), ARPspoofHostInit(), Asn1Init(), CheckDBVersion(), CSVEscape(), Database(), DatabaseInit(), DsizeCheckInit(), DupFragNode(), FlowBitsInit(), FlowBitsParse(), Frag3GlobalInit(), Frag3HandleIPOptions(), Frag3Init(), Frag3InitPkt(), Frag3NewTracker(), Frag3ParseArgs(), FragBitsInit(), GetLastCid(), IcmpCodeCheckInit(), IcmpIdCheckInit(), IcmpSeqCheckInit(), IcmpTypeCheckInit(), IpAddrSetCreate(), IpAddrSetParse(), IpIdCheckInit(), IpOptionInit(), IpProtoInit(), IpSameCheckInit(), IpTosCheckInit(), IsDataAtInit(), NewQueryNode(), ParseAlertFastArgs(), ParseAlertFullArgs(), ParseARPspoofHostArgs(), ParseDatabaseArgs(), ParseSyslogArgs(), RpcCheckInit(), SessionInit(), snort_escape_string(), SnortPcreInit(), TcpAckCheckInit(), TCPFlagCheckInit(), TcpSeqCheckInit(), TcpWinCheckInit(), TemplateInit(), TtlCheckInit(), and UpdateLastCid().

void* SPAlloc unsigned  long,
struct _SPMemControl
 

Definition at line 1392 of file util.c.

References FatalError(), _SPMemControl::mem_usage, _SPMemControl::memcap, NULL, and _SPMemControl::sp_func.

Referenced by InsertFrag(), and NewFragTracker().

int strip char *   ) 
 

Definition at line 461 of file util.c.

Referenced by ParseContentListFile(), and ParseRule().

char* StripPrefixDir char *  prefix,
char *  dir
 

void ts_print register const struct timeval *  ,
char * 
 

Definition at line 310 of file util.c.

References bzero, gettimeofday(), _progvars::include_year, pv, snprintf, thiszone, TIMEBUF_SIZE, and _progvars::use_utc.

Referenced by AlertFast(), AlertFull(), LogPortscanAlert(), PrintArpHeader(), PrintEapolPkt(), PrintIPPkt(), PrintWifiPkt(), RealAlertCSV(), and SLog().


Variable Documentation

u_long netmasks[33]
 

Definition at line 151 of file snort.c.

Referenced by GenHomenet(), GenObfuscationMask(), InitNetmasks(), and ParseIP().


Generated on Sun May 14 14:51:27 2006 by  doxygen 1.4.2