aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java
blob: 46165d872bdfbb1a8dbbecee859f1a4a75f70342 (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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
 * 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.bgp.controller;

import java.util.TreeMap;

/**
 * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller.
 */
public interface BGPCfg {

    enum State {
        /**
         * Signifies that its just created.
         */
        INIT,

        /**
         * Signifies that only IP Address is configured.
         */
        IP_CONFIGURED,

        /**
         * Signifies that only Autonomous System is configured.
         */
        AS_CONFIGURED,

        /**
         * Signifies that both IP and Autonomous System is configured.
         */
        IP_AS_CONFIGURED
    }

    /**
     * Returns the status of the configuration based on this state certain operations like connection is handled.
     *
     * @return State of the configuration
     */
    State getState();

    /**
     * To set the current state of the configuration.
     *
     * @param state Configuration State enum
     */
    void setState(State state);

    /**
     * Get the status of the link state support for this BGP speaker.
     *
     * @return  true if the link state is supported else false
     */
    boolean getLsCapability();

    /**
     * Set the link state support to this BGP speaker.
     *
     * @param lscapability true value if link state is supported else false
     */
    void setLsCapability(boolean lscapability);

    /**
     * Get the status of the 32 bit AS support for this BGP speaker.
     *
     * @return true if the 32 bit AS number is supported else false
     */
    boolean getLargeASCapability();

    /**
     * Set the 32 bit AS support capability to this BGP speaker.
     *
     * @param largeAs  true value if the 32 bit AS is supported else false
     */
    void setLargeASCapability(boolean largeAs);

    /**
     * Set the AS number to which this BGP speaker belongs.
     *
     * @param localAs 16 or 32 bit AS number, length is dependent on the capability
     */
    void setAsNumber(int localAs);

    /**
     * Get the AS number to which this BGP speaker belongs.
     *
     * @return 16 or 32 bit AS number, length is dependent on the capability
     */
    int getAsNumber();

    /**
     * Get the connection retry count number.
     *
     * @return connection retry count if there is a connection error
     */
    int getMaxConnRetryCount();

    /**
     * Set the connection retry count.
     *
     * @param retryCount number of times to try to connect if there is any error
     */
    void setMaxConnRetryCout(int retryCount);

    /**
     * Get the connection retry time in seconds.
     *
     * @return connection retry time in seconds
     */
    int getMaxConnRetryTime();

    /**
     * Set the connection retry time in seconds.
     *
     * @param retryTime connection retry times in seconds
     */
    void setMaxConnRetryTime(int retryTime);

    /**
     * Set the keep alive timer for the connection.
     *
     * @param holdTime connection hold timer in seconds
     */
    void setHoldTime(short holdTime);

    /**
     * Returns the connection hold timer in seconds.
     *
     * @return connection hold timer in seconds
     */
    short getHoldTime();

    /**
     * Returns the maximum number of session supported.
     *
     * @return maximum number of session supported
     */
    int getMaxSession();

    /**
     * Set the maximum number of sessions to support.
     *
     * @param maxsession maximum number of session
     */
    void setMaxSession(int maxsession);

    /**
     * Returns the Router ID of this BGP speaker.
     *
     * @return IP address in string format
     */
    String getRouterId();

    /**
     * Set the Router ID of this BGP speaker.
     *
     * @param routerid  IP address in string format
     */
    void setRouterId(String routerid);

    /**
     * Add the BGP peer IP address and the AS number to which it belongs.
     *
     * @param routerid IP address in string format
     * @param remoteAs  AS number to which it belongs
     *
     * @return true if added successfully else false
     */
    boolean addPeer(String routerid, int remoteAs);

    /**
     * Add the BGP peer IP address and the keep alive time.
     *
     * @param routerid IP address in string format
     * @param holdTime keep alive time for the connection
     *
     * @return true if added successfully else false
     */
    boolean addPeer(String routerid, short holdTime);

    /**
     * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
     *
     * @param routerid IP address in string format
     * @param remoteAs AS number to which it belongs
     * @param holdTime keep alive time for the connection
     *
     * @return  true if added successfully else false
     */
    boolean addPeer(String routerid, int remoteAs, short holdTime);

    /**
     * Remove the BGP peer with this IP address.
     *
     * @param routerid router IP address
     *
     * @return true if removed successfully else false
     */
    boolean removePeer(String routerid);

    /**
     * Connect to BGP peer with this IP address.
     *
     * @param routerid router IP address
     *
     * @return  true of the configuration is found and able to connect else false
     */
    boolean connectPeer(String routerid);

    /**
     * Disconnect this BGP peer with this IP address.
     *
     * @param routerid  router IP address in string format
     *
     * @return true if the configuration is found and able to disconnect else false
     */
    boolean disconnectPeer(String routerid);

    /**
     * Returns the peer tree information.
     *
     * @return return the tree map with IP as key and BGPPeerCfg as object
     */
    TreeMap<String, BGPPeerCfg> displayPeers();

    /**
     * Return the BGP Peer information with this matching IP.
     *
     * @param routerid router IP address in string format
     *
     * @return BGPPeerCfg object
     */
    BGPPeerCfg displayPeers(String routerid);

    /**
     * Check if this BGP peer is configured.
     *
     * @param routerid  router IP address in string format
     *
     * @return  true if configured exists else false
     */
    boolean isPeerConfigured(String routerid);

    /**
     * Check if this BGP speaker is having connection with the peer.
     *
     * @param routerid router IP address in string format
     *
     * @return true if the connection exists else false
     */
    boolean isPeerConnected(String routerid);

    /**
     * Return the peer tree map.
     *
     * @return return the tree map with IP as key and BGPPeerCfg as object
     */
    TreeMap<String, BGPPeerCfg> getPeerTree();

    /**
     * Set the current connection state information.
     *
     * @param routerid  router IP address in string format
     * @param state state information
     */
    void setPeerConnState(String routerid, BGPPeerCfg.State state);

    /**
     * Check if the peer can be connected or not.
     *
     * @param routerid  router IP address in string format
     *
     * @return  true if the peer can be connected else false
     */
    boolean isPeerConnectable(String routerid);

    /**
     * Get the current peer connection state information.
     *
     * @param routerid router IP address in string format
     *
     * @return state information
     */
    BGPPeerCfg.State getPeerConnState(String routerid);
}