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