2 * Copyright (c) 2015 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.impl.connection.listener;
10 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
11 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
12 import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeListener;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
20 public class HandshakeListenerImpl implements HandshakeListener {
22 private static final Logger LOG = LoggerFactory.getLogger(HandshakeListenerImpl.class);
24 private ConnectionContext connectionContext;
25 private DeviceConnectedHandler deviceConnectedHandler;
28 * @param connectionContext
29 * @param deviceConnectedHandler
31 public HandshakeListenerImpl(ConnectionContext connectionContext, DeviceConnectedHandler deviceConnectedHandler) {
32 this.connectionContext = connectionContext;
33 this.deviceConnectedHandler = deviceConnectedHandler;
37 public void onHandshakeSuccessfull(GetFeaturesOutput featureOutput, Short version) {
38 connectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.WORKING);
39 connectionContext.setFeatures(featureOutput);
40 deviceConnectedHandler.deviceConnected(connectionContext);
44 public void onHandshakeFailure() {
45 LOG.info("handshake failed: {}", connectionContext.getConnectionAdapter().getRemoteAddress());
46 connectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.RIP);
47 // TODO ensure that connection is closed