2 * pppd.h - PPP daemon global declarations.
4 * Copyright (c) 1989 Carnegie Mellon University.
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.
19 * $Id: pppd.h,v 1.55 2000/06/30 04:54:22 paulus Exp $
29 #include <stdio.h> /* for FILE */
30 #include <limits.h> /* for NGROUPS_MAX */
31 #include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
32 #include <sys/types.h> /* for u_int32_t, if defined */
33 #include <sys/time.h> /* for struct timeval */
34 #include <net/ppp_defs.h>
41 #define __V(x) (va_alist) va_dcl
54 #define NUM_PPP 1 /* One PPP interface supported (per process) */
55 #define MAXWORDLEN 1024 /* max length of word in file (incl null) */
56 #define MAXARGS 1 /* max # args to a command */
57 #define MAXNAMELEN 256 /* max length of hostname or name for auth */
58 #define MAXSECRETLEN 256 /* max length of password or secret */
61 * Option descriptor structure.
64 typedef unsigned char bool;
76 char *name; /* name of the option */
86 /* Values for flags */
87 #define OPT_VALUE 0xff /* mask for presupplied value */
88 #define OPT_HEX 0x100 /* int option is in hex */
89 #define OPT_NOARG 0x200 /* option doesn't take argument */
90 #define OPT_OR 0x400 /* OR in argument to value */
91 #define OPT_INC 0x800 /* increment value */
92 #define OPT_PRIV 0x1000 /* privileged option */
93 #define OPT_STATIC 0x2000 /* string option goes into static array */
94 #define OPT_LLIMIT 0x4000 /* check value against lower limit */
95 #define OPT_ULIMIT 0x8000 /* check value against upper limit */
96 #define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
97 #define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
98 #define OPT_NOINCR 0x20000 /* value mustn't be increased */
99 #define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
100 #define OPT_A2INFO 0x100000 /* addr2 -> option_info to update */
101 #define OPT_A2COPY 0x200000 /* addr2 -> second location to rcv value */
102 #define OPT_ENABLE 0x400000 /* use *addr2 as enable for option */
103 #define OPT_PRIVFIX 0x800000 /* can't be overridden if noauth */
104 #define OPT_PREPASS 0x1000000 /* do this opt in pre-pass to find device */
105 #define OPT_INITONLY 0x2000000 /* option can only be set in init phase */
106 #define OPT_DEVEQUIV 0x4000000 /* equiv to device name */
107 #define OPT_DEVNAM (OPT_PREPASS | OPT_INITONLY | OPT_DEVEQUIV)
108 #define OPT_SEENIT 0x10000000 /* have seen this option already */
110 #define OPT_VAL(x) ((x) & OPT_VALUE)
113 #define GIDSET_TYPE gid_t
116 /* Structure representing a list of permitted IP addresses. */
117 struct permitted_ip {
118 int permit; /* 1 = permit, 0 = forbid */
119 u_int32_t base; /* match if (addr & mask) == base */
120 u_int32_t mask; /* base and mask are in network byte order */
124 * Unfortunately, the linux kernel driver uses a different structure
125 * for statistics from the rest of the ports.
126 * This structure serves as a common representation for the bits
130 unsigned int bytes_in;
131 unsigned int bytes_out;
134 /* Used for storing a sequence of words. Usually malloced. */
136 struct wordlist *next;
140 /* An endpoint discriminator, used with multilink. */
141 #define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
144 unsigned char length;
145 unsigned char value[MAX_ENDP_LEN];
148 /* values for epdisc.class */
149 #define EPD_NULL 0 /* null discriminator, no data */
154 #define EPD_PHONENUM 5
156 typedef void (*notify_func) __P((void *, int));
159 struct notifier *next;
168 extern int hungup; /* Physical layer has disconnected */
169 extern int ifunit; /* Interface unit number */
170 extern char ifname[]; /* Interface name */
171 extern char hostname[]; /* Our hostname */
172 extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
173 extern int phase; /* Current state of link - see values below */
174 extern int baud_rate; /* Current link speed in bits/sec */
175 extern char *progname; /* Name of this program */
176 extern int redirect_stderr;/* Connector's stderr should go to file */
177 extern char peer_authname[];/* Authenticated name of peer */
178 extern int privileged; /* We were run by real-uid root */
179 extern int need_holdoff; /* Need holdoff period after link terminates */
180 extern char **script_env; /* Environment variables for scripts */
181 extern int detached; /* Have detached from controlling tty */
182 extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
183 extern int ngroups; /* How many groups valid in groups */
184 extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
185 extern int link_stats_valid; /* set if link_stats is valid */
186 extern int link_connect_time; /* time the link was up for */
187 extern int using_pty; /* using pty as device (notty or pty opt.) */
188 extern int log_to_fd; /* logging to this fd as well as syslog */
189 extern bool log_to_file; /* log_to_fd is a file */
190 extern bool log_to_specific_fd; /* log_to_fd was specified by user */
191 extern char *no_ppp_msg; /* message to print if ppp not in kernel */
192 extern volatile int status; /* exit status for pppd */
193 extern int devnam_fixed; /* can no longer change devnam */
194 extern int unsuccess; /* # unsuccessful connection attempts */
195 extern int do_callback; /* set if we want to do callback next */
196 extern int doing_callback; /* set if this is a callback */
197 extern char ppp_devnam[MAXPATHLEN];
198 extern struct notifier *pidchange; /* for notifications of pid changing */
199 extern struct notifier *phasechange; /* for notifications of phase changes */
200 extern struct notifier *exitnotify; /* for notification that we're exiting */
201 extern struct notifier *sigreceived; /* notification of received signal */
203 /* Values for do_callback and doing_callback */
204 #define CALLBACK_DIALIN 1 /* we are expecting the call back */
205 #define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
208 * Variables set by command-line options.
211 extern int debug; /* Debug flag */
212 extern int kdebugflag; /* Tell kernel to print debug messages */
213 extern int default_device; /* Using /dev/tty or equivalent */
214 extern char devnam[MAXPATHLEN]; /* Device name */
215 extern int crtscts; /* Use hardware flow control */
216 extern bool modem; /* Use modem control lines */
217 extern int inspeed; /* Input/Output speed requested */
218 extern u_int32_t netmask; /* IP netmask to set on interface */
219 extern bool lockflag; /* Create lock file to lock the serial dev */
220 extern bool nodetach; /* Don't detach from controlling tty */
221 extern bool updetach; /* Detach from controlling tty when link up */
222 extern char *initializer; /* Script to initialize physical link */
223 extern char *connect_script; /* Script to establish physical link */
224 extern char *disconnect_script; /* Script to disestablish physical link */
225 extern char *welcomer; /* Script to welcome client after connection */
226 extern char *ptycommand; /* Command to run on other side of pty */
227 extern int maxconnect; /* Maximum connect time (seconds) */
228 extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
229 extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
230 extern bool auth_required; /* Peer is required to authenticate */
231 extern bool persist; /* Reopen link after it goes down */
232 extern bool uselogin; /* Use /etc/passwd for checking PAP */
233 extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
234 extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
235 extern bool explicit_remote;/* remote_name specified with remotename opt */
236 extern bool demand; /* Do dial-on-demand */
237 extern char *ipparam; /* Extra parameter for ip up/down scripts */
238 extern bool cryptpap; /* Others' PAP passwords are encrypted */
239 extern int idle_time_limit;/* Shut down link if idle for this long */
240 extern int holdoff; /* Dead time before restarting */
241 extern bool holdoff_specified; /* true if user gave a holdoff value */
242 extern bool notty; /* Stdin/out is not a tty */
243 extern char *pty_socket; /* Socket to connect to pty */
244 extern char *record_file; /* File to record chars sent/received */
245 extern bool sync_serial; /* Device is synchronous serial device */
246 extern int maxfail; /* Max # of unsuccessful connection attempts */
247 extern char linkname[MAXPATHLEN]; /* logical name for link */
248 extern bool tune_kernel; /* May alter kernel settings as necessary */
249 extern int connect_delay; /* Time to delay after connect script */
250 extern int max_data_rate; /* max bytes/sec through charshunt */
251 extern int req_unit; /* interface unit number to use */
252 extern bool multilink; /* enable multilink operation */
253 extern bool noendpoint; /* don't send or accept endpt. discrim. */
254 extern char *bundle_name; /* bundle name for multilink */
257 extern struct bpf_program pass_filter; /* Filter for pkts to pass */
258 extern struct bpf_program active_filter; /* Filter for link-active pkts */
262 extern bool ms_lanman; /* Use LanMan password instead of NT */
263 /* Has meaning only with MS-CHAP challenges */
266 extern char *current_option; /* the name of the option being parsed */
267 extern int privileged_option; /* set iff the current option came from root */
268 extern char *option_source; /* string saying where the option came from */
274 #define PHASE_INITIALIZE 1
275 #define PHASE_SERIALCONN 2
276 #define PHASE_DORMANT 3
277 #define PHASE_ESTABLISH 4
278 #define PHASE_AUTHENTICATE 5
279 #define PHASE_CALLBACK 6
280 #define PHASE_NETWORK 7
281 #define PHASE_RUNNING 8
282 #define PHASE_TERMINATE 9
283 #define PHASE_DISCONNECT 10
284 #define PHASE_HOLDOFF 11
287 * The following struct gives the addresses of procedures to call
288 * for a particular protocol.
291 u_short protocol; /* PPP protocol number */
292 /* Initialization procedure */
293 void (*init) __P((int unit));
294 /* Process a received packet */
295 void (*input) __P((int unit, u_char *pkt, int len));
296 /* Process a received protocol-reject */
297 void (*protrej) __P((int unit));
298 /* Lower layer has come up */
299 void (*lowerup) __P((int unit));
300 /* Lower layer has gone down */
301 void (*lowerdown) __P((int unit));
302 /* Open the protocol */
303 void (*open) __P((int unit));
304 /* Close the protocol */
305 void (*close) __P((int unit, char *reason));
306 /* Print a packet in readable form */
307 int (*printpkt) __P((u_char *pkt, int len,
308 void (*printer) __P((void *, char *, ...)),
310 /* Process a received data packet */
311 void (*datainput) __P((int unit, u_char *pkt, int len));
312 bool enabled_flag; /* 0 iff protocol is disabled */
313 char *name; /* Text name of protocol */
314 char *data_name; /* Text name of corresponding data protocol */
315 option_t *options; /* List of command-line options */
316 /* Check requested options, assign defaults */
317 void (*check_options) __P((void));
318 /* Configure interface for demand-dial */
319 int (*demand_conf) __P((int unit));
320 /* Say whether to bring up link for this pkt */
321 int (*active_pkt) __P((u_char *pkt, int len));
324 /* Table of pointers to supported protocols */
325 extern struct protent *protocols[];
331 /* Procedures exported from main.c. */
332 void set_ifunit __P((int)); /* set stuff that depends on ifunit */
333 void detach __P((void)); /* Detach from controlling tty */
334 void die __P((int)); /* Cleanup and exit */
335 void quit __P((void)); /* like die(1) */
336 void novm __P((char *)); /* Say we ran out of memory, and die */
337 void timeout __P((void (*func)(void *), void *arg, int t));
338 /* Call func(arg) after t seconds */
339 void untimeout __P((void (*func)(void *), void *arg));
340 /* Cancel call to func(arg) */
341 void record_child __P((int, char *, void (*) (void *), void *));
342 int device_script __P((char *cmd, int in, int out, int dont_wait));
343 /* Run `cmd' with given stdin and stdout */
344 pid_t run_program __P((char *prog, char **args, int must_exist,
345 void (*done)(void *), void *arg));
346 /* Run program prog with args in child */
347 void reopen_log __P((void)); /* (re)open the connection to syslog */
348 void update_link_stats __P((int)); /* Get stats at link termination */
349 void script_setenv __P((char *, char *, int)); /* set script env var */
350 void script_unsetenv __P((char *)); /* unset script env var */
351 void new_phase __P((int)); /* signal start of new phase */
352 void add_notifier __P((struct notifier **, notify_func, void *));
353 void remove_notifier __P((struct notifier **, notify_func, void *));
354 void notify __P((struct notifier *, int));
356 /* Procedures exported from tty.c. */
357 void tty_init __P((void));
358 int connect_tty __P((void));
359 void disconnect_tty __P((void));
360 void tty_close_fds __P((void));
361 void cleanup_tty __P((void));
363 /* Procedures exported from utils.c. */
364 void log_packet __P((u_char *, int, char *, int));
365 /* Format a packet and log it with syslog */
366 void print_string __P((char *, int, void (*) (void *, char *, ...),
367 void *)); /* Format a string for output */
368 int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
369 int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
370 size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
371 size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
372 void dbglog __P((char *, ...)); /* log a debug message */
373 void info __P((char *, ...)); /* log an informational message */
374 void notice __P((char *, ...)); /* log a notice-level message */
375 void warn __P((char *, ...)); /* log a warning message */
376 void error __P((char *, ...)); /* log an error message */
377 void fatal __P((char *, ...)); /* log an error message and die(1) */
379 /* Procedures exported from auth.c */
380 void link_required __P((int)); /* we are starting to use the link */
381 void link_terminated __P((int)); /* we are finished with the link */
382 void link_down __P((int)); /* the LCP layer has left the Opened state */
383 void link_established __P((int)); /* the link is up; authenticate now */
384 void start_networks __P((void)); /* start all the network control protos */
385 void np_up __P((int, int)); /* a network protocol has come up */
386 void np_down __P((int, int)); /* a network protocol has gone down */
387 void np_finished __P((int, int)); /* a network protocol no longer needs link */
388 void auth_peer_fail __P((int, int));
389 /* peer failed to authenticate itself */
390 void auth_peer_success __P((int, int, char *, int));
391 /* peer successfully authenticated itself */
392 void auth_withpeer_fail __P((int, int));
393 /* we failed to authenticate ourselves */
394 void auth_withpeer_success __P((int, int));
395 /* we successfully authenticated ourselves */
396 void auth_check_options __P((void));
397 /* check authentication options supplied */
398 void auth_reset __P((int)); /* check what secrets we have */
399 int check_passwd __P((int, char *, int, char *, int, char **));
400 /* Check peer-supplied username/password */
401 int get_secret __P((int, char *, char *, char *, int *, int));
402 /* get "secret" for chap */
403 int auth_ip_addr __P((int, u_int32_t));
404 /* check if IP address is authorized */
405 int bad_ip_adrs __P((u_int32_t));
406 /* check if IP address is unreasonable */
408 /* Procedures exported from demand.c */
409 void demand_conf __P((void)); /* config interface(s) for demand-dial */
410 void demand_block __P((void)); /* set all NPs to queue up packets */
411 void demand_unblock __P((void)); /* set all NPs to pass packets */
412 void demand_discard __P((void)); /* set all NPs to discard packets */
413 void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
414 int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
415 int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
417 /* Procedures exported from multilink.c */
418 void mp_check_options __P((void)); /* Check multilink-related options */
419 int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
420 char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
421 int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
423 /* Procedures exported from sys-*.c */
424 void sys_init __P((void)); /* Do system-dependent initialization */
425 void sys_cleanup __P((void)); /* Restore system state before exiting */
426 int sys_check_options __P((void)); /* Check options specified */
427 void sys_close __P((void)); /* Clean up in a child before execing */
428 int ppp_available __P((void)); /* Test whether ppp kernel support exists */
429 int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
430 int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
431 int establish_ppp __P((int)); /* Turn serial port into a ppp interface */
432 void restore_loop __P((void)); /* Transfer ppp unit back to loopback */
433 void disestablish_ppp __P((int)); /* Restore port to normal operation */
434 void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
435 int bundle_attach __P((int)); /* Attach link to existing bundle */
436 void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
437 void clean_check __P((void)); /* Check if line was 8-bit clean */
438 void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
439 void restore_tty __P((int)); /* Restore port's original parameters */
440 void setdtr __P((int, int)); /* Raise or lower port's DTR line */
441 void output __P((int, u_char *, int)); /* Output a PPP packet */
442 void wait_input __P((struct timeval *));
443 /* Wait for input, with timeout */
444 void add_fd __P((int)); /* Add fd to set to wait for */
445 void remove_fd __P((int)); /* Remove fd from set to wait for */
446 int read_packet __P((u_char *)); /* Read PPP packet */
447 int get_loop_output __P((void)); /* Read pkts from loopback */
448 void ppp_send_config __P((int, int, u_int32_t, int, int));
449 /* Configure i/f transmit parameters */
450 void ppp_set_xaccm __P((int, ext_accm));
451 /* Set extended transmit ACCM */
452 void ppp_recv_config __P((int, int, u_int32_t, int, int));
453 /* Configure i/f receive parameters */
454 int ccp_test __P((int, u_char *, int, int));
455 /* Test support for compression scheme */
456 void ccp_flags_set __P((int, int, int));
457 /* Set kernel CCP state */
458 int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
459 int get_idle_time __P((int, struct ppp_idle *));
460 /* Find out how long link has been idle */
461 int get_ppp_stats __P((int, struct pppd_stats *));
462 /* Return link statistics */
463 int sifvjcomp __P((int, int, int, int));
464 /* Configure VJ TCP header compression */
465 int sifup __P((int)); /* Configure i/f up for one protocol */
466 int sifnpmode __P((int u, int proto, enum NPmode mode));
467 /* Set mode for handling packets for proto */
468 int sifdown __P((int)); /* Configure i/f down for one protocol */
469 int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
470 /* Configure IPv4 addresses for i/f */
471 int cifaddr __P((int, u_int32_t, u_int32_t));
472 /* Reset i/f IP addresses */
474 int sif6addr __P((int, eui64_t, eui64_t));
475 /* Configure IPv6 addresses for i/f */
476 int cif6addr __P((int, eui64_t, eui64_t));
477 /* Remove an IPv6 address from i/f */
479 int sifdefaultroute __P((int, u_int32_t, u_int32_t));
480 /* Create default route through i/f */
481 int cifdefaultroute __P((int, u_int32_t, u_int32_t));
482 /* Delete default route through i/f */
483 int sifproxyarp __P((int, u_int32_t));
484 /* Add proxy ARP entry for peer */
485 int cifproxyarp __P((int, u_int32_t));
486 /* Delete proxy ARP entry for peer */
487 u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
488 int lock __P((char *)); /* Create lock file for device */
489 int relock __P((int)); /* Rewrite lock file with new pid */
490 void unlock __P((void)); /* Delete previously-created lock file */
491 void logwtmp __P((const char *, const char *, const char *));
492 /* Write entry to wtmp file */
493 int get_host_seed __P((void)); /* Get host-dependent random number seed */
494 int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
496 int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
497 /* Set filter programs in kernel */
500 int sipxfaddr __P((int, unsigned long, unsigned char *));
501 int cipxfaddr __P((int));
503 int get_if_hwaddr __P((u_char *addr, char *name));
504 char *get_first_ethernet __P((void));
506 /* Procedures exported from options.c */
507 int parse_args __P((int argc, char **argv));
508 /* Parse options from arguments given */
509 int options_from_file __P((char *filename, int must_exist, int check_prot,
511 /* Parse options from an options file */
512 int options_from_user __P((void)); /* Parse options from user's .ppprc */
513 int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
514 int options_from_list __P((struct wordlist *, int privileged));
515 /* Parse options from a wordlist */
516 int getword __P((FILE *f, char *word, int *newlinep, char *filename));
517 /* Read a word from a file */
518 void option_error __P((char *fmt, ...));
519 /* Print an error message about an option */
520 int int_option __P((char *, int *));
521 /* Simplified number_option for decimal ints */
522 void add_options __P((option_t *)); /* Add extra options */
523 int parse_dotted_ip __P((char *, u_int32_t *));
526 * This structure is used to store information about certain
527 * options, such as where the option value came from (/etc/ppp/options,
528 * command line, etc.) and whether it came from a privileged source.
532 int priv; /* was value set by sysadmin? */
533 char *source; /* where option came from */
536 extern struct option_info devnam_info;
537 extern struct option_info initializer_info;
538 extern struct option_info connect_script_info;
539 extern struct option_info disconnect_script_info;
540 extern struct option_info welcomer_info;
541 extern struct option_info ptycommand_info;
544 * Hooks to enable plugins to change various things.
546 extern int (*new_phase_hook) __P((int));
547 extern int (*idle_time_hook) __P((struct ppp_idle *));
548 extern int (*holdoff_hook) __P((void));
549 extern int (*pap_check_hook) __P((void));
550 extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
551 struct wordlist **paddrs,
552 struct wordlist **popts));
553 extern void (*pap_logout_hook) __P((void));
554 extern int (*pap_passwd_hook) __P((char *user, char *passwd));
555 extern void (*ip_up_hook) __P((void));
556 extern void (*ip_down_hook) __P((void));
557 extern void (*ip_choose_hook) __P((u_int32_t *));
560 * Inline versions of get/put char/short/long.
561 * Pointer is advanced; we assume that both arguments
562 * are lvalues and will already be in registers.
563 * cp MUST be u_char *.
565 #define GETCHAR(c, cp) { \
568 #define PUTCHAR(c, cp) { \
569 *(cp)++ = (u_char) (c); \
573 #define GETSHORT(s, cp) { \
574 (s) = *(cp)++ << 8; \
577 #define PUTSHORT(s, cp) { \
578 *(cp)++ = (u_char) ((s) >> 8); \
579 *(cp)++ = (u_char) (s); \
582 #define GETLONG(l, cp) { \
583 (l) = *(cp)++ << 8; \
584 (l) |= *(cp)++; (l) <<= 8; \
585 (l) |= *(cp)++; (l) <<= 8; \
588 #define PUTLONG(l, cp) { \
589 *(cp)++ = (u_char) ((l) >> 24); \
590 *(cp)++ = (u_char) ((l) >> 16); \
591 *(cp)++ = (u_char) ((l) >> 8); \
592 *(cp)++ = (u_char) (l); \
595 #define INCPTR(n, cp) ((cp) += (n))
596 #define DECPTR(n, cp) ((cp) -= (n))
599 * System dependent definitions for user-level 4.3BSD UNIX implementation.
602 #define TIMEOUT(r, f, t) timeout((r), (f), (t))
603 #define UNTIMEOUT(r, f) untimeout((r), (f))
605 #define BCOPY(s, d, l) memcpy(d, s, l)
606 #define BZERO(s, n) memset(s, 0, n)
608 #define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
611 * MAKEHEADER - Add Header fields to a packet.
613 #define MAKEHEADER(p, t) { \
614 PUTCHAR(PPP_ALLSTATIONS, p); \
615 PUTCHAR(PPP_UI, p); \
619 * Exit status values.
622 #define EXIT_FATAL_ERROR 1
623 #define EXIT_OPTION_ERROR 2
624 #define EXIT_NOT_ROOT 3
625 #define EXIT_NO_KERNEL_SUPPORT 4
626 #define EXIT_USER_REQUEST 5
627 #define EXIT_LOCK_FAILED 6
628 #define EXIT_OPEN_FAILED 7
629 #define EXIT_CONNECT_FAILED 8
630 #define EXIT_PTYCMD_FAILED 9
631 #define EXIT_NEGOTIATION_FAILED 10
632 #define EXIT_PEER_AUTH_FAILED 11
633 #define EXIT_IDLE_TIMEOUT 12
634 #define EXIT_CONNECT_TIME 13
635 #define EXIT_CALLBACK 14
636 #define EXIT_PEER_DEAD 15
637 #define EXIT_HANGUP 16
638 #define EXIT_LOOPBACK 17
639 #define EXIT_INIT_FAILED 18
640 #define EXIT_AUTH_TOPEER_FAILED 19
643 * Debug macros. Slightly useful for finding bugs in pppd, not particularly
644 * useful for finding out why your connection isn't being established.
651 #define DEBUGIPV6CP 1
656 #ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
657 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
658 || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
659 || defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
660 #define LOG_PPP LOG_LOCAL2
662 #define LOG_PPP LOG_DAEMON
667 #define MAINDEBUG(x) if (debug) dbglog x
673 #define SYSDEBUG(x) if (debug) dbglog x
679 #define FSMDEBUG(x) if (debug) dbglog x
685 #define LCPDEBUG(x) if (debug) dbglog x
691 #define IPCPDEBUG(x) if (debug) dbglog x
697 #define IPV6CPDEBUG(x) if (debug) dbglog x
699 #define IPV6CPDEBUG(x)
703 #define UPAPDEBUG(x) if (debug) dbglog x
709 #define CHAPDEBUG(x) if (debug) dbglog x
715 #define IPXCPDEBUG(x) if (debug) dbglog x
717 #define IPXCPDEBUG(x)
721 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
725 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
729 #define MIN(a, b) ((a) < (b)? (a): (b))
732 #define MAX(a, b) ((a) > (b)? (a): (b))
735 #endif /* __PPP_H__ */