+++ /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;
-
-/**
- * Enumeration of all supported subsequent address family identifiers.
- */
-public enum BGPSubsequentAddressFamily {
- /**
- * RFC4760: Network Layer Reachability Information used
- * for unicast forwarding.
- */
- Unicast,
- /**
- * RFC4364: MPLS-labeled VPN address
- */
- MPLSLabeledVPN,
- /**
- * draft-ietf-idr-ls-distribution-03 : Linkstate SAFI
- */
- Linkstate
-}
package org.opendaylight.protocol.bgp.concepts;
import org.opendaylight.protocol.concepts.Identifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
+
import com.google.common.base.Preconditions;
/**
private static final long serialVersionUID = -5502662876916458740L;
- private final BGPSubsequentAddressFamily safi;
+ private final BgpSubsequentAddressFamily safi;
private final BGPAddressFamily afi;
* @param afi Address Family Identifier
* @param safi Subsequent Address Family Identifier
*/
- public BGPTableType(final BGPAddressFamily afi, final BGPSubsequentAddressFamily safi) {
+ public BGPTableType(final BGPAddressFamily afi, final BgpSubsequentAddressFamily safi) {
this.afi = Preconditions.checkNotNull(afi, "Address family may not be null");
this.safi = Preconditions.checkNotNull(safi, "Subsequent address family may not be null");
}
*
* @return safi SAFI
*/
- public BGPSubsequentAddressFamily getSubsequentAddressFamily() {
+ public BgpSubsequentAddressFamily getSubsequentAddressFamily() {
return this.safi;
}
}
}
}
+
+ typedef bgp-subsequent-address-family {
+ reference "http://tools.ietf.org/html/rfc4760#section-6";
+ type enumeration {
+ enum unicast {
+ value 1;
+ }
+ enum mpls-labeled-vpn {
+ value 128;
+ }
+ enum linkstate {
+ reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
+ value 71;
+ }
+ }
+ }
grouping bgp-aggregator {
reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
import org.junit.Test;
import org.opendaylight.protocol.concepts.IPv6;
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;
public class TableTypeTest {
@Test
public void testTableTypes() {
- final BGPTableType tt1 = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.MPLSLabeledVPN);
- final BGPTableType tt2 = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.valueOf("MPLSLabeledVPN"));
- final BGPTableType tt3 = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
+ final BGPTableType tt1 = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.MplsLabeledVpn);
+ final BGPTableType tt2 = new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.valueOf("MplsLabeledVpn"));
+ final BGPTableType tt3 = new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.Unicast);
assertEquals(IPv6.FAMILY, BGPAddressFamily.IPv6.getAddressFamily());
assertNull(BGPAddressFamily.LinkState.getAddressFamily());
try {
- new BGPTableType(null, BGPSubsequentAddressFamily.MPLSLabeledVPN);
+ new BGPTableType(null, BgpSubsequentAddressFamily.MplsLabeledVpn);
fail("Null AFI!");
} catch (final NullPointerException e) {
assertEquals("Address family may not be null", e.getMessage());
package org.opendaylight.protocol.bgp.parser.parameter;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
/**
* Multiprotocol capability Parameter as described in:
*
* @return SAFI
*/
- public BGPSubsequentAddressFamily getSafi() {
+ public BgpSubsequentAddressFamily getSafi() {
return this.tableType.getSubsequentAddressFamily();
}
prefix inet;
revision-date 2010-09-24;
}
- import bgp-message { prefix bgp-msg;}
+ import bgp-message { prefix bgp-msg; }
+ import bgp-types { prefix bgp-t; }
organization "Cisco Systems, Inc.";
contact "Dana Kutenicsova <dkutenic@cisco.com>";
}
}
- typedef bgp-subsequent-address-family {
- reference "http://tools.ietf.org/html/rfc4760#section-6
- http://tools.ietf.org/html/rfc4364#section-16
- http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
- type enumeration {
- enum unicast {
- value 1;
- }
- enum mpls-labeled-vpn {
- value 128;
- }
- enum linkstate {
- value 71;
- }
- }
- }
-
grouping bgp-table-type {
leaf afi {
type bgp-address-family;
}
leaf safi {
- type bgp-subsequent-address-family;
+ type bgp-t:bgp-subsequent-address-family;
}
}
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.concepts.Community;
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
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 com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@Test
public void testBGPParameter() {
- final BGPTableType t = new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
- final BGPTableType t1 = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
+ final BGPTableType t = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Unicast);
+ final BGPTableType t1 = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
final BGPParameter tlv1 = new MultiprotocolCapability(t);
import java.util.Set;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.concepts.IPv4Address;
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.BgpSubsequentAddressFamily;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
}
};
return event;
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.Unicast);
}
};
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Unicast);
}
};
import java.util.Arrays;
import java.util.Map.Entry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.impl.message.update.MPReachParser;
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.util.ByteArray;
import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.google.common.primitives.UnsignedBytes;
/**
private static MultiprotocolCapability parseMultiProtocolParameterValue(final byte[] bytes) throws BGPParsingException {
final BGPAddressFamily afi = MPReachParser.parseAfi(ByteArray.bytesToInt(ByteArray.subByte(bytes, 0, AFI_SIZE)));
- final BGPSubsequentAddressFamily safi = MPReachParser.parseSafi(ByteArray.bytesToInt(ByteArray.subByte(bytes, AFI_SIZE + 1,
- SAFI_SIZE)));
+ final BgpSubsequentAddressFamily safi = BgpSubsequentAddressFamily.forValue(ByteArray.bytesToInt(ByteArray.subByte(bytes,
+ AFI_SIZE + 1, SAFI_SIZE)));
+ if (safi == null)
+ throw new BGPParsingException("Subsequent Address Family Identifier: '"
+ + ByteArray.bytesToInt(ByteArray.subByte(bytes, AFI_SIZE + 1, SAFI_SIZE)) + "' not supported.");
return new MultiprotocolCapability(new BGPTableType(afi, safi));
}
return ByteArray.subByte(a, Integer.SIZE / Byte.SIZE - AFI_SIZE, AFI_SIZE);
}
- static byte putSafi(final BGPSubsequentAddressFamily safi) {
+ static byte putSafi(final BgpSubsequentAddressFamily safi) {
final byte[] a = ByteArray.intToBytes(serializeSafi(safi));
return ByteArray.subByte(a, Integer.SIZE / Byte.SIZE - SAFI_SIZE, SAFI_SIZE)[0];
}
- private static int serializeSafi(final BGPSubsequentAddressFamily type) {
+ // FIXME: this shouldn't be here, as we have the values in 2 places
+ private static int serializeSafi(final BgpSubsequentAddressFamily type) {
switch (type) {
case Unicast:
return 1;
- case MPLSLabeledVPN:
+ case MplsLabeledVpn:
return 128;
case Linkstate:
return MPReachParser.LS_SAFI;
import java.util.Set;
import java.util.SortedSet;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
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.concepts.SharedRiskLinkGroup;
import org.opendaylight.protocol.concepts.TEMetric;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
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 NextHop<?> nextHop,
final byte[] bytes) throws BGPParsingException {
if (bytes.length == 0)
return null;
// length means total length of the tlvs including route distinguisher not including the type field
final int length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, LENGTH_SIZE));
byteOffset += LENGTH_SIZE;
- if (safi == BGPSubsequentAddressFamily.MPLSLabeledVPN) {
+ if (safi == BgpSubsequentAddressFamily.MplsLabeledVpn) {
// this parses route distinguisher
ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, ROUTE_DISTINGUISHER_LENGTH));
byteOffset += ROUTE_DISTINGUISHER_LENGTH;
localDescriptor = parseNodeDescriptors(ByteArray.subByte(bytes, byteOffset, locallength));
}
byteOffset += locallength;
- final int restLength = length - ((safi == BGPSubsequentAddressFamily.MPLSLabeledVPN) ? ROUTE_DISTINGUISHER_LENGTH : 0)
+ final int restLength = length - ((safi == BgpSubsequentAddressFamily.MplsLabeledVpn) ? ROUTE_DISTINGUISHER_LENGTH : 0)
- PROTOCOL_ID_LENGTH - IDENTIFIER_LENGTH - TYPE_LENGTH - LENGTH_SIZE - locallength;
logger.debug("Restlength {}", restLength);
switch (type) {
import java.util.Set;
-
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
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.impl.IPv4MP;
import org.opendaylight.protocol.bgp.parser.impl.IPv6MP;
import org.opendaylight.protocol.bgp.parser.impl.MPReach;
-import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.IPv6;
import org.opendaylight.protocol.concepts.IPv6Address;
import org.opendaylight.protocol.concepts.Prefix;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
+
import com.google.common.primitives.UnsignedBytes;
/**
int byteOffset = 0;
final BGPAddressFamily afi = parseAfi(ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, ADDRESS_FAMILY_IDENTIFIER_SIZE)));
byteOffset += ADDRESS_FAMILY_IDENTIFIER_SIZE;
- final BGPSubsequentAddressFamily safi = parseSafi(UnsignedBytes.toInt(bytes[byteOffset]));
+ final BgpSubsequentAddressFamily safi = BgpSubsequentAddressFamily.forValue(UnsignedBytes.toInt(bytes[byteOffset]));
+ if (safi == null)
+ throw new BGPParsingException("Subsequent Address Family Identifier: '" + UnsignedBytes.toInt(bytes[byteOffset])
+ + "' not supported.");
byteOffset += SUBSEQUENT_ADDRESS_FAMILY_IDENTIFIER_SIZE;
return chooseUnreachParser(afi, safi, ByteArray.subByte(bytes, byteOffset, bytes.length - byteOffset));
}
int byteOffset = 0;
final BGPAddressFamily afi = parseAfi(ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, ADDRESS_FAMILY_IDENTIFIER_SIZE)));
byteOffset += ADDRESS_FAMILY_IDENTIFIER_SIZE;
- final BGPSubsequentAddressFamily safi = parseSafi(UnsignedBytes.toInt(bytes[byteOffset]));
+ final BgpSubsequentAddressFamily safi = BgpSubsequentAddressFamily.forValue(UnsignedBytes.toInt(bytes[byteOffset]));
+ if (safi == null)
+ throw new BGPParsingException("Subsequent Address Family Identifier: '" + UnsignedBytes.toInt(bytes[byteOffset])
+ + "' not supported.");
byteOffset += SUBSEQUENT_ADDRESS_FAMILY_IDENTIFIER_SIZE;
final int nextHopLength = UnsignedBytes.toInt(bytes[byteOffset]);
byteOffset += NEXT_HOP_LENGTH_SIZE;
return chooseReachParser(afi, safi, nextHop, ByteArray.subByte(bytes, byteOffset, bytes.length - (byteOffset)));
}
- public static BGPSubsequentAddressFamily parseSafi(final int type) throws BGPParsingException {
- switch (type) {
- case 1:
- return BGPSubsequentAddressFamily.Unicast;
- case LS_SAFI:
- return BGPSubsequentAddressFamily.Linkstate;
- case 128:
- return BGPSubsequentAddressFamily.MPLSLabeledVPN;
- default:
- throw new BGPParsingException("Subsequent Address Family Identifier: '" + type + "' not supported.");
- }
- }
-
public static BGPAddressFamily parseAfi(final int type) throws BGPParsingException {
switch (type) {
case 1:
}
}
- private static MPReach<?> chooseUnreachParser(final BGPAddressFamily afi, final BGPSubsequentAddressFamily safi, final byte[] bytes)
+ private static MPReach<?> chooseUnreachParser(final BGPAddressFamily afi, final BgpSubsequentAddressFamily safi, final byte[] bytes)
throws BGPParsingException {
switch (afi) {
case IPv4:
}
}
- private static MPReach<?> chooseReachParser(final BGPAddressFamily afi, final BGPSubsequentAddressFamily safi,
+ private static MPReach<?> chooseReachParser(final BGPAddressFamily afi, final BgpSubsequentAddressFamily safi,
final NextHop<?> nextHop, final byte[] bytes) throws BGPParsingException {
switch (afi) {
case IPv4:
addr = new IPv6NextHop(IPv6.FAMILY.addressForBytes(bytes));
break;
case 32:
- addr = new IPv6NextHop(IPv6.FAMILY.addressForBytes(ByteArray.subByte(bytes, 0, 16)), IPv6.FAMILY.addressForBytes(ByteArray.subByte(bytes, 16, 16)));
+ addr = new IPv6NextHop(IPv6.FAMILY.addressForBytes(ByteArray.subByte(bytes, 0, 16)), IPv6.FAMILY.addressForBytes(ByteArray.subByte(
+ bytes, 16, 16)));
break;
default:
throw new BGPParsingException("Cannot parse NEXT_HOP attribute. Wrong bytes length: " + bytes.length);
import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
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.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.concepts.Community;
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 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
}
};
assertEquals(expectedMessage.getTableType(), message.getTableType());
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.Unicast);
}
};
assertEquals(expectedMessage.getTableType(), message.getTableType());
@Override
public BGPTableType getTableType() {
- return new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
+ return new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Unicast);
}
};
types.add(((MultiprotocolCapability) param).getTableType());
}
}
- final Set<BGPTableType> expected = Sets.newHashSet(new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast),
- new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast),
- new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate));
+ final Set<BGPTableType> expected = Sets.newHashSet(new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast),
+ new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.Unicast),
+ new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate));
assertEquals(expected, types);
}
@Test
public void testMPReachParser() {
- String msg = "";
- try {
- MPReachParser.parseSafi(5);
- fail("Exception shoul have occured.");
- } catch (final BGPParsingException e) {
- msg = e.getMessage();
- }
- assertEquals("Subsequent Address Family Identifier: '5' not supported.", msg);
-
try {
MPReachParser.parseAfi(6);
fail("Exception should have occured.");
} catch (final BGPParsingException e) {
- msg = e.getMessage();
+ assertEquals("Address Family Identifier: '6' not supported.", e.getMessage());
}
- assertEquals("Address Family Identifier: '6' not supported.", msg);
}
@Test
import org.opendaylight.protocol.bgp.concepts.ASPath;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
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.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.concepts.Community;
import org.opendaylight.protocol.framework.DeserializerException;
import org.opendaylight.protocol.framework.DocumentedException;
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 com.google.common.collect.Lists;
import com.google.common.collect.Maps;
final Map<byte[], List<BGPMessage>> openMap = Maps.newHashMap();
final Set<BGPTableType> type = Sets.newHashSet();
- type.add(new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.MPLSLabeledVPN));
+ type.add(new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.MplsLabeledVpn));
final List<BGPParameter> params = Lists.newArrayList();
- params.add(new MultiprotocolCapability(new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.MPLSLabeledVPN)));
+ params.add(new MultiprotocolCapability(new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.MplsLabeledVpn)));
final byte[] input = new byte[] { 5, 8, 13, 21 };
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPRouteState;
import org.opendaylight.protocol.concepts.Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
public class BGPEventsTest {
@Test
public void testSynchronizedEvent() {
- BGPTableType tt = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.MPLSLabeledVPN);
- RIBSynchronizedEvent event = new RIBSynchronizedEvent(tt);
+ final BGPTableType tt = new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.MplsLabeledVpn);
+ final RIBSynchronizedEvent event = new RIBSynchronizedEvent(tt);
assertEquals(tt, event.getTable());
}
-
+
@Test
public void testChangedEvent() {
- 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());
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (param instanceof CapabilityParameter) {
if (((CapabilityParameter) param).getCode() == MultiprotocolCapability.CODE) {
final MultiprotocolCapability cap = (MultiprotocolCapability) param;
- if (cap.getAfi() == BGPAddressFamily.LinkState && cap.getSafi() == BGPSubsequentAddressFamily.Linkstate) {
+ if (cap.getAfi() == BGPAddressFamily.LinkState && cap.getSafi() == BgpSubsequentAddressFamily.Linkstate) {
this.remotePref = openObj;
this.channel.writeAndFlush(new BGPKeepAliveMessage());
this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, this.remotePref);
import java.util.List;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
import org.opendaylight.protocol.bgp.parser.parameter.AS4BytesCapability;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import com.google.common.collect.Lists;
this.as = as;
this.bgpId = bgpId;
- final BGPTableType ipv4 = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
- final BGPTableType linkstate = new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate);
+ final BGPTableType ipv4 = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
+ final BGPTableType linkstate = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate);
final List<BGPParameter> tlvs = Lists.newArrayList();
tlvs.add(new MultiprotocolCapability(ipv4));
tlvs.add(new MultiprotocolCapability(linkstate));
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
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.bgp.parser.BGPLink;
import org.opendaylight.protocol.bgp.parser.BGPNode;
import org.opendaylight.protocol.bgp.parser.BGPUpdateSynchronized;
import org.opendaylight.protocol.bgp.util.BGPIPv4RouteImpl;
import org.opendaylight.protocol.bgp.util.BGPIPv6RouteImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final BGPObject obj = msg.getAddedObjects().iterator().next();
if (obj instanceof BGPRoute<?>) {
if ((BGPRoute<?>) obj instanceof BGPIPv4RouteImpl) {
- type = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
+ type = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
} else if ((BGPRoute<?>) obj instanceof BGPIPv6RouteImpl) {
- type = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
+ type = new BGPTableType(BGPAddressFamily.IPv6, BgpSubsequentAddressFamily.Unicast);
}
} else if (obj instanceof BGPLink || obj instanceof BGPNode || obj instanceof BGPPrefix<?>) {
- type = new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate);
+ type = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate);
}
}
final SyncVariables s = this.syncStorage.get(type);
s.setEorTrue();
final BGPUpdateSynchronized up = generateEOR(entry.getKey());
logger.debug("Sending synchronization message: {}", up);
- this.listener.onMessage(session, up);
+ this.listener.onMessage(this.session, up);
}
s.setUpd(false);
}
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPUpdateSynchronized;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
public class ApiTest {
@Test
public void testBGPUpdateSynchronized() {
- final BGPTableType tt = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Linkstate);
+ final BGPTableType tt = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Linkstate);
final BGPUpdateSynchronized update = new BGPUpdateSynchronizedImpl(tt);
assertEquals(tt, update.getTableType());
}
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import com.google.common.collect.Lists;
@Mock
private ChannelPipeline pipeline;
- private final BGPTableType ipv4tt = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
+ private final BGPTableType ipv4tt = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
- private final BGPTableType linkstatett = new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate);
+ private final BGPTableType linkstatett = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate);
private final List<BGPMessage> receivedMsgs = Lists.newArrayList();
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
-import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
public class ParserTest {
public static final byte[] openBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
- (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
+ (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
public static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
public static final byte[] notificationBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
final ProtocolMessageFactory<BGPMessage> factory = new BGPMessageFactoryImpl();
@Test
public void testTLVParser() throws UnknownHostException {
- final BGPTableType t1 = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast);
- final BGPTableType t2 = new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Unicast);
+ final BGPTableType t1 = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
+ final BGPTableType t2 = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Unicast);
final List<BGPParameter> tlvs = Lists.newArrayList();
tlvs.add(new MultiprotocolCapability(t1));
import org.junit.Test;
import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
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.bgp.concepts.BaseBGPObjectState;
import org.opendaylight.protocol.bgp.parser.BGPLink;
import org.opendaylight.protocol.bgp.util.BGPIPv6RouteImpl;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import com.google.common.collect.Sets;
this.ipv6m = new BGPUpdateMessageImpl(Sets.<BGPObject> newHashSet(i6), Collections.EMPTY_SET);
this.lsm = new BGPUpdateMessageImpl(Sets.<BGPObject> newHashSet(mock(BGPLink.class)), Collections.EMPTY_SET);
- final Set<BGPTableType> types = Sets.newHashSet(new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.Unicast),
- new BGPTableType(BGPAddressFamily.LinkState, BGPSubsequentAddressFamily.Linkstate));
+ final Set<BGPTableType> types = Sets.newHashSet(new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast),
+ new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate));
this.bs = new BGPSynchronization(new BGPSession() {