OpenDaylight Controller functional modules.
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / ISwitch.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.core;
11
12 import java.util.Date;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16
17 import org.openflow.protocol.OFMessage;
18 import org.openflow.protocol.OFPhysicalPort;
19 import org.openflow.protocol.OFStatisticsRequest;
20
21 /**
22  * This interface defines an abstraction of an Open Flow Switch.
23  *
24  */
25 public interface ISwitch {
26         /**
27          * Gets a unique XID.
28          * @return XID
29          */
30         public int getNextXid();
31
32         /**
33          * Returns the Switch's ID.
34          * @return the Switch's ID
35          */
36         public Long getId();
37
38         /**
39          * Returns the Switch's table numbers supported by datapath 
40          * @return the tables
41          */
42         public Byte getTables();
43
44         /**
45          * Returns the Switch's bitmap of supported ofp_action_type
46          * @return the actions
47          */
48         public Integer getActions();
49
50         /**
51          * Returns the Switch's bitmap of supported ofp_capabilities
52          * @return the capabilities
53          */
54         public Integer getCapabilities();
55
56         /**
57          * Returns the Switch's buffering capacity in Number of Pkts
58          * @return the buffers
59          */
60         public Integer getBuffers();
61
62         /**
63          * Returns the Date when the switch was connected.
64          * @return Date The date when the switch was connected
65          */
66         public Date getConnectedDate();
67
68         /**
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
72          */
73         public Integer asyncSend(OFMessage msg);
74
75         /**
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
80          */
81         public Integer asyncSend(OFMessage msg, int xid);
82
83         /**
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.
91          */
92         public Object syncSend(OFMessage msg);
93
94         /**
95          * Returns a map containing all OFPhysicalPorts of this switch.
96          * @return The Map of OFPhysicalPort
97          */
98         public Map<Short, OFPhysicalPort> getPhysicalPorts();
99
100         /**
101          * Returns a Set containing all port IDs of this switch.
102          * @return The Set of port ID
103          */
104         public Set<Short> getPorts();
105
106         /**
107          * Returns OFPhysicalPort of the specified portNumber of this switch.
108          * @param portNumber The port ID
109          * @return OFPhysicalPort for the specified PortNumber
110          */
111         public OFPhysicalPort getPhysicalPort(Short portNumber);
112
113         /**
114          * Returns the bandwidth of the specified portNumber of this switch.
115          * @param portNumber the port ID
116          * @return bandwidth
117          */
118         public Integer getPortBandwidth(Short portNumber);
119
120         /**
121          * Returns True if the port is enabled,
122          * @param portNumber 
123          * @return True if the port is enabled
124          */
125         public boolean isPortEnabled(short portNumber);
126
127         /**
128          * Returns True if the port is enabled.
129          * @param port
130          * @return True if the port is enabled
131          */
132         public boolean isPortEnabled(OFPhysicalPort port);
133
134         /**
135          * Returns a list containing all enabled ports of this switch.
136          * @return: List containing all enabled ports of this switch
137          */
138         public List<OFPhysicalPort> getEnabledPorts();
139
140         /**
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.
147          */
148         public Object getStatistics(OFStatisticsRequest req);
149
150         /**
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
153          */
154         public boolean isOperational();
155
156 }