static bool ASSERT_TUPLE4(struct tuple const *expected, struct tuple const *actual, char const *test_name) { if (expected->l4_proto != actual->l4_proto) goto fail; if (ipv4_addr_cmp(&expected->src.addr4.l3, &actual->src.addr4.l3)) goto fail; if (expected->src.addr4.l4 != actual->src.addr4.l4) goto fail; if (ipv4_addr_cmp(&expected->dst.addr4.l3, &actual->dst.addr4.l3)) goto fail; if (expected->dst.addr4.l4 != actual->dst.addr4.l4) goto fail; return true; fail: log_err("Test '%s' failed.", test_name); if (expected) pr_err(" Expected:" TUPLE_KEY "\n", TUPLE_PRINT(expected)); else pr_err(" Expected:NULL\n"); if (actual) pr_err(" Actual: " TUPLE_KEY "\n", TUPLE_PRINT(actual)); else pr_err(" Actual: NULL\n"); return false; }
static int compare_addrs4(struct session_entry *session, struct ipv4_pair *pair) { int gap; gap = ipv4_addr_cmp(&session->ipv4.local.address, &pair->local.address); if (gap != 0) return gap; gap = session->ipv4.local.l4_id - pair->local.l4_id; if (gap != 0) return gap; gap = ipv4_addr_cmp(&session->ipv4.remote.address, &pair->remote.address); return gap; }
/** * Returns zero if "eam"->pref4.address is equals to "prefix4" or contains the "prefix4". * Otherwise return the gap of the comparison result. */ static int compare_prefix4(struct eam_entry *entry, struct ipv4_prefix *prefix4) { int gap; gap = ipv4_addr_cmp(&prefix4->address, &entry->pref4.address); if (gap == 0) return 0; if (eam_ipv4_prefix_equal(entry, prefix4)) return 0; return gap; }