Code

frontend/proto: Include the log priority in LOG messages.
[sysdb.git] / src / include / frontend / proto.h
index 9e02400e13ea597d9201d0a0577c47e9daefa11e..2fabad513b06e5c156c021617262606de628c7f2 100644 (file)
@@ -51,10 +51,21 @@ extern "C" {
 
 /* status codes returned to a client */
 typedef enum {
+       /*
+        * Generic status and log messages.
+        */
+
        /*
         * CONNECTION_OK:
-        * Indicates that a command was successful. The message body will contain
-        * the result of the command (if any) encoded as a JSON string.
+        * Indicates that a command was successful. The message body will usually
+        * be empty but may contain a string providing unformatted information
+        * providing more details.
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | message type  | length        |
+        * +---------------+---------------+
+        * | optional status message ...   |
         */
        CONNECTION_OK = 0,
 
@@ -62,16 +73,52 @@ typedef enum {
         * CONNECTION_ERROR:
         * Indicates that a command has failed. The message body will contain a
         * string describing the error.
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | message type  | length        |
+        * +---------------+---------------+
+        * | error message ...             |
         */
        CONNECTION_ERROR,
 
        /*
         * CONNECTION_LOG:
         * Indicates an asynchronous log message. The message body will contain
-        * the message string providing informational or warning logs. Log
-        * messages may be sent to the client any time.
+        * the log priority (see utils/error.h) and message. Log messages may be
+        * sent to the client any time.
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | message type  | length        |
+        * +---------------+---------------+
+        * | log priority  | log message   |
+        * +---------------+               |
+        * | ...                           |
         */
        CONNECTION_LOG,
+
+       /*
+        * Query-result specific messages.
+        */
+
+       /*
+        * CONNECTION_DATA:
+        * Indicates that a data query was successful. The message body will
+        * contain the type of the data and the result encoded as a JSON string.
+        * The type is the same as the command code of the respective command (see
+        * below) and is stored as an unsigned 32bit integer in network
+        * byte-order. The result may be empty (but the type is still included).
+        *
+        * 0               32              64
+        * +---------------+---------------+
+        * | message type  | length        |
+        * +---------------+---------------+
+        * | result type   | result ...    |
+        * +---------------+               |
+        * | ...                           |
+        */
+       CONNECTION_DATA = 100,
 } sdb_conn_status_t;
 
 /* accepted commands / state of the connection */
@@ -103,7 +150,12 @@ typedef enum {
        CONNECTION_STARTUP,
 
        /*
-        * Querying the server.
+        * Querying the server. On success, the server replies with
+        * CONNECTION_DATA.
+        *
+        * The command codes listed here are used, both, for sending a query to
+        * the server and to indicate the response type from a query in a DATA
+        * message.
         */
 
        /*
@@ -149,7 +201,7 @@ typedef enum {
         * CONNECTION_EXPR:
         * A parsed expression. Only used internally.
         */
-       CONNECTION_EXPR,
+       CONNECTION_EXPR = 100,
 } sdb_conn_state_t;
 
 #ifdef __cplusplus