func (m *Header) Decode(b []byte, pos *int, sniffer dns.WireDecodeSniffer) (err error) {
	var p0 *byte
	if p0, err = bufp0(b, pos); err != nil {
		return
	}
	if err = (*dns.Octets2)(&m.ID).Decode(b, pos, sniffer); err != nil {
		return
	}

	var w dns.Octets2
	if err = w.Decode(b, pos, sniffer); err != nil {
		return
	}

	m.RCODE = RCODE(w & 0xF)
	w >>= 4
	m.CD = w&1 != 0
	w >>= 1
	m.AD = w&1 != 0
	w >>= 1
	m.Z = w&1 != 0
	w >>= 1
	m.RA = w&1 != 0
	w >>= 1
	m.RD = w&1 != 0
	w >>= 1
	m.TC = w&1 != 0
	w >>= 1
	m.AA = w&1 != 0
	w >>= 1
	m.Opcode = Opcode(w & 0xF)
	w >>= 4
	m.QR = w&1 != 0

	if w.Decode(b, pos, sniffer); err != nil {
		return
	}

	m.QDCOUNT = uint16(w)

	if w.Decode(b, pos, sniffer); err != nil {
		return
	}

	m.ANCOUNT = uint16(w)

	if w.Decode(b, pos, sniffer); err != nil {
		return
	}

	m.NSCOUNT = uint16(w)

	if w.Decode(b, pos, sniffer); err != nil {
		return
	}

	m.ARCOUNT = uint16(w)

	if m.Z {
		err = fmt.Errorf("invalid DNS message header Z:%t", m.Z)
	}
	if sniffer != nil {
		sniffer(p0, &b[*pos-1], dns.SniffHeader, m)
	}
	return
}
// Implementation of dns.Wirer
Implementation of dns.Wirer
// Implementation of dns . Wirer
func (m *Header) Decode(b []byte, pos *int, sniffer dns.WireDecodeSniffer) (err error) {
	var p0 *byte
	if p0, err = bufp0(b, pos); err != nil {
		return
	}
	if err = (*dns.Octets2)(&m.ID).Decode(b, pos, sniffer); err != nil {
		return
	}
	var w dns.Octets2
	if err = w.Decode(b, pos, sniffer); err != nil {
		return
	}
	m.RCODE = RCODE(w & 0xF)
	w >>= 4
	m.CD = w&1 != 0
	w >>= 1
	m.AD = w&1 != 0
	w >>= 1
	m.Z = w&1 != 0
	w >>= 1
	m.RA = w&1 != 0
	w >>= 1
	m.RD = w&1 != 0
	w >>= 1
	m.TC = w&1 != 0
	w >>= 1
	m.AA = w&1 != 0
	w >>= 1
	m.Opcode = Opcode(w & 0xF)
	w >>= 4
	m.QR = w&1 != 0
	if w.Decode(b, pos, sniffer); err != nil {
		return
	}
	m.QDCOUNT = uint16(w)
	if w.Decode(b, pos, sniffer); err != nil {
		return
	}
	m.ANCOUNT = uint16(w)
	if w.Decode(b, pos, sniffer); err != nil {
		return
	}
	m.NSCOUNT = uint16(w)
	if w.Decode(b, pos, sniffer); err != nil {
		return
	}
	m.ARCOUNT = uint16(w)
	if m.Z {
		err = fmt.Errorf("invalid DNS message header Z:%t", m.Z)
	}
	if sniffer != nil {
		sniffer(p0, &b[*pos-1], dns.SniffHeader, m)
	}
	return
}
func ( m * Header ) Decode ( b [ ] byte , pos * int , sniffer dns . WireDecodeSniffer ) ( err error ) { var p0 * byte if p0 , err = bufp0 ( b , pos ) ; err != nil { return } if err = ( * dns . Octets2 ) ( & m . ID ) . Decode ( b , pos , sniffer ) ; err != nil { return } var w dns . Octets2 if err = w . Decode ( b , pos , sniffer ) ; err != nil { return } m . RCODE = RCODE ( w & 0xF ) w >>= 4 m . CD = w & 1 != 0 w >>= 1 m . AD = w & 1 != 0 w >>= 1 m . Z = w & 1 != 0 w >>= 1 m . RA = w & 1 != 0 w >>= 1 m . RD = w & 1 != 0 w >>= 1 m . TC = w & 1 != 0 w >>= 1 m . AA = w & 1 != 0 w >>= 1 m . Opcode = Opcode ( w & 0xF ) w >>= 4 m . QR = w & 1 != 0 if w . Decode ( b , pos , sniffer ) ; err != nil { return } m . QDCOUNT = uint16 ( w ) if w . Decode ( b , pos , sniffer ) ; err != nil { return } m . ANCOUNT = uint16 ( w ) if w . Decode ( b , pos , sniffer ) ; err != nil { return } m . NSCOUNT = uint16 ( w ) if w . Decode ( b , pos , sniffer ) ; err != nil { return } m . ARCOUNT = uint16 ( w ) if m . Z { err = fmt . Errorf ( " " , m . Z ) } if sniffer != nil { sniffer ( p0 , & b [ * pos - 1 ] , dns . SniffHeader , m ) } return }
Implementation of dns.Wirer
Implementation of dns . Wirer