Search in sources :

Example 1 with PeDistinguisherLabelsAttributeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder in project bgpcep by opendaylight.

the class PEDistinguisherLabelsAttributeHandler method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder, final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint) throws BGPTreatAsWithdrawException {
    final int readable = buffer.readableBytes();
    if (readable == 0) {
        return;
    }
    final boolean isIpv4;
    final int count;
    if (readable % 7 == 0) {
        count = readable / 7;
        isIpv4 = true;
    } else if (readable % 19 == 0) {
        count = readable / 19;
        isIpv4 = false;
    } else {
        // as though all the routes contained in this Update had been withdrawn.
        throw new BGPTreatAsWithdrawException(BGPError.MALFORMED_ATTR_LIST, "PE Distinguisher Labels has incorrect length %s", readable);
    }
    final List<PeDistinguisherLabelAttribute> list = new ArrayList<>(count);
    for (int i = 0; i < count; ++i) {
        final PeDistinguisherLabelAttributeBuilder attribute = new PeDistinguisherLabelAttributeBuilder();
        if (isIpv4) {
            attribute.setPeAddress(new IpAddressNoZone(Ipv4Util.addressForByteBuf(buffer)));
        } else {
            attribute.setPeAddress(new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer)));
        }
        attribute.setMplsLabel(MplsLabelUtil.mplsLabelForByteBuf(buffer));
        list.add(attribute.build());
    }
    builder.addAugmentation(new PeDistinguisherLabelsAttributeAugmentationBuilder().setPeDistinguisherLabelsAttribute(new PeDistinguisherLabelsAttributeBuilder().setPeDistinguisherLabelAttribute(list).build()).build());
}
Also used : PeDistinguisherLabelAttributeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttributeBuilder) BGPTreatAsWithdrawException(org.opendaylight.protocol.bgp.parser.BGPTreatAsWithdrawException) PeDistinguisherLabelsAttributeAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.bgp.rib.route.PeDistinguisherLabelsAttributeAugmentationBuilder) PeDistinguisherLabelsAttributeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder) ArrayList(java.util.ArrayList) PeDistinguisherLabelAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttribute) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)

Example 2 with PeDistinguisherLabelsAttributeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder in project bgpcep by opendaylight.

the class PEDistinguisherLabelsAttributeHandlerTest method buildPEDistinguisherLabelsAttributAttribute.

private static Attributes buildPEDistinguisherLabelsAttributAttribute() {
    final List<PeDistinguisherLabelAttribute> peAtt = new ArrayList<>(2);
    peAtt.add(new PeDistinguisherLabelAttributeBuilder().setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).setMplsLabel(new MplsLabel(Uint32.ONE)).build());
    peAtt.add(new PeDistinguisherLabelAttributeBuilder().setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2"))).setMplsLabel(new MplsLabel(Uint32.TWO)).build());
    return new AttributesBuilder().addAugmentation(new PeDistinguisherLabelsAttributeAugmentationBuilder().setPeDistinguisherLabelsAttribute(new PeDistinguisherLabelsAttributeBuilder().setPeDistinguisherLabelAttribute(peAtt).build()).build()).build();
}
Also used : PeDistinguisherLabelAttributeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttributeBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) PeDistinguisherLabelsAttributeAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.bgp.rib.route.PeDistinguisherLabelsAttributeAugmentationBuilder) PeDistinguisherLabelsAttributeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder) ArrayList(java.util.ArrayList) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) PeDistinguisherLabelAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttribute) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)

Aggregations

ArrayList (java.util.ArrayList)2 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)2 PeDistinguisherLabelsAttributeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.bgp.rib.route.PeDistinguisherLabelsAttributeAugmentationBuilder)2 PeDistinguisherLabelsAttributeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder)2 PeDistinguisherLabelAttribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttribute)2 PeDistinguisherLabelAttributeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttributeBuilder)2 BGPTreatAsWithdrawException (org.opendaylight.protocol.bgp.parser.BGPTreatAsWithdrawException)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)1 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)1