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