当前位置: 首页>>代码示例>>Java>>正文


Java IPv4AddressWithMask类代码示例

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


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

示例1: FirewallRule

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
/**
 * The default rule is to match on anything.
 */
public FirewallRule() {
    this.dpid = DatapathId.NONE;
    this.in_port = OFPort.ANY; 
    this.dl_src = MacAddress.NONE;
    this.dl_dst = MacAddress.NONE;
    this.dl_type = EthType.NONE;
    this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_dst_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_proto = IpProtocol.NONE;
    this.tp_src = TransportPort.NONE;
    this.tp_dst = TransportPort.NONE;
    this.any_dpid = true; 
    this.any_in_port = true; 
    this.any_dl_src = true; 
    this.any_dl_dst = true; 
    this.any_dl_type = true; 
    this.any_nw_src = true; 
    this.any_nw_dst = true; 
    this.any_nw_proto = true; 
    this.any_tp_src = true; 
    this.any_tp_dst = true;
    this.priority = 0; 
    this.action = FirewallAction.ALLOW; 
    this.ruleid = 0; 
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FirewallRule.java

示例2: FirewallRule

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
/**
 * The default rule is to match on anything.
 */
public FirewallRule() {
    this.dpid = DatapathId.NONE;
    this.in_port = OFPort.ANY;
    this.dl_src = MacAddress.NONE;
    this.dl_dst = MacAddress.NONE;
    this.dl_type = EthType.NONE;
    this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_dst_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_proto = IpProtocol.NONE;
    this.tp_src = TransportPort.NONE;
    this.tp_dst = TransportPort.NONE;
    this.any_dpid = true;
    this.any_in_port = true;
    this.any_dl_src = true;
    this.any_dl_dst = true;
    this.any_dl_type = true;
    this.any_nw_src = true;
    this.any_nw_dst = true;
    this.any_nw_proto = true;
    this.any_tp_src = true;
    this.any_tp_dst = true;
    this.priority = 0;
    this.action = FirewallAction.ALLOW;
    this.ruleid = 0;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:29,代码来源:FirewallRule.java

示例3: testSimpleAllowRule

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
@Test
public void testSimpleAllowRule() throws Exception {
    // enable firewall first
    firewall.enableFirewall(true);

    // add TCP rule
    FirewallRule rule = new FirewallRule();
    rule.dl_type = EthType.IPv4;
    rule.any_dl_type = false;
    rule.nw_proto = IpProtocol.TCP;
    rule.any_nw_proto = false;
    // source is IP 192.168.1.2
    rule.nw_src_prefix_and_mask = IPv4AddressWithMask.of("192.168.1.2/32");
    rule.any_nw_src = false;
    // dest is network 192.168.1.0/24
    rule.nw_dst_prefix_and_mask = IPv4AddressWithMask.of("192.168.1.0/24");
    rule.any_nw_dst = false;
    rule.priority = 1;
    firewall.addRule(rule);

    // simulate a packet-in events

    this.setPacketIn(tcpPacketReply);
    firewall.receive(sw, this.packetIn, cntx);
    verify(sw);

    IRoutingDecision decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
    assertEquals(IRoutingDecision.RoutingAction.FORWARD_OR_FLOOD, decision.getRoutingAction());

    // clear decision
    IRoutingDecision.rtStore.remove(cntx, IRoutingDecision.CONTEXT_DECISION);

    this.setPacketIn(tcpPacket);
    firewall.receive(sw, this.packetIn, cntx);
    verify(sw);

    decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
    assertEquals(IRoutingDecision.RoutingAction.DROP, decision.getRoutingAction());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:FirewallTest.java

示例4: testGetCanonicalFullMask

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
@Test
public void testGetCanonicalFullMask() {
    IPv4AddressWithMask empty = IPv4AddressWithMask.of("0.0.0.0/0");
    assertEquals(IPv4Address.FULL_MASK, empty.getMask());
    OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(empty.getValue(), empty.getMask());
    // canonicalize should remove /0
    assertNull(ipv4SrcMasked.getCanonical());
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:9,代码来源:OFOxmTest.java

示例5: testGetCanonicalNoMask

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
@Test
public void testGetCanonicalNoMask() {
    IPv4AddressWithMask fullIp = IPv4AddressWithMask.of("1.2.3.4/32");
    assertEquals(IPv4Address.NO_MASK, fullIp.getMask());
    OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(fullIp.getValue(), fullIp.getMask());
    assertTrue(ipv4SrcMasked.isMasked());
    assertEquals(IPv4Address.NO_MASK, ipv4SrcMasked.getMask());

    // canonicalize should convert the masked oxm to the non-masked one
    OFOxm<IPv4Address> canonical = ipv4SrcMasked.getCanonical();
    assertThat(canonical, CoreMatchers.instanceOf(OFOxmIpv4Src.class));
    assertFalse(canonical.isMasked());
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:14,代码来源:OFOxmTest.java

示例6: testGetCanonicalNormalMask

import org.projectfloodlight.openflow.types.IPv4AddressWithMask; //导入依赖的package包/类
@Test
public void testGetCanonicalNormalMask() {
    IPv4AddressWithMask ip = IPv4AddressWithMask.of("1.2.3.0/24");
    OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(ip.getValue(), ip.getMask());
    assertTrue(ipv4SrcMasked.isMasked());

    // canonicalize should convert the masked oxm to the non-masked one
    OFOxm<IPv4Address> canonical = ipv4SrcMasked.getCanonical();
    assertEquals(ipv4SrcMasked, canonical);
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:11,代码来源:OFOxmTest.java


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