+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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));
- }
-}
+++ /dev/null
-/*
- * 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));
- }
-}
+++ /dev/null
-/*
- * 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();
-}
-
}
}
}
-
+
typedef bgp-subsequent-address-family {
reference "http://tools.ietf.org/html/rfc4760#section-6";
type enumeration {
}
}
}
-
+
typedef bgp-address-family {
reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
type enumeration {
}
}
}
+
+ 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;
+ }
+ }
+ }
+ }
+ }
}
+++ /dev/null
-/*
- * 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"));
- }
-}
+++ /dev/null
-/*
- * 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"));
- }
-}
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();
}
-
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;
/**
*
* @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);
}
/**
*
* @return NextHop<T> next hop.
*/
- public NextHop<T> getNextHop() {
+ public CNextHop getNextHop() {
return this.nextHop;
}
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;
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;
/**
* @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();
}
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);
}
}
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 {
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 {
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;
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;
@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());
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;
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;
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();
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) {
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));
}
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));
}
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;
return this.nlri;
}
- public IPv4NextHop getNextHop() {
+ public CIpv4NextHop getNextHop() {
return this.nextHop;
}
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;
return this.nlri;
}
- public IPv6NextHop getNextHop() {
+ public CIpv6NextHop getNextHop() {
return this.nextHop;
}
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;
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;
* @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;
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;
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;
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)));
}
}
}
- 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:
}
}
- 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);
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;
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;
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;
* @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();
}
/**
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;
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;
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;
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);
// 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);
}
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}),
// 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);
}
/*
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");
// 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);
}
// 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(
// 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);
}
@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);
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
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;
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;
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);
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);
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));
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());
}
/**
/**
* @return the routes
*/
- public final Map<Prefix<?>, BGPRouteState<?>> getRoutes() {
+ public final Map<Prefix<?>, BGPRouteState> getRoutes() {
return this.routes;
}
}
@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());
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<?>) {
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;
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<?>)
} 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());
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;
*
* @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
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}.
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);
}
}
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}.
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);
}
}
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);
--- /dev/null
+/*
+ * 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());
+ }
+ }
+
+}