Search in sources :

Example 1 with TunnelIdCriterion

use of org.onosproject.net.flow.criteria.TunnelIdCriterion in project onos by opennetworkinglab.

the class Ofdpa2GroupHandler method processSimpleNextObjective.

/**
 * As per the OFDPA 2.0 TTP, packets are sent out of ports by using
 * a chain of groups. The simple Next Objective passed in by the application
 * is broken up into a group chain. The following chains can be created
 * depending on the parameters in the Next Objective.
 * 1. L2 Interface group (no chaining)
 * 2. L3 Unicast group -> L2 Interface group
 * 3. MPLS Interface group -> L2 Interface group
 * 4. MPLS Swap group -> MPLS Interface group -> L2 Interface group
 * 5. PW initiation group chain
 *
 * @param nextObj  the nextObjective of type SIMPLE
 */
private void processSimpleNextObjective(NextObjective nextObj) {
    TrafficTreatment treatment = nextObj.next().iterator().next();
    // determine if plain L2 or L3->L2 or MPLS Swap -> MPLS Interface -> L2
    boolean plainL2 = true;
    boolean mplsSwap = false;
    MplsLabel mplsLabel = null;
    for (Instruction ins : treatment.allInstructions()) {
        if (ins.type() == Instruction.Type.L2MODIFICATION) {
            L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
            if (l2ins.subtype() == L2ModificationInstruction.L2SubType.ETH_DST || l2ins.subtype() == L2ModificationInstruction.L2SubType.ETH_SRC) {
                plainL2 = false;
            }
            // a MPLS Swap group before the MPLS Interface Group
            if (l2ins.subtype() == L2ModificationInstruction.L2SubType.MPLS_LABEL) {
                mplsSwap = true;
                mplsLabel = ((L2ModificationInstruction.ModMplsLabelInstruction) l2ins).label();
            }
        }
    }
    if (plainL2) {
        createL2InterfaceGroup(nextObj);
        return;
    }
    // In order to understand if it is a pseudowire related
    // next objective we look for the tunnel id in the meta.
    boolean isPw = false;
    if (nextObj.meta() != null) {
        TunnelIdCriterion tunnelIdCriterion = (TunnelIdCriterion) nextObj.meta().getCriterion(TUNNEL_ID);
        if (tunnelIdCriterion != null) {
            isPw = true;
        }
    }
    if (mplsSwap && !isPw) {
        log.debug("Creating a MPLS Swap -> MPLS Interface -> L2 Interface group chain.");
        // break up simple next objective to GroupChain objects
        GroupInfo groupInfo = createL2L3Chain(treatment, nextObj.id(), nextObj.appId(), true, nextObj.meta());
        if (groupInfo == null) {
            log.error("Could not process nextObj={} in dev:{}", nextObj.id(), deviceId);
            fail(nextObj, ObjectiveError.BADPARAMS);
            return;
        }
        Deque<GroupKey> gkeyChain = new ArrayDeque<>();
        // l2 interface
        gkeyChain.addFirst(groupInfo.innerMostGroupDesc().appCookie());
        // mpls interface
        gkeyChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        // creating the mpls swap group and adding it to the chain
        int nextGid = groupInfo.nextGroupDesc().givenGroupId();
        int index = getNextAvailableIndex();
        GroupDescription swapGroupDescription = createMplsSwap(nextGid, OfdpaMplsGroupSubType.MPLS_SWAP_LABEL, index, mplsLabel, nextObj.appId());
        // ensure swap group is added after L2L3 chain
        GroupKey swapGroupKey = swapGroupDescription.appCookie();
        GroupChainElem swapChainElem = new GroupChainElem(swapGroupDescription, 1, false, deviceId);
        updatePendingGroups(groupInfo.nextGroupDesc().appCookie(), swapChainElem);
        gkeyChain.addFirst(swapGroupKey);
        // ensure nextObjective waits on the outermost groupKey
        List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
        allGroupKeys.add(gkeyChain);
        OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj);
        updatePendingNextObjective(swapGroupKey, ofdpaGrp);
        // now we are ready to send the l2 groupDescription (inner), as all the stores
        // that will get async replies have been updated. By waiting to update
        // the stores, we prevent nasty race conditions.
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    } else if (!isPw) {
        boolean isMpls = false;
        if (nextObj.meta() != null) {
            isMpls = isNotMplsBos(nextObj.meta());
        }
        log.debug("Creating a {} -> L2 Interface group chain.", (isMpls) ? "MPLS Interface" : "L3 Unicast");
        // break up simple next objective to GroupChain objects
        GroupInfo groupInfo = createL2L3Chain(treatment, nextObj.id(), nextObj.appId(), isMpls, nextObj.meta());
        if (groupInfo == null) {
            log.error("Could not process nextObj={} in dev:{}", nextObj.id(), deviceId);
            fail(nextObj, ObjectiveError.BADPARAMS);
            return;
        }
        // create object for local and distributed storage
        Deque<GroupKey> gkeyChain = new ArrayDeque<>();
        gkeyChain.addFirst(groupInfo.innerMostGroupDesc().appCookie());
        gkeyChain.addFirst(groupInfo.nextGroupDesc().appCookie());
        List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
        allGroupKeys.add(gkeyChain);
        OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj);
        // store l3groupkey with the ofdpaNextGroup for the nextObjective that depends on it
        updatePendingNextObjective(groupInfo.nextGroupDesc().appCookie(), ofdpaGrp);
        // now we are ready to send the l2 groupDescription (inner), as all the stores
        // that will get async replies have been updated. By waiting to update
        // the stores, we prevent nasty race conditions.
        groupService.addGroup(groupInfo.innerMostGroupDesc());
    } else {
        // We handle the pseudo wire with a different a procedure.
        // This procedure is meant to handle both initiation and
        // termination of the pseudo wire.
        processPwNextObjective(nextObj);
    }
}
Also used : TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) OfdpaGroupHandlerUtility.l2MulticastGroupKey(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupInstruction(org.onosproject.net.flow.instructions.Instructions.GroupInstruction) Deque(java.util.Deque) ArrayDeque(java.util.ArrayDeque) ArrayDeque(java.util.ArrayDeque) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) MplsLabel(org.onlab.packet.MplsLabel) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList)

