diff --git a/scheme/lib/dns.scm b/scheme/lib/dns.scm index 1218658..eeab0c4 100644 --- a/scheme/lib/dns.scm +++ b/scheme/lib/dns.scm @@ -565,15 +565,26 @@ (values (make-question name type class) start)))))) ;; parses a resourcerecord in a message. returns the rr and the rest of the message. + +(define (type-number->type type-number) + (if (>= type-number (vector-length the-message-types)) + 'unsupported-message-type + (vector-ref the-message-types type-number))) + +(define (class-number->class class-number) + (if (>= class-number (vector-length the-message-classes)) + 'unsupported-message-class + (vector-ref the-message-classes class-number))) + (define (parse-rr start message) (call-with-values (lambda () (parse-name start message)) (lambda (name start) - (let ((type (vector-ref the-message-types - (octet-pair->number (car start) (cadr start)))) + (let ((type (type-number->type + (octet-pair->number (car start) (cadr start)))) (start (cddr start))) - (let ((class (vector-ref the-message-classes - (octet-pair->number (car start) (cadr start)))) + (let ((class (class-number->class + (octet-pair->number (car start) (cadr start)))) (start (cddr start))) (let ((ttl (octet-quad->number (car start) (cadr start) (caddr start) (cadddr start)))