use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10 in project openflowplugin by opendaylight.
the class OpenflowUtilsTest method testPortState.
/**
* Tests {@link OpenflowUtils#createPortState(long)}.
*/
@Test
public void testPortState() {
PortStateV10 state = OpenflowUtils.createPortState(512L);
Assert.assertEquals("Wrong port state", new PortStateV10(false, false, false, false, true, false, true, false), state);
state = OpenflowUtils.createPortState(1793L);
Assert.assertEquals("Wrong port state", new PortStateV10(false, true, false, true, true, true, false, true), state);
state = OpenflowUtils.createPortState(1L);
Assert.assertEquals("Wrong port state", new PortStateV10(false, true, false, false, false, false, true, false), state);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10 in project openflowplugin by opendaylight.
the class OF10PortStatusMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setReason(PortReason.forValue(1));
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));
PortStatusMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64);
Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(7);
Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort());
byte[] address = new byte[6];
serializedBuffer.readBytes(address);
Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
byte[] name = new byte[16];
serializedBuffer.readBytes(name);
Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt()));
Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10 in project openflowplugin by opendaylight.
the class PortTranslatorUtil method translatePortState.
public static State translatePortState(final PortStateV10 state) {
StateBuilder nstate = new StateBuilder();
if (state != null) {
nstate.setBlocked(state.isBlocked());
nstate.setLinkDown(state.isLinkDown());
nstate.setLive(state.isLive());
}
return nstate.build();
}
Aggregations