// ReadFrom decodes the list of actions from the wire format into
// the list of types that implement Action interface.
774715
func (a *Actions) ReadFrom(r io.Reader) (int64, error) {
	var actionType ActionType
	*a = nil

	rm := func() (io.ReaderFrom, error) {
		if rm, ok := actionMap[actionType]; ok {
			rd, err := rm.MakeReader()
			*a = append(*a, rd.(Action))
			return rd, err
		}

		format := "ofp: unknown action type: '%x'"
		return nil, fmt.Errorf(format, actionType)
	}

	return encoding.ScanFrom(r, &actionType,
		encoding.ReaderMakerFunc(rm))
}
497645
func (Null) ReadFrom(r Reader, l int) error {
	if l != UNKNOWN_LEN && l != 0 {
		return errorsp.WithStacksAndMessage(ErrBadFormat, "l = %d", l)
	}
	return nil
}
98289
func (h *Hello) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &h.Elements)
}
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,
	)
}
1365616
func (rb *Bitmap) ReadFrom(stream io.Reader) (int64, error) {
	return rb.highlowcontainer.readFrom(stream)
}
380914
func (e *Error) ReadFrom(r io.Reader) (n int64, err error) {
	n, err = encoding.ReadFrom(r, &e.Type, &e.Code)
	if err != nil {
		return
	}

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

	return n + int64(len(e.Data)), nil
}
265176
func (xm *XM) ReadFrom(r io.Reader) (n int64, err error) {
	return xm.readFrom(r, true)
}
1114032
func (i *InstructionGotoTable) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &instruction{}, &i.Table, &defaultPad3)
}
703945
func (r *FilteredConn) ReadFrom(b []byte) (n int, addr net.Addr, err error) {
	select {
	case <-r.closed:
		return 0, nil, errClosed
	default:
	}

	var timeout <-chan time.Time

	if deadline, ok := r.deadline.Load().(time.Time); ok && !deadline.IsZero() {
		timer := time.NewTimer(deadline.Sub(time.Now()))
		timeout = timer.C
		defer timer.Stop()
	}

	select {
	case <-timeout:
		return 0, nil, errTimeout
	case pkt := <-r.recvBuffer:
		copy(b[:pkt.n], pkt.buf)
		bufPool.Put(pkt.buf[:maxPacketSize])
		return pkt.n, pkt.addr, pkt.err
	case <-r.closed:
		return 0, nil, errClosed
	}
}
1218705
func (a *AggregateStatsRequest) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &a.Table, &defaultPad3,
		&a.OutPort, &a.OutGroup, &defaultPad4, &a.Cookie,
		&a.CookieMask, &a.Match)
}
272845
func (a *ActionSetField) ReadFrom(r io.Reader) (int64, error) {
	var header action
	var num int64

	n, err := encoding.ReadFrom(r, &header)
	if err != nil {
		return n, err
	}

	limrd := io.LimitReader(r, int64(header.Len-4))
	num, err = a.Field.ReadFrom(limrd)
	n += num

	if err != nil {
		return n, err
	}

	b, err := ioutil.ReadAll(limrd)
	n += int64(len(b))
	return n, err
}
1319052
func (t *TablePropWriteActions) ReadFrom(r io.Reader) (int64, error) {
	return readTablePropActions(r, &t.Actions, &t.Miss)
}
143839
func (b *BucketCounter) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &b.PacketCount, &b.ByteCount)
}
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
}
874099
func (r *Request) ReadFrom(rd io.Reader) (n int64, err error) {
	// On the first step we will read the OpenFlow header, so
	// we could get the total length of the OpenFlow message.
	n, err = r.Header.ReadFrom(rd)
	if err != nil {
		return
	}

	// Decode the protocol version major and minor number to
	// make the request interface more or less friendly.
	r.ProtoMajor = 1
	r.ProtoMinor = int(r.Header.Version - 1)

	// FIXME: wrong for version 2
	r.Proto = fmt.Sprintf("OFP/1.%d", r.ProtoMinor)

	contentlen := int64(r.Header.Len() - headerlen)
	if contentlen < 0 {
		return n, ErrCorruptedHeader
	}

	// Define a buffer to fit the content of the OpenFlow package.
	n, buf := 0, make([]byte, int(contentlen))

	// Read all data the from the stream into the allocated buffer.
	//
	// Due to bufferized nature of the reader, it can take multiple
	// reads from the reader to retrieve the body completely.
	for n < contentlen {
		nn, err := rd.Read(buf[n:])
		if n += int64(nn); err != nil {
			return n + headerlen, err
		}
	}

	r.Body = bytes.NewBuffer(buf)
	r.ContentLength = contentlen
	return n + headerlen, nil
}
1224704
func (s *RawString) ReadFrom(r Reader, l int) error {
	var ba RawByteSlice
	if err := ba.ReadFrom(r, l); err != nil {
		return err
	}
	*s = RawString(ba)

	return nil
}
1352983
func (i *InstructionClearActions) ReadFrom(r io.Reader) (int64, error) {
	return encoding.ReadFrom(r, &defaultPad8)
}