import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
+/**
+ * Activator for registering linkstate extensions to BGP parser.
+ */
public final class BGPActivator extends AbstractBGPExtensionProviderActivator {
+
+ private static final int LINKSTATE_AFI = 16388;
+
+ private static final int LINKSTATE_SAFI = 71;
+
@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
final List<AutoCloseable> regs = new ArrayList<>();
- regs.add(context.registerAddressFamily(LinkstateAddressFamily.class, 16388));
- regs.add(context.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, 71));
+ regs.add(context.registerAddressFamily(LinkstateAddressFamily.class, LINKSTATE_AFI));
+ regs.add(context.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, LINKSTATE_SAFI));
- regs.add(context.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, new LinkstateNlriParser(false)));
- regs.add(context.registerNlriParser(LinkstateAddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, new LinkstateNlriParser(true)));
+ regs.add(context.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class,
+ new LinkstateNlriParser(false)));
+ regs.add(context.registerNlriParser(LinkstateAddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class,
+ new LinkstateNlriParser(true)));
regs.add(context.registerAttributeParser(LinkstateAttributeParser.TYPE, new LinkstateAttributeParser()));
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.LinkAttributesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.NodeAttributesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase;
final class LinkstateAdjRIBsIn extends AbstractAdjRIBsIn<CLinkstateDestination, LinkstateRoute> {
private abstract static class LinkstateRIBEntryData<A extends LinkStateAttribute> extends
- RIBEntryData<CLinkstateDestination, LinkstateRoute> {
+ RIBEntryData<CLinkstateDestination, LinkstateRoute> {
private final A lsattr;
protected LinkstateRIBEntryData(final PathAttributes attributes, final A lsattr) {
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return toStringHelper.add("lsattr", lsattr);
+ return toStringHelper.add("lsattr", this.lsattr);
}
}
@Override
protected AttributeType createAttributes(final PrefixAttributesCase lsattr) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.PrefixCaseBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.PrefixCaseBuilder();
-
if (lsattr != null) {
final PrefixAttributes a = lsattr.getPrefixAttributes();
if (a != null) {
b.setPrefixAttributes(builder.build());
}
}
-
return b.build();
}
@Override
protected AttributeType createAttributes(final LinkAttributesCase lsattr) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.LinkCaseBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.LinkCaseBuilder();
-
if (lsattr != null) {
- final LinkAttributes la = lsattr.getLinkAttributes();
- if (la != null) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.link._case.LinkAttributesBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.link._case.LinkAttributesBuilder(la);
- b.setLinkAttributes(builder.build());
+ if (lsattr.getLinkAttributes() != null) {
+ b.setLinkAttributes(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.bgp.rib.rib.loc.rib.tables.routes.linkstate.routes._case.linkstate.routes.linkstate.route.attributes.attribute.type.link._case.LinkAttributesBuilder(lsattr.getLinkAttributes()).build());
}
}
-
return b.build();
}
public void removeRoutes(final DataModificationTransaction trans, final Peer peer, final MpUnreachNlri nlri) {
final DestinationLinkstate keys = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) nlri.getWithdrawnRoutes().getDestinationType()).getDestinationLinkstate();
- for (CLinkstateDestination key : keys.getCLinkstateDestination()) {
+ for (final CLinkstateDestination key : keys.getCLinkstateDestination()) {
super.remove(trans, peer, key);
}
}
import com.google.common.primitives.UnsignedBytes;
/**
- * Parser for Link State information.
+ * Parser for Link State Path Attribute.
*
- * @see <a href="http://tools.ietf.org/html/draft-gredler-idr-ls-distribution-03">BGP-LS draft</a>
+ * @see <a href="http://tools.ietf.org/html/draft-gredler-idr-ls-distribution-04">BGP-LS draft</a>
*/
public class LinkstateAttributeParser implements AttributeParser {
// TODO: replace with actual values by IANA
private static final int LENGTH_SIZE = 2;
- private final NlriType getNlriType(final PathAttributesBuilder pab) {
+ private static final int ROUTE_TAG_LENGTH = 4;
+
+ private static final int EXTENDED_ROUTE_TAG_LENGTH = 8;
+
+ private static final int SRLG_LENGTH = 4;
+
+ private NlriType getNlriType(final PathAttributesBuilder pab) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.PathAttributes1 mpr = pab.getAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.PathAttributes1.class);
if (mpr != null && mpr.getMpReachNlri() != null) {
final DestinationType dt = mpr.getMpReachNlri().getAdvertizedRoutes().getDestinationType();
if (dt instanceof DestinationLinkstateCase) {
- for (CLinkstateDestination d : ((DestinationLinkstateCase)dt).getDestinationLinkstate().getCLinkstateDestination()) {
+ for (final CLinkstateDestination d : ((DestinationLinkstateCase) dt).getDestinationLinkstate().getCLinkstateDestination()) {
return d.getNlriType();
}
}
if (mpu != null && mpu.getMpUnreachNlri() != null) {
final DestinationType dt = mpu.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType();
if (dt instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) {
- for (CLinkstateDestination d : ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase)dt).getDestinationLinkstate().getCLinkstateDestination()) {
+ for (final CLinkstateDestination d : ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) dt).getDestinationLinkstate().getCLinkstateDestination()) {
return d.getNlriType();
}
}
*
* @param attributes key is the tlv type and value is the value of the tlv
* @return {@link LinkStateAttribute}
- * @throws BGPParsingException if a link attribute is not recognized
*/
- private static LinkStateAttribute parseLinkAttributes(final Map<Short, ByteList> attributes) throws BGPParsingException {
+ private static LinkStateAttribute parseLinkAttributes(final Map<Short, ByteList> attributes) {
final LinkAttributesBuilder builder = new LinkAttributesBuilder();
for (final Entry<Short, ByteList> entry : attributes.entrySet()) {
case TlvCode.LINK_PROTECTION_TYPE:
final LinkProtectionType lpt = LinkProtectionType.forValue(UnsignedBytes.toInt(value[0]));
if (lpt == null) {
- throw new BGPParsingException("Link Protection Type not recognized: " + UnsignedBytes.toInt(value[0]));
+ LOG.warn("Link Protection Type not recognized: {}", UnsignedBytes.toInt(value[0]));
+ break;
}
builder.setLinkProtection(lpt);
LOG.debug("Parsed Link Protection Type {}", lpt);
int i = 0;
final List<SrlgId> sharedRiskLinkGroups = Lists.newArrayList();
while (i != value.length) {
- sharedRiskLinkGroups.add(new SrlgId(ByteArray.bytesToLong(ByteArray.subByte(value, i, 4))));
- i += 4;
+ sharedRiskLinkGroups.add(new SrlgId(ByteArray.bytesToLong(ByteArray.subByte(value, i, SRLG_LENGTH))));
+ i += SRLG_LENGTH;
}
builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
LOG.debug("Parsed Shared Risk Link Groups {}", Arrays.toString(sharedRiskLinkGroups.toArray()));
*
* @param attributes key is the tlv type and value is the value of the tlv
* @return {@link LinkStateAttribute}
- * @throws BGPParsingException if a node attribute is not recognized
*/
private static LinkStateAttribute parseNodeAttributes(final Map<Short, ByteList> attributes) {
final List<TopologyIdentifier> topologyMembership = Lists.newArrayList();
case TlvCode.NODE_FLAG_BITS:
final boolean[] flags = ByteArray.parseBits(value[0]);
builder.setNodeFlags(new NodeFlagBits(flags[0], flags[1], flags[2], flags[3]));
- LOG.debug("Parsed External bit {}, area border router {}.", flags[2], flags[3]);
+ LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.", flags[0], flags[1],
+ flags[2], flags[3]);
break;
case TlvCode.NODE_OPAQUE:
LOG.debug("Ignoring opaque value: {}.", Arrays.toString(value));
*
* @param attributes key is the tlv type and value are the value bytes of the tlv
* @return {@link LinkStateAttribute}
- * @throws BGPParsingException if some prefix attributes is not recognized
*/
private static LinkStateAttribute parsePrefixAttributes(final Map<Short, ByteList> attributes) {
final PrefixAttributesBuilder builder = new PrefixAttributesBuilder();
final List<RouteTag> routeTags = Lists.newArrayList();
final List<ExtendedRouteTag> exRouteTags = Lists.newArrayList();
for (final Entry<Short, ByteList> entry : attributes.entrySet()) {
- LOG.debug("Prefix attribute TLV {}", entry.getKey());
+ LOG.trace("Prefix attribute TLV {}", entry.getKey());
for (final byte[] value : entry.getValue().getBytes()) {
switch (entry.getKey()) {
case TlvCode.IGP_FLAGS:
final boolean[] flags = ByteArray.parseBits(value[0]);
final boolean upDownBit = flags[2];
builder.setIgpBits(new IgpBitsBuilder().setUpDown(new UpDown(upDownBit)).build());
- LOG.trace("Parsed IGP flag (up/down bit) : {}", upDownBit);
+ LOG.debug("Parsed IGP flag (up/down bit) : {}", upDownBit);
break;
case TlvCode.ROUTE_TAG:
int offset = 0;
while (offset != value.length) {
- final RouteTag routeTag = new RouteTag(ByteArray.subByte(value, offset, 4));
+ final RouteTag routeTag = new RouteTag(ByteArray.subByte(value, offset, ROUTE_TAG_LENGTH));
routeTags.add(routeTag);
- LOG.trace("Parsed Route Tag: {}", routeTag);
- offset += 4;
+ LOG.debug("Parsed Route Tag: {}", routeTag);
+ offset += ROUTE_TAG_LENGTH;
}
break;
case TlvCode.EXTENDED_ROUTE_TAG:
offset = 0;
while (offset != value.length) {
- final ExtendedRouteTag exRouteTag = new ExtendedRouteTag(value);
+ final ExtendedRouteTag exRouteTag = new ExtendedRouteTag(ByteArray.subByte(value, offset, EXTENDED_ROUTE_TAG_LENGTH));
exRouteTags.add(exRouteTag);
- LOG.trace("Parsed Extended Route Tag: {}", exRouteTag);
- offset += 4;
+ LOG.debug("Parsed Extended Route Tag: {}", exRouteTag);
+ offset += EXTENDED_ROUTE_TAG_LENGTH;
}
break;
case TlvCode.PREFIX_METRIC:
final IgpMetric metric = new IgpMetric(ByteArray.bytesToLong(value));
builder.setPrefixMetric(metric);
- LOG.trace("Parsed Metric: {}", metric);
+ LOG.debug("Parsed Metric: {}", metric);
break;
case TlvCode.FORWARDING_ADDRESS:
IpAddress fwdAddress = null;
switch (value.length) {
- case 4:
+ case Ipv4Util.IP4_LENGTH:
fwdAddress = new IpAddress(Ipv4Util.addressForBytes(value));
break;
- case 16:
+ case Ipv6Util.IPV6_LENGTH:
fwdAddress = new IpAddress(Ipv6Util.addressForBytes(value));
break;
default:
LOG.debug("Ignoring unsupported forwarding address length {}", value.length);
}
- LOG.trace("Parsed FWD Address: {}", fwdAddress);
+ builder.setOspfForwardingAddress(fwdAddress);
+ LOG.debug("Parsed FWD Address: {}", fwdAddress);
break;
case TlvCode.PREFIX_OPAQUE:
LOG.debug("Parsed Opaque value: {}, not preserving it", ByteArray.bytesToHexString(value));
}
}
}
- LOG.debug("Finished parsing Prefix Attributes.");
+ LOG.trace("Finished parsing Prefix Attributes.");
builder.setRouteTags(routeTags);
builder.setExtendedTags(exRouteTags);
return new PrefixAttributesCaseBuilder().setPrefixAttributes(builder.build()).build();
import com.google.common.primitives.UnsignedBytes;
import com.google.common.primitives.UnsignedInteger;
+/**
+ * Parser and serializer for Linkstate NLRI.
+ */
public final class LinkstateNlriParser implements NlriParser {
private static final Logger LOG = LoggerFactory.getLogger(LinkstateNlriParser.class);
private static final int ROUTE_DISTINGUISHER_LENGTH = 8;
private static final int PROTOCOL_ID_LENGTH = 1;
private static final int IDENTIFIER_LENGTH = 8;
+ private static final int LINK_IDENTIFIER_LENGTH = 4;
+ private static final int ISO_SYSTEM_ID_LENGTH = 6;
+ private static final int PSN_LENGTH = 1;
private static final int TYPE_LENGTH = 2;
private static final int LENGTH_SIZE = 2;
LOG.trace("Parsing Link Descriptor: {}", Arrays.toString(value));
switch (type) {
case TlvCode.LINK_LR_IDENTIFIERS:
- builder.setLinkLocalIdentifier(ByteArray.bytesToUint32(ByteArray.subByte(value, 0, 4)).longValue());
- builder.setLinkRemoteIdentifier(ByteArray.bytesToUint32(ByteArray.subByte(value, 4, 4)).longValue());
+ builder.setLinkLocalIdentifier(ByteArray.bytesToUint32(ByteArray.subByte(value, 0, LINK_IDENTIFIER_LENGTH)).longValue());
+ builder.setLinkRemoteIdentifier(ByteArray.bytesToUint32(
+ ByteArray.subByte(value, LINK_IDENTIFIER_LENGTH, LINK_IDENTIFIER_LENGTH)).longValue());
LOG.debug("Parsed link local {} remote {} Identifiers.", builder.getLinkLocalIdentifier(),
builder.getLinkRemoteIdentifier());
break;
}
private static CRouterIdentifier parseRouterId(final byte[] value) throws BGPParsingException {
- if (value.length == 6) {
+ if (value.length == ISO_SYSTEM_ID_LENGTH) {
return new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(ByteArray.subByte(value, 0, 6))).build()).build();
+ new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(ByteArray.subByte(value, 0, ISO_SYSTEM_ID_LENGTH))).build()).build();
}
- if (value.length == 7) {
- if (value[6] == 0) {
+ if (value.length == ISO_SYSTEM_ID_LENGTH + PSN_LENGTH) {
+ if (value[ISO_SYSTEM_ID_LENGTH] == 0) {
LOG.warn("PSN octet is 0. Ignoring System ID.");
return new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(ByteArray.subByte(value, 0, 6))).build()).build();
+ new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(ByteArray.subByte(value, 0, ISO_SYSTEM_ID_LENGTH))).build()).build();
} else {
final IsIsRouterIdentifier iri = new IsIsRouterIdentifierBuilder().setIsoSystemId(
- new IsoSystemIdentifier(ByteArray.subByte(value, 0, 6))).build();
+ new IsoSystemIdentifier(ByteArray.subByte(value, 0, ISO_SYSTEM_ID_LENGTH))).build();
return new IsisPseudonodeCaseBuilder().setIsisPseudonode(
- new IsisPseudonodeBuilder().setIsIsRouterIdentifier(iri).setPsn((short) UnsignedBytes.toInt(value[6])).build()).build();
+ new IsisPseudonodeBuilder().setIsIsRouterIdentifier(iri).setPsn(
+ (short) UnsignedBytes.toInt(value[ISO_SYSTEM_ID_LENGTH])).build()).build();
}
}
if (value.length == 4) {
- return new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(ByteArray.bytesToUint32(value).longValue()).build()).build();
+ return new OspfNodeCaseBuilder().setOspfNode(
+ new OspfNodeBuilder().setOspfRouterId(ByteArray.bytesToUint32(value).longValue()).build()).build();
}
if (value.length == 8) {
final byte[] o = ByteArray.subByte(value, 0, 4);
case TlvCode.IP_REACHABILITY:
IpPrefix prefix = null;
final int prefixLength = UnsignedBytes.toInt(value[0]);
- final int size = prefixLength / 8 + ((prefixLength % 8 == 0) ? 0 : 1);
+ final int size = prefixLength / Byte.SIZE + ((prefixLength % Byte.SIZE == 0) ? 0 : 1);
if (size != value.length - 1) {
LOG.debug("Expected length {}, actual length {}.", size, value.length - 1);
throw new BGPParsingException("Illegal length of IP reachability TLV: " + (value.length - 1));
/**
* Parses common parts for Link State Nodes, Links and Prefixes, that includes protocol ID and identifier tlv.
*
- * @param nlri
- * @return BGPLinkMP or BGPNodeMP
- * @throws BGPParsingException
+ * @param nlri as byte array
+ * @return {@link CLinkstateDestination}
+ * @throws BGPParsingException if parsing was unsuccessful
*/
private List<CLinkstateDestination> parseNlri(final byte[] nlri) throws BGPParsingException {
if (nlri.length == 0) {
@Override
public void parseNlri(final byte[] nlri, final byte[] nextHop, final MpReachNlriBuilder builder) throws BGPParsingException {
+ if (nlri.length == 0) {
+ return;
+ }
final List<CLinkstateDestination> dst = parseNlri(nlri);
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
NlriUtil.parseNextHop(nextHop, builder);
}
+ /**
+ * Serializes Linkstate NLRI to byte array. We need this as NLRI serves as a key in upper layers.
+ *
+ * @param destination Linkstate NLRI to be serialized
+ * @return byte array
+ */
public static byte[] serializeNlri(final CLinkstateDestination destination) {
final ByteBuf finalBuffer = Unpooled.buffer();
finalBuffer.writeShort(destination.getNlriType().getIntValue());
final IsisNode isis = ((IsisNodeCase) routerId).getIsisNode();
bytes = isis.getIsoSystemId().getValue();
} else if (routerId instanceof IsisPseudonodeCase) {
- bytes = new byte[6 + 1];
+ bytes = new byte[ISO_SYSTEM_ID_LENGTH + PSN_LENGTH];
final IsisPseudonode isis = ((IsisPseudonodeCase) routerId).getIsisPseudonode();
ByteArray.copyWhole(isis.getIsIsRouterIdentifier().getIsoSystemId().getValue(), bytes, 0);
bytes[6] = UnsignedBytes.checkedCast((isis.getPsn() != null) ? isis.getPsn() : 0);
private static void serializeLinkDescriptors(final ByteBuf buffer, final LinkDescriptors descriptors) {
if (descriptors.getLinkLocalIdentifier() != null && descriptors.getLinkRemoteIdentifier() != null) {
buffer.writeShort(TlvCode.LINK_LR_IDENTIFIERS);
- buffer.writeShort(8);
+ buffer.writeShort(LINK_IDENTIFIER_LENGTH);
buffer.writeInt(UnsignedInteger.valueOf(descriptors.getLinkLocalIdentifier()).intValue());
buffer.writeInt(UnsignedInteger.valueOf(descriptors.getLinkRemoteIdentifier()).intValue());
}
import com.google.common.collect.Lists;
+/**
+ * Activator for registering Linkstate AFI/SAFI to RIB.
+ */
public final class RIBActivator extends AbstractRIBExtensionProviderActivator {
@Override
protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- return Lists.newArrayList(context.registerAdjRIBsInFactory(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, new AdjRIBsInFactory() {
- @Override
- public AdjRIBsIn createAdjRIBsIn(final DataModificationTransaction trans, final RibReference rib, final Comparator<PathAttributes> comparator, final TablesKey key) {
- return new LinkstateAdjRIBsIn(trans, rib, comparator, key);
- }
- }));
+ return Lists.newArrayList(context.registerAdjRIBsInFactory(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class,
+ new AdjRIBsInFactory() {
+ @Override
+ public AdjRIBsIn createAdjRIBsIn(final DataModificationTransaction trans, final RibReference rib,
+ final Comparator<PathAttributes> comparator, final TablesKey key) {
+ return new LinkstateAdjRIBsIn(trans, rib, comparator, key);
+ }
+ }));
}
}
*/
package org.opendaylight.protocol.bgp.linkstate;
-public final class TlvCode {
+final class TlvCode {
private TlvCode() {
}
- public static final short LOCAL_NODE_DESCRIPTORS = 256;
+ static final short LOCAL_NODE_DESCRIPTORS = 256;
- public static final short REMOTE_NODE_DESCRIPTORS = 257;
+ static final short REMOTE_NODE_DESCRIPTORS = 257;
/* Link Descriptor TLVs */
- public static final short LINK_LR_IDENTIFIERS = 258;
+ static final short LINK_LR_IDENTIFIERS = 258;
- public static final short IPV4_IFACE_ADDRESS = 259;
+ static final short IPV4_IFACE_ADDRESS = 259;
- public static final short IPV4_NEIGHBOR_ADDRESS = 260;
+ static final short IPV4_NEIGHBOR_ADDRESS = 260;
- public static final short IPV6_IFACE_ADDRESS = 261;
+ static final short IPV6_IFACE_ADDRESS = 261;
- public static final short IPV6_NEIGHBOR_ADDRESS = 262;
+ static final short IPV6_NEIGHBOR_ADDRESS = 262;
/* Link Attribute TLVs */
- public static final short LOCAL_IPV4_ROUTER_ID = 1028;
+ static final short LOCAL_IPV4_ROUTER_ID = 1028;
- public static final short LOCAL_IPV6_ROUTER_ID = 1029;
+ static final short LOCAL_IPV6_ROUTER_ID = 1029;
- public static final short REMOTE_IPV4_ROUTER_ID = 1030;
+ static final short REMOTE_IPV4_ROUTER_ID = 1030;
- public static final short REMOTE_IPV6_ROUTER_ID = 1031;
+ static final short REMOTE_IPV6_ROUTER_ID = 1031;
- public static final short ADMIN_GROUP = 1088;
+ static final short ADMIN_GROUP = 1088;
- public static final short MAX_BANDWIDTH = 1089;
+ static final short MAX_BANDWIDTH = 1089;
- public static final short MAX_RESERVABLE_BANDWIDTH = 1090;
+ static final short MAX_RESERVABLE_BANDWIDTH = 1090;
- public static final short UNRESERVED_BANDWIDTH = 1091;
+ static final short UNRESERVED_BANDWIDTH = 1091;
- public static final short TE_METRIC = 1092;
+ static final short TE_METRIC = 1092;
- public static final short LINK_PROTECTION_TYPE = 1093;
+ static final short LINK_PROTECTION_TYPE = 1093;
- public static final short MPLS_PROTOCOL = 1094;
+ static final short MPLS_PROTOCOL = 1094;
- public static final short METRIC = 1095;
+ static final short METRIC = 1095;
- public static final short SHARED_RISK_LINK_GROUP = 1096;
+ static final short SHARED_RISK_LINK_GROUP = 1096;
- public static final short LINK_OPAQUE = 1097;
+ static final short LINK_OPAQUE = 1097;
- public static final short LINK_NAME = 1098;
+ static final short LINK_NAME = 1098;
/* Prefix Descriptor TLVs */
- public static final short MULTI_TOPOLOGY_ID = 263;
+ static final short MULTI_TOPOLOGY_ID = 263;
- public static final short OSPF_ROUTE_TYPE = 264;
+ static final short OSPF_ROUTE_TYPE = 264;
- public static final short IP_REACHABILITY = 265;
+ static final short IP_REACHABILITY = 265;
/* Prefix Attribute TLVs */
- public static final short IGP_FLAGS = 1152;
+ static final short IGP_FLAGS = 1152;
- public static final short ROUTE_TAG = 1153;
+ static final short ROUTE_TAG = 1153;
- public static final short EXTENDED_ROUTE_TAG = 1154;
+ static final short EXTENDED_ROUTE_TAG = 1154;
- public static final short PREFIX_METRIC = 1155;
+ static final short PREFIX_METRIC = 1155;
- public static final short FORWARDING_ADDRESS = 1156;
+ static final short FORWARDING_ADDRESS = 1156;
- public static final short PREFIX_OPAQUE = 1157;
+ static final short PREFIX_OPAQUE = 1157;
/* Node Descriptor TLVs */
- public static final short AS_NUMBER = 512;
+ static final short AS_NUMBER = 512;
- public static final short BGP_LS_ID = 513;
+ static final short BGP_LS_ID = 513;
- public static final short AREA_ID = 514;
+ static final short AREA_ID = 514;
- public static final short IGP_ROUTER_ID = 515;
+ static final short IGP_ROUTER_ID = 515;
/* Node Attribute TLVs */
- public static final short NODE_FLAG_BITS = 1024;
+ static final short NODE_FLAG_BITS = 1024;
- public static final short NODE_OPAQUE = 1025;
+ static final short NODE_OPAQUE = 1025;
- public static final short DYNAMIC_HOSTNAME = 1026;
+ static final short DYNAMIC_HOSTNAME = 1026;
- public static final short ISIS_AREA_IDENTIFIER = 1027;
+ static final short ISIS_AREA_IDENTIFIER = 1027;
}
type netc:igp-metric;
}
leaf ospf-forwarding-address {
- type inet:ipv4-address;
+ type inet:ip-address;
}
}
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkProtectionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.NlriType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.CLinkstateDestinationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.LinkAttributesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.NodeAttributesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.PathAttributesBuilder;
public class LinkstateAttributeParserTest {
private static final byte[] LINK_ATTR = new byte[] { (byte) 0x04, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x2a, (byte) 0x2a,
- (byte) 0x2a, (byte) 0x2a, (byte) 0x04, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x2b, (byte) 0x2b, (byte) 0x2b,
- (byte) 0x2b, (byte) 0x04, (byte) 0x40, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x04, (byte) 0x41, (byte) 0x00, (byte) 0x04, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x04,
- (byte) 0x42, (byte) 0x00, (byte) 0x04, (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00, (byte) 0x04, (byte) 0x43,
- (byte) 0x00, (byte) 0x20, (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00, (byte) 0x46, (byte) 0x43, (byte) 0x50,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x44,
- (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x47, (byte) 0x00, (byte) 0x03,
- (byte) 0x00, (byte) 0x00, (byte) 0x0a };
-
- private static final byte[] NODE_ATTR = new byte[] { (byte) 0x04, (byte) 0x02, (byte) 0x00, (byte) 0x05, (byte) 0x31, (byte) 0x32,
- (byte) 0x4b, (byte) 0x2d, (byte) 0x32, (byte) 0x04, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x72, (byte) 0x04,
- (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x29, (byte) 0x29, (byte) 0x29, (byte) 0x29 };
+ (byte) 0x2a, (byte) 0x2a, (byte) 0x04, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x2b, (byte) 0x2b, (byte) 0x2b,
+ (byte) 0x2b, (byte) 0x04, (byte) 0x40, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x04, (byte) 0x41, (byte) 0x00, (byte) 0x04, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x04,
+ (byte) 0x42, (byte) 0x00, (byte) 0x04, (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00, (byte) 0x04, (byte) 0x43,
+ (byte) 0x00, (byte) 0x20, (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00, (byte) 0x46, (byte) 0x43, (byte) 0x50,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x44,
+ (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x45, (byte) 0x00, (byte) 0x01,
+ (byte) 0x08, (byte) 0x04, (byte) 0x46, (byte) 0x00, (byte) 0x01, (byte) 0xc0, (byte) 0x04, (byte) 0x47, (byte) 0x00,
+ (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x04, (byte) 0x48, (byte) 0x00, (byte) 0x08, (byte) 0x12,
+ (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70, (byte) 0x04, (byte) 0x4a,
+ (byte) 0x00, (byte) 0x05, (byte) 0x31, (byte) 0x32, (byte) 0x4b, (byte) 0x2d, (byte) 0x32,
+
+ (byte) 0x04, (byte) 0x88, (byte) 0x00, (byte) 0x01, (byte) 0x0a };
+
+ private static final byte[] NODE_ATTR = new byte[] { (byte) 0x01, (byte) 0x07, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x2a,
+ (byte) 0x00, (byte) 0x2b, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0xb0, (byte) 0x04, (byte) 0x02,
+ (byte) 0x00, (byte) 0x05, (byte) 0x31, (byte) 0x32, (byte) 0x4b, (byte) 0x2d, (byte) 0x32, (byte) 0x04, (byte) 0x03,
+ (byte) 0x00, (byte) 0x01, (byte) 0x72, (byte) 0x04, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0x29, (byte) 0x29,
+ (byte) 0x29, (byte) 0x29, (byte) 0x04, (byte) 0x88, (byte) 0x00, (byte) 0x01, (byte) 0x0a };
+
+ private static final byte[] P4_ATTR = new byte[] { (byte) 0x04, (byte) 0x80, (byte) 0x00, (byte) 0x01, (byte) 0xff, (byte) 0x04,
+ (byte) 0x81, (byte) 0x00, (byte) 0x08, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30,
+ (byte) 0x50, (byte) 0x70, (byte) 0x04, (byte) 0x82, (byte) 0x00, (byte) 0x08, (byte) 0x12, (byte) 0x34, (byte) 0x56,
+ (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70, (byte) 0x04, (byte) 0x83, (byte) 0x00, (byte) 0x04,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x04, (byte) 0x84, (byte) 0x00, (byte) 0x04, (byte) 0x0a,
+ (byte) 0x19, (byte) 0x02, (byte) 0x1b, (byte) 0x04, (byte) 0x85, (byte) 0x00, (byte) 0x01, (byte) 0x0a, (byte) 0x04,
+ (byte) 0x88, (byte) 0x00, (byte) 0x01, (byte) 0x0a };
private final LinkstateAttributeParser parser = new LinkstateAttributeParser();
private static PathAttributesBuilder createBuilder(final NlriType type) {
- return new PathAttributesBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.PathAttributes1.class,
+ return new PathAttributesBuilder().addAugmentation(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.PathAttributes1.class,
new PathAttributes1Builder().setMpReachNlri(
new MpReachNlriBuilder().setAfi(LinkstateAddressFamily.class).setSafi(LinkstateSubsequentAddressFamily.class).setAdvertizedRoutes(
new AdvertizedRoutesBuilder().setDestinationType(
assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getMaxReservableBandwidth().getValue());
assertNotNull(ls.getUnreservedBandwidth());
assertEquals(8, ls.getUnreservedBandwidth().size());
+ assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
+ assertTrue(ls.getMplsProtocol().isLdp());
+ assertTrue(ls.getMplsProtocol().isRsvpte());
+ assertEquals(2, ls.getSharedRiskLinkGroups().size());
+ assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
+ assertEquals("12K-2", ls.getLinkName());
}
@Test
final NodeAttributes ls = ((NodeAttributesCase) attrs.getLinkstatePathAttribute().getLinkStateAttribute()).getNodeAttributes();
assertNotNull(ls);
+ assertEquals(2, ls.getTopologyIdentifier().size());
+ assertEquals(42, ls.getTopologyIdentifier().get(0).getValue().intValue());
+ assertTrue(ls.getNodeFlags().isOverload());
+ assertFalse(ls.getNodeFlags().isAttached());
+ assertTrue(ls.getNodeFlags().isExternal());
+ assertTrue(ls.getNodeFlags().isAbr());
+
assertEquals("12K-2", ls.getDynamicHostname());
assertEquals(1, ls.getIsisAreaId().size());
assertArrayEquals(new byte[] { 114 }, ls.getIsisAreaId().get(0).getValue());
assertEquals("41.41.41.41", ls.getIpv4RouterId().getValue());
}
+
+ @Test
+ public void testPositiveV4Prefixes() throws BGPParsingException {
+ final PathAttributesBuilder builder = createBuilder(NlriType.Ipv4Prefix);
+ this.parser.parseAttribute(P4_ATTR, builder);
+
+ final PathAttributes1 attrs = builder.getAugmentation(PathAttributes1.class);
+ final PrefixAttributes ls = ((PrefixAttributesCase) attrs.getLinkstatePathAttribute().getLinkStateAttribute()).getPrefixAttributes();
+ assertNotNull(ls);
+
+ assertTrue(ls.getIgpBits().getUpDown().isUpDown());
+ assertEquals(2, ls.getRouteTags().size());
+ assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }, ls.getRouteTags().get(0).getValue());
+ assertEquals(1, ls.getExtendedTags().size());
+ assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50,
+ (byte) 0x70 }, ls.getExtendedTags().get(0).getValue());
+ assertEquals(10, ls.getPrefixMetric().getValue().intValue());
+ assertEquals("10.25.2.27", ls.getOspfForwardingAddress().getIpv4Address().getValue());
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.OspfRouteType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.ProtocolId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.TopologyIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.isis.lan.identifier.IsIsRouterIdentifierBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.CLinkstateDestination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.c.linkstate.destination.LinkDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.c.linkstate.destination.LocalNodeDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.c.linkstate.destination.PrefixDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.linkstate.destination.c.linkstate.destination.RemoteNodeDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.IsisNodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.IsisPseudonodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.OspfNodeCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.isis.node._case.IsisNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.isis.pseudonode._case.IsisPseudonodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.node.identifier.c.router.identifier.ospf.node._case.OspfNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationLinkstateCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.linkstate._case.DestinationLinkstate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.path.attributes.MpReachNlriBuilder;
public class LinkstateNlriParserTest {
- private final byte[] nodeNlri = new byte[] { (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x27, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+ private final byte[] nodeNlri = new byte[] { (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x30, (byte) 0x02, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00,
- (byte) 0x1a, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x48,
+ (byte) 0x23, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x48,
(byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x02,
- (byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x39 };
+ (byte) 0x02, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x29, (byte) 0x29, (byte) 0x29, (byte) 0x02, (byte) 0x03,
+ (byte) 0x00, (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x39, (byte) 0x05 };
- private final byte[] linkNlri = new byte[] { (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x55, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+ private final byte[] linkNlri = new byte[] { (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x53, (byte) 0x02, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x1a, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x48,
(byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x02,
(byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42,
- (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x1a, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00,
+ (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x18, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x48, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x28, (byte) 0x28,
- (byte) 0x28, (byte) 0x28, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x40, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0xc5, (byte) 0x14,
- (byte) 0xa0, (byte) 0x2a, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0xc5, (byte) 0x14, (byte) 0xa0,
- (byte) 0x28 };
+ (byte) 0x28, (byte) 0x28, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x40, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0xc5, (byte) 0x14, (byte) 0xa0, (byte) 0x2a,
+ (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x04, (byte) 0xc5, (byte) 0x14, (byte) 0xa0, (byte) 0x28 };
private final byte[] prefixNlri = new byte[] { (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x39, (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00,
assertEquals(new AsNumber(72L), nodeD.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), nodeD.getDomainId());
assertEquals(
- new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(
- new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x39 })).build()).build(), nodeD.getCRouterIdentifier());
+ new IsisPseudonodeCaseBuilder().setIsisPseudonode(
+ new IsisPseudonodeBuilder().setPsn((short) 5).setIsIsRouterIdentifier(
+ new IsIsRouterIdentifierBuilder().setIsoSystemId(
+ new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x39 })).build()).build()).build(), nodeD.getCRouterIdentifier());
assertNull(dest.getRemoteNodeDescriptors());
final RemoteNodeDescriptors remote = dest.getRemoteNodeDescriptors();
assertEquals(new AsNumber(72L), remote.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), remote.getDomainId());
- assertEquals(
- new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(
- new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x40 })).build()).build(), remote.getCRouterIdentifier());
+ assertEquals(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x00000040L).build()).build(),
+ remote.getCRouterIdentifier());
final LinkDescriptors ld = dest.getLinkDescriptors();
assertEquals("197.20.160.42", ld.getIpv4InterfaceAddress().getValue());
assertEquals("197.20.160.40", ld.getIpv4NeighborAddress().getValue());
private synchronized void addLink(final LinkId id, final boolean isRemote) {
if (isRemote) {
- remote.add(id);
+ this.remote.add(id);
} else {
- local.add(id);
+ this.local.add(id);
}
}
private synchronized boolean removeLink(final LinkId id, final boolean isRemote) {
final boolean removed;
if (isRemote) {
- removed = remote.remove(id);
+ removed = this.remote.remove(id);
} else {
- removed = local.remove(id);
+ removed = this.local.remove(id);
}
if (!removed) {
- LOG.warn("Removed non-reference link {} from TP {} isRemote {}", tp.getTpId(), id, isRemote);
+ LOG.warn("Removed non-reference link {} from TP {} isRemote {}", this.tp.getTpId(), id, isRemote);
}
- return local.isEmpty() && remote.isEmpty();
+ return this.local.isEmpty() && this.remote.isEmpty();
}
private TerminationPoint getTp() {
- return tp;
+ return this.tp;
}
}
NodeBuilder nb;
private NodeHolder(final NodeId id) {
- inab = new IgpNodeAttributesBuilder();
- nb = new NodeBuilder().setKey(new NodeKey(id)).setNodeId(id);
+ this.inab = new IgpNodeAttributesBuilder();
+ this.nb = new NodeBuilder().setKey(new NodeKey(id)).setNodeId(id);
}
/**
}
// Re-generate termination points
- nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(tps.values(), new Function<TpHolder, TerminationPoint>() {
- @Override
- public TerminationPoint apply(final TpHolder input) {
- return input.getTp();
- }
- })));
+ this.nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(this.tps.values(),
+ new Function<TpHolder, TerminationPoint>() {
+ @Override
+ public TerminationPoint apply(final TpHolder input) {
+ return input.getTp();
+ }
+ })));
// Re-generate prefixes
- inab.setPrefix(Lists.newArrayList(prefixes.values()));
+ this.inab.setPrefix(Lists.newArrayList(this.prefixes.values()));
// Write the node out
- final Node n = nb.addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes(inab.build()).build()).build();
+ final Node n = this.nb.addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes(this.inab.build()).build()).build();
trans.putOperationalData(nid, n);
LOG.debug("Created node {} at {}", n, nid);
return false;
}
private synchronized void removeTp(final TpId tp, final LinkId link, final boolean isRemote) {
- final TpHolder h = tps.get(tp);
+ final TpHolder h = this.tps.get(tp);
if (h != null) {
if (h.removeLink(link, isRemote)) {
- tps.remove(tp);
+ this.tps.remove(tp);
LOG.debug("Removed TP {}", tp);
}
} else {
}
private void addTp(final TerminationPoint tp, final LinkId link, final boolean isRemote) {
- TpHolder h = tps.get(tp.getTpId());
+ TpHolder h = this.tps.get(tp.getTpId());
if (h == null) {
h = new TpHolder(tp);
- tps.put(tp.getTpId(), h);
+ this.tps.put(tp.getTpId(), h);
}
h.addLink(link, isRemote);
}
private void addPrefix(final Prefix pfx) {
- prefixes.put(pfx.getKey(), pfx);
+ this.prefixes.put(pfx.getKey(), pfx);
}
private void removePrefix(final PrefixCase p) {
- prefixes.remove(new PrefixKey(p.getIpReachabilityInformation()));
+ this.prefixes.remove(new PrefixKey(p.getIpReachabilityInformation()));
}
private void unadvertized() {
- inab = new IgpNodeAttributesBuilder();
- nb = new NodeBuilder().setKey(nb.getKey()).setNodeId(nb.getNodeId());
- advertized = false;
- LOG.debug("Node {} is unadvertized", nb.getNodeId());
+ this.inab = new IgpNodeAttributesBuilder();
+ this.nb = new NodeBuilder().setKey(this.nb.getKey()).setNodeId(this.nb.getNodeId());
+ this.advertized = false;
+ LOG.debug("Node {} is unadvertized", this.nb.getNodeId());
}
private void advertized(final NodeBuilder nb, final IgpNodeAttributesBuilder inab) {
this.nb = Preconditions.checkNotNull(nb);
this.inab = Preconditions.checkNotNull(inab);
- advertized = true;
+ this.advertized = true;
LOG.debug("Node {} is advertized", nb.getNodeId());
}
private Object getNodeId() {
- return nb.getNodeId();
+ return this.nb.getNodeId();
}
}
}
private NodeHolder getNode(final NodeId id) {
- if (nodes.containsKey(id)) {
+ if (this.nodes.containsKey(id)) {
LOG.debug("Node {} is already present", id);
- return nodes.get(id);
+ return this.nodes.get(id);
}
final NodeHolder ret = new NodeHolder(id);
- nodes.put(id, ret);
+ this.nodes.put(id, ret);
return ret;
}
private void putNode(final DataModification<InstanceIdentifier<?>, DataObject> trans, final NodeHolder holder) {
if (holder.syncState(trans)) {
- nodes.remove(holder.getNodeId());
+ this.nodes.remove(holder.getNodeId());
}
}
LOG.debug("Created link {} at {} for {}", link, lid, l);
}
- private void removeTp(final DataModification<InstanceIdentifier<?>, DataObject> trans,
- final NodeId node, final TpId tp, final LinkId link, final boolean isRemote) {
- final NodeHolder nh = nodes.get(node);
+ private void removeTp(final DataModification<InstanceIdentifier<?>, DataObject> trans, final NodeId node, final TpId tp,
+ final LinkId link, final boolean isRemote) {
+ final NodeHolder nh = this.nodes.get(node);
if (nh != null) {
nh.removeTp(tp, link, isRemote);
putNode(trans, nh);
private void removeNode(final DataModification<InstanceIdentifier<?>, DataObject> trans, final UriBuilder base, final NodeCase n) {
final NodeId id = buildNodeId(base, n.getNodeDescriptors());
- final NodeHolder nh = nodes.get(id);
+ final NodeHolder nh = this.nodes.get(id);
if (nh != null) {
nh.unadvertized();
putNode(trans, nh);
pb.addAugmentation(
Prefix1.class,
new Prefix1Builder().setOspfPrefixAttributes(
- new OspfPrefixAttributesBuilder().setForwardingAddress(pa.getOspfForwardingAddress()).build()).build());
+ new OspfPrefixAttributesBuilder().setForwardingAddress(pa.getOspfForwardingAddress().getIpv4Address()).build()).build());
}
break;
}
private void removePrefix(final DataModification<InstanceIdentifier<?>, DataObject> trans, final UriBuilder base, final PrefixCase p) {
final NodeId node = buildNodeId(base, p.getAdvertisingNodeDescriptors());
- final NodeHolder nh = nodes.get(node);
+ final NodeHolder nh = this.nodes.get(node);
if (nh != null) {
nh.removePrefix(p);
LOG.debug("Removed prefix {}", p);