51a2ce42acd148314808d59f85628544e1b55449
[onosfw.git] /
1 /*
2  * Copyright 2014-2015 Open Networking Laboratory
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onosproject.openflow.controller;
17
18 import org.onosproject.net.Device;
19 import org.projectfloodlight.openflow.protocol.OFFactory;
20 import org.projectfloodlight.openflow.protocol.OFMessage;
21 import org.projectfloodlight.openflow.protocol.OFPortDesc;
22
23 import java.util.List;
24
25 /**
26  * Represents to provider facing side of a switch.
27  */
28 public interface OpenFlowSwitch {
29
30     /**
31      * Writes the message to the driver.
32      *
33      * Note:
34      * Calling {@link #sendMsg(OFMessage)} does NOT guarantee the messages to be
35      * transmitted on the wire in order, especially during role transition.
36      * The messages may be reordered at the switch side.
37      *
38      * Calling {@link #sendMsg(List)} guarantee the messages inside the list
39      * to be transmitted on the wire in order.
40      *
41      * @param msg the message to write
42      */
43     void sendMsg(OFMessage msg);
44
45     /**
46      * Writes the OFMessage list to the driver.
47      *
48      * @param msgs the messages to be written
49      */
50     void sendMsg(List<OFMessage> msgs);
51
52     /**
53      * Handle a message from the switch.
54      * @param fromSwitch the message to handle
55      */
56     void handleMessage(OFMessage fromSwitch);
57
58     /**
59      * Sets the role for this switch.
60      * @param role the role to set.
61      */
62     void setRole(RoleState role);
63
64     /**
65      * Fetch the role for this switch.
66      * @return the role.
67      */
68     RoleState getRole();
69
70     /**
71      * Fetches the ports of this switch.
72      * @return unmodifiable list of the ports.
73      */
74     List<OFPortDesc> getPorts();
75
76     /**
77      * Provides the factory for this OF version.
78      * @return OF version specific factory.
79      */
80     OFFactory factory();
81
82     /**
83      * Gets a string version of the ID for this switch.
84      *
85      * @return string version of the ID
86      */
87     String getStringId();
88
89     /**
90      * Gets the datapathId of the switch.
91      *
92      * @return the switch dpid in long format
93      */
94     long getId();
95
96     /**
97      * fetch the manufacturer description.
98      * @return the description
99      */
100     String manufacturerDescription();
101
102     /**
103      * fetch the datapath description.
104      * @return the description
105      */
106     String datapathDescription();
107
108     /**
109      * fetch the hardware description.
110      * @return the description
111      */
112     String hardwareDescription();
113
114     /**
115      * fetch the software description.
116      * @return the description
117      */
118     String softwareDescription();
119
120     /**
121      * fetch the serial number.
122      * @return the serial
123      */
124     String serialNumber();
125
126     /**
127      * Checks if the switch is still connected.
128      *
129      * @return whether the switch is still connected
130      */
131     boolean isConnected();
132
133     /**
134      * Disconnects the switch by closing the TCP connection. Results in a call
135      * to the channel handler's channelDisconnected method for cleanup
136      */
137     void disconnectSwitch();
138
139     /**
140      * Notifies the controller that the device has responded to a set-role request.
141      *
142      * @param requested the role requested by the controller
143      * @param response the role set at the device
144      */
145     void returnRoleReply(RoleState requested, RoleState response);
146
147     /**
148      * Returns the switch device type.
149      *
150      * @return device type
151      */
152     Device.Type deviceType();
153
154     /**
155      * Identifies the channel used to communicate with the switch.
156      *
157      * @return string representation of the connection to the device
158      */
159     String channelId();
160 }