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);
}
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;
}
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");
}
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()));
}
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");
}
Aggregations