use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage in project openflowplugin by opendaylight.
the class PortMessageDeserializer method deserialize.
@Override
public PortMessage deserialize(ByteBuf message) {
final PortMessageBuilder builder = new PortMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setPortNumber(new PortNumberUni(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1);
builder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
message.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2);
builder.setConfiguration(readPortConfig(message));
// Skip mask
message.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
builder.setAdvertisedFeatures(readPortFeatures(message));
message.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage in project openflowplugin by opendaylight.
the class PortMessageDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
buffer.writeByte(TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeInt(XID);
buffer.writeInt(PORT);
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_1);
buffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ADDRESS));
final int config = ByteBufUtils.fillBitMaskFromMap(ImmutableMap.<Integer, Boolean>builder().put(0, IS_PORTDOWN).put(2, IS_NORECV).put(5, IS_NOFWD).put(6, IS_NOPACKETIN).build());
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_2);
// config
buffer.writeInt(config);
// config mask
buffer.writeInt(config);
buffer.writeInt(ByteBufUtils.fillBitMask(0, IS_10MBHD, IS_10MBFD, IS_100MBHD, IS_100MBFD, IS_1GBHD, IS_1GBFD, IS_10GBFD, IS_40GBFD, IS_100GBFD, IS_1TBFD, IS_OTHER, IS_COPPER, IS_FIBER, IS_AUTOENG, IS_PAUSE, IS_PAUSE_ASYM));
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_3);
final PortMessage message = (PortMessage) getFactory().deserialize(buffer, EncodeConstants.OF13_VERSION_ID);
assertEquals(XID, message.getXid().intValue());
assertEquals(PORT, message.getPortNumber().getUint32().intValue());
assertEquals(ADDRESS.getValue(), message.getHardwareAddress().getValue());
// Config
assertEquals(IS_PORTDOWN, message.getConfiguration().isPORTDOWN());
assertEquals(IS_NORECV, message.getConfiguration().isNORECV());
assertEquals(IS_NOFWD, message.getConfiguration().isNOFWD());
assertEquals(IS_NOPACKETIN, message.getConfiguration().isNOPACKETIN());
// Features
assertEquals(IS_10MBHD, message.getAdvertisedFeatures().isTenMbHd());
assertEquals(IS_10MBFD, message.getAdvertisedFeatures().isTenMbHd());
assertEquals(IS_100MBHD, message.getAdvertisedFeatures().isHundredMbHd());
assertEquals(IS_100MBFD, message.getAdvertisedFeatures().isHundredMbFd());
assertEquals(IS_1GBHD, message.getAdvertisedFeatures().isOneGbHd());
assertEquals(IS_1GBFD, message.getAdvertisedFeatures().isOneGbFd());
assertEquals(IS_10GBFD, message.getAdvertisedFeatures().isTenGbFd());
assertEquals(IS_40GBFD, message.getAdvertisedFeatures().isFortyGbFd());
assertEquals(IS_100GBFD, message.getAdvertisedFeatures().isHundredGbFd());
assertEquals(IS_1TBFD, message.getAdvertisedFeatures().isOneTbFd());
assertEquals(IS_OTHER, message.getAdvertisedFeatures().isOther());
assertEquals(IS_COPPER, message.getAdvertisedFeatures().isCopper());
assertEquals(IS_FIBER, message.getAdvertisedFeatures().isFiber());
assertEquals(IS_AUTOENG, message.getAdvertisedFeatures().isAutoeng());
assertEquals(IS_PAUSE, message.getAdvertisedFeatures().isPause());
assertEquals(IS_PAUSE_ASYM, message.getAdvertisedFeatures().isPauseAsym());
assertEquals(buffer.readableBytes(), 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage in project openflowplugin by opendaylight.
the class SingleLayerPortServiceTest method buildRequest.
@Test
public void buildRequest() throws Exception {
final Port input = new PortBuilder().setPortNumber(new PortNumberUni(PORT_ID)).build();
final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
assertEquals(PortMessage.class, ofHeader.getImplementedInterface());
final PortMessage result = PortMessage.class.cast(ofHeader);
assertEquals(PORT_ID, result.getPortNumber().getUint32().longValue());
}
Aggregations