diff --git a/common.c b/common.c index b0efcd8ada89634bfe1c16df7ad21334e1b80b65..70a8ff9592083d8bf78c5b666471369dfc872a05 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 ef578089a769a8077e94145034f50c6e92bd3cb9..d051c0e3e229ea52b52bdd72304749f18d423ed8 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 cba5f20fc4908211565efcd47971b31a7113929b..2739f07f90af9d274672af7c93752357a2268a4a 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 1992d63c89f0cb39f461557b2b21d46954116b9b..afa923a653a93ddf53ca153547a51bad6bd3212b 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; }