Search in sources :

Example 6 with PortStateV10

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);
}
Also used : PortStateV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10) Test(org.junit.Test)

Example 7 with PortStateV10

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()));
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) PortStateV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 8 with PortStateV10

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();
}
Also used : StateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder)

Aggregations

PortStateV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)6 Test (org.junit.Test)5 PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)5 ByteBuf (io.netty.buffer.ByteBuf)4 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)3 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)2 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 ArrayList (java.util.ArrayList)1 StateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder)1 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)1 CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)1 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)1 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)1 PhyPortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder)1