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

Function t_inject_branch

modules/tm/t_fwd.c:1130–1213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1128}
1129
1130int t_inject_branch( struct cell *t, struct sip_msg *msg, int flags)
1131{
1132 static struct sip_msg faked_req;
1133 branch_bm_t cancel_bm = BRANCH_BM_ZERO;
1134 str reason = str_init(CANCEL_REASON_200);
1135 struct cell *bk_t = NULL;
1136 int rc;
1137
1138 /* does the transaction state still accept new branches ? */
1139 if (t->uas.status >= 200) {
1140 LM_DBG("cannot add branches to a transaction with %d UAS\n",
1141 t->uas.status);
1142 return -2;
1143 }
1144
1145 if (!fake_req( &faked_req, t->uas.request, &t->uas, NULL)) {
1146 LM_ERR("fake_req failed\n");
1147 return -1;
1148 }
1149
1150 /* do we have the branches to be injected ? */
1151 if (flags&TM_INJECT_SRC_EVENT) {
1152 /* get the branch from Event AVPs, as populated by EVI/EBR */
1153 if (ul_contact_event_to_msg( &faked_req )<0) {
1154 LM_ERR("failed to grab new branch from Event\n");
1155 goto error;
1156 }
1157 } else {
1158 /* use the RURI+dset array as destinations to be injected */
1159 if (msg->first_line.type==SIP_REQUEST) {
1160 /* take the RURI branch from the script msg and move it
1161 * into the faked msg (that will be used by t_fwd function) */
1162 if (dst_to_msg( msg, &faked_req )<0) {
1163 LM_ERR("failed to grab new branch from Event\n");
1164 goto error;
1165 }
1166 } else {
1167 /* current message is a reply, so take the first branch from dset
1168 * and move it into the faked msg (that will be used by t_fwd
1169 * function)*/
1170 if (move_msg_branch_to_ruri( 0, &faked_req)<0) {
1171 LM_ERR("no branch found to be moved as new destination\n");
1172 goto error;
1173 }
1174 /* remove it from set */
1175 remove_msg_branch(0);
1176 }
1177 }
1178
1179 /* t_forward_nonack() relies on T for various internal stuff, so be
1180 * we advertise the correct one */
1181 bk_t = get_t();
1182 set_t( t );
1183
1184 /* do we have to cancel the existing branches before injecting new ones? */
1185 if (flags&TM_INJECT_FLAG_CANCEL) {
1186 which_cancel( t, cancel_bm );
1187 }

Callers 1

w_t_inject_branchesFunction · 0.85

Calls 13

fake_reqFunction · 0.85
ul_contact_event_to_msgFunction · 0.85
dst_to_msgFunction · 0.85
move_msg_branch_to_ruriFunction · 0.85
remove_msg_branchFunction · 0.85
get_tFunction · 0.85
set_tFunction · 0.85
which_cancelFunction · 0.85
t_wait_no_more_branchesFunction · 0.85
t_forward_nonackFunction · 0.85
set_cancel_extra_hdrsFunction · 0.85
cancel_uacsFunction · 0.85

Tested by

no test coverage detected