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 * This method puts the message in an outgoing priority queue with normal
70 * priority. It will be served after high priority messages. The method
71 * should be used for non-critical messages such as statistics request,
72 * discovery packets, etc. An unique XID is generated automatically and
73 * inserted into the message.
75 * @param msg The OF message to be sent
76 * @return The XID used
78 public Integer asyncSend(OFMessage msg);
81 * This method puts the message in an outgoing priority queue with normal
82 * priority. It will be served after high priority messages. The method
83 * should be used for non-critical messages such as statistics request,
84 * discovery packets, etc. The specified XID is inserted into the message.
86 * @param msg The OF message to be Sent
87 * @param xid The XID to be used in the message
88 * @return The XID used
90 public Integer asyncSend(OFMessage msg, int xid);
93 * This method puts the message in an outgoing priority queue with high
94 * priority. It will be served first before normal priority messages. The
95 * method should be used for critical messages such as hello, echo reply
96 * etc. An unique XID is generated automatically and inserted into the
99 * @param msg The OF message to be sent
100 * @return The XID used
102 public Integer asyncFastSend(OFMessage msg);
105 * This method puts the message in an outgoing priority queue with high
106 * priority. It will be served first before normal priority messages. The
107 * method should be used for critical messages such as hello, echo reply
108 * etc. The specified XID is inserted into the message.
110 * @param msg The OF message to be sent
111 * @return The XID used
113 public Integer asyncFastSend(OFMessage msg, int xid);
116 * Sends the OF message followed by a Barrier Request with a unique XID which is automatically generated,
117 * and waits for a result from the switch.
118 * @param msg The message to be sent
119 * @return An Object which has one of the followings instances/values:
120 * Boolean with value true to indicate the message has been successfully processed and acknowledged by the switch;
121 * Boolean with value false to indicate the message has failed to be processed by the switch within a period of time or
122 * OFError to indicate that the message has been denied by the switch which responded with OFError.
124 public Object syncSend(OFMessage msg);
127 * Returns a map containing all OFPhysicalPorts of this switch.
128 * @return The Map of OFPhysicalPort
130 public Map<Short, OFPhysicalPort> getPhysicalPorts();
133 * Returns a Set containing all port IDs of this switch.
134 * @return The Set of port ID
136 public Set<Short> getPorts();
139 * Returns OFPhysicalPort of the specified portNumber of this switch.
140 * @param portNumber The port ID
141 * @return OFPhysicalPort for the specified PortNumber
143 public OFPhysicalPort getPhysicalPort(Short portNumber);
146 * Returns the bandwidth of the specified portNumber of this switch.
147 * @param portNumber the port ID
150 public Integer getPortBandwidth(Short portNumber);
153 * Returns True if the port is enabled,
155 * @return True if the port is enabled
157 public boolean isPortEnabled(short portNumber);
160 * Returns True if the port is enabled.
162 * @return True if the port is enabled
164 public boolean isPortEnabled(OFPhysicalPort port);
167 * Returns a list containing all enabled ports of this switch.
168 * @return: List containing all enabled ports of this switch
170 public List<OFPhysicalPort> getEnabledPorts();
173 * Sends OFStatisticsRequest with a unique XID generated automatically and waits for a result from the switch.
174 * @param req the OF Statistic Request to be sent
175 * @return Object has one of the following instances/values::
176 * List<OFStatistics>, a list of statistics records received from the switch as response from the request;
177 * OFError if the switch failed handle the request or
178 * NULL if timeout has occurred while waiting for the response.
180 public Object getStatistics(OFStatisticsRequest req);
183 * Returns true if the switch has reached the operational state (has sent FEATURE_REPLY to the controller).
184 * @return true if the switch is operational
186 public boolean isOperational();