bbfdm: update usp to bbfdm

This commit is contained in:
Amin Ben Romdhane 2023-05-19 15:20:48 +02:00
parent 60405b300a
commit e028ab8fda
25 changed files with 248 additions and 249 deletions

3
bbfdmd/.gitignore vendored
View file

@ -9,8 +9,7 @@
ipkg-arm_xscale/ ipkg-arm_xscale/
*.o *.o
*.so *.so
src/uspd src/bbfdmd
uspd
*.gcda *.gcda
*.gcno *.gcno
report/ report/

View file

@ -13,7 +13,7 @@ The configuration file is an `uci` file `/etc/config/bbfdm`. Sample configuratio
```bash ```bash
config bbfdmd 'bbfdmd' config bbfdmd 'bbfdmd'
option loglevel '2' option loglevel '2'
option sock '/tmp/usp.sock' option sock '/tmp/bbfdm.sock'
option transaction_timeout 10 option transaction_timeout 10
option subprocess_level '1' option subprocess_level '1'
option refresh_time '10' option refresh_time '10'
@ -35,7 +35,7 @@ For more info on the `bbfdmd` UCI configuration visit [uci documentation](../doc
`bbfdmd` internally uses both `libbbfdm-api` and `libbbfdm` to get the data-model objects. On startup it parses the uci file to check the different configurations and then based on that it registers the `bbfdm` ubus namespace. `bbfdmd` internally uses both `libbbfdm-api` and `libbbfdm` to get the data-model objects. On startup it parses the uci file to check the different configurations and then based on that it registers the `bbfdm` ubus namespace.
When a ubus method is called it first fills `usp_data_t` structure with the necessary information, then proceeds the `Get/Set/Operate/Add/Del` operation based on that information. When a ubus method is called it first fills `bbfdm_data_t` structure with the necessary information, then proceeds the `Get/Set/Operate/Add/Del` operation based on that information.
`bbfdmd` uses `bbf_entry_method` API from `libbbfdm-api` and `tEntryRoot`, `tVendorExtension`, `tVendorExtensionOverwrite` and `tVendorExtensionExclude` global shared arrays from `libbbfdm` to get the device tree schema and its values. `bbfdmd` uses `bbf_entry_method` API from `libbbfdm-api` and `tEntryRoot`, `tVendorExtension`, `tVendorExtensionOverwrite` and `tVendorExtensionExclude` global shared arrays from `libbbfdm` to get the device tree schema and its values.

View file

@ -8,7 +8,7 @@ ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}")
IF(${BBFDMD_MAX_MSG_LEN}) IF(${BBFDMD_MAX_MSG_LEN})
ADD_DEFINITIONS(-DUSPD_MAX_MSG_LEN=${BBFDMD_MAX_MSG_LEN}) ADD_DEFINITIONS(-DBBFDM_MAX_MSG_LEN=${BBFDMD_MAX_MSG_LEN})
ENDIF() ENDIF()
FILE(GLOB BBF_SOURCES *.c) FILE(GLOB BBF_SOURCES *.c)

View file

@ -1,5 +1,5 @@
/* /*
* add_delete.c: Add/Delete handler for uspd * add_delete.c: Add/Delete handler for bbfdmd
* *
* Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved.
* *
@ -25,9 +25,9 @@
#include "add_delete.h" #include "add_delete.h"
#include "get_helper.h" #include "get_helper.h"
typedef int (*ADD_DEL_CB_T)(usp_data_t *data); typedef int (*ADD_DEL_CB_T)(bbfdm_data_t *data);
static int usp_add_object(usp_data_t *data) static int bbfdm_add_object(bbfdm_data_t *data)
{ {
int fault = 0; int fault = 0;
@ -35,7 +35,7 @@ static int usp_add_object(usp_data_t *data)
void *array = blobmsg_open_array(&data->bb, "results"); void *array = blobmsg_open_array(&data->bb, "results");
fault = usp_dm_exec(&data->bbf_ctx, BBF_ADD_OBJECT); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_ADD_OBJECT);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -50,7 +50,7 @@ static int usp_add_object(usp_data_t *data)
return fault; return fault;
} }
static int usp_del_object(usp_data_t *data) static int bbfdm_del_object(bbfdm_data_t *data)
{ {
struct pathNode *pn; struct pathNode *pn;
int fault = 0; int fault = 0;
@ -64,7 +64,7 @@ static int usp_del_object(usp_data_t *data)
INFO("Req to delete object |%s|", data->bbf_ctx.in_param); INFO("Req to delete object |%s|", data->bbf_ctx.in_param);
fault = usp_dm_exec(&data->bbf_ctx, BBF_DEL_OBJECT); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_DEL_OBJECT);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -82,7 +82,7 @@ static int usp_del_object(usp_data_t *data)
return fault; return fault;
} }
static int handle_add_del_req(usp_data_t *data, ADD_DEL_CB_T req_cb) static int handle_add_del_req(bbfdm_data_t *data, ADD_DEL_CB_T req_cb)
{ {
int fault = 0; int fault = 0;
@ -91,12 +91,12 @@ static int handle_add_del_req(usp_data_t *data, ADD_DEL_CB_T req_cb)
return fault; return fault;
} }
int create_add_response(usp_data_t *data) int create_add_response(bbfdm_data_t *data)
{ {
return handle_add_del_req(data, &usp_add_object); return handle_add_del_req(data, &bbfdm_add_object);
} }
int create_del_response(usp_data_t *data) int create_del_response(bbfdm_data_t *data)
{ {
return handle_add_del_req(data, &usp_del_object); return handle_add_del_req(data, &bbfdm_del_object);
} }

View file

@ -17,7 +17,7 @@ enum {
__DM_DEL_MAX __DM_DEL_MAX
}; };
int create_add_response(usp_data_t *data); int create_add_response(bbfdm_data_t *data);
int create_del_response(usp_data_t *data); int create_del_response(bbfdm_data_t *data);
#endif /* ADD_DEL_H */ #endif /* ADD_DEL_H */

View file

