Lines Matching refs:ctx
12 static void test_v6(FirewallContext *ctx) { in test_v6() argument
17 assert_se(ctx); in test_v6()
19 log_info("/* %s(backend=%s) */", __func__, firewall_backend_to_string(ctx->backend)); in test_v6()
30 assert_se(fw_add_masquerade(&ctx, true, AF_INET6, &u1, 128) >= 0); in test_v6()
31 assert_se(fw_add_masquerade(&ctx, false, AF_INET6, &u1, 128) >= 0); in test_v6()
32 assert_se(fw_add_masquerade(&ctx, true, AF_INET6, &u1, 64) >= 0); in test_v6()
33 assert_se(fw_add_masquerade(&ctx, false, AF_INET6, &u1, 64) >= 0); in test_v6()
34 assert_se(fw_add_masquerade(&ctx, true, AF_INET6, &u3, prefixlen) >= 0); in test_v6()
35 assert_se(fw_add_masquerade(&ctx, false, AF_INET6, &u3, prefixlen) >= 0); in test_v6()
37 r = fw_add_local_dnat(&ctx, true, AF_INET6, IPPROTO_TCP, 4711, &u1, 815, NULL); in test_v6()
44 assert_se(fw_add_local_dnat(&ctx, true, AF_INET6, IPPROTO_TCP, 4711, &u2, 815, &u1) >= 0); in test_v6()
45 assert_se(fw_add_local_dnat(&ctx, false, AF_INET6, IPPROTO_TCP, 4711, &u2, 815, NULL) >= 0); in test_v6()
56 static bool test_v4(FirewallContext *ctx) { in test_v4() argument
60 assert_se(ctx); in test_v4()
62 log_info("/* %s(backend=%s) */", __func__, firewall_backend_to_string(ctx->backend)); in test_v4()
65 if (ctx->backend == FW_BACKEND_IPTABLES && fw_iptables_init_nat(NULL) < 0) { in test_v4()
71 assert_se(fw_add_masquerade(&ctx, true, AF_INET, NULL, 0) == -EINVAL); in test_v4()
72 assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.1.2.0", &u), 0) == -EINVAL); in test_v4()
74 r = fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.1.2.3", &u), 32); in test_v4()
87 assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0); in test_v4()
88 assert_se(fw_add_masquerade(&ctx, false, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0); in test_v4()
89 assert_se(fw_add_masquerade(&ctx, false, AF_INET, parse_addr("10.1.2.3", &u), 32) >= 0); in test_v4()
90 …assert_se(fw_add_local_dnat(&ctx, true, AF_INET, IPPROTO_TCP, 4711, parse_addr("1.2.3.4", &u), 815… in test_v4()
91 …assert_se(fw_add_local_dnat(&ctx, true, AF_INET, IPPROTO_TCP, 4711, parse_addr("1.2.3.4", &u), 815… in test_v4()
92 …assert_se(fw_add_local_dnat(&ctx, true, AF_INET, IPPROTO_TCP, 4711, parse_addr("1.2.3.5", &u), 815… in test_v4()
93 …assert_se(fw_add_local_dnat(&ctx, false, AF_INET, IPPROTO_TCP, 4711, parse_addr("1.2.3.5", &u), 81… in test_v4()
99 _cleanup_(fw_ctx_freep) FirewallContext *ctx = NULL; in main()
106 assert_se(fw_ctx_new(&ctx) >= 0); in main()
107 assert_se(ctx); in main()
109 if (ctx->backend == FW_BACKEND_NONE) in main()
112 if (test_v4(ctx) && ctx->backend == FW_BACKEND_NFTABLES) in main()
113 test_v6(ctx); in main()
116 if (ctx->backend != FW_BACKEND_IPTABLES) { in main()
117 ctx->backend = FW_BACKEND_IPTABLES; in main()
118 test_v4(ctx); in main()