53 pjsip_param *oli1, *oli2, *oli3;
55 static const pj_str_t oli_str1 = {
"isup-oli", 8 };
56 static const pj_str_t oli_str2 = {
"ss7-oli", 7 };
57 static const pj_str_t oli_str3 = {
"oli", 3 };
59 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
60 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
66 if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) {
68 }
else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) {
70 }
else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) {
95 if (!
id->number.valid) {
104 strcmp(
session->id.number.str,
id->number.str)) {
116 if (!
id->name.valid) {
124 strcmp(
session->id.name.str,
id->name.str)) {
178 if (!
session->endpoint->id.trust_connected_line
179 || !
session->endpoint->id.trust_inbound) {
254 pjsip_fromto_hdr *id_hdr;
255 pjsip_name_addr *id_name_addr;
256 pjsip_sip_uri *id_uri;
258 id_hdr = pjsip_from_hdr_create(tdata->pool);
259 id_hdr->type = PJSIP_H_OTHER;
260 id_hdr->sname = id_hdr->name = *hdr_name;
262 id_name_addr = pjsip_uri_clone(tdata->pool, base->uri);
263 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
266 int name_buf_len = strlen(
id->name.str) * 2 + 1;
270 pj_strdup2(tdata->pool, &id_name_addr->display, name_buf);
276 pj_strdup2(tdata->pool, &id_name_addr->display,
NULL);
279 if (
id->number.valid) {
280 pj_strdup2(tdata->pool, &id_uri->user,
id->number.str);
283 pj_strdup2(tdata->pool, &id_uri->user,
NULL);
286 id_hdr->uri = (pjsip_uri *) id_name_addr;
304 static const pj_str_t pj_privacy_name = {
"Privacy", 7 };
305 static const pj_str_t pj_privacy_value = {
"id", 2 };
306 pjsip_hdr *old_privacy;
308 old_privacy = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_privacy_name,
NULL);
312 pj_list_erase(old_privacy);
314 }
else if (!old_privacy) {
315 pjsip_generic_string_hdr *privacy_hdr = pjsip_generic_string_hdr_create(
316 tdata->pool, &pj_privacy_name, &pj_privacy_value);
317 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)privacy_hdr);
330 static const pj_str_t pj_pai_name = {
"P-Asserted-Identity", 19 };
331 pjsip_fromto_hdr *base;
332 pjsip_fromto_hdr *pai_hdr;
333 pjsip_fromto_hdr *old_pai;
338 old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name,
NULL);
349 if (old_pai->type == PJSIP_H_OTHER) {
350 pj_list_erase(old_pai);
358 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
359 base =
session->saved_from_hdr ?
session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
361 base = PJSIP_MSG_TO_HDR(tdata->msg);
370 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)pai_hdr);
383 static const pj_str_t party_str = {
"party", 5 };
384 static const pj_str_t calling_str = {
"calling", 7 };
385 static const pj_str_t called_str = {
"called", 6 };
389 party = pjsip_param_find(&hdr->other_param, &party_str);
394 party = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
395 party->name = party_str;
396 party->value = (
session->inv_session->role == PJSIP_ROLE_UAC) ? calling_str : called_str;
397 pj_list_insert_before(&hdr->other_param, party);
414 static const pj_str_t privacy_str = {
"privacy", 7 };
415 static const pj_str_t screen_str = {
"screen", 6 };
416 static const pj_str_t privacy_full_str = {
"full", 4 };
417 static const pj_str_t privacy_off_str = {
"off", 3 };
418 static const pj_str_t screen_yes_str = {
"yes", 3 };
419 static const pj_str_t screen_no_str = {
"no", 2 };
420 pjsip_param *old_privacy;
421 pjsip_param *old_screen;
422 pjsip_param *privacy;
426 old_privacy = pjsip_param_find(&hdr->other_param, &privacy_str);
427 old_screen = pjsip_param_find(&hdr->other_param, &screen_str);
430 privacy = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
431 privacy->name = privacy_str;
432 pj_list_insert_before(&hdr->other_param, privacy);
434 privacy = old_privacy;
438 screen = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
439 screen->name = screen_str;
440 pj_list_insert_before(&hdr->other_param, screen);
447 privacy->value = privacy_off_str;
449 privacy->value = privacy_full_str;
452 screen->value = screen_yes_str;
454 screen->value = screen_no_str;
467 static const pj_str_t pj_rpid_name = {
"Remote-Party-ID", 15 };
468 pjsip_fromto_hdr *base;
469 pjsip_fromto_hdr *rpid_hdr;
470 pjsip_fromto_hdr *old_rpid;
475 old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name,
NULL);
486 if (old_rpid->type == PJSIP_H_OTHER) {
487 pj_list_erase(old_rpid);
496 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
497 base =
session->saved_from_hdr ?
session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
499 base = PJSIP_MSG_TO_HDR(tdata->msg);
508 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
527 if (
session->endpoint->id.send_pai) {
530 if (
session->endpoint->id.send_rpid) {
580 || (!
session->endpoint->id.send_connected_line
582 &&
session->inv_session->state >= PJSIP_INV_STATE_EARLY)) {
598 .
method =
"INVITE,UPDATE",
624 .
requires =
"res_pjsip,res_pjsip_session",
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_USER_NUMBER_PASSED_SCREEN
@ AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER
#define AST_PRES_NUMBER_TYPE
#define AST_PRES_RESTRICTION
General Asterisk PBX channel definitions.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
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...
#define ast_channel_lock(chan)
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
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.
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
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.
#define ast_channel_unlock(chan)
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
Asterisk module definitions.
#define ast_module_shutdown_ref(mod)
Prevent unload of the module before shutdown.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
int ast_sip_set_id_connected_line(struct pjsip_rx_data *rdata, struct ast_party_id *id)
Set the ID for a connected line update.
int ast_sip_set_id_from_invite(struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound)
Set the ID from an INVITE.
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
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_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.
static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
static void add_privacy_params(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_party_id *id)
static struct ast_sip_session_supplement caller_id_supplement
static void queue_connected_line_update(struct ast_sip_session *session, const struct ast_party_id *id)
static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
static void add_pai_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
static int should_queue_connected_line_update(const struct ast_sip_session *session, const struct ast_party_id *id)
static void add_privacy_header(pjsip_tx_data *tdata, const struct ast_party_id *id)
static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
static void add_party_param(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_sip_session *session)
static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
static int load_module(void)
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 int unload_module(void)
static void add_id_headers(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
int ast_sip_can_present_connected_id(const struct ast_sip_session *session, const struct ast_party_id *id)
Determines if the Connected Line info can be presented for this session.
#define ast_sip_session_register_supplement(supplement)
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Caller Party information.
struct ast_party_id id
Caller party ID.
int ani2
Automatic Number Identification 2 (Info Digits)
struct ast_party_id ani
Automatic Number Identification (ANI)
Connected Line/Party information.
Information needed to identify an endpoint in a call.
A supplement to SIP message processing.
A structure describing a SIP session.
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.