From: Fredrik Tolf Date: Sun, 16 May 2010 00:38:33 +0000 (+0200) Subject: COMMON-NET: Added basic DNS communication. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=0818ef9996e98050d814f370f4cd3ea22e4bdf9a;p=lisp-utils.git COMMON-NET: Added basic DNS communication. There does seem to be a strict need for some kind of timeout/selection mechanism for socket operations, but it is unclear just how it should work yet. --- diff --git a/dns.lisp b/dns.lisp index 48def25..cfb1750 100644 --- a/dns.lisp +++ b/dns.lisp @@ -403,6 +403,33 @@ (concatenate 'string buf "." label) label))))) +;;; Basic communication + +(defun dns-do-request (server packet) + (declare (type address server) + (type dns-packet packet)) + (with-connection (sk server) + (socket-send sk (dns-encode packet)) + (loop + (let ((resp (dns-decode (socket-recv sk)))) + (when (= (dns-packet-txid resp) + (dns-packet-txid packet)) + (return resp)))))) + +(defun dns-std-request (queries &key (txid (random 65536)) (recurse t)) + (let ((qlist (map 'list #'(lambda (o) + (let ((name (first o)) + (type (second o))) + (make-instance 'resource-query + :name (etypecase name + (string (parse-domain-name name)) + (list name)) + :type type))) + queries))) + (make-dns-packet :txid txid + :recurse recurse + :queries qlist))) + ;;; Misc. (defmethod print-object ((q resource-query) stream)