X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FBufferHelper.java;h=aac10dab7fb5705aa7526884e54c3c0548fd37f0;hb=608331f22077157e3d006e336313ed6323a91e56;hp=a125764f97e1cce81ff6eae9932501332f12bb4b;hpb=b0c862db7ff00227cc2f1bf23fad7b4c96d08493;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index a125764f..aac10dab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -65,7 +65,17 @@ public abstract class BufferHelper { * @param length expected length of message in header */ public static void checkHeaderV13(ByteBuf input, byte msgType, int length) { - checkHeader(input, msgType, length, HelloMessageFactoryTest.VERSION_YET_SUPPORTED); + checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID); + } + + /** + * Use version 1.0 for encoded message + * @param input ByteBuf to be checked for correct OpenFlow Protocol header + * @param msgType type of received message + * @param length expected length of message in header + */ + public static void checkHeaderV10(ByteBuf input, byte msgType, int length) { + checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID); } private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) { @@ -80,7 +90,14 @@ public abstract class BufferHelper { * @param ofHeader OpenFlow protocol header */ public static void checkHeaderV13(OfHeader ofHeader) { - checkHeader(ofHeader, HelloMessageFactoryTest.VERSION_YET_SUPPORTED); + checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID); + } + + /** + * @param ofHeader OpenFlow protocol header + */ + public static void checkHeaderV10(OfHeader ofHeader) { + checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID); } private static void checkHeader(OfHeader ofHeader, Short version) { @@ -90,15 +107,16 @@ public abstract class BufferHelper { /** * @param builder + * @param version wire protocol number used * @throws NoSuchMethodException * @throws SecurityException * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException */ - public static void setupHeader(Object builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Method m = builder.getClass().getMethod("setVersion", Short.class); - m.invoke(builder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED); + m.invoke(builder, (short) version); Method m2 = builder.getClass().getMethod("setXid", Long.class); m2.invoke(builder, BufferHelper.DEFAULT_XID); } @@ -110,7 +128,17 @@ public abstract class BufferHelper { * @return message decoded pojo */ public static E decodeV13(OFDeserializer decoder, ByteBuf bb) { - return bufferToMessage(decoder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED, bb); + return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb); + } + + /** + * Use version 1.0 for decoding message + * @param decoder decoder instance + * @param bb data input buffer + * @return message decoded pojo + */ + public static E decodeV10(OFDeserializer decoder, ByteBuf bb) { + return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb); } private static E bufferToMessage(OFDeserializer decoder, short version, ByteBuf bb) {