Refactor MON_CMD and MON_OPT_TYPE conversion to/from strings
[trust_router.git] / include / mon_internal.h
index d2d1572..1e6dcdd 100644 (file)
 #include <talloc.h>
 #include <stdint.h>
 #include <jansson.h>
-#include <gmodule.h>
+#include <glib.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 <trust_router/tr_dh.h>
 #include <mon.h>
 
 /* Typedefs */
@@ -79,7 +78,6 @@ enum mon_rc {
 
 enum mon_cmd {
   MON_CMD_UNKNOWN=0,
-  MON_CMD_RECONFIGURE,
   MON_CMD_SHOW
 };
 
@@ -91,19 +89,25 @@ 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_PENDING,
+  OPT_TYPE_SHOW_TID_REQS_PROCESSED,
+  OPT_TYPE_SHOW_TID_REQS_FAILED,
+  OPT_TYPE_SHOW_TID_ERROR_COUNT,
+  OPT_TYPE_SHOW_TID_REQS_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 {
@@ -124,13 +128,15 @@ struct mon_resp {
 /* Monitoring server instance */
 struct mons_instance {
   const char *hostname;
-  unsigned int port;
+  int mon_port;
   TR_GSS_NAMES *authorized_gss_names;
   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 */
 };
 
 /* Client instance */
@@ -139,7 +145,7 @@ struct monc_instance {
 };
 
 /* Prototypes */
-/* tr_mon.c */
+/* mon_common.c */
 const char *mon_cmd_to_string(MON_CMD cmd);
 MON_CMD mon_cmd_from_string(const char *s);
 const char *mon_opt_type_to_string(MON_OPT_TYPE opt_type);
@@ -173,16 +179,20 @@ 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,
-                      unsigned int port, void *cookie, int *fd_out, size_t max_fd);
+int mons_get_listener(MONS_INSTANCE *mons,
+                      MONS_REQ_FUNC *req_handler,
+                      MONS_AUTH_FUNC *auth_handler,
+                      const char *hostname,
+                      int port,
+                      void *cookie,
+                      int *fd_out,
+                      size_t max_fd);
 int mons_accept(MONS_INSTANCE *mons, int listen);
 
 /* monc.c */
 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);
+int monc_open_connection(MONC_INSTANCE *monc, const char *server, int port);
 MON_RESP *monc_send_request(TALLOC_CTX *mem_ctx, MONC_INSTANCE *monc, MON_REQ *req);
 
 #endif //TRUST_ROUTER_MON_REQ_H