use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily in project bgpcep by opendaylight.
the class StatefulLSPIdentifierIpv4TlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof LspIdentifiers, "LspIdentifiersTlv is mandatory.");
final LspIdentifiers lsp = (LspIdentifiers) tlv;
final AddressFamily afi = lsp.getAddressFamily();
final ByteBuf body = Unpooled.buffer();
if (afi.implementedInterface().equals(Ipv6Case.class)) {
new StatefulLSPIdentifierIpv6TlvParser().serializeTlv(tlv, buffer);
}
final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
checkArgument(ipv4.getIpv4TunnelSenderAddress() != null, "Ipv4TunnelSenderAddress is mandatory.");
Ipv4Util.writeIpv4Address(ipv4.getIpv4TunnelSenderAddress(), body);
checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
body.writeShort(lsp.getLspId().getValue().shortValue());
final TunnelId tunnelId = lsp.getTunnelId();
checkArgument(tunnelId != null, "TunnelId is mandatory.");
ByteBufUtils.write(body, tunnelId.getValue());
checkArgument(ipv4.getIpv4ExtendedTunnelId() != null, "Ipv4ExtendedTunnelId is mandatory.");
Ipv4Util.writeIpv4Address(ipv4.getIpv4ExtendedTunnelId(), body);
checkArgument(ipv4.getIpv4TunnelEndpointAddress() != null, "Ipv4TunnelEndpointAddress is mandatory.");
Ipv4Util.writeIpv4Address(ipv4.getIpv4TunnelEndpointAddress(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily in project bgpcep by opendaylight.
the class StatefulLSPIdentifierIpv4TlvParser method parseTlv.
@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
checkArgument(buffer.readableBytes() == V4_LENGTH, "Length %s does not match LSP Identifiers Ipv4 tlv length.", buffer.readableBytes());
final Ipv4Builder builder = new Ipv4Builder().setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(buffer));
final LspId lspId = new LspId(Uint32.valueOf(buffer.readUnsignedShort()));
final TunnelId tunnelId = new TunnelId(ByteBufUtils.readUint16(buffer));
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.bgp.types.rev200120.AddressFamily in project bgpcep by opendaylight.
the class StatefulLSPIdentifierIpv6TlvParser method parseTlv.
@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
checkArgument(buffer.readableBytes() == V6_LENGTH, "Length %s does not match LSP Identifiers Ipv6 tlv length.", buffer.readableBytes());
final Ipv6Builder builder = new Ipv6Builder();
builder.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(buffer));
final LspId lspId = new LspId(Uint32.valueOf(buffer.readUnsignedShort()));
final TunnelId tunnelId = new TunnelId(ByteBufUtils.readUint16(buffer));
builder.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.addressForByteBuf(buffer)));
builder.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(buffer));
final AddressFamily afi = new Ipv6CaseBuilder().setIpv6(builder.build()).build();
return new LspIdentifiersBuilder().setAddressFamily(afi).setLspId(lspId).setTunnelId(tunnelId).build();
}
Aggregations