import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
import org.opendaylight.controller.sal.binding.api.NotificationProviderService
import org.opendaylight.controller.sal.binding.api.data.DataProviderService
+import org.opendaylight.openflowplugin.outputtest.OutputTestCommandProvider
import org.osgi.framework.BundleContext
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class DropTestActivator extends AbstractBindingAwareProvider {
+ static Logger LOG = LoggerFactory.getLogger(DropTestActivator);
+
static var DropTestProvider provider = new DropTestProvider();
static var DropTestCommandProvider cmdProvider
+ static var OutputTestCommandProvider outCmdProvider
override onSessionInitiated(ProviderContext session) {
+ LOG.debug("Activator DropAllPack INIT")
provider.dataService = session.getSALService(DataProviderService)
provider.notificationService = session.getSALService(NotificationProviderService)
cmdProvider.onSessionInitiated(session);
+
+ outCmdProvider.onSessionInitiated(session);
+ LOG.debug("Activator DropAllPack END")
}
override startImpl(BundleContext ctx) {
super.startImpl(ctx);
+// LOG.info("------------------------------------- DROP ALL PACK TEST INITIATED ------------------------ ")
cmdProvider = new DropTestCommandProvider(ctx,provider);
+ outCmdProvider = new OutputTestCommandProvider(ctx);
}
override protected stopImpl(BundleContext context) {
+// LOG.info("-------------------------------------- DROP ALL PACK TEST STOPED --------------------------- ")
provider.close();
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.outputtest;
+
+import org.eclipse.osgi.framework.console.CommandInterpreter;
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OutputTestCommandProvider implements CommandProvider {
+
+ private PacketProcessingService packetProcessingService;
+ private ProviderContext pc;
+ private BundleContext ctx;
+ private boolean sessionInitiated = false;
+ private static Logger LOG = LoggerFactory.getLogger(OutputTestCommandProvider.class);
+
+ public OutputTestCommandProvider(BundleContext ctx) {
+ this.ctx = ctx;
+ }
+
+ public void onSessionInitiated(ProviderContext session) {
+ pc = session;
+ packetProcessingService = session
+ .getRpcService(PacketProcessingService.class);
+ ctx.registerService(CommandProvider.class.getName(), this, null);
+ this.sessionInitiated = true;
+ }
+
+ public void _sendOutputMsg(CommandInterpreter ci) {
+ /* Sending package OUT */
+ LOG.info("SendOutMsg");
+ if (sessionInitiated) {
+ String inNodeKey = ci.nextArgument();
+
+// String resultOfPingFlow = OutputTestUtil.makePingFlowForNode(inNodeKey, pc);
+// ci.println(resultOfPingFlow);
+
+ TransmitPacketInput input = OutputTestUtil.buildTransmitInputPacket(
+ inNodeKey,
+ new String("BRM").getBytes(),
+ "0xfffffffd", // port
+ "0");
+
+ packetProcessingService.transmitPacket(input);
+ } else {
+ ci.println("Session not initiated, try again in a few seconds");
+ }
+ }
+
+ public void _sendOutTopologyMsg(CommandInterpreter ci) {
+ /* Sending package OUT */
+ LOG.info("SendOutTopologyMsg");
+
+
+ }
+
+ @Override
+ public String getHelp() {
+ StringBuilder strBuf = new StringBuilder("-------------- OUT Package ----------\n")
+ .append(" sendOutputMsg command + nodeId as param sends empty package out \n ");
+ return strBuf.toString();
+ }
+}
--- /dev/null
+package org.opendaylight.openflowplugin.outputtest
+
+import java.math.BigInteger
+import java.util.ArrayList
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
+import java.util.concurrent.ExecutionException
+
+class OutputTestUtil {
+
+ private new() {
+ throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
+ }
+
+ public static def buildTransmitInputPacket(String nodeId, byte[] packValue, String outPort, String inPort) {
+ var ref = createNodeRef(nodeId);
+ var nEgressConfRef = new NodeConnectorRef(createNodeConnRef(nodeId, outPort));
+ var nIngressConRef = new NodeConnectorRef(createNodeConnRef(nodeId, inPort));
+ var tPackBuilder = new TransmitPacketInputBuilder
+ tPackBuilder.setPayload(packValue);
+ tPackBuilder.setNode(ref);
+ // TODO VD P2 missing cookies in Test
+ tPackBuilder.setCookie(null);
+ tPackBuilder.setEgress(nEgressConfRef)
+ tPackBuilder.setIngress(nIngressConRef)
+ return tPackBuilder.build
+ }
+
+ public static def makePingFlowForNode(String nodeId, ProviderContext pc) {
+ var nodeBuilder = createNodeBuilder(nodeId)
+ var flowBuilder = createFlowBuilder(1235, null, "ping")
+
+ var dataBrokerService = pc.getSALService(DataBrokerService)
+ var modif = dataBrokerService.beginTransaction
+
+ var path = InstanceIdentifier
+ .builder(Nodes)
+ .child(Node, nodeBuilder.getKey)
+ .augmentation(FlowCapableNode)
+ .child(Table, new TableKey(flowBuilder.getTableId))
+ .child(Flow, flowBuilder.getKey()).build;
+
+ modif.putConfigurationData(path, flowBuilder.build)
+ var commitFuture = modif.commit
+
+ try {
+ var resutl = commitFuture.get
+ var status = resutl.result
+ return "Status of Flow Data Loaded Transaction: " + status
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return e.class.name
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ return e.class.name
+ }
+ }
+
+ private static def createNodeRef(String nodeId) {
+ var key = new NodeKey(new NodeId(nodeId));
+ var path = InstanceIdentifier.builder(Nodes).child(Node, key).toInstance
+ return new NodeRef(path)
+ }
+
+ private static def createNodeConnRef(String nodeId, String port) {
+ var sBuild = new StringBuilder(nodeId).append(":").append(port);
+ var nConKey = new NodeConnectorKey(new NodeConnectorId(sBuild.toString));
+ var path = InstanceIdentifier.builder(Nodes)
+ .child(Node, new NodeKey(new NodeId(nodeId)))
+ .child(NodeConnector, nConKey).toInstance()
+ return new NodeConnectorRef(path)
+ }
+
+
+
+ private static def createNodeBuilder(String nodeId) {
+ var builder = new NodeBuilder()
+ builder.setId(new NodeId(nodeId))
+ builder.setKey(new NodeKey(builder.getId()))
+ return builder
+ }
+
+ private static def createFlowBuilder(long flowId, String tableId, String flowName) {
+ var fBuild = new FlowBuilder();
+ fBuild.setMatch(new MatchBuilder().build)
+ fBuild.setInstructions(createPingInstructionsBuilder().build)
+
+ var key = new FlowKey(new FlowId(flowId));
+ fBuild.setBarrier(false);
+ // flow.setBufferId(new Long(12));
+ var value = new BigInteger("10", 10);
+ fBuild.setCookie(value);
+ fBuild.setCookieMask(value);
+ fBuild.setHardTimeout(0);
+ fBuild.setIdleTimeout(0);
+ fBuild.setInstallHw(false);
+ fBuild.setStrict(false);
+ fBuild.setContainerName(null);
+ fBuild.setFlags(new FlowModFlags(false, false, false, false, false));
+ fBuild.setId(new FlowId(new Long(12)));
+ fBuild.setTableId(checkTableId(tableId));
+ fBuild.setOutGroup(new Long(2));
+ fBuild.setOutPort(value);
+
+ fBuild.setKey(key);
+ fBuild.setPriority(2);
+ fBuild.setFlowName(flowName);
+ return fBuild
+ }
+
+ private static def createPingInstructionsBuilder() {
+ var aList = new ArrayList<Action>
+ var aBuild = new ActionBuilder
+
+ var output = new OutputActionBuilder
+ output.setMaxLength(56)
+ output.setOutputNodeConnector(new Uri("CONTROLLER"))
+ aBuild.setAction(new OutputActionCaseBuilder().setOutputAction(output.build).build)
+ aBuild.setOrder(0)
+ aBuild.setKey(new ActionKey(0))
+ aList.add(aBuild.build)
+ var asBuild = new ApplyActionsBuilder(); asBuild.setAction(aList)
+
+ var iBuild = new InstructionBuilder
+ iBuild.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(asBuild.build).build);
+ iBuild.setOrder(0);
+ iBuild.setKey(new InstructionKey(0));
+
+ var instr = new ArrayList<Instruction>(); instr.add(iBuild.build)
+ return new InstructionsBuilder().setInstruction(instr)
+ }
+
+ private static def checkTableId(String tableId) {
+ try {
+ return Short.parseShort(tableId)
+ } catch (Exception ex) {
+ return Short.parseShort("2")
+ }
+ }
+}
\ No newline at end of file
public static final Long OFPQ_ANY = ANY;
public static final BigInteger DEFAULT_COOKIE = BigInteger.ZERO;
public static final BigInteger DEFAULT_COOKIE_MASK = BigInteger.ZERO;
+ public static final Long OFP_NO_BUFFER = 0xffffffffL;
}
import java.util.List;
import java.util.concurrent.Future;
+import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.controller.sal.common.util.Rpcs;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.openflow.md.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.GetPortOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
// Convert the AddMeterInput to MeterModInput
MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
-
// For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
// the request can be routed through any connection to the switch
@Override
public Future<RpcResult<Void>> transmitPacket(TransmitPacketInput input) {
LOG.info("TransmitPacket - {}",input);
- return null;
+ // Convert TransmitPacket to PacketOutInput
+
+ // TODO VD create PacketConvertor and move convert logic there
+
+ // Build Port ID from TransmitPacketInput.Ingress
+ PortNumber inPortNr = null;
+
+ List<PathArgument> inArgs = input.getIngress().getValue().getPath();
+ if (inArgs.size() >= 3) {
+ InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(inArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
+ NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
+ String[] split = key.getId().getValue().split(":");
+ Long port = Long.decode(split[split.length-1]);
+ inPortNr = new PortNumber(port);
+ } else {
+ // TODO Ed could by in this way or Exception or something else ?
+ inPortNr = new PortNumber(0xfffffffdL);
+ }
+
+ // Build Buffer ID from TransmitPacketInput.Ingress
+ // TODO VD P! find how to fix PacketIn to add BufferID to augmetation
+ Long bufferId = OFConstants.OFP_NO_BUFFER;
+
+ PortNumber outPort = null;
+ NodeConnectorRef outRef = input.getEgress();
+ List<PathArgument> outArgs = outRef.getValue().getPathArguments();
+ if (outArgs.size() >= 3) {
+ InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(outArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
+ NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
+ String[] split = key.getId().getValue().split(":");
+ Long port = Long.decode(split[split.length-1]);
+ outPort = new PortNumber(port);
+ } else {
+ new Exception("PORT NR not exist in Egress"); //TODO : P4 search for some normal exception
+ }
+
+ // TODO VD P! wait for way to move Actions (e.g. augmentation)
+
+ // TODO VD implementation for testing PacketIn (REMOVE IT)
+ List<ActionsList> actions = new ArrayList<ActionsList>();
+ ActionsListBuilder asBuild = new ActionsListBuilder();
+ ActionBuilder aBuild = new ActionBuilder();
+ aBuild.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
+ PortActionBuilder paBuild = new PortActionBuilder();
+ paBuild.setPort(outPort);
+ aBuild.addAugmentation(PortAction.class, paBuild.build());
+ MaxLengthActionBuilder mlBuild = new MaxLengthActionBuilder();
+ mlBuild.setMaxLength(0xffff);
+ aBuild.addAugmentation(MaxLengthAction.class, mlBuild.build());
+ asBuild.setAction(aBuild.build());
+ actions.add(asBuild.build());
+
+ PacketOutInputBuilder builder = new PacketOutInputBuilder();
+ builder.setActionsList(actions);
+ builder.setData(input.getPayload());
+ builder.setVersion(version);
+ builder.setXid(sessionContext.getNextXid());
+ builder.setInPort(inPortNr);
+ builder.setBufferId(bufferId);
+ // --------------------------------------------------------
+
+ PacketOutInput message = builder.build();
+
+ // TODO VD NULL for yet - find how to translate cookie from TransmitPacketInput
+// SwitchConnectionDistinguisher cookie = ( "what is need to do" ) input.getCookie();
+ SwitchConnectionDistinguisher cookie = null ;
+
+ LOG.debug("Calling the transmitPacket RPC method");
+ return messageService.packetOut(message, cookie);
}
private FlowModInputBuilder toFlowModInputBuilder(Flow source) {
return new NodeRef(path);
}
+
+ private static void removeMeImFaick() {
+
+ }
}