kill a packStruct
This commit is contained in:
parent
472935c3d2
commit
982f277a44
1
Makefile
1
Makefile
|
@ -19,6 +19,7 @@ GOFILES=\
|
||||||
nsec3.go \
|
nsec3.go \
|
||||||
qnamestring.go\
|
qnamestring.go\
|
||||||
server.go \
|
server.go \
|
||||||
|
rawmsg.go \
|
||||||
tsig.go\
|
tsig.go\
|
||||||
types.go\
|
types.go\
|
||||||
xfr.go\
|
xfr.go\
|
||||||
|
|
8
msg.go
8
msg.go
|
@ -829,11 +829,9 @@ func packRR(rr RR, msg []byte, off int) (off2 int, ok bool) {
|
||||||
if !ok {
|
if !ok {
|
||||||
return len(msg), false
|
return len(msg), false
|
||||||
}
|
}
|
||||||
|
if !RawSetRdlength(msg, uint16(off2-off1)) {
|
||||||
// TODO make this quicker
|
return len(msg), false
|
||||||
// pack a third time; redo header with correct data length
|
}
|
||||||
rr.Header().Rdlength = uint16(off2 - off1)
|
|
||||||
packStruct(rr.Header(), msg, off)
|
|
||||||
return off2, true
|
return off2, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package dns
|
||||||
|
|
||||||
|
/* Function defined in this subpackage work on []byte and but still
|
||||||
|
* provide some higher level functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// SetRdlength sets the length of the length of the rdata
|
||||||
|
// directly at the correct position in the buffer buf.
|
||||||
|
// If buf does not look like a DNS message false is returned,
|
||||||
|
// otherwise true.
|
||||||
|
func RawSetRdlength(buf []byte, i uint16) bool {
|
||||||
|
var off int
|
||||||
|
var ok bool
|
||||||
|
if _, off, ok = unpackDomainName(buf, 0); !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// off + type(2) + class(2) + ttl(4) -> rdlength
|
||||||
|
buf[off+2+2+4], buf[off+2+2+4+1] = packUint16(i)
|
||||||
|
return true
|
||||||
|
}
|
Loading…
Reference in New Issue