summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2002-05-14 12:55:39 +0000
committerbrian <brian@FreeBSD.org>2002-05-14 12:55:39 +0000
commitc2da7c8697491402af4f8ab3082d2c047114ccad (patch)
tree213dbf675b601fdd2934367847c24da5854fd2d9 /usr.sbin/ppp
parent4e0ba1d0e6f3418e983e80b52552d0cd201048bb (diff)
downloadFreeBSD-src-c2da7c8697491402af4f8ab3082d2c047114ccad.zip
FreeBSD-src-c2da7c8697491402af4f8ab3082d2c047114ccad.tar.gz
o Clean up some #includes
o Bump version number to 3.0.4 o When talking to a RADIUS server, provide a NAS-Port-Type. When the NAS-Port-Type is Ethernet, provide a NAS-Port value equal to the SESSIONID from the environment in direct mode or the NGM_PPPOE_SESSIONID message in other modes. If no SESSIONID is found, default to the interface index in client mode or zero in server mode. When the NAS-Port-Type is ISDN, set the NAS-Port to the minor number of the physical device (ie, the N in /dev/i4brbchN). This makes it easier for the RADIUS server to identify the client WRT accounting data etc. Prompted by: lsz8425 <lsz8425@mail.cd.hn.cn>
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/atm.c1
-rw-r--r--usr.sbin/ppp/auth.c1
-rw-r--r--usr.sbin/ppp/cbcp.c3
-rw-r--r--usr.sbin/ppp/ccp.c1
-rw-r--r--usr.sbin/ppp/chap.c1
-rw-r--r--usr.sbin/ppp/chat.c1
-rw-r--r--usr.sbin/ppp/command.c3
-rw-r--r--usr.sbin/ppp/datalink.c1
-rw-r--r--usr.sbin/ppp/deflate.c5
-rw-r--r--usr.sbin/ppp/defs.c1
-rw-r--r--usr.sbin/ppp/ether.c47
-rw-r--r--usr.sbin/ppp/exec.c1
-rw-r--r--usr.sbin/ppp/filter.c4
-rw-r--r--usr.sbin/ppp/fsm.c1
-rw-r--r--usr.sbin/ppp/i4b.c15
-rw-r--r--usr.sbin/ppp/iface.c2
-rw-r--r--usr.sbin/ppp/ip.c2
-rw-r--r--usr.sbin/ppp/lcp.c1
-rw-r--r--usr.sbin/ppp/lqr.c4
-rw-r--r--usr.sbin/ppp/main.c2
-rw-r--r--usr.sbin/ppp/mp.c1
-rw-r--r--usr.sbin/ppp/mppe.c6
-rw-r--r--usr.sbin/ppp/ncp.c14
-rw-r--r--usr.sbin/ppp/ncpaddr.c10
-rw-r--r--usr.sbin/ppp/netgraph.c1
-rw-r--r--usr.sbin/ppp/pap.c1
-rw-r--r--usr.sbin/ppp/physical.c13
-rw-r--r--usr.sbin/ppp/physical.h2
-rw-r--r--usr.sbin/ppp/prompt.c1
-rw-r--r--usr.sbin/ppp/radius.c92
-rw-r--r--usr.sbin/ppp/route.c25
-rw-r--r--usr.sbin/ppp/server.c2
-rw-r--r--usr.sbin/ppp/sig.c2
-rw-r--r--usr.sbin/ppp/slcompress.c1
-rw-r--r--usr.sbin/ppp/systems.c1
-rw-r--r--usr.sbin/ppp/tcp.c1
-rw-r--r--usr.sbin/ppp/tcpmss.c1
-rw-r--r--usr.sbin/ppp/timer.c1
-rw-r--r--usr.sbin/ppp/tty.c21
-rw-r--r--usr.sbin/ppp/tun.c1
-rw-r--r--usr.sbin/ppp/udp.c1
-rw-r--r--usr.sbin/ppp/vjcomp.c1
42 files changed, 163 insertions, 133 deletions
diff --git a/usr.sbin/ppp/atm.c b/usr.sbin/ppp/atm.c
index 084418f..5d41bac 100644
--- a/usr.sbin/ppp/atm.c
+++ b/usr.sbin/ppp/atm.c
@@ -136,6 +136,7 @@ static const struct device baseatmdevice = {
atm_Sendto,
atm_device2iov,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index 1368cc3..3cdb9e8 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -53,7 +53,6 @@
#include "lqr.h"
#include "hdlc.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "auth.h"
#include "systems.h"
diff --git a/usr.sbin/ppp/cbcp.c b/usr.sbin/ppp/cbcp.c
index 8e9025a..266a502 100644
--- a/usr.sbin/ppp/cbcp.c
+++ b/usr.sbin/ppp/cbcp.c
@@ -28,6 +28,9 @@
#include <sys/param.h>
+#ifdef __FreeBSD__
+#include <netinet/in.h>
+#endif
#include <sys/un.h>
#include <string.h>
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index caa00fb..a0f6490 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -58,7 +58,6 @@
#include "lcp.h"
#include "ccp.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c
index 1ace405..cb907e6 100644
--- a/usr.sbin/ppp/chap.c
+++ b/usr.sbin/ppp/chap.c
@@ -68,7 +68,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "ccp.h"
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index 3bd3bae..79632b1 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -65,7 +65,6 @@
#include "slcompress.h"
#include "iplist.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "cbcp.h"
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 8f6c5e8..d9646a5 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -71,7 +71,6 @@
#include "hdlc.h"
#include "lcp.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#ifndef NONAT
#include "nat_cmd.h"
@@ -164,7 +163,7 @@
#define NEG_MPPE 54
#define NEG_CHAP81 55
-const char Version[] = "3.0.3";
+const char Version[] = "3.0.4";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index 87cab95..7a99589 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/ppp/datalink.c
@@ -58,7 +58,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "mp.h"
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c
index 7e9c77d..f629c5b 100644
--- a/usr.sbin/ppp/deflate.c
+++ b/usr.sbin/ppp/deflate.c
@@ -30,17 +30,12 @@
#include <stdio.h>
#include <stdlib.h>
-#include <termios.h>
#include <zlib.h>
-#include "defs.h"
#include "mbuf.h"
#include "log.h"
#include "timer.h"
#include "fsm.h"
-#include "lqr.h"
-#include "hdlc.h"
-#include "lcp.h"
#include "ccp.h"
#include "deflate.h"
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index a4929cc..f29eff6 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -40,7 +40,6 @@
#include <stdlib.h>
#include <string.h>
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
-#include <sys/linker.h>
#include <sys/module.h>
#endif
#include <termios.h>
diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c
index 3f65f1c..9c3f752 100644
--- a/usr.sbin/ppp/ether.c
+++ b/usr.sbin/ppp/ether.c
@@ -53,6 +53,7 @@
#include <sys/uio.h>
#include <termios.h>
#include <sys/time.h>
+#include <syslog.h>
#include <unistd.h>
#include "layer.h"
@@ -91,6 +92,7 @@
#include "bundle.h"
#include "id.h"
#include "iface.h"
+#include "route.h"
#include "ether.h"
@@ -102,6 +104,7 @@ struct etherdevice {
int connected; /* Are we connected yet ? */
int timeout; /* Seconds attempting to connect */
char hook[sizeof TUN_NAME + 11]; /* Our socket node hook */
+ u_int32_t slot; /* ifindex << 24 | unit */
};
#define device2ether(d) \
@@ -177,6 +180,15 @@ ether_OpenInfo(struct physical *p)
return "disconnected";
}
+static int
+ether_Slot(struct physical *p)
+{
+ struct etherdevice *dev = device2ether(p->handler);
+
+ return dev->slot;
+}
+
+
static void
ether_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov, int *auxfd, int *nauxfd)
@@ -204,10 +216,11 @@ ether_MessageIn(struct etherdevice *dev)
char msgbuf[sizeof(struct ng_mesg) + sizeof(struct ngpppoe_sts)];
struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep);
- char unknown[14];
+ char *end, unknown[14], sessionid[5];
const char *msg;
struct timeval t;
fd_set *r;
+ u_long slot;
int ret;
if (dev->cs < 0)
@@ -255,6 +268,17 @@ ether_MessageIn(struct etherdevice *dev)
if (setenv("ACNAME", sts->hook, 1) != 0)
log_Printf(LogWARN, "setenv: cannot set ACNAME=%s: %m", sts->hook);
break;
+ case NGM_PPPOE_SESSIONID:
+ msg = "SESSIONID";
+ snprintf(sessionid, sizeof sessionid, "%04x", *(u_int16_t *)sts);
+ if (setenv("SESSIONID", sessionid, 1) != 0)
+ syslog(LOG_WARNING, "setenv: cannot set SESSIONID=%s: %m",
+ sessionid);
+ /* Use this in preference to our interface index */
+ slot = strtoul(sessionid, &end, 16);
+ if (end != sessionid && *end == '\0')
+ dev->slot = slot;
+ break;
default:
snprintf(unknown, sizeof unknown, "<%d>", (int)rep->header.cmd);
msg = unknown;
@@ -304,7 +328,8 @@ static const struct device baseetherdevice = {
ether_Write,
ether_device2iov,
NULL,
- ether_OpenInfo
+ ether_OpenInfo,
+ ether_Slot
};
struct device *
@@ -409,7 +434,7 @@ ether_Create(struct physical *p)
struct ng_mesg *resp;
const struct hooklist *hlist;
const struct nodeinfo *ninfo;
- char *path;
+ char *path, *sessionid;
int ifacelen, f;
dev = NULL;
@@ -625,7 +650,8 @@ ether_Create(struct physical *p)
dev->timeout = dev->dev.cd.delay;
dev->connected = CARRIER_PENDING;
-
+ /* This will be overridden by our session id - if provided by netgraph */
+ dev->slot = GetIfIndex(path);
} else {
/* See if we're a netgraph socket */
struct stat st;
@@ -661,6 +687,19 @@ ether_Create(struct physical *p)
dev->timeout = 0;
dev->connected = CARRIER_OK;
*dev->hook = '\0';
+
+ /*
+ * If we're being envoked from pppoed(8), we may have a SESSIONID
+ * set in the environment. If so, use it as the slot
+ */
+ if ((sessionid = getenv("SESSIONID")) != NULL) {
+ char *end;
+ u_long slot;
+
+ slot = strtoul(sessionid, &end, 16);
+ dev->slot = end != sessionid && *end == '\0' ? slot : 0;
+ } else
+ dev->slot = 0;
}
}
}
diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c
index 98b1b74..67d00ac 100644
--- a/usr.sbin/ppp/exec.c
+++ b/usr.sbin/ppp/exec.c
@@ -82,6 +82,7 @@ static struct device execdevice = {
NULL,
NULL,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c
index b553d33..61f03ab 100644
--- a/usr.sbin/ppp/filter.c
+++ b/usr.sbin/ppp/filter.c
@@ -30,7 +30,6 @@
#include <sys/param.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
@@ -39,7 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
+#include <string.h>
#include <termios.h>
#include "layer.h"
@@ -58,7 +57,6 @@
#include "link.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c
index bfa3eed..09bef00 100644
--- a/usr.sbin/ppp/fsm.c
+++ b/usr.sbin/ppp/fsm.c
@@ -51,7 +51,6 @@
#include "throughput.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/i4b.c b/usr.sbin/ppp/i4b.c
index cf2032d..5744e89 100644
--- a/usr.sbin/ppp/i4b.c
+++ b/usr.sbin/ppp/i4b.c
@@ -32,6 +32,7 @@
#if defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/ioctl.h>
#endif
+#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
@@ -274,6 +275,17 @@ i4b_OpenInfo(struct physical *p)
return buf;
}
+static int
+i4b_Slot(struct physical *p)
+{
+ struct stat st;
+
+ if (fstat(p->fd, &st) == 0)
+ return minor(st.st_rdev);
+
+ return -1;
+}
+
static void
i4b_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov, int *auxfd, int *nauxfd)
@@ -312,7 +324,8 @@ static struct device basei4bdevice = {
NULL,
i4b_device2iov,
i4b_Speed,
- i4b_OpenInfo
+ i4b_OpenInfo,
+ i4b_Slot
};
struct device *
diff --git a/usr.sbin/ppp/iface.c b/usr.sbin/ppp/iface.c
index e1aeff8..b5ae7b4 100644
--- a/usr.sbin/ppp/iface.c
+++ b/usr.sbin/ppp/iface.c
@@ -35,7 +35,6 @@
#include <net/if_var.h>
#endif
#include <net/route.h>
-#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
@@ -68,7 +67,6 @@
#include "slcompress.h"
#include "descriptor.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "lcp.h"
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index 30b6cb6..269376f 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -40,13 +40,11 @@
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
-#include <arpa/inet.h>
#include <sys/un.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 3d90be9..e4a92ac 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -64,7 +64,6 @@
#include "prompt.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "mp.h"
diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c
index 881d967..2fe1844 100644
--- a/usr.sbin/ppp/lqr.c
+++ b/usr.sbin/ppp/lqr.c
@@ -29,6 +29,10 @@
*/
#include <sys/param.h>
+
+#ifdef __FreeBSD__
+#include <netinet/in.h>
+#endif
#include <sys/un.h>
#include <string.h>
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 1fb6737..f0b0794 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -43,7 +43,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/time.h>
#include <termios.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -72,7 +71,6 @@
#include "throughput.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index 3e2ca1b..7e71dad 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -62,7 +62,6 @@
#include "lqr.h"
#include "hdlc.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "auth.h"
#include "lcp.h"
diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c
index 2ce267d..bc5a499 100644
--- a/usr.sbin/ppp/mppe.c
+++ b/usr.sbin/ppp/mppe.c
@@ -34,13 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <termios.h>
-#ifdef __FreeBSD__
-#include <sha.h>
-#else
-#include <openssl/sha.h>
-#endif
#include <openssl/rc4.h>
#include "defs.h"
diff --git a/usr.sbin/ppp/ncp.c b/usr.sbin/ppp/ncp.c
index a68c91f..ea03144 100644
--- a/usr.sbin/ppp/ncp.c
+++ b/usr.sbin/ppp/ncp.c
@@ -30,31 +30,23 @@
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
-#include <arpa/inet.h>
#include <sys/socket.h>
-#include <net/if.h>
#include <net/route.h>
-#include <netdb.h>
#include <sys/un.h>
#include <errno.h>
-#include <fcntl.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
#include <termios.h>
-#include <unistd.h>
#include "layer.h"
-#include "ua.h"
#include "defs.h"
#include "command.h"
#include "mbuf.h"
#include "log.h"
#include "timer.h"
#include "fsm.h"
-#include "proto.h"
#include "iplist.h"
#include "throughput.h"
#include "slcompress.h"
@@ -62,11 +54,9 @@
#include "hdlc.h"
#include "lcp.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
-#include "vjcomp.h"
#include "async.h"
#include "ccp.h"
#include "link.h"
@@ -78,16 +68,12 @@
#include "ipv6cp.h"
#include "ncp.h"
#include "bundle.h"
-#include "id.h"
-#include "arp.h"
-#include "systems.h"
#include "prompt.h"
#include "route.h"
#include "iface.h"
#include "chat.h"
#include "auth.h"
#include "chap.h"
-#include "pap.h"
#include "cbcp.h"
#include "datalink.h"
diff --git a/usr.sbin/ppp/ncpaddr.c b/usr.sbin/ppp/ncpaddr.c
index 943db3d..239253d 100644
--- a/usr.sbin/ppp/ncpaddr.c
+++ b/usr.sbin/ppp/ncpaddr.c
@@ -28,15 +28,12 @@
#include <sys/types.h>
#include <sys/socket.h>
-#include <net/if_types.h>
-#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/un.h>
-#include <limits.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@@ -52,11 +49,8 @@
#include "iplist.h"
#include "throughput.h"
#include "mbuf.h"
-#include "ip.h"
#include "ipcp.h"
-#include "filter.h"
#include "descriptor.h"
-#include "route.h"
#include "layer.h"
#include "lqr.h"
#include "hdlc.h"
@@ -64,12 +58,8 @@
#include "ccp.h"
#include "link.h"
#include "mp.h"
-#ifndef NORADIUS
-#include "radius.h"
-#endif
#include "ipv6cp.h"
#include "ncp.h"
-#include "bundle.h"
#define ncprange_ip4addr u.ip4.ipaddr
diff --git a/usr.sbin/ppp/netgraph.c b/usr.sbin/ppp/netgraph.c
index 748ff0e..e8acaa0 100644
--- a/usr.sbin/ppp/netgraph.c
+++ b/usr.sbin/ppp/netgraph.c
@@ -313,6 +313,7 @@ static const struct device basengdevice = {
ng_Write,
ng_device2iov,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c
index d4a2a65..bc43f5d 100644
--- a/usr.sbin/ppp/pap.c
+++ b/usr.sbin/ppp/pap.c
@@ -60,7 +60,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "mp.h"
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index 9bce72e..476fc84 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -30,9 +30,6 @@
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
-#ifdef NOSUID
-#include <signal.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -71,7 +68,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
@@ -1114,3 +1110,12 @@ physical_SetAsyncParams(struct physical *p, u_int32_t mymap, u_int32_t hismap)
async_SetLinkParams(&p->async, mymap, hismap);
}
+
+int
+physical_Slot(struct physical *p)
+{
+ if (p->handler && p->handler->slot)
+ return (*p->handler->slot)(p);
+
+ return -1;
+}
diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h
index eb7c0d5..f1e3ec5 100644
--- a/usr.sbin/ppp/physical.h
+++ b/usr.sbin/ppp/physical.h
@@ -73,6 +73,7 @@ struct device {
void (*device2iov)(struct device *, struct iovec *, int *, int, int *, int *);
int (*speed)(struct physical *);
const char *(*openinfo)(struct physical *);
+ int (*slot)(struct physical *);
};
struct physical {
@@ -169,3 +170,4 @@ extern int physical_MaxDeviceSize(void);
extern int physical_AwaitCarrier(struct physical *);
extern void physical_SetDescriptor(struct physical *);
extern void physical_SetAsyncParams(struct physical *, u_int32_t, u_int32_t);
+extern int physical_Slot(struct physical *);
diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c
index 3881026..05509c1 100644
--- a/usr.sbin/ppp/prompt.c
+++ b/usr.sbin/ppp/prompt.c
@@ -59,7 +59,6 @@
#include "hdlc.h"
#include "lcp.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "async.h"
diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c
index e666165..0a98436 100644
--- a/usr.sbin/ppp/radius.c
+++ b/usr.sbin/ppp/radius.c
@@ -50,7 +50,6 @@
#include <string.h>
#include <sys/time.h>
#include <termios.h>
-#include <ttyent.h>
#include <unistd.h>
#include <netdb.h>
@@ -470,6 +469,51 @@ radius_Destroy(struct radius *r)
}
}
+static int
+radius_put_physical_details(struct rad_handle *rad, struct physical *p)
+{
+ int slot, type;
+
+ type = RAD_VIRTUAL;
+ if (p->handler)
+ switch (p->handler->type) {
+ case I4B_DEVICE:
+ type = RAD_ISDN_SYNC;
+ break;
+
+ case TTY_DEVICE:
+ type = RAD_ASYNC;
+ break;
+
+ case ETHER_DEVICE:
+ type = RAD_ETHERNET;
+ break;
+
+ case TCP_DEVICE:
+ case UDP_DEVICE:
+ case EXEC_DEVICE:
+ case ATM_DEVICE:
+ case NG_DEVICE:
+ type = RAD_VIRTUAL;
+ break;
+ }
+
+ if (rad_put_int(rad, RAD_NAS_PORT_TYPE, type) != 0) {
+ log_Printf(LogERROR, "rad_put: rad_put_int: %s\n", rad_strerror(rad));
+ rad_close(rad);
+ return 0;
+ }
+
+ if ((slot = physical_Slot(p)) >= 0)
+ if (rad_put_int(rad, RAD_NAS_PORT, slot) != 0) {
+ log_Printf(LogERROR, "rad_put: rad_put_int: %s\n", rad_strerror(rad));
+ rad_close(rad);
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* Start an authentication request to the RADIUS server.
*/
@@ -477,9 +521,8 @@ void
radius_Authenticate(struct radius *r, struct authinfo *authp, const char *name,
const char *key, int klen, const char *challenge, int clen)
{
- struct ttyent *ttyp;
struct timeval tv;
- int got, slot;
+ int got;
char hostname[MAXHOSTNAMELEN];
struct hostent *hp;
struct in_addr hostaddr;
@@ -594,28 +637,7 @@ radius_Authenticate(struct radius *r, struct authinfo *authp, const char *name,
}
}
- if (authp->physical->handler &&
- authp->physical->handler->type == TTY_DEVICE) {
- setttyent();
- for (slot = 1; (ttyp = getttyent()); ++slot)
- if (!strcmp(ttyp->ty_name, authp->physical->name.base)) {
- if (rad_put_int(r->cx.rad, RAD_NAS_PORT, slot) != 0) {
- log_Printf(LogERROR, "rad_put: rad_put_int: %s\n",
- rad_strerror(r->cx.rad));
- rad_close(r->cx.rad);
- endttyent();
- return;
- }
- break;
- }
- endttyent();
- } else if (rad_put_int(r->cx.rad, RAD_NAS_PORT, 0) != 0) {
- log_Printf(LogERROR, "rad_put: rad_put_int: %s\n",
- rad_strerror(r->cx.rad));
- rad_close(r->cx.rad);
- return;
- }
-
+ radius_put_physical_details(r->cx.rad, authp->physical);
r->cx.auth = authp;
if ((got = rad_init_send_request(r->cx.rad, &r->cx.fd, &tv)))
@@ -639,9 +661,8 @@ radius_Account(struct radius *r, struct radacct *ac, struct datalink *dl,
int acct_type, struct in_addr *peer_ip, struct in_addr *netmask,
struct pppThroughput *stats)
{
- struct ttyent *ttyp;
struct timeval tv;
- int got, slot;
+ int got;
char hostname[MAXHOSTNAMELEN];
struct hostent *hp;
struct in_addr hostaddr;
@@ -729,22 +750,7 @@ radius_Account(struct radius *r, struct radacct *ac, struct datalink *dl,
}
}
- if (dl->physical->handler &&
- dl->physical->handler->type == TTY_DEVICE) {
- setttyent();
- for (slot = 1; (ttyp = getttyent()); ++slot)
- if (!strcmp(ttyp->ty_name, dl->physical->name.base)) {
- if (rad_put_int(r->cx.rad, RAD_NAS_PORT, slot) != 0) {
- log_Printf(LogERROR, "rad_put: rad_put_string: %s\n",
- rad_strerror(r->cx.rad));
- rad_close(r->cx.rad);
- endttyent();
- return;
- }
- break;
- }
- endttyent();
- }
+ radius_put_physical_details(r->cx.rad, dl->physical);
if (rad_put_int(r->cx.rad, RAD_ACCT_STATUS_TYPE, acct_type) != 0 ||
rad_put_string(r->cx.rad, RAD_ACCT_SESSION_ID, ac->session_id) != 0 ||
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index a75cabd..e1a99c1 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -39,7 +39,6 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/un.h>
-#include <netdb.h>
#include <errno.h>
#include <stdio.h>
@@ -65,7 +64,6 @@
#include "link.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
@@ -200,6 +198,8 @@ p_flags(struct prompt *prompt, u_int32_t f, int max)
prompt_Printf(prompt, "%-*.*s", max, max, name);
}
+static int route_nifs = -1;
+
const char *
Index2Nam(int idx)
{
@@ -210,9 +210,9 @@ Index2Nam(int idx)
* the PCCARD insert/remove events can signal ppp.
*/
static char **ifs; /* Figure these out once */
- static int nifs, debug_done; /* Figure out how many once, and debug once */
+ static int debug_done; /* Debug once */
- if (idx > nifs || (idx > 0 && ifs[idx-1] == NULL)) {
+ if (idx > route_nifs || (idx > 0 && ifs[idx-1] == NULL)) {
int mib[6], have, had;
size_t needed;
char *buf, *ptr, *end;
@@ -222,7 +222,7 @@ Index2Nam(int idx)
if (ifs) {
free(ifs);
ifs = NULL;
- nifs = 0;
+ route_nifs = 0;
}
debug_done = 0;
@@ -264,7 +264,7 @@ Index2Nam(int idx)
newifs = (char **)malloc(sizeof(char *) * have);
if (!newifs) {
log_Printf(LogDEBUG, "Index2Nam: %s\n", strerror(errno));
- nifs = 0;
+ route_nifs = 0;
if (ifs) {
free(ifs);
ifs = NULL;
@@ -279,8 +279,8 @@ Index2Nam(int idx)
ifs[ifm->ifm_index-1] = (char *)malloc(dl->sdl_nlen+1);
memcpy(ifs[ifm->ifm_index-1], dl->sdl_data, dl->sdl_nlen);
ifs[ifm->ifm_index-1][dl->sdl_nlen] = '\0';
- if (nifs < ifm->ifm_index)
- nifs = ifm->ifm_index;
+ if (route_nifs < ifm->ifm_index)
+ route_nifs = ifm->ifm_index;
}
} else if (log_IsKept(LogDEBUG))
log_Printf(LogDEBUG, "Skipping out-of-range interface %d!\n",
@@ -293,13 +293,13 @@ Index2Nam(int idx)
int f;
log_Printf(LogDEBUG, "Found the following interfaces:\n");
- for (f = 0; f < nifs; f++)
+ for (f = 0; f < route_nifs; f++)
if (ifs[f] != NULL)
log_Printf(LogDEBUG, " Index %d, name \"%s\"\n", f+1, ifs[f]);
debug_done = 1;
}
- if (idx < 1 || idx > nifs || ifs[idx-1] == NULL)
+ if (idx < 1 || idx > route_nifs || ifs[idx-1] == NULL)
return NumStr(idx, NULL, 0);
return ifs[idx-1];
@@ -529,11 +529,10 @@ int
GetIfIndex(char *name)
{
int idx;
- const char *got;
idx = 1;
- while (strcmp(got = Index2Nam(idx), "???"))
- if (!strcmp(got, name))
+ while (route_nifs == -1 || idx < route_nifs)
+ if (strcmp(Index2Nam(idx), name) == 0)
return idx;
else
idx++;
diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c
index c696771..0c13bde 100644
--- a/usr.sbin/ppp/server.c
+++ b/usr.sbin/ppp/server.c
@@ -30,7 +30,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <sys/un.h>
#include <errno.h>
@@ -43,7 +42,6 @@
#include "log.h"
#include "descriptor.h"
#include "server.h"
-#include "id.h"
#include "prompt.h"
#include "ncpaddr.h"
#include "probe.h"
diff --git a/usr.sbin/ppp/sig.c b/usr.sbin/ppp/sig.c
index a42194b..49ca42c 100644
--- a/usr.sbin/ppp/sig.c
+++ b/usr.sbin/ppp/sig.c
@@ -26,8 +26,6 @@
* $FreeBSD$
*/
-#include <sys/types.h>
-
#include <signal.h>
#include "log.h"
diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c
index 82f70d6..6df3fa2 100644
--- a/usr.sbin/ppp/slcompress.c
+++ b/usr.sbin/ppp/slcompress.c
@@ -50,7 +50,6 @@
#include "lqr.h"
#include "hdlc.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "lcp.h"
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index 68e888f..24f58a5 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -36,7 +36,6 @@
#include <stdlib.h>
#include <string.h>
#include <termios.h>
-#include <unistd.h>
#include "defs.h"
#include "command.h"
diff --git a/usr.sbin/ppp/tcp.c b/usr.sbin/ppp/tcp.c
index e7968c0..9a45e98 100644
--- a/usr.sbin/ppp/tcp.c
+++ b/usr.sbin/ppp/tcp.c
@@ -114,6 +114,7 @@ static struct device tcpdevice = {
NULL,
NULL,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/tcpmss.c b/usr.sbin/ppp/tcpmss.c
index c99739e..b694624 100644
--- a/usr.sbin/ppp/tcpmss.c
+++ b/usr.sbin/ppp/tcpmss.c
@@ -53,7 +53,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/timer.c b/usr.sbin/ppp/timer.c
index 3003b6c..edd242c 100644
--- a/usr.sbin/ppp/timer.c
+++ b/usr.sbin/ppp/timer.c
@@ -32,7 +32,6 @@
#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <sys/time.h>
#include <termios.h>
#include "log.h"
diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c
index a246aab..b26bfdb 100644
--- a/usr.sbin/ppp/tty.c
+++ b/usr.sbin/ppp/tty.c
@@ -40,6 +40,7 @@
#include <sysexits.h>
#include <sys/uio.h>
#include <termios.h>
+#include <ttyent.h>
#include <unistd.h>
#ifndef NONETGRAPH
#include <netgraph.h>
@@ -553,6 +554,23 @@ tty_OpenInfo(struct physical *p)
return buf;
}
+static int
+tty_Slot(struct physical *p)
+{
+ struct ttyent *ttyp;
+ int slot;
+
+ setttyent();
+ for (slot = 1; (ttyp = getttyent()); ++slot)
+ if (!strcmp(ttyp->ty_name, p->name.base)) {
+ endttyent();
+ return slot;
+ }
+
+ endttyent();
+ return -1;
+}
+
static void
tty_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov, int *auxfd, int *nauxfd)
@@ -598,7 +616,8 @@ static struct device basettydevice = {
tty_Write,
tty_device2iov,
tty_Speed,
- tty_OpenInfo
+ tty_OpenInfo,
+ tty_Slot
};
struct device *
diff --git a/usr.sbin/ppp/tun.c b/usr.sbin/ppp/tun.c
index b48f733..1c55fcf 100644
--- a/usr.sbin/ppp/tun.c
+++ b/usr.sbin/ppp/tun.c
@@ -64,7 +64,6 @@
#include "iplist.h"
#include "slcompress.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "filter.h"
#include "descriptor.h"
diff --git a/usr.sbin/ppp/udp.c b/usr.sbin/ppp/udp.c
index e8f97bb..47cab3f 100644
--- a/usr.sbin/ppp/udp.c
+++ b/usr.sbin/ppp/udp.c
@@ -168,6 +168,7 @@ static const struct device baseudpdevice = {
udp_Sendto,
udp_device2iov,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c
index 3901335..8bc03db 100644
--- a/usr.sbin/ppp/vjcomp.c
+++ b/usr.sbin/ppp/vjcomp.c
@@ -52,7 +52,6 @@
#include "iplist.h"
#include "throughput.h"
#include "ncpaddr.h"
-#include "ip.h"
#include "ipcp.h"
#include "lcp.h"
#include "ccp.h"
OpenPOWER on IntegriCloud