Fix bridge port lowerlayer empty value

This commit is contained in:
Vivek Kumar Dutta 2023-08-22 09:41:28 +00:00
parent ddc9e915a7
commit e7be3dad22
8 changed files with 348 additions and 98 deletions

View file

@ -1,17 +1,18 @@
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "."
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
CPPCHECK_OPTIONS: " --enable=information -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS --inline-suppr -i test/"
include:
- project: 'iopsys/gitlab-ci-pipeline'
file: '/static-code-analysis.yml'
ref: '0.27'
ref: '0.30'
- project: 'docs/portal2/pipeline-template'
file: 'MkDocs.gitlab-ci.yml'
rules:
- if: $CI_COMMIT_BRANCH == "devel"
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "."
RUN_CPPCHECK: "cppcheck --enable=information --error-exitcode=1 -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS --inline-suppr -i test/"
stages:
- static_code_analysis
- unit_test

View file

@ -54,6 +54,9 @@ extern struct list_head json_memhead;
LIST_HEAD(head_registered_service);
static void register_periodic_timers(struct ubus_context *ctx);
static void cancel_periodic_timers(struct ubus_context *ctx);
// Global variables
static unsigned int g_refresh_time = BBF_INSTANCES_UPDATE_TIMEOUT;
static int g_subprocess_level = BBF_SUBPROCESS_DEPTH;
@ -573,7 +576,7 @@ int bbfdm_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
if (data.trans_id == 0) {
// Transaction-id is not defined so create an internal transaction
trans_id = transaction_start(0);
trans_id = transaction_start("INT_SET", 0);
if (trans_id == 0) {
WARNING("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR);
@ -690,7 +693,7 @@ int bbfdm_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
if (data.trans_id == 0) {
// Transaction-id is not defined so create an internal transaction
trans_id = transaction_start(0);
trans_id = transaction_start("INT_ADD", 0);
if (trans_id == 0) {
ERR("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR);
@ -810,7 +813,7 @@ int bbfdm_del_handler(struct ubus_context *ctx, struct ubus_object *obj,
if (data.trans_id == 0) {
// Transaction-id is not defined so create an internal transaction
trans_id = transaction_start(0);
trans_id = transaction_start("INT_DEL", 0);
if (trans_id == 0) {
WARNING("Failed to get the lock for the transaction");
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR);
@ -880,30 +883,32 @@ static int bbfdm_transaction_handler(struct ubus_context *ctx, struct ubus_objec
is_service_restart = blobmsg_get_bool(tb[TRANS_RESTART]);
fill_optional_data(&data, tb[TRANS_OPTIONAL]);
if (!is_str_eq(trans_cmd, "start") && data.trans_id == 0)
return UBUS_STATUS_INVALID_ARGUMENT;
INFO("ubus method|%s|, name|%s|", method, obj->name);
INFO("ubus method|%s|, name|%s|, cmd [%s]", method, obj->name, trans_cmd);
bbf_init(&data.bbf_ctx);
blob_buf_init(&data.bb, 0);
if (is_str_eq(trans_cmd, "start")) {
ret = transaction_start(max_timeout);
cancel_periodic_timers(ctx);
ret = transaction_start("API", max_timeout);
if (ret) {
blobmsg_add_u8(&data.bb, "status", true);
blobmsg_add_u32(&data.bb, "transaction_id", ret);
} else {
blobmsg_add_u8(&data.bb, "status", false);
transaction_status(&data.bb);
}
} else if (is_str_eq(trans_cmd, "commit")) {
register_periodic_timers(ctx);
ret = transaction_commit(data.trans_id, &data.bb, is_service_restart);
blobmsg_add_u8(&data.bb, "status", (ret == 0));
} else if (is_str_eq(trans_cmd, "abort")) {
register_periodic_timers(ctx);
ret = transaction_abort(data.trans_id, &data.bb);
blobmsg_add_u8(&data.bb, "status", (ret == 0));
} else if (is_str_eq(trans_cmd, "status")) {
transaction_status(&data.bb, data.trans_id);
transaction_status(&data.bb);
} else {
WARNING("method(%s) not supported", method);
}
@ -1181,8 +1186,10 @@ static void instance_fork_done(struct uloop_process *p, int ret)
INFO("Instance updater(%d) completed, starting a new instance timer", r->process.pid);
struct bbfdm_context *u = (struct bbfdm_context *)r->result;
u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time);
if (g_refresh_time != 0) {
u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time);
}
free_path_list(&u->old_instances);
async_req_free(r);
}
@ -1221,8 +1228,10 @@ static int fork_instance_checker(struct bbfdm_context *u)
r = async_req_new();
if (r == NULL) {
ERR("Error allocating instance req");
u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time);
if (g_refresh_time != 0) {
u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time);
}
free_path_list(&u->old_instances);
goto err_out;
}
@ -1266,6 +1275,10 @@ static void periodic_instance_updater(struct uloop_timeout *t)
{
struct bbfdm_context *u;
if (g_refresh_time == 0) {
return; // periodic refresh disabled
}
u = container_of(t, struct bbfdm_context, instance_timer);
if (u == NULL) {
ERR("Failed to get the bbfdm context");
@ -1452,6 +1465,43 @@ static void lookup_event_cb(struct ubus_context *ctx,
}
}
static void cancel_periodic_timers(struct ubus_context *ctx)
{
struct bbfdm_context *u;
u = container_of(ctx, struct bbfdm_context, ubus_ctx);
if (u == NULL) {
ERR("Failed to get the bbfdm context");
return;
}
DEBUG("Cancelling schema_timer and instance_timer");
uloop_timeout_cancel(&u->schema_timer);
if (g_refresh_time != 0) {
uloop_timeout_cancel(&u->instance_timer);
}
}
static void register_periodic_timers(struct ubus_context *ctx)
{
struct bbfdm_context *u;
u = container_of(ctx, struct bbfdm_context, ubus_ctx);
if (u == NULL) {
ERR("Failed to get the bbfdm context");
return;
}
DEBUG("Register schema_timer %d and instance_timer %d", BBF_SCHEMA_UPDATE_TIMEOUT, g_refresh_time);
u->schema_timer.cb = periodic_schema_updater;
uloop_timeout_set(&u->schema_timer, BBF_SCHEMA_UPDATE_TIMEOUT);
if (g_refresh_time != 0) {
u->instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&u->instance_timer, g_refresh_time);
}
}
int main(int argc, char **argv)
{
struct bbfdm_context bbfdm_ctx;
@ -1513,13 +1563,7 @@ int main(int argc, char **argv)
if (err != 0)
goto exit;
bbfdm_ctx.schema_timer.cb = periodic_schema_updater;
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
bbfdm_ctx.instance_timer.cb = periodic_instance_updater;
uloop_timeout_set(&bbfdm_ctx.instance_timer, 3 * g_refresh_time);
register_periodic_timers(&bbfdm_ctx.ubus_ctx);
} else { // It's a micro-service instance
bool is_registred = register_service(&bbfdm_ctx.ubus_ctx);

View file

@ -74,6 +74,9 @@ int get_instance_mode(int instance_mode);
// strncpy with always 0 terminated string
static inline void strncpyt(char *dst, const char *src, size_t n)
{
if (dst == NULL || src == NULL)
return;
if (n > 1) {
strncpy(dst, src, n - 1);
dst[n - 1] = 0;

View file

@ -36,14 +36,11 @@ DMOBJ *DEAMON_DM_ROOT_OBJ = NULL;
DM_MAP_VENDOR *DEAMON_DM_VENDOR_EXTENSION[2] = {0};
DM_MAP_VENDOR_EXCLUDE *DEAMON_DM_VENDOR_EXTENSION_EXCLUDE = NULL;
// uloop.h does not have versions, below line is to use
// deprecated uloop_timeout_remaining for the time being
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static struct {
int trans_id;
struct uloop_timeout trans_timeout;
int timeout_ms;
char app[32];
} g_current_trans = {.trans_id=0, .timeout_ms=10000};
static jmp_buf gs_jump_location;
@ -203,7 +200,7 @@ void fill_err_code_array(bbfdm_data_t *data, int fault)
static void transaction_timeout_handler(struct uloop_timeout *t __attribute__((unused)))
{
INFO("Transaction timeout called");
INFO("Transaction timeout called, aborting tid %d", g_current_trans.trans_id);
transaction_abort(g_current_trans.trans_id, NULL);
}
@ -220,38 +217,42 @@ static int get_random_id(void)
}
// Returns transaction id if successful, otherwise 0
int transaction_start(uint32_t max_timeout)
int transaction_start(char *app, uint32_t max_timeout)
{
int ret = 0;
uint32_t timeout;
if (g_current_trans.trans_id) {
WARNING("Transaction already in-process");
WARNING("%s Transaction locked by %s", app, g_current_trans.app);
return 0;
}
if (max_timeout > 0) {
timeout = max_timeout * 1000;
timeout = max_timeout;
} else {
timeout = g_current_trans.timeout_ms;
}
ret = get_random_id();
strncpyt(g_current_trans.app, app, 32);
g_current_trans.trans_id = ret;
g_current_trans.trans_timeout.cb = transaction_timeout_handler;
uloop_timeout_set(&g_current_trans.trans_timeout, timeout);
INFO("Transaction started with id %d, timeout %zd", g_current_trans.trans_id, timeout);
INFO("Transaction created by [%s] id %d, timeout %zd", g_current_trans.app, g_current_trans.trans_id, timeout);
return ret;
}
int transaction_status(struct blob_buf *bb, int trans_id)
int transaction_status(struct blob_buf *bb)
{
if (g_current_trans.trans_id == trans_id) {
int rem = uloop_timeout_remaining(&g_current_trans.trans_timeout);
blobmsg_add_string(bb, "status", "on-going");
blobmsg_add_u32(bb, "remaining_time", rem / 1000);
if (g_current_trans.trans_id) {
int64_t rem = uloop_timeout_remaining64(&g_current_trans.trans_timeout);
blobmsg_add_string(bb, "app", g_current_trans.app);
blobmsg_add_string(bb, "tstatus", "running");
blobmsg_add_u64(bb, "remaining_time", rem / 1000);
} else {
blobmsg_add_string(bb, "status", "not-exists");
blobmsg_add_string(bb, "tstatus", "Idle");
}
return 0;
@ -275,9 +276,10 @@ int transaction_commit(int trans_id, struct blob_buf *bb, bool is_service_restar
int ret = -1;
if (is_transaction_valid(trans_id)) {
INFO("Commit on-going transaction");
INFO("Commit on-going transaction by %s", g_current_trans.app);
uloop_timeout_cancel(&g_current_trans.trans_timeout);
g_current_trans.trans_id = 0;
g_current_trans.app[0] = '\0';
bbf_entry_restart_services(bb, is_service_restart);
@ -294,9 +296,10 @@ int transaction_abort(int trans_id, struct blob_buf *bb)
int ret = -1;
if (is_transaction_valid(trans_id)) {
INFO("Abort on-going transaction");
INFO("Abort on-going transaction by %s", g_current_trans.app);
uloop_timeout_cancel(&g_current_trans.trans_timeout);
g_current_trans.trans_id = 0;
g_current_trans.app[0] = '\0';
bbf_entry_revert_changes(bb);

View file

@ -41,10 +41,10 @@ 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);
int transaction_start(uint32_t max_timeout);
int transaction_start(char *app, uint32_t max_timeout);
int transaction_commit(int trans_id, struct blob_buf *bb, bool is_service_restart);
int transaction_abort(int trans_id, struct blob_buf *bb);
int transaction_status(struct blob_buf *bb, int trans_id);
int transaction_status(struct blob_buf *bb);
bool is_transaction_running(void);
bool is_transaction_valid(int trans_id);
int configure_transaction_timeout(int timeout);

View file

@ -19,6 +19,7 @@ https://dev.iopsys.eu/bbf/bbfdm/-/blob/devel/docs/api/ubus/bbfdm.md
| [notify_event](#notify_event) | Method | bbf (this schema) |
| [operate](#operate) | Method | bbf (this schema) |
| [schema](#schema) | Method | bbf (this schema) |
| [service](#service) | Method | bbf (this schema) |
| [set](#set) | Method | bbf (this schema) |
| [transaction](#transaction) | Method | bbf (this schema) |
@ -90,6 +91,8 @@ Add a new object in multi instance object
#### transaction_id
Required for CUD operation, it shall be same number as got from transaction->start
`transaction_id`
- is optional
@ -138,7 +141,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf add {"path":"aute dolore","optional":{"transaction_id":6658315},"obj_path":{}}
ubus call bbf add {"path":"amet enim in dolore qui","optional":{"transaction_id":38993374},"obj_path":{}}
```
### JSONRPC Example
@ -152,7 +155,7 @@ ubus call bbf add {"path":"aute dolore","optional":{"transaction_id":6658315},"o
"<SID>",
"bbf",
"add",
{ "path": "aute dolore", "optional": { "transaction_id": 6658315 }, "obj_path": {} }
{ "path": "amet enim in dolore qui", "optional": { "transaction_id": 38993374 }, "obj_path": {} }
]
}
```
@ -217,7 +220,7 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "cupidatat enim non ullamco tempor", "data": "aliqua eu", "fault": 8966, "fault_msg": "ci" }] }
{ "results": [{ "path": "pariatur ut", "data": "temp", "fault": 7365, "fault_msg": "irure sed anim Ut" }] }
```
## del
@ -273,6 +276,8 @@ Delete a object instance from multi instance object
#### transaction_id
Required for CUD operation, it shall be same number as got from transaction->start
`transaction_id`
- is optional
@ -347,7 +352,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf del {"path":"ea enim","paths":["commodo proi"],"optional":{"transaction_id":35247793}}
ubus call bbf del {"path":"aute magna Ut esse","paths":["nostrud Duis deserunt"],"optional":{"transaction_id":33739431}}
```
### JSONRPC Example
@ -361,7 +366,7 @@ ubus call bbf del {"path":"ea enim","paths":["commodo proi"],"optional":{"transa
"<SID>",
"bbf",
"del",
{ "path": "ea enim", "paths": ["commodo proi"], "optional": { "transaction_id": 35247793 } }
{ "path": "aute magna Ut esse", "paths": ["nostrud Duis deserunt"], "optional": { "transaction_id": 33739431 } }
]
}
```
@ -428,7 +433,12 @@ All items must be of the type: Unknown type ``.
```json
{
"results": [
{ "path": "laborum aliqua", "data": "tempor culpa in", "fault": 7997, "fault_msg": "amet reprehenderit consec" }
{
"path": "ad aliquip ut nulla",
"data": "sit ex dolor nisi reprehenderit",
"fault": 8077,
"fault_msg": "cillum qu"
}
]
}
```
@ -625,7 +635,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf get {"path":"aute dolor ut laborum deserunt","paths":["Loremnisi sunt enim"],"maxdepth":-13915475,"optional":{"format":"raw","proto":"usp","instance_mode":0}}
ubus call bbf get {"path":"reprehende","paths":["nostrud"],"maxdepth":-31156882,"optional":{"format":"pretty","proto":"cwmp","instance_mode":1}}
```
### JSONRPC Example
@ -640,10 +650,10 @@ ubus call bbf get {"path":"aute dolor ut laborum deserunt","paths":["Loremnisi s
"bbf",
"get",
{
"path": "aute dolor ut laborum deserunt",
"paths": ["Loremnisi sunt enim"],
"maxdepth": -13915475,
"optional": { "format": "raw", "proto": "usp", "instance_mode": 0 }
"path": "reprehende",
"paths": ["nostrud"],
"maxdepth": -31156882,
"optional": { "format": "pretty", "proto": "cwmp", "instance_mode": 1 }
}
]
}
@ -715,11 +725,11 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "adipisicing labore",
"data": "anim Excepteur laboris",
"type": "xsd:hexBinary",
"fault": 8645,
"fault_msg": "tempor"
"path": "pariatur occaecat ut sit",
"data": "minim aliq",
"type": "xsd:unsignedInt",
"fault": 9034,
"fault_msg": "sit minim nulla"
}
]
}
@ -868,7 +878,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf instances {"path":"labore","first_level":false,"optional":{"proto":"usp","instance_mode":1}}
ubus call bbf instances {"path":"veniam","first_level":false,"optional":{"proto":"cwmp","instance_mode":0}}
```
### JSONRPC Example
@ -882,7 +892,7 @@ ubus call bbf instances {"path":"labore","first_level":false,"optional":{"proto"
"<SID>",
"bbf",
"instances",
{ "path": "labore", "first_level": false, "optional": { "proto": "usp", "instance_mode": 1 } }
{ "path": "veniam", "first_level": false, "optional": { "proto": "cwmp", "instance_mode": 0 } }
]
}
```
@ -944,7 +954,7 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "aliqua reprehenderit Except", "fault": 8825, "fault_msg": "minim eu incididunt" }] }
{ "results": [{ "path": "deserunt inc", "fault": 7529, "fault_msg": "exercitation proident" }] }
```
## notify_event
@ -1009,7 +1019,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf notify_event {"name":"veniam dolor t","input":{}}
ubus call bbf notify_event {"name":"Lorem","input":{}}
```
### JSONRPC Example
@ -1019,7 +1029,7 @@ ubus call bbf notify_event {"name":"veniam dolor t","input":{}}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "notify_event", { "name": "veniam dolor t", "input": {} }]
"params": ["<SID>", "bbf", "notify_event", { "name": "Lorem", "input": {} }]
}
```
@ -1111,6 +1121,10 @@ Unknown type ``.
"type": "string",
"enum": ["start", "commit", "abort", "status"]
},
"srv_type_t": {
"type": "string",
"enum": ["register", "list"]
},
"format_t": {
"type": "string",
"default": "pretty",
@ -1123,11 +1137,12 @@ Unknown type ``.
"maximum": 1
},
"trans_id_t": {
"description": "Required for CUD operation, it shall be same number as got from transaction->start",
"type": "integer",
"minimum": 1
}
},
"out": "{\"definitions\":{\"path_t\":{\"description\":\"Complete object element path as per TR181\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.1.\",\"Device.WiFi.\"]},\"schema_path_t\":{\"description\":\"Datamodel object schema path\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.Bridging.Bridge.{i}.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.{i}.SSID\"]},\"boolean_t\":{\"type\":\"string\",\"enum\":[\"0\",\"1\"]},\"operate_path_t\":{\"description\":\"Datamodel object schema path\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.IP.Diagnostics.IPPing()\",\"Device.DHCPv4.Client.{i}.Renew()\",\"Device.FactoryReset()\"]},\"query_path_t\":{\"description\":\"DM object path with search queries\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.1.BSSID\",\"Device.WiFi.SSID.*.BSSID\",\"Device.WiFi.\"]},\"instance_t\":{\"description\":\"Multi object instances\",\"type\":\"string\",\"minLength\":6,\"maxLength\":256},\"proto_t\":{\"type\":\"string\",\"default\":\"both\",\"enum\":[\"usp\",\"cwmp\",\"both\"]},\"type_t\":{\"type\":\"string\",\"enum\":[\"xsd:string\",\"xsd:unsignedInt\",\"xsd:int\",\"xsd:unsignedLong\",\"xsd:long\",\"xsd:boolean\",\"xsd:dateTime\",\"xsd:hexBinary\",\"xsd:object\",\"xsd:command\",\"xsd:event\"]},\"fault_t\":{\"type\":\"integer\",\"minimum\":7000,\"maximum\":9050},\"trans_type_t\":{\"type\":\"string\",\"enum\":[\"start\",\"commit\",\"abort\",\"status\"]},\"format_t\":{\"type\":\"string\",\"default\":\"pretty\",\"enum\":[\"raw\",\"pretty\"]},\"instance_mode_t\":{\"type\":\"integer\",\"default\":0,\"minimum\":0,\"maximum\":1},\"trans_id_t\":{\"type\":\"integer\",\"minimum\":1}}}",
"out": "{\"definitions\":{\"path_t\":{\"description\":\"Complete object element path as per TR181\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.1.\",\"Device.WiFi.\"]},\"schema_path_t\":{\"description\":\"Datamodel object schema path\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.Bridging.Bridge.{i}.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.{i}.SSID\"]},\"boolean_t\":{\"type\":\"string\",\"enum\":[\"0\",\"1\"]},\"operate_path_t\":{\"description\":\"Datamodel object schema path\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.IP.Diagnostics.IPPing()\",\"Device.DHCPv4.Client.{i}.Renew()\",\"Device.FactoryReset()\"]},\"query_path_t\":{\"description\":\"DM object path with search queries\",\"type\":\"string\",\"minLength\":6,\"maxLength\":1024,\"examples\":[\"Device.\",\"Device.DeviceInfo.Manufacturer\",\"Device.WiFi.SSID.1.BSSID\",\"Device.WiFi.SSID.*.BSSID\",\"Device.WiFi.\"]},\"instance_t\":{\"description\":\"Multi object instances\",\"type\":\"string\",\"minLength\":6,\"maxLength\":256},\"proto_t\":{\"type\":\"string\",\"default\":\"both\",\"enum\":[\"usp\",\"cwmp\",\"both\"]},\"type_t\":{\"type\":\"string\",\"enum\":[\"xsd:string\",\"xsd:unsignedInt\",\"xsd:int\",\"xsd:unsignedLong\",\"xsd:long\",\"xsd:boolean\",\"xsd:dateTime\",\"xsd:hexBinary\",\"xsd:object\",\"xsd:command\",\"xsd:event\"]},\"fault_t\":{\"type\":\"integer\",\"minimum\":7000,\"maximum\":9050},\"trans_type_t\":{\"type\":\"string\",\"enum\":[\"start\",\"commit\",\"abort\",\"status\"]},\"srv_type_t\":{\"type\":\"string\",\"enum\":[\"register\",\"list\"]},\"format_t\":{\"type\":\"string\",\"default\":\"pretty\",\"enum\":[\"raw\",\"pretty\"]},\"instance_mode_t\":{\"type\":\"integer\",\"default\":0,\"minimum\":0,\"maximum\":1},\"trans_id_t\":{\"description\":\"Required for CUD operation, it shall be same number as got from transaction->start\",\"type\":\"integer\",\"minimum\":1}}}",
"simpletype": "complex"
}
```
@ -1192,9 +1207,14 @@ Unknown type ``.
},
"fault_t": { "type": "integer", "minimum": 7000, "maximum": 9050 },
"trans_type_t": { "type": "string", "enum": ["start", "commit", "abort", "status"] },
"srv_type_t": { "type": "string", "enum": ["register", "list"] },
"format_t": { "type": "string", "default": "pretty", "enum": ["raw", "pretty"] },
"instance_mode_t": { "type": "integer", "default": 0, "minimum": 0, "maximum": 1 },
"trans_id_t": { "type": "integer", "minimum": 1 }
"trans_id_t": {
"description": "Required for CUD operation, it shall be same number as got from transaction->start",
"type": "integer",
"minimum": 1
}
}
}
```
@ -1378,7 +1398,7 @@ The value of this property **must** be equal to one of the [known values below](
### Ubus CLI Example
```
ubus call bbf operate {"command":"officia nostrud sunt","command_key":"sunt qui","input":{},"optional":{"format":"raw","proto":"both","instance_mode":1}}
ubus call bbf operate {"command":"ex in sint ullamco","command_key":"in culpa in","input":{},"optional":{"format":"raw","proto":"cwmp","instance_mode":1}}
```
### JSONRPC Example
@ -1393,10 +1413,10 @@ ubus call bbf operate {"command":"officia nostrud sunt","command_key":"sunt qui"
"bbf",
"operate",
{
"command": "officia nostrud sunt",
"command_key": "sunt qui",
"command": "ex in sint ullamco",
"command_key": "in culpa in",
"input": {},
"optional": { "format": "raw", "proto": "both", "instance_mode": 1 }
"optional": { "format": "raw", "proto": "cwmp", "instance_mode": 1 }
}
]
}
@ -1484,11 +1504,11 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "fugiat occaecat",
"path": "ipsum velit cillum",
"data": "1",
"fault": 8855,
"fault_msg": "magna deserunt labore enim",
"output": [{ "path": "dolore ullamco", "data": "1", "type": "xsd:unsignedLong" }]
"fault": 8382,
"fault_msg": "ullamco dolore sed pariatur",
"output": [{ "path": "pariatur fugiat voluptate non Excepteur", "data": "1", "type": "xsd:hexBinary" }]
}
]
}
@ -1690,7 +1710,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf schema {"path":"proident elit","paths":["in null"],"first_level":false,"commands":true,"events":false,"params":true,"optional":{"proto":"both"}}
ubus call bbf schema {"path":"nondo labo","paths":["mollit dolor dolor"],"first_level":false,"commands":false,"events":false,"params":false,"optional":{"proto":"both"}}
```
### JSONRPC Example
@ -1705,12 +1725,12 @@ ubus call bbf schema {"path":"proident elit","paths":["in null"],"first_level":f
"bbf",
"schema",
{
"path": "proident elit",
"paths": ["in null"],
"path": "nondo labo",
"paths": ["mollit dolor dolor"],
"first_level": false,
"commands": true,
"commands": false,
"events": false,
"params": true,
"params": false,
"optional": { "proto": "both" }
}
]
@ -1821,18 +1841,178 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "utipsum magna",
"data": "0",
"type": "xsd:boolean",
"fault": 8703,
"fault_msg": "eu dolor est",
"input": [{ "path": "Excepteur Ut incididunt", "data": "1", "type": "xsd:unsignedLong" }],
"output": [{ "path": "ullamco adipisicing in", "data": "1", "type": "xsd:command" }]
"path": "amet labore tempor aliquip",
"data": "1",
"type": "xsd:command",
"fault": 7713,
"fault_msg": "nostrud",
"input": [{ "path": "dolor ex amet laborum dolore", "data": "1", "type": "xsd:string" }],
"output": [{ "path": "consectetur dolor ut", "data": "0", "type": "xsd:string" }]
}
]
}
```
## service
### Register a micro-service in the main service
`service`
- type: `Method`
### service Type
`object` with following properties:
| Property | Type | Required |
| -------- | ------ | ------------ |
| `input` | object | **Required** |
| `output` | object | **Required** |
#### input
`input`
- is **required**
- type: `object`
##### input Type
`object` with following properties:
| Property | Type | Required |
| ----------- | ------ | ------------ |
| `cmd` | string | **Required** |
| `name` | string | Optional |
| `object` | string | Optional |
| `parent_dm` | string | Optional |
#### cmd
`cmd`
- is **required**
- type: reference
##### cmd Type
`string`
The value of this property **must** be equal to one of the [known values below](#service-known-values).
##### cmd Known Values
| Value |
| -------- |
| register |
| list |
#### name
Name of the micro-service ubus object
`name`
- is optional
- type: `string`
##### name Type
`string`
#### object
Name of the micro-service object
`object`
- is optional
- type: `string`
##### object Type
`string`
#### parent_dm
Object path where the micro-service object will be added
`parent_dm`
- is optional
- type: `string`
##### parent_dm Type
`string`
### Ubus CLI Example
```
ubus call bbf service {"cmd":"list","name":"voluptate et","parent_dm":"eiusmod nisi anim amet","object":"sint laboris ullamco"}
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": [
"<SID>",
"bbf",
"service",
{ "cmd": "list", "name": "voluptate et", "parent_dm": "eiusmod nisi anim amet", "object": "sint laboris ullamco" }
]
}
```
#### output
`output`
- is **required**
- type: `object`
##### output Type
`object` with following properties:
| Property | Type | Required |
| -------- | ------- | ------------ |
| `error` | string | Optional |
| `status` | boolean | **Required** |
#### error
`error`
- is optional
- type: `string`
##### error Type
`string`
#### status
`status`
- is **required**
- type: `boolean`
##### status Type
`boolean`
### Output Example
```json
{ "status": false, "error": "dolore" }
```
## set
### Set handler
@ -1953,6 +2133,8 @@ The value of this property **must** be equal to one of the [known values below](
#### transaction_id
Required for CUD operation, it shall be same number as got from transaction->start
`transaction_id`
- is optional
@ -2032,7 +2214,7 @@ value of the object element provided in path, path should contains valid writabl
### Ubus CLI Example
```
ubus call bbf set {"path":"amet id ex adipisicing","value":"elit","optional":{"proto":"both","instance_mode":0,"transaction_id":13670657},"obj_path":{}}
ubus call bbf set {"path":"Duis et","value":"elit velit fugiat mollit sunt","optional":{"proto":"cwmp","instance_mode":0,"transaction_id":94067988},"obj_path":{}}
```
### JSONRPC Example
@ -2047,9 +2229,9 @@ ubus call bbf set {"path":"amet id ex adipisicing","value":"elit","optional":{"p
"bbf",
"set",
{
"path": "amet id ex adipisicing",
"value": "elit",
"optional": { "proto": "both", "instance_mode": 0, "transaction_id": 13670657 },
"path": "Duis et",
"value": "elit velit fugiat mollit sunt",
"optional": { "proto": "cwmp", "instance_mode": 0, "transaction_id": 94067988 },
"obj_path": {}
}
]
@ -2118,7 +2300,7 @@ All items must be of the type: Unknown type ``.
```json
{
"results": [
{ "path": "cillum dolore enim ea tempor", "data": "1", "fault": 7177, "fault_msg": "cupidatat do fugiat sed" }
{ "path": "mollit id est esse", "data": "0", "fault": 8853, "fault_msg": "ex consectetur officia irure enim" }
]
}
```
@ -2197,6 +2379,8 @@ The value of this property **must** be equal to one of the [known values below](
#### transaction_id
Required for CUD operation, it shall be same number as got from transaction->start
`transaction_id`
- is optional
@ -2210,6 +2394,8 @@ The value of this property **must** be equal to one of the [known values below](
#### restart_services
If yes, bbfdmd restart the service after CUD operation, else return list of updated uci to handler restart externally.
`restart_services`
- is optional
@ -2221,6 +2407,8 @@ The value of this property **must** be equal to one of the [known values below](
#### timeout
Timeout (in milliseconds) for the transaction, on timeout changes will be reverted
`timeout`
- is optional
@ -2235,7 +2423,7 @@ The value of this property **must** be equal to one of the [known values below](
### Ubus CLI Example
```
ubus call bbf transaction {"cmd":"commit","timeout":67151755,"restart_services":true,"optional":{"transaction_id":45369701}}
ubus call bbf transaction {"cmd":"status","timeout":25780595,"restart_services":false,"optional":{"transaction_id":25378647}}
```
### JSONRPC Example
@ -2249,7 +2437,7 @@ ubus call bbf transaction {"cmd":"commit","timeout":67151755,"restart_services":
"<SID>",
"bbf",
"transaction",
{ "cmd": "commit", "timeout": 67151755, "restart_services": true, "optional": { "transaction_id": 45369701 } }
{ "cmd": "status", "timeout": 25780595, "restart_services": false, "optional": { "transaction_id": 25378647 } }
]
}
```
@ -2309,5 +2497,5 @@ ubus call bbf transaction {"cmd":"commit","timeout":67151755,"restart_services":
### Output Example
```json
{ "status": true, "transaction_id": 61009982, "error": "amet qui Duis eiusmod" }
{ "status": false, "transaction_id": 41612487, "error": "Lorem mollit ut" }
```

View file

@ -2029,8 +2029,13 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
dmuci_get_value_by_section_string(args->bridge_port_dmmap_sec, "config", &config);
if (DM_LSTRCMP(config, "network") == 0) {
char *tag = DM_STRCHR(port, '.');
if (tag) tag[0] = '\0';
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", port, value);
if (!(*value) || (*value)[0] == 0) {
char *tag = DM_STRCHR(port, '.');
if (tag) tag[0] = '\0';
} else {
return 0;
}
}
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", port, value);
@ -2081,6 +2086,10 @@ static int set_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
return 0;
}
dmuci_get_value_by_section_string(args->bridge_port_dmmap_sec, "port", &port_device);
if (DM_STRCMP(linker, port_device) == 0) // Same as already configured
return 0;
// Update config section on dmmap_bridge_port if the linker is wirelss port or network port
if (DM_LSTRNCMP(value, "Device.WiFi.SSID.", 17) == 0) {
dmuci_set_value_by_section(args->bridge_port_dmmap_sec, "config", "wireless");
@ -2096,7 +2105,6 @@ static int set_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx,
}
dmuci_get_value_by_section_string(args->bridge_port_dmmap_sec, "enabled", &port_enabled);
dmuci_get_value_by_section_string(args->bridge_port_dmmap_sec, "port", &port_device);
if (port_device[0] == '\0') {
if (DM_STRCMP(port_enabled, "1") == 0) {

View file

@ -121,6 +121,7 @@
"maximum": 1
},
"trans_id_t": {
"description": "Required for CUD operation, it shall be same number as got from transaction->start",
"type": "integer",
"minimum": 1
}
@ -744,9 +745,11 @@
},
"timeout": {
"type": "integer",
"description": "Timeout (in milliseconds) for the transaction, on timeout changes will be reverted",
"minimum":0
},
"restart_services": {
"description": "If yes, bbfdmd restart the service after CUD operation, else return list of updated uci to handler restart externally.",
"type": "boolean"
},
"optional": {