diff options
author | Susant Sahani <susant@redhat.com> | 2014-05-06 05:41:30 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-05-06 10:04:02 (GMT) |
commit | 8f6301426a00d992d00238c7ddd666e96aa63e28 (patch) | |
tree | 264d1e1d44daf9ce6ff5d2448538b55e0dfc0567 /tests | |
parent | adb9f5d8fa605a458dbd97411564fae2584af2f7 (diff) | |
download | libnl-8f6301426a00d992d00238c7ddd666e96aa63e28.zip libnl-8f6301426a00d992d00238c7ddd666e96aa63e28.tar.gz libnl-8f6301426a00d992d00238c7ddd666e96aa63e28.tar.bz2 |
ipvti: introduce vti tunnel support
Signed-off-by: Susant Sahani <susant@redhat.com>
[thaller@redhat.com: some whitespace fixes]
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/test-create-ipvti.c | 55 |
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 584ab60..acc4f93 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ check_PROGRAMS = \ test-create-bridge \ test-create-ipgre \ test-create-ipip \ + test-create-ipvti \ test-create-sit \ test-delete-link \ test-socket-creation \ diff --git a/tests/test-create-ipvti.c b/tests/test-create-ipvti.c new file mode 100644 index 0000000..6cb92d7 --- /dev/null +++ b/tests/test-create-ipvti.c @@ -0,0 +1,55 @@ +#include <netlink/route/link/ipvti.h> +#include <netlink-private/netlink.h> + +int main(int argc, char *argv[]) +{ + struct nl_cache *link_cache; + struct rtnl_link *link; + struct in_addr addr; + struct nl_sock *sk; + int err, if_index; + + sk = nl_socket_alloc(); + if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { + nl_perror(err, "Unable to connect socket"); + return err; + } + + err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); + if ( err < 0) { + nl_perror(err, "Unable to allocate cache"); + return err; + } + + if_index = rtnl_link_name2i(link_cache, "ens33"); + if (!if_index) { + fprintf(stderr, "Unable to lookup ens33"); + return -1; + } + + link = rtnl_link_ipvti_alloc(); + if(!link) { + nl_perror(err, "Unable to allocate link"); + return -1; + + } + rtnl_link_set_name(link, "ipvti-tun"); + rtnl_link_ipvti_set_link(link, if_index); + + inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); + rtnl_link_ipvti_set_local(link, addr.s_addr); + + inet_pton(AF_INET, "192.168.254.13", &addr.s_addr); + rtnl_link_ipvti_set_remote(link, addr.s_addr); + + err = rtnl_link_add(sk, link, NLM_F_CREATE); + if (err < 0) { + nl_perror(err, "Unable to add link"); + return err; + } + + rtnl_link_put(link); + nl_close(sk); + + return 0; +} |