use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testNoPathVectorTlv.
@Test
public void testNoPathVectorTlv() throws PCEPDeserializerException {
final NoPathVectorTlvParser parser = new NoPathVectorTlvParser();
final NoPathVectorTlv tlv = new NoPathVectorBuilder().setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(noPathVectorBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(noPathVectorBytes, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOFListTlv.
@Test
public void testOFListTlv() throws PCEPDeserializerException {
final OFListTlvParser parser = new OFListTlvParser();
final List<OfId> ids = Lists.newArrayList();
ids.add(new OfId(0x1234));
ids.add(new OfId(0x5678));
final OfList tlv = new OfListBuilder().setCodes(ids).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(ofListBytes, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(ofListBytes, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv4TlvParser method parseTlv.
@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
Preconditions.checkArgument(buffer.readableBytes() == V4_LENGTH, "Length %s does not match LSP Identifiers Ipv4 tlv length.", buffer.readableBytes());
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(buffer));
final LspId lspId = new LspId((long) buffer.readUnsignedShort());
final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(Ipv4Util.addressForByteBuf(buffer)));
builder.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(buffer));
final AddressFamily afi = new Ipv4CaseBuilder().setIpv4(builder.build()).build();
return new LspIdentifiersBuilder().setAddressFamily(afi).setLspId(lspId).setTunnelId(tunnelId).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv in project bgpcep by opendaylight.
the class Stateful07LspUpdateErrorTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof LspErrorCode, "LspErrorCodeTlv is mandatory.");
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
writeUnsignedInt(((LspErrorCode) tlv).getErrorCode(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv 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);
}
}
Aggregations