$ diff -u milter-greylist-4.5.11 milter-greylist-4.5.11-6dnsrbl
diff -u milter-greylist-4.5.11/dnsrbl.c milter-greylist-4.5.11-6dnsrbl/dnsrbl.c
--- milter-greylist-4.5.11/dnsrbl.c     2013-01-20 01:01:15.000000000 +0900
+++ milter-greylist-4.5.11-6dnsrbl/dnsrbl.c     2014-11-20 14:15:05.000000000 +0900
@@ -139,8 +139,11 @@
                return 1;

        /* No IPv6 DNSRBL exists right now */
-       if (sa->sa_family != AF_INET)
-               return 0;
+       if (sa->sa_family == AF_INET) ;
+#ifdef AF_INET6
+       else if (sa->sa_family == AF_INET6) ;
+#endif
+       else    return 0;

        blacklisted = SA(&source->d_blacklisted);

@@ -174,10 +177,16 @@

        reverse_endian(SA(&ss), sa);

-       if ((iptostring(SA(&ss), salen, req, NS_MAXDNAME)) == NULL){
+        if ((SA(&ss)->sa_family==AF_INET)&&(iptostring(SA(&ss), salen, req, NS_MAXDNAME)) == NULL){
                mg_log(LOG_ERR, "iptostring failed: %s", strerror(errno));
                goto end;
        }
+#ifdef AF_INET6
+        else if ((SA(&ss)->sa_family==AF_INET6)&&(ip6tostringfordns(SA(&ss), salen, req, NS_MAXDNAME)) == NULL){
+                mg_log(LOG_ERR, "iptostring failed: %s", strerror(errno));
+                goto end;
+        }
+#endif

        (void)mystrlcat(req, ".", NS_MAXDNAME);
        (void)mystrlcat(req, dnsrbl, NS_MAXDNAME);
diff -u milter-greylist-4.5.11/pending.c milter-greylist-4.5.11-6dnsrbl/pending.c
--- milter-greylist-4.5.11/pending.c    2013-01-20 01:01:15.000000000 +0900
+++ milter-greylist-4.5.11-6dnsrbl/pending.c    2014-11-20 14:14:39.000000000 +0900
@@ -871,6 +871,62 @@
        return NULL;
 }

+char *
+ip6tostringfordns(sa, salen, buf, buflen)
+       struct sockaddr *sa;
+       socklen_t salen;
+       char *buf;
+       size_t buflen;
+{
+static char* p6[] = {
+"0.0","1.0","2.0","3.0","4.0","5.0","6.0","7.0","8.0","9.0","a.0","b.0","c.0","d.0","e.0","f.0",
+"0.1","1.1","2.1","3.1","4.1","5.1","6.1","7.1","8.1","9.1","a.1","b.1","c.1","d.1","e.1","f.1",
+"0.2","1.2","2.2","3.2","4.2","5.2","6.2","7.2","8.2","9.2","a.2","b.2","c.2","d.2","e.2","f.2",
+"0.3","1.3","2.3","3.3","4.3","5.3","6.3","7.3","8.3","9.3","a.3","b.3","c.3","d.3","e.3","f.3",
+"0.4","1.4","2.4","3.4","4.4","5.4","6.4","7.4","8.4","9.4","a.4","b.4","c.4","d.4","e.4","f.4",
+"0.5","1.5","2.5","3.5","4.5","5.5","6.5","7.5","8.5","9.5","a.5","b.5","c.5","d.5","e.5","f.5",
+"0.6","1.6","2.6","3.6","4.6","5.6","6.6","7.6","8.6","9.6","a.6","b.6","c.6","d.6","e.6","f.6",
+"0.7","1.7","2.7","3.7","4.7","5.7","6.7","7.7","8.7","9.7","a.7","b.7","c.7","d.7","e.7","f.7",
+"0.8","1.8","2.8","3.8","4.8","5.8","6.8","7.8","8.8","9.8","a.8","b.8","c.8","d.8","e.8","f.8",
+"0.9","1.9","2.9","3.9","4.9","5.9","6.9","7.9","8.9","9.9","a.9","b.9","c.9","d.9","e.9","f.9",
+"0.a","1.a","2.a","3.a","4.a","5.a","6.a","7.a","8.a","9.a","a.a","b.a","c.a","d.a","e.a","f.a",
+"0.b","1.b","2.b","3.b","4.b","5.b","6.b","7.b","8.b","9.b","a.b","b.b","c.b","d.b","e.b","f.b",
+"0.c","1.c","2.c","3.c","4.c","5.c","6.c","7.c","8.c","9.c","a.c","b.c","c.c","d.c","e.c","f.c",
+"0.d","1.d","2.d","3.d","4.d","5.d","6.d","7.d","8.d","9.d","a.d","b.d","c.d","d.d","e.d","f.d",
+"0.e","1.e","2.e","3.e","4.e","5.e","6.e","7.e","8.e","9.e","a.e","b.e","c.e","d.e","e.e","f.e",
+"0.f","1.f","2.f","3.f","4.f","5.f","6.f","7.f","8.f","9.f","a.f","b.f","c.f","d.f","e.f","f.f" };
+
+#if 0
+       if (getnameinfo(sa, salen, buf, buflen, NULL, 0, NI_NUMERICHOST) == 0)
+               return buf;
+#else
+       char *addr;
+       int len,i;
+
+       switch (sa->sa_family) {
+       case AF_INET:
+               addr = (void *)SADDR4(sa);
+               if(inet_ntop(sa->sa_family, addr, buf, buflen)==NULL) return NULL;
+               else return buf;
+#ifdef AF_INET6
+       case AF_INET6:
+               addr = (char *)SADDR6(sa);
+                len = sizeof(*SADDR6(sa));
+               strncpy(buf,"",buflen);
+               (void)mystrlcat(buf, p6[((unsigned int)(addr[0])&255)], buflen);
+               for (i = 1; i < len; i++) {
+                       (void)mystrlcat(buf, ".", buflen);
+                       (void)mystrlcat(buf, p6[((unsigned int)(addr[i])&255)], buflen);
+               }
+               return buf;
+#endif
+       default:
+               return NULL;
+       }
+#endif
+       return NULL;
+}
+
 int
 ipfromstring(str, sa, salen, family)
        char *str;
diff -u milter-greylist-4.5.11/pending.h milter-greylist-4.5.11-6dnsrbl/pending.h
--- milter-greylist-4.5.11/pending.h    2013-01-20 01:01:15.000000000 +0900
+++ milter-greylist-4.5.11-6dnsrbl/pending.h    2014-11-20 14:14:19.000000000 +0900
@@ -116,6 +116,7 @@
 int ip_match(struct sockaddr *, struct sockaddr *, ipaddr *);
 int ip_equal(struct sockaddr *, struct sockaddr *);
 char *iptostring(struct sockaddr *, socklen_t, char *, size_t);
+char *ip6tostringfordns(struct sockaddr *, socklen_t, char *, size_t);
 int ipfromstring(char *, struct sockaddr *, socklen_t *, sa_family_t);

 #endif /* _PENDING_H_ */
