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.RsvpCase in project bgpcep by opendaylight.
the class Stateful07RSVPErrorSpecTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof RsvpErrorSpec, "RSVPErrorSpecTlv is mandatory.");
final RsvpErrorSpec rsvp = (RsvpErrorSpec) tlv;
final ByteBuf body = Unpooled.buffer();
if (rsvp.getErrorType().getImplementedInterface().equals(RsvpCase.class)) {
final RsvpCase r = (RsvpCase) rsvp.getErrorType();
serializeRsvp(r.getRsvpError(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
} else {
final UserCase u = (UserCase) rsvp.getErrorType();
serializerUserError(u.getUserError(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
}
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.RsvpCase 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