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.8 1995/04/26 06:46:31 paulus Exp $
29 #include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
30 #include <sys/types.h> /* for u_int32_t, if defined */
31 #include <net/ppp_defs.h>
33 #define NUM_PPP 1 /* One PPP interface supported (per process) */
39 #define MAXWORDLEN 1024 /* max length of word in file (incl null) */
40 #define MAXARGS 1 /* max # args to a command */
41 #define MAXNAMELEN 256 /* max length of hostname or name for auth */
42 #define MAXSECRETLEN 256 /* max length of password or secret */
48 extern int hungup; /* Physical layer has disconnected */
49 extern int ifunit; /* Interface unit number */
50 extern char ifname[]; /* Interface name */
51 extern int fd; /* Serial device file descriptor */
52 extern char hostname[]; /* Our hostname */
53 extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
54 extern int phase; /* Current state of link - see values below */
55 extern int baud_rate; /* Current link speed in bits/sec */
56 extern char *progname; /* Name of this program */
59 * Variables set by command-line options.
62 extern int debug; /* Debug flag */
63 extern int kdebugflag; /* Tell kernel to print debug messages */
64 extern int default_device; /* Using /dev/tty or equivalent */
65 extern char devnam[]; /* Device name */
66 extern int crtscts; /* Use hardware flow control */
67 extern int modem; /* Use modem control lines */
68 extern int inspeed; /* Input/Output speed requested */
69 extern u_int32_t netmask; /* IP netmask to set on interface */
70 extern int lockflag; /* Create lock file to lock the serial dev */
71 extern int nodetach; /* Don't detach from controlling tty */
72 extern char *connector; /* Script to establish physical link */
73 extern char *disconnector; /* Script to disestablish physical link */
74 extern char user[]; /* Username for PAP */
75 extern char passwd[]; /* Password for PAP */
76 extern int auth_required; /* Peer is required to authenticate */
77 extern int proxyarp; /* Set up proxy ARP entry for peer */
78 extern int persist; /* Reopen link after it goes down */
79 extern int uselogin; /* Use /etc/passwd for checking PAP */
80 extern int lcp_echo_interval; /* Interval between LCP echo-requests */
81 extern int lcp_echo_fails; /* Tolerance to unanswered echo-requests */
82 extern char our_name[]; /* Our name for authentication purposes */
83 extern char remote_name[]; /* Peer's name for authentication */
84 extern int usehostname; /* Use hostname for our_name */
85 extern int disable_defaultip; /* Don't use hostname for default IP adrs */
86 extern char *ipparam; /* Extra parameter for ip up/down scripts */
87 extern int cryptpap; /* Others' PAP passwords are encrypted */
93 #define PHASE_ESTABLISH 1
94 #define PHASE_AUTHENTICATE 2
95 #define PHASE_NETWORK 3
96 #define PHASE_TERMINATE 4
101 void quit __P((void)); /* Cleanup and exit */
102 void timeout __P((void (*)(), caddr_t, int));
103 /* Look-alike of kernel's timeout() */
104 void untimeout __P((void (*)(), caddr_t));
105 /* Look-alike of kernel's untimeout() */
106 void output __P((int, u_char *, int));
107 /* Output a PPP packet */
108 void demuxprotrej __P((int, int));
109 /* Demultiplex a Protocol-Reject */
110 int check_passwd __P((int, char *, int, char *, int, char **, int *));
111 /* Check peer-supplied username/password */
112 int get_secret __P((int, char *, char *, char *, int *, int));
113 /* get "secret" for chap */
114 u_int32_t GetMask __P((u_int32_t)); /* get netmask for address */
118 * Inline versions of get/put char/short/long.
119 * Pointer is advanced; we assume that both arguments
120 * are lvalues and will already be in registers.
121 * cp MUST be u_char *.
123 #define GETCHAR(c, cp) { \
126 #define PUTCHAR(c, cp) { \
127 *(cp)++ = (u_char) (c); \
131 #define GETSHORT(s, cp) { \
132 (s) = *(cp)++ << 8; \
135 #define PUTSHORT(s, cp) { \
136 *(cp)++ = (u_char) ((s) >> 8); \
137 *(cp)++ = (u_char) (s); \
140 #define GETLONG(l, cp) { \
141 (l) = *(cp)++ << 8; \
142 (l) |= *(cp)++; (l) <<= 8; \
143 (l) |= *(cp)++; (l) <<= 8; \
146 #define PUTLONG(l, cp) { \
147 *(cp)++ = (u_char) ((l) >> 24); \
148 *(cp)++ = (u_char) ((l) >> 16); \
149 *(cp)++ = (u_char) ((l) >> 8); \
150 *(cp)++ = (u_char) (l); \
153 #define INCPTR(n, cp) ((cp) += (n))
154 #define DECPTR(n, cp) ((cp) -= (n))
162 * System dependent definitions for user-level 4.3BSD UNIX implementation.
165 #define DEMUXPROTREJ(u, p) demuxprotrej(u, p)
167 #define TIMEOUT(r, f, t) timeout((r), (f), (t))
168 #define UNTIMEOUT(r, f) untimeout((r), (f))
170 #define BCOPY(s, d, l) memcpy(d, s, l)
171 #define BZERO(s, n) memset(s, 0, n)
172 #define EXIT(u) quit()
174 #define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
177 * MAKEHEADER - Add Header fields to a packet.
179 #define MAKEHEADER(p, t) { \
180 PUTCHAR(PPP_ALLSTATIONS, p); \
181 PUTCHAR(PPP_UI, p); \
194 #ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
195 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \
196 || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
197 || defined(DEBUGCHAP)
198 #define LOG_PPP LOG_LOCAL2
200 #define LOG_PPP LOG_DAEMON
205 #define MAINDEBUG(x) if (debug) syslog x
211 #define FSMDEBUG(x) if (debug) syslog x
217 #define LCPDEBUG(x) if (debug) syslog x
223 #define IPCPDEBUG(x) if (debug) syslog x
229 #define UPAPDEBUG(x) if (debug) syslog x
235 #define CHAPDEBUG(x) if (debug) syslog x
241 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
245 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
249 #define MIN(a, b) ((a) < (b)? (a): (b))
252 #define MAX(a, b) ((a) > (b)? (a): (b))
255 #endif /* __PPP_H__ */