Java 类org.projectfloodlight.openflow.protocol.oxm.OFOxm 实例源码

项目:athena    文件:OfdpaExtensionTreatmentInterpreter.java   
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.SET_FIELD)) {
        OFActionSetField setFieldAction = (OFActionSetField) action;
        OFOxm<?> oxm = setFieldAction.getField();
        switch (oxm.getMatchField().id) {
            case VLAN_VID:
                OFOxmVlanVid vlanVid = (OFOxmVlanVid) oxm;
                return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid.getValue().getRawVid()));
            default:
                throw new UnsupportedOperationException(
                        "Driver does not support extension type " + oxm.getMatchField().id);
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected OFAction: " + action.toString());
}
项目:athena    文件:OfdpaExtensionSelectorInterpreter.java   
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected ExtensionSelector: " + extensionSelector.toString());
}
项目:athena    文件:FlowModBuilder.java   
private OFOxm buildExtensionOxm(ExtensionSelector extension) {
    if (!driverService.isPresent()) {
        log.error("No driver service present");
        return null;
    }
    Driver driver = driverService.get().getDriver(deviceId);
    if (driver.hasBehaviour(ExtensionSelectorInterpreter.class)) {
        DefaultDriverHandler handler =
                new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
        ExtensionSelectorInterpreter interpreter = handler.behaviour(ExtensionSelectorInterpreter.class);

        return interpreter.mapSelector(factory(), extension);
    }

    return null;
}
项目:athena    文件:FlowModBuilderVer13.java   
private OFAction buildL1Modification(Instruction i) {
    L1ModificationInstruction l1m = (L1ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l1m.subtype()) {
    case ODU_SIGID:
        ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m;
        OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId();

        OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(),
                (short) oduSignalId.tributarySlotLength(),
                oduSignalId.tributarySlotBitmap());

        oxm = factory().oxms().expOduSigId(oduSignalID);
        break;
    default:
        log.warn("Unimplemented action type {}.", l1m.subtype());
        break;
    }

    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:openflowj-otn    文件:OFOxmList.java   
public static OFOxmList ofList(Iterable<OFOxm<?>> oxmList) {
    Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
            MatchFields.class);
    for (OFOxm<?> o : oxmList) {
        OFOxm<?> canonical = o.getCanonical();

        if(logger.isDebugEnabled() && !Objects.equal(o, canonical)) {
            logger.debug("OFOxmList: normalized non-canonical OXM {} to {}", o, canonical);
        }

        if(canonical != null)
            map.put(canonical.getMatchField().id, canonical);

    }
    return new OFOxmList(map);
}
项目:Engine    文件:FlowModBuilder.java   
private OFOxm buildExtensionOxm(ExtensionSelector extension) {
    if (!driverService.isPresent()) {
        log.error("No driver service present");
        return null;
    }
    Driver driver = driverService.get().getDriver(deviceId);
    if (driver.hasBehaviour(ExtensionSelectorInterpreter.class)) {
        DefaultDriverHandler handler =
                new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
        ExtensionSelectorInterpreter interpreter = handler.behaviour(ExtensionSelectorInterpreter.class);

        return interpreter.mapSelector(factory(), extension);
    }

    return null;
}
项目:Engine    文件:FlowModBuilderVer13.java   
private OFAction buildL1Modification(Instruction i) {
    L1ModificationInstruction l1m = (L1ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l1m.subtype()) {
    case ODU_SIGID:
        ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m;
        OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId();

        OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(),
                (short) oduSignalId.tributarySlotLength(),
                oduSignalId.tributarySlotBitmap());

        oxm = factory().oxms().expOduSigId(oduSignalID);
        break;
    default:
        log.warn("Unimplemented action type {}.", l1m.subtype());
        break;
    }

    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:onos    文件:OfdpaExtensionTreatmentInterpreter.java   
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.SET_FIELD)) {
        OFActionSetField setFieldAction = (OFActionSetField) action;
        OFOxm<?> oxm = setFieldAction.getField();
        switch (oxm.getMatchField().id) {
            case VLAN_VID:
                OFOxmVlanVid vlanVid = (OFOxmVlanVid) oxm;
                return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid.getValue().getRawVid()));
            default:
                throw new UnsupportedOperationException(
                        "Driver does not support extension type " + oxm.getMatchField().id);
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected OFAction: " + action.toString());
}
项目:onos    文件:OfdpaExtensionSelectorInterpreter.java   
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected ExtensionSelector: " + extensionSelector.toString());
}
项目:onos    文件:FlowModBuilder.java   
private OFOxm buildExtensionOxm(ExtensionSelector extension) {
    if (!driverService.isPresent()) {
        log.error("No driver service present");
        return null;
    }
    Driver driver = driverService.get().getDriver(deviceId);
    if (driver.hasBehaviour(ExtensionSelectorInterpreter.class)) {
        DefaultDriverHandler handler =
                new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
        ExtensionSelectorInterpreter interpreter = handler.behaviour(ExtensionSelectorInterpreter.class);

        return interpreter.mapSelector(factory(), extension);
    }

    return null;
}
项目:onos    文件:FlowModBuilderVer13.java   
protected OFAction buildL1Modification(Instruction i) {
    L1ModificationInstruction l1m = (L1ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l1m.subtype()) {
    case ODU_SIGID:
        ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m;
        OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId();

        OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(),
                (short) oduSignalId.tributarySlotLength(),
                oduSignalId.tributarySlotBitmap());

        oxm = factory().oxms().expOduSigId(oduSignalID);
        break;
    default:
        log.warn("Unimplemented action type {}.", l1m.subtype());
        break;
    }

    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:loxigen-artifacts    文件:OFOxmList.java   
