Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.openflow.controller; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 17 | |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 18 | import org.onosproject.net.Device; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 19 | import org.projectfloodlight.openflow.protocol.OFFactory; |
Laszlo Papp | edadbe2 | 2017-12-14 20:05:49 +0000 | [diff] [blame] | 20 | import org.projectfloodlight.openflow.protocol.OFFeaturesReply; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 21 | import org.projectfloodlight.openflow.protocol.OFMessage; |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 22 | import org.projectfloodlight.openflow.protocol.OFMeterFeatures; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 23 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 24 | |
| 25 | import java.util.List; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Represents to provider facing side of a switch. |
| 29 | */ |
| 30 | public interface OpenFlowSwitch { |
| 31 | |
| 32 | /** |
| 33 | * Writes the message to the driver. |
Brian O'Connor | e755caa | 2015-11-16 16:43:09 -0800 | [diff] [blame] | 34 | * <p> |
| 35 | * Note: Messages may be silently dropped/lost due to IOExceptions or |
| 36 | * role. If this is a concern, then a caller should use barriers. |
| 37 | * </p> |
Charles Chan | 5b7ec34 | 2015-10-18 20:55:41 -0700 | [diff] [blame] | 38 | * |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 39 | * @param msg the message to write |
| 40 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 41 | void sendMsg(OFMessage msg); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
Saurav Das | fa2fa93 | 2015-03-03 11:29:48 -0800 | [diff] [blame] | 44 | * Writes the OFMessage list to the driver. |
Brian O'Connor | e755caa | 2015-11-16 16:43:09 -0800 | [diff] [blame] | 45 | * <p> |
| 46 | * Note: Messages may be silently dropped/lost due to IOExceptions or |
| 47 | * role. If this is a concern, then a caller should use barriers. |
| 48 | * </p> |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 49 | * |
| 50 | * @param msgs the messages to be written |
| 51 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 52 | void sendMsg(List<OFMessage> msgs); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Handle a message from the switch. |
| 56 | * @param fromSwitch the message to handle |
| 57 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 58 | void handleMessage(OFMessage fromSwitch); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Sets the role for this switch. |
| 62 | * @param role the role to set. |
| 63 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 64 | void setRole(RoleState role); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Fetch the role for this switch. |
| 68 | * @return the role. |
| 69 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 70 | RoleState getRole(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Fetches the ports of this switch. |
| 74 | * @return unmodifiable list of the ports. |
| 75 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 76 | List<OFPortDesc> getPorts(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
Jordi Ortiz | aa8de49 | 2016-12-01 00:21:36 +0100 | [diff] [blame] | 79 | * Fetches the meter features of this switch. |
| 80 | * @return unmodifiable meter features |
| 81 | */ |
| 82 | OFMeterFeatures getMeterFeatures(); |
| 83 | |
| 84 | /** |
Laszlo Papp | edadbe2 | 2017-12-14 20:05:49 +0000 | [diff] [blame] | 85 | * Fetches the features of this switch. |
| 86 | * @return unmodifiable features |
| 87 | */ |
| 88 | default OFFeaturesReply features() { |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 93 | * Provides the factory for this OF version. |
| 94 | * @return OF version specific factory. |
| 95 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 96 | OFFactory factory(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Gets a string version of the ID for this switch. |
| 100 | * |
| 101 | * @return string version of the ID |
| 102 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 103 | String getStringId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * Gets the datapathId of the switch. |
| 107 | * |
| 108 | * @return the switch dpid in long format |
| 109 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 110 | long getId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
Yuta HIGUCHI | 6ee6b8c | 2017-05-09 14:44:30 -0700 | [diff] [blame] | 113 | * Gets the datapathId of the switch. |
| 114 | * |
| 115 | * @return the switch dpid |
| 116 | */ |
| 117 | default Dpid getDpid() { |
| 118 | return new Dpid(getId()); |
| 119 | } |
| 120 | |
| 121 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 122 | * fetch the manufacturer description. |
| 123 | * @return the description |
| 124 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 125 | String manufacturerDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 126 | |
| 127 | /** |
| 128 | * fetch the datapath description. |
| 129 | * @return the description |
| 130 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 131 | String datapathDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * fetch the hardware description. |
| 135 | * @return the description |
| 136 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 137 | String hardwareDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * fetch the software description. |
| 141 | * @return the description |
| 142 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 143 | String softwareDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * fetch the serial number. |
| 147 | * @return the serial |
| 148 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 149 | String serialNumber(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 150 | |
| 151 | /** |
Yuta HIGUCHI | 69a2735 | 2014-10-31 15:48:37 -0700 | [diff] [blame] | 152 | * Checks if the switch is still connected. |
| 153 | * |
| 154 | * @return whether the switch is still connected |
| 155 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 156 | boolean isConnected(); |
Yuta HIGUCHI | 69a2735 | 2014-10-31 15:48:37 -0700 | [diff] [blame] | 157 | |
| 158 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 159 | * Disconnects the switch by closing the TCP connection. Results in a call |
| 160 | * to the channel handler's channelDisconnected method for cleanup |
| 161 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 162 | void disconnectSwitch(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 163 | |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 164 | /** |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 165 | * Notifies the controller that the device has responded to a set-role request. |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 166 | * |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 167 | * @param requested the role requested by the controller |
| 168 | * @param response the role set at the device |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 169 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 170 | void returnRoleReply(RoleState requested, RoleState response); |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 171 | |
| 172 | /** |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 173 | * Returns the switch device type. |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 174 | * |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 175 | * @return device type |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 176 | */ |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 177 | Device.Type deviceType(); |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 178 | |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 179 | /** |
| 180 | * Identifies the channel used to communicate with the switch. |
Ray Milkey | f25d135 | 2015-01-23 15:14:08 -0800 | [diff] [blame] | 181 | * |
| 182 | * @return string representation of the connection to the device |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 183 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 184 | String channelId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 185 | } |