MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / add_uac

Function add_uac

modules/tm/t_fwd.c:426–545  ·  view source on GitHub ↗

introduce a new uac to transaction; returns its branch id (>=0) or error (<0); it doesn't send a message yet -- a reply to it might interfere with the processes of adding multiple branches NOTICE: do NOT provide (str *) buffers pointing to @request itself, as this may break the function logic! */

Source from the content-addressed store, hash-verified

424 may break the function logic!
425*/
426static int add_uac( struct cell *t, struct sip_msg *request, const str *uri,
427 str* next_hop, unsigned int bflags, str* path,
428 int q, struct usr_avp **attrs, struct proxy_l *proxy)
429{
430 unsigned short branch;
431 struct sip_msg_body *body_clone=NO_BODY_CLONE_MARKER;
432 int do_free_proxy;
433 int ret;
434 struct ua_client* uac;
435
436 branch=t->nr_of_outgoings;
437 if (branch==TM_BRANCH_MAX) {
438 LM_ERR("maximum number of branches -%d- exceeded\n",TM_BRANCH_MAX);
439 ret=E_CFG;
440 goto error;
441 }
442
443 /* do we have the branch chunk allocated? */
444 if ((ret=check_and_alloc_branch( t, branch))<0)
445 goto error;
446
447 uac = & TM_BRANCH( t, branch);
448
449 /* check existing buffer -- rewriting should never occur */
450 if (uac->request.buffer.s) {
451 LM_CRIT("buffer rewrite attempt\n");
452 ret=ser_error=E_BUG;
453 goto error;
454 }
455
456 /* set proper RURI to request to reflect the branch */
457 request->new_uri=*uri;
458 request->parsed_uri_ok=0;
459 request->dst_uri=*next_hop;
460 request->path_vec=*path;
461 request->ruri_bflags=bflags;
462
463 /* we attach the attrs here as we need to see them in branch route
464 * (inside pre_print_uac_request())
465 * They will remain attached here if the UAC is successfully created;
466 * if we exit with return the attrs will be freed by clean_branch().
467 * Bottom line, we take over the attr list handling, so we NULL the
468 * received holder (so the upper level will havve nothing to care furhter)
469 */
470 if (attrs) {
471 uac->battrs = *attrs;
472 *attrs = NULL;
473 }
474
475 if ( pre_print_uac_request( t, branch, request, &body_clone)!= 0 ) {
476 ret = -1;
477 goto error01;
478 }
479
480 /* check DNS resolution */
481 if (proxy){
482 do_free_proxy = 0;
483 }else {

Callers 1

t_forward_nonackFunction · 0.85

Calls 11

check_and_alloc_branchFunction · 0.85
pre_print_uac_requestFunction · 0.85
uri2proxyFunction · 0.85
msg_callback_processFunction · 0.85
shm_clone_proxyFunction · 0.85
hostent2suFunction · 0.85
update_uac_dstFunction · 0.85
count_local_rrFunction · 0.85
free_proxyFunction · 0.85
post_print_uac_requestFunction · 0.85
init_branchFunction · 0.85

Tested by

no test coverage detected