Also parse the RP record (wire + zone)

This commit is contained in:
Miek Gieben 2012-05-01 22:57:22 +02:00
parent 63f90d6546
commit d3171d4f71
2 changed files with 50 additions and 0 deletions

View File

@ -35,6 +35,7 @@ const (
TypeMINFO uint16 = 14
TypeMX uint16 = 15
TypeTXT uint16 = 16
TypeRP uint16 = 17
TypeSIG uint16 = 24
TypeKEY uint16 = 25
TypeAAAA uint16 = 28
@ -345,6 +346,24 @@ func (rr *RR_PTR) Len() int {
return rr.Hdr.Len() + l
}
type RR_RP struct {
Hdr RR_Header
Mbox string `dns:"domain-name"`
Txt string `dns:"domain-name"`
}
func (rr *RR_RP) Header() *RR_Header {
return &rr.Hdr
}
func (rr *RR_RP) String() string {
return rr.Hdr.String() + rr.Mbox + " " + rr.Txt
}
func (rr *RR_RP) Len() int {
return rr.Hdr.Len() + len(rr.Mbox) + 1 + len(rr.Txt) + 1
}
type RR_SOA struct {
Hdr RR_Header
Ns string `dns:"cdomain-name"`
@ -1133,6 +1152,7 @@ var rr_mk = map[uint16]func() RR{
TypeMB: func() RR { return new(RR_MB) },
TypeMG: func() RR { return new(RR_MG) },
TypeMINFO: func() RR { return new(RR_MINFO) },
TypeRP: func() RR { return new(RR_RP) },
TypeMR: func() RR { return new(RR_MR) },
TypeMX: func() RR { return new(RR_MX) },
TypeNS: func() RR { return new(RR_NS) },

View File

@ -52,6 +52,9 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
case TypeTALINK:
r, e = setTALINK(h, c, o, f)
goto Slurp
case TypeRP:
r, e = setRP(h, c, o, f)
goto Slurp
// These types have a variable ending: either chunks of txt or chunks/base64 or hex.
// They need to search for the end of the RR themselves, hence they look for the ending
// newline. Thus there is no need to slurp the remainder, because there is none.
@ -155,6 +158,33 @@ func setPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
return rr, nil
}
func setRP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_RP)
rr.Hdr = h
l := <-c
rr.Mbox = l.token
_, ld, ok := IsDomainName(l.token)
if !ok {
return nil, &ParseError{f, "bad RP Mbox", l}
}
if rr.Mbox[ld-1] != '.' {
rr.Mbox = appendOrigin(rr.Mbox, o)
}
<-c // _BLANK
l = <-c
rr.Txt = l.token
_, ld, ok = IsDomainName(l.token)
if !ok {
return nil, &ParseError{f, "bad RP Txt", l}
}
if rr.Txt[ld-1] != '.' {
rr.Txt = appendOrigin(rr.Txt, o)
}
return rr, nil
}
func setMX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MX)
rr.Hdr = h