Pack a uint48 as a [3]uint16
This commit is contained in:
parent
1b39853f03
commit
11a1c753a8
14
msg.go
14
msg.go
|
@ -250,11 +250,20 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
|
|||
fmt.Fprintf(os.Stderr, "dns: unknown IP tag %v", f.Tag)
|
||||
return len(msg), false
|
||||
case "TSIG":
|
||||
// has a 3 byte inception time (check len?)
|
||||
// need to do some shifting here
|
||||
msg[off] = byte(fv.Elem(0).(*reflect.UintValue).Get() >> 8)
|
||||
msg[off+1] = byte(fv.Elem(0).(*reflect.UintValue).Get())
|
||||
msg[off+2] = byte(fv.Elem(1).(*reflect.UintValue).Get() >> 8)
|
||||
msg[off+3] = byte(fv.Elem(1).(*reflect.UintValue).Get())
|
||||
msg[off+4] = byte(fv.Elem(2).(*reflect.UintValue).Get() >> 8)
|
||||
msg[off+5] = byte(fv.Elem(2).(*reflect.UintValue).Get())
|
||||
off += 6
|
||||
}
|
||||
case *reflect.SliceValue:
|
||||
switch f.Tag {
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, ": dns: unknown IP tag %v\n", f.Tag)
|
||||
fmt.Fprintf(os.Stderr, "dns: unknown IP tag %v\n", f.Tag)
|
||||
return len(msg), false
|
||||
case "OPT": // edns
|
||||
for j := 0; j < val.Field(i).(*reflect.SliceValue).Len(); j++ {
|
||||
|
@ -274,7 +283,7 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
|
|||
msg[off+3] = byte(len(data))
|
||||
off += 4
|
||||
copy(msg[off:off+len(data)], []byte(data))
|
||||
off += len(data) // +1?? MG TODO
|
||||
off += len(data)
|
||||
}
|
||||
case "A":
|
||||
if fv.Len() > net.IPv4len || off+fv.Len() > len(msg) {
|
||||
|
@ -395,6 +404,7 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
|
|||
fmt.Fprintf(os.Stderr, "dns: unknown IP tag %v", f.Tag)
|
||||
return len(msg), false
|
||||
case "TSIG":
|
||||
println("TODO")
|
||||
}
|
||||
case *reflect.SliceValue:
|
||||
switch f.Tag {
|
||||
|
|
Loading…
Reference in New Issue