// UnmarshalBinary implements the BinaryUnmarshaler interface.
199568
func (addr *DevAddr) UnmarshalBinary(data []byte) error {
	if len(data) != 4 {
		return errors.New("ttn/core: Invalid length for DevAddr")
	}
	copy(addr[:], data)
	return nil
}
330698
func (r *SystemBootOptionsResponse) UnmarshalBinary(buf []byte) error {
	if len(buf) < 3 {
		return ErrShortPacket
	}
	r.CompletionCode = CompletionCode(buf[0])
	r.Version = buf[1]
	r.Param = buf[2]
	r.Data = buf[3:]
	return nil
}
864430
func (n *NetID) UnmarshalBinary(data []byte) error {
	if len(data) != 3 {
		return errors.New("ttn/core: Invalid length for NetID")
	}
	copy(n[:], data)
	return nil
}
1284755
func (p *PingSlotChannelReqPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 4 {
		return errors.New("lorawan: 4 bytes of data are expected")
	}

	b := make([]byte, 4)
	copy(b, data)
	b[3] = 0

	p.Frequency = binary.LittleEndian.Uint32(b) * 100
	p.DR = data[3] & ((1 << 3) | (1 << 2) | (1 << 1) | (1 << 0))

	return nil
}
348591
func (s *StatusCode) UnmarshalBinary(p []byte) error {
	b := buffer.New(p)
	// Too short to contain valid StatusCode
	if b.Len() < 2 {
		return io.ErrUnexpectedEOF
	}

	s.Code = dhcp6.Status(b.Read16())
	s.Message = string(b.Remaining())
	return nil
}
474428
func (h *Hash) UnmarshalBinary(data []byte) error {
	if len(data) == 0 {
		*h = Hash{}
		return nil
	}

	h.h = string(data)
	if !h.IsValid() {
		err := InvalidHashError{*h}
		*h = Hash{}
		return errors.WithStack(err)
	}

	return nil
}
260689
func (e *EUI64) UnmarshalBinary(data []byte) error {
	if len(data) != len(e) {
		return fmt.Errorf("lorawan: %d bytes of data are expected", len(e))
	}
	for i, v := range data {
		// little endian
		e[len(e)-i-1] = v
	}
	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
}
700438
func (r *Redundancy) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	r.NbRep = data[0] & ((1 << 3) ^ (1 << 2) ^ (1 << 1) ^ (1 << 0))
	r.ChMaskCntl = (data[0] & ((1 << 6) ^ (1 << 5) ^ (1 << 4))) >> 4
	return nil
}
586419
func (u *UUID) UnmarshalBinary(data []byte) (err error) {
	if len(data) != Size {
		err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data))
		return
	}
	copy(u[:], data)

	return
}
327240
func (n *NII) UnmarshalBinary(b []byte) error {
	// Length must be exactly 3
	if len(b) != 3 {
		return io.ErrUnexpectedEOF
	}

	n.Type = b[0]
	n.Major = b[1]
	n.Minor = b[2]

	return nil
}
432146
func (p *ForceDeviceResyncReqPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/clocksync: %d bytes are expected", p.Size())
	}
	p.ForceConf.NbTransmissions = data[0] & 0x17
	return nil
}
944649
func (n *JoinNonce) UnmarshalBinary(data []byte) error {
	if len(data) != 3 {
		return errors.New("lorawan: 3 bytes are expected")
	}

	b := make([]byte, 4)
	copy(b[:3], data)
	*n = JoinNonce(binary.LittleEndian.Uint32(b))

	return nil
}
921581
func (p *RekeyConfPayload) UnmarshalBinary(data []byte) error {
	return p.ServLoRaWANVersion.UnmarshalBinary(data)
}
417911
func (k *AES128Key) UnmarshalBinary(data []byte) error {
	if len(data) != len(k) {
		return fmt.Errorf("lorawan: %d bytes of data are expected", len(k))
	}

	for i, v := range data {
		// little endian
		k[len(k)-i-1] = v
	}

	return nil
}
424340
func (p *ADRParamSetupReqPayload) UnmarshalBinary(data []byte) error {
	return p.ADRParam.UnmarshalBinary(data)
}
522878
func (o *UUID) UnmarshalBinary(bytes []byte) error {
	if len(bytes) != o.Size() {
		return errors.New("uuid: invalid length")
	}
	o.unmarshal(bytes)
	return nil
}