Validate datatype on set request

This commit is contained in:
Suvendhu Hansa 2024-09-02 21:03:15 +05:30
parent a21c3b36b8
commit c9c4fd2d8a
9 changed files with 385 additions and 118 deletions

View file

@ -30,6 +30,20 @@
"1"
]
},
"datatype_t": {
"type": "string",
"enum": [
"int",
"unsignedInt",
"long",
"unsignedLong",
"string",
"boolean",
"dateTime",
"base64",
"hexBinary"
]
},
"operate_path_t": {
"description": "Datamodel object schema path",
"type": "string",
@ -539,6 +553,21 @@
"{\"path\":\"Device.WiFi.SSID.1.Enable\", \"value\":\"0\"}"
]
},
"datatype": {
"description": "datatype of the object element provided in path",
"$ref": "#/definitions/datatype_t",
"examples": [
"{\"path\":\"Device.WiFi.SSID.1.SSID\", \"value\":\"test_ssid\", \"datatype\":\"string\"}",
"{\"path\":\"Device.WiFi.SSID.2.Enable\", \"value\":\"true\", \"datatype\":\"boolean\"}",
"{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.ClientID\", \"value\":\"0103060C\", \"datatype\":\"hexBinary\"}",
"{\"path\":\"Device.DHCPv4.Server.Pool.1.LeaseTime\", \"value\":\"120\", \"datatype\":\"int\"}",
"{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.Order\", \"value\":\"1\", \"datatype\":\"unsignedInt\"}",
"{\"path\":\"Device.QoS.Queue.1.ShapingRate\", \"value\":\"1002\", \"datatype\":\"long\"}",
"{\"path\":\"Device.IP.Diagnostics.UploadDiagnostics.TestFileLength\", \"value\":\"1002\", \"datatype\":\"unsignedLong\"}",
"{\"path\":\"Device.USPAgent.ControllerTrust.Challenge.1.Value\", \"value\":\"01Z3A6YC\", \"datatype\":\"base64\"}",
"{\"path\":\"Device.ManagementServer.ScheduleReboot\", \"value\":\"2024-08-23T23:59:59Z\", \"datatype\":\"dateTime\"}"
]
},
"obj_path": {
"description": "To set multiple values at once, path should be relative to object elements",
"examples": [

View file

@ -109,7 +109,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf add {"path":"voluptate veniam","obj_path":{}}
ubus call bbf add {"path":"anim consequat","obj_path":{}}
```
### JSONRPC Example
@ -119,7 +119,7 @@ ubus call bbf add {"path":"voluptate veniam","obj_path":{}}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "add", { "path": "voluptate veniam", "obj_path": {} }]
"params": ["<SID>", "bbf", "add", { "path": "anim consequat", "obj_path": {} }]
}
```
@ -183,16 +183,7 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{
"results": [
{
"path": "laborum",
"data": "occaecat tempor fugiat sit",
"fault": 9015,
"fault_msg": "cillum deserunt incididunt "
}
]
}
{ "results": [{ "path": "dolor in sunt eiusmod", "data": "sunt pariatur", "fault": 8972, "fault_msg": "ea culpa" }] }
```
## del
@ -293,7 +284,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf del {"path":"elit sit Ut magna","paths":["dolor irure"]}
ubus call bbf del {"path":"eu venia","paths":["adipisicing ad dolor do"]}
```
### JSONRPC Example
@ -303,7 +294,7 @@ ubus call bbf del {"path":"elit sit Ut magna","paths":["dolor irure"]}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "del", { "path": "elit sit Ut magna", "paths": ["dolor irure"] }]
"params": ["<SID>", "bbf", "del", { "path": "eu venia", "paths": ["adipisicing ad dolor do"] }]
}
```
@ -370,10 +361,10 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "fugiat consequat dolor culpa",
"data": "Lorem et veniam laboris nulla",
"fault": 8956,
"fault_msg": "dolor"
"path": "incididunt laborum Duis",
"data": "nostrud aliquip velit",
"fault": 7729,
"fault_msg": "culpa nisi adipisicing dolore eiusmod"
}
]
}
@ -555,7 +546,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf get {"path":"amet elit occaecat mag","paths":["in nisi"],"maxdepth":54340400,"optional":{"format":"pretty","proto":"both"}}
ubus call bbf get {"path":"veniam sunt","paths":["nisi ad et veniam"],"maxdepth":-3902100,"optional":{"format":"raw","proto":"both"}}
```
### JSONRPC Example
@ -570,10 +561,10 @@ ubus call bbf get {"path":"amet elit occaecat mag","paths":["in nisi"],"maxdepth
"bbf",
"get",
{
"path": "amet elit occaecat mag",
"paths": ["in nisi"],
"maxdepth": 54340400,
"optional": { "format": "pretty", "proto": "both" }
"path": "veniam sunt",
"paths": ["nisi ad et veniam"],
"maxdepth": -3902100,
"optional": { "format": "raw", "proto": "both" }
}
]
}
@ -644,13 +635,7 @@ All items must be of the type: Unknown type ``.
```json
{
"results": [
{
"path": "do laborum culpa ad",
"data": "anim minim sint pariatur",
"type": "xsd:object",
"fault": 8594,
"fault_msg": "con"
}
{ "path": "anim consectetur", "data": "dolore d", "type": "xsd:command", "fault": 8024, "fault_msg": "quis minim" }
]
}
```
@ -782,7 +767,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf instances {"path":"in Lor","first_level":true,"optional":{"proto":"both"}}
ubus call bbf instances {"path":"veniam mollit occaecat cillum","first_level":true,"optional":{"proto":"cwmp"}}
```
### JSONRPC Example
@ -792,7 +777,12 @@ ubus call bbf instances {"path":"in Lor","first_level":true,"optional":{"proto":
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "instances", { "path": "in Lor", "first_level": true, "optional": { "proto": "both" } }]
"params": [
"<SID>",
"bbf",
"instances",
{ "path": "veniam mollit occaecat cillum", "first_level": true, "optional": { "proto": "cwmp" } }
]
}
```
@ -853,7 +843,7 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "in eiusmod dolore mollit", "fault": 8737, "fault_msg": "eu dolore ipsum" }] }
{ "results": [{ "path": "labore occaecat a", "fault": 9010, "fault_msg": "Lorem" }] }
```
## notify_event
@ -914,7 +904,7 @@ Array type: `array`
### Ubus CLI Example
```
ubus call bbf notify_event {"name":"voluptate sit deserunt ut minim","input":[]}
ubus call bbf notify_event {"name":"eu laboris anim","input":[]}
```
### JSONRPC Example
@ -924,7 +914,7 @@ ubus call bbf notify_event {"name":"voluptate sit deserunt ut minim","input":[]}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "notify_event", { "name": "voluptate sit deserunt ut minim", "input": [] }]
"params": ["<SID>", "bbf", "notify_event", { "name": "eu laboris anim", "input": [] }]
}
```
@ -960,6 +950,10 @@ Unknown type ``.
"type": "string",
"enum": ["0", "1"]
},
"datatype_t": {
"type": "string",
"enum": ["int", "unsignedInt", "long", "unsignedLong", "string", "boolean", "dateTime", "base64", "hexBinary"]
},
"operate_path_t": {
"description": "Datamodel object schema path",
"type": "string",
@ -1026,7 +1020,7 @@ Unknown type ``.
"enum": ["raw", "pretty"]
}
},
"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\"]}}}",
"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\"]},\"datatype_t\":{\"type\":\"string\",\"enum\":[\"int\",\"unsignedInt\",\"long\",\"unsignedLong\",\"string\",\"boolean\",\"dateTime\",\"base64\",\"hexBinary\"]},\"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\"]}}}",
"simpletype": "complex"
}
```
@ -1051,6 +1045,10 @@ Unknown type ``.
"examples": ["Device.Bridging.Bridge.{i}.", "Device.DeviceInfo.Manufacturer", "Device.WiFi.SSID.{i}.SSID"]
},
"boolean_t": { "type": "string", "enum": ["0", "1"] },
"datatype_t": {
"type": "string",
"enum": ["int", "unsignedInt", "long", "unsignedLong", "string", "boolean", "dateTime", "base64", "hexBinary"]
},
"operate_path_t": {
"description": "Datamodel object schema path",
"type": "string",
@ -1260,7 +1258,7 @@ The value of this property **must** be equal to one of the [known values below](
### Ubus CLI Example
```
ubus call bbf operate {"command":"minim tempor dolor ut","command_key":"cillum elit","input":{},"optional":{"format":"raw","proto":"both"}}
ubus call bbf operate {"command":"velit magna laboris aliquip culpa","command_key":"voluptate ad cupidatat","input":{},"optional":{"format":"pretty","proto":"usp"}}
```
### JSONRPC Example
@ -1275,10 +1273,10 @@ ubus call bbf operate {"command":"minim tempor dolor ut","command_key":"cillum e
"bbf",
"operate",
{
"command": "minim tempor dolor ut",
"command_key": "cillum elit",
"command": "velit magna laboris aliquip culpa",
"command_key": "voluptate ad cupidatat",
"input": {},
"optional": { "format": "raw", "proto": "both" }
"optional": { "format": "pretty", "proto": "usp" }
}
]
}
@ -1366,11 +1364,11 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "sit dolor dolore Lorem eiusmod",
"data": "0",
"fault": 8955,
"fault_msg": "elit occaecat tempor",
"output": [{ "path": "in qui cillum", "data": "0", "type": "xsd:int" }]
"path": "commodo dolor laboris",
"data": "1",
"fault": 7192,
"fault_msg": "non Lorem",
"output": [{ "path": "fugiat in qui", "data": "0", "type": "xsd:string" }]
}
]
}
@ -1572,7 +1570,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf schema {"path":"velit aliquip","paths":["volupta"],"first_level":true,"commands":false,"events":true,"params":true,"optional":{"proto":"cwmp"}}
ubus call bbf schema {"path":"qui dolor nisi","paths":["veniam in dolor deserunt"],"first_level":true,"commands":true,"events":false,"params":false,"optional":{"proto":"cwmp"}}
```
### JSONRPC Example
@ -1587,12 +1585,12 @@ ubus call bbf schema {"path":"velit aliquip","paths":["volupta"],"first_level":t
"bbf",
"schema",
{
"path": "velit aliquip",
"paths": ["volupta"],
"path": "qui dolor nisi",
"paths": ["veniam in dolor deserunt"],
"first_level": true,
"commands": false,
"events": true,
"params": true,
"commands": true,
"events": false,
"params": false,
"optional": { "proto": "cwmp" }
}
]
@ -1703,13 +1701,13 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "aliquip nisi ven",
"data": "0",
"type": "xsd:object",
"fault": 8719,
"fault_msg": "mollit",
"input": [{ "path": "tempor Ut consectetu", "data": "1", "type": "xsd:long" }],
"output": [{ "path": "velit ipsum e", "data": "1", "type": "xsd:dateTime" }]
"path": "pariatur ",
"data": "1",
"type": "xsd:boolean",
"fault": 7493,
"fault_msg": "mollit ",
"input": [{ "path": "aliquip", "data": "1", "type": "xsd:int" }],
"output": [{ "path": "elit est dolor do", "data": "1", "type": "xsd:int" }]
}
]
}
@ -1812,7 +1810,7 @@ Object path where the micro-service object will be added
### Ubus CLI Example
```
ubus call bbf service {"cmd":"register","name":"sit dolore et qui in","parent_dm":"reprehenderit pariatur Excepteur","object":"enim non ex in"}
ubus call bbf service {"cmd":"list","name":"ex fugiat","parent_dm":"esse ipsum dolore Ut et","object":"sed amet Duis"}
```
### JSONRPC Example
@ -1826,12 +1824,7 @@ ubus call bbf service {"cmd":"register","name":"sit dolore et qui in","parent_dm
"<SID>",
"bbf",
"service",
{
"cmd": "register",
"name": "sit dolore et qui in",
"parent_dm": "reprehenderit pariatur Excepteur",
"object": "enim non ex in"
}
{ "cmd": "list", "name": "ex fugiat", "parent_dm": "esse ipsum dolore Ut et", "object": "sed amet Duis" }
]
}
```
@ -1877,7 +1870,7 @@ ubus call bbf service {"cmd":"register","name":"sit dolore et qui in","parent_dm
### Output Example
```json
{ "status": false, "error": "magna nostrud Lorem" }
{ "status": true, "error": "eu aliq" }
```
## set
@ -1912,10 +1905,78 @@ Set values of datamodel object element
| Property | Type | Required |
| ---------- | ------ | ------------ |
| `datatype` | string | Optional |
| `obj_path` | object | Optional |
| `path` | string | **Required** |
| `value` | string | **Required** |
#### datatype
datatype of the object element provided in path
`datatype`
- is optional
- type: reference
##### datatype Type
`string`
The value of this property **must** be equal to one of the [known values below](#set-known-values).
##### datatype Known Values
| Value |
| ------------ |
| int |
| unsignedInt |
| long |
| unsignedLong |
| string |
| boolean |
| dateTime |
| base64 |
| hexBinary |
##### datatype Examples
```json
{ "path": "Device.WiFi.SSID.1.SSID", "value": "test_ssid", "datatype": "string" }
```
```json
{ "path": "Device.WiFi.SSID.2.Enable", "value": "true", "datatype": "boolean" }
```
```json
{ "path": "Device.DHCPv4.Relay.Forwarding.1.ClientID", "value": "0103060C", "datatype": "hexBinary" }
```
```json
{ "path": "Device.DHCPv4.Server.Pool.1.LeaseTime", "value": "120", "datatype": "int" }
```
```json
{ "path": "Device.DHCPv4.Relay.Forwarding.1.Order", "value": "1", "datatype": "unsignedInt" }
```
```json
{ "path": "Device.QoS.Queue.1.ShapingRate", "value": "1002", "datatype": "long" }
```
```json
{ "path": "Device.IP.Diagnostics.UploadDiagnostics.TestFileLength", "value": "1002", "datatype": "unsignedLong" }
```
```json
{ "path": "Device.USPAgent.ControllerTrust.Challenge.1.Value", "value": "01Z3A6YC", "datatype": "base64" }
```
```json
{ "path": "Device.ManagementServer.ScheduleReboot", "value": "2024-08-23T23:59:59Z", "datatype": "dateTime" }
```
#### obj_path
To set multiple values at once, path should be relative to object elements
@ -2011,7 +2072,7 @@ value of the object element provided in path, path should contains valid writabl
### Ubus CLI Example
```
ubus call bbf set {"path":"aliqua","value":"ullamco eu adipisicing tempor","obj_path":{}}
ubus call bbf set {"path":"occaecat veniam consequa","value":"et Excepteur occaecat fugiat","datatype":"dateTime","obj_path":{}}
```
### JSONRPC Example
@ -2021,7 +2082,17 @@ ubus call bbf set {"path":"aliqua","value":"ullamco eu adipisicing tempor","obj_
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "set", { "path": "aliqua", "value": "ullamco eu adipisicing tempor", "obj_path": {} }]
"params": [
"<SID>",
"bbf",
"set",
{
"path": "occaecat veniam consequa",
"value": "et Excepteur occaecat fugiat",
"datatype": "dateTime",
"obj_path": {}
}
]
}
```
@ -2085,5 +2156,5 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "ea sed Ut aute", "data": "0", "fault": 7846, "fault_msg": "magna veniam eu fugiat id" }] }
{ "results": [{ "path": "cillum Ut laborum proident", "data": "0", "fault": 7277, "fault_msg": "dolore ut aliquip" }] }
```

View file

@ -30,6 +30,20 @@
"1"
]
},
"datatype_t": {
"type": "string",
"enum": [
"int",
"unsignedInt",
"long",
"unsignedLong",
"string",
"boolean",
"dateTime",
"base64",
"hexBinary"
]
},
"operate_path_t": {
"description": "Datamodel object schema path",
"type": "string",
@ -539,6 +553,21 @@
"{\"path\":\"Device.WiFi.SSID.1.Enable\", \"value\":\"0\"}"
]
},
"datatype": {
"description": "datatype of the object element provided in path",
"$ref": "#/definitions/datatype_t",
"examples": [
"{\"path\":\"Device.WiFi.SSID.1.SSID\", \"value\":\"test_ssid\", \"datatype\":\"string\"}",
"{\"path\":\"Device.WiFi.SSID.2.Enable\", \"value\":\"true\", \"datatype\":\"boolean\"}",
"{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.ClientID\", \"value\":\"0103060C\", \"datatype\":\"hexBinary\"}",
"{\"path\":\"Device.DHCPv4.Server.Pool.1.LeaseTime\", \"value\":\"120\", \"datatype\":\"int\"}",
"{\"path\":\"Device.DHCPv4.Relay.Forwarding.1.Order\", \"value\":\"1\", \"datatype\":\"unsignedInt\"}",
"{\"path\":\"Device.QoS.Queue.1.ShapingRate\", \"value\":\"1002\", \"datatype\":\"long\"}",
"{\"path\":\"Device.IP.Diagnostics.UploadDiagnostics.TestFileLength\", \"value\":\"1002\", \"datatype\":\"unsignedLong\"}",
"{\"path\":\"Device.USPAgent.ControllerTrust.Challenge.1.Value\", \"value\":\"01Z3A6YC\", \"datatype\":\"base64\"}",
"{\"path\":\"Device.ManagementServer.ScheduleReboot\", \"value\":\"2024-08-23T23:59:59Z\", \"datatype\":\"dateTime\"}"
]
},
"obj_path": {
"description": "To set multiple values at once, path should be relative to object elements",
"examples": [

View file

@ -107,7 +107,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf add {"path":"tempor nostrud in i","obj_path":{}}
ubus call bbf add {"path":"eu qui","obj_path":{}}
```
### JSONRPC Example
@ -117,7 +117,7 @@ ubus call bbf add {"path":"tempor nostrud in i","obj_path":{}}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "add", { "path": "tempor nostrud in i", "obj_path": {} }]
"params": ["<SID>", "bbf", "add", { "path": "eu qui", "obj_path": {} }]
}
```
@ -181,7 +181,11 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "laborum", "data": "mollit enim", "fault": 8110, "fault_msg": "culpa fugiat" }] }
{
"results": [
{ "path": "magna enim", "data": "in aliquip id eu deserunt", "fault": 8757, "fault_msg": "quis id ut in" }
]
}
```
## del
@ -282,7 +286,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf del {"path":"culpasunt","paths":["deserunt labore ut consequa"]}
ubus call bbf del {"path":"incididunt tempor","paths":["dolore aliqua labore labori"]}
```
### JSONRPC Example
@ -292,7 +296,7 @@ ubus call bbf del {"path":"culpasunt","paths":["deserunt labore ut consequa"]}
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "bbf", "del", { "path": "culpasunt", "paths": ["deserunt labore ut consequa"] }]
"params": ["<SID>", "bbf", "del", { "path": "incididunt tempor", "paths": ["dolore aliqua labore labori"] }]
}
```
@ -356,7 +360,11 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "dolor laborum esse", "data": "laborum amet Excepteur", "fault": 8595, "fault_msg": "ut" }] }
{
"results": [
{ "path": "aliqua id deserunt", "data": "reprehenderit eu sed esse", "fault": 8791, "fault_msg": "occaecat" }
]
}
```
## get
@ -535,7 +543,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf get {"path":"officia","paths":["reprehenderit Ut"],"maxdepth":-61996452,"optional":{"format":"pretty","proto":"both"}}
ubus call bbf get {"path":"auteaute","paths":["culpa amet elit irure"],"maxdepth":-44630385,"optional":{"format":"raw","proto":"cwmp"}}
```
### JSONRPC Example
@ -550,10 +558,10 @@ ubus call bbf get {"path":"officia","paths":["reprehenderit Ut"],"maxdepth":-619
"bbf",
"get",
{
"path": "officia",
"paths": ["reprehenderit Ut"],
"maxdepth": -61996452,
"optional": { "format": "pretty", "proto": "both" }
"path": "auteaute",
"paths": ["culpa amet elit irure"],
"maxdepth": -44630385,
"optional": { "format": "raw", "proto": "cwmp" }
}
]
}
@ -624,7 +632,13 @@ All items must be of the type: Unknown type ``.
```json
{
"results": [
{ "path": "proident", "data": "consectetur", "type": "xsd:unsignedLong", "fault": 8751, "fault_msg": "culpa ea" }
{
"path": "dolore eu",
"data": "et sit exercitation cupid",
"type": "xsd:string",
"fault": 7957,
"fault_msg": "sit l"
}
]
}
```
@ -756,7 +770,7 @@ Device.WiFi.
### Ubus CLI Example
```
ubus call bbf instances {"path":"et elit officia ut","first_level":false,"optional":{"proto":"both"}}
ubus call bbf instances {"path":"laborum magna Excepteur est","first_level":false,"optional":{"proto":"usp"}}
```
### JSONRPC Example
@ -770,7 +784,7 @@ ubus call bbf instances {"path":"et elit officia ut","first_level":false,"option
"<SID>",
"bbf",
"instances",
{ "path": "et elit officia ut", "first_level": false, "optional": { "proto": "both" } }
{ "path": "laborum magna Excepteur est", "first_level": false, "optional": { "proto": "usp" } }
]
}
```
@ -832,7 +846,7 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "est do aliqua dolor", "fault": 7913, "fault_msg": "enim ex ipsum tempor elit" }] }
{ "results": [{ "path": "Duis dolor e", "fault": 8621, "fault_msg": "et nulla" }] }
```
## operate
@ -998,7 +1012,7 @@ The value of this property **must** be equal to one of the [known values below](
### Ubus CLI Example
```
ubus call bbf operate {"command":"irure reprehen","command_key":"tempor ipsum","input":{},"optional":{"format":"raw","proto":"usp"}}
ubus call bbf operate {"command":"in cupidatat minim reprehenderit","command_key":"cillum aliqua anim et veniam","input":{},"optional":{"format":"pretty","proto":"usp"}}
```
### JSONRPC Example
@ -1013,10 +1027,10 @@ ubus call bbf operate {"command":"irure reprehen","command_key":"tempor ipsum","
"bbf",
"operate",
{
"command": "irure reprehen",
"command_key": "tempor ipsum",
"command": "in cupidatat minim reprehenderit",
"command_key": "cillum aliqua anim et veniam",
"input": {},
"optional": { "format": "raw", "proto": "usp" }
"optional": { "format": "pretty", "proto": "usp" }
}
]
}
@ -1104,11 +1118,11 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "ea Lorem officia n",
"data": "1",
"fault": 8207,
"fault_msg": "in Duis eiusmod culpa",
"output": [{ "path": "eiusmod voluptate", "data": "1", "type": "xsd:command" }]
"path": "doDuis",
"data": "0",
"fault": 8434,
"fault_msg": "co",
"output": [{ "path": "anim vel", "data": "1", "type": "xsd:unsignedLong" }]
}
]
}
@ -1310,7 +1324,7 @@ All items must be of the type: Unknown type ``.
### Ubus CLI Example
```
ubus call bbf schema {"path":"sit Lorem aliquip quis adipisic","paths":["cupidatat Excepteur"],"first_level":true,"commands":true,"events":false,"params":true,"optional":{"proto":"both"}}
ubus call bbf schema {"path":"Excepteur dolor","paths":["adipisicing veniam"],"first_level":true,"commands":false,"events":true,"params":false,"optional":{"proto":"both"}}
```
### JSONRPC Example
@ -1325,12 +1339,12 @@ ubus call bbf schema {"path":"sit Lorem aliquip quis adipisic","paths":["cupidat
"bbf",
"schema",
{
"path": "sit Lorem aliquip quis adipisic",
"paths": ["cupidatat Excepteur"],
"path": "Excepteur dolor",
"paths": ["adipisicing veniam"],
"first_level": true,
"commands": true,
"events": false,
"params": true,
"commands": false,
"events": true,
"params": false,
"optional": { "proto": "both" }
}
]
@ -1441,13 +1455,13 @@ All items must be of the type: Unknown type ``.
{
"results": [
{
"path": "veniam ipsum ea elit lab",
"data": "0",
"type": "xsd:command",
"fault": 7148,
"fault_msg": "laboris et officia Duis",
"input": [{ "path": "cillum ea", "data": "1", "type": "xsd:dateTime" }],
"output": [{ "path": "esse aliquip in eu et", "data": "1", "type": "xsd:string" }]
"path": "ad dolore eiusmo",
"data": "1",
"type": "xsd:unsignedInt",
"fault": 8099,
"fault_msg": "amet laboris",
"input": [{ "path": "dolor cillum nulla", "data": "1", "type": "xsd:int" }],
"output": [{ "path": "ut eu i", "data": "0", "type": "xsd:object" }]
}
]
}
@ -1485,10 +1499,78 @@ Set values of datamodel object element
| Property | Type | Required |
| ---------- | ------ | ------------ |
| `datatype` | string | Optional |
| `obj_path` | object | Optional |
| `path` | string | **Required** |
| `value` | string | **Required** |
#### datatype
datatype of the object element provided in path
`datatype`
- is optional
- type: reference
##### datatype Type
`string`
The value of this property **must** be equal to one of the [known values below](#set-known-values).
##### datatype Known Values
| Value |
| ------------ |
| int |
| unsignedInt |
| long |
| unsignedLong |
| string |
| boolean |
| dateTime |
| base64 |
| hexBinary |
##### datatype Examples
```json
{ "path": "Device.WiFi.SSID.1.SSID", "value": "test_ssid", "datatype": "string" }
```
```json
{ "path": "Device.WiFi.SSID.2.Enable", "value": "true", "datatype": "boolean" }
```
```json
{ "path": "Device.DHCPv4.Relay.Forwarding.1.ClientID", "value": "0103060C", "datatype": "hexBinary" }
```
```json
{ "path": "Device.DHCPv4.Server.Pool.1.LeaseTime", "value": "120", "datatype": "int" }
```
```json
{ "path": "Device.DHCPv4.Relay.Forwarding.1.Order", "value": "1", "datatype": "unsignedInt" }
```
```json
{ "path": "Device.QoS.Queue.1.ShapingRate", "value": "1002", "datatype": "long" }
```
```json
{ "path": "Device.IP.Diagnostics.UploadDiagnostics.TestFileLength", "value": "1002", "datatype": "unsignedLong" }
```
```json
{ "path": "Device.USPAgent.ControllerTrust.Challenge.1.Value", "value": "01Z3A6YC", "datatype": "base64" }
```
```json
{ "path": "Device.ManagementServer.ScheduleReboot", "value": "2024-08-23T23:59:59Z", "datatype": "dateTime" }
```
#### obj_path
To set multiple values at once, path should be relative to object elements
@ -1584,7 +1666,7 @@ value of the object element provided in path, path should contains valid writabl
### Ubus CLI Example
```
ubus call bbf set {"path":"quioccaecat labore elit offic","value":"dolore nostrud dolore anim non","obj_path":{}}
ubus call bbf set {"path":"sint nulla nisi reprehenderit dol","value":"aliqua sit aliquip","datatype":"long","obj_path":{}}
```
### JSONRPC Example
@ -1598,7 +1680,7 @@ ubus call bbf set {"path":"quioccaecat labore elit offic","value":"dolore nostru
"<SID>",
"bbf",
"set",
{ "path": "quioccaecat labore elit offic", "value": "dolore nostrud dolore anim non", "obj_path": {} }
{ "path": "sint nulla nisi reprehenderit dol", "value": "aliqua sit aliquip", "datatype": "long", "obj_path": {} }
]
}
```
@ -1663,5 +1745,5 @@ All items must be of the type: Unknown type ``.
### Output Example
```json
{ "results": [{ "path": "anim no", "data": "0", "fault": 7259, "fault_msg": "ad" }] }
{ "results": [{ "path": "in esse et", "data": "1", "fault": 8550, "fault_msg": "incididunt in Ut nisi" }] }
```

View file

@ -181,6 +181,7 @@ struct dmctx {
int setaction;
char *in_param;
char *in_value;
char *in_type;
char *addobj_instance;
char *linker;
char *linker_param;
@ -361,6 +362,7 @@ enum dmt_type_enum {
DMT_BASE64,
DMT_COMMAND,
DMT_EVENT,
__DMT_INVALID
};
enum bbfdm_type_enum {

View file

@ -1430,9 +1430,10 @@ static int set_ubus_value(struct dmctx *dmctx, struct dmnode *node)
UBUS_ARGS{
{"path", dmctx->in_param, String},
{"value", param_value, String},
{"datatype", dmctx->in_type ? dmctx->in_type : "", String},
{"optional", json_object_to_json_string(in_args), Table}
},
3, &res);
4, &res);
json_object_put(in_args);
if (!res)
@ -2341,6 +2342,44 @@ static int mobj_set_value(DMOBJECT_ARGS)
return FAULT_9005;
}
static int get_datatype(char *type)
{
if (DM_STRLEN(type) == 0)
return __DMT_INVALID;
if (strcmp(type, "int") == 0)
return DMT_INT;
if (strcmp(type, "long") == 0)
return DMT_LONG;
if (strcmp(type, "unsignedInt") == 0)
return DMT_UNINT;
if (strcmp(type, "unsignedLong") == 0)
return DMT_UNLONG;
if (strcmp(type, "decimal") == 0)
return DMT_STRING;
if (strcmp(type, "hexBinary") == 0)
return DMT_HEXBIN;
if (strcmp(type, "dateTime") == 0)
return DMT_TIME;
if (strcmp(type, "boolean") == 0)
return DMT_BOOL;
if (strcmp(type, "base64") == 0)
return DMT_BASE64;
if (strcmp(type, "string") == 0)
return DMT_STRING;
return __DMT_INVALID;
}
static int mparam_set_value(DMPARAM_ARGS)
{
if (node->is_ubus_service) {
@ -2364,6 +2403,15 @@ static int mparam_set_value(DMPARAM_ARGS)
if (perm[0] == '0' || !leaf->setvalue)
return FAULT_9008;
// If type is not defined then bypass this check
if (DM_STRLEN(dmctx->in_type) != 0) {
int type = get_datatype(dmctx->in_type);
if (type != leaf->type) {
return FAULT_9006;
}
}
(leaf->getvalue)(refparam, dmctx, data, instance, &value);
snprintf(param_value, sizeof(param_value), "%s", dmctx->in_value);

View file

@ -463,6 +463,7 @@ static int bbfdm_instances_handler(struct ubus_context *ctx, struct ubus_object
static const struct blobmsg_policy dm_set_policy[] = {
[DM_SET_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING },
[DM_SET_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
[DM_SET_TYPE] = { .name = "datatype", .type = BLOBMSG_TYPE_STRING },
[DM_SET_OBJ_PATH] = { .name = "obj_path", .type = BLOBMSG_TYPE_TABLE },
[DM_SET_OPTIONAL] = { .name = "optional", .type = BLOBMSG_TYPE_TABLE },
};
@ -502,7 +503,10 @@ int bbfdm_set_handler(struct ubus_context *ctx, struct ubus_object *obj,
data.ctx = ctx;
data.bbf_ctx.in_param = path;
fault = fill_pvlist_set(&data, path, tb[DM_SET_VALUE] ? blobmsg_get_string(tb[DM_SET_VALUE]) : NULL, tb[DM_SET_OBJ_PATH], &pv_list);
char *value = tb[DM_SET_VALUE] ? blobmsg_get_string(tb[DM_SET_VALUE]) : NULL;
char *type = tb[DM_SET_TYPE] ? blobmsg_get_string(tb[DM_SET_TYPE]) : NULL;
fault = fill_pvlist_set(&data, path, value, type, tb[DM_SET_OBJ_PATH], &pv_list);
if (fault) {
BBF_ERR("Fault in fill pvlist set path |%s| : |%d|", data.bbf_ctx.in_param, fault);
fill_err_code_array(&data, fault);
@ -635,7 +639,7 @@ int bbfdm_add_handler(struct ubus_context *ctx, struct ubus_object *obj,
snprintf(path, PATH_MAX, "%s%s.", (char *)blobmsg_data(tb[DM_ADD_PATH]), data.bbf_ctx.addobj_instance);
fault = fill_pvlist_set(&data, path, NULL, tb[DM_ADD_OBJ_PATH], &pv_list);
fault = fill_pvlist_set(&data, path, NULL, NULL, tb[DM_ADD_OBJ_PATH], &pv_list);
if (fault) {
BBF_ERR("Fault in fill pvlist set path |%s|", path);
fill_err_code_array(&data, USP_FAULT_INTERNAL_ERROR);

View file

@ -25,6 +25,7 @@ int bbfdm_set_value(bbfdm_data_t *data)
list_for_each_entry(pv, data->plist, list) {
data->bbf_ctx.in_param = pv->param;
data->bbf_ctx.in_value = pv->val;
data->bbf_ctx.in_type = pv->type;
fault = bbfdm_cmd_exec(&data->bbf_ctx, BBF_SET_VALUE);
if (fault) {
@ -42,7 +43,7 @@ int bbfdm_set_value(bbfdm_data_t *data)
return fault;
}
static int set_resolved_paths(bbfdm_data_t *data, char *path, char *value, struct list_head *pv_list)
static int set_resolved_paths(bbfdm_data_t *data, char *path, char *value, char *type, struct list_head *pv_list)
{
int fault = 0;
@ -58,7 +59,7 @@ static int set_resolved_paths(bbfdm_data_t *data, char *path, char *value, struc
struct pathNode *p;
list_for_each_entry(p, &resolved_paths, list) {
add_pv_list(p->path, value, NULL, pv_list);
add_pv_list(p->path, value, type, pv_list);
}
}
@ -68,7 +69,7 @@ static int set_resolved_paths(bbfdm_data_t *data, char *path, char *value, struc
return fault;
}
int fill_pvlist_set(bbfdm_data_t *data, char *param_name, char *param_value, struct blob_attr *blob_table, struct list_head *pv_list)
int fill_pvlist_set(bbfdm_data_t *data, char *param_name, char *param_value, char *type, struct blob_attr *blob_table, struct list_head *pv_list)
{
struct blob_attr *attr;
struct blobmsg_hdr *hdr;
@ -85,7 +86,7 @@ int fill_pvlist_set(bbfdm_data_t *data, char *param_name, char *param_value, str
if (param_name[plen - 1] == '.')
return USP_FAULT_INVALID_PATH;
fault = set_resolved_paths(data, param_name, param_value, pv_list);
fault = set_resolved_paths(data, param_name, param_value, type, pv_list);
if (fault)
return fault;
@ -121,7 +122,7 @@ blob__table:
}
snprintf(path, MAX_DM_PATH, "%s%s", param_name, (char *)hdr->name);
fault = set_resolved_paths(data, path, value, pv_list);
fault = set_resolved_paths(data, path, value, NULL, pv_list);
if (fault)
return fault;
}

View file

@ -4,12 +4,13 @@
enum {
DM_SET_PATH,
DM_SET_VALUE,
DM_SET_TYPE,
DM_SET_OBJ_PATH,
DM_SET_OPTIONAL,
__DM_SET_MAX,
};
int fill_pvlist_set(bbfdm_data_t *data, char *param_name, char *param_value, struct blob_attr *blob_table, struct list_head *pv_list);
int fill_pvlist_set(bbfdm_data_t *data, char *param_name, char *param_value, char *type, struct blob_attr *blob_table, struct list_head *pv_list);
int bbfdm_set_value(bbfdm_data_t *data);
#endif /* SET_H */