summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionInfo.java
blob: a127455645d821dd516aa097d61eb092cb76c465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*
 * Copyright 2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.routing.bgp;

import org.onlab.packet.Ip4Address;

import java.net.SocketAddress;

/**
 * Class for keeping information about a BGP session.
 *
 * There are two instances per each BGP peer session: one to keep the local
 * information about the BGP session, and another to keep information about
 * the remote BGP peer.
 */
public class BgpSessionInfo {
    private SocketAddress address;              // IP addr/port
    private Ip4Address ip4Address;              // IPv4 address
    private int bgpVersion;                     // 1 octet
    private long asNumber;                      // AS number: 2 octets
    private long as4Number;                     // AS4 number: 4 octets
    private long holdtime;                      // 2 octets
    private Ip4Address bgpId;                   // 4 octets -> IPv4 address
    private boolean mpExtensions;               // Multiprotocol Extensions
                                                // enabled: RFC 4760
    private boolean ipv4Unicast;                // IPv4/UNICAST AFI/SAFI
    private boolean ipv4Multicast;              // IPv4/MULTICAST AFI/SAFI
    private boolean ipv6Unicast;                // IPv6/UNICAST AFI/SAFI
    private boolean ipv6Multicast;              // IPv6/MULTICAST AFI/SAFI
    private boolean as4OctetCapability;         // AS 4 octet path capability

    /**
     * Gets the BGP session address: local or remote.
     *
     * @return the BGP session address
     */
    public SocketAddress address() {
        return this.address;
    }

    /**
     * Sets the BGP session address: local or remote.
     *
     * @param address the BGP session address to set
     */
    public void setAddress(SocketAddress address) {
        this.address = address;
    }

    /**
     * Gets the BGP session IPv4 address: local or remote.
     *
     * @return the BGP session IPv4 address
     */
    public Ip4Address ip4Address() {
        return this.ip4Address;
    }

    /**
     * Sets the BGP session IPv4 address: local or remote.
     *
     * @param ip4Address the BGP session IPv4 address to set
     */
    public void setIp4Address(Ip4Address ip4Address) {
        this.ip4Address = ip4Address;
    }

    /**
     * Gets the BGP session BGP version: local or remote.
     *
     * @return the BGP session BGP version
     */
    public int bgpVersion() {
        return this.bgpVersion;
    }

    /**
     * Sets the BGP session BGP version: local or remote.
     *
     * @param bgpVersion the BGP session BGP version to set
     */
    public void setBgpVersion(int bgpVersion) {
        this.bgpVersion = bgpVersion;
    }

    /**
     * Gets the BGP session AS number: local or remote.
     *
     * @return the BGP session AS number
     */
    public long asNumber() {
        return this.asNumber;
    }

    /**
     * Sets the BGP session AS number: local or remote.
     *
     * @param asNumber the BGP session AS number to set
     */
    public void setAsNumber(long asNumber) {
        this.asNumber = asNumber;
    }

    /**
     * Gets the BGP session AS4 number: local or remote.
     *
     * @return the BGP session AS4 number
     */
    public long as4Number() {
        return this.as4Number;
    }

    /**
     * Sets the BGP session AS4 number: local or remote.
     *
     * @param as4Number the BGP session AS4 number to set
     */
    public void setAs4Number(long as4Number) {
        this.as4Number = as4Number;
    }

    /**
     * Gets the BGP session holdtime: local or remote.
     *
     * @return the BGP session holdtime
     */
    public long holdtime() {
        return this.holdtime;
    }

    /**
     * Sets the BGP session holdtime: local or remote.
     *
     * @param holdtime the BGP session holdtime to set
     */
    public void setHoldtime(long holdtime) {
        this.holdtime = holdtime;
    }

    /**
     * Gets the BGP session BGP Identifier as an IPv4 address: local or remote.
     *
     * @return the BGP session BGP Identifier as an IPv4 address
     */
    public Ip4Address bgpId() {
        return this.bgpId;
    }

    /**
     * Sets the BGP session BGP Identifier as an IPv4 address: local or remote.
     *
     * @param bgpId the BGP session BGP Identifier to set
     */
    public void setBgpId(Ip4Address bgpId) {
        this.bgpId = bgpId;
    }

    /**
     * Gets the BGP Multiprotocol Extensions: local or remote.
     *
     * @return true if the BGP Multiprotocol Extensions are enabled, otherwise
     * false
     */
    public boolean mpExtensions() {
        return this.mpExtensions;
    }

    /**
     * Gets the BGP session AFI/SAFI configuration for IPv4 unicast: local or
     * remote.
     *
     * @return the BGP session AFI/SAFI configuration for IPv4 unicast
     */
    public boolean ipv4Unicast() {
        return ipv4Unicast;
    }

    /**
     * Sets the BGP session AFI/SAFI configuration for IPv4 unicast: local or
     * remote.
     */
    public void setIpv4Unicast() {
        this.mpExtensions = true;
        this.ipv4Unicast = true;
    }

    /**
     * Gets the BGP session AFI/SAFI configuration for IPv4 multicast: local or
     * remote.
     *
     * @return the BGP session AFI/SAFI configuration for IPv4 multicast
     */
    public boolean ipv4Multicast() {
        return ipv4Multicast;
    }

    /**
     * Sets the BGP session AFI/SAFI configuration for IPv4 multicast: local or
     * remote.
     */
    public void setIpv4Multicast() {
        this.mpExtensions = true;
        this.ipv4Multicast = true;
    }

    /**
     * Gets the BGP session AFI/SAFI configuration for IPv6 unicast: local or
     * remote.
     *
     * @return the BGP session AFI/SAFI configuration for IPv6 unicast
     */
    public boolean ipv6Unicast() {
        return ipv6Unicast;
    }

    /**
     * Sets the BGP session AFI/SAFI configuration for IPv6 unicast: local or
     * remote.
     */
    void setIpv6Unicast() {
        this.mpExtensions = true;
        this.ipv6Unicast = true;
    }

    /**
     * Gets the BGP session AFI/SAFI configuration for IPv6 multicast: local or
     * remote.
     *
     * @return the BGP session AFI/SAFI configuration for IPv6 multicast
     */
    public boolean ipv6Multicast() {
        return ipv6Multicast;
    }

    /**
     * Sets the BGP session AFI/SAFI configuration for IPv6 multicast: local or
     * remote.
     */
    public void setIpv6Multicast() {
        this.mpExtensions = true;
        this.ipv6Multicast = true;
    }

    /**
     * Gets the BGP session 4 octet AS path capability: local or remote.
     *
     * @return true when the BGP session has 4 octet AS path capability
     */
    public boolean as4OctetCapability() {
        return this.as4OctetCapability;
    }

    /**
     * Sets the BGP session 4 octet AS path capability.
     */
    public void setAs4OctetCapability() {
        this.as4OctetCapability = true;
    }
}