[dovecot-cvs] dovecot/src/lib network.c, 1.38, 1.38.2.1 network.h, 1.14, 1.14.2.1
tss at dovecot.org
tss at dovecot.org
Sun Oct 15 17:19:48 UTC 2006
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv23012
Modified Files:
Tag: branch_1_0
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.38.2.1
diff -u -d -r1.38 -r1.38.2.1
--- network.c 14 Feb 2006 18:28:15 -0000 1.38
+++ network.c 15 Oct 2006 16:19:15 -0000 1.38.2.1
@@ -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.14.2.1
diff -u -d -r1.14 -r1.14.2.1
--- network.h 13 Jan 2006 20:26:01 -0000 1.14
+++ network.h 15 Oct 2006 16:19:15 -0000 1.14.2.1
@@ -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