use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class SrPceCapabilityTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof SrPceCapability, "SrPceCapability is mandatory.");
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
/* Reserved 2 bytes */
body.writerIndex(OFFSET);
/* Flags */
final SrPceCapability srPceCapability = (SrPceCapability) tlv;
final BitArray bits = new BitArray(BITSET_LENGTH);
bits.set(N_FLAG_POSITION, srPceCapability.getNFlag());
bits.set(X_FLAG_POSITION, srPceCapability.getXFlag());
bits.toByteBuf(body);
/* MSD */
ByteBufUtils.writeOrZero(body, srPceCapability.getMsd());
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class SrPceCapabilityTlvParser method parseTlv.
@Override
public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
final BitArray bitSet = BitArray.valueOf(buffer.readerIndex(OFFSET).readByte());
final boolean n = bitSet.get(N_FLAG_POSITION);
final boolean x = bitSet.get(X_FLAG_POSITION);
return new SrPceCapabilityBuilder().setNFlag(n).setXFlag(x).setMsd(ByteBufUtils.readUint8(buffer)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class AigpAttributeParser method parseAigpTLV.
/**
* Reads data from buffer until reaches TLV of type AIGP TLV.
*
* @param buffer TLVs in ByteBuf format
* @return instance of AigpTlv class or null if buffer contains unknown TLV type
*/
private static AigpTlv parseAigpTLV(final ByteBuf buffer) {
final int tlvType = buffer.readByte();
buffer.skipBytes(TLV_SIZE_IN_BYTES);
if (tlvType != AIGP_TLV_TYPE) {
LOG.warn("AIGP attribute contains unknown TLV type {}.", tlvType);
return null;
}
return new AigpTlvBuilder().setMetric(new AccumulatedIgpMetric(ByteBufUtils.readUint64(buffer))).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project bgpcep by opendaylight.
the class PCEPTopologySessionListener method onSessionUp.
@Override
protected void onSessionUp(final PCEPSession session, final PathComputationClientBuilder pccBuilder) {
final InetAddress peerAddress = session.getRemoteAddress();
final Tlvs tlvs = session.getRemoteTlvs();
if (tlvs != null && tlvs.augmentation(Tlvs1.class) != null) {
final Stateful stateful = tlvs.augmentation(Tlvs1.class).getStateful();
if (stateful != null) {
setStatefulCapabilities(stateful);
pccBuilder.setReportedLsp(Collections.emptyMap());
if (isSynchronized()) {
pccBuilder.setStateSync(PccSyncState.Synchronized);
} else if (isTriggeredInitialSynchro()) {
pccBuilder.setStateSync(PccSyncState.TriggeredInitialSync);
} else if (isIncrementalSynchro()) {
pccBuilder.setStateSync(PccSyncState.IncrementalSync);
} else {
pccBuilder.setStateSync(PccSyncState.InitialResync);
}
pccBuilder.setStatefulTlv(new StatefulTlvBuilder().addAugmentation(new StatefulTlv1Builder(tlvs.augmentation(Tlvs1.class)).build()).build());
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
} else {
LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv 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);
}
Aggregations