KNF, bump warns, fix warnings to print the program name.
This commit is contained in:
parent
b658434c23
commit
5fe0c59dd8
@ -1,5 +1,6 @@
|
|||||||
# $NetBSD: Makefile,v 1.14 2009/04/22 15:23:08 lukem Exp $
|
# $NetBSD: Makefile,v 1.15 2014/03/18 00:16:49 christos Exp $
|
||||||
|
|
||||||
|
WARNS?=6
|
||||||
USE_FORT?= yes # network client (local server)
|
USE_FORT?= yes # network client (local server)
|
||||||
|
|
||||||
PROG= rtsold
|
PROG= rtsold
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: dump.c,v 1.9 2009/04/11 07:51:59 lukem Exp $ */
|
/* $NetBSD: dump.c,v 1.10 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: dump.c,v 1.10 2002/05/31 10:10:03 itojun Exp $ */
|
/* $KAME: dump.c,v 1.10 2002/05/31 10:10:03 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -48,11 +48,11 @@
|
|||||||
|
|
||||||
static FILE *fp;
|
static FILE *fp;
|
||||||
|
|
||||||
extern struct ifinfo *iflist;
|
static void dump_interface_status(void);
|
||||||
|
static const char *sec2str(time_t);
|
||||||
static void dump_interface_status __P((void));
|
static const char *ifstatstr[] = {
|
||||||
static const char *sec2str __P((time_t));
|
"IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE"
|
||||||
const char *ifstatstr[] = {"IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE"};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_interface_status(void)
|
dump_interface_status(void)
|
||||||
@ -115,32 +115,32 @@ sec2str(time_t total)
|
|||||||
char *ep = &result[sizeof(result)];
|
char *ep = &result[sizeof(result)];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
days = total / 3600 / 24;
|
days = (int)(total / 3600 / 24);
|
||||||
hours = (total / 3600) % 24;
|
hours = (int)((total / 3600) % 24);
|
||||||
mins = (total / 60) % 60;
|
mins = (int)((total / 60) % 60);
|
||||||
secs = total % 60;
|
secs = (int)(total % 60);
|
||||||
|
|
||||||
if (days) {
|
if (days) {
|
||||||
first = 0;
|
first = 0;
|
||||||
n = snprintf(p, ep - p, "%dd", days);
|
n = snprintf(p, (size_t)(ep - p), "%dd", days);
|
||||||
if (n < 0 || n >= ep - p)
|
if (n < 0 || n >= ep - p)
|
||||||
return "?";
|
return "?";
|
||||||
p += n;
|
p += n;
|
||||||
}
|
}
|
||||||
if (!first || hours) {
|
if (!first || hours) {
|
||||||
first = 0;
|
first = 0;
|
||||||
n = snprintf(p, ep - p, "%dh", hours);
|
n = snprintf(p, (size_t)(ep - p), "%dh", hours);
|
||||||
if (n < 0 || n >= ep - p)
|
if (n < 0 || n >= ep - p)
|
||||||
return "?";
|
return "?";
|
||||||
p += n;
|
p += n;
|
||||||
}
|
}
|
||||||
if (!first || mins) {
|
if (!first || mins) {
|
||||||
first = 0;
|
first = 0;
|
||||||
n = snprintf(p, ep - p, "%dm", mins);
|
n = snprintf(p, (size_t)(ep - p), "%dm", mins);
|
||||||
if (n < 0 || n >= ep - p)
|
if (n < 0 || n >= ep - p)
|
||||||
return "?";
|
return "?";
|
||||||
p += n;
|
p += n;
|
||||||
}
|
}
|
||||||
snprintf(p, ep - p, "%ds", secs);
|
snprintf(p, (size_t)(ep - p), "%ds", secs);
|
||||||
return(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: if.c,v 1.15 2006/03/18 21:41:23 dan Exp $ */
|
/* $NetBSD: if.c,v 1.16 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $ */
|
/* $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -59,18 +59,17 @@
|
|||||||
|
|
||||||
#include "rtsold.h"
|
#include "rtsold.h"
|
||||||
|
|
||||||
extern int rssock;
|
|
||||||
static int ifsock;
|
static int ifsock;
|
||||||
|
|
||||||
static int get_llflag __P((const char *));
|
static int get_llflag(const char *);
|
||||||
static void get_rtaddrs __P((int, struct sockaddr *, struct sockaddr **));
|
static void get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
|
||||||
|
|
||||||
int
|
int
|
||||||
ifinit(void)
|
ifinit(void)
|
||||||
{
|
{
|
||||||
ifsock = rssock;
|
ifsock = rssock;
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -81,17 +80,17 @@ interface_up(char *name)
|
|||||||
|
|
||||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||||
|
|
||||||
if (ioctl(ifsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
|
if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) {
|
||||||
warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFFLAGS): %s",
|
warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFFLAGS): %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (!(ifr.ifr_flags & IFF_UP)) {
|
if (!(ifr.ifr_flags & IFF_UP)) {
|
||||||
ifr.ifr_flags |= IFF_UP;
|
ifr.ifr_flags |= IFF_UP;
|
||||||
if (ioctl(ifsock, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
|
if (ioctl(ifsock, SIOCSIFFLAGS, &ifr) < 0)
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"ioctl(SIOCSIFFLAGS): %s", strerror(errno));
|
"ioctl(SIOCSIFFLAGS): %s", strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
warnmsg(LOG_DEBUG, __func__, "checking if %s is ready...", name);
|
warnmsg(LOG_DEBUG, __func__, "checking if %s is ready...", name);
|
||||||
@ -105,7 +104,7 @@ interface_up(char *name)
|
|||||||
|
|
||||||
if (!(llflag & IN6_IFF_NOTREADY)) {
|
if (!(llflag & IN6_IFF_NOTREADY)) {
|
||||||
warnmsg(LOG_DEBUG, __func__, "%s is ready", name);
|
warnmsg(LOG_DEBUG, __func__, "%s is ready", name);
|
||||||
return(0);
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
if (llflag & IN6_IFF_TENTATIVE) {
|
if (llflag & IN6_IFF_TENTATIVE) {
|
||||||
warnmsg(LOG_DEBUG, __func__, "%s is tentative",
|
warnmsg(LOG_DEBUG, __func__, "%s is tentative",
|
||||||
@ -132,7 +131,7 @@ interface_status(struct ifinfo *ifinfo)
|
|||||||
if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) {
|
if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) {
|
||||||
warnmsg(LOG_ERR, __func__, "ioctl(SIOCGIFFLAGS) on %s: %s",
|
warnmsg(LOG_ERR, __func__, "ioctl(SIOCGIFFLAGS) on %s: %s",
|
||||||
ifname, strerror(errno));
|
ifname, strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* if one of UP and RUNNING flags is dropped,
|
* if one of UP and RUNNING flags is dropped,
|
||||||
@ -148,12 +147,12 @@ interface_status(struct ifinfo *ifinfo)
|
|||||||
memset(&ifmr, 0, sizeof(ifmr));
|
memset(&ifmr, 0, sizeof(ifmr));
|
||||||
strncpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
|
strncpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
|
||||||
|
|
||||||
if (ioctl(ifsock, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
|
if (ioctl(ifsock, SIOCGIFMEDIA, &ifmr) < 0) {
|
||||||
if (errno != EINVAL) {
|
if (errno != EINVAL) {
|
||||||
warnmsg(LOG_DEBUG, __func__,
|
warnmsg(LOG_DEBUG, __func__,
|
||||||
"ioctl(SIOCGIFMEDIA) on %s: %s",
|
"ioctl(SIOCGIFMEDIA) on %s: %s",
|
||||||
ifname, strerror(errno));
|
ifname, strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* EINVAL simply means that the interface does not support
|
* EINVAL simply means that the interface does not support
|
||||||
@ -177,21 +176,21 @@ interface_status(struct ifinfo *ifinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inactive:
|
inactive:
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
active:
|
active:
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROUNDUP(a, size) \
|
#define ROUNDUP(a, size) \
|
||||||
(((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
|
(((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
|
||||||
|
|
||||||
#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
|
#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
|
||||||
((caddr_t)(ap) + ((ap)->sa_len ? ROUNDUP((ap)->sa_len,\
|
((char *)(ap) + ((ap)->sa_len ? ROUNDUP((ap)->sa_len,\
|
||||||
sizeof(u_long)) : sizeof(u_long)))
|
sizeof(u_long)) : sizeof(u_long)))
|
||||||
#define ROUNDUP8(a) (1 + (((a) - 1) | 7))
|
#define ROUNDUP8(a) (1 + (((a) - 1) | 7))
|
||||||
|
|
||||||
int
|
size_t
|
||||||
lladdropt_length(struct sockaddr_dl *sdl)
|
lladdropt_length(struct sockaddr_dl *sdl)
|
||||||
{
|
{
|
||||||
switch (sdl->sdl_type) {
|
switch (sdl->sdl_type) {
|
||||||
@ -199,9 +198,9 @@ lladdropt_length(struct sockaddr_dl *sdl)
|
|||||||
#ifdef IFT_IEEE80211
|
#ifdef IFT_IEEE80211
|
||||||
case IFT_IEEE80211:
|
case IFT_IEEE80211:
|
||||||
#endif
|
#endif
|
||||||
return(ROUNDUP8(ETHER_ADDR_LEN + 2));
|
return ROUNDUP8(ETHER_ADDR_LEN + 2);
|
||||||
default:
|
default:
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,12 +240,12 @@ if_nametosdl(char *name)
|
|||||||
struct sockaddr_dl *sdl = NULL, *ret_sdl;
|
struct sockaddr_dl *sdl = NULL, *ret_sdl;
|
||||||
|
|
||||||
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
|
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
|
||||||
return(NULL);
|
return NULL;
|
||||||
if ((buf = malloc(len)) == NULL)
|
if ((buf = malloc(len)) == NULL)
|
||||||
return(NULL);
|
return NULL;
|
||||||
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
|
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lim = buf + len;
|
lim = buf + len;
|
||||||
@ -272,14 +271,14 @@ if_nametosdl(char *name)
|
|||||||
if (next == lim || sdl == NULL) {
|
if (next == lim || sdl == NULL) {
|
||||||
/* search failed */
|
/* search failed */
|
||||||
free(buf);
|
free(buf);
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) {
|
if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy((caddr_t)ret_sdl, (caddr_t)sdl, sdl->sdl_len);
|
memcpy(ret_sdl, sdl, sdl->sdl_len);
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
return(ret_sdl);
|
return(ret_sdl);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: probe.c,v 1.11 2010/01/18 04:53:10 christos Exp $ */
|
/* $NetBSD: probe.c,v 1.12 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: probe.c,v 1.15 2002/05/31 21:22:08 itojun Exp $ */
|
/* $KAME: probe.c,v 1.15 2002/05/31 21:22:08 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -58,39 +58,39 @@
|
|||||||
static struct msghdr sndmhdr;
|
static struct msghdr sndmhdr;
|
||||||
static struct iovec sndiov[2];
|
static struct iovec sndiov[2];
|
||||||
static int probesock;
|
static int probesock;
|
||||||
static void sendprobe __P((struct in6_addr *, struct ifinfo *));
|
static void sendprobe(struct in6_addr *, struct ifinfo *);
|
||||||
|
|
||||||
int
|
int
|
||||||
probe_init(void)
|
probe_init(void)
|
||||||
{
|
{
|
||||||
int scmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
|
size_t scmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
|
||||||
CMSG_SPACE(sizeof(int));
|
CMSG_SPACE(sizeof(int));
|
||||||
static u_char *sndcmsgbuf = NULL;
|
static u_char *sndcmsgbuf = NULL;
|
||||||
|
|
||||||
if (sndcmsgbuf == NULL &&
|
if (sndcmsgbuf == NULL &&
|
||||||
(sndcmsgbuf = (u_char *)malloc(scmsglen)) == NULL) {
|
(sndcmsgbuf = malloc(scmsglen)) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__, "malloc failed");
|
warnmsg(LOG_ERR, __func__, "malloc failed");
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((probesock = socket(AF_INET6, SOCK_RAW, IPPROTO_NONE)) < 0) {
|
if ((probesock = socket(AF_INET6, SOCK_RAW, IPPROTO_NONE)) < 0) {
|
||||||
warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno));
|
warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the socket send-only */
|
/* make the socket send-only */
|
||||||
if (shutdown(probesock, 0)) {
|
if (shutdown(probesock, 0)) {
|
||||||
warnmsg(LOG_ERR, __func__, "shutdown: %s", strerror(errno));
|
warnmsg(LOG_ERR, __func__, "shutdown: %s", strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize msghdr for sending packets */
|
/* initialize msghdr for sending packets */
|
||||||
sndmhdr.msg_namelen = sizeof(struct sockaddr_in6);
|
sndmhdr.msg_namelen = sizeof(struct sockaddr_in6);
|
||||||
sndmhdr.msg_iov = sndiov;
|
sndmhdr.msg_iov = sndiov;
|
||||||
sndmhdr.msg_iovlen = 1;
|
sndmhdr.msg_iovlen = 1;
|
||||||
sndmhdr.msg_control = (caddr_t)sndcmsgbuf;
|
sndmhdr.msg_control = sndcmsgbuf;
|
||||||
sndmhdr.msg_controllen = scmsglen;
|
sndmhdr.msg_controllen = (socklen_t)scmsglen;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -110,7 +110,7 @@ defrouter_probe(struct ifinfo *ifinfo)
|
|||||||
}
|
}
|
||||||
memset(&dr, 0, sizeof(dr));
|
memset(&dr, 0, sizeof(dr));
|
||||||
strlcpy(dr.ifname, "lo0", sizeof dr.ifname); /* dummy interface */
|
strlcpy(dr.ifname, "lo0", sizeof dr.ifname); /* dummy interface */
|
||||||
if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {
|
if (ioctl(s, SIOCGDRLST_IN6, &dr) < 0) {
|
||||||
warnmsg(LOG_ERR, __func__, "ioctl(SIOCGDRLST_IN6): %s",
|
warnmsg(LOG_ERR, __func__, "ioctl(SIOCGDRLST_IN6): %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto closeandend;
|
goto closeandend;
|
||||||
@ -152,7 +152,7 @@ sendprobe(struct in6_addr *addr, struct ifinfo *ifinfo)
|
|||||||
sa6_probe.sin6_addr = *addr;
|
sa6_probe.sin6_addr = *addr;
|
||||||
sa6_probe.sin6_scope_id = ifinfo->linkid;
|
sa6_probe.sin6_scope_id = ifinfo->linkid;
|
||||||
|
|
||||||
sndmhdr.msg_name = (caddr_t)&sa6_probe;
|
sndmhdr.msg_name = &sa6_probe;
|
||||||
sndmhdr.msg_iov[0].iov_base = NULL;
|
sndmhdr.msg_iov[0].iov_base = NULL;
|
||||||
sndmhdr.msg_iov[0].iov_len = 0;
|
sndmhdr.msg_iov[0].iov_len = 0;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: rtsock.c,v 1.6 2009/04/11 07:51:59 lukem Exp $ */
|
/* $NetBSD: rtsock.c,v 1.7 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: rtsock.c,v 1.4 2001/09/19 06:59:41 sakane Exp $ */
|
/* $KAME: rtsock.c,v 1.4 2001/09/19 06:59:41 sakane Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -59,12 +59,12 @@
|
|||||||
(((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
|
(((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
|
||||||
|
|
||||||
#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
|
#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
|
||||||
((caddr_t)(ap) + \
|
((char *)(ap) + \
|
||||||
((ap)->sa_len ? ROUNDUP((ap)->sa_len, sizeof(u_long)) \
|
((ap)->sa_len ? ROUNDUP((ap)->sa_len, sizeof(u_long)) \
|
||||||
: sizeof(u_long)))
|
: sizeof(u_long)))
|
||||||
|
|
||||||
#ifdef RTM_IFANNOUNCE /*NetBSD 1.5 or later*/
|
#ifdef RTM_IFANNOUNCE /*NetBSD 1.5 or later*/
|
||||||
static int rtsock_input_ifannounce __P((int, struct rt_msghdr *, char *));
|
static int rtsock_input_ifannounce(int, struct rt_msghdr *, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: rtsol.c,v 1.15 2009/04/11 07:51:59 lukem Exp $ */
|
/* $NetBSD: rtsol.c,v 1.16 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: rtsol.c,v 1.15 2002/05/31 10:10:03 itojun Exp $ */
|
/* $KAME: rtsol.c,v 1.15 2002/05/31 10:10:03 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -76,7 +76,8 @@ int
|
|||||||
sockopen(void)
|
sockopen(void)
|
||||||
{
|
{
|
||||||
static u_char *rcvcmsgbuf = NULL, *sndcmsgbuf = NULL;
|
static u_char *rcvcmsgbuf = NULL, *sndcmsgbuf = NULL;
|
||||||
int rcvcmsglen, sndcmsglen, on;
|
size_t rcvcmsglen, sndcmsglen;
|
||||||
|
int on;
|
||||||
static u_char answer[1500];
|
static u_char answer[1500];
|
||||||
struct icmp6_filter filt;
|
struct icmp6_filter filt;
|
||||||
|
|
||||||
@ -85,12 +86,12 @@ sockopen(void)
|
|||||||
if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) {
|
if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"malloc for receive msghdr failed");
|
"malloc for receive msghdr failed");
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsglen)) == NULL) {
|
if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsglen)) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"malloc for send msghdr failed");
|
"malloc for send msghdr failed");
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
memset(&sin6_allrouters, 0, sizeof(struct sockaddr_in6));
|
memset(&sin6_allrouters, 0, sizeof(struct sockaddr_in6));
|
||||||
sin6_allrouters.sin6_family = AF_INET6;
|
sin6_allrouters.sin6_family = AF_INET6;
|
||||||
@ -99,12 +100,12 @@ sockopen(void)
|
|||||||
&sin6_allrouters.sin6_addr.s6_addr) != 1) {
|
&sin6_allrouters.sin6_addr.s6_addr) != 1) {
|
||||||
warnmsg(LOG_ERR, __func__, "inet_pton failed for %s",
|
warnmsg(LOG_ERR, __func__, "inet_pton failed for %s",
|
||||||
ALLROUTER);
|
ALLROUTER);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rssock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
|
if ((rssock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
|
||||||
warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno));
|
warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* specify to tell receiving interface */
|
/* specify to tell receiving interface */
|
||||||
@ -150,27 +151,27 @@ sockopen(void)
|
|||||||
sizeof(filt)) == -1) {
|
sizeof(filt)) == -1) {
|
||||||
warnmsg(LOG_ERR, __func__, "setsockopt(ICMP6_FILTER): %s",
|
warnmsg(LOG_ERR, __func__, "setsockopt(ICMP6_FILTER): %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize msghdr for receiving packets */
|
/* initialize msghdr for receiving packets */
|
||||||
rcviov[0].iov_base = (caddr_t)answer;
|
rcviov[0].iov_base = answer;
|
||||||
rcviov[0].iov_len = sizeof(answer);
|
rcviov[0].iov_len = sizeof(answer);
|
||||||
rcvmhdr.msg_name = (caddr_t)&from;
|
rcvmhdr.msg_name = &from;
|
||||||
rcvmhdr.msg_namelen = sizeof(from);
|
rcvmhdr.msg_namelen = sizeof(from);
|
||||||
rcvmhdr.msg_iov = rcviov;
|
rcvmhdr.msg_iov = rcviov;
|
||||||
rcvmhdr.msg_iovlen = 1;
|
rcvmhdr.msg_iovlen = 1;
|
||||||
rcvmhdr.msg_control = (caddr_t) rcvcmsgbuf;
|
rcvmhdr.msg_control = rcvcmsgbuf;
|
||||||
rcvmhdr.msg_controllen = rcvcmsglen;
|
rcvmhdr.msg_controllen = (socklen_t)rcvcmsglen;
|
||||||
|
|
||||||
/* initialize msghdr for sending packets */
|
/* initialize msghdr for sending packets */
|
||||||
sndmhdr.msg_namelen = sizeof(struct sockaddr_in6);
|
sndmhdr.msg_namelen = sizeof(struct sockaddr_in6);
|
||||||
sndmhdr.msg_iov = sndiov;
|
sndmhdr.msg_iov = sndiov;
|
||||||
sndmhdr.msg_iovlen = 1;
|
sndmhdr.msg_iovlen = 1;
|
||||||
sndmhdr.msg_control = (caddr_t)sndcmsgbuf;
|
sndmhdr.msg_control = sndcmsgbuf;
|
||||||
sndmhdr.msg_controllen = sndcmsglen;
|
sndmhdr.msg_controllen = (socklen_t)sndcmsglen;
|
||||||
|
|
||||||
return(rssock);
|
return rssock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -185,8 +186,8 @@ sendpacket(struct ifinfo *ifinfo)
|
|||||||
dst = sin6_allrouters;
|
dst = sin6_allrouters;
|
||||||
dst.sin6_scope_id = ifinfo->linkid;
|
dst.sin6_scope_id = ifinfo->linkid;
|
||||||
|
|
||||||
sndmhdr.msg_name = (caddr_t)&dst;
|
sndmhdr.msg_name = &dst;
|
||||||
sndmhdr.msg_iov[0].iov_base = (caddr_t)ifinfo->rs_data;
|
sndmhdr.msg_iov[0].iov_base = ifinfo->rs_data;
|
||||||
sndmhdr.msg_iov[0].iov_len = ifinfo->rs_datalen;
|
sndmhdr.msg_iov[0].iov_len = ifinfo->rs_datalen;
|
||||||
|
|
||||||
cm = CMSG_FIRSTHDR(&sndmhdr);
|
cm = CMSG_FIRSTHDR(&sndmhdr);
|
||||||
@ -229,8 +230,9 @@ void
|
|||||||
rtsol_input(int s)
|
rtsol_input(int s)
|
||||||
{
|
{
|
||||||
char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ];
|
char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ];
|
||||||
int ifindex = 0, *hlimp = NULL;
|
int *hlimp = NULL;
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
|
size_t ifindex = 0;
|
||||||
struct in6_pktinfo *pi = NULL;
|
struct in6_pktinfo *pi = NULL;
|
||||||
struct ifinfo *ifi = NULL;
|
struct ifinfo *ifi = NULL;
|
||||||
struct icmp6_hdr *icp;
|
struct icmp6_hdr *icp;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: rtsold.c,v 1.37 2013/10/19 17:16:38 christos Exp $ */
|
/* $NetBSD: rtsold.c,v 1.38 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: rtsold.c,v 1.77 2004/01/03 01:35:13 itojun Exp $ */
|
/* $KAME: rtsold.c,v 1.77 2004/01/03 01:35:13 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -56,31 +56,11 @@
|
|||||||
|
|
||||||
#include "rtsold.h"
|
#include "rtsold.h"
|
||||||
|
|
||||||
#ifdef __bsdi__
|
|
||||||
#define timeradd(tvp, uvp, vvp) \
|
|
||||||
do { \
|
|
||||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
|
||||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
|
||||||
if ((vvp)->tv_usec >= 1000000) { \
|
|
||||||
(vvp)->tv_sec++; \
|
|
||||||
(vvp)->tv_usec -= 1000000; \
|
|
||||||
} \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
#define timersub(tvp, uvp, vvp) \
|
|
||||||
do { \
|
|
||||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
|
||||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
|
||||||
if ((vvp)->tv_usec < 0) { \
|
|
||||||
(vvp)->tv_sec--; \
|
|
||||||
(vvp)->tv_usec += 1000000; \
|
|
||||||
} \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ifinfo *iflist;
|
struct ifinfo *iflist;
|
||||||
struct timeval tm_max = {0x7fffffff, 0x7fffffff};
|
struct timeval tm_max = {0x7fffffff, 0x7fffffff};
|
||||||
static int log_upto = 999;
|
static int log_upto = 999;
|
||||||
static int fflag = 0;
|
static int fflag = 0;
|
||||||
|
static int isdaemon = 0;
|
||||||
|
|
||||||
int aflag = 0;
|
int aflag = 0;
|
||||||
int dflag = 0;
|
int dflag = 0;
|
||||||
@ -96,8 +76,6 @@ int dflag = 0;
|
|||||||
*/
|
*/
|
||||||
#define PROBE_INTERVAL 60
|
#define PROBE_INTERVAL 60
|
||||||
|
|
||||||
int main __P((int, char **));
|
|
||||||
|
|
||||||
/* static variables and functions */
|
/* static variables and functions */
|
||||||
static int mobile_node = 0;
|
static int mobile_node = 0;
|
||||||
#ifndef SMALL
|
#ifndef SMALL
|
||||||
@ -106,22 +84,22 @@ static const char *dumpfilename = "/var/run/rtsold.dump"; /* XXX: should be conf
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ifreconfig __P((char *));
|
static int ifreconfig(char *);
|
||||||
#endif
|
#endif
|
||||||
static int make_packet __P((struct ifinfo *));
|
static int make_packet(struct ifinfo *);
|
||||||
static struct timeval *rtsol_check_timer __P((void));
|
static struct timeval *rtsol_check_timer(void);
|
||||||
|
|
||||||
#ifndef SMALL
|
#ifndef SMALL
|
||||||
static void rtsold_set_dump_file __P((int));
|
static void rtsold_set_dump_file(int);
|
||||||
#endif
|
#endif
|
||||||
__dead static void usage(char *);
|
__dead static void usage(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int s, ch, once = 0;
|
int s, ch, once = 0;
|
||||||
struct timeval *timeout;
|
struct timeval *timeout;
|
||||||
char *argv0;
|
const char *ident;
|
||||||
const char *opts;
|
const char *opts;
|
||||||
struct pollfd set[2];
|
struct pollfd set[2];
|
||||||
#ifdef USE_RTSOCK
|
#ifdef USE_RTSOCK
|
||||||
@ -131,10 +109,11 @@ main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Initialization
|
* Initialization
|
||||||
*/
|
*/
|
||||||
argv0 = argv[0];
|
ident = getprogname();
|
||||||
|
isdaemon = ident[strlen(ident) - 1] == 'd';
|
||||||
|
|
||||||
/* get option */
|
/* get option */
|
||||||
if (argv0 && argv0[strlen(argv0) - 1] != 'd') {
|
if (!isdaemon) {
|
||||||
fflag = 1;
|
fflag = 1;
|
||||||
once = 1;
|
once = 1;
|
||||||
opts = "adD";
|
opts = "adD";
|
||||||
@ -162,7 +141,7 @@ main(int argc, char **argv)
|
|||||||
once = 1;
|
once = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv0);
|
usage();
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +149,7 @@ main(int argc, char **argv)
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if ((!aflag && argc == 0) || (aflag && argc != 0)) {
|
if ((!aflag && argc == 0) || (aflag && argc != 0)) {
|
||||||
usage(argv0);
|
usage();
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,13 +157,6 @@ main(int argc, char **argv)
|
|||||||
if (dflag == 0)
|
if (dflag == 0)
|
||||||
log_upto = LOG_NOTICE;
|
log_upto = LOG_NOTICE;
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
char *ident;
|
|
||||||
|
|
||||||
ident = strrchr(argv0, '/');
|
|
||||||
if (!ident)
|
|
||||||
ident = argv0;
|
|
||||||
else
|
|
||||||
ident++;
|
|
||||||
openlog(ident, LOG_NDELAY|LOG_PID, LOG_DAEMON);
|
openlog(ident, LOG_NDELAY|LOG_PID, LOG_DAEMON);
|
||||||
if (log_upto >= 0)
|
if (log_upto >= 0)
|
||||||
setlogmask(LOG_UPTO(log_upto));
|
setlogmask(LOG_UPTO(log_upto));
|
||||||
@ -293,7 +265,9 @@ main(int argc, char **argv)
|
|||||||
if (ifi == NULL)
|
if (ifi == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
e = poll(set, 2, timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFTIM);
|
e = poll(set, 2, (int)(timeout ?
|
||||||
|
(timeout->tv_sec * 1000 + timeout->tv_usec / 1000) :
|
||||||
|
INFTIM));
|
||||||
if (e < 1) {
|
if (e < 1) {
|
||||||
if (e < 0 && errno != EINTR) {
|
if (e < 0 && errno != EINTR) {
|
||||||
warnmsg(LOG_ERR, __func__, "poll: %s",
|
warnmsg(LOG_ERR, __func__, "poll: %s",
|
||||||
@ -325,19 +299,19 @@ ifconfig(char *ifname)
|
|||||||
if ((sdl = if_nametosdl(ifname)) == NULL) {
|
if ((sdl = if_nametosdl(ifname)) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"failed to get link layer information for %s", ifname);
|
"failed to get link layer information for %s", ifname);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (find_ifinfo(sdl->sdl_index)) {
|
if (find_ifinfo(sdl->sdl_index)) {
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"interface %s was already configured", ifname);
|
"interface %s was already configured", ifname);
|
||||||
free(sdl);
|
free(sdl);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ifinfo = malloc(sizeof(*ifinfo))) == NULL) {
|
if ((ifinfo = malloc(sizeof(*ifinfo))) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__, "memory allocation failed");
|
warnmsg(LOG_ERR, __func__, "memory allocation failed");
|
||||||
free(sdl);
|
free(sdl);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
memset(ifinfo, 0, sizeof(*ifinfo));
|
memset(ifinfo, 0, sizeof(*ifinfo));
|
||||||
ifinfo->sdl = sdl;
|
ifinfo->sdl = sdl;
|
||||||
@ -387,12 +361,12 @@ ifconfig(char *ifname)
|
|||||||
ifinfo->next = iflist;
|
ifinfo->next = iflist;
|
||||||
iflist = ifinfo;
|
iflist = ifinfo;
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
free(ifinfo->sdl);
|
free(ifinfo->sdl);
|
||||||
free(ifinfo);
|
free(ifinfo);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -438,20 +412,20 @@ ifreconfig(char *ifname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ifinfo *
|
struct ifinfo *
|
||||||
find_ifinfo(int ifindex)
|
find_ifinfo(size_t ifindex)
|
||||||
{
|
{
|
||||||
struct ifinfo *ifi;
|
struct ifinfo *ifi;
|
||||||
|
|
||||||
for (ifi = iflist; ifi; ifi = ifi->next)
|
for (ifi = iflist; ifi; ifi = ifi->next)
|
||||||
if (ifi->sdl->sdl_index == ifindex)
|
if (ifi->sdl->sdl_index == ifindex)
|
||||||
return(ifi);
|
return ifi;
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
make_packet(struct ifinfo *ifinfo)
|
make_packet(struct ifinfo *ifinfo)
|
||||||
{
|
{
|
||||||
size_t packlen = sizeof(struct nd_router_solicit), lladdroptlen = 0;
|
size_t packlen = sizeof(struct nd_router_solicit), lladdroptlen;
|
||||||
struct nd_router_solicit *rs;
|
struct nd_router_solicit *rs;
|
||||||
u_char *buf;
|
u_char *buf;
|
||||||
|
|
||||||
@ -467,7 +441,7 @@ make_packet(struct ifinfo *ifinfo)
|
|||||||
if ((buf = malloc(packlen)) == NULL) {
|
if ((buf = malloc(packlen)) == NULL) {
|
||||||
warnmsg(LOG_ERR, __func__,
|
warnmsg(LOG_ERR, __func__,
|
||||||
"memory allocation failed for %s", ifinfo->ifname);
|
"memory allocation failed for %s", ifinfo->ifname);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
ifinfo->rs_data = buf;
|
ifinfo->rs_data = buf;
|
||||||
|
|
||||||
@ -483,7 +457,7 @@ make_packet(struct ifinfo *ifinfo)
|
|||||||
if (lladdroptlen)
|
if (lladdroptlen)
|
||||||
lladdropt_fill(ifinfo->sdl, (struct nd_opt_hdr *)buf);
|
lladdropt_fill(ifinfo->sdl, (struct nd_opt_hdr *)buf);
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct timeval *
|
static struct timeval *
|
||||||
@ -534,7 +508,7 @@ rtsol_check_timer(void)
|
|||||||
probe = 1;
|
probe = 1;
|
||||||
ifinfo->state = IFS_DELAY;
|
ifinfo->state = IFS_DELAY;
|
||||||
} else if (ifinfo->probeinterval &&
|
} else if (ifinfo->probeinterval &&
|
||||||
(ifinfo->probetimer -=
|
(ifinfo->probetimer -= (int)
|
||||||
ifinfo->timer.tv_sec) <= 0) {
|
ifinfo->timer.tv_sec) <= 0) {
|
||||||
/* probe timer expired */
|
/* probe timer expired */
|
||||||
ifinfo->probetimer =
|
ifinfo->probetimer =
|
||||||
@ -572,7 +546,7 @@ rtsol_check_timer(void)
|
|||||||
|
|
||||||
if (timercmp(&rtsol_timer, &tm_max, ==)) {
|
if (timercmp(&rtsol_timer, &tm_max, ==)) {
|
||||||
warnmsg(LOG_DEBUG, __func__, "there is no timer");
|
warnmsg(LOG_DEBUG, __func__, "there is no timer");
|
||||||
return(NULL);
|
return NULL;
|
||||||
} else if (timercmp(&rtsol_timer, &now, <))
|
} else if (timercmp(&rtsol_timer, &now, <))
|
||||||
/* this may occur when the interval is too small */
|
/* this may occur when the interval is too small */
|
||||||
returnval.tv_sec = returnval.tv_usec = 0;
|
returnval.tv_sec = returnval.tv_usec = 0;
|
||||||
@ -583,7 +557,7 @@ rtsol_check_timer(void)
|
|||||||
warnmsg(LOG_DEBUG, __func__, "New timer is %ld:%08ld",
|
warnmsg(LOG_DEBUG, __func__, "New timer is %ld:%08ld",
|
||||||
(long)returnval.tv_sec, (long)returnval.tv_usec);
|
(long)returnval.tv_sec, (long)returnval.tv_usec);
|
||||||
|
|
||||||
return(&returnval);
|
return &returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -615,7 +589,7 @@ rtsol_timer_update(struct ifinfo *ifinfo)
|
|||||||
case IFS_DELAY:
|
case IFS_DELAY:
|
||||||
interval = arc4random() % (MAX_RTR_SOLICITATION_DELAY * MILLION);
|
interval = arc4random() % (MAX_RTR_SOLICITATION_DELAY * MILLION);
|
||||||
ifinfo->timer.tv_sec = interval / MILLION;
|
ifinfo->timer.tv_sec = interval / MILLION;
|
||||||
ifinfo->timer.tv_usec = interval % MILLION;
|
ifinfo->timer.tv_usec = (suseconds_t)(interval % MILLION);
|
||||||
break;
|
break;
|
||||||
case IFS_PROBE:
|
case IFS_PROBE:
|
||||||
if (ifinfo->probes < MAX_RTR_SOLICITATIONS)
|
if (ifinfo->probes < MAX_RTR_SOLICITATIONS)
|
||||||
@ -669,15 +643,11 @@ rtsold_set_dump_file(int sig)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(char *progname)
|
usage(void)
|
||||||
{
|
{
|
||||||
if (progname && progname[strlen(progname) - 1] != 'd') {
|
const char *opts = isdaemon ? "-1Ddfm" : "Dd";
|
||||||
fprintf(stderr, "usage: rtsol [-Dd] interface ...\n");
|
fprintf(stderr, "Usage: %s [%s] interface ...\n", getprogname(), opts);
|
||||||
fprintf(stderr, "usage: rtsol [-Dd] -a\n");
|
fprintf(stderr, "\t%s [%s] -a\n", getprogname(), opts);
|
||||||
} else {
|
|
||||||
fprintf(stderr, "usage: rtsold [-1Ddfm] interface ...\n");
|
|
||||||
fprintf(stderr, "usage: rtsold [-1Ddfm] -a\n");
|
|
||||||
}
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,18 +655,15 @@ void
|
|||||||
warnmsg(int priority, const char *func, const char *msg, ...)
|
warnmsg(int priority, const char *func, const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
if (fflag) {
|
if (fflag) {
|
||||||
if (priority <= log_upto) {
|
if (priority <= log_upto)
|
||||||
(void)vfprintf(stderr, msg, ap);
|
vwarnx(msg, ap);
|
||||||
(void)fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
char buf[BUFSIZ];
|
||||||
snprintf(buf, sizeof(buf), "<%s> %s", func, msg);
|
snprintf(buf, sizeof(buf), "<%s> %s", func, msg);
|
||||||
msg = buf;
|
vsyslog(priority, buf, ap);
|
||||||
vsyslog(priority, msg, ap);
|
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
@ -708,9 +675,10 @@ char **
|
|||||||
autoifprobe(void)
|
autoifprobe(void)
|
||||||
{
|
{
|
||||||
static char **argv = NULL;
|
static char **argv = NULL;
|
||||||
static int n = 0;
|
static size_t n = 0;
|
||||||
char **a;
|
char **a;
|
||||||
int i, found;
|
size_t i;
|
||||||
|
int found;
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
@ -753,20 +721,20 @@ autoifprobe(void)
|
|||||||
if (n != 0 && dflag > 1)
|
if (n != 0 && dflag > 1)
|
||||||
warnx("multiple interfaces found");
|
warnx("multiple interfaces found");
|
||||||
|
|
||||||
a = (char **)realloc(argv, (n + 1) * sizeof(char **));
|
a = realloc(argv, (n + 1) * sizeof(char **));
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
err(1, "realloc");
|
err(EXIT_FAILURE, "realloc");
|
||||||
argv = a;
|
argv = a;
|
||||||
argv[n] = strdup(ifa->ifa_name);
|
argv[n] = strdup(ifa->ifa_name);
|
||||||
if (!argv[n])
|
if (!argv[n])
|
||||||
err(1, "strdup");
|
err(EXIT_FAILURE, "strdup");
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
a = (char **)realloc(argv, (n + 1) * sizeof(char **));
|
a = realloc(argv, (n + 1) * sizeof(char **));
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
err(1, "realloc");
|
err(EXIT_FAILURE, "realloc");
|
||||||
argv = a;
|
argv = a;
|
||||||
argv[n] = NULL;
|
argv[n] = NULL;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: rtsold.h,v 1.10 2011/10/17 16:31:14 mbalmer Exp $ */
|
/* $NetBSD: rtsold.h,v 1.11 2014/03/18 00:16:49 christos Exp $ */
|
||||||
/* $KAME: rtsold.h,v 1.14 2002/05/31 10:10:03 itojun Exp $ */
|
/* $KAME: rtsold.h,v 1.14 2002/05/31 10:10:03 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -64,35 +64,37 @@ struct ifinfo {
|
|||||||
extern struct timeval tm_max;
|
extern struct timeval tm_max;
|
||||||
extern int dflag;
|
extern int dflag;
|
||||||
extern int aflag;
|
extern int aflag;
|
||||||
extern int ifconfig __P((char *));
|
extern struct ifinfo *iflist;
|
||||||
extern void iflist_init __P((void));
|
extern int rssock;
|
||||||
struct ifinfo *find_ifinfo __P((int));
|
|
||||||
void rtsol_timer_update __P((struct ifinfo *));
|
int ifconfig(char *);
|
||||||
extern void warnmsg __P((int, const char *, const char *, ...))
|
void iflist_init(void);
|
||||||
__attribute__((__format__(__printf__, 3, 4)));
|
struct ifinfo *find_ifinfo(size_t);
|
||||||
extern char **autoifprobe __P((void));
|
void rtsol_timer_update(struct ifinfo *);
|
||||||
|
void warnmsg(int, const char *, const char *, ...) __printflike(3, 4);
|
||||||
|
char **autoifprobe(void);
|
||||||
|
|
||||||
/* if.c */
|
/* if.c */
|
||||||
extern int ifinit __P((void));
|
int ifinit(void);
|
||||||
extern int interface_up __P((char *));
|
int interface_up(char *);
|
||||||
extern int interface_status __P((struct ifinfo *));
|
int interface_status(struct ifinfo *);
|
||||||
extern int lladdropt_length __P((struct sockaddr_dl *));
|
size_t lladdropt_length(struct sockaddr_dl *);
|
||||||
extern void lladdropt_fill __P((struct sockaddr_dl *, struct nd_opt_hdr *));
|
void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *);
|
||||||
extern struct sockaddr_dl *if_nametosdl __P((char *));
|
struct sockaddr_dl *if_nametosdl(char *);
|
||||||
extern int getinet6sysctl __P((int));
|
int getinet6sysctl(int);
|
||||||
|
|
||||||
/* rtsol.c */
|
/* rtsol.c */
|
||||||
extern int sockopen __P((void));
|
int sockopen(void);
|
||||||
extern void sendpacket __P((struct ifinfo *));
|
void sendpacket(struct ifinfo *);
|
||||||
extern void rtsol_input __P((int));
|
void rtsol_input(int);
|
||||||
|
|
||||||
/* probe.c */
|
/* probe.c */
|
||||||
extern int probe_init __P((void));
|
int probe_init(void);
|
||||||
extern void defrouter_probe __P((struct ifinfo *));
|
void defrouter_probe(struct ifinfo *);
|
||||||
|
|
||||||
/* dump.c */
|
/* dump.c */
|
||||||
extern void rtsold_dump_file __P((const char *));
|
void rtsold_dump_file(const char *);
|
||||||
|
|
||||||
/* rtsock.c */
|
/* rtsock.c */
|
||||||
extern int rtsock_open __P((void));
|
int rtsock_open(void);
|
||||||
extern int rtsock_input __P((int));
|
int rtsock_input(int);
|
||||||
|
Loading…
Reference in New Issue
Block a user