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

Function w_t_relay

modules/tm/tm.c:1363–1439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361
1362
1363static int w_t_relay( struct sip_msg *p_msg , void *flags, struct proxy_l *proxy)
1364{
1365 struct proxy_l *p = NULL;
1366 struct cell *t;
1367 int ret;
1368
1369 t=get_t();
1370
1371 if (proxy && (p=clone_proxy(proxy))==0) {
1372 LM_ERR("failed to clone proxy, dropping packet\n");
1373 return -1;
1374 }
1375
1376 if (!t || t==T_UNDEFINED) {
1377 /* no transaction yet */
1378 if (route_type==FAILURE_ROUTE) {
1379 LM_CRIT("BUG - undefined transaction in failure route\n");
1380 return -1;
1381 }
1382 ret = t_relay_to( p_msg, p, (int)(long)flags );
1383 if (ret<0) {
1384 ret = t_relay_inerr2scripterr();
1385 }
1386 } else {
1387 /* transaction already created */
1388
1389 if ( route_type!=REQUEST_ROUTE && route_type!=FAILURE_ROUTE )
1390 goto route_err;
1391
1392 if (p_msg->REQ_METHOD==METHOD_ACK) {
1393 /* local ACK*/
1394 t_release_transaction(t);
1395 return 1;
1396 }
1397
1398 if (((int)(long)flags)&TM_T_RELAY_nodnsfo_FLAG)
1399 t->flags|=T_NO_DNS_FAILOVER_FLAG;
1400 if (((int)(long)flags)&TM_T_RELAY_reason_FLAG)
1401 t->flags|=T_CANCEL_REASON_FLAG;
1402 if ( (((int)(long)flags)&TM_T_RELAY_do_cancel_dis_FLAG) &&
1403 tm_has_request_disponsition_no_cancel(p_msg)==0 )
1404 t->flags|=T_MULTI_200OK_FLAG;
1405
1406 if (route_type==FAILURE_ROUTE) {
1407 /* If called from failure route we need reset the branch counter to
1408 * ignore the previous set of branches (already terminated) */
1409 ret = t_forward_nonack( t, p_msg, p, 1/*reset*/,1/*locked*/);
1410 } else {
1411 /* if called from request route and the transaction was previously
1412 * created, better lock here to avoid any overlapping with
1413 * branch injection from other processes */
1414 LOCK_REPLIES(t);
1415
1416 /* update the transaction only if in REQUEST route; for other types
1417 of routes we do not want to inherit the local changes */
1418 if (route_type==REQUEST_ROUTE)
1419 update_cloned_msg_from_msg( t->uas.request, p_msg);
1420

Callers

nothing calls this directly

Calls 9

get_tFunction · 0.85
clone_proxyFunction · 0.85
t_relay_toFunction · 0.85
t_relay_inerr2scripterrFunction · 0.85
t_release_transactionFunction · 0.85
t_forward_nonackFunction · 0.85
free_proxyFunction · 0.85

Tested by

no test coverage detected