blob: 1b6810bee9654a765ed26a0073f0e9b555023530 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.openflow.controller;
tom7ef8ff92014-09-17 13:08:06 -070017
Marc De Leenheerb9311372015-07-09 11:36:49 -070018import org.onosproject.net.Device;
tom7ef8ff92014-09-17 13:08:06 -070019import org.projectfloodlight.openflow.protocol.OFFactory;
20import org.projectfloodlight.openflow.protocol.OFMessage;
21import org.projectfloodlight.openflow.protocol.OFPortDesc;
alshabibb452fd72015-04-22 20:46:20 -070022
23import java.util.List;
tom7ef8ff92014-09-17 13:08:06 -070024
25/**
26 * Represents to provider facing side of a switch.
27 */
28public interface OpenFlowSwitch {
29
30 /**
31 * Writes the message to the driver.
32 *
33 * @param msg the message to write
34 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070035 void sendMsg(OFMessage msg);
tom7ef8ff92014-09-17 13:08:06 -070036
37 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080038 * Writes the OFMessage list to the driver.
tom7ef8ff92014-09-17 13:08:06 -070039 *
40 * @param msgs the messages to be written
41 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070042 void sendMsg(List<OFMessage> msgs);
tom7ef8ff92014-09-17 13:08:06 -070043
44 /**
45 * Handle a message from the switch.
46 * @param fromSwitch the message to handle
47 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070048 void handleMessage(OFMessage fromSwitch);
tom7ef8ff92014-09-17 13:08:06 -070049
50 /**
51 * Sets the role for this switch.
52 * @param role the role to set.
53 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070054 void setRole(RoleState role);
tom7ef8ff92014-09-17 13:08:06 -070055
56 /**
57 * Fetch the role for this switch.
58 * @return the role.
59 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070060 RoleState getRole();
tom7ef8ff92014-09-17 13:08:06 -070061
62 /**
63 * Fetches the ports of this switch.
64 * @return unmodifiable list of the ports.
65 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070066 List<OFPortDesc> getPorts();
tom7ef8ff92014-09-17 13:08:06 -070067
68 /**
69 * Provides the factory for this OF version.
70 * @return OF version specific factory.
71 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070072 OFFactory factory();
tom7ef8ff92014-09-17 13:08:06 -070073
74 /**
75 * Gets a string version of the ID for this switch.
76 *
77 * @return string version of the ID
78 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070079 String getStringId();
tom7ef8ff92014-09-17 13:08:06 -070080
81 /**
82 * Gets the datapathId of the switch.
83 *
84 * @return the switch dpid in long format
85 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070086 long getId();
tom7ef8ff92014-09-17 13:08:06 -070087
88 /**
89 * fetch the manufacturer description.
90 * @return the description
91 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070092 String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -070093
94 /**
95 * fetch the datapath description.
96 * @return the description
97 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -070098 String datapathDescription();
tom7ef8ff92014-09-17 13:08:06 -070099
100 /**
101 * fetch the hardware description.
102 * @return the description
103 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700104 String hardwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700105
106 /**
107 * fetch the software description.
108 * @return the description
109 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700110 String softwareDescription();
tom7ef8ff92014-09-17 13:08:06 -0700111
112 /**
113 * fetch the serial number.
114 * @return the serial
115 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700116 String serialNumber();
tom7ef8ff92014-09-17 13:08:06 -0700117
118 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700119 * Checks if the switch is still connected.
120 *
121 * @return whether the switch is still connected
122 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700123 boolean isConnected();
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700124
125 /**
tom7ef8ff92014-09-17 13:08:06 -0700126 * Disconnects the switch by closing the TCP connection. Results in a call
127 * to the channel handler's channelDisconnected method for cleanup
128 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700129 void disconnectSwitch();
tom7ef8ff92014-09-17 13:08:06 -0700130
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700131 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700132 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700133 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700134 * @param requested the role requested by the controller
135 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700136 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700137 void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700138
139 /**
Marc De Leenheerb9311372015-07-09 11:36:49 -0700140 * Returns the switch device type.
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700141 *
Marc De Leenheerb9311372015-07-09 11:36:49 -0700142 * @return device type
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700143 */
Marc De Leenheerb9311372015-07-09 11:36:49 -0700144 Device.Type deviceType();
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700145
Ray Milkeye53f1712015-01-16 09:17:16 -0800146 /**
147 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800148 *
149 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800150 */
Sho SHIMIZU358815c2015-05-13 11:25:32 -0700151 String channelId();
tom7ef8ff92014-09-17 13:08:06 -0700152}