blob: faa1de3ea4ee6ec0532b1ccb07cf9c5a8018a41d [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;
20
21import org.onosproject.bgpio.exceptions.BGPParseException;
Satish Ke107e662015-09-21 19:00:17 +053022import org.onosproject.bgpio.protocol.BGPMessage;
23
24/**
25 * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners
26 * on bgp events
27 */
28public interface BGPController {
29
30 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053031 * Returns list of bgp peers connected to this BGP controller.
32 *
33 * @return Iterable of BGPPeer elements
34 */
35 Iterable<BGPPeer> getPeers();
36
37 /**
38 * Returns the actual bgp peer for the given ip address.
39 *
40 * @param bgpId the id of the bgp peer to fetch
41 * @return the interface to this bgp peer
42 */
43 BGPPeer getPeer(BGPId bgpId);
44
45 /**
Satish Ke107e662015-09-21 19:00:17 +053046 * Send a message to a particular bgp peer.
47 *
48 * @param bgpId the id of the peer to send message.
49 * @param msg the message to send
50 */
51 void writeMsg(BGPId bgpId, BGPMessage msg);
52
53 /**
54 * Process a message and notify the appropriate listeners.
55 *
56 * @param bgpId id of the peer the message arrived on
57 * @param msg the message to process.
Shashikanth VH9f8afb42015-11-04 18:00:30 +053058 * @throws BGPParseException on data processing error
Satish Ke107e662015-09-21 19:00:17 +053059 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +053060 void processBGPPacket(BGPId bgpId, BGPMessage msg) throws BGPParseException;
Satish Ke107e662015-09-21 19:00:17 +053061
62 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053063 * Close all connected BGP peers.
64 *
65 */
66 void closeConnectedPeers();
67
68 /**
Satish Ke107e662015-09-21 19:00:17 +053069 * Get the BGPConfig class to the caller.
70 *
71 * @return configuration object
72 */
73 BGPCfg getConfig();
Shashikanth VH6de20d32015-10-09 12:04:13 +053074
75 /**
76 * Get the BGP connected peers to this controller.
77 *
78 * @return the integer number
79 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +053080 int connectedPeerCount();
81
82 /**
83 * Return BGP peer manager.
84 *
85 * @return BGPPeerManager peer manager instance
86 */
87 BgpPeerManager peerManager();
88
89 /**
90 * Return BGP connected peers.
91 *
92 * @return connectedPeers connected peers
93 */
94 Map<BGPId, BGPPeer> connectedPeers();
Satish Ke107e662015-09-21 19:00:17 +053095}