Further work on tids and monitoring, tids appears to work again
[trust_router.git] / mon / mons.c
index 31ecb15..d79cbcb 100644 (file)
@@ -55,7 +55,10 @@ MONS_INSTANCE *mons_new(TALLOC_CTX *mem_ctx)
   MONS_INSTANCE *mons = talloc(mem_ctx, MONS_INSTANCE);
 
   if (mons) {
+    mons->hostname = NULL;
     mons->port = 0;
+    mons->tids = NULL;
+    mons->trps = NULL;
     mons->req_handler = NULL;
     mons->auth_handler = NULL;
     mons->cookie = NULL;
@@ -69,6 +72,18 @@ MONS_INSTANCE *mons_new(TALLOC_CTX *mem_ctx)
 }
 
 /**
+ * Callback to process a request and produce a response
+ *
+ * @param req_str JSON-encoded request
+ * @param data pointer to a MONS_INSTANCE
+ * @return pointer to the response string or null to send no response
+ */
+static char *mons_req_cb(TALLOC_CTX *mem_ctx, const char *req_str, void *data)
+{
+  return "This is a response.";
+}
+
+/**
  * Create a listener for monitoring requests
  *
  * Accept connections with mons_accept()
@@ -83,13 +98,8 @@ MONS_INSTANCE *mons_new(TALLOC_CTX *mem_ctx)
  * @param max_fd
  * @return
  */
-int mons_get_listener(MONS_INSTANCE *mons,
-                      MONS_REQ_FUNC *req_handler,
-                      MONS_AUTH_FUNC *auth_handler,
-                      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,
+                      unsigned int port, void *cookie, int *fd_out, size_t max_fd)
 {
   size_t n_fd=0;
   size_t ii=0;
@@ -120,6 +130,7 @@ int mons_get_listener(MONS_INSTANCE *mons,
     /* store the caller's request handler & cookie */
     mons->req_handler = req_handler;
     mons->auth_handler = auth_handler;
+    mons->hostname = hostname;
     mons->cookie = cookie;
   }