syscons util remove use kbdcontrol & vidcontrol instead
[unix-history] / libexec / pppd / pppd.h
CommitLineData
2a905848
RG
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.
f381ea37 18 *
bca32771 19 * $Id: pppd.h,v 1.2 1994/03/30 09:31:41 jkh Exp $
2a905848
RG
20 */
21
22/*
23 * TODO:
24 */
25
26#ifndef __PPPD_H__
27#define __PPPD_H__
28#include "args.h"
f381ea37
JH
29
30#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
31
bca32771 32#define _NPPP 1 /* One PPP interface supported (per process) */
2a905848 33
f381ea37
JH
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
2a905848 42extern int debug; /* Debug flag */
f381ea37 43extern int ifunit; /* Interface unit number */
2a905848
RG
44extern char ifname[]; /* Interface name */
45extern int fd; /* Device file descriptor */
46extern int s; /* socket descriptor */
47extern char hostname[]; /* hostname */
2a905848
RG
48extern u_char outpacket_buf[]; /* buffer for outgoing packets */
49
f381ea37 50void quit __ARGS((void)); /* Cleanup and exit */
2a905848 51void timeout __ARGS((void (*)(), caddr_t, int));
f381ea37 52 /* Look-alike of kernel's timeout() */
2a905848 53void untimeout __ARGS((void (*)(), caddr_t));
f381ea37
JH
54 /* Look-alike of kernel's untimeout() */
55void output __ARGS((int, u_char *, int));
56 /* Output a PPP packet */
57void demuxprotrej __ARGS((int, int));
58 /* Demultiplex a Protocol-Reject */
59int check_passwd __ARGS((int, char *, int, char *, int, char **, int *));
60 /* Check peer-supplied username/password */
61int get_secret __ARGS((int, char *, char *, char *, int *, int));
62 /* get "secret" for chap */
2a905848 63u_long GetMask __ARGS((u_long)); /* get netmask for address */
2a905848
RG
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
f381ea37 109#define DEMUXPROTREJ(u, p) demuxprotrej(u, p)
2a905848 110
f381ea37
JH
111#define TIMEOUT(r, f, t) timeout((r), (f), (t))
112#define UNTIMEOUT(r, f) untimeout((r), (f))
2a905848 113
f381ea37
JH
114#define BCOPY(s, d, l) memcpy(d, s, l)
115#define BZERO(s, n) memset(s, 0, n)
116#define EXIT(u) quit()
2a905848 117
2a905848
RG
118#define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); }
119
120/*
f381ea37 121 * MAKEHEADER - Add Header fields to a packet.
2a905848
RG
122 */
123#define MAKEHEADER(p, t) { \
124 PUTCHAR(ALLSTATIONS, p); \
125 PUTCHAR(UI, p); \
126 PUTSHORT(t, p); }
127
2a905848 128
f381ea37
JH
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
2a905848
RG
136#endif
137
2a905848
RG
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
f381ea37 149#define MAINDEBUG(x) if (debug) syslog x
2a905848
RG
150#else
151#define MAINDEBUG(x)
152#endif
153
154#ifdef DEBUGFSM
f381ea37 155#define FSMDEBUG(x) if (debug) syslog x
2a905848
RG
156#else
157#define FSMDEBUG(x)
158#endif
159
160#ifdef DEBUGLCP
f381ea37 161#define LCPDEBUG(x) if (debug) syslog x
2a905848
RG
162#else
163#define LCPDEBUG(x)
164#endif
165
166#ifdef DEBUGIPCP
f381ea37 167#define IPCPDEBUG(x) if (debug) syslog x
2a905848
RG
168#else
169#define IPCPDEBUG(x)
170#endif
171
172#ifdef DEBUGUPAP
f381ea37 173#define UPAPDEBUG(x) if (debug) syslog x
2a905848
RG
174#else
175#define UPAPDEBUG(x)
176#endif
177
178#ifdef DEBUGCHAP
f381ea37 179#define CHAPDEBUG(x) if (debug) syslog x
2a905848
RG
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 */
f381ea37
JH
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
2a905848 199#endif /* __PPP_H__ */