summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ppp/Makefile4
-rw-r--r--usr.sbin/ppp/ppp/arp.c68
-rw-r--r--usr.sbin/ppp/ppp/bundle.c10
-rw-r--r--usr.sbin/ppp/ppp/bundle.h8
-rw-r--r--usr.sbin/ppp/ppp/cbcp.c6
-rw-r--r--usr.sbin/ppp/ppp/ccp.c59
-rw-r--r--usr.sbin/ppp/ppp/chap.c10
-rw-r--r--usr.sbin/ppp/ppp/chap.h4
-rw-r--r--usr.sbin/ppp/ppp/chat.c10
-rw-r--r--usr.sbin/ppp/ppp/chat.h4
-rw-r--r--usr.sbin/ppp/ppp/command.c13
-rw-r--r--usr.sbin/ppp/ppp/datalink.c10
-rw-r--r--usr.sbin/ppp/ppp/datalink.h4
-rw-r--r--usr.sbin/ppp/ppp/defs.c29
-rw-r--r--usr.sbin/ppp/ppp/defs.h6
-rw-r--r--usr.sbin/ppp/ppp/descriptor.h12
-rw-r--r--usr.sbin/ppp/ppp/ether.c8
-rw-r--r--usr.sbin/ppp/ppp/iface.c70
-rw-r--r--usr.sbin/ppp/ppp/iface.h5
-rw-r--r--usr.sbin/ppp/ppp/ip.c147
-rw-r--r--usr.sbin/ppp/ppp/ipcp.c56
-rw-r--r--usr.sbin/ppp/ppp/lcp.c73
-rw-r--r--usr.sbin/ppp/ppp/log.c3
-rw-r--r--usr.sbin/ppp/ppp/log.h36
-rw-r--r--usr.sbin/ppp/ppp/main.c11
-rw-r--r--usr.sbin/ppp/ppp/mp.c10
-rw-r--r--usr.sbin/ppp/ppp/mp.h4
-rw-r--r--usr.sbin/ppp/ppp/nat_cmd.c9
-rw-r--r--usr.sbin/ppp/ppp/physical.c14
-rw-r--r--usr.sbin/ppp/ppp/physical.h10
-rw-r--r--usr.sbin/ppp/ppp/ppp.84
-rw-r--r--usr.sbin/ppp/ppp/prompt.c10
-rw-r--r--usr.sbin/ppp/ppp/prompt.h4
-rw-r--r--usr.sbin/ppp/ppp/radius.c25
-rw-r--r--usr.sbin/ppp/ppp/radius.h4
-rw-r--r--usr.sbin/ppp/ppp/route.c197
-rw-r--r--usr.sbin/ppp/ppp/route.h5
-rw-r--r--usr.sbin/ppp/ppp/server.c12
-rw-r--r--usr.sbin/ppp/ppp/server.h4
-rw-r--r--usr.sbin/ppp/ppp/timer.c30
40 files changed, 632 insertions, 376 deletions
diff --git a/usr.sbin/ppp/ppp/Makefile b/usr.sbin/ppp/ppp/Makefile
index 102f6af9e9f..d3237831a9d 100644
--- a/usr.sbin/ppp/ppp/Makefile
+++ b/usr.sbin/ppp/ppp/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.12 2000/01/07 03:26:52 brian Exp $
+# $Id: Makefile,v 1.13 2000/02/27 00:21:05 brian Exp $
PROG= ppp
SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
@@ -9,7 +9,7 @@ SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
pap.c physical.c pred.c probe.c prompt.c proto.c radius.c radlib.c \
route.c server.c sig.c slcompress.c systems.c sync.c tcp.c \
throughput.c timer.c tty.c tun.c udp.c vjcomp.c
-CFLAGS+=-Wall -DHAVE_DES -DNO_FW_PUNCH -DNOI4B -DNONETGRAPH
+CFLAGS+=-Wall -DHAVE_DES -DNO_FW_PUNCH -DNOI4B -DNONETGRAPH -DLOCALNAT -DLOCALRAD
LDADD+= -ldes -lutil -lz
DPADD+= ${LIBDES} ${LIBUTIL} ${LIBZ}
BINMODE=4554
diff --git a/usr.sbin/ppp/ppp/arp.c b/usr.sbin/ppp/ppp/arp.c
index 9d2f4e37a1d..f85509aa883 100644
--- a/usr.sbin/ppp/ppp/arp.c
+++ b/usr.sbin/ppp/ppp/arp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: arp.c,v 1.5 1999/05/08 11:06:33 brian Exp $
+ * $Id: arp.c,v 1.6 2000/02/27 00:21:05 brian Exp $
*
*/
@@ -68,6 +68,7 @@
#include "radius.h"
#endif
#include "bundle.h"
+#include "iface.h"
#include "arp.h"
/*
@@ -225,14 +226,13 @@ arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
int
get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
{
- int mib[6], sa_len, skip, b;
+ int mib[6], skip;
size_t needed;
char *buf, *ptr, *end;
struct if_msghdr *ifm;
struct ifa_msghdr *ifam;
- struct sockaddr *sa;
struct sockaddr_dl *dl;
- struct sockaddr_in *ifa, *mask;
+ struct sockaddr *sa[RTAX_MAX];
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -269,7 +269,6 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
ifam = (struct ifa_msghdr *)ptr; /* Next ifa_msghdr (alias) */
if (ifam->ifam_type != RTM_NEWADDR) /* finished ? */
break;
- sa = (struct sockaddr *)(ifam+1); /* pile of sa's at end */
ptr += ifam->ifam_msglen;
if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) !=
(RTA_NETMASK|RTA_IFA))
@@ -279,43 +278,32 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen)
log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n",
dl->sdl_nlen, dl->sdl_data);
- b = 1;
- ifa = mask = NULL;
- while (b < (RTA_NETMASK|RTA_IFA) && sa < (struct sockaddr *)ptr) {
- switch (b) {
- case RTA_IFA:
- ifa = (struct sockaddr_in *)sa;
- break;
- case RTA_NETMASK:
- /*
- * Careful here ! this sockaddr doesn't have sa_family set to
- * AF_INET, and is only 8 bytes big ! I have no idea why !
- */
- mask = (struct sockaddr_in *)sa;
- break;
+
+ iface_ParseHdr(ifam, sa);
+
+ if (sa[RTAX_IFA]->sa_family == AF_INET) {
+ struct sockaddr_in *ifa, *netmask;
+
+ ifa = (struct sockaddr_in *)sa[RTAX_IFA];
+ netmask = (struct sockaddr_in *)sa[RTAX_NETMASK];
+
+ if (log_IsKept(LogDEBUG)) {
+ char a[16];
+
+ strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1);
+ a[sizeof a - 1] = '\0';
+ log_Printf(LogDEBUG, "Check addr %s, mask %s\n",
+ inet_ntoa(ifa->sin_addr), a);
}
- if (ifam->ifam_addrs & b) {
-#define ALN sizeof(ifa->sin_addr.s_addr)
- sa_len = sa->sa_len > 0 ? ((sa->sa_len-1)|(ALN-1))+1 : ALN;
- sa = (struct sockaddr *)((char *)sa + sa_len);
+
+ if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) ==
+ (ipaddr.s_addr & netmask->sin_addr.s_addr)) {
+ log_Printf(LogPHASE, "Found interface %.*s for %s\n",
+ dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
+ memcpy(hwaddr, dl, dl->sdl_len);
+ free(buf);
+ return 1;
}
- b <<= 1;
- }
- if (log_IsKept(LogDEBUG)) {
- char a[16];
- strncpy(a, inet_ntoa(mask->sin_addr), sizeof a - 1);
- a[sizeof a - 1] = '\0';
- log_Printf(LogDEBUG, "Check addr %s, mask %s\n",
- inet_ntoa(ifa->sin_addr), a);
- }
- if (ifa->sin_family == AF_INET &&
- (ifa->sin_addr.s_addr & mask->sin_addr.s_addr) ==
- (ipaddr.s_addr & mask->sin_addr.s_addr)) {
- log_Printf(LogPHASE, "Found interface %.*s for %s\n",
- dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
- memcpy(hwaddr, dl, dl->sdl_len);
- free(buf);
- return 1;
}
}
}
diff --git a/usr.sbin/ppp/ppp/bundle.c b/usr.sbin/ppp/ppp/bundle.c
index 920fab01a42..1e2620c80ec 100644
--- a/usr.sbin/ppp/ppp/bundle.c
+++ b/usr.sbin/ppp/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.27 2000/01/07 03:26:53 brian Exp $
+ * $Id: bundle.c,v 1.28 2000/02/27 00:21:05 brian Exp $
*/
#include <sys/param.h>
@@ -426,7 +426,7 @@ bundle_FillQueues(struct bundle *bundle)
}
static int
-bundle_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+bundle_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct bundle *bundle = descriptor2bundle(d);
struct datalink *dl;
@@ -483,7 +483,7 @@ bundle_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-bundle_IsSet(struct descriptor *d, const fd_set *fdset)
+bundle_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct bundle *bundle = descriptor2bundle(d);
struct datalink *dl;
@@ -504,7 +504,7 @@ bundle_IsSet(struct descriptor *d, const fd_set *fdset)
}
static void
-bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
+bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
const fd_set *fdset)
{
struct datalink *dl;
@@ -584,7 +584,7 @@ bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
}
static int
-bundle_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
+bundle_DescriptorWrite(struct fdescriptor *d, struct bundle *bundle,
const fd_set *fdset)
{
struct datalink *dl;
diff --git a/usr.sbin/ppp/ppp/bundle.h b/usr.sbin/ppp/ppp/bundle.h
index 9c45dac23eb..cbd618ebcd5 100644
--- a/usr.sbin/ppp/ppp/bundle.h
+++ b/usr.sbin/ppp/ppp/bundle.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.h,v 1.9 2000/01/07 03:26:53 brian Exp $
+ * $Id: bundle.h,v 1.10 2000/02/27 00:21:06 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@@ -61,7 +61,7 @@ struct prompt;
struct iface;
struct bundle {
- struct descriptor desc; /* really all our datalinks */
+ struct fdescriptor desc; /* really all our datalinks */
int unit; /* The device/interface unit number */
struct {
@@ -161,8 +161,8 @@ extern void bundle_StopIdleTimer(struct bundle *);
extern int bundle_IsDead(struct bundle *);
extern struct datalink *bundle2datalink(struct bundle *, const char *);
-extern void bundle_RegisterDescriptor(struct bundle *, struct descriptor *);
-extern void bundle_UnRegisterDescriptor(struct bundle *, struct descriptor *);
+extern void bundle_RegisterDescriptor(struct bundle *, struct fdescriptor *);
+extern void bundle_UnRegisterDescriptor(struct bundle *, struct fdescriptor *);
extern void bundle_SetTtyCommandMode(struct bundle *, struct datalink *);
diff --git a/usr.sbin/ppp/ppp/cbcp.c b/usr.sbin/ppp/ppp/cbcp.c
index c3d7c06f281..6b8bd572220 100644
--- a/usr.sbin/ppp/ppp/cbcp.c
+++ b/usr.sbin/ppp/ppp/cbcp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cbcp.c,v 1.11 2000/01/07 03:26:53 brian Exp $
+ * $Id: cbcp.c,v 1.12 2000/02/27 00:21:06 brian Exp $
*/
#include <sys/param.h>
@@ -151,7 +151,7 @@ cbcpstate(int s)
{
if (s < sizeof cbcpname / sizeof cbcpname[0])
return cbcpname[s];
- return "???";
+ return HexStr(s, NULL, 0);
}
static void
@@ -214,7 +214,7 @@ cbcp_data_Type(int type)
};
if (type < 1 || type > sizeof types / sizeof types[0])
- return "???";
+ return HexStr(type, NULL, 0);
return types[type-1];
}
diff --git a/usr.sbin/ppp/ppp/ccp.c b/usr.sbin/ppp/ppp/ccp.c
index 1b533b252e5..55bf070b414 100644
--- a/usr.sbin/ppp/ppp/ccp.c
+++ b/usr.sbin/ppp/ppp/ccp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ccp.c,v 1.11 2000/01/07 03:26:53 brian Exp $
+ * $Id: ccp.c,v 1.12 2000/02/27 00:21:06 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -93,35 +93,35 @@ static struct fsm_callbacks ccp_Callbacks = {
static const char * const ccp_TimerNames[] =
{"CCP restart", "CCP openmode", "CCP stopped"};
-static char const * const cftypes[] = {
- /* Check out the latest ``Compression Control Protocol'' rfc (rfc1962.txt) */
- "OUI", /* 0: OUI */
- "PRED1", /* 1: Predictor type 1 */
- "PRED2", /* 2: Predictor type 2 */
- "PUDDLE", /* 3: Puddle Jumber */
- "???", "???", "???", "???", "???", "???",
- "???", "???", "???", "???", "???", "???",
- "HWPPC", /* 16: Hewlett-Packard PPC */
- "STAC", /* 17: Stac Electronics LZS (rfc1974) */
- "MPPC", /* 18: Microsoft PPC (rfc2118) */
- "GAND", /* 19: Gandalf FZA (rfc1993) */
- "V42BIS", /* 20: ARG->DATA.42bis compression */
- "BSD", /* 21: BSD LZW Compress */
- "???",
- "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
- "MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */
- /* 24: Deflate (according to pppd-2.3.*) */
- "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
- "DEFLATE", /* 26: Deflate (rfc1979) */
-};
-
-#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
-
static const char *
protoname(int proto)
{
- if (proto < 0 || proto > NCFTYPES)
- return "none";
+ static char const * const cftypes[] = {
+ /* Check out the latest ``Compression Control Protocol'' rfc (1962) */
+ "OUI", /* 0: OUI */
+ "PRED1", /* 1: Predictor type 1 */
+ "PRED2", /* 2: Predictor type 2 */
+ "PUDDLE", /* 3: Puddle Jumber */
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ "HWPPC", /* 16: Hewlett-Packard PPC */
+ "STAC", /* 17: Stac Electronics LZS (rfc1974) */
+ "MPPC", /* 18: Microsoft PPC (rfc2118) */
+ "GAND", /* 19: Gandalf FZA (rfc1993) */
+ "V42BIS", /* 20: ARG->DATA.42bis compression */
+ "BSD", /* 21: BSD LZW Compress */
+ NULL,
+ "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */
+ "MAGNALINK/DEFLATE",/* 24: Magnalink Variable Resource (rfc1975) */
+ /* 24: Deflate (according to pppd-2.3.*) */
+ "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */
+ "DEFLATE", /* 26: Deflate (rfc1979) */
+ };
+
+ if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
+ cftypes[proto] == NULL)
+ return HexStr(proto, NULL, 0);
+
return cftypes[proto];
}
@@ -441,10 +441,7 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
if (end == NULL)
end = "";
- if (type < NCFTYPES)
- log_Printf(LogCCP, " %s[%d] %s\n", cftypes[type], length, end);
- else
- log_Printf(LogCCP, " ???[%d] %s\n", length, end);
+ log_Printf(LogCCP, " %s[%d] %s\n", protoname(type), length, end);
if (f == -1) {
/* Don't understand that :-( */
diff --git a/usr.sbin/ppp/ppp/chap.c b/usr.sbin/ppp/ppp/chap.c
index e27f2840962..f475428cbae 100644
--- a/usr.sbin/ppp/ppp/chap.c
+++ b/usr.sbin/ppp/ppp/chap.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: chap.c,v 1.18 2000/01/07 03:26:53 brian Exp $
+ * $Id: chap.c,v 1.19 2000/02/27 00:21:06 brian Exp $
*
* TODO:
*/
@@ -331,7 +331,7 @@ chap_Respond(struct chap *chap, char *name, char *key, u_char type
}
static int
-chap_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+chap_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct chap *chap = descriptor2chap(d);
@@ -347,7 +347,7 @@ chap_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-chap_IsSet(struct descriptor *d, const fd_set *fdset)
+chap_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct chap *chap = descriptor2chap(d);
@@ -355,7 +355,7 @@ chap_IsSet(struct descriptor *d, const fd_set *fdset)
}
static void
-chap_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+chap_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct chap *chap = descriptor2chap(d);
int got;
@@ -411,7 +411,7 @@ chap_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-chap_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+chap_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
/* We never want to write here ! */
log_Printf(LogALERT, "chap_Write: Internal error: Bad call !\n");
diff --git a/usr.sbin/ppp/ppp/chap.h b/usr.sbin/ppp/ppp/chap.h
index 9ef97eb9121..90439533cd9 100644
--- a/usr.sbin/ppp/ppp/chap.h
+++ b/usr.sbin/ppp/ppp/chap.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: chap.h,v 1.7 1999/05/08 11:06:34 brian Exp $
+ * $Id: chap.h,v 1.8 2000/02/27 00:21:06 brian Exp $
*
* TODO:
*/
@@ -29,7 +29,7 @@ struct physical;
#define CHAP_FAILURE 4
struct chap {
- struct descriptor desc;
+ struct fdescriptor desc;
struct {
pid_t pid;
int fd;
diff --git a/usr.sbin/ppp/ppp/chat.c b/usr.sbin/ppp/ppp/chat.c
index b4176c4c501..3efcd65d513 100644
--- a/usr.sbin/ppp/ppp/chat.c
+++ b/usr.sbin/ppp/ppp/chat.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: chat.c,v 1.11 2000/01/07 03:26:53 brian Exp $
+ * $Id: chat.c,v 1.12 2000/02/27 00:21:06 brian Exp $
*/
#include <sys/param.h>
@@ -133,7 +133,7 @@ chat_NextChar(char *ptr, char ch)
}
static int
-chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+chat_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct chat *c = descriptor2chat(d);
int special, gotabort, gottimeout, needcr;
@@ -316,7 +316,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-chat_IsSet(struct descriptor *d, const fd_set *fdset)
+chat_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct chat *c = descriptor2chat(d);
return c->argptr && physical_IsSet(&c->physical->desc, fdset);
@@ -365,7 +365,7 @@ chat_UpdateLog(struct chat *c, int in)
}
static void
-chat_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+chat_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct chat *c = descriptor2chat(d);
@@ -479,7 +479,7 @@ chat_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-chat_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+chat_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct chat *c = descriptor2chat(d);
int result = 0;
diff --git a/usr.sbin/ppp/ppp/chat.h b/usr.sbin/ppp/ppp/chat.h
index 8caceba8e68..bcdabb6a393 100644
--- a/usr.sbin/ppp/ppp/chat.h
+++ b/usr.sbin/ppp/ppp/chat.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: chat.h,v 1.4 2000/01/07 03:26:53 brian Exp $
+ * $Id: chat.h,v 1.5 2000/02/27 00:21:06 brian Exp $
*/
#define CHAT_EXPECT 0
@@ -36,7 +36,7 @@
struct physical;
struct chat {
- struct descriptor desc;
+ struct fdescriptor desc;
struct physical *physical;
int state; /* Our CHAT_* status */
diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c
index 865f1455378..b58d1d9a5a9 100644
--- a/usr.sbin/ppp/ppp/command.c
+++ b/usr.sbin/ppp/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.36 2000/01/07 03:26:53 brian Exp $
+ * $Id: command.c,v 1.37 2000/02/27 00:21:07 brian Exp $
*
*/
#include <sys/param.h>
@@ -47,12 +47,13 @@
#include <unistd.h>
#ifndef NONAT
-#ifdef __FreeBSD__
-#include <alias.h>
-#else
+#ifdef LOCALNAT
#include "alias.h"
+#else
+#include <alias.h>
#endif
#endif
+
#include "layer.h"
#include "defs.h"
#include "command.h"
@@ -1903,8 +1904,8 @@ static struct cmdtab const SetCommands[] = {
{"lcpretry", "lcpretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "LCP retries",
"set lcpretry value [attempts]", (const void *)VAR_LCPRETRY},
{"log", NULL, log_SetLevel, LOCAL_AUTH, "log level",
- "set log [local] [+|-]async|cbcp|ccp|chat|command|connect|debug|hdlc|id0|"
- "ipcp|lcp|lqm|phase|physical|sync|tcp/ip|timer|tun..."},
+ "set log [local] [+|-]async|cbcp|ccp|chat|command|connect|debug|dns|hdlc|"
+ "id0|ipcp|lcp|lqm|phase|physical|sync|tcp/ip|timer|tun..."},
{"login", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
"login script", "set login chat-script", (const void *) VAR_LOGIN},
{"logout", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
diff --git a/usr.sbin/ppp/ppp/datalink.c b/usr.sbin/ppp/ppp/datalink.c
index e5a2e81d66b..43a74c5b17c 100644
--- a/usr.sbin/ppp/ppp/datalink.c
+++ b/usr.sbin/ppp/ppp/datalink.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.c,v 1.25 2000/01/07 03:26:53 brian Exp $
+ * $Id: datalink.c,v 1.26 2000/02/27 00:21:07 brian Exp $
*/
#include <sys/param.h>
@@ -241,7 +241,7 @@ datalink_LoginDone(struct datalink *dl)
}
static int
-datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
+datalink_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e,
int *n)
{
struct datalink *dl = descriptor2datalink(d);
@@ -410,7 +410,7 @@ datalink_RemoveFromSet(struct datalink *dl, fd_set *r, fd_set *w, fd_set *e)
}
static int
-datalink_IsSet(struct descriptor *d, const fd_set *fdset)
+datalink_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct datalink *dl = descriptor2datalink(d);
@@ -437,7 +437,7 @@ datalink_IsSet(struct descriptor *d, const fd_set *fdset)
}
static void
-datalink_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+datalink_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct datalink *dl = descriptor2datalink(d);
@@ -467,7 +467,7 @@ datalink_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-datalink_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+datalink_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct datalink *dl = descriptor2datalink(d);
int result = 0;
diff --git a/usr.sbin/ppp/ppp/datalink.h b/usr.sbin/ppp/ppp/datalink.h
index 62e072ec0ab..6dd3d5f7050 100644
--- a/usr.sbin/ppp/ppp/datalink.h
+++ b/usr.sbin/ppp/ppp/datalink.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.h,v 1.6 2000/01/07 03:26:53 brian Exp $
+ * $Id: datalink.h,v 1.7 2000/02/27 00:21:07 brian Exp $
*/
#define DATALINK_CLOSED (0)
@@ -52,7 +52,7 @@ struct physical;
struct bundle;
struct datalink {
- struct descriptor desc; /* We play either a physical or a chat */
+ struct fdescriptor desc; /* We play either a physical or a chat */
int state; /* Our DATALINK_* state */
struct physical *physical; /* Our link */
diff --git a/usr.sbin/ppp/ppp/defs.c b/usr.sbin/ppp/ppp/defs.c
index 2d6e1c53909..ae4a7420e6c 100644
--- a/usr.sbin/ppp/ppp/defs.c
+++ b/usr.sbin/ppp/ppp/defs.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: defs.c,v 1.7 2000/01/07 03:26:53 brian Exp $
+ * $Id: defs.c,v 1.8 2000/02/27 00:21:07 brian Exp $
*/
@@ -35,6 +35,7 @@
#include <ctype.h>
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
@@ -315,3 +316,29 @@ MakeArgs(char *script, char **pvect, int maxargs, int flags)
*pvect = NULL;
return nargs;
}
+
+const char *
+NumStr(long val, char *buf, size_t sz)
+{
+ static char result[23]; /* handles 64 bit numbers */
+
+ if (buf == NULL || sz == 0) {
+ buf = result;
+ sz = sizeof result;
+ }
+ snprintf(buf, sz, "<%ld>", val);
+ return buf;
+}
+
+const char *
+HexStr(long val, char *buf, size_t sz)
+{
+ static char result[21]; /* handles 64 bit numbers */
+
+ if (buf == NULL || sz == 0) {
+ buf = result;
+ sz = sizeof result;
+ }
+ snprintf(buf, sz, "<0x%lx>", val);
+ return buf;
+}
diff --git a/usr.sbin/ppp/ppp/defs.h b/usr.sbin/ppp/ppp/defs.h
index c87b42a6dec..9feba390a93 100644
--- a/usr.sbin/ppp/ppp/defs.h
+++ b/usr.sbin/ppp/ppp/defs.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: defs.h,v 1.11 2000/01/07 03:26:53 brian Exp $
+ * $Id: defs.h,v 1.12 2000/02/27 00:21:07 brian Exp $
*
* TODO:
*/
@@ -96,6 +96,8 @@
#define PARSE_REDUCE 1
#define PARSE_NOHASH 2
+#define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
+
extern void randinit(void);
extern ssize_t fullread(int, void *, size_t);
extern const char *mode2Nam(int);
@@ -105,3 +107,5 @@ extern int SpeedToInt(speed_t);
extern speed_t IntToSpeed(int);
extern char *findblank(char *, int);
extern int MakeArgs(char *, char **, int, int);
+extern const char *NumStr(long, char *, size_t);
+extern const char *HexStr(long, char *, size_t);
diff --git a/usr.sbin/ppp/ppp/descriptor.h b/usr.sbin/ppp/ppp/descriptor.h
index 6a8549b7bdd..4f8584a100a 100644
--- a/usr.sbin/ppp/ppp/descriptor.h
+++ b/usr.sbin/ppp/ppp/descriptor.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: descriptor.h,v 1.3 1999/02/11 10:14:50 brian Exp $
+ * $Id: descriptor.h,v 1.4 2000/02/27 00:21:07 brian Exp $
*/
#define PHYSICAL_DESCRIPTOR (1)
@@ -38,13 +38,13 @@
struct bundle;
-struct descriptor {
+struct fdescriptor {
int type;
- int (*UpdateSet)(struct descriptor *, fd_set *, fd_set *, fd_set *, int *);
- int (*IsSet)(struct descriptor *, const fd_set *);
- void (*Read)(struct descriptor *, struct bundle *, const fd_set *);
- int (*Write)(struct descriptor *, struct bundle *, const fd_set *);
+ int (*UpdateSet)(struct fdescriptor *, fd_set *, fd_set *, fd_set *, int *);
+ int (*IsSet)(struct fdescriptor *, const fd_set *);
+ void (*Read)(struct fdescriptor *, struct bundle *, const fd_set *);
+ int (*Write)(struct fdescriptor *, struct bundle *, const fd_set *);
};
#define descriptor_UpdateSet(d, r, w, e, n) ((*(d)->UpdateSet)(d, r, w, e, n))
diff --git a/usr.sbin/ppp/ppp/ether.c b/usr.sbin/ppp/ppp/ether.c
index 0fc1e053176..8bc4aa4c7cb 100644
--- a/usr.sbin/ppp/ppp/ether.c
+++ b/usr.sbin/ppp/ppp/ether.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ether.c,v 1.1 2000/01/07 03:26:53 brian Exp $
+ * $Id: ether.c,v 1.2 2000/02/27 00:21:07 brian Exp $
*/
#include <sys/param.h>
@@ -319,7 +319,7 @@ ether_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
}
static int
-ether_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+ether_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct physical *p = descriptor2physical(d);
struct etherdevice *dev = device2ether(p->handler);
@@ -338,7 +338,7 @@ ether_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-ether_IsSet(struct descriptor *d, const fd_set *fdset)
+ether_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct physical *p = descriptor2physical(d);
struct etherdevice *dev = device2ether(p->handler);
@@ -351,7 +351,7 @@ ether_IsSet(struct descriptor *d, const fd_set *fdset)
}
static void
-ether_DescriptorRead(struct descriptor *d, struct bundle *bundle,
+ether_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
const fd_set *fdset)
{
struct physical *p = descriptor2physical(d);
diff --git a/usr.sbin/ppp/ppp/iface.c b/usr.sbin/ppp/ppp/iface.c
index ace87979b07..e856adb4c9a 100644
--- a/usr.sbin/ppp/ppp/iface.c
+++ b/usr.sbin/ppp/ppp/iface.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: iface.c,v 1.8 2000/01/07 03:47:12 brian Exp $
+ * $Id: iface.c,v 1.9 2000/02/27 00:21:07 brian Exp $
*/
#include <sys/param.h>
@@ -94,13 +94,13 @@ bitsinmask(struct in_addr mask)
struct iface *
iface_Create(const char *name)
{
- int mib[6], i, s;
+ int mib[6], s;
size_t needed;
- char *buf, *ptr, *end, *cp, *lim;
+ char *buf, *ptr, *end;
struct if_msghdr *ifm;
struct ifa_msghdr *ifam;
struct sockaddr_dl *dl;
- struct rt_addrinfo rti;
+ struct sockaddr *sa[RTAX_MAX];
struct iface *iface;
struct iface_addr *addr;
@@ -165,29 +165,12 @@ iface_Create(const char *name)
if (ifam->ifam_type != RTM_NEWADDR) /* finished this if */
break;
- if (iface == NULL) /* Keep wading */
- continue;
-
- /* Found an address ! */
-
- if (ifam->ifam_addrs & (1 << RTAX_IFA)) {
- /* *And* it's configured ! */
- rti.rti_addrs = ifam->ifam_addrs;
- lim = (char *)ifam + ifam->ifam_msglen;
- cp = (char *)(ifam + 1);
- memset(rti.rti_info, '\0', sizeof(rti.rti_info));
- for (i = 0; i < RTAX_MAX && cp < lim; i++) {
- if ((rti.rti_addrs & (1 << i)) == 0)
- continue;
- rti.rti_info[i] = (struct sockaddr *)cp;
-#define ROUNDUP(x) \
- ((x) > 0 ? (1 + (((x) - 1) | (sizeof(long) - 1))) : sizeof(long))
- cp += ROUNDUP(rti.rti_info[i]->sa_len);
- }
+ if (iface != NULL && ifam->ifam_addrs & RTA_IFA) {
+ /* Found a configured interface ! */
+ iface_ParseHdr(ifam, sa);
- if (rti.rti_info[RTAX_IFA] &&
- rti.rti_info[RTAX_IFA]->sa_family == AF_INET) {
- /* Record the iface address rti */
+ if (sa[RTAX_IFA] && sa[RTAX_IFA]->sa_family == AF_INET) {
+ /* Record the address */
addr = (struct iface_addr *)realloc
(iface->in_addr, (iface->in_addrs + 1) * sizeof iface->in_addr[0]);
@@ -198,14 +181,17 @@ iface_Create(const char *name)
addr += iface->in_addrs;
iface->in_addrs++;
- addr->ifa.s_addr = ((struct sockaddr_in *)rti.rti_info[RTAX_IFA])->
- sin_addr.s_addr;
- addr->brd.s_addr = rti.rti_info[RTAX_BRD] ?
- ((struct sockaddr_in *)rti.rti_info[RTAX_BRD])->sin_addr.s_addr :
- INADDR_ANY;
- addr->mask.s_addr = rti.rti_info[RTAX_NETMASK] ?
- ((struct sockaddr_in *)rti.rti_info[RTAX_NETMASK])->sin_addr.s_addr:
- INADDR_ANY;
+ addr->ifa = ((struct sockaddr_in *)sa[RTAX_IFA])->sin_addr;
+
+ if (sa[RTAX_BRD])
+ addr->brd = ((struct sockaddr_in *)sa[RTAX_BRD])->sin_addr;
+ else
+ addr->brd.s_addr = INADDR_ANY;
+
+ if (sa[RTAX_NETMASK])
+ addr->mask = ((struct sockaddr_in *)sa[RTAX_NETMASK])->sin_addr;
+ else
+ addr->mask.s_addr = INADDR_ANY;
addr->bits = bitsinmask(addr->mask);
}
@@ -540,3 +526,19 @@ iface_Show(struct cmdargs const *arg)
return 0;
}
+
+void
+iface_ParseHdr(struct ifa_msghdr *ifam, struct sockaddr *sa[RTAX_MAX])
+{
+ char *wp;
+ int rtax;
+
+ wp = (char *)(ifam + 1);
+
+ for (rtax = 0; rtax < RTAX_MAX; rtax++)
+ if (ifam->ifam_addrs & (1 << rtax)) {
+ sa[rtax] = (struct sockaddr *)wp;
+ wp += ROUNDUP(sa[rtax]->sa_len);
+ } else
+ sa[rtax] = NULL;
+}
diff --git a/usr.sbin/ppp/ppp/iface.h b/usr.sbin/ppp/ppp/iface.h
index 0c377804e67..b34b927beb7 100644
--- a/usr.sbin/ppp/ppp/iface.h
+++ b/usr.sbin/ppp/ppp/iface.h
@@ -23,9 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: iface.h,v 1.3 1999/05/27 08:44:48 brian Exp $
+ * $Id: iface.h,v 1.4 2000/02/27 00:21:08 brian Exp $
*/
+struct ifa_msghdr;
+
struct iface_addr {
struct in_addr ifa; /* local address */
struct in_addr mask; /* netmask */
@@ -60,3 +62,4 @@ extern int iface_Show(struct cmdargs const *);
extern int iface_SetFlags(struct iface *, int);
extern int iface_ClearFlags(struct iface *, int);
extern void iface_Destroy(struct iface *);
+extern void iface_ParseHdr(struct ifa_msghdr *, struct sockaddr *[RTAX_MAX]);
diff --git a/usr.sbin/ppp/ppp/ip.c b/usr.sbin/ppp/ppp/ip.c
index 9c72b2e4eef..9032723bd9f 100644
--- a/usr.sbin/ppp/ppp/ip.c
+++ b/usr.sbin/ppp/ppp/ip.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ip.c,v 1.18 2000/01/07 03:26:54 brian Exp $
+ * $Id: ip.c,v 1.19 2000/02/27 00:21:08 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -68,10 +68,74 @@
#include "tun.h"
#include "ip.h"
-static const char * const TcpFlags[] = {
- "FIN", "SYN", "RST", "PSH", "ACK", "URG"
+
+#define OPCODE_QUERY 0
+#define OPCODE_IQUERY 1
+#define OPCODE_STATUS 2
+
+struct dns_header {
+ u_short id;
+ unsigned qr : 1;
+ unsigned opcode : 4;
+ unsigned aa : 1;
+ unsigned tc : 1;
+ unsigned rd : 1;
+ unsigned ra : 1;
+ unsigned z : 3;
+ unsigned rcode : 4;
+ u_short qdcount;
+ u_short ancount;
+ u_short nscount;
+ u_short arcount;
};
+static const char *
+dns_Qclass2Txt(u_short qclass)
+{
+ static char failure[6];
+ struct {
+ u_short id;
+ const char *txt;
+ } qtxt[] = {
+ /* rfc1035 */
+ { 1, "IN" }, { 2, "CS" }, { 3, "CH" }, { 4, "HS" }, { 255, "*" }
+ };
+ int f;
+
+ for (f = 0; f < sizeof qtxt / sizeof *qtxt; f++)
+ if (qtxt[f].id == qclass)
+ return qtxt[f].txt;
+
+ return HexStr(qclass, failure, sizeof failure);
+}
+
+static const char *
+dns_Qtype2Txt(u_short qtype)
+{
+ static char failure[6];
+ struct {
+ u_short id;
+ const char *txt;
+ } qtxt[] = {
+ /* rfc1035/rfc1700 */
+ { 1, "A" }, { 2, "NS" }, { 3, "MD" }, { 4, "MF" }, { 5, "CNAME" },
+ { 6, "SOA" }, { 7, "MB" }, { 8, "MG" }, { 9, "MR" }, { 10, "NULL" },
+ { 11, "WKS" }, { 12, "PTR" }, { 13, "HINFO" }, { 14, "MINFO" },
+ { 15, "MX" }, { 16, "TXT" }, { 17, "RP" }, { 18, "AFSDB" },
+ { 19, "X25" }, { 20, "ISDN" }, { 21, "RT" }, { 22, "NSAP" },
+ { 23, "NSAP-PTR" }, { 24, "SIG" }, { 25, "KEY" }, { 26, "PX" },
+ { 27, "GPOS" }, { 28, "AAAA" }, { 252, "AXFR" }, { 253, "MAILB" },
+ { 254, "MAILA" }, { 255, "*" }
+ };
+ int f;
+
+ for (f = 0; f < sizeof qtxt / sizeof *qtxt; f++)
+ if (qtxt[f].id == qtype)
+ return qtxt[f].txt;
+
+ return HexStr(qtype, failure, sizeof failure);
+}
+
static __inline int
PortMatch(int op, u_short pport, u_short rport)
{
@@ -311,26 +375,82 @@ IcmpError(struct ip *pip, int code)
}
#endif
+static void
+ip_LogDNS(const struct udphdr *uh, const char *direction)
+{
+ struct dns_header header;
+ const u_short *pktptr;
+ const u_char *ptr;
+ u_short *hptr;
+ int len;
+
+ ptr = (const char *)uh + sizeof *uh;
+ len = ntohs(uh->uh_ulen) - sizeof *uh;
+ if (len < sizeof header + 5) /* rfc1024 */
+ return;
+
+ pktptr = (const u_short *)ptr;
+ hptr = (u_short *)&header;
+ ptr += sizeof header;
+ len -= sizeof header;
+
+ while (pktptr < (const u_short *)ptr) {
+ *hptr++ = ntohs(*pktptr); /* Careful of macro side-effects ! */
+ pktptr++;
+ }
+
+ if (header.opcode == OPCODE_QUERY && header.qr == 0) {
+ /* rfc1035 */
+ char name[MAXHOSTNAMELEN + 1], *n;
+ const char *qtype, *qclass;
+ const u_char *end;
+
+ n = name;
+ end = ptr + len - 4;
+ if (end - ptr > MAXHOSTNAMELEN)
+ end = ptr + MAXHOSTNAMELEN;
+ while (ptr < end) {
+ len = *ptr++;
+ if (len > end - ptr)
+ len = end - ptr;
+ if (n != name)
+ *n++ = '.';
+ memcpy(n, ptr, len);
+ ptr += len;
+ n += len;
+ }
+ *n = '\0';
+ qtype = dns_Qtype2Txt(ntohs(*(const u_short *)end));
+ qclass = dns_Qclass2Txt(ntohs(*(const u_short *)(end + 2)));
+
+ log_Printf(LogDNS, "%sbound query %s %s %s\n",
+ direction, qclass, qtype, name);
+ }
+}
+
/*
* For debugging aid.
*/
int
PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
{
+ static const char *const TcpFlags[] = {
+ "FIN", "SYN", "RST", "PSH", "ACK", "URG"
+ };
struct ip *pip;
struct tcphdr *th;
struct udphdr *uh;
struct icmp *icmph;
char *ptop;
- int mask, len, n;
- int pri = 0;
- int logit, loglen;
+ int mask, len, n, pri, logit, loglen, result;
char logbuf[200];
- logit = log_IsKept(LogTCPIP) && filter->logok;
+ logit = (log_IsKept(LogTCPIP) || log_IsKept(LogDNS)) && filter->logok;
loglen = 0;
+ pri = 0;
- pip = (struct ip *) cp;
+ pip = (struct ip *)cp;
+ uh = NULL;
if (logit && loglen < sizeof logbuf) {
snprintf(logbuf + loglen, sizeof logbuf - loglen, "%s ", filter->name);
@@ -473,17 +593,22 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
if (direction == 0)
IcmpError(pip, pri);
#endif
- return (-1);
+ result = -1;
} else {
/* Check Keep Alive filter */
- if (logit) {
+ if (logit && log_IsKept(LogTCPIP)) {
if (FilterCheck(pip, &bundle->filter.alive))
log_Printf(LogTCPIP, "%s - NO KEEPALIVE\n", logbuf);
else
log_Printf(LogTCPIP, "%s\n", logbuf);
}
- return (pri);
+ result = pri;
}
+
+ if (uh && ntohs(uh->uh_dport) == 53 && log_IsKept(LogDNS))
+ ip_LogDNS(uh, filter->name);
+
+ return result;
}
struct mbuf *
diff --git a/usr.sbin/ppp/ppp/ipcp.c b/usr.sbin/ppp/ppp/ipcp.c
index 198203e31cf..126a493828c 100644
--- a/usr.sbin/ppp/ppp/ipcp.c
+++ b/usr.sbin/ppp/ppp/ipcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.c,v 1.19 2000/01/07 03:26:54 brian Exp $
+ * $Id: ipcp.c,v 1.20 2000/02/27 00:21:08 brian Exp $
*
* TODO:
* o Support IPADDRS properly
@@ -42,12 +42,13 @@
#include <unistd.h>
#ifndef NONAT
-#ifdef __FreeBSD__
-#include <alias.h>
-#else
+#ifdef LOCALNAT
#include "alias.h"
+#else
+#include <alias.h>
#endif
#endif
+
#include "layer.h"
#include "ua.h"
#include "defs.h"
@@ -208,26 +209,30 @@ static struct fsm_callbacks ipcp_Callbacks = {
fsm_NullRecvResetAck
};
-static const char * const cftypes[] = {
- /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
- "???",
- "IPADDRS", /* 1: IP-Addresses */ /* deprecated */
- "COMPPROTO", /* 2: IP-Compression-Protocol */
- "IPADDR", /* 3: IP-Address */
-};
-
-#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
+static const char *
+protoname(int proto)
+{
+ static struct {
+ int id;
+ const char *txt;
+ } cftypes[] = {
+ /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
+ { 1, "IPADDRS" }, /* IP-Addresses */ /* deprecated */
+ { 2, "COMPPROTO" }, /* IP-Compression-Protocol */
+ { 3, "IPADDR" }, /* IP-Address */
+ { 129, "PRIDNS" }, /* 129: Primary DNS Server Address */
+ { 130, "PRINBNS" }, /* 130: Primary NBNS Server Address */
+ { 131, "SECDNS" }, /* 131: Secondary DNS Server Address */
+ { 132, "SECNBNS" } /* 132: Secondary NBNS Server Address */
+ };
+ int f;
-static const char * const cftypes128[] = {
- /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
- "???",
- "PRIDNS", /* 129: Primary DNS Server Address */
- "PRINBNS", /* 130: Primary NBNS Server Address */
- "SECDNS", /* 131: Secondary DNS Server Address */
- "SECNBNS", /* 132: Secondary NBNS Server Address */
-};
+ for (f = 0; f < sizeof cftypes / sizeof *cftypes; f++)
+ if (cftypes[f].id == proto)
+ return cftypes[f].txt;
-#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0])
+ return NumStr(proto, NULL, 0);
+}
void
ipcp_AddInOctets(struct ipcp *ipcp, int n)
@@ -960,12 +965,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
break;
}
- if (type < NCFTYPES)
- snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes[type], length);
- else if (type > 128 && type < 128 + NCFTYPES128)
- snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes128[type-128], length);
- else
- snprintf(tbuff, sizeof tbuff, " <%d>[%d] ", type, length);
+ snprintf(tbuff, sizeof tbuff, " %s[%d] ", protoname(type), length);
switch (type) {
case TY_IPADDR: /* RFC1332 */
diff --git a/usr.sbin/ppp/ppp/lcp.c b/usr.sbin/ppp/ppp/lcp.c
index c90289874d8..4e93663dfbc 100644
--- a/usr.sbin/ppp/ppp/lcp.c
+++ b/usr.sbin/ppp/ppp/lcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.c,v 1.17 2000/01/07 03:26:54 brian Exp $
+ * $Id: lcp.c,v 1.18 2000/02/27 00:21:08 brian Exp $
*
*/
@@ -104,35 +104,43 @@ static struct fsm_callbacks lcp_Callbacks = {
static const char * const lcp_TimerNames[] =
{"LCP restart", "LCP openmode", "LCP stopped"};
-static const char * const cftypes[] = {
- /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
- "???",
- "MRU", /* 1: Maximum-Receive-Unit */
- "ACCMAP", /* 2: Async-Control-Character-Map */
- "AUTHPROTO", /* 3: Authentication-Protocol */
- "QUALPROTO", /* 4: Quality-Protocol */
- "MAGICNUM", /* 5: Magic-Number */
- "RESERVED", /* 6: RESERVED */
- "PROTOCOMP", /* 7: Protocol-Field-Compression */
- "ACFCOMP", /* 8: Address-and-Control-Field-Compression */
- "FCSALT", /* 9: FCS-Alternatives */
- "SDP", /* 10: Self-Describing-Pad */
- "NUMMODE", /* 11: Numbered-Mode */
- "MULTIPROC", /* 12: Multi-Link-Procedure */
- "CALLBACK", /* 13: Callback */
- "CONTIME", /* 14: Connect-Time */
- "COMPFRAME", /* 15: Compound-Frames */
- "NDE", /* 16: Nominal-Data-Encapsulation */
- "MRRU", /* 17: Multilink-MRRU */
- "SHORTSEQ", /* 18: Multilink-Short-Sequence-Number-Header */
- "ENDDISC", /* 19: Multilink-Endpoint-Discriminator */
- "PROPRIETRY", /* 20: Proprietary */
- "DCEID", /* 21: DCE-Identifier */
- "MULTIPP", /* 22: Multi-Link-Plus-Procedure */
- "LDBACP", /* 23: Link Discriminator for BACP */
-};
-
-#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
+static const char *
+protoname(int proto)
+{
+ static const char * const cftypes[] = {
+ /* Check out the latest ``Assigned numbers'' rfc (1700) */
+ NULL,
+ "MRU", /* 1: Maximum-Receive-Unit */
+ "ACCMAP", /* 2: Async-Control-Character-Map */
+ "AUTHPROTO", /* 3: Authentication-Protocol */
+ "QUALPROTO", /* 4: Quality-Protocol */
+ "MAGICNUM", /* 5: Magic-Number */
+ "RESERVED", /* 6: RESERVED */
+ "PROTOCOMP", /* 7: Protocol-Field-Compression */
+ "ACFCOMP", /* 8: Address-and-Control-Field-Compression */
+ "FCSALT", /* 9: FCS-Alternatives */
+ "SDP", /* 10: Self-Describing-Pad */
+ "NUMMODE", /* 11: Numbered-Mode */
+ "MULTIPROC", /* 12: Multi-Link-Procedure */
+ "CALLBACK", /* 13: Callback */
+ "CONTIME", /* 14: Connect-Time */
+ "COMPFRAME", /* 15: Compound-Frames */
+ "NDE", /* 16: Nominal-Data-Encapsulation */
+ "MRRU", /* 17: Multilink-MRRU */
+ "SHORTSEQ", /* 18: Multilink-Short-Sequence-Number-Header */
+ "ENDDISC", /* 19: Multilink-Endpoint-Discriminator */
+ "PROPRIETRY", /* 20: Proprietary */
+ "DCEID", /* 21: DCE-Identifier */
+ "MULTIPP", /* 22: Multi-Link-Plus-Procedure */
+ "LDBACP", /* 23: Link Discriminator for BACP */
+ };
+
+ if (proto < 0 || proto > sizeof cftypes / sizeof *cftypes ||
+ cftypes[proto] == NULL)
+ return HexStr(proto, NULL, 0);
+
+ return cftypes[proto];
+}
int
lcp_ReportStatus(struct cmdargs const *arg)
@@ -546,10 +554,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
type = *cp;
length = cp[1];
- if (type < 0 || type >= NCFTYPES)
- snprintf(request, sizeof request, " <%d>[%d]", type, length);
- else
- snprintf(request, sizeof request, " %s[%d]", cftypes[type], length);
+ snprintf(request, sizeof request, " %s[%d]", protoname(type), length);
if (length < 2) {
log_Printf(LogLCP, "%s:%s: Bad LCP length\n", fp->link->name, request);
diff --git a/usr.sbin/ppp/ppp/log.c b/usr.sbin/ppp/ppp/log.c
index ce4d74627fd..781cd3541a3 100644
--- a/usr.sbin/ppp/ppp/log.c
+++ b/usr.sbin/ppp/ppp/log.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: log.c,v 1.8 2000/01/07 03:26:54 brian Exp $
+ * $Id: log.c,v 1.9 2000/02/27 00:21:08 brian Exp $
*/
#include <sys/types.h>
@@ -50,6 +50,7 @@ static const char * const LogNames[] = {
"Command",
"Connect",
"Debug",
+ "DNS",
"HDLC",
"ID0",
"IPCP",
diff --git a/usr.sbin/ppp/ppp/log.h b/usr.sbin/ppp/ppp/log.h
index f2c3915f165..89cfe59f6c8 100644
--- a/usr.sbin/ppp/ppp/log.h
+++ b/usr.sbin/ppp/ppp/log.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: log.h,v 1.4 2000/01/07 03:26:54 brian Exp $
+ * $Id: log.h,v 1.5 2000/02/27 00:21:08 brian Exp $
*/
#define LogMIN (1)
@@ -34,22 +34,24 @@
#define LogCOMMAND (5)
#define LogCONNECT (6)
#define LogDEBUG (7) /* syslog(LOG_DEBUG, ....) */
-#define LogHDLC (8)
-#define LogID0 (9)
-#define LogIPCP (10)
-#define LogLCP (11)
-#define LogLQM (12)
-#define LogPHASE (13)
-#define LogPHYSICAL (14) /* syslog(LOG_INFO, ....) */
-#define LogSYNC (15) /* syslog(LOG_INFO, ....) */
-#define LogTCPIP (16)
-#define LogTIMER (17) /* syslog(LOG_DEBUG, ....) */
-#define LogTUN (18) /* If set, tun%d is output with each message */
-#define LogMAXCONF (18)
-#define LogWARN (19) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
-#define LogERROR (20) /* syslog(LOG_ERR, ....), + sent to VarTerm */
-#define LogALERT (21) /* syslog(LOG_ALERT, ....) */
-#define LogMAX (21)
+#define LogDNS (8)
+#define LogHDLC (9)
+#define LogID0 (10)
+#define LogIPCP (11)
+#define LogLCP (12)
+#define LogLQM (13)
+#define LogPHASE (14)
+#define LogPHYSICAL (15) /* syslog(LOG_INFO, ....) */
+#define LogSYNC (16) /* syslog(LOG_INFO, ....) */
+#define LogTCPIP (17)
+#define LogTIMER (18) /* syslog(LOG_DEBUG, ....) */
+#define LogTUN (19) /* If set, tun%d is output with each message */
+#define LogWARN (20) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
+#define LogERROR (21) /* syslog(LOG_ERR, ....), + sent to VarTerm */
+#define LogALERT (22) /* syslog(LOG_ALERT, ....) */
+
+#define LogMAXCONF (19)
+#define LogMAX (22)
struct mbuf;
struct cmdargs;
diff --git a/usr.sbin/ppp/ppp/main.c b/usr.sbin/ppp/ppp/main.c
index e45d2382203..65dc7707387 100644
--- a/usr.sbin/ppp/ppp/main.c
+++ b/usr.sbin/ppp/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.15 2000/01/07 03:26:54 brian Exp $
+ * $Id: main.c,v 1.16 2000/02/27 00:21:08 brian Exp $
*
* TODO:
*/
@@ -27,6 +27,8 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/un.h>
+#include <sys/socket.h>
+#include <net/route.h>
#include <errno.h>
#include <fcntl.h>
@@ -41,12 +43,13 @@
#include <sys/stat.h>
#ifndef NONAT
-#ifdef __FreeBSD__
-#include <alias.h>
-#else
+#ifdef LOCALNAT
#include "alias.h"
+#else
+#include <alias.h>
#endif
#endif
+
#include "layer.h"
#include "probe.h"
#include "mbuf.h"
diff --git a/usr.sbin/ppp/ppp/mp.c b/usr.sbin/ppp/ppp/mp.c
index 65cf338a5b6..18294b58529 100644
--- a/usr.sbin/ppp/ppp/mp.c
+++ b/usr.sbin/ppp/ppp/mp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp.c,v 1.13 2000/01/07 03:26:55 brian Exp $
+ * $Id: mp.c,v 1.14 2000/02/27 00:21:08 brian Exp $
*/
#include <sys/param.h>
@@ -966,7 +966,7 @@ mp_SetEnddisc(struct cmdargs const *arg)
}
static int
-mpserver_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
+mpserver_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e,
int *n)
{
struct mpserver *s = descriptor2mpserver(d);
@@ -996,14 +996,14 @@ mpserver_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
}
static int
-mpserver_IsSet(struct descriptor *d, const fd_set *fdset)
+mpserver_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct mpserver *s = descriptor2mpserver(d);
return s->fd >= 0 && FD_ISSET(s->fd, fdset);
}
static void
-mpserver_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+mpserver_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct mpserver *s = descriptor2mpserver(d);
@@ -1011,7 +1011,7 @@ mpserver_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-mpserver_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+mpserver_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
/* We never want to write here ! */
log_Printf(LogALERT, "mpserver_Write: Internal error: Bad call !\n");
diff --git a/usr.sbin/ppp/ppp/mp.h b/usr.sbin/ppp/ppp/mp.h
index 0adcd99e04f..539b71acf74 100644
--- a/usr.sbin/ppp/ppp/mp.h
+++ b/usr.sbin/ppp/ppp/mp.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: mp.h,v 1.6 2000/01/17 12:27:52 brian Exp $
+ * $Id: mp.h,v 1.7 2000/02/27 00:21:08 brian Exp $
*/
struct mbuf;
@@ -60,7 +60,7 @@ struct peerid {
};
struct mpserver {
- struct descriptor desc;
+ struct fdescriptor desc;
int fd; /* listen()ing or connect()ing here */
struct sockaddr_un socket; /* On this socket */
diff --git a/usr.sbin/ppp/ppp/nat_cmd.c b/usr.sbin/ppp/ppp/nat_cmd.c
index e5e8f9afdb4..ff707a2a548 100644
--- a/usr.sbin/ppp/ppp/nat_cmd.c
+++ b/usr.sbin/ppp/ppp/nat_cmd.c
@@ -2,7 +2,7 @@
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
* who places it in the public domain without restriction.
*
- * $Id: nat_cmd.c,v 1.1 2000/01/07 03:26:55 brian Exp $
+ * $Id: nat_cmd.c,v 1.2 2000/02/27 00:21:08 brian Exp $
*/
#include <sys/param.h>
@@ -19,11 +19,12 @@
#include <string.h>
#include <termios.h>
-#ifdef __FreeBSD__
-#include <alias.h>
-#else
+#ifdef LOCALNAT
#include "alias.h"
+#else
+#include <alias.h>
#endif
+
#include "layer.h"
#include "proto.h"
#include "defs.h"
diff --git a/usr.sbin/ppp/ppp/physical.c b/usr.sbin/ppp/ppp/physical.c
index e573929dbdb..47495f44c50 100644
--- a/usr.sbin/ppp/ppp/physical.c
+++ b/usr.sbin/ppp/ppp/physical.c
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.c,v 1.18 2000/01/07 03:26:55 brian Exp $
+ * $Id: physical.c,v 1.19 2000/02/27 00:21:09 brian Exp $
*
*/
@@ -97,7 +97,7 @@
#define PPPOTCPLINE "ppp"
-static int physical_DescriptorWrite(struct descriptor *, struct bundle *,
+static int physical_DescriptorWrite(struct fdescriptor *, struct bundle *,
const fd_set *);
static int
@@ -128,7 +128,7 @@ struct {
#define NDEVICES (sizeof devices / sizeof devices[0])
static int
-physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
+physical_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e,
int *n)
{
return physical_doUpdateSet(d, r, w, e, n, 0);
@@ -374,7 +374,7 @@ physical_Destroy(struct physical *p)
}
static int
-physical_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
+physical_DescriptorWrite(struct fdescriptor *d, struct bundle *bundle,
const fd_set *fdset)
{
struct physical *p = descriptor2physical(d);
@@ -496,7 +496,7 @@ physical_ShowStatus(struct cmdargs const *arg)
}
void
-physical_DescriptorRead(struct descriptor *d, struct bundle *bundle,
+physical_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
const fd_set *fdset)
{
struct physical *p = descriptor2physical(d);
@@ -788,7 +788,7 @@ physical_Write(struct physical *p, const void *buf, size_t nbytes)
}
int
-physical_doUpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
+physical_doUpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e,
int *n, int force)
{
struct physical *p = descriptor2physical(d);
@@ -850,7 +850,7 @@ physical_RemoveFromSet(struct physical *p, fd_set *r, fd_set *w, fd_set *e)
}
int
-physical_IsSet(struct descriptor *d, const fd_set *fdset)
+physical_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct physical *p = descriptor2physical(d);
return p->fd >= 0 && FD_ISSET(p->fd, fdset);
diff --git a/usr.sbin/ppp/ppp/physical.h b/usr.sbin/ppp/ppp/physical.h
index fd4063c1c1a..6d5831739a9 100644
--- a/usr.sbin/ppp/ppp/physical.h
+++ b/usr.sbin/ppp/ppp/physical.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.h,v 1.14 2000/01/07 03:26:55 brian Exp $
+ * $Id: physical.h,v 1.15 2000/02/27 00:21:09 brian Exp $
*
*/
@@ -73,7 +73,7 @@ struct device {
struct physical {
struct link link;
- struct descriptor desc;
+ struct fdescriptor desc;
int type; /* What sort of PHYS_* link are we ? */
struct async async; /* Our async state */
struct hdlc hdlc; /* Our hdlc state */
@@ -148,10 +148,10 @@ extern void physical_SetDevice(struct physical *, const char *);
extern ssize_t physical_Read(struct physical *, void *, size_t);
extern ssize_t physical_Write(struct physical *, const void *, size_t);
-extern int physical_doUpdateSet(struct descriptor *, fd_set *, fd_set *,
+extern int physical_doUpdateSet(struct fdescriptor *, fd_set *, fd_set *,
fd_set *, int *, int);
-extern int physical_IsSet(struct descriptor *, const fd_set *);
-extern void physical_DescriptorRead(struct descriptor *, struct bundle *,
+extern int physical_IsSet(struct fdescriptor *, const fd_set *);
+extern void physical_DescriptorRead(struct fdescriptor *, struct bundle *,
const fd_set *);
extern void physical_Login(struct physical *, const char *);
extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
diff --git a/usr.sbin/ppp/ppp/ppp.8 b/usr.sbin/ppp/ppp/ppp.8
index 01f81971823..cd082c24826 100644
--- a/usr.sbin/ppp/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.75 2000/01/22 02:17:52 aaron Exp $
+.\" $Id: ppp.8,v 1.76 2000/02/27 00:21:09 brian Exp $
.Dd 20 September 1995
.nr XX \w'\fC00'
.Dt PPP 8
@@ -2014,6 +2014,8 @@ files.
Log Chat lines containing the string "CONNECT".
.It Li Debug
Log debug information.
+.It Li DNS
+Log DNS QUERY packets.
.It Li HDLC
Dump HDLC packet in hex.
.It Li ID0
diff --git a/usr.sbin/ppp/ppp/prompt.c b/usr.sbin/ppp/ppp/prompt.c
index 5edc1aba8d9..df9677fd970 100644
--- a/usr.sbin/ppp/ppp/prompt.c
+++ b/usr.sbin/ppp/ppp/prompt.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.c,v 1.5 2000/01/07 03:26:55 brian Exp $
+ * $Id: prompt.c,v 1.6 2000/02/27 00:21:09 brian Exp $
*/
#include <sys/param.h>
@@ -120,7 +120,7 @@ prompt_Display(struct prompt *p)
}
static int
-prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+prompt_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct prompt *p = descriptor2prompt(d);
int sets;
@@ -151,7 +151,7 @@ prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-prompt_IsSet(struct descriptor *d, const fd_set *fdset)
+prompt_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct prompt *p = descriptor2prompt(d);
return p->fd_in >= 0 && FD_ISSET(p->fd_in, fdset);
@@ -170,7 +170,7 @@ prompt_ShowHelp(struct prompt *p)
}
static void
-prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+prompt_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct prompt *p = descriptor2prompt(d);
struct prompt *op;
@@ -291,7 +291,7 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-prompt_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+prompt_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
/* We never want to write here ! */
log_Printf(LogALERT, "prompt_Write: Internal error: Bad call !\n");
diff --git a/usr.sbin/ppp/ppp/prompt.h b/usr.sbin/ppp/ppp/prompt.h
index 699d745a460..1c536c62fad 100644
--- a/usr.sbin/ppp/ppp/prompt.h
+++ b/usr.sbin/ppp/ppp/prompt.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: prompt.h,v 1.2 1999/02/06 03:22:43 brian Exp $
+ * $Id: prompt.h,v 1.3 2000/02/27 00:21:09 brian Exp $
*/
#define LOCAL_AUTH 0x01
@@ -38,7 +38,7 @@ struct bundle;
struct cmdargs;
struct prompt {
- struct descriptor desc;
+ struct fdescriptor desc;
int fd_in, fd_out;
struct datalink *TermMode; /* The modem we're talking directly to */
FILE *Term; /* sits on top of fd_out */
diff --git a/usr.sbin/ppp/ppp/radius.c b/usr.sbin/ppp/ppp/radius.c
index e987ebbddad..1bfd59ba251 100644
--- a/usr.sbin/ppp/ppp/radius.c
+++ b/usr.sbin/ppp/ppp/radius.c
@@ -23,19 +23,26 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: radius.c,v 1.5 2000/01/07 03:26:55 brian Exp $
+ * $Id: radius.c,v 1.6 2000/02/27 00:21:09 brian Exp $
*
*/
#include <sys/param.h>
+#include <sys/socket.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/un.h>
+#include <net/route.h>
-#include <errno.h>
+#ifdef LOCALRAD
#include "radlib.h"
+#else
+#include <radlib.h>
+#endif
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -257,16 +264,16 @@ radius_Timeout(void *v)
* Time to call rad_continue_send_request() - something to read.
*/
static void
-radius_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+radius_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
radius_Continue(descriptor2radius(d), 1);
}
/*
- * Behave as a struct descriptor (descriptor.h)
+ * Behave as a struct fdescriptor (descriptor.h)
*/
static int
-radius_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+radius_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct radius *rad = descriptor2radius(d);
@@ -282,10 +289,10 @@ radius_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
/*
- * Behave as a struct descriptor (descriptor.h)
+ * Behave as a struct fdescriptor (descriptor.h)
*/
static int
-radius_IsSet(struct descriptor *d, const fd_set *fdset)
+radius_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct radius *r = descriptor2radius(d);
@@ -293,10 +300,10 @@ radius_IsSet(struct descriptor *d, const fd_set *fdset)
}
/*
- * Behave as a struct descriptor (descriptor.h)
+ * Behave as a struct fdescriptor (descriptor.h)
*/
static int
-radius_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+radius_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
/* We never want to write here ! */
log_Printf(LogALERT, "radius_Write: Internal error: Bad call !\n");
diff --git a/usr.sbin/ppp/ppp/radius.h b/usr.sbin/ppp/ppp/radius.h
index a9b625c6a3f..42df5d18d58 100644
--- a/usr.sbin/ppp/ppp/radius.h
+++ b/usr.sbin/ppp/ppp/radius.h
@@ -23,11 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: radius.h,v 1.1 1999/02/06 03:22:44 brian Exp $
+ * $Id: radius.h,v 1.2 2000/02/27 00:21:09 brian Exp $
*/
struct radius {
- struct descriptor desc; /* We're a sort of (selectable) descriptor */
+ struct fdescriptor desc; /* We're a sort of (selectable) fdescriptor */
struct {
int fd; /* We're selecting on this */
struct rad_handle *rad; /* Using this to talk to our lib */
diff --git a/usr.sbin/ppp/ppp/route.c b/usr.sbin/ppp/ppp/route.c
index 1d5d9b8abd5..0563341913d 100644
--- a/usr.sbin/ppp/ppp/route.c
+++ b/usr.sbin/ppp/ppp/route.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.c,v 1.5 2000/01/07 03:26:55 brian Exp $
+ * $Id: route.c,v 1.6 2000/02/27 00:21:09 brian Exp $
*
*/
@@ -32,6 +32,7 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/un.h>
+#include <netdb.h>
#include <errno.h>
#include <stdio.h>
@@ -67,31 +68,46 @@
#include "prompt.h"
#include "iface.h"
+
static void
p_sockaddr(struct prompt *prompt, struct sockaddr *phost,
struct sockaddr *pmask, int width)
{
char buf[29];
- struct sockaddr_in *ihost = (struct sockaddr_in *)phost;
- struct sockaddr_in *mask = (struct sockaddr_in *)pmask;
+ struct sockaddr_in *ihost4 = (struct sockaddr_in *)phost;
+ struct sockaddr_in *mask4 = (struct sockaddr_in *)pmask;
struct sockaddr_dl *dl = (struct sockaddr_dl *)phost;
+ if (log_IsKept(LogDEBUG)) {
+ char tmp[50];
+
+ log_Printf(LogDEBUG, "Found the following sockaddr:\n");
+ log_Printf(LogDEBUG, " Family %d, len %d\n",
+ (int)phost->sa_family, (int)phost->sa_len);
+ inet_ntop(phost->sa_family, phost->sa_data, tmp, sizeof tmp);
+ log_Printf(LogDEBUG, " Addr %s\n", tmp);
+ if (pmask) {
+ inet_ntop(pmask->sa_family, pmask->sa_data, tmp, sizeof tmp);
+ log_Printf(LogDEBUG, " Mask %s\n", tmp);
+ }
+ }
+
switch (phost->sa_family) {
case AF_INET:
if (!phost)
buf[0] = '\0';
- else if (ihost->sin_addr.s_addr == INADDR_ANY)
+ else if (ihost4->sin_addr.s_addr == INADDR_ANY)
strcpy(buf, "default");
- else if (!mask)
- strcpy(buf, inet_ntoa(ihost->sin_addr));
+ else if (!pmask)
+ strcpy(buf, inet_ntoa(ihost4->sin_addr));
else {
- u_int32_t msk = ntohl(mask->sin_addr.s_addr);
+ u_int32_t msk = ntohl(mask4->sin_addr.s_addr);
u_int32_t tst;
int bits;
int len;
struct sockaddr_in net;
- for (tst = 1, bits=32; tst; tst <<= 1, bits--)
+ for (tst = 1, bits = 32; tst; tst <<= 1, bits--)
if (msk & tst)
break;
@@ -99,7 +115,7 @@ p_sockaddr(struct prompt *prompt, struct sockaddr *phost,
if (!(msk & tst))
break;
- net.sin_addr.s_addr = ihost->sin_addr.s_addr & mask->sin_addr.s_addr;
+ net.sin_addr.s_addr = ihost4->sin_addr.s_addr & mask4->sin_addr.s_addr;
strcpy(buf, inet_ntoa(net.sin_addr));
for (len = strlen(buf); len > 3; buf[len -= 2] = '\0')
if (strcmp(buf + len - 2, ".0"))
@@ -135,6 +151,55 @@ p_sockaddr(struct prompt *prompt, struct sockaddr *phost,
sprintf(buf, "link#%d", dl->sdl_index);
break;
+#ifndef NOINET6
+ case AF_INET6:
+ if (!phost)
+ buf[0] = '\0';
+ else {
+ const u_char masks[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe };
+ struct sockaddr_in6 *ihost6 = (struct sockaddr_in6 *)phost;
+ struct sockaddr_in6 *mask6 = (struct sockaddr_in6 *)pmask;
+ int masklen, len;
+ const u_char *c;
+
+ /* XXX: ?????!?!?!!!!! This is horrible ! */
+ if (IN6_IS_ADDR_LINKLOCAL(&ihost6->sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&ihost6->sin6_addr)) {
+ ihost6->sin6_scope_id =
+ ntohs(*(u_short *)&ihost6->sin6_addr.s6_addr[2]);
+ *(u_short *)&ihost6->sin6_addr.s6_addr[2] = 0;
+ }
+
+ if (mask6) {
+ const u_char *p, *end;
+
+ p = (const u_char *)&mask6->sin6_addr;
+ end = p + 16;
+ for (masklen = 0, end = p + 16; p < end && *p == 0xff; p++)
+ masklen += 8;
+
+ if (p < end) {
+ for (c = masks; c < masks + sizeof masks; c++)
+ if (*c == *p) {
+ masklen += c - masks;
+ break;
+ }
+ }
+ } else
+ masklen = 128;
+
+ if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&ihost6->sin6_addr))
+ snprintf(buf, sizeof buf, "default");
+ else {
+ getnameinfo(phost, ihost6->sin6_len, buf, sizeof buf,
+ NULL, 0, NI_WITHSCOPEID | NI_NUMERICHOST);
+ if (mask6 && (len = strlen(buf)) < sizeof buf - 1)
+ snprintf(buf + len, sizeof buf - len, "/%d", masklen);
+ }
+ }
+ break;
+#endif
+
default:
sprintf(buf, "<AF type %d>", phost->sa_family);
break;
@@ -232,19 +297,21 @@ Index2Nam(int idx)
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
log_Printf(LogERROR, "Index2Nam: sysctl: estimate: %s\n",
strerror(errno));
- return "???";
+ return NumStr(idx, NULL, 0);
}
if ((buf = malloc(needed)) == NULL)
- return "???";
+ return NumStr(idx, NULL, 0);
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
free(buf);
- return "???";
+ return NumStr(idx, NULL, 0);
}
end = buf + needed;
have = 0;
for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) {
ifm = (struct if_msghdr *)ptr;
+ if (ifm->ifm_type != RTM_IFINFO)
+ continue;
dl = (struct sockaddr_dl *)(ifm + 1);
if (ifm->ifm_index > 0) {
if (ifm->ifm_index > have) {
@@ -264,7 +331,7 @@ Index2Nam(int idx)
ifs = NULL;
}
free(buf);
- return "???";
+ return NumStr(idx, NULL, 0);
}
ifs = newifs;
memset(ifs + had, '\0', sizeof(char *) * (have - had));
@@ -294,17 +361,33 @@ Index2Nam(int idx)
}
if (idx < 1 || idx > nifs || ifs[idx-1] == NULL)
- return "???";
+ return NumStr(idx, NULL, 0);
return ifs[idx-1];
}
+void
+route_ParseHdr(struct rt_msghdr *rtm, struct sockaddr *sa[RTAX_MAX])
+{
+ char *wp;
+ int rtax;
+
+ wp = (char *)(rtm + 1);
+
+ for (rtax = 0; rtax < RTAX_MAX; rtax++)
+ if (rtm->rtm_addrs & (1 << rtax)) {
+ sa[rtax] = (struct sockaddr *)wp;
+ wp += ROUNDUP(sa[rtax]->sa_len);
+ } else
+ sa[rtax] = NULL;
+}
+
int
route_Show(struct cmdargs const *arg)
{
struct rt_msghdr *rtm;
- struct sockaddr *sa_dst, *sa_gw, *sa_mask;
- char *sp, *ep, *cp, *wp;
+ struct sockaddr *sa[RTAX_MAX];
+ char *sp, *ep, *cp;
size_t needed;
int mib[6];
@@ -331,32 +414,18 @@ route_Show(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "%-20s%-20sFlags Netif\n",
"Destination", "Gateway");
for (cp = sp; cp < ep; cp += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *) cp;
- wp = (char *)(rtm+1);
+ rtm = (struct rt_msghdr *)cp;
- if (rtm->rtm_addrs & RTA_DST) {
- sa_dst = (struct sockaddr *)wp;
- wp += sa_dst->sa_len;
- } else
- sa_dst = NULL;
+ route_ParseHdr(rtm, sa);
- if (rtm->rtm_addrs & RTA_GATEWAY) {
- sa_gw = (struct sockaddr *)wp;
- wp += sa_gw->sa_len;
- } else
- sa_gw = NULL;
+ if (sa[RTAX_DST] && sa[RTAX_GATEWAY]) {
+ p_sockaddr(arg->prompt, sa[RTAX_DST], sa[RTAX_NETMASK], 20);
+ p_sockaddr(arg->prompt, sa[RTAX_GATEWAY], NULL, 20);
- if (rtm->rtm_addrs & RTA_NETMASK) {
- sa_mask = (struct sockaddr *)wp;
- wp += sa_mask->sa_len;
+ p_flags(arg->prompt, rtm->rtm_flags, 6);
+ prompt_Printf(arg->prompt, " %s\n", Index2Nam(rtm->rtm_index));
} else
- sa_mask = NULL;
-
- p_sockaddr(arg->prompt, sa_dst, sa_mask, 20);
- p_sockaddr(arg->prompt, sa_gw, NULL, 20);
-
- p_flags(arg->prompt, rtm->rtm_flags, 6);
- prompt_Printf(arg->prompt, " %s\n", Index2Nam(rtm->rtm_index));
+ prompt_Printf(arg->prompt, "<can't parse routing entry>\n");
}
free(sp);
return 0;
@@ -369,8 +438,9 @@ void
route_IfDelete(struct bundle *bundle, int all)
{
struct rt_msghdr *rtm;
- struct sockaddr *sa;
- struct in_addr sa_dst, sa_none;
+ struct sockaddr *sa[RTAX_MAX];
+ struct sockaddr_in **in;
+ struct in_addr sa_none;
int pass;
size_t needed;
char *sp, *cp, *ep;
@@ -378,6 +448,7 @@ route_IfDelete(struct bundle *bundle, int all)
log_Printf(LogDEBUG, "route_IfDelete (%d)\n", bundle->iface->index);
sa_none.s_addr = INADDR_ANY;
+ in = (struct sockaddr_in **)sa;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -406,7 +477,7 @@ route_IfDelete(struct bundle *bundle, int all)
for (pass = 0; pass < 2; pass++) {
/*
* We do 2 passes. The first deletes all cloned routes. The second
- * deletes all non-cloned routes. This is necessary to avoid
+ * deletes all non-cloned routes. This is done to avoid
* potential errors from trying to delete route X after route Y where
* route X was cloned from route Y (and is no longer there 'cos it
* may have gone with route Y).
@@ -415,28 +486,30 @@ route_IfDelete(struct bundle *bundle, int all)
/* So we can't tell ! */
continue;
for (cp = sp; cp < ep; cp += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *) cp;
- sa = (struct sockaddr *) (rtm + 1);
- log_Printf(LogDEBUG, "route_IfDelete: addrs: %x, Netif: %d (%s),"
- " flags: %x, dst: %s ?\n", rtm->rtm_addrs, rtm->rtm_index,
- Index2Nam(rtm->rtm_index), rtm->rtm_flags,
- inet_ntoa(((struct sockaddr_in *) sa)->sin_addr));
- if (rtm->rtm_addrs & RTA_DST && rtm->rtm_addrs & RTA_GATEWAY &&
- rtm->rtm_index == bundle->iface->index &&
- (all || (rtm->rtm_flags & RTF_GATEWAY))) {
- sa_dst.s_addr = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
- sa = (struct sockaddr *)((char *)sa + sa->sa_len);
- if (sa->sa_family == AF_INET || sa->sa_family == AF_LINK) {
- if ((pass == 0 && (rtm->rtm_flags & RTF_WASCLONED)) ||
- (pass == 1 && !(rtm->rtm_flags & RTF_WASCLONED))) {
- log_Printf(LogDEBUG, "route_IfDelete: Remove it (pass %d)\n", pass);
- bundle_SetRoute(bundle, RTM_DELETE, sa_dst, sa_none, sa_none, 0, 0);
+ rtm = (struct rt_msghdr *)cp;
+ route_ParseHdr(rtm, sa);
+ if (sa[RTAX_DST]) {
+ log_Printf(LogDEBUG, "route_IfDelete: addrs: %x, Netif: %d (%s),"
+ " flags: %x, dst: %s ?\n", rtm->rtm_addrs, rtm->rtm_index,
+ Index2Nam(rtm->rtm_index), rtm->rtm_flags,
+ inet_ntoa(((struct sockaddr_in *)sa[RTAX_DST])->sin_addr));
+ if (sa[RTAX_GATEWAY] && rtm->rtm_index == bundle->iface->index &&
+ (all || (rtm->rtm_flags & RTF_GATEWAY))) {
+ if (sa[RTAX_GATEWAY]->sa_family == AF_INET ||
+ sa[RTAX_GATEWAY]->sa_family == AF_LINK) {
+ if ((pass == 0 && (rtm->rtm_flags & RTF_WASCLONED)) ||
+ (pass == 1 && !(rtm->rtm_flags & RTF_WASCLONED))) {
+ log_Printf(LogDEBUG, "route_IfDelete: Remove it (pass %d)\n",
+ pass);
+ bundle_SetRoute(bundle, RTM_DELETE, in[RTAX_DST]->sin_addr,
+ sa_none, sa_none, 0, 0);
+ } else
+ log_Printf(LogDEBUG, "route_IfDelete: Skip it (pass %d)\n", pass);
} else
- log_Printf(LogDEBUG, "route_IfDelete: Skip it (pass %d)\n", pass);
- } else
- log_Printf(LogDEBUG,
- "route_IfDelete: Can't remove routes of %d family !\n",
- sa->sa_family);
+ log_Printf(LogDEBUG,
+ "route_IfDelete: Can't remove routes of %d family !\n",
+ sa[RTAX_GATEWAY]->sa_family);
+ }
}
}
}
diff --git a/usr.sbin/ppp/ppp/route.h b/usr.sbin/ppp/ppp/route.h
index 8593b5c2d26..63c3c64b58a 100644
--- a/usr.sbin/ppp/ppp/route.h
+++ b/usr.sbin/ppp/ppp/route.h
@@ -17,12 +17,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.h,v 1.2 1999/02/06 03:22:47 brian Exp $
+ * $Id: route.h,v 1.3 2000/02/27 00:21:09 brian Exp $
*
*/
struct bundle;
struct cmdargs;
+struct rt_msghdr;
+struct sockaddr;
#define ROUTE_STATIC 0
#define ROUTE_DSTMYADDR 1
@@ -52,3 +54,4 @@ extern void route_DeleteAll(struct sticky_route **);
extern void route_Clean(struct bundle *, struct sticky_route *);
extern void route_ShowSticky(struct prompt *, struct sticky_route *,
const char *, int);
+extern void route_ParseHdr(struct rt_msghdr *, struct sockaddr *[RTAX_MAX]);
diff --git a/usr.sbin/ppp/ppp/server.c b/usr.sbin/ppp/ppp/server.c
index 7b5c058fe45..a40cf4108fa 100644
--- a/usr.sbin/ppp/ppp/server.c
+++ b/usr.sbin/ppp/ppp/server.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: server.c,v 1.4 1999/03/08 22:35:37 brian Exp $
+ * $Id: server.c,v 1.5 2000/02/27 00:21:09 brian Exp $
*/
#include <sys/types.h>
@@ -46,7 +46,7 @@
#include "prompt.h"
static int
-server_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
+server_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
{
struct server *s = descriptor2server(d);
struct prompt *p;
@@ -68,7 +68,7 @@ server_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
}
static int
-server_IsSet(struct descriptor *d, const fd_set *fdset)
+server_IsSet(struct fdescriptor *d, const fd_set *fdset)
{
struct server *s = descriptor2server(d);
struct prompt *p;
@@ -84,11 +84,11 @@ server_IsSet(struct descriptor *d, const fd_set *fdset)
}
#define IN_SIZE sizeof(struct sockaddr_in)
-#define UN_SIZE sizeof(struct sockaddr_in)
+#define UN_SIZE sizeof(struct sockaddr_un)
#define ADDRSZ (IN_SIZE > UN_SIZE ? IN_SIZE : UN_SIZE)
static void
-server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+server_Read(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
struct server *s = descriptor2server(d);
char hisaddr[ADDRSZ];
@@ -162,7 +162,7 @@ server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
}
static int
-server_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
+server_Write(struct fdescriptor *d, struct bundle *bundle, const fd_set *fdset)
{
/* We never want to write here ! */
log_Printf(LogALERT, "server_Write: Internal error: Bad call !\n");
diff --git a/usr.sbin/ppp/ppp/server.h b/usr.sbin/ppp/ppp/server.h
index a9c34f86d30..f5506a2be82 100644
--- a/usr.sbin/ppp/ppp/server.h
+++ b/usr.sbin/ppp/ppp/server.h
@@ -23,13 +23,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: server.h,v 1.2 1999/02/06 03:22:47 brian Exp $
+ * $Id: server.h,v 1.3 2000/02/27 00:21:10 brian Exp $
*/
struct bundle;
struct server {
- struct descriptor desc;
+ struct fdescriptor desc;
int fd;
char passwd[50];
diff --git a/usr.sbin/ppp/ppp/timer.c b/usr.sbin/ppp/ppp/timer.c
index e4b3171e0c2..4821cab7eb2 100644
--- a/usr.sbin/ppp/ppp/timer.c
+++ b/usr.sbin/ppp/ppp/timer.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: timer.c,v 1.6 2000/01/07 03:26:56 brian Exp $
+ * $Id: timer.c,v 1.7 2000/02/27 00:21:10 brian Exp $
*
* TODO:
*/
@@ -35,6 +35,11 @@
#include "descriptor.h"
#include "prompt.h"
+
+#define RESTVAL(t) \
+ ((t).it_value.tv_sec * SECTICKS + (t).it_value.tv_usec / TICKUNIT + \
+ ((((t).it_value.tv_usec % TICKUNIT) >= (TICKUNIT >> 1)) ? 1 : 0))
+
static struct pppTimer *TimerList = NULL, *ExpiredList = NULL;
static void StopTimerNoBlock(struct pppTimer *);
@@ -80,8 +85,7 @@ timer_Start(struct pppTimer *tp)
/* Adjust our first delta so that it reflects what's really happening */
if (TimerList && getitimer(ITIMER_REAL, &itimer) == 0)
- TimerList->rest = itimer.it_value.tv_sec * SECTICKS +
- itimer.it_value.tv_usec / TICKUNIT;
+ TimerList->rest = RESTVAL(itimer);
pt = NULL;
for (t = TimerList; t; t = t->next) {
@@ -133,15 +137,24 @@ StopTimerNoBlock(struct pppTimer *tp)
pt = t;
if (t) {
- if (pt) {
+ if (pt)
pt->next = t->next;
- } else {
+ else {
TimerList = t->next;
if (TimerList == NULL) /* Last one ? */
timer_TermService(); /* Terminate Timer Service */
}
- if (t->next)
- t->next->rest += tp->rest;
+ if (t->next) {
+ if (!pt) { /* t (tp) was the first in the list */
+ struct itimerval itimer;
+
+ if (getitimer(ITIMER_REAL, &itimer) == 0)
+ t->rest = RESTVAL(itimer);
+ }
+ t->next->rest += t->rest;
+ if (!pt) /* t->next is now the first in the list */
+ timer_InitService(1);
+ }
} else {
/* Search for any pending expired timers */
pt = NULL;
@@ -215,8 +228,7 @@ timer_Show(int LogLevel, struct prompt *prompt)
/* Adjust our first delta so that it reflects what's really happening */
if (TimerList && getitimer(ITIMER_REAL, &itimer) == 0)
- TimerList->rest = itimer.it_value.tv_sec * SECTICKS +
- itimer.it_value.tv_usec / TICKUNIT;
+ TimerList->rest = RESTVAL(itimer);
#define SECS(val) ((val) / SECTICKS)
#define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS)