func (rd *DS) Decode(b []byte, pos *int, sniffer dns.WireDecodeSniffer) (err error) {
	p0 := &b[*pos]
	if err = (*dns.Octets2)(&rd.KeyTag).Decode(b, pos, sniffer); err != nil {
		return
	}
	if err = (*dns.Octet)(&rd.Algorithm).Decode(b, pos, sniffer); err != nil {
		return
	}
	if err = (*dns.Octet)(&rd.DigestType).Decode(b, pos, sniffer); err != nil {
		return
	}
	var n int
	switch rd.DigestType {
	case HashAlgorithmSHA1:
		n = 20
	default:
		return fmt.Errorf("unsupported digest type %d", rd.DigestType)
	}

	end := *pos + n
	if end > len(b) {
		return fmt.Errorf("(*rr.DS).Decode() - buffer underflow")
	}
	rd.Digest = append([]byte{}, b[*pos:end]...)
	*pos = end
	if sniffer != nil {
		sniffer(p0, &b[*pos-1], dns.SniffRDataDS, rd)
	}
	return
}
// Implementation of dns.Wirer
Implementation of dns.Wirer
// Implementation of dns . Wirer
func (rd *DS) Decode(b []byte, pos *int, sniffer dns.WireDecodeSniffer) (err error) {
	p0 := &b[*pos]
	if err = (*dns.Octets2)(&rd.KeyTag).Decode(b, pos, sniffer); err != nil {
		return
	}
	if err = (*dns.Octet)(&rd.Algorithm).Decode(b, pos, sniffer); err != nil {
		return
	}
	if err = (*dns.Octet)(&rd.DigestType).Decode(b, pos, sniffer); err != nil {
		return
	}
	var n int
	switch rd.DigestType {
	case HashAlgorithmSHA1:
		n = 20
	default:
		return fmt.Errorf("unsupported digest type %d", rd.DigestType)
	}
	end := *pos + n
	if end > len(b) {
		return fmt.Errorf("(*rr.DS).Decode() - buffer underflow")
	}
	rd.Digest = append([]byte{}, b[*pos:end]...)
	*pos = end
	if sniffer != nil {
		sniffer(p0, &b[*pos-1], dns.SniffRDataDS, rd)
	}
	return
}
func ( rd * DS ) Decode ( b [ ] byte , pos * int , sniffer dns . WireDecodeSniffer ) ( err error ) { p0 := & b [ * pos ] if err = ( * dns . Octets2 ) ( & rd . KeyTag ) . Decode ( b , pos , sniffer ) ; err != nil { return } if err = ( * dns . Octet ) ( & rd . Algorithm ) . Decode ( b , pos , sniffer ) ; err != nil { return } if err = ( * dns . Octet ) ( & rd . DigestType ) . Decode ( b , pos , sniffer ) ; err != nil { return } var n int switch rd . DigestType { case HashAlgorithmSHA1 : n = 20 default : return fmt . Errorf ( " " , rd . DigestType ) } end := * pos + n if end > len ( b ) { return fmt . Errorf ( " " ) } rd . Digest = append ( [ ] byte { } , b [ * pos : end ] ... ) * pos = end if sniffer != nil { sniffer ( p0 , & b [ * pos - 1 ] , dns . SniffRDataDS , rd ) } return }
Implementation of dns.Wirer
Implementation of dns . Wirer