Skip to content
Snippets Groups Projects
Commit 8b45740b authored by Jakob Olsson's avatar Jakob Olsson
Browse files

add some debug print

parent 29685e57
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,8 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -119,6 +119,8 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj,
int rv; int rv;
struct json_object *response; struct json_object *response;
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg)); blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[PIN]) { if (!tb[PIN]) {
...@@ -133,6 +135,7 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -133,6 +135,7 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj,
} }
if (!pin_status(&bb, global_ip_addr)) { if (!pin_status(&bb, global_ip_addr)) {
ubus_send_reply(ctx, req, bb.head);
debug_print("pin already disabled!\n"); debug_print("pin already disabled!\n");
goto disabled; goto disabled;
} }
...@@ -149,14 +152,16 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -149,14 +152,16 @@ int disable_pin(struct ubus_context *ctx, struct ubus_object *obj,
goto fail_input_response; goto fail_input_response;
} }
disabled:
return 0; return print_to_ubus(response, ctx, req);
fail_input_response: fail_input_response:
json_object_put(response); json_object_put(response);
fail_input: fail_input:
return UBUS_STATUS_INVALID_ARGUMENT; return UBUS_STATUS_INVALID_ARGUMENT;
fail_data: fail_data:
return UBUS_STATUS_UNKNOWN_ERROR; return UBUS_STATUS_UNKNOWN_ERROR;
disabled:
return 0;
} }
int enable_pin(struct ubus_context *ctx, struct ubus_object *obj, int enable_pin(struct ubus_context *ctx, struct ubus_object *obj,
...@@ -169,6 +174,8 @@ int enable_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -169,6 +174,8 @@ int enable_pin(struct ubus_context *ctx, struct ubus_object *obj,
int rv; int rv;
struct json_object *response; struct json_object *response;
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg)); blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[PIN]) { if (!tb[PIN]) {
...@@ -185,29 +192,23 @@ int enable_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -185,29 +192,23 @@ int enable_pin(struct ubus_context *ctx, struct ubus_object *obj,
if (pin_status(&bb, global_ip_addr)) { if (pin_status(&bb, global_ip_addr)) {
debug_print("pin already enabled"); debug_print("pin already enabled");
ubus_send_reply(ctx, req, bb.head);
goto enabled; goto enabled;
} }
response = mobile_enable_pin_zte(global_ip_addr, pin);
if (!response) {
debug_print("no response from get_pin_status!\n");
goto fail_data;
}
rv = check_response(response); rv = check_response(response);
if (rv < 0) { if (rv < 0) {
debug_print("incorrect pin!\n"); debug_print("incorrect pin!\n");
goto fail_input_response; goto fail_input_response;
} }
return print_to_ubus(response, ctx, req);
enabled: enabled:
return 0; return 0;
fail_input_response: fail_input_response:
json_object_put(response); json_object_put(response);
fail_input: fail_input:
return UBUS_STATUS_INVALID_ARGUMENT; return UBUS_STATUS_INVALID_ARGUMENT;
fail_data:
return UBUS_STATUS_UNKNOWN_ERROR;
} }
int verify_pin(struct ubus_context *ctx, struct ubus_object *obj, int verify_pin(struct ubus_context *ctx, struct ubus_object *obj,
...@@ -220,6 +221,8 @@ int verify_pin(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -220,6 +221,8 @@ int verify_pin(struct ubus_context *ctx, struct ubus_object *obj,
int rv; int rv;
struct json_object *response; struct json_object *response;
memset(&bb, 0, sizeof(bb));
blob_buf_init(&bb, 0);
blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg)); blobmsg_parse(pin_policy, __PIN_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[PIN]) { if (!tb[PIN]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment