/** * Return a copy of the Match configured on this flow * * @return */ public Match getMatch() { return match.clone(); }
/** * Returns whether this match is for an IPv4 flow */ public boolean isIPv4() { return !isIPv6(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((match == null) ? 0 : match.hashCode()); return result; }
private static NodeConnectorId inPortMatch(Match sourceMatch) { MatchField inPort = sourceMatch.getField(MatchType.IN_PORT); if(inPort != null && inPort.getValue() != null && (inPort.getValue() instanceof NodeConnector)) { NodeConnector port = (NodeConnector)inPort.getValue(); return (NodeConnectorId)MDFlowMapping.toUri(port); } return null; }
/** * Generic setter for frame/packet/message's header fields against which to match * Note: For MAC addresses, please pass the cloned value to this function * * @param type packet's header field type * @param value field's value to assign to the match */ public void setField(MatchType type, Object value) { MatchField field = new MatchField(type, value); if (field.isValid()) { fields.put(type, field); matches |= type.getIndex(); } }
private boolean checkValueType() { if (type.isCongruentType(value, mask) == false) { String valueClass = (value == null) ? "null" : value.getClass().getSimpleName(); String maskClass = (mask == null) ? "null" : mask.getClass().getSimpleName(); String error = "Invalid match field's value or mask types.For field: " + type.id() + " Expected:" + type.dataType().getSimpleName() + " or equivalent," + " Got:(" + valueClass + "," + maskClass + ")"; throwException(error); return false; } return true; }
/** * Full match constructor * * @param type * @param value */ public MatchField(MatchType type, Object value) { this.type = type; this.value = value; this.mask = null; // Keep this logic, value checked only if type check is fine this.isValid = checkValueType() && checkValues(); }
/** * Returns the bitmask set for this field match * * @return */ public long getBitMask() { return type.getBitMask(mask); }
/** * Returns whether the specified match is allowed * * @param match the match to test * @return true if the match is allowed, false otherwise */ public boolean allowsMatch(Match target) { return !target.conflictWithFilter(this.match); } }
@Override public int hashCode() { return type.hashCode(value, mask); }
@Override public String toString() { return "Container Flow [" + match.toString() + "]"; }
/** * Generic setter for frame/packet/message's header fields against which to match * Note: For MAC addresses, please pass the cloned value to this function * * @param type packet's header field type * @param value field's value to assign to the match * @param mask field's bitmask to apply to the match (has to be of the same class type of value) */ public void setField(MatchType type, Object value, Object mask) { MatchField field = new MatchField(type, value, mask); if (field.isValid()) { fields.put(type, field); matches |= type.getIndex(); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((actions == null) ? 0 : actions.hashCode()); result = prime * result + hardTimeout; result = prime * result + (int) (id ^ (id >>> 32)); result = prime * result + idleTimeout; result = prime * result + ((match == null) ? 0 : match.hashCode()); result = prime * result + priority; return result; }
/** * Mask based match constructor * * @param type * @param value * @param mask * has to be of the same class type of value. A null mask means * full match */ public MatchField(MatchType type, Object value, Object mask) { this.type = type; this.value = value; this.mask = mask; // Keep this logic, value checked only if type check is fine this.isValid = checkValueType() && checkValues(); }
/** * Returns a copy of the Match defined by this Container Flow * * @return Match */ public Match getMatch() { return match.clone(); }
private static Integer transportPort(final Match sourceMatch, final MatchType matchType) { MatchField transportPort = sourceMatch.getField(matchType); if (transportPort != null && transportPort.getValue() != null && transportPort.getValue().getClass().equals(Short.class)) { return NetUtils.getUnsignedShort((short) transportPort.getValue()); } return null; }