X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=blobdiff_plain;f=tr%2Ftr_trp_mons.c;h=354d1c87192d2560c4b6438760758bd56630d952;hp=9c38f0df973f11cf88826770cbda57ebfed1b13e;hb=HEAD;hpb=d842a66ec3d7b66dc745ebdc0cf428110f093679 diff --git a/tr/tr_trp_mons.c b/tr/tr_trp_mons.c index 9c38f0d..354d1c8 100644 --- a/tr/tr_trp_mons.c +++ b/tr/tr_trp_mons.c @@ -38,6 +38,9 @@ #include #include #include +#include +#include +#include #include #include @@ -49,9 +52,42 @@ static MON_RC handle_show_routes(void *cookie, json_t **response_ptr) return (*response_ptr == NULL) ? MON_NOMEM : MON_SUCCESS; } +static MON_RC handle_show_peers(void *cookie, json_t **response_ptr) +{ + TRPS_INSTANCE *trps = talloc_get_type_abort(cookie, TRPS_INSTANCE); + + *response_ptr = trp_ptable_to_json(trps->ptable); + return (*response_ptr == NULL) ? MON_NOMEM : MON_SUCCESS; +} + +static MON_RC handle_show_communities(void *cookie, json_t **response_ptr) +{ + TRPS_INSTANCE *trps = talloc_get_type_abort(cookie, TRPS_INSTANCE); + + *response_ptr = tr_comm_table_to_json(trps->ctable); + return (*response_ptr == NULL) ? MON_NOMEM : MON_SUCCESS; +} + +static MON_RC handle_show_realms(void *cookie, json_t **response_ptr) +{ + TRPS_INSTANCE *trps = talloc_get_type_abort(cookie, TRPS_INSTANCE); + + *response_ptr = tr_idp_realms_to_json(trps->ctable->idp_realms); + return (*response_ptr == NULL) ? MON_NOMEM : MON_SUCCESS; +} + void tr_trp_register_mons_handlers(TRPS_INSTANCE *trps, MONS_INSTANCE *mons) { mons_register_handler(mons, MON_CMD_SHOW, OPT_TYPE_SHOW_ROUTES, handle_show_routes, trps); + mons_register_handler(mons, + MON_CMD_SHOW, OPT_TYPE_SHOW_PEERS, + handle_show_peers, trps); + mons_register_handler(mons, + MON_CMD_SHOW, OPT_TYPE_SHOW_COMMUNITIES, + handle_show_communities, trps); + mons_register_handler(mons, + MON_CMD_SHOW, OPT_TYPE_SHOW_REALMS, + handle_show_realms, trps); }