예제 #1
0
  @Test
  public void testDlSrcMasking() {
    Condition cond = new Condition();

    // Everything should match with zero mask.
    cond.ethSrcMask = 0L;
    cond.ethSrc = MAC.random();
    cond.invDlSrc = true;
    assertFalse(cond.matches(pktCtx));
    cond.invDlSrc = false;
    assertTrue(cond.matches(pktCtx));

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

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

    // Flip one more bit and match should fail.
    cond.ethSrc = new MAC(macLong ^ 0x1ffffffffL);
    cond.invDlSrc = true;
    assertTrue(cond.matches(pktCtx));
    cond.invDlSrc = false;
    assertFalse(cond.matches(pktCtx));
  }
예제 #2
0
  @Test
  public void testDlSrc() {
    Condition cond = new Condition();

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

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

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

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

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