Search in sources :

Example 11 with TransmitPacketInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput in project genius by opendaylight.

the class ArpUtilImpl method sendPacketOutWithActions.

private Future<RpcResult<Void>> sendPacketOutWithActions(BigInteger dpnId, byte[] payload, NodeConnectorRef ref, List<Action> actions) {
    NodeConnectorRef nodeConnectorRef = MDSALUtil.getNodeConnRef(dpnId, "0xfffffffd");
    TransmitPacketInput transmitPacketInput = new TransmitPacketInputBuilder().setPayload(payload).setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).setIngress(nodeConnectorRef).setEgress(ref).setAction(actions).build();
    LOG.trace("PacketOut message framed for transmitting {}", transmitPacketInput);
    return packetProcessingService.transmitPacket(transmitPacketInput);
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 12 with TransmitPacketInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput in project netvirt by opendaylight.

the class Ipv6RouterAdvt method transmitRtrAdvertisement.

public boolean transmitRtrAdvertisement(Ipv6RtrAdvertType raType, VirtualPort routerPort, List<NodeConnectorRef> outportList, RouterSolicitationPacket rsPdu) {
    RouterAdvertisementPacketBuilder raPacket = new RouterAdvertisementPacketBuilder();
    updateRAResponse(raType, rsPdu, raPacket, routerPort);
    // Serialize the response packet
    byte[] txPayload = fillRouterAdvertisementPacket(raPacket.build());
    for (NodeConnectorRef outport : outportList) {
        InstanceIdentifier<Node> outNode = outport.getValue().firstIdentifierOf(Node.class);
        TransmitPacketInput input = new TransmitPacketInputBuilder().setPayload(txPayload).setNode(new NodeRef(outNode)).setEgress(outport).build();
        LOG.debug("Transmitting the Router Advt packet out {}", outport);
        JdkFutures.addErrorLogging(packetService.transmitPacket(input), LOG, "transmitPacket");
    }
    return true;
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) RouterAdvertisementPacketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.ipv6service.nd.packet.rev160620.RouterAdvertisementPacketBuilder)

Example 13 with TransmitPacketInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput in project openflowplugin by opendaylight.

the class LLDPSpeaker method nodeConnectorAdded.

@Override
public void nodeConnectorAdded(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId, final FlowCapableNodeConnector flowConnector) {
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
    // port, so first we check if we actually need to perform any action
    if (nodeConnectorMap.containsKey(nodeConnectorInstanceId)) {
        LOG.debug("Port {} already in LLDPSpeaker.nodeConnectorMap, no need for additional processing", nodeConnectorId.getValue());
        return;
    }
    // Prepare to build LLDP payload
    InstanceIdentifier<Node> nodeInstanceId = nodeConnectorInstanceId.firstIdentifierOf(Node.class);
    NodeId nodeId = InstanceIdentifier.keyOf(nodeInstanceId).getId();
    MacAddress srcMacAddress = flowConnector.getHardwareAddress();
    Long outputPortNo = flowConnector.getPortNumber().getUint32();
    // No need to send LLDP frames on local ports
    if (outputPortNo == null) {
        LOG.debug("Port {} is local, not sending LLDP frames through it", nodeConnectorId.getValue());
        return;
    }
    // Generate packet with destination switch and port
    TransmitPacketInput packet;
    try {
        packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(nodeConnectorInstanceId)).setNode(new NodeRef(nodeInstanceId)).setPayload(LLDPUtil.buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, addressDestionation)).build();
    } catch (NoSuchAlgorithmException | PacketException e) {
        LOG.error("Error building LLDP frame", e);
        return;
    }
    // Save packet to node connector id -> packet map to transmit it periodically on the configured interval.
    nodeConnectorMap.put(nodeConnectorInstanceId, packet);
    LOG.debug("Port {} added to LLDPSpeaker.nodeConnectorMap", nodeConnectorId.getValue());
    // Transmit packet for first time immediately
    final Future<RpcResult<Void>> resultFuture = packetProcessingService.transmitPacket(packet);
    JdkFutures.addErrorLogging(resultFuture, LOG, "transmitPacket");
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 14 with TransmitPacketInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput in project openflowplugin by opendaylight.

the class PacketProcessingServiceImplTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    TransmitPacketInput transmitPacketInput = buildTransmitPacketInput();
    final OfHeader request = packetProcessingService.buildRequest(new Xid(DUMMY_XID_VALUE), transmitPacketInput);
    assertEquals(DUMMY_XID_VALUE, request.getXid());
    assertTrue(request instanceof PacketOutInput);
    final PacketOutInput input = (PacketOutInput) request;
    assertEquals(OFConstants.OFP_NO_BUFFER, input.getBufferId());
    assertEquals(1, input.getAction().size());
    assertEquals(OutputActionCase.class, input.getAction().get(0).getActionChoice().getImplementedInterface());
    final OutputActionCase actionChoice = (OutputActionCase) input.getAction().get(0).getActionChoice();
    assertEquals(1, actionChoice.getOutputAction().getPort().getValue().intValue());
    assertEquals(ULTIMATE_PAYLOAD, new String(input.getData()));
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Example 15 with TransmitPacketInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput in project openflowplugin by opendaylight.

the class LearningSwitchHandlerSimpleImpl method sendPacketOut.

private void sendPacketOut(byte[] payload, NodeConnectorRef ingress, NodeConnectorRef egress) {
    InstanceIdentifier<Node> egressNodePath = InstanceIdentifierUtils.getNodePath(egress.getValue());
    TransmitPacketInput input = new TransmitPacketInputBuilder().setPayload(payload).setNode(new NodeRef(egressNodePath)).setEgress(egress).setIngress(ingress).build();
    JdkFutures.addErrorLogging(packetProcessingService.transmitPacket(input), LOG, "transmitPacket");
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) TransmitPacketInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)

Aggregations

TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)13 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)8 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)7 TransmitPacketInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder)7 Test (org.junit.Test)4 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)4 PacketOutInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput)4 PacketOutConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData)3 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)2 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)2 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)2 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)2