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

Function relay_reply

modules/tm/t_reply.c:1245–1452  ·  view source on GitHub ↗

this is the code which decides what and when shall be relayed upstream; note well -- it assumes it is entered locked with REPLY_LOCK and it returns unlocked! */

Source from the content-addressed store, hash-verified

1243 REPLY_LOCK and it returns unlocked!
1244*/
1245enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1246 unsigned int msg_status, branch_bm_t cancel_bitmap )
1247{
1248 int relay;
1249 int save_clone;
1250 char *buf;
1251 /* length of outbound reply */
1252 unsigned int res_len;
1253 int relayed_code;
1254 struct sip_msg *relayed_msg;
1255 struct bookmark bm;
1256 int totag_retr;
1257 enum rps reply_status;
1258 /* retransmission structure of outbound reply and request */
1259 struct retr_buf *uas_rb;
1260 str cb_s;
1261 str text;
1262
1263 /* keep compiler warnings about use of uninit vars silent */
1264 res_len=0;
1265 buf=0;
1266 relayed_msg=0;
1267 relayed_code=0;
1268 totag_retr=0;
1269
1270
1271 /* remember, what was sent upstream to know whether we are
1272 * forwarding a first final reply or not */
1273
1274 /* *** store and relay message as needed *** */
1275 reply_status = t_should_relay_response(t, msg_status, branch,
1276 &save_clone, &relay, cancel_bitmap, p_msg );
1277 LM_DBG("T_state=%d, branch=%d, save=%d, relay=%d, "
1278 "cancel_BM="BRANCH_BM_SPECS"\n", reply_status, branch,
1279 save_clone, relay, BRANCH_BM_ARGS(cancel_bitmap));
1280
1281 /* store the message if needed */
1282 if (save_clone) /* save for later use, typically branch picking */
1283 {
1284 if (!store_reply( t, branch, p_msg ))
1285 goto error01;
1286 }
1287
1288 uas_rb = & t->uas.response;
1289 if (relay >= 0 ) {
1290 /* initialize sockets for outbound reply */
1291 uas_rb->activ_type=msg_status;
1292
1293 t->relaied_reply_branch = relay;
1294
1295 /* try building the outbound reply from either the current
1296 * or a stored message */
1297 relayed_msg = branch==relay ? p_msg : TM_BRANCH(t,relay).reply;
1298 if (relayed_msg==FAKED_REPLY) {
1299 relayed_code = branch==relay
1300 ? msg_status : TM_BRANCH(t,relay).last_received;
1301
1302 text.s = error_text(relayed_code);

Callers 4

process_reply_and_timerFunction · 0.85
cancel_inviteFunction · 0.85
fake_replyFunction · 0.85

Calls 15

t_should_relay_responseFunction · 0.85
store_replyFunction · 0.85
error_textFunction · 0.85
calc_tag_suffixFunction · 0.85
run_trans_callbacksFunction · 0.85
del_notflaged_lumpsFunction · 0.85
shm_reallocFunction · 0.85
update_local_tagsFunction · 0.85
stats_trans_rplFunction · 0.85
update_totag_setFunction · 0.85

Tested by

no test coverage detected