• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Masked类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.projectfloodlight.openflow.types.Masked的典型用法代码示例。如果您正苦于以下问题:Java Masked类的具体用法?Java Masked怎么用?Java Masked使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Masked类属于org.projectfloodlight.openflow.types包,在下文中一共展示了Masked类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: iterateMaskedFields

import org.projectfloodlight.openflow.types.Masked; //导入依赖的package包/类
@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");
        }
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:70,代码来源:MatchFieldIterationBase.java


示例2: getMasked

import org.projectfloodlight.openflow.types.Masked; //导入依赖的package包/类
/**
 * 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;
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:11,代码来源:Match.java


示例3: setMasked

import org.projectfloodlight.openflow.types.Masked; //导入依赖的package包/类
/**
 * 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;
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:10,代码来源:Match.java


示例4: getMasked

import org.projectfloodlight.openflow.types.Masked; //导入依赖的package包/类
/**
 * 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;
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:12,代码来源:Match.java


示例5: setMasked

import org.projectfloodlight.openflow.types.Masked; //导入依赖的package包/类
/**
 * 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;
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:11,代码来源:Match.java



注:本文中的org.projectfloodlight.openflow.types.Masked类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Either类代码示例发布时间:2022-05-22
下一篇:
Java ITesseract类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap