use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandler method parseAttribute.
@Override
public void parseAttribute(@Nonnull final ByteBuf buffer, @Nonnull final AttributesBuilder builder) {
if (!buffer.isReadable()) {
return;
}
final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
pmsiTunnelBuilder.setLeafInformationRequired(buffer.readBoolean());
final int tunnelType = buffer.readUnsignedByte();
parseMpls(pmsiTunnelBuilder, buffer);
final TunnelIdentifier tunnelIdentifier = this.tunnelIdentifierHandler.parse(tunnelType, buffer);
if (tunnelIdentifier != null) {
pmsiTunnelBuilder.setTunnelIdentifier(tunnelIdentifier);
}
builder.addAugmentation(PmsiTunnelAugmentation.class, new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class RsvpTeP2MpLspParser method serialize.
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
final RsvpTeP2mpLps rsvpTeP2mpLsp = ((RsvpTeP2mpLsp) tunnelIdentifier).getRsvpTeP2mpLps();
ByteBufWriteUtil.writeUnsignedInt(rsvpTeP2mpLsp.getP2mpId(), buffer);
buffer.writeZero(RESERVED);
ByteBufWriteUtil.writeUnsignedShort(rsvpTeP2mpLsp.getTunnelId(), buffer);
serializeIpAddress(rsvpTeP2mpLsp.getExtendedTunnelId(), buffer);
return TunnelType.RSVP_TE_P2MP_LSP.getIntValue();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class MldpP2mpLspParser method serialize.
@Override
public int serialize(final MldpP2mpLsp tunnelIdentifier, final ByteBuf buffer) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = tunnelIdentifier.getMldpP2mpLsp();
final ByteBuf opaqueValues = Unpooled.buffer();
final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily());
if (!serializeOpaqueList(mldpP2mpLsp.getOpaqueValue(), opaqueValues) || addressFamily == 0) {
return NO_TUNNEL_INFORMATION_PRESENT;
}
final IpAddressNoZone rootNode = mldpP2mpLsp.getRootNodeAddress();
buffer.writeByte(P2MP_TYPE);
buffer.writeShort(addressFamily);
buffer.writeByte(rootNode.getIpv4AddressNoZone() != null ? Ipv4Util.IP4_LENGTH : Ipv6Util.IPV6_LENGTH);
serializeIpAddress(rootNode, buffer);
buffer.writeShort(opaqueValues.readableBytes());
buffer.writeBytes(opaqueValues);
return getType();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class RsvpTeP2MpLspParser method parse.
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
final RsvpTeP2mpLpsBuilder rsvpTeP2mpLps = new RsvpTeP2mpLpsBuilder();
rsvpTeP2mpLps.setP2mpId(buffer.readUnsignedInt());
buffer.skipBytes(2);
rsvpTeP2mpLps.setTunnelId(buffer.readUnsignedShort());
final int ipLength = buffer.readableBytes();
rsvpTeP2mpLps.setExtendedTunnelId(parseIpAddress(ipLength, buffer));
return new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLps(rsvpTeP2mpLps.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev200120.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier in project bgpcep by opendaylight.
the class PMSITunnelAttributeHandler method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final PmsiTunnelAugmentation pmsiTunnelAugmentation = ((Attributes) attribute).getAugmentation(PmsiTunnelAugmentation.class);
if (pmsiTunnelAugmentation == null) {
return;
}
final PmsiTunnel pmsiTunnelAttribute = pmsiTunnelAugmentation.getPmsiTunnel();
final TunnelIdentifier tunnel = pmsiTunnelAttribute.getTunnelIdentifier();
final ByteBuf tunnelBuffer = Unpooled.buffer();
final int tunnelType = this.tunnelIdentifierHandler.serialize(tunnel, tunnelBuffer);
final ByteBuf body = Unpooled.buffer();
serializeFlag(pmsiTunnelAttribute, body);
body.writeByte(tunnelType);
serializeMpls(pmsiTunnelAttribute.getMplsLabel(), body);
body.writeBytes(tunnelBuffer);
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, getType(), body, byteAggregator);
}
Aggregations