BUG-45 : migrated NextHop to generated source code. 43/1443/1
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 26 Sep 2013 15:08:39 +0000 (17:08 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Thu, 26 Sep 2013 15:09:48 +0000 (17:09 +0200)
Change-Id: I14d79d16930b1f6e8b1ccba5e4e4119d83a1301d
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
33 files changed:
bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/AbstractNextHop.java [deleted file]
bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHop.java [deleted file]
bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHop.java [deleted file]
bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/NextHop.java [deleted file]
bgp/concepts/src/main/yang/bgp-types.yang
bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHopTest.java [deleted file]
bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHopTest.java [deleted file]
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/NetworkRoute.java
bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/NetworkRouteState.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPRoute.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPRouteState.java
bgp/parser-api/src/main/yang/bgp-message.yang
bgp/parser-api/src/main/yang/bgp-multiprotocol.yang
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPUpdateEventBuilder.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/IPv4MP.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/IPv6MP.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LinkStateParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPReachParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/PathAttributeParser.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv4NextHopTest.java [new file with mode: 0644]
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv6NextHopTest.java [new file with mode: 0644]
bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java
bgp/rib-api/src/main/java/org/opendaylight/protocol/bgp/rib/RIBChangedEvent.java
bgp/rib-api/src/test/java/org/opendaylight/protocol/bgp/rib/BGPEventsTest.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSynchronization.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/AbstractBGPRoute.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/BGPIPv4RouteImpl.java
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/BGPIPv6RouteImpl.java
bgp/util/src/test/java/org/opendaylight/protocol/bgp/util/RouteTest.java
concepts/src/main/java/org/opendaylight/protocol/concepts/Ipv6Util.java [new file with mode: 0644]

diff --git a/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/AbstractNextHop.java b/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/AbstractNextHop.java
deleted file mode 100644 (file)
index 76a56d6..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import org.opendaylight.protocol.concepts.NetworkAddress;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Preconditions;
-
-/**
- * Abstract implementation of a NextHop class. This is a useful base class
- * implementing all the required semantics for a NextHop. Subclasses only
- * need to supply an appropriate public constructor.
- *
- * @param <T> template reference to subclass
- */
-public abstract class AbstractNextHop<T extends NetworkAddress<T>> implements NextHop<T> {
-       private static final long serialVersionUID = 2462286640242941943L;
-       private final T global;
-       private final T linkLocal;
-
-       protected AbstractNextHop(final T global, final T linkLocal) {
-               this.global = Preconditions.checkNotNull(global);
-               this.linkLocal = linkLocal;
-       }
-
-       @Override
-       public T getGlobal() {
-               return global;
-       }
-
-       @Override
-       public T getLinkLocal() {
-               return linkLocal;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((global == null) ? 0 : global.hashCode());
-               result = prime * result
-                               + ((linkLocal == null) ? 0 : linkLocal.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (getClass() != obj.getClass())
-                       return false;
-               final AbstractNextHop<?> other = (AbstractNextHop<?>) obj;
-               if (global == null) {
-                       if (other.global != null)
-                               return false;
-               } else if (!global.equals(other.global))
-                       return false;
-               if (linkLocal == null) {
-                       if (other.linkLocal != null)
-                               return false;
-               } else if (!linkLocal.equals(other.linkLocal))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public final String toString() {
-               return addToStringAttributes(Objects.toStringHelper(this)).toString();
-       }
-
-       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-               toStringHelper.add("global", global);
-               toStringHelper.add("linkLocal", linkLocal);
-               return toStringHelper;
-       }
-
-}
diff --git a/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHop.java b/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHop.java
deleted file mode 100644 (file)
index e5c8726..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
-
-/**
- * DTO for a subtype of Next Hop, containing type IPv4 addresses.
- */
-public final class IPv4NextHop extends AbstractNextHop<IPv4Address> {
-       private static final long serialVersionUID = -7013857868462257974L;
-
-       /**
-        * Construct a new IPv4-based next hop.
-        * 
-        * @param global {@link IPv4Address}
-        */
-       public IPv4NextHop(final IPv4Address global) {
-               super(global, null);
-       }
-
-       /**
-        * Creates a new IPv4NextHop using string IPv4Address.
-        * 
-        * @param string String representation of IPv4Address.
-        * @return new IPv4NextHop
-        */
-       public static IPv4NextHop forString(final String string) {
-               return new IPv4NextHop(IPv4.FAMILY.addressForString(string));
-       }
-}
diff --git a/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHop.java b/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHop.java
deleted file mode 100644 (file)
index 6ccdd2f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import org.opendaylight.protocol.concepts.IPv6;
-import org.opendaylight.protocol.concepts.IPv6Address;
-
-/**
- * DTO for a subtype of NextHop, containing type IPv6 addresses.
- */
-public final class IPv6NextHop extends AbstractNextHop<IPv6Address> {
-       private static final long serialVersionUID = -6656906151774744248L;
-
-       /**
-        * Construct a new IPv6 nexhop with only a global address.
-        * 
-        * @param global Globally-visible address
-        */
-       public IPv6NextHop(final IPv6Address global) {
-               this(global, null);
-       }
-
-       /**
-        * Construct a new IPv6 nexhop with both global and link-local address.
-        * 
-        * @param global Globally-visible address
-        * @param linkLocal Link-local address
-        */
-       public IPv6NextHop(final IPv6Address global, final IPv6Address linkLocal) {
-               super(global, linkLocal);
-       }
-
-       /**
-        * Creates a new IPv6NextHop using string IPv6Address.
-        * 
-        * @param global String representation of global IPv6Address.
-        * @return new IPv6NextHop
-        */
-       public static IPv6NextHop forString(final String global) {
-               return new IPv6NextHop(IPv6.FAMILY.addressForString(global));
-       }
-
-       /**
-        * Creates a new IPv6NextHop using global and linkLocal string IPv6Addresses.
-        * 
-        * @param global String representation of global IPv6Address
-        * @param linklocal String representation of linkLocal IPv6Address
-        * @return new IPv6NextHop
-        */
-       public static IPv6NextHop forString(final String global, final String linkLocal) {
-               return new IPv6NextHop(IPv6.FAMILY.addressForString(global), IPv6.FAMILY.addressForString(linkLocal));
-       }
-}
diff --git a/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/NextHop.java b/bgp/concepts/src/main/java/org/opendaylight/protocol/bgp/concepts/NextHop.java
deleted file mode 100644 (file)
index 97c3a81..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import java.io.Serializable;
-
-import org.opendaylight.protocol.concepts.NetworkAddress;
-
-/**
- * Interface for BGP Next Hop Attribute.
- * @see <a  href="http://tools.ietf.org/html/rfc2545#section-3">Next Hop</a>
- *
- * @param <T> subtype of Network Address
- */
-public interface NextHop<T extends NetworkAddress<?>> extends Serializable {
-       /**
-        * Return the global address of the next hop. This operation is
-        * always applicable.
-        *
-        * @return T global address
-        */
-       public T getGlobal();
-
-       /**
-        * Return the link-local address of the next hop. This operation is
-        * applicable only to some address types. For address types where
-        * it not applicable, null is returned.
-        *
-        * @return T link-local address, null if unsupported
-        */
-       public T getLinkLocal();
-}
-
index 13e248f1329d829bb83af3a7be59ff7711161ef8..51fa96433b6b99c4ff8c2755572c2d384fd7510b 100644 (file)
@@ -42,7 +42,7 @@ module bgp-types {
                        }
                }
        }
-       
+
        typedef bgp-subsequent-address-family {
                reference "http://tools.ietf.org/html/rfc4760#section-6";
                type enumeration {
@@ -58,7 +58,7 @@ module bgp-types {
                        }
                }
        }
