2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.protocol_plugin.openflow.core;
11 import java.util.Date;
12 import java.util.List;
16 import org.openflow.protocol.OFMessage;
17 import org.openflow.protocol.OFPhysicalPort;
18 import org.openflow.protocol.OFStatisticsRequest;
21 * This interface defines an abstraction of an Open Flow Switch.
24 public interface ISwitch {
30 public int getNextXid();
33 * Returns the Switch's ID.
35 * @return the Switch's ID
40 * Returns the Switch's table numbers supported by datapath
44 public Byte getTables();
47 * Returns the Switch's bitmap of supported ofp_action_type
51 public Integer getActions();
54 * Returns the Switch's bitmap of supported ofp_capabilities
56 * @return the capabilities
58 public Integer getCapabilities();
61 * Returns the Switch's buffering capacity in Number of Pkts
65 public Integer getBuffers();
68 * Returns the Date when the switch was connected.
70 * @return Date The date when the switch was connected
72 public Date getConnectedDate();
75 * This method puts the message in an outgoing priority queue with normal
76 * priority. It will be served after high priority messages. The method
77 * should be used for non-critical messages such as statistics request,
78 * discovery packets, etc. An unique XID is generated automatically and
79 * inserted into the message.
82 * The OF message to be sent
83 * @return The XID used
85 public Integer asyncSend(OFMessage msg);
88 * This method puts the message in an outgoing priority queue with normal
89 * priority. It will be served after high priority messages. The method
90 * should be used for non-critical messages such as statistics request,
91 * discovery packets, etc. The specified XID is inserted into the message.
94 * The OF message to be Sent
96 * The XID to be used in the message
97 * @return The XID used
99 public Integer asyncSend(OFMessage msg, int xid);
102 * This method puts the message in an outgoing priority queue with high
103 * priority. It will be served first before normal priority messages. The
104 * method should be used for critical messages such as hello, echo reply
105 * etc. An unique XID is generated automatically and inserted into the
109 * The OF message to be sent
110 * @return The XID used
112 public Integer asyncFastSend(OFMessage msg);
115 * This method puts the message in an outgoing priority queue with high
116 * priority. It will be served first before normal priority messages. The
117 * method should be used for critical messages such as hello, echo reply
118 * etc. The specified XID is inserted into the message.
121 * The OF message to be sent
123 * The XID to be used in the message
124 * @return The XID used
126 public Integer asyncFastSend(OFMessage msg, int xid);
129 * Sends the OF message followed by a Barrier Request with a unique XID
130 * which is automatically generated, and waits for a result from the switch.
133 * The message to be sent
134 * @return An Object which has one of the followings instances/values:
135 * Boolean with value true to indicate the message has been
136 * successfully processed and acknowledged by the switch; Boolean
137 * with value false to indicate the message has failed to be
138 * processed by the switch within a period of time or OFError to
139 * indicate that the message has been denied by the switch which
140 * responded with OFError.
142 public Object syncSend(OFMessage msg);
145 * Returns a map containing all OFPhysicalPorts of this switch.
147 * @return The Map of OFPhysicalPort
149 public Map<Short, OFPhysicalPort> getPhysicalPorts();
152 * Returns a Set containing all port IDs of this switch.
154 * @return The Set of port ID
156 public Set<Short> getPorts();
159 * Returns OFPhysicalPort of the specified portNumber of this switch.
163 * @return OFPhysicalPort for the specified PortNumber
165 public OFPhysicalPort getPhysicalPort(Short portNumber);
168 * Returns the bandwidth of the specified portNumber of this switch.
174 public Integer getPortBandwidth(Short portNumber);
177 * Returns True if the port is enabled,
181 * @return True if the port is enabled
183 public boolean isPortEnabled(short portNumber);
186 * Returns True if the port is enabled.
190 * @return True if the port is enabled
192 public boolean isPortEnabled(OFPhysicalPort port);
195 * Returns a list containing all enabled ports of this switch.
197 * @return: List containing all enabled ports of this switch
199 public List<OFPhysicalPort> getEnabledPorts();
202 * Sends OFStatisticsRequest with a unique XID generated automatically and
203 * waits for a result from the switch.
206 * the OF Statistic Request to be sent
207 * @return Object has one of the following instances/values::
208 * List<OFStatistics>, a list of statistics records received from
209 * the switch as response from the request; OFError if the switch
210 * failed handle the request or NULL if timeout has occurred while
211 * waiting for the response.
213 public Object getStatistics(OFStatisticsRequest req);
216 * Returns true if the switch has reached the operational state (has sent
217 * FEATURE_REPLY to the controller).
219 * @return true if the switch is operational
221 public boolean isOperational();
224 * Send Barrier message synchronously. The caller will be blocked until the
225 * Barrier reply arrives.
227 public Object syncSendBarrierMessage();
230 * Send Barrier message asynchronously. The caller is not blocked. The
231 * Barrier message will be sent in a transmit thread which will be blocked
232 * until the Barrier reply arrives.
234 public Object asyncSendBarrierMessage();
237 * Send a FLOW_MOD message with a wildcard match and action=DELETE.
239 public void deleteAllFlows();