X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=blobdiff_plain;f=mon%2Fmons.c;h=d2a5c8ab19c3f86d5af4f17c87a49659991f6919;hp=d79cbcbdca707482271e30b6f626ed938362a1df;hb=f55d5503336233c90fb84aec15c2f0a18116831e;hpb=e20e7787d7bd5c1f89ddfcc48fc52054b65423d8 diff --git a/mon/mons.c b/mon/mons.c index d79cbcb..d2a5c8a 100644 --- a/mon/mons.c +++ b/mon/mons.c @@ -44,6 +44,8 @@ #include #include +#include "mons_handlers.h" + /** * Allocate a new MONS_INSTANCE * @@ -78,9 +80,30 @@ MONS_INSTANCE *mons_new(TALLOC_CTX *mem_ctx) * @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) +static TR_MSG *mons_req_cb(TALLOC_CTX *mem_ctx, TR_MSG *req_msg, void *data) { - return "This is a response."; + TALLOC_CTX *tmp_ctx = talloc_new(NULL); + //MONS_INSTANCE *mons = talloc_get_type_abort(data, MONS_INSTANCE); + MON_REQ *req = NULL; + TR_MSG *resp_msg = NULL; /* This is the response value */ + + /* Validate inputs */ + if (req_msg == NULL) + goto cleanup; + + req = tr_msg_get_mon_req(req_msg); + if (req == NULL) { + /* this is an internal error */ + tr_err("mons_req_cb: Received incorrect message type (was %d, expected %d)", + tr_msg_get_msg_type(req_msg), + MON_REQUEST); + /* TODO send an error response */ + goto cleanup; + } + +cleanup: + talloc_free(tmp_ctx); + return resp_msg; } /**