Search in sources :

Example 96 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.

the class OpenflowPluginBulkTransactionProvider method createTestFlow.

private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
    FlowBuilder flow = new FlowBuilder();
    long id = 123;
    String flowType = flowTypeArg;
    if (flowType == null) {
        flowType = "f1";
    }
    switch(flowType) {
        case "f1":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f2":
            id += 2;
            flow.setMatch(createMatch2().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f3":
            id += 3;
            flow.setMatch(createMatch3().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f4":
            id += 4;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f5":
            id += 5;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction().build());
            break;
        case "f6":
            id += 6;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createGotoTableInstructions().build());
            break;
        case "f7":
            id += 7;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f8":
            id += 8;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f9":
            id += 9;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction2().build());
            break;
        case "f10":
            id += 10;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction3().build());
            break;
        case "f23":
            id += 23;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction16().build());
            break;
        case "f230":
            id += 23;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction160().build());
            break;
        case "f34":
            id += 34;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction26().build());
            break;
        case "f35":
            id += 35;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction27().build());
            break;
        case "f36":
            id += 36;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction28().build());
            break;
        case "f42":
            id += 42;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction34().build());
            break;
        case "f43":
            id += 43;
            flow.setMatch(createICMPv6Match().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f44":
            id += 44;
            flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f45":
            id += 45;
            flow.setMatch(createMetadataMatch().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f46":
            id += 46;
            flow.setMatch(createL3IPv6Match().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f81":
            id += 81;
            flow.setMatch(createLLDPMatch().build());
            flow.setInstructions(createSentToControllerInstructions().build());
            break;
        case "f82":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f83":
            id += 2;
            flow.setMatch(createMatch2().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f84":
            id += 3;
            flow.setMatch(createMatch3().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f85":
            id += 4;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f86":
            id += 6;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f87":
            id += 12;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f88":
            id += 13;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createAppyActionInstruction6().build());
            break;
        case "f89":
            id += 14;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f90":
            id += 15;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction9().build());
            break;
        case "f91":
            id += 7;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction9().build());
            break;
        case "f92":
            id += 8;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction6().build());
            break;
        case "f93":
            id += 9;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f94":
            id += 10;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f95":
            id += 42;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f96":
            id += 43;
            flow.setMatch(createICMPv6Match().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f97":
            id += 44;
            flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f98":
            id += 45;
            flow.setMatch(createMetadataMatch().build());
            flow.setInstructions(createAppyActionInstruction6().build());
            break;
        case "f99":
            id += 34;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction6().build());
            break;
        case "f100":
            id += 35;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f101":
            id += 36;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction8().build());
            break;
        case "f700":
            id += 3;
            flow.setMatch(createMatch3().build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f800":
            id += 8;
            flow.setMatch(createMatch1000().build());
            flow.setInstructions(createAppyActionInstruction6().build());
            break;
        case "f900":
            id += 5;
            flow.setMatch(createMatch1000().build());
            flow.setInstructions(createAppyActionInstruction2().build());
            break;
        case "f1000":
            id += 10;
            flow.setMatch(createMatch1000().build());
            flow.setInstructions(createAppyActionInstruction3().build());
            break;
        default:
            LOG.warn("flow type not understood: {}", flowType);
    }
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    // flow.setBufferId(12L);
    BigInteger value = BigInteger.valueOf(10);
    BigInteger outputPort = BigInteger.valueOf(4294967295L);
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setId(new FlowId("12"));
    flow.setTableId(getTableId(tableId));
    flow.setOutGroup(4294967295L);
    // set outport to OFPP_NONE (65535) to disable remove restriction for
    // flow
    flow.setOutPort(outputPort);
    FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
    flow.setKey(key);
    flow.setPriority(2);
    flow.setFlowName(originalFlowName + "X" + flowType);
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) BigInteger(java.math.BigInteger)

Example 97 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.

the class ArpUtilImpl method fireArpRespRecvdNotification.

