diff options
Diffstat (limited to 'libexec/pppd/pppd.h')
| -rw-r--r-- | libexec/pppd/pppd.h | 345 |
1 files changed, 54 insertions, 291 deletions
diff --git a/libexec/pppd/pppd.h b/libexec/pppd/pppd.h index 2a114390e2c2..1cecd3555062 100644 --- a/libexec/pppd/pppd.h +++ b/libexec/pppd/pppd.h @@ -15,6 +15,8 @@ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id: pppd.h,v 1.3 1994/03/30 09:38:17 jkh Exp $ */ /* @@ -24,30 +26,41 @@ #ifndef __PPPD_H__ #define __PPPD_H__ #include "args.h" -#define NPPP 1 /* One PPP interface supported (per process) */ + +#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */ + +#define _NPPP 1 /* One PPP interface supported (per process) */ + +/* + * Limits. + */ +#define MAXWORDLEN 1024 /* max length of word in file (incl null) */ +#define MAXARGS 1 /* max # args to a command */ +#define MAXNAMELEN 256 /* max length of hostname or name for auth */ +#define MAXSECRETLEN 256 /* max length of password or secret */ extern int debug; /* Debug flag */ +extern int ifunit; /* Interface unit number */ extern char ifname[]; /* Interface name */ extern int fd; /* Device file descriptor */ extern int s; /* socket descriptor */ extern char hostname[]; /* hostname */ -extern u_char hostname_len; /* and its length */ extern u_char outpacket_buf[]; /* buffer for outgoing packets */ -#define MAX_HOSTNAME_LEN 128 /* should be 255 - MAX_CHALLENGE_LEN + 1 */ - -void quit __ARGS((void)); /* Cleanup and exit */ +void quit __ARGS((void)); /* Cleanup and exit */ void timeout __ARGS((void (*)(), caddr_t, int)); - /* Look-alike of kernel's timeout() */ + /* Look-alike of kernel's timeout() */ void untimeout __ARGS((void (*)(), caddr_t)); - /* Look-alike of kernel's untimeout() */ -void output __ARGS((int, u_char *, int)); /* Output a PPP packet */ -void demuxprotrej __ARGS((int, int)); /* Demultiplex a Protocol-Reject */ -u_char login __ARGS((char *, int, char *, int, char **, int *)); /* Login user */ -void logout __ARGS((void)); /* Logout user */ -void get_secret __ARGS((u_char *, u_char *, int *)); /* get "secret" for chap */ + /* Look-alike of kernel's untimeout() */ +void output __ARGS((int, u_char *, int)); + /* Output a PPP packet */ +void demuxprotrej __ARGS((int, int)); + /* Demultiplex a Protocol-Reject */ +int check_passwd __ARGS((int, char *, int, char *, int, char **, int *)); + /* Check peer-supplied username/password */ +int get_secret __ARGS((int, char *, char *, char *, int *, int)); + /* get "secret" for chap */ u_long GetMask __ARGS((u_long)); /* get netmask for address */ -extern int errno; /* @@ -93,293 +106,35 @@ extern int errno; * System dependent definitions for user-level 4.3BSD UNIX implementation. */ -#define DEMUXPROTREJ(u, p) demuxprotrej(u, p) +#define DEMUXPROTREJ(u, p) demuxprotrej(u, p) -#define TIMEOUT(r, f, t) timeout((r), (f), (t)) -#define UNTIMEOUT(r, f) untimeout((r), (f)) +#define TIMEOUT(r, f, t) timeout((r), (f), (t)) +#define UNTIMEOUT(r, f) untimeout((r), (f)) -#define BCOPY(s, d, l) bcopy(s, d, l) -#define EXIT(u) quit() +#define BCOPY(s, d, l) memcpy(d, s, l) +#define BZERO(s, n) memset(s, 0, n) +#define EXIT(u) quit() -#define GETUSERPASSWD(u) -#define LOGIN(n, u, ul, p, pl, m, ml) login(u, ul, p, pl, m, ml); -#define LOGOUT(n) logout() -#define GETSECRET(n, s, sl) get_secret(n, s, sl) #define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); } /* - * return a pointer to the beginning of the data part of a packet. - */ - -#define PACKET_DATA(p) (p + DLLHEADERLEN) - -/* - * MAKEHEADER - Add Header fields to a packet. (Should we do - * AC compression here?) + * MAKEHEADER - Add Header fields to a packet. */ #define MAKEHEADER(p, t) { \ PUTCHAR(ALLSTATIONS, p); \ PUTCHAR(UI, p); \ PUTSHORT(t, p); } -/* - * SIFASYNCMAP - Config the interface async map. - */ -#ifdef STREAMS -#define SIFASYNCMAP(u, a) { \ - u_long x = a; \ - if(ioctl(fd, SIOCSIFASYNCMAP, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFASYNCMAP): %m"); \ - } } -#else -#define SIFASYNCMAP(u, a) { \ - u_long x = a; \ - if (ioctl(fd, PPPIOCSASYNCMAP, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSASYNCMAP): %m"); \ - quit(); \ - } } -#endif - -/* - * SIFPCOMPRESSION - Config the interface for protocol compression. - */ -#ifdef STREAMS -#define SIFPCOMPRESSION(u) { \ - char c = 1; \ - if(ioctl(fd, SIOCSIFCOMPPROT, &c) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFCOMPPROT): %m"); \ - }} -#else -#define SIFPCOMPRESSION(u) { \ - u_int x; \ - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); \ - quit(); \ - } \ - x |= SC_COMP_PROT; \ - if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); \ - quit(); \ - } } -#endif - -/* - * CIFPCOMPRESSION - Config the interface for no protocol compression. - */ -#ifdef STREAMS -#define CIFPCOMPRESSION(u) { \ - char c = 0; \ - if(ioctl(fd, SIOCSIFCOMPPROT, &c) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFCOMPPROT): %m"); \ - quit(); \ - }} -#else -#define CIFPCOMPRESSION(u) { \ - u_int x; \ - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCGFLAGS): %m"); \ - quit(); \ - } \ - x &= ~SC_COMP_PROT; \ - if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); \ - quit(); \ - } } -#endif -/* - * SIFACCOMPRESSION - Config the interface for address/control compression. - */ -#ifdef STREAMS -#define SIFACCOMPRESSION(u) { \ - char c = 1; \ - if(ioctl(fd, SIOCSIFCOMPAC, &c) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFCOMPAC): %m"); \ - quit(); \ - }} -#else -#define SIFACCOMPRESSION(u) { \ - u_int x; \ - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); \ - quit(); \ - } \ - x |= SC_COMP_AC; \ - if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); \ - quit(); \ - } } -#endif - -/* - * CIFACCOMPRESSION - Config the interface for no address/control compression. - */ -#ifdef STREAMS -#define CIFACCOMPRESSION(u) { \ - char c = 0; \ - if(ioctl(fd, SIOCSIFCOMPAC, &c) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFCOMPAC): %m"); \ - quit(); \ - }} -#else -#define CIFACCOMPRESSION(u) { \ - u_int x; \ - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); \ - quit(); \ - } \ - x &= ~SC_COMP_AC; \ - if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); \ - quit(); \ - } } +#ifdef DEBUGALL +#define DEBUGMAIN 1 +#define DEBUGFSM 1 +#define DEBUGLCP 1 +#define DEBUGIPCP 1 +#define DEBUGUPAP 1 +#define DEBUGCHAP 1 #endif -/* - * SIFVJCOMP - config tcp header compression - */ -#ifdef STREAMS -#define SIFVJCOMP(u, a) { \ - char x = a; \ - if (debug) syslog(LOG_DEBUG, "SIFVJCOMP unit %d to value %d\n",u,x); \ - if(ioctl(fd, SIOCSIFVJCOMP, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFVJCOMP): %m"); \ - quit(); \ - } \ -} -#else -#define SIFVJCOMP(u, a) { \ - u_int x; \ - if (debug) \ - syslog(LOG_DEBUG, "PPPIOCSFLAGS unit %d set %s\n",u,a?"on":"off"); \ - if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m"); \ - quit(); \ - } \ - x = (x & ~SC_COMP_TCP) | ((a) ? SC_COMP_TCP : 0); \ - if(ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { \ - syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m"); \ - quit(); \ - } } -#endif - -/* - * SIFUP - Config the interface up. - */ -#define SIFUP(u) { \ - struct ifreq ifr; \ - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); \ - if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); \ - quit(); \ - } \ - ifr.ifr_flags |= IFF_UP; \ - if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); \ - quit(); \ - } } - -/* - * SIFDOWN - Config the interface down. - */ -#define SIFDOWN(u) { \ - struct ifreq ifr; \ - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); \ - if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); \ - quit(); \ - } \ - ifr.ifr_flags &= ~IFF_UP; \ - if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m"); \ - quit(); \ - } } - -/* - * SIFMTU - Config the interface MTU. - */ -#define SIFMTU(u, m) { \ - struct ifreq ifr; \ - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); \ - ifr.ifr_mtu = m; \ - if (ioctl(s, SIOCSIFMTU, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFMTU): %m"); \ - quit(); \ - } } - - -#ifdef __386BSD__ /* BSD >= 44 ? */ -#define SET_SA_FAMILY(addr, family) \ - bzero((char *) &(addr), sizeof(addr)); \ - addr.sa_family = (family); \ - addr.sa_len = sizeof(addr); -#else -#define SET_SA_FAMILY(addr, family) \ - bzero((char *) &(addr), sizeof(addr)); \ - addr.sa_family = (family); -#endif - -/* - * SIFADDR - Config the interface IP addresses. - */ -#define SIFADDR(u, o, h) { \ - struct ifreq ifr; \ - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); \ - SET_SA_FAMILY(ifr.ifr_addr, AF_INET); \ - ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o; \ - if (ioctl(s, SIOCSIFADDR, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFADDR): %m"); \ - } \ - ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = h; \ - if (ioctl(s, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFDSTADDR): %m"); \ - quit(); \ - } } - -/* - * CIFADDR - Clear the interface IP addresses. - */ -#if BSD > 43 -#define CIFADDR(u, o, h) { \ - struct ortentry rt; \ - SET_SA_FAMILY(rt.rt_dst, AF_INET); \ - ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h; \ - SET_SA_FAMILY(rt.rt_gateway, AF_INET); \ - ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o; \ - rt.rt_flags |= RTF_HOST; \ - syslog(LOG_INFO, "Deleting host route from %s to %s\n", \ - ip_ntoa(h), ip_ntoa(o)); \ - if (ioctl(s, SIOCDELRT, (caddr_t) &rt) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCDELRT): %m"); \ - } } -#else -#define CIFADDR(u, o, h) { \ - struct rtentry rt; \ - SET_SA_FAMILY(rt.rt_dst, AF_INET); \ - ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h; \ - SET_SA_FAMILY(rt.rt_gateway, AF_INET); \ - ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o; \ - rt.rt_flags |= RTF_HOST; \ - syslog(LOG_INFO, "Deleting host route from %s to %s\n", \ - ip_ntoa(h), ip_ntoa(o)); \ - if (ioctl(s, SIOCDELRT, (caddr_t) &rt) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCDELRT): %m"); \ - } } -#endif - -/* - * SIFMASK - Config the interface net mask - */ -#define SIFMASK(u, m) { \ - struct ifreq ifr; \ - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); \ - SET_SA_FAMILY(ifr.ifr_addr, AF_INET); \ - ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m; \ - syslog(LOG_INFO, "Setting interface mask to %s\n", ip_ntoa(m)); \ - if (ioctl(s, SIOCSIFNETMASK, (caddr_t) &ifr) < 0) { \ - syslog(LOG_ERR, "ioctl(SIOCSIFADDR): %m"); \ - } } - #ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */ #if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUG) \ || defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \ @@ -391,37 +146,37 @@ extern int errno; #endif /* LOG_PPP */ #ifdef DEBUGMAIN -#define MAINDEBUG(x) if (debug) syslog x; +#define MAINDEBUG(x) if (debug) syslog x #else #define MAINDEBUG(x) #endif #ifdef DEBUGFSM -#define FSMDEBUG(x) if (debug) syslog x; +#define FSMDEBUG(x) if (debug) syslog x #else #define FSMDEBUG(x) #endif #ifdef DEBUGLCP -#define LCPDEBUG(x) if (debug) syslog x; +#define LCPDEBUG(x) if (debug) syslog x #else #define LCPDEBUG(x) #endif #ifdef DEBUGIPCP -#define IPCPDEBUG(x) if (debug) syslog x; +#define IPCPDEBUG(x) if (debug) syslog x #else #define IPCPDEBUG(x) #endif #ifdef DEBUGUPAP -#define UPAPDEBUG(x) if (debug) syslog x; +#define UPAPDEBUG(x) if (debug) syslog x #else #define UPAPDEBUG(x) #endif #ifdef DEBUGCHAP -#define CHAPDEBUG(x) if (debug) syslog x; +#define CHAPDEBUG(x) if (debug) syslog x #else #define CHAPDEBUG(x) #endif @@ -433,4 +188,12 @@ extern int errno; #define SIGTYPE int #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */ #endif /* SIGTYPE */ + +#ifndef MIN +#define MIN(a, b) ((a) < (b)? (a): (b)) +#endif +#ifndef MAX +#define MAX(a, b) ((a) > (b)? (a): (b)) +#endif + #endif /* __PPP_H__ */ |
