Search in sources :

Example 36 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp in project bgpcep by opendaylight.

the class Stateful07LSPIdentifierIpv6TlvParser method parseTlv.

@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    Preconditions.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((long) buffer.readUnsignedShort());
    final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
    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();
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder) Ipv6CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv6CaseBuilder) Ipv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6Builder) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.AddressFamily) TunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId) Ipv6ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId) Ipv6ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId)

Example 37 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp in project bgpcep by opendaylight.

the class Stateful07LspObjectParser method parseObject.

@Override
public Lsp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final LspBuilder builder = new LspBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    final int[] plspIdRaw = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2) };
    builder.setPlspId(new PlspId((long) ((plspIdRaw[0] << FLAGS_SIZE) | (plspIdRaw[1] << FOUR_BITS_SHIFT) | (plspIdRaw[2] >> FOUR_BITS_SHIFT))));
    parseFlags(builder, bytes);
    final TlvsBuilder b = new TlvsBuilder();
    parseTlvs(b, bytes.slice());
    builder.setTlvs(b.build());
    return builder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Example 38 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp in project bgpcep by opendaylight.

the class Stateful07LspObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Lsp, "Wrong instance of PCEPObject. Passed %s . Needed LspObject.", object.getClass());
    final Lsp specObj = (Lsp) object;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(specObj.getPlspId() != null, "PLSP-ID not present");
    writeMedium(specObj.getPlspId().getValue().intValue() << FOUR_BITS_SHIFT, body);
    final BitArray flags = serializeFlags(specObj);
    byte op = 0;
    if (specObj.getOperational() != null) {
        op = UnsignedBytes.checkedCast(specObj.getOperational().getIntValue());
        op = (byte) (op << FOUR_BITS_SHIFT);
    }
    final byte[] res = flags.array();
    res[res.length - 1] = (byte) (res[res.length - 1] | op);
    body.writeByte(res[res.length - 1]);
    serializeTlvs(specObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 39 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp in project bgpcep by opendaylight.

the class PCCTunnelManagerImpl method createLspAndSendReport.

private void createLspAndSendReport(final long plspId, final PCCTunnel tunnel, final PCCSession session, final Optional<Boolean> isSync, final Optional<Srp> srp) {
    final boolean delegation = hasDelegation(tunnel, session);
    if (delegation) {
        tunnel.cancelTimeouts();
    }
    final String destinationAddress = getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address);
    final Tlvs tlvs = createLspTlvs(plspId, true, destinationAddress, this.address, this.address, Optional.of(tunnel.getPathName()), this.syncOptimization.incrementLspDBVersion());
    final boolean sync = isSync.isPresent() ? isSync.get() : this.syncOptimization.isSyncNeedIt();
    final Lsp lsp = createLsp(plspId, sync, Optional.fromNullable(tlvs), delegation, false);
    final Pcrpt pcrtp = createPcRtpMessage(lsp, srp, tunnel.getLspState());
    session.sendReport(pcrtp);
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) MsgBuilderUtil.createLsp(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLsp) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)

Example 40 with Lsp

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp in project bgpcep by opendaylight.

the class CInitiated00PCInitiateMessageParser method getValidRequest.

protected Requests getValidRequest(final List<Object> objects) {
    final RequestsBuilder builder = new RequestsBuilder();
    builder.setSrp((Srp) objects.get(0));
    objects.remove(0);
    builder.setLsp((Lsp) objects.get(0));
    objects.remove(0);
    final List<Metrics> metrics = Lists.newArrayList();
    Object obj;
    State state = State.INIT;
    while (!objects.isEmpty() && !state.equals(State.END)) {
        obj = objects.get(0);
        state = insertObject(state, obj, builder, metrics);
        if (!state.equals(State.END)) {
            objects.remove(0);
        }
    }
    builder.setMetrics(metrics);
    return builder.build();
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)

Aggregations

PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)18 Test (org.junit.Test)17 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)16 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)15 ByteBuf (io.netty.buffer.ByteBuf)12 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)12 Collections (java.util.Collections)10 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp)10 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)9 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp)8 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)8 ArrayList (java.util.ArrayList)7 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)7 Srp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.Srp)7 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)7 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)6 SrpIdNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber)6 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)6 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)5 LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersion)5