Branch data Line data Source code
1 : : /* SPDX-License-Identifier: LGPL-2.1+ */
2 : :
3 : : #include "firewall-util.h"
4 : : #include "log.h"
5 : : #include "tests.h"
6 : :
7 : : #define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))}
8 : :
9 : 4 : int main(int argc, char *argv[]) {
10 : : int r;
11 : 4 : test_setup_logging(LOG_DEBUG);
12 : :
13 : 4 : r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
14 [ + - ]: 4 : if (r < 0)
15 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
16 : :
17 : 4 : r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
18 [ + - ]: 4 : if (r < 0)
19 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
20 : :
21 : 4 : r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
22 [ + - ]: 4 : if (r < 0)
23 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
24 : :
25 : 4 : r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
26 [ + - ]: 4 : if (r < 0)
27 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
28 : :
29 : 4 : r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 4), 815, NULL);
30 [ + - ]: 4 : if (r < 0)
31 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
32 : :
33 : 4 : r = fw_add_local_dnat(true, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, &MAKE_IN_ADDR_UNION(1, 2, 3, 4));
34 [ + - ]: 4 : if (r < 0)
35 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
36 : :
37 : 4 : r = fw_add_local_dnat(false, AF_INET, IPPROTO_TCP, NULL, NULL, 0, NULL, 0, 4711, &MAKE_IN_ADDR_UNION(1, 2, 3, 5), 815, NULL);
38 [ + - ]: 4 : if (r < 0)
39 [ + - ]: 4 : log_error_errno(r, "Failed to modify firewall: %m");
40 : :
41 : 4 : return 0;
42 : : }
|