From 3af8f3e907f754536846227a2356899ff353ab74 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakobols@kth.se> Date: Wed, 30 May 2018 14:20:13 +0200 Subject: [PATCH] some general clean up --- common.c | 26 -------------------------- common.h | 1 + dongle_apn.c | 8 ++++---- dongle_infrastructure.c | 7 ++----- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/common.c b/common.c index b0efcd8..70a8ff9 100644 --- a/common.c +++ b/common.c @@ -1,31 +1,5 @@ #include "common.h" -/* -TODO: - Initial - 1. system call //"ubus call router.net ipv4_routes | grep -B 7 \"usb0\" | grep \"flag. -*H\" -B 4 | grep destination" - 2. grep for [H]ost flag - 3. find IP - - Once Successful - 1. Implement by invoking ubus - -*/ - -char *get_ip(char *if_name) -{ - char response[1024] = {0}; - int rv; - FILE *fp = popen("ubus call router.net ipv4_routes | grep -B 7 \"usb0\" | grep \"flag.*H\" -B 4 | grep destination | cut -d ' ' -f2 | cut -d '\"' -f2", "r"); - - fscanf(fp, "%s", response); - pclose(fp); - printf("%s\n", response); - - return strdup(response); -} - int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx, struct ubus_request_data *req) { struct blob_buf bb; diff --git a/common.h b/common.h index ef57808..d051c0e 100644 --- a/common.h +++ b/common.h @@ -13,6 +13,7 @@ #include <limits.h> #include <libubox/list.h> #include <libubox/uloop.h> +#include <ctype.h> #include "libmobile.h" #include <json-c/json.h> diff --git a/dongle_apn.c b/dongle_apn.c index cba5f20..2739f07 100644 --- a/dongle_apn.c +++ b/dongle_apn.c @@ -2,7 +2,7 @@ static enum { IP, - DEV, + //DEV, __IP_MAX }; @@ -22,7 +22,7 @@ enum { static const struct blobmsg_policy ip_policy[__IP_MAX] = { [IP] = {.name = "ip_addr", .type = BLOBMSG_TYPE_STRING}, - [DEV] = {.name = "if_name", .type = BLOBMSG_TYPE_STRING} + //[DEV] = {.name = "if_name", .type = BLOBMSG_TYPE_STRING} }; const struct blobmsg_policy apn_policy[__APN_MAX] = { @@ -53,10 +53,10 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj, } else ip_addr = (char *)blobmsg_data(tb[IP]); - if (tb[DEV]) { + /*if (tb[DEV]) { dev = (char *)blobmsg_data(tb[DEV]); get_ip(dev); - } + }*/ response = mobile_get_apn_profiles(ip_addr); if (!response) goto fail_unknown; diff --git a/dongle_infrastructure.c b/dongle_infrastructure.c index 1992d63..afa923a 100644 --- a/dongle_infrastructure.c +++ b/dongle_infrastructure.c @@ -34,8 +34,6 @@ LIST_HEAD(visited); int devices_status(struct uloop_timeout *t) { - struct device *net_dev; - get_devices(); tag_missing_devices(); @@ -170,7 +168,7 @@ char *lexer(char **input, char *delimiter) char *reverse_lexer(char **input, char delimiter) { - char *token, *substr; + char *token; if (strlen(*input) == 0) { debug_print("empty input!\n"); @@ -362,9 +360,8 @@ int get_devices(void) add_device(node); } } + return 0; -fail_usb: - free(node); fail: return -1; } -- GitLab