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 1 : int main(int argc, char *argv[]) {
10 : int r;
11 1 : test_setup_logging(LOG_DEBUG);
12 :
13 1 : r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
14 1 : if (r < 0)
15 1 : log_error_errno(r, "Failed to modify firewall: %m");
16 :
17 1 : r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
18 1 : if (r < 0)
19 1 : log_error_errno(r, "Failed to modify firewall: %m");
20 :
21 1 : r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0);
22 1 : if (r < 0)
23 1 : log_error_errno(r, "Failed to modify firewall: %m");
24 :
25 1 : 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 1 : if (r < 0)
27 1 : log_error_errno(r, "Failed to modify firewall: %m");
28 :
29 1 : 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 1 : if (r < 0)
31 1 : log_error_errno(r, "Failed to modify firewall: %m");
32 :
33 1 : 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 1 : if (r < 0)
35 1 : log_error_errno(r, "Failed to modify firewall: %m");
36 :
37 1 : 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 1 : if (r < 0)
39 1 : log_error_errno(r, "Failed to modify firewall: %m");
40 :
41 1 : return 0;
42 : }
|