X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_ovs.h;h=52c2f915ce62f55e65d6e001638cee2b5740048d;hb=733fc645b6389d1f42aef8f1c1631f1db7d58196;hp=484260f607ca6c95ea864c9f9b6d55a28441deac;hpb=7f0ab40f34e685128edca1ab489bc36dbbb7bd50;p=collectd.git diff --git a/src/utils_ovs.h b/src/utils_ovs.h index 484260f6..52c2f915 100644 --- a/src/utils_ovs.h +++ b/src/utils_ovs.h @@ -65,23 +65,39 @@ #ifndef UTILS_OVS_H #define UTILS_OVS_H -#include #include +#include /* Forward declaration */ typedef struct ovs_db_s ovs_db_t; /* OVS DB callback type declaration */ -typedef void (*ovs_db_init_cb_t) (ovs_db_t *pdb); -typedef void (*ovs_db_table_cb_t) (yajl_val jupdates); -typedef void (*ovs_db_result_cb_t) (yajl_val jresult, yajl_val jerror); +typedef void (*ovs_db_table_cb_t)(yajl_val jupdates); +typedef void (*ovs_db_result_cb_t)(yajl_val jresult, yajl_val jerror); /* OVS DB structures */ struct ovs_db_callback_s { - ovs_db_init_cb_t init_cb; + /* + * This callback is called when OVS DB connection + * has been established and ready to use. Client + * can use this callback to configure OVS DB, e.g. + * to subscribe to table update notification or poll + * some OVS DB data. This field can be NULL. + */ + void (*post_conn_init)(ovs_db_t *pdb); + /* + * This callback is called when OVS DB connection + * has been lost. This field can be NULL. + */ + void (*post_conn_terminate)(void); }; typedef struct ovs_db_callback_s ovs_db_callback_t; +/* OVS DB defines */ +#define OVS_DB_ADDR_NODE_SIZE 256 +#define OVS_DB_ADDR_SERVICE_SIZE 128 +#define OVS_DB_ADDR_UNIX_SIZE 108 + /* OVS DB prototypes */ /* @@ -93,13 +109,16 @@ typedef struct ovs_db_callback_s ovs_db_callback_t; * shall destroy the returned object. * * PARAMETERS - * `surl' OVS DB communication URL. + * `node' OVS DB Address. + * `service' OVS DB service name. + * `unix' OVS DB unix socket path. * `cb' OVS DB callbacks. * * RETURN VALUE * New ovs_db_t object upon success or NULL if an error occurred. */ -ovs_db_t *ovs_db_init(const char *surl, ovs_db_callback_t *cb); +ovs_db_t *ovs_db_init(const char *node, const char *service, + const char *unix_path, ovs_db_callback_t *cb); /* * NAME @@ -133,15 +152,15 @@ int ovs_db_destroy(ovs_db_t *pdb); * RETURN VALUE * Zero upon success or non-zero if an error occurred. */ -int ovs_db_send_request(ovs_db_t *pdb, const char *method, - const char *params, ovs_db_result_cb_t cb); +int ovs_db_send_request(ovs_db_t *pdb, const char *method, const char *params, + ovs_db_result_cb_t cb); /* callback types */ #define OVS_DB_TABLE_CB_FLAG_INITIAL 0x01U -#define OVS_DB_TABLE_CB_FLAG_INSERT 0x02U -#define OVS_DB_TABLE_CB_FLAG_DELETE 0x04U -#define OVS_DB_TABLE_CB_FLAG_MODIFY 0x08U -#define OVS_DB_TABLE_CB_FLAG_ALL 0x0FU +#define OVS_DB_TABLE_CB_FLAG_INSERT 0x02U +#define OVS_DB_TABLE_CB_FLAG_DELETE 0x04U +#define OVS_DB_TABLE_CB_FLAG_MODIFY 0x08U +#define OVS_DB_TABLE_CB_FLAG_ALL 0x0FU /* * NAME @@ -176,8 +195,7 @@ int ovs_db_send_request(ovs_db_t *pdb, const char *method, int ovs_db_table_cb_register(ovs_db_t *pdb, const char *tb_name, const char **tb_column, ovs_db_table_cb_t update_cb, - ovs_db_result_cb_t result_cb, - unsigned int flags); + ovs_db_result_cb_t result_cb, unsigned int flags); /* * OVS utils API @@ -199,4 +217,20 @@ int ovs_db_table_cb_register(ovs_db_t *pdb, const char *tb_name, */ yajl_val ovs_utils_get_value_by_key(yajl_val jval, const char *key); +/* + * NAME + * ovs_utils_get_map_value + * + * DESCRIPTION + * Get OVS DB map value by given map key (rfc7047, "Notation" section). + * + * PARAMETERS + * `jval' A 2-element YAJL array that represents a OVS DB map value. + * `key' OVS DB map key name. + * + * RETURN VALUE + * YAJL value upon success or NULL if key not found. + */ +yajl_val ovs_utils_get_map_value(yajl_val jval, const char *key); + #endif