blob: 0930e8e86457287b5b389f06907d52a87d5e65ea [file] [log] [blame]
Satish Ke107e662015-09-21 19:00:17 +05301/*
2 * Copyright 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
17package org.onosproject.bgp.controller;
18
Shashikanth VH9f8afb42015-11-04 18:00:30 +053019import java.util.Map;
Shashikanth VHf62b5c02015-11-20 22:23:08 +053020import java.util.Set;
Shashikanth VH9f8afb42015-11-04 18:00:30 +053021
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053022import org.onosproject.bgpio.exceptions.BgpParseException;
23import org.onosproject.bgpio.protocol.BgpMessage;
Satish Ke107e662015-09-21 19:00:17 +053024
25/**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053026 * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on
27 * bgp events
Satish Ke107e662015-09-21 19:00:17 +053028 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053029public interface BgpController {
Satish Ke107e662015-09-21 19:00:17 +053030
31 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053032 * Returns list of bgp peers connected to this BGP controller.
33 *
34 * @return Iterable of BGPPeer elements
35 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053036 Iterable<BgpPeer> getPeers();
Shashikanth VH6de20d32015-10-09 12:04:13 +053037
38 /**
39 * Returns the actual bgp peer for the given ip address.
40 *
41 * @param bgpId the id of the bgp peer to fetch
42 * @return the interface to this bgp peer
43 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053044 BgpPeer getPeer(BgpId bgpId);
Shashikanth VH6de20d32015-10-09 12:04:13 +053045
46 /**
Shashikanth VHf62b5c02015-11-20 22:23:08 +053047 * Register a listener for BGP message events.
48 *
49 * @param listener the listener to notify
50 */
51 void addListener(BgpNodeListener listener);
52
53 /**
54 * Unregister a listener.
55 *
56 * @param listener the listener to unregister
57 */
58 void removeListener(BgpNodeListener listener);
59
60 /**
Satish Ke107e662015-09-21 19:00:17 +053061 * Send a message to a particular bgp peer.
62 *
63 * @param bgpId the id of the peer to send message.
64 * @param msg the message to send
65 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053066 void writeMsg(BgpId bgpId, BgpMessage msg);
Satish Ke107e662015-09-21 19:00:17 +053067
68 /**
69 * Process a message and notify the appropriate listeners.
70 *
71 * @param bgpId id of the peer the message arrived on
72 * @param msg the message to process.
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053073 * @throws BgpParseException on data processing error
Satish Ke107e662015-09-21 19:00:17 +053074 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053075 void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
Satish Ke107e662015-09-21 19:00:17 +053076
77 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053078 * Close all connected BGP peers.
79 *
80 */
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();
Shashikanth VHf62b5c02015-11-20 22:23:08 +0530131}