Thejaswi N K
Committed by Gerrit Code Review

[Emu][onos-2590] BGP SBI global and peer configuration

Change-Id: I02a60aad06226125a1da9d4e7ada18e07942c0e6
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-bgp</artifactId>
25 + <version>1.4.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-bgp-api</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>ONOS BGP controller subsystem API</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>org.onosproject</groupId>
37 + <artifactId>onos-bgpio</artifactId>
38 + </dependency>
39 + <dependency>
40 + <groupId>io.netty</groupId>
41 + <artifactId>netty</artifactId>
42 + </dependency>
43 + <dependency>
44 + <groupId>org.onosproject</groupId>
45 + <artifactId>onos-api</artifactId>
46 + </dependency>
47 + <dependency>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onlab-misc</artifactId>
50 + </dependency>
51 +
52 + </dependencies>
53 +
54 + <build>
55 + <plugins>
56 + <plugin>
57 + <groupId>org.apache.maven.plugins</groupId>
58 + <artifactId>maven-shade-plugin</artifactId>
59 + <version>2.3</version>
60 + <configuration>
61 + <artifactSet>
62 + <excludes>
63 + <exclude>io.netty:netty</exclude>
64 + <exclude>com.google.guava:guava</exclude>
65 + <exclude>org.slf4j:slfj-api</exclude>
66 + <exclude>ch.qos.logback:logback-core</exclude>
67 + <exclude>ch.qos.logback:logback-classic</exclude>
68 + <exclude>com.google.code.findbugs:annotations</exclude>
69 + </excludes>
70 + </artifactSet>
71 + </configuration>
72 + <executions>
73 + <execution>
74 + <phase>package</phase>
75 + <goals>
76 + <goal>shade</goal>
77 + </goals>
78 + </execution>
79 + </executions>
80 + </plugin>
81 + <plugin>
82 + <groupId>org.apache.felix</groupId>
83 + <artifactId>maven-bundle-plugin</artifactId>
84 + <configuration>
85 + <instructions>
86 + <Export-Package>
87 + org.onosproject.bgp.*,org.onosproject.bgpio.*,org.onosproject.bgp.controller
88 + </Export-Package>
89 + </instructions>
90 + </configuration>
91 + </plugin>
92 + </plugins>
93 + </build>
94 +
95 +</project>
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +package org.onosproject.bgp.controller;
17 +
18 +import java.util.TreeMap;
19 +
20 +/**
21 + * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller.
22 + */
23 +public interface BGPCfg {
24 +
25 + enum State {
26 + /**
27 + * Signifies that its just created.
28 + */
29 + INIT,
30 +
31 + /**
32 + * Signifies that only IP Address is configured.
33 + */
34 + IP_CONFIGURED,
35 +
36 + /**
37 + * Signifies that only Autonomous System is configured.
38 + */
39 + AS_CONFIGURED,
40 +
41 + /**
42 + * Signifies that both IP and Autonomous System is configured.
43 + */
44 + IP_AS_CONFIGURED
45 + }
46 +
47 + /**
48 + * Returns the status of the configuration based on this state certain operations like connection is handled.
49 + *
50 + * @return
51 + * State of the configuration
52 + */
53 + State getState();
54 +
55 + /**
56 + * To set the current state of the configuration.
57 + *
58 + * @param state
59 + * Configuration State enum
60 + */
61 + void setState(State state);
62 +
63 + /**
64 + * Get the status of the link state support for this BGP speaker.
65 + *
66 + * @return
67 + * true if the link state is supported else false
68 + */
69 + boolean getLsCapability();
70 +
71 + /**
72 + * Set the link state support to this BGP speaker.
73 + *
74 + * @param lscapability
75 + * true value if link state is supported else false
76 + */
77 + void setLsCapability(boolean lscapability);
78 +
79 + /**
80 + * Get the status of the 32 bit AS support for this BGP speaker.
81 + *
82 + * @return
83 + * true if the 32 bit AS number is supported else false
84 + */
85 + boolean getLargeASCapability();
86 +
87 + /**
88 + * Set the 32 bit AS support capability to this BGP speaker.
89 + *
90 + * @param largeAs
91 + * true value if the 32 bit AS is supported else false
92 + */
93 + void setLargeASCapability(boolean largeAs);
94 +
95 + /**
96 + * Set the AS number to which this BGP speaker belongs.
97 + *
98 + * @param localAs
99 + * 16 or 32 bit AS number, length is dependent on the capability
100 + */
101 + void setAsNumber(int localAs);
102 +
103 + /**
104 + * Get the AS number to which this BGP speaker belongs.
105 + *
106 + * @return
107 + * 16 or 32 bit AS number, length is dependent on the capability
108 + */
109 + int getAsNumber();
110 +
111 + /**
112 + * Get the connection retry count number.
113 + *
114 + * @return
115 + * connection retry count if there is a connection error
116 + */
117 + int getMaxConnRetryCount();
118 +
119 + /**
120 + * Set the connection retry count.
121 + *
122 + * @param retryCount
123 + * number of times to try to connect if there is any error
124 + */
125 + void setMaxConnRetryCout(int retryCount);
126 +
127 + /**
128 + * Get the connection retry time in seconds.
129 + *
130 + * @return
131 + * connection retry time in seconds
132 + */
133 + int getMaxConnRetryTime();
134 +
135 + /**
136 + * Set the connection retry time in seconds.
137 + *
138 + * @param retryTime
139 + * connection retry times in seconds
140 + */
141 + void setMaxConnRetryTime(int retryTime);
142 +
143 + /**
144 + * Set the keep alive timer for the connection.
145 + *
146 + * @param holdTime
147 + * connection hold timer in seconds
148 + */
149 + void setHoldTime(short holdTime);
150 +
151 + /**
152 + * Returns the connection hold timer in seconds.
153 + *
154 + * @return
155 + * connection hold timer in seconds
156 + */
157 + short getHoldTime();
158 +
159 + /**
160 + * Returns the maximum number of session supported.
161 + *
162 + * @return
163 + * maximum number of session supported
164 + */
165 + int getMaxSession();
166 +
167 + /**
168 + * Set the maximum number of sessions to support.
169 + *
170 + * @param maxsession
171 + * maximum number of session
172 + */
173 + void setMaxSession(int maxsession);
174 +
175 + /**
176 + * Returns the Router ID of this BGP speaker.
177 + *
178 + * @return
179 + * IP address in string format
180 + */
181 + String getRouterId();
182 +
183 + /**
184 + * Set the Router ID of this BGP speaker.
185 + *
186 + * @param routerid
187 + * IP address in string format
188 + */
189 + void setRouterId(String routerid);
190 +
191 + /**
192 + * Add the BGP peer IP address and the AS number to which it belongs.
193 + *
194 + * @param routerid
195 + * IP address in string format
196 + * @param remoteAs
197 + * AS number to which it belongs
198 + * @return
199 + * true if added successfully else false
200 + */
201 + boolean addPeer(String routerid, int remoteAs);
202 +
203 + /**
204 + * Add the BGP peer IP address and the keep alive time.
205 + *
206 + * @param routerid
207 + * IP address in string format
208 + * @param holdTime
209 + * keep alive time for the connection
210 + * @return
211 + * true if added successfully else false
212 + */
213 + boolean addPeer(String routerid, short holdTime);
214 +
215 + /**
216 + * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
217 + *
218 + * @param routerid
219 + * IP address in string format
220 + * @param remoteAs
221 + * AS number to which it belongs
222 + * @param holdTime
223 + * keep alive time for the connection
224 + * @return
225 + * true if added successfully else false
226 + */
227 + boolean addPeer(String routerid, int remoteAs, short holdTime);
228 +
229 + /**
230 + * Remove the BGP peer with this IP address.
231 + *
232 + * @param routerid
233 + * router IP address
234 + * @return
235 + * true if removed successfully else false
236 + */
237 + boolean removePeer(String routerid);
238 +
239 + /**
240 + * Connect to BGP peer with this IP address.
241 + *
242 + * @param routerid
243 + * router IP address
244 + * @return
245 + * true of the configuration is found and able to connect else false
246 + */
247 + boolean connectPeer(String routerid);
248 +
249 + /**
250 + * Disconnect this BGP peer with this IP address.
251 + *
252 + * @param routerid
253 + * router IP address in string format
254 + * @return
255 + * true if the configuration is found and able to disconnect else false
256 + */
257 + boolean disconnectPeer(String routerid);
258 +
259 + /**
260 + * Returns the peer tree information.
261 + *
262 + * @return
263 + * return the tree map with IP as key and BGPPeerCfg as object
264 + */
265 + TreeMap<String, BGPPeerCfg> displayPeers();
266 +
267 + /**
268 + * Return the BGP Peer information with this matching IP.
269 + *
270 + * @param routerid
271 + * router IP address in string format
272 + * @return
273 + * BGPPeerCfg object
274 + */
275 + BGPPeerCfg displayPeers(String routerid);
276 +
277 + /**
278 + * Check if this BGP peer is configured.
279 + *
280 + * @param routerid
281 + * router IP address in string format
282 + * @return
283 + * true if configured exists else false
284 + */
285 + boolean isPeerConfigured(String routerid);
286 +
287 + /**
288 + * Check if this BGP speaker is having connection with the peer.
289 + *
290 + * @param routerid
291 + * router IP address in string format
292 + * @return
293 + * true if the connection exists else false
294 + */
295 + boolean isPeerConnected(String routerid);
296 +
297 + /**
298 + * Return the peer tree map.
299 + *
300 + * @return
301 + * return the tree map with IP as key and BGPPeerCfg as object
302 + */
303 + TreeMap<String, BGPPeerCfg> getPeerTree();
304 +
305 + /**
306 + * Set the current connection state information.
307 + *
308 + * @param routerid
309 + * router IP address in string format
310 + * @param state
311 + * state information
312 + */
313 + void setPeerConnState(String routerid, BGPPeerCfg.State state);
314 +
315 + /**
316 + * Check if the peer can be connected or not.
317 + *
318 + * @param routerid
319 + * router IP address in string format
320 + * @return
321 + * true if the peer can be connected else false
322 + */
323 + boolean isPeerConnectable(String routerid);
324 +
325 + /**
326 + * Get the current peer connection state information.
327 + *
328 + * @param routerid
329 + * router IP address in string format
330 + * @return
331 + * state information
332 + */
333 + BGPPeerCfg.State getPeerConnState(String routerid);
334 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +package org.onosproject.bgp.controller;
17 +
18 +/**
19 + * BGP Peer configuration information.
20 + */
21 +public interface BGPPeerCfg {
22 +
23 + enum State {
24 +
25 + /**
26 + * Signifies that peer connection is idle.
27 + */
28 + IDLE,
29 +
30 + /**
31 + * Signifies that connection is initiated.
32 + */
33 + CONNECT,
34 +
35 + /**
36 + * Signifies that state is active and connection can be established.
37 + */
38 + ACTIVE,
39 +
40 + /**
41 + * Signifies that open is sent and anticipating reply.
42 + */
43 + OPENSENT,
44 +
45 + /**
46 + * Signifies that peer sent the open message as reply.
47 + */
48 + OPENCONFIRM,
49 +
50 + /**
51 + * Signifies that all the negotiation is successful and ready to exchange other messages.
52 + */
53 + ESTABLISHED,
54 +
55 + /**
56 + * Signifies that invalid state.
57 + */
58 + INVALID
59 + }
60 +
61 + /**
62 + * Returns the connection State information of the peer.
63 + *
64 + * @return
65 + * enum state is returned
66 + */
67 + State getState();
68 +
69 + /**
70 + * Set the connection state information of the peer.
71 + *
72 + * @param state
73 + * enum state
74 + */
75 + void setState(State state);
76 +
77 + /**
78 + * Returns the connection is initiated from us or not.
79 + *
80 + * @return
81 + * true if the connection is initiated by this peer, false if it has been received.
82 + */
83 + boolean getSelfInnitConnection();
84 +
85 + /**
86 + * Set the connection is initiated from us or not.
87 + *
88 + * @param selfInit
89 + * true if the connection is initiated by this peer, false if it has been received.
90 + */
91 + void setSelfInnitConnection(boolean selfInit);
92 +
93 + /**
94 + * Returns the AS number to which this peer belongs.
95 + *
96 + * @return
97 + * AS number
98 + */
99 + int getAsNumber();
100 +
101 + /**
102 + * Set the AS number to which this peer belongs.
103 + *
104 + * @param asNumber
105 + * AS number
106 + */
107 + void setAsNumber(int asNumber);
108 +
109 + /**
110 + * Get the keep alive timer value configured.
111 + *
112 + * @return
113 + * keep alive timer value in seconds
114 + */
115 + short getHoldtime();
116 +
117 + /**
118 + * Set the keep alive timer value.
119 + *
120 + * @param holdTime
121 + * keep alive timer value in seconds
122 + */
123 + void setHoldtime(short holdTime);
124 +
125 + /**
126 + * Return the connection type eBGP or iBGP.
127 + *
128 + * @return
129 + * true if iBGP, false if it is eBGP
130 + */
131 + boolean getIsIBgp();
132 +
133 + /**
134 + * Set the connection type eBGP or iBGP.
135 + *
136 + * @param isIBgp
137 + * true if iBGP, false if it is eBGP
138 + */
139 + void setIsIBgp(boolean isIBgp);
140 +
141 + /**
142 + * Return the peer router IP address.
143 + *
144 + * @return
145 + * IP address in string format
146 + */
147 + String getPeerRouterId();
148 +
149 + /**
150 + * Set the peer router IP address.
151 + *
152 + * @param peerId
153 + * IP address in string format
154 + */
155 + void setPeerRouterId(String peerId);
156 +
157 + /**
158 + * Set the peer router IP address and AS number.
159 + *
160 + * @param peerId
161 + * IP address in string format
162 + * @param asNumber
163 + * AS number
164 + */
165 + void setPeerRouterId(String peerId, int asNumber);
166 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * BGP controller API.
19 + */
20 +package org.onosproject.bgp.controller;
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-bgp</artifactId>
25 + <version>1.4.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-bgpio</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>ONOS BGPio Protocol subsystem</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>org.onosproject</groupId>
37 + <artifactId>onos-api</artifactId>
38 + </dependency>
39 + <dependency>
40 + <groupId>org.onosproject</groupId>
41 + <artifactId>onlab-osgi</artifactId>
42 + </dependency>
43 +
44 + <dependency>
45 + <groupId>com.fasterxml.jackson.core</groupId>
46 + <artifactId>jackson-databind</artifactId>
47 + </dependency>
48 + <dependency>
49 + <groupId>com.fasterxml.jackson.core</groupId>
50 + <artifactId>jackson-annotations</artifactId>
51 + </dependency>
52 +
53 + <dependency>
54 + <groupId>org.osgi</groupId>
55 + <artifactId>org.osgi.core</artifactId>
56 + </dependency>
57 + <dependency>
58 + <groupId>org.apache.karaf.shell</groupId>
59 + <artifactId>org.apache.karaf.shell.console</artifactId>
60 + </dependency>
61 + <dependency>
62 + <groupId>org.apache.felix</groupId>
63 + <artifactId>org.apache.felix.scr.annotations</artifactId>
64 + </dependency>
65 + </dependencies>
66 +
67 + <build>
68 + <plugins>
69 + <plugin>
70 + <groupId>org.apache.felix</groupId>
71 + <artifactId>maven-bundle-plugin</artifactId>
72 + </plugin>
73 + </plugins>
74 + </build>
75 +
76 +</project>
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * BGP custom exceptions.
19 + */
20 +package org.onosproject.bgpio.exceptions;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * BGP Protocol specific link state details.
19 + */
20 +package org.onosproject.bgpio.protocol.link_state;
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * BGP Protocol specific components.
19 + */
20 +package org.onosproject.bgpio.protocol;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * BGP Protocol specific details of version 4.
19 + */
20 +package org.onosproject.bgpio.protocol.ver4;
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * Implementation of BGP Link state attribute Tlvs.
19 + */
20 +package org.onosproject.bgpio.types.attr;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * Implementation of Tlvs, Attributes and Descriptors.
19 + */
20 +package org.onosproject.bgpio.types;
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * Implementation of BGP utility functions.
19 + */
20 +package org.onosproject.bgpio.util;
1 +<!--
2 + ~ Copyright 2015 Open Networking Laboratory
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 + -->
16 +<project xmlns="http://maven.apache.org/POM/4.0.0"
17 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19 + <modelVersion>4.0.0</modelVersion>
20 +
21 + <parent>
22 + <groupId>org.onosproject</groupId>
23 + <artifactId>onos-bgp</artifactId>
24 + <version>1.4.0-SNAPSHOT</version>
25 + <relativePath>../pom.xml</relativePath>
26 + </parent>
27 +
28 + <artifactId>onos-bgp-ctl</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <description>ONOS BGP controller subsystem API</description>
32 +
33 + <dependencies>
34 + <dependency>
35 + <groupId>org.onosproject</groupId>
36 + <artifactId>onos-bgp-api</artifactId>
37 + </dependency>
38 + <dependency>
39 + <groupId>io.netty</groupId>
40 + <artifactId>netty</artifactId>
41 + </dependency>
42 + <dependency>
43 + <groupId>org.apache.felix</groupId>
44 + <artifactId>org.apache.felix.scr.annotations</artifactId>
45 + </dependency>
46 + <dependency>
47 + <groupId>org.osgi</groupId>
48 + <artifactId>org.osgi.compendium</artifactId>
49 + </dependency>
50 + <dependency>
51 + <groupId>org.onosproject</groupId>
52 + <artifactId>onlab-misc</artifactId>
53 + </dependency>
54 + </dependencies>
55 +
56 + <build>
57 + <plugins>
58 + <plugin>
59 + <groupId>org.apache.felix</groupId>
60 + <artifactId>maven-scr-plugin</artifactId>
61 + </plugin>
62 + </plugins>
63 + </build>
64 +
65 +</project>
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +package org.onosproject.bgp.controller.impl;
17 +
18 +import java.util.Iterator;
19 +import java.util.Map.Entry;
20 +import java.util.Set;
21 +import java.util.TreeMap;
22 +
23 +import org.onlab.packet.Ip4Address;
24 +import org.onosproject.bgp.controller.BGPCfg;
25 +import org.onosproject.bgp.controller.BGPPeerCfg;
26 +import org.slf4j.Logger;
27 +import org.slf4j.LoggerFactory;
28 +
29 +/**
30 + * Provides BGP configuration of this BGP speaker.
31 + */
32 +public class BGPConfig implements BGPCfg {
33 +
34 + protected static final Logger log = LoggerFactory.getLogger(BGPConfig.class);
35 +
36 + private static final short DEFAULT_HOLD_TIMER = 120;
37 + private static final short DEFAULT_CONN_RETRY_TIME = 120;
38 + private static final short DEFAULT_CONN_RETRY_COUNT = 5;
39 +
40 + private State state = State.INIT;
41 + private int localAs;
42 + private int maxSession;
43 + private boolean lsCapability;
44 + private short holdTime;
45 + private boolean largeAs = false;
46 + private int maxConnRetryTime;
47 + private int maxConnRetryCount;
48 +
49 + private Ip4Address routerId = null;
50 + private TreeMap<String, BGPPeerCfg> bgpPeerTree = new TreeMap<>();
51 +
52 + /**
53 + * Constructor to initialize the values.
54 + */
55 + public BGPConfig() {
56 +
57 + this.holdTime = DEFAULT_HOLD_TIMER;
58 + this.maxConnRetryTime = DEFAULT_CONN_RETRY_TIME;
59 + this.maxConnRetryCount = DEFAULT_CONN_RETRY_COUNT;
60 + }
61 +
62 + @Override
63 + public State getState() {
64 + return state;
65 + }
66 +
67 + @Override
68 + public void setState(State state) {
69 + this.state = state;
70 + }
71 +
72 + @Override
73 + public int getAsNumber() {
74 + return this.localAs;
75 + }
76 +
77 + @Override
78 + public void setAsNumber(int localAs) {
79 +
80 + State localState = getState();
81 + this.localAs = localAs;
82 +
83 + /* Set configuration state */
84 + if (localState == State.IP_CONFIGURED) {
85 + setState(State.IP_AS_CONFIGURED);
86 + } else {
87 + setState(State.AS_CONFIGURED);
88 + }
89 + }
90 +
91 + @Override
92 + public int getMaxSession() {
93 + return this.maxSession;
94 + }
95 +
96 + @Override
97 + public void setMaxSession(int maxSession) {
98 + this.maxSession = maxSession;
99 + }
100 +
101 + @Override
102 + public boolean getLsCapability() {
103 + return this.lsCapability;
104 + }
105 +
106 + @Override
107 + public void setLsCapability(boolean lsCapability) {
108 + this.lsCapability = lsCapability;
109 + }
110 +
111 + @Override
112 + public String getRouterId() {
113 + if (this.routerId != null) {
114 + return this.routerId.toString();
115 + } else {
116 + return null;
117 + }
118 + }
119 +
120 + @Override
121 + public void setRouterId(String routerId) {
122 + State localState = getState();
123 + this.routerId = Ip4Address.valueOf(routerId);
124 +
125 + /* Set configuration state */
126 + if (localState == State.AS_CONFIGURED) {
127 + setState(State.IP_AS_CONFIGURED);
128 + } else {
129 + setState(State.IP_CONFIGURED);
130 + }
131 + }
132 +
133 + @Override
134 + public boolean addPeer(String routerid, int remoteAs) {
135 + return addPeer(routerid, remoteAs, DEFAULT_HOLD_TIMER);
136 + }
137 +
138 + @Override
139 + public boolean addPeer(String routerid, short holdTime) {
140 + return addPeer(routerid, this.getAsNumber(), holdTime);
141 + }
142 +
143 + @Override
144 + public boolean addPeer(String routerid, int remoteAs, short holdTime) {
145 + BGPPeerConfig lspeer = new BGPPeerConfig();
146 + if (this.bgpPeerTree.get(routerid) == null) {
147 +
148 + lspeer.setPeerRouterId(routerid);
149 + lspeer.setAsNumber(remoteAs);
150 + lspeer.setHoldtime(holdTime);
151 + lspeer.setState(BGPPeerCfg.State.IDLE);
152 + lspeer.setSelfInnitConnection(false);
153 +
154 + if (this.getAsNumber() == remoteAs) {
155 + lspeer.setIsIBgp(true);
156 + } else {
157 + lspeer.setIsIBgp(false);
158 + }
159 +
160 + this.bgpPeerTree.put(routerid, lspeer);
161 + log.debug("added successfully");
162 + return true;
163 + } else {
164 + log.debug("already exists");
165 + return false;
166 + }
167 + }
168 +
169 + @Override
170 + public boolean connectPeer(String routerid) {
171 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
172 +
173 + if (lspeer != null) {
174 + lspeer.setSelfInnitConnection(true);
175 + // TODO: initiate peer connection
176 + return true;
177 + }
178 +
179 + return false;
180 + }
181 +
182 + @Override
183 + public boolean removePeer(String routerid) {
184 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
185 +
186 + if (lspeer != null) {
187 +
188 + //TODO DISCONNECT PEER
189 + disconnectPeer(routerid);
190 + lspeer.setSelfInnitConnection(false);
191 + lspeer = this.bgpPeerTree.remove(routerid);
192 + log.debug("Deleted : " + routerid + " successfully");
193 +
194 + return true;
195 + } else {
196 + log.debug("Did not find : " + routerid);
197 + return false;
198 + }
199 + }
200 +
201 + @Override
202 + public boolean disconnectPeer(String routerid) {
203 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
204 +
205 + if (lspeer != null) {
206 +
207 + //TODO DISCONNECT PEER
208 + lspeer.setState(BGPPeerCfg.State.IDLE);
209 + lspeer.setSelfInnitConnection(false);
210 + log.debug("Disconnected : " + routerid + " successfully");
211 +
212 + return true;
213 + } else {
214 + log.debug("Did not find : " + routerid);
215 + return false;
216 + }
217 + }
218 +
219 + @Override
220 + public void setPeerConnState(String routerid, BGPPeerCfg.State state) {
221 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
222 +
223 + if (lspeer != null) {
224 + lspeer.setState(state);
225 + log.debug("Peer : " + routerid + " is not available");
226 +
227 + return;
228 + } else {
229 + log.debug("Did not find : " + routerid);
230 + return;
231 + }
232 + }
233 +
234 + @Override
235 + public BGPPeerCfg.State getPeerConnState(String routerid) {
236 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
237 +
238 + if (lspeer != null) {
239 + return lspeer.getState();
240 + } else {
241 + return BGPPeerCfg.State.INVALID; //No instance
242 + }
243 + }
244 +
245 + @Override
246 + public boolean isPeerConnectable(String routerid) {
247 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
248 +
249 + if ((lspeer != null) && lspeer.getState().equals(BGPPeerCfg.State.IDLE)) {
250 + return true;
251 + }
252 +
253 + return false;
254 + }
255 +
256 + @Override
257 + public TreeMap<String, BGPPeerCfg> getPeerTree() {
258 + return this.bgpPeerTree;
259 + }
260 +
261 + @Override
262 + public TreeMap<String, BGPPeerCfg> displayPeers() {
263 + if (this.bgpPeerTree.isEmpty()) {
264 + log.debug("There are no BGP peers");
265 + } else {
266 + Set<Entry<String, BGPPeerCfg>> set = this.bgpPeerTree.entrySet();
267 + Iterator<Entry<String, BGPPeerCfg>> list = set.iterator();
268 + BGPPeerCfg lspeer;
269 +
270 + while (list.hasNext()) {
271 + Entry<String, BGPPeerCfg> me = list.next();
272 + lspeer = me.getValue();
273 + log.debug("Peer neighbor IP :" + me.getKey());
274 + log.debug(", AS Number : " + lspeer.getAsNumber());
275 + log.debug(", Hold Timer : " + lspeer.getHoldtime());
276 + log.debug(", Is iBGP : " + lspeer.getIsIBgp());
277 + }
278 + }
279 + return null;
280 + }
281 +
282 + @Override
283 + public BGPPeerCfg displayPeers(String routerid) {
284 +
285 + if (this.bgpPeerTree.isEmpty()) {
286 + log.debug("There are no BGP peers");
287 + } else {
288 + return this.bgpPeerTree.get(routerid);
289 + }
290 + return null;
291 + }
292 +
293 + @Override
294 + public void setHoldTime(short holdTime) {
295 + this.holdTime = holdTime;
296 + }
297 +
298 + @Override
299 + public short getHoldTime() {
300 + return this.holdTime;
301 + }
302 +
303 + @Override
304 + public boolean getLargeASCapability() {
305 + return this.largeAs;
306 + }
307 +
308 + @Override
309 + public void setLargeASCapability(boolean largeAs) {
310 + this.largeAs = largeAs;
311 + }
312 +
313 + @Override
314 + public boolean isPeerConfigured(String routerid) {
315 + BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
316 + return (lspeer != null) ? true : false;
317 + }
318 +
319 + @Override
320 + public boolean isPeerConnected(String routerid) {
321 + // TODO: is peer connected
322 + return true;
323 + }
324 +
325 + @Override
326 + public int getMaxConnRetryCount() {
327 + return this.maxConnRetryCount;
328 + }
329 +
330 + @Override
331 + public void setMaxConnRetryCout(int retryCount) {
332 + this.maxConnRetryCount = retryCount;
333 + }
334 +
335 + @Override
336 + public int getMaxConnRetryTime() {
337 + return this.maxConnRetryTime;
338 + }
339 +
340 + @Override
341 + public void setMaxConnRetryTime(int retryTime) {
342 + this.maxConnRetryTime = retryTime;
343 + }
344 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +package org.onosproject.bgp.controller.impl;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +import org.onosproject.bgp.controller.BGPPeerCfg;
20 +
21 +/**
22 + * BGP Peer configuration information.
23 + */
24 +public class BGPPeerConfig implements BGPPeerCfg {
25 + private int asNumber;
26 + private short holdTime;
27 + private boolean isIBgp;
28 + private Ip4Address peerId = null;
29 + private State state;
30 + private boolean selfInitiated;
31 +
32 + /**
33 + * Constructor to initialize the values.
34 + */
35 + BGPPeerConfig() {
36 + state = State.IDLE;
37 + selfInitiated = false;
38 + }
39 +
40 + @Override
41 + public int getAsNumber() {
42 + return this.asNumber;
43 + }
44 +
45 + @Override
46 + public void setAsNumber(int asNumber) {
47 + this.asNumber = asNumber;
48 + }
49 +
50 + @Override
51 + public short getHoldtime() {
52 + return this.holdTime;
53 + }
54 +
55 + @Override
56 + public void setHoldtime(short holdTime) {
57 + this.holdTime = holdTime;
58 + }
59 +
60 + @Override
61 + public boolean getIsIBgp() {
62 + return this.isIBgp;
63 + }
64 +
65 + @Override
66 + public void setIsIBgp(boolean isIBgp) {
67 + this.isIBgp = isIBgp;
68 + }
69 +
70 + @Override
71 + public String getPeerRouterId() {
72 + if (this.peerId != null) {
73 + return this.peerId.toString();
74 + } else {
75 + return null;
76 + }
77 + }
78 +
79 + @Override
80 + public void setPeerRouterId(String peerId) {
81 + this.peerId = Ip4Address.valueOf(peerId);
82 + }
83 +
84 + @Override
85 + public void setPeerRouterId(String peerId, int asNumber) {
86 + this.peerId = Ip4Address.valueOf(peerId);
87 + this.asNumber = asNumber;
88 + }
89 +
90 + @Override
91 + public State getState() {
92 + return this.state;
93 + }
94 +
95 + @Override
96 + public void setState(State state) {
97 + this.state = state;
98 + }
99 +
100 + @Override
101 + public boolean getSelfInnitConnection() {
102 + return this.selfInitiated;
103 + }
104 +
105 + @Override
106 + public void setSelfInnitConnection(boolean selfInit) {
107 + this.selfInitiated = selfInit;
108 + }
109 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
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 + */
16 +
17 +/**
18 + * Implementation of the BGP controller IO subsystem.
19 + */
20 +package org.onosproject.bgp.controller.impl;
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos</artifactId>
25 + <version>1.4.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-bgp</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <description>ONOS BGP Protocol subsystem</description>
33 +
34 + <modules>
35 + <module>api</module>
36 + <module>ctl</module>
37 + <module>bgpio</module>
38 + </modules>
39 +
40 + <dependencies>
41 + <dependency>
42 + <groupId>org.onosproject</groupId>
43 + <artifactId>onlab-misc</artifactId>
44 + </dependency>
45 + <dependency>
46 + <groupId>org.onosproject</groupId>
47 + <artifactId>onlab-junit</artifactId>
48 + </dependency>
49 + </dependencies>
50 +
51 + <build>
52 + <plugins>
53 + <plugin>
54 + <groupId>org.apache.felix</groupId>
55 + <artifactId>maven-bundle-plugin</artifactId>
56 + </plugin>
57 + </plugins>
58 + </build>
59 +
60 +</project>
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- 2 <!--
3 - ~ Copyright 2014 Open Networking Laboratory 3 + ~ Copyright 2015 Open Networking Laboratory
4 ~ 4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License. 6 ~ you may not use this file except in compliance with the License.
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
57 57
58 <module>tools/package/archetypes</module> 58 <module>tools/package/archetypes</module>
59 <module>tools/package/branding</module> 59 <module>tools/package/branding</module>
60 + <module>bgp</module>
60 </modules> 61 </modules>
61 62
62 <url>http://onosproject.org/</url> 63 <url>http://onosproject.org/</url>
...@@ -431,11 +432,27 @@ ...@@ -431,11 +432,27 @@
431 <scope>test</scope> 432 <scope>test</scope>
432 </dependency> 433 </dependency>
433 <dependency> 434 <dependency>
435 + <groupId>org.onosproject</groupId>
436 + <artifactId>onos-bgpio</artifactId>
437 + <version>${project.version}</version>
438 + </dependency>
439 + <dependency>
434 <groupId>commons-pool</groupId> 440 <groupId>commons-pool</groupId>
435 <artifactId>commons-pool</artifactId> 441 <artifactId>commons-pool</artifactId>
436 <version>1.6</version> 442 <version>1.6</version>
437 </dependency> 443 </dependency>
438 <dependency> 444 <dependency>
445 + <groupId>org.onosproject</groupId>
446 + <artifactId>onos-bgp-api</artifactId>
447 + <version>${project.version}</version>
448 + </dependency>
449 +
450 + <dependency>
451 + <groupId>org.onosproject</groupId>
452 + <artifactId>onos-app-bgp-api</artifactId>
453 + <version>${project.version}</version>
454 + </dependency>
455 + <dependency>
439 <groupId>io.netty</groupId> 456 <groupId>io.netty</groupId>
440 <artifactId>netty-common</artifactId> 457 <artifactId>netty-common</artifactId>
441 <version>${netty4.version}</version> 458 <version>${netty4.version}</version>
......