+++ /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 java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Preconditions;
-
-/**
- * Conceptual representation of an AS path. This class distills the concept behind the encoding rules specified in RFC
- * 4271.
- *
- * @see <a href="http://tools.ietf.org/html/rfc4271#section-5.1.2">AS Path</a>
- */
-public final class ASPath implements Serializable {
- /**
- * An empty AS Path (attribute in all UPDATE messages sent to internal peers).
- */
- public static final ASPath EMPTY = new ASPath();
- private static final long serialVersionUID = 7951172606939897308L;
- private final Set<AsNumber> aggregatedAsPath;
- private final List<AsNumber> visibleAsPath;
-
- private ASPath() {
- this.visibleAsPath = Collections.emptyList();
- this.aggregatedAsPath = Collections.emptySet();
- }
-
- /**
- * Construct an AS path object representing a fully-visible path.
- *
- * @param visibleAsPath Ordered list of AS numbers in the path, corresponding to the concatenation of all
- * AS_SEQUENCE components.
- */
- public ASPath(final List<AsNumber> visibleAsPath) {
- this.aggregatedAsPath = Collections.emptySet();
- this.visibleAsPath = Collections.unmodifiableList(Preconditions.checkNotNull(visibleAsPath));
- }
-
- /**
- * Construct an AS path object representing a partially aggregated path.
- *
- * @param visibleAsPath Ordered list of AS numbers in the path, corresponding to the concatenation of all
- * AS_SEQUENCE components.
- * @param aggregatedAsPath Unordered set of AS numbers in the path, corresponding to the concatenation of all AS_SET
- * components.
- */
- public ASPath(final List<AsNumber> visibleAsPath, final Set<AsNumber> aggregatedAsPath) {
- Preconditions.checkNotNull(aggregatedAsPath);
- Preconditions.checkNotNull(visibleAsPath);
- this.aggregatedAsPath = Collections.unmodifiableSet(aggregatedAsPath);
- this.visibleAsPath = Collections.unmodifiableList(visibleAsPath);
- }
-
- /**
- * Return the visible part of an AS path. Note that an AS number may be present multiple times in a row due to
- * "AS number prepend" feature used by many routers to affect route decisions by extending the length on the list
- * while keeping the loop information intact.
- *
- * @return Ordered list of AS numbers.
- */
- public List<AsNumber> getVisibleAsPath() {
- return this.visibleAsPath;
- }
-
- /**
- * Return the aggregated part of an AS path.
- *
- * @return Unordered set of AS numbers.
- */
- public Set<AsNumber> getAggregatedAsPath() {
- return this.aggregatedAsPath;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.aggregatedAsPath == null) ? 0 : this.aggregatedAsPath.hashCode());
- result = prime * result + ((this.visibleAsPath == null) ? 0 : this.visibleAsPath.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (this.getClass() != obj.getClass())
- return false;
- final ASPath other = (ASPath) obj;
- if (this.aggregatedAsPath == null) {
- if (other.aggregatedAsPath != null)
- return false;
- } else if (!this.aggregatedAsPath.equals(other.aggregatedAsPath))
- return false;
- if (this.visibleAsPath == null) {
- if (other.visibleAsPath != null)
- return false;
- } else if (!this.visibleAsPath.equals(other.visibleAsPath))
- return false;
- return true;
- }
-
- @Override
- public final String toString() {
- return addToStringAttributes(Objects.toStringHelper(this)).toString();
- }
-
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- toStringHelper.add("aggregatedAsPath", this.aggregatedAsPath);
- toStringHelper.add("visibleAsPath", this.visibleAsPath);
- return toStringHelper;
- }
-}
}
}
}
-
+
grouping next-hop {
choice c-next-hop {
case c-ipv4-next-hop {
}
}
}
+
+ grouping as-path-segment {
+ reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
+ choice c-segment {
+ case c-a-set {
+ leaf-list as-set {
+ type inet:as-number;
+ }
+ }
+ case c-a-list {
+ list as-sequence {
+ leaf as {
+ type inet:as-number;
+ }
+ }
+ }
+ }
+ }
}
+++ /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.CoreMatchers.equalTo;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-
-public class ASPathTest {
-
- private AsNumber asn1, asn2, asn3, asn4, asn5, asn6, asn7, asn8;
-
- private List<AsNumber> visibleAsPath;
- private Set<AsNumber> aggregatedAsPath;
-
- @Before
- public void init() {
- this.asn1 = new AsNumber(429496729800L);
- this.asn2 = new AsNumber((long) 65534);
- this.asn3 = new AsNumber((long) 200);
- this.asn4 = new AsNumber(429496729799L);
- this.asn5 = new AsNumber(425201762503L);
- this.asn6 = new AsNumber((long) 64538);
- this.asn7 = new AsNumber((long) 200);
- this.asn8 = new AsNumber(429496729600L);
-
- this.visibleAsPath = new ArrayList<AsNumber>();
- this.aggregatedAsPath = new HashSet<AsNumber>();
-
- this.visibleAsPath.add(this.asn1);
- this.visibleAsPath.add(this.asn2);
- this.visibleAsPath.add(this.asn3);
- this.visibleAsPath.add(this.asn4);
-
- this.aggregatedAsPath.add(this.asn5);
- this.aggregatedAsPath.add(this.asn6);
- this.aggregatedAsPath.add(this.asn7);
- this.aggregatedAsPath.add(this.asn8);
- }
-
- @Test
- public void testGetXXXPath() {
- final ASPath asp1 = ASPath.EMPTY;
- assertEquals(0, asp1.getVisibleAsPath().size());
- assertEquals(0, asp1.getAggregatedAsPath().size());
-
- final ASPath asp2 = new ASPath(this.visibleAsPath);
- assertEquals(4, asp2.getVisibleAsPath().size());
- assertEquals(0, asp2.getAggregatedAsPath().size());
-
- final ASPath asp3 = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
- assertEquals(4, asp3.getVisibleAsPath().size());
- assertEquals(4, asp3.getAggregatedAsPath().size());
- }
-
- @Test
- public void testEqualsHashCode() {
- final ASPath asp1 = ASPath.EMPTY;
- final ASPath asp2 = asp1;
- assertEquals(asp1, asp2);
- assertEquals(asp1.hashCode(), asp2.hashCode());
- assertNotNull(asp1);
- assertThat(asp1, not(new Object()));
-
- final ASPath asp3 = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
- assertThat(asp1, not(equalTo(asp3)));
- assertThat(asp1.hashCode(), not(equalTo(asp3.hashCode())));
-
- final ASPath asp4 = new ASPath(new ArrayList<AsNumber>(), this.aggregatedAsPath);
- assertThat(asp3, not(equalTo(asp4)));
- }
-
- @Test
- public void testToString() {
- final ASPath asp = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
- assertNotNull(asp.toString());
- }
-
-}
package org.opendaylight.protocol.bgp.linkstate;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
-import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.concepts.Identifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
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;
*
* @param asPath {@link ASPath}
*/
- public final synchronized void setASPath(final ASPath asPath) {
+ public final synchronized void setASPath(final List<AsPathSegment> asPath) {
this.state = this.state.withASPath(asPath);
}
package org.opendaylight.protocol.bgp.linkstate;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
-import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.concepts.State;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
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;
private static final long serialVersionUID = 1L;
private Set<ExtendedCommunity> extendedCommunities;
private Set<Community> communities;
- private ASPath asPath;
+ private List<AsPathSegment> asPath;
protected NetworkObjectState() {
- this(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
+ this(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
}
- public NetworkObjectState(final ASPath asPath, final Set<Community> communities, final Set<ExtendedCommunity> extendedCommunities) {
+ public NetworkObjectState(final List<AsPathSegment> asPath, final Set<Community> communities,
+ final Set<ExtendedCommunity> extendedCommunities) {
this.asPath = asPath;
this.communities = communities;
this.extendedCommunities = extendedCommunities;
*
* @return Path to the advertising Autonomous System.
*/
- public final ASPath getASPath() {
+ public final List<AsPathSegment> getASPath() {
return this.asPath;
}
- public final NetworkObjectState withASPath(final ASPath asPath) {
+ public final NetworkObjectState withASPath(final List<AsPathSegment> asPath) {
final NetworkObjectState ret = newInstance();
ret.asPath = asPath;
return ret;
}
}
- grouping as-path-segment {
- choice segment {
- case a-set {
- leaf-list as-set {
- type inet:as-number;
- }
- }
- case a-list {
- list as-sequence {
- container sequence {
- leaf as {
- type inet:as-number;
- }
- }
- }
- }
- mandatory true;
- }
- }
-
notification open {
description "Open Message";
reference "http://tools.ietf.org/html/rfc4271#section-4.2";
container as-path {
reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
list segments {
- uses as-path-segment;
+ uses bgp-t:as-path-segment;
}
}
uses bgp-t:next-hop;
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.linkstate.IPv4PrefixIdentifier;
import org.opendaylight.protocol.concepts.IPv4Address;
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.AsPathSegment;
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.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
private Set<BGPObject> fillAddedObjects(final List<PathAttribute> pathAttributes, final Set<Prefix<IPv4Address>> nlri)
throws BGPParsingException {
BgpOrigin origin = null;
- ASPath aspath = null;
+ final List<AsPathSegment> aspath = Lists.newArrayList();
CIpv4NextHop nextHop = null;
BgpAggregator aggregator = null;
final Set<ExtendedCommunity> ecomm = Sets.newHashSet();
for (final PathAttribute pa : pathAttributes) {
if (pa.getValue() instanceof BgpOrigin) {
origin = (BgpOrigin) pa.getValue();
- } else if (pa.getValue() instanceof ASPath) {
- aspath = (ASPath) pa.getValue();
+ } else if (pa.getValue() instanceof List) {
+ for (final Object o : (List<?>) pa.getValue()) {
+ if (o instanceof AsPathSegment) {
+ aspath.add((AsPathSegment) o);
+ }
+ }
} else if (pa.getValue() instanceof CIpv4NextHop) {
nextHop = (CIpv4NextHop) pa.getValue();
} else if (pa.getValue() instanceof BgpAggregator) {
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
+import java.util.List;
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.as.path.segment.c.segment.c.a.list.AsSequence;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
/**
*
}
}
- static Collection<AsNumber> parseAsPathSegment(final SegmentType type, final int count, final byte[] bytes) {
- final Collection<AsNumber> coll = (type == SegmentType.AS_SEQUENCE) ? new ArrayList<AsNumber>() : new HashSet<AsNumber>();
+ static List<AsSequence> parseAsSequence(final int count, final byte[] bytes) {
+ final List<AsSequence> coll = new ArrayList<>();
+ int byteOffset = 0;
+ for (int i = 0; i < count; i++) {
+ coll.add(new AsSequenceBuilder().setAs(
+ new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH)))).build());
+ byteOffset += AS_NUMBER_LENGTH;
+ }
+ return coll;
+ }
+
+ static List<AsNumber> parseAsSet(final int count, final byte[] bytes) {
+ final List<AsNumber> coll = new ArrayList<>();
int byteOffset = 0;
for (int i = 0; i < count; i++) {
coll.add(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH))));
import java.util.Map;
import java.util.Set;
-import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
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.message.rev130918.path.attributes.AggregatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.as.path.SegmentsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
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.BgpOrigin;
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.as.path.segment.c.segment.CAListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CASetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
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;
* @throws BGPDocumentedException if there is no AS_SEQUENCE present (mandatory)
* @throws BGPParsingException
*/
- private static ASPath parseAsPath(final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
+ private static List<AsPathSegment> parseAsPath(final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
int byteOffset = 0;
- List<AsNumber> list = null;
- Set<AsNumber> set = null;
+ final List<AsPathSegment> ases = Lists.newArrayList();
+ boolean isSequence = false;
while (byteOffset < bytes.length) {
final int type = UnsignedBytes.toInt(bytes[byteOffset]);
final SegmentType segmentType = AsPathSegmentParser.parseType(type);
byteOffset += AsPathSegmentParser.LENGTH_SIZE;
if (segmentType == SegmentType.AS_SEQUENCE) {
- list = (List<AsNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
+ final List<AsSequence> numbers = AsPathSegmentParser.parseAsSequence(count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
+ ases.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(numbers).build()).build());
+ isSequence = true;
} else {
- set = (Set<AsNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
+ final List<AsNumber> list = AsPathSegmentParser.parseAsSet(count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
+ ases.add(new SegmentsBuilder().setCSegment(new CASetBuilder().setAsSet(list).build()).build());
+
}
byteOffset += count * AsPathSegmentParser.AS_NUMBER_LENGTH;
}
- if (list == null && bytes.length != 0)
+ if (!isSequence && bytes.length != 0)
throw new BGPDocumentedException("AS_SEQUENCE must be present in AS_PATH attribute.", BGPError.AS_PATH_MALFORMED);
- return (set != null) ? new ASPath(list, set) : (list == null) ? ASPath.EMPTY : new ASPath(list);
+ return ases;
}
/**
import org.junit.BeforeClass;
import org.junit.Test;
-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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
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.message.rev130918.path.attributes.as.path.SegmentsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
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.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.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CAListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CASetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
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;
// attributes
- final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65002)));
+ final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65002L)).build());
+ final List<AsPathSegment> asPath = Lists.newArrayList();
+ asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
final CIpv4NextHop nextHop = new CIpv4NextHopBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
// attributes
-
- final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65001)));
+ final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(65001L)).build());
+ final List<AsPathSegment> asPath = Lists.newArrayList();
+ asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
final CIpv6NextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
// attributes
- final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 30)), Sets.newHashSet(new AsNumber((long) 10),
- new AsNumber((long) 20)));
+ final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(30L)).build());
+ final List<AsPathSegment> asPath = Lists.newArrayList();
+ asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
+ asPath.add(new SegmentsBuilder().setCSegment(
+ new CASetBuilder().setAsSet(Lists.newArrayList(new AsNumber(10L), new AsNumber(20L))).build()).build());
final BgpAggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber((long) 30)).setNetworkAddress(
new Ipv4Address("10.0.0.9")).build();
// assertEquals(nlri, ret.getBgpUpdateMessageBuilder().getNlri());
final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Egp, null);
- final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), comms), nextHop);
+ final NetworkRouteState routeState = new NetworkRouteState(new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), comms), nextHop);
// check API message
assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
// network object state
- final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
+ final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
// network link state
assertEquals(Collections.EMPTY_SET, message.getRemovedObjects());
// network object state
- final NetworkObjectState objState = new NetworkObjectState(ASPath.EMPTY, Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
+ final NetworkObjectState objState = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
final NetworkNodeState nstate = new NetworkNodeState(objState, Collections.<TopologyIdentifier> emptySet(), Collections.<ISISAreaIdentifier> emptySet(), false, false, false, false, Collections.<RouterIdentifier> emptySet(), null);
import org.junit.Before;
import org.junit.Test;
-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.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.message.rev130918.path.attributes.as.path.SegmentsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AsPathSegment;
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.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.CAListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequence;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.c.a.list.AsSequenceBuilder;
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;
*/
private BGPUpdateMessage fillMessages(final long asn) throws UnknownHostException {
- final List<AsNumber> asnums = new ArrayList<AsNumber>();
- asnums.add(new AsNumber(asn));
- final ASPath asPath = new ASPath(asnums);
+ final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(asn)).build());
+ final List<AsPathSegment> asPath = Lists.newArrayList();
+ asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
final CNextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
import java.util.Collections;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.linkstate.IPv4PrefixIdentifier;
import org.opendaylight.protocol.bgp.linkstate.IPv6PrefixIdentifier;
import org.opendaylight.protocol.bgp.linkstate.RouteTag;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv6;
-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.AsPathSegment;
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 com.google.common.collect.Lists;
import com.google.common.collect.Sets;
public class PrefixTest {
final BaseBGPObjectState base = new BaseBGPObjectState(BgpOrigin.Egp, null);
- final NetworkObjectState state = new NetworkObjectState(new ASPath(Lists.newArrayList(new AsNumber(10L))), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
+ final NetworkObjectState state = new NetworkObjectState(Collections.<AsPathSegment> emptyList(), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
final NetworkPrefixState prefixState = new NetworkPrefixState(this.state, Sets.<RouteTag> newTreeSet(), null);
final BGPIPv4PrefixImpl r4 = new BGPIPv4PrefixImpl(this.base, new IPv4PrefixIdentifier(new NodeIdentifier(null, null, null, new OSPFRouterIdentifier(new byte[] {