kill a packStruct
This commit is contained in:
parent
472935c3d2
commit
982f277a44
1
Makefile
1
Makefile
|
@ -19,6 +19,7 @@ GOFILES=\
|
|||
nsec3.go \
|
||||
qnamestring.go\
|
||||
server.go \
|
||||
rawmsg.go \
|
||||
tsig.go\
|
||||
types.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 {
|
||||
return len(msg), false
|
||||
}
|
||||
|
||||
// TODO make this quicker
|
||||
// pack a third time; redo header with correct data length
|
||||
rr.Header().Rdlength = uint16(off2 - off1)
|
||||
packStruct(rr.Header(), msg, off)
|
||||
if !RawSetRdlength(msg, uint16(off2-off1)) {
|
||||
return len(msg), false
|
||||
}
|
||||
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