Brief introduction
Ubus is a message bus introduced by the new OpenWrt, and the main role is to implement information interaction between different applications.
Ubus runs the UBUSD process in the background after startup, and the process listens for a UNIX socket to communicate with other applications. Other applications can communicate with each other based on the interface provided by Libubox (or its own implementation).
The main ways to use Ubus are: 1. Register messages or control interfaces with them. 2. Call the message or control interface of other applications to it. 3, register the event of concern to it.
Ubus Command Usage Instructions
The Ubus command is used to control debug-related Ubus interfaces, and the main commands are described below:
-list [<path>] List objects
-Call <path> <method> [<message>] Call an object method
-Listen [<path> ...] Listen for events
-Send <type> [<message>] Send an event
-Wait_for <object> [<object> ...] Wait for multiple objects to appear on Ubus
Ubus list [-v] This command displays the interfaces registered in the current Ubus, where the-v parameter displays the details of each interface. Examples are as follows:
ubus list -v
‘dhcp‘ @26b45f5d
"ipv4leases":{}
"ipv6leases":{}
‘hostapd.wlan0‘ @5e03d420
"get_clients":{}
"del_client":{"addr":"String","reason":"Integer","deauth":"Boolean","ban_time":"Integer"}
ubus Call this command is used to invoke the interface currently registered in Ubus. Examples are as follows:
ubus call dhcp ipv6leases
{
"device": {
"br-lan": {
"leases": [
{
"duid": "0001000119660ee***4e543***3c70",
"iaid": 3***72***5,
"hostname": "*******-PC",
"assigned": 3900,
"length": 128,
"ipv6": [
"fd23:a6ed:f19b::f3c"
],
"valid": -38000
}
]
}
}
}
The Ubus listen is used to listen for Ubus related events and listens for all events if you do not specify an event name. (Wildcard characters *)
Ubus Send for sending events
Ubus wait_for is used to wait for the specified item to be registered in Ubus.
Libubus Development Notes
This article is from the "record Little Harvest Growth" blog, please be sure to keep this source http://gofly.blog.51cto.com/4344767/1685199
OpenWrt Ubus Introduction and Libubus development notes