2004-01-06 Steve Youngs <sryoungs@bigpond.net.au>
[gnus] / lisp / dns.el
index 5d572fa..e5acf4e 100644 (file)
@@ -50,11 +50,12 @@ If nil, /etc/resolv.conf will be consulted.")
     (MR 9)
     (NULL 10)
     (WKS 11)
-    (PRT 12)
+    (PTR 12)
     (HINFO 13)
     (MINFO 14)
     (MX 15)
     (TXT 16)
+    (AAAA 28) ; RFC3596
     (AXFR 252)
     (MAILB 253)
     (MAILA 254)
@@ -251,6 +252,12 @@ If TCP-P, the first two bytes of the package with be the length field."
        (push (list slot qs) spec)))
     (nreverse spec))))
 
+(defun dns-read-int32 ()
+  ;; Full 32 bit Integers can't be handled by Emacs.  If we use
+  ;; floats, it works.
+  (format "%.0f" (+ (* (dns-read-bytes 1) 16777216.0)
+                   (dns-read-bytes 3))))
+
 (defun dns-read-type (string type)
   (let ((buffer (current-buffer))
        (point (point)))
@@ -264,9 +271,22 @@ If TCP-P, the first two bytes of the package with be the length field."
              (dotimes (i 4)
                (push (dns-read-bytes 1) bytes))
              (mapconcat 'number-to-string (nreverse bytes) ".")))
-          ((eq type 'NS)
-           (dns-read-string-name string buffer))
-          ((eq type 'CNAME)
+          ((eq type 'AAAA)
+           (let (hextets)
+             (dotimes (i 8)
+               (push (dns-read-bytes 2) hextets))
+             (mapconcat (lambda (n) (format "%x" n)) (nreverse hextets) ":")))
+          ((eq type 'SOA)
+           (list (list 'mname (dns-read-name buffer))
+                 (list 'rname (dns-read-name buffer))
+                 (list 'serial (dns-read-int32))
+                 (list 'refresh (dns-read-int32))
+                 (list 'retry (dns-read-int32))
+                 (list 'expire (dns-read-int32))
+                 (list 'minimum (dns-read-int32))))
+          ((eq type 'MX)
+           (cons (dns-read-bytes 2) (dns-read-name buffer)))
+          ((or (eq type 'CNAME) (eq type 'NS) (eq type 'PTR))
            (dns-read-string-name string buffer))
           (t string)))
       (goto-char point))))
@@ -289,8 +309,8 @@ If TCP-P, the first two bytes of the package with be the length field."
   (if (featurep 'xemacs)
       `(let ((coding-system-for-read 'binary)
             (coding-system-for-write 'binary))
-        (gnus-xmas-open-network-stream "dns" (current-buffer)
-                                       ,server "domain" 'udp))
+        (open-network-stream "dns" (current-buffer)
+                             ,server "domain" 'udp))
     `(let ((server ,server)
           (coding-system-for-read 'binary)
           (coding-system-for-write 'binary))