Annotation of embedaddon/mpd/src/ppp.h, revision 1.1.1.2
1.1 misho 1:
2: /*
3: * ppp.h
4: *
5: * Written by Archie Cobbs <archie@freebsd.org>
6: * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
7: * See ``COPYRIGHT.whistle''
8: */
9:
10: #ifndef _PPP_H_
11: #define _PPP_H_
12:
13: /* Keep source files simple */
14:
15: #include <sys/types.h>
16: #include <sys/param.h>
17: #include <sys/socket.h>
18: #include <sys/ioctl.h>
19: #include <poll.h>
20: #include <sys/time.h>
21: #include <sys/uio.h>
22: #include <sys/queue.h>
23: #include <stdio.h>
24: #include <stdlib.h>
25: #include <limits.h>
26: #include <stddef.h>
27: #include <stdarg.h>
28: #include <string.h>
29: #include <signal.h>
30: #include <ctype.h>
31: #include <unistd.h>
32: #include <errno.h>
33: #include <err.h>
34: #include <netdb.h>
35: #include <fcntl.h>
36: #include <machine/endian.h>
37: #include <net/ppp_defs.h>
38: #include <netinet/in.h>
39: #include <arpa/inet.h>
40:
41: #include <pthread.h>
42: #ifdef NOLIBPDEL
43: #include "contrib/libpdel/structs/structs.h"
44: #include "contrib/libpdel/structs/type/array.h"
45: #include "contrib/libpdel/util/typed_mem.h"
46: #include "contrib/libpdel/util/pevent.h"
47: #include "contrib/libpdel/util/paction.h"
48: #include "contrib/libpdel/util/ghash.h"
49: #else
50: #include <pdel/structs/structs.h>
51: #include <pdel/structs/type/array.h>
52: #include <pdel/util/typed_mem.h>
53: #include <pdel/util/pevent.h>
54: #include <pdel/util/paction.h>
55: #include <pdel/util/ghash.h>
56: #endif
57:
58: #include <netgraph/ng_message.h>
59: #include <netgraph/ng_ppp.h>
60:
61: #include "defs.h"
1.1.1.2 ! misho 62: #include "msg.h"
1.1 misho 63:
64: /*
65: * DEFINITIONS
66: */
67:
68: /* Do our own version of assert() so it shows up in the logs */
69: #define assert(e) ((e) ? (void)0 : DoAssert(__FILE__, __LINE__, #e))
70:
71: /* Giant Mutex handling */
72: #define GIANT_MUTEX_LOCK() assert(pthread_mutex_lock(&gGiantMutex) == 0)
73: #define GIANT_MUTEX_UNLOCK() assert(pthread_mutex_unlock(&gGiantMutex) == 0)
74:
75: #define MUTEX_LOCK(m) assert(pthread_mutex_lock(&m) == 0)
76: #define MUTEX_UNLOCK(m) assert(pthread_mutex_unlock(&m) == 0)
77:
78: #define RWLOCK_RDLOCK(m) assert(pthread_rwlock_rdlock(&m) == 0)
79: #define RWLOCK_WRLOCK(m) assert(pthread_rwlock_wrlock(&m) == 0)
80: #define RWLOCK_UNLOCK(m) assert(pthread_rwlock_unlock(&m) == 0)
1.1.1.2 ! misho 81:
! 82: #define SETOVERLOAD(q) \
! 83: do { \
! 84: int t = (q); \
! 85: if (t > gQThresMax) { \
! 86: gOverload = 100; \
! 87: } else if (t > gQThresMin) { \
! 88: gOverload = (t - gQThresMin) * 100/gQThresDiff; \
! 89: } else { \
! 90: gOverload = 0; \
! 91: } \
! 92: } while (0)
1.1 misho 93:
94: #define OVERLOAD() (gOverload > (random() % 100))
95:
96: #define REF(p) do { \
97: (p)->refs++; \
98: } while (0)
99:
100: #define UNREF(p) do { \
101: if ((--(p)->refs) == 0) \
102: Freee(p); \
103: } while (0)
104:
105: #define RESETREF(v, p) do { \
106: if (v) UNREF(v); \
107: (v) = (p); \
108: if (v) REF(v); \
109: } while (0)
110:
111: #define ADLG_WAN_AUTHORIZATION_FAILURE 0
112: #define ADLG_WAN_CONNECTED 1
113: #define ADLG_WAN_CONNECTING 2
114: #define ADLG_WAN_CONNECT_FAILURE 3
115: #define ADLG_WAN_DISABLED 4
116: #define ADLG_WAN_MESSAGE 5
117: #define ADLG_WAN_NEGOTIATION_FAILURE 6
118: #define ADLG_WAN_WAIT_FOR_DEMAND 7
119:
120: #ifndef NG_PPP_STATS64
121: /* internal 64 bit counters as workaround for the 32 bit
122: * limitation for ng_ppp_link_stat
123: */
124: struct ng_ppp_link_stat64 {
125: u_int64_t xmitFrames; /* xmit frames on link */
126: u_int64_t xmitOctets; /* xmit octets on link */
127: u_int64_t recvFrames; /* recv frames on link */
128: u_int64_t recvOctets; /* recv octets on link */
129: u_int64_t badProtos; /* frames rec'd with bogus protocol */
130: u_int64_t runts; /* Too short MP fragments */
131: u_int64_t dupFragments; /* MP frames with duplicate seq # */
132: u_int64_t dropFragments; /* MP fragments we had to drop */
133: };
134: #endif
135:
136: #if defined(USE_NG_BPF) || defined(USE_IPFW)
137: /* max. length of acl rule */
138: #define ACL_LEN 256
139: #define ACL_NAME_LEN 16
140: /* max. number of acl_filters */
141: #define ACL_FILTERS 16
142: /* There are two directions for acl_limits */
143: #define ACL_DIRS 2
144: #endif
145:
146: #ifdef USE_NG_BPF
147: struct svcssrc {
148: int type;
149: #define SSSS_IN 1
150: #define SSSS_MATCH 2
151: #define SSSS_NOMATCH 3
152: #define SSSS_OUT 4
153: char hook[NG_HOOKSIZ];
154: SLIST_ENTRY(svcssrc) next;
155: };
156:
157: struct svcs {
158: char name[ACL_NAME_LEN]; /* Name of ACL */
159: SLIST_HEAD(, svcssrc) src;
160: SLIST_ENTRY(svcs) next;
161: };
162:
163: struct svcstatrec {
164: char name[ACL_NAME_LEN]; /* Name of ACL */
165: u_int64_t Packets;
166: u_int64_t Octets;
167: SLIST_ENTRY(svcstatrec) next;
168: };
169:
170: struct svcstat {
171: SLIST_HEAD(, svcstatrec) stat[ACL_DIRS];
172: };
173: #endif /* USE_NG_BPF */
174:
175: #include "bund.h"
176: #include "link.h"
177: #include "rep.h"
178: #include "phys.h"
179: #include "msgdef.h"
180:
181: /*
182: * VARIABLES
183: */
184:
185: extern Rep *gReps; /* Repeaters */
186: extern Link *gLinks; /* Links */
187: extern Bund *gBundles; /* Bundles */
188:
189: extern int gNumReps; /* Total number of repeaters */
190: extern int gNumLinks; /* Total number of links */
191: extern int gNumBundles; /* Total number of bundles */
192: extern struct console gConsole;
193: extern struct web gWeb;
194: extern struct radsrv gRadsrv;
195: extern int gBackground;
196: extern int gShutdownInProgress;
197: extern int gOverload;
198: extern pid_t gPid;
199: extern int gRouteSeq;
200:
201: #ifdef PHYSTYPE_PPTP
202: extern int gPPTPto;
203: extern int gPPTPtunlimit;
204: #endif
205: #ifdef PHYSTYPE_L2TP
206: extern int gL2TPto;
207: extern int gL2TPtunlimit;
208: #endif
209: extern int gChildren;
210: extern int gMaxChildren;
211:
212: extern struct globalconf gGlobalConf; /* Global config settings */
213:
214: #ifdef USE_NG_BPF
215: extern struct acl *acl_filters[ACL_FILTERS]; /* mpd's internal bpf filters */
216: #endif
217:
1.1.1.2 ! misho 218: #ifdef USE_PAM
! 219: extern char gPamService[32];
! 220: #endif
! 221:
1.1 misho 222: extern struct pevent_ctx *gPeventCtx;
223: extern pthread_mutex_t gGiantMutex; /* Giant Mutex */
224:
225: extern const char *gVersion; /* Program version string */
226: extern const char *gConfigFile; /* Main config file */
227: extern const char *gConfDirectory; /* Where the files are */
228:
229: /*
230: * FUNCTIONS
231: */
232:
233: extern void Greetings(void);
234: extern void SendSignal(int sig);
235: extern void DoExit(int code) __dead2;
236: extern void DoAssert(const char *file, int line, const char *x) __dead2;
237: extern void CheckOneShot(void);
238:
239: #endif
240:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>