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.device.listener;
10 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
11 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
12 import org.opendaylight.openflowplugin.api.openflow.device.listener.OpenflowMessageListenerFacade;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
28 public class OpenflowProtocolListenerFullImpl implements OpenflowMessageListenerFacade {
30 private static final Logger LOG = LoggerFactory.getLogger(OpenflowProtocolListenerFullImpl.class);
32 private final ConnectionAdapter connectionAdapter;
33 private final DeviceReplyProcessor deviceReplyProcessor;
36 * @param connectionAdapter
37 * @param deviceReplyProcessor
39 public OpenflowProtocolListenerFullImpl(final ConnectionAdapter connectionAdapter, final DeviceReplyProcessor deviceReplyProcessor) {
40 this.connectionAdapter = connectionAdapter;
41 this.deviceReplyProcessor = deviceReplyProcessor;
45 public void onEchoRequestMessage(final EchoRequestMessage echoRequestMessage) {
46 LOG.debug("echo request received: {}", echoRequestMessage.getXid());
47 final EchoReplyInputBuilder builder = new EchoReplyInputBuilder();
48 builder.setVersion(echoRequestMessage.getVersion());
49 builder.setXid(echoRequestMessage.getXid());
50 builder.setData(echoRequestMessage.getData());
52 connectionAdapter.echoReply(builder.build());
56 public void onErrorMessage(final ErrorMessage notification) {
57 deviceReplyProcessor.processReply(notification);
61 public void onExperimenterMessage(final ExperimenterMessage notification) {
62 LOG.trace("Received experiementer message: {}", notification.getClass());
63 deviceReplyProcessor.processExperimenterMessage(notification);
67 public void onFlowRemovedMessage(final FlowRemovedMessage notification) {
68 deviceReplyProcessor.processFlowRemovedMessage(notification);
72 public void onHelloMessage(final HelloMessage hello) {
73 LOG.warn("hello message received outside handshake phase -> dropping connection {}", connectionAdapter.getRemoteAddress());
74 connectionAdapter.disconnect();
78 public void onMultipartReplyMessage(final MultipartReplyMessage notification) {
79 LOG.trace("Multipart Reply with XID: {}", notification.getXid());
80 // multiMsgCollector.addMultipartMsg(notification);
84 public void onPacketInMessage(final PacketInMessage notification) {
85 deviceReplyProcessor.processPacketInMessage(notification);
89 public void onPortStatusMessage(final PortStatusMessage notification) {
90 deviceReplyProcessor.processPortStatusMessage(notification);