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