Code

store.h: Reuse the sdb_metric_store_t type for a metric's store field.
[sysdb.git] / src / include / client / sock.h
index c88fc9a02041d2a7d0f06970428e17dfcb064c07..615227d7408effab59f3b3806b905b01186a35e1 100644 (file)
 
 #include "core/object.h"
 #include "core/data.h"
-
 #include "frontend/proto.h"
-
+#include "utils/ssl.h"
 #include "utils/strbuf.h"
 
 #include <sys/socket.h>
 
+#include <stdbool.h>
 #include <stddef.h>
 
 #ifdef __cplusplus
@@ -60,11 +60,22 @@ sdb_client_create(const char *address);
 
 /*
  * sdb_client_destroy:
- * Destroyes the client connection and deallocates the client object.
+ * Destroys the client connection and deallocates the client object.
  */
 void
 sdb_client_destroy(sdb_client_t *client);
 
+/*
+ * sdb_client_set_ssl_options:
+ * Use the specified options for any SSL connections.
+ *
+ * Returns:
+ *  - 0 on success
+ *  - a negative value else
+ */
+int
+sdb_client_set_ssl_options(sdb_client_t *client, const sdb_ssl_options_t *opts);
+
 /*
  * sdb_client_connect:
  * Connect to the client's address using the specified username.
@@ -76,6 +87,21 @@ sdb_client_destroy(sdb_client_t *client);
 int
 sdb_client_connect(sdb_client_t *client, const char *username);
 
+/*
+ * sdb_client_sockfd:
+ * Return the client socket's file descriptor.
+ */
+int
+sdb_client_sockfd(sdb_client_t *client);
+
+/*
+ * sdb_client_shutdown:
+ * Shut down the client's send and/or receive operations.
+ * See shutdown(3) for details.
+ */
+int
+sdb_client_shutdown(sdb_client_t *client, int how);
+
 /*
  * sdb_client_close:
  * Close the client connection.
@@ -83,13 +109,33 @@ sdb_client_connect(sdb_client_t *client, const char *username);
 void
 sdb_client_close(sdb_client_t *client);
 
+/*
+ * sdb_client_rpc:
+ * Send the specified message to the server and wait for the reply. All
+ * received data is written to the specified buffer. If specified, the
+ * returned status code is written to the memory location pointed to by
+ * 'code'. In case of an error or an incomplete command, the status code is
+ * set to UINT32_MAX. The returned data does not include the status code and
+ * message len as received from the remote side but only the data associated
+ * with the message. The function handles all asynchronous log messages by
+ * logging them at the right log level.
+ *
+ * Returns:
+ *  - the number of bytes read
+ *    (may be zero if the message did not include any data)
+ *  - a negative value on error
+ */
+ssize_t
+sdb_client_rpc(sdb_client_t *client,
+               uint32_t cmd, uint32_t msg_len, const char *msg,
+               uint32_t *code, sdb_strbuf_t *buf);
+
 /*
  * sdb_client_send:
- * Send the specified command and accompanying data to through the client
- * connection.
+ * Send the specified command and accompanying data to the server.
  *
  * Returns:
- *  - 0 on success
+ *  - the number of bytes send
  *  - a negative value else.
  */
 ssize_t
@@ -114,6 +160,14 @@ ssize_t
 sdb_client_recv(sdb_client_t *client,
                uint32_t *code, sdb_strbuf_t *buf);
 
+/*
+ * sdb_client_eof:
+ * Returns true if end of file on the client connection was reached, that is,
+ * if the remote side closed the connection.
+ */
+bool
+sdb_client_eof(sdb_client_t *client);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif