Switched licence to LLGPL.
[iolib.git] / protocols / dns-client / dns-constants.lisp
blob06bc4c8bea5cbaf36bc1c5466ecdd88f4b5fe3d0
1 ;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
3 ;; Copyright (C) 2006, 2007 Stelian Ionescu
4 ;;
5 ;; This code is free software; you can redistribute it and/or
6 ;; modify it under the terms of the version 2.1 of
7 ;; the GNU Lesser General Public License as published by
8 ;; the Free Software Foundation, as clarified by the
9 ;; preamble found here:
10 ;; http://opensource.franz.com/preamble.html
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU Lesser General
18 ;; Public License along with this library; if not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA
22 (in-package :net.sockets)
24 (define-constant +opcode-standard+ 0)
26 (define-constant +query-type-map
27 '((:a . 1)
28 (:ns . 2)
29 (:cname . 5)
30 (:soa . 6)
31 (:wks . 11)
32 (:ptr . 12)
33 (:hinfo . 13)
34 (:mx . 15)
35 (:txt . 16)
36 (:aaaa . 28)
37 (:any . 255)))
39 (defun query-type-number (id)
40 (cdr (assoc id +query-type-map)))
42 (defun query-type-id (number)
43 (car (rassoc number +query-type-map)))
45 (defun valid-type-p (id)
46 (query-type-number id))
48 (define-constant +query-class-map
49 '((:in . 1)
50 (:any . 255)))
52 (defun query-class-number (id)
53 (cdr (assoc id +query-class-map)))
55 (defun query-class-id (number)
56 (car (rassoc number +query-class-map)))
58 (define-constant +rcode-map
59 '((:no-error . 0)
60 (:format-error . 1)
61 (:server-failure . 2)
62 (:name-error . 3)
63 (:not-implemented . 4)
64 (:refused . 5)))
66 (defun rcode-number (id)
67 (cdr (assoc id +rcode-map)))
69 (defun rcode-id (number)
70 (car (rassoc number +rcode-map)))
72 (define-constant +dns-datagram-size+ 512)