Improve fault message

This commit is contained in:
Suvendhu Hansa 2025-02-10 16:51:03 +05:30
parent 4075ec2c53
commit 8cf8920365
2 changed files with 9 additions and 4 deletions

View file

@ -767,10 +767,11 @@ static void ubus_objects_callback(struct ubus_request *req, int type __attribute
{
struct blob_attr *cur = NULL;
int rem = 0;
const struct blobmsg_policy p[3] = {
const struct blobmsg_policy p[4] = {
{ "data", BLOBMSG_TYPE_STRING },
{ "fault", BLOBMSG_TYPE_INT32 },
{ "fault_msg", BLOBMSG_TYPE_STRING },
{ "path", BLOBMSG_TYPE_STRING }
};
if (msg == NULL || req == NULL)
@ -785,13 +786,15 @@ static void ubus_objects_callback(struct ubus_request *req, int type __attribute
}
blobmsg_for_each_attr(cur, objects, rem) {
struct blob_attr *tb[3] = {0};
struct blob_attr *tb[4] = {0};
blobmsg_parse(p, 3, tb, blobmsg_data(cur), blobmsg_len(cur));
blobmsg_parse(p, 4, tb, blobmsg_data(cur), blobmsg_len(cur));
if (tb[1]) {
result->fault_code = blobmsg_get_u32(tb[1]);
snprintf(result->fault_msg, sizeof(result->fault_msg), "%s", tb[2] ? blobmsg_get_string(tb[2]) : "");
snprintf(result->fault_msg, sizeof(result->fault_msg), "%s: %s",
tb[2] ? blobmsg_get_string(tb[2]) : "Request failed for",
tb[3] ? blobmsg_get_string(tb[3]) : "");
return;
}

View file

@ -2398,6 +2398,8 @@ int cwmp_create_fault_message(struct rpc *rpc_cpe, int fault_code, const char *f
rpc_cpe->type = RPC_CPE_FAULT;
memset(cwmp_ctx.session->fault_msg, 0, sizeof(cwmp_ctx.session->fault_msg));
return 0;
}