X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frouteros_api.h;h=16ea503ccd9e1353dca30d7fb96883efd0470974;hb=c4ad812587c29fea8fbbb6179b762d6b31f15e7a;hp=070b2eab11f2c366236bd51118844b2de41de905;hpb=c51d83a318374124b877a52cd3f85c173d4bb4a5;p=routeros-api.git diff --git a/src/routeros_api.h b/src/routeros_api.h index 070b2ea..16ea503 100644 --- a/src/routeros_api.h +++ b/src/routeros_api.h @@ -1,5 +1,5 @@ /** - * libmikrotik - src/mikrotik.h + * librouteros - src/routeros_api.h * Copyright (C) 2009 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it @@ -19,41 +19,111 @@ * Florian octo Forster **/ +#ifndef ROUTEROS_API_H +#define ROUTEROS_API_H 1 + +#include +#include + +#include + #define ROUTEROS_API_PORT "8728" -struct mt_connection_s; -typedef struct mt_connection_s mt_connection_t; +#ifdef __cplusplus +extern "C" { +#endif -struct mt_reply_s; -typedef struct mt_reply_s mt_reply_t; +struct ros_connection_s; +typedef struct ros_connection_s ros_connection_t; -typedef int (*mt_reply_handler_t) (mt_connection_t *c, const mt_reply_t *r, +struct ros_reply_s; +typedef struct ros_reply_s ros_reply_t; + +typedef int (*ros_reply_handler_t) (ros_connection_t *c, const ros_reply_t *r, void *user_data); /* * Connection handling */ -mt_connection_t *mt_connect (const char *node, const char *service, +ros_connection_t *ros_connect (const char *node, const char *service, const char *username, const char *password); -int mt_disconnect (mt_connection_t *con); +int ros_disconnect (ros_connection_t *con); /* * Command execution */ -int mt_query (mt_connection_t *c, +int ros_query (ros_connection_t *c, const char *command, size_t args_num, const char * const *args, - mt_reply_handler_t *handler, void *user_data); + ros_reply_handler_t handler, void *user_data); /* * Reply handling */ -const mt_reply_t *mt_reply_next (const mt_reply_t *r); -int mt_reply_num (const mt_reply_t *r); +const ros_reply_t *ros_reply_next (const ros_reply_t *r); +int ros_reply_num (const ros_reply_t *r); + +const char *ros_reply_status (const ros_reply_t *r); /* Receiving reply parameters */ -const char *mt_reply_param_key_by_index (const mt_reply_t *r, unsigned int index); -const char *mt_reply_param_val_by_index (const mt_reply_t *r, unsigned int index); -const char *mt_reply_param_val_by_key (const mt_reply_t *r, const char *key); +const char *ros_reply_param_key_by_index (const ros_reply_t *r, + unsigned int index); +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 + */ +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; + + /* Receive and transmit rate in MBit/s */ + double rx_rate; + double tx_rate; + + /* Packet, octet and frame counters. */ + uint64_t rx_packets; + uint64_t tx_packets; + uint64_t rx_bytes; + uint64_t tx_bytes; + uint64_t rx_frames; + uint64_t tx_frames; + uint64_t rx_frame_bytes; + uint64_t tx_frame_bytes; + uint64_t rx_hw_frames; + uint64_t tx_hw_frames; + uint64_t rx_hw_frame_bytes; + uint64_t tx_hw_frame_bytes; + + /* Signal quality information (in dBm) */ + double rx_signal_strength; + double tx_signal_strength; + double signal_to_noise; + + /* Overall connection quality (in percent) */ + double rx_ccq; + double tx_ccq; + + /* Next interface */ + ros_registration_table_t *next; +}; + +/* Callback function */ +typedef int (*ros_registration_table_handler) (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); + +#ifdef __cplusplus +} +#endif + +#endif /* ROUTEROS_API_H */ /* vim: set ts=2 sw=2 noet fdm=marker : */