本文整理汇总了Java中org.projectfloodlight.openflow.protocol.oxm.OFOxm类的典型用法代码示例。如果您正苦于以下问题:Java OFOxm类的具体用法?Java OFOxm怎么用?Java OFOxm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OFOxm类属于org.projectfloodlight.openflow.protocol.oxm包,在下文中一共展示了OFOxm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapAction
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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());
}
示例2: mapSelector
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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());
}
示例3: buildExtensionOxm
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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;
}
示例4: buildL1Modification
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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;
}
示例5: ofList
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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);
}
示例6: buildL1Modification
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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;
}
示例7: mapSelector
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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;
}
示例8: buildL0Modification
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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;
}
示例9: of
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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);
}
示例10: mapSelector
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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());
}
示例11: mapOxm
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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());
}
示例12: mapAction
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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;
}
示例13: buildL0Modification
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
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;
}
示例14: testGetCanonicalNoMask
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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());
}
示例15: testGetCanonicalNormalMask
import org.projectfloodlight.openflow.protocol.oxm.OFOxm; //导入依赖的package包/类
@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);
}