Search in sources :

Example 11 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.AttributesBuilder in project bgpcep by opendaylight.

the class ExtendedCommunitiesAttributeParserTest method testEmptyListExtendedCommunityAttributeParser.

@Test
public void testEmptyListExtendedCommunityAttributeParser() throws BGPDocumentedException, BGPParsingException {
    final List<ExtendedCommunities> extendedCommunitiesList = new ArrayList<>();
    final AttributesBuilder attBuilder = new AttributesBuilder().setExtendedCommunities(extendedCommunitiesList);
    final ByteBuf output = Unpooled.buffer();
    this.handler.serializeAttribute(attBuilder.build(), output);
    Assert.assertEquals(output, output);
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 12 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.AttributesBuilder in project bgpcep by opendaylight.

the class UnrecognizedAttributesSerializerTest method testUnrecognizedAttributesSerializer.

@Test
public void testUnrecognizedAttributesSerializer() {
    final byte[] unrecognizedValue1 = { (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35 };
    final byte[] unrecognizedValue2 = { (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd7, 0x5d, 0x75, (byte) 0xd7, 0x5d, 0x75 };
    final byte[] unrecognizedBytes = { (byte) 0xe0, 0x65, 0x0c, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xe0, 0x66, 0x0c, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd7, 0x5d, 0x75, (byte) 0xd7, 0x5d, 0x75 };
    final List<UnrecognizedAttributes> unrecognizedAttrs = new ArrayList<>();
    final UnrecognizedAttributes unrecognizedAttribute1 = new UnrecognizedAttributesBuilder().setPartial(true).setTransitive(true).setType((short) 101).setValue(unrecognizedValue1).build();
    unrecognizedAttrs.add(unrecognizedAttribute1);
    final UnrecognizedAttributes unrecognizedAttribute2 = new UnrecognizedAttributesBuilder().setPartial(true).setTransitive(true).setType((short) 102).setValue(unrecognizedValue2).build();
    unrecognizedAttrs.add(unrecognizedAttribute2);
    final Attributes attrs = new AttributesBuilder().setUnrecognizedAttributes(unrecognizedAttrs).build();
    final ByteBuf buffer = Unpooled.buffer();
    ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry().serializeAttribute(attrs, buffer);
    assertArrayEquals(unrecognizedBytes, ByteArray.readAllBytes(buffer));
}
Also used : ArrayList(java.util.ArrayList) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) UnrecognizedAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder) ByteBuf(io.netty.buffer.ByteBuf) UnrecognizedAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes) Test(org.junit.Test)

Example 13 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.AttributesBuilder in project bgpcep by opendaylight.

the class ClusterIdAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) {
    final List<ClusterIdentifier> list = Lists.newArrayList();
    while (buffer.isReadable()) {
        list.add(new ClusterIdentifier(Ipv4Util.addressForByteBuf(buffer)));
    }
    builder.setClusterId(new ClusterIdBuilder().setCluster(list).build());
}
Also used : ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder)

Example 14 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.AttributesBuilder in project bgpcep by opendaylight.

the class ExtendedCommunitiesAttributeParser method parseAttribute.

@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
    final List<ExtendedCommunities> set = new ArrayList<>();
    while (buffer.isReadable()) {
        final ExtendedCommunities exComm = this.ecReg.parseExtendedCommunity(buffer);
        if (exComm != null) {
            set.add(exComm);
        }
    }
    builder.setExtendedCommunities(set);
}
Also used : ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities) ArrayList(java.util.ArrayList)

Example 15 with AttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.AttributesBuilder in project bgpcep by opendaylight.

the class FlowspecL3vpnIpv6NlriParserTest method testParseMpUnreachNlri.

@Test
public void testParseMpUnreachNlri() throws BGPParsingException {
    final List<Flowspec> fs = new ArrayList<>();
    final MpUnreachNlriBuilder mp = new MpUnreachNlriBuilder();
    final FlowspecBuilder builder = new FlowspecBuilder();
    final FragmentCase fragment = createFragment();
    builder.setFlowspecType(fragment);
    fs.add(builder.build());
    final FlowspecType label = createLabel();
    builder.setFlowspecType(label);
    fs.add(builder.build());
    final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
    result.setAfi(Ipv6AddressFamily.class);
    result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
    this.FS_PARSER.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result);
    final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6Case) result.getWithdrawnRoutes().getDestinationType()).getDestinationFlowspecL3vpnIpv6();
    final List<Flowspec> flows = flowspecDst.getFlowspec();
    final RouteDistinguisher rd = flowspecDst.getRouteDistinguisher();
    assertEquals(2, flows.size());
    assertEquals(ROUTE_DISTINGUISHER, new String(rd.getValue()));
    assertEquals(fragment, flows.get(0).getFlowspecType());
    assertEquals(label, flows.get(1).getFlowspecType());
    mp.setAfi(Ipv6AddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setFlowspec(fs).build()).build()).build());
    final ByteBuf buffer = Unpooled.buffer();
    this.FS_PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mp.build()).build()).build(), buffer);
    assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
    assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to 16777222 or equals to 258 ", this.FS_PARSER.stringNlri(flows));
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) MockitoAnnotations(org.mockito.MockitoAnnotations) DestinationFlowspecL3vpnIpv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6Builder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) FlowspecType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.FlowspecType) Flowspec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) FlowspecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder) DestinationFlowspecL3vpnIpv6(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6) Attributes2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder) FragmentCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.FragmentCase) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)118 Test (org.junit.Test)95 ByteBuf (io.netty.buffer.ByteBuf)58 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)29 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)29 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)28 ArrayList (java.util.ArrayList)26 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)25 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)24 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)23 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)23 Attributes2Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder)22 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)20 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)19 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder)19 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder)18 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)17 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)16 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)16 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)16