use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCaseBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method addSubTlvs.
private static void addSubTlvs(final List<SubTlvs> rangeSubTlvs) {
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new SidLabelTlvCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new PrefixSidTlvCaseBuilder().setPrefixSidTlv(new PrefixSidTlvBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(Uint32.valueOf(66048))).build()).build()).build()).build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight(Uint8.valueOf(5))).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCaseBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrCapabilities.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.1.1
@Test
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(Uint32.valueOf(16909060L)).build()).setRangeSize(new Uint24(Uint32.TEN)).build();
final SrCapabilities capsOspf = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.FALSE).setMplsIpv6(Boolean.FALSE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).setRangeSize(new Uint24(Uint32.TEN)).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);
SrNodeAttributesParser.serializeSrCapabilities(capsOspf, encodedOspf);
assertArrayEquals(bytesIsis, ByteArray.readAllBytes(encodedIsis));
assertArrayEquals(bytesOspf, ByteArray.readAllBytes(encodedOspf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCaseBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrPrefix.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.1
@Test
public void testSrPrefix() {
final byte[] bytes = { (byte) 0xA0, 0, 0, 0, 1, 2, 3, 4 };
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(Uint32.valueOf(16909060L)).build()).build();
final SrPrefix prefixOspf = new SrPrefixBuilder().setFlags(OSPF_PREFIX_FLAGS).setAlgorithm(Algorithm.ShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(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);
SrPrefixAttributesParser.serializeSrPrefix(prefixOspf, serializedPrefixOspf);
assertArrayEquals(bytes, ByteArray.readAllBytes(serializedPrefix));
assertArrayEquals(bytesOspf, ByteArray.readAllBytes(serializedPrefixOspf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCaseBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method addBindingSubTlvs.
private static void addBindingSubTlvs(final List<BindingSubTlvs> bindingSubTlvs) {
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new PrefixSidCaseBuilder().setPrefixSid(new PrefixSidBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new SidLabelCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new EroMetricCaseBuilder().setEroMetric(new TeMetric(Uint32.valueOf(6))).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv4EroCaseBuilder().setIpv4Ero(new Ipv4EroBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4AddressNoZone("9.8.7.6")).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new UnnumberedInterfaceIdEroCaseBuilder().setUnnumberedInterfaceIdEro(new UnnumberedInterfaceIdEroBuilder().setLoose(Boolean.FALSE).setRouterId(Uint32.valueOf(16843009L)).setInterfaceId(Uint32.valueOf(33686018L)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv4EroBackupCaseBuilder().setIpv4EroBackup(new Ipv4EroBackupBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv4AddressNoZone("3.4.5.6")).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new UnnumberedInterfaceIdBackupEroCaseBuilder().setUnnumberedInterfaceIdBackupEro(new UnnumberedInterfaceIdBackupEroBuilder().setLoose(Boolean.FALSE).setRouterId(Uint32.valueOf(50529027L)).setInterfaceId(Uint32.valueOf(67372036L)).build()).build()).build());
}
Aggregations