Pavlin Radoslavov

Updated SDN-IP to use Ip4Address and Ip4Prefix instead of IpAddress and

IpPrefix, because so far we haven't implemented IPv6.
Also, some of the BGP-related attributes (e.g., BGP Speaker ID)
are IPv4 by definition.

The following components are updated:
 * BGP implementation
 * Router component and relevant state (e.g., RouteEntry)

Other components (e.g., configuration) will continue to use
the more generic IpAddress and IpPrefix.

Change-Id: I1936ca9871fd5a9709cb4f2c2850d78ebc1472c4
...@@ -19,8 +19,8 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -19,8 +19,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
19 19
20 import java.util.Objects; 20 import java.util.Objects;
21 21
22 -import org.onlab.packet.IpAddress; 22 +import org.onlab.packet.Ip4Address;
23 -import org.onlab.packet.IpPrefix; 23 +import org.onlab.packet.Ip4Prefix;
24 24
25 import com.google.common.base.MoreObjects; 25 import com.google.common.base.MoreObjects;
26 26
...@@ -28,8 +28,8 @@ import com.google.common.base.MoreObjects; ...@@ -28,8 +28,8 @@ import com.google.common.base.MoreObjects;
28 * Represents a route entry for an IP prefix. 28 * Represents a route entry for an IP prefix.
29 */ 29 */
30 public class RouteEntry { 30 public class RouteEntry {
31 - private final IpPrefix prefix; // The IP prefix 31 + private final Ip4Prefix prefix; // The IP prefix
32 - private final IpAddress nextHop; // Next-hop IP address 32 + private final Ip4Address nextHop; // Next-hop IP address
33 33
34 /** 34 /**
35 * Class constructor. 35 * Class constructor.
...@@ -37,7 +37,7 @@ public class RouteEntry { ...@@ -37,7 +37,7 @@ public class RouteEntry {
37 * @param prefix the IP prefix of the route 37 * @param prefix the IP prefix of the route
38 * @param nextHop the next hop IP address for the route 38 * @param nextHop the next hop IP address for the route
39 */ 39 */
40 - public RouteEntry(IpPrefix prefix, IpAddress nextHop) { 40 + public RouteEntry(Ip4Prefix prefix, Ip4Address nextHop) {
41 this.prefix = checkNotNull(prefix); 41 this.prefix = checkNotNull(prefix);
42 this.nextHop = checkNotNull(nextHop); 42 this.nextHop = checkNotNull(nextHop);
43 } 43 }
...@@ -47,7 +47,7 @@ public class RouteEntry { ...@@ -47,7 +47,7 @@ public class RouteEntry {
47 * 47 *
48 * @return the IP prefix of the route 48 * @return the IP prefix of the route
49 */ 49 */
50 - public IpPrefix prefix() { 50 + public Ip4Prefix prefix() {
51 return prefix; 51 return prefix;
52 } 52 }
53 53
...@@ -56,7 +56,7 @@ public class RouteEntry { ...@@ -56,7 +56,7 @@ public class RouteEntry {
56 * 56 *
57 * @return the next hop IP address for the route 57 * @return the next hop IP address for the route
58 */ 58 */
59 - public IpAddress nextHop() { 59 + public Ip4Address nextHop() {
60 return nextHop; 60 return nextHop;
61 } 61 }
62 62
...@@ -67,7 +67,7 @@ public class RouteEntry { ...@@ -67,7 +67,7 @@ public class RouteEntry {
67 * @param ip4Prefix the IPv4 prefix to use 67 * @param ip4Prefix the IPv4 prefix to use
68 * @return the binary string representation 68 * @return the binary string representation
69 */ 69 */
70 - static String createBinaryString(IpPrefix ip4Prefix) { 70 + static String createBinaryString(Ip4Prefix ip4Prefix) {
71 if (ip4Prefix.prefixLength() == 0) { 71 if (ip4Prefix.prefixLength() == 0) {
72 return ""; 72 return "";
73 } 73 }
...@@ -75,7 +75,7 @@ public class RouteEntry { ...@@ -75,7 +75,7 @@ public class RouteEntry {
75 StringBuilder result = new StringBuilder(ip4Prefix.prefixLength()); 75 StringBuilder result = new StringBuilder(ip4Prefix.prefixLength());
76 long value = ip4Prefix.address().toInt() & 0xffffffffL; 76 long value = ip4Prefix.address().toInt() & 0xffffffffL;
77 for (int i = 0; i < ip4Prefix.prefixLength(); i++) { 77 for (int i = 0; i < ip4Prefix.prefixLength(); i++) {
78 - long mask = 1 << (IpPrefix.MAX_INET_MASK_LENGTH - 1 - i); 78 + long mask = 1 << (Ip4Prefix.MAX_MASK_LENGTH - 1 - i);
79 result.append(((value & mask) == 0) ? "0" : "1"); 79 result.append(((value & mask) == 0) ? "0" : "1");
80 } 80 }
81 return result.toString(); 81 return result.toString();
......
...@@ -53,7 +53,8 @@ import org.onlab.onos.sdnip.config.Interface; ...@@ -53,7 +53,8 @@ import org.onlab.onos.sdnip.config.Interface;
53 import org.onlab.onos.sdnip.config.SdnIpConfigService; 53 import org.onlab.onos.sdnip.config.SdnIpConfigService;
54 import org.onlab.packet.Ethernet; 54 import org.onlab.packet.Ethernet;
55 import org.onlab.packet.IpAddress; 55 import org.onlab.packet.IpAddress;
56 -import org.onlab.packet.IpPrefix; 56 +import org.onlab.packet.Ip4Address;
57 +import org.onlab.packet.Ip4Prefix;
57 import org.onlab.packet.MacAddress; 58 import org.onlab.packet.MacAddress;
58 import org.slf4j.Logger; 59 import org.slf4j.Logger;
59 import org.slf4j.LoggerFactory; 60 import org.slf4j.LoggerFactory;
...@@ -83,9 +84,9 @@ public class Router implements RouteListener { ...@@ -83,9 +84,9 @@ public class Router implements RouteListener {
83 // Stores all incoming route updates in a queue. 84 // Stores all incoming route updates in a queue.
84 private BlockingQueue<RouteUpdate> routeUpdates; 85 private BlockingQueue<RouteUpdate> routeUpdates;
85 86
86 - // The IpAddress is the next hop address of each route update. 87 + // The Ip4Address is the next hop address of each route update.
87 - private SetMultimap<IpAddress, RouteEntry> routesWaitingOnArp; 88 + private SetMultimap<Ip4Address, RouteEntry> routesWaitingOnArp;
88 - private ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> pushedRouteIntents; 89 + private ConcurrentHashMap<Ip4Prefix, MultiPointToSinglePointIntent> pushedRouteIntents;
89 90
90 private IntentService intentService; 91 private IntentService intentService;
91 private HostService hostService; 92 private HostService hostService;
...@@ -106,7 +107,8 @@ public class Router implements RouteListener { ...@@ -106,7 +107,8 @@ public class Router implements RouteListener {
106 107
107 // For routes announced by local BGP daemon in SDN network, 108 // For routes announced by local BGP daemon in SDN network,
108 // the next hop will be 0.0.0.0. 109 // the next hop will be 0.0.0.0.
109 - public static final IpAddress LOCAL_NEXT_HOP = IpAddress.valueOf("0.0.0.0"); 110 + public static final Ip4Address LOCAL_NEXT_HOP =
111 + Ip4Address.valueOf("0.0.0.0");
110 112
111 /** 113 /**
112 * Class constructor. 114 * Class constructor.
...@@ -130,7 +132,7 @@ public class Router implements RouteListener { ...@@ -130,7 +132,7 @@ public class Router implements RouteListener {
130 new DefaultByteArrayNodeFactory()); 132 new DefaultByteArrayNodeFactory());
131 routeUpdates = new LinkedBlockingQueue<>(); 133 routeUpdates = new LinkedBlockingQueue<>();
132 routesWaitingOnArp = Multimaps.synchronizedSetMultimap( 134 routesWaitingOnArp = Multimaps.synchronizedSetMultimap(
133 - HashMultimap.<IpAddress, RouteEntry>create()); 135 + HashMultimap.<Ip4Address, RouteEntry>create());
134 pushedRouteIntents = new ConcurrentHashMap<>(); 136 pushedRouteIntents = new ConcurrentHashMap<>();
135 137
136 bgpUpdatesExecutor = Executors.newSingleThreadExecutor( 138 bgpUpdatesExecutor = Executors.newSingleThreadExecutor(
...@@ -273,7 +275,7 @@ public class Router implements RouteListener { ...@@ -273,7 +275,7 @@ public class Router implements RouteListener {
273 } 275 }
274 log.debug("Syncing SDN-IP Route Intents..."); 276 log.debug("Syncing SDN-IP Route Intents...");
275 277
276 - Map<IpPrefix, MultiPointToSinglePointIntent> fetchedIntents = 278 + Map<Ip4Prefix, MultiPointToSinglePointIntent> fetchedIntents =
277 new HashMap<>(); 279 new HashMap<>();
278 280
279 // 281 //
...@@ -292,7 +294,12 @@ public class Router implements RouteListener { ...@@ -292,7 +294,12 @@ public class Router implements RouteListener {
292 Criterion c = mp2pIntent.selector().getCriterion(Type.IPV4_DST); 294 Criterion c = mp2pIntent.selector().getCriterion(Type.IPV4_DST);
293 if (c != null && c instanceof IPCriterion) { 295 if (c != null && c instanceof IPCriterion) {
294 IPCriterion ipCriterion = (IPCriterion) c; 296 IPCriterion ipCriterion = (IPCriterion) c;
295 - fetchedIntents.put(ipCriterion.ip(), mp2pIntent); 297 + Ip4Prefix ip4Prefix = ipCriterion.ip().getIp4Prefix();
298 + if (ip4Prefix == null) {
299 + // TODO: For now we support only IPv4
300 + continue;
301 + }
302 + fetchedIntents.put(ip4Prefix, mp2pIntent);
296 } else { 303 } else {
297 log.warn("No IPV4_DST criterion found for intent {}", 304 log.warn("No IPV4_DST criterion found for intent {}",
298 mp2pIntent.id()); 305 mp2pIntent.id());
...@@ -316,15 +323,15 @@ public class Router implements RouteListener { ...@@ -316,15 +323,15 @@ public class Router implements RouteListener {
316 // Intent for same prefix, then delete/withdraw the FETCHED 323 // Intent for same prefix, then delete/withdraw the FETCHED
317 // Intent. 324 // Intent.
318 // 325 //
319 - Collection<Pair<IpPrefix, MultiPointToSinglePointIntent>> 326 + Collection<Pair<Ip4Prefix, MultiPointToSinglePointIntent>>
320 storeInMemoryIntents = new LinkedList<>(); 327 storeInMemoryIntents = new LinkedList<>();
321 - Collection<Pair<IpPrefix, MultiPointToSinglePointIntent>> 328 + Collection<Pair<Ip4Prefix, MultiPointToSinglePointIntent>>
322 addIntents = new LinkedList<>(); 329 addIntents = new LinkedList<>();
323 - Collection<Pair<IpPrefix, MultiPointToSinglePointIntent>> 330 + Collection<Pair<Ip4Prefix, MultiPointToSinglePointIntent>>
324 deleteIntents = new LinkedList<>(); 331 deleteIntents = new LinkedList<>();
325 - for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : 332 + for (Map.Entry<Ip4Prefix, MultiPointToSinglePointIntent> entry :
326 pushedRouteIntents.entrySet()) { 333 pushedRouteIntents.entrySet()) {
327 - IpPrefix prefix = entry.getKey(); 334 + Ip4Prefix prefix = entry.getKey();
328 MultiPointToSinglePointIntent inMemoryIntent = 335 MultiPointToSinglePointIntent inMemoryIntent =
329 entry.getValue(); 336 entry.getValue();
330 MultiPointToSinglePointIntent fetchedIntent = 337 MultiPointToSinglePointIntent fetchedIntent =
...@@ -369,9 +376,9 @@ public class Router implements RouteListener { ...@@ -369,9 +376,9 @@ public class Router implements RouteListener {
369 // 376 //
370 // Any remaining FETCHED Intents have to be deleted/withdrawn 377 // Any remaining FETCHED Intents have to be deleted/withdrawn
371 // 378 //
372 - for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : 379 + for (Map.Entry<Ip4Prefix, MultiPointToSinglePointIntent> entry :
373 fetchedIntents.entrySet()) { 380 fetchedIntents.entrySet()) {
374 - IpPrefix prefix = entry.getKey(); 381 + Ip4Prefix prefix = entry.getKey();
375 MultiPointToSinglePointIntent fetchedIntent = entry.getValue(); 382 MultiPointToSinglePointIntent fetchedIntent = entry.getValue();
376 deleteIntents.add(Pair.of(prefix, fetchedIntent)); 383 deleteIntents.add(Pair.of(prefix, fetchedIntent));
377 } 384 }
...@@ -383,9 +390,9 @@ public class Router implements RouteListener { ...@@ -383,9 +390,9 @@ public class Router implements RouteListener {
383 // 2. Delete intents: check if the leader before each operation 390 // 2. Delete intents: check if the leader before each operation
384 // 3. Add intents: check if the leader before each operation 391 // 3. Add intents: check if the leader before each operation
385 // 392 //
386 - for (Pair<IpPrefix, MultiPointToSinglePointIntent> pair : 393 + for (Pair<Ip4Prefix, MultiPointToSinglePointIntent> pair :
387 storeInMemoryIntents) { 394 storeInMemoryIntents) {
388 - IpPrefix prefix = pair.getLeft(); 395 + Ip4Prefix prefix = pair.getLeft();
389 MultiPointToSinglePointIntent intent = pair.getRight(); 396 MultiPointToSinglePointIntent intent = pair.getRight();
390 log.debug("Intent synchronization: updating in-memory " + 397 log.debug("Intent synchronization: updating in-memory " +
391 "Intent for prefix: {}", prefix); 398 "Intent for prefix: {}", prefix);
...@@ -393,9 +400,9 @@ public class Router implements RouteListener { ...@@ -393,9 +400,9 @@ public class Router implements RouteListener {
393 } 400 }
394 // 401 //
395 isActivatedLeader = true; // Allow push of Intents 402 isActivatedLeader = true; // Allow push of Intents
396 - for (Pair<IpPrefix, MultiPointToSinglePointIntent> pair : 403 + for (Pair<Ip4Prefix, MultiPointToSinglePointIntent> pair :
397 deleteIntents) { 404 deleteIntents) {
398 - IpPrefix prefix = pair.getLeft(); 405 + Ip4Prefix prefix = pair.getLeft();
399 MultiPointToSinglePointIntent intent = pair.getRight(); 406 MultiPointToSinglePointIntent intent = pair.getRight();
400 if (!isElectedLeader) { 407 if (!isElectedLeader) {
401 isActivatedLeader = false; 408 isActivatedLeader = false;
...@@ -406,9 +413,9 @@ public class Router implements RouteListener { ...@@ -406,9 +413,9 @@ public class Router implements RouteListener {
406 intentService.withdraw(intent); 413 intentService.withdraw(intent);
407 } 414 }
408 // 415 //
409 - for (Pair<IpPrefix, MultiPointToSinglePointIntent> pair : 416 + for (Pair<Ip4Prefix, MultiPointToSinglePointIntent> pair :
410 addIntents) { 417 addIntents) {
411 - IpPrefix prefix = pair.getLeft(); 418 + Ip4Prefix prefix = pair.getLeft();
412 MultiPointToSinglePointIntent intent = pair.getRight(); 419 MultiPointToSinglePointIntent intent = pair.getRight();
413 if (!isElectedLeader) { 420 if (!isElectedLeader) {
414 isActivatedLeader = false; 421 isActivatedLeader = false;
...@@ -460,8 +467,8 @@ public class Router implements RouteListener { ...@@ -460,8 +467,8 @@ public class Router implements RouteListener {
460 synchronized (this) { 467 synchronized (this) {
461 log.debug("Processing route add: {}", routeEntry); 468 log.debug("Processing route add: {}", routeEntry);
462 469
463 - IpPrefix prefix = routeEntry.prefix(); 470 + Ip4Prefix prefix = routeEntry.prefix();
464 - IpAddress nextHop = null; 471 + Ip4Address nextHop = null;
465 RouteEntry foundRouteEntry = 472 RouteEntry foundRouteEntry =
466 bgpRoutes.put(RouteEntry.createBinaryString(prefix), 473 bgpRoutes.put(RouteEntry.createBinaryString(prefix),
467 routeEntry); 474 routeEntry);
...@@ -535,8 +542,8 @@ public class Router implements RouteListener { ...@@ -535,8 +542,8 @@ public class Router implements RouteListener {
535 * @param nextHopIpAddress IP address of the next hop 542 * @param nextHopIpAddress IP address of the next hop
536 * @param nextHopMacAddress MAC address of the next hop 543 * @param nextHopMacAddress MAC address of the next hop
537 */ 544 */
538 - private void addRouteIntentToNextHop(IpPrefix prefix, 545 + private void addRouteIntentToNextHop(Ip4Prefix prefix,
539 - IpAddress nextHopIpAddress, 546 + Ip4Address nextHopIpAddress,
540 MacAddress nextHopMacAddress) { 547 MacAddress nextHopMacAddress) {
541 548
542 // Find the attachment point (egress interface) of the next hop 549 // Find the attachment point (egress interface) of the next hop
...@@ -573,7 +580,7 @@ public class Router implements RouteListener { ...@@ -573,7 +580,7 @@ public class Router implements RouteListener {
573 * @param egressInterface egress Interface connected to next hop router 580 * @param egressInterface egress Interface connected to next hop router
574 * @param nextHopMacAddress MAC address of next hop router 581 * @param nextHopMacAddress MAC address of next hop router
575 */ 582 */
576 - private void doAddRouteIntent(IpPrefix prefix, Interface egressInterface, 583 + private void doAddRouteIntent(Ip4Prefix prefix, Interface egressInterface,
577 MacAddress nextHopMacAddress) { 584 MacAddress nextHopMacAddress) {
578 log.debug("Adding intent for prefix {}, next hop mac {}", 585 log.debug("Adding intent for prefix {}, next hop mac {}",
579 prefix, nextHopMacAddress); 586 prefix, nextHopMacAddress);
...@@ -634,7 +641,7 @@ public class Router implements RouteListener { ...@@ -634,7 +641,7 @@ public class Router implements RouteListener {
634 protected void processRouteDelete(RouteEntry routeEntry) { 641 protected void processRouteDelete(RouteEntry routeEntry) {
635 synchronized (this) { 642 synchronized (this) {
636 log.debug("Processing route delete: {}", routeEntry); 643 log.debug("Processing route delete: {}", routeEntry);
637 - IpPrefix prefix = routeEntry.prefix(); 644 + Ip4Prefix prefix = routeEntry.prefix();
638 645
639 if (bgpRoutes.remove(RouteEntry.createBinaryString(prefix))) { 646 if (bgpRoutes.remove(RouteEntry.createBinaryString(prefix))) {
640 // 647 //
...@@ -659,7 +666,7 @@ public class Router implements RouteListener { ...@@ -659,7 +666,7 @@ public class Router implements RouteListener {
659 private void executeRouteDelete(RouteEntry routeEntry) { 666 private void executeRouteDelete(RouteEntry routeEntry) {
660 log.debug("Executing route delete: {}", routeEntry); 667 log.debug("Executing route delete: {}", routeEntry);
661 668
662 - IpPrefix prefix = routeEntry.prefix(); 669 + Ip4Prefix prefix = routeEntry.prefix();
663 670
664 MultiPointToSinglePointIntent intent = 671 MultiPointToSinglePointIntent intent =
665 pushedRouteIntents.remove(prefix); 672 pushedRouteIntents.remove(prefix);
...@@ -685,11 +692,12 @@ public class Router implements RouteListener { ...@@ -685,11 +692,12 @@ public class Router implements RouteListener {
685 * @param ipAddress the IP address that an event was received for 692 * @param ipAddress the IP address that an event was received for
686 * @param macAddress the most recently known MAC address for the IP address 693 * @param macAddress the most recently known MAC address for the IP address
687 */ 694 */
688 - private void updateMac(IpAddress ipAddress, MacAddress macAddress) { 695 + private void updateMac(Ip4Address ipAddress, MacAddress macAddress) {
689 log.debug("Received updated MAC info: {} => {}", ipAddress, macAddress); 696 log.debug("Received updated MAC info: {} => {}", ipAddress, macAddress);
690 697
691 // TODO here we should check whether the next hop for any of our 698 // TODO here we should check whether the next hop for any of our
692 - // installed prefixes has changed, not just prefixes pending installation. 699 + // installed prefixes has changed, not just prefixes pending
700 + // installation.
693 701
694 // We synchronize on this to prevent changes to the radix tree 702 // We synchronize on this to prevent changes to the radix tree
695 // while we're pushing intents. If the tree changes, the 703 // while we're pushing intents. If the tree changes, the
...@@ -701,7 +709,7 @@ public class Router implements RouteListener { ...@@ -701,7 +709,7 @@ public class Router implements RouteListener {
701 709
702 for (RouteEntry routeEntry : routesToPush) { 710 for (RouteEntry routeEntry : routesToPush) {
703 // These will always be adds 711 // These will always be adds
704 - IpPrefix prefix = routeEntry.prefix(); 712 + Ip4Prefix prefix = routeEntry.prefix();
705 String binaryString = RouteEntry.createBinaryString(prefix); 713 String binaryString = RouteEntry.createBinaryString(prefix);
706 RouteEntry foundRouteEntry = 714 RouteEntry foundRouteEntry =
707 bgpRoutes.getValueForExactKey(binaryString); 715 bgpRoutes.getValueForExactKey(binaryString);
...@@ -748,7 +756,7 @@ public class Router implements RouteListener { ...@@ -748,7 +756,7 @@ public class Router implements RouteListener {
748 public Collection<MultiPointToSinglePointIntent> getPushedRouteIntents() { 756 public Collection<MultiPointToSinglePointIntent> getPushedRouteIntents() {
749 List<MultiPointToSinglePointIntent> pushedIntents = new LinkedList<>(); 757 List<MultiPointToSinglePointIntent> pushedIntents = new LinkedList<>();
750 758
751 - for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : 759 + for (Map.Entry<Ip4Prefix, MultiPointToSinglePointIntent> entry :
752 pushedRouteIntents.entrySet()) { 760 pushedRouteIntents.entrySet()) {
753 pushedIntents.add(entry.getValue()); 761 pushedIntents.add(entry.getValue());
754 } 762 }
...@@ -765,7 +773,12 @@ public class Router implements RouteListener { ...@@ -765,7 +773,12 @@ public class Router implements RouteListener {
765 event.type() == HostEvent.Type.HOST_UPDATED) { 773 event.type() == HostEvent.Type.HOST_UPDATED) {
766 Host host = event.subject(); 774 Host host = event.subject();
767 for (IpAddress ip : host.ipAddresses()) { 775 for (IpAddress ip : host.ipAddresses()) {
768 - updateMac(ip, host.mac()); 776 + Ip4Address ip4Address = ip.getIp4Address();
777 + if (ip4Address == null) {
778 + // TODO: For now we support only IPv4
779 + continue;
780 + }
781 + updateMac(ip4Address, host.mac());
769 } 782 }
770 } 783 }
771 } 784 }
......
...@@ -21,8 +21,8 @@ import java.util.ArrayList; ...@@ -21,8 +21,8 @@ import java.util.ArrayList;
21 import java.util.Objects; 21 import java.util.Objects;
22 22
23 import org.onlab.onos.sdnip.RouteEntry; 23 import org.onlab.onos.sdnip.RouteEntry;
24 -import org.onlab.packet.IpAddress; 24 +import org.onlab.packet.Ip4Address;
25 -import org.onlab.packet.IpPrefix; 25 +import org.onlab.packet.Ip4Prefix;
26 26
27 import com.google.common.base.MoreObjects; 27 import com.google.common.base.MoreObjects;
28 28
...@@ -48,8 +48,8 @@ public class BgpRouteEntry extends RouteEntry { ...@@ -48,8 +48,8 @@ public class BgpRouteEntry extends RouteEntry {
48 * @param asPath the AS path 48 * @param asPath the AS path
49 * @param localPref the route local preference 49 * @param localPref the route local preference
50 */ 50 */
51 - public BgpRouteEntry(BgpSession bgpSession, IpPrefix prefix, 51 + public BgpRouteEntry(BgpSession bgpSession, Ip4Prefix prefix,
52 - IpAddress nextHop, byte origin, 52 + Ip4Address nextHop, byte origin,
53 BgpRouteEntry.AsPath asPath, long localPref) { 53 BgpRouteEntry.AsPath asPath, long localPref) {
54 super(prefix, nextHop); 54 super(prefix, nextHop);
55 this.bgpSession = checkNotNull(bgpSession); 55 this.bgpSession = checkNotNull(bgpSession);
...@@ -232,15 +232,15 @@ public class BgpRouteEntry extends RouteEntry { ...@@ -232,15 +232,15 @@ public class BgpRouteEntry extends RouteEntry {
232 } 232 }
233 233
234 // Compare the peer BGP ID: lower is better 234 // Compare the peer BGP ID: lower is better
235 - IpAddress peerBgpId = getBgpSession().getRemoteBgpId(); 235 + Ip4Address peerBgpId = getBgpSession().getRemoteBgpId();
236 - IpAddress otherPeerBgpId = other.getBgpSession().getRemoteBgpId(); 236 + Ip4Address otherPeerBgpId = other.getBgpSession().getRemoteBgpId();
237 if (!peerBgpId.equals(otherPeerBgpId)) { 237 if (!peerBgpId.equals(otherPeerBgpId)) {
238 return (peerBgpId.compareTo(otherPeerBgpId) < 0); 238 return (peerBgpId.compareTo(otherPeerBgpId) < 0);
239 } 239 }
240 240
241 // Compare the peer BGP address: lower is better 241 // Compare the peer BGP address: lower is better
242 - IpAddress peerAddress = getBgpSession().getRemoteIp4Address(); 242 + Ip4Address peerAddress = getBgpSession().getRemoteIp4Address();
243 - IpAddress otherPeerAddress = 243 + Ip4Address otherPeerAddress =
244 other.getBgpSession().getRemoteIp4Address(); 244 other.getBgpSession().getRemoteIp4Address();
245 if (!peerAddress.equals(otherPeerAddress)) { 245 if (!peerAddress.equals(otherPeerAddress)) {
246 return (peerAddress.compareTo(otherPeerAddress) < 0); 246 return (peerAddress.compareTo(otherPeerAddress) < 0);
......
...@@ -42,8 +42,8 @@ import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.HoldTimerExpired; ...@@ -42,8 +42,8 @@ import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.HoldTimerExpired;
42 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.MessageHeaderError; 42 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.MessageHeaderError;
43 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.OpenMessageError; 43 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.OpenMessageError;
44 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.UpdateMessageError; 44 import org.onlab.onos.sdnip.bgp.BgpConstants.Notifications.UpdateMessageError;
45 -import org.onlab.packet.IpAddress; 45 +import org.onlab.packet.Ip4Address;
46 -import org.onlab.packet.IpPrefix; 46 +import org.onlab.packet.Ip4Prefix;
47 import org.slf4j.Logger; 47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory; 48 import org.slf4j.LoggerFactory;
49 49
...@@ -62,18 +62,18 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -62,18 +62,18 @@ public class BgpSession extends SimpleChannelHandler {
62 private boolean isClosed = false; 62 private boolean isClosed = false;
63 63
64 private SocketAddress remoteAddress; // Peer IP addr/port 64 private SocketAddress remoteAddress; // Peer IP addr/port
65 - private IpAddress remoteIp4Address; // Peer IPv4 address 65 + private Ip4Address remoteIp4Address; // Peer IPv4 address
66 private int remoteBgpVersion; // 1 octet 66 private int remoteBgpVersion; // 1 octet
67 private long remoteAs; // 2 octets 67 private long remoteAs; // 2 octets
68 private long remoteHoldtime; // 2 octets 68 private long remoteHoldtime; // 2 octets
69 - private IpAddress remoteBgpId; // 4 octets -> IPv4 address 69 + private Ip4Address remoteBgpId; // 4 octets -> IPv4 address
70 // 70 //
71 private SocketAddress localAddress; // Local IP addr/port 71 private SocketAddress localAddress; // Local IP addr/port
72 - private IpAddress localIp4Address; // Local IPv4 address 72 + private Ip4Address localIp4Address; // Local IPv4 address
73 private int localBgpVersion; // 1 octet 73 private int localBgpVersion; // 1 octet
74 private long localAs; // 2 octets 74 private long localAs; // 2 octets
75 private long localHoldtime; // 2 octets 75 private long localHoldtime; // 2 octets
76 - private IpAddress localBgpId; // 4 octets -> IPv4 address 76 + private Ip4Address localBgpId; // 4 octets -> IPv4 address
77 // 77 //
78 private long localKeepaliveInterval; // Keepalive interval 78 private long localKeepaliveInterval; // Keepalive interval
79 79
...@@ -83,7 +83,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -83,7 +83,7 @@ public class BgpSession extends SimpleChannelHandler {
83 private volatile Timeout sessionTimeout; // Session timeout 83 private volatile Timeout sessionTimeout; // Session timeout
84 84
85 // BGP RIB-IN routing entries from this peer 85 // BGP RIB-IN routing entries from this peer
86 - private ConcurrentMap<IpPrefix, BgpRouteEntry> bgpRibIn = 86 + private ConcurrentMap<Ip4Prefix, BgpRouteEntry> bgpRibIn =
87 new ConcurrentHashMap<>(); 87 new ConcurrentHashMap<>();
88 88
89 /** 89 /**
...@@ -110,7 +110,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -110,7 +110,7 @@ public class BgpSession extends SimpleChannelHandler {
110 * @param prefix the prefix of the route to search for 110 * @param prefix the prefix of the route to search for
111 * @return the BGP routing entry if found, otherwise null 111 * @return the BGP routing entry if found, otherwise null
112 */ 112 */
113 - public BgpRouteEntry findBgpRouteEntry(IpPrefix prefix) { 113 + public BgpRouteEntry findBgpRouteEntry(Ip4Prefix prefix) {
114 return bgpRibIn.get(prefix); 114 return bgpRibIn.get(prefix);
115 } 115 }
116 116
...@@ -128,7 +128,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -128,7 +128,7 @@ public class BgpSession extends SimpleChannelHandler {
128 * 128 *
129 * @return the BGP session remote IPv4 address 129 * @return the BGP session remote IPv4 address
130 */ 130 */
131 - public IpAddress getRemoteIp4Address() { 131 + public Ip4Address getRemoteIp4Address() {
132 return remoteIp4Address; 132 return remoteIp4Address;
133 } 133 }
134 134
...@@ -164,7 +164,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -164,7 +164,7 @@ public class BgpSession extends SimpleChannelHandler {
164 * 164 *
165 * @return the BGP session remote BGP Identifier as an IPv4 address 165 * @return the BGP session remote BGP Identifier as an IPv4 address
166 */ 166 */
167 - public IpAddress getRemoteBgpId() { 167 + public Ip4Address getRemoteBgpId() {
168 return remoteBgpId; 168 return remoteBgpId;
169 } 169 }
170 170
...@@ -209,7 +209,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -209,7 +209,7 @@ public class BgpSession extends SimpleChannelHandler {
209 * 209 *
210 * @return the BGP session local BGP Identifier as an IPv4 address 210 * @return the BGP session local BGP Identifier as an IPv4 address
211 */ 211 */
212 - public IpAddress getLocalBgpId() { 212 + public Ip4Address getLocalBgpId() {
213 return localBgpId; 213 return localBgpId;
214 } 214 }
215 215
...@@ -246,13 +246,11 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -246,13 +246,11 @@ public class BgpSession extends SimpleChannelHandler {
246 InetAddress inetAddr; 246 InetAddress inetAddr;
247 if (localAddress instanceof InetSocketAddress) { 247 if (localAddress instanceof InetSocketAddress) {
248 inetAddr = ((InetSocketAddress) localAddress).getAddress(); 248 inetAddr = ((InetSocketAddress) localAddress).getAddress();
249 - localIp4Address = IpAddress.valueOf(IpAddress.Version.INET, 249 + localIp4Address = Ip4Address.valueOf(inetAddr.getAddress());
250 - inetAddr.getAddress());
251 } 250 }
252 if (remoteAddress instanceof InetSocketAddress) { 251 if (remoteAddress instanceof InetSocketAddress) {
253 inetAddr = ((InetSocketAddress) remoteAddress).getAddress(); 252 inetAddr = ((InetSocketAddress) remoteAddress).getAddress();
254 - remoteIp4Address = IpAddress.valueOf(IpAddress.Version.INET, 253 + remoteIp4Address = Ip4Address.valueOf(inetAddr.getAddress());
255 - inetAddr.getAddress());
256 } 254 }
257 255
258 log.debug("BGP Session Connected from {} on {}", 256 log.debug("BGP Session Connected from {} on {}",
...@@ -388,7 +386,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -388,7 +386,7 @@ public class BgpSession extends SimpleChannelHandler {
388 } 386 }
389 387
390 // Remote BGP Identifier 388 // Remote BGP Identifier
391 - remoteBgpId = IpAddress.valueOf((int) message.readUnsignedInt()); 389 + remoteBgpId = Ip4Address.valueOf((int) message.readUnsignedInt());
392 390
393 // Optional Parameters 391 // Optional Parameters
394 int optParamLen = message.readUnsignedByte(); 392 int optParamLen = message.readUnsignedByte();
...@@ -460,7 +458,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -460,7 +458,7 @@ public class BgpSession extends SimpleChannelHandler {
460 */ 458 */
461 void processBgpUpdate(ChannelHandlerContext ctx, ChannelBuffer message) { 459 void processBgpUpdate(ChannelHandlerContext ctx, ChannelBuffer message) {
462 Collection<BgpRouteEntry> addedRoutes = null; 460 Collection<BgpRouteEntry> addedRoutes = null;
463 - Map<IpPrefix, BgpRouteEntry> deletedRoutes = new HashMap<>(); 461 + Map<Ip4Prefix, BgpRouteEntry> deletedRoutes = new HashMap<>();
464 462
465 int minLength = 463 int minLength =
466 BgpConstants.BGP_UPDATE_MIN_LENGTH - BgpConstants.BGP_HEADER_LENGTH; 464 BgpConstants.BGP_UPDATE_MIN_LENGTH - BgpConstants.BGP_HEADER_LENGTH;
...@@ -494,7 +492,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -494,7 +492,7 @@ public class BgpSession extends SimpleChannelHandler {
494 actionsBgpUpdateMalformedAttributeList(ctx); 492 actionsBgpUpdateMalformedAttributeList(ctx);
495 return; 493 return;
496 } 494 }
497 - Collection<IpPrefix> withdrawnPrefixes = null; 495 + Collection<Ip4Prefix> withdrawnPrefixes = null;
498 try { 496 try {
499 withdrawnPrefixes = parsePackedPrefixes(withdrawnRoutesLength, 497 withdrawnPrefixes = parsePackedPrefixes(withdrawnRoutesLength,
500 message); 498 message);
...@@ -505,7 +503,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -505,7 +503,7 @@ public class BgpSession extends SimpleChannelHandler {
505 actionsBgpUpdateInvalidNetworkField(ctx); 503 actionsBgpUpdateInvalidNetworkField(ctx);
506 return; 504 return;
507 } 505 }
508 - for (IpPrefix prefix : withdrawnPrefixes) { 506 + for (Ip4Prefix prefix : withdrawnPrefixes) {
509 log.debug("BGP RX UPDATE message WITHDRAWN from {}: {}", 507 log.debug("BGP RX UPDATE message WITHDRAWN from {}: {}",
510 remoteAddress, prefix); 508 remoteAddress, prefix);
511 BgpRouteEntry bgpRouteEntry = bgpRibIn.get(prefix); 509 BgpRouteEntry bgpRouteEntry = bgpRibIn.get(prefix);
...@@ -560,19 +558,19 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -560,19 +558,19 @@ public class BgpSession extends SimpleChannelHandler {
560 ChannelHandlerContext ctx, 558 ChannelHandlerContext ctx,
561 ChannelBuffer message) 559 ChannelBuffer message)
562 throws BgpParseException { 560 throws BgpParseException {
563 - Map<IpPrefix, BgpRouteEntry> addedRoutes = new HashMap<>(); 561 + Map<Ip4Prefix, BgpRouteEntry> addedRoutes = new HashMap<>();
564 562
565 // 563 //
566 // Parsed values 564 // Parsed values
567 // 565 //
568 Short origin = -1; // Mandatory 566 Short origin = -1; // Mandatory
569 BgpRouteEntry.AsPath asPath = null; // Mandatory 567 BgpRouteEntry.AsPath asPath = null; // Mandatory
570 - IpAddress nextHop = null; // Mandatory 568 + Ip4Address nextHop = null; // Mandatory
571 long multiExitDisc = // Optional 569 long multiExitDisc = // Optional
572 BgpConstants.Update.MultiExitDisc.LOWEST_MULTI_EXIT_DISC; 570 BgpConstants.Update.MultiExitDisc.LOWEST_MULTI_EXIT_DISC;
573 Long localPref = null; // Mandatory 571 Long localPref = null; // Mandatory
574 Long aggregatorAsNumber = null; // Optional: unused 572 Long aggregatorAsNumber = null; // Optional: unused
575 - IpAddress aggregatorIpAddress = null; // Optional: unused 573 + Ip4Address aggregatorIpAddress = null; // Optional: unused
576 574
577 // 575 //
578 // Get and verify the Path Attributes Length 576 // Get and verify the Path Attributes Length
...@@ -684,7 +682,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -684,7 +682,7 @@ public class BgpSession extends SimpleChannelHandler {
684 682
685 case BgpConstants.Update.Aggregator.TYPE: 683 case BgpConstants.Update.Aggregator.TYPE:
686 // Attribute Type Code AGGREGATOR 684 // Attribute Type Code AGGREGATOR
687 - Pair<Long, IpAddress> aggregator = 685 + Pair<Long, Ip4Address> aggregator =
688 parseAttributeTypeAggregator(ctx, attrTypeCode, attrLen, 686 parseAttributeTypeAggregator(ctx, attrTypeCode, attrLen,
689 attrFlags, message); 687 attrFlags, message);
690 aggregatorAsNumber = aggregator.getLeft(); 688 aggregatorAsNumber = aggregator.getLeft();
...@@ -720,7 +718,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -720,7 +718,7 @@ public class BgpSession extends SimpleChannelHandler {
720 // 718 //
721 // Parse the NLRI (Network Layer Reachability Information) 719 // Parse the NLRI (Network Layer Reachability Information)
722 // 720 //
723 - Collection<IpPrefix> addedPrefixes = null; 721 + Collection<Ip4Prefix> addedPrefixes = null;
724 int nlriLength = message.readableBytes(); 722 int nlriLength = message.readableBytes();
725 try { 723 try {
726 addedPrefixes = parsePackedPrefixes(nlriLength, message); 724 addedPrefixes = parsePackedPrefixes(nlriLength, message);
...@@ -734,7 +732,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -734,7 +732,7 @@ public class BgpSession extends SimpleChannelHandler {
734 } 732 }
735 733
736 // Generate the added routes 734 // Generate the added routes
737 - for (IpPrefix prefix : addedPrefixes) { 735 + for (Ip4Prefix prefix : addedPrefixes) {
738 BgpRouteEntry bgpRouteEntry = 736 BgpRouteEntry bgpRouteEntry =
739 new BgpRouteEntry(this, prefix, nextHop, 737 new BgpRouteEntry(this, prefix, nextHop,
740 origin.byteValue(), asPath, localPref); 738 origin.byteValue(), asPath, localPref);
...@@ -768,7 +766,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -768,7 +766,7 @@ public class BgpSession extends SimpleChannelHandler {
768 ChannelHandlerContext ctx, 766 ChannelHandlerContext ctx,
769 Short origin, 767 Short origin,
770 BgpRouteEntry.AsPath asPath, 768 BgpRouteEntry.AsPath asPath,
771 - IpAddress nextHop, 769 + Ip4Address nextHop,
772 Long localPref) 770 Long localPref)
773 throws BgpParseException { 771 throws BgpParseException {
774 // 772 //
...@@ -1025,7 +1023,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1025,7 +1023,7 @@ public class BgpSession extends SimpleChannelHandler {
1025 * @return the parsed NEXT_HOP value 1023 * @return the parsed NEXT_HOP value
1026 * @throws BgpParseException 1024 * @throws BgpParseException
1027 */ 1025 */
1028 - private IpAddress parseAttributeTypeNextHop( 1026 + private Ip4Address parseAttributeTypeNextHop(
1029 ChannelHandlerContext ctx, 1027 ChannelHandlerContext ctx,
1030 int attrTypeCode, 1028 int attrTypeCode,
1031 int attrLen, 1029 int attrLen,
...@@ -1043,8 +1041,8 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1043,8 +1041,8 @@ public class BgpSession extends SimpleChannelHandler {
1043 } 1041 }
1044 1042
1045 message.markReaderIndex(); 1043 message.markReaderIndex();
1046 - long address = message.readUnsignedInt(); 1044 + Ip4Address nextHopAddress =
1047 - IpAddress nextHopAddress = IpAddress.valueOf((int) address); 1045 + Ip4Address.valueOf((int) message.readUnsignedInt());
1048 // 1046 //
1049 // Check whether the NEXT_HOP IP address is semantically correct. 1047 // Check whether the NEXT_HOP IP address is semantically correct.
1050 // As per RFC 4271, Section 6.3: 1048 // As per RFC 4271, Section 6.3:
...@@ -1173,7 +1171,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1173,7 +1171,7 @@ public class BgpSession extends SimpleChannelHandler {
1173 * @return the parsed AGGREGATOR value: a tuple of <AS-Number, IP-Address> 1171 * @return the parsed AGGREGATOR value: a tuple of <AS-Number, IP-Address>
1174 * @throws BgpParseException 1172 * @throws BgpParseException
1175 */ 1173 */
1176 - private Pair<Long, IpAddress> parseAttributeTypeAggregator( 1174 + private Pair<Long, Ip4Address> parseAttributeTypeAggregator(
1177 ChannelHandlerContext ctx, 1175 ChannelHandlerContext ctx,
1178 int attrTypeCode, 1176 int attrTypeCode,
1179 int attrLen, 1177 int attrLen,
...@@ -1193,11 +1191,10 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1193,11 +1191,10 @@ public class BgpSession extends SimpleChannelHandler {
1193 // The AGGREGATOR AS number 1191 // The AGGREGATOR AS number
1194 long aggregatorAsNumber = message.readUnsignedShort(); 1192 long aggregatorAsNumber = message.readUnsignedShort();
1195 // The AGGREGATOR IP address 1193 // The AGGREGATOR IP address
1196 - long aggregatorAddress = message.readUnsignedInt(); 1194 + Ip4Address aggregatorIpAddress =
1197 - IpAddress aggregatorIpAddress = 1195 + Ip4Address.valueOf((int) message.readUnsignedInt());
1198 - IpAddress.valueOf((int) aggregatorAddress);
1199 1196
1200 - Pair<Long, IpAddress> aggregator = Pair.of(aggregatorAsNumber, 1197 + Pair<Long, Ip4Address> aggregator = Pair.of(aggregatorAsNumber,
1201 aggregatorIpAddress); 1198 aggregatorIpAddress);
1202 return aggregator; 1199 return aggregator;
1203 } 1200 }
...@@ -1215,10 +1212,10 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1215,10 +1212,10 @@ public class BgpSession extends SimpleChannelHandler {
1215 * @return a collection of parsed IPv4 network prefixes 1212 * @return a collection of parsed IPv4 network prefixes
1216 * @throws BgpParseException 1213 * @throws BgpParseException
1217 */ 1214 */
1218 - private Collection<IpPrefix> parsePackedPrefixes(int totalLength, 1215 + private Collection<Ip4Prefix> parsePackedPrefixes(int totalLength,
1219 ChannelBuffer message) 1216 ChannelBuffer message)
1220 throws BgpParseException { 1217 throws BgpParseException {
1221 - Collection<IpPrefix> result = new ArrayList<>(); 1218 + Collection<Ip4Prefix> result = new ArrayList<>();
1222 1219
1223 if (totalLength == 0) { 1220 if (totalLength == 0) {
1224 return result; 1221 return result;
...@@ -1242,8 +1239,8 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1242,8 +1239,8 @@ public class BgpSession extends SimpleChannelHandler {
1242 prefixBytelen--; 1239 prefixBytelen--;
1243 } 1240 }
1244 address <<= extraShift; 1241 address <<= extraShift;
1245 - IpPrefix prefix = 1242 + Ip4Prefix prefix =
1246 - IpPrefix.valueOf(IpAddress.valueOf((int) address), 1243 + Ip4Prefix.valueOf(Ip4Address.valueOf((int) address),
1247 prefixBitlen); 1244 prefixBitlen);
1248 result.add(prefix); 1245 result.add(prefix);
1249 } 1246 }
...@@ -1413,7 +1410,7 @@ public class BgpSession extends SimpleChannelHandler { ...@@ -1413,7 +1410,7 @@ public class BgpSession extends SimpleChannelHandler {
1413 int attrLen, 1410 int attrLen,
1414 int attrFlags, 1411 int attrFlags,
1415 ChannelBuffer message, 1412 ChannelBuffer message,
1416 - IpAddress nextHop) { 1413 + Ip4Address nextHop) {
1417 log.debug("BGP RX UPDATE Error from {}: Invalid NEXT_HOP Attribute {}", 1414 log.debug("BGP RX UPDATE Error from {}: Invalid NEXT_HOP Attribute {}",
1418 remoteAddress, nextHop); 1415 remoteAddress, nextHop);
1419 1416
......
...@@ -35,8 +35,8 @@ import org.jboss.netty.channel.Channels; ...@@ -35,8 +35,8 @@ import org.jboss.netty.channel.Channels;
35 import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; 35 import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
36 import org.onlab.onos.sdnip.RouteListener; 36 import org.onlab.onos.sdnip.RouteListener;
37 import org.onlab.onos.sdnip.RouteUpdate; 37 import org.onlab.onos.sdnip.RouteUpdate;
38 -import org.onlab.packet.IpAddress; 38 +import org.onlab.packet.Ip4Address;
39 -import org.onlab.packet.IpPrefix; 39 +import org.onlab.packet.Ip4Prefix;
40 import org.slf4j.Logger; 40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory; 41 import org.slf4j.LoggerFactory;
42 42
...@@ -49,10 +49,10 @@ public class BgpSessionManager { ...@@ -49,10 +49,10 @@ public class BgpSessionManager {
49 private Channel serverChannel; // Listener for incoming BGP connections 49 private Channel serverChannel; // Listener for incoming BGP connections
50 private ConcurrentMap<SocketAddress, BgpSession> bgpSessions = 50 private ConcurrentMap<SocketAddress, BgpSession> bgpSessions =
51 new ConcurrentHashMap<>(); 51 new ConcurrentHashMap<>();
52 - private IpAddress myBgpId; // Same BGP ID for all peers 52 + private Ip4Address myBgpId; // Same BGP ID for all peers
53 53
54 private BgpRouteSelector bgpRouteSelector = new BgpRouteSelector(); 54 private BgpRouteSelector bgpRouteSelector = new BgpRouteSelector();
55 - private ConcurrentMap<IpPrefix, BgpRouteEntry> bgpRoutes = 55 + private ConcurrentMap<Ip4Prefix, BgpRouteEntry> bgpRoutes =
56 new ConcurrentHashMap<>(); 56 new ConcurrentHashMap<>();
57 57
58 private final RouteListener routeListener; 58 private final RouteListener routeListener;
...@@ -105,8 +105,7 @@ public class BgpSessionManager { ...@@ -105,8 +105,7 @@ public class BgpSessionManager {
105 if (bgpSession.getLocalAddress() instanceof InetSocketAddress) { 105 if (bgpSession.getLocalAddress() instanceof InetSocketAddress) {
106 InetAddress inetAddr = 106 InetAddress inetAddr =
107 ((InetSocketAddress) bgpSession.getLocalAddress()).getAddress(); 107 ((InetSocketAddress) bgpSession.getLocalAddress()).getAddress();
108 - IpAddress ip4Address = IpAddress.valueOf(IpAddress.Version.INET, 108 + Ip4Address ip4Address = Ip4Address.valueOf(inetAddr.getAddress());
109 - inetAddr.getAddress());
110 updateMyBgpId(ip4Address); 109 updateMyBgpId(ip4Address);
111 } 110 }
112 return true; 111 return true;
...@@ -128,7 +127,7 @@ public class BgpSessionManager { ...@@ -128,7 +127,7 @@ public class BgpSessionManager {
128 * 127 *
129 * @param ip4Address the IPv4 address to use as BGP ID 128 * @param ip4Address the IPv4 address to use as BGP ID
130 */ 129 */
131 - private synchronized void updateMyBgpId(IpAddress ip4Address) { 130 + private synchronized void updateMyBgpId(Ip4Address ip4Address) {
132 if (myBgpId == null) { 131 if (myBgpId == null) {
133 myBgpId = ip4Address; 132 myBgpId = ip4Address;
134 log.debug("BGP: My BGP ID is {}", myBgpId); 133 log.debug("BGP: My BGP ID is {}", myBgpId);
...@@ -140,7 +139,7 @@ public class BgpSessionManager { ...@@ -140,7 +139,7 @@ public class BgpSessionManager {
140 * 139 *
141 * @return the local BGP Identifier as an IPv4 address 140 * @return the local BGP Identifier as an IPv4 address
142 */ 141 */
143 - IpAddress getMyBgpId() { 142 + Ip4Address getMyBgpId() {
144 return myBgpId; 143 return myBgpId;
145 } 144 }
146 145
...@@ -352,7 +351,7 @@ public class BgpSessionManager { ...@@ -352,7 +351,7 @@ public class BgpSessionManager {
352 * @param prefix the prefix of the route 351 * @param prefix the prefix of the route
353 * @return the best route if found, otherwise null 352 * @return the best route if found, otherwise null
354 */ 353 */
355 - private BgpRouteEntry findBestBgpRoute(IpPrefix prefix) { 354 + private BgpRouteEntry findBestBgpRoute(Ip4Prefix prefix) {
356 BgpRouteEntry bestRoute = null; 355 BgpRouteEntry bestRoute = null;
357 356
358 // Iterate across all BGP Sessions and select the best route 357 // Iterate across all BGP Sessions and select the best route
......
...@@ -42,7 +42,9 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -42,7 +42,9 @@ import org.onlab.onos.net.provider.ProviderId;
42 import org.onlab.onos.sdnip.config.Interface; 42 import org.onlab.onos.sdnip.config.Interface;
43 import org.onlab.packet.Ethernet; 43 import org.onlab.packet.Ethernet;
44 import org.onlab.packet.IpAddress; 44 import org.onlab.packet.IpAddress;
45 +import org.onlab.packet.Ip4Address;
45 import org.onlab.packet.IpPrefix; 46 import org.onlab.packet.IpPrefix;
47 +import org.onlab.packet.Ip4Prefix;
46 import org.onlab.packet.MacAddress; 48 import org.onlab.packet.MacAddress;
47 import org.onlab.packet.VlanId; 49 import org.onlab.packet.VlanId;
48 50
...@@ -209,36 +211,36 @@ public class IntentSyncTest { ...@@ -209,36 +211,36 @@ public class IntentSyncTest {
209 // 6. RouteEntry6 was newly added, but the intent was not submitted. 211 // 6. RouteEntry6 was newly added, but the intent was not submitted.
210 // 212 //
211 RouteEntry routeEntry1 = new RouteEntry( 213 RouteEntry routeEntry1 = new RouteEntry(
212 - IpPrefix.valueOf("1.1.1.0/24"), 214 + Ip4Prefix.valueOf("1.1.1.0/24"),
213 - IpAddress.valueOf("192.168.10.1")); 215 + Ip4Address.valueOf("192.168.10.1"));
214 216
215 RouteEntry routeEntry2 = new RouteEntry( 217 RouteEntry routeEntry2 = new RouteEntry(
216 - IpPrefix.valueOf("2.2.2.0/24"), 218 + Ip4Prefix.valueOf("2.2.2.0/24"),
217 - IpAddress.valueOf("192.168.20.1")); 219 + Ip4Address.valueOf("192.168.20.1"));
218 220
219 RouteEntry routeEntry3 = new RouteEntry( 221 RouteEntry routeEntry3 = new RouteEntry(
220 - IpPrefix.valueOf("3.3.3.0/24"), 222 + Ip4Prefix.valueOf("3.3.3.0/24"),
221 - IpAddress.valueOf("192.168.30.1")); 223 + Ip4Address.valueOf("192.168.30.1"));
222 224
223 RouteEntry routeEntry4 = new RouteEntry( 225 RouteEntry routeEntry4 = new RouteEntry(
224 - IpPrefix.valueOf("4.4.4.0/24"), 226 + Ip4Prefix.valueOf("4.4.4.0/24"),
225 - IpAddress.valueOf("192.168.30.1")); 227 + Ip4Address.valueOf("192.168.30.1"));
226 228
227 RouteEntry routeEntry4Update = new RouteEntry( 229 RouteEntry routeEntry4Update = new RouteEntry(
228 - IpPrefix.valueOf("4.4.4.0/24"), 230 + Ip4Prefix.valueOf("4.4.4.0/24"),
229 - IpAddress.valueOf("192.168.20.1")); 231 + Ip4Address.valueOf("192.168.20.1"));
230 232
231 RouteEntry routeEntry5 = new RouteEntry( 233 RouteEntry routeEntry5 = new RouteEntry(
232 - IpPrefix.valueOf("5.5.5.0/24"), 234 + Ip4Prefix.valueOf("5.5.5.0/24"),
233 - IpAddress.valueOf("192.168.10.1")); 235 + Ip4Address.valueOf("192.168.10.1"));
234 236
235 RouteEntry routeEntry6 = new RouteEntry( 237 RouteEntry routeEntry6 = new RouteEntry(
236 - IpPrefix.valueOf("6.6.6.0/24"), 238 + Ip4Prefix.valueOf("6.6.6.0/24"),
237 - IpAddress.valueOf("192.168.10.1")); 239 + Ip4Address.valueOf("192.168.10.1"));
238 240
239 RouteEntry routeEntry7 = new RouteEntry( 241 RouteEntry routeEntry7 = new RouteEntry(
240 - IpPrefix.valueOf("7.7.7.0/24"), 242 + Ip4Prefix.valueOf("7.7.7.0/24"),
241 - IpAddress.valueOf("192.168.10.1")); 243 + Ip4Address.valueOf("192.168.10.1"));
242 244
243 MultiPointToSinglePointIntent intent1 = intentBuilder( 245 MultiPointToSinglePointIntent intent1 = intentBuilder(
244 routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1); 246 routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
...@@ -286,7 +288,7 @@ public class IntentSyncTest { ...@@ -286,7 +288,7 @@ public class IntentSyncTest {
286 routeEntry7); 288 routeEntry7);
287 TestUtils.setField(router, "bgpRoutes", bgpRoutes); 289 TestUtils.setField(router, "bgpRoutes", bgpRoutes);
288 290
289 - ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> 291 + ConcurrentHashMap<Ip4Prefix, MultiPointToSinglePointIntent>
290 pushedRouteIntents = new ConcurrentHashMap<>(); 292 pushedRouteIntents = new ConcurrentHashMap<>();
291 pushedRouteIntents.put(routeEntry1.prefix(), intent1); 293 pushedRouteIntents.put(routeEntry1.prefix(), intent1);
292 pushedRouteIntents.put(routeEntry3.prefix(), intent3); 294 pushedRouteIntents.put(routeEntry3.prefix(), intent3);
...@@ -355,7 +357,7 @@ public class IntentSyncTest { ...@@ -355,7 +357,7 @@ public class IntentSyncTest {
355 * @param egressPoint to which packets should be sent 357 * @param egressPoint to which packets should be sent
356 * @return the constructed MultiPointToSinglePointIntent 358 * @return the constructed MultiPointToSinglePointIntent
357 */ 359 */
358 - private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix, 360 + private MultiPointToSinglePointIntent intentBuilder(Ip4Prefix ipPrefix,
359 String nextHopMacAddress, ConnectPoint egressPoint) { 361 String nextHopMacAddress, ConnectPoint egressPoint) {
360 362
361 TrafficSelector.Builder selectorBuilder = 363 TrafficSelector.Builder selectorBuilder =
......
...@@ -20,8 +20,8 @@ import static org.hamcrest.Matchers.not; ...@@ -20,8 +20,8 @@ import static org.hamcrest.Matchers.not;
20 import static org.junit.Assert.assertThat; 20 import static org.junit.Assert.assertThat;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 -import org.onlab.packet.IpAddress; 23 +import org.onlab.packet.Ip4Address;
24 -import org.onlab.packet.IpPrefix; 24 +import org.onlab.packet.Ip4Prefix;
25 25
26 /** 26 /**
27 * Unit tests for the RouteEntry class. 27 * Unit tests for the RouteEntry class.
...@@ -32,8 +32,8 @@ public class RouteEntryTest { ...@@ -32,8 +32,8 @@ public class RouteEntryTest {
32 */ 32 */
33 @Test 33 @Test
34 public void testConstructor() { 34 public void testConstructor() {
35 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 35 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
36 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 36 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
37 37
38 RouteEntry routeEntry = new RouteEntry(prefix, nextHop); 38 RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
39 assertThat(routeEntry.toString(), 39 assertThat(routeEntry.toString(),
...@@ -45,8 +45,8 @@ public class RouteEntryTest { ...@@ -45,8 +45,8 @@ public class RouteEntryTest {
45 */ 45 */
46 @Test(expected = NullPointerException.class) 46 @Test(expected = NullPointerException.class)
47 public void testInvalidConstructorNullPrefix() { 47 public void testInvalidConstructorNullPrefix() {
48 - IpPrefix prefix = null; 48 + Ip4Prefix prefix = null;
49 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 49 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
50 50
51 new RouteEntry(prefix, nextHop); 51 new RouteEntry(prefix, nextHop);
52 } 52 }
...@@ -56,8 +56,8 @@ public class RouteEntryTest { ...@@ -56,8 +56,8 @@ public class RouteEntryTest {
56 */ 56 */
57 @Test(expected = NullPointerException.class) 57 @Test(expected = NullPointerException.class)
58 public void testInvalidConstructorNullNextHop() { 58 public void testInvalidConstructorNullNextHop() {
59 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 59 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
60 - IpAddress nextHop = null; 60 + Ip4Address nextHop = null;
61 61
62 new RouteEntry(prefix, nextHop); 62 new RouteEntry(prefix, nextHop);
63 } 63 }
...@@ -67,8 +67,8 @@ public class RouteEntryTest { ...@@ -67,8 +67,8 @@ public class RouteEntryTest {
67 */ 67 */
68 @Test 68 @Test
69 public void testGetFields() { 69 public void testGetFields() {
70 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 70 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
71 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 71 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
72 72
73 RouteEntry routeEntry = new RouteEntry(prefix, nextHop); 73 RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
74 assertThat(routeEntry.prefix(), is(prefix)); 74 assertThat(routeEntry.prefix(), is(prefix));
...@@ -80,28 +80,28 @@ public class RouteEntryTest { ...@@ -80,28 +80,28 @@ public class RouteEntryTest {
80 */ 80 */
81 @Test 81 @Test
82 public void testCreateBinaryString() { 82 public void testCreateBinaryString() {
83 - IpPrefix prefix; 83 + Ip4Prefix prefix;
84 84
85 - prefix = IpPrefix.valueOf("0.0.0.0/0"); 85 + prefix = Ip4Prefix.valueOf("0.0.0.0/0");
86 assertThat(RouteEntry.createBinaryString(prefix), is("")); 86 assertThat(RouteEntry.createBinaryString(prefix), is(""));
87 87
88 - prefix = IpPrefix.valueOf("192.168.166.0/22"); 88 + prefix = Ip4Prefix.valueOf("192.168.166.0/22");
89 assertThat(RouteEntry.createBinaryString(prefix), 89 assertThat(RouteEntry.createBinaryString(prefix),
90 is("1100000010101000101001")); 90 is("1100000010101000101001"));
91 91
92 - prefix = IpPrefix.valueOf("192.168.166.0/23"); 92 + prefix = Ip4Prefix.valueOf("192.168.166.0/23");
93 assertThat(RouteEntry.createBinaryString(prefix), 93 assertThat(RouteEntry.createBinaryString(prefix),
94 is("11000000101010001010011")); 94 is("11000000101010001010011"));
95 95
96 - prefix = IpPrefix.valueOf("192.168.166.0/24"); 96 + prefix = Ip4Prefix.valueOf("192.168.166.0/24");
97 assertThat(RouteEntry.createBinaryString(prefix), 97 assertThat(RouteEntry.createBinaryString(prefix),
98 is("110000001010100010100110")); 98 is("110000001010100010100110"));
99 99
100 - prefix = IpPrefix.valueOf("130.162.10.1/25"); 100 + prefix = Ip4Prefix.valueOf("130.162.10.1/25");
101 assertThat(RouteEntry.createBinaryString(prefix), 101 assertThat(RouteEntry.createBinaryString(prefix),
102 is("1000001010100010000010100")); 102 is("1000001010100010000010100"));
103 103
104 - prefix = IpPrefix.valueOf("255.255.255.255/32"); 104 + prefix = Ip4Prefix.valueOf("255.255.255.255/32");
105 assertThat(RouteEntry.createBinaryString(prefix), 105 assertThat(RouteEntry.createBinaryString(prefix),
106 is("11111111111111111111111111111111")); 106 is("11111111111111111111111111111111"));
107 } 107 }
...@@ -111,12 +111,12 @@ public class RouteEntryTest { ...@@ -111,12 +111,12 @@ public class RouteEntryTest {
111 */ 111 */
112 @Test 112 @Test
113 public void testEquality() { 113 public void testEquality() {
114 - IpPrefix prefix1 = IpPrefix.valueOf("1.2.3.0/24"); 114 + Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
115 - IpAddress nextHop1 = IpAddress.valueOf("5.6.7.8"); 115 + Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
116 RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1); 116 RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
117 117
118 - IpPrefix prefix2 = IpPrefix.valueOf("1.2.3.0/24"); 118 + Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/24");
119 - IpAddress nextHop2 = IpAddress.valueOf("5.6.7.8"); 119 + Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
120 RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2); 120 RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
121 121
122 assertThat(routeEntry1, is(routeEntry2)); 122 assertThat(routeEntry1, is(routeEntry2));
...@@ -127,16 +127,16 @@ public class RouteEntryTest { ...@@ -127,16 +127,16 @@ public class RouteEntryTest {
127 */ 127 */
128 @Test 128 @Test
129 public void testNonEquality() { 129 public void testNonEquality() {
130 - IpPrefix prefix1 = IpPrefix.valueOf("1.2.3.0/24"); 130 + Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
131 - IpAddress nextHop1 = IpAddress.valueOf("5.6.7.8"); 131 + Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
132 RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1); 132 RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
133 133
134 - IpPrefix prefix2 = IpPrefix.valueOf("1.2.3.0/25"); // Different 134 + Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/25"); // Different
135 - IpAddress nextHop2 = IpAddress.valueOf("5.6.7.8"); 135 + Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
136 RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2); 136 RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
137 137
138 - IpPrefix prefix3 = IpPrefix.valueOf("1.2.3.0/24"); 138 + Ip4Prefix prefix3 = Ip4Prefix.valueOf("1.2.3.0/24");
139 - IpAddress nextHop3 = IpAddress.valueOf("5.6.7.9"); // Different 139 + Ip4Address nextHop3 = Ip4Address.valueOf("5.6.7.9"); // Different
140 RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3); 140 RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
141 141
142 assertThat(routeEntry1, is(not(routeEntry2))); 142 assertThat(routeEntry1, is(not(routeEntry2)));
...@@ -148,8 +148,8 @@ public class RouteEntryTest { ...@@ -148,8 +148,8 @@ public class RouteEntryTest {
148 */ 148 */
149 @Test 149 @Test
150 public void testToString() { 150 public void testToString() {
151 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 151 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
152 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 152 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
153 RouteEntry routeEntry = new RouteEntry(prefix, nextHop); 153 RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
154 154
155 assertThat(routeEntry.toString(), 155 assertThat(routeEntry.toString(),
......
...@@ -57,7 +57,9 @@ import org.onlab.onos.sdnip.config.Interface; ...@@ -57,7 +57,9 @@ import org.onlab.onos.sdnip.config.Interface;
57 import org.onlab.onos.sdnip.config.SdnIpConfigService; 57 import org.onlab.onos.sdnip.config.SdnIpConfigService;
58 import org.onlab.packet.Ethernet; 58 import org.onlab.packet.Ethernet;
59 import org.onlab.packet.IpAddress; 59 import org.onlab.packet.IpAddress;
60 +import org.onlab.packet.Ip4Address;
60 import org.onlab.packet.IpPrefix; 61 import org.onlab.packet.IpPrefix;
62 +import org.onlab.packet.Ip4Prefix;
61 import org.onlab.packet.MacAddress; 63 import org.onlab.packet.MacAddress;
62 import org.onlab.packet.VlanId; 64 import org.onlab.packet.VlanId;
63 65
...@@ -228,8 +230,8 @@ public class RouterTest { ...@@ -228,8 +230,8 @@ public class RouterTest {
228 public void testProcessRouteAdd() throws TestUtilsException { 230 public void testProcessRouteAdd() throws TestUtilsException {
229 // Construct a route entry 231 // Construct a route entry
230 RouteEntry routeEntry = new RouteEntry( 232 RouteEntry routeEntry = new RouteEntry(
231 - IpPrefix.valueOf("1.1.1.0/24"), 233 + Ip4Prefix.valueOf("1.1.1.0/24"),
232 - IpAddress.valueOf("192.168.10.1")); 234 + Ip4Address.valueOf("192.168.10.1"));
233 235
234 // Construct a MultiPointToSinglePointIntent intent 236 // Construct a MultiPointToSinglePointIntent intent
235 TrafficSelector.Builder selectorBuilder = 237 TrafficSelector.Builder selectorBuilder =
...@@ -281,8 +283,8 @@ public class RouterTest { ...@@ -281,8 +283,8 @@ public class RouterTest {
281 283
282 // Construct the existing route entry 284 // Construct the existing route entry
283 RouteEntry routeEntry = new RouteEntry( 285 RouteEntry routeEntry = new RouteEntry(
284 - IpPrefix.valueOf("1.1.1.0/24"), 286 + Ip4Prefix.valueOf("1.1.1.0/24"),
285 - IpAddress.valueOf("192.168.10.1")); 287 + Ip4Address.valueOf("192.168.10.1"));
286 288
287 // Construct the existing MultiPointToSinglePointIntent intent 289 // Construct the existing MultiPointToSinglePointIntent intent
288 TrafficSelector.Builder selectorBuilder = 290 TrafficSelector.Builder selectorBuilder =
...@@ -305,8 +307,8 @@ public class RouterTest { ...@@ -305,8 +307,8 @@ public class RouterTest {
305 307
306 // Start to construct a new route entry and new intent 308 // Start to construct a new route entry and new intent
307 RouteEntry routeEntryUpdate = new RouteEntry( 309 RouteEntry routeEntryUpdate = new RouteEntry(
308 - IpPrefix.valueOf("1.1.1.0/24"), 310 + Ip4Prefix.valueOf("1.1.1.0/24"),
309 - IpAddress.valueOf("192.168.20.1")); 311 + Ip4Address.valueOf("192.168.20.1"));
310 312
311 // Construct a new MultiPointToSinglePointIntent intent 313 // Construct a new MultiPointToSinglePointIntent intent
312 TrafficSelector.Builder selectorBuilderNew = 314 TrafficSelector.Builder selectorBuilderNew =
...@@ -359,8 +361,8 @@ public class RouterTest { ...@@ -359,8 +361,8 @@ public class RouterTest {
359 361
360 // Construct the existing route entry 362 // Construct the existing route entry
361 RouteEntry routeEntry = new RouteEntry( 363 RouteEntry routeEntry = new RouteEntry(
362 - IpPrefix.valueOf("1.1.1.0/24"), 364 + Ip4Prefix.valueOf("1.1.1.0/24"),
363 - IpAddress.valueOf("192.168.10.1")); 365 + Ip4Address.valueOf("192.168.10.1"));
364 366
365 // Construct the existing MultiPointToSinglePointIntent intent 367 // Construct the existing MultiPointToSinglePointIntent intent
366 TrafficSelector.Builder selectorBuilder = 368 TrafficSelector.Builder selectorBuilder =
...@@ -406,7 +408,8 @@ public class RouterTest { ...@@ -406,7 +408,8 @@ public class RouterTest {
406 public void testLocalRouteAdd() throws TestUtilsException { 408 public void testLocalRouteAdd() throws TestUtilsException {
407 // Construct a route entry, the next hop is the local BGP speaker 409 // Construct a route entry, the next hop is the local BGP speaker
408 RouteEntry routeEntry = new RouteEntry( 410 RouteEntry routeEntry = new RouteEntry(
409 - IpPrefix.valueOf("1.1.1.0/24"), IpAddress.valueOf("0.0.0.0")); 411 + Ip4Prefix.valueOf("1.1.1.0/24"),
412 + Ip4Address.valueOf("0.0.0.0"));
410 413
411 // Reset intentService to check whether the submit method is called 414 // Reset intentService to check whether the submit method is called
412 reset(intentService); 415 reset(intentService);
......
...@@ -58,7 +58,9 @@ import org.onlab.onos.sdnip.config.Interface; ...@@ -58,7 +58,9 @@ import org.onlab.onos.sdnip.config.Interface;
58 import org.onlab.onos.sdnip.config.SdnIpConfigService; 58 import org.onlab.onos.sdnip.config.SdnIpConfigService;
59 import org.onlab.packet.Ethernet; 59 import org.onlab.packet.Ethernet;
60 import org.onlab.packet.IpAddress; 60 import org.onlab.packet.IpAddress;
61 +import org.onlab.packet.Ip4Address;
61 import org.onlab.packet.IpPrefix; 62 import org.onlab.packet.IpPrefix;
63 +import org.onlab.packet.Ip4Prefix;
62 import org.onlab.packet.MacAddress; 64 import org.onlab.packet.MacAddress;
63 import org.onlab.packet.VlanId; 65 import org.onlab.packet.VlanId;
64 66
...@@ -191,8 +193,8 @@ public class RouterTestWithAsyncArp { ...@@ -191,8 +193,8 @@ public class RouterTestWithAsyncArp {
191 193
192 // Construct a route entry 194 // Construct a route entry
193 RouteEntry routeEntry = new RouteEntry( 195 RouteEntry routeEntry = new RouteEntry(
194 - IpPrefix.valueOf("1.1.1.0/24"), 196 + Ip4Prefix.valueOf("1.1.1.0/24"),
195 - IpAddress.valueOf("192.168.10.1")); 197 + Ip4Address.valueOf("192.168.10.1"));
196 198
197 // Construct a route intent 199 // Construct a route intent
198 MultiPointToSinglePointIntent intent = staticIntentBuilder(); 200 MultiPointToSinglePointIntent intent = staticIntentBuilder();
...@@ -243,8 +245,8 @@ public class RouterTestWithAsyncArp { ...@@ -243,8 +245,8 @@ public class RouterTestWithAsyncArp {
243 245
244 // Construct the existing route entry 246 // Construct the existing route entry
245 RouteEntry routeEntry = new RouteEntry( 247 RouteEntry routeEntry = new RouteEntry(
246 - IpPrefix.valueOf("1.1.1.0/24"), 248 + Ip4Prefix.valueOf("1.1.1.0/24"),
247 - IpAddress.valueOf("192.168.10.1")); 249 + Ip4Address.valueOf("192.168.10.1"));
248 250
249 // Construct the existing MultiPointToSinglePointIntent intent 251 // Construct the existing MultiPointToSinglePointIntent intent
250 MultiPointToSinglePointIntent intent = staticIntentBuilder(); 252 MultiPointToSinglePointIntent intent = staticIntentBuilder();
...@@ -256,8 +258,8 @@ public class RouterTestWithAsyncArp { ...@@ -256,8 +258,8 @@ public class RouterTestWithAsyncArp {
256 258
257 // Start to construct a new route entry and new intent 259 // Start to construct a new route entry and new intent
258 RouteEntry routeEntryUpdate = new RouteEntry( 260 RouteEntry routeEntryUpdate = new RouteEntry(
259 - IpPrefix.valueOf("1.1.1.0/24"), 261 + Ip4Prefix.valueOf("1.1.1.0/24"),
260 - IpAddress.valueOf("192.168.20.1")); 262 + Ip4Address.valueOf("192.168.20.1"));
261 263
262 // Construct a new MultiPointToSinglePointIntent intent 264 // Construct a new MultiPointToSinglePointIntent intent
263 TrafficSelector.Builder selectorBuilderNew = 265 TrafficSelector.Builder selectorBuilderNew =
...@@ -323,8 +325,8 @@ public class RouterTestWithAsyncArp { ...@@ -323,8 +325,8 @@ public class RouterTestWithAsyncArp {
323 325
324 // Construct the existing route entry 326 // Construct the existing route entry
325 RouteEntry routeEntry = new RouteEntry( 327 RouteEntry routeEntry = new RouteEntry(
326 - IpPrefix.valueOf("1.1.1.0/24"), 328 + Ip4Prefix.valueOf("1.1.1.0/24"),
327 - IpAddress.valueOf("192.168.10.1")); 329 + Ip4Address.valueOf("192.168.10.1"));
328 330
329 // Construct the existing MultiPointToSinglePointIntent intent 331 // Construct the existing MultiPointToSinglePointIntent intent
330 MultiPointToSinglePointIntent intent = staticIntentBuilder(); 332 MultiPointToSinglePointIntent intent = staticIntentBuilder();
...@@ -401,7 +403,7 @@ public class RouterTestWithAsyncArp { ...@@ -401,7 +403,7 @@ public class RouterTestWithAsyncArp {
401 MultiPointToSinglePointIntent intent) 403 MultiPointToSinglePointIntent intent)
402 throws TestUtilsException { 404 throws TestUtilsException {
403 405
404 - ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent> 406 + ConcurrentHashMap<Ip4Prefix, MultiPointToSinglePointIntent>
405 pushedRouteIntents = new ConcurrentHashMap<>(); 407 pushedRouteIntents = new ConcurrentHashMap<>();
406 pushedRouteIntents.put(routeEntry.prefix(), intent); 408 pushedRouteIntents.put(routeEntry.prefix(), intent);
407 TestUtils.setField(router, "pushedRouteIntents", pushedRouteIntents); 409 TestUtils.setField(router, "pushedRouteIntents", pushedRouteIntents);
......
...@@ -207,7 +207,7 @@ public class SdnIpTest { ...@@ -207,7 +207,7 @@ public class SdnIpTest {
207 reset(intentService); 207 reset(intentService);
208 208
209 for (RouteUpdate update : routeUpdates) { 209 for (RouteUpdate update : routeUpdates) {
210 - IpAddress nextHopAddress = update.routeEntry().nextHop(); 210 + Ip4Address nextHopAddress = update.routeEntry().nextHop();
211 211
212 // Find out the egress ConnectPoint 212 // Find out the egress ConnectPoint
213 ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress); 213 ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress);
...@@ -268,7 +268,7 @@ public class SdnIpTest { ...@@ -268,7 +268,7 @@ public class SdnIpTest {
268 reset(intentService); 268 reset(intentService);
269 269
270 for (RouteUpdate update : routeUpdates) { 270 for (RouteUpdate update : routeUpdates) {
271 - IpAddress nextHopAddress = update.routeEntry().nextHop(); 271 + Ip4Address nextHopAddress = update.routeEntry().nextHop();
272 272
273 // Find out the egress ConnectPoint 273 // Find out the egress ConnectPoint
274 ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress); 274 ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress);
...@@ -342,11 +342,6 @@ public class SdnIpTest { ...@@ -342,11 +342,6 @@ public class SdnIpTest {
342 prefixLength); 342 prefixLength);
343 // We have to ensure we don't generate the same prefix twice 343 // We have to ensure we don't generate the same prefix twice
344 // (this is quite easy to happen with small prefix lengths). 344 // (this is quite easy to happen with small prefix lengths).
345 - // TODO:
346 - // The IpPrefix does the comparison using 32 bits length,
347 - // but we need to compare only the prefix length. So I use
348 - // Ip4Prefix for this moment and changed to IpPrefix. This
349 - // can be improved in the future.
350 } while (prefixes.contains(prefix)); 345 } while (prefixes.contains(prefix));
351 346
352 prefixes.add(prefix); 347 prefixes.add(prefix);
...@@ -368,7 +363,7 @@ public class SdnIpTest { ...@@ -368,7 +363,7 @@ public class SdnIpTest {
368 RouteUpdate update = 363 RouteUpdate update =
369 new RouteUpdate(RouteUpdate.Type.UPDATE, 364 new RouteUpdate(RouteUpdate.Type.UPDATE,
370 new RouteEntry(prefix, 365 new RouteEntry(prefix,
371 - nextHop.ipAddress())); 366 + nextHop.ipAddress().getIp4Address()));
372 367
373 routeUpdates.add(update); 368 routeUpdates.add(update);
374 } 369 }
......
...@@ -26,30 +26,30 @@ import java.util.ArrayList; ...@@ -26,30 +26,30 @@ import java.util.ArrayList;
26 26
27 import org.junit.Before; 27 import org.junit.Before;
28 import org.junit.Test; 28 import org.junit.Test;
29 -import org.onlab.packet.IpAddress; 29 +import org.onlab.packet.Ip4Address;
30 -import org.onlab.packet.IpPrefix; 30 +import org.onlab.packet.Ip4Prefix;
31 31
32 /** 32 /**
33 * Unit tests for the BgpRouteEntry class. 33 * Unit tests for the BgpRouteEntry class.
34 */ 34 */
35 public class BgpRouteEntryTest { 35 public class BgpRouteEntryTest {
36 private BgpSession bgpSession; 36 private BgpSession bgpSession;
37 - private static final IpAddress BGP_SESSION_BGP_ID = 37 + private static final Ip4Address BGP_SESSION_BGP_ID =
38 - IpAddress.valueOf("10.0.0.1"); 38 + Ip4Address.valueOf("10.0.0.1");
39 - private static final IpAddress BGP_SESSION_IP_ADDRESS = 39 + private static final Ip4Address BGP_SESSION_IP_ADDRESS =
40 - IpAddress.valueOf("20.0.0.1"); 40 + Ip4Address.valueOf("20.0.0.1");
41 41
42 private BgpSession bgpSession2; 42 private BgpSession bgpSession2;
43 - private static final IpAddress BGP_SESSION_BGP_ID2 = 43 + private static final Ip4Address BGP_SESSION_BGP_ID2 =
44 - IpAddress.valueOf("10.0.0.2"); 44 + Ip4Address.valueOf("10.0.0.2");
45 - private static final IpAddress BGP_SESSION_IP_ADDRESS2 = 45 + private static final Ip4Address BGP_SESSION_IP_ADDRESS2 =
46 - IpAddress.valueOf("20.0.0.1"); 46 + Ip4Address.valueOf("20.0.0.1");
47 47
48 private BgpSession bgpSession3; 48 private BgpSession bgpSession3;
49 - private static final IpAddress BGP_SESSION_BGP_ID3 = 49 + private static final Ip4Address BGP_SESSION_BGP_ID3 =
50 - IpAddress.valueOf("10.0.0.1"); 50 + Ip4Address.valueOf("10.0.0.1");
51 - private static final IpAddress BGP_SESSION_IP_ADDRESS3 = 51 + private static final Ip4Address BGP_SESSION_IP_ADDRESS3 =
52 - IpAddress.valueOf("20.0.0.2"); 52 + Ip4Address.valueOf("20.0.0.2");
53 53
54 @Before 54 @Before
55 public void setUp() throws Exception { 55 public void setUp() throws Exception {
...@@ -85,8 +85,8 @@ public class BgpRouteEntryTest { ...@@ -85,8 +85,8 @@ public class BgpRouteEntryTest {
85 * @return a generated BGP Route Entry 85 * @return a generated BGP Route Entry
86 */ 86 */
87 private BgpRouteEntry generateBgpRouteEntry() { 87 private BgpRouteEntry generateBgpRouteEntry() {
88 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 88 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
89 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 89 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
90 byte origin = BgpConstants.Update.Origin.IGP; 90 byte origin = BgpConstants.Update.Origin.IGP;
91 // Setup the AS Path 91 // Setup the AS Path
92 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 92 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -143,8 +143,8 @@ public class BgpRouteEntryTest { ...@@ -143,8 +143,8 @@ public class BgpRouteEntryTest {
143 @Test(expected = NullPointerException.class) 143 @Test(expected = NullPointerException.class)
144 public void testInvalidConstructorNullBgpSession() { 144 public void testInvalidConstructorNullBgpSession() {
145 BgpSession bgpSessionNull = null; 145 BgpSession bgpSessionNull = null;
146 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 146 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
147 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 147 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
148 byte origin = BgpConstants.Update.Origin.IGP; 148 byte origin = BgpConstants.Update.Origin.IGP;
149 // Setup the AS Path 149 // Setup the AS Path
150 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 150 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -161,8 +161,8 @@ public class BgpRouteEntryTest { ...@@ -161,8 +161,8 @@ public class BgpRouteEntryTest {
161 */ 161 */
162 @Test(expected = NullPointerException.class) 162 @Test(expected = NullPointerException.class)
163 public void testInvalidConstructorNullAsPath() { 163 public void testInvalidConstructorNullAsPath() {
164 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 164 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
165 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 165 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
166 byte origin = BgpConstants.Update.Origin.IGP; 166 byte origin = BgpConstants.Update.Origin.IGP;
167 BgpRouteEntry.AsPath asPath = null; 167 BgpRouteEntry.AsPath asPath = null;
168 long localPref = 100; 168 long localPref = 100;
...@@ -177,8 +177,8 @@ public class BgpRouteEntryTest { ...@@ -177,8 +177,8 @@ public class BgpRouteEntryTest {
177 @Test 177 @Test
178 public void testGetFields() { 178 public void testGetFields() {
179 // Create the fields to compare against 179 // Create the fields to compare against
180 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 180 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
181 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 181 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
182 byte origin = BgpConstants.Update.Origin.IGP; 182 byte origin = BgpConstants.Update.Origin.IGP;
183 // Setup the AS Path 183 // Setup the AS Path
184 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 184 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -231,8 +231,8 @@ public class BgpRouteEntryTest { ...@@ -231,8 +231,8 @@ public class BgpRouteEntryTest {
231 // 231 //
232 // Test local route with AS Path that begins with AS_SET 232 // Test local route with AS Path that begins with AS_SET
233 // 233 //
234 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 234 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
235 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 235 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
236 byte origin = BgpConstants.Update.Origin.IGP; 236 byte origin = BgpConstants.Update.Origin.IGP;
237 // Setup the AS Path 237 // Setup the AS Path
238 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 238 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -291,8 +291,8 @@ public class BgpRouteEntryTest { ...@@ -291,8 +291,8 @@ public class BgpRouteEntryTest {
291 // 291 //
292 // Get neighbor AS for a local route 292 // Get neighbor AS for a local route
293 // 293 //
294 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 294 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
295 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 295 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
296 byte origin = BgpConstants.Update.Origin.IGP; 296 byte origin = BgpConstants.Update.Origin.IGP;
297 // Setup the AS Path 297 // Setup the AS Path
298 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 298 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -341,8 +341,8 @@ public class BgpRouteEntryTest { ...@@ -341,8 +341,8 @@ public class BgpRouteEntryTest {
341 // 341 //
342 // Compare two routes with different LOCAL_PREF 342 // Compare two routes with different LOCAL_PREF
343 // 343 //
344 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 344 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
345 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 345 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
346 byte origin = BgpConstants.Update.Origin.IGP; 346 byte origin = BgpConstants.Update.Origin.IGP;
347 // Setup the AS Path 347 // Setup the AS Path
348 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 348 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
...@@ -460,8 +460,8 @@ public class BgpRouteEntryTest { ...@@ -460,8 +460,8 @@ public class BgpRouteEntryTest {
460 BgpRouteEntry bgpRouteEntry1 = generateBgpRouteEntry(); 460 BgpRouteEntry bgpRouteEntry1 = generateBgpRouteEntry();
461 461
462 // Setup BGP Route 2 462 // Setup BGP Route 2
463 - IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24"); 463 + Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
464 - IpAddress nextHop = IpAddress.valueOf("5.6.7.8"); 464 + Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
465 byte origin = BgpConstants.Update.Origin.IGP; 465 byte origin = BgpConstants.Update.Origin.IGP;
466 // Setup the AS Path 466 // Setup the AS Path
467 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>(); 467 ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
......
...@@ -45,8 +45,8 @@ import org.onlab.junit.TestUtils; ...@@ -45,8 +45,8 @@ import org.onlab.junit.TestUtils;
45 import org.onlab.junit.TestUtils.TestUtilsException; 45 import org.onlab.junit.TestUtils.TestUtilsException;
46 import org.onlab.onos.sdnip.RouteListener; 46 import org.onlab.onos.sdnip.RouteListener;
47 import org.onlab.onos.sdnip.RouteUpdate; 47 import org.onlab.onos.sdnip.RouteUpdate;
48 -import org.onlab.packet.IpAddress; 48 +import org.onlab.packet.Ip4Address;
49 -import org.onlab.packet.IpPrefix; 49 +import org.onlab.packet.Ip4Prefix;
50 50
51 import com.google.common.net.InetAddresses; 51 import com.google.common.net.InetAddresses;
52 52
...@@ -54,9 +54,10 @@ import com.google.common.net.InetAddresses; ...@@ -54,9 +54,10 @@ import com.google.common.net.InetAddresses;
54 * Unit tests for the BgpSessionManager class. 54 * Unit tests for the BgpSessionManager class.
55 */ 55 */
56 public class BgpSessionManagerTest { 56 public class BgpSessionManagerTest {
57 - private static final IpAddress IP_LOOPBACK_ID = 57 + private static final Ip4Address IP_LOOPBACK_ID =
58 - IpAddress.valueOf("127.0.0.1"); 58 + Ip4Address.valueOf("127.0.0.1");
59 - private static final IpAddress BGP_PEER1_ID = IpAddress.valueOf("10.0.0.1"); 59 + private static final Ip4Address BGP_PEER1_ID =
60 + Ip4Address.valueOf("10.0.0.1");
60 private static final long DEFAULT_LOCAL_PREF = 10; 61 private static final long DEFAULT_LOCAL_PREF = 10;
61 private static final long DEFAULT_MULTI_EXIT_DISC = 20; 62 private static final long DEFAULT_MULTI_EXIT_DISC = 20;
62 63
...@@ -245,7 +246,7 @@ public class BgpSessionManagerTest { ...@@ -245,7 +246,7 @@ public class BgpSessionManagerTest {
245 @Test 246 @Test
246 public void testProcessedBgpUpdateMessages() throws InterruptedException { 247 public void testProcessedBgpUpdateMessages() throws InterruptedException {
247 BgpSession bgpSession; 248 BgpSession bgpSession;
248 - IpAddress nextHopRouter; 249 + Ip4Address nextHopRouter;
249 BgpRouteEntry bgpRouteEntry; 250 BgpRouteEntry bgpRouteEntry;
250 ChannelBuffer message; 251 ChannelBuffer message;
251 Collection<BgpRouteEntry> bgpRibIn; 252 Collection<BgpRouteEntry> bgpRibIn;
...@@ -265,18 +266,18 @@ public class BgpSessionManagerTest { ...@@ -265,18 +266,18 @@ public class BgpSessionManagerTest {
265 bgpSession = bgpSessionManager.getBgpSessions().iterator().next(); 266 bgpSession = bgpSessionManager.getBgpSessions().iterator().next();
266 267
267 // Prepare routes to add/delete 268 // Prepare routes to add/delete
268 - nextHopRouter = IpAddress.valueOf("10.20.30.40"); 269 + nextHopRouter = Ip4Address.valueOf("10.20.30.40");
269 - Collection<IpPrefix> addedRoutes = new LinkedList<>(); 270 + Collection<Ip4Prefix> addedRoutes = new LinkedList<>();
270 - Collection<IpPrefix> withdrawnRoutes = new LinkedList<>(); 271 + Collection<Ip4Prefix> withdrawnRoutes = new LinkedList<>();
271 - addedRoutes.add(IpPrefix.valueOf("0.0.0.0/0")); 272 + addedRoutes.add(Ip4Prefix.valueOf("0.0.0.0/0"));
272 - addedRoutes.add(IpPrefix.valueOf("20.0.0.0/8")); 273 + addedRoutes.add(Ip4Prefix.valueOf("20.0.0.0/8"));
273 - addedRoutes.add(IpPrefix.valueOf("30.0.0.0/16")); 274 + addedRoutes.add(Ip4Prefix.valueOf("30.0.0.0/16"));
274 - addedRoutes.add(IpPrefix.valueOf("40.0.0.0/24")); 275 + addedRoutes.add(Ip4Prefix.valueOf("40.0.0.0/24"));
275 - addedRoutes.add(IpPrefix.valueOf("50.0.0.0/32")); 276 + addedRoutes.add(Ip4Prefix.valueOf("50.0.0.0/32"));
276 - withdrawnRoutes.add(IpPrefix.valueOf("60.0.0.0/8")); 277 + withdrawnRoutes.add(Ip4Prefix.valueOf("60.0.0.0/8"));
277 - withdrawnRoutes.add(IpPrefix.valueOf("70.0.0.0/16")); 278 + withdrawnRoutes.add(Ip4Prefix.valueOf("70.0.0.0/16"));
278 - withdrawnRoutes.add(IpPrefix.valueOf("80.0.0.0/24")); 279 + withdrawnRoutes.add(Ip4Prefix.valueOf("80.0.0.0/24"));
279 - withdrawnRoutes.add(IpPrefix.valueOf("90.0.0.0/32")); 280 + withdrawnRoutes.add(Ip4Prefix.valueOf("90.0.0.0/32"));
280 // Write the routes 281 // Write the routes
281 message = peerChannelHandler.prepareBgpUpdate(nextHopRouter, 282 message = peerChannelHandler.prepareBgpUpdate(nextHopRouter,
282 addedRoutes, 283 addedRoutes,
...@@ -314,7 +315,7 @@ public class BgpSessionManagerTest { ...@@ -314,7 +315,7 @@ public class BgpSessionManagerTest {
314 // 315 //
315 bgpRouteEntry = 316 bgpRouteEntry =
316 new BgpRouteEntry(bgpSession, 317 new BgpRouteEntry(bgpSession,
317 - IpPrefix.valueOf("0.0.0.0/0"), 318 + Ip4Prefix.valueOf("0.0.0.0/0"),
318 nextHopRouter, 319 nextHopRouter,
319 (byte) BgpConstants.Update.Origin.IGP, 320 (byte) BgpConstants.Update.Origin.IGP,
320 asPath, 321 asPath,
...@@ -324,7 +325,7 @@ public class BgpSessionManagerTest { ...@@ -324,7 +325,7 @@ public class BgpSessionManagerTest {
324 // 325 //
325 bgpRouteEntry = 326 bgpRouteEntry =
326 new BgpRouteEntry(bgpSession, 327 new BgpRouteEntry(bgpSession,
327 - IpPrefix.valueOf("20.0.0.0/8"), 328 + Ip4Prefix.valueOf("20.0.0.0/8"),
328 nextHopRouter, 329 nextHopRouter,
329 (byte) BgpConstants.Update.Origin.IGP, 330 (byte) BgpConstants.Update.Origin.IGP,
330 asPath, 331 asPath,
...@@ -334,7 +335,7 @@ public class BgpSessionManagerTest { ...@@ -334,7 +335,7 @@ public class BgpSessionManagerTest {
334 // 335 //
335 bgpRouteEntry = 336 bgpRouteEntry =
336 new BgpRouteEntry(bgpSession, 337 new BgpRouteEntry(bgpSession,
337 - IpPrefix.valueOf("30.0.0.0/16"), 338 + Ip4Prefix.valueOf("30.0.0.0/16"),
338 nextHopRouter, 339 nextHopRouter,
339 (byte) BgpConstants.Update.Origin.IGP, 340 (byte) BgpConstants.Update.Origin.IGP,
340 asPath, 341 asPath,
...@@ -344,7 +345,7 @@ public class BgpSessionManagerTest { ...@@ -344,7 +345,7 @@ public class BgpSessionManagerTest {
344 // 345 //
345 bgpRouteEntry = 346 bgpRouteEntry =
346 new BgpRouteEntry(bgpSession, 347 new BgpRouteEntry(bgpSession,
347 - IpPrefix.valueOf("40.0.0.0/24"), 348 + Ip4Prefix.valueOf("40.0.0.0/24"),
348 nextHopRouter, 349 nextHopRouter,
349 (byte) BgpConstants.Update.Origin.IGP, 350 (byte) BgpConstants.Update.Origin.IGP,
350 asPath, 351 asPath,
...@@ -354,7 +355,7 @@ public class BgpSessionManagerTest { ...@@ -354,7 +355,7 @@ public class BgpSessionManagerTest {
354 // 355 //
355 bgpRouteEntry = 356 bgpRouteEntry =
356 new BgpRouteEntry(bgpSession, 357 new BgpRouteEntry(bgpSession,
357 - IpPrefix.valueOf("50.0.0.0/32"), 358 + Ip4Prefix.valueOf("50.0.0.0/32"),
358 nextHopRouter, 359 nextHopRouter,
359 (byte) BgpConstants.Update.Origin.IGP, 360 (byte) BgpConstants.Update.Origin.IGP,
360 asPath, 361 asPath,
...@@ -365,8 +366,8 @@ public class BgpSessionManagerTest { ...@@ -365,8 +366,8 @@ public class BgpSessionManagerTest {
365 // Delete some routes 366 // Delete some routes
366 addedRoutes = new LinkedList<>(); 367 addedRoutes = new LinkedList<>();
367 withdrawnRoutes = new LinkedList<>(); 368 withdrawnRoutes = new LinkedList<>();
368 - withdrawnRoutes.add(IpPrefix.valueOf("0.0.0.0/0")); 369 + withdrawnRoutes.add(Ip4Prefix.valueOf("0.0.0.0/0"));
369 - withdrawnRoutes.add(IpPrefix.valueOf("50.0.0.0/32")); 370 + withdrawnRoutes.add(Ip4Prefix.valueOf("50.0.0.0/32"));
370 371
371 // Write the routes 372 // Write the routes
372 message = peerChannelHandler.prepareBgpUpdate(nextHopRouter, 373 message = peerChannelHandler.prepareBgpUpdate(nextHopRouter,
...@@ -382,7 +383,7 @@ public class BgpSessionManagerTest { ...@@ -382,7 +383,7 @@ public class BgpSessionManagerTest {
382 // 383 //
383 bgpRouteEntry = 384 bgpRouteEntry =
384 new BgpRouteEntry(bgpSession, 385 new BgpRouteEntry(bgpSession,
385 - IpPrefix.valueOf("20.0.0.0/8"), 386 + Ip4Prefix.valueOf("20.0.0.0/8"),
386 nextHopRouter, 387 nextHopRouter,
387 (byte) BgpConstants.Update.Origin.IGP, 388 (byte) BgpConstants.Update.Origin.IGP,
388 asPath, 389 asPath,
...@@ -392,7 +393,7 @@ public class BgpSessionManagerTest { ...@@ -392,7 +393,7 @@ public class BgpSessionManagerTest {
392 // 393 //
393 bgpRouteEntry = 394 bgpRouteEntry =
394 new BgpRouteEntry(bgpSession, 395 new BgpRouteEntry(bgpSession,
395 - IpPrefix.valueOf("30.0.0.0/16"), 396 + Ip4Prefix.valueOf("30.0.0.0/16"),
396 nextHopRouter, 397 nextHopRouter,
397 (byte) BgpConstants.Update.Origin.IGP, 398 (byte) BgpConstants.Update.Origin.IGP,
398 asPath, 399 asPath,
...@@ -402,7 +403,7 @@ public class BgpSessionManagerTest { ...@@ -402,7 +403,7 @@ public class BgpSessionManagerTest {
402 // 403 //
403 bgpRouteEntry = 404 bgpRouteEntry =
404 new BgpRouteEntry(bgpSession, 405 new BgpRouteEntry(bgpSession,
405 - IpPrefix.valueOf("40.0.0.0/24"), 406 + Ip4Prefix.valueOf("40.0.0.0/24"),
406 nextHopRouter, 407 nextHopRouter,
407 (byte) BgpConstants.Update.Origin.IGP, 408 (byte) BgpConstants.Update.Origin.IGP,
408 asPath, 409 asPath,
......
...@@ -22,8 +22,8 @@ import org.jboss.netty.buffer.ChannelBuffers; ...@@ -22,8 +22,8 @@ import org.jboss.netty.buffer.ChannelBuffers;
22 import org.jboss.netty.channel.ChannelHandlerContext; 22 import org.jboss.netty.channel.ChannelHandlerContext;
23 import org.jboss.netty.channel.ChannelStateEvent; 23 import org.jboss.netty.channel.ChannelStateEvent;
24 import org.jboss.netty.channel.SimpleChannelHandler; 24 import org.jboss.netty.channel.SimpleChannelHandler;
25 -import org.onlab.packet.IpAddress; 25 +import org.onlab.packet.Ip4Address;
26 -import org.onlab.packet.IpPrefix; 26 +import org.onlab.packet.Ip4Prefix;
27 27
28 /** 28 /**
29 * Class for handling the remote BGP Peer session. 29 * Class for handling the remote BGP Peer session.
...@@ -31,7 +31,7 @@ import org.onlab.packet.IpPrefix; ...@@ -31,7 +31,7 @@ import org.onlab.packet.IpPrefix;
31 class TestBgpPeerChannelHandler extends SimpleChannelHandler { 31 class TestBgpPeerChannelHandler extends SimpleChannelHandler {
32 static final long PEER_AS = 65001; 32 static final long PEER_AS = 65001;
33 static final int PEER_HOLDTIME = 120; // 120 seconds 33 static final int PEER_HOLDTIME = 120; // 120 seconds
34 - final IpAddress bgpId; // The BGP ID 34 + final Ip4Address bgpId; // The BGP ID
35 final long localPref; // Local preference for routes 35 final long localPref; // Local preference for routes
36 final long multiExitDisc = 20; // MED value 36 final long multiExitDisc = 20; // MED value
37 37
...@@ -43,8 +43,7 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler { ...@@ -43,8 +43,7 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler {
43 * @param bgpId the BGP ID to use 43 * @param bgpId the BGP ID to use
44 * @param localPref the local preference for the routes to use 44 * @param localPref the local preference for the routes to use
45 */ 45 */
46 - TestBgpPeerChannelHandler(IpAddress bgpId, 46 + TestBgpPeerChannelHandler(Ip4Address bgpId, long localPref) {
47 - long localPref) {
48 this.bgpId = bgpId; 47 this.bgpId = bgpId;
49 this.localPref = localPref; 48 this.localPref = localPref;
50 } 49 }
...@@ -99,9 +98,9 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler { ...@@ -99,9 +98,9 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler {
99 * @param withdrawnRoutes the routes to withdraw 98 * @param withdrawnRoutes the routes to withdraw
100 * @return the message to transmit (BGP header included) 99 * @return the message to transmit (BGP header included)
101 */ 100 */
102 - ChannelBuffer prepareBgpUpdate(IpAddress nextHopRouter, 101 + ChannelBuffer prepareBgpUpdate(Ip4Address nextHopRouter,
103 - Collection<IpPrefix> addedRoutes, 102 + Collection<Ip4Prefix> addedRoutes,
104 - Collection<IpPrefix> withdrawnRoutes) { 103 + Collection<Ip4Prefix> withdrawnRoutes) {
105 int attrFlags; 104 int attrFlags;
106 ChannelBuffer message = 105 ChannelBuffer message =
107 ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH); 106 ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH);
...@@ -178,24 +177,24 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler { ...@@ -178,24 +177,24 @@ class TestBgpPeerChannelHandler extends SimpleChannelHandler {
178 * @param prefixes the prefixes to encode 177 * @param prefixes the prefixes to encode
179 * @return the buffer with the encoded prefixes 178 * @return the buffer with the encoded prefixes
180 */ 179 */
181 - private ChannelBuffer encodePackedPrefixes(Collection<IpPrefix> prefixes) { 180 + private ChannelBuffer encodePackedPrefixes(Collection<Ip4Prefix> prefixes) {
182 ChannelBuffer message = 181 ChannelBuffer message =
183 ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH); 182 ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH);
184 183
185 // Write each of the prefixes 184 // Write each of the prefixes
186 - for (IpPrefix prefix : prefixes) { 185 + for (Ip4Prefix prefix : prefixes) {
187 int prefixBitlen = prefix.prefixLength(); 186 int prefixBitlen = prefix.prefixLength();
188 int prefixBytelen = (prefixBitlen + 7) / 8; // Round-up 187 int prefixBytelen = (prefixBitlen + 7) / 8; // Round-up
189 message.writeByte(prefixBitlen); 188 message.writeByte(prefixBitlen);
190 189
191 - IpAddress address = prefix.address(); 190 + Ip4Address address = prefix.address();
192 long value = address.toInt() & 0xffffffffL; 191 long value = address.toInt() & 0xffffffffL;
193 - for (int i = 0; i < IpAddress.INET_BYTE_LENGTH; i++) { 192 + for (int i = 0; i < Ip4Address.BYTE_LENGTH; i++) {
194 if (prefixBytelen-- == 0) { 193 if (prefixBytelen-- == 0) {
195 break; 194 break;
196 } 195 }
197 long nextByte = 196 long nextByte =
198 - (value >> ((IpAddress.INET_BYTE_LENGTH - i - 1) * 8)) & 0xff; 197 + (value >> ((Ip4Address.BYTE_LENGTH - i - 1) * 8)) & 0xff;
199 message.writeByte((int) nextByte); 198 message.writeByte((int) nextByte);
200 } 199 }
201 } 200 }
......
...@@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffer; ...@@ -21,7 +21,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
21 import org.jboss.netty.channel.Channel; 21 import org.jboss.netty.channel.Channel;
22 import org.jboss.netty.channel.ChannelHandlerContext; 22 import org.jboss.netty.channel.ChannelHandlerContext;
23 import org.jboss.netty.handler.codec.frame.FrameDecoder; 23 import org.jboss.netty.handler.codec.frame.FrameDecoder;
24 -import org.onlab.packet.IpAddress; 24 +import org.onlab.packet.Ip4Address;
25 25
26 /** 26 /**
27 * Class for handling the decoding of the BGP messages at the remote 27 * Class for handling the decoding of the BGP messages at the remote
...@@ -31,7 +31,7 @@ class TestBgpPeerFrameDecoder extends FrameDecoder { ...@@ -31,7 +31,7 @@ class TestBgpPeerFrameDecoder extends FrameDecoder {
31 int remoteBgpVersion; // 1 octet 31 int remoteBgpVersion; // 1 octet
32 long remoteAs; // 2 octets 32 long remoteAs; // 2 octets
33 long remoteHoldtime; // 2 octets 33 long remoteHoldtime; // 2 octets
34 - IpAddress remoteBgpIdentifier; // 4 octets -> IPv4 address 34 + Ip4Address remoteBgpIdentifier; // 4 octets -> IPv4 address
35 35
36 final CountDownLatch receivedOpenMessageLatch = new CountDownLatch(1); 36 final CountDownLatch receivedOpenMessageLatch = new CountDownLatch(1);
37 final CountDownLatch receivedKeepaliveMessageLatch = new CountDownLatch(1); 37 final CountDownLatch receivedKeepaliveMessageLatch = new CountDownLatch(1);
...@@ -144,7 +144,8 @@ class TestBgpPeerFrameDecoder extends FrameDecoder { ...@@ -144,7 +144,8 @@ class TestBgpPeerFrameDecoder extends FrameDecoder {
144 remoteBgpVersion = message.readUnsignedByte(); 144 remoteBgpVersion = message.readUnsignedByte();
145 remoteAs = message.readUnsignedShort(); 145 remoteAs = message.readUnsignedShort();
146 remoteHoldtime = message.readUnsignedShort(); 146 remoteHoldtime = message.readUnsignedShort();
147 - remoteBgpIdentifier = IpAddress.valueOf((int) message.readUnsignedInt()); 147 + remoteBgpIdentifier =
148 + Ip4Address.valueOf((int) message.readUnsignedInt());
148 // Optional Parameters 149 // Optional Parameters
149 int optParamLen = message.readUnsignedByte(); 150 int optParamLen = message.readUnsignedByte();
150 if (message.readableBytes() < optParamLen) { 151 if (message.readableBytes() < optParamLen) {
......