TID_REQ *tid_dup_req (TID_REQ *orig_req) { TID_REQ *new_req = NULL; if (NULL == (new_req = talloc_zero(orig_req, TID_REQ))) { tr_crit("tid_dup_req: Can't allocated duplicate request."); return NULL; } /* Memcpy for flat fields, not valid until names are duped. */ memcpy(new_req, orig_req, sizeof(TID_REQ)); json_incref(new_req->json_references); new_req->free_conn = 0; if ((NULL == (new_req->rp_realm = tr_dup_name(orig_req->rp_realm))) || (NULL == (new_req->realm = tr_dup_name(orig_req->realm))) || (NULL == (new_req->comm = tr_dup_name(orig_req->comm)))) { tr_crit("tid_dup_req: Can't duplicate request (names)."); } if (orig_req->orig_coi) { if (NULL == (new_req->orig_coi = tr_dup_name(orig_req->orig_coi))) { tr_crit("tid_dup_req: Can't duplicate request (orig_coi)."); } } return new_req; }
/** * Create a response with minimal fields filled in * * @param mem_ctx talloc context for the return value * @param req request to respond to * @return new response structure allocated in the mem_ctx context */ static TID_RESP *tids_create_response(TALLOC_CTX *mem_ctx, TID_REQ *req) { TID_RESP *resp=NULL; int success=0; if (NULL == (resp = tid_resp_new(mem_ctx))) { tr_crit("tids_create_response: Error allocating response structure."); return NULL; } resp->result = TID_SUCCESS; /* presume success */ if ((NULL == (resp->rp_realm = tr_dup_name(req->rp_realm))) || (NULL == (resp->realm = tr_dup_name(req->realm))) || (NULL == (resp->comm = tr_dup_name(req->comm)))) { tr_crit("tids_create_response: Error allocating fields in response."); goto cleanup; } if (req->orig_coi) { if (NULL == (resp->orig_coi = tr_dup_name(req->orig_coi))) { tr_crit("tids_create_response: Error allocating fields in response."); goto cleanup; } } if (req->request_id) { if (NULL == (resp->request_id = tr_dup_name(req->request_id))) { tr_crit("tids_create_response: Error allocating fields in response."); goto cleanup; } } success=1; cleanup: if ((!success) && (resp!=NULL)) { talloc_free(resp); resp=NULL; } return resp; }
/* get a copy of the servicename, caller must free via tr_free_name */ TR_NAME *trp_peer_dup_servicename(TRP_PEER *peer) { return tr_dup_name(peer->servicename); }
/* Get a name that identifies this peer for display to the user, etc. * Makes a copy, caller is responsible for freeing. */ TR_NAME *trp_peer_dup_label(TRP_PEER *peer) { return tr_dup_name(trp_peer_get_label(peer));; }
TR_NAME *tr_comm_dup_owner_contact(TR_COMM *comm) { return tr_dup_name(comm->owner_contact); }
TR_NAME *tr_comm_dup_owner_realm(TR_COMM *comm) { return tr_dup_name(comm->owner_realm); }
TR_NAME *tr_comm_dup_id(TR_COMM *comm) { return tr_dup_name(comm->id); }
TR_NAME *trp_route_dup_next_hop(TRP_ROUTE *entry) { return tr_dup_name(trp_route_get_next_hop(entry)); }
TR_NAME *trp_route_dup_peer(TRP_ROUTE *entry) { return tr_dup_name(trp_route_get_peer(entry)); }
TR_NAME *trp_route_dup_realm(TRP_ROUTE *entry) { return tr_dup_name(trp_route_get_realm(entry)); }