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

Function send_ack

modules/tm/t_reply.c:303–343  ·  view source on GitHub ↗

* Build and send an ACK to a negative reply * On successful send: * - return 0 * - populate @ack_buf, for callback purposes, which *must* be SHM freed! */

Source from the content-addressed store, hash-verified

301 * - populate @ack_buf, for callback purposes, which *must* be SHM freed!
302 */
303static int send_ack(struct sip_msg* rpl, struct cell *trans, int branch, str *ack_buf)
304{
305 str method = str_init(ACK);
306 str to;
307 struct usr_avp **backup_list;
308 int rc;
309
310 if(parse_headers(rpl,is_local(trans)?HDR_EOH_F:(HDR_TO_F|HDR_FROM_F),0)==-1
311 || !rpl->to || !rpl->from ) {
312 LM_ERR("failed to generate a HBH ACK if key HFs in reply missing\n");
313 goto error;
314 }
315 to.s=rpl->to->name.s;
316 to.len=rpl->to->len;
317
318 ack_buf->s = is_local(trans)?
319 build_dlg_ack(rpl, trans, branch, &to, (unsigned int*)&ack_buf->len):
320 build_local( trans, branch, &method, NULL, rpl, (unsigned int*)&ack_buf->len );
321 if (ack_buf->s==0) {
322 LM_ERR("failed to build ACK\n");
323 goto error;
324 }
325
326 if (TM_BRANCH(trans,branch).br_flags & tcp_no_new_conn_bflag)
327 tcp_no_new_conn = 1;
328
329 set_bavp_list(&TM_BRANCH(trans,branch).user_avps);
330 backup_list = set_avp_list( &trans->user_avps );
331
332 rc = SEND_PR_BUFFER(&TM_BRANCH(trans,branch).request, ack_buf->s, ack_buf->len);
333
334 set_avp_list(backup_list);
335 reset_bavp_list();
336
337 tcp_no_new_conn = 0;
338
339 return rc;
340error:
341 memset(ack_buf, 0, sizeof *ack_buf);
342 return -1;
343}
344
345
346static int _reply_light( struct cell *trans, char* buf, unsigned int len,

Callers 1

reply_receivedFunction · 0.85

Calls 5

build_dlg_ackFunction · 0.85
build_localFunction · 0.85
set_bavp_listFunction · 0.85
set_avp_listFunction · 0.85
reset_bavp_listFunction · 0.85

Tested by

no test coverage detected