Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
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; |
| 20 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 21 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 22 | |
| 23 | import java.util.List; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Represents to provider facing side of a switch. |
| 27 | */ |
| 28 | public interface OpenFlowSwitch { |
| 29 | |
| 30 | /** |
| 31 | * Writes the message to the driver. |
| 32 | * |
| 33 | * @param msg the message to write |
| 34 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 35 | void sendMsg(OFMessage msg); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
Saurav Das | fa2fa93 | 2015-03-03 11:29:48 -0800 | [diff] [blame] | 38 | * Writes the OFMessage list to the driver. |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 39 | * |
| 40 | * @param msgs the messages to be written |
| 41 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 42 | void sendMsg(List<OFMessage> msgs); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Handle a message from the switch. |
| 46 | * @param fromSwitch the message to handle |
| 47 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 48 | void handleMessage(OFMessage fromSwitch); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Sets the role for this switch. |
| 52 | * @param role the role to set. |
| 53 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 54 | void setRole(RoleState role); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Fetch the role for this switch. |
| 58 | * @return the role. |
| 59 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 60 | RoleState getRole(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Fetches the ports of this switch. |
| 64 | * @return unmodifiable list of the ports. |
| 65 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 66 | List<OFPortDesc> getPorts(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Provides the factory for this OF version. |
| 70 | * @return OF version specific factory. |
| 71 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 72 | OFFactory factory(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Gets a string version of the ID for this switch. |
| 76 | * |
| 77 | * @return string version of the ID |
| 78 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 79 | String getStringId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Gets the datapathId of the switch. |
| 83 | * |
| 84 | * @return the switch dpid in long format |
| 85 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 86 | long getId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * fetch the manufacturer description. |
| 90 | * @return the description |
| 91 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 92 | String manufacturerDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * fetch the datapath description. |
| 96 | * @return the description |
| 97 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 98 | String datapathDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * fetch the hardware description. |
| 102 | * @return the description |
| 103 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 104 | String hardwareDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * fetch the software description. |
| 108 | * @return the description |
| 109 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 110 | String softwareDescription(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * fetch the serial number. |
| 114 | * @return the serial |
| 115 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 116 | String serialNumber(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
Yuta HIGUCHI | 69a2735 | 2014-10-31 15:48:37 -0700 | [diff] [blame] | 119 | * Checks if the switch is still connected. |
| 120 | * |
| 121 | * @return whether the switch is still connected |
| 122 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 123 | boolean isConnected(); |
Yuta HIGUCHI | 69a2735 | 2014-10-31 15:48:37 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 126 | * Disconnects the switch by closing the TCP connection. Results in a call |
| 127 | * to the channel handler's channelDisconnected method for cleanup |
| 128 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 129 | void disconnectSwitch(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 130 | |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 131 | /** |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 132 | * 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] | 133 | * |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 134 | * @param requested the role requested by the controller |
| 135 | * @param response the role set at the device |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 136 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 137 | void returnRoleReply(RoleState requested, RoleState response); |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 140 | * Returns the switch device type. |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 141 | * |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 142 | * @return device type |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 143 | */ |
Marc De Leenheer | b931137 | 2015-07-09 11:36:49 -0700 | [diff] [blame] | 144 | Device.Type deviceType(); |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 145 | |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 146 | /** |
| 147 | * Identifies the channel used to communicate with the switch. |
Ray Milkey | f25d135 | 2015-01-23 15:14:08 -0800 | [diff] [blame] | 148 | * |
| 149 | * @return string representation of the connection to the device |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 150 | */ |
Sho SHIMIZU | 358815c | 2015-05-13 11:25:32 -0700 | [diff] [blame] | 151 | String channelId(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 152 | } |