This is a modification by Manvendra Bhangui (www.indimail.org) of Erwin Hoffmann's (fehcom.de) tcpserver.c included in his ucspi-tcp6-0.98 to make it work with spf check versus IPv4-mapped IPv6 addresses. ############# diff -ruN net-original/ucspi-tcp6-0.98/src/tcpserver.c net/ucspi-tcp6-0.98/src/tcpserver.c --- net-original/ucspi-tcp6-0.98/src/tcpserver.c 2013-01-11 21:18:19.000000000 +0100 +++ net/ucspi-tcp6-0.98/src/tcpserver.c 2013-08-06 11:14:37.000000000 +0200 @@ -53,6 +53,7 @@ char remoteportstr[FMT_ULONG]; char remoteip[16]; char remoteipstr[IP6_FMT]; +char remoteip6str[IP6_FMT]; static stralloc remotehostsa; char *remotehost = 0; @@ -142,11 +143,15 @@ char *stripaddr; int j; - if (!forcev6 && ip6_isv4mapped(remoteip)) mappedv4 = 1; + if (!forcev6 && ip6_isv4mapped(remoteip)) + mappedv4 = 1; if (mappedv4) - remoteipstr[ip4_fmt(remoteipstr,remoteip+12)] = 0; + remoteipstr[ip4_fmt(remoteipstr, remoteip + 12)] = 0; else - remoteipstr[ip6_compactaddr(remoteipstr,remoteip)] = 0; + if (noipv6 && !forcev6) + remoteipstr[ip4_fmt(remoteipstr, remoteip)] = 0; + else + remoteipstr[ip6_compactaddr(remoteipstr, remoteip)] = 0; if (verbosity >= 2) { strnum[fmt_ulong(strnum,getpid())] = 0; @@ -208,11 +213,15 @@ remotehost = remotehostsa.s; } } - if (!noipv6) - remoteipstr[ip6_compactaddr(remoteipstr,remoteip)] = 0; env("TCPREMOTEIP",remoteipstr); env("TCPREMOTEPORT",remoteportstr); env("TCPREMOTEHOST",remotehost); + if (!noipv6) { + remoteip6str[ip6_compactaddr(remoteip6str, remoteip)] = 0; + env("TCP6REMOTEIP", remoteip6str); + env("TCP6REMOTEPORT", remoteportstr); + env("TCP6REMOTEHOST", remotehost); + } if (flagremoteinfo) { if (remoteinfo6(&tcpremoteinfo,remoteip,remoteport,localip,localport,timeout,netif) == -1)