HIP unpack support -- not tested

This commit is contained in:
Miek Gieben 2012-02-19 15:33:12 +01:00
parent f45d4d933d
commit c82a1af1e3
2 changed files with 43 additions and 31 deletions

20
msg.go
View File

@ -642,18 +642,30 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
default:
println("dns: unknown tag unpacking slice", val.Type().Field(i).Tag)
return lenmsg, false
// Need to add domain-name for HIP
case "domain-name":
// HIP record slice of name (or none)
servers := make([]string, 0)
var s string
for off < lenmsg {
s, off, ok = UnpackDomainName(msg, off)
if !ok {
println("dns: failure unpacking domain-name")
return lenmsg, false
}
servers = append(servers, s)
}
fv.Set(reflect.ValueOf(servers))
case "txt":
txt := make([]string,0)
txt := make([]string, 0)
rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint())
Txts:
l := int(msg[off])
if off + l + 1 > lenmsg {
if off+l+1 > lenmsg {
println("dns: failure unpacking txt strings")
return lenmsg, false
}
txt = append(txt, string(msg[off+1:off+l+1]))
off += l+1
off += l + 1
if off < rdlength {
// More
goto Txts

View File

@ -859,7 +859,7 @@ func (rr *RR_NSEC3) String() string {
func (rr *RR_NSEC3) Len() int {
return rr.Hdr.Len() + 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1 + len(rr.TypeBitMap)
// TODO: typebitmap
// TODO: typebitmap length
}
type RR_NSEC3PARAM struct {