OpenWrt Ubus Introduction and Libubus development notes

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.