blob: b5cfe5a2fa1525c14f3a60256be67a25bd6bcd81 [file] [log] [blame]
Satish Ke107e662015-09-21 19:00:17 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Ke107e662015-09-21 19:00:17 +05303 *
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
17package org.onosproject.bgp.controller;
18
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053019import org.onosproject.bgpio.exceptions.BgpParseException;
20import org.onosproject.bgpio.protocol.BgpMessage;
Satish Ke107e662015-09-21 19:00:17 +053021
mohamedrahil00f6f262016-11-24 20:20:41 +053022import java.util.List;
Jonathan Hart51539b82015-10-29 09:53:04 -070023import java.util.Map;
24import java.util.Set;
25
Satish Ke107e662015-09-21 19:00:17 +053026/**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053027 * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on
28 * bgp events
Satish Ke107e662015-09-21 19:00:17 +053029 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053030public interface BgpController {
Satish Ke107e662015-09-21 19:00:17 +053031
32 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053033 * Returns list of bgp peers connected to this BGP controller.
34 *
35 * @return Iterable of BGPPeer elements
36 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053037 Iterable<BgpPeer> getPeers();
Shashikanth VH6de20d32015-10-09 12:04:13 +053038
39 /**
40 * Returns the actual bgp peer for the given ip address.
41 *
42 * @param bgpId the id of the bgp peer to fetch
43 * @return the interface to this bgp peer
44 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053045 BgpPeer getPeer(BgpId bgpId);
Shashikanth VH6de20d32015-10-09 12:04:13 +053046
47 /**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053048 * Register a listener for BGP message events.
49 *
50 * @param listener the listener to notify
51 */
52 void addListener(BgpNodeListener listener);
53
54 /**
55 * Unregister a listener.
56 *
57 * @param listener the listener to unregister
58 */
59 void removeListener(BgpNodeListener listener);
60
61 /**
Satish Ke107e662015-09-21 19:00:17 +053062 * Send a message to a particular bgp peer.
63 *
64 * @param bgpId the id of the peer to send message.
mohamedrahil00f6f262016-11-24 20:20:41 +053065 * @param msg the message to send
Satish Ke107e662015-09-21 19:00:17 +053066 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053067 void writeMsg(BgpId bgpId, BgpMessage msg);
Satish Ke107e662015-09-21 19:00:17 +053068
69 /**
70 * Process a message and notify the appropriate listeners.
71 *
72 * @param bgpId id of the peer the message arrived on
mohamedrahil00f6f262016-11-24 20:20:41 +053073 * @param msg the message to process.
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053074 * @throws BgpParseException on data processing error
Satish Ke107e662015-09-21 19:00:17 +053075 */
Jonathan Hart51539b82015-10-29 09:53:04 -070076 void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
Satish Ke107e662015-09-21 19:00:17 +053077
78 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053079 * Close all connected BGP peers.
Shashikanth VH6de20d32015-10-09 12:04:13 +053080 */
81 void closeConnectedPeers();
82
83 /**
Satish Ke107e662015-09-21 19:00:17 +053084 * Get the BGPConfig class to the caller.
85 *
86 * @return configuration object
87 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053088 BgpCfg getConfig();
Shashikanth VH6de20d32015-10-09 12:04:13 +053089
90 /**
91 * Get the BGP connected peers to this controller.
92 *
93 * @return the integer number
94 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +053095 int connectedPeerCount();
96
97 /**
Shashikanth VH3fe37982015-11-30 11:50:07 +053098 * Return BGP local RIB instance with VPN.
99 *
100 * @return BGPLocalRibImpl local RIB with VPN
101 */
102 BgpLocalRib bgpLocalRibVpn();
103
104 /**
105 * Return BGP local RIB instance.
106 *
107 * @return BGPLocalRibImpl local RIB
108 */
109 BgpLocalRib bgpLocalRib();
110
111 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530112 * Return BGP peer manager.
113 *
114 * @return BGPPeerManager peer manager instance
115 */
116 BgpPeerManager peerManager();
117
118 /**
119 * Return BGP connected peers.
120 *
121 * @return connectedPeers connected peers
122 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530123 Map<BgpId, BgpPeer> connectedPeers();
Shashikanth VHf62b5c02015-11-20 22:23:08 +0530124
125 /**
126 * Return BGP node listener.
127 *
128 * @return node listener
129 */
130 Set<BgpNodeListener> listener();
Priyanka Bfc51c952016-03-26 14:30:33 +0530131
132 /**
133 * Register a listener for BGP message events.
134 *
135 * @param listener the listener to notify
136 */
137 void addLinkListener(BgpLinkListener listener);
138
139 /**
140 * Unregister a listener.
141 *
142 * @param listener the listener to unregister
143 */
144 void removeLinkListener(BgpLinkListener listener);
145
146 /**
147 * Return BGP link listener.
148 *
149 * @return link listener
150 */
151 Set<BgpLinkListener> linkListener();
mohamedrahil00f6f262016-11-24 20:20:41 +0530152
153 /**
154 * Stores the exceptions occured during an active session.
155 *
156 * @param peerId BGP peer id
157 * @param exception exceptions based on the peer id.
158 */
159 void activeSessionExceptionAdd(String peerId, String exception);
160
161 /**
162 * Stores the exceptions occured during an closed session.
163 *
164 * @param peerId BGP peer id
165 * @param exception exceptions based on the peer id
166 */
167 void closedSessionExceptionAdd(String peerId, String exception);
168
169 /**
170 * Return active session exceptions.
171 *
172 * @return activeSessionMap
173 */
174 Map<String, List<String>> activeSessionMap();
175
176 /**
177 * Return closed session exceptions.
178 *
179 * @return closedSessionMap
180 */
181 Map<String, List<String>> closedSessionMap();
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530182 /**
183 * Register a listener for BGP message events.
184 *
185 * @param listener the listener to notify
186 */
187 void addRouteListener(BgpRouteListener listener);
188
189 /**
190 * Unregister a listener.
191 *
192 * @param listener the listener to unregister
193 */
194 void removeRouteListener(BgpRouteListener listener);
195
196 /**
197 * Return BGP route listener.
198 *
199 * @return route listener
200 */
201 Set<BgpRouteListener> routeListener();
mohamedrahil00f6f262016-11-24 20:20:41 +0530202
Shashikanth VHf62b5c02015-11-20 22:23:08 +0530203}