From 181a639463de22b7d232a034e95a00a6198e045c Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 7 Sep 2016 15:13:56 -0400 Subject: [PATCH] Install callback to request routes when connections established. --- include/trp_internal.h | 1 + tr/tr_trp.c | 1 + trp/trps.c | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/include/trp_internal.h b/include/trp_internal.h index 35f3f97..30abf54 100644 --- a/include/trp_internal.h +++ b/include/trp_internal.h @@ -165,6 +165,7 @@ TRP_RC trpc_send_msg(TRPC_INSTANCE *trpc, const char *msg_content); TRPS_INSTANCE *trps_new (TALLOC_CTX *mem_ctx); void trps_free (TRPS_INSTANCE *trps); void trps_set_ptable(TRPS_INSTANCE *trps, TRP_PTABLE *ptable); +void trps_set_peer_status_callback(TRPS_INSTANCE *trps, void (*cb)(TRP_PEER *, void *), void *cookie); TRP_RC trps_init_rtable(TRPS_INSTANCE *trps); void trps_clear_rtable(TRPS_INSTANCE *trps); void trps_set_connect_interval(TRPS_INSTANCE *trps, unsigned int interval); diff --git a/tr/tr_trp.c b/tr/tr_trp.c index 11a2d30..5f78976 100644 --- a/tr/tr_trp.c +++ b/tr/tr_trp.c @@ -797,6 +797,7 @@ void tr_config_changed(TR_CFG *new_cfg, void *cookie) trps_set_update_interval(trps, new_cfg->internal->trp_update_interval); trps_set_sweep_interval(trps, new_cfg->internal->trp_sweep_interval); trps_set_ptable(trps, new_cfg->peers); + trps_set_peer_status_callback(trps, tr_peer_status_change, (void *)trps); trps_clear_rtable(trps); /* should we do this every time??? */ tr_add_local_routes(trps, new_cfg); /* should we do this every time??? */ trps_update_active_routes(trps); /* find new routes */ diff --git a/trp/trps.c b/trp/trps.c index 1c6cde5..f770e1c 100644 --- a/trp/trps.c +++ b/trp/trps.c @@ -130,6 +130,19 @@ void trps_set_ptable(TRPS_INSTANCE *trps, TRP_PTABLE *ptable) trps->ptable=ptable; } +void trps_set_peer_status_callback(TRPS_INSTANCE *trps, void (*cb)(TRP_PEER *, void *), void *cookie) +{ + TRP_PTABLE_ITER *iter=NULL; + TRP_PEER *peer=NULL; + if (trps->ptable==NULL) + return; + + iter=trp_ptable_iter_new(NULL); + for (peer=trp_ptable_iter_first(iter, trps->ptable); peer!=NULL; peer=trp_ptable_iter_next(iter)) + trp_peer_set_conn_status_cb(peer, cb, cookie); + trp_ptable_iter_free(iter); +} + TRPC_INSTANCE *trps_find_trpc(TRPS_INSTANCE *trps, TRP_PEER *peer) { TRPC_INSTANCE *cur=NULL; -- 2.1.4