Clean up monitoring format/naming
[trust_router.git] / include / mon_internal.h
index 189695f..29ea514 100644 (file)
 #include <stdint.h>
 #include <jansson.h>
 #include <gmodule.h>
-//#include <trp_internal.h>
+#include <gssapi.h>
+#include <trust_router/tid.h>
+#include <trp_internal.h>
 #include <tr_gss_names.h>
+#include <tr_gss_client.h>
 #include <tr_name_internal.h>
-#include <gssapi.h>
 #include <trust_router/tr_dh.h>
+#include <mon.h>
 
 /* Typedefs */
 typedef struct mon_req MON_REQ;
@@ -88,19 +91,24 @@ enum mon_resp_code {
 
 enum mon_opt_type {
   OPT_TYPE_UNKNOWN=0,
+  OPT_TYPE_ANY,
 
   // System information
   OPT_TYPE_SHOW_VERSION,
-  OPT_TYPE_SHOW_SERIAL,
+  OPT_TYPE_SHOW_CONFIG_FILES,
 
   // System statistics
   OPT_TYPE_SHOW_UPTIME,
   OPT_TYPE_SHOW_TID_REQ_COUNT,
+  OPT_TYPE_SHOW_TID_REQ_ERR_COUNT,
   OPT_TYPE_SHOW_TID_REQ_PENDING,
 
   // Dynamic trust router state
   OPT_TYPE_SHOW_ROUTES,
-  OPT_TYPE_SHOW_COMMUNITIES
+  OPT_TYPE_SHOW_PEERS,
+  OPT_TYPE_SHOW_COMMUNITIES,
+  OPT_TYPE_SHOW_REALMS,
+  OPT_TYPE_SHOW_RP_CLIENTS
 };
 
 struct mon_opt {
@@ -113,7 +121,6 @@ struct mon_req {
 };
 
 struct mon_resp {
-  MON_REQ *req; // request this responds to
   MON_RESP_CODE code;
   TR_NAME *message;
   json_t *payload;
@@ -124,16 +131,18 @@ struct mons_instance {
   const char *hostname;
   unsigned int port;
   TR_GSS_NAMES *authorized_gss_names;
-  void *tids; // TODO sort out header file cycles and use typed pointers
-  void *trps; // TODO sort out header file cycles and use typed pointers
+  TIDS_INSTANCE *tids;
+  TRPS_INSTANCE *trps;
   MONS_REQ_FUNC *req_handler;
   MONS_AUTH_FUNC *auth_handler;
   void *cookie;
+  GPtrArray *handlers;
+  GArray *pids; /* PIDs of active mons processes */
 };
 
-/* Monitoring client instance */
+/* Client instance */
 struct monc_instance {
-  DH *client_dh;
+  TR_GSSC_INSTANCE *gssc;
 };
 
 /* Prototypes */
@@ -155,18 +164,20 @@ json_t *mon_req_encode(MON_REQ *req);
 
 /* mon_req_decode.c */
 MON_REQ *mon_req_decode(TALLOC_CTX *mem_ctx, json_t *req_json);
+MON_REQ *mon_req_parse(TALLOC_CTX *mem_ctx, const char *input);
 
 /* mon_resp.c */
-MON_RESP *mon_resp_new(TALLOC_CTX *mem_ctx,
-                          MON_REQ *req,
-                          MON_RESP_CODE code,
-                          const char *msg,
-                          json_t *payload);
+MON_RESP *mon_resp_new(TALLOC_CTX *mem_ctx, MON_RESP_CODE code, const char *msg, json_t *payload);
 void mon_resp_free(MON_RESP *resp);
+int mon_resp_set_message(MON_RESP *resp, const char *new_msg);
+void mon_resp_set_payload(MON_RESP *resp, json_t *new_payload);
 
 /* mon_resp_encode.c */
 json_t *mon_resp_encode(MON_RESP *resp);
 
+/* mon_resp_decode.c */
+MON_RESP * mon_resp_decode(TALLOC_CTX *mem_ctx, json_t *resp_json);
+
 /* mons.c */
 MONS_INSTANCE *mons_new(TALLOC_CTX *mem_ctx);
 int mons_get_listener(MONS_INSTANCE *mons, MONS_REQ_FUNC *req_handler, MONS_AUTH_FUNC *auth_handler, const char *hostname,
@@ -174,14 +185,11 @@ int mons_get_listener(MONS_INSTANCE *mons, MONS_REQ_FUNC *req_handler, MONS_AUTH
 int mons_accept(MONS_INSTANCE *mons, int listen);
 
 /* monc.c */
-MONC_INSTANCE *monc_create(void);
-void monc_destroy(MONC_INSTANCE *monc);
-int monc_open_connection (MONC_INSTANCE *monc, const char *server, unsigned int port, gss_ctx_id_t *gssctx);
-int monc_send_request (MONC_INSTANCE *monc, int conn, gss_ctx_id_t gssctx, MONC_RESP_FUNC *resp_handler,
-                       void *cookie);
-int monc_fwd_request(MONC_INSTANCE *monc, int conn, gss_ctx_id_t gssctx, MON_REQ *mon_req,
-                     MONC_RESP_FUNC *resp_handler, void *cookie);
-DH * monc_get_dh(MONC_INSTANCE *inst);
+MONC_INSTANCE *monc_new(TALLOC_CTX *mem_ctx);
+void monc_free(MONC_INSTANCE *monc);
+DH *monc_get_dh(MONC_INSTANCE *inst);
 DH *monc_set_dh(MONC_INSTANCE *inst, DH *dh);
+int monc_open_connection(MONC_INSTANCE *monc, const char *server, unsigned int port);
+MON_RESP *monc_send_request(TALLOC_CTX *mem_ctx, MONC_INSTANCE *monc, MON_REQ *req);
 
 #endif //TRUST_ROUTER_MON_REQ_H