|
@@ -0,0 +1,1393 @@
+Qmail IPv6 patch
+ Kazunori Fujiwara <fujiwara@pyon.org>
+ originally 1997,1998
+ 2002 Oct. 6.
+
+This patch enables qmail to receive and send mail via IPv6 network.
+
+This patch was not guaranteed.
+The fault by having applied this patch belongs to one which applied the patch.
+
+apply this patch and defines some macros on conf-cc.
+INET6 (default) enables IPv6 transport
+TCPTO_REFUSED when enabled, tcpto denial cache caches
+ connection refused hosts.
+ (normaly, timeout only)
+
+patch needed part:
+
+DNS Resolving:
+ o resolve AAAA with A
+ o IPv6 address reverse resolve.
+ o resolve MX's AAAA and A
+
+Receiving:
+ tcp_env resolves IPv6 and IPv4 socket address to environ.
+
+Sending:
+ A and AAAA are also resolved.
+ IPv4 address and an IPv6 address are treated similarly.
+ tcpto denial cache caches IPv4 and IPv6 addresses.
+
+
+You need IPv6'ed inetd and tcp wrappers.
+
+You want to use IPv6 only life, You need OSs which have IPv6 resolver
+like *BSD.
+
+
+-----
+Changes:
+ I found my old patch's tcpto bug on 2002 Oct. 6.
+ Older patch's tcpto is not work.
+ without dinial cache, sending mails works.
+ but some useless connects increase.
+
+
+Please inform me something wrong with this patch and this text.
+
+
+
+diff -ub qmail-1.03/conf-cc qmail-1.03+v6/conf-cc
+--- qmail-1.03/conf-cc Mon Jun 15 19:53:16 1998
++++ qmail-1.03+v6/conf-cc Mon Oct 7 01:05:47 2002
+@@ -1,3 +1,5 @@
++cc -O2 -DINET6
+ cc -O2
++cc -O2 -DINET6 -DTCPTO_REFUSED
+
+ This will be used to compile .c files.
+diff -ub qmail-1.03/dns.c qmail-1.03+v6/dns.c
+--- qmail-1.03/dns.c Mon Jun 15 19:53:16 1998
++++ qmail-1.03+v6/dns.c Sun Oct 6 15:52:29 2002
+@@ -3,6 +3,7 @@
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <arpa/nameser.h>
++#include <sys/socket.h>
+ #include <resolv.h>
+ #include <errno.h>
+ extern int res_query();
+@@ -29,6 +30,9 @@
+ static int numanswers;
+ static char name[MAXDNAME];
+ static struct ip_address ip;
++#ifdef INET6
++static struct ip6_address ip6;
++#endif
+ unsigned short pref;
+
+ static stralloc glue = {0};
+@@ -142,6 +146,43 @@
+ return 0;
+ }
+
++#ifdef INET6
++static int findip6(wanttype)
++int wanttype;
++{
++ unsigned short rrtype;
++ unsigned short rrdlen;
++ int i;
++
++ if (numanswers <= 0) return 2;
++ --numanswers;
++ if (responsepos == responseend) return DNS_SOFT;
++
++ i = dn_expand(response.buf,responseend,responsepos,name,MAXDNAME);
++ if (i < 0) return DNS_SOFT;
++ responsepos += i;
++
++ i = responseend - responsepos;
++ if (i < 4 + 3 * 2) return DNS_SOFT;
++
++ rrtype = getshort(responsepos);
++ rrdlen = getshort(responsepos + 8);
++ responsepos += 10;
++
++ if (rrtype == wanttype)
++ {
++ if (rrdlen < 16)
++ return DNS_SOFT;
++ bcopy(&responsepos[0], &ip6.d, 16);
++ responsepos += rrdlen;
++ return 1;
++ }
++
++ responsepos += rrdlen;
++ return 0;
++}
++#endif
++
+ static int findmx(wanttype)
+ int wanttype;
+ {
+@@ -263,6 +304,57 @@
+ return DNS_HARD;
+ }
+
++#ifdef INET6
++static int iaafmt6(s,ip)
++char *s;
++struct ip6_address *ip;
++{
++ unsigned int i;
++ int j;
++ unsigned int len;
++ static char data[] = "0123456789abcdef";
++ len = 0;
++
++ if (s) {
++ for (j = 15; j >= 0; j--) {
++ *s++ = data[ip->d[j] & 0x0f];
++ *s++ = '.';
++ *s++ = data[(ip->d[j] >> 4) & 0x0f];
++ *s++ = '.';
++ }
++ strcpy(s, "ip6.int");
++ }
++ return 71;
++ /* 1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.ip6.int */
++}
++
++int dns_ptr6(sa,ip)
++stralloc *sa;
++struct ip6_address *ip;
++{
++ int r;
++
++ if (!stralloc_ready(sa,iaafmt6((char *) 0,ip))) return DNS_MEM;
++ sa->len = iaafmt6(sa->s,ip);
++ switch(resolve(sa,T_PTR))
++ {
++ case DNS_MEM: return DNS_MEM;
++ case DNS_SOFT: return DNS_SOFT;
++ case DNS_HARD: return DNS_HARD;
++ }
++ while ((r = findname(T_PTR)) != 2)
++ {
++ if (r == DNS_SOFT) return DNS_SOFT;
++ if (r == 1)
++ {
++ if (!stralloc_copys(sa,name)) return DNS_MEM;
++ return 0;
++ }
++ }
++ return DNS_HARD;
++}
++#endif
++
+ static int dns_ipplus(ia,sa,pref)
+ ipalloc *ia;
+ stralloc *sa;
+@@ -270,33 +362,66 @@
+ {
+ int r;
+ struct ip_mx ix;
++ int err4 = 0, err6 = 0;
+
+ if (!stralloc_copy(&glue,sa)) return DNS_MEM;
+ if (!stralloc_0(&glue)) return DNS_MEM;
+ if (glue.s[0]) {
+ ix.pref = 0;
+- if (!glue.s[ip_scan(glue.s,&ix.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.ip)])
++ ix.af = AF_INET;
++ if (!glue.s[ip_scan(glue.s,&ix.addr.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.addr.ip)])
+ {
+ if (!ipalloc_append(ia,&ix)) return DNS_MEM;
+ return 0;
+ }
|