+++ /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.ASNumber;
-import org.opendaylight.protocol.concepts.NetworkAddress;
-
-/**
- *
- * BGP Path Attribute AGGREGATOR.
- *
- * @see <a href="http://tools.ietf.org/html/rfc4271#section-5.1.7">BGP Aggregator</a>
- *
- */
-public interface BGPAggregator {
-
- /**
- * The BGP Speaker returns its own AS Number.
- *
- * @return own AS Number
- */
- public ASNumber getASNumber();
-
- /**
- * The BGP Speaker returns its own IP Address.
- *
- * @return own IP Address
- */
- public NetworkAddress<?> getNetworkAddress();
-}
package org.opendaylight.protocol.bgp.concepts;
import org.opendaylight.protocol.concepts.State;
+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 com.google.common.base.Objects;
private static final long serialVersionUID = 2371691093534458869L;
private final BgpOrigin origin;
- private final BGPAggregator aggregator;
+ private final BgpAggregator aggregator;
/**
* Creates BaswBGPObjectState.
*
- * @param origin {@link BGPOrigin}
- * @param aggregator {@link BGPAggregator}
+ * @param origin {@link BgpOrigin}
+ * @param aggregator {@link BgpAggregator}
*/
- public BaseBGPObjectState(final BgpOrigin origin, final BGPAggregator aggregator) {
+ public BaseBGPObjectState(final BgpOrigin origin, final BgpAggregator aggregator) {
super();
this.origin = origin;
this.aggregator = aggregator;
*
* @return BGPAggregator attribute of this object
*/
- public final BGPAggregator getAggregator() {
+ public final BgpAggregator getAggregator() {
return this.aggregator;
}
}
}
}
-}
\ No newline at end of file
+
+ grouping bgp-aggregator {
+ reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
+ description "BGP Path Attribute AGGREGATOR.";
+ leaf as-number {
+ type inet:as-number;
+ }
+ leaf network-address {
+ type inet:ipv4-address;
+ }
+ }
+}
}
}
- typedef as-number {
- type uint32;
- }
-
grouping as-path-segment {
choice segment {
case a-set {
leaf-list as-set {
- type as-number;
+ type inet:as-number;
}
}
case a-list {
list as-sequence {
container sequence {
leaf as {
- type as-number;
+ type inet:as-number;
}
}
}
container as4-bytes {
reference "http://tools.ietf.org/html/rfc6793";
leaf as-number {
- type as-number;
+ type inet:as-number;
}
}
}
}
container atomic-aggregate {
reference "http://tools.ietf.org/html/rfc4271#section-5.1.6";
- presence "Atomic Aggregare attribute is present.";
+ presence "Atomic Aggregate attribute is present.";
}
container aggregator {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
- leaf as {
- type as-number;
- }
- leaf ip {
- type inet:ipv4-address;
- }
+ uses bgp-t:bgp-aggregator;
}
}
container withdrawn-routes {
*/
package org.opendaylight.protocol.bgp.parser.impl;
-import org.opendaylight.protocol.bgp.concepts.BGPAggregator;
-
-import org.opendaylight.protocol.concepts.ASNumber;
-import org.opendaylight.protocol.concepts.NetworkAddress;
+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.BgpAggregator;
/**
- * Implementation of BGP Aggregator object.
+ * Implementation of BGP Aggregator object. RFC4760 assumes that any BGP speaker (including the one that supports
+ * multiprotocol capabilities defined in this document) has to have an IPv4 address (which will be used, among other
+ * things, in the AGGREGATOR attribute).
+ *
* @param <T> subtype of Network Address
*/
-public class BGPAggregatorImpl<T extends NetworkAddress<T>> implements
- BGPAggregator {
+public class BGPAggregatorImpl implements BgpAggregator {
- private final ASNumber asNumber;
+ private final AsNumber asNumber;
- private final T address;
+ private final Ipv4Address address;
- public BGPAggregatorImpl(ASNumber asNumber, T address) {
+ public BGPAggregatorImpl(final AsNumber asNumber, final Ipv4Address address) {
this.address = address;
this.asNumber = asNumber;
}
@Override
- public ASNumber getASNumber() {
+ public AsNumber getAsNumber() {
return this.asNumber;
}
@Override
- public T getNetworkAddress() {
+ public Ipv4Address getNetworkAddress() {
return this.address;
}
final int prime = 31;
int result = 1;
result = prime * result + ((this.address == null) ? 0 : this.address.hashCode());
- result = prime * result
- + ((this.asNumber == null) ? 0 : this.asNumber.hashCode());
+ result = prime * result + ((this.asNumber == null) ? 0 : this.asNumber.hashCode());
return result;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (this.getClass() != obj.getClass())
return false;
- final BGPAggregatorImpl<?> other = (BGPAggregatorImpl<?>) obj;
+ final BGPAggregatorImpl other = (BGPAggregatorImpl) obj;
if (this.address == null) {
if (other.address != null)
return false;
import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.protocol.bgp.concepts.ASPath;
-import org.opendaylight.protocol.bgp.concepts.BGPAggregator;
import org.opendaylight.protocol.bgp.concepts.BGPObject;
import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.concepts.Community;
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.BgpAggregator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
BgpOrigin origin = null;
ASPath aspath = null;
IPv4NextHop nextHop = null;
- BGPAggregator aggregator = null;
+ BgpAggregator aggregator = null;
final Set<ExtendedCommunity> ecomm = Sets.newHashSet();
final Set<Community> comm = Sets.newHashSet();
final Map<Integer, ByteList> linkstate = Maps.newHashMap();
aspath = (ASPath) pa.getValue();
} else if (pa.getValue() instanceof IPv4NextHop) {
nextHop = (IPv4NextHop) pa.getValue();
- } else if (pa.getValue() instanceof BGPAggregator) {
- aggregator = (BGPAggregator) pa.getValue();
+ } else if (pa.getValue() instanceof BgpAggregator) {
+ aggregator = (BgpAggregator) pa.getValue();
} else if (pa.getValue() instanceof Set) {
for (final Object o : (Set<?>) pa.getValue()) {
if (o instanceof ExtendedCommunity) {
import java.util.Set;
import org.opendaylight.protocol.bgp.concepts.ASPath;
-import org.opendaylight.protocol.bgp.concepts.BGPAggregator;
import org.opendaylight.protocol.bgp.concepts.ClusterIdentifier;
import org.opendaylight.protocol.bgp.concepts.Community;
import org.opendaylight.protocol.bgp.concepts.ExtendedCommunity;
import org.opendaylight.protocol.bgp.parser.impl.PathAttribute.TypeCode;
import org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType;
import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
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.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.BgpAggregator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import com.google.common.collect.Lists;
* @param bytes byte array to be parsed
* @return new BGPAggregator object
*/
- private static BGPAggregator parseAggregator(final byte[] bytes) {
- final ASNumber asNumber = new ASNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, 0, AsPathSegmentParser.AS_NUMBER_LENGTH)));
- final IPv4Address address = new IPv4Address(ByteArray.subByte(bytes, AsPathSegmentParser.AS_NUMBER_LENGTH, 4));
- return new BGPAggregatorImpl<IPv4Address>(asNumber, address);
+ private static BgpAggregator parseAggregator(final byte[] bytes) {
+ final AsNumber asNumber = new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, 0, AsPathSegmentParser.AS_NUMBER_LENGTH)));
+ final Ipv4Address address = new Ipv4Address(IPv4.FAMILY.addressForBytes(
+ ByteArray.subByte(bytes, AsPathSegmentParser.AS_NUMBER_LENGTH, 4)).toString());
+ return new BGPAggregatorImpl(asNumber, address);
}
/**
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPAggregator;
import org.opendaylight.protocol.bgp.concepts.BGPObject;
import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
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.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 com.google.common.collect.Lists;
final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(30)), Sets.newHashSet(new ASNumber(10), new ASNumber(20)));
- final BGPAggregator aggregator = new BGPAggregatorImpl<IPv4Address>(new ASNumber(30), IPv4.FAMILY.addressForString("10.0.0.9"));
+ final BgpAggregator aggregator = new BGPAggregatorImpl(new AsNumber((long) 30), new Ipv4Address("10.0.0.9"));
final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.9");
final IPv4Prefix pref1 = IPv4.FAMILY.prefixForString("172.16.0.0/21");
@Test
public void testHashCodeEquals() throws UnknownHostException {
- final BGPAggregator agg1 = new BGPAggregatorImpl<IPv4Address>(new ASNumber(6), IPv4.FAMILY.addressForString("10.0.0.9"));
+ final BgpAggregator agg1 = new BGPAggregatorImpl(new AsNumber((long) 6), new Ipv4Address("10.0.0.9"));
- final BGPAggregator agg2 = new BGPAggregatorImpl<IPv4Address>(new ASNumber(6), IPv4.FAMILY.addressForString("10.0.0.9"));
+ final BgpAggregator agg2 = new BGPAggregatorImpl(new AsNumber((long) 6), new Ipv4Address("10.0.0.9"));
assertEquals(agg1, agg2);
assertEquals("HashCodes should be equal", agg1.hashCode(), agg2.hashCode());
import org.opendaylight.protocol.bgp.parser.impl.message.update.MPReachParser;
import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
-import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.ISOSystemIdentifier;
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.Ipv4Address;
import com.google.common.collect.Sets;
@Test
public void testBGPAggregatorImpl() {
- final BGPAggregatorImpl<IPv4Address> ipv4 = new BGPAggregatorImpl<IPv4Address>(new ASNumber(5524), IPv4.FAMILY.addressForString("124.55.42.1"));
- final BGPAggregatorImpl<IPv4Address> ipv4i = new BGPAggregatorImpl<IPv4Address>(new ASNumber(5525), IPv4.FAMILY.addressForString("124.55.42.1"));
+ final BGPAggregatorImpl ipv4 = new BGPAggregatorImpl(new AsNumber((long) 5524), new Ipv4Address("124.55.42.1"));
+ final BGPAggregatorImpl ipv4i = new BGPAggregatorImpl(new AsNumber((long) 5525), new Ipv4Address("124.55.42.1"));
assertNotSame(ipv4.hashCode(), ipv4i.hashCode());
- assertEquals(ipv4, new BGPAggregatorImpl<IPv4Address>(new ASNumber(5524), IPv4.FAMILY.addressForString("124.55.42.1")));
+ assertEquals(ipv4, new BGPAggregatorImpl(new AsNumber((long) 5524), new Ipv4Address("124.55.42.1")));
- assertNotSame(ipv4.getASNumber(), ipv4i.getASNumber());
+ assertNotSame(ipv4.getAsNumber(), ipv4i.getAsNumber());
assertEquals(ipv4.getNetworkAddress(), ipv4i.getNetworkAddress());
}