source: rtems/cpukit/pppd/pppd.h @ aee474b

4.104.114.84.9
Last change on this file since aee474b was aee474b, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 12, 2001 at 1:43:05 PM

2001-10-12 Mike Siers <mikes@…>

  • Update to stable working state. Congratulations Mike! :)
  • modem_example: Directory removed.
  • modem_example/16550.h, modem_example/README, modem_example/modem.c, modem_example/modem.h, modem_example/ppp.c, modem_example/ppp.h, modem_example/pppcompress.c: Files removed.
  • pppd/example/pppd.options: New file.
  • pppd/README, pppd/STATUS, pppd/cbcp.c, pppd/cbcp.h, pppd/chat.c, pppd/pppd.h, pppd/rtemsmain.c: Updated.
  • Property mode set to 100644
File size: 23.5 KB
Line 
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$
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 defined(__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#ifdef INET6
47#include "eui64.h"
48#endif
49
50/*
51 * Limits.
52 */
53
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 */
59
60/*
61 * Option descriptor structure.
62 */
63
64typedef unsigned char   bool;
65
66enum opt_type {
67        o_special_noarg = 0,
68        o_special = 1,
69        o_bool,
70        o_int,
71        o_uint32,
72        o_string,
73};
74
75typedef struct {
76        char    *name;          /* name of the option */
77        enum opt_type type;
78        void    *addr;
79        char    *description;
80        int     flags;
81        void    *addr2;
82        int     upper_limit;
83        int     lower_limit;
84} option_t;
85
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
109#define OPT_VAL(x)      ((x) & OPT_VALUE)
110
111#ifndef GIDSET_TYPE
112#define GIDSET_TYPE     gid_t
113#endif
114
115/* Structure representing a list of permitted IP addresses. */
116struct permitted_ip {
117    int         permit;         /* 1 = permit, 0 = forbid */
118    u_int32_t   base;           /* match if (addr & mask) == base */
119    u_int32_t   mask;           /* base and mask are in network byte order */
120};
121
122/*
123 * Unfortunately, the linux kernel driver uses a different structure
124 * for statistics from the rest of the ports.
125 * This structure serves as a common representation for the bits
126 * pppd needs.
127 */
128struct pppd_stats {
129    unsigned int        bytes_in;
130    unsigned int        bytes_out;
131};
132
133/* Used for storing a sequence of words.  Usually malloced. */
134struct wordlist {
135    struct wordlist     *next;
136    char                *word;
137};
138
139/*
140 * Global variables.
141 */
142
143extern int      kill_link;      /* Signal to terminate processing loop */
144extern int      hungup;         /* Physical layer has disconnected */
145extern int      pppifunit;      /* Interface unit number */
146extern char     ifname[];       /* Interface name */
147extern int      ttyfd;          /* Serial device file descriptor */
148extern char     hostname[];     /* Our hostname */
149extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
150extern int      phase;          /* Current state of link - see values below */
151extern int      baud_rate;      /* Current link speed in bits/sec */
152extern char     *progname;      /* Name of this program */
153extern int      redirect_stderr;/* Connector's stderr should go to file */
154extern char     peer_authname[];/* Authenticated name of peer */
155extern int      privileged;     /* We were run by real-uid root */
156extern int      need_holdoff;   /* Need holdoff period after link terminates */
157extern char     **script_env;   /* Environment variables for scripts */
158extern int      detached;       /* Have detached from controlling tty */
159extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
160extern int      ngroups;        /* How many groups valid in groups */
161extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
162extern int      using_pty;      /* using pty as device (notty or pty opt.) */
163extern int      log_to_fd;      /* logging to this fd as well as syslog */
164extern char     *no_ppp_msg;    /* message to print if ppp not in kernel */
165extern volatile int status;     /* exit status for pppd */
166extern int      devnam_fixed;   /* can no longer change devnam */
167extern int      unsuccess;      /* # unsuccessful connection attempts */
168extern int      do_callback;    /* set if we want to do callback next */
169extern int      doing_callback; /* set if this is a callback */
170
171/* Values for do_callback and doing_callback */
172#define CALLBACK_DIALIN         1       /* we are expecting the call back */
173#define CALLBACK_DIALOUT        2       /* we are dialling out to call back */
174
175/*
176 * Variables set by command-line options.
177 */
178
179extern int      debug;          /* Debug flag */
180extern int      kdebugflag;     /* Tell kernel to print debug messages */
181extern int      default_device; /* Using /dev/tty or equivalent */
182extern char     devnam[MAXPATHLEN];     /* Device name */
183extern int      crtscts;        /* Use hardware flow control */
184extern bool     modem;          /* Use modem control lines */
185extern int      inspeed;        /* Input/Output speed requested */
186extern u_int32_t netmask;       /* IP netmask to set on interface */
187extern bool     lockflag;       /* Create lock file to lock the serial dev */
188extern bool     nodetach;       /* Don't detach from controlling tty */
189extern bool     updetach;       /* Detach from controlling tty when link up */
190extern char     *initializer;   /* Script to initialize physical link */
191extern char     *connect_script; /* Script to establish physical link */
192extern char     *disconnect_script; /* Script to disestablish physical link */
193extern char     *welcomer;      /* Script to welcome client after connection */
194extern char     *ptycommand;    /* Command to run on other side of pty */
195extern int      maxconnect;     /* Maximum connect time (seconds) */
196extern char     user[MAXNAMELEN];/* Our name for authenticating ourselves */
197extern char     passwd[MAXSECRETLEN];   /* Password for PAP or CHAP */
198extern bool     auth_required;  /* Peer is required to authenticate */
199extern bool     persist;        /* Reopen link after it goes down */
200extern bool     uselogin;       /* Use /etc/passwd for checking PAP */
201extern char     our_name[MAXNAMELEN];/* Our name for authentication purposes */
202extern char     remote_name[MAXNAMELEN]; /* Peer's name for authentication */
203extern bool     explicit_remote;/* remote_name specified with remotename opt */
204extern bool     demand;         /* Do dial-on-demand */
205extern char     *ipparam;       /* Extra parameter for ip up/down scripts */
206extern bool     cryptpap;       /* Others' PAP passwords are encrypted */
207extern int      idle_time_limit;/* Shut down link if idle for this long */
208extern int      holdoff;        /* Dead time before restarting */
209extern bool     holdoff_specified; /* true if user gave a holdoff value */
210extern bool     notty;          /* Stdin/out is not a tty */
211extern char     *record_file;   /* File to record chars sent/received */
212extern bool     sync_serial;    /* Device is synchronous serial device */
213extern int      maxfail;        /* Max # of unsuccessful connection attempts */
214extern char     linkname[MAXPATHLEN]; /* logical name for link */
215extern bool     tune_kernel;    /* May alter kernel settings as necessary */
216extern int      connect_delay;  /* Time to delay after connect script */
217
218#ifdef PPP_FILTER
219extern struct   bpf_program pass_filter;   /* Filter for pkts to pass */
220extern struct   bpf_program active_filter; /* Filter for link-active pkts */
221#endif
222
223#ifdef MSLANMAN
224extern bool     ms_lanman;      /* Use LanMan password instead of NT */
225                                /* Has meaning only with MS-CHAP challenges */
226#endif
227
228extern char *current_option;    /* the name of the option being parsed */
229extern int  privileged_option;  /* set iff the current option came from root */
230extern char *option_source;     /* string saying where the option came from */
231
232/*
233 * Values for phase.
234 */
235#define PHASE_DEAD              0
236#define PHASE_INITIALIZE        1
237#define PHASE_SERIALCONN        2
238#define PHASE_DORMANT           3
239#define PHASE_ESTABLISH         4
240#define PHASE_AUTHENTICATE      5
241#define PHASE_CALLBACK          6
242#define PHASE_NETWORK           7
243#define PHASE_RUNNING           8
244#define PHASE_TERMINATE         9
245#define PHASE_DISCONNECT        10
246#define PHASE_HOLDOFF           11
247
248/*
249 * The following struct gives the addresses of procedures to call
250 * for a particular protocol.
251 */
252struct protent {
253    u_short protocol;           /* PPP protocol number */
254    /* Initialization procedure */
255    void (*init) __P((int unit));
256    /* Process a received packet */
257    void (*input) __P((int unit, u_char *pkt, int len));
258    /* Process a received protocol-reject */
259    void (*protrej) __P((int unit));
260    /* Lower layer has come up */
261    void (*lowerup) __P((int unit));
262    /* Lower layer has gone down */
263    void (*lowerdown) __P((int unit));
264    /* Open the protocol */
265    void (*open) __P((int unit));
266    /* Close the protocol */
267    void (*close) __P((int unit, char *reason));
268    /* Print a packet in readable form */
269    int  (*printpkt) __P((u_char *pkt, int len,
270                          void (*printer) __P((void *, char *, ...)),
271                          void *arg));
272    /* Process a received data packet */
273    void (*datainput) __P((int unit, u_char *pkt, int len));
274    bool enabled_flag;          /* 0 iff protocol is disabled */
275    char *name;                 /* Text name of protocol */
276    char *data_name;            /* Text name of corresponding data protocol */
277    option_t *options;          /* List of command-line options */
278    /* Check requested options, assign defaults */
279    void (*check_options) __P((void));
280    /* Configure interface for demand-dial */
281    int  (*demand_conf) __P((int unit));
282    /* Say whether to bring up link for this pkt */
283    int  (*active_pkt) __P((u_char *pkt, int len));
284};
285
286/* Table of pointers to supported protocols */
287extern struct protent *protocols[];
288
289/*
290 * Prototypes.
291 */
292
293/* Procedures exported from main.c. */
294void die __P((int));            /* Cleanup and exit */
295void quit __P((void));          /* like die(1) */
296void novm __P((char *));        /* Say we ran out of memory, and die */
297void ppptimeout __P((void (*func)(void *), void *arg, int t));
298                                /* Call func(arg) after t seconds */
299void untimeout __P((void (*func)(void *), void *arg));
300                                /* Cancel call to func(arg) */
301void update_link_stats __P((int)); /* Get stats at link termination */
302void new_phase __P((int));      /* signal start of new phase */
303
304/* Procedures exported from utils.c. */
305void log_packet __P((u_char *, int, char *, int));
306                                /* Format a packet and log it with syslog */
307void print_string __P((char *, int,  void (*) (void *, char *, ...),
308                void *));       /* Format a string for output */
309int slprintf __P((char *, int, char *, ...));           /* sprintf++ */
310int vslprintf __P((char *, int, char *, va_list));      /* vsprintf++ */
311size_t strlcpy __P((char *, const char *, size_t));     /* safe strcpy */
312size_t strlcat __P((char *, const char *, size_t));     /* safe strncpy */
313void pppd_dbglog __P((char *, ...));    /* log a debug message */
314void pppd_info __P((char *, ...));      /* log an informational message */
315void pppd_notice __P((char *, ...));    /* log a notice-level message */
316void pppd_warn __P((char *, ...));      /* log a warning message */
317void pppd_error __P((char *, ...));     /* log an error message */
318void pppd_fatal __P((char *, ...));     /* log an error message and die(1) */
319
320#define dbglog pppd_dbglog
321#define info   pppd_info
322#define notice pppd_notice
323#define warn   pppd_warn
324#define error  pppd_error
325#define fatal  pppd_fatal
326
327/* Procedures exported from auth.c */
328void link_required __P((int));    /* we are starting to use the link */
329void link_terminated __P((int));  /* we are finished with the link */
330void link_down __P((int));        /* the LCP layer has left the Opened state */
331void link_established __P((int)); /* the link is up; authenticate now */
332void start_networks __P((void));  /* start all the network control protos */
333void np_up __P((int, int));       /* a network protocol has come up */
334void np_down __P((int, int));     /* a network protocol has gone down */
335void np_finished __P((int, int)); /* a network protocol no longer needs link */
336void auth_peer_fail __P((int, int));
337                                /* peer failed to authenticate itself */
338void auth_peer_success __P((int, int, char *, int));
339                                /* peer successfully authenticated itself */
340void auth_withpeer_fail __P((int, int));
341                                /* we failed to authenticate ourselves */
342void auth_withpeer_success __P((int, int));
343                                /* we successfully authenticated ourselves */
344int  auth_check_options __P((void));
345                                /* check authentication options supplied */
346void auth_reset __P((int));     /* check what secrets we have */
347int  check_passwd __P((int, char *, int, char *, int, char **));
348                                /* Check peer-supplied username/password */
349int  get_secret __P((int, char *, char *, char *, int *, int));
350                                /* get "secret" for chap */
351int  auth_ip_addr __P((int, u_int32_t));
352                                /* check if IP address is authorized */
353int  bad_ip_adrs __P((u_int32_t));
354                                /* check if IP address is unreasonable */
355
356/* Procedures exported from demand.c */
357void demand_conf __P((void));   /* config interface(s) for demand-dial */
358void demand_block __P((void));  /* set all NPs to queue up packets */
359void demand_unblock __P((void)); /* set all NPs to pass packets */
360void demand_discard __P((void)); /* set all NPs to discard packets */
361void demand_rexmit __P((int));  /* retransmit saved frames for an NP */
362int  loop_chars __P((unsigned char *, int)); /* process chars from loopback */
363int  loop_frame __P((unsigned char *, int)); /* should we bring link up? */
364
365/* Procedures exported from sys-*.c */
366void sys_init __P((void));      /* Do system-dependent initialization */
367void sys_cleanup __P((void));   /* Restore system state before exiting */
368int  sys_check_options __P((void)); /* Check options specified */
369void sys_close __P((void));     /* Clean up in a child before execing */
370int  ppp_available __P((void)); /* Test whether ppp kernel support exists */
371int  get_pty __P((int *, int *, char *, int));  /* Get pty master/slave */
372int  open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
373int  establish_ppp __P((int));  /* Turn serial port into a ppp interface */
374void restore_loop __P((void));  /* Transfer ppp unit back to loopback */
375void disestablish_ppp __P((int)); /* Restore port to normal operation */
376void clean_check __P((void));   /* Check if line was 8-bit clean */
377void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
378void restore_tty __P((int));    /* Restore port's original parameters */
379void setdtr __P((int, int));    /* Raise or lower port's DTR line */
380void output __P((int, u_char *, int)); /* Output a PPP packet */
381void wait_input __P((struct timeval *));
382                                /* Wait for input, with timeout */
383int  read_packet __P((u_char *)); /* Read PPP packet */
384int  get_loop_output __P((void)); /* Read pkts from loopback */
385void ppp_send_config __P((int, int, u_int32_t, int, int));
386                                /* Configure i/f transmit parameters */
387void ppp_set_xaccm __P((int, ext_accm));
388                                /* Set extended transmit ACCM */
389void ppp_recv_config __P((int, int, u_int32_t, int, int));
390                                /* Configure i/f receive parameters */
391int  ccp_test __P((int, u_char *, int, int));
392                                /* Test support for compression scheme */
393void ccp_flags_set __P((int, int, int));
394                                /* Set kernel CCP state */
395int  ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
396int  get_idle_time __P((int, struct ppp_idle *));
397                                /* Find out how long link has been idle */
398int  get_ppp_stats __P((int, struct pppd_stats *));
399                                /* Return link statistics */
400int  sifvjcomp __P((int, int, int, int));
401                                /* Configure VJ TCP header compression */
402int  sifup __P((int));          /* Configure i/f up for one protocol */
403int  sifnpmode __P((int u, int proto, enum NPmode mode));
404                                /* Set mode for handling packets for proto */
405int  sifdown __P((int));        /* Configure i/f down for one protocol */
406int  sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
407                                /* Configure IPv4 addresses for i/f */
408int  cifaddr __P((int, u_int32_t, u_int32_t));
409                                /* Reset i/f IP addresses */
410#ifdef INET6
411int  sif6addr __P((int, eui64_t, eui64_t));
412                                /* Configure IPv6 addresses for i/f */
413int  cif6addr __P((int, eui64_t, eui64_t));
414                                /* Remove an IPv6 address from i/f */
415#endif
416int  sifdefaultroute __P((int, u_int32_t, u_int32_t));
417                                /* Create default route through i/f */
418int  cifdefaultroute __P((int, u_int32_t, u_int32_t));
419                                /* Delete default route through i/f */
420int  sifproxyarp __P((int, u_int32_t));
421                                /* Add proxy ARP entry for peer */
422int  cifproxyarp __P((int, u_int32_t));
423                                /* Delete proxy ARP entry for peer */
424u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
425int  lock __P((char *));        /* Create lock file for device */
426int  relock __P((int));         /* Rewrite lock file with new pid */
427void unlock __P((void));        /* Delete previously-created lock file */
428void logwtmp __P((const char *, const char *, const char *));
429                                /* Write entry to wtmp file */
430int  get_host_seed __P((void)); /* Get host-dependent random number seed */
431int  have_route_to __P((u_int32_t)); /* Check if route to addr exists */
432#ifdef PPP_FILTER
433int  set_filters __P((struct bpf_program *pass, struct bpf_program *active));
434                                /* Set filter programs in kernel */
435#endif
436#ifdef IPX_CHANGE
437int  sipxfaddr __P((int, unsigned long, unsigned char *));
438int  cipxfaddr __P((int));
439#endif
440
441/* Procedures exported from options.c */
442int  parse_args __P((int argc, char **argv));
443                                /* Parse options from arguments given */
444int  options_from_file __P((char *filename, int must_exist, int check_prot,
445                            int privileged));
446                                /* Parse options from an options file */
447int  options_from_user __P((void)); /* Parse options from user's .ppprc */
448int  options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
449int  options_from_list __P((struct wordlist *, int privileged));
450                                /* Parse options from a wordlist */
451int  getword __P((FILE *f, char *word, int *newlinep, char *filename));
452                                /* Read a word from a file */
453void option_error __P((char *fmt, ...));
454                                /* Print an error message about an option */
455int int_option __P((char *, int *));
456                                /* Simplified number_option for decimal ints */
457void add_options __P((option_t *)); /* Add extra options */
458
459/*
460 * This structure is used to store information about certain
461 * options, such as where the option value came from (/etc/ppp/options,
462 * command line, etc.) and whether it came from a privileged source.
463 */
464
465struct option_info {
466    int     priv;               /* was value set by sysadmin? */
467    char    *source;            /* where option came from */
468};
469
470extern struct option_info devnam_info;
471extern struct option_info initializer_info;
472extern struct option_info connect_script_info;
473extern struct option_info disconnect_script_info;
474extern struct option_info welcomer_info;
475extern struct option_info ptycommand_info;
476
477/*
478 * Hooks to enable plugins to change various things.
479 */
480extern int (*new_phase_hook) __P((int));
481extern int (*idle_time_hook) __P((struct ppp_idle *));
482extern int (*holdoff_hook) __P((void));
483extern int (*pap_check_hook) __P((void));
484extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
485                                 struct wordlist **paddrs,
486                                 struct wordlist **popts));
487extern void (*pap_logout_hook) __P((void));
488extern int (*pap_passwd_hook) __P((char *user, char *passwd));
489extern void (*ip_up_hook) __P((void));
490extern void (*ip_down_hook) __P((void));
491extern void (*auth_linkup_hook) __P((void));
492extern void (*auth_linkdown_hook) __P((void));
493
494/*
495 * Inline versions of get/put char/short/long.
496 * Pointer is advanced; we assume that both arguments
497 * are lvalues and will already be in registers.
498 * cp MUST be u_char *.
499 */
500#define GETCHAR(c, cp) { \
501        (c) = *(cp)++; \
502}
503#define PUTCHAR(c, cp) { \
504        *(cp)++ = (u_char) (c); \
505}
506
507
508#define GETSHORT(s, cp) { \
509        (s) = *(cp)++ << 8; \
510        (s) |= *(cp)++; \
511}
512#define PUTSHORT(s, cp) { \
513        *(cp)++ = (u_char) ((s) >> 8); \
514        *(cp)++ = (u_char) (s); \
515}
516
517#define GETLONG(l, cp) { \
518        (l) = *(cp)++ << 8; \
519        (l) |= *(cp)++; (l) <<= 8; \
520        (l) |= *(cp)++; (l) <<= 8; \
521        (l) |= *(cp)++; \
522}
523#define PUTLONG(l, cp) { \
524        *(cp)++ = (u_char) ((l) >> 24); \
525        *(cp)++ = (u_char) ((l) >> 16); \
526        *(cp)++ = (u_char) ((l) >> 8); \
527        *(cp)++ = (u_char) (l); \
528}
529
530#define INCPTR(n, cp)   ((cp) += (n))
531#define DECPTR(n, cp)   ((cp) -= (n))
532
533/*
534 * System dependent definitions for user-level 4.3BSD UNIX implementation.
535 */
536
537#define TIMEOUT(r, f, t)        ppptimeout((r), (f), (t))
538#define UNTIMEOUT(r, f)         untimeout((r), (f))
539
540#define BCOPY(s, d, l)          memcpy(d, s, l)
541#define BZERO(s, n)             memset(s, 0, n)
542
543#define PRINTMSG(m, l)          { info("Remote message: %0.*v", l, m); }
544
545/*
546 * MAKEHEADER - Add Header fields to a packet.
547 */
548#define MAKEHEADER(p, t) { \
549    PUTCHAR(PPP_ALLSTATIONS, p); \
550    PUTCHAR(PPP_UI, p); \
551    PUTSHORT(t, p); }
552
553/*
554 * Exit status values.
555 */
556#define EXIT_OK                 0
557#define EXIT_FATAL_ERROR        1
558#define EXIT_OPTION_ERROR       2
559#define EXIT_NOT_ROOT           3
560#define EXIT_NO_KERNEL_SUPPORT  4
561#define EXIT_USER_REQUEST       5
562#define EXIT_LOCK_FAILED        6
563#define EXIT_OPEN_FAILED        7
564#define EXIT_CONNECT_FAILED     8
565#define EXIT_PTYCMD_FAILED      9
566#define EXIT_NEGOTIATION_FAILED 10
567#define EXIT_PEER_AUTH_FAILED   11
568#define EXIT_IDLE_TIMEOUT       12
569#define EXIT_CONNECT_TIME       13
570#define EXIT_CALLBACK           14
571#define EXIT_PEER_DEAD          15
572#define EXIT_HANGUP             16
573#define EXIT_LOOPBACK           17
574#define EXIT_INIT_FAILED        18
575#define EXIT_AUTH_TOPEER_FAILED 19
576
577/*
578 * Debug macros.  Slightly useful for finding bugs in pppd, not particularly
579 * useful for finding out why your connection isn't being established.
580 */
581
582#ifdef DEBUGALL
583#define DEBUGMAIN       1
584#define DEBUGFSM        1
585#define DEBUGLCP        1
586#define DEBUGIPCP       1
587#define DEBUGIPV6CP     1
588#define DEBUGUPAP       1
589#define DEBUGCHAP       1
590#endif
591#define DEBUGMAIN       1
592#define DEBUGUPAP       1
593#define DEBUGCHAP       1
594
595
596#ifdef DEBUGMAIN
597#define MAINDEBUG(x)    if (debug) dbglog x
598#else
599#define MAINDEBUG(x)
600#endif
601
602#ifdef DEBUGSYS
603#define SYSDEBUG(x)     if (debug) dbglog x
604#else
605#define SYSDEBUG(x)
606#endif
607
608#ifdef DEBUGFSM
609#define FSMDEBUG(x)     if (debug) dbglog x
610#else
611#define FSMDEBUG(x)
612#endif
613
614#ifdef DEBUGLCP
615#define LCPDEBUG(x)     if (debug) dbglog x
616#else
617#define LCPDEBUG(x)
618#endif
619
620#ifdef DEBUGIPCP
621#define IPCPDEBUG(x)    if (debug) dbglog x
622#else
623#define IPCPDEBUG(x)
624#endif
625
626#ifdef DEBUGIPV6CP
627#define IPV6CPDEBUG(x)  if (debug) dbglog x
628#else
629#define IPV6CPDEBUG(x)
630#endif
631
632#ifdef DEBUGUPAP
633#define UPAPDEBUG(x)    if (debug) dbglog x
634#else
635#define UPAPDEBUG(x)
636#endif
637
638#ifdef DEBUGCHAP
639#define CHAPDEBUG(x)    if (debug) dbglog x
640#else
641#define CHAPDEBUG(x)
642#endif
643
644#ifdef DEBUGIPXCP
645#define IPXCPDEBUG(x)   if (debug) dbglog x
646#else
647#define IPXCPDEBUG(x)
648#endif
649
650#ifndef SIGTYPE
651#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
652#define SIGTYPE void
653#else
654#define SIGTYPE int
655#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
656#endif /* SIGTYPE */
657
658#ifndef MIN
659#define MIN(a, b)       ((a) < (b)? (a): (b))
660#endif
661#ifndef MAX
662#define MAX(a, b)       ((a) > (b)? (a): (b))
663#endif
664
665#endif /* __PPP_H__ */
Note: See TracBrowser for help on using the repository browser.