-
Notifications
You must be signed in to change notification settings - Fork 31
/
common.lisp
50 lines (34 loc) · 1.13 KB
/
common.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*-
;;;
;;; --- DNS client constants.
;;;
(in-package :iolib.sockets)
(defconstant +dns-max-datagram-size+ 4096)
(defconstant +opcode-standard+ 0)
;;; Query types
(defconstant (+query-type-map+ :test 'equal)
'((:a . 1) (:ns . 2) (:cname . 5) (:soa . 6)
(:wks . 11) (:ptr . 12) (:hinfo . 13) (:mx . 15)
(:txt . 16) (:aaaa . 28) (:srv . 33) (:any . 255)))
(defun query-type-number (id)
(cdr (assoc id +query-type-map+)))
(defun query-type-id (number)
(car (rassoc number +query-type-map+)))
(defun dns-record-type-p (id)
(query-type-number id))
;;; Query classes
(defconstant (+query-class-map+ :test 'equal)
'((:in . 1) (:any . 255)))
(defun query-class-number (id)
(cdr (assoc id +query-class-map+)))
(defun query-class-id (number)
(car (rassoc number +query-class-map+)))
;;; Error codes
(defconstant (+rcode-map+ :test 'equal)
'((:no-error . 0) (:format-error . 1)
(:server-failure . 2) (:name-error . 3)
(:not-implemented . 4) (:refused . 5)))
(defun rcode-number (id)
(cdr (assoc id +rcode-map+)))
(defun rcode-id (number)
(car (rassoc number +rcode-map+)))