2 * Copyright (c) 2013 Pantheon Technologies s.r.o. 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
9 package org.opendaylight.openflowjava.protocol.impl.clients;
11 import java.util.Stack;
13 import org.opendaylight.openflowjava.util.ByteBufUtils;
16 * Class for providing prepared handshake scenario
18 * @author michal.polkorab
20 public final class ScenarioFactory {
22 private ScenarioFactory() {
23 throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
27 * Creates stack with handshake needed messages.
28 * <ol> XID of messages:
29 * <li> hello sent - 00000001
30 * <li> hello waiting - 00000002
31 * <li> featuresrequest waiting - 00000003
32 * <li> featuresreply sent - 00000003
34 * @return stack filled with Handshake messages
36 public static Stack<ClientEvent> createHandshakeScenario() {
37 Stack<ClientEvent> stack = new Stack<>();
38 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
39 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
40 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
41 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
42 + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03")));
47 * Creates stack with handshake needed messages.
48 * <ol> XID of messages:
49 * <li> hello sent - 00000001
50 * <li> hello waiting - 00000002
51 * <li> featuresrequest waiting - 00000003
52 * <li> featuresreply sent - 00000003
54 * @param auxiliaryId auxiliaryId wanted in featuresReply message
55 * @return stack filled with Handshake messages (featuresReply with auxiliaryId set)
57 public static Stack<ClientEvent> createHandshakeScenarioWithAuxiliaryId(byte auxiliaryId) {
58 Stack<ClientEvent> stack = new Stack<>();
59 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
60 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
61 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
62 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
63 + "00 01 02 03 04 05 06 07 00 01 02 03 01 " + String.format("%02x ", auxiliaryId) + " 00 00 00 01 02 03 00 01 02 03")));