diff --git a/README.md b/README.md index 63c879afaed1f971f8f8b535eef961d3f5dceadb..d9dee16610826e591bf971fe43445e2c423f9ea8 100644 --- a/README.md +++ b/README.md @@ -500,7 +500,7 @@ root@iopsys:~# ubus call usp.raw setm_attributes '{"paths":[{"path":"Device.Devi API to run operate/diagnostics commands as defined in TR-369 ```bash -root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Diagnostics.", "action":"IPPing","input":{"Host":"iopsys.eu"}}' +root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Diagnostics.", "action":"IPPing()","input":{"Host":"iopsys.eu"}}' { "Results": [ { @@ -521,7 +521,7 @@ root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Diagnostics.", "action" ] } -root@iopsys:~# ubus call usp.raw operate '{"path":"Device.IP.Diagnostics.", "action":"IPPing","input":{"Host":"iopsys.eu"}}' +root@iopsys:~# ubus call usp.raw operate '{"path":"Device.IP.Diagnostics.", "action":"IPPing()","input":{"Host":"iopsys.eu"}}' { "Results": [ { @@ -547,7 +547,7 @@ root@iopsys:~# ubus call usp.raw operate '{"path":"Device.IP.Diagnostics.", "act ] } -root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Interface.[Name==\"wan\"].", "action":"Reset"}' +root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Interface.[Name==\"wan\"].", "action":"Reset()"}' { "Results": [ { @@ -561,7 +561,7 @@ root@iopsys:~# ubus call usp operate '{"path":"Device.IP.Interface.[Name==\"wan\ ] } -root@iopsys:~# ubus call usp.raw operate '{"path":"Device.IP.Interface.[Name==\"wan\"].", "action":"Reset"}' +root@iopsys:~# ubus call usp.raw operate '{"path":"Device.IP.Interface.[Name==\"wan\"].", "action":"Reset()"}' { "Results": [ { diff --git a/docs/api/usp.raw.md b/docs/api/usp.raw.md index ab49945231bfbf7d945345a37b40f1319426c65a..4d62abba79924306e8c8ab6b6a5943817d4a7cb6 100644 --- a/docs/api/usp.raw.md +++ b/docs/api/usp.raw.md @@ -2108,7 +2108,7 @@ The value of this property **must** be equal to one of the [known values below]( ### Ubus CLI Example ``` -ubus call usp.raw operate {"path":"quis proident t","action":"cillum","proto":"both","input":{}} +ubus call usp.raw operate {"path":"quis proident t","action":"cillum()","proto":"both","input":{}} ``` ### JSONRPC Example @@ -2122,7 +2122,7 @@ ubus call usp.raw operate {"path":"quis proident t","action":"cillum","proto":"b "<SID>", "usp.raw", "operate", - { "path": "quis proident t", "action": "cillum", "proto": "both", "input": {} } + { "path": "quis proident t", "action": "cillum()", "proto": "both", "input": {} } ] } ``` diff --git a/src/get_helper.c b/src/get_helper.c index 81da726efc55d9d457848eff071ec6ec985b8311..6c483b2a92b1616201ba60672cb043b29c5a6346 100644 --- a/src/get_helper.c +++ b/src/get_helper.c @@ -1364,13 +1364,13 @@ static int usp_dm_exec(struct dmctx *bbf_ctx, int cmd, char *path, char *arg1, c return fault; } -int usp_dm_exec_apply(struct dmctx *bbf_ctx, int cmd, char *arg1, char *arg2) +int usp_dm_exec_apply(struct dmctx *bbf_ctx, int cmd, char *arg1) { int fault = 0; if (sigsetjmp(gs_jump_location, 1) == 0) { gs_jump_called_by_bbf = true; - fault = dm_entry_apply(bbf_ctx, cmd, arg1, arg2); + fault = dm_entry_apply(bbf_ctx, cmd, arg1); } else { ERR("PID [%ld]::Exception on [%d] apply", getpid(), cmd); print_last_dm_object(); @@ -1414,7 +1414,7 @@ static int usp_dm_set_notif(char *path, int proto, char *arg1, char *arg2, int i } if (fault == USP_ERR_OK) - fault = usp_dm_exec_apply(&dm_ctx, CMD_SET_NOTIFICATION, NULL, NULL); + fault = usp_dm_exec_apply(&dm_ctx, CMD_SET_NOTIFICATION, NULL); bbf_cleanup(&dm_ctx); @@ -1439,13 +1439,13 @@ int usp_dm_operate(struct blob_buf *bb, char *path, char *input_params, bool raw case CMD_NOT_FOUND: fault = USP_FAULT_INVALID_PATH; break; - case UBUS_INVALID_ARGUMENTS: + case CMD_INVALID_ARGUMENTS: fault = USP_FAULT_INVALID_ARGUMENT; break; - case FAIL: + case CMD_FAIL: fault = USP_FAULT_COMMAND_FAILURE; break; - case SUCCESS: + case CMD_SUCCESS: fault = USP_ERR_OK; DEBUG("command executed successfully"); break; @@ -1455,7 +1455,7 @@ int usp_dm_operate(struct blob_buf *bb, char *path, char *input_params, bool raw break; } - if (ret == SUCCESS) { + if (ret == CMD_SUCCESS) { list_for_each_entry(n, &bbf_ctx.list_parameter, list) { add_pv_node(n->name, n->data, n->type, &pv_local); } diff --git a/src/get_helper.h b/src/get_helper.h index 1e792b15b8a9644f80130b1ee660ee96b1415e1e..a3da528e744d713d2dd0a15f117e999f714545b4 100644 --- a/src/get_helper.h +++ b/src/get_helper.h @@ -83,6 +83,6 @@ int transaction_abort(int trans_id); int configure_transaction_timeout(int timeout); void handle_pending_signal(int); void print_last_dm_object(void); -int usp_dm_exec_apply(struct dmctx *bbf_ctx, int cmd, char *arg1, char *arg2); +int usp_dm_exec_apply(struct dmctx *bbf_ctx, int cmd, char *arg1); #endif /* GET_HELPER_H */ diff --git a/src/operate.c b/src/operate.c index 78c0090581d38e2e836c90ca092def356e143bfb..81cd2303a7bfc1113e0dbfc758f9dfd9bfee99e7 100644 --- a/src/operate.c +++ b/src/operate.c @@ -28,31 +28,6 @@ #include <libbbfdm/dmbbfcommon.h> #include <libubus.h> -static int get_operate_schema_path(char *path, char *schema) -{ - char *temp; - char *tok, *save; - - schema[0] = '\0'; - temp = strdup(path); - tok = strtok_r(temp, ".", &save); - while (tok != NULL) { - if (tok[0] == '*') - strcat(schema, "{i}"); - else - strcat(schema, tok); - - tok = strtok_r(NULL, ".", &save); - - if (tok) - strcat(schema, "."); - } - free(temp); - - strcat(schema, "()"); - return 0; -} - static void usp_operate_cmd(usp_data_t *data, struct blob_buf *bb) { struct pathNode *rv; @@ -94,7 +69,6 @@ static void usp_operate_cmd(usp_data_t *data, struct blob_buf *bb) void list_operate_schema(struct blob_buf *bb) { struct dm_parameter *n; - char tmp[MAX_DM_PATH] = {'\0'}; void *array, *table, *array_arg; struct dmctx bbf_ctx; operation_args *args; @@ -110,14 +84,12 @@ void list_operate_schema(struct blob_buf *bb) array = blobmsg_open_array(bb, "parameters"); list_for_each_entry(n, &bbf_ctx.list_parameter, list) { - get_operate_schema_path(n->name, tmp); table = blobmsg_open_table(bb, NULL); - blobmsg_add_string(bb, "parameter", tmp); + blobmsg_add_string(bb, "parameter", n->name); blobmsg_add_string(bb, "type", n->type); - DEBUG("Operate node|%s|, schema|%s| type(%s)", - n->name, tmp, n->type); + DEBUG("Operate node|%s|, type(%s)", n->name, n->type); // filling in and out parameter if (n->data) { diff --git a/src/set.c b/src/set.c index 6172460d951949a0e4c87257c113b72d85e90f51..99dbe0f552f82a8af10ab54281960e63a6a0faac 100644 --- a/src/set.c +++ b/src/set.c @@ -78,7 +78,7 @@ int usp_set_value(usp_data_t *data) del_list_fault_param(p); } //Apply for all parameters - fault = usp_dm_exec_apply(&bbf_ctx, CMD_SET_VALUE, data->set_key, NULL); + fault = usp_dm_exec_apply(&bbf_ctx, CMD_SET_VALUE, data->set_key); if (fault == 0 && fault_occured == false) { blobmsg_add_u8(&bb, "status", true); if (get_bbfdatamodel_type() == BBFDM_CWMP) diff --git a/test/api/json/usp.raw.validation.json b/test/api/json/usp.raw.validation.json index e5676ab3388308e48a46c3cfd4161896df67d955..31b964e37328adcf47f1e68d44dee04e4021e556 100644 --- a/test/api/json/usp.raw.validation.json +++ b/test/api/json/usp.raw.validation.json @@ -65,7 +65,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } diff --git a/test/api/json/usp.validation.json b/test/api/json/usp.validation.json index da601f16dc191dc14b0df12da6bff26fbd5905e3..567f54d783185913d400ac95fdfba2a6b8c88b36 100644 --- a/test/api/json/usp.validation.json +++ b/test/api/json/usp.validation.json @@ -50,7 +50,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } diff --git a/test/funl/json/usp.mandatoryParam.json b/test/funl/json/usp.mandatoryParam.json index 042087c4c94cab8c90546a5cfa9f615abb9382ed..de1bd5dac68b295c6fca5bcbf89ff9137beb195c 100644 --- a/test/funl/json/usp.mandatoryParam.json +++ b/test/funl/json/usp.mandatoryParam.json @@ -150,7 +150,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } @@ -161,7 +161,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing" + "action":"IPPing()" }, "rc": 0 }, @@ -169,7 +169,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing" + "action":"IPPing()" }, "rc": 0 }, @@ -186,7 +186,7 @@ { "method": "operate", "args": { - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } diff --git a/test/funl/json/usp.raw.mandatoryParam.json b/test/funl/json/usp.raw.mandatoryParam.json index c4264f220c9e561338bdc20454b0e01864d6bfde..c7a962bcba4c410c42054d87e48443c8fd346be5 100644 --- a/test/funl/json/usp.raw.mandatoryParam.json +++ b/test/funl/json/usp.raw.mandatoryParam.json @@ -129,7 +129,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } @@ -140,7 +140,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing" + "action":"IPPing()" }, "rc": 0 }, @@ -148,7 +148,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing" + "action":"IPPing()" }, "rc": 0 }, @@ -165,7 +165,7 @@ { "method": "operate", "args": { - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } diff --git a/test/funl/json/usp.raw.validation.json b/test/funl/json/usp.raw.validation.json index 574300c387fd0940601a94f23cbb862d330bbc71..ba1924a15097e9e8800e4348ce0f881d376dfc7d 100644 --- a/test/funl/json/usp.raw.validation.json +++ b/test/funl/json/usp.raw.validation.json @@ -306,7 +306,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } diff --git a/test/funl/json/usp.validation.json b/test/funl/json/usp.validation.json index 73348ddf4c82a57bcb7b5c92a805c849fbd3d5be..0b521b4ebbd6389d86f09a495dcb92459661b23b 100644 --- a/test/funl/json/usp.validation.json +++ b/test/funl/json/usp.validation.json @@ -399,7 +399,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu" } @@ -410,7 +410,7 @@ "method": "operate", "args": { "path":"Device.IP.Diagnostics.", - "action":"IPPing", + "action":"IPPing()", "input":{ "Host":"iopsys.eu", "Host":"localhost" @@ -422,7 +422,7 @@ "method": "operate", "args": { "path":"Device.WiFi.", - "action":"NeighboringWiFiDiagnostic" + "action":"NeighboringWiFiDiagnostic()" }, "rc": 0 }, @@ -430,7 +430,7 @@ "method": "operate", "args": { "path":"Device.WiFi.SSID.1.", - "action":"NeighboringWiFiDiagnostic" + "action":"NeighboringWiFiDiagnostic()" }, "rc": 0 },