Grovel sockaddr_nl
[iolib.git] / src / sockets / dns / common.lisp
blob298f9fba7a46e9f9fb0236d55fa95d272b9fc526
1 ;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- DNS client constants.
4 ;;;
6 (in-package :iolib.sockets)
8 (defconstant +dns-max-datagram-size+ 4096)
10 (defconstant +opcode-standard+ 0)
12 ;;; Query types
14 (defconstant (+query-type-map+ :test 'equal)
15 '((:a . 1) (:ns . 2) (:cname . 5) (:soa . 6)
16 (:wks . 11) (:ptr . 12) (:hinfo . 13) (:mx . 15)
17 (:txt . 16) (:aaaa . 28) (:srv . 33) (:any . 255)))
19 (defun query-type-number (id)
20 (cdr (assoc id +query-type-map+)))
22 (defun query-type-id (number)
23 (car (rassoc number +query-type-map+)))
25 (defun dns-record-type-p (id)
26 (query-type-number id))
28 ;;; Query classes
30 (defconstant (+query-class-map+ :test 'equal)
31 '((:in . 1) (:any . 255)))
33 (defun query-class-number (id)
34 (cdr (assoc id +query-class-map+)))
36 (defun query-class-id (number)
37 (car (rassoc number +query-class-map+)))
39 ;;; Error codes
41 (defconstant (+rcode-map+ :test 'equal)
42 '((:no-error . 0) (:format-error . 1)
43 (:server-failure . 2) (:name-error . 3)
44 (:not-implemented . 4) (:refused . 5)))
46 (defun rcode-number (id)
47 (cdr (assoc id +rcode-map+)))
49 (defun rcode-id (number)
50 (car (rassoc number +rcode-map+)))