use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method parseUnreachNlriMultiPathTest.
@Test
public void parseUnreachNlriMultiPathTest() {
final MpUnreachNlri mpUnreachNlri = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()).build()).build()).build();
final MpUnreachNlriBuilder mpUnreachNlriBuilder = new MpUnreachNlriBuilder();
mpUnreachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpUnreachNlriBuilder, this.constraint);
mpUnreachNlriBuilder.setAfi(null).setSafi(null);
Assert.assertEquals(mpUnreachNlri, mpUnreachNlriBuilder.build());
final Ipv4NlriParser serializer = new Ipv4NlriParser();
final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length);
final Attributes attributes = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreachNlri).build()).build();
serializer.serializeAttribute(attributes, output);
Assert.assertArrayEquals(MP_NLRI_BYTES, output.array());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method parseReachNlriMultiPathTest.
@Test
public void parseReachNlriMultiPathTest() {
final MpReachNlri mpReachNlri = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()).build()).build()).build();
final MpReachNlriBuilder mpReachNlriBuilder = new MpReachNlriBuilder();
mpReachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpReachNlriBuilder, this.constraint);
mpReachNlriBuilder.setAfi(null).setSafi(null);
Assert.assertEquals(mpReachNlri, mpReachNlriBuilder.build());
final Ipv4NlriParser serializer = new Ipv4NlriParser();
final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length);
final Attributes attributes = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachNlri).build()).build();
serializer.serializeAttribute(attributes, output);
Assert.assertArrayEquals(MP_NLRI_BYTES, output.array());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.
the class Ipv4NlriParser method prefixes.
private static DestinationIpv4 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
final List<Ipv4Prefixes> prefixes = new ArrayList<>();
while (nlri.isReadable()) {
final Ipv4PrefixesBuilder prefixesBuilder = new Ipv4PrefixesBuilder();
if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
prefixesBuilder.setPathId(PathIdUtil.readPathId(nlri));
}
prefixesBuilder.setPrefix(Ipv4Util.prefixForByteBuf(nlri));
prefixes.add(prefixesBuilder.build());
}
return new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project bgpcep by opendaylight.
the class PrefixesBuilder method createAttributes.
private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport, final Ipv4Prefix addressPrefix) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
attBuilder.setExtendedCommunities(createExtComm(extCom));
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
final Ipv4PrefixesBuilder prefixes = new Ipv4PrefixesBuilder().setPrefix(addressPrefix);
if (multiPathSupport) {
prefixes.setPathId(new PathId(5L));
}
attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(prefixes.build())).build()).build()).build()).build()).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.Prefixes in project openflowplugin by opendaylight.
the class MatchConvertorTest method testArpMatchConversionWithMasks.
@Test
public void testArpMatchConversionWithMasks() {
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
/* Use canonnical prefixes !!! */
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));
arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));
ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
srcHwBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(arpBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 4, entries.size());
MatchEntry entry = entries.get(0);
entry = entries.get(0);
checkEntryHeader(entry, ArpSpa.class, true);
Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp spa mask", new byte[] { (byte) 255, 0, 0, 0 }, ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());
entry = entries.get(1);
checkEntryHeader(entry, ArpTpa.class, true);
Assert.assertEquals("Wrong arp tpa", "10.0.0.4", ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp tpa mask", new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 254 }, ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getMask());
entry = entries.get(2);
checkEntryHeader(entry, ArpSha.class, true);
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp sha mask", new byte[] { 0, 0, 0, 0, 0, 8 }, ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMask());
entry = entries.get(3);
checkEntryHeader(entry, ArpTha.class, true);
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp tha mask", new byte[] { 0, 0, 0, 0, 0, 9 }, ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());
}
Aggregations