/*! * \internal * \brief Session supplement callback for outgoing INVITE requests * * For an initial INVITE request, we may change the From header to appropriately * reflect the identity information. On all INVITEs (initial and reinvite) we may * add other identity headers such as P-Asserted-Identity and Remote-Party-ID based * on configuration and privacy settings * * \param session The session on which the INVITE will be sent * \param tdata The outbound INVITE request */ static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata) { struct ast_party_id connected_id; if (!session->channel) { return; } connected_id = ast_channel_connected_effective_id(session->channel); if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED && ast_strlen_zero(session->endpoint->fromuser) && (session->endpoint->id.trust_outbound || ((connected_id.name.presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED && (connected_id.number.presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED))) { /* Only change the From header on the initial outbound INVITE. Switching it * mid-call might confuse some UAs. */ pjsip_fromto_hdr *from; pjsip_dialog *dlg; from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, tdata->msg->hdr.next); dlg = session->inv_session->dlg; modify_id_header(tdata->pool, from, &connected_id); modify_id_header(dlg->pool, dlg->local.info, &connected_id); } add_id_headers(session, tdata, &connected_id); }
/*! * \internal * \brief Session supplement for outgoing INVITE response * * This will add P-Asserted-Identity and Remote-Party-ID headers if necessary * * \param session The session on which the INVITE response is to be sent * \param tdata The outbound INVITE response */ static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata) { struct ast_party_id connected_id; if (!session->channel) { return; } connected_id = ast_channel_connected_effective_id(session->channel); add_id_headers(session, tdata, &connected_id); }
/*! * \internal * \brief Session supplement callback for outgoing INVITE requests * * On all INVITEs (initial and reinvite) we may add other identity headers * such as P-Asserted-Identity and Remote-Party-ID based on configuration * and privacy settings * * \param session The session on which the INVITE will be sent * \param tdata The outbound INVITE request */ static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata) { struct ast_party_id effective_id; struct ast_party_id connected_id; if (!session->channel) { return; } ast_party_id_init(&connected_id); ast_channel_lock(session->channel); effective_id = ast_channel_connected_effective_id(session->channel); ast_party_id_copy(&connected_id, &effective_id); ast_channel_unlock(session->channel); add_id_headers(session, tdata, &connected_id); ast_party_id_free(&connected_id); }
/*! * \internal * \brief Session supplement for outgoing INVITE response * * This will add P-Asserted-Identity and Remote-Party-ID headers if necessary * * \param session The session on which the INVITE response is to be sent * \param tdata The outbound INVITE response */ static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata) { struct ast_party_id effective_id; struct ast_party_id connected_id; if (!session->channel) { return; } /* Must do a deep copy unless we hold the channel lock the entire time. */ ast_party_id_init(&connected_id); ast_channel_lock(session->channel); effective_id = ast_channel_connected_effective_id(session->channel); ast_party_id_copy(&connected_id, &effective_id); ast_channel_unlock(session->channel); add_id_headers(session, tdata, &connected_id); ast_party_id_free(&connected_id); }
/*! * \internal * \brief Session supplement callback for outgoing INVITE requests * * For an initial INVITE request, we may change the From header to appropriately * reflect the identity information. On all INVITEs (initial and reinvite) we may * add other identity headers such as P-Asserted-Identity and Remote-Party-ID based * on configuration and privacy settings * * \param session The session on which the INVITE will be sent * \param tdata The outbound INVITE request */ static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata) { struct ast_party_id effective_id; struct ast_party_id connected_id; if (!session->channel) { return; } /* Must do a deep copy unless we hold the channel lock the entire time. */ ast_party_id_init(&connected_id); ast_channel_lock(session->channel); effective_id = ast_channel_connected_effective_id(session->channel); ast_party_id_copy(&connected_id, &effective_id); ast_channel_unlock(session->channel); if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) { /* Only change the From header on the initial outbound INVITE. Switching it * mid-call might confuse some UAs. */ pjsip_fromto_hdr *from; pjsip_dialog *dlg; from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, tdata->msg->hdr.next); dlg = session->inv_session->dlg; if (ast_strlen_zero(session->endpoint->fromuser) && (session->endpoint->id.trust_outbound || (ast_party_id_presentation(&connected_id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED)) { modify_id_header(tdata->pool, from, &connected_id); modify_id_header(dlg->pool, dlg->local.info, &connected_id); } ast_sip_add_usereqphone(session->endpoint, tdata->pool, from->uri); ast_sip_add_usereqphone(session->endpoint, dlg->pool, dlg->local.info->uri); } add_id_headers(session, tdata, &connected_id); ast_party_id_free(&connected_id); }