[Olsr-dev] [PATCH v1 070/115] info: split out neighbors and 2hop printer functions
Ferry Huberts
(spam-protected)
Wed Dec 2 21:28:43 CET 2015
From: Ferry Huberts <(spam-protected)>
Making it all more generic
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/info/info_types.h | 4 ++--
lib/info/olsrd_info.c | 6 +++---
lib/jsoninfo/src/olsrd_jsoninfo.c | 10 +++++++++-
lib/jsoninfo/src/olsrd_jsoninfo.h | 3 ++-
lib/txtinfo/src/olsrd_txtinfo.c | 9 ++++++++-
lib/txtinfo/src/olsrd_txtinfo.h | 3 ++-
6 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/lib/info/info_types.h b/lib/info/info_types.h
index 38dcb0c..cb8ba03 100644
--- a/lib/info/info_types.h
+++ b/lib/info/info_types.h
@@ -76,7 +76,6 @@ typedef void (*init_plugin)(const char *plugin_name);
typedef bool (*determine_command)(const char *str, unsigned int siw);
typedef const char * (*mime_type)(unsigned int send_what);
typedef void (*output_start_end)(struct autobuf *abuf);
-typedef void (*printer_neighbors)(struct autobuf *abuf, bool list_2hop);
typedef void (*printer_generic)(struct autobuf *abuf);
typedef struct {
@@ -85,7 +84,7 @@ typedef struct {
mime_type determine_mime_type;
output_start_end output_start;
output_start_end output_end;
- printer_neighbors neighbors;
+ printer_generic neighbors;
printer_generic links;
printer_generic routes;
printer_generic topology;
@@ -96,6 +95,7 @@ typedef struct {
printer_generic version;
printer_generic olsrd_conf;
printer_generic interfaces;
+ printer_generic twohop;
printer_generic config;
printer_generic plugins;
} info_plugin_functions_t;
diff --git a/lib/info/olsrd_info.c b/lib/info/olsrd_info.c
index e807f8a..13631dd 100644
--- a/lib/info/olsrd_info.c
+++ b/lib/info/olsrd_info.c
@@ -202,7 +202,7 @@ static void send_info(unsigned int send_what, int the_socket) {
if ((send_what & SIW_LINKS) && (*functions).links)
(*(*functions).links)(&abuf);
if ((send_what & SIW_NEIGHBORS) && (*functions).neighbors)
- (*(*functions).neighbors)(&abuf, false);
+ (*(*functions).neighbors)(&abuf);
if ((send_what & SIW_TOPOLOGY) && (*functions).topology)
(*(*functions).topology)(&abuf);
if ((send_what & SIW_HNA) && (*functions).hna)
@@ -219,8 +219,8 @@ static void send_info(unsigned int send_what, int the_socket) {
(*(*functions).config)(&abuf);
if ((send_what & SIW_INTERFACES) && (*functions).interfaces)
(*(*functions).interfaces)(&abuf);
- if ((send_what & SIW_2HOP) && (*functions).neighbors)
- (*(*functions).neighbors)(&abuf, true);
+ if ((send_what & SIW_2HOP) && (*functions).twohop)
+ (*(*functions).twohop)(&abuf);
if ((send_what & SIW_VERSION) && (*functions).version)
(*(*functions).version)(&abuf);
if ((send_what & SIW_PLUGINS) && (*functions).plugins)
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
index 16ecace..2be95c6 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo.c
+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
@@ -151,7 +151,7 @@ void output_end(struct autobuf *abuf) {
abuf_puts(abuf, "\n");
}
-void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop) {
+static void ipc_print_neighbors_internal(struct autobuf *abuf, bool list_2hop) {
struct ipaddr_str buf1;
struct neighbor_entry *neigh;
struct neighbor_2_list_entry *list_2;
@@ -194,6 +194,10 @@ void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop) {
abuf_json_mark_object(false, true, abuf, NULL);
}
+void ipc_print_neighbors(struct autobuf *abuf) {
+ ipc_print_neighbors_internal(abuf, false);
+}
+
void ipc_print_links(struct autobuf *abuf) {
struct ipaddr_str buf1, buf2;
struct lqtextbuffer lqbuffer1;
@@ -618,6 +622,10 @@ void ipc_print_interfaces(struct autobuf *abuf) {
abuf_json_mark_object(false, true, abuf, NULL);
}
+void ipc_print_twohop(struct autobuf *abuf) {
+ ipc_print_neighbors_internal(abuf, true);
+}
+
void ipc_print_config(struct autobuf *abuf) {
struct ip_prefix_list *hna;
struct ipaddr_str buf, mainaddrbuf;
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.h b/lib/jsoninfo/src/olsrd_jsoninfo.h
index 71b3471..ced8389 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo.h
+++ b/lib/jsoninfo/src/olsrd_jsoninfo.h
@@ -58,7 +58,7 @@ const char * determine_mime_type(unsigned int send_what);
void output_start(struct autobuf *abuf);
void output_end(struct autobuf *abuf);
-void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop);
+void ipc_print_neighbors(struct autobuf *abuf);
void ipc_print_links(struct autobuf *abuf);
void ipc_print_routes(struct autobuf *abuf);
void ipc_print_topology(struct autobuf *abuf);
@@ -69,6 +69,7 @@ void ipc_print_sgw(struct autobuf *abuf);
void ipc_print_version(struct autobuf *abuf);
void ipc_print_olsrd_conf(struct autobuf *abuf);
void ipc_print_interfaces(struct autobuf *abuf);
+void ipc_print_twohop(struct autobuf *abuf);
void ipc_print_config(struct autobuf *abuf);
void ipc_print_plugins(struct autobuf *abuf);
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index e442550..ae80ad5 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -116,7 +116,7 @@ bool isCommand(const char *str, unsigned int siw) {
}
}
-void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop) {
+static void ipc_print_neighbors_internal(struct autobuf *abuf, bool list_2hop) {
struct ipaddr_str buf1;
struct neighbor_entry *neigh;
struct neighbor_2_list_entry *list_2;
@@ -148,6 +148,10 @@ void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop) {
abuf_puts(abuf, "\n");
}
+void ipc_print_neighbors(struct autobuf *abuf) {
+ ipc_print_neighbors_internal(abuf, false);
+}
+
void ipc_print_links(struct autobuf *abuf) {
struct ipaddr_str buf1, buf2;
struct lqtextbuffer lqbuffer1, lqbuffer2;
@@ -495,3 +499,6 @@ void ipc_print_interfaces(struct autobuf *abuf) {
abuf_puts(abuf, "\n");
}
+void ipc_print_twohop(struct autobuf *abuf) {
+ ipc_print_neighbors_internal(abuf, true);
+}
diff --git a/lib/txtinfo/src/olsrd_txtinfo.h b/lib/txtinfo/src/olsrd_txtinfo.h
index d0a0de9..80302aa 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.h
+++ b/lib/txtinfo/src/olsrd_txtinfo.h
@@ -48,7 +48,7 @@
bool isCommand(const char *str, unsigned int siw);
-void ipc_print_neighbors(struct autobuf *abuf, bool list_2hop);
+void ipc_print_neighbors(struct autobuf *abuf);
void ipc_print_links(struct autobuf *abuf);
void ipc_print_routes(struct autobuf *abuf);
void ipc_print_topology(struct autobuf *abuf);
@@ -59,5 +59,6 @@ void ipc_print_sgw(struct autobuf *abuf);
void ipc_print_version(struct autobuf *abuf);
void ipc_print_olsrd_conf(struct autobuf *abuf);
void ipc_print_interfaces(struct autobuf *abuf);
+void ipc_print_twohop(struct autobuf *abuf);
#endif /* _OLSRD_TXTINFO_PRINTERS_H */
--
2.5.0
More information about the Olsr-dev
mailing list