]> git.ozlabs.org Git - ppp.git/blob - pppd/pppd.h
Update to state of pppd-new directory
[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.8.2.1 1995/06/01 07:01:37 paulus Exp $
20  */
21
22 /*
23  * TODO:
24  */
25
26 #ifndef __PPPD_H__
27 #define __PPPD_H__
28
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>
32
33 #define NUM_PPP 1               /* One PPP interface supported (per process) */
34
35 /*
36  * Limits.
37  */
38
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 */
43
44 /*
45  * Global variables.
46  */
47
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 */
57
58 /*
59  * Variables set by command-line options.
60  */
61
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 int      demand;         /* Do dial-on-demand */
87 extern char     *ipparam;       /* Extra parameter for ip up/down scripts */
88 extern int      cryptpap;       /* Others' PAP passwords are encrypted */
89 extern int      idle_time_limit;/* Shut down link if idle for this long */
90 extern int      holdoff;        /* Dead time before restarting */
91
92 /*
93  * Values for phase.
94  */
95 #define PHASE_DEAD              0
96 #define PHASE_DORMANT           1
97 #define PHASE_ESTABLISH         2
98 #define PHASE_AUTHENTICATE      3
99 #define PHASE_NETWORK           4
100 #define PHASE_TERMINATE         5
101 #define PHASE_HOLDOFF           6
102
103 /*
104  * Prototypes.
105  */
106 void quit __P((void));  /* Cleanup and exit */
107 void timeout __P((void (*)(), caddr_t, int));
108                                 /* Look-alike of kernel's timeout() */
109 void untimeout __P((void (*)(), caddr_t));
110                                 /* Look-alike of kernel's untimeout() */
111 void output __P((int, u_char *, int));
112                                 /* Output a PPP packet */
113 void demuxprotrej __P((int, int));
114                                 /* Demultiplex a Protocol-Reject */
115 int  check_passwd __P((int, char *, int, char *, int, char **, int *));
116                                 /* Check peer-supplied username/password */
117 int  get_secret __P((int, char *, char *, char *, int *, int));
118                                 /* get "secret" for chap */
119 u_int32_t GetMask __P((u_int32_t)); /* get netmask for address */
120 void die __P((int));
121 void np_up __P((int, int));
122 void np_down __P((int, int));
123 void np_finished __P((int, int));
124
125 /*
126  * Inline versions of get/put char/short/long.
127  * Pointer is advanced; we assume that both arguments
128  * are lvalues and will already be in registers.
129  * cp MUST be u_char *.
130  */
131 #define GETCHAR(c, cp) { \
132         (c) = *(cp)++; \
133 }
134 #define PUTCHAR(c, cp) { \
135         *(cp)++ = (u_char) (c); \
136 }
137
138
139 #define GETSHORT(s, cp) { \
140         (s) = *(cp)++ << 8; \
141         (s) |= *(cp)++; \
142 }
143 #define PUTSHORT(s, cp) { \
144         *(cp)++ = (u_char) ((s) >> 8); \
145         *(cp)++ = (u_char) (s); \
146 }
147
148 #define GETLONG(l, cp) { \
149         (l) = *(cp)++ << 8; \
150         (l) |= *(cp)++; (l) <<= 8; \
151         (l) |= *(cp)++; (l) <<= 8; \
152         (l) |= *(cp)++; \
153 }
154 #define PUTLONG(l, cp) { \
155         *(cp)++ = (u_char) ((l) >> 24); \
156         *(cp)++ = (u_char) ((l) >> 16); \
157         *(cp)++ = (u_char) ((l) >> 8); \
158         *(cp)++ = (u_char) (l); \
159 }
160
161 #define INCPTR(n, cp)   ((cp) += (n))
162 #define DECPTR(n, cp)   ((cp) -= (n))
163
164 #undef  FALSE
165 #define FALSE   0
166 #undef  TRUE
167 #define TRUE    1
168
169 /*
170  * System dependent definitions for user-level 4.3BSD UNIX implementation.
171  */
172
173 #define DEMUXPROTREJ(u, p)      demuxprotrej(u, p)
174
175 #define TIMEOUT(r, f, t)        timeout((r), (f), (t))
176 #define UNTIMEOUT(r, f)         untimeout((r), (f))
177
178 #define BCOPY(s, d, l)          memcpy(d, s, l)
179 #define BZERO(s, n)             memset(s, 0, n)
180 #define EXIT(u)                 quit()
181
182 #define PRINTMSG(m, l)  { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
183
184 /*
185  * MAKEHEADER - Add Header fields to a packet.
186  */
187 #define MAKEHEADER(p, t) { \
188     PUTCHAR(PPP_ALLSTATIONS, p); \
189     PUTCHAR(PPP_UI, p); \
190     PUTSHORT(t, p); }
191
192
193 #ifdef DEBUGALL
194 #define DEBUGMAIN       1
195 #define DEBUGFSM        1
196 #define DEBUGLCP        1
197 #define DEBUGIPCP       1
198 #define DEBUGUPAP       1
199 #define DEBUGCHAP       1
200 #endif
201
202 #ifndef LOG_PPP                 /* we use LOG_LOCAL2 for syslog by default */
203 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
204   || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
205   || defined(DEBUGCHAP) || defined(DEBUG)
206 #define LOG_PPP LOG_LOCAL2
207 #else
208 #define LOG_PPP LOG_DAEMON
209 #endif
210 #endif /* LOG_PPP */
211
212 #ifdef DEBUGMAIN
213 #define MAINDEBUG(x)    if (debug) syslog x
214 #else
215 #define MAINDEBUG(x)
216 #endif
217
218 #ifdef DEBUGSYS
219 #define SYSDEBUG(x)     if (debug) syslog x
220 #else
221 #define SYSDEBUG(x)
222 #endif
223
224 #ifdef DEBUGFSM
225 #define FSMDEBUG(x)     if (debug) syslog x
226 #else
227 #define FSMDEBUG(x)
228 #endif
229
230 #ifdef DEBUGLCP
231 #define LCPDEBUG(x)     if (debug) syslog x
232 #else
233 #define LCPDEBUG(x)
234 #endif
235
236 #ifdef DEBUGIPCP
237 #define IPCPDEBUG(x)    if (debug) syslog x
238 #else
239 #define IPCPDEBUG(x)
240 #endif
241
242 #ifdef DEBUGUPAP
243 #define UPAPDEBUG(x)    if (debug) syslog x
244 #else
245 #define UPAPDEBUG(x)
246 #endif
247
248 #ifdef DEBUGCHAP
249 #define CHAPDEBUG(x)    if (debug) syslog x
250 #else
251 #define CHAPDEBUG(x)
252 #endif
253
254 #ifndef SIGTYPE
255 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
256 #define SIGTYPE void
257 #else
258 #define SIGTYPE int
259 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
260 #endif /* SIGTYPE */
261
262 #ifndef MIN
263 #define MIN(a, b)       ((a) < (b)? (a): (b))
264 #endif
265 #ifndef MAX
266 #define MAX(a, b)       ((a) > (b)? (a): (b))
267 #endif
268
269 #endif /* __PPP_H__ */