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();
}
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();
}
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);
}
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;
}
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());
}
Aggregations