[dovecot-cvs] dovecot/src/lib network.c, 1.38, 1.39 network.h, 1.14, 1.15

tss at dovecot.org tss at dovecot.org
Sun Oct 15 17:19:20 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv23019/lib

Modified Files:
	network.c network.h 
Log Message:
Added net_ipv6_mapped_ipv4_convert().



Index: network.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/network.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- network.c	14 Feb 2006 18:28:15 -0000	1.38
+++ network.c	15 Oct 2006 16:19:17 -0000	1.39
@@ -570,6 +570,25 @@
 	return 0;
 }
 
+int net_ipv6_mapped_ipv4_convert(const struct ip_addr *src,
+				 struct ip_addr *dest)
+{
+#ifdef HAVE_IPV6
+	if (!IPADDR_IS_V6(src))
+		return -1;
+	if (src->ip.in6_u.u6_addr32[0] != 0 ||
+	    src->ip.in6_u.u6_addr32[1] != 0 ||
+	    src->ip.in6_u.u6_addr32[2] != 0xffff0000)
+		return -1;
+
+	dest->family = AF_INET;
+	memcpy(&dest->ip, &src->ip.in6_u.u6_addr32[3], 4);
+	return 0;
+#else
+	return -1;
+#endif
+}
+
 /* Get socket error */
 int net_geterror(int fd)
 {

Index: network.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/network.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- network.h	13 Jan 2006 20:26:01 -0000	1.14
+++ network.h	15 Oct 2006 16:19:18 -0000	1.15
@@ -93,6 +93,10 @@
 const char *net_ip2addr(const struct ip_addr *ip);
 /* char* -> struct ip_addr translation. */
 int net_addr2ip(const char *addr, struct ip_addr *ip);
+/* Convert IPv6 mapped IPv4 address to an actual IPv4 address. Returns 0 if
+   successful, -1 if the source address isn't IPv6 mapped IPv4 address. */
+int net_ipv6_mapped_ipv4_convert(const struct ip_addr *src,
+				 struct ip_addr *dest);
 
 /* Get socket error */
 int net_geterror(int fd);



More information about the dovecot-cvs mailing list