Annotation of embedaddon/mpd/src/ppp.h, revision 1.1.1.3.2.1
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:
1.1.1.3 misho 71: #ifdef __clang__
1.1.1.3.2.1! misho 72: #ifndef NO_THREAD_SAFETY_ANALYSIS
1.1.1.3 misho 73: #ifndef THREAD_ANNOTATION_ATTRIBUTE__
74: #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
75: #endif
76: #define NO_THREAD_SAFETY_ANALYSIS \
77: THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
1.1.1.3.2.1! misho 78: #endif
1.1.1.3 misho 79: #else
80: #define NO_THREAD_SAFETY_ANALYSIS
81: #endif /* __clang__ */
82:
1.1 misho 83: /* Giant Mutex handling */
84: #define GIANT_MUTEX_LOCK() assert(pthread_mutex_lock(&gGiantMutex) == 0)
85: #define GIANT_MUTEX_UNLOCK() assert(pthread_mutex_unlock(&gGiantMutex) == 0)
86:
87: #define MUTEX_LOCK(m) assert(pthread_mutex_lock(&m) == 0)
88: #define MUTEX_UNLOCK(m) assert(pthread_mutex_unlock(&m) == 0)
89:
90: #define RWLOCK_RDLOCK(m) assert(pthread_rwlock_rdlock(&m) == 0)
91: #define RWLOCK_WRLOCK(m) assert(pthread_rwlock_wrlock(&m) == 0)
92: #define RWLOCK_UNLOCK(m) assert(pthread_rwlock_unlock(&m) == 0)
1.1.1.2 misho 93:
94: #define SETOVERLOAD(q) \
95: do { \
96: int t = (q); \
97: if (t > gQThresMax) { \
98: gOverload = 100; \
99: } else if (t > gQThresMin) { \
100: gOverload = (t - gQThresMin) * 100/gQThresDiff; \
101: } else { \
102: gOverload = 0; \
103: } \
104: } while (0)
1.1 misho 105:
106: #define OVERLOAD() (gOverload > (random() % 100))
107:
108: #define REF(p) do { \
109: (p)->refs++; \
110: } while (0)
111:
112: #define UNREF(p) do { \
113: if ((--(p)->refs) == 0) \
114: Freee(p); \
115: } while (0)
116:
117: #define RESETREF(v, p) do { \
118: if (v) UNREF(v); \
119: (v) = (p); \
120: if (v) REF(v); \
121: } while (0)
122:
123: #define ADLG_WAN_AUTHORIZATION_FAILURE 0
124: #define ADLG_WAN_CONNECTED 1
125: #define ADLG_WAN_CONNECTING 2
126: #define ADLG_WAN_CONNECT_FAILURE 3
127: #define ADLG_WAN_DISABLED 4
128: #define ADLG_WAN_MESSAGE 5
129: #define ADLG_WAN_NEGOTIATION_FAILURE 6
130: #define ADLG_WAN_WAIT_FOR_DEMAND 7
131:
132: #ifndef NG_PPP_STATS64
133: /* internal 64 bit counters as workaround for the 32 bit
134: * limitation for ng_ppp_link_stat
135: */
136: struct ng_ppp_link_stat64 {
137: u_int64_t xmitFrames; /* xmit frames on link */
138: u_int64_t xmitOctets; /* xmit octets on link */
139: u_int64_t recvFrames; /* recv frames on link */
140: u_int64_t recvOctets; /* recv octets on link */
141: u_int64_t badProtos; /* frames rec'd with bogus protocol */
142: u_int64_t runts; /* Too short MP fragments */
143: u_int64_t dupFragments; /* MP frames with duplicate seq # */
144: u_int64_t dropFragments; /* MP fragments we had to drop */
145: };
146: #endif
147:
148: #if defined(USE_NG_BPF) || defined(USE_IPFW)
149: /* max. length of acl rule */
150: #define ACL_LEN 256
151: #define ACL_NAME_LEN 16
152: /* max. number of acl_filters */
153: #define ACL_FILTERS 16
154: /* There are two directions for acl_limits */
155: #define ACL_DIRS 2
156: #endif
157:
158: #ifdef USE_NG_BPF
159: struct svcssrc {
160: int type;
161: #define SSSS_IN 1
162: #define SSSS_MATCH 2
163: #define SSSS_NOMATCH 3
164: #define SSSS_OUT 4
165: char hook[NG_HOOKSIZ];
166: SLIST_ENTRY(svcssrc) next;
167: };
168:
169: struct svcs {
170: char name[ACL_NAME_LEN]; /* Name of ACL */
171: SLIST_HEAD(, svcssrc) src;
172: SLIST_ENTRY(svcs) next;
173: };
174:
175: struct svcstatrec {
176: char name[ACL_NAME_LEN]; /* Name of ACL */
177: u_int64_t Packets;
178: u_int64_t Octets;
179: SLIST_ENTRY(svcstatrec) next;
180: };
181:
182: struct svcstat {
183: SLIST_HEAD(, svcstatrec) stat[ACL_DIRS];
184: };
185: #endif /* USE_NG_BPF */
186:
187: #include "bund.h"
188: #include "link.h"
189: #include "rep.h"
190: #include "phys.h"
191: #include "msgdef.h"
192:
193: /*
194: * VARIABLES
195: */
196:
197: extern Rep *gReps; /* Repeaters */
198: extern Link *gLinks; /* Links */
199: extern Bund *gBundles; /* Bundles */
200:
201: extern int gNumReps; /* Total number of repeaters */
202: extern int gNumLinks; /* Total number of links */
203: extern int gNumBundles; /* Total number of bundles */
204: extern struct console gConsole;
205: extern struct web gWeb;
1.1.1.3.2.1! misho 206: #ifdef USE_RADIUS
1.1 misho 207: extern struct radsrv gRadsrv;
1.1.1.3.2.1! misho 208: #endif
1.1 misho 209: extern int gBackground;
210: extern int gShutdownInProgress;
211: extern int gOverload;
212: extern pid_t gPid;
213: extern int gRouteSeq;
214:
215: #ifdef PHYSTYPE_PPTP
216: extern int gPPTPto;
1.1.1.3 misho 217: extern unsigned gPPTPtunlimit;
1.1 misho 218: #endif
219: #ifdef PHYSTYPE_L2TP
220: extern int gL2TPto;
1.1.1.3 misho 221: extern unsigned gL2TPtunlimit;
1.1 misho 222: #endif
223: extern int gChildren;
224: extern int gMaxChildren;
225:
226: extern struct globalconf gGlobalConf; /* Global config settings */
227:
1.1.1.3 misho 228: #if defined(USE_NG_BPF) && !defined(RADSRV)
1.1 misho 229: extern struct acl *acl_filters[ACL_FILTERS]; /* mpd's internal bpf filters */
230: #endif
231:
1.1.1.2 misho 232: #ifdef USE_PAM
233: extern char gPamService[32];
234: #endif
235:
1.1 misho 236: extern struct pevent_ctx *gPeventCtx;
237: extern pthread_mutex_t gGiantMutex; /* Giant Mutex */
238:
239: extern const char *gVersion; /* Program version string */
240: extern const char *gConfigFile; /* Main config file */
241: extern const char *gConfDirectory; /* Where the files are */
242:
243: /*
244: * FUNCTIONS
245: */
246:
247: extern void Greetings(void);
248: extern void SendSignal(int sig);
249: extern void DoExit(int code) __dead2;
250: extern void DoAssert(const char *file, int line, const char *x) __dead2;
251: extern void CheckOneShot(void);
252:
253: #endif
254:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>