/* * ppp.h * * Written by Archie Cobbs * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved. * See ``COPYRIGHT.whistle'' */ #ifndef _PPP_H_ #define _PPP_H_ /* Keep source files simple */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef NOLIBPDEL #include "contrib/libpdel/structs/structs.h" #include "contrib/libpdel/structs/type/array.h" #include "contrib/libpdel/util/typed_mem.h" #include "contrib/libpdel/util/pevent.h" #include "contrib/libpdel/util/paction.h" #include "contrib/libpdel/util/ghash.h" #else #include #include #include #include #include #include #endif #include #include #include "defs.h" #include "msg.h" /* * DEFINITIONS */ /* Do our own version of assert() so it shows up in the logs */ #define assert(e) ((e) ? (void)0 : DoAssert(__FILE__, __LINE__, #e)) /* Giant Mutex handling */ #define GIANT_MUTEX_LOCK() assert(pthread_mutex_lock(&gGiantMutex) == 0) #define GIANT_MUTEX_UNLOCK() assert(pthread_mutex_unlock(&gGiantMutex) == 0) #define MUTEX_LOCK(m) assert(pthread_mutex_lock(&m) == 0) #define MUTEX_UNLOCK(m) assert(pthread_mutex_unlock(&m) == 0) #define RWLOCK_RDLOCK(m) assert(pthread_rwlock_rdlock(&m) == 0) #define RWLOCK_WRLOCK(m) assert(pthread_rwlock_wrlock(&m) == 0) #define RWLOCK_UNLOCK(m) assert(pthread_rwlock_unlock(&m) == 0) #define SETOVERLOAD(q) \ do { \ int t = (q); \ if (t > gQThresMax) { \ gOverload = 100; \ } else if (t > gQThresMin) { \ gOverload = (t - gQThresMin) * 100/gQThresDiff; \ } else { \ gOverload = 0; \ } \ } while (0) #define OVERLOAD() (gOverload > (random() % 100)) #define REF(p) do { \ (p)->refs++; \ } while (0) #define UNREF(p) do { \ if ((--(p)->refs) == 0) \ Freee(p); \ } while (0) #define RESETREF(v, p) do { \ if (v) UNREF(v); \ (v) = (p); \ if (v) REF(v); \ } while (0) #define ADLG_WAN_AUTHORIZATION_FAILURE 0 #define ADLG_WAN_CONNECTED 1 #define ADLG_WAN_CONNECTING 2 #define ADLG_WAN_CONNECT_FAILURE 3 #define ADLG_WAN_DISABLED 4 #define ADLG_WAN_MESSAGE 5 #define ADLG_WAN_NEGOTIATION_FAILURE 6 #define ADLG_WAN_WAIT_FOR_DEMAND 7 #ifndef NG_PPP_STATS64 /* internal 64 bit counters as workaround for the 32 bit * limitation for ng_ppp_link_stat */ struct ng_ppp_link_stat64 { u_int64_t xmitFrames; /* xmit frames on link */ u_int64_t xmitOctets; /* xmit octets on link */ u_int64_t recvFrames; /* recv frames on link */ u_int64_t recvOctets; /* recv octets on link */ u_int64_t badProtos; /* frames rec'd with bogus protocol */ u_int64_t runts; /* Too short MP fragments */ u_int64_t dupFragments; /* MP frames with duplicate seq # */ u_int64_t dropFragments; /* MP fragments we had to drop */ }; #endif #if defined(USE_NG_BPF) || defined(USE_IPFW) /* max. length of acl rule */ #define ACL_LEN 256 #define ACL_NAME_LEN 16 /* max. number of acl_filters */ #define ACL_FILTERS 16 /* There are two directions for acl_limits */ #define ACL_DIRS 2 #endif #ifdef USE_NG_BPF struct svcssrc { int type; #define SSSS_IN 1 #define SSSS_MATCH 2 #define SSSS_NOMATCH 3 #define SSSS_OUT 4 char hook[NG_HOOKSIZ]; SLIST_ENTRY(svcssrc) next; }; struct svcs { char name[ACL_NAME_LEN]; /* Name of ACL */ SLIST_HEAD(, svcssrc) src; SLIST_ENTRY(svcs) next; }; struct svcstatrec { char name[ACL_NAME_LEN]; /* Name of ACL */ u_int64_t Packets; u_int64_t Octets; SLIST_ENTRY(svcstatrec) next; }; struct svcstat { SLIST_HEAD(, svcstatrec) stat[ACL_DIRS]; }; #endif /* USE_NG_BPF */ #include "bund.h" #include "link.h" #include "rep.h" #include "phys.h" #include "msgdef.h" /* * VARIABLES */ extern Rep *gReps; /* Repeaters */ extern Link *gLinks; /* Links */ extern Bund *gBundles; /* Bundles */ extern int gNumReps; /* Total number of repeaters */ extern int gNumLinks; /* Total number of links */ extern int gNumBundles; /* Total number of bundles */ extern struct console gConsole; extern struct web gWeb; extern struct radsrv gRadsrv; extern int gBackground; extern int gShutdownInProgress; extern int gOverload; extern pid_t gPid; extern int gRouteSeq; #ifdef PHYSTYPE_PPTP extern int gPPTPto; extern int gPPTPtunlimit; #endif #ifdef PHYSTYPE_L2TP extern int gL2TPto; extern int gL2TPtunlimit; #endif extern int gChildren; extern int gMaxChildren; extern struct globalconf gGlobalConf; /* Global config settings */ #ifdef USE_NG_BPF extern struct acl *acl_filters[ACL_FILTERS]; /* mpd's internal bpf filters */ #endif #ifdef USE_PAM extern char gPamService[32]; #endif extern struct pevent_ctx *gPeventCtx; extern pthread_mutex_t gGiantMutex; /* Giant Mutex */ extern const char *gVersion; /* Program version string */ extern const char *gConfigFile; /* Main config file */ extern const char *gConfDirectory; /* Where the files are */ /* * FUNCTIONS */ extern void Greetings(void); extern void SendSignal(int sig); extern void DoExit(int code) __dead2; extern void DoAssert(const char *file, int line, const char *x) __dead2; extern void CheckOneShot(void); #endif