Search in sources :

Example 6 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class CInitiated00PCInitiateMessageParser method serializeMessage.

@Override
public void serializeMessage(final Message message, final ByteBuf out) {
    Preconditions.checkArgument(message instanceof Pcinitiate, "Wrong instance of Message. Passed instance of %s. Need PcinitiateMessage.", message.getClass());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.PcinitiateMessage init = ((Pcinitiate) message).getPcinitiateMessage();
    final ByteBuf buffer = Unpooled.buffer();
    for (final Requests req : init.getRequests()) {
        serializeRequest(req, buffer);
    }
    MessageUtil.formatMessage(TYPE, buffer, out);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)

Example 7 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method processSmrPackets.

private List<MapRequest> processSmrPackets(SocketReader reader, String address, int expectedSmrs) {
    InetAddress inetAddress = null;
    try {
        inetAddress = InetAddress.getByName(address);
    } catch (UnknownHostException e) {
        LOG.error("Unknown address {}.", address, e);
    }
    final List<MapRequest> requests = Lists.newArrayList();
    byte[][] buffers = reader.getBuffers(expectedSmrs);
    for (byte[] buf : buffers) {
        ByteBuffer packet = ByteBuffer.wrap(buf);
        if (MappingServiceIntegrationTestUtil.checkType(packet, MessageType.MapRequest)) {
            MapRequest request = MapRequestSerializer.getInstance().deserialize(packet, inetAddress);
            requests.add(request);
        }
    }
    return requests;
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress) ByteBuffer(java.nio.ByteBuffer)

Example 8 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project genius by opendaylight.

the class ArpUtilImpl method sendArpRequest.

@Override
public Future<RpcResult<Void>> sendArpRequest(SendArpRequestInput arpReqInput) {
    LOG.trace("rpc sendArpRequest invoked for ip {}", arpReqInput.getIpaddress());
    BigInteger dpnId;
    byte[] payload;
    String interfaceName = null;
    byte[] srcIpBytes;
    byte[] dstIpBytes;
    byte[] srcMac;
    RpcResultBuilder<Void> failureBuilder = RpcResultBuilder.failed();
    RpcResultBuilder<Void> successBuilder = RpcResultBuilder.success();
    try {
        dstIpBytes = getIpAddressBytes(arpReqInput.getIpaddress());
    } catch (UnknownHostException e) {
        LOG.error("Cannot get IP address", e);
        failureBuilder.withError(ErrorType.APPLICATION, ArpConstants.UNKNOWN_IP_ADDRESS_SUPPLIED);
        return Futures.immediateFuture(failureBuilder.build());
    }
    int localErrorCount = 0;
    for (InterfaceAddress interfaceAddress : arpReqInput.getInterfaceAddress()) {
        try {
            interfaceName = interfaceAddress.getInterface();
            srcIpBytes = getIpAddressBytes(interfaceAddress.getIpAddress());
            GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
            checkNotNull(portResult);
            dpnId = portResult.getDpid();
            Long portid = portResult.getPortno();
            checkArgument(null != dpnId && !BigInteger.ZERO.equals(dpnId), ArpConstants.DPN_NOT_FOUND_ERROR, interfaceName);
            NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
            checkNotNull(ref, ArpConstants.NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
            LOG.trace("sendArpRequest received dpnId {} out interface {}", dpnId, interfaceName);
            if (interfaceAddress.getMacaddress() == null) {
                srcMac = MDSALUtil.getMacAddressForNodeConnector(dataBroker, (InstanceIdentifier<NodeConnector>) ref.getValue());
            } else {
                String macAddr = interfaceAddress.getMacaddress().getValue();
                srcMac = HexEncode.bytesFromHexString(macAddr);
            }
            checkNotNull(srcMac, ArpConstants.FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, ref.getValue());
            checkNotNull(srcIpBytes, ArpConstants.FAILED_TO_GET_SRC_IP_FOR_INTERFACE, interfaceName);
            payload = ArpPacketUtil.getPayload(ArpConstants.ARP_REQUEST_OP, srcMac, srcIpBytes, ArpPacketUtil.ETHERNET_BROADCAST_DESTINATION, dstIpBytes);
            List<Action> actions = getEgressAction(interfaceName);
            sendPacketOutWithActions(dpnId, payload, ref, actions);
            LOG.trace("sent arp request for {}", arpReqInput.getIpaddress());
        } catch (UnknownHostException | PacketException | InterruptedException | ExecutionException | ReadFailedException e) {
            LOG.trace("failed to send arp req for {} on interface {}", arpReqInput.getIpaddress(), interfaceName);
            failureBuilder.withError(ErrorType.APPLICATION, ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
            successBuilder.withError(ErrorType.APPLICATION, ArpConstants.FAILED_TO_SEND_ARP_REQ_FOR_INTERFACE + interfaceName, e);
            localErrorCount++;
        }
    }
    if (localErrorCount == arpReqInput.getInterfaceAddress().size()) {
        // All the requests failed
        return Futures.immediateFuture(failureBuilder.build());
    }
    return Futures.immediateFuture(successBuilder.build());
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) UnknownHostException(java.net.UnknownHostException) InterfaceAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddress) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) BigInteger(java.math.BigInteger) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getRequests.

