Hi,
I realize that there is a large number of modules for API access out there and I feel kinda guilty for reinventing the wheel yet again. Unfortunately, though, none of the existing implementations did fit my bill, most due to language restrictions on my end. I need a plain C99 / POSIX.1-2001 implementation with a GNU General Public License (GPL) compatible license which is thread and reentrant-safe. webasdf’s implementation comes close, but lacks a build system, documentation and source code management.
I’ve therefore written (yet) another library called librouteros (if you can think of a better name, let me know) which is available from verplant.org/librouteros/. The library uses the GNU autotools and libtool and can therefore be easily built using:
./configure && make
Using the library is straight forward: First, you create a connection object using ros_connect. This object, the command you wish to execute and a callback function are then passed to ros_query. That function will do all the network communication, parse the reply into a generic ros_reply_t object and call the callback function. The network communication is hidden from the calling code and the functional approach makes memory management very easy. More detailed documentation is available as librouteros(3) manual page.
Currently the library is still in an early development stage which is denoted by the major version 0 (zero). This means both, API and ABI, are still unstable and may change at any time. If you want to contribute patches, please feel free to check out the source code from repository with the following command and send patches via email (or post a link here). My email address can be found on my homepage and in the README file.
git clone git://git.verplant.org/librouteros.git
If you have a Github account and want to use that, please let me know.
The long-term goal is to abstract the actual commands used, too. There are currently two high-level interfaces to receive a list of interfaces and the registration table as already parsed structures. More high-level interfaces will be added as the need arises.
My ultimate goal is to write a plugin for collectd to read statistics from my RouterBoards. Development of the library is heavily influenced by this goal and my personal use of the devices. So everything interesting for point-to-point connections will probably be available soon, while, for example, hotspot statistics / support is unlikely to be written by me. Patches are, of course, very welcome ![]()
Regards,
—octo