746147bd73871aafa56f468d9aff1108d04ee84c
[controller.git] / opendaylight / md-sal / sal-compability / src / main / java / org / opendaylight / controller / sal / compability / adsal / DataPacketServiceAdapter.java
1 package org.opendaylight.controller.sal.compability.adsal;
2
3 import org.opendaylight.controller.sal.compability.NodeMapping;
4 import org.opendaylight.controller.sal.packet.*;
5 import org.opendaylight.controller.sal.packet.RawPacket;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.*;
8
9 public class DataPacketServiceAdapter implements IPluginInDataPacketService {
10
11     PacketProcessingService delegate;
12
13     @Override
14     public void transmitDataPacket(RawPacket outPkt) {
15         TransmitPacketInput packet = toTransmitPacketInput(outPkt);
16         delegate.transmitPacket(packet);
17     }
18
19     private TransmitPacketInput toTransmitPacketInput(RawPacket rawPacket) {
20         TransmitPacketInputBuilder builderTPIB = new TransmitPacketInputBuilder();
21
22         NodeConnectorRef egress = NodeMapping.toNodeConnectorRef(rawPacket.getOutgoingNodeConnector());
23         NodeConnectorRef ingress = NodeMapping.toNodeConnectorRef(rawPacket.getIncomingNodeConnector());
24         byte[] payload = rawPacket.getPacketData();
25
26         builderTPIB.setEgress(egress);
27         builderTPIB.setIngress(ingress);
28         builderTPIB.setPayload(payload);
29
30         return builderTPIB.build();
31     }
32
33 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.