Merge remote branch 'origin/master'
[routeros-api.git] / src / routeros_api.h
index f1395c9..4527876 100644 (file)
 #ifndef ROUTEROS_API_H
 #define ROUTEROS_API_H 1
 
+#include <stdint.h>
+#include <inttypes.h>
+
 #include <routeros_version.h>
 
 #define ROUTEROS_API_PORT "8728"
 
+/*
+ * C++ doesn't have _Bool. We can't simply "#define _Bool bool", because we
+ * don't know if "bool" and "_Bool" are of the same size. If they are not, this
+ * would result in ABI incompatible code.
+ *
+ * So we're doing a best-effort solution here: If we're compiled with the GNU
+ * C++ compiler, g++, we include <stdbool.h>. The GCC will, as a GNU extension,
+ * define _Bool for C++. Since it's the compiler doing the definition, it's
+ * kind of save to assume that it will be done in an ABI compatible manner.
+ *
+ * If this results in any problems for you, define "ROS_HAVE_CPP_BOOL" to true
+ * to have this magic disabled. You will then have to define _Bool yourself.
+ *
+ * TODO: Write a test program for the configure sript to figure out the size of
+ *   _Bool. Make this size available via <routeros_versioin.h> and define _Bool
+ *   to short, long, ... here.
+ */
 #ifdef __cplusplus
+# if !defined (ROS_HAVE_CPP_BOOL) || !ROS_HAVE_CPP_BOOL
+#  ifdef __GNUC__
+#   include <stdbool.h>
+#  endif /* __GNUC__ */
+# endif /* !defined (ROS_HAVE_CPP_BOOL) || !ROS_HAVE_CPP_BOOL */
+
 extern "C" {
 #endif
 
@@ -69,15 +95,60 @@ const char *ros_reply_param_val_by_index (const ros_reply_t *r,
                unsigned int index);
 const char *ros_reply_param_val_by_key (const ros_reply_t *r, const char *key);
 
-/*
- * High-level function for accessing /interface/wireless/registration-table
- */
+/* High-level function for accessing /interface {{{ */
+struct ros_interface_s;
+typedef struct ros_interface_s ros_interface_t;
+struct ros_interface_s
+{
+       /* Name of the interface */
+       const char *name;
+       const char *type;
+       const char *comment;
+
+       /* Packet, octet and error counters. */
+       uint64_t rx_packets;
+       uint64_t tx_packets;
+       uint64_t rx_bytes;
+       uint64_t tx_bytes;
+       uint64_t rx_errors;
+       uint64_t tx_errors;
+       uint64_t rx_drops;
+       uint64_t tx_drops;
+
+       /* Maximum transfer unit */
+       unsigned int mtu;
+       unsigned int l2mtu;
+
+       /* Interface flags */
+       _Bool dynamic;
+       _Bool running;
+       _Bool enabled;
+
+       /* Next interface */
+       const ros_interface_t *next;
+};
+
+/* Callback function */
+typedef int (*ros_interface_handler_t) (ros_connection_t *c,
+               const ros_interface_t *i, void *user_data);
+
+int ros_interface (ros_connection_t *c,
+               ros_interface_handler_t handler, void *user_data);
+/* }}} /interface */
+
+/* High-level function for accessing /interface/wireless/registration-table {{{ */
 struct ros_registration_table_s;
 typedef struct ros_registration_table_s ros_registration_table_t;
 struct ros_registration_table_s
 {
        /* Name of the interface */
        const char *interface;
+       /* Name of the remote radio */
+       const char *radio_name;
+
+       /* ap is set to true, if the REMOTE radio is an access point. */
+       _Bool ap;
+       _Bool wds;
 
        /* Receive and transmit rate in MBit/s */
        double rx_rate;
@@ -107,15 +178,16 @@ struct ros_registration_table_s
        double tx_ccq;
 
        /* Next interface */
-       ros_registration_table_t *next;
+       const ros_registration_table_t *next;
 };
 
 /* Callback function */
-typedef int (*ros_registration_table_handler) (ros_connection_t *c,
+typedef int (*ros_registration_table_handler_t) (ros_connection_t *c,
                const ros_registration_table_t *r, void *user_data);
 
 int ros_registration_table (ros_connection_t *c,
-               ros_registration_table_handler handler, void *user_data);
+               ros_registration_table_handler_t handler, void *user_data);
+/* }}} /interface/wireless/registration-table */
 
 #ifdef __cplusplus
 }