49 pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
52 uri = pjsip_uri_get_uri(id_name_addr);
57 semi = strchr(cid_num,
';');
98 static pjsip_fromto_hdr *
get_id_header(pjsip_rx_data *rdata,
const pj_str_t *header_name)
100 static const pj_str_t from = {
"From", 4 };
101 pj_str_t header_content;
102 pjsip_fromto_hdr *parsed_hdr;
103 pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
120 if (!rdata->tp_info.pool) {
123 if (!&ident->hvalue) {
127 ast_log(
LOG_WARNING,
"strlens %lu %lu\n", pj_strlen(&header_content), pj_strlen(&ident->hvalue));
130 pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
132 parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
133 pj_strlen(&header_content), &parsed_len);
155 #define MAX_OLI_DIGITS 2 157 static const pj_str_t from = {
"From", 4 };
158 static const pj_str_t oli_str1 = {
"oli", 3 };
159 static const pj_str_t oli_str2 = {
"isup-oli", 8 };
160 static const pj_str_t oli_str3 = {
"ss7-oli", 7 };
161 const pjsip_param *oli1, *oli2, *oli3;
166 if ((oli1 = pjsip_param_find(&from_hdr->other_param, &oli_str1))) {
169 }
else if ((oli2 = pjsip_param_find(&from_hdr->other_param, &oli_str2))) {
172 }
else if ((oli3 = pjsip_param_find(&from_hdr->other_param, &oli_str3))) {
193 static const pj_str_t pai_str = {
"P-Asserted-Identity", 19 };
194 static const pj_str_t privacy_str = {
"Privacy", 7 };
196 pjsip_generic_string_hdr *privacy;
208 privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str,
NULL);
209 if (!privacy || !pj_stricmp2(&privacy->hvalue,
"none")) {
234 static const pj_str_t rpid_str = {
"Remote-Party-ID", 15 };
235 static const pj_str_t privacy_str = {
"privacy", 7 };
236 static const pj_str_t screen_str = {
"screen", 6 };
237 pjsip_fromto_hdr *rpid_hdr =
get_id_header(rdata, &rpid_str);
239 pjsip_param *privacy;
251 privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str);
252 screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str);
253 if (privacy && !pj_stricmp2(&privacy->value,
"full")) {
260 if (screen && !pj_stricmp2(&screen->value,
"yes")) {
286 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
287 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
378 caller.
id = connected.
id;
379 caller.
ani = connected.
id;
490 pjsip_fromto_hdr *id_hdr;
491 pjsip_name_addr *id_name_addr;
492 pjsip_sip_uri *id_uri;
494 id_hdr = pjsip_from_hdr_create(tdata->pool);
495 id_hdr->type = PJSIP_H_OTHER;
496 id_hdr->sname = id_hdr->name = *hdr_name;
498 id_name_addr = pjsip_uri_clone(tdata->pool, base->uri);
499 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
502 int name_buf_len = strlen(id->
name.
str) * 2 + 1;
506 pj_strdup2(tdata->pool, &id_name_addr->display, name_buf);
512 pj_strdup2(tdata->pool, &id_name_addr->display,
NULL);
516 pj_strdup2(tdata->pool, &id_uri->user, id->
number.
str);
519 pj_strdup2(tdata->pool, &id_uri->user,
NULL);
522 id_hdr->uri = (pjsip_uri *) id_name_addr;
540 static const pj_str_t pj_privacy_name = {
"Privacy", 7 };
541 static const pj_str_t pj_privacy_value = {
"id", 2 };
542 pjsip_hdr *old_privacy;
544 old_privacy = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_privacy_name,
NULL);
548 pj_list_erase(old_privacy);
550 }
else if (!old_privacy) {
551 pjsip_generic_string_hdr *privacy_hdr = pjsip_generic_string_hdr_create(
552 tdata->pool, &pj_privacy_name, &pj_privacy_value);
553 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)privacy_hdr);
565 static const pj_str_t pj_pai_name = {
"P-Asserted-Identity", 19 };
566 pjsip_fromto_hdr *base;
567 pjsip_fromto_hdr *pai_hdr;
568 pjsip_fromto_hdr *old_pai;
573 old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name,
NULL);
584 if (old_pai->type == PJSIP_H_OTHER) {
585 pj_list_erase(old_pai);
593 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
596 base = PJSIP_MSG_TO_HDR(tdata->msg);
605 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)pai_hdr);
618 static const pj_str_t party_str = {
"party", 5 };
619 static const pj_str_t calling_str = {
"calling", 7 };
620 static const pj_str_t called_str = {
"called", 6 };
624 party = pjsip_param_find(&hdr->other_param, &party_str);
629 party = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
630 party->name = party_str;
631 party->value = (session->
inv_session->role == PJSIP_ROLE_UAC) ? calling_str : called_str;
632 pj_list_insert_before(&hdr->other_param, party);
649 static const pj_str_t privacy_str = {
"privacy", 7 };
650 static const pj_str_t screen_str = {
"screen", 6 };
651 static const pj_str_t privacy_full_str = {
"full", 4 };
652 static const pj_str_t privacy_off_str = {
"off", 3 };
653 static const pj_str_t screen_yes_str = {
"yes", 3 };
654 static const pj_str_t screen_no_str = {
"no", 2 };
655 pjsip_param *old_privacy;
656 pjsip_param *old_screen;
657 pjsip_param *privacy;
661 old_privacy = pjsip_param_find(&hdr->other_param, &privacy_str);
662 old_screen = pjsip_param_find(&hdr->other_param, &screen_str);
665 privacy = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
666 privacy->name = privacy_str;
667 pj_list_insert_before(&hdr->other_param, privacy);
669 privacy = old_privacy;
673 screen = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
674 screen->name = screen_str;
675 pj_list_insert_before(&hdr->other_param, screen);
682 privacy->value = privacy_off_str;
684 privacy->value = privacy_full_str;
687 screen->value = screen_yes_str;
689 screen->value = screen_no_str;
701 static const pj_str_t pj_rpid_name = {
"Remote-Party-ID", 15 };
702 pjsip_fromto_hdr *base;
703 pjsip_fromto_hdr *rpid_hdr;
704 pjsip_fromto_hdr *old_rpid;
709 old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name,
NULL);
720 if (old_rpid->type == PJSIP_H_OTHER) {
721 pj_list_erase(old_rpid);
730 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
733 base = PJSIP_MSG_TO_HDR(tdata->msg);
742 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
818 && session->
inv_session->state >= PJSIP_INV_STATE_EARLY)) {
834 .
method =
"INVITE,UPDATE",
860 .requires =
"res_pjsip,res_pjsip_session",
static pjsip_fromto_hdr * get_id_header(pjsip_rx_data *rdata, const pj_str_t *header_name)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
Information needed to identify an endpoint in a call.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
#define ast_channel_lock(chan)
static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
struct ast_sip_endpoint * endpoint
char * str
Subscriber phone number (Malloced)
static pjsip_fromto_hdr * create_new_id_hdr(const pj_str_t *hdr_name, pjsip_fromto_hdr *base, pjsip_tx_data *tdata, const struct ast_party_id *id)
static void add_privacy_header(pjsip_tx_data *tdata, const struct ast_party_id *id)
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
static int set_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
struct ast_party_id id
Connected party ID.
struct ast_party_name name
Subscriber name.
static void set_id_from_hdr(pjsip_fromto_hdr *hdr, struct ast_party_id *id)
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
static void add_id_headers(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
static int load_module(void)
char * str
Subscriber name (Malloced)
static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
#define ast_strdup(str)
A wrapper for strdup()
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
static void add_privacy_params(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_party_id *id)
static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
static struct ast_sip_session_supplement caller_id_supplement
struct pjsip_inv_session * inv_session
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
static char cid_num[AST_MAX_EXTENSION]
A structure describing a SIP session.
#define AST_PRES_RESTRICTED
#define ast_strlen_zero(foo)
static void queue_connected_line_update(struct ast_sip_session *session, const struct ast_party_id *id)
struct ast_party_id id
Caller party ID.
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
struct ast_party_id ani
Automatic Number Identification (ANI)
General Asterisk PBX channel definitions.
#define AST_PRES_USER_NUMBER_UNSCREENED
static int should_queue_connected_line_update(const struct ast_sip_session *session, const struct ast_party_id *id)
static struct ast_mansession session
Caller Party information.
Conversion utility functions.
struct ast_channel * channel
unsigned int trust_outbound
unsigned int send_connected_line
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
struct ast_sip_endpoint_id_configuration id
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
#define AST_PRES_NUMBER_TYPE
#define ast_module_shutdown_ref(mod)
Prevent unload of the module before shutdown.
int ani2
Automatic Number Identification 2 (Info Digits)
Connected Line/Party information.
static int set_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
unsigned int trust_inbound
static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
#define ast_channel_unlock(chan)
static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
int source
Information about the source of an update.
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
static char cid_name[AST_MAX_EXTENSION]
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
Set name and number information on an identity header.
A supplement to SIP message processing.
#define AST_PRES_RESTRICTION
#define AST_PRES_USER_NUMBER_PASSED_SCREEN
char * tag
User-set "tag".
static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
unsigned int trust_connected_line
unsigned char valid
TRUE if the name information is valid/present.
pjsip_fromto_hdr * saved_from_hdr
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
unsigned char valid
TRUE if the number information is valid/present.
static void add_party_param(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_sip_session *session)
static void add_pai_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
#define ast_sip_session_register_supplement(supplement)
struct ast_party_number number
Subscriber phone number.