// ReadFrom implements io.ReaderFrom interface. It deserializes the
// packet queue from the wire format.
547097
func (q *PacketQueue) ReadFrom(r io.Reader) (int64, error) {
	var length uint16
	n, err := encoding.ReadFrom(r, &q.Queue, &q.Port,
		&length, &defaultPad6)

	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(length-packetQueueLen))
	nn, err := q.Properties.ReadFrom(limrd)
	return n + nn, err
}
665482
func (ac *arrayContainer) readFrom(stream io.Reader) (int, error) {
	buf := uint16SliceAsByteSlice(ac.content)
	return io.ReadFull(stream, buf)
}
739801
func (s *String) ReadFrom(r Reader, l int) error {
	var ba ByteSlice
	if err := ba.ReadFrom(r, l); err != nil {
		return err
	}
	*s = String(ba)

	return nil
}
643337
func (b *BitSet) ReadFrom(stream io.Reader) (int64, error) {
	var length uint64

	// Read length first
	err := binary.Read(stream, binaryOrder, &length)
	if err != nil {
		return 0, err
	}
	newset := New(uint(length))

	if uint64(newset.length) != length {
		return 0, errors.New("Unmarshalling error: type mismatch")
	}

	// Read remaining bytes as set
	err = binary.Read(stream, binaryOrder, newset.set)
	if err != nil {
		return 0, err
	}

	*b = *newset
	return int64(b.BinaryStorageSize()), nil
}
1037617
func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
	// Attempt to receive on socket
	n, addr, err := p.s.Recvfrom(b, 0)
	if err != nil {
		return n, nil, err
	}

	// Retrieve hardware address and other information from addr.
	sa, ok := addr.(*unix.SockaddrLinklayer)
	if !ok || sa.Halen < 6 {
		return n, nil, unix.EINVAL
	}

	// Use length specified to convert byte array into a hardware address slice.
	mac := make(net.HardwareAddr, sa.Halen)
	copy(mac, sa.Addr[:])

	// packet(7):
	//   sll_hatype and sll_pkttype are set on received packets for your
	//   information.
	// TODO(mdlayher): determine if similar fields exist and are useful on
	// non-Linux platforms
	return n, &Addr{
		HardwareAddr: mac,
	}, nil
}
1354870
func (p *PortStatus) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &p.Reason, &defaultPad7, &p.Port)
}
63765
func (m *MeterConfigRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Meter, &defaultPad4)
}
1179619
func (s *Slice) ReadFrom(r io.Reader) (n int64, err error) {
	const buf_SIZE = 32 * 1024
	buf := make([]byte, buf_SIZE)
	for {
		nRead, err := r.Read(buf)
		if nRead == 0 {
			if err != io.EOF {
				return n, err
			}
			break
		}
		n += int64(nRead)
		*s = append(*s, buf[:nRead]...)
		if err == io.EOF {
			break
		}

		if err != nil {
			return n, err
		}
	}

	return n, nil
}
26641
func (sc *SwitchConfig) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &sc.Flags, &sc.MissSendLength)
}
1030878
func (i *Instructions) ReadFrom(r io.Reader) (n int64, err error) {
	var instType InstructionType

	rm := func() (io.ReaderFrom, error) {
		if rm, ok := instructionMap[instType]; ok {
			rd, err := rm.MakeReader()
			*i = append(*i, rd.(Instruction))
			return rd, err
		}

		return nil, fmt.Errorf("ofp: unknown instruction type: %s", instType)
	}

	return encoding.ScanFrom(r, &instType,
		encoding.ReaderMakerFunc(rm))
}
1306353
func (i *VInt) ReadFrom(r Reader, l int) error {
	var v VInt
	b, err := r.ReadByte()
	if err != nil {
		return errorsp.WithStacks(err)
	}
	v = VInt(b & 0x7f)
	for n := uint(7); b&0x80 != 0; n += 7 {
		if b, err = r.ReadByte(); err != nil {
			if errorsp.Cause(err) == io.EOF {
				return errorsp.WithStacks(io.ErrUnexpectedEOF)
			}
			return errorsp.WithStacks(err)
		}
		v |= VInt(b&0x7f) << n
	}
	*i = v
	return nil
}
1319052
func (t *TablePropWriteActions) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropActions(r, &t.Actions, &t.Miss)
}
14626
func (q *QueueStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &q.Port, &q.Queue)
}
149678
func (p *PacketOut) ReadFrom(r io.Reader) (int64, error) {
	var plen uint16

	n, err := encoding.ReadFrom(r, &p.Buffer, &p.InPort,
		&plen, &defaultPad6)

	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(plen))
	p.Actions = nil

	nn, err := p.Actions.ReadFrom(limrd)
	if n += nn; err != nil {
		return n, err
	}

	p.Data, err = ioutil.ReadAll(r)
	return n + int64(len(p.Data)), err
}
832814
func (p *PortMod) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.HWAddr,
		&defaultPad2, &p.Config, &p.Mask, &p.Advertise, &defaultPad4,
	)
}
390866
func (c *rankCache) ReadFrom(r io.Reader) (n int64, err error) {
	panic("FIXME: TODO")
}
328795
func (g *GroupStats) ReadFrom(r io.Reader) (int64, error) {
	var length uint16

	n, err := encoding.ReadFrom(r, &length, &defaultPad2,
		&g.Group, &g.RefCount, &defaultPad4, &g.PacketCount, &g.ByteCount,
		&g.DurationSec, &g.DurationNSec)

	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(length-groupStatsLen))
	counterMaker := encoding.ReaderMakerOf(BucketCounter{})

	nn, err := encoding.ReadSliceFrom(limrd, counterMaker, g.BucketStats)
	return n + nn, err
}