/*!
 * \internal
 * \brief Session supplement callback on an incoming INVITE request
 *
 * If we are receiving an initial INVITE, then we will set the session's identity
 * based on the INVITE or configured endpoint values. If we are receiving a reinvite,
 * then we will potentially queue a connected line update via the \ref update_incoming_connected_line
 * function
 *
 * \param session The session that has received an INVITE
 * \param rdata The incoming INVITE
 */
static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
{
	if (!session->channel) {
		/*
		 * Since we have no channel this must be the initial inbound
		 * INVITE.  Set the session ID directly because the channel
		 * has not been created yet.
		 */
		if (session->endpoint->id.trust_inbound
			&& (!set_id_from_pai(rdata, &session->id)
				|| !set_id_from_rpid(rdata, &session->id))) {
			ast_free(session->id.tag);
			session->id.tag = ast_strdup(session->endpoint->id.self.tag);
			return 0;
		}
		ast_party_id_copy(&session->id, &session->endpoint->id.self);
		if (!session->endpoint->id.self.number.valid) {
			set_id_from_from(rdata, &session->id);
		}
	} else {
		/*
		 * ReINVITE or UPDATE.  Check for changes to the ID and queue
		 * a connected line update if necessary.
		 */
		update_incoming_connected_line(session, rdata);
	}
	return 0;
}
示例#2
0
/*!
 * \internal
 * \brief Session supplement callback on an incoming INVITE request
 *
 * If we are receiving an initial INVITE, then we will set the session's identity
 * based on the INVITE or configured endpoint values. If we are receiving a reinvite,
 * then we will potentially queue a connected line update via the \ref update_incoming_connected_line
 * function
 *
 * \param session The session that has received an INVITE
 * \param rdata The incoming INVITE
 */
static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
{
	if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
		/*
		 * Initial inbound INVITE.  Set the session ID directly
		 * because the channel has not been created yet.
		 */
		if (session->endpoint->id.trust_inbound
			&& (!set_id_from_pai(rdata, &session->id)
				|| !set_id_from_rpid(rdata, &session->id))) {
			ast_free(session->id.tag);
			session->id.tag = ast_strdup(session->endpoint->id.self.tag);
			return 0;
		}
		ast_party_id_copy(&session->id, &session->endpoint->id.self);
		if (!session->endpoint->id.self.number.valid) {
			set_id_from_from(rdata, &session->id);
		}
	} else if (session->channel) {
		/* Reinvite. Check for changes to the ID and queue a connected line
		 * update if necessary
		 */
		update_incoming_connected_line(session, rdata);
	}
	return 0;
}