Merge "Move adsal into its own subdirectory."
[controller.git] / opendaylight / adsal / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / ISwitch.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.core;
10
11 import java.util.Date;
12 import java.util.List;
13 import java.util.Map;
14 import java.util.Set;
15
16 import org.openflow.protocol.OFMessage;
17 import org.openflow.protocol.OFPhysicalPort;
18 import org.openflow.protocol.OFStatisticsRequest;
19
20 /**
21  * This interface defines an abstraction of an Open Flow Switch.
22  *
23  */
24 public interface ISwitch {
25     /**
26      * Gets a unique XID.
27      *
28      * @return XID
29      */
30     public int getNextXid();
31
32     /**
33      * Returns the Switch's ID.
34      *
35      * @return the Switch's ID
36      */
37     public Long getId();
38
39     /**
40      * Returns the Switch's table numbers supported by datapath
41      *
42      * @return the tables
43      */
44     public Byte getTables();
45
46     /**
47      * Returns the Switch's bitmap of supported ofp_action_type
48      *
49      * @return the actions
50      */
51     public Integer getActions();
52
53     /**
54      * Returns the Switch's bitmap of supported ofp_capabilities
55      *
56      * @return the capabilities
57      */
58     public Integer getCapabilities();
59
60     /**
61      * Returns the Switch's buffering capacity in Number of Pkts
62      *
63      * @return the buffers
64      */
65     public Integer getBuffers();
66
67     /**
68      * Returns the Date when the switch was connected.
69      *
70      * @return Date The date when the switch was connected
71      */
72     public Date getConnectedDate();
73
74     /**
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.
80      *
81      * @param msg
82      *            The OF message to be sent
83      * @return The XID used
84      */
85     public Integer asyncSend(OFMessage msg);
86
87     /**
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.
92      *
93      * @param msg
94      *            The OF message to be Sent
95      * @param xid
96      *            The XID to be used in the message
97      * @return The XID used
98      */
99     public Integer asyncSend(OFMessage msg, int xid);
100
101     /**
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
106      * message.
107      *
108      * @param msg
109      *            The OF message to be sent
110      * @return The XID used
111      */
112     public Integer asyncFastSend(OFMessage msg);
113
114     /**
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.
119      *
120      * @param msg
121      *            The OF message to be sent
122      * @param xid
123      *            The XID to be used in the message
124      * @return The XID used
125      */
126     public Integer asyncFastSend(OFMessage msg, int xid);
127
128     /**
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.
131      *
132      * @param msg
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.
141      */
142     public Object syncSend(OFMessage msg);
143
144     /**
145      * Returns a map containing all OFPhysicalPorts of this switch.
146      *
147      * @return The Map of OFPhysicalPort
148      */
149     public Map<Short, OFPhysicalPort> getPhysicalPorts();
150
151     /**
152      * Returns a Set containing all port IDs of this switch.
153      *
154      * @return The Set of port ID
155      */
156     public Set<Short> getPorts();
157
158     /**
159      * Returns OFPhysicalPort of the specified portNumber of this switch.
160      *
161      * @param portNumber
162      *            The port ID
163      * @return OFPhysicalPort for the specified PortNumber
164      */
165     public OFPhysicalPort getPhysicalPort(Short portNumber);
166
167     /**
168      * Returns the bandwidth of the specified portNumber of this switch.
169      *
170      * @param portNumber
171      *            the port ID
172      * @return bandwidth
173      */
174     public Integer getPortBandwidth(Short portNumber);
175
176     /**
177      * Returns True if the port is enabled,
178      *
179      * @param portNumber
180      *            the port ID
181      * @return True if the port is enabled
182      */
183     public boolean isPortEnabled(short portNumber);
184
185     /**
186      * Returns True if the port is enabled.
187      *
188      * @param port
189      *            the OpenFlow port
190      * @return True if the port is enabled
191      */
192     public boolean isPortEnabled(OFPhysicalPort port);
193
194     /**
195      * Returns a list containing all enabled ports of this switch.
196      *
197      * @return: List containing all enabled ports of this switch
198      */
199     public List<OFPhysicalPort> getEnabledPorts();
200
201     /**
202      * Sends OFStatisticsRequest with a unique XID generated automatically and
203      * waits for a result from the switch.
204      *
205      * @param req
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.
212      */
213     public Object getStatistics(OFStatisticsRequest req);
214
215     /**
216      * Returns true if the switch has reached the operational state (has sent
217      * FEATURE_REPLY to the controller).
218      *
219      * @return true if the switch is operational
220      */
221     public boolean isOperational();
222
223     /**
224      * Send Barrier message synchronously. The caller will be blocked until the
225      * Barrier reply arrives.
226      */
227     public Object syncSendBarrierMessage();
228
229     /**
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.
233      */
234     public Object asyncSendBarrierMessage();
235
236     /**
237      * Send a FLOW_MOD message with a wildcard match and action=DELETE.
238      */
239     public void deleteAllFlows();
240 }