static int has_diversion_reason(pjsip_rx_data *rdata)
{
	pjsip_param *reason;
	pjsip_fromto_hdr *hdr = get_diversion_header(rdata);

	return hdr &&
		(reason = get_diversion_reason(hdr)) &&
		!pj_stricmp2(&reason->value, SEND_TO_VM_REDIRECT_VALUE);
}
Exemplo n.º 2
0
static int diversion_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
{
	pjsip_fromto_hdr *hdr = get_diversion_header(rdata);

	if (hdr) {
		set_redirecting(session, hdr, (pjsip_name_addr*)
				PJSIP_MSG_TO_HDR(rdata->msg_info.msg)->uri);
	}

	return 0;
}
Exemplo n.º 3
0
static int has_diversion_reason(pjsip_rx_data *rdata)
{
	pjsip_param *reason;
	pjsip_fromto_hdr *hdr = get_diversion_header(rdata);

	if (!hdr) {
		return 0;
	}
	reason = get_diversion_reason(hdr);
	return reason
		&& (!pj_stricmp2(&reason->value, SEND_TO_VM_REDIRECT_QUOTED_VALUE)
			|| !pj_stricmp2(&reason->value, SEND_TO_VM_REDIRECT_VALUE));
}
Exemplo n.º 4
0
static void diversion_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
{
	static const pj_str_t contact_name = { "Contact", 7 };

	pjsip_status_line status = rdata->msg_info.msg->line.status;
	pjsip_fromto_hdr *div_hdr;
	pjsip_contact_hdr *contact_hdr;

	if ((status.code != 302) && (status.code != 181)) {
		return;
	}

	/* use the diversion header info if there is one. if not one then use the
           session caller id info. if that doesn't exist use info from the To hdr*/
	if (!(div_hdr = get_diversion_header(rdata)) && !session->id.number.valid) {
		div_hdr = PJSIP_MSG_TO_HDR(rdata->msg_info.msg);
	}

	contact_hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &contact_name, NULL);

	set_redirecting(session, div_hdr, contact_hdr ?	(pjsip_name_addr*)contact_hdr->uri :
			(pjsip_name_addr*)PJSIP_MSG_FROM_HDR(rdata->msg_info.msg)->uri);
}