]> git.ozlabs.org Git - ppp.git/blob - pppd/pppd.h
added ppp_available
[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.1 1993/11/11 03:54:25 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 extern int debug;               /* Debug flag */
43 extern int ifunit;              /* Interface unit number */
44 extern char ifname[];           /* Interface name */
45 extern int fd;                  /* Device file descriptor */
46 extern int s;                   /* socket descriptor */
47 extern char hostname[];         /* hostname */
48 extern u_char outpacket_buf[];  /* buffer for outgoing packets */
49
50 void quit __ARGS((void));       /* Cleanup and exit */
51 void timeout __ARGS((void (*)(), caddr_t, int));
52                                 /* Look-alike of kernel's timeout() */
53 void untimeout __ARGS((void (*)(), caddr_t));
54                                 /* Look-alike of kernel's untimeout() */
55 void output __ARGS((int, u_char *, int));
56                                 /* Output a PPP packet */
57 void demuxprotrej __ARGS((int, int));
58                                 /* Demultiplex a Protocol-Reject */
59 int  check_passwd __ARGS((int, char *, int, char *, int, char **, int *));
60                                 /* Check peer-supplied username/password */
61 int  get_secret __ARGS((int, char *, char *, char *, int *, int));
62                                 /* get "secret" for chap */
63 u_long GetMask __ARGS((u_long)); /* get netmask for address */
64
65
66 /*
67  * Inline versions of get/put char/short/long.
68  * Pointer is advanced; we assume that both arguments
69  * are lvalues and will already be in registers.
70  * cp MUST be u_char *.
71  */
72 #define GETCHAR(c, cp) { \
73         (c) = *(cp)++; \
74 }
75 #define PUTCHAR(c, cp) { \
76         *(cp)++ = (c); \
77 }
78
79
80 #define GETSHORT(s, cp) { \
81         (s) = *(cp)++ << 8; \
82         (s) |= *(cp)++; \
83 }
84 #define PUTSHORT(s, cp) { \
85         *(cp)++ = (s) >> 8; \
86         *(cp)++ = (s); \
87 }
88
89 #define GETLONG(l, cp) { \
90         (l) = *(cp)++ << 8; \
91         (l) |= *(cp)++; (l) <<= 8; \
92         (l) |= *(cp)++; (l) <<= 8; \
93         (l) |= *(cp)++; \
94 }
95 #define PUTLONG(l, cp) { \
96         *(cp)++ = (l) >> 24; \
97         *(cp)++ = (l) >> 16; \
98         *(cp)++ = (l) >> 8; \
99         *(cp)++ = (l); \
100 }
101
102 #define INCPTR(n, cp)   ((cp) += (n))
103 #define DECPTR(n, cp)   ((cp) -= (n))
104
105 /*
106  * System dependent definitions for user-level 4.3BSD UNIX implementation.
107  */
108
109 #define DEMUXPROTREJ(u, p)      demuxprotrej(u, p)
110
111 #define TIMEOUT(r, f, t)        timeout((r), (f), (t))
112 #define UNTIMEOUT(r, f)         untimeout((r), (f))
113
114 #define BCOPY(s, d, l)          memcpy(d, s, l)
115 #define BZERO(s, n)             memset(s, 0, n)
116 #define EXIT(u)                 quit()
117
118 #define PRINTMSG(m, l)  { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
119
120 /*
121  * MAKEHEADER - Add Header fields to a packet.
122  */
123 #define MAKEHEADER(p, t) { \
124     PUTCHAR(ALLSTATIONS, p); \
125     PUTCHAR(UI, p); \
126     PUTSHORT(t, p); }
127
128
129 #ifdef DEBUGALL
130 #define DEBUGMAIN       1
131 #define DEBUGFSM        1
132 #define DEBUGLCP        1
133 #define DEBUGIPCP       1
134 #define DEBUGUPAP       1
135 #define DEBUGCHAP       1
136 #endif
137
138 #ifndef LOG_PPP                 /* we use LOG_LOCAL2 for syslog by default */
139 #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \
140   || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
141   || defined(DEBUGCHAP) 
142 #define LOG_PPP LOG_LOCAL2
143 #else
144 #define LOG_PPP LOG_DAEMON
145 #endif
146 #endif /* LOG_PPP */
147
148 #ifdef DEBUGMAIN
149 #define MAINDEBUG(x)    if (debug) syslog x
150 #else
151 #define MAINDEBUG(x)
152 #endif
153
154 #ifdef DEBUGFSM
155 #define FSMDEBUG(x)     if (debug) syslog x
156 #else
157 #define FSMDEBUG(x)
158 #endif
159
160 #ifdef DEBUGLCP
161 #define LCPDEBUG(x)     if (debug) syslog x
162 #else
163 #define LCPDEBUG(x)
164 #endif
165
166 #ifdef DEBUGIPCP
167 #define IPCPDEBUG(x)    if (debug) syslog x
168 #else
169 #define IPCPDEBUG(x)
170 #endif
171
172 #ifdef DEBUGUPAP
173 #define UPAPDEBUG(x)    if (debug) syslog x
174 #else
175 #define UPAPDEBUG(x)
176 #endif
177
178 #ifdef DEBUGCHAP
179 #define CHAPDEBUG(x)    if (debug) syslog x
180 #else
181 #define CHAPDEBUG(x)
182 #endif
183
184 #ifndef SIGTYPE
185 #if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
186 #define SIGTYPE void
187 #else
188 #define SIGTYPE int
189 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
190 #endif /* SIGTYPE */
191
192 #ifndef MIN
193 #define MIN(a, b)       ((a) < (b)? (a): (b))
194 #endif
195 #ifndef MAX
196 #define MAX(a, b)       ((a) > (b)? (a): (b))
197 #endif
198
199 #endif /* __PPP_H__ */