2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.it;
10 import java.util.Stack;
12 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
13 import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent;
14 import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;
15 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
18 * provisioning of most common scenarios used by testing of integration between OFLibrary, OFPlugin and MD-SAL
20 public abstract class ScenarioFactory {
22 /** version bitmap hex-string containing version 1.3 */
23 public static final String VERSION_BITMAP_13 = "00 01 00 08 00 00 00 10";
24 /** version bitmap hex-string containing versions: 1.0 + 1.3 */
25 public static final String VERSION_BITMAP_10_13 = "00 01 00 08 00 00 00 12";
28 * Creates stack with handshake needed messages.
29 * <ol> XID of messages:
30 * <li> hello sent - 00000001
31 * <li> hello waiting - 00000015
32 * <li> featuresrequest waiting - 00000002
33 * <li> featuresreply sent - 00000002
35 * @param switchVersionBitmap
37 * @param pluginVersionBitmap
38 * @return stack filled with Handshake messages
40 public static Stack<ClientEvent> createHandshakeScenarioVBM(
41 String switchVersionBitmap, short auxId, String pluginVersionBitmap) {
42 Stack<ClientEvent> stack = new Stack<>();
44 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 01 "
45 + switchVersionBitmap)));
46 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 "
47 + pluginVersionBitmap)));
48 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
49 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes(
50 "04 06 00 20 00 00 00 02 "
51 + "00 01 02 03 04 05 06 07 "
53 + Integer.toHexString(auxId)
54 + " 00 00 00 01 02 03 00 01 02 03")));
60 * @param pluginVersionBitmap
61 * @return handshake scenario without switch version bitmap
63 public static Stack<ClientEvent> createHandshakeScenario(short auxId, String pluginVersionBitmap) {
64 Stack<ClientEvent> stack = new Stack<>();
66 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
67 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 "
68 + pluginVersionBitmap)));
69 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
70 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes(
71 "04 06 00 20 00 00 00 02 "
72 + "00 01 02 03 04 05 06 07 "
74 + Integer.toHexString(auxId)
75 + " 00 00 00 01 02 03 00 01 02 03")));