/** * Examine all the MatchFields in a Match object and pick out * the MatchFields that are not supported by OF-DPA. * * @param m * @return */ public static List<MatchFields> checkMatchFields(Match m) { List<MatchFields> unsupported = null; Iterator<MatchField<?>> mfi = m.getMatchFields().iterator(); while (mfi.hasNext()) { MatchField<?> mf = mfi.next(); if (!getSupportedMatchFields().contains(mf.id)) { if (unsupported == null) { unsupported = new ArrayList<MatchFields>(); } unsupported.add(mf.id); } } return unsupported; }
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); }
@Test public void iterateSingleExactMatchField() { OFPort port5 = OFPort.of(5); Match match = factory.buildMatch() .setExact(MatchField.IN_PORT, port5) .build(); Iterator<MatchField<?>> iter = match.getMatchFields().iterator(); assertThat(iter.hasNext(), is(true)); MatchField<?> matchField = iter.next(); assertThat(matchField.id, is(MatchFields.IN_PORT)); assertThat(match.isExact(matchField), is(true)); @SuppressWarnings("unchecked") MatchField<OFPort> portMatchField = (MatchField<OFPort>) matchField; OFPort port = match.get(portMatchField); assertThat(port, is(port5)); assertThat(iter.hasNext(), is(false)); }
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); }
private OFOxmList(Map<MatchFields, OFOxm<?>> oxmMap) { this.oxmMap = oxmMap; }
public Builder() { oxmMap = new EnumMap<MatchFields, OFOxm<?>>(MatchFields.class); }
public Builder(EnumMap<MatchFields, OFOxm<?>> oxmMap) { this.oxmMap = oxmMap; }
public OFOxmList.Builder createBuilder() { return new OFOxmList.Builder(new EnumMap<MatchFields, OFOxm<?>>(oxmMap)); }
/** * Get the MatchFields that an OF-DPA switch supports matching. * Note that this does not specify match codependencies or * mutually exclusive matches. * * @return, an unmodifiable list of potential MatchFields */ public static List<MatchFields> getSupportedMatchFields() { return ALLOWED_MATCHES; }