// UnmarshalBinary implements the BinaryUnmarshaler interface.
343724
func (prefix *DevAddrPrefix) UnmarshalBinary(data []byte) error {
	if len(data) != 5 {
		return errors.New("ttn/core: Invalid length for DevAddrPrefix")
	}
	copy(prefix.DevAddr[:], data[1:])
	prefix.Length = int(data[0])
	prefix.DevAddr = prefix.DevAddr.Mask(prefix.Length)
	return nil
}
824194
func (p *RejoinParamSetupAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}

	p.TimeOK = data[0]&1 != 0
	return nil
}
424841
func (p *BeaconFreqAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}

	p.BeaconFrequencyOK = data[0]&(1<<0) != 0

	return nil
}
1111605
func (o *GetAuthCallbackOKBody) UnmarshalBinary(b []byte) error {
	var res GetAuthCallbackOKBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
728836
func (bf *BitField) UnmarshalBinary(bs []byte) error {
	buf := bytes.NewBuffer(bs)
	n, err := binary.ReadUvarint(buf)
	if err != nil {
		return err
	}
	if n > math.MaxUint32 {
		return fmt.Errorf("encoded number is out of range: %d > %d", n, uint32(math.MaxUint32))
	}

	size := uint32(n)
	if size == 0 {
		bf.size = 0
		bf.data = nil
		return nil
	}
	data := buf.Bytes()
	if uint32(len(data)) != (size+8-1)>>3 {
		return fmt.Errorf("mismatched size (%d) v. byte count (%d)", size, len(data))
	}

	bf.size = size
	bf.data = data
	return nil
}
723217
func (id *ID) UnmarshalBinary(data []byte) error {
	return id.h.UnmarshalBinary(data)
}
1202316
func (bh *Header) UnmarshalBinary(b []byte) error {
	return bh.DecodeBinary(bytes.NewReader(b))
}
167515
func (d *DHCPMessageType) UnmarshalBinary(p []byte) error {
	buf := uio.NewBigEndianBuffer(p)
	*d = DHCPMessageType(buf.Read8())
	return buf.FinError()
}
1278755
func (h *MHDR) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	h.Major = Major(data[0] & 3)
	h.MType = MType((data[0] & 224) >> 5)
	return nil
}
621288
func (p *Property) UnmarshalBinary(data []byte) error {
	buf := bytes.NewBuffer(data)

	err := binary.Read(buf, binary.LittleEndian, &p.header)
	if err != nil {
		return err
	}

	switch p.header.Kind {
	case vixPropertyTypeBool:
		return binary.Read(buf, binary.LittleEndian, &p.data.Bool)
	case vixPropertyTypeInt32:
		return binary.Read(buf, binary.LittleEndian, &p.data.Int32)
	case vixPropertyTypeInt64:
		return binary.Read(buf, binary.LittleEndian, &p.data.Int64)
	case vixPropertyTypeString:
		s := make([]byte, p.header.Length)
		if _, err := buf.Read(s); err != nil {
			return err
		}

		p.data.String = string(bytes.TrimRight(s, "\x00"))
	case vixPropertyTypeBlob:
		p.data.Blob = make([]byte, p.header.Length)
		if _, err := buf.Read(p.data.Blob); err != nil {
			return err
		}
	default:
		return errors.New("VIX_E_UNRECOGNIZED_PROPERTY")
	}

	return nil
}
744646
func (i *IP) UnmarshalBinary(b []byte) error {
	if len(b) != net.IPv6len {
		return io.ErrUnexpectedEOF
	}

	if ip := net.IP(b); ip.To4() != nil {
		return io.ErrUnexpectedEOF
	}

	*i = make(IP, net.IPv6len)
	copy(*i, b)
	return nil
}
1001206
func (h *TLFReaderKeyBundleID) UnmarshalBinary(data []byte) error {
	return h.h.UnmarshalBinary(data)
}
855720
func (eui *EUI64) UnmarshalBinary(data []byte) error {
	if len(data) != 8 {
		return errors.New("ttn/core: Invalid length for EUI64")
	}
	copy(eui[:], data)
	return nil
}
408405
func (a *DevAddr) UnmarshalBinary(data []byte) error {
	if len(data) != len(a) {
		return fmt.Errorf("lorawan: %d bytes of data are expected", len(a))
	}
	for i, v := range data {
		// little endian
		a[len(a)-i-1] = v
	}
	return nil
}
1354757
func (p *RXParamSetupAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	p.ChannelACK = data[0]&(1<<0) > 0
	p.RX2DataRateACK = data[0]&(1<<1) > 0
	p.RX1DROffsetACK = data[0]&(1<<2) > 0
	return nil
}
826937
func (p *NewChannelAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	p.ChannelFrequencyOK = data[0]&(1<<0) > 0
	p.DataRateRangeOK = data[0]&(1<<1) > 0
	return nil
}
235384
func (hmac *HMAC) UnmarshalBinary(data []byte) error {
	return hmac.h.UnmarshalBinary(data)
}