/** * return a Wildcards object that has the given flags set * <p> * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays * unmodified. </b> */ public Wildcards wildcard(final Wildcards.Flag flag) { final int flags = flag.wildcard(this.flags); if (flags == this.flags) { return this; } else { return new Wildcards(flags); } }
/** set the wildcard using the Wildcards convenience object */ public OFMatch setWildcards(final Wildcards wildcards) { this.wildcards = wildcards.getInt(); return this; }
/** a Java expression that constructs 'this' wildcards set */ public String toJava() { if (this.isFull()) { return "Wildcards.FULL"; } else if (this.isExact()) { return "Wildcards.EXACT"; } final StringBuilder b = new StringBuilder(); final EnumSet<Flag> myFlags = this.getWildcardedFlags(); if (myFlags.size() < 3) { // default to start with empty b.append("Wildcards.of(" + Wildcards.commaJoiner.join(this.prefix("Flag.", myFlags.iterator())) + ")"); } else { // too many - start with full final EnumSet<Flag> invFlags = this.inverted().getWildcardedFlags(); b.append("Wildcards.ofMatches(" + Wildcards.commaJoiner.join(this.prefix("Flag.", invFlags.iterator())) + ")"); } if (Flag.NW_SRC.isPartiallyOn(this.flags)) { b.append(".setNwSrcMask(" + this.getNwSrcMask() + ")"); } if (Flag.NW_DST.isPartiallyOn(this.flags)) { b.append(".setNwDstMask(" + this.getNwDstMask() + ")"); } return b.toString(); }
/** * return a wildcard object matching the given int flags. May reuse / cache * frequently used wildcard instances. Don't rely on it though (use equals * not ==). * * @param flags * @return */ public static Wildcards of(final int paramFlags) { final int flags = Wildcards.sanitizeInt(paramFlags); switch (flags) { case 0x0000: return Wildcards.EXACT; case OFMatch.OFPFW_ALL_SANITIZED: return Wildcards.FULL; case INT_INPORT_L2_MATCH: return Wildcards.INPORT_L2_MATCH; default: return new Wildcards(flags); } }
public static List<OFAction> prependUnRewriteActions(final OFMatch match) { final List<OFAction> actions = new LinkedList<OFAction>(); if (!match.getWildcardObj().isWildcarded(Flag.NW_SRC)) { final OVXActionNetworkLayerSource srcAct = new OVXActionNetworkLayerSource(); srcAct.setNetworkAddress(match.getNetworkSource()); actions.add(srcAct); } if (!match.getWildcardObj().isWildcarded(Flag.NW_DST)) { final OVXActionNetworkLayerDestination dstAct = new OVXActionNetworkLayerDestination(); dstAct.setNetworkAddress(match.getNetworkDestination()); actions.add(dstAct); } return actions; } }
/** * return a Wildcard object that is inverted to this wildcard object. * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays * unmodified. </b> * * @return a modified object */ public Wildcards inverted() { return Wildcards.of(this.flags ^ OFMatch.OFPFW_ALL_SANITIZED); }
@Override public String toString() { final List<String> res = new ArrayList<String>(); for (final Wildcards.Flag flag : Flag.values()) { if (flag.isFullyOn(this.flags)) { res.add(flag.name().toLowerCase()); } } if (Flag.NW_SRC.isPartiallyOn(this.flags)) { res.add("nw_src(/" + this.getNwSrcMask() + ")"); } if (Flag.NW_DST.isPartiallyOn(this.flags)) { res.add("nw_dst(/" + this.getNwDstMask() + ")"); } return Wildcards.pipeJoiner.join(res); }
if ((this.match.getWildcardObj().isFull() || this.match.getWildcards() == -1) && this.outPort == OFPort.OFPP_NONE.getValue()) { FlowTable ft = sw.getFlowTable();
private void learnAddresses(final OFMatch match, final Mappable map) { if (match.getDataLayerType() == Ethernet.TYPE_IPV4 || match.getDataLayerType() == Ethernet.TYPE_ARP) { if (!match.getWildcardObj().isWildcarded(Flag.NW_SRC)) { IPMapper.getPhysicalIp(this.tenantId, match.getNetworkSource()); } if (!match.getWildcardObj().isWildcarded(Flag.NW_DST)) { IPMapper.getPhysicalIp(this.tenantId, match.getNetworkDestination()); } } }
/** * Get wildcards * * @return */ public Wildcards getWildcardObj() { return Wildcards.of(this.wildcards); }
int length = 0; if ((this.match.getWildcardObj().isFull() || this.match.getWildcards() == -1) // the
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; }
/** convience method return a wildcard for an arbitrary number of set flags */ public static Wildcards of(final Wildcards.Flag... setFlags) { int flags = 0; for (final Wildcards.Flag flag : setFlags) { flags = flag.wildcard(0); } return Wildcards.of(flags); }
/** * return a Wildcards object that matches on exactly the given flag * <p> * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays * unmodified. </b> */ public Wildcards matchOn(final Wildcards.Flag flag) { final int flags = flag.matchOn(this.flags); if (flags == this.flags) { return this; } else { return new Wildcards(flags); } }
/** * Return an OFAction associated with nw_src * * @param tenantId * @return OFAction or null */ public OFAction getNetworkSrcAction(int tenantId) { OVXActionNetworkLayerSource srcAct = null; if (!this.getWildcardObj().isWildcarded(Flag.NW_SRC)) { srcAct = new OVXActionNetworkLayerSource(); srcAct.setNetworkAddress(IPMapper.getPhysicalIp(tenantId, this.networkSource)); } return srcAct; }
/** * convience method return a wildcard for an ofmatch that amtch on an * arbitrary number of set flags */ public static Wildcards ofMatches(final Wildcards.Flag... setFlags) { int flags = Wildcards.FULL_INT; for (final Wildcards.Flag flag : setFlags) { flags = flag.matchOn(flags); } return Wildcards.of(flags); }
/** * return a Wildcards object that has the given flags wildcarded * <p> * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays * unmodified. </b> */ public Wildcards wildcard(final Wildcards.Flag... setFlags) { int flags = this.flags; for (final Wildcards.Flag flag : setFlags) { flags = flag.wildcard(flags); } if (flags == this.flags) { return this; } else { return new Wildcards(flags); } }
/** * Return an OFAction associated with nw_dst * * @param tenantId * @return OFAction or null */ public OFAction getNetworkDstAction(int tenantId) { OVXActionNetworkLayerDestination dstAct = null; if (!this.getWildcardObj().isWildcarded(Flag.NW_DST)) { dstAct = new OVXActionNetworkLayerDestination(); dstAct.setNetworkAddress(IPMapper.getPhysicalIp(tenantId, this.networkDestination)); } return dstAct; } }
/** convience method return a wildcards for ofmatches that match on one flag */ public static Wildcards ofMatches(final Wildcards.Flag setFlag) { return Wildcards.of(setFlag.matchOn(Wildcards.FULL_INT)); }
/** * return a Wildcards object that matches on exactly the given flags * <p> * <b>NOTE:</b> NOT a mutator function. 'this' wildcard object stays * unmodified. </b> */ public Wildcards matchOn(final Wildcards.Flag... setFlags) { int flags = this.flags; for (final Wildcards.Flag flag : setFlags) { flags = flag.matchOn(flags); } if (flags == this.flags) { return this; } else { return new Wildcards(flags); } }