Java 类org.projectfloodlight.openflow.types.Masked 实例源码

项目:loxigen-artifacts    文件:MatchFieldIterationBase.java   
@SuppressWarnings("unchecked")
@Test
public void iterateMaskedFields() {
    MacAddress macSrc = MacAddress.of("01:02:03:04:00:00");
    MacAddress macSrcMask = MacAddress.of("FF:FF:FF:FF:00:00");
    MacAddress macDst = MacAddress.of("11:22:33:00:00:00");
    MacAddress macDstMask = MacAddress.of("FF:FF:FF:00:00:00");
    IPv4Address ipSrc = IPv4Address.of("10.192.20.0");
    IPv4Address ipSrcMask = IPv4Address.of("255.255.255.0");
    IPv4Address ipDst = IPv4Address.of("10.192.20.0");
    IPv4Address ipDstMask = IPv4Address.of("255.255.255.128");
    TransportPort tcpSrcMask = TransportPort.of(0x01F0);
    OFVersion version = factory.getVersion();
    boolean supportsAllMasks = (version != OFVersion.OF_10) &&
            (version != OFVersion.OF_11) && (version != OFVersion.OF_12);
    int matchFieldCount = 4;
    Match.Builder builder = factory.buildMatch()
            .setExact(MatchField.ETH_TYPE, EthType.IPv4)
            .setMasked(MatchField.IPV4_SRC, ipSrc, ipSrcMask)
            .setMasked(MatchField.IPV4_DST, ipDst, ipDstMask)
            .setExact(MatchField.IP_PROTO, IpProtocol.TCP);
    if (supportsAllMasks) {
        builder.setMasked(MatchField.ETH_SRC, macSrc, macSrcMask);
        builder.setMasked(MatchField.ETH_DST, macDst, macDstMask);
        builder.setMasked(MatchField.TCP_SRC, tcpSrcMask, tcpSrcMask);
        matchFieldCount += 3;
    }
    Match match = builder.build();
    assertThat(Iterables.size(match.getMatchFields()), is(matchFieldCount));
    for (MatchField<?> matchField: match.getMatchFields()) {
        switch (matchField.id) {
        case ETH_TYPE:
            EthType ethType = match.get((MatchField<EthType>) matchField);
            assertThat(ethType, is(EthType.IPv4));
            break;
        case ETH_SRC:
            Masked<MacAddress> mac = match.getMasked((MatchField<MacAddress>) matchField);
            assertThat(mac.getValue(), is(macSrc));
            assertThat(mac.getMask(), is(macSrcMask));
            break;
        case ETH_DST:
            mac = match.getMasked((MatchField<MacAddress>) matchField);
            assertThat(mac.getValue(), is(macDst));
            assertThat(mac.getMask(), is(macDstMask));
            break;
        case IP_PROTO:
            IpProtocol ipProtocol = match.get((MatchField<IpProtocol>) matchField);
            assertThat(ipProtocol, is(IpProtocol.TCP));
            break;
        case IPV4_SRC:
            Masked<IPv4Address> ip = match.getMasked((MatchField<IPv4Address>) matchField);
            assertThat(ip.getValue(), is(ipSrc));
            assertThat(ip.getMask(), is(ipSrcMask));
            break;
        case IPV4_DST:
            ip = match.getMasked((MatchField<IPv4Address>) matchField);
            assertThat(ip.getValue(), is(ipDst));
            assertThat(ip.getMask(), is(ipDstMask));
            break;
        case TCP_SRC:
            Masked<TransportPort> tcp = match.getMasked((MatchField<TransportPort>) matchField);
            assertThat(tcp.getValue(), is(tcpSrcMask));
            assertThat(tcp.getMask(), is(tcpSrcMask));
            break;
        default:
            fail("Unexpected match field returned from iterator");
        }
    }
}
项目:openflowj-otn    文件:Match.java   
/**
 * Returns the masked value for the given field from this match, along with the mask itself.
 * Prerequisite: field is partially masked.
 * If prerequisite is not met, a <code>null</code> is returned.
 *
 * @param field Match field to retrieve.
 * @return Masked value of match field or null if no mask is set.
 * @throws UnsupportedOperationException If field is not supported.
 */
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
项目:openflowj-otn    文件:Match.java   
/**
 * Sets a masked value for a field.
 *
 * @param field Match field to set.
 * @param valueWithMask Compound Masked object contains the value and the mask.
 * @return the Builder instance used.
 * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
 */
public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
项目:loxigen-artifacts    文件:Match.java   
/**
 * Returns the masked value for the given field from this match, along with the mask itself.
 * Prerequisite: field is partially masked.
 * If prerequisite is not met, a <code>null</code> is returned.
 *
 * @param <F> MatchField type
 * @param field Match field to retrieve.
 * @return Masked value of match field or null if no mask is set.
 * @throws UnsupportedOperationException If field is not supported.
 */
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
项目:loxigen-artifacts    文件:Match.java   
/**
 * Sets a masked value for a field.
 *
 * @param <F> MatchField and value with mask type
 * @param field Match field to set.
 * @param valueWithMask Compound Masked object contains the value and the mask.
 * @return the Builder instance used.
 * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported.
 */
public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
项目:openflowj-otn    文件:Match.java   
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
项目:loxigen-artifacts    文件:Match.java   
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;