Thanks Alexandru! That was very helpful. Now I have a better understanding of the ubus structure.
Few more questions: - when/where does this ubus.c file (executable?) run? - how these functions used? when are they called? starting from line 42 to line 47 (https://github.com/lede-project/source/blob/master/package/network/services/hostapd/src/src/ap/ubus.h#L42) Thanks again. On Wed, Jul 5, 2017 at 11:54 PM, Alexandru Ardelean <ardeleana...@gmail.com> wrote: > On Thu, Jul 6, 2017 at 4:31 AM, Carlito Nueno <carlitonu...@gmail.com> wrote: >> Hi all, >> >> I want to customize a small feature in how hostapd responds to probe >> request and I was looking at >> https://github.com/lede-project/source/blob/master/package/network/services/hostapd/src/src/ap/ubus.c >> >> Please help me understand how it works? for example when I call `ubus >> call hostapd.wlan0-1 del_client "{....}" what happens? > > the `ubus` cli will talk to ubusd > ubusd is the broker [or hub] for all things ubus between all processes > [that register with ubus[d] ] > > hostapd has registered the `hostapd.wlan0-1` ubus object here > https://github.com/lede-project/source/blob/master/package/network/services/hostapd/src/src/ap/ubus.c#L457 > via the ubus_add_object() > > all registration to ubusd is done via libubus, which abstracts a lot > of the stuff to connect/talk to ubusd > all that you need to use [in a daemon/process with ubus] is in > libubus.h ; that header is exported at build time for other modules to > use > http://git.openwrt.org/?p=project/ubus.git;a=blob;f=libubus.h;h=4e45cb620a28befe23c27d3b8dc7eb1a1d12fb1a;hb=HEAD > > it's important that all operations to ubus[d] be done on a > ubus_context object, which is a wrapper struct for a socket FD, some > buffer data, and other stuff > > [ well, this was mostly ubus internals [in case it interests you ] ] > >> >> I know that ubus_cli >> (http://git.openwrt.org/?p=project/ubus.git;a=blob;f=cli.c;h=19ccbb5093ce4c326010a9b2f504d7cd50798275;hb=HEAD) >> parses the input but how does ubus call the functions inside the above >> file (the ubus.c, ubus hostapd extension)? > > the ubus cli tool uses libubus > but the code for cli, may not be a sufficient example to do other > operations [like in hostapd ] > >> >> I see that there is this function, but how is that called >> >> static int hostapd_bss_del_client(struct ubus_context *ctx, struct >> ubus_object *obj, struct ubus_request_data *req, const char *method, >> struct blob_attr *msg); >> > > Coming back to your "I want to customize a small feature in how hostapd" > I think that all you might need to do is register a new function here: > https://github.com/lede-project/source/blob/master/package/network/services/hostapd/src/src/ap/ubus.c#L419 > or extend an existing one. > > As I mentioned, the ubus cli talks to ubusd. > When doing `ubus call hostapd.wlan0-1 del_client "{....}"` , this > means that hostapd has already registered a ` hostapd.wlan0-1` with > ubusd > When you call "del_client", the hostapd_bss_del_client() callback will > be called [ubus cli will ask ubusd to access del_client from > hostapd.wlan0-1 ] , but before that, the `del_policy` object will be > used to validate the message format. > [ You may have noticed that some callbacks are UBUS_METHOD_NOARG() and > some are UBUS_METHOD() ; the ones without a policy arg will get > processed without any msg format validation ] > >> >> Thank you! >> > > Maybe this information was not too well structured. > But hope it helps. > >> _______________________________________________ >> Lede-dev mailing list >> Lede-dev@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/lede-dev _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev