[msg] Add UnpackRRWithHeader (#643)

This function allow to extra the raw content of a record type based on
an existing header.
Fixes #633
This commit is contained in:
chantra 2018-03-15 02:09:45 -07:00 committed by Miek Gieben
parent 906238edc6
commit 5b169d1842
1 changed files with 7 additions and 0 deletions

7
msg.go
View File

@ -595,6 +595,13 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) {
if err != nil {
return nil, len(msg), err
}
return UnpackRRWithHeader(h, msg, off)
}
// UnpackRRWithHeader unpacks the record type specific payload given an existing
// RR_Header.
func UnpackRRWithHeader(h RR_Header, msg []byte, off int) (rr RR, off1 int, err error) {
end := off + int(h.Rdlength)
if fn, known := typeToUnpack[h.Rrtype]; !known {