Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.bgp.controller; |
| 18 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame^] | 19 | import java.util.Map; |
| 20 | |
| 21 | import org.onosproject.bgpio.exceptions.BGPParseException; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 22 | import 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 | */ |
| 28 | public interface BGPController { |
| 29 | |
| 30 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 31 | * 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 K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 46 | * 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 VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame^] | 58 | * @throws BGPParseException on data processing error |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 59 | */ |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame^] | 60 | void processBGPPacket(BGPId bgpId, BGPMessage msg) throws BGPParseException; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 61 | |
| 62 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 63 | * Close all connected BGP peers. |
| 64 | * |
| 65 | */ |
| 66 | void closeConnectedPeers(); |
| 67 | |
| 68 | /** |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 69 | * Get the BGPConfig class to the caller. |
| 70 | * |
| 71 | * @return configuration object |
| 72 | */ |
| 73 | BGPCfg getConfig(); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Get the BGP connected peers to this controller. |
| 77 | * |
| 78 | * @return the integer number |
| 79 | */ |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame^] | 80 | 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 K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 95 | } |