Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.bgp.controller; |
| 18 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 19 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 20 | import org.onosproject.bgpio.protocol.BgpMessage; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 21 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 22 | import java.util.Map; |
| 23 | import java.util.Set; |
| 24 | |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 25 | /** |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 26 | * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on |
| 27 | * bgp events |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 28 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 29 | public interface BgpController { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 30 | |
| 31 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 32 | * Returns list of bgp peers connected to this BGP controller. |
| 33 | * |
| 34 | * @return Iterable of BGPPeer elements |
| 35 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 36 | Iterable<BgpPeer> getPeers(); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 37 | |
| 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 VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 44 | BgpPeer getPeer(BgpId bgpId); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 45 | |
| 46 | /** |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 47 | * 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 K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 61 | * 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 VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 66 | void writeMsg(BgpId bgpId, BgpMessage msg); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 67 | |
| 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 VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 73 | * @throws BgpParseException on data processing error |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 74 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 75 | void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 76 | |
| 77 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 78 | * Close all connected BGP peers. |
| 79 | * |
| 80 | */ |
| 81 | void closeConnectedPeers(); |
| 82 | |
| 83 | /** |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 84 | * Get the BGPConfig class to the caller. |
| 85 | * |
| 86 | * @return configuration object |
| 87 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 88 | BgpCfg getConfig(); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Get the BGP connected peers to this controller. |
| 92 | * |
| 93 | * @return the integer number |
| 94 | */ |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 95 | int connectedPeerCount(); |
| 96 | |
| 97 | /** |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 98 | * 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 VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 112 | * 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 VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 123 | Map<BgpId, BgpPeer> connectedPeers(); |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Return BGP node listener. |
| 127 | * |
| 128 | * @return node listener |
| 129 | */ |
| 130 | Set<BgpNodeListener> listener(); |
Priyanka B | fc51c95 | 2016-03-26 14:30:33 +0530 | [diff] [blame] | 131 | |
| 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(); |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 152 | } |