/*! * \internal * \brief Set an ast_party_id structure based on data in a P-Asserted-Identity header * * This makes use of \ref set_id_from_hdr for setting name and number. It uses * the contents of a Privacy header in order to set presentation information. * * \param rdata The incoming message * \param[out] id The ID to set * \retval 0 Successfully set the party ID * \retval non-zero Could not set the party ID */ static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id) { static const pj_str_t pai_str = { "P-Asserted-Identity", 19 }; static const pj_str_t privacy_str = { "Privacy", 7 }; pjsip_fromto_hdr *pai_hdr = get_id_header(rdata, &pai_str); pjsip_generic_string_hdr *privacy; if (!pai_hdr) { return -1; } set_id_from_hdr(pai_hdr, id); if (!id->number.valid) { return -1; } privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str, NULL); if (privacy && !pj_stricmp2(&privacy->hvalue, "id")) { id->number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED; id->name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED; } else { id->number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; id->name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; } return 0; }
/*! * \internal * \brief Set an ast_party_id structure based on data in a Remote-Party-ID header * * This makes use of \ref set_id_from_hdr for setting name and number. It uses * the privacy and screen parameters in order to set presentation information. * * \param rdata The incoming message * \param[out] id The ID to set * \retval 0 Succesfully set the party ID * \retval non-zero Could not set the party ID */ static int set_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id) { static const pj_str_t rpid_str = { "Remote-Party-ID", 15 }; static const pj_str_t privacy_str = { "privacy", 7 }; static const pj_str_t screen_str = { "screen", 6 }; pjsip_fromto_hdr *rpid_hdr = get_id_header(rdata, &rpid_str); pjsip_param *screen; pjsip_param *privacy; if (!rpid_hdr) { return -1; } set_id_from_hdr(rpid_hdr, id); if (!id->number.valid) { return -1; } privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str); screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str); if (privacy && !pj_stricmp2(&privacy->value, "full")) { id->number.presentation |= AST_PRES_RESTRICTED; id->name.presentation |= AST_PRES_RESTRICTED; } if (screen && !pj_stricmp2(&screen->value, "yes")) { id->number.presentation |= AST_PRES_USER_NUMBER_PASSED_SCREEN; id->name.presentation |= AST_PRES_USER_NUMBER_PASSED_SCREEN; } return 0; }