// UnmarshalBinary unmarshals the DHCP message type option from binary.
167515
func (d *DHCPMessageType) UnmarshalBinary(p []byte) error {
	buf := uio.NewBigEndianBuffer(p)
	*d = DHCPMessageType(buf.Read8())
	return buf.FinError()
}
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
}
1257548
func (p *PingSlotChannelAnsPayload) 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.DataRateOK = data[0]&(1<<1) != 0

	return nil
}
631857
func (p *Packet) UnmarshalBinary(q []byte) error {
	b := buffer.New(q)
	// Packet must contain at least a message type and transaction ID
	if b.Len() < 4 {
		return ErrInvalidPacket
	}

	p.MessageType = MessageType(b.Read8())
	b.ReadBytes(p.TransactionID[:])

	if err := (&p.Options).UnmarshalBinary(b.Remaining()); err != nil {
		return ErrInvalidPacket
	}
	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
}
97655
func (o *OptionCodes) UnmarshalBinary(p []byte) error {
	b := uio.NewBigEndianBuffer(p)
	*o = make(OptionCodes, 0, b.Len())
	for b.Has(1) {
		*o = append(*o, dhcp4.OptionCode(b.Read8()))
	}
	return b.FinError()
}
649708
func UnmarshalBinary(data []byte, fields ...interface{}) error {
	buf := bytes.NewBuffer(data)

	for _, p := range fields {
		switch m := p.(type) {
		case encoding.BinaryUnmarshaler:
			return m.UnmarshalBinary(buf.Bytes())
		case *[]byte:
			*m = buf.Bytes()
			return nil
		default:
			err := binary.Read(buf, binary.LittleEndian, p)
			if err != nil {
				return ProtocolError(err)
			}
		}
	}

	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
}
138664
func (n *DevNonce) UnmarshalBinary(data []byte) error {
	if len(data) != 2 {
		return errors.New("lorawan: 2 bytes are expected")
	}
	*n = DevNonce(binary.LittleEndian.Uint16(data))
	return nil
}
628695
func (i *IP) UnmarshalBinary(p []byte) error {
	if len(p) < net.IPv4len {
		return io.ErrUnexpectedEOF
	}

	*i = make([]byte, net.IPv4len)
	copy(*i, p[:net.IPv4len])
	return nil
}
170283
func (s *SubnetMask) UnmarshalBinary(p []byte) error {
	buf := uio.NewBigEndianBuffer(p)
	*s = buf.CopyN(net.IPv4len)
	return buf.FinError()
}
1034858
func (i *InterfaceID) UnmarshalBinary(b []byte) error {
	*i = make([]byte, len(b))
	copy(*i, b)
	return nil
}
670131
func (key *AES128Key) UnmarshalBinary(data []byte) error {
	if len(data) != 16 {
		return errors.New("ttn/core: Invalid length for AES128Key")
	}
	copy(key[:], data)
	return nil
}
235384
func (hmac *HMAC) UnmarshalBinary(data []byte) error {
	return hmac.h.UnmarshalBinary(data)
}
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
}
647332
func (p *FragSessionDeleteAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) < p.Size() {
		return fmt.Errorf("lorawan/applayer/fragmentation: %d byte is expected", p.Size())
	}

	p.Status.FragIndex = data[0] & 0x03
	p.Status.SessionDoesNotExist = data[0]&0x04 != 0

	return nil
}