From: Florian Forster Date: Thu, 26 Nov 2009 22:18:24 +0000 (+0100) Subject: doc/librouteros.pod: Describe the high level "interface" interface. X-Git-Tag: librouteros-0.2.0~10 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=71c3e87fb2d0fdfff80f0cead3f5dc8643a1f189;p=routeros-api.git doc/librouteros.pod: Describe the high level "interface" interface. --- diff --git a/doc/librouteros.pod b/doc/librouteros.pod index c6fc532..d1ea98b 100644 --- a/doc/librouteros.pod +++ b/doc/librouteros.pod @@ -24,47 +24,15 @@ it will be freed by the library before returning to where the query was called from. When the application is done talking to the device and disconnects, the connection object will be freed. -=head1 DATA TYPES +=head1 INTERFACES -The following data types are used and returned by librouteros: +=head2 Connection -=over 4 - -=item B - -The "connection object" represents the connection to one device. -This is an opaque data type, meaning that you can only have pointers to such -objects but not dereference or manipulate them directly. - -=item B - -One part of a reply (which are stored as a list) received from a device. The -head of the list (the first part) is passed to the callback function. -This is an opaque data type, meaning that you can only have pointers to such -objects but not dereference or manipulate them directly. - -=item B - -Convenience data type for the callback functions. Callback functions must have -the following prototype: - - int callback (ros_connection_t *c, const ros_reply_t *r, void *user_data); - -The first and second arguments are objects representing the connection and the -reply respectively. I is a pointer as passed to B (see -below). +The connection to a I device is represented by a pointer to a +B type. This is an opaque data type which cannot be +dereferenced or manipulated directly. -The value returned by the callback function will be returned by B to -the calling code. To distinguish from error codes returned by B upon -errors, use negative values in the callback function. - -=back - -=head1 FUNCTIONS - -The following functions are part of librouteros' API and exported. Functions -not listed here are not part of the API, should not be exported and may change -and disappear at any time. Please report such functions are bugs. +Connection management is done with the following functions: =over 4 @@ -84,6 +52,38 @@ connection. After this call, I may not be used anymore. Returns zero upon success and an error code otherwise. +=back + +=head2 General / low level queries + +This interface abstracts the network protocol only and leaves actually +formulating queries and interpreting replies to the calling code. This is meant +for queries and features for which no higher level interface exists. + +The query is sent to the daemon using the B function. The reply is +decoded and passed to a callback function with the following prototype, also +called B: + + int callback (ros_connection_t *c, const ros_reply_t *r, void *user_data); + +The reply is broken into parts (or "sentences") and passed to the callback +function as a linked list of type B. The callback uses a couple of +helper functions to iterate over this list and fetch parameters as necessary. + +The first and second arguments are objects representing the connection and the +reply respectively. I is a pointer as passed to B (see +below). The arguments I and I may not be modified or freed. They will be +freed after the function returns, so pointers to this data are invalid after +this. + +The value returned by the callback function will be returned by B to +the calling code. To distinguish from error codes returned by B upon +errors, use negative values in the callback function. + +General queries / replies are handled using the following functions: + +=over 4 + =item int B (ros_connection_t *I, const char *I, size_t I, const char * const *I, ros_reply_handler_t I, void *I) Sends the command I with the I arguments I via the @@ -124,7 +124,7 @@ Returns the parameter value at index I (starting with zero) of reply I. If I is out of bounds, returns C. The returned pointer must not be freed. -=item const char *ros_reply_param_val_by_key (const ros_reply_t *r, const char *key) +=item const char *B (const ros_reply_t *I, const char *I) Returns the parameter value corresponding to key I (or C if there is no such key) of reply I. @@ -132,6 +132,39 @@ The returned pointer must not be freed. =back +=head2 High level interface functions for "interface" + +This function and the associated struct provide basic information about the +device's interfaces in an easy and intuitive to use form. It is equivalent to +issuing the C command. As with the generic interface above, a +query function is called with a pointer to a callback function. That callback +function is then called with a list of B structures. + +The query function has the following prototype: + + int ros_interface (ros_connection_t *c, + ros_interface_handler_t handler, void *user_data); + +I is a pointer to a connection object as returned by B. + +I is a function pointer to a callback function handling the result. +The callback function must have the following prototype, called +B for convenience: + + int callback (ros_connection_t *c, + const ros_interface_t *i, void *user_data); + +The argument I is a pointer to the first element of the list of interfaces +received from the device. This struct is defined in Erouteros_api.hE +and contains information such as the name of the device, received and +transmitted bytes and whether or not the interface is currently running. No +element of the list nor any of their members may be modified and will be freed +when the callback returns. + +=head2 High level interface functions for "registration-table" + +B: Describe the registration-table interface. + =head1 ERROR HANDLING Some of the functions above return an "error code". This error code can be