public static OFOxmList ofList(Iterable<OFOxm<?>> oxmList) {
    Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
            MatchFields.class);
    for (OFOxm<?> o : oxmList) {
        OFOxm<?> canonical = o.getCanonical();

        if(logger.isDebugEnabled() && !Objects.equal(o, canonical)) {
            logger.debug("OFOxmList: normalized non-canonical OXM {} to {}", o, canonical);
        }

        if(canonical != null)
            map.put(canonical.getMatchField().id, canonical);

    }
    return new OFOxmList(map);
}
项目:athena    文件:NiciraExtensionSelectorInterpreter.java   
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();

    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
        NiciraMatchNshSpi niciraNshSpi = (NiciraMatchNshSpi) extensionSelector;
        return factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
        NiciraMatchNshSi niciraNshSi = (NiciraMatchNshSi) extensionSelector;
        return factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_ENCAP_ETH_TYPE.type())) {
        NiciraMatchEncapEthType niciraEncapEthType = (NiciraMatchEncapEthType) extensionSelector;
        return factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
        // TODO
    }
    return null;
}
项目:athena    文件:FlowModBuilderVer13.java   
private OFAction buildL0Modification(Instruction i) {
    L0ModificationInstruction l0m = (L0ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l0m.subtype()) {
        case OCH:
            try {
                ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m;
                OchSignal signal = modOchSignalInstruction.lambda();
                byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
                byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
                oxm = factory().oxms().expOchSigId(
                        new CircuitSignalID(gridType, channelSpacing,
                                (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
            } catch (NoMappingFoundException e) {
                log.warn(e.getMessage());
                break;
            }
            break;
        default:
            log.warn("Unimplemented action type {}.", l0m.subtype());
            break;
    }
    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:openflowj-otn    文件:OFOxmList.java   
public static OFOxmList of(OFOxm<?>... oxms) {
    Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
            MatchFields.class);
    for (OFOxm<?> o : oxms) {
        OFOxm<?> canonical = o.getCanonical();

        if(logger.isDebugEnabled() && !Objects.equal(o, canonical)) {
            logger.debug("OFOxmList: normalized non-canonical OXM {} to {}", o, canonical);
        }

        if(canonical != null)
            map.put(canonical.getMatchField().id, canonical);
    }
    return new OFOxmList(map);
}
项目:Engine    文件:FlowModBuilderVer13.java   
private OFAction buildL0Modification(Instruction i) {
    L0ModificationInstruction l0m = (L0ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l0m.subtype()) {
        case OCH:
            try {
                ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m;
                OchSignal signal = modOchSignalInstruction.lambda();
                byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
                byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
                oxm = factory().oxms().expOchSigId(
                        new CircuitSignalID(gridType, channelSpacing,
                                (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
            } catch (NoMappingFoundException e) {
                log.warn(e.getMessage());
                break;
            }
            break;
        default:
            log.warn("Unimplemented action type {}.", l0m.subtype());
            break;
    }
    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:onos    文件:Ofdpa3ExtensionSelectorInterpreter.java   
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorTypes.OFDPA_MATCH_OVID.type())) {
        VlanId vlanId = ((Ofdpa3MatchOvid) extensionSelector).vlanId();
        if (vlanId.equals(VlanId.NONE)) {
            throw new UnsupportedOperationException(
                    "Unexpected ExtensionSelector: " + extensionSelector.toString());
        } else if (vlanId.equals(VlanId.ANY)) {
            throw new UnsupportedOperationException(
                    "Unexpected ExtensionSelector: " + extensionSelector.toString());
        } else {
            short mask = (short) 0x1000;
            short oVid = (short) (mask | vlanId.toShort());
            return factory.oxms().ofdpaOvid(U16.ofRaw(oVid));
        }
    } else if (type.equals(ExtensionSelectorTypes.OFDPA_MATCH_MPLS_L2_PORT.type())) {
        int mplsL2Port = ((Ofdpa3MatchMplsL2Port) extensionSelector).mplsL2Port();
        /*
         * 0x0000XXXX UNI Interface.
         * 0x0002XXXX NNI Interface
         */
        if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) ||
                (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
            return factory.oxms().ofdpaMplsL2Port(U32.ofRaw(mplsL2Port));
        }
        throw new UnsupportedOperationException(
                    "Unexpected ExtensionSelector: " + extensionSelector.toString());
    }
    throw new UnsupportedOperationException(
            "Unexpected ExtensionSelector: " + extensionSelector.toString());
}
项目:onos    文件:Ofdpa3ExtensionSelectorInterpreter.java   
@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
    if (oxm.getMatchField().equals(MatchField.OFDPA_OVID)) {
        VlanId vlanId;
        if (oxm.isMasked()) {
            throw new UnsupportedOperationException(
                    "Unexpected OXM: " + oxm.toString());
        } else {
            OFOxmOfdpaOvid ovid = ((OFOxmOfdpaOvid) oxm);
            short mask = (short) 0x0FFF;
            short oVid = (short) (mask & ovid.getValue().getRaw());
            vlanId = VlanId.vlanId(oVid);
            }
        return new Ofdpa3MatchOvid(vlanId);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_MPLS_L2_PORT)) {
        Integer mplsL2Port;
        /*
         * Supported but not used for now.
         */
        if (oxm.isMasked()) {
            throw new UnsupportedOperationException(
                    "Unexpected OXM: " + oxm.toString());
        } else {
            OFOxmOfdpaMplsL2Port mplsl2port = ((OFOxmOfdpaMplsL2Port) oxm);
            mplsL2Port = mplsl2port.getValue().getRaw();
            /*
             * 0x0000XXXX UNI Interface.
             * 0x0002XXXX NNI Interface
             */
            if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) ||
                    (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
                return new Ofdpa3MatchMplsL2Port(mplsL2Port);
            }
            throw new UnsupportedOperationException(
                    "Unexpected OXM: " + oxm.toString());
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected OXM: " + oxm.toString());
}
项目:onos    文件:OplinkExtensionTreatmentInterpreter.java   
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.EXPERIMENTER)) {
        OFActionExperimenter actionExp = (OFActionExperimenter) action;
        if (actionExp.getExperimenter() == ATTENUATION_EXP) {
            OFActionOplinkAtt actionAtt = (OFActionOplinkAtt) action;
            return new OplinkAttenuation(((OFOxm<U32>) actionAtt.getField()).getValue().getRaw());
        }
    }
    return null;
}
项目:onos    文件:FlowModBuilderVer13.java   
protected OFAction buildL0Modification(Instruction i) {
    L0ModificationInstruction l0m = (L0ModificationInstruction) i;
    OFOxm<?> oxm = null;
    switch (l0m.subtype()) {
        case OCH:
            try {
                ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m;
                OchSignal signal = modOchSignalInstruction.lambda();
                byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
                byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
                oxm = factory().oxms().expOchSigId(
                        new CircuitSignalID(gridType, channelSpacing,
                                (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
            } catch (NoMappingFoundException e) {
                log.warn(e.getMessage());
                break;
            }
            break;
        default:
            log.warn("Unimplemented action type {}.", l0m.subtype());
            break;
    }
    if (oxm != null) {
        return factory().actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:loxigen-artifacts    文件:OFOxmList.java   
public static OFOxmList of(OFOxm<?>... oxms) {
    Map<MatchFields, OFOxm<?>> map = new EnumMap<MatchFields, OFOxm<?>>(
            MatchFields.class);
    for (OFOxm<?> o : oxms) {
        OFOxm<?> canonical = o.getCanonical();

        if(logger.isDebugEnabled() && !Objects.equal(o, canonical)) {
            logger.debug("OFOxmList: normalized non-canonical OXM {} to {}", o, canonical);
        }

        if(canonical != null)
            map.put(canonical.getMatchField().id, canonical);
    }
    return new OFOxmList(map);
}
项目:loxigen-artifacts    文件:OFOxmTest.java   
@Test
public void testGetCanonicalNoMask() {
    IPv4AddressWithMask fullIp = IPv4AddressWithMask.of("1.2.3.4/32");
    assertEquals(IPv4Address.NO_MASK, fullIp.getMask());
    OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(fullIp.getValue(), fullIp.getMask());
    assertTrue(ipv4SrcMasked.isMasked());
    assertEquals(IPv4Address.NO_MASK, ipv4SrcMasked.getMask());

    // canonicalize should convert the masked oxm to the non-masked one
    OFOxm<IPv4Address> canonical = ipv4SrcMasked.getCanonical();
    assertThat(canonical, CoreMatchers.instanceOf(OFOxmIpv4Src.class));
    assertFalse(canonical.isMasked());
}
项目:loxigen-artifacts    文件:OFOxmTest.java   
@Test
public void testGetCanonicalNormalMask() {
    IPv4AddressWithMask ip = IPv4AddressWithMask.of("1.2.3.0/24");
    OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(ip.getValue(), ip.getMask());
    assertTrue(ipv4SrcMasked.isMasked());

    // canonicalize should convert the masked oxm to the non-masked one
    OFOxm<IPv4Address> canonical = ipv4SrcMasked.getCanonical();
    assertEquals(ipv4SrcMasked, canonical);
}
项目:athena    文件:GroupModBuilder.java   
private OFAction buildL2Modification(Instruction i) {
    L2ModificationInstruction l2m = (L2ModificationInstruction) i;
    L2ModificationInstruction.ModEtherInstruction eth;
    OFOxm<?> oxm = null;
    switch (l2m.subtype()) {
        case ETH_DST:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethDst(MacAddress.of(eth.mac().toLong()));
            break;
        case ETH_SRC:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethSrc(MacAddress.of(eth.mac().toLong()));
            break;
        case VLAN_ID:
            L2ModificationInstruction.ModVlanIdInstruction vlanId =
                    (L2ModificationInstruction.ModVlanIdInstruction) l2m;
            oxm = factory.oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
            break;
        case VLAN_PCP:
            L2ModificationInstruction.ModVlanPcpInstruction vlanPcp =
                    (L2ModificationInstruction.ModVlanPcpInstruction) l2m;
            oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
            break;
        case VLAN_POP:
            return factory.actions().popVlan();
        case VLAN_PUSH:
            L2ModificationInstruction.PushHeaderInstructions pushVlanInstruction
                    = (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().pushVlan(
                    EthType.of(pushVlanInstruction.ethernetType().toShort()));
        case MPLS_PUSH:
            L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions =
                    (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().pushMpls(EthType.of(pushHeaderInstructions
                                                         .ethernetType().toShort()));
        case MPLS_POP:
            L2ModificationInstruction.PushHeaderInstructions popHeaderInstructions =
                    (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().popMpls(EthType.of(popHeaderInstructions
                                                        .ethernetType().toShort()));
        case MPLS_LABEL:
            L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
                    (L2ModificationInstruction.ModMplsLabelInstruction) l2m;
            oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label().toInt()));
            break;
        case MPLS_BOS:
            L2ModificationInstruction.ModMplsBosInstruction mplsBos =
                    (L2ModificationInstruction.ModMplsBosInstruction) l2m;
            oxm = factory.oxms()
                    .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE
                                               : OFBooleanValue.FALSE);
            break;
        case DEC_MPLS_TTL:
            return factory.actions().decMplsTtl();
        case TUNNEL_ID:
            L2ModificationInstruction.ModTunnelIdInstruction tunnelId =
                    (L2ModificationInstruction.ModTunnelIdInstruction) l2m;
            oxm = factory.oxms().tunnelId(U64.of(tunnelId.tunnelId()));
            break;
        default:
            log.warn("Unimplemented action type {}.", l2m.subtype());
            break;
    }

    if (oxm != null) {
        return factory.actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:athena    文件:GroupModBuilder.java   
private OFAction buildL3Modification(Instruction i) {
    L3ModificationInstruction l3m = (L3ModificationInstruction) i;
    L3ModificationInstruction.ModIPInstruction ip;
    Ip4Address ip4;
    Ip6Address ip6;
    OFOxm<?> oxm = null;
    switch (l3m.subtype()) {
        case IPV4_SRC:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory.oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
            break;
        case IPV4_DST:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory.oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
            break;
        case IPV6_SRC:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory.oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_DST:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory.oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_FLABEL:
            L3ModificationInstruction.ModIPv6FlowLabelInstruction flowLabelInstruction =
                (L3ModificationInstruction.ModIPv6FlowLabelInstruction) i;
            int flowLabel = flowLabelInstruction.flowLabel();
            oxm = factory.oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
            break;
        case DEC_TTL:
            return factory.actions().decNwTtl();
        case TTL_IN:
            return factory.actions().copyTtlIn();
        case TTL_OUT:
            return factory.actions().copyTtlOut();
        default:
            log.warn("Unimplemented action type {}.", l3m.subtype());
            break;
    }

    if (oxm != null) {
        return factory.actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:ravikumaran201504    文件:GroupModBuilder.java   
private OFAction buildL2Modification(Instruction i) {
    L2ModificationInstruction l2m = (L2ModificationInstruction) i;
    L2ModificationInstruction.ModEtherInstruction eth;
    OFOxm<?> oxm = null;
    switch (l2m.subtype()) {
        case ETH_DST:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethDst(MacAddress.of(eth.mac().toLong()));
            break;
        case ETH_SRC:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethSrc(MacAddress.of(eth.mac().toLong()));
            break;
        case VLAN_ID:
            L2ModificationInstruction.ModVlanIdInstruction vlanId =
                    (L2ModificationInstruction.ModVlanIdInstruction) l2m;
            oxm = factory.oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
            break;
        case VLAN_PCP:
            L2ModificationInstruction.ModVlanPcpInstruction vlanPcp =
                    (L2ModificationInstruction.ModVlanPcpInstruction) l2m;
            oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
            break;
        case VLAN_POP:
            return factory.actions().popVlan();
        case VLAN_PUSH:
            L2ModificationInstruction.PushHeaderInstructions pushVlanInstruction
                    = (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().pushVlan(
                    EthType.of(pushVlanInstruction.ethernetType()));
        case MPLS_PUSH:
            L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions =
                    (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().pushMpls(EthType.of(pushHeaderInstructions
                                                         .ethernetType()));
        case MPLS_POP:
            L2ModificationInstruction.PushHeaderInstructions popHeaderInstructions =
                    (L2ModificationInstruction.PushHeaderInstructions) l2m;
            return factory.actions().popMpls(EthType.of(popHeaderInstructions
                                                        .ethernetType()));
        case MPLS_LABEL:
            L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
                    (L2ModificationInstruction.ModMplsLabelInstruction) l2m;
            oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label()
                    .longValue()));
            break;
        case DEC_MPLS_TTL:
            return factory.actions().decMplsTtl();
        default:
            log.warn("Unimplemented action type {}.", l2m.subtype());
            break;
    }

    if (oxm != null) {
        return factory.actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:ravikumaran201504    文件:GroupModBuilder.java   
private OFAction buildL3Modification(Instruction i) {
    L3ModificationInstruction l3m = (L3ModificationInstruction) i;
    L3ModificationInstruction.ModIPInstruction ip;
    Ip4Address ip4;
    Ip6Address ip6;
    OFOxm<?> oxm = null;
    switch (l3m.subtype()) {
        case IPV4_SRC:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory.oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
            break;
        case IPV4_DST:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip4 = ip.ip().getIp4Address();
            oxm = factory.oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
            break;
        case IPV6_SRC:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory.oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_DST:
            ip = (L3ModificationInstruction.ModIPInstruction) i;
            ip6 = ip.ip().getIp6Address();
            oxm = factory.oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
            break;
        case IPV6_FLABEL:
            L3ModificationInstruction.ModIPv6FlowLabelInstruction flowLabelInstruction =
                (L3ModificationInstruction.ModIPv6FlowLabelInstruction) i;
            int flowLabel = flowLabelInstruction.flowLabel();
            oxm = factory.oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
            break;
        case DEC_TTL:
            return factory.actions().decNwTtl();
        case TTL_IN:
            return factory.actions().copyTtlIn();
        case TTL_OUT:
            return factory.actions().copyTtlOut();
        default:
            log.warn("Unimplemented action type {}.", l3m.subtype());
            break;
    }

    if (oxm != null) {
        return factory.actions().buildSetField().setField(oxm).build();
    }
    return null;
}
项目:openflowj-otn    文件:OFOxmList.java   
private OFOxmList(Map<MatchFields, OFOxm<?>> oxmMap) {
    this.oxmMap = oxmMap;
}
项目:openflowj-otn    文件:OFOxmList.java   
@SuppressWarnings("unchecked")
public <T extends OFValueType<T>> OFOxm<T> get(MatchField<T> matchField) {
    return (OFOxm<T>) oxmMap.get(matchField.id);
}
项目:openflowj-otn    文件:OFOxmList.java   
public Builder() {
    oxmMap = new EnumMap<MatchFields, OFOxm<?>>(MatchFields.class);
}
项目:openflowj-otn    文件:OFOxmList.java   
public Builder(EnumMap<MatchFields, OFOxm<?>> oxmMap) {
    this.oxmMap = oxmMap;
}
项目:openflowj-otn    文件:OFOxmList.java   
public <T extends OFValueType<T>> void set(OFOxm<T> oxm) {
    oxmMap.put(oxm.getMatchField().id, oxm);
}
项目:openflowj-otn    文件:OFOxmList.java   
@Override
public Iterator<OFOxm<?>> iterator() {
    return oxmMap.values().iterator();
}
项目:openflowj-otn    文件:OFOxmList.java   
public static OFOxmList readFrom(ChannelBuffer bb, int length,
        OFMessageReader<OFOxm<?>> reader) throws OFParseError {
    return ofList(ChannelUtils.readList(bb, length, reader));
}
项目:openflowj-otn    文件:OFOxmList.java   
@Override
public void writeTo(ChannelBuffer bb) {
    for (OFOxm<?> o : this) {
        o.writeTo(bb);
    }
}
项目:openflowj-otn    文件:OFOxmList.java   
public OFOxmList.Builder createBuilder() {
    return new OFOxmList.Builder(new EnumMap<MatchFields, OFOxm<?>>(oxmMap));
}
项目:openflowj-otn    文件:OFOxmList.java   
@Override
public void putTo(PrimitiveSink sink) {
    for (OFOxm<?> o : this) {
        o.putTo(sink);
    }
}
项目:onos    文件:NiciraExtensionSelectorInterpreter.java   
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();

    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
        NiciraMatchNshSpi niciraNshSpi = (NiciraMatchNshSpi) extensionSelector;
        return factory.oxms().nsp(U32.of(niciraNshSpi.nshSpi().servicePathId()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
        NiciraMatchNshSi niciraNshSi = (NiciraMatchNshSi) extensionSelector;
        return factory.oxms().nsi(U8.of(niciraNshSi.nshSi().serviceIndex()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_ENCAP_ETH_TYPE.type())) {
        NiciraMatchEncapEthType niciraEncapEthType = (NiciraMatchEncapEthType) extensionSelector;
        return factory.oxms().encapEthType(U16.of(niciraEncapEthType.encapEthType()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
        // TODO
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
        // TODO
    }

    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_STATE.type())) {
        NiciraMatchCtState niciraMatchCtState = (NiciraMatchCtState) extensionSelector;
        return factory.oxms().conntrackStateMasked(U32.of(niciraMatchCtState.ctState()),
                U32.of(niciraMatchCtState.ctStateMask()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_ZONE.type())) {
        NiciraMatchCtZone niciraMatchCtZone = (NiciraMatchCtZone) extensionSelector;
        return factory.oxms().conntrackZone(U16.of(niciraMatchCtZone.ctZone()));
    }
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_CONNTRACK_MARK.type())) {
        NiciraMatchCtMark niciraMatchCtMark = (NiciraMatchCtMark) extensionSelector;
        return factory.oxms().conntrackMark(U32.of(niciraMatchCtMark.ctMark()));
    }
    return null;
}
项目:onos    文件:Ofdpa3ExtensionTreatmentInterpreter.java   
@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.SET_FIELD)) {
        OFActionSetField setFieldAction = (OFActionSetField) action;
        OFOxm<?> oxm = setFieldAction.getField();
        switch (oxm.getMatchField().id) {
            case OFDPA_MPLS_TYPE:
                OFOxmOfdpaMplsType mplsType = (OFOxmOfdpaMplsType) oxm;
                return new Ofdpa3SetMplsType(mplsType.getValue().getRaw());
            case OFDPA_OVID:
                OFOxmOfdpaOvid ovid = ((OFOxmOfdpaOvid) oxm);
                short mask = (short) 0x0FFF;
                short oVid = (short) (mask & ovid.getValue().getRaw());
                VlanId vlanId = VlanId.vlanId(oVid);
                return new Ofdpa3SetOvid(vlanId);
            case OFDPA_MPLS_L2_PORT:
                OFOxmOfdpaMplsL2Port mplsl2Port = ((OFOxmOfdpaMplsL2Port) oxm);
                Integer mplsL2Port = mplsl2Port.getValue().getRaw();
                if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) ||
                        (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
                    return new Ofdpa3SetMplsL2Port(mplsL2Port);
                }
                break;
            case OFDPA_QOS_INDEX:
                OFOxmOfdpaQosIndex qosindex = ((OFOxmOfdpaQosIndex) oxm);
                Integer qosIndex = (int) qosindex.getValue().getRaw();
                if (qosIndex >= 0 && qosIndex <= 255) {
                    return new Ofdpa3SetQosIndex(qosIndex);
                }
                break;
            default:
                throw new UnsupportedOperationException(
                        "Driver does not support extension type " + oxm.getMatchField().id);
        }
    } else if (action.getType().equals(OFActionType.EXPERIMENTER)) {
        OFActionExperimenter experimenter = (OFActionExperimenter) action;
        if (Long.valueOf(experimenter.getExperimenter()).intValue() == TYPE_OFDPA) {
            OFActionOfdpa ofdpa = (OFActionOfdpa) experimenter;
            switch (ofdpa.getExpType()) {
                case SUB_TYPE_PUSH_L2_HEADER:
                    return new Ofdpa3PushL2Header();
                case SUB_TYPE_POP_L2_HEADER:
                    return new Ofdpa3PopL2Header();
                case SUB_TYPE_PUSH_CW:
                    return new Ofdpa3PushCw();
                case SUB_TYPE_POP_CW:
                    return new Ofdpa3PopCw();
                default:
                    throw new UnsupportedOperationException(
                            "Unexpected OFAction: " + action.toString());
            }
        }
        throw new UnsupportedOperationException(
                "Unexpected OFAction: " + action.toString());
    }
    throw new UnsupportedOperationException(
            "Unexpected OFAction: " + action.toString());
}
项目:onos    文件:GroupModBuilder.java   
private OFAction buildL2Modification(Instruction i) {
    L2ModificationInstruction l2m = (L2ModificationInstruction) i;
    L2ModificationInstruction.ModEtherInstruction eth;
    OFOxm<?> oxm = null;
    switch (l2m.subtype()) {
        case ETH_DST:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethDst(MacAddress.of(eth.mac().toLong()));
            break;
        case ETH_SRC:
            eth = (L2ModificationInstruction.ModEtherInstruction) l2m;
            oxm = factory.oxms().ethSrc(MacAddress.of(eth.mac().toLong()));
            break;
        case VLAN_ID:
            L2ModificationInstruction.ModVlanIdInstruction vlanId =
                    (L2ModificationInstruction.ModVlanIdInstruction) l2m;
            oxm = factory.oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
            break;
        case VLAN_PCP:
            L2ModificationInstruction.ModVlanPcpInstruction vlanPcp =
                    (L2ModificationInstruction.ModVlanPcpInstruction) l2m;
            oxm = factory.oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
            break;
        case VLAN_POP:
            return factory.actions().popVlan();
        case VLAN_PUSH:
            L2ModificationInstruction.ModVlanHeaderInstruction pushVlanInstruction
                    = (L2ModificationInstruction.ModVlanHeaderInstruction) l2m;
            return factory.actions().pushVlan(
                    EthType.of(pushVlanInstruction.ethernetType().toShort()));
        case MPLS_PUSH:
            L2ModificationInstruction.ModMplsHeaderInstruction pushHeaderInstructions =
                    (L2ModificationInstruction.ModMplsHeaderInstruction) l2m;
            return factory.actions().pushMpls(EthType.of(pushHeaderInstructions
                                                         .ethernetType().toShort()));
        case MPLS_POP:
            L2ModificationInstruction.ModMplsHeaderInstruction popHeaderInstructions =
                    (L2ModificationInstruction.ModMplsHeaderInstruction) l2m;
            return factory.actions().popMpls(EthType.of(popHeaderInstructions
                                                        .ethernetType().toShort()));
        case MPLS_LABEL:
            L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
                    (L2ModificationInstruction.ModMplsLabelInstruction) l2m;
            oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label().toInt()));
            break;
        case MPLS_BOS:
            L2ModificationInstruction.ModMplsBosInstruction mplsBos =
                    (L2ModificationInstruction.ModMplsBosInstruction) l2m;
            oxm = factory.oxms()
                    .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE
                                               : OFBooleanValue.FALSE);
            break;
        case DEC_MPLS_TTL:
            return factory.actions().decMplsTtl();
        case TUNNEL_ID:
            L2ModificationInstruction.ModTunnelIdInstruction tunnelId =
                    (L2ModificationInstruction.ModTunnelIdInstruction) l2m;
            oxm = factory.oxms().tunnelId(U64.of(tunnelId.tunnelId()));
            break;
        default:
            log.warn("Unimplemented action type {}.", l2m.subtype());
            break;
    }

    if (oxm != null) {
        return factory.actions().buildSetField().setField(oxm).build();
    }
    return null;
}