blob: 84ce3fde256920a56e2f0d98551dd269c495813d [file] [log] [blame]
Shashikanth VH6de20d32015-10-09 12:04:13 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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;
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;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053022import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri;
23import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecRouteKey;
Priyanka Bc08e56d2015-11-27 15:28:33 +053024import org.onosproject.bgpio.types.BgpValueType;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053025import org.onosproject.bgpio.types.attr.WideCommunity;
Shashikanth VH6de20d32015-10-09 12:04:13 +053026
27/**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053028 * Represents the peer side of an BGP peer.
Shashikanth VH6de20d32015-10-09 12:04:13 +053029 *
30 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053031public interface BgpPeer {
Shashikanth VH6de20d32015-10-09 12:04:13 +053032
Shashikanth VHafb2e002016-02-12 14:48:29 +053033 enum FlowSpecOperation {
34
35 /**
36 * Signifies addition of flow specification rule.
37 */
38 ADD,
39
40 /**
41 * Signifies updation of flow specification rule.
42 */
43 UPDATE,
44
45 /**
46 * Signifies deletion of flow specification rule.
47 */
48 DELETE
49 }
Shashikanth VH6de20d32015-10-09 12:04:13 +053050 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053051 * Sets the associated Netty channel for this bgp peer.
52 *
53 * @param channel the Netty channel
54 */
55 void setChannel(Channel channel);
56
57 /**
58 * Gets the associated Netty channel handler for this bgp peer.
59 *
60 * @return Channel channel connected.
61 */
62 Channel getChannel();
63
64 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053065 * Sets whether the bgp peer is connected.
66 *
67 * @param connected whether the bgp peer is connected
68 */
69 void setConnected(boolean connected);
70
71 /**
Shashikanth VH6de20d32015-10-09 12:04:13 +053072 * Checks whether the handshake is complete.
73 *
74 * @return true is finished, false if not.
75 */
76 boolean isHandshakeComplete();
77
78 /**
79 * Writes the message to the peer.
80 *
81 * @param msg the message to write
82 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053083 void sendMessage(BgpMessage msg);
Shashikanth VH6de20d32015-10-09 12:04:13 +053084
85 /**
86 * Writes the BGPMessage list to the peer.
87 *
88 * @param msgs the messages to be written
89 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053090 void sendMessage(List<BgpMessage> msgs);
Shashikanth VH6de20d32015-10-09 12:04:13 +053091
92 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +053093 * Provides the factory for BGP version.
Shashikanth VH6de20d32015-10-09 12:04:13 +053094 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +053095 * @return BGP version specific factory.
Shashikanth VH6de20d32015-10-09 12:04:13 +053096 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053097 BgpFactory factory();
Shashikanth VH6de20d32015-10-09 12:04:13 +053098
99 /**
100 * Checks if the bgp peer is still connected.
101 *
102 * @return whether the bgp peer is still connected
103 */
104 boolean isConnected();
105
106 /**
107 * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's
108 * channelDisconnected method for cleanup
109 */
110 void disconnectPeer();
111
112 /**
113 * Identifies the channel used to communicate with the bgp peer.
114 *
115 * @return string representation of the connection to the peer
116 */
117 String channelId();
118
119 /**
Priyanka Bc08e56d2015-11-27 15:28:33 +0530120 * Maintaining Adj-RIB-In separately for each peer.
121 *
122 * @param pathAttr list of Bgp path attributes
123 * @throws BgpParseException while building Adj-Rib-In
124 */
125 void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException;
126
127 /**
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530128 * Return the BGP session info.
Shashikanth VH6de20d32015-10-09 12:04:13 +0530129 *
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530130 * @return sessionInfo bgp session info
Shashikanth VH6de20d32015-10-09 12:04:13 +0530131 */
Shashikanth VH9f8afb42015-11-04 18:00:30 +0530132 BgpSessionInfo sessionInfo();
Shashikanth VHafb2e002016-02-12 14:48:29 +0530133
134 /**
135 * Updates flow specification rule.
136 *
137 * @param operType operation type add or delete or update
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530138 * @param routeKey flow route key for the flow rule
Shashikanth VHafb2e002016-02-12 14:48:29 +0530139 * @param flowSpec BGP flow specification components
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530140 * @param wideCommunity for route policy
Shashikanth VHafb2e002016-02-12 14:48:29 +0530141 */
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530142 void updateFlowSpec(FlowSpecOperation operType, BgpFlowSpecRouteKey routeKey,
143 BgpFlowSpecNlri flowSpec, WideCommunity wideCommunity);
Shashikanth VH6de20d32015-10-09 12:04:13 +0530144}