Search in sources :

Example 6 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder in project openflowplugin by opendaylight.

the class OF10HelloMessageFactory method deserialize.

@Override
public HelloMessage deserialize(ByteBuf rawMessage) {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    if (rawMessage.readableBytes() > 0) {
        rawMessage.skipBytes(rawMessage.readableBytes());
    }
    return builder.build();
}
Also used : HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)

Example 7 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder in project openflowplugin by opendaylight.

the class HelloMessageFactory method deserialize.

@Override
public HelloMessage deserialize(ByteBuf rawMessage) {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    builder.setVersion(getVersion());
    builder.setXid(rawMessage.readUnsignedInt());
    if (rawMessage.readableBytes() > 0) {
        builder.setElements(readElement(rawMessage));
    }
    return builder.build();
}
Also used : HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)

Example 8 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder in project openflowplugin by opendaylight.

the class HelloMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    HelloMessageBuilder builder = new HelloMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    HelloMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8);
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 9 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder in project openflowplugin by opendaylight.

the class HandshakeManagerImplTest method addVersionBitmap.

/**
 * Adds version bitmap.
 * @param versionOrder version order
 * @param helloBuilder hello builder
 * @return builder
 */
private static HelloMessageBuilder addVersionBitmap(List<Short> versionOrder, HelloMessageBuilder helloBuilder) {
    short highestVersion = versionOrder.get(0);
    int elementsCount = highestVersion / Integer.SIZE;
    ElementsBuilder elementsBuilder = new ElementsBuilder();
    List<Elements> elementList = new ArrayList<>();
    int orderIndex = versionOrder.size();
    int value = versionOrder.get(--orderIndex);
    for (int index = 0; index <= elementsCount; index++) {
        List<Boolean> booleanList = new ArrayList<>();
        for (int i = 0; i < Integer.SIZE; i++) {
            if (value == index * Integer.SIZE + i) {
                booleanList.add(true);
                value = orderIndex == 0 ? highestVersion : versionOrder.get(--orderIndex);
            } else {
                booleanList.add(false);
            }
        }
        elementsBuilder.setType(HelloElementType.forValue(1));
        elementsBuilder.setVersionBitmap(booleanList);
        elementList.add(elementsBuilder.build());
    }
    helloBuilder.setElements(elementList);
    return helloBuilder;
}
Also used : ArrayList(java.util.ArrayList) ElementsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)

Example 10 with HelloMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder in project openflowplugin by opendaylight.

the class HandshakeManagerImplTest method testVersionNegotiationNoCommonVersionInBitmap.

/**
 * Test of version negotiation Where bitmap version {0x05,0x02}.
 */
@Test
public void testVersionNegotiationNoCommonVersionInBitmap() throws Exception {
    LOG.debug("testVersionNegotiationNoCommonVersionInBitmap");
    Short version = (short) 0x05;
    expectedErrors = 1;
    handshakeManager.setUseVersionBitmap(true);
    HelloMessageBuilder helloMessage = createHelloMessage(version, helloXid);
    addVersionBitmap(Lists.newArrayList((short) 0x05, (short) 0x02), helloMessage);
    handshakeManager.shake(helloMessage.build());
    Mockito.verify(handshakeListener, Mockito.never()).onHandshakeSuccessful(Matchers.any(GetFeaturesOutput.class), Matchers.anyShort());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) Test(org.junit.Test)

Aggregations

HelloMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)15 Test (org.junit.Test)13 GetFeaturesInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput)6 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)4 HelloMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage)4 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)2 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)2 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)2 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)2 GetFeaturesOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder)2 HelloInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput)2 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 PacketInMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Elements (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)1