]> git.ozlabs.org Git - ppp.git/blob - pppd/pppd.h
add hdrlen stuff
[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.6 1994/10/24 04:31:11 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 int      s;              /* Socket descriptor */
53 extern char     hostname[];     /* Our hostname */
54 extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
55 extern int      phase;          /* Current state of link - see values below */
56 extern int      baud_rate;      /* Current link speed in bits/sec */
57 extern char     *progname;      /* Name of this program */
58
59 /*
60  * Variables set by command-line options.
61  */
62
63 extern int      debug;          /* Debug flag */
64 extern int      kdebugflag;     /* Tell kernel to print debug messages */
65 extern int      default_device; /* Using /dev/tty or equivalent */
66 extern char     devnam[];       /* Device name */
67 extern int      crtscts;        /* Use hardware flow control */
68 extern int      modem;          /* Use modem control lines */
69 extern int      inspeed;        /* Input/Output speed requested */
70 extern u_int32_t netmask;       /* IP netmask to set on interface */
71 extern int      lockflag;       /* Create lock file to lock the serial dev */
72 extern int      nodetach;       /* Don't detach from controlling tty */
73 extern char     *connector;     /* Script to establish physical link */
74 extern char     *disconnector;  /* Script to disestablish physical link */
75 extern char     user[];         /* Username for PAP */
76 extern char     passwd[];       /* Password for PAP */
77 extern int      auth_required;  /* Peer is required to authenticate */
78 extern int      proxyarp;       /* Set up proxy ARP entry for peer */
79 extern int      persist;        /* Reopen link after it goes down */
80 extern int      uselogin;       /* Use /etc/passwd for checking PAP */
81 extern int      lcp_echo_interval; /* Interval between LCP echo-requests */
82 extern int      lcp_echo_fails; /* Tolerance to unanswered echo-requests */
83 extern char     our_name[];     /* Our name for authentication purposes */
84 extern char     remote_name[];  /* Peer's name for authentication */
85 extern int      usehostname;    /* Use hostname for our_name */
86 extern int      disable_defaultip; /* Don't use hostname for default IP adrs */
87
88 /*
89  * Values for phase.
90  */
91 #define PHASE_DEAD              0
92 #define PHASE_ESTABLISH         1
93 #define PHASE_AUTHENTICATE      2
94 #define PHASE_NETWORK           3
95 #define PHASE_TERMINATE         4
96
97 /*
98  * Prototypes.
99  */
100 void quit __P((void));  /* Cleanup and exit */
101 void timeout __P((void (*)(), caddr_t, int));
102                                 /* Look-alike of kernel's timeout() */
103 void untimeout __P((void (*)(), caddr_t));
104                                 /* Look-alike of kernel's untimeout() */
105 void output __P((int, u_char *, int));
106                                 /* Output a PPP packet */
107 void demuxprotrej __P((int, int));
108                                 /* Demultiplex a Protocol-Reject */
109 int  check_passwd __P((int, char *, int, char *, int, char **, int *));
110                                 /* Check peer-supplied username/password */
111 int  get_secret __P((int, char *, char *, char *, int *, int));
112                                 /* get "secret" for chap */
113 u_int32_t GetMask __P((u_int32_t)); /* get netmask for address */
114 void die __P((int));
115
116 /*
117  * Inline versions of get/put char/short/long.
118  * Pointer is advanced; we assume that both arguments
119  * are lvalues and will already be in registers.
120  * cp MUST be u_char *.
121  */
122 #define GETCHAR(c, cp) { \
123         (c) = *(cp)++; \
124 }
125 #define PUTCHAR(c, cp) { \
126         *(cp)++ = (u_char) (c); \
127 }
128
129
130 #define GETSHORT(s, cp) { \
131         (s) = *(cp)++ << 8; \
132         (s) |= *(cp)++; \
133 }
134 #define PUTSHORT(s, cp) { \
135         *(cp)++ = (u_char) ((s) >> 8); \
136         *(cp)++ = (u_char) (s); \
137 }
138
139 #define GETLONG(l, cp) { \
140         (l) = *(cp)++ << 8; \
141         (l) |= *(cp)++; (l) <<= 8; \
142         (l) |= *(cp)++; (l) <<= 8; \
143         (l) |= *(cp)++; \
144 }
145 #define PUTLONG(l, cp) { \
146         *(cp)++ = (u_char) ((l) >> 24); \
147         *(cp)++ = (u_char) ((l) >> 16); \
148         *(cp)++ = (u_char) ((l) >> 8); \
149         *(cp)++ = (u_char) (l); \
150 }
151
152 #define INCPTR(n, cp)   ((cp) += (n))
153 #define DECPTR(n, cp)   ((cp) -= (n))
154
155 #define FALSE   0
156 #define TRUE    1
157
158 /*
159  * System dependent definitions for user-level 4.3BSD UNIX implementation.
160  */
161
162 #define DEMUXPROTREJ(u, p)      demuxprotrej(u, p)
163
164 #define TIMEOUT(r, f, t)        timeout((r), (f), (t))
165 #define UNTIMEOUT(r, f)         untimeout((r), (f))
166
167 #define BCOPY(s, d, l)          memcpy(d, s, l)
168 #define BZERO(s, n)             memset(s, 0, n)
169 #define EXIT(u)                 quit()
170
171 #define PRINTMSG(m, l)  { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
172
173 /*
174  * MAKEHEADER - Add Header fields to a packet.
175  */
176 #define MAKEHEADER(p, t) { \
177     PUTCHAR(PPP_ALLSTATIONS, p); \
178     PUTCHAR(PPP_UI, p); \
179     PUTSHORT(t, p); }
180
181
182 #ifdef DEBUGALL
183 #define DEBUGMAIN       1
184 #define DEBUGFSM        1
185 #define DEBUGLCP        1
186 #define DEBUGIPCP       1
187 #define DEBUGUPAP       1
188 #define DEBUGCHAP       1
189 #endif
190
191 #ifndef LOG_PPP                 /* we use LOG_LOCAL2 for syslog by default */
192 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \
193   || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
194   || defined(DEBUGCHAP) 
195 #define LOG_PPP LOG_LOCAL2
196 #else
197 #define LOG_PPP LOG_DAEMON
198 #endif
199 #endif /* LOG_PPP */
200
201 #ifdef DEBUGMAIN
202 #define MAINDEBUG(x)    if (debug) syslog x
203 #else
204 #define MAINDEBUG(x)
205 #endif
206
207 #ifdef DEBUGFSM
208 #define FSMDEBUG(x)     if (debug) syslog x
209 #else
210 #define FSMDEBUG(x)
211 #endif
212
213 #ifdef DEBUGLCP
214 #define LCPDEBUG(x)     if (debug) syslog x
215 #else
216 #define LCPDEBUG(x)
217 #endif
218
219 #ifdef DEBUGIPCP
220 #define IPCPDEBUG(x)    if (debug) syslog x
221 #else
222 #define IPCPDEBUG(x)
223 #endif
224
225 #ifdef DEBUGUPAP
226 #define UPAPDEBUG(x)    if (debug) syslog x
227 #else
228 #define UPAPDEBUG(x)
229 #endif
230
231 #ifdef DEBUGCHAP
232 #define CHAPDEBUG(x)    if (debug) syslog x
233 #else
234 #define CHAPDEBUG(x)
235 #endif
236
237 #ifndef SIGTYPE
238 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
239 #define SIGTYPE void
240 #else
241 #define SIGTYPE int
242 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
243 #endif /* SIGTYPE */
244
245 #ifndef MIN
246 #define MIN(a, b)       ((a) < (b)? (a): (b))
247 #endif
248 #ifndef MAX
249 #define MAX(a, b)       ((a) > (b)? (a): (b))
250 #endif
251
252 #endif /* __PPP_H__ */