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.protocol.impl.util.ByteBufUtils;
16 * Class for providing prepared handshake scenario
18 * @author michal.polkorab
20 public class ScenarioFactory {
23 * Creates stack with handshake needed messages.
24 * <ol> XID of messages:
25 * <li> hello sent - 00000001
26 * <li> hello waiting - 00000002
27 * <li> featuresrequest waiting - 00000003
28 * <li> featuresreply sent - 00000003
30 * @return stack filled with Handshake messages
32 public static Stack<ClientEvent> createHandshakeScenario() {
33 Stack<ClientEvent> stack = new Stack<>();
34 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
35 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
36 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
37 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
38 + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03")));
43 * Creates stack with handshake needed messages.
44 * <ol> XID of messages:
45 * <li> hello sent - 00000001
46 * <li> hello waiting - 00000002
47 * <li> featuresrequest waiting - 00000003
48 * <li> featuresreply sent - 00000003
50 * @param auxiliaryId auxiliaryId wanted in featuresReply message
51 * @return stack filled with Handshake messages (featuresReply with auxiliaryId set)
53 public static Stack<ClientEvent> createHandshakeScenarioWithAuxiliaryId(byte auxiliaryId) {
54 Stack<ClientEvent> stack = new Stack<>();
55 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
56 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
57 stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
58 stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
59 + "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")));