blob: 80d9c1038938a4d95aaa6acc447131932d7cdc4c [file] [log] [blame]
Carmelo Cascone37d5dbf2016-04-18 15:15:48 -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
Carmelo Casconee4da9092016-04-26 12:14:08 -070019import org.onlab.util.ImmutableByteSequence;
20
Carmelo Cascone37d5dbf2016-04-18 15:15:48 -070021import java.util.Collection;
22
23/**
24 * RPC client to control a BMv2 device.
25 */
26public interface Bmv2Client {
27 /**
28 * Adds a new table entry.
29 *
30 * @param entry a table entry value
31 * @return table-specific entry ID
32 * @throws Bmv2RuntimeException if any error occurs
33 */
34 long addTableEntry(Bmv2TableEntry entry) throws Bmv2RuntimeException;
35
36 /**
37 * Modifies a currently installed entry by updating its action.
38 *
39 * @param tableName string value of table name
40 * @param entryId long value of entry ID
41 * @param action an action value
42 * @throws Bmv2RuntimeException if any error occurs
43 */
44 void modifyTableEntry(String tableName,
45 long entryId, Bmv2Action action)
46 throws Bmv2RuntimeException;
47
48 /**
49 * Deletes currently installed entry.
50 *
51 * @param tableName string value of table name
52 * @param entryId long value of entry ID
53 * @throws Bmv2RuntimeException if any error occurs
54 */
55 void deleteTableEntry(String tableName,
56 long entryId) throws Bmv2RuntimeException;
57
58 /**
59 * Sets table default action.
60 *
61 * @param tableName string value of table name
62 * @param action an action value
63 * @throws Bmv2RuntimeException if any error occurs
64 */
65 void setTableDefaultAction(String tableName, Bmv2Action action)
66 throws Bmv2RuntimeException;
67
68 /**
69 * Returns information of the ports currently configured in the switch.
70 *
71 * @return collection of port information
72 * @throws Bmv2RuntimeException if any error occurs
73 */
74 Collection<Bmv2PortInfo> getPortsInfo() throws Bmv2RuntimeException;
75
76 /**
77 * Return a string representation of a table content.
78 *
79 * @param tableName string value of table name
80 * @return table string dump
81 * @throws Bmv2RuntimeException if any error occurs
82 */
83 String dumpTable(String tableName) throws Bmv2RuntimeException;
84
85 /**
Carmelo Casconee4da9092016-04-26 12:14:08 -070086 * Requests the device to transmit a given byte sequence over the given port.
87 *
88 * @param portNumber a port number
89 * @param packet a byte sequence
90 * @throws Bmv2RuntimeException
91 */
92 void transmitPacket(int portNumber, ImmutableByteSequence packet) throws Bmv2RuntimeException;
93
94 /**
Carmelo Cascone37d5dbf2016-04-18 15:15:48 -070095 * Reset the state of the switch (e.g. delete all entries, etc.).
96 *
97 * @throws Bmv2RuntimeException if any error occurs
98 */
99 void resetState() throws Bmv2RuntimeException;
100}