Example #1
0
 @Before
 public void setUp() {
   pktMatch = new FlowMatch();
   pktMatch.setInputPortNumber((short) 5);
   pktMatch.setEthSrc("02:11:33:00:11:01");
   pktMatch.setEthDst("02:11:aa:ee:22:05");
   pktMatch.setEtherType(IPv4.ETHERTYPE);
   pktMatch.setNetworkSrc(srcIpAddr);
   pktMatch.setNetworkDst(dstIpAddr);
   pktMatch.setNetworkProto((byte) 6);
   pktMatch.setNetworkTOS((byte) 34);
   pktMatch.setSrcPort(4321);
   pktMatch.setDstPort(1234);
   rand = new Random();
   pktCtx = new PacketContext(1, null, pktMatch, null);
 }
Example #2
0
  @Test
  public void testDlDstMasking() {
    Condition cond = new Condition();

    // Everything should match with zero mask.
    cond.dlDstMask = 0L;
    cond.ethDst = MAC.random();
    cond.invDlDst = true;
    assertFalse(cond.matches(pktCtx));
    cond.invDlDst = false;
    assertTrue(cond.matches(pktCtx));

    // Ignore lower 32 bits.
    cond.dlDstMask = 0xffffL << 32;

    // Flip lower 32 bits and match should still succeed.
    long macLong = pktMatch.getEthDst().asLong();
    cond.ethDst = new MAC(macLong ^ 0xffffffffL);
    cond.invDlDst = true;
    assertFalse(cond.matches(pktCtx));
    cond.invDlDst = false;
    assertTrue(cond.matches(pktCtx));

    // Flip one more bit and match should fail.
    cond.ethDst = new MAC(macLong ^ 0x1ffffffffL);
    cond.invDlDst = true;
    assertTrue(cond.matches(pktCtx));
    cond.invDlDst = false;
    assertFalse(cond.matches(pktCtx));
  }
Example #3
0
  @Test
  public void testDlDst() {
    Condition cond = new Condition();

    // InvDlDst shouldn't matter when ethDst is null.
    cond.invDlDst = true;
    assertTrue(cond.matches(pktCtx));

    cond.ethDst = pktMatch.getEthDst();
    assertFalse(cond.matches(pktCtx));

    cond.invDlDst = false;
    assertTrue(cond.matches(pktCtx));

    cond.ethDst = MAC.random();
    assertFalse(cond.matches(pktCtx));

    cond.invDlDst = true;
    assertTrue(cond.matches(pktCtx));
  }
Example #4
0
  @Test
  public void testDlSrc() {
    Condition cond = new Condition();

    // InvDlSrc shouldn't matter when ethSrc is null.
    cond.invDlSrc = true;
    assertTrue(cond.matches(pktCtx, false));

    cond.ethSrc = pktMatch.getEthSrc();
    assertFalse(cond.matches(pktCtx, false));

    cond.invDlSrc = false;
    assertTrue(cond.matches(pktCtx, false));

    cond.ethSrc = MAC.random();
    assertFalse(cond.matches(pktCtx, false));

    cond.invDlSrc = true;
    assertTrue(cond.matches(pktCtx, false));
  }