Logo Search packages:      
Sourcecode: netams version File versions  Download package

common.h

/*************************************************************************
***   Authentication, authorization, accounting + firewalling package
***   Copyright 1998-2002 Anton Vinokurov <anton@netams.com>
***   Copyright 2002-2008 NeTAMS Development Team
***   This code is GPL v3
***   For latest version and more info, visit this project web page
***   located at http://www.netams.com
***
*************************************************************************/
/* $Id: common.h,v 1.63 2009-08-01 09:23:55 anton Exp $ */

//////////////////////////////////////////////////////////////////////////////////////////
#define KILL            1
#define RELOAD          2
#define SHUTDOWN        3
extern const char *signal_name[];
//////////////////////////////////////////////////////////////////////////////////////////
// Logging Management ///////////////////////////////////////////////////////////////////
void aLog(u_char level, char const *fmt, ...) __attribute__ ((format (printf, 2, 3)));

#define     D_EMERG         0x0000  /* for program start/stop records*/
#define     D_ALERT         0x0001  /* for threads start/stop, db open/close ? */
#define     D_CRIT          0x0002  /* die without data save */
#define     D_ERR     0x0003  /* errors, program will be closed with save */
#define     D_WARN          0x0004  /* warnings, should be logged */
#define     D_NOTICE    0x0005  /* */
#define     D_INFO          0x0006  /* informational messages for daily run*/
#define     D_DEBUG         0x0007  /* all debugging info is on */
#define     D_DEFAULT_DEBUG       D_INFO

enum event_type { SYSTEM=0, ACCESS, LOGIN, QUOTA, BILLING, RADIUS };    
//////////////////////////////////////////////////////////////////////////////////////////
typedef unsigned oid;
oid newOid(oid newid=0);
//////////////////////////////////////////////////////////////////////////////////////////
// Debugging management
typedef long long Debug;
extern Debug debug;

#if defined(DEBUG ) || defined(OLD_GCC)
u_char aDebug(u_char d, char const *fmt, ...);
#else
#define aDebug(...)
#endif

void aDebugInit();
u_char aDebugAdd(Debug *d, const char *str);
u_char aDebugRm(Debug *d, const char *str);
u_char aDebugIsSet(Debug *d, u_char u);

extern const char *debug_list[64]; 

#define DEBUG_NONE            0
#define     DEBUG_COMMAND           1
#define DEBUG_PARSE           2
#define DEBUG_SLEEP           3
#define DEBUG_SERVER          4
#define DEBUG_PROC_MUX        5
#define DEBUG_DS_IP           6
#define DEBUG_STORAGE         7
#define DEBUG_ALERT           8
#define DEBUG_SCHED           9
#define DEBUG_HTML            11
#define DEBUG_MONITOR         12
#define DEBUG_LOGIN           13
#define DEBUG_QUOTA           14
#define DEBUG_IPTREE          15
#define DEBUG_FLOW            16
#define DEBUG_DS_MUX          17
#define DEBUG_MEMORY          18
#define DEBUG_POLICY          19
#define DEBUG_BILLING         20
#define DEBUG_BW        22
#define DEBUG_ACLSERVER       23
#define DEBUG_MUTEX           24
#define DEBUG_DS_RAW    25
#define DEBUG_ALL       63

//////////////////////////////////////////////////////////////////////////////////////////
char *timeU2T(time_t time, char *buf);
time_t timeT2U(char *buf, time_t *time);
char *bytesQ2T(unsigned long long bytes, char *buf);
unsigned long long bytesT2Q(char *buf);

void termination(int signal=SIGTERM);
void logrotate(int signal);
//////////////////////////////////////////////////////////////////////////////////////////
struct time_counters {
      time_t ht;
      time_t dt;
      time_t wt;
      time_t mt;
};

void PrepareTimeCounters(struct time_counters *tc, time_t t=time(NULL));
void FillTimeCounters(policy_data *np,struct time_counters *tc);
time_t aGetActual(char prefix, time_t t=time(NULL));
//////////////////////////////////////////////////////////////////////////////////////////
void aShowVersion (FILE*);
void print_to_string(char **string, char const *fmt, ...);
char* set_string(const char *string);
char* cExec(const char *cmd);
int aCommand(const char *cmd, int mode, FILE *f=NULL);
int netams_system(const char* command);
//////////////////////////////////////////////////////////////////////////////////////////
u_char mask2mlen(in_addr *addr);
/* taken from http://groups.google.com/groups?hl=ru&lr=&threadm=cl3a87%24pa5%244%40wagner.wagner
.home&rnum=1&prev=/groups%3Fq%3D%25D0%25BC%25D0%25B0%25D1%2581%25D0%25BA%25D0%25B0%2B%25D1%2581%
25D0%25B5%25D1%2582%25D0%25B8%2Bgroup:*ru*unix.prog%26hl%3Dru%26lr%3D%26scoring%3Dr%26selm%3Dcl3
a87%2524pa5%25244%2540wagner.wagner.home%26rnum%3D1  */
#define MLEN2MASK(mlen) ((mlen)?(((in_addr_t)~(uint32_t)0) << (32 - (mlen))):0)
#define MASK2MLEN(mask) mask2mlen(&mask)
//////////////////////////////////////////////////////////////////////////////////////////
void aOidsInit();
int aShowSystemHealth(struct cli_def *cli, u_char is_html=0);
int getAddr(char *str, in_addr *addr, in_addr *mask=NULL);
int getdayofweek(const char *str);
extern const char *daysofweek[7];
//////////////////////////////////////////////////////////////////////////////////////////

Generated by  Doxygen 1.6.0   Back to index