3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.protocol_plugin.openflow.core;
12 import java.util.Date;
13 import java.util.List;
17 import org.openflow.protocol.OFMessage;
18 import org.openflow.protocol.OFPhysicalPort;
19 import org.openflow.protocol.OFStatisticsRequest;
22 * This interface defines an abstraction of an Open Flow Switch.
25 public interface ISwitch {
30 public int getNextXid();
33 * Returns the Switch's ID.
34 * @return the Switch's ID
39 * Returns the Switch's table numbers supported by datapath
42 public Byte getTables();
45 * Returns the Switch's bitmap of supported ofp_action_type
48 public Integer getActions();
51 * Returns the Switch's bitmap of supported ofp_capabilities
52 * @return the capabilities
54 public Integer getCapabilities();
57 * Returns the Switch's buffering capacity in Number of Pkts
60 public Integer getBuffers();
63 * Returns the Date when the switch was connected.
64 * @return Date The date when the switch was connected
66 public Date getConnectedDate();
69 * Sends the message. A unique XID is generated automatically and inserted into the message.
70 * @param msg TheOF message to be sent
71 * @return The XID used
73 public Integer asyncSend(OFMessage msg);
76 * Sends the message with the specified XID.
77 * @param msg The OF message to be Sent
78 * @param xid The XID to be used in the message
79 * @return The XID used
81 public Integer asyncSend(OFMessage msg, int xid);
84 * Sends the OF message followed by a Barrier Request with a unique XID which is automatically generated,
85 * and waits for a result from the switch.
86 * @param msg The message to be sent
87 * @return An Object which has one of the followings instances/values:
88 * Boolean with value true to indicate the message has been successfully processed and acknowledged by the switch;
89 * Boolean with value false to indicate the message has failed to be processed by the switch within a period of time or
90 * OFError to indicate that the message has been denied by the switch which responded with OFError.
92 public Object syncSend(OFMessage msg);
95 * Returns a map containing all OFPhysicalPorts of this switch.
96 * @return The Map of OFPhysicalPort
98 public Map<Short, OFPhysicalPort> getPhysicalPorts();
101 * Returns a Set containing all port IDs of this switch.
102 * @return The Set of port ID
104 public Set<Short> getPorts();
107 * Returns OFPhysicalPort of the specified portNumber of this switch.
108 * @param portNumber The port ID
109 * @return OFPhysicalPort for the specified PortNumber
111 public OFPhysicalPort getPhysicalPort(Short portNumber);
114 * Returns the bandwidth of the specified portNumber of this switch.
115 * @param portNumber the port ID
118 public Integer getPortBandwidth(Short portNumber);
121 * Returns True if the port is enabled,
123 * @return True if the port is enabled
125 public boolean isPortEnabled(short portNumber);
128 * Returns True if the port is enabled.
130 * @return True if the port is enabled
132 public boolean isPortEnabled(OFPhysicalPort port);
135 * Returns a list containing all enabled ports of this switch.
136 * @return: List containing all enabled ports of this switch
138 public List<OFPhysicalPort> getEnabledPorts();
141 * Sends OFStatisticsRequest with a unique XID generated automatically and waits for a result from the switch.
142 * @param req the OF Statistic Request to be sent
143 * @return Object has one of the following instances/values::
144 * List<OFStatistics>, a list of statistics records received from the switch as response from the request;
145 * OFError if the switch failed handle the request or
146 * NULL if timeout has occurred while waiting for the response.
148 public Object getStatistics(OFStatisticsRequest req);
151 * Returns true if the switch has reached the operational state (has sent FEATURE_REPLY to the controller).
152 * @return true if the switch is operational
154 public boolean isOperational();