void tr_print_config (TR_CFG *cfg) {
tr_notice("tr_print_config: Logging running trust router configuration.");
- tr_print_comms(cfg->comms);
+ tr_print_comms(cfg->ctable);
}
void tr_print_comms (TR_COMM_TABLE *ctab)
TR_CFG *cfg=talloc(mem_ctx, TR_CFG);
if (cfg!=NULL) {
cfg->internal=NULL;
- cfg->idp_realms=NULL;
- cfg->rp_realms=NULL;
cfg->rp_clients=NULL;
cfg->peers=NULL;
cfg->default_servers=NULL;
- cfg->comms=tr_comm_table_new(cfg);
- if (cfg->comms==NULL) {
+ cfg->ctable=tr_comm_table_new(cfg);
+ if (cfg->ctable==NULL) {
talloc_free(cfg);
cfg=NULL;
}
json_t *jcfgsettle = NULL;
json_t *jroutesweep = NULL;
json_t *jrouteupdate = NULL;
+ json_t *jtidreq_timeout = NULL;
+ json_t *jtidresp_numer = NULL;
+ json_t *jtidresp_denom = NULL;
json_t *jrouteconnect = NULL;
if ((!trc) || (!jcfg))
trc->internal->trp_update_interval=TR_DEFAULT_TRP_UPDATE_INTERVAL;
}
+ if (NULL != (jtidreq_timeout = json_object_get(jint, "tid_request_timeout"))) {
+ if (json_is_number(jtidreq_timeout)) {
+ trc->internal->tid_req_timeout = json_integer_value(jtidreq_timeout);
+ } else {
+ tr_debug("tr_cfg_parse_internal: Parsing error, tid_request_timeout is not a number.");
+ return TR_CFG_NOPARSE;
+ }
+ } else {
+ /* if not configured, use the default */
+ trc->internal->tid_req_timeout=TR_DEFAULT_TID_REQ_TIMEOUT;
+ }
+
+ if (NULL != (jtidresp_numer = json_object_get(jint, "tid_response_numerator"))) {
+ if (json_is_number(jtidresp_numer)) {
+ trc->internal->tid_resp_numer = json_integer_value(jtidresp_numer);
+ } else {
+ tr_debug("tr_cfg_parse_internal: Parsing error, tid_response_numerator is not a number.");
+ return TR_CFG_NOPARSE;
+ }
+ } else {
+ /* if not configured, use the default */
+ trc->internal->tid_resp_numer=TR_DEFAULT_TID_RESP_NUMER;
+ }
+
+ if (NULL != (jtidresp_denom = json_object_get(jint, "tid_response_denominator"))) {
+ if (json_is_number(jtidresp_denom)) {
+ trc->internal->tid_resp_denom = json_integer_value(jtidresp_denom);
+ } else {
+ tr_debug("tr_cfg_parse_internal: Parsing error, tid_response_denominator is not a number.");
+ return TR_CFG_NOPARSE;
+ }
+ } else {
+ /* if not configured, use the default */
+ trc->internal->tid_resp_denom=TR_DEFAULT_TID_RESP_DENOM;
+ }
+
if (NULL != (jlog = json_object_get(jint, "logging"))) {
if (NULL != (jlogthres = json_object_get(jlog, "log_threshold"))) {
if (json_is_string(jlogthres)) {
/* if we succeeded, link things to the configuration and move out of tmp context */
if (retval==TR_CFG_SUCCESS) {
if (new_idp_realms!=NULL) {
- tr_idp_realm_add(trc->idp_realms, new_idp_realms); /* fixes talloc contexts except for head*/
- talloc_steal(trc, trc->idp_realms); /* make sure the head is in the right context */
+ tr_idp_realm_add(trc->ctable->idp_realms, new_idp_realms); /* fixes talloc contexts except for head*/
+ talloc_steal(trc, trc->ctable->idp_realms); /* make sure the head is in the right context */
}
if (new_rp_clients!=NULL) {
*rc=TR_CFG_ERROR;
return;
}
- tr_comm_add_idp_realm(trc->comms, comm, found_idp, NULL, NULL); /* no provenance, never expires */
+ tr_comm_add_idp_realm(trc->ctable, comm, found_idp, 0, NULL, NULL); /* no provenance, never expires */
}
*rc=TR_CFG_SUCCESS;
}
/* see if we already have this RP in this community */
- found_rp=tr_comm_find_rp(trc->comms, comm, rp_name);
+ found_rp=tr_comm_find_rp(trc->ctable, comm, rp_name);
if (found_rp!=NULL) {
tr_notice("tr_cfg_parse_comm_rps: RP %s repeated in community %.*s.",
s, tr_comm_get_id(comm)->len, tr_comm_get_id(comm)->buf);
}
/* Add the RP to the community, first see if we have the RP in any community */
- found_rp=tr_rp_realm_lookup(trc->rp_realms, rp_name);
- if (found_rp!=NULL)
+ found_rp=tr_rp_realm_lookup(trc->ctable->rp_realms, rp_name);
+ if (found_rp!=NULL) {
+ tr_debug("tr_cfg_parse_comm_rps: RP realm %s already exists.", s);
new_rp=found_rp; /* use it rather than creating a new realm record */
- else {
+ } else {
new_rp=tr_rp_realm_new(NULL);
if (new_rp==NULL) {
tr_err("tr_cfg_parse_comm_rps: unable to allocate RP record for %s in community %.*s.",
s, tr_comm_get_id(comm)->len, tr_comm_get_id(comm)->buf);
}
+ tr_debug("tr_cfg_parse_comm_rps: setting name to %s", rp_name->buf);
tr_rp_realm_set_id(new_rp, rp_name);
rp_name=NULL; /* rp_name no longer belongs to us */
- tr_rp_realm_add(trc->rp_realms, new_rp);
+ tr_rp_realm_add(trc->ctable->rp_realms, new_rp);
+ talloc_steal(trc->ctable, trc->ctable->rp_realms); /* make sure head is in the right context */
}
- tr_comm_add_rp_realm(trc->comms, comm, new_rp, NULL, NULL);
+ tr_comm_add_rp_realm(trc->ctable, comm, new_rp, 0, NULL, NULL);
}
}
trc,
json_array_get(jcomms, i),
&rc))) {
- return rc;
+ return rc;
}
tr_debug("tr_cfg_parse_comms: Community configured: %s.",
tr_comm_get_id(comm)->buf);
- tr_comm_table_add_comm(trc->comms, comm);
+ tr_comm_table_add_comm(trc->ctable, comm);
}
}
tr_debug("tr_cfg_parse_comms: Finished (rc=%d)", rc);
rc = TR_CFG_ERROR;
}
- if (0==tr_comm_table_size(trc->comms)) {
+ if (0==tr_comm_table_size(trc->ctable)) {
tr_debug("tr_cfg_validate: Error: No Communities configured");
rc = TR_CFG_ERROR;
}
- if ((NULL == trc->default_servers) && (NULL == trc->idp_realms)) {
+ if ((NULL == trc->default_servers) && (NULL == trc->ctable->idp_realms)) {
tr_debug("tr_cfg_validate: Error: No default servers or IDPs configured.");
rc = TR_CFG_ERROR;
}
return NULL;
}
- for (cfg_idp = tr_cfg->idp_realms; NULL != cfg_idp; cfg_idp = cfg_idp->next) {
+ for (cfg_idp = tr_cfg->ctable->idp_realms; NULL != cfg_idp; cfg_idp = cfg_idp->next) {
if (!tr_name_cmp (idp_id, cfg_idp->realm_id)) {
tr_debug("tr_cfg_find_idp: Found %s.", idp_id->buf);
return cfg_idp;