diff --git a/README.md b/README.md index f286b70ff154b30f85d97e0bc06e8ce3561ae83a..856ec6b682bb9c4fb3a62218eccb8293fcf60834 100644 --- a/README.md +++ b/README.md @@ -411,7 +411,7 @@ API to set multiple attributes to specific object, object name must be provided ````bash root@iopsys:~# ubus call usp setm_attributes '{"paths":[{"path":"Device.DeviceIn -fo.SerialNumber","notify-type":"1","notify":"1"}]}' +fo.SerialNumber","notify-type":"1","notify":"1"}]}' { "parameters": [ { @@ -886,6 +886,123 @@ root@iopsys:~# ubus call usp get '{"path":"Device.Users.User.*.Username"}' } ] } + +root@iopsys:~# ubus call usp.raw set '{"path":"Device.IP.Diagnostics.IPPing.DiagnosticsState", "value":"Requested", "proto":"cwmp"}' +{ + "parameters": [ + { + "path": "Device.IP.Diagnostics.IPPing.DiagnosticsState", + "status": true, + "flag": 16 + } + ] +} + +root@iopsys:~# ubus call usp.raw set '{"path":"Device.Users.User.2.Username", "value":"abc", "proto":"cwmp"}' +{ + "parameters": [ + { + "path": "Device.Users.User.2.Username", + "status": true, + "flag": 0 + } + ] +} + +root@iopsys:~# ubus call usp.raw set '{"path":"Device.Users.User.2.Username", "value":"abc"}' +{ + "parameters": [ + { + "path": "Device.Users.User.2.Username", + "status": true + } + ] +} + +root@iopsys:~# ubus call usp.raw list_inform +{ + "parameters": [ + { + "parameter": "Device.DeviceInfo.ActiveFirmwareImage", + "value": "Device.DeviceInfo.FirmwareImage.1", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.Description", + "value": "Iopsys code analysis test simulator", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.HardwareVersion", + "value": "1.0", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.Manufacturer", + "value": "iopsys", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.ManufacturerOUI", + "value": "XXX", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.ModelName", + "value": "ModelName", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.ProductClass", + "value": "FirstClass", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.ProvisioningCode", + "value": "", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.SerialNumber", + "value": "000000001", + "type": "xsd:string" + }, + { + "parameter": "Device.DeviceInfo.SoftwareVersion", + "value": "IOPSYS-CODE-ANALYSIS", + "type": "xsd:string" + }, + { + "parameter": "Device.ManagementServer.AliasBasedAddressing", + "value": "true", + "type": "xsd:boolean" + }, + { + "parameter": "Device.ManagementServer.ConnReqJabberID", + "value": "", + "type": "xsd:string" + }, + { + "parameter": "Device.ManagementServer.ConnReqXMPPConnection", + "value": "", + "type": "xsd:string" + }, + { + "parameter": "Device.ManagementServer.ConnectionRequestURL", + "value": "", + "type": "xsd:string" + }, + { + "parameter": "Device.ManagementServer.ParameterKey", + "value": "", + "type": "xsd:string" + } + ] +} + +root@iopsys:~# ubus call usp.raw init_notify '{"proto":"cwmp", "amd_version":5, "instance_mode": 0}' +root@iopsys:~# + ```` - For more info on the usp ubus API see [link](./docs/api/usp.md) diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh index 5af400118194804b065675d696618d306edc4494..dd32184823fee7bd8f5b19bb5848f506e7cc4aff 100755 --- a/gitlab-ci/install-dependencies.sh +++ b/gitlab-ci/install-dependencies.sh @@ -45,4 +45,4 @@ cp config/dmmap /etc/bbfdm/ mkdir -p /usr/share/bbfdm cp scripts/functions /usr/share/bbfdm mkdir -p /usr/lib/bbfdm - +mkdir -p /etc/icwmpd diff --git a/src/get_helper.c b/src/get_helper.c index b4644593dae1eb417e707fca8f28bf5e313d845e..1d6d2e4bc888926f0bdc95967d61f427eb53797b 100644 --- a/src/get_helper.c +++ b/src/get_helper.c @@ -1294,13 +1294,14 @@ int usp_dm_set(struct dmctx *dm_ctx, struct blob_buf *bb, char *path, char *valu } table = blobmsg_open_table(bb, NULL); + bb_add_string(bb, "path", path); if (fault) { blobmsg_add_u8(bb, "status", false); - bb_add_string(bb, "path", path); blobmsg_add_u32(bb, "fault", (uint32_t)fault); } else { blobmsg_add_u8(bb, "status", true); - bb_add_string(bb, "path", path); + //if (get_bbfdatamodel_type() == BBFDM_CWMP) + blobmsg_add_u64(bb, "flag", dm_ctx->end_session_flag); } blobmsg_close_table(bb, table); @@ -1635,3 +1636,27 @@ void fill_err_code(struct blob_buf *bb, int fault) if (bb && fault) blobmsg_add_u32(bb, "fault", fault); } + +void list_inform_params(struct blob_buf *bb) +{ + struct dm_parameter *n; + void *array, *table; + struct dmctx bbf_ctx; + + memset(&bbf_ctx, 0, sizeof(struct dmctx)); + set_bbfdatamodel_type(BBFDM_CWMP); + bbf_init(&bbf_ctx, ROOT_NODE); + + usp_dm_exec(&bbf_ctx, CMD_INFORM, "", NULL, NULL); + array = blobmsg_open_array(bb, "parameters"); + list_for_each_entry(n, &bbf_ctx.list_parameter, list) { + table = blobmsg_open_table(bb, NULL); + blobmsg_add_string(bb, "parameter", n->name); + blobmsg_add_string(bb, "value", n->data); + blobmsg_add_string(bb, "type", n->type); + blobmsg_close_table(bb, table); + } + + blobmsg_close_array(bb, array); + bbf_cleanup(&bbf_ctx); +} diff --git a/src/get_helper.h b/src/get_helper.h index cc240823fa67ff7b842943e4b76cff932a1705cb..57645d71693c5374c442bd1344c38a15802c2766 100644 --- a/src/get_helper.h +++ b/src/get_helper.h @@ -52,6 +52,7 @@ int bbf_dm_get_schema(struct list_head *pv_list); int bbf_dm_get_names(struct dmctx *bbf_ctx, char *path, char *next); int bbf_dm_list_operate(struct dmctx *bbf_ctx); +void list_inform_params(struct blob_buf *bb); int usp_dm_set(struct dmctx *dm_ctx, struct blob_buf *bb, char *path, char *value, char *key); diff --git a/src/usp.c b/src/usp.c index 1669120dadb6f8844763b266413b2b21f90685d4..cb40992a73d360792e491c7bd94df653ffe75ef7 100644 --- a/src/usp.c +++ b/src/usp.c @@ -84,6 +84,13 @@ enum { __DM_SET_MAX, }; +enum { + DM_INIT_NOTIFY_PROTO, + DM_INIT_NOTIFY_AMD, + DM_INIT_NOTIFY_INSTANCE, + __DM_INIT_NOTIFY_MAX, +}; + enum { DM_GET_SAFE_PATHS, DM_GET_SAFE_PROTO, @@ -781,9 +788,67 @@ int usp_list_operate(struct ubus_context *actx, struct ubus_object *obj, return 0; } +int usp_list_inform_params(struct ubus_context *actx, struct ubus_object *obj, + struct ubus_request_data *req, const char *method, + struct blob_attr *msg __attribute__((unused))) +{ + struct blob_buf bb; + + memset(&bb, 0, sizeof(struct blob_buf)); + blob_buf_init(&bb, 0); + + INFO("ubus method|%s|, name|%s|", method, obj->name); + + list_inform_params(&bb); + + ubus_send_reply(actx, req, bb.head); + blob_buf_free(&bb); + return 0; +} + +static const struct blobmsg_policy dm_init_notify_policy[] = { + [DM_INIT_NOTIFY_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, + [DM_INIT_NOTIFY_AMD] = { .name = "amd_version", .type = BLOBMSG_TYPE_INT32 }, + [DM_INIT_NOTIFY_INSTANCE] = { .name = "instance_mode", .type = BLOBMSG_TYPE_INT32 }, +}; + +int usp_init_notify_file(__attribute__((unused)) struct ubus_context *ctx, + struct ubus_object *obj, + __attribute__((unused)) struct ubus_request_data *req, + const char *method, + struct blob_attr *msg) +{ + int proto, amd, instance; + struct blob_attr *tb[__DM_INIT_NOTIFY_MAX] = {NULL}; + + if (blobmsg_parse(dm_init_notify_policy, __DM_INIT_NOTIFY_MAX, tb, blob_data(msg), blob_len(msg))) { + ERR("Failed to parse blob"); + return UBUS_STATUS_UNKNOWN_ERROR; + } + + if (!tb[DM_INIT_NOTIFY_PROTO] || + !tb[DM_INIT_NOTIFY_AMD] || + !tb[DM_INIT_NOTIFY_INSTANCE]) + return UBUS_STATUS_INVALID_ARGUMENT; + + INFO("ubus method|%s|, name|%s|", method, obj->name); + + proto = get_bbf_proto_type(tb[DM_INIT_NOTIFY_PROTO]); + amd = blobmsg_get_u32(tb[DM_INIT_NOTIFY_AMD]); + instance = blobmsg_get_u32(tb[DM_INIT_NOTIFY_INSTANCE]); + + DEBUG("proto(%zd), amd(%zd), instance(%zd)", proto, amd, instance); + dmbbf_update_enabled_notify_file(proto, amd, instance); + + DEBUG("init of notify file done"); + + return 0; +} + static struct ubus_method usp_methods[] = { UBUS_METHOD_NOARG("dump_schema", usp_list_schema), UBUS_METHOD_NOARG("list_operate", usp_list_operate), + UBUS_METHOD_NOARG("list_inform", usp_list_inform_params), UBUS_METHOD("get", usp_get_handler, dm_get_policy), UBUS_METHOD("object_names", usp_get_handler, dm_get_policy), UBUS_METHOD("instances", usp_get_handler, dm_get_policy), @@ -796,6 +861,7 @@ static struct ubus_method usp_methods[] = { UBUS_METHOD("getm_names", usp_get_safe_names, dm_get_safe_policy), UBUS_METHOD("getm_attributes", usp_get_attributes, dm_get_safe_policy), UBUS_METHOD("setm_attributes", usp_set_safe_attributes, dm_sets_policy), + UBUS_METHOD("init_notify", usp_init_notify_file, dm_init_notify_policy), }; static struct ubus_object_type usp_type = UBUS_OBJECT_TYPE("usp", usp_methods);