Java Code Examples for org.onosproject.net.flow.criteria.Criterion#Type

The following examples show how to use org.onosproject.net.flow.criteria.Criterion#Type . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForwardingObjectiveTranslator.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processVersatileFwd(ForwardingObjective obj,
                                 ObjectiveTranslation.Builder resultBuilder)
        throws FabricPipelinerException {

    final Set<Criterion.Type> unsupportedCriteria = obj.selector().criteria()
            .stream()
            .map(Criterion::type)
            .filter(t -> !ACL_CRITERIA.contains(t))
            .collect(Collectors.toSet());

    if (!unsupportedCriteria.isEmpty()) {
        throw new FabricPipelinerException(format(
                "unsupported ACL criteria %s", unsupportedCriteria.toString()));
    }

    aclRule(obj, resultBuilder);
}
 
Example 2
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) {
    if (CRITERION_MAP.containsKey(type)) {
        return Optional.of(PiMatchFieldId.of(CRITERION_MAP.get(type)));
    } else {
        return Optional.empty();
    }
}
 
Example 3
Source File: InterpreterImpl.java    From ngsdn-tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) {
    if (CRITERION_MAP.containsKey(type)) {
        return Optional.of(PiMatchFieldId.of(CRITERION_MAP.get(type)));
    } else {
        return Optional.empty();
    }
}
 
Example 4
Source File: FlowObjectiveCompositionUtil.java    From onos with Apache License 2.0 5 votes vote down vote up
public static Set<Criterion.Type> getTypeSet(TrafficSelector trafficSelector) {
    Set<Criterion.Type> typeSet = new HashSet<>();
    for (Criterion criterion : trafficSelector.criteria()) {
        typeSet.add(criterion.type());
    }
    return typeSet;
}
 
Example 5
Source File: OltPipeline.java    From onos with Apache License 2.0 5 votes vote down vote up
static Optional<Criterion> readFromSelector(TrafficSelector selector, Criterion.Type type) {
    if (selector == null) {
        return Optional.empty();
    }
    Criterion criterion = selector.getCriterion(type);
    return (criterion == null)
            ? Optional.empty() : Optional.of(criterion);
}
 
Example 6
Source File: CriterionCodecTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that all criterion types are covered by the codec.
 */
@Test
public void checkCriterionTypes() throws Exception {
    EncodeCriterionCodecHelper encoder = new EncodeCriterionCodecHelper(
            Criteria.dummy(), context);
    EnumMap<Criterion.Type, Object> formatMap =
            getField(encoder, "formatMap");
    assertThat(formatMap, notNullValue());

    for (Criterion.Type type : Criterion.Type.values()) {
        assertThat("Entry not found for " + type.toString(),
                formatMap.get(type), notNullValue());
    }
}
 
Example 7
Source File: PipelineInterpreterImpl.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) {
    return Optional.ofNullable(CRITERION_MAP.get(type));
}
 
Example 8
Source File: EncodeCriterionCodecHelper.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an encoder object for a criterion.
 * Initializes the formatter lookup map for the criterion subclasses.
 *
 * @param criterion Criterion to encode
 * @param context   context of the JSON encoding
 */
