firewall3: add UBUS support for redirect sections
[project/firewall3.git] / utils.h
diff --git a/utils.h b/utils.h
index c74a5dd..9a716ae 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -32,6 +32,7 @@
 #include <ifaddrs.h>
 
 #include <libubox/list.h>
+#include <libubox/blob.h>
 #include <uci.h>
 
 
@@ -46,6 +47,16 @@ void warn(const char *format, ...);
 void error(const char *format, ...);
 void info(const char *format, ...);
 
+
+#define warn_section(t, r, e, fmt, ...)                                        \
+       do {                                                                    \
+               if (e)                                                          \
+                       warn_elem(e, fmt, ##__VA_ARGS__);                       \
+               else                                                            \
+                       warn("Warning: ubus " t " (%s) " fmt,                   \
+                               (r && r->name) ? r->name : "?", ##__VA_ARGS__); \
+       } while(0)
+
 #define fw3_setbit(field, flag) field |= (1 << (flag))
 #define fw3_delbit(field, flag) field &= ~(1 << (flag))
 #define fw3_hasbit(field, flag) (field & (1 << (flag)))
@@ -103,4 +114,6 @@ bool fw3_bitlen2netmask(int family, int bits, void *mask);
 
 void fw3_flush_conntrack(void *zone);
 
+bool fw3_attr_parse_name_type(struct blob_attr *entry, const char **name, const char **type);
+
 #endif