blob: cc3f87dd1143eeafdf2856ffedcbebe97b3b1972 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
tom9c94c5b2014-09-17 13:14:42 -070019package org.onlab.onos.openflow.controller.driver;
tom7ef8ff92014-09-17 13:08:06 -070020
tom9c94c5b2014-09-17 13:14:42 -070021import org.onlab.onos.openflow.controller.Dpid;
22import org.onlab.onos.openflow.controller.OpenFlowSwitch;
Ayaka Koshibeab91cc42014-09-25 10:20:52 -070023import org.onlab.onos.openflow.controller.RoleState;
tom7ef8ff92014-09-17 13:08:06 -070024import org.projectfloodlight.openflow.protocol.OFMessage;
25
26/**
27 * Responsible for keeping track of the current set of switches
28 * connected to the system. As well as whether they are in Master
29 * role or not.
30 *
31 */
32public interface OpenFlowAgent {
33
34 /**
35 * Add a switch that has just connected to the system.
36 * @param dpid the dpid to add
37 * @param sw the actual switch object.
38 * @return true if added, false otherwise.
39 */
40 public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw);
41
42 /**
43 * Checks if the activation for this switch is valid.
44 * @param dpid the dpid to check
45 * @return true if valid, false otherwise
46 */
47 public boolean validActivation(Dpid dpid);
48
49 /**
50 * Called when a switch is activated, with this controller's role as MASTER.
51 * @param dpid the dpid to add.
52 * @param sw the actual switch
53 * @return true if added, false otherwise.
54 */
55 public boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw);
56
57 /**
58 * Called when a switch is activated, with this controller's role as EQUAL.
59 * @param dpid the dpid to add.
60 * @param sw the actual switch
61 * @return true if added, false otherwise.
62 */
63 public boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw);
64
65 /**
66 * Called when this controller's role for a switch transitions from equal
67 * to master. For 1.0 switches, we internally refer to the role 'slave' as
68 * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'.
69 * @param dpid the dpid to transistion.
70 */
71 public void transitionToMasterSwitch(Dpid dpid);
72
73 /**
74 * Called when this controller's role for a switch transitions to equal.
75 * For 1.0 switches, we internally refer to the role 'slave' as
76 * 'equal'.
77 * @param dpid the dpid to transistion.
78 */
79 public void transitionToEqualSwitch(Dpid dpid);
80
81 /**
82 * Clear all state in controller switch maps for a switch that has
83 * disconnected from the local controller. Also release control for
84 * that switch from the global repository. Notify switch listeners.
85 * @param dpid the dpid to remove.
86 */
87 public void removeConnectedSwitch(Dpid dpid);
88
89 /**
90 * Process a message coming from a switch.
91 *
92 * @param dpid the dpid the message came on.
93 * @param m the message to process
94 */
95 public void processMessage(Dpid dpid, OFMessage m);
Ayaka Koshibeab91cc42014-09-25 10:20:52 -070096
97 /**
98 * Notifies the controller that role assertion has failed.
99 *
100 * @param dpid the switch that failed role assertion
101 * @param role the failed role
102 */
103 public void returnRoleAssertFailed(Dpid dpid, RoleState role);
tom7ef8ff92014-09-17 13:08:06 -0700104}