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

Function _reply

modules/tm/t_reply.c:511–554  ·  view source on GitHub ↗

send a UAS reply * returns 1 if everything was OK or -1 for error */

Source from the content-addressed store, hash-verified

509 * returns 1 if everything was OK or -1 for error
510 */
511static int _reply( struct cell *trans, struct sip_msg* p_msg,
512 unsigned int code, const str *text, int lock )
513{
514 unsigned int len;
515 char * buf, *dset;
516 struct bookmark bm;
517 int dset_len;
518
519 if (code>=200) set_kr(REQ_RPLD);
520 /* compute the buffer in private memory prior to entering lock;
521 * create to-tag if needed */
522
523 /* if that is a redirection message, dump current message set to it */
524 if (code>=300 && code<400) {
525 dset=print_dset(p_msg, &dset_len);
526 if (dset) {
527 add_lump_rpl(p_msg, dset, dset_len, LUMP_RPL_HDR);
528 }
529 }
530
531 if (has_tran_tmcbs(trans, TMCB_LOCAL_RESPONSE)) {
532 run_trans_callbacks(TMCB_LOCAL_RESPONSE,
533 trans, p_msg, 0, code);
534 }
535
536 /* check if the UAS retranmission port needs to be updated */
537 if ( (p_msg->msg_flags ^ trans->uas.request->msg_flags) & FL_FORCE_RPORT )
538 su_setport( &trans->uas.response.dst.to, p_msg->rcv.src_port );
539
540 if (code>=180 && p_msg->to
541 && (get_to(p_msg)->tag_value.s==0
542 || get_to(p_msg)->tag_value.len==0)) {
543 calc_tag_suffix( p_msg, tm_tag_suffix );
544 buf = build_res_buf_from_sip_req(code,text, &tm_tag, p_msg, &len, &bm);
545 return _reply_light( trans, buf, len, code,
546 tm_tag.s, TOTAG_VALUE_LEN, lock, &bm);
547 } else {
548 buf = build_res_buf_from_sip_req(code,text, 0 /*no to-tag*/,
549 p_msg, &len, &bm);
550
551 return _reply_light(trans,buf,len,code, 0, 0 /* no to-tag */,
552 lock, &bm);
553 }
554}
555
556/*if msg is set -> it will fake the env. vars conforming with the msg; if NULL
557 * the env. will be restore to original */

Callers 2

t_replyFunction · 0.85
t_reply_unsafeFunction · 0.85

Calls 8

set_krFunction · 0.85
print_dsetFunction · 0.85
add_lump_rplFunction · 0.85
run_trans_callbacksFunction · 0.85
su_setportFunction · 0.85
calc_tag_suffixFunction · 0.85
_reply_lightFunction · 0.85

Tested by

no test coverage detected