blob: f7bb52628419532abd3abf69169848c7af8c67f3 [file] [log] [blame]
Pavlin Radoslavov8a36ce32015-01-28 12:26:57 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Pavlin Radoslavov8a36ce32015-01-28 12:26:57 -08003 *
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 */
Jonathan Hartf4bd0482017-01-27 15:11:18 -080016
Jonathan Hart41349e92015-02-09 14:14:02 -080017package org.onosproject.routing.bgp;
18
19import org.onlab.packet.Ip4Address;
Pavlin Radoslavov8a36ce32015-01-28 12:26:57 -080020
21import java.net.SocketAddress;
Pavlin Radoslavov8a36ce32015-01-28 12:26:57 -080022
23/**
24 * Class for keeping information about a BGP session.
25 *
26 * There are two instances per each BGP peer session: one to keep the local
27 * information about the BGP session, and another to keep information about
28 * the remote BGP peer.
29 */
30public class BgpSessionInfo {
31 private SocketAddress address; // IP addr/port
32 private Ip4Address ip4Address; // IPv4 address
33 private int bgpVersion; // 1 octet
34 private long asNumber; // AS number: 2 octets
35 private long as4Number; // AS4 number: 4 octets
36 private long holdtime; // 2 octets
37 private Ip4Address bgpId; // 4 octets -> IPv4 address
38 private boolean mpExtensions; // Multiprotocol Extensions
39 // enabled: RFC 4760
40 private boolean ipv4Unicast; // IPv4/UNICAST AFI/SAFI
41 private boolean ipv4Multicast; // IPv4/MULTICAST AFI/SAFI
42 private boolean ipv6Unicast; // IPv6/UNICAST AFI/SAFI
43 private boolean ipv6Multicast; // IPv6/MULTICAST AFI/SAFI
44 private boolean as4OctetCapability; // AS 4 octet path capability
45
46 /**
47 * Gets the BGP session address: local or remote.
48 *
49 * @return the BGP session address
50 */
51 public SocketAddress address() {
52 return this.address;
53 }
54
55 /**
56 * Sets the BGP session address: local or remote.
57 *
58 * @param address the BGP session address to set
59 */
60 public void setAddress(SocketAddress address) {
61 this.address = address;
62 }
63
64 /**
65 * Gets the BGP session IPv4 address: local or remote.
66 *
67 * @return the BGP session IPv4 address
68 */
69 public Ip4Address ip4Address() {
70 return this.ip4Address;
71 }
72
73 /**
74 * Sets the BGP session IPv4 address: local or remote.
75 *
76 * @param ip4Address the BGP session IPv4 address to set
77 */
78 public void setIp4Address(Ip4Address ip4Address) {
79 this.ip4Address = ip4Address;
80 }
81
82 /**
83 * Gets the BGP session BGP version: local or remote.
84 *
85 * @return the BGP session BGP version
86 */
87 public int bgpVersion() {
88 return this.bgpVersion;
89 }
90
91 /**
92 * Sets the BGP session BGP version: local or remote.
93 *
94 * @param bgpVersion the BGP session BGP version to set
95 */
96 public void setBgpVersion(int bgpVersion) {
97 this.bgpVersion = bgpVersion;
98 }
99
100 /**
101 * Gets the BGP session AS number: local or remote.
102 *
103 * @return the BGP session AS number
104 */
105 public long asNumber() {
106 return this.asNumber;
107 }
108
109 /**
110 * Sets the BGP session AS number: local or remote.
111 *
112 * @param asNumber the BGP session AS number to set
113 */
114 public void setAsNumber(long asNumber) {
115 this.asNumber = asNumber;
116 }
117
118 /**
119 * Gets the BGP session AS4 number: local or remote.
120 *
121 * @return the BGP session AS4 number
122 */
123 public long as4Number() {
124 return this.as4Number;
125 }
126
127 /**
128 * Sets the BGP session AS4 number: local or remote.
129 *
130 * @param as4Number the BGP session AS4 number to set
131 */
132 public void setAs4Number(long as4Number) {
133 this.as4Number = as4Number;
134 }
135
136 /**
137 * Gets the BGP session holdtime: local or remote.
138 *
139 * @return the BGP session holdtime
140 */
141 public long holdtime() {
142 return this.holdtime;
143 }
144
145 /**
146 * Sets the BGP session holdtime: local or remote.
147 *
148 * @param holdtime the BGP session holdtime to set
149 */
150 public void setHoldtime(long holdtime) {
151 this.holdtime = holdtime;
152 }
153
154 /**
155 * Gets the BGP session BGP Identifier as an IPv4 address: local or remote.
156 *
157 * @return the BGP session BGP Identifier as an IPv4 address
158 */
159 public Ip4Address bgpId() {
160 return this.bgpId;
161 }
162
163 /**
164 * Sets the BGP session BGP Identifier as an IPv4 address: local or remote.
165 *
166 * @param bgpId the BGP session BGP Identifier to set
167 */
168 public void setBgpId(Ip4Address bgpId) {
169 this.bgpId = bgpId;
170 }
171
172 /**
173 * Gets the BGP Multiprotocol Extensions: local or remote.
174 *
175 * @return true if the BGP Multiprotocol Extensions are enabled, otherwise
176 * false
177 */
178 public boolean mpExtensions() {
179 return this.mpExtensions;
180 }
181
182 /**
183 * Gets the BGP session AFI/SAFI configuration for IPv4 unicast: local or
184 * remote.
185 *
186 * @return the BGP session AFI/SAFI configuration for IPv4 unicast
187 */
188 public boolean ipv4Unicast() {
189 return ipv4Unicast;
190 }
191
192 /**
193 * Sets the BGP session AFI/SAFI configuration for IPv4 unicast: local or
194 * remote.
195 */
196 public void setIpv4Unicast() {
197 this.mpExtensions = true;
198 this.ipv4Unicast = true;
199 }
200
201 /**
202 * Gets the BGP session AFI/SAFI configuration for IPv4 multicast: local or
203 * remote.
204 *
205 * @return the BGP session AFI/SAFI configuration for IPv4 multicast
206 */
207 public boolean ipv4Multicast() {
208 return ipv4Multicast;
209 }
210
211 /**
212 * Sets the BGP session AFI/SAFI configuration for IPv4 multicast: local or
213 * remote.
214 */
215 public void setIpv4Multicast() {
216 this.mpExtensions = true;
217 this.ipv4Multicast = true;
218 }
219
220 /**
221 * Gets the BGP session AFI/SAFI configuration for IPv6 unicast: local or
222 * remote.
223 *
224 * @return the BGP session AFI/SAFI configuration for IPv6 unicast
225 */
226 public boolean ipv6Unicast() {
227 return ipv6Unicast;
228 }
229
230 /**
231 * Sets the BGP session AFI/SAFI configuration for IPv6 unicast: local or
232 * remote.
233 */
234 void setIpv6Unicast() {
235 this.mpExtensions = true;
236 this.ipv6Unicast = true;
237 }
238
239 /**
240 * Gets the BGP session AFI/SAFI configuration for IPv6 multicast: local or
241 * remote.
242 *
243 * @return the BGP session AFI/SAFI configuration for IPv6 multicast
244 */
245 public boolean ipv6Multicast() {
246 return ipv6Multicast;
247 }
248
249 /**
250 * Sets the BGP session AFI/SAFI configuration for IPv6 multicast: local or
251 * remote.
252 */
253 public void setIpv6Multicast() {
254 this.mpExtensions = true;
255 this.ipv6Multicast = true;
256 }
257
258 /**
259 * Gets the BGP session 4 octet AS path capability: local or remote.
260 *
261 * @return true when the BGP session has 4 octet AS path capability
262 */
263 public boolean as4OctetCapability() {
264 return this.as4OctetCapability;
265 }
266
267 /**
268 * Sets the BGP session 4 octet AS path capability.
269 */
270 public void setAs4OctetCapability() {
271 this.as4OctetCapability = true;
272 }
273}