use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class PcRptMessageCodecTest method testGetValidReportsPositive.
@Test
public void testGetValidReportsPositive() {
final PcRptMessageCodec codec = new PcRptMessageCodec(this.ctx.getObjectHandlerRegistry());
final BandwidthUsage bw = new BandwidthUsageBuilder().setBwSample(BW).build();
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(new Ipv4AddressNoZone("127.0.1.1"));
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(new Ipv4AddressNoZone("127.0.1.2")));
builder.setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone("127.0.1.3"));
final AddressFamily afiLsp = new Ipv4CaseBuilder().setIpv4(builder.build()).build();
final LspId lspId = new LspId(Uint32.ONE);
final TunnelId tunnelId = new TunnelId(Uint16.ONE);
final LspIdentifiers identifier = new LspIdentifiersBuilder().setAddressFamily(afiLsp).setLspId(lspId).setTunnelId(tunnelId).build();
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).setTlvs(new TlvsBuilder().setLspIdentifiers(identifier).build()).build();
final Ero ero = new EroBuilder().build();
final Queue<Object> objects = new ArrayDeque<>(List.of(lsp, ero, bw));
final Reports validReports = codec.getValidReports(objects, List.of());
assertNotNull(validReports.getPath().getBandwidth().augmentation(Bandwidth1.class));
assertTrue(objects.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class PcRptMessageCodecTest method testGetValidReportsNegative.
@Test
public void testGetValidReportsNegative() {
final PcRptMessageCodec codec = new PcRptMessageCodec(this.ctx.getObjectHandlerRegistry());
final BandwidthUsage bw = new BandwidthUsageBuilder().setBwSample(BW).build();
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(new Ipv4AddressNoZone("127.0.1.1"));
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(new Ipv4AddressNoZone("127.0.1.2")));
builder.setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone("127.0.1.3"));
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).build();
final Ero ero = new EroBuilder().build();
final Queue<Object> objects = new ArrayDeque<>(List.of(lsp, ero, bw));
final Reports validReports = codec.getValidReports(objects, new ArrayList<>());
assertNull(validReports);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class SrAttributeParserTest method testRangeTlv.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.2
@Test
public void testRangeTlv() {
final byte[] tested = { 0, 0, 0, 5, // sid
4, // sid
(byte) 0x89, // sid
0, // sid
4, // sid
1, // sid
2, // sid
3, // sid
4, // prefix + mpls label
4, // prefix + mpls label
(byte) 0x86, // prefix + mpls label
0, // prefix + mpls label
7, // prefix + mpls label
(byte) 0xac, // prefix + mpls label
1, // prefix + mpls label
0, // prefix + mpls label
0, // prefix + mpls label
1, // prefix + mpls label
2, // prefix + mpls label
0, // binding sid
4, // binding sid
(byte) 0x88, // binding sid
0, // binding sid
0x58, // binding sid
5, // binding sid
0x48, // binding sid
0, // binding sid
0, // prefix
4, // prefix
(byte) 0x86, // prefix
0, // prefix
8, // prefix
(byte) 0xa0, // prefix
1, // prefix
0, // prefix
0, // prefix
1, // prefix
2, // prefix
3, // prefix
4, // sid
4, // sid
(byte) 0x89, // sid
0, // sid
4, // sid
1, // sid
2, // sid
3, // sid
4, // ero metric
4, // ero metric
(byte) 0x8a, // ero metric
0, // ero metric
4, // ero metric
0, // ero metric
0, // ero metric
0, // ero metric
6, // IPv4 ERO
4, // IPv4 ERO
(byte) 0x8b, // IPv4 ERO
0, // IPv4 ERO
8, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
9, // IPv4 ERO
8, // IPv4 ERO
7, // IPv4 ERO
6, // Unnumbered Interface ID ERO Sub-TLV
4, // Unnumbered Interface ID ERO Sub-TLV
(byte) 0x8d, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0x0c, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // IPv4 ERO backup
4, // IPv4 ERO backup
(byte) 0x8e, // IPv4 ERO backup
0, // IPv4 ERO backup
8, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
3, // IPv4 ERO backup
4, // IPv4 ERO backup
5, // IPv4 ERO backup
6, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
(byte) 0x90, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0x0c, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4 };
final SrRange parsedRange = RangeTlvParser.parseSrRange(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1);
final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
addSubTlvs(rangeSubTlvs);
final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(Uint16.valueOf(5)).setSubTlvs(rangeSubTlvs).build();
assertEquals(expected, parsedRange);
final ByteBuf serializedRange = Unpooled.buffer();
RangeTlvParser.serializeSrRange(parsedRange, serializedRange);
assertArrayEquals(tested, ByteArray.getAllBytes(serializedRange));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class SrAttributeParserTest method testRangeTlvIpv6.
@Test
public void testRangeTlvIpv6() {
final byte[] tested = Bytes.concat(new byte[] { 0, 0, 0, 5, // binding sid
4, // binding sid
(byte) 0x88, // binding sid
0, // binding sid
0x34, // binding sid
5, // binding sid
0x48, // binding sid
0, // binding sid
0, // binding sub-tlvs
4, (byte) 0x8c, 0, 0x14, 0, 0, 0, // IPv6 ERO
0 }, // IPv6 ERO
IPV6_A_BYTES, // IPv6 ERO backup
new byte[] { 4, (byte) 0x8f, 0, 0x14, 0, 0, 0, 0 }, // IPv6 ERO backup
IPV6_B_BYTES);
final SrRange parsedRange = RangeTlvParser.parseSrRange(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1);
final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv6EroCaseBuilder().setIpv6Ero(new Ipv6EroBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6AddressNoZone(IPV6_A)).build()).build()).build());
bindingSubTlvs.add(new BindingSubTlvsBuilder().setBindingSubTlv(new Ipv6EroBackupCaseBuilder().setIpv6EroBackup(new Ipv6EroBackupBuilder().setLoose(Boolean.FALSE).setAddress(new Ipv6AddressNoZone(IPV6_B)).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight(Uint8.valueOf(5))).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(Uint16.valueOf(5)).setSubTlvs(rangeSubTlvs).build();
assertEquals(expected, parsedRange);
final ByteBuf serializedRange = Unpooled.buffer();
RangeTlvParser.serializeSrRange(parsedRange, serializedRange);
assertArrayEquals(tested, ByteArray.getAllBytes(serializedRange));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class PCEPValidatorTest method testMissingLspObjectErrorInPcRptMsg.
@Test
public void testMissingLspObjectErrorInPcRptMsg() throws PCEPDeserializerException {
final byte[] statefulMsg = { (byte) 0x20, (byte) 0x0B, (byte) 0x00, (byte) 0x1C, /* srp-object */
(byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x001, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, /* sr-ero-object */
(byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x0C, /* ipv4 prefix subobject */
(byte) 0x81, (byte) 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x00 };
new InitiatedActivator().start(ctx);
new StatefulActivator().start(ctx);
final StatefulPCReportMessageParser parser = new StatefulPCReportMessageParser(this.ctx.getObjectHandlerRegistry());
final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
final List<Message> errors = new ArrayList<>();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder().setErrors(List.of(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType(Uint8.valueOf(6)).setValue(Uint8.valueOf(8)).build()).build())).build()).build(), errors.get(0));
}
Aggregations