public EncodeCriterionCodecHelper(Criterion criterion, CodecContext context) {
    this.criterion = criterion;
    this.context = context;

    formatMap = new EnumMap<>(Criterion.Type.class);

    formatMap.put(Criterion.Type.IN_PORT, new FormatInPort());
    formatMap.put(Criterion.Type.IN_PHY_PORT, new FormatInPort());
    formatMap.put(Criterion.Type.METADATA, new FormatMetadata());
    formatMap.put(Criterion.Type.ETH_DST, new FormatEth());
    formatMap.put(Criterion.Type.ETH_DST_MASKED, new FormatEthMasked());
    formatMap.put(Criterion.Type.ETH_SRC, new FormatEth());
    formatMap.put(Criterion.Type.ETH_TYPE, new FormatEthType());
    formatMap.put(Criterion.Type.VLAN_VID, new FormatVlanVid());
    formatMap.put(Criterion.Type.VLAN_PCP, new FormatVlanPcp());
    formatMap.put(Criterion.Type.INNER_VLAN_VID, new FormatInnerVlanVid());
    formatMap.put(Criterion.Type.INNER_VLAN_PCP, new FormatInnerVlanPcp());
    formatMap.put(Criterion.Type.IP_DSCP, new FormatIpDscp());
    formatMap.put(Criterion.Type.IP_ECN, new FormatIpEcn());
    formatMap.put(Criterion.Type.IP_PROTO, new FormatIpProto());
    formatMap.put(Criterion.Type.IPV4_SRC, new FormatIp());
    formatMap.put(Criterion.Type.IPV4_DST, new FormatIp());
    formatMap.put(Criterion.Type.TCP_SRC, new FormatTcp());
    formatMap.put(Criterion.Type.TCP_SRC_MASKED, new FormatTcpMask());
    formatMap.put(Criterion.Type.TCP_DST, new FormatTcp());
    formatMap.put(Criterion.Type.TCP_DST_MASKED, new FormatTcpMask());
    formatMap.put(Criterion.Type.UDP_SRC, new FormatUdp());
    formatMap.put(Criterion.Type.UDP_SRC_MASKED, new FormatUdpMask());
    formatMap.put(Criterion.Type.UDP_DST, new FormatUdp());
    formatMap.put(Criterion.Type.UDP_DST_MASKED, new FormatUdpMask());
    formatMap.put(Criterion.Type.SCTP_SRC, new FormatSctp());
    formatMap.put(Criterion.Type.SCTP_SRC_MASKED, new FormatSctpMask());
    formatMap.put(Criterion.Type.SCTP_DST, new FormatSctp());
    formatMap.put(Criterion.Type.SCTP_DST_MASKED, new FormatSctpMask());
    formatMap.put(Criterion.Type.ICMPV4_TYPE, new FormatIcmpV4Type());
    formatMap.put(Criterion.Type.ICMPV4_CODE, new FormatIcmpV4Code());
    formatMap.put(Criterion.Type.IPV6_SRC, new FormatIp());
    formatMap.put(Criterion.Type.IPV6_DST, new FormatIp());
    formatMap.put(Criterion.Type.IPV6_FLABEL, new FormatIpV6FLabel());
    formatMap.put(Criterion.Type.ICMPV6_TYPE, new FormatIcmpV6Type());
    formatMap.put(Criterion.Type.ICMPV6_CODE, new FormatIcmpV6Code());
    formatMap.put(Criterion.Type.IPV6_ND_TARGET, new FormatV6NDTarget());
    formatMap.put(Criterion.Type.IPV6_ND_SLL, new FormatV6NDTll());
    formatMap.put(Criterion.Type.IPV6_ND_TLL, new FormatV6NDTll());
    formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel());
    formatMap.put(Criterion.Type.MPLS_BOS, new FormatMplsBos());
    formatMap.put(Criterion.Type.IPV6_EXTHDR, new FormatIpV6Exthdr());
    formatMap.put(Criterion.Type.OCH_SIGID, new FormatOchSigId());
    formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType());
    formatMap.put(Criterion.Type.TUNNEL_ID, new FormatTunnelId());
    formatMap.put(Criterion.Type.DUMMY, new FormatDummyType());
    formatMap.put(Criterion.Type.ODU_SIGID, new FormatOduSignalId());
    formatMap.put(Criterion.Type.ODU_SIGTYPE, new FormatOduSignalType());
    formatMap.put(Criterion.Type.PROTOCOL_INDEPENDENT, new FormatProtocolIndependent());
    formatMap.put(Criterion.Type.EXTENSION, new FormatExtension());
    // Currently unimplemented
    formatMap.put(Criterion.Type.ARP_OP, new FormatUnknown());
    formatMap.put(Criterion.Type.ARP_SPA, new FormatUnknown());
    formatMap.put(Criterion.Type.ARP_TPA, new FormatUnknown());
    formatMap.put(Criterion.Type.ARP_SHA, new FormatUnknown());
    formatMap.put(Criterion.Type.ARP_THA, new FormatUnknown());
    formatMap.put(Criterion.Type.MPLS_TC, new FormatUnknown());
    formatMap.put(Criterion.Type.PBB_ISID, new FormatUnknown());
    formatMap.put(Criterion.Type.UNASSIGNED_40, new FormatUnknown());
    formatMap.put(Criterion.Type.PBB_UCA, new FormatUnknown());
    formatMap.put(Criterion.Type.TCP_FLAGS, new FormatUnknown());
    formatMap.put(Criterion.Type.ACTSET_OUTPUT, new FormatUnknown());
    formatMap.put(Criterion.Type.PACKET_TYPE, new FormatUnknown());
    formatMap.put(Criterion.Type.ETH_SRC_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.TCP_SRC_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.TCP_DST_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.UDP_SRC_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.UDP_DST_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.SCTP_SRC_MASKED, new FormatUnknown());
    formatMap.put(Criterion.Type.SCTP_DST_MASKED, new FormatUnknown());

}
 