@ -48,7 +48,7 @@ extern struct list_head loaded_json_files;
extern struct list_head json_list; extern struct list_head json_list;
extern struct list_head json_memhead; extern struct list_head json_memhead;
#define USP_SUBPROCESS_DEPTH (2) #define bbfdm_SUBPROCESS_DEPTH (2)
#define BBF_SCHEMA_UPDATE_TIMEOUT (60 * 1000) #define BBF_SCHEMA_UPDATE_TIMEOUT (60 * 1000)
#define BBF_INSTANCES_UPDATE_TIMEOUT (25 * 1000) #define BBF_INSTANCES_UPDATE_TIMEOUT (25 * 1000)
@ -56,7 +56,7 @@ extern struct list_head json_memhead;
// Global variables // Global variables
static unsigned int g_refresh_time = BBF_INSTANCES_UPDATE_TIMEOUT; static unsigned int g_refresh_time = BBF_INSTANCES_UPDATE_TIMEOUT;
static int g_subprocess_level = USP_SUBPROCESS_DEPTH; static int g_subprocess_level = bbfdm_SUBPROCESS_DEPTH;
static void *deamon_lib_handle = NULL; static void *deamon_lib_handle = NULL;
static json_object *deamon_json_obj = NULL; static json_object *deamon_json_obj = NULL;
@ -91,7 +91,7 @@ static void usage(char *prog)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
static void usp_cleanup(struct usp_context *u) static void bbfdm_cleanup(struct bbfdm_context *u)
{ {
free_path_list(&u->instances); free_path_list(&u->instances);
free_path_list(&u->old_instances); free_path_list(&u->old_instances);
@ -110,7 +110,7 @@ static void usp_cleanup(struct usp_context *u)
} }
} }
static bool is_sync_operate_cmd(usp_data_t *data __attribute__((unused))) static bool is_sync_operate_cmd(bbfdm_data_t *data __attribute__((unused)))
{ {
return false; return false;
} }
@ -130,7 +130,7 @@ static bool is_subprocess_required(const char *path)
return ret; return ret;
} }
static void fill_optional_data(usp_data_t *data, struct blob_attr *msg) static void fill_optional_data(bbfdm_data_t *data, struct blob_attr *msg)
{ {
struct blob_attr *attr; struct blob_attr *attr;
size_t rem; size_t rem;
@ -166,14 +166,14 @@ static void fill_optional_data(usp_data_t *data, struct blob_attr *msg)
data->is_raw ? "raw" : "pretty"); data->is_raw ? "raw" : "pretty");
} }
static void async_req_free(struct uspd_async_req *r) static void async_req_free(struct bbfdm_async_req *r)
{ {
free(r); free(r);
} }
static void async_complete_cb(struct uloop_process *p, __attribute__((unused)) int ret) static void async_complete_cb(struct uloop_process *p, __attribute__((unused)) int ret)
{ {
struct uspd_async_req *r = container_of(p, struct uspd_async_req, process); struct bbfdm_async_req *r = container_of(p, struct bbfdm_async_req, process);
if (r) { if (r) {
INFO("Async call with pid(%d) completes", r->process.pid); INFO("Async call with pid(%d) completes", r->process.pid);
@ -188,9 +188,9 @@ static void async_complete_cb(struct uloop_process *p, __attribute__((unused)) i
} }
static struct uspd_async_req *async_req_new(void) static struct bbfdm_async_req *async_req_new(void)
{ {
struct uspd_async_req *r = malloc(sizeof(*r)); struct bbfdm_async_req *r = malloc(sizeof(*r));
if (r) { if (r) {
memset(&r->process, 0, sizeof(r->process)); memset(&r->process, 0, sizeof(r->process));
@ -200,11 +200,11 @@ static struct uspd_async_req *async_req_new(void)
return r; return r;
} }
static int uspd_start_deferred(usp_data_t *data, void (*EXEC_CB)(usp_data_t *data, void *d)) static int bbfdm_start_deferred(bbfdm_data_t *data, void (*EXEC_CB)(bbfdm_data_t *data, void *d))
{ {
struct uspd_async_req *r = NULL; struct bbfdm_async_req *r = NULL;
pid_t child; pid_t child;
struct usp_context *u; struct bbfdm_context *u;
void *result = NULL; void *result = NULL;
result = mmap(NULL, DEF_IPC_DATA_LEN, PROT_READ| PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); result = mmap(NULL, DEF_IPC_DATA_LEN, PROT_READ| PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
@ -224,9 +224,9 @@ static int uspd_start_deferred(usp_data_t *data, void (*EXEC_CB)(usp_data_t *dat
ERR("fork error"); ERR("fork error");
goto err_out; goto err_out;
} else if (child == 0) { } else if (child == 0) {
u = container_of(data->ctx, struct usp_context, ubus_ctx); u = container_of(data->ctx, struct bbfdm_context, ubus_ctx);
if (u == NULL) { if (u == NULL) {
ERR("Failed to get the usp context"); ERR("Failed to get the bbfdm context");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -243,14 +243,14 @@ static int uspd_start_deferred(usp_data_t *data, void (*EXEC_CB)(usp_data_t *dat
INFO("Calling from subprocess"); INFO("Calling from subprocess");
EXEC_CB(data, result); EXEC_CB(data, result);
usp_cleanup(u); bbfdm_cleanup(u);
closelog(); closelog();
/* write result and exit */ /* write result and exit */
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
// parent // parent
INFO("Creating usp(%d) sub process(%d) for path(%s)", getpid(), child, data->bbf_ctx.in_param); INFO("Creating bbfdm(%d) sub process(%d) for path(%s)", getpid(), child, data->bbf_ctx.in_param);
r->result = result; r->result = result;
r->ctx = data->ctx; r->ctx = data->ctx;
r->process.pid = child; r->process.pid = child;
@ -269,11 +269,11 @@ err_out:
return UBUS_STATUS_UNKNOWN_ERROR; return UBUS_STATUS_UNKNOWN_ERROR;
} }
static bool is_object_schema_update_available(struct usp_context *u) static bool is_object_schema_update_available(struct bbfdm_context *u)
{ {
size_t ll, min_len; size_t ll, min_len;
LIST_HEAD(paths_list); LIST_HEAD(paths_list);
usp_data_t data = { bbfdm_data_t data = {
.is_raw = true, .is_raw = true,
.plist = &paths_list, .plist = &paths_list,
.bbf_ctx.nextlevel = false, .bbf_ctx.nextlevel = false,
@ -327,17 +327,17 @@ static const struct blobmsg_policy dm_get_policy[] = {
[DM_GET_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE}, [DM_GET_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE},
}; };
static int usp_get_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), static int bbfdm_get_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
struct ubus_request_data *req, const char *method __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)),
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_GET_MAX]; struct blob_attr *tb[__DM_GET_MAX];
LIST_HEAD(paths_list); LIST_HEAD(paths_list);
usp_data_t data; bbfdm_data_t data;
uint8_t maxdepth = 0; uint8_t maxdepth = 0;
bool is_subprocess_needed = false; bool is_subprocess_needed = false;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_get_policy, __DM_GET_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_get_policy, __DM_GET_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -379,9 +379,9 @@ static int usp_get_handler(struct ubus_context *ctx, struct ubus_object *obj __a
if (is_subprocess_needed) { if (is_subprocess_needed) {
INFO("Creating subprocess for get method"); INFO("Creating subprocess for get method");
uspd_start_deferred(&data, usp_get_value_async); bbfdm_start_deferred(&data, bbfdm_get_value_async);
} else { } else {
usp_get_value(&data); bbfdm_get_value(&data);
} }
free_path_list(&paths_list); free_path_list(&paths_list);
@ -398,15 +398,15 @@ static const struct blobmsg_policy dm_schema_policy[] = {
[DM_SCHEMA_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE}, [DM_SCHEMA_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE},
}; };
static int usp_schema_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), static int bbfdm_schema_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
struct ubus_request_data *req, const char *method __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)),
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_SCHEMA_MAX]; struct blob_attr *tb[__DM_SCHEMA_MAX];
LIST_HEAD(paths_list); LIST_HEAD(paths_list);
usp_data_t data; bbfdm_data_t data;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_schema_policy, __DM_SCHEMA_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_schema_policy, __DM_SCHEMA_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -446,7 +446,7 @@ static int usp_schema_handler(struct ubus_context *ctx, struct ubus_object *obj
blob_buf_init(&data.bb, 0); blob_buf_init(&data.bb, 0);
if (dm_type == BBFDM_CWMP) if (dm_type == BBFDM_CWMP)
usp_get_names(&data); bbfdm_get_names(&data);
else else
bbf_dm_get_supported_dm(&data); bbf_dm_get_supported_dm(&data);
@ -464,15 +464,15 @@ static const struct blobmsg_policy dm_instances_policy[] = {
[DM_INSTANCES_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [DM_INSTANCES_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
static int usp_instances_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), static int bbfdm_instances_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
struct ubus_request_data *req, const char *method __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)),
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_INSTANCES_MAX]; struct blob_attr *tb[__DM_INSTANCES_MAX];
LIST_HEAD(paths_list); LIST_HEAD(paths_list);
usp_data_t data; bbfdm_data_t data;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_instances_policy, __DM_INSTANCES_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_instances_policy, __DM_INSTANCES_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -505,7 +505,7 @@ static int usp_instances_handler(struct ubus_context *ctx, struct ubus_object *o
fill_optional_data(&data, tb[DM_INSTANCES_OPTIONAL]); fill_optional_data(&data, tb[DM_INSTANCES_OPTIONAL]);
blob_buf_init(&data.bb, 0); blob_buf_init(&data.bb, 0);
usp_get_instances(&data); bbfdm_get_instances(&data);
ubus_send_reply(ctx, req, data.bb.head); ubus_send_reply(ctx, req, data.bb.head);
blob_buf_free(&data.bb); blob_buf_free(&data.bb);
@ -520,18 +520,18 @@ static const struct blobmsg_policy dm_set_policy[] = {
[DM_SET_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [DM_SET_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
int usp_set_handler(struct ubus_context *ctx, struct ubus_object *obj, int bbfdm_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_SET_MAX] = {NULL}; struct blob_attr *tb[__DM_SET_MAX] = {NULL};
char path[PATH_MAX] = {'\0'}; char path[PATH_MAX] = {'\0'};
usp_data_t data; bbfdm_data_t data;
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
int trans_id = 0; int trans_id = 0;
LIST_HEAD(pv_list); LIST_HEAD(pv_list);
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_set_policy, __DM_SET_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_set_policy, __DM_SET_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -555,7 +555,7 @@ int usp_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
fault = fill_pvlist_set(path, tb[DM_SET_VALUE] ? blobmsg_get_string(tb[DM_SET_VALUE]) : NULL, tb[DM_SET_OBJ_PATH], &pv_list); fault = fill_pvlist_set(path, tb[DM_SET_VALUE] ? blobmsg_get_string(tb[DM_SET_VALUE]) : NULL, tb[DM_SET_OBJ_PATH], &pv_list);
if (fault) { if (fault) {
ERR("Fault in fill pvlist set path |%s|", data.bbf_ctx.in_param); ERR("Fault in fill pvlist set path |%s|", data.bbf_ctx.in_param);
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
@ -567,7 +567,7 @@ int usp_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
// no need to process it further since transaction-id is not valid // no need to process it further since transaction-id is not valid
if (data.trans_id && !is_transaction_valid(data.trans_id)) { if (data.trans_id && !is_transaction_valid(data.trans_id)) {
WARNING("Transaction not started yet"); WARNING("Transaction not started yet");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
@ -576,12 +576,12 @@ int usp_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
trans_id = transaction_start(0); trans_id = transaction_start(0);
if (trans_id == 0) { if (trans_id == 0) {
WARNING("Failed to get the lock for the transaction"); WARNING("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
} }
usp_set_value(&data); bbfdm_set_value(&data);
if (data.trans_id == 0) { if (data.trans_id == 0) {
// Internal transaction: need to commit the changes // Internal transaction: need to commit the changes
@ -603,15 +603,15 @@ static const struct blobmsg_policy dm_operate_policy[__DM_OPERATE_MAX] = {
[DM_OPERATE_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [DM_OPERATE_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
static int usp_operate_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)),
struct ubus_request_data *req, const char *method __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)),
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_OPERATE_MAX] = {NULL}; struct blob_attr *tb[__DM_OPERATE_MAX] = {NULL};
char path[MAX_DM_PATH] = {0}; char path[MAX_DM_PATH] = {0};
usp_data_t data; bbfdm_data_t data;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_operate_policy, __DM_OPERATE_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_operate_policy, __DM_OPERATE_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -636,9 +636,9 @@ static int usp_operate_handler(struct ubus_context *ctx, struct ubus_object *obj
INFO("ubus method|%s|, name|%s|, path(%s)", method, obj->name, data.bbf_ctx.in_param); INFO("ubus method|%s|, name|%s|, path(%s)", method, obj->name, data.bbf_ctx.in_param);
if (is_sync_operate_cmd(&data)) { if (is_sync_operate_cmd(&data)) {
usp_operate_cmd_sync(&data); bbfdm_operate_cmd_sync(&data);
} else { } else {
uspd_start_deferred(&data, usp_operate_cmd_async); bbfdm_start_deferred(&data, bbfdm_operate_cmd_async);
} }
return 0; return 0;
@ -650,17 +650,17 @@ static const struct blobmsg_policy dm_add_policy[] = {
[DM_ADD_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [DM_ADD_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
int usp_add_handler(struct ubus_context *ctx, struct ubus_object *obj, int bbfdm_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_ADD_MAX]; struct blob_attr *tb[__DM_ADD_MAX];
char path[PATH_MAX]; char path[PATH_MAX];
usp_data_t data; bbfdm_data_t data;
int trans_id = 0; int trans_id = 0;
int fault = 0; int fault = 0;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_add_policy, __DM_ADD_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_add_policy, __DM_ADD_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -684,7 +684,7 @@ int usp_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
// no need to process it further since transaction-id is not valid // no need to process it further since transaction-id is not valid
if (data.trans_id && !is_transaction_valid(data.trans_id)) { if (data.trans_id && !is_transaction_valid(data.trans_id)) {
WARNING("Transaction not started yet"); WARNING("Transaction not started yet");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
@ -693,7 +693,7 @@ int usp_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
trans_id = transaction_start(0); trans_id = transaction_start(0);
if (trans_id == 0) { if (trans_id == 0) {
ERR("Failed to get the lock for the transaction"); ERR("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
} }
@ -718,7 +718,7 @@ int usp_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
fault = fill_pvlist_set(path, NULL, tb[DM_ADD_OBJ_PATH], &pv_list); fault = fill_pvlist_set(path, NULL, tb[DM_ADD_OBJ_PATH], &pv_list);
if (fault) { if (fault) {
ERR("Fault in fill pvlist set path |%s|", path); ERR("Fault in fill pvlist set path |%s|", path);
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
if (data.trans_id == 0) { if (data.trans_id == 0) {
// Internal transaction: need to abort the changes // Internal transaction: need to abort the changes
@ -731,7 +731,7 @@ int usp_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
data.plist = &pv_list; data.plist = &pv_list;
usp_set_value(&data); bbfdm_set_value(&data);
free_pv_list(&pv_list); free_pv_list(&pv_list);
} }
@ -754,16 +754,16 @@ static const struct blobmsg_policy dm_del_policy[] = {
[DM_DEL_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [DM_DEL_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
int usp_del_handler(struct ubus_context *ctx, struct ubus_object *obj, int bbfdm_del_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__DM_DEL_MAX]; struct blob_attr *tb[__DM_DEL_MAX];
LIST_HEAD(paths_list); LIST_HEAD(paths_list);
usp_data_t data; bbfdm_data_t data;
int trans_id = 0; int trans_id = 0;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(dm_del_policy, __DM_DEL_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(dm_del_policy, __DM_DEL_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -804,7 +804,7 @@ int usp_del_handler(struct ubus_context *ctx, struct ubus_object *obj,
// no need to process it further since transaction-id is not valid // no need to process it further since transaction-id is not valid
if (data.trans_id && !is_transaction_valid(data.trans_id)) { if (data.trans_id && !is_transaction_valid(data.trans_id)) {
WARNING("Transaction not started yet"); WARNING("Transaction not started yet");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
@ -813,7 +813,7 @@ int usp_del_handler(struct ubus_context *ctx, struct ubus_object *obj,
trans_id = transaction_start(0); trans_id = transaction_start(0);
if (trans_id == 0) { if (trans_id == 0) {
WARNING("Failed to get the lock for the transaction"); WARNING("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR); fill_err_code_array(&data, bbfdm_FAULT_INTERNAL_ERROR);
goto end; goto end;
} }
} }
@ -848,19 +848,19 @@ static const struct blobmsg_policy transaction_policy[] = {
[TRANS_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE }, [TRANS_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
}; };
static int usp_transaction_handler(struct ubus_context *ctx, struct ubus_object *obj, static int bbfdm_transaction_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg) struct blob_attr *msg)
{ {
struct blob_attr *tb[__TRANS_MAX] = {NULL}; struct blob_attr *tb[__TRANS_MAX] = {NULL};
usp_data_t data; bbfdm_data_t data;
bool is_service_restart = true; bool is_service_restart = true;
uint32_t max_timeout = 0; uint32_t max_timeout = 0;
char *trans_cmd = "status"; char *trans_cmd = "status";
int ret; int ret;
memset(&data, 0, sizeof(usp_data_t)); memset(&data, 0, sizeof(bbfdm_data_t));
if (blobmsg_parse(transaction_policy, __TRANS_MAX, tb, blob_data(msg), blob_len(msg))) { if (blobmsg_parse(transaction_policy, __TRANS_MAX, tb, blob_data(msg), blob_len(msg))) {
ERR("Failed to parse blob"); ERR("Failed to parse blob");
@ -926,7 +926,7 @@ static const struct blobmsg_policy dm_notify_event_policy[] = {
[BBF_NOTIFY_PRAMS] = { .name = "input", .type = BLOBMSG_TYPE_TABLE }, [BBF_NOTIFY_PRAMS] = { .name = "input", .type = BLOBMSG_TYPE_TABLE },
}; };
static int usp_notify_event(struct ubus_context *ctx, struct ubus_object *obj, static int bbfdm_notify_event(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req __attribute__((unused)), const char *method, struct ubus_request_data *req __attribute__((unused)), const char *method,
struct blob_attr *msg) struct blob_attr *msg)
{ {
@ -957,15 +957,15 @@ static int usp_notify_event(struct ubus_context *ctx, struct ubus_object *obj,
} }
static struct ubus_method bbf_methods[] = { static struct ubus_method bbf_methods[] = {
UBUS_METHOD("get", usp_get_handler, dm_get_policy), UBUS_METHOD("get", bbfdm_get_handler, dm_get_policy),
UBUS_METHOD("schema", usp_schema_handler, dm_schema_policy), UBUS_METHOD("schema", bbfdm_schema_handler, dm_schema_policy),
UBUS_METHOD("instances", usp_instances_handler, dm_instances_policy), UBUS_METHOD("instances", bbfdm_instances_handler, dm_instances_policy),
UBUS_METHOD("set", usp_set_handler, dm_set_policy), UBUS_METHOD("set", bbfdm_set_handler, dm_set_policy),
UBUS_METHOD("operate", usp_operate_handler, dm_operate_policy), UBUS_METHOD("operate", bbfdm_operate_handler, dm_operate_policy),
UBUS_METHOD("add", usp_add_handler, dm_add_policy), UBUS_METHOD("add", bbfdm_add_handler, dm_add_policy),
UBUS_METHOD("del", usp_del_handler, dm_del_policy), UBUS_METHOD("del", bbfdm_del_handler, dm_del_policy),
UBUS_METHOD("transaction", usp_transaction_handler, transaction_policy), UBUS_METHOD("transaction", bbfdm_transaction_handler, transaction_policy),
UBUS_METHOD("notify_event", usp_notify_event, dm_notify_event_policy), UBUS_METHOD("notify_event", bbfdm_notify_event, dm_notify_event_policy),
}; };
static struct ubus_object_type bbf_type = UBUS_OBJECT_TYPE(UBUS_METHOD_NAME, bbf_methods); static struct ubus_object_type bbf_type = UBUS_OBJECT_TYPE(UBUS_METHOD_NAME, bbf_methods);
@ -980,12 +980,12 @@ static struct ubus_object bbf_object = {
static void periodic_schema_updater(struct uloop_timeout *t) static void periodic_schema_updater(struct uloop_timeout *t)
{ {
bool ret; bool ret;
struct usp_context *u; struct bbfdm_context *u;
struct blob_buf bb; struct blob_buf bb;
u = container_of(t, struct usp_context, schema_timer); u = container_of(t, struct bbfdm_context, schema_timer);
if (u == NULL) { if (u == NULL) {
ERR("Failed to get the usp context"); ERR("Failed to get the bbfdm context");
return; return;
} }
@ -1064,7 +1064,7 @@ static void update_instances_list(struct list_head *inst)
bbf_init(&bbf_ctx); bbf_init(&bbf_ctx);
if (0 == usp_dm_exec(&bbf_ctx, BBF_INSTANCES)) { if (0 == bbfdm_dm_exec(&bbf_ctx, BBF_INSTANCES)) {
struct dm_parameter *nptr_dp; struct dm_parameter *nptr_dp;
list_for_each_entry(nptr_dp, &bbf_ctx.list_parameter, list) { list_for_each_entry(nptr_dp, &bbf_ctx.list_parameter, list) {
@ -1078,11 +1078,11 @@ static void update_instances_list(struct list_head *inst)
static void periodic_instance_updater(struct uloop_timeout *t); static void periodic_instance_updater(struct uloop_timeout *t);
static void instance_fork_done(struct uloop_process *p, int ret) static void instance_fork_done(struct uloop_process *p, int ret)
{ {
struct uspd_async_req *r = container_of(p, struct uspd_async_req, process); struct bbfdm_async_req *r = container_of(p, struct bbfdm_async_req, process);
if (r) { if (r) {
INFO("Instance updater(%d) completed, starting a new instance timer", r->process.pid); INFO("Instance updater(%d) completed, starting a new instance timer", r->process.pid);
struct usp_context *u = (struct usp_context *)r->result; struct bbfdm_context *u = (struct bbfdm_context *)r->result;
u->instance_timer.cb = periodic_instance_updater; u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time); uloop_timeout_set(&u->instance_timer, g_refresh_time);
@ -1116,9 +1116,9 @@ static void instance_compare_publish(struct list_head *new_inst, struct list_hea
free_path_list(&inst_list); free_path_list(&inst_list);
} }
static int fork_instance_checker(struct usp_context *u) static int fork_instance_checker(struct bbfdm_context *u)
{ {
struct uspd_async_req *r = NULL; struct bbfdm_async_req *r = NULL;
pid_t child; pid_t child;
r = async_req_new(); r = async_req_new();
@ -1131,7 +1131,7 @@ static int fork_instance_checker(struct usp_context *u)
} }
child = fork(); child = fork();
if (child == 0) { if (child == 0) {
prctl(PR_SET_NAME, (unsigned long) "usp_instance"); prctl(PR_SET_NAME, (unsigned long) "bbfdm_instance");
// child initialise signal to prevent segfaults // child initialise signal to prevent segfaults
signal_init(); signal_init();
/* free fd's and memory inherited from parent */ /* free fd's and memory inherited from parent */
@ -1144,7 +1144,7 @@ static int fork_instance_checker(struct usp_context *u)
DEBUG("subprocess instances checker"); DEBUG("subprocess instances checker");
instance_compare_publish(&u->instances, &u->old_instances); instance_compare_publish(&u->instances, &u->old_instances);
usp_cleanup(u); bbfdm_cleanup(u);
closelog(); closelog();
/* write result and exit */ /* write result and exit */
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -1167,11 +1167,11 @@ err_out:
static void periodic_instance_updater(struct uloop_timeout *t) static void periodic_instance_updater(struct uloop_timeout *t)
{ {
struct usp_context *u; struct bbfdm_context *u;
u = container_of(t, struct usp_context, instance_timer); u = container_of(t, struct bbfdm_context, instance_timer);
if (u == NULL) { if (u == NULL) {
ERR("Failed to get the usp context"); ERR("Failed to get the bbfdm context");
return; return;
} }
@ -1273,7 +1273,7 @@ static int bbfdm_load_deamon_config(const char *json_path)
return err; return err;
} }
static int usp_init(struct usp_context *u) static int bbfdm_init(struct bbfdm_context *u)
{ {
INFO("Registering ubus objects...."); INFO("Registering ubus objects....");
return ubus_add_object(&u->ubus_ctx, &bbf_object); return ubus_add_object(&u->ubus_ctx, &bbf_object);
@ -1281,7 +1281,7 @@ static int usp_init(struct usp_context *u)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct usp_context usp_ctx; struct bbfdm_context bbfdm_ctx;
const char *input_json = DEFAULT_JSON_INPUT; const char *input_json = DEFAULT_JSON_INPUT;
const char *ubus_socket = NULL; const char *ubus_socket = NULL;
int err = 0, ch; int err = 0, ch;
@ -1313,15 +1313,15 @@ int main(int argc, char **argv)
openlog("bbfdm", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); openlog("bbfdm", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
memset(&usp_ctx, 0, sizeof(struct usp_context)); memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context));
INIT_LIST_HEAD(&usp_ctx.instances); INIT_LIST_HEAD(&bbfdm_ctx.instances);
INIT_LIST_HEAD(&usp_ctx.old_instances); INIT_LIST_HEAD(&bbfdm_ctx.old_instances);
INIT_LIST_HEAD(&usp_ctx.event_handlers); INIT_LIST_HEAD(&bbfdm_ctx.event_handlers);
uloop_init(); uloop_init();
err = ubus_connect_ctx(&usp_ctx.ubus_ctx, ubus_socket); err = ubus_connect_ctx(&bbfdm_ctx.ubus_ctx, ubus_socket);
if (err != UBUS_STATUS_OK) { if (err != UBUS_STATUS_OK) {
fprintf(stderr, "Failed to connect to ubus\n"); fprintf(stderr, "Failed to connect to ubus\n");
return -1; return -1;
@ -1329,31 +1329,31 @@ int main(int argc, char **argv)
signal_init(); signal_init();
err = register_events_to_ubus(&usp_ctx.ubus_ctx, &usp_ctx.event_handlers); err = register_events_to_ubus(&bbfdm_ctx.ubus_ctx, &bbfdm_ctx.event_handlers);
if (err != 0) if (err != 0)
goto exit; goto exit;
ubus_add_uloop(&usp_ctx.ubus_ctx); ubus_add_uloop(&bbfdm_ctx.ubus_ctx);
err = usp_init(&usp_ctx); err = bbfdm_init(&bbfdm_ctx);
if (err != UBUS_STATUS_OK) if (err != UBUS_STATUS_OK)
goto exit; goto exit;
usp_ctx.schema_timer.cb = periodic_schema_updater; bbfdm_ctx.schema_timer.cb = periodic_schema_updater;
uloop_timeout_set(&usp_ctx.schema_timer, BBF_SCHEMA_UPDATE_TIMEOUT); uloop_timeout_set(&bbfdm_ctx.schema_timer, BBF_SCHEMA_UPDATE_TIMEOUT);
// initial timer should be bigger to give more space to other applications to initialize // initial timer should be bigger to give more space to other applications to initialize
usp_ctx.instance_timer.cb = periodic_instance_updater; bbfdm_ctx.instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&usp_ctx.instance_timer, 3 * g_refresh_time); uloop_timeout_set(&bbfdm_ctx.instance_timer, 3 * g_refresh_time);
INFO("Waiting on uloop...."); INFO("Waiting on uloop....");
uloop_run(); uloop_run();
exit: exit:
free_ubus_event_handler(&usp_ctx.ubus_ctx, &usp_ctx.event_handlers); free_ubus_event_handler(&bbfdm_ctx.ubus_ctx, &bbfdm_ctx.event_handlers);
ubus_shutdown(&usp_ctx.ubus_ctx); ubus_shutdown(&bbfdm_ctx.ubus_ctx);
uloop_done(); uloop_done();
usp_cleanup(&usp_ctx); bbfdm_cleanup(&bbfdm_ctx);
closelog(); closelog();
return err; return err;

View file

@ -7,14 +7,14 @@
#include "libbbfdm-api/dmbbf.h" #include "libbbfdm-api/dmbbf.h"
struct uspd_async_req { struct bbfdm_async_req {
struct ubus_context *ctx; struct ubus_context *ctx;
struct ubus_request_data req; struct ubus_request_data req;
struct uloop_process process; struct uloop_process process;
void *result; void *result;
}; };
struct usp_context { struct bbfdm_context {
struct ubus_context ubus_ctx; struct ubus_context ubus_ctx;
size_t dm_schema_len; size_t dm_schema_len;
struct uloop_timeout schema_timer; struct uloop_timeout schema_timer;
@ -29,7 +29,7 @@ struct ev_handler_node {
struct list_head list; struct list_head list;
}; };
typedef struct usp_data { typedef struct bbfdm_data {
struct ubus_context *ctx; struct ubus_context *ctx;
struct ubus_request_data *req; struct ubus_request_data *req;
struct list_head *plist; struct list_head *plist;
@ -38,6 +38,6 @@ typedef struct usp_data {
uint8_t depth; uint8_t depth;
bool is_raw; bool is_raw;
int trans_id; int trans_id;
} usp_data_t; } bbfdm_data_t;
#endif /* BBFDMD_H */ #endif /* BBFDMD_H */

View file

@ -166,7 +166,7 @@ int count_delim(const char *path)
return (count - 1); return (count - 1);
} }
bool validate_msglen(usp_data_t *data) bool validate_msglen(bbfdm_data_t *data)
{ {
size_t data_len = blob_pad_len(data->bb.head); size_t data_len = blob_pad_len(data->bb.head);

View file

@ -29,9 +29,9 @@
#define GLOB_CHAR "[[+*]+" #define GLOB_CHAR "[[+*]+"
#define GLOB_EXPR "[=><]+" #define GLOB_EXPR "[=><]+"
#define GLOB_USP_PATH "[+#=><]+" #define GLOB_bbfdm_PATH "[+#=><]+"
#define USP_ERR_OK 0 #define bbfdm_ERR_OK 0
extern DMOBJ *DEAMON_DM_ROOT_OBJ; extern DMOBJ *DEAMON_DM_ROOT_OBJ;
extern DM_MAP_VENDOR *DEAMON_DM_VENDOR_EXTENSION[2]; extern DM_MAP_VENDOR *DEAMON_DM_VENDOR_EXTENSION[2];
@ -49,7 +49,7 @@ void print_warning(const char *format, ...);
void print_info(const char *format, ...); void print_info(const char *format, ...);
void print_debug(const char *format, ...); void print_debug(const char *format, ...);
bool get_boolean_string(char *value); bool get_boolean_string(char *value);
bool validate_msglen(usp_data_t *data); bool validate_msglen(bbfdm_data_t *data);
int get_dm_type(char *dm_type); int get_dm_type(char *dm_type);
int get_proto_type(const char *proto); int get_proto_type(const char *proto);

View file

@ -1,5 +1,5 @@
/* /*
* events.c: Handler to generate usp events on ubus * events.c: Handler to generate bbfdm events on ubus
* *
* Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved.
* *
@ -157,7 +157,7 @@ static void generate_blob_input(struct blob_buf *b, const char *type, struct lis
} }
} }
static void uspd_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev, static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev,
const char *type, struct blob_attr *msg) const char *type, struct blob_attr *msg)
{ {
(void)ev; (void)ev;
@ -249,7 +249,7 @@ int register_events_to_ubus(struct ubus_context *ctx, struct list_head *ev_list)
} }
memset(ev, 0, sizeof(struct ubus_event_handler)); memset(ev, 0, sizeof(struct ubus_event_handler));
ev->cb = uspd_event_handler; ev->cb = bbfdm_event_handler;
if (0 != ubus_register_event_handler(ctx, ev, ev_map_list[i].event)) { if (0 != ubus_register_event_handler(ctx, ev, ev_map_list[i].event)) {
ERR("Failed to register: %s", ev_map_list[i].event); ERR("Failed to register: %s", ev_map_list[i].event);
@ -282,7 +282,7 @@ bool is_registered_event(char *name)
bbf_init(&bbf_ctx); bbf_init(&bbf_ctx);
if (0 == usp_dm_exec(&bbf_ctx, BBF_SCHEMA)) { if (0 == bbfdm_dm_exec(&bbf_ctx, BBF_SCHEMA)) {
struct dm_parameter *param; struct dm_parameter *param;
list_for_each_entry(param, &bbf_ctx.list_parameter, list) { list_for_each_entry(param, &bbf_ctx.list_parameter, list) {

View file

@ -1,5 +1,5 @@
/* /*
* get.c: Get handler for uspd * get.c: Get handler for bbfdmd
* *
* Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved.
* *
@ -29,9 +29,9 @@
#include <libubus.h> #include <libubus.h>
void usp_get_value_async(usp_data_t *data, void *output) void bbfdm_get_value_async(bbfdm_data_t *data, void *output)
{ {
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
struct pathNode *pn; struct pathNode *pn;
void *array = NULL; void *array = NULL;
@ -46,7 +46,7 @@ void usp_get_value_async(usp_data_t *data, void *output)
data->bbf_ctx.in_param = pn->path; data->bbf_ctx.in_param = pn->path;
fault = usp_dm_exec(&data->bbf_ctx, BBF_GET_VALUE); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_GET_VALUE);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -88,9 +88,9 @@ void usp_get_value_async(usp_data_t *data, void *output)
bbf_cleanup(&data->bbf_ctx); bbf_cleanup(&data->bbf_ctx);
} }
void usp_get_value(usp_data_t *data) void bbfdm_get_value(bbfdm_data_t *data)
{ {
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
struct pathNode *pn; struct pathNode *pn;
void *array = NULL; void *array = NULL;
@ -107,7 +107,7 @@ void usp_get_value(usp_data_t *data)
data->bbf_ctx.in_param = pn->path; data->bbf_ctx.in_param = pn->path;
fault = usp_dm_exec(&data->bbf_ctx, BBF_GET_VALUE); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_GET_VALUE);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -150,9 +150,9 @@ void usp_get_value(usp_data_t *data)
bbf_cleanup(&data->bbf_ctx); bbf_cleanup(&data->bbf_ctx);
} }
void usp_get_names(usp_data_t *data) void bbfdm_get_names(bbfdm_data_t *data)
{ {
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
struct pathNode *pn; struct pathNode *pn;
bbf_init(&data->bbf_ctx); bbf_init(&data->bbf_ctx);
@ -164,7 +164,7 @@ void usp_get_names(usp_data_t *data)
data->bbf_ctx.in_param = pn->path; data->bbf_ctx.in_param = pn->path;
fault = usp_dm_exec(&data->bbf_ctx, BBF_GET_NAME); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_GET_NAME);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -192,9 +192,9 @@ void usp_get_names(usp_data_t *data)
bbf_cleanup(&data->bbf_ctx); bbf_cleanup(&data->bbf_ctx);
} }
void usp_get_instances(usp_data_t *data) void bbfdm_get_instances(bbfdm_data_t *data)
{ {
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
struct pathNode *pn; struct pathNode *pn;
bbf_init(&data->bbf_ctx); bbf_init(&data->bbf_ctx);
@ -206,7 +206,7 @@ void usp_get_instances(usp_data_t *data)
data->bbf_ctx.in_param = pn->path; data->bbf_ctx.in_param = pn->path;
fault = usp_dm_exec(&data->bbf_ctx, BBF_INSTANCES); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_INSTANCES);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -320,11 +320,11 @@ static void fill_param_schema(struct blob_buf *bb, struct dm_parameter *param)
} }
} }
int bbf_dm_get_supported_dm(usp_data_t *data) int bbf_dm_get_supported_dm(bbfdm_data_t *data)
{ {
struct dm_parameter *param; struct dm_parameter *param;
struct pathNode *pn; struct pathNode *pn;
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
bbf_init(&data->bbf_ctx); bbf_init(&data->bbf_ctx);
@ -335,7 +335,7 @@ int bbf_dm_get_supported_dm(usp_data_t *data)
data->bbf_ctx.in_param = pn->path; data->bbf_ctx.in_param = pn->path;
fault = usp_dm_exec(&data->bbf_ctx, BBF_SCHEMA); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_SCHEMA);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {

View file

@ -31,13 +31,13 @@ enum {
__DM_SCHEMA_MAX __DM_SCHEMA_MAX
}; };
void usp_get_value(usp_data_t *data); void bbfdm_get_value(bbfdm_data_t *data);
void usp_get_value_async(usp_data_t *data, void *output); void bbfdm_get_value_async(bbfdm_data_t *data, void *output);
void usp_get_names(usp_data_t *data); void bbfdm_get_names(bbfdm_data_t *data);
void usp_get_instances(usp_data_t *data); void bbfdm_get_instances(bbfdm_data_t *data);
int bbf_dm_get_supported_dm(usp_data_t *data); int bbf_dm_get_supported_dm(bbfdm_data_t *data);
#endif /* GET_H */ #endif /* GET_H */

View file

@ -1,5 +1,5 @@
/* /*
* get_helper.c: Get Fast handler for uspd * get_helper.c: Get Fast handler for bbfdmd
* *
* Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved.
* *
@ -167,12 +167,12 @@ void free_path_list(struct list_head *plist)
} }
} }
int usp_dm_exec(struct dmctx *bbf_ctx, int cmd) int bbfdm_dm_exec(struct dmctx *bbf_ctx, int cmd)
{ {
int fault = 0; int fault = 0;
if (bbf_ctx->in_param == NULL) if (bbf_ctx->in_param == NULL)
return USP_FAULT_INTERNAL_ERROR; return bbfdm_FAULT_INTERNAL_ERROR;
if (sigsetjmp(gs_jump_location, 1) == 0) { if (sigsetjmp(gs_jump_location, 1) == 0) {
gs_jump_called_by_bbf = true; gs_jump_called_by_bbf = true;
@ -180,7 +180,7 @@ int usp_dm_exec(struct dmctx *bbf_ctx, int cmd)
} else { } else {
ERR("PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param); ERR("PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param);
print_last_dm_object(); print_last_dm_object();
fault = USP_FAULT_INTERNAL_ERROR; fault = bbfdm_FAULT_INTERNAL_ERROR;
} }
gs_jump_called_by_bbf = false; gs_jump_called_by_bbf = false;
@ -191,7 +191,7 @@ int usp_dm_exec(struct dmctx *bbf_ctx, int cmd)
return fault; return fault;
} }
void fill_err_code_table(usp_data_t *data, int fault) void fill_err_code_table(bbfdm_data_t *data, int fault)
{ {
void *table = blobmsg_open_table(&data->bb, NULL); void *table = blobmsg_open_table(&data->bb, NULL);
blobmsg_add_string(&data->bb, "path", data->bbf_ctx.in_param); blobmsg_add_string(&data->bb, "path", data->bbf_ctx.in_param);
@ -200,7 +200,7 @@ void fill_err_code_table(usp_data_t *data, int fault)
blobmsg_close_table(&data->bb, table); blobmsg_close_table(&data->bb, table);
} }
void fill_err_code_array(usp_data_t *data, int fault) void fill_err_code_array(bbfdm_data_t *data, int fault)
{ {
void *array = blobmsg_open_array(&data->bb, "results"); void *array = blobmsg_open_array(&data->bb, "results");
void *table = blobmsg_open_table(&data->bb, NULL); void *table = blobmsg_open_table(&data->bb, NULL);

View file

@ -29,7 +29,7 @@ void bbf_sub_cleanup(struct dmctx *dm_ctx);
bool present_in_path_list(struct list_head *plist, char *entry); bool present_in_path_list(struct list_head *plist, char *entry);
int usp_dm_exec(struct dmctx *bbf_ctx, int cmd); int bbfdm_dm_exec(struct dmctx *bbf_ctx, int cmd);
void add_pv_list(char *para, char *val, char *type, struct list_head *pv_list); void add_pv_list(char *para, char *val, char *type, struct list_head *pv_list);
void free_pv_list(struct list_head *pv_list); void free_pv_list(struct list_head *pv_list);
@ -37,8 +37,8 @@ void free_pv_list(struct list_head *pv_list);
void add_path_list(char *param, struct list_head *plist); void add_path_list(char *param, struct list_head *plist);
void free_path_list(struct list_head *plist); void free_path_list(struct list_head *plist);
void fill_err_code_table(usp_data_t *data, int fault); void fill_err_code_table(bbfdm_data_t *data, int fault);
void fill_err_code_array(usp_data_t *data, int fault); void fill_err_code_array(bbfdm_data_t *data, int fault);
void bb_add_string(struct blob_buf *bb, const char *name, const char *value); void bb_add_string(struct blob_buf *bb, const char *name, const char *value);

View file

@ -25,8 +25,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#ifdef USPD_MAX_MSG_LEN #ifdef BBFDM_MAX_MSG_LEN
#define DEF_IPC_DATA_LEN (USPD_MAX_MSG_LEN - 128) // Configured Len - 128 bytes #define DEF_IPC_DATA_LEN (BBFDM_MAX_MSG_LEN - 128) // Configured Len - 128 bytes
#else #else
#define DEF_IPC_DATA_LEN (10 * 1024 * 1024 - 128) // 10M - 128 bytes #define DEF_IPC_DATA_LEN (10 * 1024 * 1024 - 128) // 10M - 128 bytes
#endif #endif

View file

@ -1,5 +1,5 @@
/* /*
* operate.c: Operate handler for uspd * operate.c: Operate handler for bbfdmd
* *
* Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved.
* *
@ -29,32 +29,32 @@
#include <libubus.h> #include <libubus.h>
static int usp_dm_operate(usp_data_t *data) static int bbfdm_dm_operate(bbfdm_data_t *data)
{ {
int fault = 0, ret = 0; int fault = 0, ret = 0;
void *table, *array; void *table, *array;
bbf_init(&data->bbf_ctx); bbf_init(&data->bbf_ctx);
ret = usp_dm_exec(&data->bbf_ctx, BBF_OPERATE); ret = bbfdm_dm_exec(&data->bbf_ctx, BBF_OPERATE);
// This switch should be removed in the future and will be treated internally // This switch should be removed in the future and will be treated internally
switch (ret) { switch (ret) {
case CMD_NOT_FOUND: case CMD_NOT_FOUND:
fault = USP_FAULT_INVALID_PATH; fault = bbfdm_FAULT_INVALID_PATH;
break; break;
case CMD_INVALID_ARGUMENTS: case CMD_INVALID_ARGUMENTS:
fault = USP_FAULT_INVALID_ARGUMENT; fault = bbfdm_FAULT_INVALID_ARGUMENT;
break; break;
case CMD_FAIL: case CMD_FAIL:
fault = USP_FAULT_COMMAND_FAILURE; fault = bbfdm_FAULT_COMMAND_FAILURE;
break; break;
case CMD_SUCCESS: case CMD_SUCCESS:
fault = USP_ERR_OK; fault = bbfdm_ERR_OK;
DEBUG("command executed successfully"); DEBUG("command executed successfully");
break; break;
default: default:
WARNING("Case(%d) not defined", fault); WARNING("Case(%d) not defined", fault);
fault = USP_FAULT_INVALID_PATH; fault = bbfdm_FAULT_INVALID_PATH;
break; break;
} }
@ -99,36 +99,36 @@ static int usp_dm_operate(usp_data_t *data)
bbf_cleanup(&data->bbf_ctx); bbf_cleanup(&data->bbf_ctx);
if (fault != USP_ERR_OK) { if (fault != bbfdm_ERR_OK) {
WARNING("Fault(%d) path(%s) input(%s)", fault, data->bbf_ctx.in_param, data->bbf_ctx.in_value); WARNING("Fault(%d) path(%s) input(%s)", fault, data->bbf_ctx.in_param, data->bbf_ctx.in_value);
return fault; return fault;
} }
return USP_ERR_OK; return bbfdm_ERR_OK;
} }
static void usp_operate_cmd(usp_data_t *data) static void bbfdm_operate_cmd(bbfdm_data_t *data)
{ {
void *array = blobmsg_open_array(&data->bb, "results"); void *array = blobmsg_open_array(&data->bb, "results");
usp_dm_operate(data); bbfdm_dm_operate(data);
blobmsg_close_array(&data->bb, array); blobmsg_close_array(&data->bb, array);
} }
void usp_operate_cmd_async(usp_data_t *data, void *output) void bbfdm_operate_cmd_async(bbfdm_data_t *data, void *output)
{ {
blob_buf_init(&data->bb, 0); blob_buf_init(&data->bb, 0);
usp_operate_cmd(data); bbfdm_operate_cmd(data);
memcpy(output, data->bb.head, blob_pad_len(data->bb.head)); memcpy(output, data->bb.head, blob_pad_len(data->bb.head));
blob_buf_free(&data->bb); blob_buf_free(&data->bb);
} }
void usp_operate_cmd_sync(usp_data_t *data) void bbfdm_operate_cmd_sync(bbfdm_data_t *data)
{ {
blob_buf_init(&data->bb, 0); blob_buf_init(&data->bb, 0);
usp_operate_cmd(data); bbfdm_operate_cmd(data);
ubus_send_reply(data->ctx, data->req, data->bb.head); ubus_send_reply(data->ctx, data->req, data->bb.head);
blob_buf_free(&data->bb); blob_buf_free(&data->bb);

View file

@ -14,7 +14,7 @@ enum {
__DM_OPERATE_MAX, __DM_OPERATE_MAX,
}; };
void usp_operate_cmd_async(usp_data_t *data, void *output); void bbfdm_operate_cmd_async(bbfdm_data_t *data, void *output);
void usp_operate_cmd_sync(usp_data_t *data); void bbfdm_operate_cmd_sync(bbfdm_data_t *data);
#endif /* OPERATE_H */ #endif /* OPERATE_H */

View file

@ -1,5 +1,5 @@
/* /*
* set.c: Set handler for uspd * set.c: Set handler for bbfdmd
* *
* Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved. * Copyright (C) 2023 iopsys Software Solutions AB. All rights reserved.
* *
@ -26,11 +26,11 @@
#include <libubus.h> #include <libubus.h>
int usp_set_value(usp_data_t *data) int bbfdm_set_value(bbfdm_data_t *data)
{ {
struct pvNode *pv = NULL; struct pvNode *pv = NULL;
void *array = NULL; void *array = NULL;
int fault = USP_ERR_OK; int fault = bbfdm_ERR_OK;
array = blobmsg_open_array(&data->bb, "results"); array = blobmsg_open_array(&data->bb, "results");
@ -38,7 +38,7 @@ int usp_set_value(usp_data_t *data)
data->bbf_ctx.in_param = pv->param; data->bbf_ctx.in_param = pv->param;
data->bbf_ctx.in_value = pv->val; data->bbf_ctx.in_value = pv->val;
fault = usp_dm_exec(&data->bbf_ctx, BBF_SET_VALUE); fault = bbfdm_dm_exec(&data->bbf_ctx, BBF_SET_VALUE);
if (fault) { if (fault) {
fill_err_code_table(data, fault); fill_err_code_table(data, fault);
} else { } else {
@ -62,20 +62,20 @@ int fill_pvlist_set(char *param_name, char *param_value, struct blob_attr *blob_
size_t plen = DM_STRLEN(param_name); size_t plen = DM_STRLEN(param_name);
if (plen == 0) if (plen == 0)
return USP_FAULT_INVALID_PATH; return bbfdm_FAULT_INVALID_PATH;
if (!param_value) if (!param_value)
goto blob__table; goto blob__table;
if (param_name[plen - 1] == '.') if (param_name[plen - 1] == '.')
return USP_FAULT_INVALID_PATH; return bbfdm_FAULT_INVALID_PATH;
add_pv_list(param_name, param_value, NULL, pv_list); add_pv_list(param_name, param_value, NULL, pv_list);
blob__table: blob__table:
if (!blob_table) if (!blob_table)
return USP_ERR_OK; return bbfdm_ERR_OK;
size_t tlen = (size_t)blobmsg_data_len(blob_table); size_t tlen = (size_t)blobmsg_data_len(blob_table);
@ -100,12 +100,12 @@ blob__table:
break; break;
default: default:
INFO("Unhandled set request type|%x|", blob_id(attr)); INFO("Unhandled set request type|%x|", blob_id(attr));
return USP_FAULT_INVALID_ARGUMENT; return bbfdm_FAULT_INVALID_ARGUMENT;
} }
snprintf(path, MAX_DM_PATH, "%s%s", param_name, (char *)hdr->name); snprintf(path, MAX_DM_PATH, "%s%s", param_name, (char *)hdr->name);
add_pv_list(path, value, NULL, pv_list); add_pv_list(path, value, NULL, pv_list);
} }
return USP_ERR_OK; return bbfdm_ERR_OK;
} }

View file

@ -15,7 +15,7 @@ enum {
}; };
int fill_pvlist_set(char *param_name, char *param_value, struct blob_attr *blob_table, struct list_head *pv_list); int fill_pvlist_set(char *param_name, char *param_value, struct blob_attr *blob_table, struct list_head *pv_list);
int usp_set_value(usp_data_t *data); int bbfdm_set_value(bbfdm_data_t *data);
#endif /* SET_H */ #endif /* SET_H */

View file

@ -2,7 +2,7 @@
## Path syntax and possible error cases ## Path syntax and possible error cases
Please note some error scenerios with the uspd. Please note some error scenerios with the bbfdm.
1. The path parameter value must start with 'Device.'. The command below doesn't have Device before path "Users.User." 1. The path parameter value must start with 'Device.'. The command below doesn't have Device before path "Users.User."

View file

@ -1,6 +1,6 @@
# Parallel UBUS calls # Parallel UBUS calls
All `operate` operation and `get` operation with a depth up to 'USP_SUBPROCESS_DEPTH(2)' All `operate` operation and `get` operation with a depth up to 'bbfdm_SUBPROCESS_DEPTH(2)'
runs in a parallel subprocess to avoid blocking the next call. runs in a parallel subprocess to avoid blocking the next call.
```console ```console

View file

@ -8,7 +8,7 @@
## 1. Shared library via external package ## 1. Shared library via external package
The application should bring its shared library under **'/usr/lib/bbfdm/'** path that contains the sub tree of **Objects/Parameters** and the related functions **Get/Set/Add/Delete/Operate**. The new added objects, parameters and operates will be automatically shown by icwmpd and uspd/obuspa. The application should bring its shared library under **'/usr/lib/bbfdm/'** path that contains the sub tree of **Objects/Parameters** and the related functions **Get/Set/Add/Delete/Operate**. The new added objects, parameters and operates will be automatically shown by icwmpd and bbfdmd/obuspa.
Each library should contains the Root table: **“tDynamicObj”** Each library should contains the Root table: **“tDynamicObj”**
@ -36,7 +36,7 @@ For the other tables, they are defined in the same way as the Object and Paramet
### 2. JSON File via external package ### 2. JSON File via external package
The application should bring its JSON file under **'/etc/bbfdm/json/'** path with **UCI** and **UBUS** mappings. The new added parameters will be automatically shown by icwmpd and uspd/obuspa. The application should bring its JSON file under **'/etc/bbfdm/json/'** path with **UCI** and **UBUS** mappings. The new added parameters will be automatically shown by icwmpd and bbfdmd/obuspa.
#### Some examples on JSON Definition #### Some examples on JSON Definition

View file

@ -260,45 +260,45 @@ enum {
BBF_OPERATE, BBF_OPERATE,
}; };
enum usp_fault_code_enum { enum bbfdm_fault_code_enum {
USP_FAULT_GENERAL_FAILURE = 7000, // general failure bbfdm_FAULT_GENERAL_FAILURE = 7000, // general failure
USP_FAULT_MESSAGE_NOT_UNDERSTOOD = 7001, // message was not understood bbfdm_FAULT_MESSAGE_NOT_UNDERSTOOD = 7001, // message was not understood
USP_FAULT_REQUEST_DENIED = 7002, // Cannot or will not process message bbfdm_FAULT_REQUEST_DENIED = 7002, // Cannot or will not process message
USP_FAULT_INTERNAL_ERROR = 7003, // Message failed due to an internal error bbfdm_FAULT_INTERNAL_ERROR = 7003, // Message failed due to an internal error
USP_FAULT_INVALID_ARGUMENT = 7004, // invalid values in the request elements bbfdm_FAULT_INVALID_ARGUMENT = 7004, // invalid values in the request elements
USP_FAULT_RESOURCES_EXCEEDED = 7005, // Message failed due to memory or processing limitations bbfdm_FAULT_RESOURCES_EXCEEDED = 7005, // Message failed due to memory or processing limitations
USP_FAULT_PERMISSION_DENIED = 7006, // Source endpoint does not have authorisation to use this message bbfdm_FAULT_PERMISSION_DENIED = 7006, // Source endpoint does not have authorisation to use this message
USP_FAULT_INVALID_CONFIGURATION = 7007, // invalid or unstable state bbfdm_FAULT_INVALID_CONFIGURATION = 7007, // invalid or unstable state
// ParamError codes // ParamError codes
USP_FAULT_INVALID_PATH_SYNTAX = 7008, // Requested path was invalid or a reference was invalid bbfdm_FAULT_INVALID_PATH_SYNTAX = 7008, // Requested path was invalid or a reference was invalid
USP_FAULT_PARAM_ACTION_FAILED = 7009, // Parameter failed to update for a general reason described in an err_msg element. bbfdm_FAULT_PARAM_ACTION_FAILED = 7009, // Parameter failed to update for a general reason described in an err_msg element.
USP_FAULT_UNSUPPORTED_PARAM = 7010, // Requested Path Name associated with this ParamError did not match any instantiated parameters bbfdm_FAULT_UNSUPPORTED_PARAM = 7010, // Requested Path Name associated with this ParamError did not match any instantiated parameters
USP_FAULT_INVALID_TYPE = 7011, // Unable to convert string value to correct data type bbfdm_FAULT_INVALID_TYPE = 7011, // Unable to convert string value to correct data type
USP_FAULT_INVALID_VALUE = 7012, // Out of range or invalid enumeration bbfdm_FAULT_INVALID_VALUE = 7012, // Out of range or invalid enumeration
USP_FAULT_PARAM_READ_ONLY = 7013, // Attempted to write to a read only parameter bbfdm_FAULT_PARAM_READ_ONLY = 7013, // Attempted to write to a read only parameter
USP_FAULT_VALUE_CONFLICT = 7014, // Requested value would result in an invalid configuration bbfdm_FAULT_VALUE_CONFLICT = 7014, // Requested value would result in an invalid configuration
USP_FAULT_CRUD_FAILURE = 7015, // General failure to perform the CRUD operation bbfdm_FAULT_CRUD_FAILURE = 7015, // General failure to perform the CRUD operation
USP_FAULT_OBJECT_DOES_NOT_EXIST = 7016, // Requested object instance does not exist bbfdm_FAULT_OBJECT_DOES_NOT_EXIST = 7016, // Requested object instance does not exist
USP_FAULT_CREATION_FAILURE = 7017, // General failure to create the object bbfdm_FAULT_CREATION_FAILURE = 7017, // General failure to create the object
USP_FAULT_NOT_A_TABLE = 7018, // The requested pathname was expected to be a multi-instance object, but wasn't bbfdm_FAULT_NOT_A_TABLE = 7018, // The requested pathname was expected to be a multi-instance object, but wasn't
USP_FAULT_OBJECT_NOT_CREATABLE = 7019, // Attempted to create an object which was non-creatable (for non-writable multi-instance objects) bbfdm_FAULT_OBJECT_NOT_CREATABLE = 7019, // Attempted to create an object which was non-creatable (for non-writable multi-instance objects)
USP_FAULT_SET_FAILURE = 7020, // General failure to set a parameter bbfdm_FAULT_SET_FAILURE = 7020, // General failure to set a parameter
USP_FAULT_REQUIRED_PARAM_FAILED = 7021, // The CRUD operation failed because a required parameter failed to update bbfdm_FAULT_REQUIRED_PARAM_FAILED = 7021, // The CRUD operation failed because a required parameter failed to update
USP_FAULT_COMMAND_FAILURE = 7022, // Command failed to operate bbfdm_FAULT_COMMAND_FAILURE = 7022, // Command failed to operate
USP_FAULT_COMMAND_CANCELLED = 7023, // Command failed to complete because it was cancelled bbfdm_FAULT_COMMAND_CANCELLED = 7023, // Command failed to complete because it was cancelled
USP_FAULT_OBJECT_NOT_DELETABLE = 7024, // Attempted to delete an object which was non-deletable, or object failed to be deleted bbfdm_FAULT_OBJECT_NOT_DELETABLE = 7024, // Attempted to delete an object which was non-deletable, or object failed to be deleted
USP_FAULT_UNIQUE_KEY_CONFLICT = 7025, // unique keys would conflict bbfdm_FAULT_UNIQUE_KEY_CONFLICT = 7025, // unique keys would conflict
USP_FAULT_INVALID_PATH = 7026, // Path is not present in the data model schema bbfdm_FAULT_INVALID_PATH = 7026, // Path is not present in the data model schema
// Brokered USP Record Errors // Brokered USP Record Errors
USP_FAULT_RECORD_NOT_PARSED = 7100, // Record could not be parsed bbfdm_FAULT_RECORD_NOT_PARSED = 7100, // Record could not be parsed
USP_FAULT_SECURE_SESS_REQUIRED = 7101, // A secure session must be started before pasing any records bbfdm_FAULT_SECURE_SESS_REQUIRED = 7101, // A secure session must be started before pasing any records
USP_FAULT_SECURE_SESS_NOT_SUPPORTED = 7102, // Secure session is not supported by this endpoint bbfdm_FAULT_SECURE_SESS_NOT_SUPPORTED = 7102, // Secure session is not supported by this endpoint
USP_FAULT_SEG_NOT_SUPPORTED = 7103, // Segmentation and reassembly is not supported by this endpoint bbfdm_FAULT_SEG_NOT_SUPPORTED = 7103, // Segmentation and reassembly is not supported by this endpoint
USP_FAULT_RECORD_FIELD_INVALID = 7104, // A USP record field was invalid bbfdm_FAULT_RECORD_FIELD_INVALID = 7104, // A USP record field was invalid
}; };
enum fault_code_enum { enum fault_code_enum {

View file

@ -66,69 +66,69 @@ int bbf_fault_map(unsigned int dm_type, int fault)
if (dm_type == BBFDM_USP) { if (dm_type == BBFDM_USP) {
switch(fault) { switch(fault) {
case FAULT_9000: case FAULT_9000:
out_fault = USP_FAULT_MESSAGE_NOT_UNDERSTOOD; out_fault = bbfdm_FAULT_MESSAGE_NOT_UNDERSTOOD;
break; break;
case FAULT_9001: case FAULT_9001:
out_fault = USP_FAULT_REQUEST_DENIED; out_fault = bbfdm_FAULT_REQUEST_DENIED;
break; break;
case FAULT_9002: case FAULT_9002:
out_fault = USP_FAULT_INTERNAL_ERROR; out_fault = bbfdm_FAULT_INTERNAL_ERROR;
break; break;
case FAULT_9003: case FAULT_9003:
out_fault = USP_FAULT_INVALID_ARGUMENT; out_fault = bbfdm_FAULT_INVALID_ARGUMENT;
break; break;
case FAULT_9004: case FAULT_9004:
case FAULT_9027: case FAULT_9027:
out_fault = USP_FAULT_RESOURCES_EXCEEDED; out_fault = bbfdm_FAULT_RESOURCES_EXCEEDED;
break; break;
case FAULT_9005: case FAULT_9005:
out_fault = USP_FAULT_INVALID_PATH; out_fault = bbfdm_FAULT_INVALID_PATH;
break; break;
case FAULT_9006: case FAULT_9006:
out_fault = USP_FAULT_INVALID_TYPE; out_fault = bbfdm_FAULT_INVALID_TYPE;
break; break;
case FAULT_9007: case FAULT_9007:
out_fault = USP_FAULT_INVALID_VALUE; out_fault = bbfdm_FAULT_INVALID_VALUE;
break; break;
case FAULT_9008: case FAULT_9008:
out_fault = USP_FAULT_PARAM_READ_ONLY; out_fault = bbfdm_FAULT_PARAM_READ_ONLY;
break; break;
default: default:
if (fault >= FAULT_9000) if (fault >= FAULT_9000)
out_fault = USP_FAULT_GENERAL_FAILURE; out_fault = bbfdm_FAULT_GENERAL_FAILURE;
else else
out_fault = fault; out_fault = fault;
} }
} else if (dm_type == BBFDM_CWMP) { } else if (dm_type == BBFDM_CWMP) {
switch(fault) { switch(fault) {
case USP_FAULT_GENERAL_FAILURE: case bbfdm_FAULT_GENERAL_FAILURE:
out_fault = FAULT_9002; out_fault = FAULT_9002;
break; break;
case USP_FAULT_MESSAGE_NOT_UNDERSTOOD: case bbfdm_FAULT_MESSAGE_NOT_UNDERSTOOD:
out_fault = FAULT_9000; out_fault = FAULT_9000;
break; break;
case USP_FAULT_REQUEST_DENIED: case bbfdm_FAULT_REQUEST_DENIED:
out_fault = FAULT_9001; out_fault = FAULT_9001;
break; break;
case USP_FAULT_INTERNAL_ERROR: case bbfdm_FAULT_INTERNAL_ERROR:
out_fault = FAULT_9002; out_fault = FAULT_9002;
break; break;
case USP_FAULT_INVALID_ARGUMENT: case bbfdm_FAULT_INVALID_ARGUMENT:
out_fault = FAULT_9003; out_fault = FAULT_9003;
break; break;
case USP_FAULT_RESOURCES_EXCEEDED: case bbfdm_FAULT_RESOURCES_EXCEEDED:
out_fault = FAULT_9004; out_fault = FAULT_9004;
break; break;
case USP_FAULT_INVALID_TYPE: case bbfdm_FAULT_INVALID_TYPE:
out_fault = FAULT_9006; out_fault = FAULT_9006;
break; break;
case USP_FAULT_INVALID_VALUE: case bbfdm_FAULT_INVALID_VALUE:
out_fault = FAULT_9007; out_fault = FAULT_9007;
break; break;
case USP_FAULT_PARAM_READ_ONLY: case bbfdm_FAULT_PARAM_READ_ONLY:
out_fault = FAULT_9008; out_fault = FAULT_9008;
break; break;
case USP_FAULT_INVALID_PATH: case bbfdm_FAULT_INVALID_PATH:
out_fault = FAULT_9005; out_fault = FAULT_9005;
break; break;
default: default:
@ -146,10 +146,10 @@ int bbf_entry_method(struct dmctx *ctx, int cmd)
int fault = 0; int fault = 0;
if (!ctx || !ctx->dm_entryobj) if (!ctx || !ctx->dm_entryobj)
return bbf_fault_map(ctx->dm_type, USP_FAULT_INVALID_CONFIGURATION); return bbf_fault_map(ctx->dm_type, bbfdm_FAULT_INVALID_CONFIGURATION);
if (!ctx->in_param) if (!ctx->in_param)
return bbf_fault_map(ctx->dm_type, USP_FAULT_INVALID_PATH); return bbf_fault_map(ctx->dm_type, bbfdm_FAULT_INVALID_PATH);
load_plugins(ctx); load_plugins(ctx);

View file

@ -114,7 +114,7 @@ static void send_transfer_complete_event(const char *command, const char *obj_pa
strftime(complete_time, sizeof(complete_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&complete_t)); strftime(complete_time, sizeof(complete_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&complete_t));
if (!get_response_code_status(transfer_url, res_code)) { if (!get_response_code_status(transfer_url, res_code)) {
fault_code = USP_FAULT_GENERAL_FAILURE; fault_code = bbfdm_FAULT_GENERAL_FAILURE;
snprintf(fault_string, sizeof(fault_string), "%s operation is failed, fault code (%ld)", transfer_type, res_code); snprintf(fault_string, sizeof(fault_string), "%s operation is failed, fault code (%ld)", transfer_type, res_code);
} }