Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Fix building of IPv4-Mapped IPv6 addresses.
details: https://anonhg.NetBSD.org/src/rev/9ce7781ee2e2
branches: trunk
changeset: 343585:9ce7781ee2e2
user: rtr <rtr%NetBSD.org@localhost>
date: Mon Feb 15 19:00:42 2016 +0000
description:
Fix building of IPv4-Mapped IPv6 addresses.
As discussed on tech-net@ use in6_sin_2_v4mapsin6() to build mapped
addresses.
diffstat:
sys/netinet/sctp_indata.c | 30 +++-------------------
sys/netinet/sctputil.c | 60 +++++++---------------------------------------
2 files changed, 14 insertions(+), 76 deletions(-)
diffs (189 lines):
diff -r 8681bde539d3 -r 9ce7781ee2e2 sys/netinet/sctp_indata.c
--- a/sys/netinet/sctp_indata.c Mon Feb 15 17:35:39 2016 +0000
+++ b/sys/netinet/sctp_indata.c Mon Feb 15 19:00:42 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sctp_indata.c,v 1.2 2015/12/13 18:53:57 christos Exp $ */
+/* $NetBSD: sctp_indata.c,v 1.3 2016/02/15 19:00:42 rtr Exp $ */
/* $KAME: sctp_indata.c,v 1.36 2005/03/06 16:04:17 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctp_indata.c,v 1.2 2015/12/13 18:53:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctp_indata.c,v 1.3 2016/02/15 19:00:42 rtr Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -424,13 +424,7 @@
const struct sockaddr_in *sin;
sin = (const struct sockaddr_in *)to;
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -653,14 +647,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr,
- &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -1962,14 +1949,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr,
- &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
diff -r 8681bde539d3 -r 9ce7781ee2e2 sys/netinet/sctputil.c
--- a/sys/netinet/sctputil.c Mon Feb 15 17:35:39 2016 +0000
+++ b/sys/netinet/sctputil.c Mon Feb 15 19:00:42 2016 +0000
@@ -1,5 +1,5 @@
/* $KAME: sctputil.c,v 1.39 2005/06/16 20:54:06 jinmei Exp $ */
-/* $NetBSD: sctputil.c,v 1.1 2015/10/13 21:28:35 rjs Exp $ */
+/* $NetBSD: sctputil.c,v 1.2 2016/02/15 19:00:42 rtr Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.1 2015/10/13 21:28:35 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.2 2016/02/15 19:00:42 rtr Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2087,13 +2087,7 @@
const struct sockaddr_in *sin;
sin = (const struct sockaddr_in *)to;
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- memcpy(&sin6.sin6_addr.s6_addr16[3], &sin->sin_addr,
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2179,13 +2173,7 @@
const struct sockaddr_in *sin;
sin = (const struct sockaddr_in *)to;
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2279,13 +2267,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2357,13 +2339,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2433,13 +2409,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2518,13 +2488,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
@@ -2620,13 +2584,7 @@
const struct sockaddr_in *sin;
sin = satocsin(to);
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = AF_INET6;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr16[2] = 0xffff;
- bcopy(&sin->sin_addr, &sin6.sin6_addr.s6_addr16[3],
- sizeof(sin6.sin6_addr.s6_addr16[3]));
- sin6.sin6_port = sin->sin_port;
+ in6_sin_2_v4mapsin6(sin, &sin6);
to = (struct sockaddr *)&sin6;
}
/* check and strip embedded scope junk */
Home |
Main Index |
Thread Index |
Old Index