tejeshwer degala
Committed by Gerrit Code Review

ONOS-4086 to ONOS-4091, ONOS-4098 to ONOS-4100:ISIS controller implementation

Change-Id: I7be52805652fe762baf808515401d6b5042b2aa5
Showing 32 changed files with 2179 additions and 55 deletions
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.isis.controller; 16 package org.onosproject.isis.controller;
17 17
18 +import com.fasterxml.jackson.databind.JsonNode;
18 import org.onosproject.isis.controller.topology.IsisRouterListener; 19 import org.onosproject.isis.controller.topology.IsisRouterListener;
19 20
20 import java.util.List; 21 import java.util.List;
...@@ -41,18 +42,9 @@ public interface IsisController { ...@@ -41,18 +42,9 @@ public interface IsisController {
41 /** 42 /**
42 * Updates configuration of processes. 43 * Updates configuration of processes.
43 * 44 *
44 - * @param processes process instance to update 45 + * @param processesNode json node represents process
45 */ 46 */
46 - void updateConfig(List<IsisProcess> processes); 47 + void updateConfig(JsonNode processesNode);
47 -
48 - /**
49 - * Deletes configuration parameters.
50 - *
51 - * @param processes list of process instance
52 - * @param attribute string key which deletes the particular node or element
53 - * from the controller
54 - */
55 - void deleteConfig(List<IsisProcess> processes, String attribute);
56 48
57 /** 49 /**
58 * Gets the all configured processes. 50 * Gets the all configured processes.
......
...@@ -230,6 +230,13 @@ public interface IsisInterface { ...@@ -230,6 +230,13 @@ public interface IsisInterface {
230 void setPriority(int priority); 230 void setPriority(int priority);
231 231
232 /** 232 /**
233 + * Returns hello interval.
234 + *
235 + * @return hello interval
236 + */
237 + public int helloInterval();
238 +
239 + /**
233 * Sets hello interval. 240 * Sets hello interval.
234 * 241 *
235 * @param helloInterval hello interval 242 * @param helloInterval hello interval
...@@ -301,4 +308,11 @@ public interface IsisInterface { ...@@ -301,4 +308,11 @@ public interface IsisInterface {
301 * @param circuitId circuit ID 308 * @param circuitId circuit ID
302 */ 309 */
303 void setCircuitId(String circuitId); 310 void setCircuitId(String circuitId);
311 +
312 + /**
313 + * Removes neighbor from the interface neighbor map.
314 + *
315 + * @param isisNeighbor ISIS neighbor instance
316 + */
317 + void removeNeighbor(IsisNeighbor isisNeighbor);
304 } 318 }
......
...@@ -98,4 +98,14 @@ public interface IsisNeighbor { ...@@ -98,4 +98,14 @@ public interface IsisNeighbor {
98 * @param holdingTime Holding time of neighbor 98 * @param holdingTime Holding time of neighbor
99 */ 99 */
100 void setHoldingTime(int holdingTime); 100 void setHoldingTime(int holdingTime);
101 +
102 + /**
103 + * Starts the inactivity timer for this neighbor.
104 + */
105 + void startInactivityTimeCheck();
106 +
107 + /**
108 + * Stops the inactivity timer.
109 + */
110 + void stopInactivityTimeCheck();
101 } 111 }
......
...@@ -23,6 +23,13 @@ import java.util.List; ...@@ -23,6 +23,13 @@ import java.util.List;
23 public interface IsisProcess { 23 public interface IsisProcess {
24 24
25 /** 25 /**
26 + * Returns process ID.
27 + *
28 + * @return process ID
29 + */
30 + public String processId();
31 +
32 + /**
26 * Sets process ID. 33 * Sets process ID.
27 * 34 *
28 * @param processId process ID 35 * @param processId process ID
......
1 +<!--
2 + ~ Copyright 2016 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
17 + xmlns="http://maven.apache.org/POM/4.0.0"
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-isis</artifactId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + <relativePath>../pom.xml</relativePath>
26 + </parent>
27 +
28 + <artifactId>onos-isis-ctl</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <description>ONOS ISIS controller subsystem API</description>
32 +
33 + <dependencies>
34 + <dependency>
35 + <groupId>org.onosproject</groupId>
36 + <artifactId>onos-isis-isisio</artifactId>
37 + <version>${project.version}</version>
38 + </dependency>
39 + <dependency>
40 + <groupId>org.apache.felix</groupId>
41 + <artifactId>org.apache.felix.scr.annotations</artifactId>
42 + </dependency>
43 + <dependency>
44 + <groupId>org.osgi</groupId>
45 + <artifactId>org.osgi.compendium</artifactId>
46 + </dependency>
47 + <dependency>
48 + <groupId>org.easymock</groupId>
49 + <artifactId>easymock</artifactId>
50 + </dependency>
51 + </dependencies>
52 +
53 + <build>
54 + <plugins>
55 + <plugin>
56 + <groupId>org.apache.felix</groupId>
57 + <artifactId>maven-scr-plugin</artifactId>
58 + </plugin>
59 + </plugins>
60 + </build>
61 +
62 +
63 +</project>
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import com.fasterxml.jackson.databind.JsonNode;
19 +import org.apache.felix.scr.annotations.Activate;
20 +import org.apache.felix.scr.annotations.Component;
21 +import org.apache.felix.scr.annotations.Deactivate;
22 +import org.apache.felix.scr.annotations.Reference;
23 +import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.apache.felix.scr.annotations.Service;
25 +import org.onosproject.isis.controller.IsisController;
26 +import org.onosproject.isis.controller.IsisProcess;
27 +import org.onosproject.isis.controller.topology.IsisRouterListener;
28 +import org.onosproject.net.driver.DriverService;
29 +import org.slf4j.Logger;
30 +import org.slf4j.LoggerFactory;
31 +
32 +import java.util.List;
33 +
34 +/**
35 + * Represents ISIS controller implementation.
36 + */
37 +@Component(immediate = true)
38 +@Service
39 +public class DefaultIsisController implements IsisController {
40 +
41 + protected static final Logger log = LoggerFactory.getLogger(DefaultIsisController.class);
42 + private final Controller controller = new Controller();
43 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
44 + protected DriverService driverService;
45 +
46 + @Activate
47 + public void activate() {
48 + log.debug("ISISControllerImpl activate");
49 + }
50 +
51 + @Deactivate
52 + public void deactivate() {
53 + controller.isisDeactivate();
54 + log.debug("ISISControllerImpl deActivate");
55 + }
56 +
57 + @Override
58 + public List<IsisProcess> allConfiguredProcesses() {
59 + List<IsisProcess> processes = controller.getAllConfiguredProcesses();
60 + return processes;
61 + }
62 +
63 + @Override
64 + public void updateConfig(JsonNode jsonNode) {
65 + log.debug("updateConfig::IsisList::processes::{}", jsonNode);
66 + try {
67 + controller.updateConfig(jsonNode);
68 + } catch (Exception e) {
69 + log.debug("Error::updateConfig::{}", e.getMessage());
70 + }
71 + }
72 +
73 + @Override
74 + public void addRouterListener(IsisRouterListener isisRouterListener) {
75 + log.debug("IsisControllerImpl::addRouterListener...");
76 + }
77 +
78 + @Override
79 + public void removeRouterListener(IsisRouterListener isisRouterListener) {
80 + log.debug("IsisControllerImpl::removeRouterListener...");
81 + }
82 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +import org.onlab.packet.MacAddress;
20 +import org.onosproject.isis.controller.IsisInterface;
21 +import org.onosproject.isis.controller.IsisInterfaceState;
22 +import org.onosproject.isis.controller.IsisNeighbor;
23 +import org.onosproject.isis.controller.IsisPduType;
24 +import org.onosproject.isis.controller.IsisRouterType;
25 +import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
26 +import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
27 +import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
28 +import org.onosproject.isis.io.util.IsisConstants;
29 +import org.slf4j.Logger;
30 +import org.slf4j.LoggerFactory;
31 +
32 +import java.util.List;
33 +import java.util.concurrent.Executors;
34 +import java.util.concurrent.ScheduledExecutorService;
35 +import java.util.concurrent.TimeUnit;
36 +
37 +/**
38 + * Representation of an ISIS neighbor.
39 + * The first thing an ISIS router must do is find its neighbors and form adjacency.
40 + * Each neighbor that the router finds will be represented by this class.
41 + */
42 +public class DefaultIsisNeighbor implements IsisNeighbor {
43 + private static final Logger log = LoggerFactory.getLogger(DefaultIsisNeighbor.class);
44 + private String neighborAreaId;
45 + private String neighborSystemId;
46 + private Ip4Address interfaceIp;
47 + private MacAddress neighborMacAddress;
48 + private int holdingTime;
49 + private IsisRouterType routerType;
50 + private String l1LanId;
51 + private String l2LanId;
52 + private byte localCircuitId;
53 + private int localExtendedCircuitId;
54 + private IsisInterfaceState neighborState = IsisInterfaceState.INITIAL;
55 + private InternalInactivityTimeCheck inActivityTimeCheckTask;
56 + private ScheduledExecutorService exServiceInActivity;
57 + private boolean inActivityTimerScheduled = false;
58 + private IsisInterface isisInterface;
59 +
60 + /**
61 + * Creates an instance of ISIS neighbor.
62 + *
63 + * @param helloMessage hello message instance
64 + * @param isisInterface ISIS interface instance
65 + */
66 + public DefaultIsisNeighbor(HelloPdu helloMessage, IsisInterface isisInterface) {
67 + this.neighborMacAddress = helloMessage.sourceMac();
68 + List<String> areaAddresses = helloMessage.areaAddress();
69 + this.neighborAreaId = (areaAddresses != null) ? areaAddresses.get(0) : "";
70 + this.neighborSystemId = helloMessage.sourceId();
71 + List<Ip4Address> interfaceIpAddresses = helloMessage.interfaceIpAddresses();
72 + this.interfaceIp = (helloMessage.interfaceIpAddresses() != null) ?
73 + interfaceIpAddresses.get(0) : IsisConstants.DEFAULTIP;
74 + this.holdingTime = helloMessage.holdingTime();
75 + this.routerType = IsisRouterType.get(helloMessage.circuitType());
76 + if (helloMessage instanceof L1L2HelloPdu) {
77 + if (IsisPduType.L1HELLOPDU == helloMessage.isisPduType()) {
78 + l1LanId = ((L1L2HelloPdu) helloMessage).lanId();
79 + } else if (IsisPduType.L2HELLOPDU == helloMessage.isisPduType()) {
80 + l2LanId = ((L1L2HelloPdu) helloMessage).lanId();
81 + }
82 + } else if (helloMessage instanceof P2PHelloPdu) {
83 + this.localCircuitId = ((P2PHelloPdu) helloMessage).localCircuitId();
84 + }
85 + this.isisInterface = isisInterface;
86 + }
87 +
88 + /**
89 + * Returns local extended circuit ID.
90 + *
91 + * @return local extended circuit ID
92 + */
93 + public int localExtendedCircuitId() {
94 + return localExtendedCircuitId;
95 + }
96 +
97 + /**
98 + * Sets local extended circuit ID.
99 + *
100 + * @param localExtendedCircuitId neighbor extended circuit ID
101 + */
102 + public void setLocalExtendedCircuitId(int localExtendedCircuitId) {
103 + this.localExtendedCircuitId = localExtendedCircuitId;
104 + }
105 +
106 + /**
107 + * Returns neighbor area ID.
108 + *
109 + * @return neighbor area ID
110 + */
111 + public String neighborAreaId() {
112 + return neighborAreaId;
113 + }
114 +
115 + /**
116 + * Sets neighbor area ID.
117 + *
118 + * @param neighborAreaId neighbor area ID
119 + */
120 + public void setNeighborAreaId(String neighborAreaId) {
121 + this.neighborAreaId = neighborAreaId;
122 + }
123 +
124 + /**
125 + * Returns neighbor system ID.
126 + *
127 + * @return neighbor system ID
128 + */
129 + public String neighborSystemId() {
130 + return neighborSystemId;
131 + }
132 +
133 + /**
134 + * Sets neighbor system ID.
135 + *
136 + * @param neighborSystemId neighbor system ID
137 + */
138 + public void setNeighborSystemId(String neighborSystemId) {
139 + this.neighborSystemId = neighborSystemId;
140 + }
141 +
142 + /**
143 + * Returns interface IP.
144 + *
145 + * @return interface IP
146 + */
147 + public Ip4Address interfaceIp() {
148 + return interfaceIp;
149 + }
150 +
151 + /**
152 + * Sets interface IP.
153 + *
154 + * @param interfaceIp IP
155 + */
156 + public void setInterfaceIp(Ip4Address interfaceIp) {
157 + this.interfaceIp = interfaceIp;
158 + }
159 +
160 + /**
161 + * Returns neighbor mac address.
162 + *
163 + * @return neighborMacAddress neighbor mac address
164 + */
165 + public MacAddress neighborMacAddress() {
166 + return neighborMacAddress;
167 + }
168 +
169 + /**
170 + * Sets neighbor mac address.
171 + *
172 + * @param neighborMacAddress mac address
173 + */
174 + public void setNeighborMacAddress(MacAddress neighborMacAddress) {
175 + this.neighborMacAddress = neighborMacAddress;
176 + }
177 +
178 + /**
179 + * Returns holding time.
180 + *
181 + * @return holding time
182 + */
183 + public int holdingTime() {
184 + return holdingTime;
185 + }
186 +
187 + /**
188 + * Sets holding time.
189 + *
190 + * @param holdingTime holding time
191 + */
192 + public void setHoldingTime(int holdingTime) {
193 + this.holdingTime = holdingTime;
194 + }
195 +
196 + /**
197 + * Returns router type.
198 + *
199 + * @return router type
200 + */
201 + public IsisRouterType routerType() {
202 + return routerType;
203 + }
204 +
205 + /**
206 + * Sets router type.
207 + *
208 + * @param routerType router type
209 + */
210 + public void setRouterType(IsisRouterType routerType) {
211 + this.routerType = routerType;
212 + }
213 +
214 + /**
215 + * Returns L1 lan ID.
216 + *
217 + * @return L1 lan ID
218 + */
219 + public String l1LanId() {
220 + return l1LanId;
221 + }
222 +
223 + /**
224 + * Sets L1 lan ID.
225 + *
226 + * @param l1LanId L1 lan ID
227 + */
228 + public void setL1LanId(String l1LanId) {
229 + this.l1LanId = l1LanId;
230 + }
231 +
232 + /**
233 + * Returns L2 lan ID.
234 + *
235 + * @return L2 lan ID
236 + */
237 + public String l2LanId() {
238 + return l2LanId;
239 + }
240 +
241 + /**
242 + * Sets L2 lan ID.
243 + *
244 + * @param l2LanId L2 lan ID
245 + */
246 + public void setL2LanId(String l2LanId) {
247 + this.l1LanId = l1LanId;
248 + }
249 +
250 + /**
251 + * Gets the neighbor interface state.
252 + *
253 + * @return neighbor interface state
254 + */
255 + public IsisInterfaceState interfaceState() {
256 + return neighborState;
257 + }
258 +
259 + /**
260 + * Sets the neighbor interface state.
261 + *
262 + * @param neighborState the neighbor interface state
263 + */
264 + public void setNeighborState(IsisInterfaceState neighborState) {
265 + this.neighborState = neighborState;
266 + }
267 +
268 + /**
269 + * Returns local circuit ID.
270 + *
271 + * @return local circuit ID
272 + */
273 + public byte localCircuitId() {
274 + return localCircuitId;
275 + }
276 +
277 + /**
278 + * Sets local circuit ID.
279 + *
280 + * @param localCircuitId local circuit ID
281 + */
282 + public void setLocalCircuitId(byte localCircuitId) {
283 + this.localCircuitId = localCircuitId;
284 + }
285 +
286 + /**
287 + * Returns neighbor state.
288 + *
289 + * @return neighbor state
290 + */
291 + public IsisInterfaceState neighborState() {
292 + return neighborState;
293 + }
294 +
295 + /**
296 + * Starts the inactivity timer.
297 + */
298 + public void startInactivityTimeCheck() {
299 + if (!inActivityTimerScheduled) {
300 + log.debug("IsisNeighbor::startInactivityTimeCheck");
301 + inActivityTimeCheckTask = new InternalInactivityTimeCheck();
302 + exServiceInActivity = Executors.newSingleThreadScheduledExecutor();
303 + exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, holdingTime,
304 + holdingTime, TimeUnit.SECONDS);
305 + inActivityTimerScheduled = true;
306 + }
307 + }
308 +
309 + /**
310 + * Stops the inactivity timer.
311 + */
312 + public void stopInactivityTimeCheck() {
313 + if (inActivityTimerScheduled) {
314 + log.debug("IsisNeighbor::stopInactivityTimeCheck ");
315 + exServiceInActivity.shutdown();
316 + inActivityTimerScheduled = false;
317 + }
318 + }
319 +
320 + /**
321 + * Called when neighbor is down.
322 + */
323 + public void neighborDown() {
324 + log.debug("Neighbor Down {} and NeighborSystemId {}", neighborMacAddress,
325 + neighborSystemId);
326 + stopInactivityTimeCheck();
327 + isisInterface.setL1LanId(IsisConstants.DEFAULTLANID);
328 + isisInterface.setL2LanId(IsisConstants.DEFAULTLANID);
329 +
330 + neighborState = IsisInterfaceState.DOWN;
331 + isisInterface.removeNeighbor(this);
332 + }
333 +
334 + /**
335 + * Represents a Task which will do an inactivity time check.
336 + */
337 + private class InternalInactivityTimeCheck implements Runnable {
338 + /**
339 + * Creates an instance.
340 + */
341 + InternalInactivityTimeCheck() {
342 + }
343 +
344 + @Override
345 + public void run() {
346 + log.debug("Neighbor Not Heard till the past router dead interval .");
347 + neighborDown();
348 + }
349 + }
350 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import org.onosproject.isis.controller.IsisInterface;
19 +import org.onosproject.isis.controller.IsisProcess;
20 +
21 +import java.util.List;
22 +
23 +/**
24 + * Represents of an ISIS process.
25 + */
26 +public class DefaultIsisProcess implements IsisProcess {
27 + private String processId;
28 + private List<IsisInterface> isisInterfaceList;
29 +
30 + /**
31 + * Gets process ID.
32 + *
33 + * @return process ID
34 + */
35 + public String processId() {
36 + return processId;
37 + }
38 +
39 + /**
40 + * Sets process ID.
41 + *
42 + * @param processId process ID
43 + */
44 + public void setProcessId(String processId) {
45 + this.processId = processId;
46 + }
47 +
48 + /**
49 + * Gets list of ISIS interface details.
50 + *
51 + * @return list of ISIS interface details
52 + */
53 + public List<IsisInterface> isisInterfaceList() {
54 + return isisInterfaceList;
55 + }
56 +
57 + /**
58 + * Sets list of ISIS interface details.
59 + *
60 + * @param isisInterfaceList list of ISIS interface details
61 + */
62 + public void setIsisInterfaceList(List<IsisInterface> isisInterfaceList) {
63 + this.isisInterfaceList = isisInterfaceList;
64 + }
65 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import com.google.common.primitives.Bytes;
19 +import org.jboss.netty.channel.Channel;
20 +import org.onosproject.isis.controller.IsisInterface;
21 +import org.onosproject.isis.controller.IsisNetworkType;
22 +import org.onosproject.isis.controller.IsisRouterType;
23 +import org.onosproject.isis.io.util.IsisUtil;
24 +import org.slf4j.Logger;
25 +import org.slf4j.LoggerFactory;
26 +
27 +/**
28 + * Representation of an ISIS hello pdu sender task.
29 + */
30 +public class IsisHelloPduSender implements Runnable {
31 + private static final Logger log = LoggerFactory.getLogger(IsisHelloPduSender.class);
32 + private Channel channel = null;
33 + private IsisInterface isisInterface = null;
34 +
35 + /**
36 + * Creates an instance of Hello PDU Sender task.
37 + *
38 + * @param channel netty channel instance
39 + * @param isisInterface ISIS interface instance
40 + */
41 + public IsisHelloPduSender(Channel channel, IsisInterface isisInterface) {
42 + this.channel = channel;
43 + this.isisInterface = isisInterface;
44 + }
45 +
46 + @Override
47 + public void run() {
48 + if (channel != null) {
49 + try {
50 + byte[] helloPdu = null;
51 + byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()};
52 +
53 + if (isisInterface.networkType() == IsisNetworkType.P2P) {
54 + helloPdu = IsisUtil.getP2pHelloPdu(isisInterface, true);
55 + helloPdu = Bytes.concat(helloPdu, interfaceIndex);
56 + channel.write(helloPdu);
57 + } else if (isisInterface.networkType() == IsisNetworkType.BROADCAST) {
58 + switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
59 + case L1:
60 + helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
61 + helloPdu = Bytes.concat(helloPdu, interfaceIndex);
62 + channel.write(helloPdu);
63 + break;
64 + case L2:
65 + helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
66 + helloPdu = Bytes.concat(helloPdu, interfaceIndex);
67 + channel.write(helloPdu);
68 + break;
69 + case L1L2:
70 + helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
71 + helloPdu = Bytes.concat(helloPdu, interfaceIndex);
72 + channel.write(helloPdu);
73 +
74 + helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
75 + helloPdu = Bytes.concat(helloPdu, interfaceIndex);
76 + channel.write(helloPdu);
77 + break;
78 + default:
79 + log.debug("IsisHelloPduSender::Unknown circuit type...!!!");
80 + break;
81 + }
82 + }
83 + } catch (Exception e) {
84 + log.debug("Exception @IsisHelloPduSender:: {}", e.getMessage());
85 + }
86 + }
87 + }
88 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.jboss.netty.channel.Channel;
20 +import org.jboss.netty.channel.ChannelHandlerContext;
21 +import org.jboss.netty.handler.codec.frame.FrameDecoder;
22 +import org.onlab.packet.MacAddress;
23 +import org.onosproject.isis.controller.IsisMessage;
24 +import org.onosproject.isis.io.isispacket.IsisMessageReader;
25 +import org.onosproject.isis.io.util.IsisConstants;
26 +import org.onosproject.isis.io.util.IsisUtil;
27 +import org.slf4j.Logger;
28 +import org.slf4j.LoggerFactory;
29 +
30 +import java.util.LinkedList;
31 +import java.util.List;
32 +
33 +/**
34 + * Decodes an ISIS message from a Channel, for use in a netty pipeline.
35 + */
36 +public class IsisMessageDecoder extends FrameDecoder {
37 +
38 + private static final Logger log = LoggerFactory.getLogger(IsisMessageDecoder.class);
39 +
40 + @Override
41 + protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
42 + log.debug("IsisMessageDecoder::Message received <:> length {}", buffer.readableBytes());
43 + if (!channel.isConnected()) {
44 + log.info("Channel is not connected.");
45 + return null;
46 + }
47 +
48 + IsisMessageReader messageReader = new IsisMessageReader();
49 + List<IsisMessage> isisMessageList = new LinkedList<>();
50 + int dataLength = buffer.readableBytes();
51 + while (buffer.readableBytes() >= IsisConstants.MINIMUM_FRAME_LEN) {
52 + ChannelBuffer payload = buffer.readBytes(IsisConstants.MINIMUM_FRAME_LEN);
53 + ChannelBuffer ethernetHeader = payload.readBytes(IsisUtil.ETHER_HEADER_LEN);
54 + //Read the Source MAC address from ethernet header at the 6th position
55 + MacAddress sourceMac = getSourceMac(ethernetHeader);
56 + //Strip 17 byte ethernet header and get the ISIS data buffer
57 + ChannelBuffer isisDataBuffer = payload.readBytes(payload.readableBytes());
58 + int readableBytes = isisDataBuffer.readableBytes();
59 + IsisMessage message = messageReader.readFromBuffer(isisDataBuffer);
60 + //Last 7 bytes is metadata. ie. interface MAC address and interface index.
61 + if (message != null) {
62 + if (isisDataBuffer.readableBytes() >= IsisConstants.METADATA_LEN) {
63 + //Sets the source MAC
64 + message.setSourceMac(sourceMac);
65 + isisDataBuffer.readerIndex(readableBytes - IsisConstants.METADATA_LEN);
66 + log.debug("IsisMessageDecoder::Reading metadata <:> length {}", isisDataBuffer.readableBytes());
67 + byte[] macBytes = new byte[IsisUtil.SIX_BYTES];
68 + isisDataBuffer.readBytes(macBytes, 0, IsisUtil.SIX_BYTES);
69 + MacAddress macAddress = MacAddress.valueOf(macBytes);
70 + int interfaceIndex = isisDataBuffer.readByte();
71 + message.setInterfaceMac(macAddress);
72 + message.setInterfaceIndex(interfaceIndex);
73 + }
74 + isisMessageList.add(message);
75 + }
76 + }
77 +
78 + return isisMessageList;
79 + }
80 +
81 + /**
82 + * Gets the source MAC address from the ethernet header.
83 + *
84 + * @param ethHeader ethernet header bytes
85 + * @return MAC address of the source router
86 + */
87 + private MacAddress getSourceMac(ChannelBuffer ethHeader) {
88 + //Source MAC is at position 6 to 11 (6 bytes)
89 + ethHeader.skipBytes(IsisUtil.SIX_BYTES);
90 + MacAddress sourceMac = MacAddress.valueOf(ethHeader.readBytes(IsisUtil.SIX_BYTES).array());
91 +
92 + return sourceMac;
93 + }
94 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.jboss.netty.buffer.ChannelBuffers;
20 +import org.jboss.netty.channel.Channel;
21 +import org.jboss.netty.channel.ChannelHandlerContext;
22 +import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +/**
27 + * Encodes an ISIS message for output into a ChannelBuffer, for use in a netty pipeline.
28 + */
29 +public class IsisMessageEncoder extends OneToOneEncoder {
30 + private static final Logger log = LoggerFactory.getLogger(IsisMessageEncoder.class);
31 +
32 + @Override
33 + protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
34 +
35 + byte[] byteMsg = (byte[]) msg;
36 + log.debug("Encoding isisMessage of length {}", byteMsg.length);
37 + ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length);
38 + channelBuffer.writeBytes(byteMsg);
39 +
40 + return channelBuffer;
41 + }
42 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl;
17 +
18 +import org.jboss.netty.channel.ChannelPipeline;
19 +import org.jboss.netty.channel.ChannelPipelineFactory;
20 +import org.jboss.netty.channel.Channels;
21 +
22 +/**
23 + * Creates a ChannelPipeline for a client-side ISIS channel.
24 + */
25 +public class IsisPipelineFactory implements ChannelPipelineFactory {
26 + private IsisChannelHandler isisChannelHandler;
27 +
28 + /**
29 + * Creates an instance of ISIS channel pipeline factory.
30 + *
31 + * @param isisChannelHandler ISIS channel handler instance
32 + */
33 + public IsisPipelineFactory(IsisChannelHandler isisChannelHandler) {
34 + this.isisChannelHandler = isisChannelHandler;
35 + }
36 +
37 + @Override
38 + public ChannelPipeline getPipeline() throws Exception {
39 + ChannelPipeline pipeline = Channels.pipeline();
40 + pipeline.addLast("encoder", new IsisMessageDecoder());
41 + pipeline.addLast("decoder", new IsisMessageEncoder());
42 + pipeline.addLast("handler", isisChannelHandler);
43 +
44 + return pipeline;
45 + }
46 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl.lsdb;
17 +
18 +import org.onosproject.isis.controller.IsisInterface;
19 +import org.onosproject.isis.controller.IsisLsdb;
20 +import org.onosproject.isis.controller.IsisLsdbAge;
21 +import org.onosproject.isis.controller.IsisLspBin;
22 +import org.onosproject.isis.controller.IsisMessage;
23 +import org.onosproject.isis.controller.IsisPduType;
24 +import org.onosproject.isis.controller.LspWrapper;
25 +import org.onosproject.isis.io.isispacket.pdu.LsPdu;
26 +import org.onosproject.isis.io.util.IsisConstants;
27 +import org.slf4j.Logger;
28 +import org.slf4j.LoggerFactory;
29 +
30 +import java.util.Iterator;
31 +import java.util.List;
32 +import java.util.Map;
33 +import java.util.concurrent.ConcurrentHashMap;
34 +import java.util.concurrent.CopyOnWriteArrayList;
35 +
36 +/**
37 + * Representation of ISIS link state database.
38 + */
39 +public class DefaultIsisLsdb implements IsisLsdb {
40 + private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdb.class);
41 + private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>();
42 + private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>();
43 + private IsisLsdbAge lsdbAge = null;
44 + private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
45 + private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
46 +
47 + /**
48 + * Creates an instance of ISIS LSDB.
49 + */
50 + public DefaultIsisLsdb() {
51 + lsdbAge = new DefaultIsisLsdbAge();
52 + }
53 +
54 + /**
55 + * Initializes the link state database.
56 + */
57 + public void initializeDb() {
58 + lsdbAge.startDbAging();
59 + }
60 +
61 + /**
62 + * Returns the LSDB LSP key.
63 + *
64 + * @param systemId system ID
65 + * @return key
66 + */
67 + public String lspKey(String systemId) {
68 + StringBuilder lspKey = new StringBuilder();
69 + lspKey.append(systemId);
70 + lspKey.append(".00");
71 + lspKey.append("-");
72 + lspKey.append("00");
73 +
74 + return lspKey.toString();
75 + }
76 +
77 + /**
78 + * Returns the neighbor L1 database information.
79 + *
80 + * @return neighbor L1 database information
81 + */
82 + public Map<String, LspWrapper> getL1Db() {
83 + return isisL1Db;
84 + }
85 +
86 + /**
87 + * Returns the neighbor L2 database information.
88 + *
89 + * @return neighbor L2 database information
90 + */
91 + public Map<String, LspWrapper> getL2Db() {
92 + return isisL2Db;
93 + }
94 +
95 + /**
96 + * Returns the LSDB instance.
97 + *
98 + * @return LSDB instance
99 + */
100 + public IsisLsdb isisLsdb() {
101 + return this;
102 + }
103 +
104 + /**
105 + * Returns all LSPs (L1 and L2).
106 + *
107 + * @param excludeMaxAgeLsp exclude the max age LSPs
108 + * @return List of LSPs
109 + */
110 + public List<LspWrapper> allLspHeaders(boolean excludeMaxAgeLsp) {
111 + List<LspWrapper> summaryList = new CopyOnWriteArrayList();
112 + addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL1Db);
113 + addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL2Db);
114 +
115 + return summaryList;
116 + }
117 +
118 + /**
119 + * Adds the LSPs to summary list.
120 + *
121 + * @param summaryList summary list
122 + * @param excludeMaxAgeLsp exclude max age LSP
123 + * @param lspMap map of LSP
124 + */
125 + private void addLspToHeaderList(List summaryList, boolean excludeMaxAgeLsp, Map lspMap) {
126 + Iterator slotVals = lspMap.values().iterator();
127 + while (slotVals.hasNext()) {
128 + LspWrapper wrapper = (LspWrapper) slotVals.next();
129 + if (excludeMaxAgeLsp) {
130 + //if current age of lsa is max age or lsa present in Max Age bin
131 + if (wrapper.remainingLifetime() != 0) {
132 + addToList(wrapper, summaryList);
133 + }
134 + } else {
135 + addToList(wrapper, summaryList);
136 + }
137 + }
138 + }
139 +
140 + /**
141 + * Adds the LSPWrapper to summary list.
142 + *
143 + * @param wrapper LSP wrapper instance
144 + * @param summList LSP summary list
145 + */
146 + private void addToList(LspWrapper wrapper, List summList) {
147 + //set the current age
148 + ((LsPdu) wrapper.lsPdu()).setRemainingLifeTime(wrapper.remainingLifetime());
149 + summList.add(wrapper);
150 + }
151 +
152 + /**
153 + * Finds the LSP from appropriate maps L1 or L2 based on type.
154 + *
155 + * @param pduType L1 or L2 LSP
156 + * @param lspId LSP ID
157 + * @return LSP wrapper object
158 + */
159 + public LspWrapper findLsp(IsisPduType pduType, String lspId) {
160 + LspWrapper lspWrapper = null;
161 +
162 + switch (pduType) {
163 + case L1LSPDU:
164 + lspWrapper = isisL1Db.get(lspId);
165 + break;
166 + case L2LSPDU:
167 + lspWrapper = isisL2Db.get(lspId);
168 + break;
169 + default:
170 + log.debug("Unknown LSP type..!!!");
171 + break;
172 + }
173 +
174 + //set the current age
175 + if (lspWrapper != null) {
176 + //set the current age
177 + ((DefaultLspWrapper) lspWrapper).lsPdu().setRemainingLifeTime(lspWrapper.remainingLifetime());
178 + }
179 +
180 + return lspWrapper;
181 + }
182 +
183 + /**
184 + * Installs a new self-originated LSP.
185 + *
186 + * @return true if successfully added
187 + */
188 + public boolean addLsp(IsisMessage isisMessage, boolean isSelfOriginated, IsisInterface isisInterface) {
189 + LsPdu lspdu = (LsPdu) isisMessage;
190 + DefaultLspWrapper lspWrapper = new DefaultLspWrapper();
191 + lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
192 + lspWrapper.setRemainingLifetime(IsisConstants.LSPMAXAGE - lsdbAge.ageCounter());
193 + lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
194 + lspWrapper.setLsPdu(lspdu);
195 + lspWrapper.setAgeCounterWhenReceived(lsdbAge.ageCounter());
196 + lspWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.ageCounterRollOver());
197 + lspWrapper.setSelfOriginated(isSelfOriginated);
198 + lspWrapper.setIsisInterface(isisInterface);
199 + lspWrapper.setLsdbAge(lsdbAge);
200 + addLsp(lspWrapper, lspdu.lspId());
201 +
202 + log.debug("Added LSp In LSDB: {}", lspWrapper);
203 +
204 + return true;
205 + }
206 +
207 + /**
208 + * Adds the LSP to L1 or L2 database.
209 + *
210 + * @param lspWrapper LSA wrapper instance
211 + * @param key key
212 + * @return True if added else false
213 + */
214 + private boolean addLsp(LspWrapper lspWrapper, String key) {
215 + //Remove the lsa from bin if exist.
216 + removeLspFromBin(lspWrapper);
217 +
218 + switch (lspWrapper.lsPdu().isisPduType()) {
219 + case L1LSPDU:
220 + isisL1Db.put(key, lspWrapper);
221 + break;
222 + case L2LSPDU:
223 + isisL2Db.put(key, lspWrapper);
224 + break;
225 + default:
226 + log.debug("Unknown LSP type to add..!!!");
227 + break;
228 + }
229 +
230 + //add it to bin
231 + Integer binNumber = lsdbAge.age2Bin(IsisConstants.LSPMAXAGE - lspWrapper.remainingLifetime());
232 + IsisLspBin lspBin = lsdbAge.getLspBin(binNumber);
233 + if (lspBin != null) {
234 + //remove from existing
235 + lspWrapper.setBinNumber(binNumber);
236 + lspBin.addIsisLsp(key, lspWrapper);
237 + lsdbAge.addLspBin(binNumber, lspBin);
238 + log.debug("Added Type {} LSP to LSDB and LSABin[{}], Remaining life time of LSA {}",
239 + lspWrapper.lsPdu().isisPduType(),
240 + binNumber, lspWrapper.remainingLifetime());
241 + }
242 +
243 + return false;
244 + }
245 +
246 + /**
247 + * Removes LSP from Bin.
248 + *
249 + * @param lsaWrapper LSP wrapper instance
250 + */
251 + public void removeLspFromBin(LspWrapper lsaWrapper) {
252 + if (lsaWrapper != null) {
253 + lsdbAge.removeLspFromBin(lsaWrapper);
254 + }
255 + }
256 +
257 + /**
258 + * Returns new ,latest or old according to the type of ISIS message received.
259 + *
260 + * @param lsp1 LSP instance
261 + * @param lsp2 LSP instance
262 + * @return string status
263 + */
264 + public String isNewerOrSameLsp(IsisMessage lsp1, IsisMessage lsp2) {
265 + LsPdu receivedLsp = (LsPdu) lsp1;
266 + LsPdu lspFromDb = (LsPdu) lsp2;
267 + if (receivedLsp.sequenceNumber() > lspFromDb.sequenceNumber()) {
268 + return "latest";
269 + } else if (receivedLsp.sequenceNumber() < lspFromDb.sequenceNumber()) {
270 + return "old";
271 + } else if (receivedLsp.sequenceNumber() == lspFromDb.sequenceNumber()) {
272 + return "same";
273 + }
274 +
275 + return "";
276 + }
277 +
278 + /**
279 + * Returns the sequence number.
280 + *
281 + * @param lspType type of LSP
282 + * @return sequence number
283 + */
284 + public int lsSequenceNumber(IsisPduType lspType) {
285 + switch (lspType) {
286 + case L1LSPDU:
287 + return l1LspSeqNo++;
288 + case L2LSPDU:
289 + return l2LspSeqNo++;
290 + default:
291 + return IsisConstants.STARTLSSEQUENCENUM;
292 + }
293 + }
294 +
295 + /**
296 + * Deletes the given LSP.
297 + *
298 + * @param lspMessage LSP instance
299 + */
300 + public void deleteLsp(IsisMessage lspMessage) {
301 + LsPdu lsp = (LsPdu) lspMessage;
302 + String lspKey = lsp.lspId();
303 + switch (lsp.isisPduType()) {
304 + case L1LSPDU:
305 + isisL1Db.remove(lspKey);
306 + break;
307 + case L2LSPDU:
308 + isisL2Db.remove(lspKey);
309 + break;
310 + default:
311 + log.debug("Unknown LSP type to remove..!!!");
312 + break;
313 + }
314 + }
315 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl.lsdb;
17 +
18 +import org.onosproject.isis.controller.IsisLsdbAge;
19 +import org.onosproject.isis.controller.IsisLspBin;
20 +import org.onosproject.isis.controller.LspWrapper;
21 +import org.onosproject.isis.io.isispacket.pdu.LsPdu;
22 +import org.onosproject.isis.io.util.IsisConstants;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import java.util.Map;
27 +import java.util.concurrent.ArrayBlockingQueue;
28 +import java.util.concurrent.BlockingQueue;
29 +import java.util.concurrent.ConcurrentHashMap;
30 +import java.util.concurrent.Executors;
31 +import java.util.concurrent.ScheduledExecutorService;
32 +import java.util.concurrent.TimeUnit;
33 +
34 +/**
35 + * Representation of ISIS link state database ageing process.
36 + */
37 +public class DefaultIsisLsdbAge implements IsisLsdbAge {
38 + private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class);
39 + protected static int ageCounter = 0;
40 + private InternalAgeTimer dbAgeTimer;
41 + private ScheduledExecutorService exServiceage;
42 + private Integer maxBins = 1200;
43 + private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins);
44 + private int ageCounterRollOver = 0;
45 + private IsisLspQueueConsumer queueConsumer = null;
46 + private BlockingQueue<LspWrapper> lsaQueue = new ArrayBlockingQueue<>(1024);
47 +
48 + /**
49 + * Creates an instance of LSDB age.
50 + */
51 + public DefaultIsisLsdbAge() {
52 + // create LSBin's in the HashMap.
53 + for (int i = 0; i < maxBins; i++) {
54 + IsisLspBin lspBin = new DefaultIsisLspBin(i);
55 + ageBins.put(i, lspBin);
56 + }
57 + }
58 +
59 + /**
60 + * Returns age counter.
61 + *
62 + * @return age counter
63 + */
64 + public int ageCounter() {
65 + return ageCounter;
66 + }
67 +
68 + /**
69 + * Returns age counter roll over.
70 + *
71 + * @return age counter roll over
72 + */
73 + public int ageCounterRollOver() {
74 +
75 + return ageCounterRollOver;
76 + }
77 +
78 + /**
79 + * Adds LSP to LS bin for ageing.
80 + *
81 + * @param binNumber key to store in bin
82 + * @param lspBin LSP bin instance
83 + */
84 + public void addLspBin(int binNumber, IsisLspBin lspBin) {
85 + if (!ageBins.containsKey(binNumber)) {
86 + ageBins.put(binNumber, lspBin);
87 + }
88 + }
89 +
90 + /**
91 + * Returns LSP from Bin.
92 + *
93 + * @param binKey key
94 + * @return bin instance
95 + */
96 + public IsisLspBin getLspBin(int binKey) {
97 +
98 + return ageBins.get(binKey);
99 + }
100 +
101 + /**
102 + * Removes LSP from Bin.
103 + *
104 + * @param lspWrapper wrapper instance
105 + */
106 + public void removeLspFromBin(LspWrapper lspWrapper) {
107 + if (ageBins.containsKey(lspWrapper.binNumber())) {
108 + IsisLspBin lsaBin = ageBins.get(lspWrapper.binNumber());
109 + lsaBin.removeIsisLsp(((LsPdu) lspWrapper.lsPdu()).lspId(), lspWrapper);
110 + }
111 + }
112 +
113 + /**
114 + * Returns the bin number.
115 + *
116 + * @param age Can be either age or ageCounter
117 + * @return bin number.
118 + */
119 + public int age2Bin(int age) {
120 + if (age <= ageCounter) {
121 + return (ageCounter - age);
122 + } else {
123 + return ((IsisConstants.LSPMAXAGE - 1) + (ageCounter - age));
124 + }
125 + }
126 +
127 + /**
128 + * Starts the aging timer and queue consumer.
129 + */
130 + public void startDbAging() {
131 + startDbAgeTimer();
132 + queueConsumer = new IsisLspQueueConsumer(lsaQueue);
133 + new Thread(queueConsumer).start();
134 + }
135 +
136 + /**
137 + * Starts DB aging task.
138 + */
139 + private void startDbAgeTimer() {
140 + dbAgeTimer = new InternalAgeTimer();
141 + //from 1 sec
142 + exServiceage = Executors.newSingleThreadScheduledExecutor();
143 + exServiceage.scheduleAtFixedRate(dbAgeTimer, 1, 1, TimeUnit.SECONDS);
144 + }
145 +
146 + /**
147 + * Gets called every second as part of the aging process.
148 + */
149 + public void ageLsp() {
150 + refreshLsa();
151 + maxAgeLsa();
152 +
153 + if (ageCounter == IsisConstants.LSPMAXAGE) {
154 + ageCounter = 0;
155 + ageCounterRollOver++;
156 + } else {
157 + ageCounter++;
158 + }
159 + }
160 +
161 + /**
162 + * If the LSP have completed the MaxAge - they are moved called stop aging.
163 + */
164 + public void maxAgeLsa() {
165 + if (ageCounter == 0) {
166 + return;
167 + }
168 + //Get from Age Bins
169 + IsisLspBin lspBin = ageBins.get(ageCounter - 1);
170 + if (lspBin == null) {
171 + return;
172 + }
173 + Map lspBinMap = lspBin.listOfLsp();
174 + for (Object key : lspBinMap.keySet()) {
175 + LspWrapper lspWrapper = (LspWrapper) lspBinMap.get((String) key);
176 + if (lspWrapper.currentAge() == IsisConstants.LSPMAXAGE) {
177 + lspWrapper.setLspProcessing(IsisConstants.MAXAGELSP);
178 + log.debug("Lsp picked for maxage removal. Age Counter: {}, AgeCounterRollover: {}, " +
179 + "AgeCounterRollover WhenAddedToDb: {}, LSA Type: {}, LSA Key: {}",
180 + ageCounter, ageCounterRollOver, lspWrapper.currentAge(),
181 + lspWrapper.lsPdu().isisPduType(), key);
182 + //add it to lspQueue for processing
183 + try {
184 + lsaQueue.put(lspWrapper);
185 + //remove from bin
186 + lspBin.removeIsisLsp((String) key, lspWrapper);
187 + } catch (InterruptedException e) {
188 + log.debug("Error::LSDBAge::maxAgeLsp::{}", e.getMessage());
189 + }
190 + }
191 + }
192 +
193 + }
194 +
195 + /*
196 + * If the LSP is in age bin of 900s- it's pushed into refresh list.
197 + */
198 + public void refreshLsa() {
199 + int binNumber;
200 + if (ageCounter < IsisConstants.LSPREFRESH) {
201 + binNumber = ageCounter + IsisConstants.LSPREFRESH;
202 + } else {
203 + binNumber = ageCounter - IsisConstants.LSPREFRESH;
204 + }
205 + if (binNumber > IsisConstants.LSPMAXAGE) {
206 + binNumber = binNumber - IsisConstants.LSPMAXAGE;
207 + }
208 + IsisLspBin lspBin = ageBins.get(binNumber);
209 + if (lspBin == null) {
210 + return;
211 + }
212 + Map lspBinMap = lspBin.listOfLsp();
213 + for (Object key : lspBinMap.keySet()) {
214 + LspWrapper lsp = (LspWrapper) lspBinMap.get((String) key);
215 + try {
216 + if (lsp.isSelfOriginated()) {
217 + log.debug("Lsp picked for refreshLsp. binNumber: {}, LSA Type: {}, LSA Key: {}",
218 + binNumber, lsp.lspType(), key);
219 + lsp.setLspProcessing(IsisConstants.REFRESHLSP);
220 + lsaQueue.put(lsp);
221 + //remove from bin
222 + lspBin.removeIsisLsp((String) key, lsp);
223 + }
224 + } catch (InterruptedException e) {
225 + log.debug("Error::LSDBAge::refreshLsp::{}", e.getMessage());
226 + }
227 + }
228 + }
229 +
230 +
231 + /**
232 + * Runnable task which runs every second and calls aging process.
233 + */
234 + private class InternalAgeTimer implements Runnable {
235 +
236 + /**
237 + * Creates an instance of age timer task.
238 + */
239 + InternalAgeTimer() {
240 + log.debug("Starts::IsisLsdbAge::AgeTimer...!!! ");
241 + }
242 +
243 + @Override
244 + public void run() {
245 + ageLsp();
246 + }
247 + }
248 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl.lsdb;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import org.onosproject.isis.controller.IsisLspBin;
20 +import org.onosproject.isis.controller.LspWrapper;
21 +
22 +import java.util.Map;
23 +import java.util.concurrent.ConcurrentHashMap;
24 +
25 +/**
26 + * Representation of LSP bin, where an LSP is stored for Aging.
27 + * A bin is identified by a bin number and can have one or more LSPs
28 + * store in a particular bin location
29 + */
30 +public class DefaultIsisLspBin implements IsisLspBin {
31 + private int binNumber;
32 + private Map<String, LspWrapper> listOfLsp = new ConcurrentHashMap<>();
33 +
34 + /**
35 + * Creates ISIS LSP bin instance.
36 + *
37 + * @param binNumber bin number
38 + */
39 + public DefaultIsisLspBin(int binNumber) {
40 + this.binNumber = binNumber;
41 + }
42 +
43 + /**
44 + * Adds the LSP to wrapper.
45 + *
46 + * @param lspKey key to add the LSP
47 + * @param lspWrapper LSP wrapper instance
48 + */
49 + public void addIsisLsp(String lspKey, LspWrapper lspWrapper) {
50 + if (!listOfLsp.containsKey(lspKey)) {
51 + listOfLsp.put(lspKey, lspWrapper);
52 + lspWrapper.setBinNumber(this.binNumber);
53 + }
54 + }
55 +
56 + /**
57 + * Returns the LSP wrapper.
58 + *
59 + * @param lspKey LSP key
60 + * @return LSP wrapper
61 + */
62 + public LspWrapper isisLsp(String lspKey) {
63 + return listOfLsp.get(lspKey);
64 + }
65 +
66 + /**
67 + * Removes ISIS LSP from database.
68 + *
69 + * @param lspKey LSP key
70 + * @param lspWrapper LSP wrapper instance
71 + */
72 + public void removeIsisLsp(String lspKey, LspWrapper lspWrapper) {
73 + if (listOfLsp.containsKey(lspKey)) {
74 + listOfLsp.remove(lspKey);
75 + }
76 + }
77 +
78 + /**
79 + * Returns all LSP wrappers.
80 + *
81 + * @return all LSP wrappers
82 + */
83 + public Map<String, LspWrapper> listOfLsp() {
84 + return listOfLsp;
85 + }
86 +
87 + /**
88 + * Returns the bin number.
89 + *
90 + * @return the bin number
91 + */
92 + public int binNumber() {
93 + return binNumber;
94 + }
95 +
96 + @Override
97 + public String toString() {
98 + return MoreObjects.toStringHelper(getClass())
99 + .omitNullValues()
100 + .add("binNumber", binNumber)
101 + .add("listOfLsp", listOfLsp)
102 + .toString();
103 + }
104 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl.lsdb;
17 +
18 +import org.onosproject.isis.controller.IsisInterface;
19 +import org.onosproject.isis.controller.IsisLsdbAge;
20 +import org.onosproject.isis.controller.IsisPduType;
21 +import org.onosproject.isis.controller.LspWrapper;
22 +import org.onosproject.isis.io.isispacket.pdu.LsPdu;
23 +import org.onosproject.isis.io.util.IsisConstants;
24 +
25 +/**
26 + * Representation of LSP wrapper where the LSPs are stored with metadata.
27 + */
28 +public class DefaultLspWrapper implements LspWrapper {
29 + private int binNumber = -1;
30 + private boolean selfOriginated = false;
31 + private IsisPduType lspType;
32 + private int lspAgeReceived;
33 + private int ageCounterWhenReceived;
34 + private LsPdu lsPdu;
35 + private IsisLsdbAge lsdbAge;
36 + private int ageCounterRollOverWhenAdded;
37 + private int remainingLifetime;
38 + private IsisInterface isisInterface;
39 + private String lspProcessing;
40 +
41 + /**
42 + * Returns "refreshLsp" or "maxageLsp" based on LSP to process.
43 + *
44 + * @return LSP processing string
45 + */
46 + public String lspProcessing() {
47 + return lspProcessing;
48 + }
49 +
50 + /**
51 + * Sets LSP processing "refreshLsp" or "maxageLsp" based on LSP to process.
52 + *
53 + * @param lspProcessing "refreshLsp" or "maxageLsp" based on LSP to process
54 + */
55 + public void setLspProcessing(String lspProcessing) {
56 + this.lspProcessing = lspProcessing;
57 + }
58 +
59 + /**
60 + * Returns LSP age received.
61 + *
62 + * @return LSP age received
63 + */
64 + public int lspAgeReceived() {
65 + return lspAgeReceived;
66 + }
67 +
68 + /**
69 + * Sets LSP age received.
70 + *
71 + * @param lspAgeReceived LSP age received.
72 + */
73 + public void setLspAgeReceived(int lspAgeReceived) {
74 + this.lspAgeReceived = lspAgeReceived;
75 + }
76 +
77 + /**
78 + * Returns ISIS interface instance.
79 + *
80 + * @return ISIS interface instance
81 + */
82 + public IsisInterface isisInterface() {
83 + return isisInterface;
84 + }
85 +
86 + /**
87 + * Sets ISIS interface.
88 + *
89 + * @param isisInterface ISIS interface instance
90 + */
91 + public void setIsisInterface(IsisInterface isisInterface) {
92 + this.isisInterface = isisInterface;
93 + }
94 +
95 + /**
96 + * Returns age counter when received.
97 + *
98 + * @return age counter when received
99 + */
100 + public int ageCounterWhenReceived() {
101 +
102 + return ageCounterWhenReceived;
103 + }
104 +
105 + /**
106 + * Sets age counter when received.
107 + *
108 + * @param ageCounterWhenReceived age counter when received
109 + */
110 + public void setAgeCounterWhenReceived(int ageCounterWhenReceived) {
111 + this.ageCounterWhenReceived = ageCounterWhenReceived;
112 + }
113 +
114 + /**
115 + * Returns age counter roll over.
116 + *
117 + * @return age counter roll over
118 + */
119 + public int ageCounterRollOverWhenAdded() {
120 + return ageCounterRollOverWhenAdded;
121 + }
122 +
123 + /**
124 + * Sets age counter roll over when added.
125 + *
126 + * @param ageCounterRollOverWhenAdded age counter roll over when added
127 + */
128 + public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) {
129 + this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded;
130 + }
131 +
132 + /**
133 + * Returns bin number.
134 + *
135 + * @return bin number
136 + */
137 + public int binNumber() {
138 + return binNumber;
139 + }
140 +
141 + /**
142 + * Sets bin number.
143 + *
144 + * @param binNumber bin number
145 + */
146 + public void setBinNumber(int binNumber) {
147 + this.binNumber = binNumber;
148 + }
149 +
150 + /**
151 + * Returns true if self originated.
152 + *
153 + * @return true if self originated.
154 + */
155 + public boolean isSelfOriginated() {
156 + return selfOriginated;
157 + }
158 +
159 + /**
160 + * Sets true if self originated.
161 + *
162 + * @param selfOriginated true if self originated else false
163 + */
164 + public void setSelfOriginated(boolean selfOriginated) {
165 + this.selfOriginated = selfOriginated;
166 + }
167 +
168 + /**
169 + * Returns ISIS PDU type.
170 + *
171 + * @return ISIS PDU type
172 + */
173 + public IsisPduType lspType() {
174 + return lspType;
175 + }
176 +
177 + /**
178 + * Sets ISIS PDU type.
179 + *
180 + * @param lspType ISIS PDU type
181 + */
182 + public void setLspType(IsisPduType lspType) {
183 + this.lspType = lspType;
184 + }
185 +
186 + /**
187 + * Returns LSPDU which the wrapper contains.
188 + *
189 + * @return LSPDU which the wrapper contains
190 + */
191 + public LsPdu lsPdu() {
192 + return lsPdu;
193 + }
194 +
195 + /**
196 + * Sets LSPDU which the wrapper contains.
197 + *
198 + * @param lsPdu LSPDU which the wrapper contains
199 + */
200 + public void setLsPdu(LsPdu lsPdu) {
201 + this.lsPdu = lsPdu;
202 + }
203 +
204 + /**
205 + * Returns ISIS LSDB age.
206 + *
207 + * @return ISIS LSDB age
208 + */
209 + public IsisLsdbAge lsdbAge() {
210 + return lsdbAge;
211 + }
212 +
213 + /**
214 + * Sets LSDB age.
215 + *
216 + * @param lsdbAge LSDB age
217 + */
218 + public void setLsdbAge(IsisLsdbAge lsdbAge) {
219 + this.lsdbAge = lsdbAge;
220 + }
221 +
222 + /**
223 + * Returns the current LSP Age.
224 + *
225 + * @return LSP age
226 + */
227 + public int currentAge() {
228 +
229 + int currentAge = 0;
230 + //ls age received
231 + if (lsdbAge.ageCounter() >= ageCounterWhenReceived) {
232 + currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
233 + } else {
234 + currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter())
235 + - ageCounterWhenReceived);
236 + }
237 +
238 + if (currentAge >= IsisConstants.LSPMAXAGE) {
239 + return IsisConstants.LSPMAXAGE;
240 + } else if ((currentAge == lspAgeReceived) && ageCounterRollOverWhenAdded
241 + != lsdbAge.ageCounterRollOver()) {
242 + return IsisConstants.LSPMAXAGE;
243 + }
244 +
245 + return currentAge;
246 + }
247 +
248 + /**
249 + * Returns remaining time.
250 + *
251 + * @return remaining time
252 + */
253 + public int remainingLifetime() {
254 + //Calculate the remaining lifetime
255 + remainingLifetime = IsisConstants.LSPMAXAGE - lsdbAge.ageCounter();
256 + return remainingLifetime;
257 + }
258 +
259 + /**
260 + * Sets remaining life time.
261 + *
262 + * @param remainingLifetime LSPs remaining life time
263 + */
264 + public void setRemainingLifetime(int remainingLifetime) {
265 + this.remainingLifetime = remainingLifetime;
266 + }
267 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.isis.controller.impl.lsdb;
17 +
18 +import org.jboss.netty.channel.Channel;
19 +import org.onosproject.isis.controller.IsisLsdb;
20 +import org.onosproject.isis.controller.IsisPduType;
21 +import org.onosproject.isis.controller.LspWrapper;
22 +import org.onosproject.isis.controller.impl.DefaultIsisInterface;
23 +import org.onosproject.isis.io.isispacket.pdu.LsPdu;
24 +import org.onosproject.isis.io.util.IsisConstants;
25 +import org.onosproject.isis.io.util.IsisUtil;
26 +import org.slf4j.Logger;
27 +import org.slf4j.LoggerFactory;
28 +
29 +import java.util.concurrent.BlockingQueue;
30 +
31 +/**
32 + * Representation of LSP queue consumer.
33 + */
34 +public class IsisLspQueueConsumer implements Runnable {
35 + private static final Logger log = LoggerFactory.getLogger(IsisLspQueueConsumer.class);
36 + private BlockingQueue queue = null;
37 +
38 + /**
39 + * Creates an instance of LSP queue consumer.
40 + *
41 + * @param queue queue instance
42 + */
43 + public IsisLspQueueConsumer(BlockingQueue queue) {
44 + this.queue = queue;
45 + }
46 +
47 + /**
48 + * Gets the LSP wrapper instance from queue and process it.
49 + */
50 + @Override
51 + public void run() {
52 + log.debug("LSPQueueConsumer:run...!!!");
53 + try {
54 + while (true) {
55 + if (!queue.isEmpty()) {
56 + LspWrapper wrapper = (LspWrapper) queue.take();
57 + String lspProcessing = wrapper.lspProcessing();
58 + switch (lspProcessing) {
59 + case IsisConstants.REFRESHLSP:
60 + log.debug("LSPQueueConsumer: Message - " + IsisConstants.REFRESHLSP +
61 + " consumed.");
62 + processRefreshLsp(wrapper);
63 + break;
64 + case IsisConstants.MAXAGELSP:
65 + log.debug("LSPQueueConsumer: Message - " + IsisConstants.MAXAGELSP +
66 + " consumed.");
67 + processMaxAgeLsa(wrapper);
68 + break;
69 + default:
70 + log.debug("Unknown command to process the LSP in queue ...!!!");
71 + break;
72 + }
73 + }
74 + }
75 +
76 + } catch (Exception e) {
77 + log.debug("Error::LSPQueueConsumer::{}", e.getMessage());
78 + }
79 + }
80 +
81 + /**
82 + * Process refresh LSP.
83 + *
84 + * @param wrapper LSP wrapper instance
85 + */
86 + private void processRefreshLsp(LspWrapper wrapper) throws Exception {
87 + if (wrapper.isSelfOriginated()) { //self originated
88 + DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
89 + Channel channel = isisInterface.channel();
90 + if (channel != null && channel.isConnected()) {
91 + LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
92 + lsPdu.setSequenceNumber(isisInterface.isisLsdb().lsSequenceNumber(
93 + IsisPduType.get(lsPdu.pduType())));
94 + lsPdu.setRemainingLifeTime(IsisConstants.LSPMAXAGE);
95 + byte[] lspBytes = lsPdu.asBytes();
96 + lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
97 + IsisConstants.LENGTHPOSITION + 1,
98 + IsisConstants.RESERVEDPOSITION);
99 + lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
100 + IsisConstants.CHECKSUMPOSITION + 1);
101 + //write to the channel
102 + channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex()));
103 +
104 + log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}",
105 + wrapper.lsPdu());
106 + }
107 +
108 + }
109 + }
110 +
111 + /**
112 + * Process max age LSP.
113 + *
114 + * @param wrapper LSP wrapper instance
115 + */
116 + private void processMaxAgeLsa(LspWrapper wrapper) {
117 + //set the destination
118 + DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
119 + if (isisInterface != null) {
120 + //delete from db
121 + LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
122 + IsisLsdb isisDb = isisInterface.isisLsdb();
123 + isisDb.deleteLsp(lsPdu);
124 + log.debug("LSPQueueConsumer: processMaxAgeLsp - Removed-Max Age LSP {}",
125 + wrapper.lsPdu());
126 + }
127 + }
128 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -13,32 +13,8 @@ ...@@ -13,32 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.isis.io.util;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 16
20 /** 17 /**
21 - * Representation of ISIS config. 18 + * Implementation of the ISIS controller LSDB and related functionality.
22 - */
23 -public enum IsisConfig {
24 - INSTANCE;
25 - private JsonNode jsonNodes = null;
26 -
27 - /**
28 - * Returns the config value.
29 - *
30 - * @return jsonNodes json node
31 - */
32 - public JsonNode config() {
33 - return jsonNodes;
34 - }
35 -
36 - /**
37 - * Sets the config value for jsonNode.
38 - *
39 - * @param jsonNodes json node
40 */ 19 */
41 - public void setConfig(JsonNode jsonNodes) {
42 - this.jsonNodes = jsonNodes;
43 - }
44 -}
...\ No newline at end of file ...\ No newline at end of file
20 +package org.onosproject.isis.controller.impl.lsdb;
...\ No newline at end of file ...\ No newline at end of file
......
1 +/*
2 + * Copyright 2016-present 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 ISIS controller.
19 + */
20 +package org.onosproject.isis.controller.impl;
...\ No newline at end of file ...\ No newline at end of file
...@@ -280,7 +280,7 @@ public class LsPdu extends IsisHeader { ...@@ -280,7 +280,7 @@ public class LsPdu extends IsisHeader {
280 * Returns the packet data unit length of link state packet. 280 * Returns the packet data unit length of link state packet.
281 * Entire length of this PDU, in octets 281 * Entire length of this PDU, in octets
282 * 282 *
283 - * @return pduLength packte date unit length 283 + * @return pduLength packet data unit length
284 */ 284 */
285 public int pduLength() { 285 public int pduLength() {
286 return pduLength; 286 return pduLength;
...@@ -290,7 +290,7 @@ public class LsPdu extends IsisHeader { ...@@ -290,7 +290,7 @@ public class LsPdu extends IsisHeader {
290 * Sets the packet data unit length for link state packet. 290 * Sets the packet data unit length for link state packet.
291 * Entire Length of this PDU, in octets 291 * Entire Length of this PDU, in octets
292 * 292 *
293 - * @param pduLength packte data length 293 + * @param pduLength packet data length
294 */ 294 */
295 public void setPduLength(int pduLength) { 295 public void setPduLength(int pduLength) {
296 this.pduLength = pduLength; 296 this.pduLength = pduLength;
......
...@@ -220,10 +220,9 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { ...@@ -220,10 +220,9 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
220 byte[] bytes = null; 220 byte[] bytes = null;
221 byte[] tlvHeader = tlvHeaderAsByteArray(); 221 byte[] tlvHeader = tlvHeaderAsByteArray();
222 byte[] tlvBody = tlvBodyAsBytes(); 222 byte[] tlvBody = tlvBodyAsBytes();
223 - //systemID + pseudo number+length of subtlv=11l
224 - tlvBody[10] = (byte) (tlvBody.length - 11);
225 tlvHeader[1] = (byte) tlvBody.length; 223 tlvHeader[1] = (byte) tlvBody.length;
226 bytes = Bytes.concat(tlvHeader, tlvBody); 224 bytes = Bytes.concat(tlvHeader, tlvBody);
225 +
227 return bytes; 226 return bytes;
228 } 227 }
229 228
...@@ -246,8 +245,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { ...@@ -246,8 +245,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
246 } else { 245 } else {
247 controlInfo = controlInfo + "0"; 246 controlInfo = controlInfo + "0";
248 } 247 }
249 - String prefixlength = IsisUtil.toEightBitBinary(Integer.toBinaryString(this.prefixLength())); 248 + String prefixLength = IsisUtil.toEightBitBinary(Integer.toBinaryString(this.prefixLength()));
250 - controlInfo = controlInfo + prefixlength.substring(2, prefixlength.length()); 249 + controlInfo = controlInfo + prefixLength.substring(2, prefixLength.length());
251 bodyLst.add(Byte.parseByte(controlInfo, 2)); 250 bodyLst.add(Byte.parseByte(controlInfo, 2));
252 if (this.isSubTlvPresence()) { 251 if (this.isSubTlvPresence()) {
253 bodyLst.add(this.subTlvLength()); 252 bodyLst.add(this.subTlvLength());
...@@ -255,6 +254,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv { ...@@ -255,6 +254,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
255 bodyLst.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv)); 254 bodyLst.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
256 } 255 }
257 } 256 }
257 + bodyLst.addAll(Bytes.asList(IsisUtil.prefixToBytes(this.prefix())));
258 +
258 return Bytes.toArray(bodyLst); 259 return Bytes.toArray(bodyLst);
259 } 260 }
260 261
......
1 +/*
2 + * Copyright 2016-present 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.isis.io.isispacket.tlv;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import com.google.common.primitives.Bytes;
20 +import org.jboss.netty.buffer.ChannelBuffer;
21 +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder;
22 +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes;
23 +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType;
24 +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
25 +import org.onosproject.isis.io.util.IsisUtil;
26 +
27 +import java.util.ArrayList;
28 +import java.util.List;
29 +
30 +/**
31 + * Representation of IS extended reachability TLV.
32 + */
33 +public class IsExtendedReachability extends TlvHeader implements IsisTlv {
34 +
35 + private String neighborId;
36 + private int metric;
37 + private List<TrafficEngineeringSubTlv> trafEnginSubTlv = new ArrayList<>();
38 +
39 + /**
40 + * Creates an instance of IP external reachability TLV.
41 + *
42 + * @param tlvHeader TLV header
43 + */
44 + public IsExtendedReachability(TlvHeader tlvHeader) {
45 + this.setTlvType(tlvHeader.tlvType());
46 + this.setTlvLength(tlvHeader.tlvLength());
47 + }
48 +
49 + /**
50 + * Returns neighbor ID.
51 + *
52 + * @return neighbor ID
53 + */
54 + public String neighborId() {
55 + return neighborId;
56 + }
57 +
58 + /**
59 + * Sets neighbor ID.
60 + *
61 + * @param neighborId neighbor ID
62 + */
63 + public void setNeighborId(String neighborId) {
64 + this.neighborId = neighborId;
65 + }
66 +
67 + /**
68 + * Returns metric.
69 + *
70 + * @return metric
71 + */
72 + public int metric() {
73 + return metric;
74 + }
75 +
76 + /**
77 + * Sets metric.
78 + *
79 + * @param metric metric
80 + */
81 + public void setMetric(int metric) {
82 + this.metric = metric;
83 + }
84 +
85 + /**
86 + * Adds the traffic engineering sub TLV to IS extended reachability TLV.
87 + *
88 + * @param trafEnginSubTlv traffic engineering sub TLV
89 + */
90 + public void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv) {
91 + this.trafEnginSubTlv.add(trafEnginSubTlv);
92 + }
93 +
94 + @Override
95 + public void readFrom(ChannelBuffer channelBuffer) {
96 + byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
97 + channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
98 + this.setNeighborId(IsisUtil.systemId(tempByteArray));
99 + this.setMetric(channelBuffer.readUnsignedMedium());
100 + while (channelBuffer.readableBytes() > 0) {
101 + TlvHeader tlvHeader = new TlvHeader();
102 + tlvHeader.setTlvType(channelBuffer.readByte());
103 + tlvHeader.setTlvLength(channelBuffer.readByte());
104 + SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType());
105 + if (tlvValue != null) {
106 + this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader,
107 + channelBuffer.readBytes(tlvHeader.tlvLength())));
108 + } else {
109 + channelBuffer.readBytes(tlvHeader.tlvLength());
110 + }
111 + }
112 + }
113 +
114 + @Override
115 + public byte[] asBytes() {
116 + byte[] bytes = null;
117 + byte[] tlvHeader = tlvHeaderAsByteArray();
118 + byte[] tlvBody = tlvBodyAsBytes();
119 + tlvHeader[1] = (byte) tlvBody.length;
120 + bytes = Bytes.concat(tlvHeader, tlvBody);
121 + return bytes;
122 + }
123 +
124 + /**
125 + * Returns TLV body of IS extended reachability TLV.
126 + *
127 + * @return byteArray TLV body of IS extended reachability TLV.
128 + */
129 + private byte[] tlvBodyAsBytes() {
130 + List<Byte> byteList = new ArrayList<>();
131 + byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId()));
132 + byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric())));
133 + if (this.trafEnginSubTlv.size() > 0) {
134 + for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.trafEnginSubTlv) {
135 + byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
136 + }
137 + }
138 + return Bytes.toArray(byteList);
139 + }
140 +
141 + @Override
142 + public String toString() {
143 + return MoreObjects.toStringHelper(getClass())
144 + .omitNullValues()
145 + .add("neighborId", neighborId)
146 + .add("metric", metric)
147 + .add("trafEnginSubTlv", trafEnginSubTlv)
148 + .toString();
149 + }
150 +
151 +}
...@@ -358,10 +358,7 @@ public class MetricOfInternalReachability { ...@@ -358,10 +358,7 @@ public class MetricOfInternalReachability {
358 } else { 358 } else {
359 this.setErrorMetricSupported(false); 359 this.setErrorMetricSupported(false);
360 } 360 }
361 - List<Byte> byteList = new ArrayList<>(); 361 +
362 - while (channelBuffer.readableBytes() > 0) {
363 - byteList.add(channelBuffer.readByte());
364 - }
365 byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES]; 362 byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
366 channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); 363 channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
367 this.setIpAddress(Ip4Address.valueOf(tempByteArray)); 364 this.setIpAddress(Ip4Address.valueOf(tempByteArray));
......
...@@ -42,7 +42,10 @@ public class TlvFinder extends TlvHeader { ...@@ -42,7 +42,10 @@ public class TlvFinder extends TlvHeader {
42 //TODO 42 //TODO
43 break; 43 break;
44 case EXTENDEDISREACHABILITY: 44 case EXTENDEDISREACHABILITY:
45 - //TODO 45 + IsExtendedReachability isExtendedReachability =
46 + new IsExtendedReachability(tlvHeader);
47 + isExtendedReachability.readFrom(channelBuffer);
48 + isisTlv = isExtendedReachability;
46 break; 49 break;
47 case HOSTNAME: 50 case HOSTNAME:
48 HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader); 51 HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader);
......
...@@ -82,6 +82,10 @@ public final class TlvsToBytes { ...@@ -82,6 +82,10 @@ public final class TlvsToBytes {
82 LspEntriesTlv lspEntriesTlv 82 LspEntriesTlv lspEntriesTlv
83 = (LspEntriesTlv) isisTlv; 83 = (LspEntriesTlv) isisTlv;
84 tlvBytes.addAll(Bytes.asList(lspEntriesTlv.asBytes())); 84 tlvBytes.addAll(Bytes.asList(lspEntriesTlv.asBytes()));
85 + } else if (isisTlv instanceof IsExtendedReachability) {
86 + IsExtendedReachability isExtendedReachability
87 + = (IsExtendedReachability) isisTlv;
88 + tlvBytes.addAll(Bytes.asList(isExtendedReachability.asBytes()));
85 } else { 89 } else {
86 log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes "); 90 log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes ");
87 } 91 }
......
...@@ -16,21 +16,25 @@ ...@@ -16,21 +16,25 @@
16 16
17 package org.onosproject.isis.io.util; 17 package org.onosproject.isis.io.util;
18 18
19 +import org.onlab.packet.Ip4Address;
20 +
19 /** 21 /**
20 * Representation of ISIS Constants. 22 * Representation of ISIS Constants.
21 */ 23 */
22 public final class IsisConstants { 24 public final class IsisConstants {
23 - public static final char PDU_LENGTH = 1497; // mtu (1500) - (3) LLC 25 + public static final char PDU_LENGTH = 1497;
26 + public static final char CONFIG_LENGTH = 1498;
24 public static final int MINIMUM_FRAME_LEN = 1521; 27 public static final int MINIMUM_FRAME_LEN = 1521;
25 public static final int METADATA_LEN = 7; 28 public static final int METADATA_LEN = 7;
26 public static final String SHOST = "127.0.0.1"; 29 public static final String SHOST = "127.0.0.1";
30 + public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
27 public static final int SPORT = 3000; 31 public static final int SPORT = 3000;
28 public static final byte L2 = 1; 32 public static final byte L2 = 1;
29 public static final int IRPDISCRIMINATOR = 131; 33 public static final int IRPDISCRIMINATOR = 131;
30 public static final int ISISVERSION = 1; 34 public static final int ISISVERSION = 1;
31 public static final int RESERVED = 0; 35 public static final int RESERVED = 0;
32 public static final int MAXAREAADDRESS = 0; 36 public static final int MAXAREAADDRESS = 0;
33 - public static final int IDLENGTH = 0; 37 + public static final int SYSTEMIDLENGTH = 0;
34 public static final int PROTOCOLSUPPORTED = 204; 38 public static final int PROTOCOLSUPPORTED = 204;
35 public static final int LOCALCIRCUITIDFORP2P = 130; 39 public static final int LOCALCIRCUITIDFORP2P = 130;
36 public static final int P2PHELLOHEADERLENGTH = 20; 40 public static final int P2PHELLOHEADERLENGTH = 20;
...@@ -48,6 +52,27 @@ public final class IsisConstants { ...@@ -48,6 +52,27 @@ public final class IsisConstants {
48 public static final int CHECKSUMPOSITION = 24; 52 public static final int CHECKSUMPOSITION = 24;
49 public static final String REFRESHLSP = "refreshLsp"; 53 public static final String REFRESHLSP = "refreshLsp";
50 public static final String MAXAGELSP = "maxAgeLsp"; 54 public static final String MAXAGELSP = "maxAgeLsp";
55 + public static final String DEFAULTLANID = "0000.0000.0000.00";
56 + public static final String PROCESSESID = "processId";
57 + public static final String INTERFACE = "interface";
58 + public static final String INTERFACEIP = "interfaceIp";
59 + public static final String NETWORKMASK = "networkMask";
60 + public static final String INTERFACEINDEX = "interfaceIndex";
61 + public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName";
62 + public static final String SYSTEMID = "systemId";
63 + public static final String LANID = "lanId";
64 + public static final String IDLENGTH = "idLength";
65 + public static final String MAXAREAADDRESSES = "maxAreaAddresses";
66 + public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType";
67 + public static final String CIRCUITID = "circuitId";
68 + public static final String NETWORKTYPE = "networkType";
69 + public static final String AREAADDRESS = "areaAddress";
70 + public static final String AREALENGTH = "areaLength";
71 + public static final String LSPID = "lspId";
72 + public static final String HOLDINGTIME = "holdingTime";
73 + public static final String HELLOINTERVAL = "helloInterval";
74 + public static final String PRIORITY = "priority";
75 + public static final String MACADDRESS = "macAddress";
51 76
52 /** 77 /**
53 * Non parameterized constructor. 78 * Non parameterized constructor.
......
...@@ -391,7 +391,7 @@ public final class IsisUtil { ...@@ -391,7 +391,7 @@ public final class IsisUtil {
391 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR); 391 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
392 isisHeader.setPduHeaderLength((byte) IsisConstants.P2PHELLOHEADERLENGTH); 392 isisHeader.setPduHeaderLength((byte) IsisConstants.P2PHELLOHEADERLENGTH);
393 isisHeader.setVersion((byte) IsisConstants.ISISVERSION); 393 isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
394 - isisHeader.setIdLength((byte) IsisConstants.IDLENGTH); 394 + isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
395 isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value()); 395 isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
396 isisHeader.setVersion2((byte) IsisConstants.ISISVERSION); 396 isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
397 //isisHeader.setReserved((byte) IsisConstants.RESERVED); 397 //isisHeader.setReserved((byte) IsisConstants.RESERVED);
...@@ -484,7 +484,7 @@ public final class IsisUtil { ...@@ -484,7 +484,7 @@ public final class IsisUtil {
484 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR); 484 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
485 isisHeader.setPduHeaderLength((byte) IsisConstants.HELLOHEADERLENGTH); 485 isisHeader.setPduHeaderLength((byte) IsisConstants.HELLOHEADERLENGTH);
486 isisHeader.setVersion((byte) IsisConstants.ISISVERSION); 486 isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
487 - isisHeader.setIdLength((byte) IsisConstants.IDLENGTH); 487 + isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
488 if (isisPduType == IsisPduType.L1HELLOPDU) { 488 if (isisPduType == IsisPduType.L1HELLOPDU) {
489 isisHeader.setIsisPduType(IsisPduType.L1HELLOPDU.value()); 489 isisHeader.setIsisPduType(IsisPduType.L1HELLOPDU.value());
490 lanId = isisInterface.l1LanId(); 490 lanId = isisInterface.l1LanId();
...@@ -693,4 +693,19 @@ public final class IsisUtil { ...@@ -693,4 +693,19 @@ public final class IsisUtil {
693 } 693 }
694 return prefix; 694 return prefix;
695 } 695 }
696 +
697 + /**
698 + * Converts the prefix to bytes.
699 + *
700 + * @param prefix prefix
701 + * @return prefix to bytes
702 + */
703 + public static byte[] prefixToBytes(String prefix) {
704 + List<Byte> byteList = new ArrayList<>();
705 + StringTokenizer tokenizer = new StringTokenizer(prefix, ".");
706 + while (tokenizer.hasMoreTokens()) {
707 + byteList.add((byte) Integer.parseInt(tokenizer.nextToken()));
708 + }
709 + return Bytes.toArray(byteList);
710 + }
696 } 711 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -26,6 +26,7 @@ import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas; ...@@ -26,6 +26,7 @@ import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
26 import org.onosproject.isis.io.isispacket.pdu.LsPdu; 26 import org.onosproject.isis.io.isispacket.pdu.LsPdu;
27 import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv; 27 import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
28 import org.onosproject.isis.io.isispacket.tlv.HostNameTlv; 28 import org.onosproject.isis.io.isispacket.tlv.HostNameTlv;
29 +import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
29 import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv; 30 import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv;
30 import org.onosproject.isis.io.isispacket.tlv.IpInternalReachabilityTlv; 31 import org.onosproject.isis.io.isispacket.tlv.IpInternalReachabilityTlv;
31 import org.onosproject.isis.io.isispacket.tlv.IsReachabilityTlv; 32 import org.onosproject.isis.io.isispacket.tlv.IsReachabilityTlv;
...@@ -115,7 +116,7 @@ public class LspGenerator { ...@@ -115,7 +116,7 @@ public class LspGenerator {
115 } else if (isisInterface.networkType() == IsisNetworkType.P2P) { 116 } else if (isisInterface.networkType() == IsisNetworkType.P2P) {
116 MacAddress neighborMac = isisInterface.neighbors().iterator().next(); 117 MacAddress neighborMac = isisInterface.neighbors().iterator().next();
117 IsisNeighbor neighbor = isisInterface.lookup(neighborMac); 118 IsisNeighbor neighbor = isisInterface.lookup(neighborMac);
118 - metricsOfReachability.setNeighborId(neighbor.neighborSystemId()); 119 + metricsOfReachability.setNeighborId(neighbor.neighborSystemId() + ".00");
119 } 120 }
120 121
121 isReachabilityTlv.addMeticsOfReachability(metricsOfReachability); 122 isReachabilityTlv.addMeticsOfReachability(metricsOfReachability);
...@@ -137,10 +138,25 @@ public class LspGenerator { ...@@ -137,10 +138,25 @@ public class LspGenerator {
137 metricOfIntRea.setErrorMetric((byte) 0); 138 metricOfIntRea.setErrorMetric((byte) 0);
138 metricOfIntRea.setErrorMetricSupported(false); 139 metricOfIntRea.setErrorMetricSupported(false);
139 metricOfIntRea.setExpenseIsInternal(true); 140 metricOfIntRea.setExpenseIsInternal(true);
140 - metricOfIntRea.setIpAddress(isisInterface.interfaceIpAddress()); 141 + Ip4Address ip4Address = isisInterface.interfaceIpAddress();
142 + byte[] ipAddress = ip4Address.toOctets();
143 + ipAddress[ipAddress.length - 1] = 0;
144 + metricOfIntRea.setIpAddress(Ip4Address.valueOf(ipAddress));
141 metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask())); 145 metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask()));
142 ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea); 146 ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea);
143 lsp.addTlv(ipInterReacTlv); 147 lsp.addTlv(ipInterReacTlv);
148 +
149 + tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value());
150 + tlvHeader.setTlvLength(0);
151 + IpExtendedReachabilityTlv extendedTlv = new IpExtendedReachabilityTlv(tlvHeader);
152 + extendedTlv.setDown(false);
153 + extendedTlv.setMetric(10);
154 + extendedTlv.setPrefix("192.168.7");
155 + extendedTlv.setPrefixLength(24);
156 + extendedTlv.setSubTlvLength((byte) 0);
157 + extendedTlv.setSubTlvPresence(false);
158 + lsp.addTlv(extendedTlv);
159 +
144 return lsp; 160 return lsp;
145 } 161 }
146 162
...@@ -149,7 +165,7 @@ public class LspGenerator { ...@@ -149,7 +165,7 @@ public class LspGenerator {
149 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR); 165 isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
150 isisHeader.setPduHeaderLength((byte) IsisUtil.getPduHeaderLength(pduType.value())); 166 isisHeader.setPduHeaderLength((byte) IsisUtil.getPduHeaderLength(pduType.value()));
151 isisHeader.setVersion((byte) IsisConstants.ISISVERSION); 167 isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
152 - isisHeader.setIdLength((byte) IsisConstants.IDLENGTH); 168 + isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
153 isisHeader.setIsisPduType(pduType.value()); 169 isisHeader.setIsisPduType(pduType.value());
154 isisHeader.setVersion2((byte) IsisConstants.ISISVERSION); 170 isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
155 isisHeader.setReserved((byte) IsisConstants.RESERVED); 171 isisHeader.setReserved((byte) IsisConstants.RESERVED);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
34 <modules> 34 <modules>
35 <module>api</module> 35 <module>api</module>
36 <module>isisio</module> 36 <module>isisio</module>
37 + <module>ctl</module>
37 </modules> 38 </modules>
38 39
39 </project> 40 </project>
......