blob: 672529eece02fe2b34af47cd253c900c581a7f0e [file] [log] [blame]
Carmelo Casconee4da9092016-04-26 12:14:08 -07001/*
2 * Copyright 2016-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
17package org.onosproject.bmv2.api.runtime;
18
19import org.onlab.util.ImmutableByteSequence;
20
21/**
22 * A server that listens for requests from a BMv2 device.
23 */
24public interface Bmv2ControlPlaneServer {
25 /**
26 * Default listening port.
27 */
28 int DEFAULT_PORT = 40123;
29
30 /**
31 * Register the given hello listener, to be called each time a hello message is received from a BMv2 device.
32 *
33 * @param listener a hello listener
34 */
35 void addHelloListener(HelloListener listener);
36
37 /**
38 * Unregister the given hello listener.
39 *
40 * @param listener a hello listener
41 */
42 void removeHelloListener(HelloListener listener);
43
44 /**
45 * Register the given packet listener, to be called each time a packet-in message is received from a BMv2 device.
46 *
47 * @param listener a packet listener
48 */
49 void addPacketListener(PacketListener listener);
50
51 /**
52 * Unregister the given packet listener.
53 *
54 * @param listener a packet listener
55 */
56 void removePacketListener(PacketListener listener);
57
58 interface HelloListener {
59
60 /**
61 * Handles a hello message.
62 *
63 * @param device the BMv2 device that originated the message
64 */
65 void handleHello(Bmv2Device device);
66 }
67
68 interface PacketListener {
69
70 /**
71 * Handles a packet-in message.
72 *
73 * @param device the BMv2 device that originated the message
74 * @param inputPort the device port where the packet was received
75 * @param reason a reason code
76 * @param tableId the table id that originated this packet-in
77 * @param contextId the context id where the packet-in was originated
78 * @param packet the packet body
79 */
80 void handlePacketIn(Bmv2Device device, int inputPort, long reason, int tableId, int contextId,
81 ImmutableByteSequence packet);
82 }
83}