diff options
author | Sven Eden <yamakuzure@gmx.net> | 2016-12-16 12:09:41 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 10:18:01 +0100 |
commit | 1cfc78c91965df340cdde100ad6cb3ed50b28927 (patch) | |
tree | adc3d49b97131cd3e70edff05b14e9b67926e404 /src/test | |
parent | 86e97d599f8b1ca379dce64fadac9b8f6b002ac5 (diff) |
Prep v221: Update and clean up build system to sync with upstream
This commit replays the moving around of source files that have been
done between systemd-219 and systemd-221.
Further the Makefile.am is synchronized with the upstream version and
then "re-cleaned".
A lot of functions, that are not used anywhere in elogind have been
coated into #if 0/#endif directives to further shorten the list of
dependencies.
All unneeded files have been removed.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-firewall-util.c | 60 | ||||
-rw-r--r-- | src/test/test-netlink-manual.c | 147 |
2 files changed, 0 insertions, 207 deletions
diff --git a/src/test/test-firewall-util.c b/src/test/test-firewall-util.c deleted file mode 100644 index d636e427c..000000000 --- a/src/test/test-firewall-util.c +++ /dev/null @@ -1,60 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/*** - This file is part of systemd. - - Copyright 2015 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ - -#include "log.h" -#include "firewall-util.h" - -#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))} - -int main(int argc, char *argv[]) { - int r; - log_set_max_level(LOG_DEBUG); - - r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - r = fw_add_masquerade(true, AF_INET, 0, NULL, 0, "foobar", NULL, 0); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - r = fw_add_masquerade(false, AF_INET, 0, NULL, 0, "foobar", NULL, 0); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - 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); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - 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); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - 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)); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - 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); - if (r < 0) - log_error_errno(r, "Failed to modify firewall: %m"); - - return 0; -} diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c deleted file mode 100644 index 149843297..000000000 --- a/src/test/test-netlink-manual.c +++ /dev/null @@ -1,147 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/*** - This file is part of systemd. - - Copyright 2014 Susant Sahani - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ - -#include <arpa/inet.h> -#include <net/if.h> -#include <linux/ip.h> -#include <linux/if_tunnel.h> -#include <libkmod.h> - -#include "util.h" -#include "macro.h" -#include "sd-netlink.h" - -static int load_module(const char *mod_name) { - struct kmod_ctx *ctx; - struct kmod_list *list = NULL, *l; - int r; - - ctx = kmod_new(NULL, NULL); - if (!ctx) { - kmod_unref(ctx); - return -ENOMEM; - } - - r = kmod_module_new_from_lookup(ctx, mod_name, &list); - if (r < 0) - return -1; - - kmod_list_foreach(l, list) { - struct kmod_module *mod = kmod_module_get_module(l); - - r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL); - if (r >= 0) - r = 0; - else - r = -1; - - kmod_module_unref(mod); - } - - kmod_module_unref_list(list); - kmod_unref(ctx); - - return r; -} - -static int test_tunnel_configure(sd_netlink *rtnl) { - int r; - sd_netlink_message *m, *n; - struct in_addr local, remote; - - /* skip test if module cannot be loaded */ - r = load_module("ipip"); - if(r < 0) - return EXIT_TEST_SKIP; - - if(getuid() != 0) - return EXIT_TEST_SKIP; - - /* IPIP tunnel */ - assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0); - assert_se(m); - - assert_se(sd_netlink_message_append_string(m, IFLA_IFNAME, "ipip-tunnel") >= 0); - assert_se(sd_netlink_message_append_u32(m, IFLA_MTU, 1234)>= 0); - - assert_se(sd_netlink_message_open_container(m, IFLA_LINKINFO) >= 0); - - assert_se(sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "ipip") >= 0); - - inet_pton(AF_INET, "192.168.21.1", &local.s_addr); - assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); - - inet_pton(AF_INET, "192.168.21.2", &remote.s_addr); - assert_se(sd_netlink_message_append_u32(m, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); - - assert_se(sd_netlink_message_close_container(m) >= 0); - assert_se(sd_netlink_message_close_container(m) >= 0); - - assert_se(sd_netlink_call(rtnl, m, -1, 0) == 1); - - assert_se((m = sd_netlink_message_unref(m)) == NULL); - - r = load_module("sit"); - if(r < 0) - return EXIT_TEST_SKIP; - - /* sit */ - assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0); - assert_se(n); - - assert_se(sd_netlink_message_append_string(n, IFLA_IFNAME, "sit-tunnel") >= 0); - assert_se(sd_netlink_message_append_u32(n, IFLA_MTU, 1234)>= 0); - - assert_se(sd_netlink_message_open_container(n, IFLA_LINKINFO) >= 0); - - assert_se(sd_netlink_message_open_container_union(n, IFLA_INFO_DATA, "sit") >= 0); - - assert_se(sd_netlink_message_append_u8(n, IFLA_IPTUN_PROTO, IPPROTO_IPIP) >= 0); - - inet_pton(AF_INET, "192.168.21.3", &local.s_addr); - assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_LOCAL, local.s_addr) >= 0); - - inet_pton(AF_INET, "192.168.21.4", &remote.s_addr); - assert_se(sd_netlink_message_append_u32(n, IFLA_IPTUN_REMOTE, remote.s_addr) >= 0); - - assert_se(sd_netlink_message_close_container(n) >= 0); - assert_se(sd_netlink_message_close_container(n) >= 0); - - assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1); - - assert_se((m = sd_netlink_message_unref(n)) == NULL); - - return EXIT_SUCCESS; -} - -int main(int argc, char *argv[]) { - sd_netlink *rtnl; - int r; - - assert_se(sd_netlink_open(&rtnl) >= 0); - assert_se(rtnl); - - r = test_tunnel_configure(rtnl); - - assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL); - - return r; -} |