Exemplo n.º 1
0
/*
 * Build and send an ACK to a negative reply
 */
static int send_ack(struct sip_msg* rpl, struct cell *trans, int branch)
{
	str method = str_init(ACK);
	str to;
	char *ack_p;
	unsigned int  ack_len;

	if(parse_headers(rpl,is_local(trans)?HDR_EOH_F:(HDR_TO_F|HDR_FROM_F),0)==-1
	|| !rpl->to || !rpl->from ) {
		LM_ERR("failed to generate a HBH ACK if key HFs in reply missing\n");
		goto error;
	}
	to.s=rpl->to->name.s;
	to.len=rpl->to->len;

	ack_p = is_local(trans)?
		build_dlg_ack(rpl, trans, branch, &to, &ack_len):
		build_local( trans, branch, &method, NULL, rpl, &ack_len );
	if (ack_p==0) {
		LM_ERR("failed to build ACK\n");
		goto error;
	}

	SEND_PR_BUFFER(&trans->uac[branch].request, ack_p, ack_len);
	shm_free(ack_p);

	return 0;
error:
	return -1;
}
Exemplo n.º 2
0
struct retr_buf *local_ack_rb(sip_msg_t *rpl_2xx, struct cell *trans,
					unsigned int branch, str *hdrs, str *body)
{
	struct retr_buf *lack;
	unsigned int buf_len;
	char *buffer;
	struct dest_info dst;

	buf_len = (unsigned)sizeof(struct retr_buf);
	if (! (buffer = build_dlg_ack(rpl_2xx, trans, branch, hdrs, body, 
			&buf_len, &dst))) {
		return 0;
	} else {
		/* 'buffer' now points into a contiguous chunk of memory with enough
		 * room to hold both the retr. buffer and the string raw buffer: it
		 * points to the begining of the string buffer; we iterate back to get
		 * the begining of the space for the retr. buffer. */
		lack = &((struct retr_buf *)buffer)[-1];
		lack->buffer = buffer;
		lack->buffer_len = buf_len;
		lack->dst = dst;
	}

	/* TODO: need next 2? */
	lack->activ_type = TYPE_LOCAL_ACK;
	lack->my_T = trans;

	return lack;
}