protected List<Requests> getRequests(final List<Object> objects, final List<Message> errors) {
    final List<Requests> requests = new ArrayList<>();
    while (!objects.isEmpty()) {
        final RequestsBuilder rBuilder = new RequestsBuilder();
        Rp rpObj = null;
        if (!(objects.get(0) instanceof Rp)) {
            // if RP obj is missing return error only
            errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
            return null;
        }
        rpObj = (Rp) objects.get(0);
        objects.remove(0);
        if (!rpObj.isProcessingRule()) {
            errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
        } else {
            rBuilder.setRp(rpObj);
        }
        final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
        if (!vendorInfo.isEmpty()) {
            rBuilder.setVendorInformationObject(vendorInfo);
        }
        // expansion
        if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
            rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
        }
        final P2pBuilder p2pBuilder = new P2pBuilder();
        if (!objects.isEmpty() && objects.get(0) instanceof EndpointsObj) {
            final EndpointsObj ep = (EndpointsObj) objects.get(0);
            objects.remove(0);
            if (!ep.isProcessingRule()) {
                errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
            } else {
                p2pBuilder.setEndpointsObj(ep);
            }
        } else {
            errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
            return null;
        }
        // p2p
        if (!rpObj.isP2mp()) {
            final SegmentComputation segm = getSegmentComputation(p2pBuilder, objects, errors, rpObj);
            if (segm != null) {
                rBuilder.setSegmentComputation(segm);
            }
        }
        requests.add(rBuilder.build());
    }
    return requests;
}
Also used : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.key.object.PathKey) ArrayList(java.util.ArrayList) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) PathKeyExpansionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.PathKeyExpansionBuilder) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder) P2pBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) SegmentComputation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.SegmentComputation)

Example 10 with Requests

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method validate.

@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Preconditions.checkArgument(objects != null, "Passed list can't be null.");
    if (objects.isEmpty()) {
        throw new PCEPDeserializerException("Pcrep message cannot be empty.");
    }
    final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
    mBuilder.setMonitoringRequest(getMonitoring(objects));
    final List<Svec> svecs = getSvecs(objects);
    if (!svecs.isEmpty()) {
        mBuilder.setSvec(svecs);
    }
    final List<Requests> requests = getRequests(objects, errors);
    if (requests != null) {
        mBuilder.setRequests(requests);
    } else {
        errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
    }
    if (!objects.isEmpty()) {
        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
    }
    return new PcreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
Also used : Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec) PcreqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcreqBuilder) PcreqMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.PcreqMessageBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

Test (org.junit.Test)15 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)15 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)12 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)12 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests)11 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)11 ArrayList (java.util.ArrayList)9 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)9 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)9 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)8 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate)8 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs)8 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)7 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)7 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)7 Collections (java.util.Collections)6 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder)5 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)5 ByteBuf (io.netty.buffer.ByteBuf)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)4