Example #1
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 #2
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));
  }