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

Function build_dlg_ack

modules/tm/t_msgbuilder.c:447–572  ·  view source on GitHub ↗

* The function creates an ACK for a local INVITE. If 200 OK, route set * will be created and parsed */

Source from the content-addressed store, hash-verified

445 * will be created and parsed
446 */
447char *build_dlg_ack(struct sip_msg* rpl, struct cell *Trans,
448 unsigned int branch, str* to, unsigned int *len)
449{
450 char *req_buf, *p, *via;
451 unsigned int via_len;
452 char branch_buf[MAX_BRANCH_PARAM_LEN];
453 int branch_len;
454 str branch_str;
455 struct hostport hp;
456 struct rte* list;
457 str contact, ruri, *cont;
458 const struct socket_info* send_sock;
459 str next_hop;
460
461
462 if (rpl->first_line.u.reply.statuscode < 300 ) {
463 /* build e2e ack for 2xx reply -> we need the route set */
464 if (get_contact_uri(rpl, &contact) < 0) {
465 return 0;
466 }
467
468 if (process_routeset(rpl, &contact, &list, &ruri, &next_hop) < 0) {
469 return 0;
470 }
471
472 if ((contact.s != ruri.s) || (contact.len != ruri.len)) {
473 /* contact != ruri means that the next
474 * hop is a strict router, cont will be non-zero
475 * and print_routeset will append it at the end
476 * of the route set
477 */
478 cont = &contact;
479 } else {
480 /* Next hop is a loose router, nothing to append */
481 cont = 0;
482 }
483 } else {
484 /* build hop-by-hop ack for negative reply ->
485 * ruri is the same as in INVITE; no route set */
486 ruri = TM_BRANCH(Trans,branch).uri;
487 cont = 0;
488 list = 0;
489 }
490
491 /* method, separators, version: "ACK sip:user@domain.org SIP/2.0" */
492 *len = SIP_VERSION_LEN + ACK_LEN + 2 /* spaces */ + CRLF_LEN;
493 *len += ruri.len;
494
495 /* use same socket as for INVITE -bogdan */
496 send_sock = TM_BRANCH(Trans,branch).request.dst.send_sock;
497
498 if (!t_calc_branch(Trans, branch, branch_buf, &branch_len)) goto error;
499 branch_str.s = branch_buf;
500 branch_str.len = branch_len;
501 set_hostport(&hp, 0);
502
503 /* build via */
504 via = via_builder(&via_len, send_sock, &branch_str, 0,

Callers 1

send_ackFunction · 0.85

Calls 8

process_routesetFunction · 0.85
t_calc_branchFunction · 0.85
via_builderFunction · 0.85
calc_routeset_lenFunction · 0.85
shm_mallocFunction · 0.85
print_rsFunction · 0.85
free_rte_listFunction · 0.85
get_contact_uriFunction · 0.70

Tested by

no test coverage detected