1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
3 ;;; common.lisp --- DNS client constants.
5 ;;; Copyright (C) 2006-2008, Stelian Ionescu <sionescu@common-lisp.net>
7 ;;; This code is free software; you can redistribute it and/or
8 ;;; modify it under the terms of the version 2.1 of
9 ;;; the GNU Lesser General Public License as published by
10 ;;; the Free Software Foundation, as clarified by the
11 ;;; preamble found here:
12 ;;; http://opensource.franz.com/preamble.html
14 ;;; This program is distributed in the hope that it will be useful,
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU Lesser General
20 ;;; Public License along with this library; if not, write to the
21 ;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 ;;; Boston, MA 02110-1301, USA
24 (in-package :net.sockets
)
26 (defconstant +dns-max-datagram-size
+ 4096)
28 (defconstant +opcode-standard
+ 0)
32 (define-constant +query-type-to-value-map
+
33 #h
:eq
{:a
=> 1 , :ns
=> 2 , :cname
=> 5 , :soa
=> 6 ,
34 :wks
=> 11 , :ptr
=> 12 , :hinfo
=> 13 , :mx
=> 15 ,
35 :txt
=> 16 , :aaaa
=> 28 , :any
=> 255}
38 (define-constant +query-value-to-type-map
+
39 #h
{1 => :a
, 2 => :ns
, 5 => :cname
, 6 => :soa
,
40 11 => :wks
, 12 => :ptr
, 13 => :hinfo
, 15 => :mx
,
41 16 => :txt
, 28 => :aaaa
, 255 => :any
}
44 (defun query-type-number (id)
45 (gethash id
+query-type-to-value-map
+))
47 (defun query-type-id (number)
48 (gethash number
+query-value-to-type-map
+))
50 (defun dns-record-type-p (id)
51 (query-type-number id
))
55 (define-constant +query-class-to-value-map
+
56 #h
:eq
{:in
=> 1 , :any
=> 255}
59 (define-constant +query-value-to-class-map
+
60 #h
{1 => :in
, 255 => :any
}
63 (defun query-class-number (id)
64 (gethash id
+query-class-to-value-map
+))
66 (defun query-class-id (number)
67 (gethash number
+query-value-to-class-map
+))
71 (define-constant +rcode-to-value-map
+
72 #h
:eq
{:no-error
=> 0 , :format-error
=> 1 ,
73 :server-failure
=> 2 , :name-error
=> 3 ,
74 :not-implemented
=> 4 , :refused
=> 5}
77 (define-constant +value-to-rcode-map
+
78 #h
{0 => :no-error
, 1 => :format-error
,
79 2 => :server-failure
, 3 => :name-error
,
80 4 => :not-implemented
, 5 => :refused
}
83 (defun rcode-number (id)
84 (gethash id
+rcode-to-value-map
+))
86 (defun rcode-id (number)
87 (gethash number
+value-to-rcode-map
+))