aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowAgent.java
blob: ad6dede1c54183814fec7ac9089afc29206c2f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright 2014 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.openflow.controller.driver;

import org.onosproject.openflow.controller.Dpid;
import org.onosproject.openflow.controller.OpenFlowSwitch;
import org.onosproject.openflow.controller.RoleState;
import org.projectfloodlight.openflow.protocol.OFMessage;

/**
 * Responsible for keeping track of the current set of switches
 * connected to the system. As well as whether they are in Master
 * role or not.
 *
 */
public interface OpenFlowAgent {

    /**
     * Add a switch that has just connected to the system.
     * @param dpid the dpid to add
     * @param sw the actual switch object.
     * @return true if added, false otherwise.
     */
    boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw);

    /**
     * Checks if the activation for this switch is valid.
     * @param dpid the dpid to check
     * @return true if valid, false otherwise
     */
    boolean validActivation(Dpid dpid);

    /**
     * Called when a switch is activated, with this controller's role as MASTER.
     * @param dpid the dpid to add.
     * @param sw the actual switch
     * @return true if added, false otherwise.
     */
    boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw);

    /**
     * Called when a switch is activated, with this controller's role as EQUAL.
     * @param dpid the dpid to add.
     * @param sw the actual switch
     * @return true if added, false otherwise.
     */
    boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw);

    /**
     * Called when this controller's role for a switch transitions from equal
     * to master. For 1.0 switches, we internally refer to the role 'slave' as
     * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'.
     * @param dpid the dpid to transistion.
     */
    void transitionToMasterSwitch(Dpid dpid);

    /**
     * Called when this controller's role for a switch transitions to equal.
     * For 1.0 switches, we internally refer to the role 'slave' as
     * 'equal'.
     * @param dpid the dpid to transistion.
     */
    void transitionToEqualSwitch(Dpid dpid);

    /**
     * Clear all state in controller switch maps for a switch that has
     * disconnected from the local controller. Also release control for
     * that switch from the global repository. Notify switch listeners.
     * @param dpid the dpid to remove.
     */
    void removeConnectedSwitch(Dpid dpid);

    /**
     * Process a message coming from a switch.
     *
     * @param dpid the dpid the message came on.
     * @param m the message to process
     */
    void processMessage(Dpid dpid, OFMessage m);

    /**
     * Notifies the controller that role assertion has failed.
     *
     * @param dpid the switch that failed role assertion
     * @param requested the role controller requested
     * @param response role reply from the switch
     */
    void returnRoleReply(Dpid dpid, RoleState requested, RoleState response);
}