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