1 |
30 |
unneback |
/*
|
2 |
|
|
* pppd.h - PPP daemon global declarations.
|
3 |
|
|
*
|
4 |
|
|
* Copyright (c) 1989 Carnegie Mellon University.
|
5 |
|
|
* All rights reserved.
|
6 |
|
|
*
|
7 |
|
|
* Redistribution and use in source and binary forms are permitted
|
8 |
|
|
* provided that the above copyright notice and this paragraph are
|
9 |
|
|
* duplicated in all such forms and that any documentation,
|
10 |
|
|
* advertising materials, and other materials related to such
|
11 |
|
|
* distribution and use acknowledge that the software was developed
|
12 |
|
|
* by Carnegie Mellon University. The name of the
|
13 |
|
|
* University may not be used to endorse or promote products derived
|
14 |
|
|
* from this software without specific prior written permission.
|
15 |
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
16 |
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
17 |
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
|
|
*
|
19 |
|
|
* $Id: pppd.h,v 1.2 2001-09-27 12:01:57 chris Exp $
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
|
|
/*
|
23 |
|
|
* TODO:
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
#ifndef __PPPD_H__
|
27 |
|
|
#define __PPPD_H__
|
28 |
|
|
|
29 |
|
|
#include <stdio.h> /* for FILE */
|
30 |
|
|
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
31 |
|
|
#include <sys/types.h> /* for u_int32_t, if defined */
|
32 |
|
|
#include <sys/time.h> /* for struct timeval */
|
33 |
|
|
#include <net/ppp_defs.h>
|
34 |
|
|
|
35 |
|
|
#if __STDC__
|
36 |
|
|
#include <stdarg.h>
|
37 |
|
|
#define __V(x) x
|
38 |
|
|
#else
|
39 |
|
|
#include <varargs.h>
|
40 |
|
|
#define __V(x) (va_alist) va_dcl
|
41 |
|
|
#define const
|
42 |
|
|
#endif
|
43 |
|
|
|
44 |
|
|
/*
|
45 |
|
|
* Limits.
|
46 |
|
|
*/
|
47 |
|
|
|
48 |
|
|
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
49 |
|
|
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
50 |
|
|
#define MAXARGS 1 /* max # args to a command */
|
51 |
|
|
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
52 |
|
|
#define MAXSECRETLEN 256 /* max length of password or secret */
|
53 |
|
|
|
54 |
|
|
/*
|
55 |
|
|
* Global variables.
|
56 |
|
|
*/
|
57 |
|
|
|
58 |
|
|
extern int hungup; /* Physical layer has disconnected */
|
59 |
|
|
extern int interfunit; /* Interface unit number */
|
60 |
|
|
extern char ifname[]; /* Interface name */
|
61 |
|
|
extern int ttyfd; /* Serial device file descriptor */
|
62 |
|
|
extern char hostname[]; /* Our hostname */
|
63 |
|
|
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
64 |
|
|
extern int phase; /* Current state of link - see values below */
|
65 |
|
|
extern int baud_rate; /* Current link speed in bits/sec */
|
66 |
|
|
extern char *progname; /* Name of this program */
|
67 |
|
|
extern int redirect_stderr;/* Connector's stderr should go to file */
|
68 |
|
|
extern char peer_authname[];/* Authenticated name of peer */
|
69 |
|
|
extern int privileged; /* We were run by real-uid root */
|
70 |
|
|
extern int need_holdoff; /* Need holdoff period after link terminates */
|
71 |
|
|
extern char **script_env; /* Environment variables for scripts */
|
72 |
|
|
extern int detached; /* Have detached from controlling tty */
|
73 |
|
|
|
74 |
|
|
/*
|
75 |
|
|
* Variables set by command-line options.
|
76 |
|
|
*/
|
77 |
|
|
|
78 |
|
|
extern int debug; /* Debug flag */
|
79 |
|
|
extern int kdebugflag; /* Tell kernel to print debug messages */
|
80 |
|
|
extern int default_device; /* Using /dev/tty or equivalent */
|
81 |
|
|
extern char devnam[]; /* Device name */
|
82 |
|
|
extern int crtscts; /* Use hardware flow control */
|
83 |
|
|
extern int modem; /* Use modem control lines */
|
84 |
|
|
extern int inspeed; /* Input/Output speed requested */
|
85 |
|
|
extern u_int32_t netmask; /* IP netmask to set on interface */
|
86 |
|
|
extern int lockflag; /* Create lock file to lock the serial dev */
|
87 |
|
|
extern int nodetach; /* Don't detach from controlling tty */
|
88 |
|
|
extern char *connector[]; /* Script to establish physical link */
|
89 |
|
|
extern char **disconnector; /* Script to disestablish physical link */
|
90 |
|
|
extern char **welcomer; /* Script to welcome client after connection */
|
91 |
|
|
extern int maxconnect; /* Maximum connect time (seconds) */
|
92 |
|
|
extern char user[]; /* Our name for authenticating ourselves */
|
93 |
|
|
extern char passwd[]; /* Password for PAP */
|
94 |
|
|
extern int auth_required; /* Peer is required to authenticate */
|
95 |
|
|
extern int proxyarp; /* Set up proxy ARP entry for peer */
|
96 |
|
|
extern int persist; /* Reopen link after it goes down */
|
97 |
|
|
extern int uselogin; /* Use /etc/passwd for checking PAP */
|
98 |
|
|
extern int lcp_echo_interval; /* Interval between LCP echo-requests */
|
99 |
|
|
extern int lcp_echo_fails; /* Tolerance to unanswered echo-requests */
|
100 |
|
|
extern char our_name[]; /* Our name for authentication purposes */
|
101 |
|
|
extern char remote_name[]; /* Peer's name for authentication */
|
102 |
|
|
extern int explicit_remote;/* remote_name specified with remotename opt */
|
103 |
|
|
extern int usehostname; /* Use hostname for our_name */
|
104 |
|
|
extern int disable_defaultip; /* Don't use hostname for default IP adrs */
|
105 |
|
|
extern int demand; /* Do dial-on-demand */
|
106 |
|
|
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
107 |
|
|
extern int cryptpap; /* Others' PAP passwords are encrypted */
|
108 |
|
|
extern int idle_time_limit;/* Shut down link if idle for this long */
|
109 |
|
|
extern int holdoff; /* Dead time before restarting */
|
110 |
|
|
extern int refuse_pap; /* Don't wanna auth. ourselves with PAP */
|
111 |
|
|
extern int refuse_chap; /* Don't wanna auth. ourselves with CHAP */
|
112 |
|
|
#ifdef PPP_FILTER
|
113 |
|
|
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
114 |
|
|
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
115 |
|
|
#endif
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
#ifdef MSLANMAN
|
119 |
|
|
extern int ms_lanman; /* Nonzero if use LanMan password instead of NT */
|
120 |
|
|
/* Has meaning only with MS-CHAP challenges */
|
121 |
|
|
#endif
|
122 |
|
|
|
123 |
|
|
/*
|
124 |
|
|
* Values for phase.
|
125 |
|
|
*/
|
126 |
|
|
#define PHASE_DEAD 0
|
127 |
|
|
#define PHASE_INITIALIZE 1
|
128 |
|
|
#define PHASE_DORMANT 2
|
129 |
|
|
#define PHASE_ESTABLISH 3
|
130 |
|
|
#define PHASE_AUTHENTICATE 4
|
131 |
|
|
#define PHASE_CALLBACK 5
|
132 |
|
|
#define PHASE_NETWORK 6
|
133 |
|
|
#define PHASE_TERMINATE 7
|
134 |
|
|
#define PHASE_HOLDOFF 8
|
135 |
|
|
|
136 |
|
|
/*
|
137 |
|
|
* The following struct gives the addresses of procedures to call
|
138 |
|
|
* for a particular protocol.
|
139 |
|
|
*/
|
140 |
|
|
struct protent {
|
141 |
|
|
u_short protocol; /* PPP protocol number */
|
142 |
|
|
/* Initialization procedure */
|
143 |
|
|
void (*init) __P((int unit));
|
144 |
|
|
/* Process a received packet */
|
145 |
|
|
void (*input) __P((int unit, u_char *pkt, int len));
|
146 |
|
|
/* Process a received protocol-reject */
|
147 |
|
|
void (*protrej) __P((int unit));
|
148 |
|
|
/* Lower layer has come up */
|
149 |
|
|
void (*lowerup) __P((int unit));
|
150 |
|
|
/* Lower layer has gone down */
|
151 |
|
|
void (*lowerdown) __P((int unit));
|
152 |
|
|
/* Open the protocol */
|
153 |
|
|
void (*open) __P((int unit));
|
154 |
|
|
/* Close the protocol */
|
155 |
|
|
void (*close) __P((int unit, char *reason));
|
156 |
|
|
/* Print a packet in readable form */
|
157 |
|
|
int (*printpkt) __P((u_char *pkt, int len,
|
158 |
|
|
void (*printer) __P((void *, char *, ...)),
|
159 |
|
|
void *arg));
|
160 |
|
|
/* Process a received data packet */
|
161 |
|
|
void (*datainput) __P((int unit, u_char *pkt, int len));
|
162 |
|
|
int enabled_flag; /* 0 iff protocol is disabled */
|
163 |
|
|
char *name; /* Text name of protocol */
|
164 |
|
|
/* Check requested options, assign defaults */
|
165 |
|
|
void (*check_options) __P((void));
|
166 |
|
|
/* Configure interface for demand-dial */
|
167 |
|
|
int (*demand_conf) __P((int unit));
|
168 |
|
|
/* Say whether to bring up link for this pkt */
|
169 |
|
|
int (*active_pkt) __P((u_char *pkt, int len));
|
170 |
|
|
};
|
171 |
|
|
|
172 |
|
|
/* Table of pointers to supported protocols */
|
173 |
|
|
extern struct protent *protocols[];
|
174 |
|
|
|
175 |
|
|
/*
|
176 |
|
|
* Prototypes.
|
177 |
|
|
*/
|
178 |
|
|
|
179 |
|
|
/* Procedures exported from main.c. */
|
180 |
|
|
void detach __P((void)); /* Detach from controlling tty */
|
181 |
|
|
void die __P((int)); /* Cleanup and exit */
|
182 |
|
|
void quit __P((void)); /* like die(1) */
|
183 |
|
|
void novm __P((char *)); /* Say we ran out of memory, and die */
|
184 |
|
|
void my_timeout __P((void (*func)(void *), void *arg, int t));
|
185 |
|
|
/* Call func(arg) after t seconds */
|
186 |
|
|
void untimeout __P((void (*func)(void *), void *arg));
|
187 |
|
|
/* Cancel call to func(arg) */
|
188 |
|
|
int run_program __P((char *prog, char **args, int must_exist));
|
189 |
|
|
/* Run program prog with args in child */
|
190 |
|
|
void demuxprotrej __P((int, int));
|
191 |
|
|
/* Demultiplex a Protocol-Reject */
|
192 |
|
|
void format_packet __P((u_char *, int, void (*) (void *, char *, ...),
|
193 |
|
|
void *)); /* Format a packet in human-readable form */
|
194 |
|
|
void log_packet __P((u_char *, int, char *, int));
|
195 |
|
|
/* Format a packet and log it with syslog */
|
196 |
|
|
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
197 |
|
|
void *)); /* Format a string for output */
|
198 |
|
|
int fmtmsg __P((char *, int, char *, ...)); /* sprintf++ */
|
199 |
|
|
int vfmtmsg __P((char *, int, char *, va_list)); /* vsprintf++ */
|
200 |
|
|
void script_setenv __P((char *, char *)); /* set script env var */
|
201 |
|
|
void script_unsetenv __P((char *)); /* unset script env var */
|
202 |
|
|
/* My procedures */
|
203 |
|
|
int connect_stb();
|
204 |
|
|
int disconnect_stb();
|
205 |
|
|
int pppdmain(int, char*[]);
|
206 |
|
|
int chatmain(char*);
|
207 |
|
|
|
208 |
|
|
/* Procedures exported from auth.c */
|
209 |
|
|
|
210 |
|
|
void link_required __P((int)); /* we are starting to use the link */
|
211 |
|
|
void link_terminated __P((int)); /* we are finished with the link */
|
212 |
|
|
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
213 |
|
|
void link_established __P((int)); /* the link is up; authenticate now */
|
214 |
|
|
void np_up __P((int, int)); /* a network protocol has come up */
|
215 |
|
|
void np_down __P((int, int)); /* a network protocol has gone down */
|
216 |
|
|
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
217 |
|
|
void auth_peer_fail __P((int, int));
|
218 |
|
|
/* peer failed to authenticate itself */
|
219 |
|
|
void auth_peer_success __P((int, int, char *, int));
|
220 |
|
|
/* peer successfully authenticated itself */
|
221 |
|
|
void auth_withpeer_fail __P((int, int));
|
222 |
|
|
/* we failed to authenticate ourselves */
|
223 |
|
|
void auth_withpeer_success __P((int, int));
|
224 |
|
|
/* we successfully authenticated ourselves */
|
225 |
|
|
void auth_check_options __P((void));
|
226 |
|
|
/* check authentication options supplied */
|
227 |
|
|
void auth_reset __P((int)); /* check what secrets we have */
|
228 |
|
|
int check_passwd __P((int, char *, int, char *, int, char **, int *));
|
229 |
|
|
/* Check peer-supplied username/password */
|
230 |
|
|
int get_secret __P((int, char *, char *, char *, int *, int));
|
231 |
|
|
/* get "secret" for chap */
|
232 |
|
|
int auth_ip_addr __P((int, u_int32_t));
|
233 |
|
|
/* check if IP address is authorized */
|
234 |
|
|
int bad_ip_adrs __P((u_int32_t));
|
235 |
|
|
/* check if IP address is unreasonable */
|
236 |
|
|
void check_access __P((FILE *, char *));
|
237 |
|
|
/* check permissions on secrets file */
|
238 |
|
|
|
239 |
|
|
/* Procedures exported from demand.c */
|
240 |
|
|
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
241 |
|
|
void demand_block __P((void)); /* set all NPs to queue up packets */
|
242 |
|
|
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
243 |
|
|
void demand_discard __P((void)); /* set all NPs to discard packets */
|
244 |
|
|
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
245 |
|
|
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
246 |
|
|
int loop_frame __P((unsigned char *, int)); /* process frame from loopback */
|
247 |
|
|
|
248 |
|
|
/* Procedures exported from sys-*.c */
|
249 |
|
|
void sys_init __P((void)); /* Do system-dependent initialization */
|
250 |
|
|
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
251 |
|
|
void sys_check_options __P((void)); /* Check options specified */
|
252 |
|
|
void sys_close __P((void)); /* Clean up in a child before execing */
|
253 |
|
|
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
254 |
|
|
void open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
255 |
|
|
void establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
256 |
|
|
void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
|
257 |
|
|
void disestablish_ppp __P((int)); /* Restore port to normal operation */
|
258 |
|
|
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
259 |
|
|
void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
|
260 |
|
|
void restore_tty __P((int)); /* Restore port's original parameters */
|
261 |
|
|
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
262 |
|
|
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
263 |
|
|
void wait_input __P((struct timeval *));
|
264 |
|
|
/* Wait for input, with timeout */
|
265 |
|
|
void wait_loop_output __P((struct timeval *));
|
266 |
|
|
/* Wait for pkt from loopback, with timeout */
|
267 |
|
|
void wait_time __P((struct timeval *)); /* Wait for given length of time */
|
268 |
|
|
int read_packet __P((u_char *)); /* Read PPP packet */
|
269 |
|
|
int get_loop_output __P((void)); /* Read pkts from loopback */
|
270 |
|
|
void ppp_send_config __P((int, int, u_int32_t, int, int));
|
271 |
|
|
/* Configure i/f transmit parameters */
|
272 |
|
|
void ppp_set_xaccm __P((int, ext_accm));
|
273 |
|
|
/* Set extended transmit ACCM */
|
274 |
|
|
void ppp_recv_config __P((int, int, u_int32_t, int, int));
|
275 |
|
|
/* Configure i/f receive parameters */
|
276 |
|
|
int ccp_test __P((int, u_char *, int, int));
|
277 |
|
|
/* Test support for compression scheme */
|
278 |
|
|
void ccp_flags_set __P((int, int, int));
|
279 |
|
|
/* Set kernel CCP state */
|
280 |
|
|
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
281 |
|
|
int get_idle_time __P((int, struct ppp_idle *));
|
282 |
|
|
/* Find out how long link has been idle */
|
283 |
|
|
int sifvjcomp __P((int, int, int, int));
|
284 |
|
|
/* Configure VJ TCP header compression */
|
285 |
|
|
int sifup __P((int)); /* Configure i/f up (for IP) */
|
286 |
|
|
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
287 |
|
|
/* Set mode for handling packets for proto */
|
288 |
|
|
int sifdown __P((int)); /* Configure i/f down (for IP) */
|
289 |
|
|
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
290 |
|
|
/* Configure IP addresses for i/f */
|
291 |
|
|
int cifaddr __P((int, u_int32_t, u_int32_t));
|
292 |
|
|
/* Reset i/f IP addresses */
|
293 |
|
|
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
294 |
|
|
/* Create default route through i/f */
|
295 |
|
|
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
296 |
|
|
/* Delete default route through i/f */
|
297 |
|
|
int sifproxyarp __P((int, u_int32_t));
|
298 |
|
|
/* Add proxy ARP entry for peer */
|
299 |
|
|
int cifproxyarp __P((int, u_int32_t));
|
300 |
|
|
/* Delete proxy ARP entry for peer */
|
301 |
|
|
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
302 |
|
|
int lock __P((char *)); /* Create lock file for device */
|
303 |
|
|
void unlock __P((void)); /* Delete previously-created lock file */
|
304 |
|
|
int daemon __P((int, int)); /* Detach us from terminal session */
|
305 |
|
|
void logwtmp __P((const char *, const char *, const char *));
|
306 |
|
|
/* Write entry to wtmp file */
|
307 |
|
|
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
308 |
|
|
#ifdef PPP_FILTER
|
309 |
|
|
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
310 |
|
|
/* Set filter programs in kernel */
|
311 |
|
|
#endif
|
312 |
|
|
|
313 |
|
|
/* Procedures exported from options.c */
|
314 |
|
|
int parse_args __P((int argc, char **argv));
|
315 |
|
|
/* Parse options from arguments given */
|
316 |
|
|
void usage __P((void)); /* Print a usage message */
|
317 |
|
|
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
318 |
|
|
int privileged));
|
319 |
|
|
/* Parse options from an options file */
|
320 |
|
|
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
321 |
|
|
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
322 |
|
|
void scan_args __P((int argc, char **argv));
|
323 |
|
|
/* Look for tty name in command-line args */
|
324 |
|
|
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
325 |
|
|
/* Read a word from a file */
|
326 |
|
|
void option_error __P((char *fmt, ...));
|
327 |
|
|
/* Print an error message about an option */
|
328 |
|
|
|
329 |
|
|
/*
|
330 |
|
|
* This structure is used to store information about certain
|
331 |
|
|
* options, such as where the option value came from (/etc/ppp/options,
|
332 |
|
|
* command line, etc.) and whether it came from a privileged source.
|
333 |
|
|
*/
|
334 |
|
|
|
335 |
|
|
struct option_info {
|
336 |
|
|
int priv; /* was value set by sysadmin? */
|
337 |
|
|
char *source; /* where option came from */
|
338 |
|
|
};
|
339 |
|
|
|
340 |
|
|
extern struct option_info auth_req_info;
|
341 |
|
|
extern struct option_info connector_info;
|
342 |
|
|
extern struct option_info disconnector_info;
|
343 |
|
|
extern struct option_info welcomer_info;
|
344 |
|
|
extern struct option_info devnam_info;
|
345 |
|
|
|
346 |
|
|
/*
|
347 |
|
|
* Inline versions of get/put char/short/long.
|
348 |
|
|
* Pointer is advanced; we assume that both arguments
|
349 |
|
|
* are lvalues and will already be in registers.
|
350 |
|
|
* cp MUST be u_char *.
|
351 |
|
|
*/
|
352 |
|
|
#define GETCHAR(c, cp) { \
|
353 |
|
|
(c) = *(cp)++; \
|
354 |
|
|
}
|
355 |
|
|
#define PUTCHAR(c, cp) { \
|
356 |
|
|
*(cp)++ = (u_char) (c); \
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
#define GETSHORT(s, cp) { \
|
361 |
|
|
(s) = *(cp)++ << 8; \
|
362 |
|
|
(s) |= *(cp)++; \
|
363 |
|
|
}
|
364 |
|
|
#define PUTSHORT(s, cp) { \
|
365 |
|
|
*(cp)++ = (u_char) ((s) >> 8); \
|
366 |
|
|
*(cp)++ = (u_char) (s); \
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
#define GETLONG(l, cp) { \
|
370 |
|
|
(l) = *(cp)++ << 8; \
|
371 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
372 |
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
373 |
|
|
(l) |= *(cp)++; \
|
374 |
|
|
}
|
375 |
|
|
#define PUTLONG(l, cp) { \
|
376 |
|
|
*(cp)++ = (u_char) ((l) >> 24); \
|
377 |
|
|
*(cp)++ = (u_char) ((l) >> 16); \
|
378 |
|
|
*(cp)++ = (u_char) ((l) >> 8); \
|
379 |
|
|
*(cp)++ = (u_char) (l); \
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
#define INCPTR(n, cp) ((cp) += (n))
|
383 |
|
|
#define DECPTR(n, cp) ((cp) -= (n))
|
384 |
|
|
|
385 |
|
|
#undef FALSE
|
386 |
|
|
#define FALSE 0
|
387 |
|
|
#undef TRUE
|
388 |
|
|
#define TRUE 1
|
389 |
|
|
|
390 |
|
|
/*
|
391 |
|
|
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
392 |
|
|
*/
|
393 |
|
|
|
394 |
|
|
#define DEMUXPROTREJ(u, p) demuxprotrej(u, p)
|
395 |
|
|
|
396 |
|
|
#define TIMEOUT(r, f, t) my_timeout((r), (f), (t))
|
397 |
|
|
#define UNTIMEOUT(r, f) untimeout((r), (f))
|
398 |
|
|
|
399 |
|
|
#define BCOPY(s, d, l) memcpy(d, s, l)
|
400 |
|
|
#define BZERO(s, n) memset(s, 0, n)
|
401 |
|
|
#define EXIT(u) quit()
|
402 |
|
|
|
403 |
|
|
#define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
|
404 |
|
|
|
405 |
|
|
/*
|
406 |
|
|
* MAKEHEADER - Add Header fields to a packet.
|
407 |
|
|
*/
|
408 |
|
|
#define MAKEHEADER(p, t) { \
|
409 |
|
|
PUTCHAR(PPP_ALLSTATIONS, p); \
|
410 |
|
|
PUTCHAR(PPP_UI, p); \
|
411 |
|
|
PUTSHORT(t, p); }
|
412 |
|
|
|
413 |
|
|
/* #define DEBUGALL */
|
414 |
|
|
|
415 |
|
|
#ifdef DEBUGALL
|
416 |
|
|
#define DEBUGMAIN 1
|
417 |
|
|
#define DEBUGFSM 1
|
418 |
|
|
#define DEBUGLCP 1
|
419 |
|
|
#define DEBUGIPCP 1
|
420 |
|
|
#define DEBUGUPAP 1
|
421 |
|
|
#define DEBUGCHAP 1
|
422 |
|
|
#endif
|
423 |
|
|
|
424 |
|
|
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
|
425 |
|
|
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|
426 |
|
|
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
|
427 |
|
|
|| defined(DEBUGCHAP) || defined(DEBUG)
|
428 |
|
|
#define LOG_PPP LOG_LOCAL2
|
429 |
|
|
#else
|
430 |
|
|
#define LOG_PPP LOG_DAEMON
|
431 |
|
|
#endif
|
432 |
|
|
#endif /* LOG_PPP */
|
433 |
|
|
extern rtems_id pppdaemon_tid;
|
434 |
|
|
#ifdef DEBUGMAIN
|
435 |
|
|
#define MAINDEBUG(x) if (debug) syslog x
|
436 |
|
|
#else
|
437 |
|
|
#define MAINDEBUG(x)
|
438 |
|
|
#endif
|
439 |
|
|
|
440 |
|
|
#ifdef DEBUGSYS
|
441 |
|
|
#define SYSDEBUG(x) if (debug) syslog x
|
442 |
|
|
#else
|
443 |
|
|
#define SYSDEBUG(x)
|
444 |
|
|
#endif
|
445 |
|
|
|
446 |
|
|
#ifdef DEBUGFSM
|
447 |
|
|
#define FSMDEBUG(x) if (debug) syslog x
|
448 |
|
|
#else
|
449 |
|
|
#define FSMDEBUG(x)
|
450 |
|
|
#endif
|
451 |
|
|
|
452 |
|
|
#ifdef DEBUGLCP
|
453 |
|
|
#define LCPDEBUG(x) if (debug) syslog x
|
454 |
|
|
#else
|
455 |
|
|
#define LCPDEBUG(x)
|
456 |
|
|
#endif
|
457 |
|
|
|
458 |
|
|
#ifdef DEBUGIPCP
|
459 |
|
|
#define IPCPDEBUG(x) if (debug) syslog x
|
460 |
|
|
#else
|
461 |
|
|
#define IPCPDEBUG(x)
|
462 |
|
|
#endif
|
463 |
|
|
|
464 |
|
|
#ifdef DEBUGUPAP
|
465 |
|
|
#define UPAPDEBUG(x) if (debug) syslog x
|
466 |
|
|
#else
|
467 |
|
|
#define UPAPDEBUG(x)
|
468 |
|
|
#endif
|
469 |
|
|
|
470 |
|
|
#ifdef DEBUGCHAP
|
471 |
|
|
#define CHAPDEBUG(x) if (debug) syslog x
|
472 |
|
|
#else
|
473 |
|
|
#define CHAPDEBUG(x)
|
474 |
|
|
#endif
|
475 |
|
|
|
476 |
|
|
#ifdef DEBUGIPXCP
|
477 |
|
|
#define IPXCPDEBUG(x) if (debug) syslog x
|
478 |
|
|
#else
|
479 |
|
|
#define IPXCPDEBUG(x)
|
480 |
|
|
#endif
|
481 |
|
|
|
482 |
|
|
#ifndef SIGTYPE
|
483 |
|
|
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
484 |
|
|
#define SIGTYPE void
|
485 |
|
|
#else
|
486 |
|
|
#define SIGTYPE int
|
487 |
|
|
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
488 |
|
|
#endif /* SIGTYPE */
|
489 |
|
|
|
490 |
|
|
#ifndef MIN
|
491 |
|
|
#define MIN(a, b) ((a) < (b)? (a): (b))
|
492 |
|
|
#endif
|
493 |
|
|
#ifndef MAX
|
494 |
|
|
#define MAX(a, b) ((a) > (b)? (a): (b))
|
495 |
|
|
#endif
|
496 |
|
|
|
497 |
|
|
#endif /* __PPP_H__ */
|