// ReadFrom implements io.ReadFrom interface. It deserializes the
// instruction used to apply meter from the wire format.
196779
func (i *InstructionMeter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &instruction{}, &i.Meter)
}
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
}
429902
func (p *Port) ReadFrom(r io.Reader) (int64, error) {
	p.HWAddr = make(net.HardwareAddr, 6)
	var name [portNameLen]byte

	n, err := encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.HWAddr,
		&defaultPad2, &name, &p.Config, &p.State, &p.Curr, &p.Advertised,
		&p.Supported, &p.Peer, &p.CurrSpeed, &p.MaxSpeed,
	)

	p.Name = string(name[:])
	return n, err
}
1149359
func ReadFrom(r io.Reader) (*Index, error) {
	var (
		idx   Index
		magic [3]byte
		err   error
	)
	err = binary.Read(r, binary.LittleEndian, &magic)
	if err != nil {
		return nil, err
	}
	if magic != csiMagic {
		return nil, errors.New("csi: magic number mismatch")
	}
	version := []byte{0}
	_, err = io.ReadFull(r, version)
	if err != nil {
		return nil, err
	}
	idx.Version = version[0]
	if idx.Version != 0x1 && idx.Version != 0x2 {
		return nil, fmt.Errorf("csi: unknown version: %d", version[0])
	}
	err = binary.Read(r, binary.LittleEndian, &idx.minShift)
	if err != nil {
		return nil, err
	}
	if int32(idx.minShift) < 0 {
		return nil, errors.New("csi: invalid minimum shift value")
	}
	err = binary.Read(r, binary.LittleEndian, &idx.depth)
	if err != nil {
		return nil, err
	}
	if int32(idx.depth) < 0 {
		return nil, errors.New("csi: invalid index depth value")
	}
	var n int32
	err = binary.Read(r, binary.LittleEndian, &n)
	if err != nil {
		return nil, err
	}
	if n > 0 {
		idx.Auxilliary = make([]byte, n)
		_, err = io.ReadFull(r, idx.Auxilliary)
		if err != nil {
			return nil, err
		}
	}
	binLimit := uint32(((1 << ((idx.depth + 1) * nextBinShift)) - 1) / 7)
	idx.refs, err = readIndices(r, idx.Version, binLimit)
	if err != nil {
		return nil, err
	}
	var nUnmapped uint64
	err = binary.Read(r, binary.LittleEndian, &nUnmapped)
	if err == nil {
		idx.unmapped = &nUnmapped
	} else if err != io.EOF {
		return nil, err
	}
	idx.isSorted = true
	return &idx, nil
}
882913
func (d *Description) ReadFrom(r io.Reader) (int64, error) {
	var mfr, hw, sw, dp [descLen]byte
	var sn [serialNumLen]byte

	n, err := encoding.ReadFrom(r, &mfr, &hw, &sw, &sn, &dp)
	if err != nil {
		return n, err
	}

	d.Manufacturer = string(mfr[:])
	d.Hardware = string(hw[:])
	d.Software = string(sw[:])
	d.SerialNum = string(sn[:])
	d.Datapath = string(dp[:])
	return n, err
}
1018153
func (m *Message) ReadFrom(r io.Reader) (int64, error) {
	lengthBuf, n1, err := readUntilSpace(r)
	if err != nil {
		return 0, err
	}
	length, err := strconv.Atoi(string(lengthBuf))
	if err != nil {
		return 0, err
	}
	r2 := io.LimitReader(r, int64(length))
	buf, err := ioutil.ReadAll(r2)
	if err != nil {
		return int64(n1 + len(buf)), err
	}
	if len(buf) != int(length) {
		return int64(n1 + len(buf)), fmt.Errorf("Expected to read %d bytes, got %d", length, len(buf))
	}
	err = m.UnmarshalBinary(buf)
	if err != nil {
		return 0, err
	}
	return int64(n1 + len(buf)), err
}
526692
func (e *ErrorExperimenter) ReadFrom(r io.Reader) (n int64, err error) {
	var etype ErrType
	n, err = encoding.ReadFrom(r, &etype, &e.ExpType, &e.Experimenter)
	if err != nil {
		return n, err
	}

	e.Data, err = ioutil.ReadAll(r)
	if err != nil {
		return
	}

	return n + int64(len(e.Data)), nil
}
191099
func (m *ExperimenterMultipartHeader) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &m.Experimenter, &m.ExpType)
}
1350585
func (f *FlowMod) ReadFrom(r io.Reader) (int64, error) {
	// Set the list of instructions to nil, if someone will decide
	// to reuse the same exemplar for multiple deserializations.
	f.Instructions = nil

	return encoding.ReadFrom(r, &f.Cookie, &f.CookieMask, &f.Table,
		&f.Command, &f.IdleTimeout, &f.HardTimeout, &f.Priority,
		&f.Buffer, &f.OutPort, &f.OutGroup, &f.Flags, &defaultPad2,
		&f.Match, &f.Instructions,
	)
}
140836
func (f *FlowStats) ReadFrom(r io.Reader) (int64, error) {
	var len uint16

	n, err := encoding.ReadFrom(r, &len, &f.Table, &defaultPad1,
		&f.DurationSec, &f.DurationNSec, &f.Priority, &f.IdleTimeout,
		&f.HardTimeout, &f.Flags, &defaultPad4, &f.Cookie, &f.PacketCount,
		&f.ByteCount, &f.Match)

	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(len)-n)
	f.Instructions = nil

	nn, err := f.Instructions.ReadFrom(limrd)
	return n + nn, err
}
39471
func (a *ActionCopyTTLOut) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad8)
}
26641
func (sc *SwitchConfig) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &sc.Flags, &sc.MissSendLength)
}
1353760
func (c Config) ReadFrom(r io.Reader) (int64, error) {
	data, err := ioutil.ReadAll(r)
	if err != nil {
		return int64(len(data)), err
	}
	if err = json.Unmarshal(data, &c); err != nil {
		return int64(len(data)), err
	}
	return int64(len(data)), nil
}
1135270
func (i *RawVInt) ReadFrom(r Reader, l int) error {
	if l < 0 {
		return errorsp.WithStacksAndMessage(ErrBadFormat, "l = %d", l)
	}
	var v RawVInt
	n := uint(0)
	for ; l > 0; l-- {
		b, err := r.ReadByte()
		if err != nil {
			return errorsp.WithStacks(err)
		}
		v |= (RawVInt(b) & 0xff) << n
		n += 8
	}
	*i = v
	return nil
}
909927
func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error) {
	return c.p.ReadFrom(b)
}
348667
func (t *TableMod) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &t.Table, &pad3{}, &t.Config)
}
664432
func (q *QueueStats) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &q.Port, &q.Queue, &q.TxBytes,
		&q.TxPackets, &q.TxErrors, &q.DurationSec, &q.DurationNSec)
}