use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeTeLsp.
public static TeLspCase serializeTeLsp(final ChoiceNode objectType) {
final TeLspCaseBuilder teLsp = new TeLspCaseBuilder();
teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
return teLsp.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder in project bgpcep by opendaylight.
the class TeLspIpv6NlriParser method parseObjectType.
@Override
protected ObjectType parseObjectType(final ByteBuf buffer) {
final TeLspCaseBuilder builder = new TeLspCaseBuilder();
final Ipv6CaseBuilder ipv6CaseBuilder = new Ipv6CaseBuilder();
ipv6CaseBuilder.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(buffer));
builder.setTunnelId(new TunnelId(ByteBufUtils.readUint16(buffer)));
builder.setLspId(new LspId(Uint32.valueOf(buffer.readUnsignedShort())));
ipv6CaseBuilder.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(buffer));
return builder.setAddressFamily(ipv6CaseBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder in project bgpcep by opendaylight.
the class TeLspIpv4NlriParser method parseObjectType.
@Override
protected ObjectType parseObjectType(final ByteBuf buffer) {
final TeLspCaseBuilder builder = new TeLspCaseBuilder();
final Ipv4CaseBuilder ipv4CaseBuilder = new Ipv4CaseBuilder();
ipv4CaseBuilder.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(buffer));
builder.setTunnelId(new TunnelId(ByteBufUtils.readUint16(buffer)));
builder.setLspId(new LspId(Uint32.valueOf(buffer.readUnsignedShort())));
ipv4CaseBuilder.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(buffer));
return builder.setAddressFamily(ipv4CaseBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testPositiveTELspAttribute.
@Test
public void testPositiveTELspAttribute() throws BGPParsingException, BGPDocumentedException {
final AttributesBuilder builder = createBuilder(new TeLspCaseBuilder().build());
this.parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final TeLspAttributes teLspAttributes = ((TeLspAttributesCase) attrs.getLinkStateAttribute()).getTeLspAttributes();
assertNotNull(teLspAttributes);
final TspecObject tSpec = teLspAttributes.getTspecObject();
assertNotNull(tSpec);
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 }), tSpec.getTokenBucketRate());
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 }), teLspAttributes.getTspecObject().getTokenBucketSize());
assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03 }), tSpec.getPeakDataRate());
assertEquals(Uint32.valueOf(4), tSpec.getMinimumPolicedUnit());
assertEquals(Uint32.valueOf(5), tSpec.getMaximumPacketSize());
final AssociationObject associationObject = teLspAttributes.getAssociationObject();
assertEquals(AssociationType.Recovery, associationObject.getAssociationType());
final IpAddressNoZone ipv4 = new IpAddressNoZone(Ipv4Util.addressForByteBuf(Unpooled.copiedBuffer(new byte[] { 0x01, 0x02, 0x03, 0x04 })));
assertEquals(ipv4, associationObject.getIpAddress());
final short associationId = 2;
assertEquals(associationId, associationObject.getAssociationId().shortValue());
// serialization
final ByteBuf buff = Unpooled.buffer();
this.parser.serializeAttribute(builder.build(), buff);
assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
Aggregations