Example 9
Source File: BasicInterpreterImpl.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) {
    return Optional.ofNullable(CRITERION_MAP.get(type));
}
 
Example 10
Source File: FabricInterpreter.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<PiMatchFieldId> mapCriterionType(Criterion.Type type) {
    return Optional.ofNullable(CRITERION_MAP.get(type));
}
 
Example 11
Source File: FabricUtils.java    From onos with Apache License 2.0 4 votes vote down vote up
public static Criterion criterionNotNull(Collection<Criterion> criteria, Criterion.Type type) {
    return checkNotNull(criterion(criteria, type),
                        format("%s criterion cannot be null", type));
}
 
Example 12
Source File: FabricUtils.java    From onos with Apache License 2.0 4 votes vote down vote up
public static Criterion criterionNotNull(TrafficSelector selector, Criterion.Type type) {
    return checkNotNull(criterion(selector, type),
                        format("%s criterion cannot be null", type));
}
 
Example 13
Source File: FabricUtils.java    From onos with Apache License 2.0 4 votes vote down vote up
public static Criterion criterion(TrafficSelector selector, Criterion.Type type) {
    return selector.getCriterion(type);
}
 
Example 14
Source File: FabricUtils.java    From onos with Apache License 2.0 4 votes vote down vote up
public static Criterion criterion(Collection<Criterion> criteria, Criterion.Type type) {
    return criteria.stream()
            .filter(c -> c.type().equals(type))
            .findFirst().orElse(null);
}
 
Example 15
Source File: OltPipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
private Criterion filterForCriterion(Collection<Criterion> criteria, Criterion.Type type) {
    return criteria.stream()
            .filter(c -> c.type().equals(type))
            .limit(1)
            .findFirst().orElse(null);
}
 
Example 16
Source File: NokiaOltPipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
private Criterion filterForCriterion(Collection<Criterion> criteria, Criterion.Type type) {
    return criteria.stream()
            .filter(c -> c.type().equals(type))
            .limit(1)
            .findFirst().orElse(null);
}
 
Example 17
Source File: DefaultTrafficSelectorTest.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a criterion type matcher.  Returns a matcher
 * for a criterion with the given type.
 *
 * @param type type of Criterion to match
 * @return Matcher object
 */
@Factory
public static Matcher<TrafficSelector> hasCriterionWithType(Criterion.Type type) {
    return new CriterionExistsMatcher(type);
}
 
Example 18
Source File: TsLoopPacket.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a packet header field value by the designated header type.
 *
 * Returns null if the field does not exist.
 *
 * @param criterionType as packet header type
 * @return the packet header field value; may be null
 */
public Criterion getHeader(Criterion.Type criterionType) {
    return match.get(criterionType);
}
 
Example 19
Source File: TsLoopPacket.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Returns true if there is the type of header field in the packet.
 *
 * @param criterionType packet header type
 * @return true if the field exists; false otherwise
 */
public boolean headerExists(Criterion.Type criterionType) {
    return match.containsKey(criterionType);
}
 
Example 20
Source File: FlowRuleCodecTest.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Looks up a criterion in the instruction map based on type and subtype.
 *
 * @param type type string
 * @return criterion that matches
 */
private Criterion getCriterion(Criterion.Type type) {
    Criterion criterion = criteria.get(type.name());
    assertThat(criterion.type(), is(type));
    return criterion;
}