Asterisk - The Open Source Telephony Project GIT-master-f36a736
res_pjsip_caller_id.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * Mark Michelson <mmichelson@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*** MODULEINFO
20 <depend>pjproject</depend>
21 <depend>res_pjsip</depend>
22 <depend>res_pjsip_session</depend>
23 <support_level>core</support_level>
24 ***/
25
26#include "asterisk.h"
27
28#include <pjsip.h>
29#include <pjsip_ua.h>
30
31#include "asterisk/res_pjsip.h"
33#include "asterisk/channel.h"
34#include "asterisk/module.h"
35#include "asterisk/callerid.h"
37
38/*!
39 * \internal
40 * \brief Set an ANI2 integer based on OLI data in a From header
41 *
42 * This uses the contents of a From header in order to set Originating Line information.
43 *
44 * \param rdata The incoming message
45 * \param ani2 The ANI2 field to set
46 * \retval 0 Successfully parsed OLI
47 * \retval non-zero Could not parse OLI
48 */
49static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
50{
51 char oli[AST_CHANNEL_NAME];
52
53 pjsip_param *oli1, *oli2, *oli3;
54
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 };
58
59 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
60 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
61
62 if (!from) {
63 return -1; /* This had better not happen */
64 }
65
66 if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) {
67 ast_copy_pj_str(oli, &oli1->value, sizeof(oli));
68 } else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) {
69 ast_copy_pj_str(oli, &oli2->value, sizeof(oli));
70 } else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) {
71 ast_copy_pj_str(oli, &oli3->value, sizeof(oli));
72 } else {
73 return -1;
74 }
75
76 return ast_str_to_int(oli, ani2);
77}
78
79/*!
80 * \internal
81 * \brief Determine if a connected line update should be queued
82 *
83 * This uses information about the session and the ID that would be queued
84 * in the connected line update in order to determine if we should queue
85 * a connected line update.
86 *
87 * \param session The session whose channel we wish to queue the connected line update on
88 * \param id The identification information that would be queued on the connected line update
89 * \retval 0 We should not queue a connected line update
90 * \retval non-zero We should queue a connected line update
91 */
93{
94 /* Invalid number means no update */
95 if (!id->number.valid) {
96 return 0;
97 }
98
99 /* If the session has never communicated an update or if the
100 * new ID has a different number than the session, then we
101 * should queue an update
102 */
103 if (ast_strlen_zero(session->id.number.str) ||
104 strcmp(session->id.number.str, id->number.str)) {
105 return 1;
106 }
107
108 /* By making it to this point, it means the number is not enough
109 * to determine if an update should be sent. Now we look at
110 * the name
111 */
112
113 /* If the number couldn't warrant an update and the name is
114 * invalid, then no update
115 */
116 if (!id->name.valid) {
117 return 0;
118 }
119
120 /* If the name has changed or we don't have a name set for the
121 * session, then we should send an update
122 */
123 if (ast_strlen_zero(session->id.name.str) ||
124 strcmp(session->id.name.str, id->name.str)) {
125 return 1;
126 }
127
128 /* Neither the name nor the number have changed. No update */
129 return 0;
130}
131
132/*!
133 * \internal
134 * \brief Queue a connected line update on a session's channel.
135 * \param session The session whose channel should have the connected line update queued upon.
136 * \param id The identification information to place in the connected line update
137 */
139{
141 struct ast_party_caller caller;
142
143 /* Fill connected line information */
145 connected.id = *id;
146 connected.id.tag = session->endpoint->id.self.tag;
148
149 /* Save to channel driver copy */
151
152 /* Update our channel CALLERID() */
153 ast_party_caller_init(&caller);
154 caller.id = connected.id;
155 caller.ani = connected.id;
156 caller.ani2 = ast_channel_caller(session->channel)->ani2;
157 ast_channel_set_caller_event(session->channel, &caller, NULL);
158
159 /* Tell peer about the new connected line information. */
161}
162
163/*!
164 * \internal
165 * \brief Make updates to connected line information based on an incoming request.
166 *
167 * This will get identity information from an incoming request. Once the identification is
168 * retrieved, we will check if the new information warrants a connected line update and queue
169 * a connected line update if so.
170 *
171 * \param session The session on which we received an incoming request
172 * \param rdata The incoming request
173 */
174static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
175{
176 struct ast_party_id id;
177
178 if (!session->endpoint->id.trust_connected_line
179 || !session->endpoint->id.trust_inbound) {
180 return;
181 }
182
184 if (!ast_sip_set_id_connected_line(rdata, &id)) {
187 }
188 }
190}
191
192/*!
193 * \internal
194 * \brief Session supplement callback on an incoming INVITE request
195 *
196 * If we are receiving an initial INVITE, then we will set the session's identity
197 * based on the INVITE or configured endpoint values. If we are receiving a reinvite,
198 * then we will potentially queue a connected line update via the \ref update_incoming_connected_line
199 * function
200 *
201 * \param session The session that has received an INVITE
202 * \param rdata The incoming INVITE
203 */
204static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
205{
206 if (!session->channel) {
207 int ani2;
208 /*
209 * Since we have no channel this must be the initial inbound
210 * INVITE. Set the session ID directly because the channel
211 * has not been created yet.
212 */
213 ast_sip_set_id_from_invite(rdata, &session->id, &session->endpoint->id.self, session->endpoint->id.trust_inbound);
214 session->ani2 = set_id_from_oli(rdata, &ani2) ? 0 : ani2;
215 } else {
216 /*
217 * ReINVITE or UPDATE. Check for changes to the ID and queue
218 * a connected line update if necessary.
219 */
221 }
222 return 0;
223}
224
225/*!
226 * \internal
227 * \brief Session supplement callback on INVITE response
228 *
229 * INVITE responses could result in queuing connected line updates.
230 *
231 * \param session The session on which communication is happening
232 * \param rdata The incoming INVITE response
233 */
234static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
235{
236 if (!session->channel) {
237 return;
238 }
239
241}
242
243/*!
244 * \internal
245 * \brief Create an identity header for an outgoing message
246 * \param hdr_name The name of the header to create
247 * \param base
248 * \param tdata The message to place the header on
249 * \param id The identification information for the new header
250 * \return newly-created header
251 */
252static 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)
253{
254 pjsip_fromto_hdr *id_hdr;
255 pjsip_name_addr *id_name_addr;
256 pjsip_sip_uri *id_uri;
257
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;
261
262 id_name_addr = pjsip_uri_clone(tdata->pool, base->uri);
263 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
264
265 if (id->name.valid && !ast_strlen_zero(id->name.str)) {
266 int name_buf_len = strlen(id->name.str) * 2 + 1;
267 char *name_buf = ast_alloca(name_buf_len);
268
269 ast_escape_quoted(id->name.str, name_buf, name_buf_len);
270 pj_strdup2(tdata->pool, &id_name_addr->display, name_buf);
271 } else {
272 /*
273 * We need to clear the remnants of the clone or it'll be left set.
274 * pj_strdup2 is safe to call with a NULL src and it resets both slen and ptr.
275 */
276 pj_strdup2(tdata->pool, &id_name_addr->display, NULL);
277 }
278
279 if (id->number.valid) {
280 pj_strdup2(tdata->pool, &id_uri->user, id->number.str);
281 } else {
282 /* Similar to name, make sure the number is also cleared when invalid */
283 pj_strdup2(tdata->pool, &id_uri->user, NULL);
284 }
285
286 id_hdr->uri = (pjsip_uri *) id_name_addr;
287 return id_hdr;
288}
289
290/*!
291 * \internal
292 * \brief Add a Privacy header to an outbound message
293 *
294 * When sending a P-Asserted-Identity header, if privacy is requested, then we
295 * will need to indicate such by adding a Privacy header. Similarly, if no
296 * privacy is requested, and a Privacy header already exists on the message,
297 * then the old Privacy header should be removed.
298 *
299 * \param tdata The outbound message to add the Privacy header to
300 * \param id The id information used to determine privacy
301 */
302static void add_privacy_header(pjsip_tx_data *tdata, const struct ast_party_id *id)
303{
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;
307
308 old_privacy = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_privacy_name, NULL);
309
311 if (old_privacy) {
312 pj_list_erase(old_privacy);
313 }
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);
318 }
319}
320
321/*!
322 * \internal
323 * \brief Add a P-Asserted-Identity header to an outbound message
324 * \param session The session on which communication is happening
325 * \param tdata The message to add the header to
326 * \param id The identification information used to populate the header
327 */
328static void add_pai_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
329{
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;
334
335 /* Since inv_session reuses responses, we have to make sure there's not already
336 * a P-Asserted-Identity present. If there is, we just modify the old one.
337 */
338 old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name, NULL);
339 if (old_pai) {
340 /* If type is OTHER, then the existing header was most likely
341 * added by the PJSIP_HEADER dial plan function as a simple
342 * name/value pair. We can't pass this to modify_id_header because
343 * there are no virtual functions to get the uri. We could parse
344 * it into a pjsip_fromto_hdr but it isn't worth it since
345 * modify_id_header is just going to overwrite the name and number
346 * anyway. We'll just remove it from the header list instead
347 * and create a new one.
348 */
349 if (old_pai->type == PJSIP_H_OTHER) {
350 pj_list_erase(old_pai);
351 } else {
352 ast_sip_modify_id_header(tdata->pool, old_pai, id);
353 add_privacy_header(tdata, id);
354 return;
355 }
356 }
357
358 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
359 base = session->saved_from_hdr ? session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
360 } else {
361 base = PJSIP_MSG_TO_HDR(tdata->msg);
362 }
363
364 pai_hdr = create_new_id_hdr(&pj_pai_name, base, tdata, id);
365 if (!pai_hdr) {
366 return;
367 }
368 add_privacy_header(tdata, id);
369
370 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)pai_hdr);
371}
372
373/*!
374 * \internal
375 * \brief Add party parameter to a Remote-Party-ID header.
376 *
377 * \param tdata The message where the Remote-Party-ID header is
378 * \param hdr The header on which the parameters are being added
379 * \param session The session involved
380 */
381static void add_party_param(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_sip_session *session)
382{
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 };
386 pjsip_param *party;
387
388 /* The party value can't change throughout the lifetime, so it is set only once */
389 party = pjsip_param_find(&hdr->other_param, &party_str);
390 if (party) {
391 return;
392 }
393
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);
398}
399
400/*!
401 * \internal
402 * \brief Add privacy and screen parameters to a Remote-Party-ID header.
403 *
404 * If privacy is requested, then the privacy and screen parameters need to
405 * reflect this. Similarly, if no privacy or screening is to be communicated,
406 * we need to make sure that any previously set values are updated.
407 *
408 * \param tdata The message where the Remote-Party-ID header is
409 * \param hdr The header on which the parameters are being added
410 * \param id The identification information used to determine privacy
411 */
412static void add_privacy_params(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_party_id *id)
413{
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;
423 pjsip_param *screen;
424 int presentation;
425
426 old_privacy = pjsip_param_find(&hdr->other_param, &privacy_str);
427 old_screen = pjsip_param_find(&hdr->other_param, &screen_str);
428
429 if (!old_privacy) {
430 privacy = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
431 privacy->name = privacy_str;
432 pj_list_insert_before(&hdr->other_param, privacy);
433 } else {
434 privacy = old_privacy;
435 }
436
437 if (!old_screen) {
438 screen = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
439 screen->name = screen_str;
440 pj_list_insert_before(&hdr->other_param, screen);
441 } else {
442 screen = old_screen;
443 }
444
445 presentation = ast_party_id_presentation(id);
446 if ((presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
447 privacy->value = privacy_off_str;
448 } else {
449 privacy->value = privacy_full_str;
450 }
452 screen->value = screen_yes_str;
453 } else {
454 screen->value = screen_no_str;
455 }
456}
457
458/*!
459 * \internal
460 * \brief Add a Remote-Party-ID header to an outbound message
461 * \param session The session on which communication is happening
462 * \param tdata The message to add the header to
463 * \param id The identification information used to populate the header
464 */
465static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
466{
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;
471
472 /* Since inv_session reuses responses, we have to make sure there's not already
473 * a P-Asserted-Identity present. If there is, we just modify the old one.
474 */
475 old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name, NULL);
476 if (old_rpid) {
477 /* If type is OTHER, then the existing header was most likely
478 * added by the PJSIP_HEADER dial plan function as a simple
479 * name/value pair. We can't pass this to modify_id_header because
480 * there are no virtual functions to get the uri. We could parse
481 * it into a pjsip_fromto_hdr but it isn't worth it since
482 * modify_id_header is just going to overwrite the name and number
483 * anyway. We'll just remove it from the header list instead
484 * and create a new one.
485 */
486 if (old_rpid->type == PJSIP_H_OTHER) {
487 pj_list_erase(old_rpid);
488 } else {
489 ast_sip_modify_id_header(tdata->pool, old_rpid, id);
490 add_party_param(tdata, old_rpid, session);
491 add_privacy_params(tdata, old_rpid, id);
492 return;
493 }
494 }
495
496 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
497 base = session->saved_from_hdr ? session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
498 } else {
499 base = PJSIP_MSG_TO_HDR(tdata->msg);
500 }
501
502 rpid_hdr = create_new_id_hdr(&pj_rpid_name, base, tdata, id);
503 if (!rpid_hdr) {
504 return;
505 }
506 add_party_param(tdata, rpid_hdr, session);
507 add_privacy_params(tdata, rpid_hdr, id);
508 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
509}
510
511/*!
512 * \internal
513 * \brief Add any appropriate identification headers to an outbound SIP message
514 *
515 * This will determine if an outbound message should have identification headers and
516 * will add the appropriately configured headers
517 *
518 * \param session The session on which we will be sending the message
519 * \param tdata The outbound message
520 * \param id The identity information to place on the message
521 */
522static void add_id_headers(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
523{
525 return;
526 }
527 if (session->endpoint->id.send_pai) {
528 add_pai_header(session, tdata, id);
529 }
530 if (session->endpoint->id.send_rpid) {
531 add_rpid_header(session, tdata, id);
532 }
533}
534
535/*!
536 * \internal
537 * \brief Session supplement callback for outgoing INVITE requests
538 *
539 * On all INVITEs (initial and reinvite) we may add other identity headers
540 * such as P-Asserted-Identity and Remote-Party-ID based on configuration
541 * and privacy settings
542 *
543 * \param session The session on which the INVITE will be sent
544 * \param tdata The outbound INVITE request
545 */
546static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
547{
548 struct ast_party_id effective_id;
549 struct ast_party_id connected_id;
550
551 if (!session->channel) {
552 return;
553 }
554
555 ast_party_id_init(&connected_id);
556 ast_channel_lock(session->channel);
557 effective_id = ast_channel_connected_effective_id(session->channel);
558 ast_party_id_copy(&connected_id, &effective_id);
559 ast_channel_unlock(session->channel);
560
561 add_id_headers(session, tdata, &connected_id);
562 ast_party_id_free(&connected_id);
563}
564
565/*!
566 * \internal
567 * \brief Session supplement for outgoing INVITE response
568 *
569 * This will add P-Asserted-Identity and Remote-Party-ID headers if necessary
570 *
571 * \param session The session on which the INVITE response is to be sent
572 * \param tdata The outbound INVITE response
573 */
574static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
575{
576 struct ast_party_id effective_id;
577 struct ast_party_id connected_id;
578
579 if (!session->channel
580 || (!session->endpoint->id.send_connected_line
581 && session->inv_session
582 && session->inv_session->state >= PJSIP_INV_STATE_EARLY)) {
583 return;
584 }
585
586 /* Must do a deep copy unless we hold the channel lock the entire time. */
587 ast_party_id_init(&connected_id);
588 ast_channel_lock(session->channel);
589 effective_id = ast_channel_connected_effective_id(session->channel);
590 ast_party_id_copy(&connected_id, &effective_id);
591 ast_channel_unlock(session->channel);
592
593 add_id_headers(session, tdata, &connected_id);
594 ast_party_id_free(&connected_id);
595}
596
598 .method = "INVITE,UPDATE",
599 .priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL - 1000,
600 .incoming_request = caller_id_incoming_request,
601 .incoming_response = caller_id_incoming_response,
602 .outgoing_request = caller_id_outgoing_request,
603 .outgoing_response = caller_id_outgoing_response,
604};
605
606static int load_module(void)
607{
608 ast_module_shutdown_ref(AST_MODULE_SELF);
611}
612
613static int unload_module(void)
614{
616 return 0;
617}
618
620 .support_level = AST_MODULE_SUPPORT_CORE,
621 .load = load_module,
622 .unload = unload_module,
623 .load_pri = AST_MODPRI_APP_DEPEND,
624 .requires = "res_pjsip,res_pjsip_session",
enum queue_result id
Definition: app_queue.c:1667
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
Definition: astmm.h:288
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_USER_NUMBER_PASSED_SCREEN
Definition: callerid.h:427
#define AST_PRES_ALLOWED
Definition: callerid.h:432
@ AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER
Definition: callerid.h:554
#define AST_PRES_NUMBER_TYPE
Definition: callerid.h:425
#define AST_PRES_RESTRICTION
Definition: callerid.h:431
General Asterisk PBX channel definitions.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1776
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1840
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...
Definition: channel.c:7394
#define ast_channel_lock(chan)
Definition: channel.h:2968
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition: channel.c:1830
#define AST_CHANNEL_NAME
Definition: channel.h:173
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.
Definition: channel.c:1784
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.
Definition: channel.c:2041
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.
Definition: channel.c:9128
#define ast_channel_unlock(chan)
Definition: channel.h:2969
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition: channel.c:1997
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
Definition: conversions.c:44
char connected
Definition: eagi_proxy.c:82
Asterisk module definitions.
@ AST_MODFLAG_LOAD_ORDER
Definition: module.h:331
#define ast_module_shutdown_ref(mod)
Prevent unload of the module before shutdown.
Definition: module.h:478
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:557
@ AST_MODPRI_APP_DEPEND
Definition: module.h:342
@ AST_MODULE_SUPPORT_CORE
Definition: module.h:121
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
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.
Definition: res_pjsip.c:2822
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.
Definition: res_pjsip.c:2827
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
Definition: res_pjsip.h:3185
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.
Definition: res_pjsip.c:2201
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.
Definition: res_pjsip.c:2850
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.
Definition: pjsip_session.c:63
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Caller Party information.
Definition: channel.h:420
struct ast_party_id id
Caller party ID.
Definition: channel.h:422
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:429
Connected Line/Party information.
Definition: channel.h:458
Information needed to identify an endpoint in a call.
Definition: channel.h:340
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.
Definition: utils.c:781