- Plugin sends Barrier msg every 100 async msgs (configurable thru config.ini: of...
[controller.git] / opendaylight / 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      * @return The XID used
123      */
124     public Integer asyncFastSend(OFMessage msg, int xid);
125
126     /**
127      * Sends the OF message followed by a Barrier Request with a unique XID
128      * which is automatically generated, and waits for a result from the switch.
129      * 
130      * @param msg
131      *            The message to be sent
132      * @return An Object which has one of the followings instances/values:
133      *         Boolean with value true to indicate the message has been
134      *         successfully processed and acknowledged by the switch; Boolean
135      *         with value false to indicate the message has failed to be
136      *         processed by the switch within a period of time or OFError to
137      *         indicate that the message has been denied by the switch which
138      *         responded with OFError.
139      */
140     public Object syncSend(OFMessage msg);
141
142     /**
143      * Returns a map containing all OFPhysicalPorts of this switch.
144      * 
145      * @return The Map of OFPhysicalPort
146      */
147     public Map<Short, OFPhysicalPort> getPhysicalPorts();
148
149     /**
150      * Returns a Set containing all port IDs of this switch.
151      * 
152      * @return The Set of port ID
153      */
154     public Set<Short> getPorts();
155
156     /**
157      * Returns OFPhysicalPort of the specified portNumber of this switch.
158      * 
159      * @param portNumber
160      *            The port ID
161      * @return OFPhysicalPort for the specified PortNumber
162      */
163     public OFPhysicalPort getPhysicalPort(Short portNumber);
164
165     /**
166      * Returns the bandwidth of the specified portNumber of this switch.
167      * 
168      * @param portNumber
169      *            the port ID
170      * @return bandwidth
171      */
172     public Integer getPortBandwidth(Short portNumber);
173
174     /**
175      * Returns True if the port is enabled,
176      * 
177      * @param portNumber
178      * @return True if the port is enabled
179      */
180     public boolean isPortEnabled(short portNumber);
181
182     /**
183      * Returns True if the port is enabled.
184      * 
185      * @param port
186      * @return True if the port is enabled
187      */
188     public boolean isPortEnabled(OFPhysicalPort port);
189
190     /**
191      * Returns a list containing all enabled ports of this switch.
192      * 
193      * @return: List containing all enabled ports of this switch
194      */
195     public List<OFPhysicalPort> getEnabledPorts();
196
197     /**
198      * Sends OFStatisticsRequest with a unique XID generated automatically and
199      * waits for a result from the switch.
200      * 
201      * @param req
202      *            the OF Statistic Request to be sent
203      * @return Object has one of the following instances/values::
204      *         List<OFStatistics>, a list of statistics records received from
205      *         the switch as response from the request; OFError if the switch
206      *         failed handle the request or NULL if timeout has occurred while
207      *         waiting for the response.
208      */
209     public Object getStatistics(OFStatisticsRequest req);
210
211     /**
212      * Returns true if the switch has reached the operational state (has sent
213      * FEATURE_REPLY to the controller).
214      * 
215      * @return true if the switch is operational
216      */
217     public boolean isOperational();
218
219     /**
220      * Sends synchronous Barrier message 
221      */
222     public Object sendBarrierMessage();
223 }