summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/addr.c2
-rw-r--r--src/lib/class.c2
-rw-r--r--src/lib/cls.c2
-rw-r--r--src/lib/ct.c2
-rw-r--r--src/lib/exp.c2
-rw-r--r--src/lib/link.c5
-rw-r--r--src/lib/neigh.c2
-rw-r--r--src/lib/nh.c64
-rw-r--r--src/lib/qdisc.c2
-rw-r--r--src/lib/route.c2
-rw-r--r--src/lib/rule.c2
-rw-r--r--src/lib/tc.c5
-rw-r--r--src/lib/utils.c8
13 files changed, 94 insertions, 6 deletions
diff --git a/src/lib/addr.c b/src/lib/addr.c
index a79e9b4e..7b12f367 100644
--- a/src/lib/addr.c
+++ b/src/lib/addr.c
@@ -10,6 +10,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/addr.h>
diff --git a/src/lib/class.c b/src/lib/class.c
index d7312c38..9373b077 100644
--- a/src/lib/class.c
+++ b/src/lib/class.c
@@ -9,6 +9,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/class.h>
diff --git a/src/lib/cls.c b/src/lib/cls.c
index d8fd1a8b..9c94b0de 100644
--- a/src/lib/cls.c
+++ b/src/lib/cls.c
@@ -9,6 +9,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/cls.h>
#include <netlink/route/cls/ematch.h>
diff --git a/src/lib/ct.c b/src/lib/ct.c
index c00c0fbd..959a850f 100644
--- a/src/lib/ct.c
+++ b/src/lib/ct.c
@@ -10,6 +10,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/ct.h>
diff --git a/src/lib/exp.c b/src/lib/exp.c
index 48d4ea01..dcda30c8 100644
--- a/src/lib/exp.c
+++ b/src/lib/exp.c
@@ -11,6 +11,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/exp.h>
diff --git a/src/lib/link.c b/src/lib/link.c
index d1c3e4b0..67580b46 100644
--- a/src/lib/link.c
+++ b/src/lib/link.c
@@ -10,9 +10,12 @@
* @{
*/
+#include "nl-default.h"
+
+#include <linux/if.h>
+
#include <netlink/cli/utils.h>
#include <netlink/cli/link.h>
-#include <linux/if.h>
struct rtnl_link *nl_cli_link_alloc(void)
{
diff --git a/src/lib/neigh.c b/src/lib/neigh.c
index 5b44f478..a4b211e3 100644
--- a/src/lib/neigh.c
+++ b/src/lib/neigh.c
@@ -10,6 +10,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/neigh.h>
diff --git a/src/lib/nh.c b/src/lib/nh.c
new file mode 100644
index 00000000..c1f51374
--- /dev/null
+++ b/src/lib/nh.c
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/*
+ * Copyright (c) 2022 Stanislav Zaikin <zstaseg@gmail.com>
+ */
+
+/**
+ * @ingroup cli
+ * @defgroup cli_nh nhs
+ *
+ * @{
+ */
+
+#include "nl-default.h"
+
+#include <linux/if.h>
+
+#include <netlink/cli/utils.h>
+#include <netlink/cli/nh.h>
+#include <netlink/route/nh.h>
+
+struct rtnl_nh *nl_cli_nh_alloc(void)
+{
+ struct rtnl_nh *nh;
+
+ nh = rtnl_nh_alloc();
+ if (!nh)
+ nl_cli_fatal(ENOMEM, "Unable to allocate nh object");
+
+ return nh;
+}
+
+struct nl_cache *nl_cli_nh_alloc_cache_family_flags(struct nl_sock *sock,
+ int family,
+ unsigned int flags)
+{
+ struct nl_cache *cache;
+ int err;
+
+ if ((err = rtnl_nh_alloc_cache(sock, family, &cache)) < 0)
+ nl_cli_fatal(err, "Unable to allocate nh cache: %s",
+ nl_geterror(err));
+
+ nl_cache_mngt_provide(cache);
+
+ return cache;
+}
+
+struct nl_cache *nl_cli_nh_alloc_cache_family(struct nl_sock *sock, int family)
+{
+ return nl_cli_nh_alloc_cache_family_flags(sock, family, 0);
+}
+
+struct nl_cache *nl_cli_nh_alloc_cache(struct nl_sock *sock)
+{
+ return nl_cli_nh_alloc_cache_family(sock, AF_UNSPEC);
+}
+
+struct nl_cache *nl_cli_nh_alloc_cache_flags(struct nl_sock *sock,
+ unsigned int flags)
+{
+ return nl_cli_nh_alloc_cache_family_flags(sock, AF_UNSPEC, flags);
+}
+
+/** @} */
diff --git a/src/lib/qdisc.c b/src/lib/qdisc.c
index beb83cc4..659594a3 100644
--- a/src/lib/qdisc.c
+++ b/src/lib/qdisc.c
@@ -9,6 +9,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/qdisc.h>
#include <netlink/route/class.h>
diff --git a/src/lib/route.c b/src/lib/route.c
index 7297a2f6..d814950b 100644
--- a/src/lib/route.c
+++ b/src/lib/route.c
@@ -10,6 +10,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/route.h>
diff --git a/src/lib/rule.c b/src/lib/rule.c
index 6ef93214..8a54e734 100644
--- a/src/lib/rule.c
+++ b/src/lib/rule.c
@@ -10,6 +10,8 @@
* @{
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/rule.h>
diff --git a/src/lib/tc.c b/src/lib/tc.c
index ba3de180..3bed636a 100644
--- a/src/lib/tc.c
+++ b/src/lib/tc.c
@@ -3,9 +3,12 @@
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
*/
+#include "nl-default.h"
+
#include <netlink/cli/utils.h>
#include <netlink/cli/tc.h>
-#include <netlink-private/route/tc-api.h>
+
+#include "nl-priv-dynamic-route/nl-priv-dynamic-route.h"
/**
* @ingroup cli
diff --git a/src/lib/utils.c b/src/lib/utils.c
index cbcdafe9..2839e276 100644
--- a/src/lib/utils.c
+++ b/src/lib/utils.c
@@ -15,15 +15,15 @@
* accordingly via nl_cli_fatal().
*/
-#include <netlink/cli/utils.h>
-#include <locale.h>
-
-#include "lib/defs.h"
+#include "nl-default.h"
+#include <locale.h>
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
+#include <netlink/cli/utils.h>
+
/**
* Parse a text based 32 bit unsigned integer argument
* @arg arg Integer in text form.