public void asyncSend(OFMessage msg) throws Exception { synchronized (outBuffer) { int msgLen = msg.getLengthU(); if (outBuffer.remaining() < msgLen) {
@Override public void readFrom(final ChannelBuffer data) { super.readFrom(data); this.vendor = data.readInt(); if (this.vendorDataFactory == null) { throw new RuntimeException("OFVendorDataFactory not set"); } this.vendorData = this.vendorDataFactory.parseVendorData(this.vendor, data, super.getLengthU() - OFVendor.MINIMUM_LENGTH); }
@Override protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg) throws Exception { if (!(msg instanceof List)) { return msg; } @SuppressWarnings("unchecked") final List<OFMessage> msglist = (List<OFMessage>) msg; int size = 0; for (final OFMessage ofm : msglist) { size += ofm.getLengthU(); } final ChannelBuffer buf = ChannelBuffers.buffer(size); for (final OFMessage ofm : msglist) { ofm.writeTo(buf); } return buf; }
public void asyncSend(OFMessage msg) throws Exception { synchronized (myAppData) { int msgLen = msg.getLengthU(); if (myAppData.remaining() < msgLen) {
/** * Write this offending message into the payload of the Error message * * @param offendingMsg */ public void setOffendingMsg(final OFMessage offendingMsg) { if (offendingMsg == null) { super.setLengthU(OFError.MINIMUM_LENGTH); } else { this.error = new byte[offendingMsg.getLengthU()]; final ChannelBuffer data = ChannelBuffers.wrappedBuffer(this.error); data.writerIndex(0); offendingMsg.writeTo(data); super.setLengthU(OFError.MINIMUM_LENGTH + offendingMsg.getLengthU()); } }
/** * Returns a summary of the message * * @return "ofmsg=v=$version;t=$type:l=$len:xid=$xid" */ @Override public String toString() { return "ofmsg" + ":v=" + U8.f(this.getVersion()) + ";t=" + this.getType() + ";l=" + this.getLengthU() + ";x=" + U32.f(this.getXid()); }
@Override public void readFrom(final ChannelBuffer data) { super.readFrom(data); this.statisticType = OFStatisticsType.valueOf(data.readShort(), this.getType()); this.flags = data.readShort(); if (this.statisticsFactory == null) { throw new RuntimeException("OFStatisticsFactory not set"); } this.statistics = this.statisticsFactory.parseStatistics( this.getType(), this.statisticType, data, super.getLengthU() - OFStatisticsMessageBase.MINIMUM_LENGTH); }
@Override public void readFrom(final ChannelBuffer data) { super.readFrom(data); this.datapathId = data.readLong(); this.buffers = data.readInt(); this.tables = data.readByte(); data.readerIndex(data.readerIndex() + 3); // pad this.capabilities = data.readInt(); this.actions = data.readInt(); if (this.ports == null) { this.ports = new ArrayList<OFPhysicalPort>(); } else { this.ports.clear(); } final int portCount = (super.getLengthU() - 32) / OFPhysicalPort.MINIMUM_LENGTH; OFPhysicalPort port; for (int i = 0; i < portCount; ++i) { port = new OFPhysicalPort(); port.readFrom(data); this.ports.add(port); } }
data.resetReaderIndex(); if (demux.getLengthU() > data.readableBytes()) { return ofm; if (OFMessage.class.equals(ofm.getClass())) { data.readerIndex(data.readerIndex() + ofm.getLengthU() - OFMessage.MINIMUM_LENGTH);