blob: df163462dccbf7c2b1abfa48427048564fdede04 [file] [log] [blame]
Shashikanth VH6de20d32015-10-09 12:04:13 +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 */
16package org.onosproject.bgp.controller;
17import java.util.List;
18import org.jboss.netty.channel.Channel;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053019import org.onosproject.bgpio.protocol.BgpFactory;
20import org.onosproject.bgpio.protocol.BgpMessage;
Shashikanth VH6de20d32015-10-09 12:04:13 +053021
22/**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053023 * Represents the peer side of an BGP peer.
Shashikanth VH6de20d32015-10-09 12:04:13 +053024 *
25 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053026public interface BgpPeer {
Shashikanth VH6de20d32015-10-09 12:04:13 +053027
28 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053029 * 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 VH6de20d32015-10-09 12:04:13 +053043 * 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 VH6de20d32015-10-09 12:04:13 +053050 * 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 VH5dd8dbe2015-11-26 13:22:18 +053061 void sendMessage(BgpMessage msg);
Shashikanth VH6de20d32015-10-09 12:04:13 +053062
63 /**
64 * Writes the BGPMessage list to the peer.
65 *
66 * @param msgs the messages to be written
67 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053068 void sendMessage(List<BgpMessage> msgs);
Shashikanth VH6de20d32015-10-09 12:04:13 +053069
70 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053071 * Provides the factory for BGP version.
Shashikanth VH6de20d32015-10-09 12:04:13 +053072 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +053073 * @return BGP version specific factory.
Shashikanth VH6de20d32015-10-09 12:04:13 +053074 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053075 BgpFactory factory();
Shashikanth VH6de20d32015-10-09 12:04:13 +053076
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 VH9f8afb42015-11-04 18:00:30 +053098 * Return the BGP session info.
Shashikanth VH6de20d32015-10-09 12:04:13 +053099 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530100 * @return sessionInfo bgp session info
Shashikanth VH6de20d32015-10-09 12:04:13 +0530101 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530102 BgpSessionInfo sessionInfo();
Shashikanth VH6de20d32015-10-09 12:04:13 +0530103}