use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactory method deserialize.
@Override
public GetFeaturesOutput deserialize(final ByteBuf rawMessage) {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(datapathId);
builder.setDatapathId(new BigInteger(1, datapathId));
builder.setBuffers(rawMessage.readUnsignedInt());
builder.setTables(rawMessage.readUnsignedByte());
rawMessage.skipBytes(PADDING_IN_FEATURES_REPLY_HEADER);
builder.setCapabilitiesV10(createCapabilitiesV10(rawMessage.readUnsignedInt()));
builder.setActionsV10(createActionsV10(rawMessage.readUnsignedInt()));
List<PhyPort> ports = new ArrayList<>();
while (rawMessage.readableBytes() > 0) {
ports.add(deserializePort(rawMessage));
}
builder.setPhyPort(ports);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method createPorts.
private static List<PhyPort> createPorts() {
final List<PhyPort> ports = new ArrayList<>();
PhyPortBuilder builder = new PhyPortBuilder();
builder.setPortNo(1L);
builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
builder.setName("Port name");
builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
builder.setCurrentFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setAdvertisedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setSupportedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setPeerFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
ports.add(builder.build());
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setDatapathId(BigInteger.valueOf(1L));
builder.setBuffers(1L);
builder.setTables((short) 1);
builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true));
builder.setPhyPort(createPorts());
GetFeaturesOutput message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(3);
Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), createCapabilities(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
PhyPort port = message.getPhyPort().get(0);
Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
byte[] address = new byte[6];
serializedBuffer.readBytes(address);
Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
byte[] name = new byte[16];
serializedBuffer.readBytes(name);
Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactory method deserializePort.
private static PhyPort deserializePort(final ByteBuf rawMessage) {
PhyPortBuilder builder = new PhyPortBuilder();
builder.setPortNo((long) rawMessage.readUnsignedShort());
builder.setHwAddr(ByteBufUtils.readIetfMacAddress(rawMessage));
builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
builder.setConfigV10(OpenflowUtils.createPortConfig(rawMessage.readUnsignedInt()));
builder.setStateV10(OpenflowUtils.createPortState(rawMessage.readUnsignedInt()));
builder.setCurrentFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt()));
builder.setAdvertisedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt()));
builder.setSupportedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt()));
builder.setPeerFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactory method serialize.
@Override
public void serialize(final GetFeaturesOutput message, final ByteBuf outBuffer) {
ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
outBuffer.writeLong(message.getDatapathId().longValue());
outBuffer.writeInt(message.getBuffers().intValue());
outBuffer.writeByte(message.getTables().intValue());
outBuffer.writeZero(PADDING);
outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10()));
outBuffer.writeInt(createActionsV10(message.getActionsV10()));
for (PhyPort port : message.getPhyPort()) {
outBuffer.writeShort(port.getPortNo().intValue());
outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr()));
writeName(port.getName(), outBuffer);
writePortConfig(port.getConfigV10(), outBuffer);
writePortState(port.getStateV10(), outBuffer);
writePortFeature(port.getCurrentFeaturesV10(), outBuffer);
writePortFeature(port.getAdvertisedFeaturesV10(), outBuffer);
writePortFeature(port.getSupportedFeaturesV10(), outBuffer);
writePortFeature(port.getPeerFeaturesV10(), outBuffer);
}
ByteBufUtils.updateOFHeaderLength(outBuffer);
}
Aggregations