mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
"sin" is a reserved C library function name. use sin6
Obtained from: KAME MFC after: 1 week
This commit is contained in:
parent
e5a9696004
commit
4c4ac8c03d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119031
@ -686,9 +686,9 @@ static int nrt;
|
||||
static struct netinfo6 *np;
|
||||
|
||||
void
|
||||
ripflush(ifcp, sin)
|
||||
ripflush(ifcp, sin6)
|
||||
struct ifc *ifcp;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
{
|
||||
int i;
|
||||
int error;
|
||||
@ -696,10 +696,10 @@ ripflush(ifcp, sin)
|
||||
if (ifcp)
|
||||
tracet(1, "Send(%s): info(%d) to %s.%d\n",
|
||||
ifcp->ifc_name, nrt,
|
||||
inet6_n2p(&sin->sin6_addr), ntohs(sin->sin6_port));
|
||||
inet6_n2p(&sin6->sin6_addr), ntohs(sin6->sin6_port));
|
||||
else
|
||||
tracet(1, "Send: info(%d) to %s.%d\n",
|
||||
nrt, inet6_n2p(&sin->sin6_addr), ntohs(sin->sin6_port));
|
||||
nrt, inet6_n2p(&sin6->sin6_addr), ntohs(sin6->sin6_port));
|
||||
if (dflag >= 2) {
|
||||
np = ripbuf->rip6_nets;
|
||||
for (i = 0; i < nrt; i++, np++) {
|
||||
@ -722,7 +722,7 @@ ripflush(ifcp, sin)
|
||||
trace(2, "\n");
|
||||
}
|
||||
}
|
||||
error = sendpacket(sin, RIPSIZE(nrt));
|
||||
error = sendpacket(sin6, RIPSIZE(nrt));
|
||||
if (error == EAFNOSUPPORT) {
|
||||
/* Protocol not supported */
|
||||
tracet(1, "Could not send info to %s (%s): "
|
||||
@ -737,9 +737,9 @@ ripflush(ifcp, sin)
|
||||
* Generate RIP6_RESPONSE packets and send them.
|
||||
*/
|
||||
void
|
||||
ripsend(ifcp, sin, flag)
|
||||
ripsend(ifcp, sin6, flag)
|
||||
struct ifc *ifcp;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
int flag;
|
||||
{
|
||||
struct riprt *rrt;
|
||||
@ -763,12 +763,12 @@ ripsend(ifcp, sin, flag)
|
||||
*np = rrt->rrt_info;
|
||||
np++; nrt++;
|
||||
if (nrt == maxrte) {
|
||||
ripflush(NULL, sin);
|
||||
ripflush(NULL, sin6);
|
||||
nh = NULL;
|
||||
}
|
||||
}
|
||||
if (nrt) /* Send last packet */
|
||||
ripflush(NULL, sin);
|
||||
ripflush(NULL, sin6);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ ripsend(ifcp, sin, flag)
|
||||
np = ripbuf->rip6_nets;
|
||||
*np = rrt_info;
|
||||
nrt = 1;
|
||||
ripflush(ifcp, sin);
|
||||
ripflush(ifcp, sin6);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -825,7 +825,7 @@ ripsend(ifcp, sin, flag)
|
||||
(rrt->rrt_rflags & RRTF_NH_NOT_LLADDR) == 0) {
|
||||
if (nh == NULL || !IN6_ARE_ADDR_EQUAL(nh, &rrt->rrt_gw)) {
|
||||
if (nrt == maxrte - 2)
|
||||
ripflush(ifcp, sin);
|
||||
ripflush(ifcp, sin6);
|
||||
np->rip6_dest = rrt->rrt_gw;
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&np->rip6_dest))
|
||||
SET_IN6_LINKLOCAL_IFINDEX(np->rip6_dest, 0);
|
||||
@ -840,7 +840,7 @@ ripsend(ifcp, sin, flag)
|
||||
rrt->rrt_rflags & RRTF_NH_NOT_LLADDR)) {
|
||||
/* Reset nexthop */
|
||||
if (nrt == maxrte - 2)
|
||||
ripflush(ifcp, sin);
|
||||
ripflush(ifcp, sin6);
|
||||
memset(np, 0, sizeof(struct netinfo6));
|
||||
np->rip6_metric = NEXTHOP_METRIC;
|
||||
nh = NULL;
|
||||
@ -851,12 +851,12 @@ ripsend(ifcp, sin, flag)
|
||||
*np = rrt->rrt_info;
|
||||
np++; nrt++;
|
||||
if (nrt == maxrte) {
|
||||
ripflush(ifcp, sin);
|
||||
ripflush(ifcp, sin6);
|
||||
nh = NULL;
|
||||
}
|
||||
}
|
||||
if (nrt) /* Send last packet */
|
||||
ripflush(ifcp, sin);
|
||||
ripflush(ifcp, sin6);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -963,8 +963,8 @@ tobeadv(rrt, ifcp)
|
||||
* Send a rip packet actually.
|
||||
*/
|
||||
int
|
||||
sendpacket(sin, len)
|
||||
struct sockaddr_in6 *sin;
|
||||
sendpacket(sin6, len)
|
||||
struct sockaddr_in6 *sin6;
|
||||
int len;
|
||||
{
|
||||
/*
|
||||
@ -981,18 +981,18 @@ sendpacket(sin, len)
|
||||
struct sockaddr_in6 sincopy;
|
||||
|
||||
/* do not overwrite the given sin */
|
||||
sincopy = *sin;
|
||||
sin = &sincopy;
|
||||
sincopy = *sin6;
|
||||
sin6 = &sincopy;
|
||||
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)
|
||||
|| IN6_IS_ADDR_MULTICAST(&sin->sin6_addr)) {
|
||||
idx = IN6_LINKLOCAL_IFINDEX(sin->sin6_addr);
|
||||
SET_IN6_LINKLOCAL_IFINDEX(sin->sin6_addr, 0);
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)
|
||||
|| IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
|
||||
idx = IN6_LINKLOCAL_IFINDEX(sin6->sin6_addr);
|
||||
SET_IN6_LINKLOCAL_IFINDEX(sin6->sin6_addr, 0);
|
||||
} else
|
||||
idx = 0;
|
||||
|
||||
m.msg_name = (caddr_t)sin;
|
||||
m.msg_namelen = sizeof(*sin);
|
||||
m.msg_name = (caddr_t)sin6;
|
||||
m.msg_namelen = sizeof(*sin6);
|
||||
iov[0].iov_base = (caddr_t)ripbuf;
|
||||
iov[0].iov_len = len;
|
||||
m.msg_iov = iov;
|
||||
@ -1339,11 +1339,11 @@ sendrequest(ifcp)
|
||||
* Process a RIP6_REQUEST packet.
|
||||
*/
|
||||
void
|
||||
riprequest(ifcp, np, nn, sin)
|
||||
riprequest(ifcp, np, nn, sin6)
|
||||
struct ifc *ifcp;
|
||||
struct netinfo6 *np;
|
||||
int nn;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
{
|
||||
int i;
|
||||
struct riprt *rrt;
|
||||
@ -1359,12 +1359,12 @@ riprequest(ifcp, np, nn, sin)
|
||||
else
|
||||
np->rip6_metric = HOPCNT_INFINITY6;
|
||||
}
|
||||
(void)sendpacket(sin, RIPSIZE(nn));
|
||||
(void)sendpacket(sin6, RIPSIZE(nn));
|
||||
return;
|
||||
}
|
||||
/* Whole routing table dump */
|
||||
trace(1, "\tRIP Request -- whole routing table\n");
|
||||
ripsend(ifcp, sin, RRTF_SENDANYWAY);
|
||||
ripsend(ifcp, sin6, RRTF_SENDANYWAY);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1450,20 +1450,20 @@ ifconfig1(name, sa, ifcp, s)
|
||||
int s;
|
||||
{
|
||||
struct in6_ifreq ifr;
|
||||
const struct sockaddr_in6 *sin;
|
||||
const struct sockaddr_in6 *sin6;
|
||||
struct ifac *ifa;
|
||||
int plen;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
sin = (const struct sockaddr_in6 *)sa;
|
||||
ifr.ifr_addr = *sin;
|
||||
sin6 = (const struct sockaddr_in6 *)sa;
|
||||
ifr.ifr_addr = *sin6;
|
||||
strcpy(ifr.ifr_name, name);
|
||||
if (ioctl(s, SIOCGIFNETMASK_IN6, (char *)&ifr) < 0) {
|
||||
fatal("ioctl: SIOCGIFNETMASK_IN6");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
plen = sin6mask2len(&ifr.ifr_addr);
|
||||
if ((ifa = ifa_match(ifcp, &sin->sin6_addr, plen)) != NULL) {
|
||||
if ((ifa = ifa_match(ifcp, &sin6->sin6_addr, plen)) != NULL) {
|
||||
/* same interface found */
|
||||
/* need check if something changed */
|
||||
/* XXX not yet implemented */
|
||||
@ -1480,10 +1480,10 @@ ifconfig1(name, sa, ifcp, s)
|
||||
ifa->ifa_conf = ifcp;
|
||||
ifa->ifa_next = ifcp->ifc_addr;
|
||||
ifcp->ifc_addr = ifa;
|
||||
ifa->ifa_addr = sin->sin6_addr;
|
||||
ifa->ifa_addr = sin6->sin6_addr;
|
||||
ifa->ifa_plen = plen;
|
||||
if (ifcp->ifc_flags & IFF_POINTOPOINT) {
|
||||
ifr.ifr_addr = *sin;
|
||||
ifr.ifr_addr = *sin6;
|
||||
if (ioctl(s, SIOCGIFDSTADDR_IN6, (char *)&ifr) < 0) {
|
||||
fatal("ioctl: SIOCGIFDSTADDR_IN6");
|
||||
/*NOTREACHED*/
|
||||
@ -2651,7 +2651,7 @@ addroute(rrt, gw, ifcp)
|
||||
struct netinfo6 *np;
|
||||
u_char buf[BUFSIZ], buf1[BUFSIZ], buf2[BUFSIZ];
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
int len;
|
||||
|
||||
np = &rrt->rrt_info;
|
||||
@ -2677,24 +2677,24 @@ addroute(rrt, gw, ifcp)
|
||||
rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
|
||||
rtm->rtm_rmx.rmx_hopcount = np->rip6_metric - 1;
|
||||
rtm->rtm_inits = RTV_HOPCOUNT;
|
||||
sin = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
sin6 = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
/* Destination */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = np->rip6_dest;
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = np->rip6_dest;
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
/* Gateway */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = *gw;
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = *gw;
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
/* Netmask */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = *(plen2mask(np->rip6_plen));
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = *(plen2mask(np->rip6_plen));
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
|
||||
len = (char *)sin - (char *)buf;
|
||||
len = (char *)sin6 - (char *)buf;
|
||||
rtm->rtm_msglen = len;
|
||||
if (write(rtsock, buf, len) > 0)
|
||||
return 0;
|
||||
@ -2722,7 +2722,7 @@ delroute(np, gw)
|
||||
{
|
||||
u_char buf[BUFSIZ], buf2[BUFSIZ];
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
int len;
|
||||
|
||||
inet_ntop(AF_INET6, (void *)gw, (char *)buf2, sizeof(buf2));
|
||||
@ -2744,24 +2744,24 @@ delroute(np, gw)
|
||||
if (np->rip6_plen == sizeof(struct in6_addr) * 8)
|
||||
rtm->rtm_flags |= RTF_HOST;
|
||||
rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
|
||||
sin = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
sin6 = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
/* Destination */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = np->rip6_dest;
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = np->rip6_dest;
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
/* Gateway */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = *gw;
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = *gw;
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
/* Netmask */
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = *(plen2mask(np->rip6_plen));
|
||||
sin = (struct sockaddr_in6 *)((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = *(plen2mask(np->rip6_plen));
|
||||
sin6 = (struct sockaddr_in6 *)((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
|
||||
len = (char *)sin - (char *)buf;
|
||||
len = (char *)sin6 - (char *)buf;
|
||||
rtm->rtm_msglen = len;
|
||||
if (write(rtsock, buf, len) >= 0)
|
||||
return 0;
|
||||
@ -2791,7 +2791,7 @@ getroute(np, gw)
|
||||
u_long myseq;
|
||||
int len;
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
rtm = (struct rt_msghdr *)buf;
|
||||
len = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in6);
|
||||
@ -2802,10 +2802,10 @@ getroute(np, gw)
|
||||
rtm->rtm_seq = myseq;
|
||||
rtm->rtm_addrs = RTA_DST;
|
||||
rtm->rtm_msglen = len;
|
||||
sin = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin->sin6_family = AF_INET6;
|
||||
sin->sin6_addr = np->rip6_dest;
|
||||
sin6 = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = np->rip6_dest;
|
||||
if (write(rtsock, buf, len) < 0) {
|
||||
if (errno == ESRCH) /* No such route found */
|
||||
return NULL;
|
||||
@ -2819,13 +2819,13 @@ getroute(np, gw)
|
||||
}
|
||||
rtm = (struct rt_msghdr *)buf;
|
||||
} while (rtm->rtm_seq != myseq || rtm->rtm_pid != pid);
|
||||
sin = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
sin6 = (struct sockaddr_in6 *)&buf[sizeof(struct rt_msghdr)];
|
||||
if (rtm->rtm_addrs & RTA_DST) {
|
||||
sin = (struct sockaddr_in6 *)
|
||||
((char *)sin + ROUNDUP(sin->sin6_len));
|
||||
sin6 = (struct sockaddr_in6 *)
|
||||
((char *)sin6 + ROUNDUP(sin6->sin6_len));
|
||||
}
|
||||
if (rtm->rtm_addrs & RTA_GATEWAY) {
|
||||
*gw = sin->sin6_addr;
|
||||
*gw = sin6->sin6_addr;
|
||||
return gw;
|
||||
}
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user