本文整理汇总了Java中org.openflow.protocol.Wildcards.Flag类的典型用法代码示例。如果您正苦于以下问题:Java Flag类的具体用法?Java Flag怎么用?Java Flag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Flag类属于org.openflow.protocol.Wildcards包,在下文中一共展示了Flag类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAll
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testAll() {
Wildcards all = Wildcards.FULL;
assertTrue(all.isFull());
assertFalse(all.isExact());
assertEquals(0, all.getNwDstMask());
assertEquals(0, all.getNwSrcMask());
// unsetting flags from NONE is a no-op
Wildcards stillAll = all.wildcard(Flag.IN_PORT);
assertTrue(stillAll.isFull());
assertEquals(all, stillAll);
// so is setting a >= 32 netmask
stillAll = all.withNwSrcMask(0);
assertTrue(stillAll.isFull());
assertEquals(all, stillAll);
stillAll = all.withNwDstMask(0);
assertTrue(stillAll.isFull());
assertEquals(all, stillAll);
}
示例2: testNone
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testNone() {
Wildcards none = Wildcards.EXACT;
assertTrue(none.isExact());
assertEquals(32, none.getNwDstMask());
assertEquals(32, none.getNwSrcMask());
// unsetting flags from NONE is a no-op
Wildcards stillNone = none.matchOn(Flag.IN_PORT);
assertTrue(stillNone.isExact());
assertEquals(none, stillNone);
// so is setting a >= 32 netmask
stillNone = none.withNwSrcMask(32);
assertTrue(stillNone.isExact());
assertEquals(none, stillNone);
stillNone = none.withNwDstMask(32);
assertTrue(stillNone.isExact());
assertEquals(none, stillNone);
}
示例3: testSetTwoFlags
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testSetTwoFlags() {
Wildcards none = Wildcards.EXACT;
// set two flags
Wildcards two = none.wildcard(Flag.DL_SRC, Flag.DL_DST);
assertFalse(two.isExact());
assertTrue(two.isWildcarded(Flag.DL_SRC));
assertTrue(two.isWildcarded(Flag.DL_DST));
assertEquals(OFMatch.OFPFW_DL_SRC | OFMatch.OFPFW_DL_DST, two.getInt());
assertEquals(EnumSet.of(Flag.DL_SRC, Flag.DL_DST), two.getWildcardedFlags());
// unset dl_dst
Wildcards gone = two.matchOn(Flag.DL_DST);
assertFalse(gone.isExact());
assertTrue(gone.isWildcarded(Flag.DL_SRC));
assertFalse(gone.isWildcarded(Flag.DL_DST));
assertEquals(OFMatch.OFPFW_DL_SRC, gone.getInt());
assertEquals(EnumSet.of(Flag.DL_SRC), gone.getWildcardedFlags());
}
示例4: testInvert
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testInvert() {
assertEquals(Wildcards.FULL, Wildcards.EXACT.inverted());
Wildcards some = Wildcards.of(Flag.DL_VLAN, Flag.DL_VLAN_PCP);
Wildcards inv = some.inverted();
for(Flag f : Flag.values()) {
boolean shouldBeSet = (f == Flag.DL_VLAN || f == Flag.DL_VLAN_PCP);
assertEquals("Flag " + f + " "
+ (shouldBeSet ? "should be set " : "should not be set"),
shouldBeSet, some.isWildcarded(f));
assertEquals(!(f == Flag.DL_VLAN || f == Flag.DL_VLAN_PCP), inv.isWildcarded(f));
}
assertEquals(0, inv.getNwDstMask());
assertEquals(0, inv.getNwSrcMask());
}
示例5: prependRewriteActions
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
public static List<OFAction> prependRewriteActions(final Integer tenantId,
final OFMatch match) {
final List<OFAction> actions = new LinkedList<OFAction>();
if (!match.getWildcardObj().isWildcarded(Flag.NW_SRC)) {
final OVXActionNetworkLayerSource srcAct = new OVXActionNetworkLayerSource();
srcAct.setNetworkAddress(getPhysicalIp(tenantId,
match.getNetworkSource()));
actions.add(srcAct);
}
if (!match.getWildcardObj().isWildcarded(Flag.NW_DST)) {
final OVXActionNetworkLayerDestination dstAct = new OVXActionNetworkLayerDestination();
dstAct.setNetworkAddress(getPhysicalIp(tenantId,
match.getNetworkDestination()));
actions.add(dstAct);
}
return actions;
}
示例6: learnHostIP
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
private void learnHostIP(OFMatch match, Mappable map) {
if (!match.getWildcardObj().isWildcarded(Flag.NW_SRC)) {
try {
map.getVirtualNetwork(tenantId).getHost(ovxPort)
.setIPAddress(match.getNetworkSource());
} catch (NetworkMappingException e) {
log.warn("Failed to lookup virtual network {}", this.tenantId);
return;
} catch (NullPointerException npe) {
log.warn("No host attached at {} port {}", this.ovxPort
.getParentSwitch().getSwitchName(), this.ovxPort
.getPhysicalPortNumber());
}
}
}
示例7: testIsFlowModAllowedSimple
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testIsFlowModAllowedSimple(){
OFFlowMod flow = new OFFlowMod();
OFMatch match = new OFMatch();
match.setInputPort((short)1);
match.setDataLayerVirtualLan((short)1000);
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_VLAN));
match.setWildcards(match.getWildcardObj().matchOn(Flag.IN_PORT));
flow.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionVirtualLanIdentifier setVid = new OFActionVirtualLanIdentifier();
setVid.setVirtualLanIdentifier((short)102);
OFActionOutput output = new OFActionOutput();
output.setPort((short)2);
actions.add(setVid);
actions.add(output);
flow.setActions(actions);
List <OFFlowMod> flows = slicer.allowedFlows(flow);
assertTrue("flows is the right size", flows.size() == 1);
assertEquals("flow was allowed and matches", flow, flows.get(0));
}
示例8: testSetOneFlag
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testSetOneFlag() {
Wildcards none = Wildcards.EXACT;
assertTrue(none.isExact());
assertFalse(none.isWildcarded(Flag.DL_SRC));
Wildcards one = none.wildcard(Flag.DL_SRC);
assertFalse(one.isExact());
assertTrue(one.isWildcarded(Flag.DL_SRC));
assertEquals(OFMatch.OFPFW_DL_SRC, one.getInt());
assertEquals(EnumSet.of(Flag.DL_SRC), one.getWildcardedFlags());
}
示例9: testSetNwSrc
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testSetNwSrc() {
Wildcards none = Wildcards.EXACT;
assertEquals(32, none.getNwSrcMask());
// unsetting flags from NONE is a no-op
Wildcards nwSet = none.withNwSrcMask(8);
assertFalse(nwSet.isExact());
assertEquals(EnumSet.noneOf(Flag.class), nwSet.getWildcardedFlags());
assertEquals(8, nwSet.getNwSrcMask());
assertEquals((32 - 8) << OFMatch.OFPFW_NW_SRC_SHIFT, nwSet.getInt());
}
示例10: testSetNwDst
import org.openflow.protocol.Wildcards.Flag; //导入依赖的package包/类
@Test
public void testSetNwDst() {
Wildcards none = Wildcards.EXACT;
assertEquals(32, none.getNwDstMask());
// unsetting flags from NONE is a no-op
Wildcards nwSet = none.withNwDstMask(8);
assertFalse(nwSet.isExact());
assertEquals(EnumSet.noneOf(Flag.class), nwSet.getWildcardedFlags());
assertEquals(8, nwSet.getNwDstMask());
assertEquals((32 - 8) << OFMatch.OFPFW_NW_DST_SHIFT, nwSet.getInt());
}