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.ArrayDeque;
12 import java.util.Deque;
14 import org.opendaylight.openflowjava.util.ByteBufUtils;
17 * Class for providing prepared handshake scenario
19 * @author michal.polkorab
21 public final class ScenarioFactory {
23 private ScenarioFactory() {
24 throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
28 * Creates stack with handshake needed messages.
29 * <ol> XID of messages:
30 * <li> hello sent - 00000001
31 * <li> hello waiting - 00000002
32 * <li> featuresrequest waiting - 00000003
33 * <li> featuresreply sent - 00000003
35 * @return stack filled with Handshake messages
37 public static Deque<ClientEvent> createHandshakeScenario() {
38 Deque<ClientEvent> stack = new ArrayDeque<>();
39 stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
40 stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
41 stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
42 stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
43 + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03")));
48 * Creates stack with handshake needed messages.
49 * <ol> XID of messages:
50 * <li> hello sent - 00000001
51 * <li> hello waiting - 00000002
52 * <li> featuresrequest waiting - 00000003
53 * <li> featuresreply sent - 00000003
55 * @param auxiliaryId auxiliaryId wanted in featuresReply message
56 * @return stack filled with Handshake messages (featuresReply with auxiliaryId set)
58 public static Deque<ClientEvent> createHandshakeScenarioWithAuxiliaryId(byte auxiliaryId) {
59 Deque<ClientEvent> queue = new ArrayDeque<>();
60 queue.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
61 queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
62 queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
63 queue.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
64 + "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")));