Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.drivers.bmv2; |
| 18 | |
Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 19 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 20 | import org.onosproject.net.packet.OutboundPacket; |
| 21 | import org.onosproject.net.packet.PacketProgrammable; |
| 22 | |
Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 23 | /** |
| 24 | * Packet Programmable behaviour for BMv2 devices. |
| 25 | */ |
| 26 | public class Bmv2PacketProgrammable extends AbstractHandlerBehaviour implements PacketProgrammable { |
Carmelo Cascone | 59f57de | 2017-07-11 19:55:09 -0400 | [diff] [blame] | 27 | |
Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 28 | @Override |
| 29 | public void emit(OutboundPacket packet) { |
Carmelo Cascone | 59f57de | 2017-07-11 19:55:09 -0400 | [diff] [blame] | 30 | // TODO: implement using P4runtime client. |
| 31 | // DriverHandler handler = handler(); |
| 32 | // GrpcController controller = handler.get(GrpcController.class); |
| 33 | // DeviceId deviceId = handler.data().deviceId(); |
| 34 | // GrpcChannelId channelId = GrpcChannelId.of(deviceId, "bmv2"); |
| 35 | // GrpcServiceId serviceId = GrpcServiceId.of(channelId, "p4runtime"); |
| 36 | // GrpcStreamObserverId observerId = GrpcStreamObserverId.of(serviceId, |
| 37 | // this.getClass().getSimpleName()); |
| 38 | // Optional<GrpcObserverHandler> manager = controller.getObserverManager(observerId); |
| 39 | // if (!manager.isPresent()) { |
| 40 | // //this is the first time the behaviour is called |
| 41 | // controller.addObserver(observerId, new Bmv2PacketInObserverHandler()); |
| 42 | // } |
| 43 | // //other already registered the observer for us. |
| 44 | // Optional<StreamObserver> observer = manager.get().requestStreamObserver(); |
| 45 | // observer.ifPresent(objectStreamObserver -> objectStreamObserver.onNext(packet)); |
Andrea Campanella | 378e21a | 2017-06-07 12:09:59 +0200 | [diff] [blame] | 46 | } |
| 47 | } |