Move adsal into its own subdirectory.
[controller.git] / opendaylight / adsal / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / DataPacketServices.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11
12 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15 import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
16 import org.opendaylight.controller.sal.core.NodeConnector;
17 import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
18 import org.opendaylight.controller.sal.packet.RawPacket;
19
20 public class DataPacketServices implements IPluginInDataPacketService {
21     protected static final Logger logger = LoggerFactory
22             .getLogger(DataPacketServices.class);
23     private IDataPacketMux iDataPacketMux = null;
24     private IPluginOutConnectionService connectionOutService;
25
26     void setIDataPacketMux(IDataPacketMux s) {
27         this.iDataPacketMux = s;
28     }
29
30     void unsetIDataPacketMux(IDataPacketMux s) {
31         if (this.iDataPacketMux == s) {
32             this.iDataPacketMux = null;
33         }
34     }
35
36     void setIPluginOutConnectionService(IPluginOutConnectionService s) {
37         connectionOutService = s;
38     }
39
40     void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
41         if (connectionOutService == s) {
42             connectionOutService = null;
43         }
44     }
45
46     @Override
47     public void transmitDataPacket(RawPacket outPkt) {
48         NodeConnector nc = outPkt.getOutgoingNodeConnector();
49         if (connectionOutService != null && connectionOutService.isLocal(nc.getNode())) {
50             this.iDataPacketMux.transmitDataPacket(outPkt);
51         } else {
52             logger.debug("{} is dropped in the controller "+outPkt);
53         }
54     }
55 }