00001 /* $Id$ */ 00002 /* 00003 ** Copyright (C) 2002 Martin Roesch <roesch@sourcefire.com> 00004 ** 00005 ** This program is free software; you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation; either version 2 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program; if not, write to the Free Software 00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 00021 #ifndef __UTIL_H__ 00022 #define __UTIL_H__ 00023 00024 #define TIMEBUF_SIZE 26 00025 00026 #ifndef WIN32 00027 #include <sys/time.h> 00028 #include <sys/types.h> 00029 #endif /* !WIN32 */ 00030 00031 #ifdef HAVE_CONFIG_H 00032 #include "config.h" 00033 #endif 00034 00035 #ifndef HAVE_STRLCAT 00036 #include "strlcatu.h" 00037 #endif 00038 00039 #ifndef HAVE_STRLCPY 00040 #include "strlcpyu.h" 00041 #endif 00042 00043 #include "sfsnprintfappend.h" 00044 00045 extern u_long netmasks[33]; 00046 00047 /* Self preservation memory control struct */ 00048 typedef struct _SPMemControl 00049 { 00050 unsigned long memcap; 00051 unsigned long mem_usage; 00052 void *control; 00053 int (*sp_func)(struct _SPMemControl *); 00054 00055 unsigned long fault_count; 00056 00057 } SPMemControl; 00058 00059 00060 int DisplayBanner(); 00061 void GetTime(char *); 00062 int gmt2local(time_t); 00063 void ts_print(register const struct timeval *, char *); 00064 char *copy_argv(char **); 00065 int strip(char *); 00066 float CalcPct(float, float); 00067 void ReadPacketsFromFile(); 00068 void GenHomenet(char *); 00069 void InitNetmasks(); 00070 void InitBinFrag(); 00071 void GoDaemon(); 00072 void CheckLogDir(); 00073 char *read_infile(char *); 00074 void InitProtoNames(); 00075 void CleanupProtoNames(); 00076 void PrintError(char *); 00077 void ErrorMessage(const char *, ...); 00078 void LogMessage(const char *, ...); 00079 void FatalError(const char *, ...); 00080 void FatalPrintError(char *); 00081 void CreatePidFile(char *); 00082 void SetUidGid(void); 00083 void SetChroot(char *, char **); 00084 void DropStats(int); 00085 void GenObfuscationMask(char *); 00086 void *SPAlloc(unsigned long, struct _SPMemControl *); 00087 void *SnortAlloc(unsigned long); 00088 char *CurrentWorkingDir(void); 00089 char *GetAbsolutePath(char *dir); 00090 char *StripPrefixDir(char *prefix, char *dir); 00091 #ifdef TIMESTATS 00092 void DropHourlyStats(int trap); 00093 #endif 00094 00095 #endif /*__UTIL_H__*/