blob: 9f4d47da05b49e70a77213dc7b187a49d2afba24 [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;
Priyanka Bc08e56d2015-11-27 15:28:33 +053019import org.onosproject.bgpio.exceptions.BgpParseException;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053020import org.onosproject.bgpio.protocol.BgpFactory;
21import org.onosproject.bgpio.protocol.BgpMessage;
Priyanka Bc08e56d2015-11-27 15:28:33 +053022import org.onosproject.bgpio.types.BgpValueType;
Shashikanth VH6de20d32015-10-09 12:04:13 +053023
24/**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053025 * Represents the peer side of an BGP peer.
Shashikanth VH6de20d32015-10-09 12:04:13 +053026 *
27 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053028public interface BgpPeer {
Shashikanth VH6de20d32015-10-09 12:04:13 +053029
30 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053031 * Sets the associated Netty channel for this bgp peer.
32 *
33 * @param channel the Netty channel
34 */
35 void setChannel(Channel channel);
36
37 /**
38 * Gets the associated Netty channel handler for this bgp peer.
39 *
40 * @return Channel channel connected.
41 */
42 Channel getChannel();
43
44 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053045 * Sets whether the bgp peer is connected.
46 *
47 * @param connected whether the bgp peer is connected
48 */
49 void setConnected(boolean connected);
50
51 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053052 * Checks whether the handshake is complete.
53 *
54 * @return true is finished, false if not.
55 */
56 boolean isHandshakeComplete();
57
58 /**
59 * Writes the message to the peer.
60 *
61 * @param msg the message to write
62 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053063 void sendMessage(BgpMessage msg);
Shashikanth VH6de20d32015-10-09 12:04:13 +053064
65 /**
66 * Writes the BGPMessage list to the peer.
67 *
68 * @param msgs the messages to be written
69 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053070 void sendMessage(List<BgpMessage> msgs);
Shashikanth VH6de20d32015-10-09 12:04:13 +053071
72 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053073 * Provides the factory for BGP version.
Shashikanth VH6de20d32015-10-09 12:04:13 +053074 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +053075 * @return BGP version specific factory.
Shashikanth VH6de20d32015-10-09 12:04:13 +053076 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053077 BgpFactory factory();
Shashikanth VH6de20d32015-10-09 12:04:13 +053078
79 /**
80 * Checks if the bgp peer is still connected.
81 *
82 * @return whether the bgp peer is still connected
83 */
84 boolean isConnected();
85
86 /**
87 * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's
88 * channelDisconnected method for cleanup
89 */
90 void disconnectPeer();
91
92 /**
93 * Identifies the channel used to communicate with the bgp peer.
94 *
95 * @return string representation of the connection to the peer
96 */
97 String channelId();
98
99 /**
Priyanka Bc08e56d2015-11-27 15:28:33 +0530100 * Maintaining Adj-RIB-In separately for each peer.
101 *
102 * @param pathAttr list of Bgp path attributes
103 * @throws BgpParseException while building Adj-Rib-In
104 */
105 void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException;
106
107 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530108 * Return the BGP session info.
Shashikanth VH6de20d32015-10-09 12:04:13 +0530109 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530110 * @return sessionInfo bgp session info
Shashikanth VH6de20d32015-10-09 12:04:13 +0530111 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530112 BgpSessionInfo sessionInfo();
Shashikanth VH6de20d32015-10-09 12:04:13 +0530113}