[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:
parent
906238edc6
commit
5b169d1842
7
msg.go
7
msg.go
|
@ -595,6 +595,13 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, len(msg), err
|
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)
|
end := off + int(h.Rdlength)
|
||||||
|
|
||||||
if fn, known := typeToUnpack[h.Rrtype]; !known {
|
if fn, known := typeToUnpack[h.Rrtype]; !known {
|
||||||
|
|
Loading…
Reference in New Issue