1b6810bee9654a765ed26a0073f0e9b555023530
[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      * @param msg the message to write
34      */
35     void sendMsg(OFMessage msg);
36
37     /**
38      * Writes the OFMessage list to the driver.
39      *
40      * @param msgs the messages to be written
41      */
42     void sendMsg(List<OFMessage> msgs);
43
44     /**
45      * Handle a message from the switch.
46      * @param fromSwitch the message to handle
47      */
48     void handleMessage(OFMessage fromSwitch);
49
50     /**
51      * Sets the role for this switch.
52      * @param role the role to set.
53      */
54     void setRole(RoleState role);
55
56     /**
57      * Fetch the role for this switch.
58      * @return the role.
59      */
60     RoleState getRole();
61
62     /**
63      * Fetches the ports of this switch.
64      * @return unmodifiable list of the ports.
65      */
66     List<OFPortDesc> getPorts();
67
68     /**
69      * Provides the factory for this OF version.
70      * @return OF version specific factory.
71      */
72     OFFactory factory();
73
74     /**
75      * Gets a string version of the ID for this switch.
76      *
77      * @return string version of the ID
78      */
79     String getStringId();
80
81     /**
82      * Gets the datapathId of the switch.
83      *
84      * @return the switch dpid in long format
85      */
86     long getId();
87
88     /**
89      * fetch the manufacturer description.
90      * @return the description
91      */
92     String manufacturerDescription();
93
94     /**
95      * fetch the datapath description.
96      * @return the description
97      */
98     String datapathDescription();
99
100     /**
101      * fetch the hardware description.
102      * @return the description
103      */
104     String hardwareDescription();
105
106     /**
107      * fetch the software description.
108      * @return the description
109      */
110     String softwareDescription();
111
112     /**
113      * fetch the serial number.
114      * @return the serial
115      */
116     String serialNumber();
117
118     /**
119      * Checks if the switch is still connected.
120      *
121      * @return whether the switch is still connected
122      */
123     boolean isConnected();
124
125     /**
126      * Disconnects the switch by closing the TCP connection. Results in a call
127      * to the channel handler's channelDisconnected method for cleanup
128      */
129     void disconnectSwitch();
130
131     /**
132      * Notifies the controller that the device has responded to a set-role request.
133      *
134      * @param requested the role requested by the controller
135      * @param response the role set at the device
136      */
137     void returnRoleReply(RoleState requested, RoleState response);
138
139     /**
140      * Returns the switch device type.
141      *
142      * @return device type
143      */
144     Device.Type deviceType();
145
146     /**
147      * Identifies the channel used to communicate with the switch.
148      *
149      * @return string representation of the connection to the device
150      */
151     String channelId();
152 }