* @param length expected length of message in header\r
*/\r
public static void checkHeaderV13(ByteBuf input, byte msgType, int length) {\r
- checkHeader(input, msgType, length, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+ checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID);\r
+ }\r
+ \r
+ /**\r
+ * Use version 1.0 for encoded message\r
+ * @param input ByteBuf to be checked for correct OpenFlow Protocol header\r
+ * @param msgType type of received message\r
+ * @param length expected length of message in header\r
+ */\r
+ public static void checkHeaderV10(ByteBuf input, byte msgType, int length) {\r
+ checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID);\r
}\r
\r
private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) {\r
* @param ofHeader OpenFlow protocol header\r
*/\r
public static void checkHeaderV13(OfHeader ofHeader) {\r
- checkHeader(ofHeader, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+ checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID);\r
+ }\r
+ \r
+ /**\r
+ * @param ofHeader OpenFlow protocol header\r
+ */\r
+ public static void checkHeaderV10(OfHeader ofHeader) {\r
+ checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID);\r
}\r
\r
private static void checkHeader(OfHeader ofHeader, Short version) {\r
\r
/**\r
* @param builder\r
+ * @param version wire protocol number used\r
* @throws NoSuchMethodException\r
* @throws SecurityException\r
* @throws IllegalAccessException\r
* @throws IllegalArgumentException\r
* @throws InvocationTargetException\r
*/\r
- public static void setupHeader(Object builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\r
+ public static void setupHeader(Object builder, int version) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\r
Method m = builder.getClass().getMethod("setVersion", Short.class);\r
- m.invoke(builder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED);\r
+ m.invoke(builder, (short) version);\r
Method m2 = builder.getClass().getMethod("setXid", Long.class);\r
m2.invoke(builder, BufferHelper.DEFAULT_XID);\r
}\r
* @return message decoded pojo\r
*/\r
public static <E extends DataObject> E decodeV13(OFDeserializer<E> decoder, ByteBuf bb) {\r
- return bufferToMessage(decoder, HelloMessageFactoryTest.VERSION_YET_SUPPORTED, bb);\r
+ return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb);\r
+ }\r
+ \r
+ /**\r
+ * Use version 1.0 for decoding message\r
+ * @param decoder decoder instance\r
+ * @param bb data input buffer\r
+ * @return message decoded pojo\r
+ */\r
+ public static <E extends DataObject> E decodeV10(OFDeserializer<E> decoder, ByteBuf bb) {\r
+ return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb);\r
}\r
\r
private static <E extends DataObject> E bufferToMessage(OFDeserializer<E> decoder, short version, ByteBuf bb) {\r