8581d4a9da64894c59a84e70544043ea67e1e9d9
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / DataPacketAdapter.xtend
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.compatibility
9
10 import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived
13 import org.opendaylight.controller.sal.packet.RawPacket
14
15 class DataPacketAdapter implements PacketProcessingListener {
16
17     @Property
18     IPluginOutDataPacketService dataPacketPublisher;
19
20     override onPacketReceived(PacketReceived packet) {
21         val RawPacket inPacket = packet.toRawPacket();
22         dataPacketPublisher.receiveDataPacket(inPacket);
23     }
24
25     public static def RawPacket toRawPacket(PacketReceived received) {        
26         val ret = new RawPacket(received.payload);
27         ret.setIncomingNodeConnector(NodeMapping.toADNodeConnector(received.ingress))
28         return ret;
29     }
30
31 }