Select Git revision
enum.scm 4.25 KiB
(define-module (dns enum)
:export (rr-types
int->rr rr->int
class-types
int->class class->int
rcode-types
int->rcode rcode->int
opcode-types
int->opcode opcode->int))
(define (flip-cons c)
(cons (cdr c) (car c)))
(define (make-mappings name table)
(values
(lambda (i)
(cond ((assv i (map flip-cons table)) => cdr)
((integer? i) (inexact->exact i))
(else (scm-error 'wrong-type-arg (format #f "int->~a" name)
"Unknown value ~s, expected known integer or one of ~a"
(list i (map car table)) (list (map car table))))))
(lambda (value)
(cond ((integer? value) (inexact->exact value))
((assv value table) => cdr)
(else (scm-error 'wrong-type-arg (format #f "~a->int" name)
"Unknown value ~s"
(list value) #f))) )))
;; All number are documented at
;; https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
(define rr-types
'(; 0 reserved
(A . 1)
(NS . 2)
(MD . 3)
(MF . 4)
(CNAME . 5)
(SOA . 6)
(MB . 7)
(MG . 8)
(MR . 9)
(NULL . 10)
(WKS . 11)
(PTR . 12)
(HINFO . 13)
(MINFO . 14)
(MX . 15)
(TXT . 16)
(RP . 17)
(AFSDB . 18)
(X25 . 19)
(ISDN . 20)
(RT . 21)
(NSAP . 22)
(NSAP-PTR . 23)
(SIG . 24)
(KEY . 25)
(PX . 26)
(GPOS . 27)
(AAAA . 28)
(LOC . 29)
(NXT . 30)
(EID . 30)
(NIMLOC . 32)
(SRV . 33)
(ATMA . 34)
(NAPTR . 35)
(KX . 36)