Start packing nsec/nsec3 typeBitMap

This commit is contained in:
Miek Gieben 2011-01-09 22:51:36 +01:00
parent d3f9bbe2c9
commit 69f9bc6ecd
2 changed files with 15 additions and 13 deletions

27
msg.go
View File

@ -286,8 +286,10 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
msg[off] = byte(fv.Elem(j).(*reflect.UintValue).Get()) msg[off] = byte(fv.Elem(j).(*reflect.UintValue).Get())
off++ off++
} }
case "NSEC3": case "NSEC": // NSEC/NSEC3
case "NSEC": for j := 0; j < val.Field(i).(*reflect.SliceValue).Len(); j++ {
var _ = byte(fv.Elem(j).(*reflect.UintValue).Get())
}
// handle type bit maps // handle type bit maps
} }
case *reflect.StructValue: case *reflect.StructValue:
@ -442,41 +444,40 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
if off+blocks > len(msg) { if off+blocks > len(msg) {
return len(msg), false return len(msg), false
} }
// could be 16 bits encoded..
off += 2 off += 2
for i := 0; i < blocks; i++ { for j := 0; j < blocks; j++ {
b := msg[off+i] b := msg[off+j]
// Check the bits one by one, and set the type // Check the bits one by one, and set the type
if b&0x80 == 0x80 { if b&0x80 == 0x80 {
nsec[ni] = uint16(window*256 + i*8 + 0) nsec[ni] = uint16(window*256 + j*8 + 0)
ni++ ni++
} }
if b&0x40 == 0x40 { if b&0x40 == 0x40 {
nsec[ni] = uint16(window*256 + i*8 + 1) nsec[ni] = uint16(window*256 + j*8 + 1)
ni++ ni++
} }
if b&0x20 == 0x20 { if b&0x20 == 0x20 {
nsec[ni] = uint16(window*256 + i*8 + 2) nsec[ni] = uint16(window*256 + j*8 + 2)
ni++ ni++
} }
if b&0x10 == 0x10 { if b&0x10 == 0x10 {
nsec[ni] = uint16(window*256 + i*8 + 3) nsec[ni] = uint16(window*256 + j*8 + 3)
ni++ ni++
} }
if b&0x8 == 0x8 { if b&0x8 == 0x8 {
nsec[ni] = uint16(window*256 + i*8 + 4) nsec[ni] = uint16(window*256 + j*8 + 4)
ni++ ni++
} }
if b&0x4 == 0x4 { if b&0x4 == 0x4 {
nsec[ni] = uint16(window*256 + i*8 + 5) nsec[ni] = uint16(window*256 + j*8 + 5)
ni++ ni++
} }
if b&0x2 == 0x2 { if b&0x2 == 0x2 {
nsec[ni] = uint16(window*256 + i*8 + 6) nsec[ni] = uint16(window*256 + j*8 + 6)
ni++ ni++
} }
if b&0x1 == 0x1 { if b&0x1 == 0x1 {
nsec[ni] = uint16(window*256 + i*8 + 7) nsec[ni] = uint16(window*256 + j*8 + 7)
ni++ ni++
} }
} }

View File

@ -422,6 +422,7 @@ func (rr *RR_NSEC) Header() *RR_Header {
func (rr *RR_NSEC) String() string { func (rr *RR_NSEC) String() string {
s := rr.Hdr.String() + " " + rr.NextDomain s := rr.Hdr.String() + " " + rr.NextDomain
for i:=0; i < len(rr.TypeBitMap); i++ { for i:=0; i < len(rr.TypeBitMap); i++ {
// Check if map exists, otherwise "TYPE" + strcov.Itoa(int(rr.TypeBitMap[i]))
s = s + " " + Rr_str[rr.TypeBitMap[i]] s = s + " " + Rr_str[rr.TypeBitMap[i]]
} }
return s return s