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 |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -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 |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -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 | */ |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 16 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 17 | package org.onosproject.openflow.controller.driver; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 18 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 19 | import org.jboss.netty.channel.Channel; |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 20 | import org.onlab.packet.IpAddress; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 21 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.openflow.controller.Dpid; |
| 23 | import org.onosproject.openflow.controller.RoleState; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 24 | import org.projectfloodlight.openflow.protocol.OFDescStatsReply; |
| 25 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
| 26 | import org.projectfloodlight.openflow.protocol.OFExperimenter; |
| 27 | import org.projectfloodlight.openflow.protocol.OFFactories; |
| 28 | import org.projectfloodlight.openflow.protocol.OFFactory; |
| 29 | import org.projectfloodlight.openflow.protocol.OFFeaturesReply; |
| 30 | import org.projectfloodlight.openflow.protocol.OFMessage; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 31 | import org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleRequest; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 32 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
| 33 | import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply; |
Thomas Vachuska | 3927446 | 2014-12-02 13:23:50 -0800 | [diff] [blame] | 34 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 35 | import org.projectfloodlight.openflow.protocol.OFRoleReply; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 36 | import org.projectfloodlight.openflow.protocol.OFRoleRequest; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 37 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 38 | import org.slf4j.Logger; |
| 39 | import org.slf4j.LoggerFactory; |
| 40 | |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 41 | import java.io.IOException; |
| 42 | import java.net.InetSocketAddress; |
| 43 | import java.net.SocketAddress; |
| 44 | import java.util.ArrayList; |
| 45 | import java.util.Collections; |
| 46 | import java.util.List; |
| 47 | import java.util.concurrent.atomic.AtomicInteger; |
| 48 | import java.util.stream.Collectors; |
| 49 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 50 | /** |
| 51 | * An abstract representation of an OpenFlow switch. Can be extended by others |
| 52 | * to serve as a base for their vendor specific representation of a switch. |
| 53 | */ |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 54 | public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour |
| 55 | implements OpenFlowSwitchDriver { |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 56 | |
Yuta HIGUCHI | f5416d8 | 2014-10-24 21:17:40 -0700 | [diff] [blame] | 57 | protected final Logger log = LoggerFactory.getLogger(getClass()); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 58 | |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 59 | private Channel channel; |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 60 | protected String channelId; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 61 | |
| 62 | private boolean connected; |
| 63 | protected boolean startDriverHandshakeCalled = false; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 64 | private Dpid dpid; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 65 | private OpenFlowAgent agent; |
| 66 | private final AtomicInteger xidCounter = new AtomicInteger(0); |
| 67 | |
| 68 | private OFVersion ofVersion; |
| 69 | |
Srikanth Vavilapalli | f5b234a | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 70 | protected List<OFPortDescStatsReply> ports = new ArrayList<>(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 71 | |
| 72 | protected boolean tableFull; |
| 73 | |
| 74 | private RoleHandler roleMan; |
| 75 | |
| 76 | protected RoleState role; |
| 77 | |
| 78 | protected OFFeaturesReply features; |
| 79 | protected OFDescStatsReply desc; |
| 80 | |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 81 | @Override |
| 82 | public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) { |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 83 | this.dpid = dpid; |
| 84 | this.desc = desc; |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 85 | this.ofVersion = ofv; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | //************************ |
| 89 | // Channel related |
| 90 | //************************ |
| 91 | |
| 92 | @Override |
| 93 | public final void disconnectSwitch() { |
| 94 | this.channel.close(); |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public final void sendMsg(OFMessage m) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 99 | if (role == RoleState.MASTER) { |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 100 | channel.write(Collections.singletonList(m)); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 101 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public final void sendMsg(List<OFMessage> msgs) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 106 | if (role == RoleState.MASTER) { |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 107 | channel.write(msgs); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 108 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Override |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 112 | public final void sendRoleRequest(OFMessage msg) { |
| 113 | if (msg instanceof OFRoleRequest || |
| 114 | msg instanceof OFNiciraControllerRoleRequest) { |
| 115 | channel.write(Collections.singletonList(msg)); |
| 116 | return; |
| 117 | } |
| 118 | throw new IllegalArgumentException("Someone is trying to send " + |
| 119 | "a non role request message"); |
| 120 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 121 | |
alshabib | a2df7b2a | 2015-05-06 13:57:10 -0700 | [diff] [blame] | 122 | public final void sendHandshakeMessage(OFMessage message) { |
| 123 | if (!this.isDriverHandshakeComplete()) { |
| 124 | channel.write(Collections.singletonList(message)); |
| 125 | } |
| 126 | } |
| 127 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 128 | @Override |
| 129 | public final boolean isConnected() { |
| 130 | return this.connected; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public final void setConnected(boolean connected) { |
| 135 | this.connected = connected; |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 136 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 137 | |
| 138 | @Override |
| 139 | public final void setChannel(Channel channel) { |
| 140 | this.channel = channel; |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 141 | final SocketAddress address = channel.getRemoteAddress(); |
| 142 | if (address instanceof InetSocketAddress) { |
| 143 | final InetSocketAddress inetAddress = (InetSocketAddress) address; |
| 144 | final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress()); |
Pavlin Radoslavov | 87dd930 | 2015-03-10 13:53:24 -0700 | [diff] [blame] | 145 | if (ipAddress.isIp4()) { |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 146 | channelId = ipAddress.toString() + ':' + inetAddress.getPort(); |
| 147 | } else { |
| 148 | channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort(); |
| 149 | } |
| 150 | } |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 151 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 152 | |
Ray Milkey | e53f171 | 2015-01-16 09:17:16 -0800 | [diff] [blame] | 153 | @Override |
| 154 | public String channelId() { |
| 155 | return channelId; |
| 156 | } |
| 157 | |
| 158 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 159 | //************************ |
| 160 | // Switch features related |
| 161 | //************************ |
| 162 | |
| 163 | @Override |
| 164 | public final long getId() { |
| 165 | return this.dpid.value(); |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 166 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 167 | |
| 168 | @Override |
| 169 | public final String getStringId() { |
| 170 | return this.dpid.toString(); |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public final void setOFVersion(OFVersion ofV) { |
| 175 | this.ofVersion = ofV; |
| 176 | } |
| 177 | |
| 178 | @Override |
| 179 | public void setTableFull(boolean full) { |
| 180 | this.tableFull = full; |
| 181 | } |
| 182 | |
| 183 | @Override |
| 184 | public void setFeaturesReply(OFFeaturesReply featuresReply) { |
| 185 | this.features = featuresReply; |
| 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public abstract Boolean supportNxRole(); |
| 190 | |
| 191 | //************************ |
| 192 | // Message handling |
| 193 | //************************ |
| 194 | /** |
| 195 | * Handle the message coming from the dataplane. |
| 196 | * |
| 197 | * @param m the actual message |
| 198 | */ |
| 199 | @Override |
| 200 | public final void handleMessage(OFMessage m) { |
Thomas Vachuska | 3927446 | 2014-12-02 13:23:50 -0800 | [diff] [blame] | 201 | if (this.role == RoleState.MASTER || m instanceof OFPortStatus) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 202 | this.agent.processMessage(dpid, m); |
| 203 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public RoleState getRole() { |
| 208 | return role; |
Thomas Vachuska | 1c681d7 | 2015-05-18 14:58:53 -0700 | [diff] [blame^] | 209 | } |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 210 | |
| 211 | @Override |
| 212 | public final boolean connectSwitch() { |
| 213 | return this.agent.addConnectedSwitch(dpid, this); |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public final boolean activateMasterSwitch() { |
| 218 | return this.agent.addActivatedMasterSwitch(dpid, this); |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public final boolean activateEqualSwitch() { |
| 223 | return this.agent.addActivatedEqualSwitch(dpid, this); |
| 224 | } |
| 225 | |
| 226 | @Override |
| 227 | public final void transitionToEqualSwitch() { |
| 228 | this.agent.transitionToEqualSwitch(dpid); |
| 229 | } |
| 230 | |
| 231 | @Override |
| 232 | public final void transitionToMasterSwitch() { |
| 233 | this.agent.transitionToMasterSwitch(dpid); |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public final void removeConnectedSwitch() { |
| 238 | this.agent.removeConnectedSwitch(dpid); |
| 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public OFFactory factory() { |
| 243 | return OFFactories.getFactory(ofVersion); |
| 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public void setPortDescReply(OFPortDescStatsReply portDescReply) { |
Srikanth Vavilapalli | f5b234a | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 248 | this.ports.add(portDescReply); |
| 249 | } |
| 250 | |
| 251 | @Override |
| 252 | public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) { |
| 253 | this.ports.addAll(portDescReplies); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | @Override |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 257 | public void returnRoleReply(RoleState requested, RoleState response) { |
| 258 | this.agent.returnRoleReply(dpid, requested, response); |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | @Override |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 262 | public abstract void startDriverHandshake(); |
| 263 | |
| 264 | @Override |
| 265 | public abstract boolean isDriverHandshakeComplete(); |
| 266 | |
| 267 | @Override |
| 268 | public abstract void processDriverHandshakeMessage(OFMessage m); |
| 269 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 270 | |
| 271 | // Role Handling |
| 272 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 273 | @Override |
| 274 | public void setRole(RoleState role) { |
| 275 | try { |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 276 | if (this.roleMan.sendRoleRequest(role, RoleRecvStatus.MATCHED_SET_ROLE)) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 277 | log.info("Sending role {} to switch {}", role, getStringId()); |
| 278 | if (role == RoleState.SLAVE || role == RoleState.EQUAL) { |
| 279 | this.role = role; |
| 280 | } |
alshabib | 7814e9f | 2014-09-30 11:52:12 -0700 | [diff] [blame] | 281 | } else { |
| 282 | this.role = role; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 283 | } |
| 284 | } catch (IOException e) { |
| 285 | log.error("Unable to write to switch {}.", this.dpid); |
| 286 | } |
| 287 | } |
| 288 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 289 | @Override |
| 290 | public void reassertRole() { |
| 291 | if (this.getRole() == RoleState.MASTER) { |
| 292 | log.warn("Received permission error from switch {} while " + |
| 293 | "being master. Reasserting master role.", |
| 294 | this.getStringId()); |
| 295 | this.setRole(RoleState.MASTER); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 300 | |
| 301 | @Override |
| 302 | public void handleRole(OFMessage m) throws SwitchStateException { |
| 303 | RoleReplyInfo rri = roleMan.extractOFRoleReply((OFRoleReply) m); |
| 304 | RoleRecvStatus rrs = roleMan.deliverRoleReply(rri); |
| 305 | if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) { |
| 306 | if (rri.getRole() == RoleState.MASTER) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 307 | this.role = rri.getRole(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 308 | this.transitionToMasterSwitch(); |
| 309 | } else if (rri.getRole() == RoleState.EQUAL || |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 310 | rri.getRole() == RoleState.SLAVE) { |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 311 | this.transitionToEqualSwitch(); |
| 312 | } |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 313 | } else { |
alshabib | 4785eec | 2014-12-04 16:45:45 -0800 | [diff] [blame] | 314 | log.warn("Failed to set role for {}", this.getStringId()); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public void handleNiciraRole(OFMessage m) throws SwitchStateException { |
| 320 | RoleState r = this.roleMan.extractNiciraRoleReply((OFExperimenter) m); |
| 321 | if (r == null) { |
| 322 | // The message wasn't really a Nicira role reply. We just |
| 323 | // dispatch it to the OFMessage listeners in this case. |
| 324 | this.handleMessage(m); |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 325 | return; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | RoleRecvStatus rrs = this.roleMan.deliverRoleReply( |
| 329 | new RoleReplyInfo(r, null, m.getXid())); |
| 330 | if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) { |
| 331 | if (r == RoleState.MASTER) { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 332 | this.role = r; |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 333 | this.transitionToMasterSwitch(); |
| 334 | } else if (r == RoleState.EQUAL || |
| 335 | r == RoleState.SLAVE) { |
| 336 | this.transitionToEqualSwitch(); |
| 337 | } |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 338 | } else { |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 339 | this.disconnectSwitch(); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
| 343 | @Override |
| 344 | public boolean handleRoleError(OFErrorMsg error) { |
| 345 | try { |
| 346 | return RoleRecvStatus.OTHER_EXPECTATION != this.roleMan.deliverError(error); |
| 347 | } catch (SwitchStateException e) { |
| 348 | this.disconnectSwitch(); |
| 349 | } |
| 350 | return true; |
| 351 | } |
| 352 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 353 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 354 | |
| 355 | @Override |
| 356 | public final void setAgent(OpenFlowAgent ag) { |
| 357 | if (this.agent == null) { |
| 358 | this.agent = ag; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | @Override |
| 363 | public final void setRoleHandler(RoleHandler roleHandler) { |
| 364 | if (this.roleMan == null) { |
| 365 | this.roleMan = roleHandler; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public void setSwitchDescription(OFDescStatsReply d) { |
| 371 | this.desc = d; |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public int getNextTransactionId() { |
| 376 | return this.xidCounter.getAndIncrement(); |
| 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public List<OFPortDesc> getPorts() { |
Srikanth Vavilapalli | f5b234a | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 381 | return this.ports.stream() |
| 382 | .flatMap((portReply) -> (portReply.getEntries().stream())) |
| 383 | .collect(Collectors.toList()); |
| 384 | //return Collections.unmodifiableList(ports.getEntries()); |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | @Override |
Ray Milkey | d3edd03 | 2015-01-16 11:38:58 -0800 | [diff] [blame] | 388 | public String manufacturerDescription() { |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 389 | return this.desc.getMfrDesc(); |
| 390 | } |
| 391 | |
| 392 | |
| 393 | @Override |
| 394 | public String datapathDescription() { |
| 395 | return this.desc.getDpDesc(); |
| 396 | } |
| 397 | |
| 398 | |
| 399 | @Override |
| 400 | public String hardwareDescription() { |
| 401 | return this.desc.getHwDesc(); |
| 402 | } |
| 403 | |
| 404 | @Override |
| 405 | public String softwareDescription() { |
| 406 | return this.desc.getSwDesc(); |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public String serialNumber() { |
| 411 | return this.desc.getSerialNum(); |
| 412 | } |
| 413 | |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 414 | |
Praseed Balakrishnan | a22eadf | 2014-10-20 14:21:45 -0700 | [diff] [blame] | 415 | @Override |
| 416 | public boolean isOptical() { |
| 417 | return false; |
| 418 | } |
| 419 | |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 420 | |
alshabib | b452fd7 | 2015-04-22 20:46:20 -0700 | [diff] [blame] | 421 | @Override |
| 422 | public String toString() { |
| 423 | return this.getClass().getName() + " [" + ((channel != null) |
| 424 | ? channel.getRemoteAddress() : "?") |
| 425 | + " DPID[" + ((getStringId() != null) ? getStringId() : "?") + "]]"; |
| 426 | } |
| 427 | |
| 428 | |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 429 | |
tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 430 | } |