Search in sources :

Example 1 with IgpBits

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits in project bgpcep by opendaylight.

the class LinkstateAttributeParserTest method testPositiveV4Prefixes.

@Test
public void testPositiveV4Prefixes() throws BGPParsingException, BGPDocumentedException {
    final AttributesBuilder builder = createUnreachBuilder(new PrefixCaseBuilder().setPrefixDescriptors(new PrefixDescriptorsBuilder().setIpReachabilityInformation(new IpPrefix(new Ipv4Prefix("127.0.0.1/32"))).build()).build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(P4_ATTR), builder, null);
    final Attributes1 attrs = builder.augmentation(Attributes1.class);
    final PrefixAttributes ls = ((PrefixAttributesCase) attrs.getLinkStateAttribute()).getPrefixAttributes();
    assertNotNull(ls);
    assertNotNull(ls.getSrRange());
    assertFalse(ls.getSrRange().getInterArea());
    assertEquals(1, ls.getSrRange().getSubTlvs().size());
    assertNotNull(ls.getSrBindingSidLabels());
    final IgpBits ispBits = ls.getIgpBits();
    assertTrue(ispBits.getUpDown().getUpDown());
    assertTrue(ispBits.getIsIsUpDown());
    assertTrue(ispBits.getOspfNoUnicast());
    assertTrue(ispBits.getOspfLocalAddress());
    assertTrue(ispBits.getOspfPropagateNssa());
    assertEquals(2, ls.getRouteTags().size());
    assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }, ls.getRouteTags().get(0).getValue());
    assertEquals(1, ls.getExtendedTags().size());
    assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70 }, ls.getExtendedTags().get(0).getValue());
    assertEquals(10, ls.getPrefixMetric().getValue().intValue());
    assertEquals("10.25.2.27", ls.getOspfForwardingAddress().getIpv4AddressNoZone().getValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    buff.skipBytes(3);
    // there is unresolved TLV at the end, that needs to be cut off
    assertArrayEquals(P4_ATTR, ByteArray.getAllBytes(buff));
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) PrefixDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.PrefixDescriptorsBuilder) PrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCaseBuilder) PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) PrefixAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1) IgpBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Example 2 with IgpBits

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits in project bgpcep by opendaylight.

the class PrefixAttributesParser method serializePrefixAttributes.

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);
        final IgpBits igpBits = prefixAtrributes.getIgpBits();
        igpBit.set(UP_DOWN_BIT, igpBits.getUpDown().getUpDown() || igpBits.getIsIsUpDown());
        igpBit.set(OSPF_NO_UNICAST, igpBits.getOspfNoUnicast());
        igpBit.set(OSPF_LOCAL_ADDRESS, igpBits.getOspfLocalAddress());
        igpBit.set(OSPF_PROPAGATE_ADDRESS, igpBits.getOspfPropagateNssa());
        TlvUtil.writeTLV(IGP_FLAGS, Unpooled.wrappedBuffer(igpBit.array()), byteAggregator);
    }
    serializeRouteTags(prefixAtrributes.getRouteTags(), byteAggregator);
    serializeExtendedRouteTags(prefixAtrributes.getExtendedTags(), byteAggregator);
    serializePrefixMetric(prefixAtrributes.getPrefixMetric(), byteAggregator);
    serializeForwardingAddress(prefixAtrributes.getOspfForwardingAddress(), byteAggregator);
    serializeSrPrefix(prefixAtrributes.getSrPrefix(), byteAggregator);
    serializeIpv6SrPrefix(prefixAtrributes.getIpv6SrPrefix(), byteAggregator);
    serializeSrRange(prefixAtrributes.getSrRange(), byteAggregator);
    serializeSrBindingLabel(prefixAtrributes.getSrBindingSidLabels(), byteAggregator);
}
Also used : PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) BitArray(org.opendaylight.protocol.util.BitArray) IgpBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits)

Aggregations

PrefixAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes)2 IgpBits (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 BitArray (org.opendaylight.protocol.util.BitArray)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1)1 PrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCaseBuilder)1 PrefixDescriptorsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.PrefixDescriptorsBuilder)1 PrefixAttributesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase)1 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)1