diff options
-rw-r--r-- | tests/test-cache-mngr.c | 38 | ||||
-rw-r--r-- | tests/test-create-bond.c | 2 | ||||
-rw-r--r-- | tests/test-genl.c | 16 | ||||
-rw-r--r-- | tests/test-nf-cache-mngr.c | 23 | ||||
-rw-r--r-- | tests/test-socket-creation.c | 15 |
5 files changed, 49 insertions, 45 deletions
diff --git a/tests/test-cache-mngr.c b/tests/test-cache-mngr.c index 777bce8..2c917da 100644 --- a/tests/test-cache-mngr.c +++ b/tests/test-cache-mngr.c @@ -1,10 +1,12 @@ -#include "../src/utils.h" +#include <netlink/netlink.h> +#include <netlink/cache.h> +#include <netlink/cli/utils.h> #include <signal.h> static int quit = 0; static void change_cb(struct nl_cache *cache, struct nl_object *obj, - int action) + int action, void *data) { struct nl_dump_params dp = { .dp_type = NL_DUMP_LINE, @@ -35,32 +37,32 @@ int main(int argc, char *argv[]) signal(SIGINT, sigint); - sock = nlt_alloc_socket(); + sock = nl_cli_alloc_socket(); err = nl_cache_mngr_alloc(sock, NETLINK_ROUTE, NL_AUTO_PROVIDE, &mngr); if (err < 0) - fatal(err, "Unable to allocate cache manager: %s", - nl_geterror(err)); + nl_cli_fatal(err, "Unable to allocate cache manager: %s", + nl_geterror(err)); - if ((err = nl_cache_mngr_add(mngr, "route/link", &change_cb, &lc)) < 0) - fatal(err, "Unable to add cache route/link: %s", - nl_geterror(err)); + if ((err = nl_cache_mngr_add(mngr, "route/link", &change_cb, NULL, &lc)) < 0) + nl_cli_fatal(err, "Unable to add cache route/link: %s", + nl_geterror(err)); - if ((err = nl_cache_mngr_add(mngr, "route/neigh", &change_cb, &nc)) < 0) - fatal(err, "Unable to add cache route/neigh: %s", - nl_geterror(err)); + if ((err = nl_cache_mngr_add(mngr, "route/neigh", &change_cb, NULL, &nc)) < 0) + nl_cli_fatal(err, "Unable to add cache route/neigh: %s", + nl_geterror(err)); - if ((err = nl_cache_mngr_add(mngr, "route/addr", &change_cb, &ac)) < 0) - fatal(err, "Unable to add cache route/addr: %s", - nl_geterror(err)); + if ((err = nl_cache_mngr_add(mngr, "route/addr", &change_cb, NULL, &ac)) < 0) + nl_cli_fatal(err, "Unable to add cache route/addr: %s", + nl_geterror(err)); - if ((err = nl_cache_mngr_add(mngr, "route/route", &change_cb, &rc)) < 0) - fatal(err, "Unable to add cache route/route: %s", - nl_geterror(err)); + if ((err = nl_cache_mngr_add(mngr, "route/route", &change_cb, NULL, &rc)) < 0) + nl_cli_fatal(err, "Unable to add cache route/route: %s", + nl_geterror(err)); while (!quit) { int err = nl_cache_mngr_poll(mngr, 5000); if (err < 0 && err != -NLE_INTR) - fatal(err, "Polling failed: %s", nl_geterror(err)); + nl_cli_fatal(err, "Polling failed: %s", nl_geterror(err)); } diff --git a/tests/test-create-bond.c b/tests/test-create-bond.c index 99166aa..e54b0e6 100644 --- a/tests/test-create-bond.c +++ b/tests/test-create-bond.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) link = rtnl_link_alloc(); rtnl_link_set_name(link, "my_bond"); - if ((err = rtnl_link_set_info_type(link, "bond")) < 0) { + if ((err = rtnl_link_set_type(link, "bond")) < 0) { nl_perror(err, "Unable to set link info type"); return err; } diff --git a/tests/test-genl.c b/tests/test-genl.c index 8bf60c5..2706a92 100644 --- a/tests/test-genl.c +++ b/tests/test-genl.c @@ -1,4 +1,4 @@ -#include "../src/utils.h" +#include <netlink/cli/utils.h> int main(int argc, char *argv[]) { @@ -7,26 +7,26 @@ int main(int argc, char *argv[]) void *hdr; int err; - sock = nlt_alloc_socket(); - nlt_connect(sock, NETLINK_GENERIC); + sock = nl_cli_alloc_socket(); + nl_cli_connect(sock, NETLINK_GENERIC); msg = nlmsg_alloc(); if (msg == NULL) - fatal(NLE_NOMEM, "Unable to allocate netlink message"); + nl_cli_fatal(NLE_NOMEM, "Unable to allocate netlink message"); hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, GENL_ID_CTRL, 0, 0, CTRL_CMD_GETFAMILY, 1); if (hdr == NULL) - fatal(ENOMEM, "Unable to write genl header"); + nl_cli_fatal(ENOMEM, "Unable to write genl header"); if ((err = nla_put_u32(msg, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL)) < 0) - fatal(err, "Unable to add attribute: %s", nl_geterror(err)); + nl_cli_fatal(err, "Unable to add attribute: %s", nl_geterror(err)); if ((err = nl_send_auto_complete(sock, msg)) < 0) - fatal(err, "Unable to send message: %s", nl_geterror(err)); + nl_cli_fatal(err, "Unable to send message: %s", nl_geterror(err)); if ((err = nl_recvmsgs_default(sock)) < 0) - fatal(err, "Unable to receive message: %s", nl_geterror(err)); + nl_cli_fatal(err, "Unable to receive message: %s", nl_geterror(err)); nlmsg_free(msg); nl_close(sock); diff --git a/tests/test-nf-cache-mngr.c b/tests/test-nf-cache-mngr.c index 05485bf..b4f3022 100644 --- a/tests/test-nf-cache-mngr.c +++ b/tests/test-nf-cache-mngr.c @@ -1,13 +1,13 @@ -#include "../src/utils.h" +#include <netlink/cli/utils.h> static void change_cb(struct nl_cache *cache, struct nl_object *obj, - int action) + int action, void *data) { struct nfnl_ct *ct = (struct nfnl_ct *) obj; static struct nl_addr *hack = NULL; if (!hack) - hack = nl_addr_parse("194.88.212.233", AF_INET); + nl_addr_parse("194.88.212.233", AF_INET, &hack); if (!nl_addr_cmp(hack, nfnl_ct_get_src(ct, 1)) || !nl_addr_cmp(hack, nfnl_ct_get_dst(ct, 1))) { @@ -26,25 +26,26 @@ int main(int argc, char *argv[]) struct nl_cache_mngr *mngr; struct nl_sock *sock; struct nl_cache *ct; + int err; - sock = nlt_socket_alloc(); + sock = nl_cli_alloc_socket(); - mngr = nl_cache_mngr_alloc(sock, NETLINK_NETFILTER, NL_AUTO_PROVIDE); - if (!mngr) { - nl_perror("nl_cache_mngr_alloc"); + err = nl_cache_mngr_alloc(sock, NETLINK_NETFILTER, NL_AUTO_PROVIDE, &mngr); + if (err < 0) { + nl_perror(err, "nl_cache_mngr_alloc"); return -1; } - ct = nl_cache_mngr_add(mngr, "netfilter/ct", &change_cb); - if (ct == NULL) { - nl_perror("nl_cache_mngr_add(netfilter/ct)"); + err = nl_cache_mngr_add(mngr, "netfilter/ct", &change_cb, NULL, &ct); + if (err < 0) { + nl_perror(err, "nl_cache_mngr_add(netfilter/ct)"); return -1; } for (;;) { int err = nl_cache_mngr_poll(mngr, 5000); if (err < 0) { - nl_perror("nl_cache_mngr_poll()"); + nl_perror(err, "nl_cache_mngr_poll()"); return -1; } diff --git a/tests/test-socket-creation.c b/tests/test-socket-creation.c index a170ccd..83f3ad4 100644 --- a/tests/test-socket-creation.c +++ b/tests/test-socket-creation.c @@ -1,23 +1,24 @@ -#include "../src/utils.h" +#include <netlink/netlink.h> +#include <errno.h> int main(int argc, char *argv[]) { struct nl_sock *h[1025]; int i; - h[0] = nl_handle_alloc(); + h[0] = nl_socket_alloc(); printf("Created handle with port 0x%x\n", nl_socket_get_local_port(h[0])); - nl_handle_destroy(h[0]); - h[0] = nl_handle_alloc(); + nl_socket_free(h[0]); + h[0] = nl_socket_alloc(); printf("Created handle with port 0x%x\n", nl_socket_get_local_port(h[0])); - nl_handle_destroy(h[0]); + nl_socket_free(h[0]); for (i = 0; i < 1025; i++) { - h[i] = nl_handle_alloc(); + h[i] = nl_socket_alloc(); if (h[i] == NULL) - nl_perror("Unable to allocate socket"); + nl_perror(ENOMEM, "Unable to allocate socket"); else printf("Created handle with port 0x%x\n", nl_socket_get_local_port(h[i])); |