gluon-mesh-babel: move code from handle_neighbour.c into neighbours-babel
After refactoring the respondd module to work with a separate thread, handle_neighbour() is different in those two programs. A common implemenation thus is impossible and the structure is removed.
This commit is contained in:
parent
d061c97933
commit
005b8bd5f0
@ -27,5 +27,5 @@ LDFLAGS_JSONC = $(shell pkg-config --libs json-c)
|
||||
respondd.so: respondd.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -shared $(LDFLAGS_JSONC) -o $@ $^ -lgluonutil -lblobmsg_json -lubox -lubus -luci
|
||||
|
||||
neighbours-babel: neighbours-babel.c handle_neighbour.c
|
||||
neighbours-babel: neighbours-babel.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_JSONC) $(LDFLAGS) $(LDLIBS) $(LDFLAGS_JSONC) -o $@ $^
|
||||
|
@ -1,28 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "handle_neighbour.h"
|
||||
#include <libbabelhelper/babelhelper.h>
|
||||
|
||||
bool handle_neighbour(char **data, void *arg) {
|
||||
struct json_object *obj = (struct json_object*)arg;
|
||||
|
||||
if (data[NEIGHBOUR]) {
|
||||
struct json_object *neigh = json_object_new_object();
|
||||
|
||||
if (data[RXCOST])
|
||||
json_object_object_add(neigh, "rxcost", json_object_new_int(atoi(data[RXCOST])));
|
||||
if (data[TXCOST])
|
||||
json_object_object_add(neigh, "txcost", json_object_new_int(atoi(data[TXCOST])));
|
||||
if (data[COST])
|
||||
json_object_object_add(neigh, "cost", json_object_new_int(atoi(data[COST])));
|
||||
if (data[REACH])
|
||||
json_object_object_add(neigh, "reachability", json_object_new_double(strtod(data[REACH], NULL)));
|
||||
if (data[IF])
|
||||
json_object_object_add(neigh, "ifname", json_object_new_string(data[IF]));
|
||||
if (data[ADDRESS])
|
||||
json_object_object_add(obj, data[ADDRESS] , neigh);
|
||||
}
|
||||
return true;
|
||||
}
|
@ -2,8 +2,30 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <json-c/json.h>
|
||||
#include <stdlib.h>
|
||||
#include <libbabelhelper/babelhelper.h>
|
||||
#include "handle_neighbour.h"
|
||||
|
||||
bool handle_neighbour(char **data, void *arg) {
|
||||
struct json_object *obj = (struct json_object*)arg;
|
||||
|
||||
if (data[NEIGHBOUR]) {
|
||||
struct json_object *neigh = json_object_new_object();
|
||||
|
||||
if (data[RXCOST])
|
||||
json_object_object_add(neigh, "rxcost", json_object_new_int(atoi(data[RXCOST])));
|
||||
if (data[TXCOST])
|
||||
json_object_object_add(neigh, "txcost", json_object_new_int(atoi(data[TXCOST])));
|
||||
if (data[COST])
|
||||
json_object_object_add(neigh, "cost", json_object_new_int(atoi(data[COST])));
|
||||
if (data[REACH])
|
||||
json_object_object_add(neigh, "reachability", json_object_new_double(strtod(data[REACH], NULL)));
|
||||
if (data[IF])
|
||||
json_object_object_add(neigh, "ifname", json_object_new_string(data[IF]));
|
||||
if (data[ADDRESS])
|
||||
json_object_object_add(obj, data[ADDRESS] , neigh);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct json_object *neighbours;
|
||||
|
Loading…
Reference in New Issue
Block a user