common/tr_config.c \
common/tr_mq.c
-mon_srcs = \
- mon/mon_common.c \
+mon_srcs = \
+ mon/mons.c \
+ mon/mon_common.c \
mon/mon_req.c \
mon/mon_req_encode.c \
mon/mon_req_decode.c \
tr/tr_cfgwatch.c \
tr/tr_tid.c \
tr/tr_trp.c \
+tr/tr_mon.c \
common/tr_gss.c \
$(tid_srcs) \
$(trp_srcs) \
+$(mon_srcs) \
$(common_srcs)
tr_trust_router_LDFLAGS = $(AM_LDFLAGS) -levent_pthreads -pthread
include/tr_msg.h include/tr.h \
include/tr_idp.h include/tr_rp.h \
include/tr_comm.h include/tr_apc.h \
- include/tr_tid.h include/tr_trp.h \
+ include/tr_tid.h include/tr_trp.h include/tr_mon.h \
include/tr_filter.h include/tr_gss_names.h \
include/tid_internal.h include/trp_internal.h \
include/tr_cfgwatch.h include/tr_event.h \
#include <stdint.h>
#include <jansson.h>
#include <gmodule.h>
-
-#include <tr.h>
+#include <trp_internal.h>
#include <tr_gss_names.h>
#include <tr_name_internal.h>
#include <gssapi.h>
--- /dev/null
+/*
+ * Copyright (c) 2018, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef TR_MON_H
+#define TR_MON_H
+
+#include <tr_event.h>
+#include <tr_config.h>
+#include <mon_internal.h>
+
+int tr_mons_event_init(struct event_base *base,
+ MONS_INSTANCE *mons,
+ TR_CFG_MGR *cfg_mgr,
+ struct tr_socket_event *mons_ev);
+
+#endif /* TR_MON_H */
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;
}
/**
+ * 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()
#include <signal.h>
#include <tid_internal.h>
+#include <mon_internal.h>
+#include <tr_mon.h>
#include <tr_tid.h>
#include <tr_trp.h>
#include <tr_config.h>
struct cmdline_args opts;
struct event_base *ev_base;
struct tr_socket_event tids_ev = {0};
-// struct tr_socket_event mon_ev = {0};
+ struct tr_socket_event mon_ev = {0};
struct event *cfgwatch_ev;
configure_signals();
return 1;
}
-// /***** initialize the monitoring interface instance *****/
-// if (NULL == (tr->mons = mons_new(tr))) {
-// tr_crit("Error initializing monitoring interface instance.");
-// return 1;
-// }
+ /***** initialize the monitoring interface instance *****/
+ if (NULL == (tr->mons = mons_new(tr))) {
+ tr_crit("Error initializing monitoring interface instance.");
+ return 1;
+ }
+ /* Monitor our tids/trps instances */
+ tr->mons->tids = tr->tids;
+ tr->mons->trps = tr->trps;
/***** process configuration *****/
tr->cfgwatch=tr_cfgwatch_create(tr);
return 1;
}
-// /* install monitoring interface events */
-// tr_debug("Initializing monitoring interface events.");
-// if (0 != tr_mon_event_init(tr->mons, ev_base, &mon_ev)) {
-// tr_crit("Error initializing monitoring interface.");
-// return 1;
-// }
+ /* install monitoring interface events */
+ tr_debug("Initializing monitoring interface events.");
+ if (0 != tr_mons_event_init(ev_base, tr->mons, tr->cfg_mgr, &mon_ev)) {
+ tr_crit("Error initializing monitoring interface.");
+ return 1;
+ }
/* install TID server events */
tr_debug("Initializing TID server events.");
#include <tr_config.h>
#include <tr_debug.h>
#include <mon_internal.h>
+#include <tr_mon.h>
/*
* Cookie for the event handling callback
* @param mons_ev monitoring interface event instance
* @return 0 on success, nonzero on failure.
* */
-int tr_mon_event_init(struct event_base *base, MONS_INSTANCE *mons, TR_CFG_MGR *cfg_mgr, struct tr_socket_event *mons_ev)
+int tr_mons_event_init(struct event_base *base,
+ MONS_INSTANCE *mons,
+ TR_CFG_MGR *cfg_mgr,
+ struct tr_socket_event *mons_ev)
{
TALLOC_CTX *tmp_ctx=talloc_new(NULL);
struct tr_mons_event_cookie *cookie=NULL;