User Tools

Site Tools



It's one of the core libraries used within openwrt because it's a set of utilities, mostly wrappers, that are present usually in programs and that have been coded in a flexible and reusable way to avoid wasting time.

The library consists mostly on independent functionalities, ones higher level than others.


Simple utility functions. Endian conversion, bitfield operations, compiler attribute wrapping, sequential memory allocation function (calloc_a), static array size macro, assertion/bug utility function, clock get time wrapper for apple compatibility, base64 encoding decoding.


This is a really simple library encouraged to be a wrapper to avoid all those socket api library calls. You can create TCP, UDP and UNIX sockets, clients and servers, ipv4/v6 and non/blocking.

The idea is to call usock() and have your fd returned.


The most used part. Uloop is a loop runner for i/o. Gets in charge of polling the different file descriptors you have added to it, gets in charge of running timers, and helps you manage child processes. Supports epoll and kqueue as event running backends.

The fd management part is set up with the uloop_fd struct, just adding the fd and the callback function you want called when an event arises. The rest of the structure is for internal use.

The timeout management part is mostly prepared to do simple things, if you have the idea of doing something comples, you might want to have a look on libubox/runqueue.h which implements interesting functionality on top of uloop.

Timeout structure should be initialized with just the callback and pending=false (timeout={.cb=cb_func} does the work), and added to uloop using uloop_timeout_set(), do not use the other _add() function because then you will need to set up the time yourself calling time.h functions. _set() uses _add() internally.

Finally the process part, ….

doc/techref/libubox.txt · Last modified: 2015/10/09 10:27 by txomon