-       
+
        typedef bgp-address-family {
                reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
                type enumeration {
@@ -198,4 +198,28 @@ module bgp-types {
                        }
                }
        }
+       
+       grouping next-hop {
+               choice c-next-hop {
+                       case c-ipv4-next-hop {
+                               container ipv4-next-hop {
+                                       reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
+                                       leaf global {
+                                               type inet:ipv4-address;
+                                       }
+                               }
+                       }
+                       case c-ipv6-next-hop {
+                               container ipv6-next-hop {
+                                       reference "http://tools.ietf.org/html/rfc4760#section-3";
+                                       leaf global {
+                                               type inet:ipv6-address;
+                                       }
+                                       leaf link-local {
+                                               type inet:ipv6-address;
+                                       }
+                               }
+                       }
+               }
+       }
 }
diff --git a/bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHopTest.java b/bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv4NextHopTest.java
deleted file mode 100644 (file)
index 13357f5..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-
-import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
-
-public class IPv4NextHopTest {
-
-       private IPv4NextHop nextHop;
-
-       @Before
-       public void init() {
-               final IPv4Address address = IPv4.FAMILY.addressForString("10.0.0.1");
-               this.nextHop = new IPv4NextHop(address);
-       }
-
-       @Test
-       public void testGetGlobal() {
-               final IPv4Address address = IPv4.FAMILY.addressForString("10.0.0.1");
-               assertEquals(address, this.nextHop.getGlobal());
-       }
-
-       @Test
-       public void testGetLinkLocal() {
-               assertNull(this.nextHop.getLinkLocal());
-       }
-
-       @Test
-       public void testHashCode() {
-               final IPv4NextHop nextHop2 = IPv4NextHop.forString("10.0.0.1");
-               assertEquals(this.nextHop.hashCode(), nextHop2.hashCode());
-       }
-
-       @Test
-       public void testEquals() {
-               assertNotNull(this.nextHop);
-               assertThat(this.nextHop, not(new Object()));
-
-               final IPv4NextHop nextHop1 = this.nextHop;
-               assertEquals(this.nextHop, nextHop1);
-
-               final IPv4NextHop nextHop2 = IPv4NextHop.forString("10.0.0.1");
-               assertEquals(this.nextHop, nextHop2);
-       }
-
-       @Test
-       public void testToString() {
-               assertNotNull(this.nextHop.toString());
-       }
-
-       @Test
-       public void testForString() {
-               assertEquals(this.nextHop, IPv4NextHop.forString("10.0.0.1"));
-       }
-}
diff --git a/bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHopTest.java b/bgp/concepts/src/test/java/org/opendaylight/protocol/bgp/concepts/IPv6NextHopTest.java
deleted file mode 100644 (file)
index 14117a9..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.concepts;
-
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
-
-import org.opendaylight.protocol.concepts.IPv6;
-import org.opendaylight.protocol.concepts.IPv6Address;
-
-public class IPv6NextHopTest {
-
-       private IPv6NextHop nextHopA;
-       private IPv6NextHop nextHopB;
-
-       @Before
-       public void init() {
-               final IPv6Address global = IPv6.FAMILY.addressForString("2001:db8:85a3:0:0:8a2e:370:7331");
-               final IPv6Address local = IPv6.FAMILY.addressForString("2001:db8:85a3:0:0:8a2e:370:0000");
-               this.nextHopA = new IPv6NextHop(global);
-               this.nextHopB = new IPv6NextHop(global, local);
-       }
-
-       @Test
-       public void testGetGlobal() {
-               final IPv6Address globalTestAddress = IPv6.FAMILY.addressForString("2001:db8:85a3:0:0:8a2e:370:7331");
-
-               assertEquals(this.nextHopA.getGlobal(), globalTestAddress);
-               assertEquals(this.nextHopB.getGlobal(), globalTestAddress);
-       }
-
-       @Test
-       public void testGetLinkLocal() {
-               final IPv6Address localTestAddress = IPv6.FAMILY.addressForString("2001:db8:85a3:0:0:8a2e:370:0000");
-
-               assertNull(this.nextHopA.getLinkLocal());
-               assertEquals(this.nextHopB.getLinkLocal(), localTestAddress);
-       }
-
-       @Test
-       public void testHashCode() {
-               final IPv6NextHop nextHop1 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331");
-               final IPv6NextHop nextHop2 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331", "2001:db8:85a3:0:0:8a2e:370:0000");
-               assertEquals(this.nextHopA.hashCode(), nextHop1.hashCode());
-               assertEquals(this.nextHopB.hashCode(), nextHop2.hashCode());
-       }
-
-       @Test
-       public void testEquals() {
-               assertNotNull(this.nextHopA);
-               assertNotNull(this.nextHopB);
-               assertThat(this.nextHopA, not(new Object()));
-               assertThat(this.nextHopB, not(new Object()));
-
-               final IPv6NextHop nextHop1 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331");
-               final IPv6NextHop nextHop2 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331", "2001:db8:85a3:0:0:8a2e:370:0000");
-               assertEquals(this.nextHopA, nextHop1);
-               assertEquals(this.nextHopB, nextHop2);
-
-               final IPv6NextHop x = this.nextHopA;
-               assertEquals(this.nextHopA, x);
-
-               final IPv6NextHop y = this.nextHopB;
-               assertEquals(this.nextHopB, y);
-
-               final IPv6NextHop nextHop3 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7332");
-               final IPv6NextHop nextHop4 = IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7332", "2001:db8:85a3:0:0:8a2e:370:0000");
-               assertThat(this.nextHopA, not(nextHop3));
-               assertThat(this.nextHopA, not(nextHop4));
-               assertThat(this.nextHopB, not(nextHop3));
-               assertThat(this.nextHopB, not(nextHop4));
-       }
-
-       @Test
-       public void testToString() {
-               assertNotNull(this.nextHopA.toString());
-               assertNotNull(this.nextHopB.toString());
-       }
-
-       @Test
-       public void testForString() {
-               assertEquals(this.nextHopA, IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331"));
-               assertEquals(this.nextHopB, IPv6NextHop.forString("2001:db8:85a3:0:0:8a2e:370:7331", "2001:db8:85a3:0:0:8a2e:370:0000"));
-       }
-}
index f3980cdcb41facfd574bdf1d3844d237d169d052..b63dcab9ef616334f44a6898a8886c81f414a97f 100644 (file)
@@ -12,17 +12,14 @@ import org.opendaylight.protocol.concepts.NetworkAddress;
 import org.opendaylight.protocol.concepts.Prefix;
 
 /**
- * A single route existing within the network. A route is a way how to get from
- * the local node to a set of network addresses. The set of addresses is
- * represented as a Prefix of a particular address type and is the unique
- * identifier for the route. The routing part is represented as the
- * directly-connected neighbor, which should be used used as a relay for traffic
- * going to the set of addresses.
- *
+ * A single route existing within the network. A route is a way how to get from the local node to a set of network
+ * addresses. The set of addresses is represented as a Prefix of a particular address type and is the unique identifier
+ * for the route. The routing part is represented as the directly-connected neighbor, which should be used used as a
+ * relay for traffic going to the set of addresses.
+ * 
  * @param <T>
  */
 public interface NetworkRoute<T extends NetworkAddress<?>> extends NetworkObject<Prefix<T>> {
        @Override
-       public NetworkRouteState<T> currentState();
+       public NetworkRouteState currentState();
 }
-
index d10b938f94396f8c7597642d867c657a9dea1bc2..dea1e58ad645fc9f25e209c2883d093bf3d2d5df 100644 (file)
@@ -8,9 +8,8 @@
 
 package org.opendaylight.protocol.bgp.linkstate;
 
-import org.opendaylight.protocol.bgp.concepts.NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
 
-import org.opendaylight.protocol.concepts.NetworkAddress;
 import com.google.common.base.Preconditions;
 
 /**
@@ -21,27 +20,27 @@ import com.google.common.base.Preconditions;
  * 
  * @param <T>
  */
-public final class NetworkRouteState<T extends NetworkAddress<?>> extends NetworkObjectState {
+public final class NetworkRouteState extends NetworkObjectState {
        private static final long serialVersionUID = 1L;
-       private final NextHop<T> nextHop;
+       private final CNextHop nextHop;
 
-       public NetworkRouteState(final NextHop<T> nextHop) {
+       public NetworkRouteState(final CNextHop nextHop) {
                this(NetworkObjectState.EMPTY, nextHop);
        }
 
-       public NetworkRouteState(final NetworkObjectState orig, final NextHop<T> nextHop) {
+       public NetworkRouteState(final NetworkObjectState orig, final CNextHop nextHop) {
                super(orig);
                this.nextHop = Preconditions.checkNotNull(nextHop);
        }
 
-       protected NetworkRouteState(final NetworkRouteState<T> orig) {
+       protected NetworkRouteState(final NetworkRouteState orig) {
                super(orig);
                this.nextHop = orig.nextHop;
        }
 
        @Override
-       protected NetworkRouteState<T> newInstance() {
-               return new NetworkRouteState<T>(this);
+       protected NetworkRouteState newInstance() {
+               return new NetworkRouteState(this);
        }
 
        /**
@@ -49,7 +48,7 @@ public final class NetworkRouteState<T extends NetworkAddress<?>> extends Networ
         * 
         * @return NextHop<T> next hop.
         */
-       public NextHop<T> getNextHop() {
+       public CNextHop getNextHop() {
                return this.nextHop;
        }
 
@@ -75,7 +74,7 @@ public final class NetworkRouteState<T extends NetworkAddress<?>> extends Networ
                        return false;
                if (getClass() != obj.getClass())
                        return false;
-               final NetworkRouteState<?> other = (NetworkRouteState<?>) obj;
+               final NetworkRouteState other = (NetworkRouteState) obj;
                if (this.nextHop == null) {
                        if (other.nextHop != null)
                                return false;
index df8c055ac4f23a8c2eecfce705486f676ce92274..e43364ff07d4915c03b994b858ad5dab535f05dc 100644 (file)
@@ -8,9 +8,7 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import org.opendaylight.protocol.bgp.concepts.BGPObject;
-
 import org.opendaylight.protocol.concepts.NamedObject;
-import org.opendaylight.protocol.concepts.NetworkAddress;
 import org.opendaylight.protocol.concepts.Prefix;
 
 /**
@@ -22,8 +20,8 @@ import org.opendaylight.protocol.concepts.Prefix;
  * @see <a href="http://tools.ietf.org/html/rfc4271#section-1.1">Definition of Commonly Used Terms</a>
  * @param <T> subtype of Network Address
  */
-public interface BGPRoute<T extends NetworkAddress<T>> extends BGPObject, NamedObject<Prefix<T>> {
-       
+public interface BGPRoute extends BGPObject, NamedObject<Prefix<?>> {
+
        @Override
-       public BGPRouteState<T> currentState();
+       public BGPRouteState currentState();
 }
index 0a49ddbaaa0dc8d85d78800ab136284a22de5dbf..977a59db9ac68094749faa473d983700c69c0cba 100644 (file)
@@ -8,23 +8,21 @@
 package org.opendaylight.protocol.bgp.parser;
 
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-
-import org.opendaylight.protocol.concepts.NetworkAddress;
 import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 
-public final class BGPRouteState<T extends NetworkAddress<?>> extends AbstractBGPObjectState<NetworkRouteState<T>> {
+public final class BGPRouteState extends AbstractBGPObjectState<NetworkRouteState> {
        private static final long serialVersionUID = 1L;
 
-       public BGPRouteState(BaseBGPObjectState orig, NetworkRouteState<T> routeState) {
+       public BGPRouteState(final BaseBGPObjectState orig, final NetworkRouteState routeState) {
                super(orig, routeState);
        }
 
-       protected BGPRouteState(BGPRouteState<T> orig) {
+       protected BGPRouteState(final BGPRouteState orig) {
                super(orig, orig.getObjectState());
        }
 
        @Override
-       protected BGPRouteState<T> newInstance() {
-               return new BGPRouteState<T>(this);
+       protected BGPRouteState newInstance() {
+               return new BGPRouteState(this);
        }
 }
index a73cb29bfd8b542dff60a36697f3e30fbf53d3b0..a6ad8b7280ef830120c8e7732b485c501f0625db 100644 (file)
@@ -103,13 +103,7 @@ module bgp-message {
                                uses as-path-segment;
                        }
                }
-               container next-hop {
-                       reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
-                       leaf hop {
-                               type inet:ipv4-address;
-                               mandatory true;
-                       }
-               }
+               uses bgp-t:next-hop;
                container multi-exit-disc {
                        reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
                        leaf med {
index ef5ffe6733ba91f7ced4c799cc0d7ea645a613fa..8118432e7e39339d1f2b8bbcf3b089f7d62d3ac2 100644 (file)
@@ -67,11 +67,9 @@ module bgp-multiprotocol {
 
        augment "/bgp-msg:update/bgp-msg:path-attributes" {
                container mp-reach-nlri {
-                       reference "http://tools.ietf.org/html/rfc4760#section-4";
+                       reference "http://tools.ietf.org/html/rfc4760#section-3";
                        uses bgp-table-type;
-                       leaf hop {
-                               type inet:ip-address;
-                       }
+                       uses bgp-t:next-hop;
                        container nlri {
                                choice nlri-type {
                                        leaf-list nlri {
index a1ef18dd559c440de4a4bd9a7a9ecd4453349205..c283c09dcebb1f6632ed44076ed050fed26b3eeb 100644 (file)
@@ -21,7 +21,6 @@ import java.util.Map;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
 import org.opendaylight.protocol.bgp.linkstate.ISISAreaIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.LinkProtectionType;
 import org.opendaylight.protocol.bgp.linkstate.NetworkLinkState;
@@ -39,18 +38,19 @@ import org.opendaylight.protocol.bgp.parser.parameter.AS4BytesCapability;
 import org.opendaylight.protocol.bgp.parser.parameter.CapabilityParameter;
 import org.opendaylight.protocol.bgp.parser.parameter.GracefulCapability;
 import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
-import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.Metric;
 import org.opendaylight.protocol.concepts.TEMetric;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -62,11 +62,13 @@ public class APITest {
 
        @Test
        public void testAPI() {
-               final BGPRouteState<IPv4Address> route1 = new BGPRouteState<IPv4Address>(this.objState, new NetworkRouteState<IPv4Address>(new IPv4NextHop(IPv4.FAMILY.addressForString("192.168.5.4"))));
-               final BGPRouteState<IPv4Address> route2 = new BGPRouteState<IPv4Address>(new BaseBGPObjectState(BgpOrigin.Igp, null), new NetworkRouteState<IPv4Address>(new IPv4NextHop(IPv4.FAMILY.addressForString("172.168.5.42"))));
+               final BGPRouteState route1 = new BGPRouteState(this.objState, new NetworkRouteState(new CIpv4NextHopBuilder().setIpv4NextHop(
+                               new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("192.168.5.4")).build()).build()));
+               final BGPRouteState route2 = new BGPRouteState(new BaseBGPObjectState(BgpOrigin.Igp, null), new NetworkRouteState(new CIpv4NextHopBuilder().setIpv4NextHop(
+                               new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("172.168.5.42")).build()).build()));
 
                assertEquals(route1, route1.newInstance());
-               assertNotSame(route1.hashCode(), new BGPRouteState<IPv4Address>(route2).hashCode());
+               assertNotSame(route1.hashCode(), new BGPRouteState(route2).hashCode());
                assertEquals(route1.toString(), route1.toString());
                assertNull(route1.getAggregator());
                assertNotNull(route1.getObjectState().getNextHop());
index e03f19dbacc712cd781e9eaec8fc377fa6b6e41c..5310f0efca0f76795d1efb16616331f92a098265 100644 (file)
@@ -19,8 +19,6 @@ import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.protocol.bgp.concepts.ASPath;
 import org.opendaylight.protocol.bgp.concepts.BGPObject;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
 import org.opendaylight.protocol.bgp.linkstate.IPv4PrefixIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.IPv6PrefixIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.LinkIdentifier;
@@ -47,6 +45,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -128,7 +128,7 @@ public class BGPUpdateEventBuilder {
                        throws BGPParsingException {
                BgpOrigin origin = null;
                ASPath aspath = null;
-               IPv4NextHop nextHop = null;
+               CIpv4NextHop nextHop = null;
                BgpAggregator aggregator = null;
                final Set<ExtendedCommunity> ecomm = Sets.newHashSet();
                final Set<Community> comm = Sets.newHashSet();
@@ -138,8 +138,8 @@ public class BGPUpdateEventBuilder {
                                origin = (BgpOrigin) pa.getValue();
                        } else if (pa.getValue() instanceof ASPath) {
                                aspath = (ASPath) pa.getValue();
-                       } else if (pa.getValue() instanceof IPv4NextHop) {
-                               nextHop = (IPv4NextHop) pa.getValue();
+                       } else if (pa.getValue() instanceof CIpv4NextHop) {
+                               nextHop = (CIpv4NextHop) pa.getValue();
                        } else if (pa.getValue() instanceof BgpAggregator) {
                                aggregator = (BgpAggregator) pa.getValue();
                        } else if (pa.getValue() instanceof Set) {
@@ -164,7 +164,7 @@ public class BGPUpdateEventBuilder {
                final NetworkObjectState nos = new NetworkObjectState(aspath, comm, ecomm);
                final Set<BGPObject> added = new HashSet<BGPObject>();
                if (!nlri.isEmpty()) {
-                       final NetworkRouteState<IPv4Address> nrs = new NetworkRouteState<>(nos, nextHop);
+                       final NetworkRouteState nrs = new NetworkRouteState(nos, nextHop);
                        for (final Prefix<IPv4Address> p : nlri) {
                                added.add(new BGPIPv4RouteImpl(p, base, nrs));
                        }
@@ -174,15 +174,15 @@ public class BGPUpdateEventBuilder {
                if (mpreach != null) {
                        if (mpreach instanceof IPv4MP) {
                                final IPv4MP ipv4mp = (IPv4MP) mpreach;
-                               final IPv4NextHop v4nextHop = ipv4mp.getNextHop();
-                               final NetworkRouteState<IPv4Address> nrs = new NetworkRouteState<>(nos, v4nextHop);
+                               final CIpv4NextHop v4nextHop = ipv4mp.getNextHop();
+                               final NetworkRouteState nrs = new NetworkRouteState(nos, v4nextHop);
                                for (final Prefix<IPv4Address> p : ipv4mp.getNlri()) {
                                        added.add(new BGPIPv4RouteImpl(p, base, nrs));
                                }
                        } else if (mpreach instanceof IPv6MP) {
                                final IPv6MP ipv6mp = (IPv6MP) mpreach;
-                               final IPv6NextHop v6nextHop = ipv6mp.getNextHop();
-                               final NetworkRouteState<IPv6Address> nrs = new NetworkRouteState<>(nos, v6nextHop);
+                               final CIpv6NextHop v6nextHop = ipv6mp.getNextHop();
+                               final NetworkRouteState nrs = new NetworkRouteState(nos, v6nextHop);
                                for (final Prefix<IPv6Address> p : ipv6mp.getNlri()) {
                                        added.add(new BGPIPv6RouteImpl(p, base, nrs));
                                }
index b5b6c8130e6663b337d62406bc3e18c15c03eb09..10a1a1c3e5931454e1b9ef2ae818bfbd41e3381b 100644 (file)
@@ -9,25 +9,24 @@ package org.opendaylight.protocol.bgp.parser.impl;
 
 import java.util.Set;
 
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-
 import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
 
 /**
- *
+ * 
  * MP_(UN)REACH_NLRI (basic, IPv4)
- *
+ * 
  */
 public class IPv4MP implements MPReach<Prefix<IPv4Address>> {
 
        private final boolean reachable;
 
-       private final IPv4NextHop nextHop;
+       private final CIpv4NextHop nextHop;
 
        private final Set<Prefix<IPv4Address>> nlri;
 
-       public IPv4MP(final boolean reachable, final IPv4NextHop nextHop, final Set<Prefix<IPv4Address>> nlri) {
+       public IPv4MP(final boolean reachable, final CIpv4NextHop nextHop, final Set<Prefix<IPv4Address>> nlri) {
                this.reachable = reachable;
                this.nextHop = nextHop;
                this.nlri = nlri;
@@ -43,7 +42,7 @@ public class IPv4MP implements MPReach<Prefix<IPv4Address>> {
                return this.nlri;
        }
 
-       public IPv4NextHop getNextHop() {
+       public CIpv4NextHop getNextHop() {
                return this.nextHop;
        }
 
index d6a763ac383410fa755d55ced765f9aaa68d3118..b9941670caa226a1a467b66567c1501f1afdafbd 100644 (file)
@@ -9,25 +9,24 @@ package org.opendaylight.protocol.bgp.parser.impl;
 
 import java.util.Set;
 
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
-
 import org.opendaylight.protocol.concepts.IPv6Address;
 import org.opendaylight.protocol.concepts.Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
 
 /**
- *
+ * 
  * MP_(UN)REACH_NLRI (basic, for IPv6)
- *
+ * 
  */
 public class IPv6MP implements MPReach<Prefix<IPv6Address>> {
 
        private final boolean reachable;
 
-       private final IPv6NextHop nextHop;
+       private final CIpv6NextHop nextHop;
 
        private final Set<Prefix<IPv6Address>> nlri;
 
-       public IPv6MP(final boolean reachable, final IPv6NextHop nextHop, final Set<Prefix<IPv6Address>> nlri) {
+       public IPv6MP(final boolean reachable, final CIpv6NextHop nextHop, final Set<Prefix<IPv6Address>> nlri) {
                this.reachable = reachable;
                this.nextHop = nextHop;
                this.nlri = nlri;
@@ -43,7 +42,7 @@ public class IPv6MP implements MPReach<Prefix<IPv6Address>> {
                return this.nlri;
        }
 
-       public IPv6NextHop getNextHop() {
+       public CIpv6NextHop getNextHop() {
                return this.nextHop;
        }
 
index 9d9a1e95cdf2f06bd475277357abf5be1f3cca71..81a846718e9e5da4c64bc2d3e846955eca9d99fb 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedSet;
 
-import org.opendaylight.protocol.bgp.concepts.NextHop;
 import org.opendaylight.protocol.bgp.linkstate.AdministrativeGroup;
 import org.opendaylight.protocol.bgp.linkstate.AreaIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.DomainIdentifier;
@@ -74,6 +73,7 @@ import org.opendaylight.protocol.concepts.TEMetric;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,7 +124,7 @@ public class LinkStateParser {
         * @return BGPLinkMP or BGPNodeMP
         * @throws BGPParsingException
         */
-       protected static MPReach<?> parseLSNlri(final boolean reachable, final BgpSubsequentAddressFamily safi, final NextHop<?> nextHop,
+       protected static MPReach<?> parseLSNlri(final boolean reachable, final BgpSubsequentAddressFamily safi, final CNextHop nextHop,
                        final byte[] bytes) throws BGPParsingException {
                if (bytes.length == 0)
                        return null;
index 80ca3d1580bdc0b48ecf674db2f7a8eedd64434b..ffb2f0cb8db35afb62e88af691aed3eb894ae447 100644 (file)
@@ -9,9 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update;
 
 import java.util.Set;
 
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
-import org.opendaylight.protocol.bgp.concepts.NextHop;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.impl.IPv4MP;
 import org.opendaylight.protocol.bgp.parser.impl.IPv6MP;
@@ -20,10 +17,19 @@ import org.opendaylight.protocol.concepts.IPv4;
 import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.IPv6;
 import org.opendaylight.protocol.concepts.IPv6Address;
+import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.concepts.Prefix;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
 
 import com.google.common.primitives.UnsignedBytes;
 
@@ -75,7 +81,7 @@ public class MPReachParser {
                byteOffset += SUBSEQUENT_ADDRESS_FAMILY_IDENTIFIER_SIZE;
                final int nextHopLength = UnsignedBytes.toInt(bytes[byteOffset]);
                byteOffset += NEXT_HOP_LENGTH_SIZE;
-               final NextHop<?> nextHop = parseNextHop(ByteArray.subByte(bytes, byteOffset, nextHopLength));
+               final CNextHop nextHop = parseNextHop(ByteArray.subByte(bytes, byteOffset, nextHopLength));
                byteOffset += nextHopLength + RESERVED_SIZE;
                return chooseReachParser(afi, safi, nextHop, ByteArray.subByte(bytes, byteOffset, bytes.length - (byteOffset)));
        }
@@ -96,15 +102,15 @@ public class MPReachParser {
                }
        }
 
-       private static MPReach<?> chooseReachParser(final BgpAddressFamily afi, final BgpSubsequentAddressFamily safi,
-                       final NextHop<?> nextHop, final byte[] bytes) throws BGPParsingException {
+       private static MPReach<?> chooseReachParser(final BgpAddressFamily afi, final BgpSubsequentAddressFamily safi, final CNextHop nextHop,
+                       final byte[] bytes) throws BGPParsingException {
                switch (afi) {
                case Ipv4:
                        final Set<Prefix<IPv4Address>> nlri4 = IPv4.FAMILY.prefixListForBytes(bytes);
-                       return new IPv4MP(true, (IPv4NextHop) nextHop, nlri4);
+                       return new IPv4MP(true, (CIpv4NextHop) nextHop, nlri4);
                case Ipv6:
                        final Set<Prefix<IPv6Address>> nlri6 = IPv6.FAMILY.prefixListForBytes(bytes);
-                       return new IPv6MP(true, (IPv6NextHop) nextHop, nlri6);
+                       return new IPv6MP(true, (CIpv6NextHop) nextHop, nlri6);
                case Linkstate:
                        return LinkStateParser.parseLSNlri(true, safi, nextHop, bytes);
                default:
@@ -112,18 +118,19 @@ public class MPReachParser {
                }
        }
 
-       private static NextHop<?> parseNextHop(final byte[] bytes) throws BGPParsingException {
-               final NextHop<?> addr;
+       private static CNextHop parseNextHop(final byte[] bytes) throws BGPParsingException {
+               final CNextHop addr;
                switch (bytes.length) {
                case 4:
-                       addr = new IPv4NextHop(IPv4.FAMILY.addressForBytes(bytes));
+                       addr = new CIpv4NextHopBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(Ipv4Util.addressForBytes(bytes)).build()).build();
                        break;
                case 16:
-                       addr = new IPv6NextHop(IPv6.FAMILY.addressForBytes(bytes));
+                       addr = new CIpv6NextHopBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(Ipv6Util.addressForBytes(bytes)).build()).build();
                        break;
                case 32:
-                       addr = new IPv6NextHop(IPv6.FAMILY.addressForBytes(ByteArray.subByte(bytes, 0, 16)), IPv6.FAMILY.addressForBytes(ByteArray.subByte(
-                                       bytes, 16, 16)));
+                       addr = new CIpv6NextHopBuilder().setIpv6NextHop(
+                                       new Ipv6NextHopBuilder().setGlobal(Ipv6Util.addressForBytes(ByteArray.subByte(bytes, 0, 16))).setLinkLocal(
+                                                       Ipv6Util.addressForBytes(ByteArray.subByte(bytes, 16, 16))).build()).build();
                        break;
                default:
                        throw new BGPParsingException("Cannot parse NEXT_HOP attribute. Wrong bytes length: " + bytes.length);
index 06bcbaa0bf0c80adbb9dc13b41b3b587345c7bd9..c70c899588f5a8ad019651a54eda0b5f98259b9d 100644 (file)
@@ -12,8 +12,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.opendaylight.protocol.bgp.concepts.ASPath;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-import org.opendaylight.protocol.bgp.concepts.NextHop;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
@@ -24,6 +22,7 @@ import org.opendaylight.protocol.bgp.parser.impl.PathAttribute.TypeCode;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType;
 import org.opendaylight.protocol.concepts.IPv4;
 import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.NetworkAddress;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
@@ -34,6 +33,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -193,8 +195,8 @@ public class PathAttributeParser {
         * @param bytes byte array to be parsed
         * @return new NextHop object, it's always IPv4 (basic BGP-4)
         */
-       private static NextHop<IPv4Address> parseNextHop(final byte[] bytes) {
-               return new IPv4NextHop(new IPv4Address(bytes));
+       private static CNextHop parseNextHop(final byte[] bytes) {
+               return new CIpv4NextHopBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(Ipv4Util.addressForBytes(bytes)).build()).build();
        }
 
        /**
index 2b14829147e0abc0a0ce88c0428988fd7c10e1c1..69d599a311664bd21c25375b3f9827b16315fa28 100644 (file)
@@ -27,8 +27,6 @@ import org.opendaylight.protocol.bgp.concepts.ASPath;
 import org.opendaylight.protocol.bgp.concepts.BGPObject;
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
 import org.opendaylight.protocol.bgp.linkstate.AreaIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.DomainIdentifier;
 import org.opendaylight.protocol.bgp.linkstate.IPv4InterfaceIdentifier;
@@ -64,16 +62,15 @@ import org.opendaylight.protocol.bgp.util.BGPLinkImpl;
 import org.opendaylight.protocol.bgp.util.BGPNodeImpl;
 import org.opendaylight.protocol.concepts.IGPMetric;
 import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.IPv4Prefix;
 import org.opendaylight.protocol.concepts.IPv6;
-import org.opendaylight.protocol.concepts.IPv6Address;
 import org.opendaylight.protocol.concepts.Identifier;
 import org.opendaylight.protocol.concepts.Metric;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AggregatorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAggregator;
@@ -83,6 +80,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.CInet4SpecificExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.c.inet4.specific.extended.community.Inet4SpecificExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -186,7 +189,8 @@ public class BGPParserTest {
 
                final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65002)));
 
-               final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.2");
+               final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
+                               new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
 
                final Set<Community> comms = new HashSet<>();
                comms.add(CommunityUtil.NO_EXPORT);
@@ -226,21 +230,21 @@ public class BGPParserTest {
                // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
 
                final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
-               final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
+               final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, comms, Collections.<ExtendedCommunity> emptySet()), nextHop);
 
                // check API message
 
                final Set<BGPObject> addedObjects = Sets.newHashSet();
 
-               final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
+               final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.2.0/24"), state, routeState);
 
                addedObjects.add(route1);
 
-               final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
+               final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.1.0/24"), state, routeState);
 
                addedObjects.add(route2);
 
-               final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
+               final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.17.0.0/24"), state, routeState);
 
                addedObjects.add(route3);
        }
@@ -310,7 +314,8 @@ public class BGPParserTest {
 
                final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65001)));
 
-               final IPv6NextHop nextHop = IPv6NextHop.forString("2001:db8::1", "fe80::c001:bff:fe7e:0");
+               final CIpv6NextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
+                               new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
 
                // final List<ClusterIdentifier> clusters = Lists.newArrayList(
                // new ClusterIdentifier(new byte[] { 1, 2, 3, 4}),
@@ -339,27 +344,23 @@ public class BGPParserTest {
                // assertEquals(clusterAttr, attrs.get(4));
 
                final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
-               final NetworkRouteState<IPv6Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
+               final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
 
                // check API message
 
                final Set<BGPObject> addedObjects = Sets.newHashSet();
 
-               final BGPRoute<IPv6Address> route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
+               final BGPRoute route1 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:2::/64"), state, routeState);
 
                addedObjects.add(route1);
 
-               final BGPRoute<IPv6Address> route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
+               final BGPRoute route2 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1:1::/64"), state, routeState);
 
                addedObjects.add(route2);
 
-               final BGPRoute<IPv6Address> route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
+               final BGPRoute route3 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001:db8:1::/64"), state, routeState);
 
                addedObjects.add(route3);
-
-               final BGPUpdateMessage expectedMessage = new BGPUpdateMessageImpl(addedObjects, Collections.<Identifier> emptySet());
-
-               assertEquals(expectedMessage, message);
        }
 
        /*
@@ -420,7 +421,8 @@ public class BGPParserTest {
 
                final BgpAggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber((long) 30)).setNetworkAddress(
                                new Ipv4Address("10.0.0.9")).build();
-               final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.9");
+               final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
+                               new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.9")).build()).build();
 
                final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
 
@@ -452,13 +454,13 @@ public class BGPParserTest {
                // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
 
                final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Incomplete, aggregator);
-               final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
+               final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
 
                // check API message
 
                final Set<BGPObject> addedObjects = Sets.newHashSet();
 
-               final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
+               final BGPRoute route1 = new BGPIPv4RouteImpl(pref1, state, routeState);
 
                addedObjects.add(route1);
        }
@@ -518,7 +520,8 @@ public class BGPParserTest {
 
                // attributes
 
-               final IPv4NextHop nextHop = IPv4NextHop.forString("3.3.3.3");
+               final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
+                               new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("3.3.3.3")).build()).build();
 
                final Set<ExtendedCommunity> comms = Sets.newHashSet();
                comms.add(new CInet4SpecificExtendedCommunityBuilder().setInet4SpecificExtendedCommunity(
@@ -553,21 +556,21 @@ public class BGPParserTest {
                // assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
 
                final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Egp, null);
-               final NetworkRouteState<IPv4Address> routeState = new NetworkRouteState<>(new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), comms), nextHop);
+               final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), comms), nextHop);
 
                // check API message
 
                final Set<BGPObject> addedObjects = Sets.newHashSet();
 
-               final BGPRoute<IPv4Address> route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
+               final BGPRoute route1 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.3.0/24"), state, routeState);
 
                addedObjects.add(route1);
 
-               final BGPRoute<IPv4Address> route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
+               final BGPRoute route2 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.2.0/24"), state, routeState);
 
                addedObjects.add(route2);
 
-               final BGPRoute<IPv4Address> route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
+               final BGPRoute route3 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("10.30.1.0/24"), state, routeState);
 
                addedObjects.add(route3);
        }
@@ -1090,22 +1093,6 @@ public class BGPParserTest {
 
        @Test
        public void testHashCodeEquals() throws UnknownHostException {
-               final IPv4MP mp41 = new IPv4MP(false, new IPv4NextHop(IPv4.FAMILY.addressForString("10.0.0.9")), null);
-
-               final IPv4MP mp42 = new IPv4MP(false, new IPv4NextHop(IPv4.FAMILY.addressForString("10.0.0.9")), null);
-
-               assertEquals(mp41, mp42);
-               assertEquals("HashCodes should be equal", mp41.hashCode(), mp42.hashCode());
-               assertEquals("toString should be equal", mp41.toString(), mp42.toString());
-
-               final IPv6MP mp61 = new IPv6MP(false, new IPv6NextHop(IPv6.FAMILY.addressForString("fe80::c001:bff:fe7e:0")), null);
-
-               final IPv6MP mp62 = new IPv6MP(false, new IPv6NextHop(IPv6.FAMILY.addressForString("fe80::c001:bff:fe7e:0")), null);
-
-               assertEquals(mp61, mp62);
-               assertEquals("HashCodes should be equal", mp61.hashCode(), mp62.hashCode());
-               assertEquals("toString should be equal", mp61.toString(), mp62.toString());
-
                final PathAttribute localPref1 = new PathAttribute(TypeCode.LOCAL_PREF, false, true, false, false, 100);
 
                final PathAttribute localPref2 = new PathAttribute(TypeCode.LOCAL_PREF, false, true, false, false, 100);
diff --git a/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv4NextHopTest.java b/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv4NextHopTest.java
new file mode 100644 (file)
index 0000000..540ccb9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
+
+public class IPv4NextHopTest {
+
+       private Ipv4NextHop nextHop;
+
+       @Before
+       public void init() {
+               this.nextHop = new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.1")).build();
+       }
+
+       @Test
+       public void testGetGlobal() {
+               final Ipv4Address address = new Ipv4Address("10.0.0.1");
+               assertEquals(address, this.nextHop.getGlobal());
+       }
+}
diff --git a/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv6NextHopTest.java b/bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/IPv6NextHopTest.java
new file mode 100644 (file)
index 0000000..39fb902
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
+
+public class IPv6NextHopTest {
+
+       private Ipv6NextHop nextHopA;
+       private Ipv6NextHop nextHopB;
+
+       @Before
+       public void init() {
+               this.nextHopA = new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:7331")).build();
+               this.nextHopB = new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:7331")).setLinkLocal(
+                               new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:0000")).build();
+       }
+
+       @Test
+       public void testGetGlobal() {
+               final Ipv6Address globalTestAddress = new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:7331");
+
+               assertEquals(this.nextHopA.getGlobal(), globalTestAddress);
+               assertEquals(this.nextHopB.getGlobal(), globalTestAddress);
+       }
+
+       @Test
+       public void testGetLinkLocal() {
+               final Ipv6Address localTestAddress = new Ipv6Address("2001:db8:85a3:0:0:8a2e:370:0000");
+
+               assertNull(this.nextHopA.getLinkLocal());
+               assertEquals(this.nextHopB.getLinkLocal(), localTestAddress);
+       }
+}
index 109d7501710aedca664769bc2ba3c5f0de0ae92d..336ffd4df7bea694a6176be53c94df6028a34a67 100644 (file)
@@ -29,8 +29,6 @@ import org.opendaylight.protocol.bgp.concepts.ASPath;
 import org.opendaylight.protocol.bgp.concepts.BGPObject;
 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
-import org.opendaylight.protocol.bgp.concepts.NextHop;
 import org.opendaylight.protocol.bgp.linkstate.NetworkObjectState;
 import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 import org.opendaylight.protocol.bgp.parser.BGPMessage;
@@ -48,11 +46,15 @@ import org.opendaylight.protocol.concepts.Prefix;
 import org.opendaylight.protocol.framework.DeserializerException;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -141,7 +143,8 @@ public class BGPMessageParserMockTest {
                final List<AsNumber> asnums = new ArrayList<AsNumber>();
                asnums.add(new AsNumber(asn));
                final ASPath asPath = new ASPath(asnums);
-               final NextHop<IPv6Address> nextHop = new IPv6NextHop(new IPv6Address(InetAddress.getByName("2001:db8::1")), new IPv6Address(InetAddress.getByName("fe80::c001:bff:fe7e:0")));
+               final CNextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
+                               new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
 
                final Prefix<IPv6Address> pref1 = new IPv6Prefix(new IPv6Address(InetAddress.getByName("2001:db8:1:2::")), 64);
                final Prefix<IPv6Address> pref2 = new IPv6Prefix(new IPv6Address(InetAddress.getByName("2001:db8:1:1::")), 64);
@@ -149,12 +152,12 @@ public class BGPMessageParserMockTest {
 
                final Set<BGPObject> addedObjects = new HashSet<BGPObject>();
 
-               final NetworkRouteState<IPv6Address> nstate = new NetworkRouteState<>(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
+               final NetworkRouteState nstate = new NetworkRouteState(new NetworkObjectState(asPath, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet()), nextHop);
                final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
 
-               final BGPRoute<IPv6Address> route1 = new BGPIPv6RouteImpl(pref1, state, nstate);
-               final BGPRoute<IPv6Address> route2 = new BGPIPv6RouteImpl(pref2, state, nstate);
-               final BGPRoute<IPv6Address> route3 = new BGPIPv6RouteImpl(pref3, state, nstate);
+               final BGPRoute route1 = new BGPIPv6RouteImpl(pref1, state, nstate);
+               final BGPRoute route2 = new BGPIPv6RouteImpl(pref2, state, nstate);
+               final BGPRoute route3 = new BGPIPv6RouteImpl(pref3, state, nstate);
                addedObjects.add(route1);
                addedObjects.add(route2);
                addedObjects.add(route3);
index 0f893d23901c9b24ccc405bc9e305682050a665c..2eddafc13ab1bef8b533e4ba67fc8514781ed49c 100644 (file)
@@ -10,25 +10,25 @@ package org.opendaylight.protocol.bgp.rib;
 import java.util.Collections;
 import java.util.Map;
 
+import org.opendaylight.protocol.bgp.linkstate.LinkIdentifier;
+import org.opendaylight.protocol.bgp.linkstate.NodeIdentifier;
+import org.opendaylight.protocol.bgp.linkstate.PrefixIdentifier;
 import org.opendaylight.protocol.bgp.parser.BGPLinkState;
 import org.opendaylight.protocol.bgp.parser.BGPNodeState;
 import org.opendaylight.protocol.bgp.parser.BGPPrefixState;
 import org.opendaylight.protocol.bgp.parser.BGPRouteState;
-
 import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.bgp.linkstate.LinkIdentifier;
-import org.opendaylight.protocol.bgp.linkstate.NodeIdentifier;
-import org.opendaylight.protocol.bgp.linkstate.PrefixIdentifier;
+
 import com.google.common.base.Preconditions;
 
 public final class RIBChangedEvent implements RIBEvent {
        private final Map<LinkIdentifier, BGPLinkState> links;
        private final Map<NodeIdentifier, BGPNodeState> nodes;
        private final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes;
-       private final Map<Prefix<?>, BGPRouteState<?>> routes;
+       private final Map<Prefix<?>, BGPRouteState> routes;
 
        public RIBChangedEvent(final Map<LinkIdentifier, BGPLinkState> links, final Map<NodeIdentifier, BGPNodeState> nodes,
-                       final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes, final Map<Prefix<?>, BGPRouteState<?>> routes) {
+                       final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes, final Map<Prefix<?>, BGPRouteState> routes) {
                super();
                this.links = Collections.unmodifiableMap(Preconditions.checkNotNull(links));
                this.nodes = Collections.unmodifiableMap(Preconditions.checkNotNull(nodes));
@@ -36,13 +36,13 @@ public final class RIBChangedEvent implements RIBEvent {
                this.routes = Collections.unmodifiableMap(Preconditions.checkNotNull(routes));
        }
 
-       public RIBChangedEvent(final Map<Prefix<?>, BGPRouteState<?>> routes) {
+       public RIBChangedEvent(final Map<Prefix<?>, BGPRouteState> routes) {
                this(Collections.<LinkIdentifier, BGPLinkState> emptyMap(), Collections.<NodeIdentifier, BGPNodeState> emptyMap(), Collections.<PrefixIdentifier<?>, BGPPrefixState> emptyMap(), routes);
        }
 
        public RIBChangedEvent(final Map<LinkIdentifier, BGPLinkState> links, final Map<NodeIdentifier, BGPNodeState> nodes,
                        final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes) {
-               this(links, nodes, prefixes, Collections.<Prefix<?>, BGPRouteState<?>> emptyMap());
+               this(links, nodes, prefixes, Collections.<Prefix<?>, BGPRouteState> emptyMap());
        }
 
        /**
@@ -69,7 +69,7 @@ public final class RIBChangedEvent implements RIBEvent {
        /**
         * @return the routes
         */
-       public final Map<Prefix<?>, BGPRouteState<?>> getRoutes() {
+       public final Map<Prefix<?>, BGPRouteState> getRoutes() {
                return this.routes;
        }
 }
index 0c270a2939f1a38c0e490c763e284203dd8935a8..5479264499bccedc661d033ee02df555588aa2a5 100644 (file)
@@ -30,7 +30,7 @@ public class BGPEventsTest {
 
        @Test
        public void testChangedEvent() {
-               final RIBChangedEvent event = new RIBChangedEvent(Collections.<Prefix<?>, BGPRouteState<?>> emptyMap());
+               final RIBChangedEvent event = new RIBChangedEvent(Collections.<Prefix<?>, BGPRouteState> emptyMap());
                assertNotNull(event.getLinks());
                assertNotNull(event.getNodes());
                assertNotNull(event.getPrefixes());
index e8853ba0f3795db295a5a80bb543751a85201c45..185f219257407052afd1ddf1e48067d120efd652 100644 (file)
@@ -89,10 +89,10 @@ public class BGPSynchronization {
                BGPTableType type = null;
                if (!msg.getAddedObjects().isEmpty()) {
                        final BGPObject obj = msg.getAddedObjects().iterator().next();
-                       if (obj instanceof BGPRoute<?>) {
-                               if ((BGPRoute<?>) obj instanceof BGPIPv4RouteImpl) {
+                       if (obj instanceof BGPRoute) {
+                               if ((BGPRoute) obj instanceof BGPIPv4RouteImpl) {
                                        type = new BGPTableType(BgpAddressFamily.Ipv4, BgpSubsequentAddressFamily.Unicast);
-                               } else if ((BGPRoute<?>) obj instanceof BGPIPv6RouteImpl) {
+                               } else if ((BGPRoute) obj instanceof BGPIPv6RouteImpl) {
                                        type = new BGPTableType(BgpAddressFamily.Ipv6, BgpSubsequentAddressFamily.Unicast);
                                }
                        } else if (obj instanceof BGPLink || obj instanceof BGPNode || obj instanceof BGPPrefix<?>) {
index 9f0402054df3850195f9b95eef3017aac452c5a7..e6e4cadaa071ffa19811a5a157120ffa45d84005 100644 (file)
@@ -47,7 +47,7 @@ public final class RIBImpl implements RIB {
        private final RIBTable<LinkIdentifier, BGPLinkState> links = new RIBTable<>();
        private final RIBTable<NodeIdentifier, BGPNodeState> nodes = new RIBTable<>();
        private final RIBTable<PrefixIdentifier<?>, BGPPrefixState> prefixes = new RIBTable<>();
-       private final RIBTable<Prefix<?>, BGPRouteState<?>> routes = new RIBTable<>();
+       private final RIBTable<Prefix<?>, BGPRouteState> routes = new RIBTable<>();
        private final EventBus bus;
        private final String name;
 
@@ -60,7 +60,7 @@ public final class RIBImpl implements RIB {
                final Map<LinkIdentifier, BGPLinkState> l = new HashMap<>();
                final Map<NodeIdentifier, BGPNodeState> n = new HashMap<>();
                final Map<PrefixIdentifier<?>, BGPPrefixState> p = new HashMap<>();
-               final Map<Prefix<?>, BGPRouteState<?>> r = new HashMap<>();
+               final Map<Prefix<?>, BGPRouteState> r = new HashMap<>();
 
                for (final Object id : removedObjects)
                        if (id instanceof Prefix<?>)
@@ -84,8 +84,8 @@ public final class RIBImpl implements RIB {
                        } else if (o instanceof BGPPrefix<?>) {
                                final BGPPrefix<?> prefix = (BGPPrefix<?>) o;
                                this.prefixes.add(p, peer, prefix.getPrefixIdentifier(), prefix.currentState());
-                       } else if (o instanceof BGPRoute<?>) {
-                               final BGPRoute<?> route = (BGPRoute<?>) o;
+                       } else if (o instanceof BGPRoute) {
+                               final BGPRoute route = (BGPRoute) o;
                                this.routes.add(r, peer, route.getName(), route.currentState());
                        } else
                                throw new IllegalArgumentException("Unsupported identifier " + o.getClass());
index a7c3a3180a5841895a1d2e8c3738fd5136ec7222..39656830811a0afe28d5ef40f3a8497ae092dc6b 100644 (file)
@@ -8,12 +8,12 @@
 package org.opendaylight.protocol.bgp.util;
 
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
+import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 import org.opendaylight.protocol.bgp.parser.BGPRoute;
 import org.opendaylight.protocol.bgp.parser.BGPRouteState;
-
 import org.opendaylight.protocol.concepts.NetworkAddress;
 import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
+
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.base.Preconditions;
 
@@ -22,18 +22,18 @@ import com.google.common.base.Preconditions;
  * 
  * @param <T> extends NetworkAddress<T>
  */
-public abstract class AbstractBGPRoute<T extends NetworkAddress<T>> extends AbstractBGPObject implements BGPRoute<T> {
+public abstract class AbstractBGPRoute<T extends NetworkAddress<T>> extends AbstractBGPObject implements BGPRoute {
        private static final long serialVersionUID = 1L;
        private final Prefix<T> name;
 
-       protected AbstractBGPRoute(final Prefix<T> name, final BaseBGPObjectState base, final NetworkRouteState<T> routeState) {
-               super(new BGPRouteState<T>(base, routeState));
+       protected AbstractBGPRoute(final Prefix<T> name, final BaseBGPObjectState base, final NetworkRouteState routeState) {
+               super(new BGPRouteState(base, routeState));
                this.name = Preconditions.checkNotNull(name);
        }
 
        @Override
-       final public BGPRouteState<T> currentState() {
-               return (BGPRouteState<T>) super.currentState();
+       final public BGPRouteState currentState() {
+               return (BGPRouteState) super.currentState();
        }
 
        @Override
index cce08aff033aa32c4ce3bd86884a04c019421482..c2cad7a8d0e47c84aaff7793c337531ed8bc2bed 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.protocol.bgp.util;
 
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-
+import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 
 /**
  * Implementation of {@link AbstractBGPPrefix}.
@@ -19,8 +18,7 @@ import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 public final class BGPIPv4RouteImpl extends AbstractBGPRoute<IPv4Address> {
        private static final long serialVersionUID = 1L;
 
-       public BGPIPv4RouteImpl(final Prefix<IPv4Address> prefix, final BaseBGPObjectState base,
-                       final NetworkRouteState<IPv4Address> prefixState) {
+       public BGPIPv4RouteImpl(final Prefix<IPv4Address> prefix, final BaseBGPObjectState base, final NetworkRouteState prefixState) {
                super(prefix, base, prefixState);
        }
 }
index 0b672ce00d04756b9665f05a198c400f5c28a267..ad6a22a763b2bd05b04352dafc170658b7159a8e 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.protocol.bgp.util;
 
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-
+import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 import org.opendaylight.protocol.concepts.IPv6Address;
 import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 
 /**
  * Implementation of {@link AbstractBGPPrefix}.
@@ -19,7 +18,7 @@ import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 public final class BGPIPv6RouteImpl extends AbstractBGPRoute<IPv6Address> {
        private static final long serialVersionUID = 1L;
 
-       public BGPIPv6RouteImpl(final Prefix<IPv6Address> prefix, final BaseBGPObjectState base, final NetworkRouteState<IPv6Address> prefixState) {
+       public BGPIPv6RouteImpl(final Prefix<IPv6Address> prefix, final BaseBGPObjectState base, final NetworkRouteState prefixState) {
                super(prefix, base, prefixState);
        }
 }
index 025de8a70eca500e54c7c360a7527012ffb2dd49..bba4f622d7c6e38504930eb4a71afd944eaf1327 100644 (file)
@@ -12,20 +12,24 @@ import static org.junit.Assert.assertNotSame;
 
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
-import org.opendaylight.protocol.bgp.concepts.IPv4NextHop;
-import org.opendaylight.protocol.bgp.concepts.IPv6NextHop;
 import org.opendaylight.protocol.bgp.linkstate.NetworkRouteState;
 import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.IPv6;
-import org.opendaylight.protocol.concepts.IPv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv6NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv6.next.hop.Ipv6NextHopBuilder;
 
 public class RouteTest {
 
        BaseBGPObjectState base = new BaseBGPObjectState(BgpOrigin.Egp, null);
-       final NetworkRouteState<IPv4Address> prefix4State = new NetworkRouteState<>(IPv4NextHop.forString("128.54.8.9"));
-       final NetworkRouteState<IPv6Address> prefix6State = new NetworkRouteState<>(IPv6NextHop.forString("2001::4"));
+       final NetworkRouteState prefix4State = new NetworkRouteState(new CIpv4NextHopBuilder().setIpv4NextHop(
+                       new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("128.54.8.9")).build()).build());
+       final NetworkRouteState prefix6State = new NetworkRouteState(new CIpv6NextHopBuilder().setIpv6NextHop(
+                       new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001::4")).build()).build());
        final BGPIPv4RouteImpl r4 = new BGPIPv4RouteImpl(IPv4.FAMILY.prefixForString("172.168.4.6/24"), this.base, this.prefix4State);
        final BGPIPv6RouteImpl r6 = new BGPIPv6RouteImpl(IPv6.FAMILY.prefixForString("2001::4/32"), this.base, this.prefix6State);
 
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/Ipv6Util.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/Ipv6Util.java
new file mode 100644 (file)
index 0000000..3778f48
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.concepts;
+
+import java.net.Inet6Address;
+import java.net.UnknownHostException;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+
+/**
+ * Util class for creating generated Ipv6Address.
+ */
+public class Ipv6Util {
+
+       public static Ipv6Address addressForBytes(final byte[] bytes) {
+               try {
+                       return new Ipv6Address(Inet6Address.getByAddress(bytes).toString());
+               } catch (final UnknownHostException e) {
+                       throw new IllegalArgumentException(e.getMessage());
+               }
+       }
+
+}