- don't leak the ipv6 file descriptor when we close
- fix packet statistics - don't check errno if n != -1 - check more error conditions - relinguish the ppp tty when we are on demand mode, fixes demand mode - ansi prototypes
This commit is contained in:
parent
9708e1086d
commit
36134a63ad
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sys-bsd.c,v 1.51 2005/02/20 11:12:45 cube Exp $ */
|
/* $NetBSD: sys-bsd.c,v 1.52 2005/12/31 08:36:01 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sys-bsd.c - System-dependent procedures for setting up
|
* sys-bsd.c - System-dependent procedures for setting up
|
||||||
@ -79,7 +79,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
#define RCSID "Id: sys-bsd.c,v 1.47 2000/04/13 12:04:23 paulus Exp "
|
#define RCSID "Id: sys-bsd.c,v 1.47 2000/04/13 12:04:23 paulus Exp "
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: sys-bsd.c,v 1.51 2005/02/20 11:12:45 cube Exp $");
|
__RCSID("$NetBSD: sys-bsd.c,v 1.52 2005/12/31 08:36:01 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -172,10 +172,10 @@ static u_int32_t default_route_gateway; /* gateway addr for default route */
|
|||||||
static u_int32_t proxy_arp_addr; /* remote addr for proxy arp */
|
static u_int32_t proxy_arp_addr; /* remote addr for proxy arp */
|
||||||
|
|
||||||
/* Prototypes for procedures local to this file. */
|
/* Prototypes for procedures local to this file. */
|
||||||
static int get_flags __P((int));
|
static int get_flags(int);
|
||||||
static void set_flags __P((int, int));
|
static void set_flags(int, int);
|
||||||
static int dodefaultroute __P((u_int32_t, int));
|
static int dodefaultroute(u_int32_t, int);
|
||||||
static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
|
static int get_ether_addr(u_int32_t, struct sockaddr_dl *);
|
||||||
static void restore_loop(void); /* Transfer ppp unit back to loopback */
|
static void restore_loop(void); /* Transfer ppp unit back to loopback */
|
||||||
|
|
||||||
|
|
||||||
@ -185,8 +185,7 @@ static void restore_loop(void); /* Transfer ppp unit back to loopback */
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_flags(fd)
|
get_flags(int fd)
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
@ -200,8 +199,7 @@ get_flags(fd)
|
|||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_flags(fd, flags)
|
set_flags(int fd, int flags)
|
||||||
int fd, flags;
|
|
||||||
{
|
{
|
||||||
SYSDEBUG((LOG_DEBUG, "set flags = %x\n", flags));
|
SYSDEBUG((LOG_DEBUG, "set flags = %x\n", flags));
|
||||||
|
|
||||||
@ -213,7 +211,7 @@ set_flags(fd, flags)
|
|||||||
* sys_init - System-dependent initialization.
|
* sys_init - System-dependent initialization.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
sys_init()
|
sys_init(void)
|
||||||
{
|
{
|
||||||
/* Get an internet socket for doing socket ioctl's on. */
|
/* Get an internet socket for doing socket ioctl's on. */
|
||||||
if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
@ -236,7 +234,7 @@ sys_init()
|
|||||||
* This should call die() because it's called from die().
|
* This should call die() because it's called from die().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
sys_cleanup()
|
sys_cleanup(void)
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@ -262,18 +260,23 @@ sys_cleanup()
|
|||||||
void
|
void
|
||||||
sys_close()
|
sys_close()
|
||||||
{
|
{
|
||||||
close(sock_fd);
|
if (sock_fd >= 0)
|
||||||
if (loop_slave >= 0) {
|
close(sock_fd);
|
||||||
|
#ifdef INET6
|
||||||
|
if (sock6_fd >= 0)
|
||||||
|
close(sock6_fd);
|
||||||
|
#endif
|
||||||
|
if (loop_slave >= 0)
|
||||||
close(loop_slave);
|
close(loop_slave);
|
||||||
|
if (loop_master >= 0)
|
||||||
close(loop_master);
|
close(loop_master);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sys_check_options - check the options that the user specified
|
* sys_check_options - check the options that the user specified
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sys_check_options()
|
sys_check_options(void)
|
||||||
{
|
{
|
||||||
#ifndef CDTRCTS
|
#ifndef CDTRCTS
|
||||||
if (crtscts == 2) {
|
if (crtscts == 2) {
|
||||||
@ -289,7 +292,7 @@ sys_check_options()
|
|||||||
* (in fact we check whether we can do an ioctl on ppp0).
|
* (in fact we check whether we can do an ioctl on ppp0).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ppp_available()
|
ppp_available(void)
|
||||||
{
|
{
|
||||||
struct if_clonereq ifcr;
|
struct if_clonereq ifcr;
|
||||||
char *cp, *buf;
|
char *cp, *buf;
|
||||||
@ -344,8 +347,7 @@ file in the ppp-2.2 distribution.\n";
|
|||||||
* tty_establish_ppp - Turn the serial port into a ppp interface.
|
* tty_establish_ppp - Turn the serial port into a ppp interface.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
tty_establish_ppp(fd)
|
tty_establish_ppp(int fd)
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
int pppdisc = PPPDISC;
|
int pppdisc = PPPDISC;
|
||||||
int x;
|
int x;
|
||||||
@ -367,22 +369,22 @@ tty_establish_ppp(fd)
|
|||||||
if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
|
if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
|
||||||
fatal("ioctl(TIOCSETD): %m");
|
fatal("ioctl(TIOCSETD): %m");
|
||||||
|
|
||||||
|
if (ioctl(fd, PPPIOCGUNIT, &x) < 0)
|
||||||
|
fatal("ioctl(PPPIOCGUNIT): %m");
|
||||||
if (!demand) {
|
if (!demand) {
|
||||||
/*
|
/*
|
||||||
* Find out which interface we were given.
|
* Find out which interface we were given.
|
||||||
*/
|
*/
|
||||||
if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0)
|
ifunit = x;
|
||||||
fatal("ioctl(PPPIOCGUNIT): %m");
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Check that we got the same unit again.
|
* Check that we got the same unit again.
|
||||||
*/
|
*/
|
||||||
if (ioctl(fd, PPPIOCGUNIT, &x) < 0)
|
|
||||||
fatal("ioctl(PPPIOCGUNIT): %m");
|
|
||||||
if (x != ifunit)
|
if (x != ifunit)
|
||||||
fatal("transfer_ppp failed: wanted unit %d, got %d", ifunit, x);
|
fatal("transfer_ppp failed: wanted unit %d, got %d", ifunit, x);
|
||||||
x = TTYDISC;
|
x = TTYDISC;
|
||||||
ioctl(loop_slave, TIOCSETD, &x);
|
if (ioctl(loop_slave, TIOCSETD, &x) == -1)
|
||||||
|
fatal("ioctl(TIOCGETD): %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
ppp_fd = fd;
|
ppp_fd = fd;
|
||||||
@ -411,7 +413,7 @@ tty_establish_ppp(fd)
|
|||||||
* restore_loop - reattach the ppp unit to the loopback.
|
* restore_loop - reattach the ppp unit to the loopback.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
restore_loop()
|
restore_loop(void)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -452,7 +454,7 @@ tty_disestablish_ppp(fd)
|
|||||||
if (demand)
|
if (demand)
|
||||||
restore_loop();
|
restore_loop();
|
||||||
|
|
||||||
if (!hungup) {
|
if (!hungup || demand) {
|
||||||
|
|
||||||
|
|
||||||
/* Flush the tty output buffer so that the TIOCSETD doesn't hang. */
|
/* Flush the tty output buffer so that the TIOCSETD doesn't hang. */
|
||||||
@ -479,8 +481,7 @@ tty_disestablish_ppp(fd)
|
|||||||
* Used in demand mode.
|
* Used in demand mode.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cfg_bundle(mrru, mtru, rssn, tssn)
|
cfg_bundle(int mrru, int mtru, int rssn, int tssn)
|
||||||
int mrru, mtru, rssn, tssn;
|
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
@ -515,8 +516,7 @@ cfg_bundle(mrru, mtru, rssn, tssn)
|
|||||||
* a new one.
|
* a new one.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
make_new_bundle(mrru, mtru, rssn, tssn)
|
make_new_bundle(int mrru, int mtru, int rssn, int tssn)
|
||||||
int mrru, mtru, rssn, tssn;
|
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
@ -537,8 +537,7 @@ make_new_bundle(mrru, mtru, rssn, tssn)
|
|||||||
* We assume the unit is controlled by another pppd.
|
* We assume the unit is controlled by another pppd.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
bundle_attach(ifnum)
|
bundle_attach(int ifnum)
|
||||||
int ifnum;
|
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
@ -577,7 +576,7 @@ void destroy_bundle(void)
|
|||||||
* Check whether the link seems not to be 8-bit clean.
|
* Check whether the link seems not to be 8-bit clean.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
clean_check()
|
clean_check(void)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
char *s;
|
char *s;
|
||||||
@ -624,8 +623,7 @@ clean_check()
|
|||||||
* For *BSD, we assume that speed_t values numerically equal bits/second.
|
* For *BSD, we assume that speed_t values numerically equal bits/second.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set_up_tty(fd, local)
|
set_up_tty(int fd, int local)
|
||||||
int fd, local;
|
|
||||||
{
|
{
|
||||||
struct termios tios;
|
struct termios tios;
|
||||||
|
|
||||||
@ -691,8 +689,7 @@ set_up_tty(fd, local)
|
|||||||
* restore_tty - restore the terminal to the saved settings.
|
* restore_tty - restore the terminal to the saved settings.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
restore_tty(fd)
|
restore_tty(int fd)
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
if (restore_term) {
|
if (restore_term) {
|
||||||
if (!default_device) {
|
if (!default_device) {
|
||||||
@ -717,8 +714,7 @@ restore_tty(fd)
|
|||||||
* This is called from die(), so it shouldn't call die().
|
* This is called from die(), so it shouldn't call die().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
setdtr(fd, on)
|
setdtr(int fd, int on)
|
||||||
int fd, on;
|
|
||||||
{
|
{
|
||||||
int modembits = TIOCM_DTR;
|
int modembits = TIOCM_DTR;
|
||||||
|
|
||||||
@ -730,9 +726,7 @@ int fd, on;
|
|||||||
* sif6addr - Config the interface with an IPv6 link-local address
|
* sif6addr - Config the interface with an IPv6 link-local address
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sif6addr(unit, our_eui64, his_eui64)
|
sif6addr(int unit, eui64_t our_eui64, eui64_t his_eui64)
|
||||||
int unit;
|
|
||||||
eui64_t our_eui64, his_eui64;
|
|
||||||
{
|
{
|
||||||
#ifdef __KAME__
|
#ifdef __KAME__
|
||||||
int ifindex;
|
int ifindex;
|
||||||
@ -839,9 +833,7 @@ sif6addr(unit, our_eui64, his_eui64)
|
|||||||
* cif6addr - Remove IPv6 address from interface
|
* cif6addr - Remove IPv6 address from interface
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cif6addr(unit, our_eui64, his_eui64)
|
cif6addr(int unit, eui64_t our_eui64, eui64_t his_eui64)
|
||||||
int unit;
|
|
||||||
eui64_t our_eui64, his_eui64;
|
|
||||||
{
|
{
|
||||||
#ifdef __KAME__
|
#ifdef __KAME__
|
||||||
int ifindex;
|
int ifindex;
|
||||||
@ -920,11 +912,7 @@ cif6addr(unit, our_eui64, his_eui64)
|
|||||||
* to the uid given. Assumes slave_name points to >= 12 bytes of space.
|
* to the uid given. Assumes slave_name points to >= 12 bytes of space.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_pty(master_fdp, slave_fdp, slave_name, uid)
|
get_pty(int *master_fdp, int *slave_fdp, char *slave_name, int uid)
|
||||||
int *master_fdp;
|
|
||||||
int *slave_fdp;
|
|
||||||
char *slave_name;
|
|
||||||
int uid;
|
|
||||||
{
|
{
|
||||||
struct termios tios;
|
struct termios tios;
|
||||||
|
|
||||||
@ -954,7 +942,7 @@ get_pty(master_fdp, slave_fdp, slave_name, uid)
|
|||||||
* Here we use a pty.
|
* Here we use a pty.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
open_ppp_loopback()
|
open_ppp_loopback(void)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
struct termios tios;
|
struct termios tios;
|
||||||
@ -1005,10 +993,7 @@ open_ppp_loopback()
|
|||||||
* output - Output PPP packet.
|
* output - Output PPP packet.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
output(unit, p, len)
|
output(int unit, u_char *p, int len)
|
||||||
int unit;
|
|
||||||
u_char *p;
|
|
||||||
int len;
|
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
dbglog("sent %P", p, len);
|
dbglog("sent %P", p, len);
|
||||||
@ -1026,8 +1011,7 @@ output(unit, p, len)
|
|||||||
* if timo is NULL).
|
* if timo is NULL).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
wait_input(timo)
|
wait_input(struct timeval *timo)
|
||||||
struct timeval *timo;
|
|
||||||
{
|
{
|
||||||
fd_set ready;
|
fd_set ready;
|
||||||
int n;
|
int n;
|
||||||
@ -1042,8 +1026,7 @@ wait_input(timo)
|
|||||||
/*
|
/*
|
||||||
* add_fd - add an fd to the set that wait_input waits for.
|
* add_fd - add an fd to the set that wait_input waits for.
|
||||||
*/
|
*/
|
||||||
void add_fd(fd)
|
void add_fd(int fd)
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
if (fd >= FD_SETSIZE)
|
if (fd >= FD_SETSIZE)
|
||||||
fatal("descriptor too big");
|
fatal("descriptor too big");
|
||||||
@ -1055,8 +1038,7 @@ void add_fd(fd)
|
|||||||
/*
|
/*
|
||||||
* remove_fd - remove an fd from the set that wait_input waits for.
|
* remove_fd - remove an fd from the set that wait_input waits for.
|
||||||
*/
|
*/
|
||||||
void remove_fd(fd)
|
void remove_fd(int fd)
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
FD_CLR(fd, &in_fds);
|
FD_CLR(fd, &in_fds);
|
||||||
}
|
}
|
||||||
@ -1068,8 +1050,7 @@ void remove_fd(fd)
|
|||||||
* if timo is NULL).
|
* if timo is NULL).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
wait_loop_output(timo)
|
wait_loop_output(struct timeval *timo)
|
||||||
struct timeval *timo;
|
|
||||||
{
|
{
|
||||||
fd_set ready;
|
fd_set ready;
|
||||||
int n;
|
int n;
|
||||||
@ -1089,8 +1070,7 @@ wait_loop_output(timo)
|
|||||||
* signal is received.
|
* signal is received.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
wait_time(timo)
|
wait_time(struct timeval *timo)
|
||||||
struct timeval *timo;
|
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -1105,8 +1085,7 @@ wait_time(timo)
|
|||||||
* read_packet - get a PPP packet from the serial device.
|
* read_packet - get a PPP packet from the serial device.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
read_packet(buf)
|
read_packet(u_char *buf)
|
||||||
u_char *buf;
|
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -1125,7 +1104,7 @@ read_packet(buf)
|
|||||||
* Return value is 1 if we need to bring up the link, 0 otherwise.
|
* Return value is 1 if we need to bring up the link, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_loop_output()
|
get_loop_output(void)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int n;
|
int n;
|
||||||
@ -1137,7 +1116,7 @@ get_loop_output()
|
|||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
fatal("eof on loopback");
|
fatal("eof on loopback");
|
||||||
if (errno != EWOULDBLOCK)
|
if (n == -1 && errno != EWOULDBLOCK)
|
||||||
fatal("read from loopback: %m");
|
fatal("read from loopback: %m");
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
@ -1148,8 +1127,7 @@ get_loop_output()
|
|||||||
* netif_set_mtu - set the MTU on the PPP network interface.
|
* netif_set_mtu - set the MTU on the PPP network interface.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
netif_set_mtu(unit, mtu)
|
netif_set_mtu(int unit, int mtu)
|
||||||
int unit, mtu;
|
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@ -1186,10 +1164,7 @@ netif_get_mtu(int unit)
|
|||||||
* the ppp interface.
|
* the ppp interface.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
tty_send_config(mtu, asyncmap, pcomp, accomp)
|
tty_send_config(int mtu, u_int32_t asyncmap, int pcomp, int accomp)
|
||||||
int mtu;
|
|
||||||
u_int32_t asyncmap;
|
|
||||||
int pcomp, accomp;
|
|
||||||
{
|
{
|
||||||
u_int x;
|
u_int x;
|
||||||
#if 0
|
#if 0
|
||||||
@ -1212,8 +1187,7 @@ tty_send_config(mtu, asyncmap, pcomp, accomp)
|
|||||||
* ppp_set_xaccm - set the extended transmit ACCM for the interface.
|
* ppp_set_xaccm - set the extended transmit ACCM for the interface.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
tty_set_xaccm(accm)
|
tty_set_xaccm(ext_accm accm)
|
||||||
ext_accm accm;
|
|
||||||
{
|
{
|
||||||
if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
|
if (ioctl(ppp_fd, PPPIOCSXASYNCMAP, accm) < 0 && errno != ENOTTY)
|
||||||
warn("ioctl(set extended ACCM): %m");
|
warn("ioctl(set extended ACCM): %m");
|
||||||
@ -1225,10 +1199,7 @@ tty_set_xaccm(accm)
|
|||||||
* the ppp interface.
|
* the ppp interface.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
tty_recv_config(mru, asyncmap, pcomp, accomp)
|
tty_recv_config(int mru, u_int32_t asyncmap, int pcomp, int accomp)
|
||||||
int mru;
|
|
||||||
u_int32_t asyncmap;
|
|
||||||
int pcomp, accomp;
|
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -1248,9 +1219,7 @@ tty_recv_config(mru, asyncmap, pcomp, accomp)
|
|||||||
* (e.g. code size should be reduced), or -1 if the method is unknown.
|
* (e.g. code size should be reduced), or -1 if the method is unknown.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ccp_test(unit, opt_ptr, opt_len, for_transmit)
|
ccp_test(int unit, u_char *opt_ptr, int opt_len, int for_transmit)
|
||||||
int unit, opt_len, for_transmit;
|
|
||||||
u_char *opt_ptr;
|
|
||||||
{
|
{
|
||||||
struct ppp_option_data data;
|
struct ppp_option_data data;
|
||||||
|
|
||||||
@ -1266,8 +1235,7 @@ ccp_test(unit, opt_ptr, opt_len, for_transmit)
|
|||||||
* ccp_flags_set - inform kernel about the current state of CCP.
|
* ccp_flags_set - inform kernel about the current state of CCP.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ccp_flags_set(unit, isopen, isup)
|
ccp_flags_set(int unit, int isopen, int isup)
|
||||||
int unit, isopen, isup;
|
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -1283,8 +1251,7 @@ ccp_flags_set(unit, isopen, isup)
|
|||||||
* 0 otherwise. This is necessary because of patent nonsense.
|
* 0 otherwise. This is necessary because of patent nonsense.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ccp_fatal_error(unit)
|
ccp_fatal_error(int unit)
|
||||||
int unit;
|
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
@ -1296,9 +1263,7 @@ ccp_fatal_error(unit)
|
|||||||
* get_idle_time - return how long the link has been idle.
|
* get_idle_time - return how long the link has been idle.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_idle_time(u, ip)
|
get_idle_time(int u, struct ppp_idle *ip)
|
||||||
int u;
|
|
||||||
struct ppp_idle *ip;
|
|
||||||
{
|
{
|
||||||
return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0;
|
return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0;
|
||||||
}
|
}
|
||||||
@ -1307,9 +1272,7 @@ get_idle_time(u, ip)
|
|||||||
* get_ppp_stats - return statistics for the link.
|
* get_ppp_stats - return statistics for the link.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_ppp_stats(u, stats)
|
get_ppp_stats(int u, struct pppd_stats *stats)
|
||||||
int u;
|
|
||||||
struct pppd_stats *stats;
|
|
||||||
{
|
{
|
||||||
struct ifpppstatsreq req;
|
struct ifpppstatsreq req;
|
||||||
|
|
||||||
@ -1321,6 +1284,8 @@ get_ppp_stats(u, stats)
|
|||||||
}
|
}
|
||||||
stats->bytes_in = req.stats.p.ppp_ibytes;
|
stats->bytes_in = req.stats.p.ppp_ibytes;
|
||||||
stats->bytes_out = req.stats.p.ppp_obytes;
|
stats->bytes_out = req.stats.p.ppp_obytes;
|
||||||
|
stats->pkts_in = req.stats.p.ppp_ipackets;
|
||||||
|
stats->pkts_out = req.stats.p.ppp_opackets;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1330,8 +1295,8 @@ get_ppp_stats(u, stats)
|
|||||||
* set_filters - transfer the pass and active filters to the kernel.
|
* set_filters - transfer the pass and active filters to the kernel.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
set_filters(pass_in, pass_out, active_in, active_out)
|
set_filters(struct bpf_program *pass_in, struct bpf_program *pass_out,
|
||||||
struct bpf_program *pass_in, *pass_out, *active_in, *active_out;
|
struct bpf_program *active_in, struct bpf_program *active_out)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
@ -1371,8 +1336,7 @@ set_filters(pass_in, pass_out, active_in, active_out)
|
|||||||
* sifvjcomp - config tcp header compression
|
* sifvjcomp - config tcp header compression
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifvjcomp(u, vjcomp, cidcomp, maxcid)
|
sifvjcomp(int u, int vjcomp, int cidcomp, int maxcid)
|
||||||
int u, vjcomp, cidcomp, maxcid;
|
|
||||||
{
|
{
|
||||||
u_int x;
|
u_int x;
|
||||||
|
|
||||||
@ -1391,8 +1355,7 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid)
|
|||||||
* sifup - Config the interface up and enable IP packets to pass.
|
* sifup - Config the interface up and enable IP packets to pass.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifup(u)
|
sifup(int u)
|
||||||
int u;
|
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@ -1414,10 +1377,7 @@ sifup(u)
|
|||||||
* sifnpmode - Set the mode for handling packets for a given NP.
|
* sifnpmode - Set the mode for handling packets for a given NP.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifnpmode(u, proto, mode)
|
sifnpmode(int u, int proto, enum NPmode mode)
|
||||||
int u;
|
|
||||||
int proto;
|
|
||||||
enum NPmode mode;
|
|
||||||
{
|
{
|
||||||
struct npioctl npi;
|
struct npioctl npi;
|
||||||
|
|
||||||
@ -1434,8 +1394,7 @@ sifnpmode(u, proto, mode)
|
|||||||
* sifdown - Config the interface down and disable IP.
|
* sifdown - Config the interface down and disable IP.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifdown(u)
|
sifdown(int u)
|
||||||
int u;
|
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int rv;
|
int rv;
|
||||||
@ -1475,9 +1434,7 @@ sifdown(u)
|
|||||||
* sifaddr - Config the interface IP addresses and netmask.
|
* sifaddr - Config the interface IP addresses and netmask.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifaddr(u, o, h, m)
|
sifaddr(int u, u_int32_t o, u_int32_t h, u_int32_t m)
|
||||||
int u;
|
|
||||||
u_int32_t o, h, m;
|
|
||||||
{
|
{
|
||||||
struct ifaliasreq ifra;
|
struct ifaliasreq ifra;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
@ -1515,9 +1472,7 @@ sifaddr(u, o, h, m)
|
|||||||
* through the interface if possible.
|
* through the interface if possible.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cifaddr(u, o, h)
|
cifaddr(int u, u_int32_t o, u_int32_t h)
|
||||||
int u;
|
|
||||||
u_int32_t o, h;
|
|
||||||
{
|
{
|
||||||
struct ifaliasreq ifra;
|
struct ifaliasreq ifra;
|
||||||
|
|
||||||
@ -1540,9 +1495,7 @@ cifaddr(u, o, h)
|
|||||||
* sifdefaultroute - assign a default route through the address given.
|
* sifdefaultroute - assign a default route through the address given.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifdefaultroute(u, l, g)
|
sifdefaultroute(int u, u_int32_t l, u_int32_t g)
|
||||||
int u;
|
|
||||||
u_int32_t l, g;
|
|
||||||
{
|
{
|
||||||
return dodefaultroute(g, 's');
|
return dodefaultroute(g, 's');
|
||||||
}
|
}
|
||||||
@ -1551,9 +1504,7 @@ sifdefaultroute(u, l, g)
|
|||||||
* cifdefaultroute - delete a default route through the address given.
|
* cifdefaultroute - delete a default route through the address given.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cifdefaultroute(u, l, g)
|
cifdefaultroute(int u, u_int32_t l, u_int32_t g)
|
||||||
int u;
|
|
||||||
u_int32_t l, g;
|
|
||||||
{
|
{
|
||||||
return dodefaultroute(g, 'c');
|
return dodefaultroute(g, 'c');
|
||||||
}
|
}
|
||||||
@ -1562,9 +1513,7 @@ cifdefaultroute(u, l, g)
|
|||||||
* dodefaultroute - talk to a routing socket to add/delete a default route.
|
* dodefaultroute - talk to a routing socket to add/delete a default route.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
dodefaultroute(g, cmd)
|
dodefaultroute(u_int32_t g, int cmd)
|
||||||
u_int32_t g;
|
|
||||||
int cmd;
|
|
||||||
{
|
{
|
||||||
int routes;
|
int routes;
|
||||||
struct {
|
struct {
|
||||||
@ -1640,9 +1589,7 @@ static struct {
|
|||||||
static int arpmsg_valid;
|
static int arpmsg_valid;
|
||||||
|
|
||||||
int
|
int
|
||||||
sifproxyarp(unit, hisaddr)
|
sifproxyarp(int unit, u_int32_t hisaddr)
|
||||||
int unit;
|
|
||||||
u_int32_t hisaddr;
|
|
||||||
{
|
{
|
||||||
int routes;
|
int routes;
|
||||||
|
|
||||||
@ -1690,9 +1637,7 @@ sifproxyarp(unit, hisaddr)
|
|||||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cifproxyarp(unit, hisaddr)
|
cifproxyarp(int unit, u_int32_t hisaddr)
|
||||||
int unit;
|
|
||||||
u_int32_t hisaddr;
|
|
||||||
{
|
{
|
||||||
int routes;
|
int routes;
|
||||||
|
|
||||||
@ -1725,9 +1670,7 @@ cifproxyarp(unit, hisaddr)
|
|||||||
* sifproxyarp - Make a proxy ARP entry for the peer.
|
* sifproxyarp - Make a proxy ARP entry for the peer.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sifproxyarp(unit, hisaddr)
|
sifproxyarp(int unit, u_int32_t hisaddr)
|
||||||
int unit;
|
|
||||||
u_int32_t hisaddr;
|
|
||||||
{
|
{
|
||||||
struct arpreq arpreq;
|
struct arpreq arpreq;
|
||||||
struct {
|
struct {
|
||||||
@ -1765,9 +1708,7 @@ sifproxyarp(unit, hisaddr)
|
|||||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cifproxyarp(unit, hisaddr)
|
cifproxyarp(int unit, u_int32_t hisaddr)
|
||||||
int unit;
|
|
||||||
u_int32_t hisaddr;
|
|
||||||
{
|
{
|
||||||
struct arpreq arpreq;
|
struct arpreq arpreq;
|
||||||
|
|
||||||
@ -1789,9 +1730,7 @@ cifproxyarp(unit, hisaddr)
|
|||||||
* the same subnet as ipaddr.
|
* the same subnet as ipaddr.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
get_ether_addr(ipaddr, hwaddr)
|
get_ether_addr(u_int32_t ipaddr, struct sockaddr_dl *hwaddr)
|
||||||
u_int32_t ipaddr;
|
|
||||||
struct sockaddr_dl *hwaddr;
|
|
||||||
{
|
{
|
||||||
u_int32_t ina, mask;
|
u_int32_t ina, mask;
|
||||||
struct sockaddr_dl *dla;
|
struct sockaddr_dl *dla;
|
||||||
@ -1862,9 +1801,7 @@ get_ether_addr(ipaddr, hwaddr)
|
|||||||
* network interface device.
|
* network interface device.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_if_hwaddr(addr, name)
|
get_if_hwaddr(u_char *addr, char *name)
|
||||||
u_char *addr;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
struct ifreq ifreq;
|
struct ifreq ifreq;
|
||||||
struct sockaddr_dl *sdl = (struct sockaddr_dl *) &ifreq.ifr_addr;
|
struct sockaddr_dl *sdl = (struct sockaddr_dl *) &ifreq.ifr_addr;
|
||||||
@ -1889,7 +1826,7 @@ get_if_hwaddr(addr, name)
|
|||||||
* interface on this system.
|
* interface on this system.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
get_first_ethernet()
|
get_first_ethernet(void)
|
||||||
{
|
{
|
||||||
static char ifname[IFNAMSIZ];
|
static char ifname[IFNAMSIZ];
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
@ -1930,8 +1867,7 @@ get_first_ethernet()
|
|||||||
* user-specified netmask.
|
* user-specified netmask.
|
||||||
*/
|
*/
|
||||||
u_int32_t
|
u_int32_t
|
||||||
GetMask(addr)
|
GetMask(u_int32_t addr)
|
||||||
u_int32_t addr;
|
|
||||||
{
|
{
|
||||||
u_int32_t mask, nmask, ina;
|
u_int32_t mask, nmask, ina;
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
@ -1993,7 +1929,7 @@ int have_route_to(u_int32_t addr)
|
|||||||
* Use the hostid as part of the random number seed.
|
* Use the hostid as part of the random number seed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_host_seed()
|
get_host_seed(void)
|
||||||
{
|
{
|
||||||
return gethostid();
|
return gethostid();
|
||||||
}
|
}
|
||||||
@ -2007,8 +1943,7 @@ get_host_seed()
|
|||||||
static char *lock_file; /* name of lock file created */
|
static char *lock_file; /* name of lock file created */
|
||||||
|
|
||||||
int
|
int
|
||||||
lock(dev)
|
lock(char *dev)
|
||||||
char *dev;
|
|
||||||
{
|
{
|
||||||
char hdb_lock_buffer[12];
|
char hdb_lock_buffer[12];
|
||||||
int fd, pid, n;
|
int fd, pid, n;
|
||||||
@ -2067,7 +2002,7 @@ lock(dev)
|
|||||||
* unlock - remove our lockfile
|
* unlock - remove our lockfile
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
unlock()
|
unlock(void)
|
||||||
{
|
{
|
||||||
if (lock_file) {
|
if (lock_file) {
|
||||||
unlink(lock_file);
|
unlink(lock_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user