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>
This commit is contained in:
parent
8b20c954cb
commit
de59e178aa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96582
@ -136,6 +136,7 @@ static const struct device baseatmdevice = {
|
||||
atm_Sendto,
|
||||
atm_device2iov,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -28,6 +28,9 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 *);
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ static struct device execdevice = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 *
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -29,6 +29,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -313,6 +313,7 @@ static const struct device basengdevice = {
|
||||
ng_Write,
|
||||
ng_device2iov,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 *);
|
||||
|
@ -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"
|
||||
|
@ -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 ||
|
||||
|
@ -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++;
|
||||
|
@ -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"
|
||||
|
@ -26,8 +26,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "log.h"
|
||||
|
@ -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"
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "defs.h"
|
||||
#include "command.h"
|
||||
|
@ -114,6 +114,7 @@ static struct device tcpdevice = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "log.h"
|
||||
|
@ -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 *
|
||||
|
@ -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"
|
||||
|
@ -168,6 +168,7 @@ static const struct device baseudpdevice = {
|
||||
udp_Sendto,
|
||||
udp_device2iov,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user