This fixes up a pile of warnings and flips the switch.
JIRA: BGPCEP-713
Change-Id: I0ed6c260558a4fee42c4432da4c137245984c42a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <violationSeverity>warn</violationSeverity>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
DestinationLinkstate.QNAME);
}
- public synchronized static LinkstateRIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
- if(SINGLETON == null){
+ public static synchronized LinkstateRIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
+ if (SINGLETON == null) {
SINGLETON = new LinkstateRIBSupport(mappingService);
}
return SINGLETON;
private static final int UTILIZED_BANDWIDTH = 1120;
private LinkAttributesParser() {
- throw new UnsupportedOperationException();
+
}
@FunctionalInterface
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
- static LinkStateAttribute parseLinkAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
+ static LinkStateAttribute parseLinkAttributes(final Multimap<Integer, ByteBuf> attributes,
+ final ProtocolId protocolId) {
final LinkAttributesBuilder builder = new LinkAttributesBuilder();
final List<SrAdjIds> srAdjIds = new ArrayList<>();
final List<SrLanAdjIds> srLanAdjIds = new ArrayList<>();
final int key = entry.getKey();
final ByteBuf value = entry.getValue();
switch (key) {
- case TlvUtil.LOCAL_IPV4_ROUTER_ID:
- builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
- LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
- break;
- case TlvUtil.LOCAL_IPV6_ROUTER_ID:
- builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
- LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
- break;
- case REMOTE_IPV4_ROUTER_ID:
- builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
- LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
- break;
- case REMOTE_IPV6_ROUTER_ID:
- builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
- LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
- break;
- case ADMIN_GROUP:
- builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
- LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
- break;
- case MAX_BANDWIDTH:
- builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
- LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
- break;
- case MAX_RESERVABLE_BANDWIDTH:
- builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
- LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
- break;
- case UNRESERVED_BANDWIDTH:
- parseUnreservedBandwidth(value, builder);
- break;
- case TE_METRIC:
- builder.setTeMetric(new TeMetric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
- LOG.debug("Parsed Metric {}", builder.getTeMetric());
- break;
- case LINK_PROTECTION_TYPE:
- builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
- LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
- break;
- case MPLS_PROTOCOL:
- final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
- builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
- LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
- break;
- case METRIC:
- // length can 3, 2 or 1
- builder.setMetric(new Metric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
- LOG.debug("Parsed Metric {}", builder.getMetric());
- break;
- case SHARED_RISK_LINK_GROUP:
- parseSrlg(value, builder);
- break;
- case LINK_OPAQUE:
- LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
- break;
- case LINK_NAME:
- builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
- LOG.debug("Parsed Link Name : {}", builder.getLinkName());
- break;
- case SR_ADJ_ID:
- srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
- LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
- break;
- case SR_LAN_ADJ_ID:
- srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
- LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
- break;
- case PEER_NODE_SID_CODE:
- builder.setPeerNodeSid(new PeerNodeSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
- LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
- break;
- case PEER_ADJ_SID_CODE:
- builder.setPeerAdjSid(new PeerAdjSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
- LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
- break;
- case PEER_SET_SID_CODE:
- peerSetSids.add(new PeerSetSidsBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
- LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
- break;
- // Performance Metrics
- case LINK_DELAY:
- builder.setLinkDelay(new Delay(value.readUnsignedInt()));
- LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
- break;
- case LINK_MIN_MAX_DELAY:
- builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder().setMinDelay(new Delay(value.readUnsignedInt()))
+ case TlvUtil.LOCAL_IPV4_ROUTER_ID:
+ builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
+ LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
+ break;
+ case TlvUtil.LOCAL_IPV6_ROUTER_ID:
+ builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
+ LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
+ break;
+ case REMOTE_IPV4_ROUTER_ID:
+ builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
+ LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
+ break;
+ case REMOTE_IPV6_ROUTER_ID:
+ builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
+ LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
+ break;
+ case ADMIN_GROUP:
+ builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
+ LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
+ break;
+ case MAX_BANDWIDTH:
+ builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
+ LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
+ break;
+ case MAX_RESERVABLE_BANDWIDTH:
+ builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
+ LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
+ break;
+ case UNRESERVED_BANDWIDTH:
+ parseUnreservedBandwidth(value, builder);
+ break;
+ case TE_METRIC:
+ builder.setTeMetric(new TeMetric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
+ LOG.debug("Parsed Metric {}", builder.getTeMetric());
+ break;
+ case LINK_PROTECTION_TYPE:
+ builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
+ LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
+ break;
+ case MPLS_PROTOCOL:
+ final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
+ builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
+ LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
+ break;
+ case METRIC:
+ // length can 3, 2 or 1
+ builder.setMetric(new Metric(ByteArray.bytesToLong(ByteArray.readAllBytes(value))));
+ LOG.debug("Parsed Metric {}", builder.getMetric());
+ break;
+ case SHARED_RISK_LINK_GROUP:
+ parseSrlg(value, builder);
+ break;
+ case LINK_OPAQUE:
+ LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
+ break;
+ case LINK_NAME:
+ builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
+ LOG.debug("Parsed Link Name : {}", builder.getLinkName());
+ break;
+ case SR_ADJ_ID:
+ srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
+ LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
+ break;
+ case SR_LAN_ADJ_ID:
+ srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
+ LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
+ break;
+ case PEER_NODE_SID_CODE:
+ builder.setPeerNodeSid(new PeerNodeSidBuilder(
+ SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
+ LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
+ break;
+ case PEER_ADJ_SID_CODE:
+ builder.setPeerAdjSid(new PeerAdjSidBuilder(
+ SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
+ LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
+ break;
+ case PEER_SET_SID_CODE:
+ peerSetSids.add(new PeerSetSidsBuilder(
+ SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
+ LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
+ break;
+ // Performance Metrics
+ case LINK_DELAY:
+ builder.setLinkDelay(new Delay(value.readUnsignedInt()));
+ LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
+ break;
+ case LINK_MIN_MAX_DELAY:
+ builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder()
+ .setMinDelay(new Delay(value.readUnsignedInt()))
.setMaxDelay(new Delay(value.readUnsignedInt())).build());
- LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
- break;
- case DELAY_VARIATION:
- builder.setDelayVariation(new Delay(value.readUnsignedInt()));
- LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
- break;
- case LINK_LOSS:
- builder.setLinkLoss(new Loss(value.readUnsignedInt()));
- LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
- break;
- case RESIDUAL_BANDWIDTH:
- builder.setResidualBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
- LOG.debug("Parsed Residual Bandwidth {}", builder.getResidualBandwidth());
- break;
- case AVAILABLE_BANDWIDTH:
- builder.setAvailableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
- LOG.debug("Parsed Available Bandwidth {}", builder.getAvailableBandwidth());
- break;
- case UTILIZED_BANDWIDTH:
- builder.setUtilizedBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
- LOG.debug("Parsed Utilized Bandwidth {}", builder.getUtilizedBandwidth());
- break;
- default:
- LOG.warn("TLV {} is not a valid link attribute, ignoring it", key);
+ LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
+ break;
+ case DELAY_VARIATION:
+ builder.setDelayVariation(new Delay(value.readUnsignedInt()));
+ LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
+ break;
+ case LINK_LOSS:
+ builder.setLinkLoss(new Loss(value.readUnsignedInt()));
+ LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
+ break;
+ case RESIDUAL_BANDWIDTH:
+ builder.setResidualBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
+ LOG.debug("Parsed Residual Bandwidth {}", builder.getResidualBandwidth());
+ break;
+ case AVAILABLE_BANDWIDTH:
+ builder.setAvailableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
+ LOG.debug("Parsed Available Bandwidth {}", builder.getAvailableBandwidth());
+ break;
+ case UTILIZED_BANDWIDTH:
+ builder.setUtilizedBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
+ LOG.debug("Parsed Utilized Bandwidth {}", builder.getUtilizedBandwidth());
+ break;
+ default:
+ LOG.warn("TLV {} is not a valid link attribute, ignoring it", key);
}
}
if (!srAdjIds.isEmpty()) {
}
private static void parseUnreservedBandwidth(final ByteBuf value, final LinkAttributesBuilder builder) {
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.UnreservedBandwidth> unreservedBandwidth = new ArrayList<>(UNRESERVED_BW_COUNT);
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate
+ .attribute.UnreservedBandwidth> unreservedBandwidth = new ArrayList<>(UNRESERVED_BW_COUNT);
for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
- unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
+ unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(
+ new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
}
builder.setUnreservedBandwidth(unreservedBandwidth);
LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
static void serializeLinkAttributes(final LinkAttributesCase linkAttributesCase, final ByteBuf output) {
final LinkAttributes linkAttributes = linkAttributesCase.getLinkAttributes();
LOG.trace("Started serializing Link Attributes");
- ifPresentApply(linkAttributes.getLocalIpv4RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
- ifPresentApply(linkAttributes.getLocalIpv6RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
- ifPresentApply(linkAttributes.getRemoteIpv4RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
- ifPresentApply(linkAttributes.getRemoteIpv6RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
- ifPresentApply(linkAttributes.getAdminGroup(), value -> TlvUtil.writeTLV(ADMIN_GROUP, Unpooled.copyInt((((AdministrativeGroup) value).getValue()).intValue()), output));
- ifPresentApply(linkAttributes.getMaxLinkBandwidth(), value -> TlvUtil.writeTLV(MAX_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
- ifPresentApply(linkAttributes.getMaxReservableBandwidth(), value -> TlvUtil.writeTLV(MAX_RESERVABLE_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
+ ifPresentApply(linkAttributes.getLocalIpv4RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID,
+ Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
+ ifPresentApply(linkAttributes.getLocalIpv6RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID,
+ Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
+ ifPresentApply(linkAttributes.getRemoteIpv4RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV4_ROUTER_ID,
+ Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
+ ifPresentApply(linkAttributes.getRemoteIpv6RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV6_ROUTER_ID,
+ Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
+ ifPresentApply(linkAttributes.getAdminGroup(), value -> TlvUtil.writeTLV(ADMIN_GROUP,
+ Unpooled.copyInt(((AdministrativeGroup) value).getValue().intValue()), output));
+ ifPresentApply(linkAttributes.getMaxLinkBandwidth(), value -> TlvUtil.writeTLV(MAX_BANDWIDTH,
+ Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
+ ifPresentApply(linkAttributes.getMaxReservableBandwidth(), value -> TlvUtil.writeTLV(MAX_RESERVABLE_BANDWIDTH,
+ Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
serializeUnreservedBw(linkAttributes.getUnreservedBandwidth(), output);
- ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC, Unpooled.copyLong(((TeMetric) value).getValue()), output));
- ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE, Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
+ ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC,
+ Unpooled.copyLong(((TeMetric) value).getValue()), output));
+ ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE,
+ Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
serializeMplsProtocolMask(linkAttributes.getMplsProtocol(), output);
- ifPresentApply(linkAttributes.getMetric(), value -> TlvUtil.writeTLV(METRIC, Unpooled.copyMedium(((Metric) value).getValue().intValue()), output));
+ ifPresentApply(linkAttributes.getMetric(), value -> TlvUtil.writeTLV(METRIC,
+ Unpooled.copyMedium(((Metric) value).getValue().intValue()), output));
serializeSrlg(linkAttributes.getSharedRiskLinkGroups(), output);
- ifPresentApply(linkAttributes.getLinkName(), value -> TlvUtil.writeTLV(LINK_NAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode((String) value)), output));
- ifPresentApply(linkAttributes.getSrAdjIds(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<SrAdjIds>) value, SR_ADJ_ID, output));
- ifPresentApply(linkAttributes.getSrLanAdjIds(), value -> SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifiers((List<SrLanAdjIds>) value, output));
- ifPresentApply(linkAttributes.getPeerNodeSid(), value -> TlvUtil.writeTLV(PEER_NODE_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerNodeSid) value), output));
- ifPresentApply(linkAttributes.getPeerAdjSid(), value -> TlvUtil.writeTLV(PEER_ADJ_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerAdjSid) value), output));
- ifPresentApply(linkAttributes.getPeerSetSids(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<PeerSetSids>) value, PEER_SET_SID_CODE, output));
+ ifPresentApply(linkAttributes.getLinkName(), value -> TlvUtil.writeTLV(LINK_NAME,
+ Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode((String) value)), output));
+ ifPresentApply(linkAttributes.getSrAdjIds(),
+ value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<SrAdjIds>) value, SR_ADJ_ID,
+ output));
+ ifPresentApply(linkAttributes.getSrLanAdjIds(),
+ value -> SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifiers((List<SrLanAdjIds>) value, output));
+ ifPresentApply(linkAttributes.getPeerNodeSid(), value -> TlvUtil.writeTLV(PEER_NODE_SID_CODE,
+ SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerNodeSid) value), output));
+ ifPresentApply(linkAttributes.getPeerAdjSid(), value -> TlvUtil.writeTLV(PEER_ADJ_SID_CODE,
+ SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerAdjSid) value), output));
+ ifPresentApply(linkAttributes.getPeerSetSids(),
+ value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<PeerSetSids>) value,
+ PEER_SET_SID_CODE, output));
// Performance Metrics
- ifPresentApply(linkAttributes.getLinkDelay(), value -> TlvUtil.writeTLV(LINK_DELAY, Unpooled.copyInt((((Delay) value).getValue()).intValue()), output));
+ ifPresentApply(linkAttributes.getLinkDelay(), value -> TlvUtil.writeTLV(LINK_DELAY,
+ Unpooled.copyInt(((Delay) value).getValue().intValue()), output));
serializeLinkMinMaxDelay(linkAttributes.getLinkMinMaxDelay(), output);
- ifPresentApply(linkAttributes.getDelayVariation(), value -> TlvUtil.writeTLV(DELAY_VARIATION, Unpooled.copyInt((((Delay) value).getValue()).intValue()), output));
- ifPresentApply(linkAttributes.getLinkLoss(), value -> TlvUtil.writeTLV(LINK_LOSS, Unpooled.copyInt((((Loss) value).getValue()).intValue()), output));
- ifPresentApply(linkAttributes.getResidualBandwidth(), value -> TlvUtil.writeTLV(RESIDUAL_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
- ifPresentApply(linkAttributes.getAvailableBandwidth(), value -> TlvUtil.writeTLV(AVAILABLE_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
- ifPresentApply(linkAttributes.getUtilizedBandwidth(), value -> TlvUtil.writeTLV(UTILIZED_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
+ ifPresentApply(linkAttributes.getDelayVariation(), value -> TlvUtil.writeTLV(DELAY_VARIATION,
+ Unpooled.copyInt(((Delay) value).getValue().intValue()), output));
+ ifPresentApply(linkAttributes.getLinkLoss(), value -> TlvUtil.writeTLV(LINK_LOSS,
+ Unpooled.copyInt(((Loss) value).getValue().intValue()), output));
+ ifPresentApply(linkAttributes.getResidualBandwidth(), value -> TlvUtil.writeTLV(RESIDUAL_BANDWIDTH,
+ Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
+ ifPresentApply(linkAttributes.getAvailableBandwidth(), value -> TlvUtil.writeTLV(AVAILABLE_BANDWIDTH,
+ Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
+ ifPresentApply(linkAttributes.getUtilizedBandwidth(), value -> TlvUtil.writeTLV(UTILIZED_BANDWIDTH,
+ Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
LOG.trace("Finished serializing Link Attributes");
}
}
}
- private static void serializeMplsProtocolMask(final MplsProtocolMask mplsProtocolMask, final ByteBuf byteAggregator) {
+ private static void serializeMplsProtocolMask(final MplsProtocolMask mplsProtocolMask,
+ final ByteBuf byteAggregator) {
if (mplsProtocolMask != null) {
final ByteBuf mplsProtocolMaskBuf = Unpooled.buffer(1);
final BitArray mask = new BitArray(FLAGS_SIZE);
}
final ObjectType nlriType = lsDestination.getObjectType();
final ProtocolId protocolId = lsDestination.getProtocolId();
- final Attributes1 a = new Attributes1Builder().setLinkStateAttribute(parseLinkState(nlriType, protocolId, buffer)).build();
+ final Attributes1 a = new Attributes1Builder().setLinkStateAttribute(
+ parseLinkState(nlriType, protocolId, buffer)).build();
builder.addAugmentation(Attributes1.class, a);
}
private static CLinkstateDestination getNlriType(final AttributesBuilder pab) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1 mpr = pab.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1.class);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329
+ .Attributes1 mpr = pab.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .multiprotocol.rev180329.Attributes1.class);
if (mpr != null && mpr.getMpReachNlri() != null) {
final DestinationType dt = mpr.getMpReachNlri().getAdvertizedRoutes().getDestinationType();
if (dt instanceof DestinationLinkstateCase) {
- for (final CLinkstateDestination d : ((DestinationLinkstateCase) dt).getDestinationLinkstate().getCLinkstateDestination()) {
+ for (final CLinkstateDestination d : ((DestinationLinkstateCase) dt).getDestinationLinkstate()
+ .getCLinkstateDestination()) {
return d;
}
}
final Attributes2 mpu = pab.augmentation(Attributes2.class);
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.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) {
- for(final CLinkstateDestination d :((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.
- routes.destination.type.DestinationLinkstateCase) dt).getDestinationLinkstate().getCLinkstateDestination()) {
+ if (dt instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase) {
+ for (final CLinkstateDestination d : ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationLinkstateCase) dt).getDestinationLinkstate().getCLinkstateDestination()) {
return d;
}
}
return null;
}
- private LinkStateAttribute parseLinkState(final ObjectType nlri, final ProtocolId protocolId, final ByteBuf buffer) throws BGPParsingException {
-
+ private LinkStateAttribute parseLinkState(final ObjectType nlri, final ProtocolId protocolId, final ByteBuf buffer)
+ throws BGPParsingException {
if (nlri instanceof PrefixCase) {
return PrefixAttributesParser.parsePrefixAttributes(getAttributesMap(buffer), protocolId);
} else if (nlri instanceof LinkCase) {
} else if (linkState instanceof PrefixAttributesCase) {
PrefixAttributesParser.serializePrefixAttributes((PrefixAttributesCase) linkState, lsBuffer);
} else if (linkState instanceof TeLspAttributesCase) {
- TeLspAttributesParser.serializeLspAttributes(this.rsvpTeObjectRegistry, (TeLspAttributesCase) linkState, lsBuffer);
+ TeLspAttributesParser.serializeLspAttributes(this.rsvpTeObjectRegistry, (TeLspAttributesCase) linkState,
+ lsBuffer);
byteAggregator.writeBytes(lsBuffer);
return;
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
-import java.nio.charset.StandardCharsets;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrNodeAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
import org.opendaylight.protocol.util.BitArray;
/* Segment routing TLVs */
private static final int SR_CAPABILITIES = 1034;
private static final int SR_ALGORITHMS = 1035;
-
+
private NodeAttributesParser() {
- throw new UnsupportedOperationException();
+
}
/**
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
- static LinkStateAttribute parseNodeAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
+ static LinkStateAttribute parseNodeAttributes(final Multimap<Integer, ByteBuf> attributes,
+ final ProtocolId protocolId) {
final List<TopologyIdentifier> topologyMembership = new ArrayList<>();
final List<IsisAreaIdentifier> areaMembership = new ArrayList<>();
final NodeAttributesBuilder builder = new NodeAttributesBuilder();
final ByteBuf value = entry.getValue();
LOG.trace("Node attribute TLV {}", key);
switch (key) {
- case TlvUtil.MULTI_TOPOLOGY_ID:
- parseTopologyId(topologyMembership, value);
- break;
- case NODE_FLAG_BITS:
- parseNodeFlags(value, builder);
- break;
- case NODE_OPAQUE:
- if (LOG.isDebugEnabled()) {
- LOG.debug("Ignoring opaque value: {}.", ByteBufUtil.hexDump(value));
- }
- break;
- case DYNAMIC_HOSTNAME:
- builder.setDynamicHostname(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
- LOG.debug("Parsed Node Name {}", builder.getDynamicHostname());
- break;
- case ISIS_AREA_IDENTIFIER:
- final IsisAreaIdentifier ai = new IsisAreaIdentifier(ByteArray.readAllBytes(value));
- areaMembership.add(ai);
- LOG.debug("Parsed AreaIdentifier {}", ai);
- break;
- case TlvUtil.LOCAL_IPV4_ROUTER_ID:
- final Ipv4RouterIdentifier ip4 = new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value));
- builder.setIpv4RouterId(ip4);
- LOG.debug("Parsed IPv4 Router Identifier {}", ip4);
- break;
- case TlvUtil.LOCAL_IPV6_ROUTER_ID:
- final Ipv6RouterIdentifier ip6 = new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value));
- builder.setIpv6RouterId(ip6);
- LOG.debug("Parsed IPv6 Router Identifier {}", ip6);
- break;
- case SR_CAPABILITIES:
- final SrCapabilities caps = SrNodeAttributesParser.parseSrCapabilities(value, protocolId);
- builder.setSrCapabilities(caps);
- LOG.debug("Parsed SR Capabilities {}", caps);
- break;
- case SR_ALGORITHMS:
- final SrAlgorithm algs = SrNodeAttributesParser.parseSrAlgorithms(value);
- builder.setSrAlgorithm(algs);
- LOG.debug("Parsed SR Algorithms {}", algs);
- break;
- default:
- LOG.warn("TLV {} is not a valid node attribute, ignoring it", key);
+ case TlvUtil.MULTI_TOPOLOGY_ID:
+ parseTopologyId(topologyMembership, value);
+ break;
+ case NODE_FLAG_BITS:
+ parseNodeFlags(value, builder);
+ break;
+ case NODE_OPAQUE:
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring opaque value: {}.", ByteBufUtil.hexDump(value));
+ }
+ break;
+ case DYNAMIC_HOSTNAME:
+ builder.setDynamicHostname(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
+ LOG.debug("Parsed Node Name {}", builder.getDynamicHostname());
+ break;
+ case ISIS_AREA_IDENTIFIER:
+ final IsisAreaIdentifier ai = new IsisAreaIdentifier(ByteArray.readAllBytes(value));
+ areaMembership.add(ai);
+ LOG.debug("Parsed AreaIdentifier {}", ai);
+ break;
+ case TlvUtil.LOCAL_IPV4_ROUTER_ID:
+ final Ipv4RouterIdentifier ip4 = new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value));
+ builder.setIpv4RouterId(ip4);
+ LOG.debug("Parsed IPv4 Router Identifier {}", ip4);
+ break;
+ case TlvUtil.LOCAL_IPV6_ROUTER_ID:
+ final Ipv6RouterIdentifier ip6 = new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value));
+ builder.setIpv6RouterId(ip6);
+ LOG.debug("Parsed IPv6 Router Identifier {}", ip6);
+ break;
+ case SR_CAPABILITIES:
+ final SrCapabilities caps = SrNodeAttributesParser.parseSrCapabilities(value, protocolId);
+ builder.setSrCapabilities(caps);
+ LOG.debug("Parsed SR Capabilities {}", caps);
+ break;
+ case SR_ALGORITHMS:
+ final SrAlgorithm algs = SrNodeAttributesParser.parseSrAlgorithms(value);
+ builder.setSrAlgorithm(algs);
+ LOG.debug("Parsed SR Algorithms {}", algs);
+ break;
+ default:
+ LOG.warn("TLV {} is not a valid node attribute, ignoring it", key);
}
}
LOG.trace("Finished parsing Node Attributes.");
private static void parseNodeFlags(final ByteBuf value, final NodeAttributesBuilder builder) {
final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
- builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get
- (EXTERNAL_BIT), flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
+ builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT),
+ flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.",
flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
}
private static void parseTopologyId(final List<TopologyIdentifier> topologyMembership, final ByteBuf value) {
while (value.isReadable()) {
- final TopologyIdentifier topId = new TopologyIdentifier(value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET);
+ final TopologyIdentifier topId = new TopologyIdentifier(
+ value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET);
topologyMembership.add(topId);
LOG.debug("Parsed Topology Identifier: {}", topId);
}
serializeTopologyId(nodeAttributes.getTopologyIdentifier(), byteAggregator);
serializeNodeFlagBits(nodeAttributes.getNodeFlags(), byteAggregator);
if (nodeAttributes.getDynamicHostname() != null) {
- TlvUtil.writeTLV(DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode(nodeAttributes.getDynamicHostname())), byteAggregator);
+ TlvUtil.writeTLV(DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode(
+ nodeAttributes.getDynamicHostname())), byteAggregator);
}
final List<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
if (isisList != null) {
for (final IsisAreaIdentifier isisAreaIdentifier : isisList) {
- TlvUtil.writeTLV(ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()), byteAggregator);
+ TlvUtil.writeTLV(ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()),
+ byteAggregator);
}
}
if (nodeAttributes.getIpv4RouterId() != null) {
- TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress(nodeAttributes.getIpv4RouterId()), byteAggregator);
+ TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress(nodeAttributes.getIpv4RouterId()),
+ byteAggregator);
}
if (nodeAttributes.getIpv6RouterId() != null) {
- TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress(nodeAttributes.getIpv6RouterId()), byteAggregator);
+ TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress(nodeAttributes.getIpv6RouterId()),
+ byteAggregator);
}
if (nodeAttributes.getSrCapabilities() != null) {
final ByteBuf capBuffer = Unpooled.buffer();
private static final int RANGE = 1159;
private PrefixAttributesParser() {
- throw new UnsupportedOperationException();
+
}
/**
* @param protocolId to differentiate parsing methods
* @return {@link LinkStateAttribute}
*/
- static LinkStateAttribute parsePrefixAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
+ static LinkStateAttribute parsePrefixAttributes(final Multimap<Integer, ByteBuf> attributes,
+ final ProtocolId protocolId) {
final PrefixAttributesBuilder builder = new PrefixAttributesBuilder();
final List<RouteTag> routeTags = new ArrayList<>();
final List<ExtendedRouteTag> exRouteTags = new ArrayList<>();
return new PrefixAttributesCaseBuilder().setPrefixAttributes(builder.build()).build();
}
- private static void parseAttribute(final int key, final ByteBuf value, final ProtocolId protocolId, final PrefixAttributesBuilder builder, final List<RouteTag> routeTags, final List<ExtendedRouteTag> exRouteTags) {
+ private static void parseAttribute(final int key, final ByteBuf value, final ProtocolId protocolId,
+ final PrefixAttributesBuilder builder, final List<RouteTag> routeTags,
+ final List<ExtendedRouteTag> exRouteTags) {
switch (key) {
- case IGP_FLAGS:
- parseIgpFags(builder, value);
- break;
- case ROUTE_TAG:
- parseRouteTags(routeTags, value);
- break;
- case EXTENDED_ROUTE_TAG:
- parseExtendedRouteTags(exRouteTags, value);
- break;
- case PREFIX_METRIC:
- final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
- builder.setPrefixMetric(metric);
- LOG.debug("Parsed Metric: {}", metric);
- break;
- case FORWARDING_ADDRESS:
- final IpAddress fwdAddress = parseForwardingAddress(value);
- builder.setOspfForwardingAddress(fwdAddress);
- LOG.debug("Parsed FWD Address: {}", fwdAddress);
- break;
- case PREFIX_OPAQUE:
- if (LOG.isDebugEnabled()) {
- LOG.debug("Parsed Opaque value: {}, not preserving it", ByteBufUtil.hexDump(value));
- }
- break;
- case PREFIX_SID:
- final SrPrefix prefix = SrPrefixAttributesParser.parseSrPrefix(value, protocolId);
- builder.setSrPrefix(prefix);
- LOG.debug("Parsed SR Prefix: {}", prefix);
- break;
- case IPV6_PREFIX_SID:
- final Ipv6SrPrefix ipv6Prefix = Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(value);
- builder.setIpv6SrPrefix(ipv6Prefix);
- LOG.debug("Parsed Ipv6 SR Prefix: {}", ipv6Prefix);
- break;
- case RANGE:
- final SrRange range = RangeTlvParser.parseSrRange(value, protocolId);
- builder.setSrRange(range);
- LOG.debug("Parsed SR Range: {}", range);
- break;
- case BINDING_SID:
- parseBindingSid(builder, value, protocolId);
- break;
- default:
- LOG.warn("TLV {} is not a valid prefix attribute, ignoring it", key);
+ case IGP_FLAGS:
+ parseIgpFags(builder, value);
+ break;
+ case ROUTE_TAG:
+ parseRouteTags(routeTags, value);
+ break;
+ case EXTENDED_ROUTE_TAG:
+ parseExtendedRouteTags(exRouteTags, value);
+ break;
+ case PREFIX_METRIC:
+ final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
+ builder.setPrefixMetric(metric);
+ LOG.debug("Parsed Metric: {}", metric);
+ break;
+ case FORWARDING_ADDRESS:
+ final IpAddress fwdAddress = parseForwardingAddress(value);
+ builder.setOspfForwardingAddress(fwdAddress);
+ LOG.debug("Parsed FWD Address: {}", fwdAddress);
+ break;
+ case PREFIX_OPAQUE:
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parsed Opaque value: {}, not preserving it", ByteBufUtil.hexDump(value));
+ }
+ break;
+ case PREFIX_SID:
+ final SrPrefix prefix = SrPrefixAttributesParser.parseSrPrefix(value, protocolId);
+ builder.setSrPrefix(prefix);
+ LOG.debug("Parsed SR Prefix: {}", prefix);
+ break;
+ case IPV6_PREFIX_SID:
+ final Ipv6SrPrefix ipv6Prefix = Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(value);
+ builder.setIpv6SrPrefix(ipv6Prefix);
+ LOG.debug("Parsed Ipv6 SR Prefix: {}", ipv6Prefix);
+ break;
+ case RANGE:
+ final SrRange range = RangeTlvParser.parseSrRange(value, protocolId);
+ builder.setSrRange(range);
+ LOG.debug("Parsed SR Range: {}", range);
+ break;
+ case BINDING_SID:
+ parseBindingSid(builder, value, protocolId);
+ break;
+ default:
+ LOG.warn("TLV {} is not a valid prefix attribute, ignoring it", key);
}
}
private static void parseIgpFags(final PrefixAttributesBuilder builder, final ByteBuf value) {
final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
final boolean upDownBit = flags.get(UP_DOWN_BIT);
- builder.setIgpBits(new IgpBitsBuilder().setUpDown(new UpDown(upDownBit)).setIsIsUpDown(upDownBit).setOspfNoUnicast(flags.get(OSPF_NO_UNICAST))
- .setOspfLocalAddress(flags.get(OSPF_LOCAL_ADDRESS)).setOspfPropagateNssa(flags.get(OSPF_PROPAGATE_ADDRESS)).build());
+ builder.setIgpBits(new IgpBitsBuilder().setUpDown(new UpDown(upDownBit)).setIsIsUpDown(upDownBit)
+ .setOspfNoUnicast(flags.get(OSPF_NO_UNICAST))
+ .setOspfLocalAddress(flags.get(OSPF_LOCAL_ADDRESS))
+ .setOspfPropagateNssa(flags.get(OSPF_PROPAGATE_ADDRESS)).build());
LOG.debug("Parsed IGP flag (up/down bit) : {}", upDownBit);
}
- private static void parseBindingSid(final PrefixAttributesBuilder builder, final ByteBuf value, final ProtocolId protocolId) {
+ private static void parseBindingSid(final PrefixAttributesBuilder builder, final ByteBuf value,
+ final ProtocolId protocolId) {
final List<SrBindingSidLabels> labels;
if (builder.getSrBindingSidLabels() != null) {
labels = builder.getSrBindingSidLabels();
private static void parseExtendedRouteTags(final List<ExtendedRouteTag> exRouteTags, final ByteBuf value) {
while (value.isReadable()) {
- final ExtendedRouteTag exRouteTag = new ExtendedRouteTag(ByteArray.readBytes(value, EXTENDED_ROUTE_TAG_LENGTH));
+ final ExtendedRouteTag exRouteTag = new ExtendedRouteTag(ByteArray.readBytes(value,
+ EXTENDED_ROUTE_TAG_LENGTH));
exRouteTags.add(exRouteTag);
LOG.debug("Parsed Extended Route Tag: {}", exRouteTag);
}
}
private static IpAddress parseForwardingAddress(final ByteBuf value) {
- IpAddress fwdAddress = null;
switch (value.readableBytes()) {
- case Ipv4Util.IP4_LENGTH:
- fwdAddress = new IpAddress(Ipv4Util.addressForByteBuf(value));
- break;
- case Ipv6Util.IPV6_LENGTH:
- fwdAddress = new IpAddress(Ipv6Util.addressForByteBuf(value));
- break;
- default:
- LOG.debug("Ignoring unsupported forwarding address length {}", value.readableBytes());
+ case Ipv4Util.IP4_LENGTH:
+ return new IpAddress(Ipv4Util.addressForByteBuf(value));
+ case Ipv6Util.IPV6_LENGTH:
+ return new IpAddress(Ipv6Util.addressForByteBuf(value));
+ default:
+ LOG.debug("Ignoring unsupported forwarding address length {}", value.readableBytes());
+ return null;
}
- return fwdAddress;
}
- static void serializePrefixAttributes(final PrefixAttributesCase prefixAttributesCase, final ByteBuf byteAggregator) {
+ static void serializePrefixAttributes(final PrefixAttributesCase prefixAttributesCase,
+ final ByteBuf byteAggregator) {
final PrefixAttributes prefixAtrributes = prefixAttributesCase.getPrefixAttributes();
if (prefixAtrributes.getIgpBits() != null) {
final BitArray igpBit = new BitArray(FLAGS_SIZE);
serializeSrBindingLabel(prefixAtrributes.getSrBindingSidLabels(), byteAggregator);
}
- private static void serializeSrBindingLabel(final List<SrBindingSidLabels> srBindingSidLabels, final ByteBuf byteAggregator) {
+ private static void serializeSrBindingLabel(final List<SrBindingSidLabels> srBindingSidLabels,
+ final ByteBuf byteAggregator) {
if (srBindingSidLabels != null) {
for (final SrBindingSidLabels bindingSid : srBindingSidLabels) {
final ByteBuf sidBuffer = Unpooled.buffer();
- BindingSidLabelParser.serializeBindingSidAttributes(bindingSid.getWeight(), bindingSid.getFlags(), bindingSid.getBindingSubTlvs(), sidBuffer);
+ BindingSidLabelParser.serializeBindingSidAttributes(bindingSid.getWeight(), bindingSid.getFlags(),
+ bindingSid.getBindingSubTlvs(), sidBuffer);
TlvUtil.writeTLV(PrefixAttributesParser.BINDING_SID, sidBuffer, byteAggregator);
}
}
}
}
- private static void serializeExtendedRouteTags(final List<ExtendedRouteTag> exRouteTags, final ByteBuf byteAggregator) {
+ private static void serializeExtendedRouteTags(final List<ExtendedRouteTag> exRouteTags,
+ final ByteBuf byteAggregator) {
if (exRouteTags != null) {
final ByteBuf extendedBuf = Unpooled.buffer();
for (final ExtendedRouteTag exRouteTag : exRouteTags) {
throw new UnsupportedOperationException();
}
- static LinkStateAttribute parseTeLspAttributes(final RSVPTeObjectRegistry registry, final ByteBuf attributes) throws BGPParsingException {
+ static LinkStateAttribute parseTeLspAttributes(final RSVPTeObjectRegistry registry, final ByteBuf attributes)
+ throws BGPParsingException {
final TeLspAttributesBuilder builder = new TeLspAttributesBuilder();
LOG.trace("Initiated parsing TE LSP Objects.");
try {
addObject(builder, registry.parseRSPVTe(classNum, cType, value));
} catch (final RSVPParsingException e) {
- LOG.debug("Parsering TE LSP Object error. class number: {} cType: {} value: {}", classNum, cType, value, e);
- throw new BGPParsingException(e.getMessage());
+ LOG.debug("Parsering TE LSP Object error. class number: {} cType: {} value: {}", classNum, cType, value,
+ e);
+ throw new BGPParsingException(e.getMessage(), e);
}
}
LOG.trace("Finished parsing TE LSP Objects.");
}
- static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
+ static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState,
+ final ByteBuf output) {
LOG.trace("Started serializing TE LSP Objects");
final ByteBuf byteBuf = Unpooled.buffer();
private static final int RESERVED_BINDING_SID = 2;
private BindingSidLabelParser() {
- throw new UnsupportedOperationException();
+
}
public static SrBindingSidLabels parseBindingSidLabel(final ByteBuf buffer, final ProtocolId protocolId) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
bindingSid.setFlags(parseBindingSidFlags(flags, protocolId));
buffer.skipBytes(RESERVED_BINDING_SID);
- bindingSid.setBindingSubTlvs(SimpleBindingSubTlvsRegistry.getInstance().parseBindingSubTlvs(buffer, protocolId));
+ bindingSid.setBindingSubTlvs(
+ SimpleBindingSubTlvsRegistry.getInstance().parseBindingSubTlvs(buffer, protocolId));
return bindingSid.build();
}
private static Flags parseBindingSidFlags(final BitArray flags, final ProtocolId protocol) {
switch (protocol) {
- case IsisLevel1:
- case IsisLevel2:
- return new IsisBindingFlagsCaseBuilder().setAddressFamily(flags.get(AFI)).setMirrorContext(flags.get(MIRROR_CONTEXT))
- .setSpreadTlv(flags.get(SPREAD_TLV)).setLeakedFromLevel2(flags.get(LEAKED)).setAttachedFlag(flags.get(ATTACHED)).build();
- case Ospf:
- case OspfV3:
- return new OspfBindingFlagsCaseBuilder().setMirroring(flags.get(MIRROR_CONTEXT_OSPF)).build();
- default:
- return null;
+ case IsisLevel1:
+ case IsisLevel2:
+ return new IsisBindingFlagsCaseBuilder().setAddressFamily(flags.get(AFI))
+ .setMirrorContext(flags.get(MIRROR_CONTEXT))
+ .setSpreadTlv(flags.get(SPREAD_TLV)).setLeakedFromLevel2(flags.get(LEAKED))
+ .setAttachedFlag(flags.get(ATTACHED)).build();
+ case Ospf:
+ case OspfV3:
+ return new OspfBindingFlagsCaseBuilder().setMirroring(flags.get(MIRROR_CONTEXT_OSPF)).build();
+ default:
+ return null;
}
}
- public static void serializeBindingSidAttributes(final Weight weight, final Flags flags, final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
+ public static void serializeBindingSidAttributes(final Weight weight, final Flags flags,
+ final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
aggregator.writeByte(weight.getValue());
final BitArray bitFlags = serializeBindingSidFlags(flags);
bitFlags.toByteBuf(aggregator);
* 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.linkstate.impl.attribute.sr;
-
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.Ipv6SrPrefixBuilder;
private static final int FLAGS_SIZE = 2;
private Ipv6SrPrefixAttributesParser() {
- throw new UnsupportedOperationException();
+
}
public static Ipv6SrPrefix parseSrIpv6Prefix(final ByteBuf buffer) {
private static final int RESERVED = 1;
private RangeTlvParser() {
- throw new UnsupportedOperationException();
+
}
public static SrRange parseSrRange(final ByteBuf buffer, final ProtocolId protocolId) {
final int type = buffer.readUnsignedShort();
final int length = buffer.readUnsignedShort();
switch (type) {
- case PREFIX_SID:
- subTlvCase = new PrefixSidTlvCaseBuilder(SrPrefixAttributesParser.parseSrPrefix(buffer.readSlice(length), protocolId)).build();
- break;
- case IPV6_PREFIX_SID:
- subTlvCase = new Ipv6PrefixSidTlvCaseBuilder(Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(buffer.readSlice(length))).build();
- break;
- case BINDING_SID:
- subTlvCase = new BindingSidTlvCaseBuilder(BindingSidLabelParser.parseBindingSidLabel(buffer.readSlice(length), protocolId)).build();
- break;
- case SID_TYPE:
- subTlvCase = new SidLabelTlvCaseBuilder().setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(Size.forValue(length), buffer.readSlice(length))).build();
- break;
- default:
- LOG.info("Unknown type of range sub-tlv: {}", type);
- buffer.skipBytes(length);
- continue;
+ case PREFIX_SID:
+ subTlvCase = new PrefixSidTlvCaseBuilder(
+ SrPrefixAttributesParser.parseSrPrefix(buffer.readSlice(length), protocolId)).build();
+ break;
+ case IPV6_PREFIX_SID:
+ subTlvCase = new Ipv6PrefixSidTlvCaseBuilder(
+ Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(buffer.readSlice(length))).build();
+ break;
+ case BINDING_SID:
+ subTlvCase = new BindingSidTlvCaseBuilder(
+ BindingSidLabelParser.parseBindingSidLabel(buffer.readSlice(length), protocolId)).build();
+ break;
+ case SID_TYPE:
+ subTlvCase = new SidLabelTlvCaseBuilder().setSidLabelIndex(
+ SidLabelIndexParser.parseSidLabelIndex(Size.forValue(length), buffer.readSlice(length)))
+ .build();
+ break;
+ default:
+ LOG.info("Unknown type of range sub-tlv: {}", type);
+ buffer.skipBytes(length);
+ continue;
}
subTlvs.add(subTlv.setRangeSubTlv(subTlvCase).build());
}
private static final int LABEL_MASK = 0xfffff;
private SidLabelIndexParser() {
- throw new UnsupportedOperationException();
+
}
public enum Size {
public static SidLabelIndex parseSidLabelIndex(final Size length, final ByteBuf buffer) {
switch (length) {
- case LABEL:
- return new LocalLabelCaseBuilder()
- .setLocalLabel(new MplsLabel(Long.valueOf(buffer.readUnsignedMedium() & LABEL_MASK))).build();
- case SID:
- return new SidCaseBuilder().setSid(buffer.readUnsignedInt()).build();
- case IPV6_ADD:
- return new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(buffer)).build();
- default:
- return null;
+ case LABEL:
+ return new LocalLabelCaseBuilder()
+ .setLocalLabel(new MplsLabel(Long.valueOf(buffer.readUnsignedMedium() & LABEL_MASK))).build();
+ case SID:
+ return new SidCaseBuilder().setSid(buffer.readUnsignedInt()).build();
+ case IPV6_ADD:
+ return new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(buffer)).build();
+ default:
+ return null;
}
}
private static final int FLAGS_BITS_SIZE = 8;
private static final int FLAGS_BYTE_SIZE = 1;
- /** OSPF flags
+ /*
+ OSPF flags
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|B|V|L|S| |
*/
private SrLinkAttributesParser() {
- throw new UnsupportedOperationException();
+
}
public static SrAdjIds parseAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
public Class<? extends DataContainer> getImplementedInterface() {
return EpeAdjSidTlv.class;
}
+
@Override
public Weight getWeight() {
return weight;
}
+
@Override
public SidLabelIndex getSidLabelIndex() {
return sidValue;
srLanAdjIdBuilder.setWeight(new Weight(buffer.readUnsignedByte()));
buffer.skipBytes(RESERVED);
switch (protocolId) {
- case IsisLevel1:
- case IsisLevel2:
- srLanAdjIdBuilder.setIsoSystemId(new IsoSystemIdentifier(ByteArray.readBytes(buffer, ISO_SYSTEM_ID_SIZE)));
- break;
- case Ospf:
- case OspfV3:
- srLanAdjIdBuilder.setNeighborId(Ipv4Util.addressForByteBuf(buffer));
- break;
- default:
- return null;
+ case IsisLevel1:
+ case IsisLevel2:
+ srLanAdjIdBuilder.setIsoSystemId(new IsoSystemIdentifier(
+ ByteArray.readBytes(buffer, ISO_SYSTEM_ID_SIZE)));
+ break;
+ case Ospf:
+ case OspfV3:
+ srLanAdjIdBuilder.setNeighborId(Ipv4Util.addressForByteBuf(buffer));
+ break;
+ default:
+ return null;
}
// length determines a type of next field, which is used for parsing
- srLanAdjIdBuilder.setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer));
+ srLanAdjIdBuilder.setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndex(
+ Size.forValue(buffer.readableBytes()), buffer));
return srLanAdjIdBuilder.build();
}
return null;
}
switch (protocol) {
- case IsisLevel1:
- case IsisLevel2:
- return new IsisAdjFlagsCaseBuilder().setAddressFamily(flags.get(ADDRESS_FAMILY_FLAG)).setBackup(flags.get(BACKUP_ISIS))
- .setSet(flags.get(SET_ISIS)).build();
- case Ospf:
- case OspfV3:
- return new OspfAdjFlagsCaseBuilder().setBackup(flags.get(BACKUP_OSPF)).setSet(flags.get(SET_OSPF)).build();
- default:
- return null;
+ case IsisLevel1:
+ case IsisLevel2:
+ return new IsisAdjFlagsCaseBuilder().setAddressFamily(flags.get(ADDRESS_FAMILY_FLAG))
+ .setBackup(flags.get(BACKUP_ISIS))
+ .setSet(flags.get(SET_ISIS)).build();
+ case Ospf:
+ case OspfV3:
+ return new OspfAdjFlagsCaseBuilder().setBackup(flags.get(BACKUP_OSPF)).setSet(flags.get(SET_OSPF))
+ .build();
+ default:
+ return null;
}
}
- public static <T extends EpeAdjSidTlv> void serializeAdjacencySegmentIdentifiers(final List<T> adjSids, final int type, final ByteBuf byteAggregator) {
+ public static <T extends EpeAdjSidTlv> void serializeAdjacencySegmentIdentifiers(final List<T> adjSids,
+ final int type, final ByteBuf byteAggregator) {
adjSids.forEach(id -> TlvUtil.writeTLV(type, serializeAdjacencySegmentIdentifier(id), byteAggregator));
}
public static <T extends EpeAdjSidTlv> ByteBuf serializeAdjacencySegmentIdentifier(final T adjSid) {
final ByteBuf value = Unpooled.buffer();
- if(adjSid instanceof SrAdjIds) {
+ if (adjSid instanceof SrAdjIds) {
final BitArray flags = serializeAdjFlags(((SrAdjIds) adjSid).getFlags(), adjSid.getSidLabelIndex());
flags.toByteBuf(value);
- }else {
+ } else {
value.writeZero(FLAGS_BYTE_SIZE);
}
value.writeByte(adjSid.getWeight().getValue());
return value;
}
- public static void serializeLanAdjacencySegmentIdentifiers(final List<SrLanAdjIds> srLanAdjIds, final ByteBuf byteAggregator) {
+ public static void serializeLanAdjacencySegmentIdentifiers(final List<SrLanAdjIds> srLanAdjIds,
+ final ByteBuf byteAggregator) {
for (final SrLanAdjIds id : srLanAdjIds) {
TlvUtil.writeTLV(SR_LAN_ADJ_ID, serializeLanAdjacencySegmentIdentifier(id), byteAggregator);
}
bitFlags.set(BACKUP_ISIS, isisFlags.isBackup());
bitFlags.set(SET_ISIS, isisFlags.isSet());
SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_ISIS, LOCAL_ISIS);
- } else if (flags == null){
+ } else if (flags == null) {
SidLabelIndexParser.setFlags(sidLabelIndex, bitFlags, VALUE_EPE, LOCAL_EPE);
}
return bitFlags;
}
-
}
private static final int RESERVERED = 1;
private SrNodeAttributesParser() {
- throw new UnsupportedOperationException();
+
}
public static SrCapabilities parseSrCapabilities(final ByteBuf buffer, final ProtocolId protocol) {
private static final int RESERVED_PREFIX = 2;
private SrPrefixAttributesParser() {
- throw new UnsupportedOperationException();
+
}
public static SrPrefix parseSrPrefix(final ByteBuf buffer, final ProtocolId protocol) {
private static Flags parsePrefixFlags(final BitArray flags, final ProtocolId protocol) {
switch (protocol) {
- case IsisLevel1:
- case IsisLevel2:
- return new IsisPrefixFlagsCaseBuilder().setReadvertisement(flags.get(RE_ADVERTISEMENT))
- .setNodeSid(flags.get(NODE_SID)).setNoPhp(flags.get(NO_PHP)).setExplicitNull(flags.get(EXPLICIT_NULL)).build();
- case Ospf:
- case OspfV3:
- return new OspfPrefixFlagsCaseBuilder().setExplicitNull(flags.get(EXPLICIT_NULL))
- .setMappingServer(flags.get(MAPPING_SERVER)).setNoPhp(flags.get(NO_PHP_OSPF)).build();
- default:
- return null;
+ case IsisLevel1:
+ case IsisLevel2:
+ return new IsisPrefixFlagsCaseBuilder().setReadvertisement(flags.get(RE_ADVERTISEMENT))
+ .setNodeSid(flags.get(NODE_SID)).setNoPhp(flags.get(NO_PHP))
+ .setExplicitNull(flags.get(EXPLICIT_NULL)).build();
+ case Ospf:
+ case OspfV3:
+ return new OspfPrefixFlagsCaseBuilder().setExplicitNull(flags.get(EXPLICIT_NULL))
+ .setMappingServer(flags.get(MAPPING_SERVER)).setNoPhp(flags.get(NO_PHP_OSPF)).build();
+ default:
+ return null;
}
}
public static void serializeSrPrefix(final SrPrefix srPrefix, final ByteBuf aggregator) {
- serializePrefixAttributes(srPrefix.getFlags(), srPrefix.getAlgorithm(), srPrefix.getSidLabelIndex(), aggregator);
+ serializePrefixAttributes(srPrefix.getFlags(), srPrefix.getAlgorithm(), srPrefix.getSidLabelIndex(),
+ aggregator);
}
- public static void serializePrefixAttributes(final Flags flags, final Algorithm algorithm, final SidLabelIndex sidLabelIndex, final ByteBuf buffer) {
+ public static void serializePrefixAttributes(final Flags flags, final Algorithm algorithm,
+ final SidLabelIndex sidLabelIndex, final ByteBuf buffer) {
final BitArray bitFlags = serializePrefixFlags(flags, sidLabelIndex);
bitFlags.toByteBuf(buffer);
buffer.writeByte(algorithm.getIntValue());
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.sid.sub.tlvs.UnnumberedEroParser.parseUnnumberedEroCase;
import static org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.sid.sub.tlvs.UnnumberedEroParser.serializeUnnumberedIdEro;
-import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof UnnumberedInterfaceIdBackupEroCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof UnnumberedInterfaceIdBackupEroCase,
+ "Wrong BindingSubTlv instance expected", bindingSubTlv);
final UnnumberedInterfaceIdBackupEroCase unnumberedBackup = (UnnumberedInterfaceIdBackupEroCase) bindingSubTlv;
- TlvUtil.writeTLV(BACKUP_UNNUMBERED_ERO, serializeUnnumberedIdEro(unnumberedBackup.isLoose(), unnumberedBackup.getRouterId(),
- unnumberedBackup.getInterfaceId()), aggregator);
+ TlvUtil.writeTLV(BACKUP_UNNUMBERED_ERO, serializeUnnumberedIdEro(unnumberedBackup.isLoose(),
+ unnumberedBackup.getRouterId(), unnumberedBackup.getInterfaceId()), aggregator);
}
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof EroMetricCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof EroMetricCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final ByteBuf buffer = Unpooled.buffer();
buffer.writeInt(((EroMetricCase) bindingSubTlv).getEroMetric().getValue().intValue());
TlvUtil.writeTLV(getType(), buffer, aggregator);
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer;
@Override
public BindingSubTlv parseSubTlv(final ByteBuf slice, final ProtocolId protocolId) {
final Ipv4EroCase ipv4Backup = Ipv4EroParser.parseIpv4EroCase(slice);
- return new Ipv4EroBackupCaseBuilder().setAddress(ipv4Backup.getAddress()).setLoose(ipv4Backup.isLoose()).build();
+ return new Ipv4EroBackupCaseBuilder().setAddress(ipv4Backup.getAddress()).setLoose(ipv4Backup.isLoose())
+ .build();
}
@Override
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof Ipv4EroBackupCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof Ipv4EroBackupCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final Ipv4EroBackupCase ipv4Backup = (Ipv4EroBackupCase) bindingSubTlv;
- TlvUtil.writeTLV(getType(), Ipv4EroParser.serializeIpv4EroCase(ipv4Backup.isLoose(), ipv4Backup.getAddress()), aggregator);
+ TlvUtil.writeTLV(getType(), Ipv4EroParser.serializeIpv4EroCase(ipv4Backup.isLoose(), ipv4Backup.getAddress()),
+ aggregator);
}
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof Ipv4EroCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof Ipv4EroCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final Ipv4EroCase ipv4Ero = (Ipv4EroCase) bindingSubTlv;
TlvUtil.writeTLV(getType(), serializeIpv4EroCase(ipv4Ero.isLoose(), ipv4Ero.getAddress()), aggregator);
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrPrefixAttributesParser;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof PrefixSidCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof PrefixSidCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final PrefixSidCase prefix = (PrefixSidCase) bindingSubTlv;
final ByteBuf buffer = Unpooled.buffer();
- SrPrefixAttributesParser.serializePrefixAttributes(prefix.getFlags(), prefix.getAlgorithm(), prefix.getSidLabelIndex(), buffer);
+ SrPrefixAttributesParser.serializePrefixAttributes(prefix.getFlags(), prefix.getAlgorithm(),
+ prefix.getSidLabelIndex(), buffer);
TlvUtil.writeTLV(getType(), buffer, aggregator);
}
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer;
@Override
public BindingSubTlv parseSubTlv(final ByteBuf slice, final ProtocolId protocolId) {
final Ipv6EroCase ipv6backup = Ipv6EroParser.parseIpv6EroCase(slice);
- return new Ipv6EroBackupCaseBuilder().setAddress(ipv6backup.getAddress()).setLoose(ipv6backup.isLoose()).build();
+ return new Ipv6EroBackupCaseBuilder().setAddress(ipv6backup.getAddress()).setLoose(ipv6backup.isLoose())
+ .build();
}
@Override
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof Ipv6EroBackupCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof Ipv6EroBackupCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final Ipv6EroBackupCase ipv6Backup = (Ipv6EroBackupCase) bindingSubTlv;
- TlvUtil.writeTLV(getType(), Ipv6EroParser.serializeIpv6EroCase(ipv6Backup.isLoose(), ipv6Backup.getAddress()), aggregator);
+ TlvUtil.writeTLV(getType(), Ipv6EroParser.serializeIpv6EroCase(ipv6Backup.isLoose(), ipv6Backup.getAddress()),
+ aggregator);
}
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof Ipv6EroCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof Ipv6EroCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final Ipv6EroCase ipv6Ero = (Ipv6EroCase) bindingSubTlv;
TlvUtil.writeTLV(getType(), serializeIpv6EroCase(ipv6Ero.isLoose(), ipv6Ero.getAddress()), aggregator);
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.Ipv6SrPrefixAttributesParser;
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof Ipv6PrefixSidCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof Ipv6PrefixSidCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
final Ipv6PrefixSidCase prefix = (Ipv6PrefixSidCase) bindingSubTlv;
final ByteBuf buffer = Unpooled.buffer();
Ipv6SrPrefixAttributesParser.serializePrefixAttributes(prefix.getAlgorithm(), buffer);
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SidLabelIndexParser;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
@Override
public BindingSubTlv parseSubTlv(final ByteBuf slice, final ProtocolId protocolId) {
- final SidLabelIndex sid = SidLabelIndexParser.parseSidLabelIndex(SidLabelIndexParser.Size.forValue(slice.readableBytes()), slice);
+ final SidLabelIndex sid = SidLabelIndexParser.parseSidLabelIndex(SidLabelIndexParser.Size.forValue(
+ slice.readableBytes()), slice);
return new SidLabelCaseBuilder().setSidLabelIndex(sid).build();
}
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof SidLabelCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
- TlvUtil.writeTLV(getType(), SidLabelIndexParser.serializeSidValue(((SidLabelCase) bindingSubTlv).getSidLabelIndex()), aggregator);
+ checkArgument(bindingSubTlv instanceof SidLabelCase, "Wrong BindingSubTlv instance expected",
+ bindingSubTlv);
+ TlvUtil.writeTLV(getType(), SidLabelIndexParser.serializeSidValue(
+ ((SidLabelCase) bindingSubTlv).getSidLabelIndex()), aggregator);
}
}
* 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.linkstate.impl.attribute.sr.binding.sid.sub.tlvs;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
@Override
public BindingSubTlv parseSubTlv(final ByteBuf slice, final ProtocolId protocolId) {
final UnnumberedInterfaceIdEroCase unnumbered = parseUnnumberedEroCase(slice);
- return new UnnumberedInterfaceIdEroCaseBuilder().setLoose(unnumbered.isLoose()).setRouterId(unnumbered.getRouterId())
- .setInterfaceId(unnumbered.getInterfaceId()).build();
+ return new UnnumberedInterfaceIdEroCaseBuilder().setLoose(unnumbered.isLoose())
+ .setRouterId(unnumbered.getRouterId())
+ .setInterfaceId(unnumbered.getInterfaceId()).build();
}
@Override
@Override
public void serializeSubTlv(final BindingSubTlv bindingSubTlv, final ByteBuf aggregator) {
- Preconditions.checkArgument(bindingSubTlv instanceof UnnumberedInterfaceIdEroCase, "Wrong BindingSubTlv instance expected", bindingSubTlv);
+ checkArgument(bindingSubTlv instanceof UnnumberedInterfaceIdEroCase,
+ "Wrong BindingSubTlv instance expected", bindingSubTlv);
final UnnumberedInterfaceIdEroCase unnumberedEro = (UnnumberedInterfaceIdEroCase) bindingSubTlv;
- TlvUtil.writeTLV(getType(), serializeUnnumberedIdEro(unnumberedEro.isLoose(), unnumberedEro.getRouterId(), unnumberedEro.getInterfaceId()), aggregator);
+ TlvUtil.writeTLV(getType(), serializeUnnumberedIdEro(unnumberedEro.isLoose(), unnumberedEro.getRouterId(),
+ unnumberedEro.getInterfaceId()), aggregator);
}
static UnnumberedInterfaceIdEroCase parseUnnumberedEroCase(final ByteBuf buffer) {
* 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.linkstate.impl.nlri;
import io.netty.buffer.ByteBuf;
@Override
protected final void serializeObjectType(final ObjectType objectType, final ByteBuf buffer) {
final PrefixCase prefix = (PrefixCase) objectType;
- SimpleNlriTypeRegistry.getInstance().serializeTlv(AdvertisingNodeDescriptors.QNAME, prefix.getAdvertisingNodeDescriptors(), buffer);
+ SimpleNlriTypeRegistry.getInstance().serializeTlv(AdvertisingNodeDescriptors.QNAME,
+ prefix.getAdvertisingNodeDescriptors(), buffer);
serializePrefixDescriptor(prefix.getPrefixDescriptors(), buffer);
}
/* Link Descriptor QNames */
@VisibleForTesting
- public static final NodeIdentifier IPV4_IFACE_NID = new NodeIdentifier(Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME);
+ public static final NodeIdentifier IPV4_IFACE_NID = NodeIdentifier.create(
+ Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME);
@VisibleForTesting
- public static final NodeIdentifier IPV4_NEIGHBOR_NID = new NodeIdentifier(Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME);
+ public static final NodeIdentifier IPV4_NEIGHBOR_NID = NodeIdentifier.create(
+ Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME);
@VisibleForTesting
- public static final NodeIdentifier LINK_LOCAL_NID = new NodeIdentifier(QName.create(LinkDescriptors.QNAME, "link-local-identifier").intern());
+ public static final NodeIdentifier LINK_LOCAL_NID = NodeIdentifier.create(
+ QName.create(LinkDescriptors.QNAME, "link-local-identifier").intern());
@VisibleForTesting
- public static final NodeIdentifier LINK_REMOTE_NID = new NodeIdentifier(QName.create(LinkDescriptors.QNAME, "link-remote-identifier").intern());
- private static final NodeIdentifier IPV6_IFACE_NID = new NodeIdentifier(Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME);
- private static final NodeIdentifier IPV6_NEIGHBOR_NID = new NodeIdentifier(Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME);
+ public static final NodeIdentifier LINK_REMOTE_NID = NodeIdentifier.create(
+ QName.create(LinkDescriptors.QNAME, "link-remote-identifier").intern());
+ private static final NodeIdentifier IPV6_IFACE_NID = NodeIdentifier.create(
+ Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME);
+ private static final NodeIdentifier IPV6_NEIGHBOR_NID = NodeIdentifier.create(
+ Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME);
@FunctionalInterface
private interface SerializerInterface {
linkDescBuilder.setLinkLocalIdentifier((Long) descriptors.getChild(LINK_LOCAL_NID).get().getValue());
linkDescBuilder.setLinkRemoteIdentifier((Long) descriptors.getChild(LINK_REMOTE_NID).get().getValue());
}
- ifPresentApply(descriptors, IPV4_IFACE_NID, value -> linkDescBuilder.setIpv4InterfaceAddress(new Ipv4InterfaceIdentifier((String) value)));
- ifPresentApply(descriptors, IPV6_IFACE_NID, value -> linkDescBuilder.setIpv6InterfaceAddress(new Ipv6InterfaceIdentifier((String) value)));
- ifPresentApply(descriptors, IPV4_NEIGHBOR_NID, value -> linkDescBuilder.setIpv4NeighborAddress(new Ipv4InterfaceIdentifier((String) value)));
- ifPresentApply(descriptors, IPV6_NEIGHBOR_NID, value -> linkDescBuilder.setIpv6NeighborAddress(new Ipv6InterfaceIdentifier((String) value)));
- ifPresentApply(descriptors, TlvUtil.MULTI_TOPOLOGY_NID, value -> linkDescBuilder.setMultiTopologyId(new TopologyIdentifier((Integer) value)));
+ ifPresentApply(descriptors, IPV4_IFACE_NID,
+ value -> linkDescBuilder.setIpv4InterfaceAddress(new Ipv4InterfaceIdentifier((String) value)));
+ ifPresentApply(descriptors, IPV6_IFACE_NID,
+ value -> linkDescBuilder.setIpv6InterfaceAddress(new Ipv6InterfaceIdentifier((String) value)));
+ ifPresentApply(descriptors, IPV4_NEIGHBOR_NID,
+ value -> linkDescBuilder.setIpv4NeighborAddress(new Ipv4InterfaceIdentifier((String) value)));
+ ifPresentApply(descriptors, IPV6_NEIGHBOR_NID,
+ value -> linkDescBuilder.setIpv6NeighborAddress(new Ipv6InterfaceIdentifier((String) value)));
+ ifPresentApply(descriptors, TlvUtil.MULTI_TOPOLOGY_NID,
+ value -> linkDescBuilder.setMultiTopologyId(new TopologyIdentifier((Integer) value)));
return linkDescBuilder.build();
}
- private static void ifPresentApply(final ContainerNode descriptors, final NodeIdentifier nid, final SerializerInterface serializer) {
+ private static void ifPresentApply(final ContainerNode descriptors, final NodeIdentifier nid,
+ final SerializerInterface serializer) {
if (descriptors.getChild(nid).isPresent()) {
serializer.check(descriptors.getChild(nid).get().getValue());
}
builder.setLinkLocalIdentifier(linkIdentifiers.getLinkLocalIdentifier());
builder.setLinkRemoteIdentifier(linkIdentifiers.getLinkRemoteIdentifier());
}
- builder.setIpv4InterfaceAddress((Ipv4InterfaceIdentifier) tlvs.get(Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME));
- builder.setIpv4NeighborAddress((Ipv4InterfaceIdentifier) tlvs.get(Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME));
- builder.setIpv6InterfaceAddress((Ipv6InterfaceIdentifier) tlvs.get(Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME));
- builder.setIpv6NeighborAddress((Ipv6InterfaceIdentifier) tlvs.get(Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME));
+ builder.setIpv4InterfaceAddress(
+ (Ipv4InterfaceIdentifier) tlvs.get(Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME));
+ builder.setIpv4NeighborAddress(
+ (Ipv4InterfaceIdentifier) tlvs.get(Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME));
+ builder.setIpv6InterfaceAddress(
+ (Ipv6InterfaceIdentifier) tlvs.get(Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME));
+ builder.setIpv6NeighborAddress(
+ (Ipv6InterfaceIdentifier) tlvs.get(Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME));
builder.setMultiTopologyId((TopologyIdentifier) tlvs.get(MultiTopoIdTlvParser.MULTI_TOPOLOGY_ID_QNAME));
return builder.build();
if (linkDescriptor.getLinkLocalIdentifier() != null && linkDescriptor.getLinkRemoteIdentifier() != null) {
reg.serializeTlv(LinkLrIdentifiers.QNAME, linkDescriptor, body);
}
- reg.serializeTlv(Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME, linkDescriptor.getIpv4InterfaceAddress(), body);
- reg.serializeTlv(Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME, linkDescriptor.getIpv4NeighborAddress(), body);
- reg.serializeTlv(Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME, linkDescriptor.getIpv6InterfaceAddress(), body);
- reg.serializeTlv(Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME, linkDescriptor.getIpv6NeighborAddress(), body);
+ reg.serializeTlv(Ipv4InterfaceTlvParser.IPV4_IFACE_ADDRESS_QNAME, linkDescriptor.getIpv4InterfaceAddress(),
+ body);
+ reg.serializeTlv(Ipv4NeighborTlvParser.IPV4_NEIGHBOR_ADDRESS_QNAME, linkDescriptor.getIpv4NeighborAddress(),
+ body);
+ reg.serializeTlv(Ipv6InterfaceTlvParser.IPV6_IFACE_ADDRESS_QNAME, linkDescriptor.getIpv6InterfaceAddress(),
+ body);
+ reg.serializeTlv(Ipv6NeighborTlvParser.IPV6_NEIGHBOR_ADDRESS_QNAME, linkDescriptor.getIpv6NeighborAddress(),
+ body);
reg.serializeTlv(MultiTopoIdTlvParser.MULTI_TOPOLOGY_ID_QNAME, linkDescriptor.getMultiTopologyId(), body);
}
private static final Logger LOG = LoggerFactory.getLogger(LinkstateNlriParser.class);
@VisibleForTesting
- public static final NodeIdentifier OBJECT_TYPE_NID = new NodeIdentifier(ObjectType.QNAME);
+ public static final NodeIdentifier OBJECT_TYPE_NID = NodeIdentifier.create(ObjectType.QNAME);
@VisibleForTesting
- public static final NodeIdentifier NODE_DESCRIPTORS_NID = new NodeIdentifier(NodeDescriptors.QNAME);
+ public static final NodeIdentifier NODE_DESCRIPTORS_NID = NodeIdentifier.create(NodeDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier LOCAL_NODE_DESCRIPTORS_NID = new NodeIdentifier(LocalNodeDescriptors.QNAME);
+ public static final NodeIdentifier LOCAL_NODE_DESCRIPTORS_NID = NodeIdentifier.create(LocalNodeDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier REMOTE_NODE_DESCRIPTORS_NID = new NodeIdentifier(RemoteNodeDescriptors.QNAME);
+ public static final NodeIdentifier REMOTE_NODE_DESCRIPTORS_NID = NodeIdentifier.create(RemoteNodeDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier ADVERTISING_NODE_DESCRIPTORS_NID
- = new NodeIdentifier(AdvertisingNodeDescriptors.QNAME);
+ public static final NodeIdentifier ADVERTISING_NODE_DESCRIPTORS_NID = NodeIdentifier.create(
+ AdvertisingNodeDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier PREFIX_DESCRIPTORS_NID = new NodeIdentifier(PrefixDescriptors.QNAME);
+ public static final NodeIdentifier PREFIX_DESCRIPTORS_NID = NodeIdentifier.create(PrefixDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier LINK_DESCRIPTORS_NID = new NodeIdentifier(LinkDescriptors.QNAME);
+ public static final NodeIdentifier LINK_DESCRIPTORS_NID = NodeIdentifier.create(LinkDescriptors.QNAME);
@VisibleForTesting
- public static final NodeIdentifier PROTOCOL_ID_NID = new NodeIdentifier(
- QName.create(CLinkstateDestination.QNAME.getModule(), "protocol-id"));
+ public static final NodeIdentifier PROTOCOL_ID_NID = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME.getModule(), "protocol-id").intern());
@VisibleForTesting
- public static final NodeIdentifier IDENTIFIER_NID = new NodeIdentifier(
- QName.create(CLinkstateDestination.QNAME.getModule(), "identifier"));
+ public static final NodeIdentifier IDENTIFIER_NID = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME.getModule(), "identifier").intern());
@VisibleForTesting
- private static final NodeIdentifier DISTINGUISHER_NID = new NodeIdentifier(
- QName.create(CLinkstateDestination.QNAME.getModule(), "route-distinguisher"));
+ private static final NodeIdentifier DISTINGUISHER_NID = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME.getModule(), "route-distinguisher").intern());
private final SimpleNlriTypeRegistry nlriTypeReg = SimpleNlriTypeRegistry.getInstance();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof DestinationLinkstateCase) {
final DestinationLinkstateCase linkstateCase
= (DestinationLinkstateCase) withdrawnRoutes.getDestinationType();
- for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate()
+ for (final CLinkstateDestination linkstateDestinationCase : linkstateCase.getDestinationLinkstate()
.getCLinkstateDestination()) {
- this.nlriTypeReg.serializeNlriType(cLinkstateDestination, byteAggregator);
+ this.nlriTypeReg.serializeNlriType(linkstateDestinationCase, byteAggregator);
}
}
}
.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
.DestinationLinkstateCase) advertizedRoutes.getDestinationType();
- for (final CLinkstateDestination cLinkstateDestination : linkstateCase.getDestinationLinkstate()
+ for (final CLinkstateDestination linkstateDestinationCase : linkstateCase.getDestinationLinkstate()
.getCLinkstateDestination()) {
- this.nlriTypeReg.serializeNlriType(cLinkstateDestination, byteAggregator);
+ this.nlriTypeReg.serializeNlriType(linkstateDestinationCase, byteAggregator);
}
}
}
// FIXME : use codec
private static int domProtocolIdValue(final String protocolId) {
switch (protocolId) {
- case "isis-level1":
- return ProtocolId.IsisLevel1.getIntValue();
- case "isis-level2":
- return ProtocolId.IsisLevel2.getIntValue();
- case "ospf":
- return ProtocolId.Ospf.getIntValue();
- case "direct":
- return ProtocolId.Direct.getIntValue();
- case "static":
- return ProtocolId.Static.getIntValue();
- case "ospf-v3":
- return ProtocolId.OspfV3.getIntValue();
- case "rsvp-te":
- return ProtocolId.RsvpTe.getIntValue();
- case "bgp-epe":
- return ProtocolId.BgpEpe.getIntValue();
- case "segment-routing":
- return ProtocolId.SegmentRouting.getIntValue();
- default:
- return 0;
+ case "isis-level1":
+ return ProtocolId.IsisLevel1.getIntValue();
+ case "isis-level2":
+ return ProtocolId.IsisLevel2.getIntValue();
+ case "ospf":
+ return ProtocolId.Ospf.getIntValue();
+ case "direct":
+ return ProtocolId.Direct.getIntValue();
+ case "static":
+ return ProtocolId.Static.getIntValue();
+ case "ospf-v3":
+ return ProtocolId.OspfV3.getIntValue();
+ case "rsvp-te":
+ return ProtocolId.RsvpTe.getIntValue();
+ case "bgp-epe":
+ return ProtocolId.BgpEpe.getIntValue();
+ case "segment-routing":
+ return ProtocolId.SegmentRouting.getIntValue();
+ default:
+ return 0;
}
}
/* Node Descriptor QNames */
@VisibleForTesting
- public static final NodeIdentifier AS_NUMBER_NID = new NodeIdentifier(AsNumTlvParser.AS_NUMBER_QNAME);
+ public static final NodeIdentifier AS_NUMBER_NID = NodeIdentifier.create(AsNumTlvParser.AS_NUMBER_QNAME);
@VisibleForTesting
- public static final NodeIdentifier AREA_NID = new NodeIdentifier(AreaIdTlvParser.AREA_ID_QNAME);
+ public static final NodeIdentifier AREA_NID = NodeIdentifier.create(AreaIdTlvParser.AREA_ID_QNAME);
@VisibleForTesting
- public static final NodeIdentifier DOMAIN_NID = new NodeIdentifier(DomainIdTlvParser.DOMAIN_ID_QNAME);
+ public static final NodeIdentifier DOMAIN_NID = NodeIdentifier.create(DomainIdTlvParser.DOMAIN_ID_QNAME);
@VisibleForTesting
- private static final NodeIdentifier ROUTER_NID = new NodeIdentifier(CRouterIdentifier.QNAME);
+ private static final NodeIdentifier ROUTER_NID = NodeIdentifier.create(CRouterIdentifier.QNAME);
@VisibleForTesting
- public static final NodeIdentifier BGP_ROUTER_NID = new NodeIdentifier(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME);
+ public static final NodeIdentifier BGP_ROUTER_NID = NodeIdentifier.create(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME);
@VisibleForTesting
- public static final NodeIdentifier MEMBER_ASN_NID = new NodeIdentifier(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME);
+ public static final NodeIdentifier MEMBER_ASN_NID = NodeIdentifier.create(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME);
/* Router Identifier QNames */
@VisibleForTesting
- public static final NodeIdentifier ISIS_NODE_NID = new NodeIdentifier(IsisNode.QNAME);
+ public static final NodeIdentifier ISIS_NODE_NID = NodeIdentifier.create(IsisNode.QNAME);
@VisibleForTesting
- public static final NodeIdentifier ISIS_PSEUDONODE_NID = new NodeIdentifier(IsisPseudonode.QNAME);
+ public static final NodeIdentifier ISIS_PSEUDONODE_NID = NodeIdentifier.create(IsisPseudonode.QNAME);
@VisibleForTesting
- public static final NodeIdentifier OSPF_NODE_NID = new NodeIdentifier(OspfNode.QNAME);
+ public static final NodeIdentifier OSPF_NODE_NID = NodeIdentifier.create(OspfNode.QNAME);
@VisibleForTesting
- private static final NodeIdentifier OSPF_PSEUDONODE_NID = new NodeIdentifier(OspfPseudonode.QNAME);
+ private static final NodeIdentifier OSPF_PSEUDONODE_NID = NodeIdentifier.create(OspfPseudonode.QNAME);
@VisibleForTesting
- public static final NodeIdentifier ISO_SYSTEM_NID = new NodeIdentifier(
- QName.create(NodeDescriptors.QNAME.getModule(), "iso-system-id"));
+ public static final NodeIdentifier ISO_SYSTEM_NID = NodeIdentifier.create(
+ QName.create(NodeDescriptors.QNAME, "iso-system-id"));
@VisibleForTesting
- public static final NodeIdentifier ISIS_ROUTER_NID = new NodeIdentifier(
- QName.create(NodeDescriptors.QNAME.getModule(),"is-is-router-identifier"));
+ public static final NodeIdentifier ISIS_ROUTER_NID = NodeIdentifier.create(
+ QName.create(NodeDescriptors.QNAME, "is-is-router-identifier").intern());
@VisibleForTesting
- public static final NodeIdentifier PSN_NID = new NodeIdentifier(
- QName.create(NodeDescriptors.QNAME.getModule(),"psn"));
+ public static final NodeIdentifier PSN_NID = NodeIdentifier.create(
+ QName.create(NodeDescriptors.QNAME, "psn").intern());
@VisibleForTesting
- public static final NodeIdentifier OSPF_ROUTER_NID = new NodeIdentifier(
- QName.create(NodeDescriptors.QNAME.getModule(),"ospf-router-id"));
- private static final NodeIdentifier LAN_IFACE_NID = new NodeIdentifier(
- QName.create(NodeDescriptors.QNAME.getModule(),"lan-interface"));
+ public static final NodeIdentifier OSPF_ROUTER_NID = NodeIdentifier.create(
+ QName.create(NodeDescriptors.QNAME, "ospf-router-id").intern());
+ private static final NodeIdentifier LAN_IFACE_NID = NodeIdentifier.create(
+ QName.create(NodeDescriptors.QNAME, "lan-interface").intern());
@Override
protected ObjectType parseObjectType(final ByteBuf buffer) {
}
private static IsisNodeCase serializeIsisNode(final ContainerNode isis) {
- final IsisNodeCaseBuilder builder = new IsisNodeCaseBuilder();
- final IsisNodeBuilder isisBuilder = new IsisNodeBuilder();
- isisBuilder.setIsoSystemId(new IsoSystemIdentifier((byte[]) isis.getChild(ISO_SYSTEM_NID).get().getValue()));
- builder.setIsisNode(isisBuilder.build());
- return builder.build();
+ return new IsisNodeCaseBuilder()
+ .setIsisNode(new IsisNodeBuilder().setIsoSystemId(
+ new IsoSystemIdentifier((byte[]) isis.getChild(ISO_SYSTEM_NID).get().getValue())).build())
+ .build();
}
private static IsisPseudonodeCase serializeIsisPseudoNode(final ContainerNode pseudoIsisNode) {
}
private static CRouterIdentifier serializeRouterId(final ContainerNode descriptorsData) {
- CRouterIdentifier cRouterId = null;
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId
- = descriptorsData.getChild(ROUTER_NID);
+ CRouterIdentifier ret = null;
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRouterId =
+ descriptorsData.getChild(ROUTER_NID);
if (maybeRouterId.isPresent()) {
final ChoiceNode routerId = (ChoiceNode) maybeRouterId.get();
if (routerId.getChild(ISIS_NODE_NID).isPresent()) {
- cRouterId = serializeIsisNode((ContainerNode) routerId.getChild(ISIS_NODE_NID).get());
+ ret = serializeIsisNode((ContainerNode) routerId.getChild(ISIS_NODE_NID).get());
} else if (routerId.getChild(ISIS_PSEUDONODE_NID).isPresent()) {
- cRouterId = serializeIsisPseudoNode((ContainerNode) routerId.getChild(ISIS_PSEUDONODE_NID).get());
+ ret = serializeIsisPseudoNode((ContainerNode) routerId.getChild(ISIS_PSEUDONODE_NID).get());
} else if (routerId.getChild(OSPF_NODE_NID).isPresent()) {
- cRouterId = serializeOspfNode((ContainerNode) routerId.getChild(OSPF_NODE_NID).get());
+ ret = serializeOspfNode((ContainerNode) routerId.getChild(OSPF_NODE_NID).get());
} else if (routerId.getChild(OSPF_PSEUDONODE_NID).isPresent()) {
- cRouterId = serializeOspfPseudoNode((ContainerNode) routerId.getChild(OSPF_PSEUDONODE_NID).get());
+ ret = serializeOspfPseudoNode((ContainerNode) routerId.getChild(OSPF_PSEUDONODE_NID).get());
}
}
- return cRouterId;
+ return ret;
}
private static AsNumber serializeAsNumber(final ContainerNode descriptorsData) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> asNumber
- = descriptorsData.getChild(AS_NUMBER_NID);
- return asNumber.map(dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
+ return descriptorsData.getChild(AS_NUMBER_NID).map(
+ dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
}
private static DomainIdentifier serializeDomainId(final ContainerNode descriptorsData) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> domainId = descriptorsData.getChild(DOMAIN_NID);
- return domainId.map(dataContainerChild
- -> new DomainIdentifier((Long) dataContainerChild.getValue())).orElse(null);
+ return descriptorsData.getChild(DOMAIN_NID).map(
+ dataContainerChild -> new DomainIdentifier((Long) dataContainerChild.getValue())).orElse(null);
}
private static AreaIdentifier serializeAreaId(final ContainerNode descriptorsData) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> areaId = descriptorsData.getChild(AREA_NID);
- return areaId.map(dataContainerChild
- -> new AreaIdentifier((Long) dataContainerChild.getValue())).orElse(null);
+ return descriptorsData.getChild(AREA_NID).map(
+ dataContainerChild -> new AreaIdentifier((Long) dataContainerChild.getValue())).orElse(null);
}
private static Ipv4Address serializeBgpRouterId(final ContainerNode descriptorsData) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> bgpRouterId
- = descriptorsData.getChild(BGP_ROUTER_NID);
- return bgpRouterId.map(dataContainerChild
- -> new Ipv4Address((String) dataContainerChild.getValue())).orElse(null);
+ return descriptorsData.getChild(BGP_ROUTER_NID).map(
+ dataContainerChild -> new Ipv4Address((String) dataContainerChild.getValue())).orElse(null);
}
private static AsNumber serializeMemberAsn(final ContainerNode descriptorsData) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> memberAsn
- = descriptorsData.getChild(MEMBER_ASN_NID);
- return memberAsn.map(dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
+ return descriptorsData.getChild(MEMBER_ASN_NID).map(
+ dataContainerChild -> new AsNumber((Long) dataContainerChild.getValue())).orElse(null);
}
static LocalNodeDescriptors serializeLocalNodeDescriptors(final ContainerNode descriptorsData) {
- final LocalNodeDescriptorsBuilder builder = new LocalNodeDescriptorsBuilder();
- builder.setAsNumber(serializeAsNumber(descriptorsData));
- builder.setDomainId(serializeDomainId(descriptorsData));
- builder.setAreaId(serializeAreaId(descriptorsData));
- builder.setCRouterIdentifier(serializeRouterId(descriptorsData));
- builder.setBgpRouterId(serializeBgpRouterId(descriptorsData));
- builder.setMemberAsn(serializeMemberAsn(descriptorsData));
- return builder.build();
+ return new LocalNodeDescriptorsBuilder()
+ .setAsNumber(serializeAsNumber(descriptorsData))
+ .setDomainId(serializeDomainId(descriptorsData))
+ .setAreaId(serializeAreaId(descriptorsData))
+ .setCRouterIdentifier(serializeRouterId(descriptorsData))
+ .setBgpRouterId(serializeBgpRouterId(descriptorsData))
+ .setMemberAsn(serializeMemberAsn(descriptorsData))
+ .build();
}
static RemoteNodeDescriptors serializeRemoteNodeDescriptors(final ContainerNode descriptorsData) {
- final RemoteNodeDescriptorsBuilder builder = new RemoteNodeDescriptorsBuilder();
- builder.setAsNumber(serializeAsNumber(descriptorsData));
- builder.setDomainId(serializeDomainId(descriptorsData));
- builder.setAreaId(serializeAreaId(descriptorsData));
- builder.setCRouterIdentifier(serializeRouterId(descriptorsData));
- builder.setBgpRouterId(serializeBgpRouterId(descriptorsData));
- builder.setMemberAsn(serializeMemberAsn(descriptorsData));
- return builder.build();
+ return new RemoteNodeDescriptorsBuilder()
+ .setAsNumber(serializeAsNumber(descriptorsData))
+ .setDomainId(serializeDomainId(descriptorsData))
+ .setAreaId(serializeAreaId(descriptorsData))
+ .setCRouterIdentifier(serializeRouterId(descriptorsData))
+ .setBgpRouterId(serializeBgpRouterId(descriptorsData))
+ .setMemberAsn(serializeMemberAsn(descriptorsData))
+ .build();
}
static AdvertisingNodeDescriptors serializeAdvNodeDescriptors(final ContainerNode descriptorsData) {
- final AdvertisingNodeDescriptorsBuilder builder = new AdvertisingNodeDescriptorsBuilder();
- builder.setAsNumber(serializeAsNumber(descriptorsData));
- builder.setDomainId(serializeDomainId(descriptorsData));
- builder.setAreaId(serializeAreaId(descriptorsData));
- builder.setCRouterIdentifier(serializeRouterId(descriptorsData));
- return builder.build();
+ return new AdvertisingNodeDescriptorsBuilder()
+ .setAsNumber(serializeAsNumber(descriptorsData))
+ .setDomainId(serializeDomainId(descriptorsData))
+ .setAreaId(serializeAreaId(descriptorsData))
+ .setCRouterIdentifier(serializeRouterId(descriptorsData))
+ .build();
}
static NodeDescriptors serializeNodeDescriptors(final ContainerNode descriptorsData) {
- final NodeDescriptorsBuilder builder = new NodeDescriptorsBuilder();
- builder.setAsNumber(serializeAsNumber(descriptorsData));
- builder.setDomainId(serializeDomainId(descriptorsData));
- builder.setAreaId(serializeAreaId(descriptorsData));
- builder.setCRouterIdentifier(serializeRouterId(descriptorsData));
- return builder.build();
+ return new NodeDescriptorsBuilder()
+ .setAsNumber(serializeAsNumber(descriptorsData))
+ .setDomainId(serializeDomainId(descriptorsData))
+ .setAreaId(serializeAreaId(descriptorsData))
+ .setCRouterIdentifier(serializeRouterId(descriptorsData))
+ .build();
}
}
* 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.linkstate.impl.tlvs;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LocalNodeDescriptorsBuilder;
import org.opendaylight.yangtools.yang.common.QName;
-
-public abstract class AbstractLocalNodeDescriptorTlvCodec<T extends NodeIdentifier> extends AbstractNodeDescriptorTlvCodec implements
- LinkstateTlvParser<LocalNodeDescriptors>, LinkstateTlvParser.LinkstateTlvSerializer<T> {
+public abstract class AbstractLocalNodeDescriptorTlvCodec<T extends NodeIdentifier>
+ extends AbstractNodeDescriptorTlvCodec implements LinkstateTlvParser<LocalNodeDescriptors>,
+ LinkstateTlvParser.LinkstateTlvSerializer<T> {
private static final int LOCAL_NODE_DESCRIPTORS_TYPE = 256;
@Override
public final LocalNodeDescriptors parseTlvBody(final ByteBuf value) {
final Map<QName, Object> parsedSubTlvs = new HashMap<>();
- final LocalNodeDescriptorsBuilder builder = new LocalNodeDescriptorsBuilder(parseNodeDescriptor(value, parsedSubTlvs));
+ final LocalNodeDescriptorsBuilder builder = new LocalNodeDescriptorsBuilder(
+ parseNodeDescriptor(value, parsedSubTlvs));
builder.setBgpRouterId((Ipv4Address) parsedSubTlvs.get(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME));
builder.setMemberAsn((AsNumber) parsedSubTlvs.get(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME));
return builder.build();
public final int getType() {
return LOCAL_NODE_DESCRIPTORS_TYPE;
}
-
}
* 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.linkstate.impl.tlvs;
import io.netty.buffer.ByteBuf;
public Class<? extends DataContainer> getImplementedInterface() {
return NodeIdentifier.class;
}
+
@Override
public AsNumber getAsNumber() {
return asNumber;
}
+
@Override
public DomainIdentifier getDomainId() {
return domainId;
}
+
@Override
public AreaIdentifier getAreaId() {
return areaId;
}
+
@Override
public CRouterIdentifier getCRouterIdentifier() {
return routerId;
tlvReg.serializeTlv(AreaIdTlvParser.AREA_ID_QNAME, tlv.getAreaId(), body);
tlvReg.serializeTlv(CRouterIdentifier.QNAME, tlv.getCRouterIdentifier(), body);
}
-
}
* 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.linkstate.impl.tlvs;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.prefix._case.AdvertisingNodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class AdvertisingNodeDescriptorTlvParser extends AbstractLocalNodeDescriptorTlvCodec<AdvertisingNodeDescriptors> {
+public final class AdvertisingNodeDescriptorTlvParser extends
+ AbstractLocalNodeDescriptorTlvCodec<AdvertisingNodeDescriptors> {
@Override
public void serializeTlvBody(final AdvertisingNodeDescriptors tlv, final ByteBuf body) {
serializeNodeDescriptor(tlv, body);
public QName getTlvQName() {
return AdvertisingNodeDescriptors.QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class AreaIdTlvParser implements LinkstateTlvParser<AreaIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<AreaIdentifier> {
+public final class AreaIdTlvParser implements LinkstateTlvParser<AreaIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<AreaIdentifier> {
private static final int AREA_ID = 514;
public QName getTlvQName() {
return AREA_ID_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class AsNumTlvParser implements LinkstateTlvParser<AsNumber>, LinkstateTlvParser.LinkstateTlvSerializer<AsNumber> {
+public final class AsNumTlvParser implements LinkstateTlvParser<AsNumber>,
+ LinkstateTlvParser.LinkstateTlvSerializer<AsNumber> {
private static final int AS_NUMBER = 512;
public QName getTlvQName() {
return AS_NUMBER_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.epe.rev150622.EpeNodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class BgpRouterIdTlvParser implements LinkstateTlvParser<Ipv4Address>, LinkstateTlvParser.LinkstateTlvSerializer<Ipv4Address> {
+public final class BgpRouterIdTlvParser implements LinkstateTlvParser<Ipv4Address>,
+ LinkstateTlvParser.LinkstateTlvSerializer<Ipv4Address> {
private static final int BGP_ROUTER_ID = 516;
public static final QName BGP_ROUTER_ID_QNAME = QName.create(EpeNodeDescriptors.QNAME, "bgp-router-id").intern();
-
@Override
public void serializeTlvBody(final Ipv4Address tlv, final ByteBuf body) {
ByteBufWriteUtil.writeIpv4Address(tlv, body);
public QName getTlvQName() {
return BGP_ROUTER_ID_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class DomainIdTlvParser implements LinkstateTlvParser<DomainIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<DomainIdentifier> {
+public final class DomainIdTlvParser implements LinkstateTlvParser<DomainIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<DomainIdentifier> {
private static final int BGP_LS_ID = 513;
public QName getTlvQName() {
return DOMAIN_ID_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LinkDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class Ipv4InterfaceTlvParser implements LinkstateTlvParser<Ipv4InterfaceIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<Ipv4InterfaceIdentifier> {
+public final class Ipv4InterfaceTlvParser implements LinkstateTlvParser<Ipv4InterfaceIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<Ipv4InterfaceIdentifier> {
private static final int IPV4_IFACE_ADDRESS = 259;
- public static final QName IPV4_IFACE_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv4-interface-address").intern();
-
+ public static final QName IPV4_IFACE_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv4-interface-address")
+ .intern();
@Override
public void serializeTlvBody(final Ipv4InterfaceIdentifier tlv, final ByteBuf body) {
public QName getTlvQName() {
return IPV4_IFACE_ADDRESS_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LinkDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class Ipv4NeighborTlvParser implements LinkstateTlvParser<Ipv4InterfaceIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<Ipv4InterfaceIdentifier> {
+public final class Ipv4NeighborTlvParser implements LinkstateTlvParser<Ipv4InterfaceIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<Ipv4InterfaceIdentifier> {
private static final int IPV4_NEIGHBOR_ADDRESS = 260;
- public static final QName IPV4_NEIGHBOR_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv4-neighbor-address").intern();
-
+ public static final QName IPV4_NEIGHBOR_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv4-neighbor-address")
+ .intern();
@Override
public void serializeTlvBody(final Ipv4InterfaceIdentifier tlv, final ByteBuf body) {
public QName getTlvQName() {
return IPV4_NEIGHBOR_ADDRESS_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LinkDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class Ipv6InterfaceTlvParser implements LinkstateTlvParser<Ipv6InterfaceIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<Ipv6InterfaceIdentifier> {
+public final class Ipv6InterfaceTlvParser implements LinkstateTlvParser<Ipv6InterfaceIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<Ipv6InterfaceIdentifier> {
private static final int IPV6_IFACE_ADDRESS = 261;
- public static final QName IPV6_IFACE_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv6-interface-address").intern();
-
+ public static final QName IPV6_IFACE_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv6-interface-address")
+ .intern();
@Override
public void serializeTlvBody(final Ipv6InterfaceIdentifier tlv, final ByteBuf body) {
public QName getTlvQName() {
return IPV6_IFACE_ADDRESS_QNAME;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.LinkDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class Ipv6NeighborTlvParser implements LinkstateTlvParser<Ipv6InterfaceIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<Ipv6InterfaceIdentifier> {
+public final class Ipv6NeighborTlvParser implements LinkstateTlvParser<Ipv6InterfaceIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<Ipv6InterfaceIdentifier> {
private static final int IPV6_NEIGHBOR_ADDRESS = 262;
- public static final QName IPV6_NEIGHBOR_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv6-neighbor-address").intern();
-
+ public static final QName IPV6_NEIGHBOR_ADDRESS_QNAME = QName.create(LinkDescriptors.QNAME, "ipv6-neighbor-address")
+ .intern();
@Override
public void serializeTlvBody(final Ipv6InterfaceIdentifier tlv, final ByteBuf body) {
public QName getTlvQName() {
return IPV6_NEIGHBOR_ADDRESS_QNAME;
}
-
}
-
-
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.QName;
-public final class LinkIdTlvParser implements LinkstateTlvParser.LinkstateTlvSerializer<LinkLrIdentifiers>, LinkstateTlvParser<LinkLrIdentifiers> {
+public final class LinkIdTlvParser implements LinkstateTlvParser.LinkstateTlvSerializer<LinkLrIdentifiers>,
+ LinkstateTlvParser<LinkLrIdentifiers> {
private static final int LINK_LR_IDENTIFIERS = 258;
public Class<? extends DataContainer> getImplementedInterface() {
return LinkLrIdentifiers.class;
}
+
@Override
public Long getLinkRemoteIdentifier() {
return remoteId;
}
+
@Override
public Long getLinkLocalIdentifier() {
return localId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.epe.rev150622.EpeNodeDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-public final class MemAsNumTlvParser implements LinkstateTlvParser<AsNumber>, LinkstateTlvParser.LinkstateTlvSerializer<AsNumber> {
+public final class MemAsNumTlvParser implements LinkstateTlvParser<AsNumber>,
+ LinkstateTlvParser.LinkstateTlvSerializer<AsNumber> {
private static final int MEMBER_AS_NUMBER = 517;
public QName getTlvQName() {
return MEMBER_AS_NUMBER_QNAME;
}
-
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-public final class MultiTopoIdTlvParser implements LinkstateTlvParser<TopologyIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<TopologyIdentifier> {
+public final class MultiTopoIdTlvParser implements LinkstateTlvParser<TopologyIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<TopologyIdentifier> {
- public static final QName MULTI_TOPOLOGY_ID_QNAME = QName.create(LinkDescriptors.QNAME, "multi-topology-id").intern();
+ public static final QName MULTI_TOPOLOGY_ID_QNAME = QName.create(LinkDescriptors.QNAME, "multi-topology-id")
+ .intern();
@Override
public void serializeTlvBody(final TopologyIdentifier tlv, final ByteBuf body) {
package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
import io.netty.buffer.ByteBuf;
-import java.util.Optional;
import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.OspfRouteType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.prefix._case.PrefixDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
public final class OspfRouteTlvParser implements LinkstateTlvParser<OspfRouteType>,
LinkstateTlvParser.LinkstateTlvSerializer<OspfRouteType> {
}
public static OspfRouteType serializeModel(final ContainerNode prefixDesc) {
- final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> ospfRoute
- = prefixDesc.getChild(OSPF_ROUTE_NID);
- return ospfRoute.map(dataContainerChild
- -> OspfRouteType.forValue(domOspfRouteTypeValue((String) dataContainerChild.getValue())))
- .orElse(null);
+ return prefixDesc.getChild(OSPF_ROUTE_NID).map(
+ dataContainerChild -> OspfRouteType.forValue(domOspfRouteTypeValue((String) dataContainerChild.getValue())))
+ .orElse(null);
}
-
// FIXME : use codec
private static int domOspfRouteTypeValue(final String ospfRouteType) {
switch (ospfRouteType) {
- case "intra-area":
- return OspfRouteType.IntraArea.getIntValue();
- case "inter-area":
- return OspfRouteType.InterArea.getIntValue();
- case "external1":
- return OspfRouteType.External1.getIntValue();
- case "external2":
- return OspfRouteType.External2.getIntValue();
- case "nssa1":
- return OspfRouteType.Nssa1.getIntValue();
- case "nssa2":
- return OspfRouteType.Nssa2.getIntValue();
- default:
- return 0;
+ case "intra-area":
+ return OspfRouteType.IntraArea.getIntValue();
+ case "inter-area":
+ return OspfRouteType.InterArea.getIntValue();
+ case "external1":
+ return OspfRouteType.External1.getIntValue();
+ case "external2":
+ return OspfRouteType.External2.getIntValue();
+ case "nssa1":
+ return OspfRouteType.Nssa1.getIntValue();
+ case "nssa2":
+ return OspfRouteType.Nssa2.getIntValue();
+ default:
+ return 0;
}
}
}
* 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.linkstate.impl.tlvs;
import com.google.common.annotations.VisibleForTesting;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.prefix._case.PrefixDescriptors;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class ReachTlvParser implements LinkstateTlvParser.LinkstateTlvSerializer<IpPrefix>, LinkstateTlvParser<IpPrefix> {
- public static final QName IP_REACHABILITY_QNAME = QName.create(PrefixDescriptors.QNAME, "ip-reachability-information").intern();
+public final class ReachTlvParser implements LinkstateTlvParser.LinkstateTlvSerializer<IpPrefix>,
+ LinkstateTlvParser<IpPrefix> {
+ public static final QName IP_REACHABILITY_QNAME = QName.create(PrefixDescriptors.QNAME,
+ "ip-reachability-information").intern();
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier IP_REACH_NID = new YangInstanceIdentifier.NodeIdentifier(IP_REACHABILITY_QNAME);
+ public static final NodeIdentifier IP_REACH_NID = NodeIdentifier.create(IP_REACHABILITY_QNAME);
private static final Logger LOG = LoggerFactory.getLogger(ReachTlvParser.class);
private static final int IP_REACHABILITY = 265;
* 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.linkstate.impl.tlvs;
import io.netty.buffer.ByteBuf;
import java.util.HashMap;
import java.util.Map;
-import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry;
import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
+import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.RemoteNodeDescriptors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.link._case.RemoteNodeDescriptorsBuilder;
import org.opendaylight.yangtools.yang.common.QName;
-public final class RemoteNodeDescriptorTlvParser extends AbstractNodeDescriptorTlvCodec implements LinkstateTlvParser<RemoteNodeDescriptors>, LinkstateTlvParser.LinkstateTlvSerializer<RemoteNodeDescriptors> {
+public final class RemoteNodeDescriptorTlvParser extends AbstractNodeDescriptorTlvCodec
+ implements LinkstateTlvParser<RemoteNodeDescriptors>,
+ LinkstateTlvParser.LinkstateTlvSerializer<RemoteNodeDescriptors> {
private static final int REMOTE_NODE_DESCRIPTORS_TYPE = 257;
@Override
@Override
public RemoteNodeDescriptors parseTlvBody(final ByteBuf value) {
final Map<QName, Object> parsedSubTlvs = new HashMap<>();
- final RemoteNodeDescriptorsBuilder builder = new RemoteNodeDescriptorsBuilder(parseNodeDescriptor(value, parsedSubTlvs));
+ final RemoteNodeDescriptorsBuilder builder = new RemoteNodeDescriptorsBuilder(
+ parseNodeDescriptor(value, parsedSubTlvs));
builder.setBgpRouterId((Ipv4Address) parsedSubTlvs.get(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME));
builder.setMemberAsn((AsNumber) parsedSubTlvs.get(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME));
return builder.build();
public int getType() {
return REMOTE_NODE_DESCRIPTORS_TYPE;
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
-public final class RouterIdTlvParser implements LinkstateTlvParser<CRouterIdentifier>, LinkstateTlvParser.LinkstateTlvSerializer<CRouterIdentifier> {
+public final class RouterIdTlvParser implements LinkstateTlvParser<CRouterIdentifier>,
+ LinkstateTlvParser.LinkstateTlvSerializer<CRouterIdentifier> {
private static final int OSPF_PSEUDONODE_ROUTER_ID_LENGTH = 8;
private static final int OSPF_ROUTER_ID_LENGTH = 4;
@Override
public CRouterIdentifier parseTlvBody(final ByteBuf value) {
- if (value.readableBytes() == ISO_SYSTEM_ID_LENGTH || (value.readableBytes() == ISO_SYSTEM_ID_LENGTH + PSN_LENGTH && value.getByte(ISO_SYSTEM_ID_LENGTH) == 0)) {
+ if (value.readableBytes() == ISO_SYSTEM_ID_LENGTH || value.readableBytes() == ISO_SYSTEM_ID_LENGTH + PSN_LENGTH
+ && value.getByte(ISO_SYSTEM_ID_LENGTH) == 0) {
return new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(ByteArray.readBytes(value, ISO_SYSTEM_ID_LENGTH))).build()).build();
+ new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(
+ ByteArray.readBytes(value, ISO_SYSTEM_ID_LENGTH))).build()).build();
}
if (value.readableBytes() == ISO_SYSTEM_ID_LENGTH + PSN_LENGTH) {
final IsIsRouterIdentifier iri = new IsIsRouterIdentifierBuilder().setIsoSystemId(
new IsoSystemIdentifier(ByteArray.readBytes(value, ISO_SYSTEM_ID_LENGTH))).build();
- return new IsisPseudonodeCaseBuilder().setIsisPseudonode(new IsisPseudonodeBuilder().setIsIsRouterIdentifier(iri).setPsn((short) value.readByte()).build()).build();
+ return new IsisPseudonodeCaseBuilder().setIsisPseudonode(new IsisPseudonodeBuilder()
+ .setIsIsRouterIdentifier(iri).setPsn((short) value.readByte()).build()).build();
}
if (value.readableBytes() == OSPF_ROUTER_ID_LENGTH) {
return new OspfNodeCaseBuilder().setOspfNode(
}
if (value.readableBytes() == OSPF_PSEUDONODE_ROUTER_ID_LENGTH) {
return new OspfPseudonodeCaseBuilder().setOspfPseudonode(
- new OspfPseudonodeBuilder().setOspfRouterId(value.readUnsignedInt()).setLanInterface(new OspfInterfaceIdentifier(value.readUnsignedInt())).build()).build();
+ new OspfPseudonodeBuilder().setOspfRouterId(value.readUnsignedInt())
+ .setLanInterface(new OspfInterfaceIdentifier(value.readUnsignedInt())).build()).build();
}
return null;
}
public QName getTlvQName() {
return CRouterIdentifier.QNAME;
}
-
}
* 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.linkstate.spi;
import io.netty.buffer.ByteBuf;
import java.math.BigInteger;
-import org.opendaylight.protocol.bgp.linkstate.spi.NlriTypeCaseParser;
-import org.opendaylight.protocol.bgp.linkstate.spi.NlriTypeCaseSerializer;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Identifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
* 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.linkstate.spi;
import com.google.common.annotations.VisibleForTesting;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
public abstract class AbstractTeLspNlriCodec extends AbstractNlriTypeCodec {
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier LSP_ID = new YangInstanceIdentifier.NodeIdentifier(
+ public static final NodeIdentifier LSP_ID = NodeIdentifier.create(
QName.create(CLinkstateDestination.QNAME, "lsp-id").intern());
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier TUNNEL_ID = new YangInstanceIdentifier.NodeIdentifier(
+ public static final NodeIdentifier TUNNEL_ID = NodeIdentifier.create(
QName.create(CLinkstateDestination.QNAME, "tunnel-id").intern());
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier IPV4_TUNNEL_SENDER_ADDRESS = new YangInstanceIdentifier.NodeIdentifier(
+ public static final NodeIdentifier IPV4_TUNNEL_SENDER_ADDRESS = NodeIdentifier.create(
QName.create(CLinkstateDestination.QNAME, "ipv4-tunnel-sender-address").intern());
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier IPV4_TUNNEL_ENDPOINT_ADDRESS = new YangInstanceIdentifier
- .NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "ipv4-tunnel-endpoint-address").intern());
+ public static final NodeIdentifier IPV4_TUNNEL_ENDPOINT_ADDRESS = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME, "ipv4-tunnel-endpoint-address").intern());
@VisibleForTesting
- private static final YangInstanceIdentifier.NodeIdentifier IPV6_TUNNEL_SENDER_ADDRESS = new YangInstanceIdentifier
- .NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-sender-address").intern());
+ private static final NodeIdentifier IPV6_TUNNEL_SENDER_ADDRESS = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-sender-address").intern());
@VisibleForTesting
- private static final YangInstanceIdentifier.NodeIdentifier IPV6_TUNNEL_ENDPOINT_ADDRESS = new YangInstanceIdentifier
- .NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-endpoint-address").intern());
+ private static final NodeIdentifier IPV6_TUNNEL_ENDPOINT_ADDRESS = NodeIdentifier.create(
+ QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-endpoint-address").intern());
@VisibleForTesting
- public static final YangInstanceIdentifier.NodeIdentifier ADDRESS_FAMILY = new YangInstanceIdentifier.NodeIdentifier(AddressFamily.QNAME);
+ public static final NodeIdentifier ADDRESS_FAMILY = NodeIdentifier.create(AddressFamily.QNAME);
public static boolean isTeLsp(final ChoiceNode objectType) {
return objectType.getChild(ADDRESS_FAMILY).isPresent();
teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
- teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
+ teLsp.setAddressFamily(serializeAddressFamily(addressFamily,
+ addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
return teLsp.build();
}
private static AddressFamily serializeAddressFamily(final ChoiceNode addressFamily, final boolean ipv4Case) {
if (ipv4Case) {
return new Ipv4CaseBuilder()
- .setIpv4TunnelSenderAddress(new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).get().getValue()))
- .setIpv4TunnelEndpointAddress(new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
+ .setIpv4TunnelSenderAddress(
+ new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).get().getValue()))
+ .setIpv4TunnelEndpointAddress(
+ new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
.build();
}
return new Ipv6CaseBuilder()
- .setIpv6TunnelSenderAddress(new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_SENDER_ADDRESS).get().getValue()))
- .setIpv6TunnelEndpointAddress(new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
+ .setIpv6TunnelSenderAddress(
+ new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_SENDER_ADDRESS).get().getValue()))
+ .setIpv6TunnelEndpointAddress(
+ new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
.build();
}
interface LinkstateTlvSerializer<T> {
- void serializeTlvBody(final T tlv, final ByteBuf body);
+ void serializeTlvBody(T tlv, ByteBuf body);
int getType();
public static final int TOPOLOGY_ID_OFFSET = 0x3fff;
public static final int MULTI_TOPOLOGY_ID = 263;
- public static final NodeIdentifier MULTI_TOPOLOGY_NID = new NodeIdentifier(QName.create(PrefixDescriptors.QNAME, "topology-identifier").intern());
+ public static final NodeIdentifier MULTI_TOPOLOGY_NID = new NodeIdentifier(QName.create(PrefixDescriptors.QNAME,
+ "topology-identifier").intern());
public static final int LOCAL_IPV4_ROUTER_ID = 1028;
public static final int LOCAL_IPV6_ROUTER_ID = 1029;
private static final Logger LOG = LoggerFactory.getLogger(TlvUtil.class);
+
private TlvUtil() {
- throw new UnsupportedOperationException();
}
/**
return parseTlv(buffer, getParser(buffer));
}
+ private static <T> T parseTlv(final ByteBuf buffer, final LinkstateTlvParser<T> parser) {
+ if (parser == null) {
+ return null;
+ }
+ checkArgument(buffer != null && buffer.isReadable());
+ final int length = buffer.readUnsignedShort();
+ return parser.parseTlvBody(buffer.readSlice(length));
+ }
+
public Map<QName, Object> parseSubTlvs(final ByteBuf buffer) {
final Map<QName, Object> tlvs = new HashMap<>();
while (buffer.isReadable()) {
return parser;
}
- private static <T> T parseTlv(final ByteBuf buffer, final LinkstateTlvParser<T> parser) {
- if (parser == null) {
- return null;
- }
- checkArgument(buffer != null && buffer.isReadable());
- final int length = buffer.readUnsignedShort();
- return parser.parseTlvBody(buffer.readSlice(length));
- }
-
-
public <T> void serializeTlv(final QName tlvQName, final T tlv, final ByteBuf buffer) {
if (tlv == null) {
return;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser;
-import org.opendaylight.protocol.bgp.linkstate.impl.attribute.NodeAttributesParser;
-import org.opendaylight.protocol.bgp.linkstate.impl.attribute.PrefixAttributesParser;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.rsvp.parser.impl.RSVPActivator;
public class LinkstateAttributeParserTest {
- private static final byte[] TE_LSP_ATTR = {0x00, (byte) 0x63, 0x00, (byte) 0x30, // TE LSP Attribute Type, length, value
+ private static final byte[] TE_LSP_ATTR = {
+ 0x00, (byte) 0x63, 0x00, (byte) 0x30, // TE LSP Attribute Type, length, value
0x00, (byte) 0x20, (byte) 0x0c, 0x02, // Length, Class, Ctype
0x00, 0x00, 0x00, 0x07,
0x01, 0x00, 0x00, 0x06,
0x00, 0x00, 0x00, 0x05, //Maximum Packet Size
0x00, (byte) 0x08, (byte) 0xc7, 0x01, // Length, Class, Ctype
0x00, 0x01, 0x00, 0x02,
- 0x01, 0x02, 0x03, 0x04,};
-
- private static final byte[] LINK_ATTR = {0x04, 0x04, 0, 0x04, 0x2a, 0x2a, 0x2a, 0x2a, 0x04, 0x06, 0, 0x04, 0x2b, 0x2b, 0x2b, 0x2b,
- 0x04, 0x40, 0, 0x04, 0, 0, 0, 0, 0x04, 0x41, 0, 0x04, 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, 0x04, 0x42, 0, 0x04,
- 0x46, 0x43, 0x50, 0, 0x04, 0x43, 0, 0x20, 0x46, 0x43, 0x50, 0, 0x46, 0x43, 0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x04, 0x44, 0, 0x08, 0, 0, 0, 0, 0, 0, 0, 0, 0x04, 0x45, 0, 0x02, 0, 0x08, 0x04, 0x46, 0, 0x01,
- (byte) 0xc0, 0x04, 0x47, 0, 0x03, 0, 0, 0x0a, 0x04, 0x48, 0, 0x08, 0x12, 0x34, 0x56, 0x78, 0x10, 0x30, 0x50, 0x70, 0x04, 0x4a,
- 0, 0x05, 0x31, 0x32, 0x4b, 0x2d, 0x32,
+ 0x01, 0x02, 0x03, 0x04
+ };
+
+ private static final byte[] LINK_ATTR = {
+ 0x04, 0x04, 0, 0x04, 0x2a, 0x2a, 0x2a, 0x2a, 0x04, 0x06, 0, 0x04, 0x2b, 0x2b, 0x2b, 0x2b, 0x04, 0x40, 0, 0x04,
+ 0, 0, 0, 0, 0x04, 0x41, 0, 0x04, 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, 0x04, 0x42, 0, 0x04, 0x46, 0x43,
+ 0x50, 0, 0x04, 0x43, 0, 0x20, 0x46, 0x43, 0x50, 0, 0x46, 0x43, 0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x04, 0x44, 0, 0x08, 0, 0, 0, 0, 0, 0, 0, 0, 0x04, 0x45, 0, 0x02, 0, 0x08,
+ 0x04, 0x46, 0, 0x01, (byte) 0xc0, 0x04, 0x47, 0, 0x03, 0, 0, 0x0a, 0x04, 0x48, 0, 0x08, 0x12, 0x34, 0x56, 0x78,
+ 0x10, 0x30, 0x50, 0x70, 0x04, 0x4a, 0, 0x05, 0x31, 0x32, 0x4b, 0x2d, 0x32,
0x04, 0x4b, 0, 0x07, (byte)-80, 10, 0, 0, (byte)0x0f, (byte)0xff, (byte)0xff, // sr-adj
0x04, 0x4b, 0, 0x07, (byte)-80, 10, 0, 0, (byte)0x0f, (byte)0xff, (byte)0xef, // sr-adj
0x04, 0x4c, 0, 0x0d, (byte)-80, 10, 0, 0, 1, 2, 3, 4, 5, 6, (byte)0x0f, (byte)0xff, (byte)0xff, // sr-lan-adj
0x04, 0x5e, 0, 0x04, 0x46, 0x43, 0x50, 0, // Residual Bandwidth
0x04, 0x5f, 0, 0x04, 0x46, 0x43, 0x50, 0, // Available Bandwidth
0x04, 0x60, 0, 0x04, 0, 0, 0, 0, // Utilized Bandwidth
- 0x04, (byte) 0x88, 0, 0x01, 0x0a };
+ 0x04, (byte) 0x88, 0, 0x01, 0x0a
+ };
- private static final byte[] NODE_ATTR = { 0x01, 0x07, 0, 0x04, 0, 0x2a, 0, 0x2b, 0x04, 0, 0, 0x01, (byte) 0xbc, 0x04, 0x02, 0,
- 0x05, 0x31, 0x32, 0x4b, 0x2d, 0x32, 0x04, 0x03, 0, 0x01, 0x72, 0x04, 0x03, 0, 0x01, 0x73, 0x04, 0x04, 0, 0x04,
- 0x29, 0x29, 0x29, 0x29, 0x04, (byte) 0x88, 0, 0x01, 0x0a,
+ private static final byte[] NODE_ATTR = {
+ 0x01, 0x07, 0, 0x04, 0, 0x2a, 0, 0x2b, 0x04, 0, 0, 0x01, (byte) 0xbc, 0x04, 0x02, 0, 0x05, 0x31, 0x32, 0x4b,
+ 0x2d, 0x32, 0x04, 0x03, 0, 0x01, 0x72, 0x04, 0x03, 0, 0x01, 0x73, 0x04, 0x04, 0, 0x04, 0x29, 0x29, 0x29, 0x29,
+ 0x04, (byte) 0x88, 0, 0x01, 0x0a,
4, 0x0a, 0, 0x0c, (byte)0xe0, 0, 1, 2, 3, 4, (byte)0x89, 0, 3, 1, 2, 0, // sr-caps
4, 0x0b, 0, 2, 0, 1 // sr-algorythms
- };
+ };
- private static final byte[] NODE_ATTR_S = { 0x01, 0x07, 0, 0x04, 0, 0x2a, 0, 0x2b, 0x04, 0, 0, 0x01, (byte) 0xbc, 0x04, 0x02, 0,
- 0x05, 0x31, 0x32, 0x4b, 0x2d, 0x32, 0x04, 0x03, 0, 0x01, 0x72, 0x04, 0x03, 0, 0x01, 0x73, 0x04, 0x04, 0, 0x04,
- 0x29, 0x29, 0x29, 0x29,
+ private static final byte[] NODE_ATTR_S = {
+ 0x01, 0x07, 0, 0x04, 0, 0x2a, 0, 0x2b, 0x04, 0, 0, 0x01, (byte) 0xbc, 0x04, 0x02, 0, 0x05, 0x31, 0x32, 0x4b,
+ 0x2d, 0x32, 0x04, 0x03, 0, 0x01, 0x72, 0x04, 0x03, 0, 0x01, 0x73, 0x04, 0x04, 0, 0x04, 0x29, 0x29, 0x29, 0x29,
4, 0x0a, 0, 0x0c, (byte)0xe0, 0, 1, 2, 3, 4, (byte)0x89, 0, 3, 1, 2, 0, // sr-caps
4, 0x0b, 0, 2, 0, 1 // sr-algorythms
- };
+ };
- private static final byte[] P4_ATTR = { 0x04, (byte) 0x80, 0, 0x01, (byte) 0xF0, 0x04, (byte) 0x81, 0, 0x08, 0x12, 0x34, 0x56, 0x78,
+ private static final byte[] P4_ATTR = {
+ 0x04, (byte) 0x80, 0, 0x01, (byte) 0xF0, 0x04, (byte) 0x81, 0, 0x08, 0x12, 0x34, 0x56, 0x78,
0x10, 0x30, 0x50, 0x70, 0x04, (byte) 0x82, 0, 0x08, 0x12, 0x34, 0x56, 0x78, 0x10, 0x30, 0x50, 0x70,
0x04, (byte) 0x83, 0, 0x04, 0, 0, 0, 0x0a, 0x04, (byte) 0x84, 0, 0x04, 0x0a, 0x19, 0x02, 0x1b,
4, (byte)0x86, 0,8, (byte)0xf0, 0, 0,0, 1,2,3,4, // prefix-sid tlv
4, (byte)0x87, 0,0x0c, 0, 0, 0, 5, 4, (byte)0x89, 0, 4, 1,2,3,4, // range tlv
4, (byte)0x88, 0, 4, 1, (byte)0xf0, 0, 0 // binding sid tlv
- };
+ };
private RSVPExtensionProviderContext context;
private RSVPActivator rsvpActivator;
this.rsvpActivator.start(this.context);
this.parser = new LinkstateAttributeParser(false,this.context.getRsvpRegistry());
}
+
private static AttributesBuilder createBuilder(final ObjectType type) {
- return new AttributesBuilder().addAugmentation(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1.class,
- new Attributes1Builder().setMpReachNlri(
- new MpReachNlriBuilder().setAfi(LinkstateAddressFamily.class).setSafi(LinkstateSubsequentAddressFamily.class).setAdvertizedRoutes(
- new AdvertizedRoutesBuilder().setDestinationType(
- new DestinationLinkstateCaseBuilder().setDestinationLinkstate(
- new DestinationLinkstateBuilder().setCLinkstateDestination(
- Lists.newArrayList(new CLinkstateDestinationBuilder().setObjectType(type).setProtocolId(ProtocolId.IsisLevel1).build())).build()).build()).build()).build()).build());
+ return new AttributesBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.multiprotocol.rev180329.Attributes1.class, new Attributes1Builder().setMpReachNlri(
+ new MpReachNlriBuilder().setAfi(LinkstateAddressFamily.class)
+ .setSafi(LinkstateSubsequentAddressFamily.class)
+ .setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
+ new DestinationLinkstateCaseBuilder().setDestinationLinkstate(
+ new DestinationLinkstateBuilder().setCLinkstateDestination(
+ Lists.newArrayList(new CLinkstateDestinationBuilder().setObjectType(type)
+ .setProtocolId(ProtocolId.IsisLevel1).build())).build()).build()).build()).build())
+ .build());
}
private static AttributesBuilder createUnreachBuilder(final ObjectType type) {
- return new AttributesBuilder().addAugmentation(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2.class,
- new Attributes2Builder().setMpUnreachNlri(
- new MpUnreachNlriBuilder().setAfi(LinkstateAddressFamily.class).setSafi(LinkstateSubsequentAddressFamily.class).setWithdrawnRoutes(
- new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(
- Lists.newArrayList(new CLinkstateDestinationBuilder().setObjectType(type).setProtocolId(ProtocolId.IsisLevel1).build())).build()).build()).build()).build()).build());
+ return new AttributesBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.multiprotocol.rev180329.Attributes2.class, new Attributes2Builder().setMpUnreachNlri(
+ new MpUnreachNlriBuilder().setAfi(LinkstateAddressFamily.class)
+ .setSafi(LinkstateSubsequentAddressFamily.class)
+ .setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder()
+ .setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(
+ Lists.newArrayList(new CLinkstateDestinationBuilder().setObjectType(type)
+ .setProtocolId(ProtocolId.IsisLevel1).build())).build()).build()).build()).build())
+ .build());
}
@Test
buff.skipBytes(4);
// there is unresolved TLV at the end, that needs to be cut off
- assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length -5), ByteArray.getAllBytes(buff));
+ assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length - 5), ByteArray.getAllBytes(buff));
}
@Test
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());
+ 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());
assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLinkAttributesPrivateConstructor() throws Throwable {
- final Constructor<LinkAttributesParser> c = LinkAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testNodeAttributesPrivateConstructor() throws Throwable {
- final Constructor<NodeAttributesParser> c = NodeAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testPrefixAttributesPrivateConstructor() throws Throwable {
- final Constructor<PrefixAttributesParser> c = PrefixAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
}
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator;
-import org.opendaylight.protocol.bgp.linkstate.spi.AbstractTeLspNlriCodec;
import org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkNlriParser;
import org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser;
import org.opendaylight.protocol.bgp.linkstate.impl.nlri.NodeNlriParser;
-import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry;
+import org.opendaylight.protocol.bgp.linkstate.spi.AbstractTeLspNlriCodec;
import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
+import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleNlriTypeRegistry;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
private static final NodeIdentifier C_LINKSTATE_NID = new NodeIdentifier(CLinkstateDestination.QNAME);
private static final NodeIdentifier C_ROUTER_ID_NID = new NodeIdentifier(CRouterIdentifier.QNAME);
- 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) 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) 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[] 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) 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) 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) 0x85, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
- private final byte[] linkNlri = new byte[] { (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x85, (byte) 0x02, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
// local node descriptors
(byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x2a,
- (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) 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,
2, 4, 0, 4, 1, 1, 1, 1,
2, 5, 0, 4, 0, 0, 1, 2,
// remote node descriptors
(byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x28,
- (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) 0x04,
+ (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) 0x04,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x40,
2, 4, 0, 4, 1, 1, 1, 2,
2, 5, 0, 4, 0, 0, 1, 3,
// link descriptors
1, 2, 0, 8, 1, 2, 3, 4, 0x0a,
- 0x0b, 0x0c, 0x0d, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0xc5, (byte) 0x14, (byte) 0xa0, (byte) 0x2a,
+ 0x0b, 0x0c, 0x0d, (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,
1, 7, 0, 2, 0, 3 };
- 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, (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) 0x07, (byte) 0x00,
- (byte) 0x02, (byte) 0x00, (byte) 0x0F, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x09,
- (byte) 0x00, (byte) 0x03, (byte) 0x10, (byte) 0xFF, (byte) 0xFF };
-
- private final byte[] teLspNlri = new byte[] { (byte) 0x00, (byte) 0x05, //NLRI Type Te-IPV4
+ 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, (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) 0x07, (byte) 0x00, (byte) 0x02, (byte) 0x00,
+ (byte) 0x0F, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x09,
+ (byte) 0x00, (byte) 0x03, (byte) 0x10, (byte) 0xFF, (byte) 0xFF
+ };
+
+ private final byte[] teLspNlri = new byte[] {
+ (byte) 0x00, (byte) 0x05, //NLRI Type Te-IPV4
(byte) 0x00, (byte) 0x15, // length
(byte) 0x08, //Protocol-ID
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, // Identifier
+ // Identifier
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, //IPv4 Tunnel Sender Address
(byte) 0x00, (byte) 0x01, //Tunnel ID
(byte) 0x00, (byte) 0x01, //LSP ID
final LinkstateNlriParser parser = new LinkstateNlriParser();
final MpReachNlriBuilder builder = new MpReachNlriBuilder();
this.registry = SimpleNlriTypeRegistry.getInstance();
- final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ final BGPActivator act = new BGPActivator(true,
+ ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
parser.parseNlri(Unpooled.copiedBuffer(data), builder, null);
- final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate();
+ final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType())
+ .getDestinationLinkstate();
assertEquals(1, ls.getCLinkstateDestination().size());
this.dest = ls.getCLinkstateDestination().get(0);
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
- final NodeCase nCase = ((NodeCase) this.dest.getObjectType());
+ final NodeCase nCase = (NodeCase) this.dest.getObjectType();
final NodeDescriptors nodeD = nCase.getNodeDescriptors();
assertEquals(new AsNumber(72L), nodeD.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), nodeD.getDomainId());
assertEquals(new IsisPseudonodeCaseBuilder().setIsisPseudonode(
new IsisPseudonodeBuilder().setPsn((short) 5).setIsIsRouterIdentifier(
- new IsIsRouterIdentifierBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { 0, 0, 0, 0, 0, (byte) 0x39 })).build()).build()).build(), nodeD.getCRouterIdentifier());
+ new IsIsRouterIdentifierBuilder().setIsoSystemId(
+ new IsoSystemIdentifier(new byte[] { 0, 0, 0, 0, 0, (byte) 0x39 })).build()).build()).build(),
+ nodeD.getCRouterIdentifier());
final ByteBuf buffer = Unpooled.buffer();
this.registry.serializeNlriType(this.dest, buffer);
assertArrayEquals(this.nodeNlri, ByteArray.readAllBytes(buffer));
// test BI form
- final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder
- .create();
+ final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
final ImmutableLeafNodeBuilder<Long> areaID = new ImmutableLeafNodeBuilder<>();
areaID.withNodeIdentifier(NodeNlriParser.AREA_NID);
- areaID.withValue(2697513L); nodeDescriptors.addChild(areaID.build());
+ areaID.withValue(2697513L);
+ nodeDescriptors.addChild(areaID.build());
final ImmutableLeafNodeBuilder<Long> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
isoSystemID.withValue(new byte[]{0, 0, 0, 0, 0, (byte) 0x39});
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> isisPseudoRouter = Builders.containerBuilder();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> isisPseudoRouter =
+ Builders.containerBuilder();
isisPseudoRouter.withNodeIdentifier(NodeNlriParser.ISIS_ROUTER_NID);
isisPseudoRouter.addChild(isoSystemID.build());
isisNode.addChild(isisPseudoRouter.build());
- isisNode.addChild(Builders.leafBuilder().withNodeIdentifier(NodeNlriParser.PSN_NID).withValue((short) 5).build());
+ isisNode.addChild(Builders.leafBuilder().withNodeIdentifier(NodeNlriParser.PSN_NID).withValue((short) 5)
+ .build());
crouterId.addChild(isisNode.build());
nodeDescriptors.addChild(crouterId.build());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
- final LinkCase lCase = ((LinkCase) this.dest.getObjectType());
+ final LinkCase lCase = (LinkCase) this.dest.getObjectType();
final LocalNodeDescriptors local = lCase.getLocalNodeDescriptors();
assertEquals(new AsNumber(72L), local.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), local.getDomainId());
assertEquals(
new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(
- new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
+ new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] {
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42 })).build()).build(),
+ local.getCRouterIdentifier());
assertEquals("1.1.1.1", local.getBgpRouterId().getValue());
assertEquals(new AsNumber(258L), local.getMemberAsn());
final RemoteNodeDescriptors remote = lCase.getRemoteNodeDescriptors();
assertEquals(new AsNumber(72L), remote.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), remote.getDomainId());
- assertEquals(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x00000040L).build()).build(),
+ assertEquals(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(0x00000040L).build())
+ .build(),
remote.getCRouterIdentifier());
assertEquals(new AsNumber(259L), remote.getMemberAsn());
assertEquals("1.1.1.2", remote.getBgpRouterId().getValue());
assertArrayEquals(this.linkNlri, ByteArray.readAllBytes(buffer));
// test BI form
- final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
+ final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
// local node descriptors
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> localNodeDescriptors = Builders.containerBuilder();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> localNodeDescriptors =
+ Builders.containerBuilder();
localNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.LOCAL_NODE_DESCRIPTORS_NID);
final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
localNodeDescriptors.addChild(memberAsn.build());
// remote descriptors
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> remoteNodeDescriptors = Builders.containerBuilder();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> remoteNodeDescriptors =
+ Builders.containerBuilder();
remoteNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.REMOTE_NODE_DESCRIPTORS_NID);
remoteNodeDescriptors.addChild(asNumber.build());
remoteNodeDescriptors.addChild(domainID.build());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
- final PrefixCase pCase = ((PrefixCase) this.dest.getObjectType());
+ final PrefixCase pCase = (PrefixCase) this.dest.getObjectType();
final AdvertisingNodeDescriptors local = pCase.getAdvertisingNodeDescriptors();
assertEquals(new AsNumber(72L), local.getAsNumber());
assertEquals(new DomainIdentifier(0x28282828L), local.getDomainId());
assertEquals(
- new IsisNodeCaseBuilder().setIsisNode(
- new IsisNodeBuilder().setIsoSystemId(
- new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
+ new IsisNodeCaseBuilder().setIsisNode(new IsisNodeBuilder().setIsoSystemId(
+ new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
final PrefixDescriptors pd = pCase.getPrefixDescriptors();
assertEquals(OspfRouteType.External1, pd.getOspfRouteType());
assertArrayEquals(this.prefixNlri, ByteArray.readAllBytes(buffer));
// test BI form
- final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
+ final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
// advertising node descriptors
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> advertisingNodeDescriptors = Builders.containerBuilder();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> advertisingNodeDescriptors =
+ Builders.containerBuilder();
advertisingNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.ADVERTISING_NODE_DESCRIPTORS_NID);
final ImmutableLeafNodeBuilder<Long> asNumber = new ImmutableLeafNodeBuilder<>();
advertisingNodeDescriptors.addChild(crouterId.build());
// prefix descriptors
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> prefixDescriptors = Builders.containerBuilder();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> prefixDescriptors =
+ Builders.containerBuilder();
prefixDescriptors.withNodeIdentifier(LinkstateNlriParser.PREFIX_DESCRIPTORS_NID);
prefixDescriptors.addChild(asNumber.build());
prefixDescriptors.addChild(domainID.build());
assertEquals(new Ipv4Address("4.3.2.1"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelEndpointAddress());
// test BI form
- final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
+ final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
linkstateBI.addChild(objectType.build());
assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
+
@Test
public void testSerializeAttribute() throws BGPParsingException {
final LinkstateNlriParser parser = new LinkstateNlriParser();
setUp(this.prefixNlri);
final List<CLinkstateDestination> dests = Lists.newArrayList(this.dest);
- final DestinationLinkstateCase dlc = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder().setCLinkstateDestination(dests).build()).build();
+ final DestinationLinkstateCase dlc = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(
+ new DestinationLinkstateBuilder().setCLinkstateDestination(dests).build()).build();
final AdvertizedRoutes aroutes = new AdvertizedRoutesBuilder().setDestinationType(dlc).build();
- final Attributes1 reach = new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(aroutes).build()).build();
+ final Attributes1 reach = new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder()
+ .setAdvertizedRoutes(aroutes).build()).build();
Attributes pa = new AttributesBuilder().addAugmentation(Attributes1.class, reach).build();
setUp(this.nodeNlri);
final List<CLinkstateDestination> destsU = Lists.newArrayList(this.dest);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase dlcU =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(destsU).build()).build();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase dlcU =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder()
+ .setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(destsU)
+ .build()).build();
final WithdrawnRoutes wroutes = new WithdrawnRoutesBuilder().setDestinationType(dlcU).build();
- final Attributes2 unreach = new Attributes2Builder().setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(wroutes).build()).build();
+ final Attributes2 unreach = new Attributes2Builder().setMpUnreachNlri(new MpUnreachNlriBuilder()
+ .setWithdrawnRoutes(wroutes).build()).build();
pa = new AttributesBuilder().addAugmentation(Attributes2.class, unreach).build();
private static final NodeCase OBJECT_TYPE2 = new NodeCaseBuilder().setNodeDescriptors(new NodeDescriptorsBuilder()
- .setAreaId(new AreaIdentifier(2697513L)).setAsNumber(new AsNumber(72L)).setCRouterIdentifier(new IsisPseudonodeCaseBuilder()
+ .setAreaId(new AreaIdentifier(2697513L)).setAsNumber(new AsNumber(72L)).setCRouterIdentifier(
+ new IsisPseudonodeCaseBuilder()
.setIsisPseudonode(new IsisPseudonodeBuilder().setIsIsRouterIdentifier(new IsIsRouterIdentifierBuilder()
- .setIsoSystemId(new IsoSystemIdentifier(new byte[]{0, 0, 0, 0, 0, (byte) 0x39})).build()).setPsn((short) 5).build()).build())
+ .setIsoSystemId(new IsoSystemIdentifier(new byte[]{0, 0, 0, 0, 0, (byte) 0x39})).build())
+ .setPsn((short) 5).build()).build())
.setDomainId(new DomainIdentifier(28282828L)).build()).build();
private static final RouteDistinguisher RD = new RouteDistinguisher(new RdTwoOctetAs("0:5:3"));
.setObjectType(OBJECT_TYPE2)
.setProtocolId(ProtocolId.IsisLevel1).build();
- private static final DestinationLinkstateCase REACH_NLRI = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder()
- .setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase UNREACH_NLRI =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn
- .routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight
- .params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate
- ._case.DestinationLinkstateBuilder().setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
+ private static final DestinationLinkstateCase REACH_NLRI = new DestinationLinkstateCaseBuilder()
+ .setDestinationLinkstate(new DestinationLinkstateBuilder()
+ .setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.update.attributes
+ .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder()
+ .setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .linkstate.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination
+ .linkstate._case.DestinationLinkstateBuilder()
+ .setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
static {
final BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
assertEquals(LinkstateAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(16388));
- assertEquals(LinkstateSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(71));
+ assertEquals(LinkstateSubsequentAddressFamily.class,
+ context.getSubsequentAddressFamilyRegistry().classForFamily(71));
final ByteBuf buffer = Unpooled.buffer();
SimpleNlriTypeRegistry.getInstance().serializeNlriType(LINKSTATE_DESTINATION, buffer);
ROUTE_KEY = new LinkstateRouteKey(PATH_ID, ByteArray.encodeBase64(buffer));
@Test
public void testRouteAttributesIdentifier() {
Assert.assertEquals(new NodeIdentifier(QName.create(LinkstateRoutes.QNAME,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes
+ .QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
}
@Test
@Test
public void testChangedRoutes() {
- final Routes emptyCase = new LinkstateRoutesCaseBuilder().build();
+ final Routes emptyCase = new LinkstateRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
public class ParserTest {
- /**
- * Used by other tests as well
- */
- private static final List<byte[]> inputBytes = new ArrayList<>();
+ // Used by other tests as well
+ private static final List<byte[]> INPUT_BYTES = new ArrayList<>();
private static final int COUNTER = 4;
.getSingletonInstance().getAttributeRegistry(), mock(NlriRegistry.class));
for (int i = 1; i <= COUNTER; i++) {
final String name = "/up" + i + ".bin";
- try (final InputStream is = ParserTest.class.getResourceAsStream(name)){
+ try (InputStream is = ParserTest.class.getResourceAsStream(name)) {
if (is == null) {
throw new IOException("Failed to get resource " + name);
}
final ByteArrayOutputStream bis = new ByteArrayOutputStream();
final byte[] data = new byte[MAX_SIZE];
- int nRead;
- while ((nRead = is.read(data, 0, data.length)) != -1) {
- bis.write(data, 0, nRead);
+ int numRead;
+ while ((numRead = is.read(data, 0, data.length)) != -1) {
+ bis.write(data, 0, numRead);
}
bis.flush();
- inputBytes.add(bis.toByteArray());
+ INPUT_BYTES.add(bis.toByteArray());
is.close();
}
}
@Test
public void testResource() {
- assertNotNull(inputBytes);
+ assertNotNull(INPUT_BYTES);
}
/*
*/
@Test
public void testEORLS() throws Exception {
- final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
- final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0),
+ final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(0), MessageUtil.COMMON_HEADER_LENGTH);
+ final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(INPUT_BYTES.get(0),
MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
null);
final ByteBuf buffer = Unpooled.buffer();
ParserTest.updateParser.serializeMessage(message, buffer);
- assertArrayEquals(inputBytes.get(0), ByteArray.readAllBytes(buffer));
+ assertArrayEquals(INPUT_BYTES.get(0), ByteArray.readAllBytes(buffer));
}
/*
*/
@Test
public void testBGPLink() throws Exception {
- final byte[] body = ByteArray.cutBytes(inputBytes.get(1), MessageUtil.COMMON_HEADER_LENGTH);
- final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(1),
+ final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(1), MessageUtil.COMMON_HEADER_LENGTH);
+ final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(INPUT_BYTES.get(1),
MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
null);
paBuilder.addAugmentation(Attributes1.class, lsBuilder.build());
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.
- Attributes1Builder lsAttrBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
- bgp.linkstate.rev180329.Attributes1Builder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329
+ .Attributes1Builder lsAttrBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .bgp.linkstate.rev180329.Attributes1Builder();
lsAttrBuilder.setLinkStateAttribute(
new LinkAttributesCaseBuilder().setLinkAttributes(new LinkAttributesBuilder()
final ByteBuf buffer = Unpooled.buffer();
ParserTest.updateParser.serializeMessage(message, buffer);
- assertArrayEquals(inputBytes.get(1), ByteArray.readAllBytes(buffer));
+ assertArrayEquals(INPUT_BYTES.get(1), ByteArray.readAllBytes(buffer));
}
/*
*/
@Test
public void testBGPNode() throws Exception {
- final byte[] body = ByteArray.cutBytes(inputBytes.get(2), MessageUtil.COMMON_HEADER_LENGTH);
+ final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(2), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray
- .bytesToInt(ByteArray.subByte(inputBytes.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
+ .bytesToInt(ByteArray.subByte(INPUT_BYTES.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength,
null);
final ByteBuf buffer = Unpooled.buffer();
ParserTest.updateParser.serializeMessage(message, buffer);
- assertArrayEquals(inputBytes.get(2), ByteArray.readAllBytes(buffer));
+ assertArrayEquals(INPUT_BYTES.get(2), ByteArray.readAllBytes(buffer));
}
/*
public void testOpenMessage() throws Exception {
final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext
.getSingletonInstance().getMessageRegistry();
- final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)), null);
+ final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(INPUT_BYTES.get(3)), null);
final Open open = (Open) o;
final Set<BgpTableType> types = Sets.newHashSet();
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
final CParameters cParam = optCapa.getCParameters();
- if(cParam != null && cParam.augmentation(CParameters1.class) != null
+ if (cParam != null && cParam.augmentation(CParameters1.class) != null
&& cParam.augmentation(CParameters1.class).getMultiprotocolCapability() != null) {
final MultiprotocolCapability mp = cParam.augmentation(CParameters1.class)
.getMultiprotocolCapability();
final ByteBuf buffer = Unpooled.buffer();
msgReg.serializeMessage(o, buffer);
- assertArrayEquals(inputBytes.get(3), ByteArray.readAllBytes(buffer));
+ assertArrayEquals(INPUT_BYTES.get(3), ByteArray.readAllBytes(buffer));
}
}
import com.google.common.primitives.Bytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator;
-import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.BindingSidLabelParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.Ipv6SrPrefixAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.RangeTlvParser;
-import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SidLabelIndexParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrLinkAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrNodeAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrPrefixAttributesParser;
private static final byte[] IPV6_B_BYTES = { 0x20, 1, 0x0d, (byte) 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
private static final Ipv6Address IPV6_B = new Ipv6Address("2001:db8::2");
- private static final IsisPrefixFlagsCase ISIS_PREFIX_FLAGS = new IsisPrefixFlagsCaseBuilder().setReadvertisement(Boolean.TRUE).setNodeSid(Boolean.FALSE).setNoPhp(Boolean.TRUE).setExplicitNull(Boolean.FALSE).build();
- private static final OspfPrefixFlagsCase OSPF_PREFIX_FLAGS = new OspfPrefixFlagsCaseBuilder().setNoPhp(Boolean.FALSE).setMappingServer(Boolean.TRUE).setExplicitNull(Boolean.FALSE).build();
+ private static final IsisPrefixFlagsCase ISIS_PREFIX_FLAGS = new IsisPrefixFlagsCaseBuilder()
+ .setReadvertisement(Boolean.TRUE).setNodeSid(Boolean.FALSE).setNoPhp(Boolean.TRUE)
+ .setExplicitNull(Boolean.FALSE).build();
+ private static final OspfPrefixFlagsCase OSPF_PREFIX_FLAGS = new OspfPrefixFlagsCaseBuilder()
+ .setNoPhp(Boolean.FALSE).setMappingServer(Boolean.TRUE).setExplicitNull(Boolean.FALSE).build();
private static final IsisBindingFlagsCase BINDING_FLAGS = new IsisBindingFlagsCaseBuilder()
.setAddressFamily(Boolean.FALSE)
@Before
public void setUp() throws Exception {
- final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
+ final BGPActivator act = new BGPActivator(true,
+ ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
}
@Test
public void testSrAlgorithm() {
final byte[] bytes = { 0 };
- final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Lists.newArrayList(Algorithm.ShortestPathFirst)).build();
+ final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Lists.newArrayList(Algorithm.ShortestPathFirst))
+ .build();
final SrAlgorithm empty = new SrAlgorithmBuilder().setAlgorithms(Collections.emptyList()).build();
assertEquals(alg, SrNodeAttributesParser.parseSrAlgorithms(Unpooled.wrappedBuffer(bytes)));
final ByteBuf b = Unpooled.buffer();
public void testSrCapabilities() {
final byte[] bytesIsis = { (byte)0xC0, 0, 0, 0, 10, 4, (byte)0x89, 0, 4, 1, 2, 3, 4 };
final byte[] bytesOspf = { 0, 0, 0, 0, 10, 4, (byte)0x89, 0, 4, 1, 2, 3, 4 };
- final SrCapabilities capsIsis = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.TRUE).setMplsIpv6(Boolean.TRUE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).setRangeSize((long) 10).build();
- final SrCapabilities capsOspf = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.FALSE).setMplsIpv6(Boolean.FALSE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).setRangeSize((long) 10).build();
- assertEquals(capsIsis, SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.IsisLevel1));
- assertEquals(capsOspf, SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.Ospf));
+ final SrCapabilities capsIsis = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.TRUE).setMplsIpv6(Boolean.TRUE)
+ .setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build())
+ .setRangeSize((long) 10).build();
+ final SrCapabilities capsOspf = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.FALSE)
+ .setMplsIpv6(Boolean.FALSE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder()
+ .setSid(16909060L).build()).setRangeSize((long) 10).build();
+ assertEquals(capsIsis,
+ SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.IsisLevel1));
+ assertEquals(capsOspf,
+ SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.Ospf));
final ByteBuf encodedIsis = Unpooled.buffer();
final ByteBuf encodedOspf = Unpooled.buffer();
SrNodeAttributesParser.serializeSrCapabilities(capsIsis, encodedIsis);
final byte[] bytesOspf = { (byte)0x20, 0, 0, 0, 1, 2, 3, 4 };
final SrPrefix prefixIsis = new SrPrefixBuilder()
.setFlags(ISIS_PREFIX_FLAGS)
- .setAlgorithm(Algorithm.ShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build();
+ .setAlgorithm(Algorithm.ShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build())
+ .build();
final SrPrefix prefixOspf = new SrPrefixBuilder()
.setFlags(OSPF_PREFIX_FLAGS)
- .setAlgorithm(Algorithm.ShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build();
- assertEquals(prefixIsis, SrPrefixAttributesParser.parseSrPrefix(Unpooled.wrappedBuffer(bytes), ProtocolId.IsisLevel1));
- assertEquals(prefixOspf, SrPrefixAttributesParser.parseSrPrefix(Unpooled.wrappedBuffer(bytes), ProtocolId.Ospf));
+ .setAlgorithm(Algorithm.ShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build())
+ .build();
+ assertEquals(prefixIsis,
+ SrPrefixAttributesParser.parseSrPrefix(Unpooled.wrappedBuffer(bytes), ProtocolId.IsisLevel1));
+ assertEquals(prefixOspf,
+ SrPrefixAttributesParser.parseSrPrefix(Unpooled.wrappedBuffer(bytes), ProtocolId.Ospf));
final ByteBuf serializedPrefix = Unpooled.buffer();
final ByteBuf serializedPrefixOspf = Unpooled.buffer();
SrPrefixAttributesParser.serializeSrPrefix(prefixIsis, serializedPrefix);
final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
addSubTlvs(rangeSubTlvs);
- final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(5).setSubTlvs(rangeSubTlvs).build();
+ final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(5)
+ .setSubTlvs(rangeSubTlvs).build();
assertEquals(expected, parsedRange);
new PrefixSidTlvCaseBuilder()
.setFlags(ISIS_PREFIX_FLAGS)
.setAlgorithm(Algorithm.StrictShortestPathFirst)
- .setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(66048L)).build()).build()).build());
+ .setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(66048L)).build()).build())
+ .build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(
.setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build())
.build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
- new SidLabelCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build()).build());
+ new SidLabelCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build())
+ .build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
new EroMetricCaseBuilder().setEroMetric(new TeMetric(6L)).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
new Ipv4EroCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4Address("9.8.7.6")).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
- new UnnumberedInterfaceIdEroCaseBuilder().setLoose(Boolean.FALSE).setRouterId(16843009L).setInterfaceId(33686018L).build()).build());
+ new UnnumberedInterfaceIdEroCaseBuilder().setLoose(Boolean.FALSE).setRouterId(16843009L)
+ .setInterfaceId(33686018L).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
- new Ipv4EroBackupCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4Address("3.4.5.6")).build()).build());
+ new Ipv4EroBackupCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4Address("3.4.5.6")).build())
+ .build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
- new UnnumberedInterfaceIdBackupEroCaseBuilder().setLoose(Boolean.FALSE).setRouterId(50529027L).setInterfaceId(67372036L).build()).build());
+ new UnnumberedInterfaceIdBackupEroCaseBuilder().setLoose(Boolean.FALSE).setRouterId(50529027L)
+ .setInterfaceId(67372036L).build()).build());
}
@Test
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
new Ipv6EroCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6Address(IPV6_A)).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(
- new Ipv6EroBackupCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6Address(IPV6_B)).build()).build());
+ new Ipv6EroBackupCaseBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6Address(IPV6_B)).build())
+ .build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(
new BindingSidTlvCaseBuilder()
.setWeight(new Weight((short) 5))
.setFlags(BINDING_FLAGS)
.setBindingSubTlvs(bindingSubTlvs).build()).build());
- final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(5).setSubTlvs(rangeSubTlvs).build();
+ final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(5)
+ .setSubTlvs(rangeSubTlvs).build();
assertEquals(expected, parsedRange);
final SrAdjIds srAdjId = new SrAdjIdsBuilder()
.setFlags(ISIS_ADJ_FLAGS)
.setWeight(new Weight((short) 10))
- .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
+ .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(
+ Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
final SrAdjIds ospfAdj = new SrAdjIdsBuilder()
.setFlags(OSPF_ADJ_FLAGS)
.setWeight(new Weight((short) 10))
- .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
+ .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(
+ Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
- assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
- assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
+ assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(
+ Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
+ assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(
+ Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
final ByteBuf serializedData = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(srAdjId);
final ByteBuf serializedOspf = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(ospfAdj);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
.setWeight(new Weight((short)10))
.setNeighborId(new Ipv4Address("1.2.3.4"))
.setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(24000L)).build()).build();
- assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.Ospf));
+ assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(
+ Unpooled.wrappedBuffer(tested), ProtocolId.Ospf));
final ByteBuf serializedData = SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifier(srLanAdjId);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
}
@Test
public void testSrLanAdjIdIsis() {
- final byte[] tested = { (byte)0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ final byte[] tested = { (byte)0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16 };
final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
final byte[] systemId = { 1, 2, 3, 4, 5, 6 };
final SrLanAdjIds srLanAdjId = new SrLanAdjIdsBuilder()
.setFlags(ISIS_ADJ_FLAGS)
.setWeight(new Weight((short)10))
.setIsoSystemId(new IsoSystemIdentifier(systemId))
- .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
- assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1));
+ .setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(
+ Unpooled.copiedBuffer(sidLabel))).build()).build();
+ assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(
+ Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1));
final ByteBuf serializedData = SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifier(srLanAdjId);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
}
-
- @Test(expected=UnsupportedOperationException.class)
- public void testSrLinkAttributesPrivateConstructor() throws Throwable {
- final Constructor<SrLinkAttributesParser> c = SrLinkAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testSrNodeAttributesPrivateConstructor() throws Throwable {
- final Constructor<SrNodeAttributesParser> c = SrNodeAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testSrPrefixAttributesPrivateConstructor() throws Throwable {
- final Constructor<SrPrefixAttributesParser> c = SrPrefixAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testIpv6SrPrefixAttributesPrivateConstructor() throws Throwable {
- final Constructor<Ipv6SrPrefixAttributesParser> c = Ipv6SrPrefixAttributesParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testBindingParserPrivateConstructor() throws Throwable {
- final Constructor<BindingSidLabelParser> c = BindingSidLabelParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testRangeTlvParserPrivateConstructor() throws Throwable {
- final Constructor<RangeTlvParser> c = RangeTlvParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testSidLabelIndexParserPrivateConstructor() throws Throwable {
- final Constructor<SidLabelIndexParser> c = SidLabelIndexParser.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
}
+++ /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.linkstate;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import org.junit.Test;
-import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
-
-public class TlvUtilTest {
-
- @Test(expected=UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<TlvUtil> c = TlvUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-}