]> git.ozlabs.org Git - ppp.git/blob - pppd/pppd.h
exit with an appropriate value to indicate what happened
[ppp.git] / pppd / pppd.h
1 /*
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.39 1999/05/12 06:19:49 paulus 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 <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>
35
36 #if __STDC__
37 #include <stdarg.h>
38 #define __V(x)  x
39 #else
40 #include <varargs.h>
41 #define __V(x)  (va_alist) va_dcl
42 #define const
43 #define volatile
44 #endif
45
46 /*
47  * Limits.
48  */
49
50 #define NUM_PPP         1       /* One PPP interface supported (per process) */
51 #define MAXWORDLEN      1024    /* max length of word in file (incl null) */
52 #define MAXARGS         1       /* max # args to a command */
53 #define MAXNAMELEN      256     /* max length of hostname or name for auth */
54 #define MAXSECRETLEN    256     /* max length of password or secret */
55
56 /*
57  * Option descriptor structure.
58  */
59
60 typedef unsigned char   bool;
61
62 enum opt_type {
63         o_special_noarg = 0,
64         o_special = 1,
65         o_bool,
66         o_int,
67         o_uint32,
68         o_string,
69 };
70
71 typedef struct {
72         char    *name;          /* name of the option */
73         enum opt_type type;
74         void    *addr;
75         char    *description;
76         int     flags;
77         void    *addr2;
78         int     upper_limit;
79         int     lower_limit;
80 } option_t;
81
82 /* Values for flags */
83 #define OPT_VALUE       0xff    /* mask for presupplied value */
84 #define OPT_HEX         0x100   /* int option is in hex */
85 #define OPT_NOARG       0x200   /* option doesn't take argument */
86 #define OPT_OR          0x400   /* OR in argument to value */
87 #define OPT_INC         0x800   /* increment value */
88 #define OPT_PRIV        0x1000  /* privileged option */
89 #define OPT_STATIC      0x2000  /* string option goes into static array */
90 #define OPT_LLIMIT      0x4000  /* check value against lower limit */
91 #define OPT_ULIMIT      0x8000  /* check value against upper limit */
92 #define OPT_LIMITS      (OPT_LLIMIT|OPT_ULIMIT)
93 #define OPT_ZEROOK      0x10000 /* 0 value is OK even if not within limits */
94 #define OPT_NOINCR      0x20000 /* value mustn't be increased */
95 #define OPT_ZEROINF     0x40000 /* with OPT_NOINCR, 0 == infinity */
96 #define OPT_A2INFO      0x100000 /* addr2 -> option_info to update */
97 #define OPT_A2COPY      0x200000 /* addr2 -> second location to rcv value */
98 #define OPT_ENABLE      0x400000 /* use *addr2 as enable for option */
99 #define OPT_PRIVFIX     0x800000 /* can't be overridden if noauth */
100 #define OPT_PREPASS     0x1000000/* do this opt in pre-pass to find device */
101
102 #define OPT_VAL(x)      ((x) & OPT_VALUE)
103
104 #ifndef GIDSET_TYPE
105 #define GIDSET_TYPE     gid_t
106 #endif
107
108 /* Structure representing a list of permitted IP addresses. */
109 struct permitted_ip {
110     int         permit;         /* 1 = permit, 0 = forbid */
111     u_int32_t   base;           /* match if (addr & mask) == base */
112     u_int32_t   mask;           /* base and mask are in network byte order */
113 };
114
115 /*
116  * Unfortunately, the linux kernel driver uses a different structure
117  * for statistics from the rest of the ports.
118  * This structure serves as a common representation for the bits
119  * pppd needs.
120  */
121 struct pppd_stats {
122     unsigned int        bytes_in;
123     unsigned int        bytes_out;
124 };
125
126 /*
127  * Global variables.
128  */
129
130 extern int      hungup;         /* Physical layer has disconnected */
131 extern int      ifunit;         /* Interface unit number */
132 extern char     ifname[];       /* Interface name */
133 extern int      ttyfd;          /* Serial device file descriptor */
134 extern char     hostname[];     /* Our hostname */
135 extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
136 extern int      phase;          /* Current state of link - see values below */
137 extern int      baud_rate;      /* Current link speed in bits/sec */
138 extern char     *progname;      /* Name of this program */
139 extern int      redirect_stderr;/* Connector's stderr should go to file */
140 extern char     peer_authname[];/* Authenticated name of peer */
141 extern int      privileged;     /* We were run by real-uid root */
142 extern int      need_holdoff;   /* Need holdoff period after link terminates */
143 extern char     **script_env;   /* Environment variables for scripts */
144 extern int      detached;       /* Have detached from controlling tty */
145 extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
146 extern int      ngroups;        /* How many groups valid in groups */
147 extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
148 extern int      link_stats_valid; /* set if link_stats is valid */
149 extern int      using_pty;      /* using pty as device (notty or pty opt.) */
150 extern int      log_to_fd;      /* logging to this fd as well as syslog */
151 extern char     *no_ppp_msg;    /* message to print if ppp not in kernel */
152 extern volatile int status;     /* exit status for pppd */
153
154 /*
155  * Variables set by command-line options.
156  */
157
158 extern int      debug;          /* Debug flag */
159 extern int      kdebugflag;     /* Tell kernel to print debug messages */
160 extern int      default_device; /* Using /dev/tty or equivalent */
161 extern char     devnam[MAXPATHLEN];     /* Device name */
162 extern int      crtscts;        /* Use hardware flow control */
163 extern bool     modem;          /* Use modem control lines */
164 extern int      inspeed;        /* Input/Output speed requested */
165 extern u_int32_t netmask;       /* IP netmask to set on interface */
166 extern bool     lockflag;       /* Create lock file to lock the serial dev */
167 extern bool     nodetach;       /* Don't detach from controlling tty */
168 extern bool     updetach;       /* Detach from controlling tty when link up */
169 extern char     *connector;     /* Script to establish physical link */
170 extern char     *disconnector;  /* Script to disestablish physical link */
171 extern char     *welcomer;      /* Script to welcome client after connection */
172 extern char     *ptycommand;    /* Command to run on other side of pty */
173 extern int      maxconnect;     /* Maximum connect time (seconds) */
174 extern char     user[MAXNAMELEN];/* Our name for authenticating ourselves */
175 extern char     passwd[MAXSECRETLEN];   /* Password for PAP */
176 extern bool     auth_required;  /* Peer is required to authenticate */
177 extern bool     persist;        /* Reopen link after it goes down */
178 extern bool     uselogin;       /* Use /etc/passwd for checking PAP */
179 extern char     our_name[MAXNAMELEN];/* Our name for authentication purposes */
180 extern char     remote_name[MAXNAMELEN]; /* Peer's name for authentication */
181 extern bool     explicit_remote;/* remote_name specified with remotename opt */
182 extern bool     demand;         /* Do dial-on-demand */
183 extern char     *ipparam;       /* Extra parameter for ip up/down scripts */
184 extern bool     cryptpap;       /* Others' PAP passwords are encrypted */
185 extern int      idle_time_limit;/* Shut down link if idle for this long */
186 extern int      holdoff;        /* Dead time before restarting */
187 extern bool     notty;          /* Stdin/out is not a tty */
188 extern char     *record_file;   /* File to record chars sent/received */
189 extern bool     sync_serial;    /* Device is synchronous serial device */
190
191 #ifdef PPP_FILTER
192 extern struct   bpf_program pass_filter;   /* Filter for pkts to pass */
193 extern struct   bpf_program active_filter; /* Filter for link-active pkts */
194 #endif
195
196 char *current_option;           /* the name of the option being parsed */
197 int  privileged_option;         /* set iff the current option came from root */
198 char *option_source;            /* string saying where the option came from */
199
200 #ifdef MSLANMAN
201 extern bool     ms_lanman;      /* Use LanMan password instead of NT */
202                                 /* Has meaning only with MS-CHAP challenges */
203 #endif
204
205 /*
206  * Values for phase.
207  */
208 #define PHASE_DEAD              0
209 #define PHASE_INITIALIZE        1
210 #define PHASE_DORMANT           2
211 #define PHASE_ESTABLISH         3
212 #define PHASE_AUTHENTICATE      4
213 #define PHASE_CALLBACK          5
214 #define PHASE_NETWORK           6
215 #define PHASE_TERMINATE         7
216 #define PHASE_HOLDOFF           8
217
218 /*
219  * The following struct gives the addresses of procedures to call
220  * for a particular protocol.
221  */
222 struct protent {
223     u_short protocol;           /* PPP protocol number */
224     /* Initialization procedure */
225     void (*init) __P((int unit));
226     /* Process a received packet */
227     void (*input) __P((int unit, u_char *pkt, int len));
228     /* Process a received protocol-reject */
229     void (*protrej) __P((int unit));
230     /* Lower layer has come up */
231     void (*lowerup) __P((int unit));
232     /* Lower layer has gone down */
233     void (*lowerdown) __P((int unit));
234     /* Open the protocol */
235     void (*open) __P((int unit));
236     /* Close the protocol */
237     void (*close) __P((int unit, char *reason));
238     /* Print a packet in readable form */
239     int  (*printpkt) __P((u_char *pkt, int len,
240                           void (*printer) __P((void *, char *, ...)),
241                           void *arg));
242     /* Process a received data packet */
243     void (*datainput) __P((int unit, u_char *pkt, int len));
244     bool enabled_flag;          /* 0 iff protocol is disabled */
245     char *name;                 /* Text name of protocol */
246     char *data_name;            /* Text name of corresponding data protocol */
247     option_t *options;          /* List of command-line options */
248     /* Check requested options, assign defaults */
249     void (*check_options) __P((void));
250     /* Configure interface for demand-dial */
251     int  (*demand_conf) __P((int unit));
252     /* Say whether to bring up link for this pkt */
253     int  (*active_pkt) __P((u_char *pkt, int len));
254 };
255
256 /* Table of pointers to supported protocols */
257 extern struct protent *protocols[];
258
259 /*
260  * Prototypes.
261  */
262
263 /* Procedures exported from main.c. */
264 void detach __P((void));        /* Detach from controlling tty */
265 void die __P((int));            /* Cleanup and exit */
266 void quit __P((void));          /* like die(1) */
267 void novm __P((char *));        /* Say we ran out of memory, and die */
268 void timeout __P((void (*func)(void *), void *arg, int t));
269                                 /* Call func(arg) after t seconds */
270 void untimeout __P((void (*func)(void *), void *arg));
271                                 /* Cancel call to func(arg) */
272 pid_t run_program __P((char *prog, char **args, int must_exist,
273                        void (*done)(void *), void *arg));
274                                 /* Run program prog with args in child */
275 void demuxprotrej __P((int, int));
276                                 /* Demultiplex a Protocol-Reject */
277 void log_packet __P((u_char *, int, char *, int));
278                                 /* Format a packet and log it with syslog */
279 void print_string __P((char *, int,  void (*) (void *, char *, ...),
280                 void *));       /* Format a string for output */
281 int slprintf __P((char *, int, char *, ...));           /* sprintf++ */
282 int vslprintf __P((char *, int, char *, va_list));      /* vsprintf++ */
283 void script_setenv __P((char *, char *));       /* set script env var */
284 void script_unsetenv __P((char *));             /* unset script env var */
285 size_t strlcpy __P((char *, const char *, size_t));     /* safe strcpy */
286 size_t strlcat __P((char *, const char *, size_t));     /* safe strncpy */
287 void dbglog __P((char *, ...)); /* log a debug message */
288 void info __P((char *, ...));   /* log an informational message */
289 void notice __P((char *, ...)); /* log a notice-level message */
290 void warn __P((char *, ...));   /* log a warning message */
291 void error __P((char *, ...));  /* log an error message */
292 void fatal __P((char *, ...));  /* log an error message and die(1) */
293 void reopen_log __P((void));    /* (re)open the connection to syslog */
294
295 /* Procedures exported from auth.c */
296 void link_required __P((int));    /* we are starting to use the link */
297 void link_terminated __P((int));  /* we are finished with the link */
298 void link_down __P((int));        /* the LCP layer has left the Opened state */
299 void link_established __P((int)); /* the link is up; authenticate now */
300 void np_up __P((int, int));       /* a network protocol has come up */
301 void np_down __P((int, int));     /* a network protocol has gone down */
302 void np_finished __P((int, int)); /* a network protocol no longer needs link */
303 void auth_peer_fail __P((int, int));
304                                 /* peer failed to authenticate itself */
305 void auth_peer_success __P((int, int, char *, int));
306                                 /* peer successfully authenticated itself */
307 void auth_withpeer_fail __P((int, int));
308                                 /* we failed to authenticate ourselves */
309 void auth_withpeer_success __P((int, int));
310                                 /* we successfully authenticated ourselves */
311 void auth_check_options __P((void));
312                                 /* check authentication options supplied */
313 void auth_reset __P((int));     /* check what secrets we have */
314 int  check_passwd __P((int, char *, int, char *, int, char **, int *));
315                                 /* Check peer-supplied username/password */
316 int  get_secret __P((int, char *, char *, char *, int *, int));
317                                 /* get "secret" for chap */
318 int  auth_ip_addr __P((int, u_int32_t));
319                                 /* check if IP address is authorized */
320 int  bad_ip_adrs __P((u_int32_t));
321                                 /* check if IP address is unreasonable */
322
323 /* Procedures exported from demand.c */
324 void demand_conf __P((void));   /* config interface(s) for demand-dial */
325 void demand_block __P((void));  /* set all NPs to queue up packets */
326 void demand_unblock __P((void)); /* set all NPs to pass packets */
327 void demand_discard __P((void)); /* set all NPs to discard packets */
328 void demand_rexmit __P((int));  /* retransmit saved frames for an NP */
329 int  loop_chars __P((unsigned char *, int)); /* process chars from loopback */
330 int  loop_frame __P((unsigned char *, int)); /* should we bring link up? */
331
332 /* Procedures exported from sys-*.c */
333 void sys_init __P((void));      /* Do system-dependent initialization */
334 void sys_cleanup __P((void));   /* Restore system state before exiting */
335 int  sys_check_options __P((void)); /* Check options specified */
336 void sys_close __P((void));     /* Clean up in a child before execing */
337 int  ppp_available __P((void)); /* Test whether ppp kernel support exists */
338 int  get_pty __P((int *, int *, char *, int));  /* Get pty master/slave */
339 int  open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
340 int  establish_ppp __P((int));  /* Turn serial port into a ppp interface */
341 void restore_loop __P((void));  /* Transfer ppp unit back to loopback */
342 void disestablish_ppp __P((int)); /* Restore port to normal operation */
343 void clean_check __P((void));   /* Check if line was 8-bit clean */
344 void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
345 void restore_tty __P((int));    /* Restore port's original parameters */
346 void setdtr __P((int, int));    /* Raise or lower port's DTR line */
347 void output __P((int, u_char *, int)); /* Output a PPP packet */
348 void wait_input __P((struct timeval *));
349                                 /* Wait for input, with timeout */
350 void add_fd __P((int));         /* Add fd to set to wait for */
351 void remove_fd __P((int));      /* Remove fd from set to wait for */
352 int  read_packet __P((u_char *)); /* Read PPP packet */
353 int  get_loop_output __P((void)); /* Read pkts from loopback */
354 void ppp_send_config __P((int, int, u_int32_t, int, int));
355                                 /* Configure i/f transmit parameters */
356 void ppp_set_xaccm __P((int, ext_accm));
357                                 /* Set extended transmit ACCM */
358 void ppp_recv_config __P((int, int, u_int32_t, int, int));
359                                 /* Configure i/f receive parameters */
360 int  ccp_test __P((int, u_char *, int, int));
361                                 /* Test support for compression scheme */
362 void ccp_flags_set __P((int, int, int));
363                                 /* Set kernel CCP state */
364 int  ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
365 int  get_idle_time __P((int, struct ppp_idle *));
366                                 /* Find out how long link has been idle */
367 int  get_ppp_stats __P((int, struct pppd_stats *));
368                                 /* Return link statistics */
369 int  sifvjcomp __P((int, int, int, int));
370                                 /* Configure VJ TCP header compression */
371 int  sifup __P((int));          /* Configure i/f up (for IP) */
372 int  sifnpmode __P((int u, int proto, enum NPmode mode));
373                                 /* Set mode for handling packets for proto */
374 int  sifdown __P((int));        /* Configure i/f down (for IP) */
375 int  sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
376                                 /* Configure IP addresses for i/f */
377 int  cifaddr __P((int, u_int32_t, u_int32_t));
378                                 /* Reset i/f IP addresses */
379 int  sifdefaultroute __P((int, u_int32_t, u_int32_t));
380                                 /* Create default route through i/f */
381 int  cifdefaultroute __P((int, u_int32_t, u_int32_t));
382                                 /* Delete default route through i/f */
383 int  sifproxyarp __P((int, u_int32_t));
384                                 /* Add proxy ARP entry for peer */
385 int  cifproxyarp __P((int, u_int32_t));
386                                 /* Delete proxy ARP entry for peer */
387 u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
388 int  lock __P((char *));        /* Create lock file for device */
389 int  relock __P((int));         /* Rewrite lock file with new pid */
390 void unlock __P((void));        /* Delete previously-created lock file */
391 void logwtmp __P((const char *, const char *, const char *));
392                                 /* Write entry to wtmp file */
393 int  get_host_seed __P((void)); /* Get host-dependent random number seed */
394 int  have_route_to __P((u_int32_t)); /* Check if route to addr exists */
395 #ifdef PPP_FILTER
396 int  set_filters __P((struct bpf_program *pass, struct bpf_program *active));
397                                 /* Set filter programs in kernel */
398 #endif
399 #ifdef IPX_CHANGE
400 int  sipxfaddr __P((int, unsigned long, unsigned char *));
401 int  cipxfaddr __P((int));
402 #endif
403
404 /* Procedures exported from options.c */
405 int  parse_args __P((int argc, char **argv));
406                                 /* Parse options from arguments given */
407 int  options_from_file __P((char *filename, int must_exist, int check_prot,
408                             int privileged));
409                                 /* Parse options from an options file */
410 int  options_from_user __P((void)); /* Parse options from user's .ppprc */
411 int  options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
412 void scan_args __P((int argc, char **argv));
413                                 /* Look for tty name in command-line args */
414 int  getword __P((FILE *f, char *word, int *newlinep, char *filename));
415                                 /* Read a word from a file */
416 void option_error __P((char *fmt, ...));
417                                 /* Print an error message about an option */
418 int int_option __P((char *, int *));
419                                 /* Simplified number_option for decimal ints */
420
421 /*
422  * This structure is used to store information about certain
423  * options, such as where the option value came from (/etc/ppp/options,
424  * command line, etc.) and whether it came from a privileged source.
425  */
426
427 struct option_info {
428     int     priv;               /* was value set by sysadmin? */
429     char    *source;            /* where option came from */
430 };
431
432 extern struct option_info devnam_info;
433 extern struct option_info connector_info;
434 extern struct option_info disconnector_info;
435 extern struct option_info welcomer_info;
436 extern struct option_info ptycommand_info;
437
438 /*
439  * Inline versions of get/put char/short/long.
440  * Pointer is advanced; we assume that both arguments
441  * are lvalues and will already be in registers.
442  * cp MUST be u_char *.
443  */
444 #define GETCHAR(c, cp) { \
445         (c) = *(cp)++; \
446 }
447 #define PUTCHAR(c, cp) { \
448         *(cp)++ = (u_char) (c); \
449 }
450
451
452 #define GETSHORT(s, cp) { \
453         (s) = *(cp)++ << 8; \
454         (s) |= *(cp)++; \
455 }
456 #define PUTSHORT(s, cp) { \
457         *(cp)++ = (u_char) ((s) >> 8); \
458         *(cp)++ = (u_char) (s); \
459 }
460
461 #define GETLONG(l, cp) { \
462         (l) = *(cp)++ << 8; \
463         (l) |= *(cp)++; (l) <<= 8; \
464         (l) |= *(cp)++; (l) <<= 8; \
465         (l) |= *(cp)++; \
466 }
467 #define PUTLONG(l, cp) { \
468         *(cp)++ = (u_char) ((l) >> 24); \
469         *(cp)++ = (u_char) ((l) >> 16); \
470         *(cp)++ = (u_char) ((l) >> 8); \
471         *(cp)++ = (u_char) (l); \
472 }
473
474 #define INCPTR(n, cp)   ((cp) += (n))
475 #define DECPTR(n, cp)   ((cp) -= (n))
476
477 /*
478  * System dependent definitions for user-level 4.3BSD UNIX implementation.
479  */
480
481 #define TIMEOUT(r, f, t)        timeout((r), (f), (t))
482 #define UNTIMEOUT(r, f)         untimeout((r), (f))
483
484 #define BCOPY(s, d, l)          memcpy(d, s, l)
485 #define BZERO(s, n)             memset(s, 0, n)
486
487 #define PRINTMSG(m, l)          { info("Remote message: %0.*v", l, m); }
488
489 /*
490  * MAKEHEADER - Add Header fields to a packet.
491  */
492 #define MAKEHEADER(p, t) { \
493     PUTCHAR(PPP_ALLSTATIONS, p); \
494     PUTCHAR(PPP_UI, p); \
495     PUTSHORT(t, p); }
496
497 /*
498  * Exit status values.
499  */
500 #define EXIT_OK                 0
501 #define EXIT_FATAL_ERROR        1
502 #define EXIT_OPTION_ERROR       2
503 #define EXIT_NOT_ROOT           3
504 #define EXIT_NO_KERNEL_SUPPORT  4
505 #define EXIT_USER_REQUEST       5
506 #define EXIT_LOCK_FAILED        6
507 #define EXIT_OPEN_FAILED        7
508 #define EXIT_CONNECT_FAILED     8
509 #define EXIT_PTYCMD_FAILED      9
510 #define EXIT_NEGOTIATION_FAILED 10
511 #define EXIT_PEER_AUTH_FAILED   11
512 #define EXIT_IDLE_TIMEOUT       12
513 #define EXIT_CONNECT_TIME       13
514 #define EXIT_CALLBACK           14
515 #define EXIT_PEER_DEAD          15
516 #define EXIT_HANGUP             16
517
518 /*
519  * Debug macros.  Slightly useful for finding bugs in pppd, not particularly
520  * useful for finding out why your connection isn't being established.
521  */
522 #ifdef DEBUGALL
523 #define DEBUGMAIN       1
524 #define DEBUGFSM        1
525 #define DEBUGLCP        1
526 #define DEBUGIPCP       1
527 #define DEBUGUPAP       1
528 #define DEBUGCHAP       1
529 #endif
530
531 #ifndef LOG_PPP                 /* we use LOG_LOCAL2 for syslog by default */
532 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
533   || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
534   || defined(DEBUGCHAP) || defined(DEBUG)
535 #define LOG_PPP LOG_LOCAL2
536 #else
537 #define LOG_PPP LOG_DAEMON
538 #endif
539 #endif /* LOG_PPP */
540
541 #ifdef DEBUGMAIN
542 #define MAINDEBUG(x)    if (debug) dbglog x
543 #else
544 #define MAINDEBUG(x)
545 #endif
546
547 #ifdef DEBUGSYS
548 #define SYSDEBUG(x)     if (debug) dbglog x
549 #else
550 #define SYSDEBUG(x)
551 #endif
552
553 #ifdef DEBUGFSM
554 #define FSMDEBUG(x)     if (debug) dbglog x
555 #else
556 #define FSMDEBUG(x)
557 #endif
558
559 #ifdef DEBUGLCP
560 #define LCPDEBUG(x)     if (debug) dbglog x
561 #else
562 #define LCPDEBUG(x)
563 #endif
564
565 #ifdef DEBUGIPCP
566 #define IPCPDEBUG(x)    if (debug) dbglog x
567 #else
568 #define IPCPDEBUG(x)
569 #endif
570
571 #ifdef DEBUGUPAP
572 #define UPAPDEBUG(x)    if (debug) dbglog x
573 #else
574 #define UPAPDEBUG(x)
575 #endif
576
577 #ifdef DEBUGCHAP
578 #define CHAPDEBUG(x)    if (debug) dbglog x
579 #else
580 #define CHAPDEBUG(x)
581 #endif
582
583 #ifdef DEBUGIPXCP
584 #define IPXCPDEBUG(x)   if (debug) dbglog x
585 #else
586 #define IPXCPDEBUG(x)
587 #endif
588
589 #ifndef SIGTYPE
590 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
591 #define SIGTYPE void
592 #else
593 #define SIGTYPE int
594 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
595 #endif /* SIGTYPE */
596
597 #ifndef MIN
598 #define MIN(a, b)       ((a) < (b)? (a): (b))
599 #endif
600 #ifndef MAX
601 #define MAX(a, b)       ((a) > (b)? (a): (b))
602 #endif
603
604 #endif /* __PPP_H__ */