use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testStateful07LspObjectWithTlv.
@Test
public void testStateful07LspObjectWithTlv() throws IOException, PCEPDeserializerException {
final Stateful07LspObjectParser parser = new Stateful07LspObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject2WithTLV.bin"));
final LspBuilder builder = new LspBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setAdministrative(true);
builder.setDelegate(false);
builder.setRemove(true);
builder.setSync(false);
builder.setOperational(OperationalStatus.GoingDown);
builder.setPlspId(new PlspId(0x12345L));
final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(627610883L).build();
final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName("Med".getBytes())).build();
final Ipv4Builder afi = new Ipv4Builder();
afi.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })));
afi.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }))));
afi.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })));
final LspIdentifiers tlv3 = new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(afi.build()).build()).setLspId(new LspId(65535L)).setTunnelId(new TunnelId(4660)).build();
final RsvpErrorBuilder rsvpBuilder = new RsvpErrorBuilder();
rsvpBuilder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }))));
rsvpBuilder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags(false, true));
rsvpBuilder.setCode((short) 146);
rsvpBuilder.setValue(5634);
final RsvpErrorSpec tlv4 = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(rsvpBuilder.build()).build()).build();
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspErrorCode(tlv1).setSymbolicPathName(tlv2).setLspIdentifiers(tlv3).setRsvpErrorSpec(tlv4).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testRSVPError6SpecTlv.
@Test
public void testRSVPError6SpecTlv() throws PCEPDeserializerException {
final Stateful07RSVPErrorSpecTlvParser parser = new Stateful07RSVPErrorSpecTlvParser();
final RsvpErrorBuilder builder = new RsvpErrorBuilder();
builder.setNode(new IpAddress(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0 }))));
builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags(false, true));
builder.setCode((short) 213);
builder.setValue(50649);
final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(rsvpError6Bytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(rsvpError6Bytes, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testRSVPError4SpecTlv.
@Test
public void testRSVPError4SpecTlv() throws PCEPDeserializerException {
final Stateful07RSVPErrorSpecTlvParser parser = new Stateful07RSVPErrorSpecTlvParser();
final RsvpErrorBuilder builder = new RsvpErrorBuilder();
builder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }))));
builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags(false, true));
builder.setCode((short) 146);
builder.setValue(5634);
final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(rsvpErrorBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(rsvpErrorBytes, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder in project bgpcep by opendaylight.
the class Stateful07RSVPErrorSpecTlvParser method parseRsvp.
private static RsvpCase parseRsvp(final int classType, final ByteBuf buffer) {
final RsvpErrorBuilder builder = new RsvpErrorBuilder();
if (classType == RSVP_IPV4_ERROR_CLASS_TYPE) {
builder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(buffer)));
} else if (classType == RSVP_IPV6_ERROR_CLASS_TYPE) {
builder.setNode(new IpAddress(Ipv6Util.addressForByteBuf(buffer)));
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
final short errorCode = buffer.readUnsignedByte();
builder.setCode(errorCode);
final int errorValue = buffer.readUnsignedShort();
builder.setValue(errorValue);
return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
}
Aggregations