Search in sources :

Example 1 with PiCriterion

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

the class CriterionCodecTest method matchPiTypeDecodingTest.

/**
 * Tests protocol-independent type criterion decoding.
 */
@Test
public void matchPiTypeDecodingTest() throws IOException {
    Criterion criterion = getCriterion("PiCriterion.json");
    Assert.assertThat(criterion.type(), is(Criterion.Type.PROTOCOL_INDEPENDENT));
    Collection<PiFieldMatch> piFieldMatches = ((PiCriterion) criterion).fieldMatches();
    for (PiFieldMatch piFieldMatch : piFieldMatches) {
        switch(piFieldMatch.type()) {
            case EXACT:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("ingress_port"));
                Assert.assertThat(((PiExactFieldMatch) piFieldMatch).value(), is(copyFrom((byte) 0x10)));
                break;
            case LPM:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("src_addr"));
                Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
                Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).prefixLength(), is(24));
                break;
            case TERNARY:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("dst_addr"));
                Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
                Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).mask(), is(copyFrom(0xfffffff)));
                break;
            case RANGE:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("egress_port"));
                Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).highValue(), is(copyFrom((byte) 0x20)));
                Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).lowValue(), is(copyFrom((byte) 0x10)));
                break;
            case OPTIONAL:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("eth_dst"));
                Assert.assertThat(((PiOptionalFieldMatch) piFieldMatch).value(), is(copyFrom(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 })));
                break;
            default:
                Assert.fail();
        }
    }
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) PiFieldMatch(org.onosproject.net.pi.runtime.PiFieldMatch) Test(org.junit.Test)

Example 2 with PiCriterion

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

the class IntProgrammableImpl method populateInstTableEntry.

private void populateInstTableEntry(PiTableId tableId, PiMatchFieldId matchFieldId, int matchValue, PiActionId actionId, ApplicationId appId) {
    PiCriterion instCriterion = PiCriterion.builder().matchExact(matchFieldId, matchValue).build();
    TrafficSelector instSelector = DefaultTrafficSelector.builder().matchPi(instCriterion).build();
    PiAction instAction = PiAction.builder().withId(actionId).build();
    TrafficTreatment instTreatment = DefaultTrafficTreatment.builder().piTableAction(instAction).build();
    FlowRule instFlowRule = DefaultFlowRule.builder().withSelector(instSelector).withTreatment(instTreatment).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(tableId).fromApp(appId).build();
    flowRuleService.applyFlowRules(instFlowRule);
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 3 with PiCriterion

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

the class FabricIntProgrammable method setSourcePort.

@Override
public boolean setSourcePort(PortNumber port) {
    if (!setupBehaviour()) {
        return false;
    }
    PiCriterion ingressCriterion = PiCriterion.builder().matchExact(FabricConstants.HDR_IG_PORT, port.toLong()).build();
    TrafficSelector srcSelector = DefaultTrafficSelector.builder().matchPi(ingressCriterion).build();
    PiAction setSourceAct = PiAction.builder().withId(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_INT_SET_SOURCE).build();
    TrafficTreatment srcTreatment = DefaultTrafficTreatment.builder().piTableAction(setSourceAct).build();
    FlowRule srcFlowRule = DefaultFlowRule.builder().withSelector(srcSelector).withTreatment(srcTreatment).fromApp(appId).withPriority(DEFAULT_PRIORITY).makePermanent().forDevice(deviceId).forTable(FabricConstants.FABRIC_INGRESS_PROCESS_SET_SOURCE_SINK_TB_SET_SOURCE).build();
    flowRuleService.applyFlowRules(srcFlowRule);
    return true;
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Example 4 with PiCriterion

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

the class FabricBngProgrammable method setupPuntToCpu.

/**
 * Set the punt to CPU rules of the BNG from a specific Application ID.
 *
 * @param appId Application ID asking to recive BNG control plane packets.
 */
private void setupPuntToCpu(ApplicationId appId) {
    for (Criterion c : PuntCpuCriterionFactory.getAllPuntCriterion()) {
        FlowRule flPuntCpu = buildTPppoeCpFlowRule((PiCriterion) c, appId);
        flowRuleService.applyFlowRules(flPuntCpu);
    }
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule)

Example 5 with PiCriterion

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

the class NextObjectiveTranslator method egressVlan.

private void egressVlan(PortNumber outPort, NextObjective obj, Instruction popVlanInst, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException {
    final VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) criterion(obj.meta(), Criterion.Type.VLAN_VID);
    final PiCriterion egressVlanTableMatch = PiCriterion.builder().matchExact(FabricConstants.HDR_EG_PORT, outPort.toLong()).build();
    final TrafficSelector selector = DefaultTrafficSelector.builder().matchPi(egressVlanTableMatch).matchVlanId(vlanIdCriterion.vlanId()).build();
    final TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    if (popVlanInst == null) {
        treatmentBuilder.pushVlan();
    } else {
        treatmentBuilder.popVlan();
    }
    resultBuilder.addFlowRule(flowRule(obj, FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN, selector, treatmentBuilder.build()));
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Aggregations

PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)23 TrafficSelector (org.onosproject.net.flow.TrafficSelector)19 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)18 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)18 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)17 PiAction (org.onosproject.net.pi.runtime.PiAction)16 FlowRule (org.onosproject.net.flow.FlowRule)12 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)11 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)10 Test (org.junit.Test)5 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)5 NextObjective (org.onosproject.net.flowobjective.NextObjective)5 Criterion (org.onosproject.net.flow.criteria.Criterion)3 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)3 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)3 GroupBucket (org.onosproject.net.group.GroupBucket)3 GroupBuckets (org.onosproject.net.group.GroupBuckets)3 GroupDescription (org.onosproject.net.group.GroupDescription)3 PiMatchFieldId (org.onosproject.net.pi.model.PiMatchFieldId)3 PiTableId (org.onosproject.net.pi.model.PiTableId)3