当前位置: 首页>>代码示例>>Java>>正文


Java PortNumber.CONTROLLER属性代码示例

本文整理汇总了Java中org.onosproject.net.PortNumber.CONTROLLER属性的典型用法代码示例。如果您正苦于以下问题:Java PortNumber.CONTROLLER属性的具体用法?Java PortNumber.CONTROLLER怎么用?Java PortNumber.CONTROLLER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.onosproject.net.PortNumber的用法示例。


在下文中一共展示了PortNumber.CONTROLLER属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processVersatile

@Override
protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.info("Processing versatile forwarding objective");

    EthTypeCriterion ethType =
            (EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null) {
        log.error("Versatile forwarding objective must include ethType");
        fail(fwd, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    if (fwd.nextId() == null && fwd.treatment() == null) {
        log.error("Forwarding objective {} from {} must contain "
                + "nextId or Treatment", fwd.selector(), fwd.appId());
        return Collections.emptySet();
    }

    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
    fwd.selector().criteria().forEach(criterion -> {
        if (criterion instanceof VlanIdCriterion) {
            // avoid matching on vlans
            return;
        } else {
            sbuilder.add(criterion);
        }
    });

    // XXX driver does not currently do type checking as per Tables 65-67 in
    // OFDPA 2.0 spec. The only allowed treatment is a punt to the controller.
    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    if (fwd.treatment() != null) {
        for (Instruction ins : fwd.treatment().allInstructions()) {
            if (ins instanceof OutputInstruction) {
                OutputInstruction o = (OutputInstruction) ins;
                if (o.port() == PortNumber.CONTROLLER) {
                    // emulating real ofdpa behavior by popping off internal
                    // vlan before sending to controller
                    ttBuilder.popVlan();
                    ttBuilder.add(o);
                } else {
                    log.warn("Only allowed treatments in versatile forwarding "
                            + "objectives are punts to the controller");
                }
            } else {
                log.warn("Cannot process instruction in versatile fwd {}", ins);
            }
        }
    }
    if (fwd.nextId() != null) {
        // overide case
        NextGroup next = getGroupForNextObjective(fwd.nextId());
        List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
        // we only need the top level group's key to point the flow to it
        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(), fwd.nextId(), deviceId);
            fail(fwd, ObjectiveError.GROUPMISSING);
            return Collections.emptySet();
        }
        ttBuilder.deferred().group(group.id());
    }

    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
            .fromApp(fwd.appId())
            .withPriority(fwd.priority())
            .forDevice(deviceId)
            .withSelector(sbuilder.build())
            .withTreatment(ttBuilder.build())
            .makePermanent()
            .forTable(ACL_TABLE);
    return Collections.singletonList(ruleBuilder.build());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:73,代码来源:CpqdOfdpa2Pipeline.java

示例2: processVersatile

@Override
protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
    log.info("Processing versatile forwarding objective");

    EthTypeCriterion ethType =
            (EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType == null) {
        log.error("Versatile forwarding objective must include ethType");
        fail(fwd, ObjectiveError.BADPARAMS);
        return Collections.emptySet();
    }
    if (fwd.nextId() == null && fwd.treatment() == null) {
        log.error("Forwarding objective {} from {} must contain "
                + "nextId or Treatment", fwd.selector(), fwd.appId());
        return Collections.emptySet();
    }

    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
    fwd.selector().criteria().forEach(criterion -> {
        if (criterion instanceof VlanIdCriterion) {
            VlanId vlanId = ((VlanIdCriterion) criterion).vlanId();
            // ensure that match does not include vlan = NONE as OF-DPA does not
            // match untagged packets this way in the ACL table.
            if (vlanId.equals(VlanId.NONE)) {
                return;
            }
        }
        sbuilder.add(criterion);
    });

    // XXX driver does not currently do type checking as per Tables 65-67 in
    // OFDPA 2.0 spec. The only allowed treatment is a punt to the controller.
    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    if (fwd.treatment() != null) {
        for (Instruction ins : fwd.treatment().allInstructions()) {
            if (ins instanceof OutputInstruction) {
                OutputInstruction o = (OutputInstruction) ins;
                if (o.port() == PortNumber.CONTROLLER) {
                    ttBuilder.add(o);
                } else {
                    log.warn("Only allowed treatments in versatile forwarding "
                            + "objectives are punts to the controller");
                }
            } else {
                log.warn("Cannot process instruction in versatile fwd {}", ins);
            }
        }
    }
    if (fwd.nextId() != null) {
        // overide case
        NextGroup next = getGroupForNextObjective(fwd.nextId());
        List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
        // we only need the top level group's key to point the flow to it
        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(), fwd.nextId(), deviceId);
            fail(fwd, ObjectiveError.GROUPMISSING);
            return Collections.emptySet();
        }
        ttBuilder.deferred().group(group.id());
    }

    FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
            .fromApp(fwd.appId())
            .withPriority(fwd.priority())
            .forDevice(deviceId)
            .withSelector(sbuilder.build())
            .withTreatment(ttBuilder.build())
            .makePermanent()
            .forTable(ACL_TABLE);
    return Collections.singletonList(ruleBuilder.build());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:73,代码来源:CpqdOfdpa2VlanPipeline.java


注:本文中的org.onosproject.net.PortNumber.CONTROLLER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。