blob: ab261730609fbd19995249120e57039973a782bb [file] [log] [blame]
Shashikanth VH6de20d32015-10-09 12:04:13 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Shashikanth VH6de20d32015-10-09 12:04:13 +05303 *
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;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053019import org.onlab.packet.IpAddress;
Priyanka Bc08e56d2015-11-27 15:28:33 +053020import org.onosproject.bgpio.exceptions.BgpParseException;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053021import org.onosproject.bgpio.protocol.BgpEvpnNlri;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053022import org.onosproject.bgpio.protocol.BgpFactory;
23import org.onosproject.bgpio.protocol.BgpMessage;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053024import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri;
25import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecRouteKey;
Priyanka Bc08e56d2015-11-27 15:28:33 +053026import org.onosproject.bgpio.types.BgpValueType;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053027import org.onosproject.bgpio.types.attr.WideCommunity;
Shashikanth VH6de20d32015-10-09 12:04:13 +053028
29/**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053030 * Represents the peer side of an BGP peer.
Shashikanth VH6de20d32015-10-09 12:04:13 +053031 *
32 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053033public interface BgpPeer {
Shashikanth VH6de20d32015-10-09 12:04:13 +053034
Shashikanth VHafb2e002016-02-12 14:48:29 +053035 enum FlowSpecOperation {
36
37 /**
38 * Signifies addition of flow specification rule.
39 */
40 ADD,
41
42 /**
43 * Signifies updation of flow specification rule.
44 */
45 UPDATE,
46
47 /**
48 * Signifies deletion of flow specification rule.
49 */
50 DELETE
51 }
Shashikanth VH6de20d32015-10-09 12:04:13 +053052 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053053 * Sets the associated Netty channel for this bgp peer.
54 *
55 * @param channel the Netty channel
56 */
57 void setChannel(Channel channel);
58
59 /**
60 * Gets the associated Netty channel handler for this bgp peer.
61 *
62 * @return Channel channel connected.
63 */
64 Channel getChannel();
65
66 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053067 * Sets whether the bgp peer is connected.
68 *
69 * @param connected whether the bgp peer is connected
70 */
71 void setConnected(boolean connected);
72
73 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053074 * Checks whether the handshake is complete.
75 *
76 * @return true is finished, false if not.
77 */
78 boolean isHandshakeComplete();
79
80 /**
81 * Writes the message to the peer.
82 *
83 * @param msg the message to write
84 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053085 void sendMessage(BgpMessage msg);
Shashikanth VH6de20d32015-10-09 12:04:13 +053086
87 /**
88 * Writes the BGPMessage list to the peer.
89 *
90 * @param msgs the messages to be written
91 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053092 void sendMessage(List<BgpMessage> msgs);
Shashikanth VH6de20d32015-10-09 12:04:13 +053093
94 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053095 * Provides the factory for BGP version.
Shashikanth VH6de20d32015-10-09 12:04:13 +053096 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +053097 * @return BGP version specific factory.
Shashikanth VH6de20d32015-10-09 12:04:13 +053098 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053099 BgpFactory factory();
Shashikanth VH6de20d32015-10-09 12:04:13 +0530100
101 /**
102 * Checks if the bgp peer is still connected.
103 *
104 * @return whether the bgp peer is still connected
105 */
106 boolean isConnected();
107
108 /**
109 * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's
110 * channelDisconnected method for cleanup
111 */
112 void disconnectPeer();
113
114 /**
115 * Identifies the channel used to communicate with the bgp peer.
116 *
117 * @return string representation of the connection to the peer
118 */
119 String channelId();
120
121 /**
Priyanka Bc08e56d2015-11-27 15:28:33 +0530122 * Maintaining Adj-RIB-In separately for each peer.
123 *
124 * @param pathAttr list of Bgp path attributes
125 * @throws BgpParseException while building Adj-Rib-In
126 */
127 void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException;
128
129 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530130 * Return the BGP session info.
Shashikanth VH6de20d32015-10-09 12:04:13 +0530131 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530132 * @return sessionInfo bgp session info
Shashikanth VH6de20d32015-10-09 12:04:13 +0530133 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530134 BgpSessionInfo sessionInfo();
Shashikanth VHafb2e002016-02-12 14:48:29 +0530135
136 /**
137 * Updates flow specification rule.
138 *
139 * @param operType operation type add or delete or update
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530140 * @param routeKey flow route key for the flow rule
Shashikanth VHafb2e002016-02-12 14:48:29 +0530141 * @param flowSpec BGP flow specification components
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530142 * @param wideCommunity for route policy
Shashikanth VHafb2e002016-02-12 14:48:29 +0530143 */
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530144 void updateFlowSpec(FlowSpecOperation operType, BgpFlowSpecRouteKey routeKey,
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530145 BgpFlowSpecNlri flowSpec, WideCommunity wideCommunity);
146
147 /**
148 * Updates evpn rule.
149 *
150 * @param operType operation type add or delete or update
151 * @param nextHop next Hop
152 * @param extcommunity extended community
153 * @param evpnNlris list of evpnNlri
154 */
155 void updateEvpnNlri(FlowSpecOperation operType, IpAddress nextHop,
156 List<BgpValueType> extcommunity,
157 List<BgpEvpnNlri> evpnNlris);
Shashikanth VH6de20d32015-10-09 12:04:13 +0530158}