Wrap service handlers to method handleServiceCall.
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / PacketProcessingServiceImpl.java
1 /**
2  * Copyright (c) 2015 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.openflowplugin.impl.services;
9
10 import java.math.BigInteger;
11 import java.util.concurrent.Future;
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
17 import org.opendaylight.yangtools.yang.common.RpcResult;
18
19 public class PacketProcessingServiceImpl extends CommonService implements PacketProcessingService {
20
21     @Override
22     //TODO this implementation is incorrect. Handling of exceptional states as in ServiceCallProcessingUtil.handleServiceCall() is missing
23     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
24         final PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, deviceContext.getNextXid()
25                 .getValue(), datapathId);
26
27         BigInteger connectionID = PRIMARY_CONNECTION;
28         final ConnectionCookie connectionCookie = input.getConnectionCookie();
29         if (connectionCookie != null && connectionCookie.getValue() != null) {
30             connectionID = BigInteger.valueOf(connectionCookie.getValue());
31         }
32
33         return provideConnectionAdapter(connectionID).packetOut(message);
34     }
35 }