Fix Tsig parsing

This commit is contained in:
Miek Gieben 2011-01-25 15:09:30 +01:00
parent 7e51041a24
commit 1ece21a05e
2 changed files with 66 additions and 46 deletions

19
msg.go
View File

@ -598,6 +598,25 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
fmt.Fprintf(os.Stderr, "dns: failure unpacking domain-name")
return len(msg), false
}
case "fixed-size":
// We should already know how many bytes we can expect
// TODO(mg) pack variant
println(val.Type().Name())
println(f.Name) // MAC Otherdata, then get back the
//f := val.Type().(*reflect.StructType).Field(i)
//FieldByName(MACSize), Othersize to get the stuff we need
var size int
// consumed += len(val.FieldByName("SignerName").(*reflect.StringValue).Get()) + 1
switch val.Type().Name() {
case "RR_TSIG":
// tsig has MACSize
size = 16 // TODO(mg) other hashes
}
if off+size > len(msg) {
fmt.Fprintf(os.Stderr, "dns: failure unpacking fixed-size string")
return len(msg), false
}
s = string(msg[off : off+size])
case "":
if off >= len(msg) || off+1+int(msg[off]) > len(msg) {
fmt.Fprintf(os.Stderr, "dns: failure unpacking string")

View File

@ -22,11 +22,11 @@ type RR_TSIG struct {
TimeSigned uint64
Fudge uint16
MACSize uint16
MAC string
MAC string "fixed-size"
OrigId uint16
Error uint16
OtherLen uint16
OtherData string
OtherData string "fixed-size"
}
func (rr *RR_TSIG) Header() *RR_Header {
@ -35,6 +35,7 @@ func (rr *RR_TSIG) Header() *RR_Header {
func (rr *RR_TSIG) String() string {
// It has no official presentation format
println("mac len: ", rr.MACSize)
return rr.Hdr.String() +
" " + rr.Algorithm +
" " + tsigTimeToDate(rr.TimeSigned) +