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

Function build_res_buf_from_sip_req

msg_translator.c:2480–2762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2478
2479
2480char * build_res_buf_from_sip_req( unsigned int code, const str *text ,str *new_tag,
2481 struct sip_msg* msg, unsigned int *returned_len, struct bookmark *bmark)
2482{
2483 char *buf, *p, *received_buf, *rport_buf, *warning_buf;
2484 char *content_len_buf, *after_body, *totags;
2485 unsigned int len, foo, received_len, rport_len;
2486 unsigned int warning_len, content_len_len;
2487 struct hdr_field *hdr;
2488 struct lump_rpl *lump, *body;
2489 int i;
2490 str to_tag;
2491
2492 body = 0;
2493 buf=0;
2494 to_tag.s = 0;
2495 to_tag.len = 0;
2496 received_buf=rport_buf=warning_buf=content_len_buf=0;
2497 received_len=rport_len=warning_len=content_len_len=0;
2498
2499 /* force parsing all headers -- we want to return all
2500 Via's in the reply and they may be scattered down to the
2501 end of header (non-block Vias are a really poor property
2502 of SIP :( ) */
2503 if (parse_headers( msg, HDR_EOH_F, 0 )==-1) {
2504 LM_ERR("parse_headers failed\n");
2505 goto error00;
2506 }
2507
2508 /*computes the length of the new response buffer*/
2509 len = 0;
2510
2511 /* check if rport needs to be updated */
2512 if ( (msg->msg_flags&FL_FORCE_RPORT)||
2513 (msg->via1->rport /*&& msg->via1->rport->value.s==0*/)){
2514 if ((rport_buf=rport_builder(msg, &rport_len))==0){
2515 LM_ERR("rport_builder failed\n");
2516 goto error00;
2517 }
2518 if (msg->via1->rport)
2519 len -= msg->via1->rport->size+1; /* include ';' */
2520 }
2521
2522 /* check if received needs to be added or via rport has to be added */
2523 if (rport_buf || received_test(msg)) {
2524 if ((received_buf=received_builder(msg,&received_len))==0) {
2525 LM_ERR("received_builder failed\n");
2526 goto error01;
2527 }
2528 }
2529
2530 /* first line */
2531 len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ +
2532 text->len + CRLF_LEN/*new line*/;
2533 /* copy the TO hdr */
2534 if (msg->to) {
2535 if (new_tag && new_tag->len) {
2536 to_tag=get_to(msg)->tag_value;
2537 if (to_tag.len )

Callers 4

sl_send_reply_helperFunction · 0.85
_replyFunction · 0.85
relay_replyFunction · 0.85
_reply_with_bodyFunction · 0.85

Calls 6

rport_builderFunction · 0.85
received_testFunction · 0.85
received_builderFunction · 0.85
warning_builderFunction · 0.85
int2strFunction · 0.85
append_strFunction · 0.85

Tested by

no test coverage detected