Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +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 | package org.onosproject.bgp.controller; |
| 17 | import java.util.List; |
| 18 | import org.jboss.netty.channel.Channel; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame^] | 19 | import org.onosproject.bgpio.protocol.BgpFactory; |
| 20 | import org.onosproject.bgpio.protocol.BgpMessage; |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 21 | |
| 22 | /** |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 23 | * Represents the peer side of an BGP peer. |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 24 | * |
| 25 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame^] | 26 | public interface BgpPeer { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 27 | |
| 28 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 29 | * Sets the associated Netty channel for this bgp peer. |
| 30 | * |
| 31 | * @param channel the Netty channel |
| 32 | */ |
| 33 | void setChannel(Channel channel); |
| 34 | |
| 35 | /** |
| 36 | * Gets the associated Netty channel handler for this bgp peer. |
| 37 | * |
| 38 | * @return Channel channel connected. |
| 39 | */ |
| 40 | Channel getChannel(); |
| 41 | |
| 42 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 43 | * Sets whether the bgp peer is connected. |
| 44 | * |
| 45 | * @param connected whether the bgp peer is connected |
| 46 | */ |
| 47 | void setConnected(boolean connected); |
| 48 | |
| 49 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 50 | * Checks whether the handshake is complete. |
| 51 | * |
| 52 | * @return true is finished, false if not. |
| 53 | */ |
| 54 | boolean isHandshakeComplete(); |
| 55 | |
| 56 | /** |
| 57 | * Writes the message to the peer. |
| 58 | * |
| 59 | * @param msg the message to write |
| 60 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame^] | 61 | void sendMessage(BgpMessage msg); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Writes the BGPMessage list to the peer. |
| 65 | * |
| 66 | * @param msgs the messages to be written |
| 67 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame^] | 68 | void sendMessage(List<BgpMessage> msgs); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 69 | |
| 70 | /** |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 71 | * Provides the factory for BGP version. |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 72 | * |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 73 | * @return BGP version specific factory. |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 74 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame^] | 75 | BgpFactory factory(); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * Checks if the bgp peer is still connected. |
| 79 | * |
| 80 | * @return whether the bgp peer is still connected |
| 81 | */ |
| 82 | boolean isConnected(); |
| 83 | |
| 84 | /** |
| 85 | * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's |
| 86 | * channelDisconnected method for cleanup |
| 87 | */ |
| 88 | void disconnectPeer(); |
| 89 | |
| 90 | /** |
| 91 | * Identifies the channel used to communicate with the bgp peer. |
| 92 | * |
| 93 | * @return string representation of the connection to the peer |
| 94 | */ |
| 95 | String channelId(); |
| 96 | |
| 97 | /** |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 98 | * Return the BGP session info. |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 99 | * |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 100 | * @return sessionInfo bgp session info |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 101 | */ |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 102 | BgpSessionInfo sessionInfo(); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 103 | } |