diff --git a/usr.sbin/ppp/atm.c b/usr.sbin/ppp/atm.c index 084418f8670..5d41bacb547 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 1368cc3a8d7..3cdb9e8c1c5 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 8e9025a2abf..266a5027032 100644 --- a/usr.sbin/ppp/cbcp.c +++ b/usr.sbin/ppp/cbcp.c @@ -28,6 +28,9 @@ #include +#ifdef __FreeBSD__ +#include +#endif #include #include diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index caa00fbb0ff..a0f6490080d 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 1ace4057932..cb907e63d07 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 3bd3bae9752..79632b1fc92 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 8f6c5e83b06..d9646a520c6 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 87cab957078..7a9958943ac 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 7e9c77dd7c7..f629c5b028c 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -30,17 +30,12 @@ #include #include -#include #include -#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 a4929ccc984..f29eff655ca 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -40,7 +40,6 @@ #include #include #if defined(__FreeBSD__) && !defined(NOKLDLOAD) -#include #include #endif #include diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c index 3f65f1cc694..9c3f752ae1f 100644 --- a/usr.sbin/ppp/ether.c +++ b/usr.sbin/ppp/ether.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #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 98b1b7459f8..67d00ac6bf3 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 b553d33818e..61f03ab472a 100644 --- a/usr.sbin/ppp/filter.c +++ b/usr.sbin/ppp/filter.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -39,7 +38,7 @@ #include #include -#include +#include #include #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 bfa3eed438b..09bef0058d0 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 cf2032dcbad..5744e89dfad 100644 --- a/usr.sbin/ppp/i4b.c +++ b/usr.sbin/ppp/i4b.c @@ -32,6 +32,7 @@ #if defined(__OpenBSD__) || defined(__NetBSD__) #include #endif +#include #include #include @@ -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 e1aeff8d592..b5ae7b48581 100644 --- a/usr.sbin/ppp/iface.c +++ b/usr.sbin/ppp/iface.c @@ -35,7 +35,6 @@ #include #endif #include -#include #include #include #include @@ -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 30b6cb6f668..269376fa798 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -40,13 +40,11 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 3d90be94038..e4a92ace865 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 881d967cfc1..2fe1844d08d 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -29,6 +29,10 @@ */ #include + +#ifdef __FreeBSD__ +#include +#endif #include #include diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 1fb6737f598..f0b079474c8 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -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 3e2ca1b5d53..7e71dadbed8 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 2ce267ddd16..bc5a499ac2c 100644 --- a/usr.sbin/ppp/mppe.c +++ b/usr.sbin/ppp/mppe.c @@ -34,13 +34,7 @@ #include #include -#include #include -#ifdef __FreeBSD__ -#include -#else -#include -#endif #include #include "defs.h" diff --git a/usr.sbin/ppp/ncp.c b/usr.sbin/ppp/ncp.c index a68c91f1e0f..ea031444189 100644 --- a/usr.sbin/ppp/ncp.c +++ b/usr.sbin/ppp/ncp.c @@ -30,31 +30,23 @@ #include #include #include -#include #include -#include #include -#include #include #include -#include #include #include #include -#include #include -#include #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 943db3dd937..239253dd8ad 100644 --- a/usr.sbin/ppp/ncpaddr.c +++ b/usr.sbin/ppp/ncpaddr.c @@ -28,15 +28,12 @@ #include #include -#include -#include #include #include #include #include #include -#include #include #include #include @@ -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 748ff0efb09..e8acaa0ee84 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 d4a2a65fa56..bc43f5d3305 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 9bce72e3e31..476fc840cb7 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -30,9 +30,6 @@ #include #include #include -#ifdef NOSUID -#include -#endif #include #include #include @@ -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 eb7c0d50e63..f1e3ec59da2 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 388102640a9..05509c11efa 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 e666165e397..0a98436b90c 100644 --- a/usr.sbin/ppp/radius.c +++ b/usr.sbin/ppp/radius.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -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 a75cabda620..e1a99c17ea6 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -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 c696771ecfc..0c13bde3ca5 100644 --- a/usr.sbin/ppp/server.c +++ b/usr.sbin/ppp/server.c @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -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 a42194be0c7..49ca42cf378 100644 --- a/usr.sbin/ppp/sig.c +++ b/usr.sbin/ppp/sig.c @@ -26,8 +26,6 @@ * $FreeBSD$ */ -#include - #include #include "log.h" diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c index 82f70d66d26..6df3fa2a823 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 68e888f6308..24f58a50d90 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -36,7 +36,6 @@ #include #include #include -#include #include "defs.h" #include "command.h" diff --git a/usr.sbin/ppp/tcp.c b/usr.sbin/ppp/tcp.c index e7968c09609..9a45e9814f0 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 c99739e5104..b6946240e52 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 3003b6c39a8..edd242c6be0 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "log.h" diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c index a246aab9544..b26bfdbcc78 100644 --- a/usr.sbin/ppp/tty.c +++ b/usr.sbin/ppp/tty.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #ifndef NONETGRAPH #include @@ -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 b48f7333ec7..1c55fcfee3f 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 e8f97bb169a..47cab3f7ab0 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 3901335475b..8bc03dbab26 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"