Committed by
Gerrit Code Review
Fixed pom.xml issues and build issues. Corrected checkstyle issues
Change-Id: I90744f53e40f417ffe7ae62ffe138eea7a489bc0
Showing
26 changed files
with
241 additions
and
148 deletions
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 2016 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. |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | <artifactId>onos-ospf-api</artifactId> | 29 | <artifactId>onos-ospf-api</artifactId> |
30 | <packaging>bundle</packaging> | 30 | <packaging>bundle</packaging> |
31 | 31 | ||
32 | - <description>ONOS Ospf controller subsystem API</description> | 32 | + <description>ONOS OSPF controller subsystem API</description> |
33 | 33 | ||
34 | <dependencies> | 34 | <dependencies> |
35 | <dependency> | 35 | <dependency> | ... | ... |
... | @@ -33,27 +33,9 @@ | ... | @@ -33,27 +33,9 @@ |
33 | <dependencies> | 33 | <dependencies> |
34 | <dependency> | 34 | <dependency> |
35 | <groupId>org.onosproject</groupId> | 35 | <groupId>org.onosproject</groupId> |
36 | - <artifactId>onos-ospf-api</artifactId> | ||
37 | - <version>${project.version}</version> | ||
38 | - </dependency> | ||
39 | - <dependency> | ||
40 | - <groupId>org.onosproject</groupId> | ||
41 | <artifactId>onos-ospf-protocol</artifactId> | 36 | <artifactId>onos-ospf-protocol</artifactId> |
42 | <version>${project.version}</version> | 37 | <version>${project.version}</version> |
43 | </dependency> | 38 | </dependency> |
44 | - | ||
45 | - <dependency> | ||
46 | - <groupId>io.netty</groupId> | ||
47 | - <artifactId>netty</artifactId> | ||
48 | - </dependency> | ||
49 | - <dependency> | ||
50 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
51 | - <artifactId>jackson-databind</artifactId> | ||
52 | - </dependency> | ||
53 | - <dependency> | ||
54 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
55 | - <artifactId>jackson-annotations</artifactId> | ||
56 | - </dependency> | ||
57 | <dependency> | 39 | <dependency> |
58 | <groupId>org.apache.felix</groupId> | 40 | <groupId>org.apache.felix</groupId> |
59 | <artifactId>org.apache.felix.scr.annotations</artifactId> | 41 | <artifactId>org.apache.felix.scr.annotations</artifactId> |
... | @@ -65,8 +47,6 @@ | ... | @@ -65,8 +47,6 @@ |
65 | <dependency> | 47 | <dependency> |
66 | <groupId>org.easymock</groupId> | 48 | <groupId>org.easymock</groupId> |
67 | <artifactId>easymock</artifactId> | 49 | <artifactId>easymock</artifactId> |
68 | - <version>3.2</version> | ||
69 | - <scope>test</scope> | ||
70 | </dependency> | 50 | </dependency> |
71 | </dependencies> | 51 | </dependencies> |
72 | 52 | ... | ... |
... | @@ -729,8 +729,8 @@ public class OspfAreaImpl implements OspfArea { | ... | @@ -729,8 +729,8 @@ public class OspfAreaImpl implements OspfArea { |
729 | if (nbr.getLsReqList().containsKey(key)) { | 729 | if (nbr.getLsReqList().containsKey(key)) { |
730 | LsaWrapper lsWrapper = lsaLookup(recLsa); | 730 | LsaWrapper lsWrapper = lsaLookup(recLsa); |
731 | if (lsWrapper != null) { | 731 | if (lsWrapper != null) { |
732 | - LsaHeader ownLSA = (LsaHeader) lsWrapper.ospfLsa(); | 732 | + LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa(); |
733 | - String status = isNewerOrSameLsa(recLsa, ownLSA); | 733 | + String status = isNewerOrSameLsa(recLsa, ownLsa); |
734 | if (status.equals("old")) { | 734 | if (status.equals("old")) { |
735 | continue; | 735 | continue; |
736 | } else if (status.equals("same")) { | 736 | } else if (status.equals("same")) { | ... | ... |
... | @@ -258,7 +258,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -258,7 +258,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { |
258 | log.debug("OspfChannelHandler::List of OspfMessages Size {}", ospfMessageList.size()); | 258 | log.debug("OspfChannelHandler::List of OspfMessages Size {}", ospfMessageList.size()); |
259 | if (ospfMessageList != null) { | 259 | if (ospfMessageList != null) { |
260 | for (OspfMessage ospfMessage : ospfMessageList) { | 260 | for (OspfMessage ospfMessage : ospfMessageList) { |
261 | - processOSPFMessage(ospfMessage, ctx); | 261 | + processOspfMessage(ospfMessage, ctx); |
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | log.debug("OspfChannelHandler::OspfMessages Null List...!!"); | 264 | log.debug("OspfChannelHandler::OspfMessages Null List...!!"); |
... | @@ -267,7 +267,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -267,7 +267,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { |
267 | if (message instanceof OspfMessage) { | 267 | if (message instanceof OspfMessage) { |
268 | OspfMessage ospfMessage = (OspfMessage) message; | 268 | OspfMessage ospfMessage = (OspfMessage) message; |
269 | log.debug("OspfChannelHandler::OspfMessages received...!!"); | 269 | log.debug("OspfChannelHandler::OspfMessages received...!!"); |
270 | - processOSPFMessage(ospfMessage, ctx); | 270 | + processOspfMessage(ospfMessage, ctx); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
... | @@ -280,8 +280,8 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -280,8 +280,8 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { |
280 | * @param ctx channel handler context instance. | 280 | * @param ctx channel handler context instance. |
281 | * @throws Exception might throws exception | 281 | * @throws Exception might throws exception |
282 | */ | 282 | */ |
283 | - public void processOSPFMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { | 283 | + public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { |
284 | - log.debug("OspfChannelHandler::processOSPFMessage...!!!"); | 284 | + log.debug("OspfChannelHandler::processOspfMessage...!!!"); |
285 | 285 | ||
286 | if (!validateMessage(ospfMessage)) { | 286 | if (!validateMessage(ospfMessage)) { |
287 | return; | 287 | return; | ... | ... |
... | @@ -1046,8 +1046,7 @@ public class OspfNbrImpl implements OspfNbr { | ... | @@ -1046,8 +1046,7 @@ public class OspfNbrImpl implements OspfNbr { |
1046 | 1046 | ||
1047 | //If LSA type is external & the area is configured as stub area discard the lsa RFC 2328 13(3) | 1047 | //If LSA type is external & the area is configured as stub area discard the lsa RFC 2328 13(3) |
1048 | if ((recLsa.getOspfLsaType() == OspfLsaType.EXTERNAL_LSA) && | 1048 | if ((recLsa.getOspfLsaType() == OspfLsaType.EXTERNAL_LSA) && |
1049 | - (!ospfArea.isExternalRoutingCapability())) // to determine how to store options | 1049 | + (!ospfArea.isExternalRoutingCapability())) { |
1050 | - { | ||
1051 | return true; | 1050 | return true; |
1052 | } | 1051 | } |
1053 | 1052 | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.ospf.controller.area; | 16 | package org.onosproject.ospf.controller.area; |
17 | 17 | ||
18 | 18 | ||
19 | -import org.easymock.EasyMock; | ||
20 | import org.junit.After; | 19 | import org.junit.After; |
21 | import org.junit.Before; | 20 | import org.junit.Before; |
22 | import org.junit.Test; | 21 | import org.junit.Test; |
... | @@ -105,18 +104,13 @@ public class OspfAreaAddressRangeImplTest { | ... | @@ -105,18 +104,13 @@ public class OspfAreaAddressRangeImplTest { |
105 | */ | 104 | */ |
106 | @Test | 105 | @Test |
107 | public void testEquals() throws Exception { | 106 | public void testEquals() throws Exception { |
108 | - assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(false)); | 107 | + assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(true)); |
109 | } | 108 | } |
110 | 109 | ||
111 | /** | 110 | /** |
112 | - * Tests equals() method. | 111 | + * Tests hashCode() method. |
113 | */ | 112 | */ |
114 | @Test | 113 | @Test |
115 | - public void testEquals1() throws Exception { | ||
116 | - assertThat(ospfAreaAddressRange.equals(EasyMock.createMock(OspfAreaAddressRange.class)), is(false)); | ||
117 | - } | ||
118 | - | ||
119 | - @Test | ||
120 | public void testHashCode() throws Exception { | 114 | public void testHashCode() throws Exception { |
121 | result = ospfAreaAddressRange.hashCode(); | 115 | result = ospfAreaAddressRange.hashCode(); |
122 | assertThat(result, is(notNullValue())); | 116 | assertThat(result, is(notNullValue())); | ... | ... |
... | @@ -186,22 +186,22 @@ public class OspfAreaImplTest { | ... | @@ -186,22 +186,22 @@ public class OspfAreaImplTest { |
186 | Ip4Address.valueOf("2.2.2.2"), 2, | 186 | Ip4Address.valueOf("2.2.2.2"), 2, |
187 | new OspfInterfaceChannelHandler(new Controller(), | 187 | new OspfInterfaceChannelHandler(new Controller(), |
188 | new OspfAreaImpl(), | 188 | new OspfAreaImpl(), |
189 | - new OspfInterfaceImpl()) | 189 | + new OspfInterfaceImpl()), |
190 | - , topologyForDeviceAndLink)); | 190 | + topologyForDeviceAndLink)); |
191 | ospfNbrList.put("3.3.3.3", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 191 | ospfNbrList.put("3.3.3.3", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
192 | Ip4Address.valueOf("1.1.1.1"), | 192 | Ip4Address.valueOf("1.1.1.1"), |
193 | Ip4Address.valueOf("2.2.2.2"), 2, | 193 | Ip4Address.valueOf("2.2.2.2"), 2, |
194 | new OspfInterfaceChannelHandler(new Controller(), | 194 | new OspfInterfaceChannelHandler(new Controller(), |
195 | new OspfAreaImpl(), | 195 | new OspfAreaImpl(), |
196 | - new OspfInterfaceImpl()) | 196 | + new OspfInterfaceImpl()), |
197 | - , topologyForDeviceAndLink)); | 197 | + topologyForDeviceAndLink)); |
198 | ospfNbrList.put("4.4.4.4", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 198 | ospfNbrList.put("4.4.4.4", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
199 | Ip4Address.valueOf("1.1.1.1"), | 199 | Ip4Address.valueOf("1.1.1.1"), |
200 | Ip4Address.valueOf("2.2.2.2"), 2, | 200 | Ip4Address.valueOf("2.2.2.2"), 2, |
201 | new OspfInterfaceChannelHandler(new Controller(), | 201 | new OspfInterfaceChannelHandler(new Controller(), |
202 | new OspfAreaImpl(), | 202 | new OspfAreaImpl(), |
203 | - new OspfInterfaceImpl()) | 203 | + new OspfInterfaceImpl()), |
204 | - , topologyForDeviceAndLink)); | 204 | + topologyForDeviceAndLink)); |
205 | 205 | ||
206 | ospfInterface.setListOfNeighbors(ospfNbrList); | 206 | ospfInterface.setListOfNeighbors(ospfNbrList); |
207 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10")); | 207 | ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10")); |
... | @@ -265,8 +265,8 @@ public class OspfAreaImplTest { | ... | @@ -265,8 +265,8 @@ public class OspfAreaImplTest { |
265 | Ip4Address.valueOf("2.2.2.2"), 2, | 265 | Ip4Address.valueOf("2.2.2.2"), 2, |
266 | new OspfInterfaceChannelHandler(new Controller(), | 266 | new OspfInterfaceChannelHandler(new Controller(), |
267 | new OspfAreaImpl(), | 267 | new OspfAreaImpl(), |
268 | - new OspfInterfaceImpl()) | 268 | + new OspfInterfaceImpl()), |
269 | - , topologyForDeviceAndLink); | 269 | + topologyForDeviceAndLink); |
270 | ospfNbr.setState(OspfNeighborState.FULL); | 270 | ospfNbr.setState(OspfNeighborState.FULL); |
271 | ospfInterface1.addNeighbouringRouter(ospfNbr); | 271 | ospfInterface1.addNeighbouringRouter(ospfNbr); |
272 | ospfInterfaces.add(ospfInterface1); | 272 | ospfInterfaces.add(ospfInterface1); |
... | @@ -290,8 +290,8 @@ public class OspfAreaImplTest { | ... | @@ -290,8 +290,8 @@ public class OspfAreaImplTest { |
290 | Ip4Address.valueOf("2.2.2.2"), 2, | 290 | Ip4Address.valueOf("2.2.2.2"), 2, |
291 | new OspfInterfaceChannelHandler(new Controller(), | 291 | new OspfInterfaceChannelHandler(new Controller(), |
292 | new OspfAreaImpl(), | 292 | new OspfAreaImpl(), |
293 | - new OspfInterfaceImpl()) | 293 | + new OspfInterfaceImpl()), |
294 | - , topologyForDeviceAndLink); | 294 | + topologyForDeviceAndLink); |
295 | ospfNbr.setState(OspfNeighborState.FULL); | 295 | ospfNbr.setState(OspfNeighborState.FULL); |
296 | ospfInterfaces = new ArrayList(); | 296 | ospfInterfaces = new ArrayList(); |
297 | ospfInterface1 = new OspfInterfaceImpl(); | 297 | ospfInterface1 = new OspfInterfaceImpl(); |
... | @@ -352,8 +352,8 @@ public class OspfAreaImplTest { | ... | @@ -352,8 +352,8 @@ public class OspfAreaImplTest { |
352 | Ip4Address.valueOf("2.2.2.2"), 2, | 352 | Ip4Address.valueOf("2.2.2.2"), 2, |
353 | new OspfInterfaceChannelHandler(new Controller(), | 353 | new OspfInterfaceChannelHandler(new Controller(), |
354 | new OspfAreaImpl(), | 354 | new OspfAreaImpl(), |
355 | - new OspfInterfaceImpl()) | 355 | + new OspfInterfaceImpl()), |
356 | - , topologyForDeviceAndLink); | 356 | + topologyForDeviceAndLink); |
357 | ospfNbr.setState(OspfNeighborState.FULL); | 357 | ospfNbr.setState(OspfNeighborState.FULL); |
358 | ospfInterface1.addNeighbouringRouter(ospfNbr); | 358 | ospfInterface1.addNeighbouringRouter(ospfNbr); |
359 | ospfInterfaces.add(ospfInterface1); | 359 | ospfInterfaces.add(ospfInterface1); |
... | @@ -516,8 +516,8 @@ public class OspfAreaImplTest { | ... | @@ -516,8 +516,8 @@ public class OspfAreaImplTest { |
516 | Ip4Address.valueOf("2.2.2.2"), 2, | 516 | Ip4Address.valueOf("2.2.2.2"), 2, |
517 | new OspfInterfaceChannelHandler(new Controller(), | 517 | new OspfInterfaceChannelHandler(new Controller(), |
518 | new OspfAreaImpl(), | 518 | new OspfAreaImpl(), |
519 | - new OspfInterfaceImpl()) | 519 | + new OspfInterfaceImpl()), |
520 | - , topologyForDeviceAndLink); | 520 | + topologyForDeviceAndLink); |
521 | ospfNbr.setState(OspfNeighborState.EXCHANGE.EXCHANGE); | 521 | ospfNbr.setState(OspfNeighborState.EXCHANGE.EXCHANGE); |
522 | ospfInterface1.addNeighbouringRouter(ospfNbr); | 522 | ospfInterface1.addNeighbouringRouter(ospfNbr); |
523 | ospfInterfaces.add(ospfInterface1); | 523 | ospfInterfaces.add(ospfInterface1); |
... | @@ -633,8 +633,8 @@ public class OspfAreaImplTest { | ... | @@ -633,8 +633,8 @@ public class OspfAreaImplTest { |
633 | Ip4Address.valueOf("2.2.2.2"), 2, | 633 | Ip4Address.valueOf("2.2.2.2"), 2, |
634 | new OspfInterfaceChannelHandler(new Controller(), | 634 | new OspfInterfaceChannelHandler(new Controller(), |
635 | new OspfAreaImpl(), | 635 | new OspfAreaImpl(), |
636 | - new OspfInterfaceImpl()) | 636 | + new OspfInterfaceImpl()), |
637 | - , topologyForDeviceAndLink); | 637 | + topologyForDeviceAndLink); |
638 | ospfNbr.setState(OspfNeighborState.FULL); | 638 | ospfNbr.setState(OspfNeighborState.FULL); |
639 | ospfInterface1.addNeighbouringRouter(ospfNbr); | 639 | ospfInterface1.addNeighbouringRouter(ospfNbr); |
640 | ospfInterfaces.add(ospfInterface1); | 640 | ospfInterfaces.add(ospfInterface1); |
... | @@ -665,8 +665,8 @@ public class OspfAreaImplTest { | ... | @@ -665,8 +665,8 @@ public class OspfAreaImplTest { |
665 | Ip4Address.valueOf("2.2.2.2"), 2, | 665 | Ip4Address.valueOf("2.2.2.2"), 2, |
666 | new OspfInterfaceChannelHandler(new Controller(), | 666 | new OspfInterfaceChannelHandler(new Controller(), |
667 | new OspfAreaImpl(), | 667 | new OspfAreaImpl(), |
668 | - new OspfInterfaceImpl()) | 668 | + new OspfInterfaceImpl()), |
669 | - , topologyForDeviceAndLink); | 669 | + topologyForDeviceAndLink); |
670 | ospfNbr.setState(OspfNeighborState.FULL); | 670 | ospfNbr.setState(OspfNeighborState.FULL); |
671 | ospfInterface1.addNeighbouringRouter(ospfNbr); | 671 | ospfInterface1.addNeighbouringRouter(ospfNbr); |
672 | ospfInterfaces.add(ospfInterface1); | 672 | ospfInterfaces.add(ospfInterface1); | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ospf.controller.area; | 16 | package org.onosproject.ospf.controller.area; |
17 | 17 | ||
18 | - | ||
19 | import org.junit.After; | 18 | import org.junit.After; |
20 | import org.junit.Assert; | 19 | import org.junit.Assert; |
21 | import org.junit.Before; | 20 | import org.junit.Before; |
... | @@ -115,8 +114,8 @@ public class OspfInterfaceImplTest { | ... | @@ -115,8 +114,8 @@ public class OspfInterfaceImplTest { |
115 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 114 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
116 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, | 115 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, |
117 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), | 116 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), |
118 | - new OspfInterfaceImpl()) | 117 | + new OspfInterfaceImpl()), |
119 | - , topologyForDeviceAndLink); | 118 | + topologyForDeviceAndLink); |
120 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); | 119 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); |
121 | ospfInterface.addNeighbouringRouter(ospfNbr); | 120 | ospfInterface.addNeighbouringRouter(ospfNbr); |
122 | assertThat(ospfInterface, is(notNullValue())); | 121 | assertThat(ospfInterface, is(notNullValue())); |
... | @@ -131,8 +130,8 @@ public class OspfInterfaceImplTest { | ... | @@ -131,8 +130,8 @@ public class OspfInterfaceImplTest { |
131 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 130 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
132 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, | 131 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, |
133 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), | 132 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), |
134 | - new OspfInterfaceImpl()) | 133 | + new OspfInterfaceImpl()), |
135 | - , topologyForDeviceAndLink); | 134 | + topologyForDeviceAndLink); |
136 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); | 135 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); |
137 | ospfInterface.addNeighbouringRouter(ospfNbr); | 136 | ospfInterface.addNeighbouringRouter(ospfNbr); |
138 | assertThat(ospfInterface.neighbouringRouter("111.111.111.111"), is(notNullValue())); | 137 | assertThat(ospfInterface.neighbouringRouter("111.111.111.111"), is(notNullValue())); |
... | @@ -166,8 +165,8 @@ public class OspfInterfaceImplTest { | ... | @@ -166,8 +165,8 @@ public class OspfInterfaceImplTest { |
166 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 165 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
167 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, | 166 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, |
168 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), | 167 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), |
169 | - new OspfInterfaceImpl()) | 168 | + new OspfInterfaceImpl()), |
170 | - , topologyForDeviceAndLink); | 169 | + topologyForDeviceAndLink); |
171 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); | 170 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); |
172 | ospfInterface.addNeighbouringRouter(ospfNbr); | 171 | ospfInterface.addNeighbouringRouter(ospfNbr); |
173 | assertThat(ospfInterface.isNeighborInList("111.111.111.111"), is(notNullValue())); | 172 | assertThat(ospfInterface.isNeighborInList("111.111.111.111"), is(notNullValue())); |
... | @@ -183,8 +182,8 @@ public class OspfInterfaceImplTest { | ... | @@ -183,8 +182,8 @@ public class OspfInterfaceImplTest { |
183 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, | 182 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, |
184 | new OspfInterfaceChannelHandler(new Controller(), | 183 | new OspfInterfaceChannelHandler(new Controller(), |
185 | new OspfAreaImpl(), | 184 | new OspfAreaImpl(), |
186 | - new OspfInterfaceImpl()) | 185 | + new OspfInterfaceImpl()), |
187 | - , topologyForDeviceAndLink); | 186 | + topologyForDeviceAndLink); |
188 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); | 187 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); |
189 | ospfNbrHashMap.put("111.111.111.111", ospfNbr); | 188 | ospfNbrHashMap.put("111.111.111.111", ospfNbr); |
190 | ospfInterface.setListOfNeighbors(ospfNbrHashMap); | 189 | ospfInterface.setListOfNeighbors(ospfNbrHashMap); |
... | @@ -200,8 +199,8 @@ public class OspfInterfaceImplTest { | ... | @@ -200,8 +199,8 @@ public class OspfInterfaceImplTest { |
200 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), | 199 | ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(), |
201 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, | 200 | Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2, |
202 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), | 201 | new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(), |
203 | - new OspfInterfaceImpl()) | 202 | + new OspfInterfaceImpl()), |
204 | - , topologyForDeviceAndLink); | 203 | + topologyForDeviceAndLink); |
205 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); | 204 | ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111")); |
206 | ospfNbrHashMap.put("111.111.111.111", ospfNbr); | 205 | ospfNbrHashMap.put("111.111.111.111", ospfNbr); |
207 | ospfInterface.setListOfNeighbors(ospfNbrHashMap); | 206 | ospfInterface.setListOfNeighbors(ospfNbrHashMap); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -47,8 +47,8 @@ public class OspfMessageDecoderTest { | ... | @@ -47,8 +47,8 @@ public class OspfMessageDecoderTest { |
47 | -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48}; | 47 | -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48}; |
48 | private final byte[] lsUpdatePacket = {0, 0, 0, 0, 2, 4, 0, 76, -64, -88, -86, 3, 0, 0, 0, 1, 7, 111, | 48 | private final byte[] lsUpdatePacket = {0, 0, 0, 0, 2, 4, 0, 76, -64, -88, -86, 3, 0, 0, 0, 1, 7, 111, |
49 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 16, 2, 1, -64, -88, | 49 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 16, 2, 1, -64, -88, |
50 | - -86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2, 0, 0, 2 | 50 | + -86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2, 0, 0, 2, |
51 | - , -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10}; | 51 | + -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10}; |
52 | private final byte[] lsRequestPacket = {0, 0, 0, 0, 2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57, | 52 | private final byte[] lsRequestPacket = {0, 0, 0, 0, 2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57, |
53 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8}; | 53 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8}; |
54 | private OspfMessageDecoder ospfMessageDecoder; | 54 | private OspfMessageDecoder ospfMessageDecoder; |
... | @@ -80,7 +80,5 @@ public class OspfMessageDecoderTest { | ... | @@ -80,7 +80,5 @@ public class OspfMessageDecoderTest { |
80 | socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000); | 80 | socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000); |
81 | channelBuffer = ChannelBuffers.copiedBuffer(hellopacket); | 81 | channelBuffer = ChannelBuffers.copiedBuffer(hellopacket); |
82 | assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue())); | 82 | assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue())); |
83 | - | ||
84 | - | ||
85 | } | 83 | } |
86 | } | 84 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -33,7 +33,6 @@ import org.onosproject.ospf.controller.area.OspfInterfaceImpl; | ... | @@ -33,7 +33,6 @@ import org.onosproject.ospf.controller.area.OspfInterfaceImpl; |
33 | import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl; | 33 | import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl; |
34 | import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl; | 34 | import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl; |
35 | import org.onosproject.ospf.protocol.lsa.LsaHeader; | 35 | import org.onosproject.ospf.protocol.lsa.LsaHeader; |
36 | - | ||
37 | import org.onosproject.ospf.protocol.lsa.types.NetworkLsa; | 36 | import org.onosproject.ospf.protocol.lsa.types.NetworkLsa; |
38 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; | 37 | import org.onosproject.ospf.protocol.lsa.types.RouterLsa; |
39 | import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; | 38 | import org.onosproject.ospf.protocol.ospfpacket.OspfMessage; |
... | @@ -42,7 +41,6 @@ import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; | ... | @@ -42,7 +41,6 @@ import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket; |
42 | import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest; | 41 | import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest; |
43 | import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; | 42 | import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate; |
44 | import org.onosproject.ospf.protocol.util.ChecksumCalculator; | 43 | import org.onosproject.ospf.protocol.util.ChecksumCalculator; |
45 | - | ||
46 | import org.onosproject.ospf.protocol.util.OspfUtil; | 44 | import org.onosproject.ospf.protocol.util.OspfUtil; |
47 | 45 | ||
48 | import java.net.SocketAddress; | 46 | import java.net.SocketAddress; |
... | @@ -102,8 +100,8 @@ public class OspfNbrImplTest { | ... | @@ -102,8 +100,8 @@ public class OspfNbrImplTest { |
102 | ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"), | 100 | ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"), |
103 | Ip4Address.valueOf("2.2.2.2"), 2, | 101 | Ip4Address.valueOf("2.2.2.2"), 2, |
104 | new OspfInterfaceChannelHandler(new Controller(), | 102 | new OspfInterfaceChannelHandler(new Controller(), |
105 | - ospfArea, ospfInterface) | 103 | + ospfArea, ospfInterface), |
106 | - , topologyForDeviceAndLink); | 104 | + topologyForDeviceAndLink); |
107 | 105 | ||
108 | } | 106 | } |
109 | 107 | ... | ... |
... | @@ -91,7 +91,7 @@ public class LsaWrapperImplTest { | ... | @@ -91,7 +91,7 @@ public class LsaWrapperImplTest { |
91 | * Tests addLsa() method. | 91 | * Tests addLsa() method. |
92 | */ | 92 | */ |
93 | @Test | 93 | @Test |
94 | - public void testAddLSA() throws Exception { | 94 | + public void testAddLsa() throws Exception { |
95 | lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa()); | 95 | lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa()); |
96 | assertThat(lsaWrapper, is(notNullValue())); | 96 | assertThat(lsaWrapper, is(notNullValue())); |
97 | } | 97 | } |
... | @@ -216,7 +216,7 @@ public class LsaWrapperImplTest { | ... | @@ -216,7 +216,7 @@ public class LsaWrapperImplTest { |
216 | * Tests isSentReplyForOlderLsa() method. | 216 | * Tests isSentReplyForOlderLsa() method. |
217 | */ | 217 | */ |
218 | @Test | 218 | @Test |
219 | - public void testIsSentReplyForOlderLSA() throws Exception { | 219 | + public void testIsSentReplyForOlderLsa() throws Exception { |
220 | lsaWrapper.setSentReplyForOlderLsa(true); | 220 | lsaWrapper.setSentReplyForOlderLsa(true); |
221 | assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true)); | 221 | assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true)); |
222 | } | 222 | } |
... | @@ -231,15 +231,6 @@ public class LsaWrapperImplTest { | ... | @@ -231,15 +231,6 @@ public class LsaWrapperImplTest { |
231 | } | 231 | } |
232 | 232 | ||
233 | /** | 233 | /** |
234 | - * Tests isCheckAge() setter method. | ||
235 | - */ | ||
236 | - @Test | ||
237 | - public void testIsSentReplyForOlderLsa() throws Exception { | ||
238 | - lsaWrapper.setIsSequenceRollOver(true); | ||
239 | - assertThat(lsaWrapper.isSequenceRollOver(), is(true)); | ||
240 | - } | ||
241 | - | ||
242 | - /** | ||
243 | * Tests isSentReplyForOlderLsa() getter method. | 234 | * Tests isSentReplyForOlderLsa() getter method. |
244 | */ | 235 | */ |
245 | @Test | 236 | @Test | ... | ... |
... | @@ -65,8 +65,6 @@ public class OspfLsdbImplTest { | ... | @@ -65,8 +65,6 @@ public class OspfLsdbImplTest { |
65 | opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader()); | 65 | opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader()); |
66 | opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader()); | 66 | opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader()); |
67 | externalLsa = new ExternalLsa(new LsaHeader()); | 67 | externalLsa = new ExternalLsa(new LsaHeader()); |
68 | - | ||
69 | - | ||
70 | } | 68 | } |
71 | 69 | ||
72 | @After | 70 | @After |
... | @@ -130,7 +128,6 @@ public class OspfLsdbImplTest { | ... | @@ -130,7 +128,6 @@ public class OspfLsdbImplTest { |
130 | assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true)); | 128 | assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true)); |
131 | ospfLsdb.initializeDb(); | 129 | ospfLsdb.initializeDb(); |
132 | assertThat(ospfLsdb.getAllLsaHeaders(true, true).size(), is(5)); | 130 | assertThat(ospfLsdb.getAllLsaHeaders(true, true).size(), is(5)); |
133 | - | ||
134 | } | 131 | } |
135 | 132 | ||
136 | /** | 133 | /** |
... | @@ -236,7 +233,7 @@ public class OspfLsdbImplTest { | ... | @@ -236,7 +233,7 @@ public class OspfLsdbImplTest { |
236 | * Tests addLSA() method. | 233 | * Tests addLSA() method. |
237 | */ | 234 | */ |
238 | @Test | 235 | @Test |
239 | - public void testAddLSA() throws Exception { | 236 | + public void testAddLsa() throws Exception { |
240 | routerLsa.setLsType(1); | 237 | routerLsa.setLsType(1); |
241 | assertThat(ospfLsdb.addLsa(routerLsa, false, new OspfInterfaceImpl()), is(true)); | 238 | assertThat(ospfLsdb.addLsa(routerLsa, false, new OspfInterfaceImpl()), is(true)); |
242 | networkLsa.setLsType(2); | 239 | networkLsa.setLsType(2); |
... | @@ -380,7 +377,7 @@ public class OspfLsdbImplTest { | ... | @@ -380,7 +377,7 @@ public class OspfLsdbImplTest { |
380 | * Tests isNewerOrSameLsa() method. | 377 | * Tests isNewerOrSameLsa() method. |
381 | */ | 378 | */ |
382 | @Test | 379 | @Test |
383 | - public void testIsNewerorSameLSA() throws Exception { | 380 | + public void testIsNewerorSameLsa() throws Exception { |
384 | lsaWrapper = new LsaWrapperImpl(); | 381 | lsaWrapper = new LsaWrapperImpl(); |
385 | opaqueLsaHeader1 = new OpaqueLsaHeader(); | 382 | opaqueLsaHeader1 = new OpaqueLsaHeader(); |
386 | opaqueLsaHeader1.setLsType(1); | 383 | opaqueLsaHeader1.setLsType(1); | ... | ... |
... | @@ -33,8 +33,8 @@ | ... | @@ -33,8 +33,8 @@ |
33 | 33 | ||
34 | <modules> | 34 | <modules> |
35 | <module>api</module> | 35 | <module>api</module> |
36 | - <!--module>ctl</module--> | 36 | + <module>ctl</module> |
37 | - <!--module>protocol</module--> | 37 | + <module>protocol</module> |
38 | </modules> | 38 | </modules> |
39 | 39 | ||
40 | </project> | 40 | </project> | ... | ... |
1 | <!-- | 1 | <!-- |
2 | - ~ Copyright 2014 Open Networking Laboratory | 2 | + ~ Copyright 2016 Open Networking Laboratory |
3 | ~ | 3 | ~ |
4 | ~ Licensed under the Apache License, Version 2.0 (the "License"); | 4 | ~ Licensed under the Apache License, Version 2.0 (the "License"); |
5 | ~ you may not use this file except in compliance with the License. | 5 | ~ you may not use this file except in compliance with the License. |
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | <artifactId>onos-ospf-protocol</artifactId> | 28 | <artifactId>onos-ospf-protocol</artifactId> |
29 | <packaging>bundle</packaging> | 29 | <packaging>bundle</packaging> |
30 | 30 | ||
31 | - <description>ONOS Ospf controller protocol</description> | 31 | + <description>ONOS OSPF controller protocol</description> |
32 | <dependencies> | 32 | <dependencies> |
33 | <dependency> | 33 | <dependency> |
34 | <groupId>org.onosproject</groupId> | 34 | <groupId>org.onosproject</groupId> | ... | ... |
... | @@ -136,7 +136,7 @@ public class NetworkLsa extends LsaHeader { | ... | @@ -136,7 +136,7 @@ public class NetworkLsa extends LsaHeader { |
136 | byte[] lsaMessage = null; | 136 | byte[] lsaMessage = null; |
137 | 137 | ||
138 | byte[] lsaHeader = getLsaHeaderAsByteArray(); | 138 | byte[] lsaHeader = getLsaHeaderAsByteArray(); |
139 | - byte[] lsaBody = getLSABodyAsByteArray(); | 139 | + byte[] lsaBody = getLsaBodyAsByteArray(); |
140 | lsaMessage = Bytes.concat(lsaHeader, lsaBody); | 140 | lsaMessage = Bytes.concat(lsaHeader, lsaBody); |
141 | 141 | ||
142 | return lsaMessage; | 142 | return lsaMessage; |
... | @@ -148,7 +148,7 @@ public class NetworkLsa extends LsaHeader { | ... | @@ -148,7 +148,7 @@ public class NetworkLsa extends LsaHeader { |
148 | * @return LSA body as byte array | 148 | * @return LSA body as byte array |
149 | * @throws OspfParseException might throws exception while parsing packet | 149 | * @throws OspfParseException might throws exception while parsing packet |
150 | */ | 150 | */ |
151 | - public byte[] getLSABodyAsByteArray() throws OspfParseException { | 151 | + public byte[] getLsaBodyAsByteArray() throws OspfParseException { |
152 | List<Byte> bodyLst = new ArrayList<>(); | 152 | List<Byte> bodyLst = new ArrayList<>(); |
153 | 153 | ||
154 | try { | 154 | try { | ... | ... |
... | @@ -13,36 +13,184 @@ | ... | @@ -13,36 +13,184 @@ |
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.ospf.protocol.util; | 16 | +package org.onosproject.ospf.protocol.ospfpacket.types; |
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.onlab.packet.Ip4Address; | ||
22 | +import org.onosproject.ospf.exceptions.OspfParseException; | ||
23 | +import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader; | ||
24 | +import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket; | ||
25 | +import org.onosproject.ospf.protocol.util.OspfPacketType; | ||
26 | +import org.onosproject.ospf.protocol.util.OspfUtil; | ||
27 | +import org.slf4j.Logger; | ||
28 | +import org.slf4j.LoggerFactory; | ||
29 | + | ||
30 | +import java.net.InetAddress; | ||
31 | +import java.util.ArrayList; | ||
32 | +import java.util.List; | ||
17 | 33 | ||
18 | /** | 34 | /** |
19 | - * Representation of different OSPF packet types. | 35 | + * Representation of an OSPF Link State Request packet. |
36 | + * Link State Request packets are OSPF packet type 3. After exchanging | ||
37 | + * database description packets with a neighboring router, a router may | ||
38 | + * find that parts of its link-state database are out-of-date. The | ||
39 | + * Link State Request packet is used to request the pieces of the | ||
40 | + * neighbor's database that are more up-to-date. | ||
20 | */ | 41 | */ |
21 | -public enum OspfPacketType { | 42 | +public class LsRequest extends OspfPacketHeader { |
43 | + /* | ||
44 | + 0 1 2 3 | ||
45 | + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | ||
46 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
47 | + | Version # | 3 | Packet length | | ||
48 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
49 | + | Router ID | | ||
50 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
51 | + | Area ID | | ||
52 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
53 | + | Checksum | AuType | | ||
54 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
55 | + | Authentication | | ||
56 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
57 | + | Authentication | | ||
58 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
59 | + | LS type | | ||
60 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
61 | + | Link State ID | | ||
62 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
63 | + | Advertising Router | | ||
64 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
65 | + | ... | | ||
22 | 66 | ||
23 | - HELLO(1), | 67 | + LsRequest Message Format |
24 | - DD(2), | 68 | + REFERENCE : RFC 2328 |
25 | - LSREQUEST(3), | 69 | + */ |
26 | - LSUPDATE(4), | 70 | + private static final Logger log = LoggerFactory.getLogger(LsRequest.class); |
27 | - LSAACK(5); | 71 | + private List<LsRequestPacket> linkStateRequests = new ArrayList<>(); |
28 | 72 | ||
29 | - private int value; | 73 | + /** |
74 | + * Creates an instance of link state request packet. | ||
75 | + */ | ||
76 | + public LsRequest() { | ||
77 | + } | ||
30 | 78 | ||
31 | /** | 79 | /** |
32 | - * Creates instance of OSPF packet types. | 80 | + * Creates an instance of link state request packet. |
33 | * | 81 | * |
34 | - * @param value | 82 | + * @param ospfHeader OSPF header instance. |
35 | */ | 83 | */ |
36 | - OspfPacketType(int value) { | 84 | + public LsRequest(OspfPacketHeader ospfHeader) { |
37 | - this.value = value; | 85 | + populateHeader(ospfHeader); |
38 | } | 86 | } |
39 | 87 | ||
40 | /** | 88 | /** |
41 | - * Gets the value. | 89 | + * Adds link state request. |
42 | * | 90 | * |
43 | - * @return value | 91 | + * @param lsRequestPacket ls request packet instance |
44 | */ | 92 | */ |
45 | - public int value() { | 93 | + public void addLinkStateRequests(LsRequestPacket lsRequestPacket) { |
46 | - return value; | 94 | + if (!linkStateRequests.contains(lsRequestPacket)) { |
95 | + linkStateRequests.add(lsRequestPacket); | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Gets link state request packet instance. | ||
101 | + * | ||
102 | + * @return link state request packet instance | ||
103 | + */ | ||
104 | + public List<LsRequestPacket> getLinkStateRequests() { | ||
105 | + return linkStateRequests; | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public OspfPacketType ospfMessageType() { | ||
110 | + return OspfPacketType.LSREQUEST; | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException { | ||
115 | + | ||
116 | + while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) { | ||
117 | + LsRequestPacket lsRequestPacket = new LsRequestPacket(); | ||
118 | + lsRequestPacket.setLsType(channelBuffer.readInt()); | ||
119 | + byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; | ||
120 | + channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); | ||
121 | + lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString()); | ||
122 | + tempByteArray = new byte[OspfUtil.FOUR_BYTES]; | ||
123 | + channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); | ||
124 | + lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString()); | ||
125 | + | ||
126 | + this.addLinkStateRequests(lsRequestPacket); | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public byte[] asBytes() { | ||
132 | + byte[] lsrMessage = null; | ||
133 | + byte[] lsrHeader = getLsrHeaderAsByteArray(); | ||
134 | + byte[] lsrBody = getLsrBodyAsByteArray(); | ||
135 | + lsrMessage = Bytes.concat(lsrHeader, lsrBody); | ||
136 | + | ||
137 | + return lsrMessage; | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * Gets LS request packet header as byte array. | ||
142 | + * | ||
143 | + * @return LS request packet header as byte array | ||
144 | + */ | ||
145 | + public byte[] getLsrHeaderAsByteArray() { | ||
146 | + List<Byte> headerLst = new ArrayList<>(); | ||
147 | + | ||
148 | + try { | ||
149 | + headerLst.add((byte) this.ospfVersion()); | ||
150 | + headerLst.add((byte) this.ospfType()); | ||
151 | + headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength()))); | ||
152 | + headerLst.addAll(Bytes.asList(this.routerId().toOctets())); | ||
153 | + headerLst.addAll(Bytes.asList(this.areaId().toOctets())); | ||
154 | + headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum()))); | ||
155 | + headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType()))); | ||
156 | + //Authentication is 0 always. Total 8 bytes consist of zero | ||
157 | + byte[] auth = new byte[OspfUtil.EIGHT_BYTES]; | ||
158 | + headerLst.addAll(Bytes.asList(auth)); | ||
159 | + } catch (Exception e) { | ||
160 | + log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); | ||
161 | + return Bytes.toArray(headerLst); | ||
162 | + } | ||
163 | + | ||
164 | + return Bytes.toArray(headerLst); | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * Gets LS request packet body as byte array. | ||
169 | + * | ||
170 | + * @return LS request packet body as byte array | ||
171 | + */ | ||
172 | + public byte[] getLsrBodyAsByteArray() { | ||
173 | + List<Byte> bodyLst = new ArrayList<>(); | ||
174 | + | ||
175 | + try { | ||
176 | + for (LsRequestPacket lsrPacket : linkStateRequests) { | ||
177 | + bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(lsrPacket.lsType()))); | ||
178 | + bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.linkStateId()).getAddress())); | ||
179 | + bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.ownRouterId()).getAddress())); | ||
180 | + } | ||
181 | + } catch (Exception e) { | ||
182 | + log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage()); | ||
183 | + return Bytes.toArray(bodyLst); | ||
184 | + } | ||
185 | + | ||
186 | + return Bytes.toArray(bodyLst); | ||
187 | + } | ||
188 | + | ||
189 | + @Override | ||
190 | + public String toString() { | ||
191 | + return MoreObjects.toStringHelper(getClass()) | ||
192 | + .omitNullValues() | ||
193 | + .add("linkStateRequests", linkStateRequests) | ||
194 | + .toString(); | ||
47 | } | 195 | } |
48 | } | 196 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -181,9 +181,9 @@ public class LsUpdate extends OspfPacketHeader { | ... | @@ -181,9 +181,9 @@ public class LsUpdate extends OspfPacketHeader { |
181 | addLsa(asbrSummaryLsa); | 181 | addLsa(asbrSummaryLsa); |
182 | break; | 182 | break; |
183 | case OspfParameters.SUMMARY: | 183 | case OspfParameters.SUMMARY: |
184 | - SummaryLsa summaryLSA = new SummaryLsa(header); | 184 | + SummaryLsa summaryLsa = new SummaryLsa(header); |
185 | - summaryLSA.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH)); | 185 | + summaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH)); |
186 | - addLsa(summaryLSA); | 186 | + addLsa(summaryLsa); |
187 | break; | 187 | break; |
188 | case OspfParameters.EXTERNAL_LSA: | 188 | case OspfParameters.EXTERNAL_LSA: |
189 | ExternalLsa externalLsa = new ExternalLsa(header); | 189 | ExternalLsa externalLsa = new ExternalLsa(header); | ... | ... |
... | @@ -97,7 +97,7 @@ public class UnreservedBandwidthTest { | ... | @@ -97,7 +97,7 @@ public class UnreservedBandwidthTest { |
97 | * Tests getLinkSubTypeTlvBodyAsByteArray() method. | 97 | * Tests getLinkSubTypeTlvBodyAsByteArray() method. |
98 | */ | 98 | */ |
99 | @Test | 99 | @Test |
100 | - public void testGetLinkSubTypeTLVBodyAsByteArray() throws Exception { | 100 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { |
101 | result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray(); | 101 | result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray(); |
102 | assertThat(result, is(notNullValue())); | 102 | assertThat(result, is(notNullValue())); |
103 | } | 103 | } | ... | ... |
... | @@ -112,7 +112,7 @@ public class RouterTlvTest { | ... | @@ -112,7 +112,7 @@ public class RouterTlvTest { |
112 | * Tests getTlvBodyAsByteArray() method. | 112 | * Tests getTlvBodyAsByteArray() method. |
113 | */ | 113 | */ |
114 | @Test(expected = Exception.class) | 114 | @Test(expected = Exception.class) |
115 | - public void testGetTLVBodyAsByteArray() throws Exception { | 115 | + public void testGetTlvBodyAsByteArray() throws Exception { |
116 | result = rtlv.getTlvBodyAsByteArray(); | 116 | result = rtlv.getTlvBodyAsByteArray(); |
117 | assertThat(result, is(notNullValue())); | 117 | assertThat(result, is(notNullValue())); |
118 | } | 118 | } | ... | ... |
... | @@ -164,7 +164,7 @@ public class NetworkLsaTest { | ... | @@ -164,7 +164,7 @@ public class NetworkLsaTest { |
164 | networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1")); | 164 | networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1")); |
165 | networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2")); | 165 | networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2")); |
166 | networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3")); | 166 | networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3")); |
167 | - result1 = networkLsa.getLSABodyAsByteArray(); | 167 | + result1 = networkLsa.getLsaBodyAsByteArray(); |
168 | assertThat(result1, is(notNullValue())); | 168 | assertThat(result1, is(notNullValue())); |
169 | } | 169 | } |
170 | 170 | ||
... | @@ -177,7 +177,7 @@ public class NetworkLsaTest { | ... | @@ -177,7 +177,7 @@ public class NetworkLsaTest { |
177 | networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1")); | 177 | networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1")); |
178 | networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2")); | 178 | networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2")); |
179 | networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3")); | 179 | networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3")); |
180 | - result1 = networkLsa.getLSABodyAsByteArray(); | 180 | + result1 = networkLsa.getLsaBodyAsByteArray(); |
181 | assertThat(result1, is(notNullValue())); | 181 | assertThat(result1, is(notNullValue())); |
182 | } | 182 | } |
183 | 183 | ... | ... |
... | @@ -43,9 +43,9 @@ public class OspfMessageReaderTest { | ... | @@ -43,9 +43,9 @@ public class OspfMessageReaderTest { |
43 | -86, 8, -64, -88, -86, 8}; | 43 | -86, 8, -64, -88, -86, 8}; |
44 | private final byte[] packet4 = {1, 1, 1, 1, 2, 4, 1, 36, -64, -88, -86, 3, 0, | 44 | private final byte[] packet4 = {1, 1, 1, 1, 2, 4, 1, 36, -64, -88, -86, 3, 0, |
45 | 0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, | 45 | 0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, |
46 | - 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0 | 46 | + 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, |
47 | - , 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86 | 47 | + 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, |
48 | - , 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, | 48 | + 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, |
49 | -1, -1, -1, 0, 3, 0, 0, 10, 0, 3, 2, 5, 80, -44, | 49 | -1, -1, -1, 0, 3, 0, 0, 10, 0, 3, 2, 5, 80, -44, |
50 | 16, 0, -64, -88, -86, 2, -128, 0, 0, 1, 42, 73, 0, | 50 | 16, 0, -64, -88, -86, 2, -128, 0, 0, 1, 42, 73, 0, |
51 | 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, 0, 0, 0, | 51 | 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, 0, 0, 0, |
... | @@ -55,8 +55,8 @@ public class OspfMessageReaderTest { | ... | @@ -55,8 +55,8 @@ public class OspfMessageReaderTest { |
55 | 3, 2, 5, -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, | 55 | 3, 2, 5, -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, |
56 | 0, 1, -45, 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, | 56 | 0, 1, -45, 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, |
57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, | 57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, |
58 | - -64, -88, -86, 2, -128, 0, 0, 1, 55, 8, 0, 36, -1, -1 | 58 | + -64, -88, -86, 2, -128, 0, 0, 1, 55, 8, 0, 36, -1, -1, |
59 | - , -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 59 | + -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
60 | 3, 2, 5, -64, -88, 1, 0, -64, -88, -86, 2, -128, 0, 0, | 60 | 3, 2, 5, -64, -88, 1, 0, -64, -88, -86, 2, -128, 0, 0, |
61 | 1, 44, 18, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, | 61 | 1, 44, 18, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, |
62 | 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64, | 62 | 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64, | ... | ... |
... | @@ -95,17 +95,6 @@ public class LsAcknowledgeTest { | ... | @@ -95,17 +95,6 @@ public class LsAcknowledgeTest { |
95 | assertThat(lsAck, is(notNullValue())); | 95 | assertThat(lsAck, is(notNullValue())); |
96 | } | 96 | } |
97 | 97 | ||
98 | - | ||
99 | - /** | ||
100 | - * Tests ospfMessageType() getter method. | ||
101 | - */ | ||
102 | - @Test | ||
103 | - public void testGetOSPFMessageType() throws Exception { | ||
104 | - ospfPacketType = lsAck.ospfMessageType(); | ||
105 | - assertThat(ospfPacketType, is(notNullValue())); | ||
106 | - assertThat(ospfPacketType, is(OspfPacketType.LSAACK)); | ||
107 | - } | ||
108 | - | ||
109 | /** | 98 | /** |
110 | * Tests ospfMessageType() getter method. | 99 | * Tests ospfMessageType() getter method. |
111 | */ | 100 | */ | ... | ... |
... | @@ -102,7 +102,7 @@ public class LsUpdateTest { | ... | @@ -102,7 +102,7 @@ public class LsUpdateTest { |
102 | private SummaryLsa ospflsa2; | 102 | private SummaryLsa ospflsa2; |
103 | private AsbrSummaryLsa ospflsa3; | 103 | private AsbrSummaryLsa ospflsa3; |
104 | private ExternalLsa ospflsa4; | 104 | private ExternalLsa ospflsa4; |
105 | - private Vector<OspfLsa> listLSA = new Vector(); | 105 | + private Vector<OspfLsa> listLsa = new Vector(); |
106 | private List lsa; | 106 | private List lsa; |
107 | private int result; | 107 | private int result; |
108 | private OspfPacketType ospfMessageType; | 108 | private OspfPacketType ospfMessageType; |
... | @@ -151,7 +151,7 @@ public class LsUpdateTest { | ... | @@ -151,7 +151,7 @@ public class LsUpdateTest { |
151 | ospflsa2 = null; | 151 | ospflsa2 = null; |
152 | ospflsa3 = null; | 152 | ospflsa3 = null; |
153 | ospflsa4 = null; | 153 | ospflsa4 = null; |
154 | - listLSA.clear(); | 154 | + listLsa.clear(); |
155 | lsa = null; | 155 | lsa = null; |
156 | ospfMessageType = null; | 156 | ospfMessageType = null; |
157 | ospfPacketHeader = null; | 157 | ospfPacketHeader = null; |
... | @@ -325,13 +325,13 @@ public class LsUpdateTest { | ... | @@ -325,13 +325,13 @@ public class LsUpdateTest { |
325 | byte[] lsUpdatePacket = {0, 0, 0, 7, 0, 2, 2, | 325 | byte[] lsUpdatePacket = {0, 0, 0, 7, 0, 2, 2, |
326 | 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58, | 326 | 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58, |
327 | -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0, | 327 | -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0, |
328 | - 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10 | 328 | + 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, |
329 | - , 0, 3, 2, 5, 80, -44, 16, 0, -64, -88, -86, 2, -128, 0, 0 | 329 | + 0, 3, 2, 5, 80, -44, 16, 0, -64, -88, -86, 2, -128, 0, 0, |
330 | - , 1, 42, 73, 0, 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, | 330 | + 1, 42, 73, 0, 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, |
331 | - 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88 | 331 | + 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88, |
332 | - , -86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1, 0, | 332 | + -86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1, 0, |
333 | - -128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0, 3, 2, 5 | 333 | + -128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0, 3, 2, 5, |
334 | - , -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, 0, 1, -45, | 334 | + -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, 0, 1, -45, |
335 | 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, | 335 | 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, |
336 | 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, -64, -88, -86, 2, | 336 | 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, -64, -88, -86, 2, |
337 | -128, 0, 0, 1, 55, 8, 0, 36, -1, -1, -1, 0, -128, 0, 0, | 337 | -128, 0, 0, 1, 55, 8, 0, 36, -1, -1, -1, 0, -128, 0, 0, | ... | ... |
... | @@ -295,8 +295,8 @@ public class OspfUtilTest { | ... | @@ -295,8 +295,8 @@ public class OspfUtilTest { |
295 | 48, 0, 0, 0, 2, 1, 1, 1, 1, 10, 10, 10, 7, 1, 0, 0, 10, 10, 10, 10, 0, -1, -1, -1, | 295 | 48, 0, 0, 0, 2, 1, 1, 1, 1, 10, 10, 10, 7, 1, 0, 0, 10, 10, 10, 10, 0, -1, -1, -1, |
296 | 0, 3, 0, 0, 10, 0, 10, 66, 10, 1, 0, 0, 1, 7, 7, 7, 7, -128, 0, 0, 1, -64, 79, 0, | 296 | 0, 3, 0, 0, 10, 0, 10, 66, 10, 1, 0, 0, 1, 7, 7, 7, 7, -128, 0, 0, 1, -64, 79, 0, |
297 | 116, 0, 1, 0, 4, 0, 0, 0, 0, 0, 2, 0, 84, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 0, 4, 10, | 297 | 116, 0, 1, 0, 4, 0, 0, 0, 0, 0, 2, 0, 84, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 0, 4, 10, |
298 | - 10, 10, 0, 0, 5, 0, 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73 | 298 | + 10, 10, 0, 0, 5, 0, 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73, |
299 | - , -104, -106, -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, | 299 | + -104, -106, -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, |
300 | -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, | 300 | -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, |
301 | 73, -104, -106, -128, 0, 9, 0, 4, 0, 0, 0, 0}; | 301 | 73, -104, -106, -128, 0, 9, 0, 4, 0, 0, 0, 0}; |
302 | channelBuffer = ChannelBuffers.copiedBuffer(header); | 302 | channelBuffer = ChannelBuffers.copiedBuffer(header); | ... | ... |
-
Please register or login to post a comment