]> git.ozlabs.org Git - ppp.git/blob - pppd/pppd.h
patch to proxyarp stuff from Michael Callahan
[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.3 1994/05/26 06:43:42 paulus Exp $
20  */
21
22 /*
23  * TODO:
24  */
25
26 #ifndef __PPPD_H__
27 #define __PPPD_H__
28 #include "args.h"
29
30 #include <sys/param.h>          /* for MAXPATHLEN and BSD4_4, if defined */
31
32 #define NPPP    1               /* One PPP interface supported (per process) */
33
34 /*
35  * Limits.
36  */
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 */
41
42 /*
43  * Global variables.
44  */
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 */
53
54 /*
55  * Values for phase.
56  */
57 #define PHASE_DEAD              0
58 #define PHASE_ESTABLISH         1
59 #define PHASE_AUTHENTICATE      2
60 #define PHASE_NETWORK           3
61 #define PHASE_TERMINATE         4
62
63 /*
64  * Prototypes.
65  */
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 */
80
81
82 /*
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 *.
87  */
88 #define GETCHAR(c, cp) { \
89         (c) = *(cp)++; \
90 }
91 #define PUTCHAR(c, cp) { \
92         *(cp)++ = (u_char) (c); \
93 }
94
95
96 #define GETSHORT(s, cp) { \
97         (s) = *(cp)++ << 8; \
98         (s) |= *(cp)++; \
99 }
100 #define PUTSHORT(s, cp) { \
101         *(cp)++ = (u_char) ((s) >> 8); \
102         *(cp)++ = (u_char) (s); \
103 }
104
105 #define GETLONG(l, cp) { \
106         (l) = *(cp)++ << 8; \
107         (l) |= *(cp)++; (l) <<= 8; \
108         (l) |= *(cp)++; (l) <<= 8; \
109         (l) |= *(cp)++; \
110 }
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); \
116 }
117
118 #define INCPTR(n, cp)   ((cp) += (n))
119 #define DECPTR(n, cp)   ((cp) -= (n))
120
121 /*
122  * System dependent definitions for user-level 4.3BSD UNIX implementation.
123  */
124
125 #define DEMUXPROTREJ(u, p)      demuxprotrej(u, p)
126
127 #define TIMEOUT(r, f, t)        timeout((r), (f), (t))
128 #define UNTIMEOUT(r, f)         untimeout((r), (f))
129
130 #define BCOPY(s, d, l)          memcpy(d, s, l)
131 #define BZERO(s, n)             memset(s, 0, n)
132 #define EXIT(u)                 quit()
133
134 #define PRINTMSG(m, l)  { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
135
136 /*
137  * MAKEHEADER - Add Header fields to a packet.
138  */
139 #define MAKEHEADER(p, t) { \
140     PUTCHAR(ALLSTATIONS, p); \
141     PUTCHAR(UI, p); \
142     PUTSHORT(t, p); }
143
144
145 #ifdef DEBUGALL
146 #define DEBUGMAIN       1
147 #define DEBUGFSM        1
148 #define DEBUGLCP        1
149 #define DEBUGIPCP       1
150 #define DEBUGUPAP       1
151 #define DEBUGCHAP       1
152 #endif
153
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
159 #else
160 #define LOG_PPP LOG_DAEMON
161 #endif
162 #endif /* LOG_PPP */
163
164 #ifdef DEBUGMAIN
165 #define MAINDEBUG(x)    if (debug) syslog x
166 #else
167 #define MAINDEBUG(x)
168 #endif
169
170 #ifdef DEBUGFSM
171 #define FSMDEBUG(x)     if (debug) syslog x
172 #else
173 #define FSMDEBUG(x)
174 #endif
175
176 #ifdef DEBUGLCP
177 #define LCPDEBUG(x)     if (debug) syslog x
178 #else
179 #define LCPDEBUG(x)
180 #endif
181
182 #ifdef DEBUGIPCP
183 #define IPCPDEBUG(x)    if (debug) syslog x
184 #else
185 #define IPCPDEBUG(x)
186 #endif
187
188 #ifdef DEBUGUPAP
189 #define UPAPDEBUG(x)    if (debug) syslog x
190 #else
191 #define UPAPDEBUG(x)
192 #endif
193
194 #ifdef DEBUGCHAP
195 #define CHAPDEBUG(x)    if (debug) syslog x
196 #else
197 #define CHAPDEBUG(x)
198 #endif
199
200 #ifndef SIGTYPE
201 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
202 #define SIGTYPE void
203 #else
204 #define SIGTYPE int
205 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
206 #endif /* SIGTYPE */
207
208 #ifndef MIN
209 #define MIN(a, b)       ((a) < (b)? (a): (b))
210 #endif
211 #ifndef MAX
212 #define MAX(a, b)       ((a) > (b)? (a): (b))
213 #endif
214
215 #endif /* __PPP_H__ */