Search in sources :

Example 1 with PcreqMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage in project bgpcep by opendaylight.

the class PCEPMonitoringRequestMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    Preconditions.checkArgument(message instanceof Pcmonreq, "Wrong instance of Message. Passed instance of %s. Need Pcmonreq.", message.getClass());
    final PcreqMessage msg = ((Pcmonreq) message).getPcreqMessage();
    Preconditions.checkArgument(msg.getMonitoringRequest() != null, "MONITORING object MUST be present.");
    final ByteBuf buffer = Unpooled.buffer();
    serializeMonitoringRequest(msg.getMonitoringRequest(), buffer);
    if (msg.getSvec() != null) {
        serializeSvec(msg, buffer);
    }
    if (msg.getRequests() != null) {
        serializeRequest(msg, buffer);
    }
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : Pcmonreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcmonreq) ByteBuf(io.netty.buffer.ByteBuf) PcreqMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage)

Example 2 with PcreqMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeRequest.

protected void serializeRequest(final PcreqMessage msg, final ByteBuf buffer) {
    for (final Requests req : msg.nonnullRequests()) {
        serializeObject(req.getRp(), buffer);
        serializeVendorInformationObjects(req.getVendorInformationObject(), buffer);
        if (req.getPathKeyExpansion() != null) {
            serializeObject(req.getPathKeyExpansion().getPathKey(), buffer);
        }
        if (req.getSegmentComputation() != null) {
            final SegmentComputation sc = req.getSegmentComputation();
            if (sc.getP2p() != null) {
                serializeP2P(buffer, sc.getP2p());
            }
            if (sc.getP2mp() != null) {
                serializeP2MP(buffer, sc.getP2mp());
            }
        }
    }
}
Also used : Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests) SegmentComputation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputation)

Example 3 with PcreqMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method handlePcreqMessage.

private boolean handlePcreqMessage(final PcreqMessage message) {
    LOG.info("Start PcRequest Message handler");
    /* Get a Path Computation to compute the Path from the Request */
    PathComputation pathComputation = pceServerProvider.getPathComputation();
    Message rep = null;
    /* Reply with Error Message if no valid Path Computation is available */
    if (pathComputation == null) {
        rep = createErrorMsg(PCEPErrors.RESOURCE_LIMIT_EXCEEDED, Uint32.ZERO);
        sendMessage(rep, new SrpIdNumber(Uint32.ZERO), null);
        return false;
    }
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests req : message.getRequests()) {
        LOG.debug("Process request {}", req);
        rep = pathComputation.computePath(req);
        SrpIdNumber repId = null;
        if (req.getRp() != null) {
            repId = new SrpIdNumber(req.getRp().getRequestId().getValue());
        } else {
            repId = new SrpIdNumber(Uint32.ZERO);
        }
        sendMessage(rep, repId, null);
    }
    return false;
}
Also used : PathComputation(org.opendaylight.bgpcep.pcep.server.PathComputation) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) PcreqMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage) PcrptMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptMessage) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Collections(java.util.Collections) SrpIdNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber)

Example 4 with PcreqMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeSvec.

protected void serializeSvec(final PcreqMessage msg, final ByteBuf buffer) {
    for (final Svec s : msg.nonnullSvec()) {
        serializeObject(s.getSvec(), buffer);
        serializeObject(s.getOf(), buffer);
        serializeObject(s.getGc(), buffer);
        serializeObject(s.getXro(), buffer);
        if (s.getMetric() != null) {
            for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.svec.Metric m : s.nonnullMetric()) {
                serializeObject(m.getMetric(), buffer);
            }
        }
        serializeVendorInformationObjects(s.getVendorInformationObject(), buffer);
    }
}
Also used : Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec)

Example 5 with PcreqMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    checkArgument(message instanceof Pcreq, "Wrong instance of Message. Passed instance of %s. Need Pcreq.", message.getClass());
    final PcreqMessage msg = ((Pcreq) message).getPcreqMessage();
    checkArgument(!msg.nonnullRequests().isEmpty(), "Requests cannot be null or empty.");
    final ByteBuf buffer = Unpooled.buffer();
    if (msg.getMonitoringRequest() != null) {
        serializeMonitoringRequest(msg.getMonitoringRequest(), buffer);
    }
    if (msg.getSvec() != null) {
        serializeSvec(msg, buffer);
    }
    serializeRequest(msg, buffer);
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Pcreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq) PcreqMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage)

Aggregations

PcreqMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessage)3 ByteBuf (io.netty.buffer.ByteBuf)2 Collections (java.util.Collections)1 PathComputation (org.opendaylight.bgpcep.pcep.server.PathComputation)1 PcrptMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcrptMessage)1 SrpIdNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SrpIdNumber)1 Pcmonreq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcmonreq)1 Pcreq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq)1 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message)1 PcerrMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage)1 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests)1 Svec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec)1 SegmentComputation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputation)1