private void fireArpRespRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMacAddressBytes, int tableId, BigInteger metadata, InetAddress dstInetAddr, byte[] dstMacAddressBytes) throws InterruptedException {
    arpRespRecvd.mark();
    IpAddress srcIp = new IpAddress(srcInetAddr.getHostAddress().toCharArray());
    IpAddress dstIp = new IpAddress(dstInetAddr.getHostAddress().toCharArray());
    String srcMacAddress = NWUtil.toStringMacAddress(srcMacAddressBytes);
    PhysAddress srcMac = new PhysAddress(srcMacAddress);
    String dstMacAddress = NWUtil.toStringMacAddress(dstMacAddressBytes);
    PhysAddress dstMac = new PhysAddress(dstMacAddress);
    ArpResponseReceivedBuilder builder = new ArpResponseReceivedBuilder();
    builder.setInterface(interfaceName);
    builder.setSrcIpaddress(srcIp);
    builder.setOfTableId((long) tableId);
    builder.setSrcMac(srcMac);
    builder.setMetadata(metadata);
    builder.setDstIpaddress(dstIp);
    builder.setDstMac(dstMac);
    ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
    if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
        arpRespRecvdNotificationRejected.mark();
    } else {
        arpRespRecvdNotification.mark();
    }
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ArpResponseReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.ArpResponseReceivedBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 98 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.

the class ArpUtilTestUtil method createPayload.

public static PacketReceived createPayload(int oc) {
    final short ID = 2;
    byte[] payload = bytePayload(// Destination MAC
    "1F 1F 1F 1F 1F 1F", // Source MAC
    "00 01 02 03 04 05", // Ethernet type
    "08 06", // Hardware type
    "0 1", // Protocol type
    "8 0", // Hardware size
    "6", // Protocol size
    "4", // Opcode
    OP_CODE[oc], // Sender MAC Address
    "00 01 02 03 04 05", // Sender IP Address
    "C0 A8 0 2", // Target MAC Address
    "00 01 02 03 04 05", // Target IP Address
    "C0 A8 0 2");
    return new PacketReceivedBuilder().setPacketInReason(SendToController.class).setTableId(new TableId(ID)).setPayload(payload).setIngress(new NodeConnectorRef(InstanceIdentifier.create(Node.class))).setMatch(new MatchBuilder().setMetadata(new MetadataBuilder().setMetadata(META_DATA).build()).build()).build();
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) SendToController(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController) MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder)

Example 99 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.

the class AlivenessProtocolHandlerARP method handlePacketIn.

@Override
public String handlePacketIn(ARP packet, PacketReceived packetReceived) {
    short tableId = packetReceived.getTableId().getValue();
    int arpType = packet.getOpCode();
    if (LOG.isTraceEnabled()) {
        LOG.trace("packet: {}, tableId {}, arpType {}", packetReceived, tableId, arpType);
    }
    if (arpType == ARP.REPLY) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("packet: {}", packetReceived);
        }
        BigInteger metadata = packetReceived.getMatch().getMetadata().getMetadata();
        int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
        String interfaceName = null;
        try {
            GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build();
            Future<RpcResult<GetInterfaceFromIfIndexOutput>> output = interfaceManager.getInterfaceFromIfIndex(input);
            RpcResult<GetInterfaceFromIfIndexOutput> result = output.get();
            if (result.isSuccessful()) {
                GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult();
                interfaceName = ifIndexOutput.getInterfaceName();
            } else {
                LOG.warn("RPC call to get interface name for if index {} failed with errors {}", portTag, result.getErrors());
                return null;
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
        }
        if (!Strings.isNullOrEmpty(interfaceName)) {
            String sourceIp = NWUtil.toStringIpAddress(packet.getSenderProtocolAddress());
            String targetIp = NWUtil.toStringIpAddress(packet.getTargetProtocolAddress());
            return getMonitoringKey(interfaceName, targetIp, sourceIp);
        } else {
            LOG.debug("No interface associated with tag {} to interpret the received ARP Reply", portTag);
        }
    }
    return null;
}
Also used : GetInterfaceFromIfIndexInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInput) GetInterfaceFromIfIndexInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException) GetInterfaceFromIfIndexOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput)

Example 100 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project genius by opendaylight.

the class MDSALManager method deleteFlowInternal.

public void deleteFlowInternal(BigInteger dpId, Flow flow, WriteTransaction tx) {
    FlowKey flowKey = new FlowKey(flow.getId());
    short tableId = flow.getTableId();
    deleteFlow(dpId, tableId, flowKey, tx);
}
Also used : FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)

Aggregations

BigInteger (java.math.BigInteger)38 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)26 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)17 ByteBuf (io.netty.buffer.ByteBuf)16 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)16 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)15 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)15 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)14 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)14 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)7 Optional (com.google.common.base.Optional)6 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5