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

Function _reply_light

modules/tm/t_reply.c:346–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344
345
346static int _reply_light( struct cell *trans, char* buf, unsigned int len,
347 unsigned int code, char *to_tag, unsigned int to_tag_len,
348 int lock, struct bookmark *bm)
349{
350 struct retr_buf *rb;
351 unsigned int buf_len;
352 branch_bm_t cancel_bitmap = BRANCH_BM_ZERO;
353 str cb_s;
354
355 if (!buf)
356 {
357 LM_DBG("response building failed\n");
358 /* determine if there are some branches to be canceled */
359 if ( is_invite(trans) ) {
360 if (lock) LOCK_REPLIES( trans );
361 which_cancel(trans, cancel_bitmap );
362 if (lock) UNLOCK_REPLIES( trans );
363 }
364 /* and clean-up, including cancellations, if needed */
365 goto error;
366 }
367
368 if (lock) LOCK_REPLIES( trans );
369 if (trans->uas.status>=200) {
370 LM_ERR("failed to generate %d reply when a final %d was sent out\n",
371 code, trans->uas.status);
372 goto error2;
373 }
374 if ( is_invite(trans) && code>=200 )
375 which_cancel(trans, cancel_bitmap );
376
377
378 rb = & trans->uas.response;
379 rb->activ_type=code;
380
381 trans->uas.status = code;
382 buf_len = rb->buffer.s ? len : len + REPLY_OVERBUFFER_LEN;
383 rb->buffer.s = shm_realloc( rb->buffer.s, buf_len );
384 /* puts the reply's buffer to uas.response */
385 if (! rb->buffer.s ) {
386 LM_ERR("failed to allocate shmem buffer\n");
387 goto error3;
388 }
389 update_local_tags(trans, bm, rb->buffer.s, buf);
390
391 rb->buffer.len = len ;
392 memcpy( rb->buffer.s , buf , len );
393 /* needs to be protected too because what timers are set depends
394 on current transactions status */
395 /* t_update_timers_after_sending_reply( rb ); */
396 trans->relaied_reply_branch=-2;
397 if (lock) UNLOCK_REPLIES( trans );
398
399 /* do UAC cleanup procedures in case we generated
400 a final answer whereas there are pending UACs */
401 if (code>=200) {
402 if ( is_local(trans) ) {
403 LM_DBG("local transaction completed\n");

Callers 2

_replyFunction · 0.85
_reply_with_bodyFunction · 0.85

Calls 13

which_cancelFunction · 0.85
shm_reallocFunction · 0.85
update_local_tagsFunction · 0.85
run_trans_callbacksFunction · 0.85
set_extra_tmcb_paramsFunction · 0.85
cleanup_uac_timersFunction · 0.85
cancel_uacsFunction · 0.85
set_final_timerFunction · 0.85
put_on_waitFunction · 0.85
run_top_routeFunction · 0.85
free_sip_msgFunction · 0.85

Tested by

no test coverage detected