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.3 1994/05/26 06:43:42 paulus Exp $
30 #include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
32 #define NPPP 1 /* One PPP interface supported (per process) */
37 #define MAXWORDLEN 1024 /* max length of word in file (incl null) */
38 #define MAXARGS 1 /* max # args to a command */
39 #define MAXNAMELEN 256 /* max length of hostname or name for auth */
40 #define MAXSECRETLEN 256 /* max length of password or secret */
45 extern int debug; /* Debug flag */
46 extern int ifunit; /* Interface unit number */
47 extern char ifname[]; /* Interface name */
48 extern int fd; /* Device file descriptor */
49 extern int s; /* socket descriptor */
50 extern char hostname[]; /* hostname */
51 extern u_char outpacket_buf[]; /* buffer for outgoing packets */
52 extern int phase; /* See values below */
58 #define PHASE_ESTABLISH 1
59 #define PHASE_AUTHENTICATE 2
60 #define PHASE_NETWORK 3
61 #define PHASE_TERMINATE 4
66 void quit __ARGS((void)); /* Cleanup and exit */
67 void timeout __ARGS((void (*)(), caddr_t, int));
68 /* Look-alike of kernel's timeout() */
69 void untimeout __ARGS((void (*)(), caddr_t));
70 /* Look-alike of kernel's untimeout() */
71 void output __ARGS((int, u_char *, int));
72 /* Output a PPP packet */
73 void demuxprotrej __ARGS((int, int));
74 /* Demultiplex a Protocol-Reject */
75 int check_passwd __ARGS((int, char *, int, char *, int, char **, int *));
76 /* Check peer-supplied username/password */
77 int get_secret __ARGS((int, char *, char *, char *, int *, int));
78 /* get "secret" for chap */
79 u_long GetMask __ARGS((u_long)); /* get netmask for address */
83 * Inline versions of get/put char/short/long.
84 * Pointer is advanced; we assume that both arguments
85 * are lvalues and will already be in registers.
86 * cp MUST be u_char *.
88 #define GETCHAR(c, cp) { \
91 #define PUTCHAR(c, cp) { \
92 *(cp)++ = (u_char) (c); \
96 #define GETSHORT(s, cp) { \
100 #define PUTSHORT(s, cp) { \
101 *(cp)++ = (u_char) ((s) >> 8); \
102 *(cp)++ = (u_char) (s); \
105 #define GETLONG(l, cp) { \
106 (l) = *(cp)++ << 8; \
107 (l) |= *(cp)++; (l) <<= 8; \
108 (l) |= *(cp)++; (l) <<= 8; \
111 #define PUTLONG(l, cp) { \
112 *(cp)++ = (u_char) ((l) >> 24); \
113 *(cp)++ = (u_char) ((l) >> 16); \
114 *(cp)++ = (u_char) ((l) >> 8); \
115 *(cp)++ = (u_char) (l); \
118 #define INCPTR(n, cp) ((cp) += (n))
119 #define DECPTR(n, cp) ((cp) -= (n))
122 * System dependent definitions for user-level 4.3BSD UNIX implementation.
125 #define DEMUXPROTREJ(u, p) demuxprotrej(u, p)
127 #define TIMEOUT(r, f, t) timeout((r), (f), (t))
128 #define UNTIMEOUT(r, f) untimeout((r), (f))
130 #define BCOPY(s, d, l) memcpy(d, s, l)
131 #define BZERO(s, n) memset(s, 0, n)
132 #define EXIT(u) quit()
134 #define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
137 * MAKEHEADER - Add Header fields to a packet.
139 #define MAKEHEADER(p, t) { \
140 PUTCHAR(ALLSTATIONS, p); \
154 #ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
155 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \
156 || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
157 || defined(DEBUGCHAP)
158 #define LOG_PPP LOG_LOCAL2
160 #define LOG_PPP LOG_DAEMON
165 #define MAINDEBUG(x) if (debug) syslog x
171 #define FSMDEBUG(x) if (debug) syslog x
177 #define LCPDEBUG(x) if (debug) syslog x
183 #define IPCPDEBUG(x) if (debug) syslog x
189 #define UPAPDEBUG(x) if (debug) syslog x
195 #define CHAPDEBUG(x) if (debug) syslog x
201 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
205 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
209 #define MIN(a, b) ((a) < (b)? (a): (b))
212 #define MAX(a, b) ((a) > (b)? (a): (b))
215 #endif /* __PPP_H__ */