Example 2 with TunnelIdCriterion

use of org.onosproject.net.flow.criteria.TunnelIdCriterion in project onos by opennetworkinglab.

the class Ofdpa3Pipeline method processInitPwVersatile.

/**
 * Helper method to process the pw forwarding objectives.
 *
 * @param forwardingObjective the fw objective to process
 * @return a singleton list of flow rule
 */
private Collection<FlowRule> processInitPwVersatile(ForwardingObjective forwardingObjective) {
    // We retrieve the matching criteria for mpls l2 port.
    TunnelIdCriterion tunnelIdCriterion = (TunnelIdCriterion) forwardingObjective.selector().getCriterion(TUNNEL_ID);
    PortCriterion portCriterion = (PortCriterion) forwardingObjective.selector().getCriterion(IN_PORT);
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    int mplsLogicalPort;
    long tunnelId;
    // Mpls tunnel ids according to the OFDPA manual have to be
    // in the range [2^17-1, 2^16].
    tunnelId = MPLS_TUNNEL_ID_BASE | tunnelIdCriterion.tunnelId();
    if (tunnelId > MPLS_TUNNEL_ID_MAX) {
        log.error("Pw Versatile Forwarding Objective must include tunnel id < {}", MPLS_TUNNEL_ID_MAX);
        fail(forwardingObjective, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    // Port has not been null.
    if (portCriterion == null) {
        log.error("Pw Versatile Forwarding Objective must include port");
        fail(forwardingObjective, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    // 0x0000XXXX is UNI interface.
    if (portCriterion.port().toLong() > MPLS_UNI_PORT_MAX) {
        log.error("Pw Versatile Forwarding Objective invalid logical port {}", portCriterion.port().toLong());
        fail(forwardingObjective, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    mplsLogicalPort = ((int) portCriterion.port().toLong());
    if (forwardingObjective.nextId() == null) {
        log.error("Pw Versatile Forwarding Objective must contain nextId ", forwardingObjective.nextId());
        fail(forwardingObjective, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    // We don't expect a treatment.
    if (forwardingObjective.treatment() != null && !forwardingObjective.treatment().equals(DefaultTrafficTreatment.emptyTreatment())) {
        log.error("Pw Versatile Forwarding Objective cannot contain a treatment ", forwardingObjective.nextId());
        fail(forwardingObjective, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    // We retrieve the l2 vpn group and point the mpls
    // l2 port to this.
    NextGroup next = getGroupForNextObjective(forwardingObjective.nextId());
    if (next == null) {
        log.warn("next-id:{} not found in dev:{}", forwardingObjective.nextId(), deviceId);
        fail(forwardingObjective, ObjectiveError.GROUPMISSING);
        return Collections.emptySet();
    }
    List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
    Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
    if (group == null) {
        log.warn("Group with key:{} for next-id:{} not found in dev:{}", gkeys.get(0).peekFirst(), forwardingObjective.nextId(), deviceId);
        fail(forwardingObjective, ObjectiveError.GROUPMISSING);
        return Collections.emptySet();
    }
    // We prepare the flow rule for the mpls l2 port table.
    selector.matchTunnelId(tunnelId);
    selector.extension(new Ofdpa3MatchMplsL2Port(mplsLogicalPort), deviceId);
    // This should not be necessary but without we receive an error
    treatment.extension(new Ofdpa3SetQosIndex(0), deviceId);
    treatment.transition(MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE);
    treatment.deferred().group(group.id());
    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(forwardingObjective.appId()).withPriority(MPLS_L2_PORT_PRIORITY).forDevice(deviceId).withSelector(selector.build()).withTreatment(treatment.build()).makePermanent().forTable(MPLS_L2_PORT_FLOW_TABLE);
    return Collections.singletonList(ruleBuilder.build());
}
Also used : NextGroup(org.onosproject.net.behaviour.NextGroup) NextGroup(org.onosproject.net.behaviour.NextGroup) Group(org.onosproject.net.group.Group) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) Ofdpa3MatchMplsL2Port(org.onosproject.driver.extensions.Ofdpa3MatchMplsL2Port) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Deque(java.util.Deque) Ofdpa3SetQosIndex(org.onosproject.driver.extensions.Ofdpa3SetQosIndex) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule)

Example 3 with TunnelIdCriterion

use of org.onosproject.net.flow.criteria.TunnelIdCriterion in project onos by opennetworkinglab.

the class FlowModBuilder method buildMatch.

/**
 * Builds the match for the flow mod.
 *
 * @return the match
 */
// CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES
protected Match buildMatch() {
    Match.Builder mBuilder = factory.buildMatch();
    Ip6Address ip6Address;
    Ip4Prefix ip4Prefix;
    Ip6Prefix ip6Prefix;
    EthCriterion ethCriterion;
    IPCriterion ipCriterion;
    TcpPortCriterion tcpPortCriterion;
    UdpPortCriterion udpPortCriterion;
    SctpPortCriterion sctpPortCriterion;
    IPv6NDLinkLayerAddressCriterion llAddressCriterion;
    ArpHaCriterion arpHaCriterion;
    ArpPaCriterion arpPaCriterion;
    for (Criterion c : selector.criteria()) {
        switch(c.type()) {
            case IN_PORT:
                PortCriterion inPort = (PortCriterion) c;
                mBuilder.setExact(MatchField.IN_PORT, OFPort.of((int) inPort.port().toLong()));
                break;
            case IN_PHY_PORT:
                PortCriterion inPhyPort = (PortCriterion) c;
                mBuilder.setExact(MatchField.IN_PORT, OFPort.of((int) inPhyPort.port().toLong()));
                break;
            case METADATA:
                MetadataCriterion metadata = (MetadataCriterion) c;
                mBuilder.setExact(MatchField.METADATA, OFMetadata.ofRaw(metadata.metadata()));
                break;
            case ETH_DST:
                ethCriterion = (EthCriterion) c;
                mBuilder.setExact(MatchField.ETH_DST, MacAddress.of(ethCriterion.mac().toLong()));
                break;
            case ETH_DST_MASKED:
                ethCriterion = (EthCriterion) c;
                mBuilder.setMasked(MatchField.ETH_DST, MacAddress.of(ethCriterion.mac().toLong()), MacAddress.of(ethCriterion.mask().toLong()));
                break;
            case ETH_SRC:
                ethCriterion = (EthCriterion) c;
                mBuilder.setExact(MatchField.ETH_SRC, MacAddress.of(ethCriterion.mac().toLong()));
                break;
            case ETH_SRC_MASKED:
                ethCriterion = (EthCriterion) c;
                mBuilder.setMasked(MatchField.ETH_SRC, MacAddress.of(ethCriterion.mac().toLong()), MacAddress.of(ethCriterion.mask().toLong()));
                break;
            case ETH_TYPE:
                EthTypeCriterion ethType = (EthTypeCriterion) c;
                mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(ethType.ethType().toShort()));
                break;
            case VLAN_VID:
                VlanIdCriterion vid = (VlanIdCriterion) c;
                if (vid.vlanId().equals(VlanId.ANY)) {
                    mBuilder.setMasked(MatchField.VLAN_VID, OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
                } else if (vid.vlanId().equals(VlanId.NONE)) {
                    mBuilder.setExact(MatchField.VLAN_VID, OFVlanVidMatch.NONE);
                } else {
                    mBuilder.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort())));
                }
                break;
            case VLAN_PCP:
                VlanPcpCriterion vpcp = (VlanPcpCriterion) c;
                mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority()));
                break;
            case IP_DSCP:
                IPDscpCriterion ipDscpCriterion = (IPDscpCriterion) c;
                mBuilder.setExact(MatchField.IP_DSCP, IpDscp.of(ipDscpCriterion.ipDscp()));
                break;
            case IP_ECN:
                IPEcnCriterion ipEcnCriterion = (IPEcnCriterion) c;
                mBuilder.setExact(MatchField.IP_ECN, IpEcn.of(ipEcnCriterion.ipEcn()));
                break;
            case IP_PROTO:
                IPProtocolCriterion p = (IPProtocolCriterion) c;
                mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol()));
                break;
            case IPV4_SRC:
                ipCriterion = (IPCriterion) c;
                ip4Prefix = ipCriterion.ip().getIp4Prefix();
                if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
                    Ip4Address maskAddr = Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
                    Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), IPv4Address.of(maskAddr.toInt()));
                    mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp);
                } else {
                    mBuilder.setExact(MatchField.IPV4_SRC, IPv4Address.of(ip4Prefix.address().toInt()));
                }
                break;
            case IPV4_DST:
                ipCriterion = (IPCriterion) c;
                ip4Prefix = ipCriterion.ip().getIp4Prefix();
                if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) {
                    Ip4Address maskAddr = Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength());
                    Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), IPv4Address.of(maskAddr.toInt()));
                    mBuilder.setMasked(MatchField.IPV4_DST, maskedIp);
                } else {
                    mBuilder.setExact(MatchField.IPV4_DST, IPv4Address.of(ip4Prefix.address().toInt()));
                }
                break;
            case TCP_SRC:
                tcpPortCriterion = (TcpPortCriterion) c;
                mBuilder.setExact(MatchField.TCP_SRC, TransportPort.of(tcpPortCriterion.tcpPort().toInt()));
                break;
            case TCP_SRC_MASKED:
                tcpPortCriterion = (TcpPortCriterion) c;
                mBuilder.setMasked(MatchField.TCP_SRC, TransportPort.of(tcpPortCriterion.tcpPort().toInt()), TransportPort.of(tcpPortCriterion.mask().toInt()));
                break;
            case TCP_DST:
                tcpPortCriterion = (TcpPortCriterion) c;
                mBuilder.setExact(MatchField.TCP_DST, TransportPort.of(tcpPortCriterion.tcpPort().toInt()));
                break;
            case TCP_DST_MASKED:
                tcpPortCriterion = (TcpPortCriterion) c;
                mBuilder.setMasked(MatchField.TCP_DST, TransportPort.of(tcpPortCriterion.tcpPort().toInt()), TransportPort.of(tcpPortCriterion.mask().toInt()));
                break;
            case UDP_SRC:
                udpPortCriterion = (UdpPortCriterion) c;
                mBuilder.setExact(MatchField.UDP_SRC, TransportPort.of(udpPortCriterion.udpPort().toInt()));
                break;
            case UDP_SRC_MASKED:
                udpPortCriterion = (UdpPortCriterion) c;
                mBuilder.setMasked(MatchField.UDP_SRC, TransportPort.of(udpPortCriterion.udpPort().toInt()), TransportPort.of(udpPortCriterion.mask().toInt()));
                break;
            case UDP_DST:
                udpPortCriterion = (UdpPortCriterion) c;
                mBuilder.setExact(MatchField.UDP_DST, TransportPort.of(udpPortCriterion.udpPort().toInt()));
                break;
            case UDP_DST_MASKED:
                udpPortCriterion = (UdpPortCriterion) c;
                mBuilder.setMasked(MatchField.UDP_DST, TransportPort.of(udpPortCriterion.udpPort().toInt()), TransportPort.of(udpPortCriterion.mask().toInt()));
                break;
            case SCTP_SRC:
                sctpPortCriterion = (SctpPortCriterion) c;
                mBuilder.setExact(MatchField.SCTP_SRC, TransportPort.of(sctpPortCriterion.sctpPort().toInt()));
                break;
            case SCTP_SRC_MASKED:
                sctpPortCriterion = (SctpPortCriterion) c;
                mBuilder.setMasked(MatchField.SCTP_SRC, TransportPort.of(sctpPortCriterion.sctpPort().toInt()), TransportPort.of(sctpPortCriterion.mask().toInt()));
                break;
            case SCTP_DST:
                sctpPortCriterion = (SctpPortCriterion) c;
                mBuilder.setExact(MatchField.SCTP_DST, TransportPort.of(sctpPortCriterion.sctpPort().toInt()));
                break;
            case SCTP_DST_MASKED:
                sctpPortCriterion = (SctpPortCriterion) c;
                mBuilder.setMasked(MatchField.SCTP_DST, TransportPort.of(sctpPortCriterion.sctpPort().toInt()), TransportPort.of(sctpPortCriterion.mask().toInt()));
                break;
            case ICMPV4_TYPE:
                IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c;
                mBuilder.setExact(MatchField.ICMPV4_TYPE, ICMPv4Type.of(icmpType.icmpType()));
                break;
            case ICMPV4_CODE:
                IcmpCodeCriterion icmpCode = (IcmpCodeCriterion) c;
                mBuilder.setExact(MatchField.ICMPV4_CODE, ICMPv4Code.of(icmpCode.icmpCode()));
                break;
            case IPV6_SRC:
                ipCriterion = (IPCriterion) c;
                ip6Prefix = ipCriterion.ip().getIp6Prefix();
                if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
                    Ip6Address maskAddr = Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
                    Masked<IPv6Address> maskedIp = Masked.of(IPv6Address.of(ip6Prefix.address().toString()), IPv6Address.of(maskAddr.toString()));
                    mBuilder.setMasked(MatchField.IPV6_SRC, maskedIp);
                } else {
                    mBuilder.setExact(MatchField.IPV6_SRC, IPv6Address.of(ip6Prefix.address().toString()));
                }
                break;
            case IPV6_DST:
                ipCriterion = (IPCriterion) c;
                ip6Prefix = ipCriterion.ip().getIp6Prefix();
                if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) {
                    Ip6Address maskAddr = Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength());
                    Masked<IPv6Address> maskedIp = Masked.of(IPv6Address.of(ip6Prefix.address().toString()), IPv6Address.of(maskAddr.toString()));
                    mBuilder.setMasked(MatchField.IPV6_DST, maskedIp);
                } else {
                    mBuilder.setExact(MatchField.IPV6_DST, IPv6Address.of(ip6Prefix.address().toString()));
                }
                break;
            case IPV6_FLABEL:
                IPv6FlowLabelCriterion flowLabelCriterion = (IPv6FlowLabelCriterion) c;
                mBuilder.setExact(MatchField.IPV6_FLABEL, IPv6FlowLabel.of(flowLabelCriterion.flowLabel()));
                break;
            case ICMPV6_TYPE:
                Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c;
                mBuilder.setExact(MatchField.ICMPV6_TYPE, U8.of(icmpv6Type.icmpv6Type()));
                break;
            case ICMPV6_CODE:
                Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c;
                mBuilder.setExact(MatchField.ICMPV6_CODE, U8.of(icmpv6Code.icmpv6Code()));
                break;
            case IPV6_ND_TARGET:
                IPv6NDTargetAddressCriterion targetAddressCriterion = (IPv6NDTargetAddressCriterion) c;
                ip6Address = targetAddressCriterion.targetAddress();
                mBuilder.setExact(MatchField.IPV6_ND_TARGET, IPv6Address.of(ip6Address.toOctets()));
                break;
            case IPV6_ND_SLL:
                llAddressCriterion = (IPv6NDLinkLayerAddressCriterion) c;
                mBuilder.setExact(MatchField.IPV6_ND_SLL, MacAddress.of(llAddressCriterion.mac().toLong()));
                break;
            case IPV6_ND_TLL:
                llAddressCriterion = (IPv6NDLinkLayerAddressCriterion) c;
                mBuilder.setExact(MatchField.IPV6_ND_TLL, MacAddress.of(llAddressCriterion.mac().toLong()));
                break;
            case MPLS_LABEL:
                MplsCriterion mp = (MplsCriterion) c;
                mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt()));
                break;
            case IPV6_EXTHDR:
                IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = (IPv6ExthdrFlagsCriterion) c;
                mBuilder.setExact(MatchField.IPV6_EXTHDR, U16.of(exthdrFlagsCriterion.exthdrFlags()));
                break;
            case OCH_SIGID:
                try {
                    OchSignalCriterion ochSignalCriterion = (OchSignalCriterion) c;
                    OchSignal signal = ochSignalCriterion.lambda();
                    byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
                    byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
                    mBuilder.setExact(MatchField.EXP_OCH_SIG_ID, new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
                } catch (NoMappingFoundException e) {
                    log.warn(e.getMessage());
                }
                break;
            case OCH_SIGTYPE:
                try {
                    OchSignalTypeCriterion sc = (OchSignalTypeCriterion) c;
                    byte signalType = OpenFlowValueMapper.lookupOchSignalType(sc.signalType());
                    mBuilder.setExact(MatchField.EXP_OCH_SIGTYPE, U8.of(signalType));
                } catch (NoMappingFoundException e) {
                    log.warn(e.getMessage());
                }
                break;
            case ODU_SIGID:
                OduSignalIdCriterion oduSignalIdCriterion = (OduSignalIdCriterion) c;
                OduSignalId oduSignalId = oduSignalIdCriterion.oduSignalId();
                mBuilder.setExact(MatchField.EXP_ODU_SIG_ID, new OduSignalID((short) oduSignalId.tributaryPortNumber(), (short) oduSignalId.tributarySlotLength(), oduSignalId.tributarySlotBitmap()));
                break;
            case ODU_SIGTYPE:
                try {
                    OduSignalTypeCriterion oduSignalTypeCriterion = (OduSignalTypeCriterion) c;
                    byte oduSigType = OpenFlowValueMapper.lookupOduSignalType(oduSignalTypeCriterion.signalType());
                    mBuilder.setExact(MatchField.EXP_ODU_SIGTYPE, U8.of(oduSigType));
                } catch (NoMappingFoundException e) {
                    log.warn(e.getMessage());
                }
                break;
            case TUNNEL_ID:
                TunnelIdCriterion tunnelId = (TunnelIdCriterion) c;
                mBuilder.setExact(MatchField.TUNNEL_ID, U64.of(tunnelId.tunnelId()));
                break;
            case MPLS_BOS:
                MplsBosCriterion mplsBos = (MplsBosCriterion) c;
                mBuilder.setExact(MatchField.MPLS_BOS, mplsBos.mplsBos() ? OFBooleanValue.TRUE : OFBooleanValue.FALSE);
                break;
            case ARP_OP:
                ArpOpCriterion arpOp = (ArpOpCriterion) c;
                mBuilder.setExact(MatchField.ARP_OP, ArpOpcode.of(arpOp.arpOp()));
                break;
            case ARP_SHA:
                arpHaCriterion = (ArpHaCriterion) c;
                mBuilder.setExact(MatchField.ARP_SHA, MacAddress.of(arpHaCriterion.mac().toLong()));
                break;
            case ARP_SPA:
                arpPaCriterion = (ArpPaCriterion) c;
                mBuilder.setExact(MatchField.ARP_SPA, IPv4Address.of(arpPaCriterion.ip().toInt()));
                break;
            case ARP_THA:
                arpHaCriterion = (ArpHaCriterion) c;
                mBuilder.setExact(MatchField.ARP_THA, MacAddress.of(arpHaCriterion.mac().toLong()));
                break;
            case ARP_TPA:
                arpPaCriterion = (ArpPaCriterion) c;
                mBuilder.setExact(MatchField.ARP_TPA, IPv4Address.of(arpPaCriterion.ip().toInt()));
                break;
            case EXTENSION:
                ExtensionCriterion extensionCriterion = (ExtensionCriterion) c;
                OFOxm oxm = buildExtensionOxm(extensionCriterion.extensionSelector());
                if (oxm == null) {
                    log.warn("Unable to build extension selector");
                    break;
                }
                if (oxm.isMasked()) {
                    mBuilder.setMasked(oxm.getMatchField(), oxm.getValue(), oxm.getMask());
                } else {
                    mBuilder.setExact(oxm.getMatchField(), oxm.getValue());
                }
                break;
            case MPLS_TC:
            case PBB_ISID:
            // TODO: need to implement PBB-ISID case when OpenFlowJ is ready
            default:
                log.warn("Match type {} not yet implemented.", c.type());
        }
    }
    return mBuilder.build();
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) Ip4Address(org.onlab.packet.Ip4Address) IPv6Address(org.projectfloodlight.openflow.types.IPv6Address) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) IPv4Address(org.projectfloodlight.openflow.types.IPv4Address) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) Ip6Address(org.onlab.packet.Ip6Address) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) CircuitSignalID(org.projectfloodlight.openflow.types.CircuitSignalID) ArpHaCriterion(org.onosproject.net.flow.criteria.ArpHaCriterion) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) MplsBosCriterion(org.onosproject.net.flow.criteria.MplsBosCriterion) OFOxm(org.projectfloodlight.openflow.protocol.oxm.OFOxm) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) NoMappingFoundException(org.onosproject.provider.of.flow.util.NoMappingFoundException) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) Ip6Prefix(org.onlab.packet.Ip6Prefix) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) ArpHaCriterion(org.onosproject.net.flow.criteria.ArpHaCriterion) MplsBosCriterion(org.onosproject.net.flow.criteria.MplsBosCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) ExtensionCriterion(org.onosproject.net.flow.criteria.ExtensionCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) ArpOpCriterion(org.onosproject.net.flow.criteria.ArpOpCriterion) ArpPaCriterion(org.onosproject.net.flow.criteria.ArpPaCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) OduSignalId(org.onosproject.net.OduSignalId) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) OchSignal(org.onosproject.net.OchSignal) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) ArpOpCriterion(org.onosproject.net.flow.criteria.ArpOpCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) ExtensionCriterion(org.onosproject.net.flow.criteria.ExtensionCriterion) ArpPaCriterion(org.onosproject.net.flow.criteria.ArpPaCriterion) MetadataCriterion(org.onosproject.net.flow.criteria.MetadataCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Ip4Prefix(org.onlab.packet.Ip4Prefix) OduSignalID(org.projectfloodlight.openflow.types.OduSignalID)

Example 4 with TunnelIdCriterion

use of org.onosproject.net.flow.criteria.TunnelIdCriterion in project onos by opennetworkinglab.

the class FlowRuleCodecTest method codecCriteriaFlowTest.

/**
 * Checks that a rule with one of each kind of criterion decodes properly.
 *
 * @throws IOException if the resource cannot be processed
 */
@Test
public void codecCriteriaFlowTest() throws Exception {
    FlowRule rule = getRule("criteria-flow.json");
    checkCommonData(rule);
    assertThat(rule.selector().criteria().size(), is(35));
    rule.selector().criteria().forEach(criterion -> criteria.put(criterion.type().name(), criterion));
    Criterion criterion;
    criterion = getCriterion(Criterion.Type.ETH_TYPE);
    assertThat(((EthTypeCriterion) criterion).ethType(), is(new EthType(2054)));
    criterion = getCriterion(Criterion.Type.ETH_DST);
    assertThat(((EthCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:55")));
    criterion = getCriterion(Criterion.Type.ETH_SRC);
    assertThat(((EthCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:55")));
    criterion = getCriterion(Criterion.Type.IN_PORT);
    assertThat(((PortCriterion) criterion).port(), is(PortNumber.portNumber(23)));
    criterion = getCriterion(Criterion.Type.IN_PHY_PORT);
    assertThat(((PortCriterion) criterion).port(), is(PortNumber.portNumber(44)));
    criterion = getCriterion(Criterion.Type.VLAN_VID);
    assertThat(((VlanIdCriterion) criterion).vlanId(), is(VlanId.vlanId((short) 777)));
    criterion = getCriterion(Criterion.Type.VLAN_PCP);
    assertThat(((VlanPcpCriterion) criterion).priority(), is(((byte) 3)));
    criterion = getCriterion(Criterion.Type.IP_DSCP);
    assertThat(((IPDscpCriterion) criterion).ipDscp(), is(((byte) 2)));
    criterion = getCriterion(Criterion.Type.IP_ECN);
    assertThat(((IPEcnCriterion) criterion).ipEcn(), is(((byte) 1)));
    criterion = getCriterion(Criterion.Type.IP_PROTO);
    assertThat(((IPProtocolCriterion) criterion).protocol(), is(((short) 4)));
    criterion = getCriterion(Criterion.Type.IPV4_SRC);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("1.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV4_DST);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("2.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV6_SRC);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("3.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.IPV6_DST);
    assertThat(((IPCriterion) criterion).ip(), is((IpPrefix.valueOf("4.2.0.0/32"))));
    criterion = getCriterion(Criterion.Type.TCP_SRC);
    assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(), is(80));
    criterion = getCriterion(Criterion.Type.TCP_DST);
    assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(), is(443));
    criterion = getCriterion(Criterion.Type.UDP_SRC);
    assertThat(((UdpPortCriterion) criterion).udpPort().toInt(), is(180));
    criterion = getCriterion(Criterion.Type.UDP_DST);
    assertThat(((UdpPortCriterion) criterion).udpPort().toInt(), is(1443));
    criterion = getCriterion(Criterion.Type.SCTP_SRC);
    assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(), is(280));
    criterion = getCriterion(Criterion.Type.SCTP_DST);
    assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(), is(2443));
    criterion = getCriterion(Criterion.Type.ICMPV4_TYPE);
    assertThat(((IcmpTypeCriterion) criterion).icmpType(), is((short) 24));
    criterion = getCriterion(Criterion.Type.ICMPV4_CODE);
    assertThat(((IcmpCodeCriterion) criterion).icmpCode(), is((short) 16));
    criterion = getCriterion(Criterion.Type.ICMPV6_TYPE);
    assertThat(((Icmpv6TypeCriterion) criterion).icmpv6Type(), is((short) 14));
    criterion = getCriterion(Criterion.Type.ICMPV6_CODE);
    assertThat(((Icmpv6CodeCriterion) criterion).icmpv6Code(), is((short) 6));
    criterion = getCriterion(Criterion.Type.IPV6_FLABEL);
    assertThat(((IPv6FlowLabelCriterion) criterion).flowLabel(), is(8));
    criterion = getCriterion(Criterion.Type.IPV6_ND_TARGET);
    assertThat(((IPv6NDTargetAddressCriterion) criterion).targetAddress().toString(), is("1111:2222:3333:4444:5555:6666:7777:8888"));
    criterion = getCriterion(Criterion.Type.IPV6_ND_SLL);
    assertThat(((IPv6NDLinkLayerAddressCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:56")));
    criterion = getCriterion(Criterion.Type.IPV6_ND_TLL);
    assertThat(((IPv6NDLinkLayerAddressCriterion) criterion).mac(), is(MacAddress.valueOf("00:11:22:33:44:57")));
    criterion = getCriterion(Criterion.Type.MPLS_LABEL);
    assertThat(((MplsCriterion) criterion).label(), is(MplsLabel.mplsLabel(123)));
    criterion = getCriterion(Criterion.Type.IPV6_EXTHDR);
    assertThat(((IPv6ExthdrFlagsCriterion) criterion).exthdrFlags(), is(99));
    criterion = getCriterion(Criterion.Type.TUNNEL_ID);
    assertThat(((TunnelIdCriterion) criterion).tunnelId(), is(100L));
    criterion = getCriterion(Criterion.Type.OCH_SIGTYPE);
    assertThat(((OchSignalTypeCriterion) criterion).signalType(), is(OchSignalType.FIXED_GRID));
    criterion = getCriterion(Criterion.Type.ODU_SIGTYPE);
    assertThat(((OduSignalTypeCriterion) criterion).signalType(), is(OduSignalType.ODU4));
    criterion = getCriterion(Criterion.Type.ODU_SIGID);
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributaryPortNumber(), is(1));
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotLength(), is(80));
    assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotBitmap(), is(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }));
}
Also used : EthType(org.onlab.packet.EthType) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) Test(org.junit.Test)

Example 5 with TunnelIdCriterion

use of org.onosproject.net.flow.criteria.TunnelIdCriterion in project onos by opennetworkinglab.

the class LinkCollectionCompiler method forwardingTreatment.

/**
 * Compares tag type between ingress and egress point and generate
 * treatment for egress point of intent.
 *
 * @param ingress ingress selector for the intent
 * @param egress egress selector for the intent
 * @param ethType the ethertype to use in mpls_pop
 * @return Builder of TrafficTreatment
 */
private TrafficTreatment forwardingTreatment(TrafficSelector ingress, TrafficSelector egress, EthType ethType) {
    if (ingress.equals(egress)) {
        return DefaultTrafficTreatment.emptyTreatment();
    }
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    /*
         * "null" means there is no tag for the port
         * Tag criterion will be null if port is normal connection point
         */
    Criterion ingressTagCriterion = getTagCriterion(ingress);
    Criterion egressTagCriterion = getTagCriterion(egress);
    if (ingressTagCriterion.type() != egressTagCriterion.type()) {
        /*
             * Tag type of ingress port and egress port are different.
             * Need to remove tag from ingress, then add new tag for egress.
             * Remove nothing if ingress port use VXLAN or there is no tag
             * on ingress port.
             */
        switch(ingressTagCriterion.type()) {
            case VLAN_VID:
                builder.popVlan();
                break;
            case MPLS_LABEL:
                if (copyTtl) {
                    builder.copyTtlIn();
                }
                builder.popMpls(ethType);
                break;
            default:
                break;
        }
        /*
             * Push new tag for egress port.
             */
        switch(egressTagCriterion.type()) {
            case VLAN_VID:
                builder.pushVlan();
                break;
            case MPLS_LABEL:
                builder.pushMpls();
                if (copyTtl) {
                    builder.copyTtlOut();
                }
                break;
            default:
                break;
        }
    }
    switch(egressTagCriterion.type()) {
        case VLAN_VID:
            VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) egressTagCriterion;
            builder.setVlanId(vlanIdCriterion.vlanId());
            break;
        case MPLS_LABEL:
            MplsCriterion mplsCriterion = (MplsCriterion) egressTagCriterion;
            builder.setMpls(mplsCriterion.label());
            break;
        case TUNNEL_ID:
            TunnelIdCriterion tunnelIdCriterion = (TunnelIdCriterion) egressTagCriterion;
            builder.setTunnelId(tunnelIdCriterion.tunnelId());
            break;
        default:
            break;
    }
    return builder.build();
}
Also used : TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Aggregations

TunnelIdCriterion (org.onosproject.net.flow.criteria.TunnelIdCriterion)7 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 Criterion (org.onosproject.net.flow.criteria.Criterion)3 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)3 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)3 Deque (java.util.Deque)2 Test (org.junit.Test)2 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)2 FlowRule (org.onosproject.net.flow.FlowRule)2 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)2 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)2 IPDscpCriterion (org.onosproject.net.flow.criteria.IPDscpCriterion)2 IPEcnCriterion (org.onosproject.net.flow.criteria.IPEcnCriterion)2 IPProtocolCriterion (org.onosproject.net.flow.criteria.IPProtocolCriterion)2 IPv6ExthdrFlagsCriterion (org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion)2 IPv6FlowLabelCriterion (org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion)2 IPv6NDLinkLayerAddressCriterion (org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion)2 IPv6NDTargetAddressCriterion (org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion)2 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)2