-/* $OpenBSD: ndp.c,v 1.73 2016/07/31 19:17:41 jca Exp $ */
+/* $OpenBSD: ndp.c,v 1.74 2016/07/31 19:23:24 jca Exp $ */
/* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */
/*
static int nflag;
static int tflag;
static int32_t thiszone; /* time difference with gmt */
-static int s = -1;
+static int rtsock = -1;
static int repeat = 0;
char ntop_buf[INET6_ADDRSTRLEN]; /* inet_ntop() */
void
getsocket(void)
{
- if (s < 0) {
- s = socket(PF_ROUTE, SOCK_RAW, 0);
- if (s < 0) {
+ if (rtsock < 0) {
+ rtsock = socket(PF_ROUTE, SOCK_RAW, 0);
+ if (rtsock < 0) {
err(1, "socket");
/* NOTREACHED */
}
l = rtm->rtm_msglen;
rtm->rtm_seq = ++seq;
rtm->rtm_type = cmd;
- if ((rlen = write(s, (char *)&m_rtmsg, l)) < 0) {
+ if ((rlen = write(rtsock, (char *)&m_rtmsg, l)) < 0) {
if (errno != ESRCH || cmd != RTM_DELETE) {
err(1, "writing to routing socket");
/* NOTREACHED */
}
}
do {
- l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
+ l = read(rtsock, (char *)&m_rtmsg, sizeof(m_rtmsg));
} while (l > 0 && (rtm->rtm_version != RTM_VERSION ||
rtm->rtm_seq != seq || rtm->rtm_pid != pid));
if (l < 0)