Asterisk - The Open Source Telephony Project GIT-master-266378a
Loading...
Searching...
No Matches
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#include "asterisk/taskpool.h"
38
39static int extract_oli(const pjsip_param *param_list, char *buf, size_t len)
40{
41 static const pj_str_t oli_str1 = { "isup-oli", 8 };
42 static const pj_str_t oli_str2 = { "ss7-oli", 7 };
43 static const pj_str_t oli_str3 = { "oli", 3 };
44 pjsip_param *oli;
45
46 if ((oli = pjsip_param_find(param_list, &oli_str1))
47 || (oli = pjsip_param_find(param_list, &oli_str2))
48 || (oli = pjsip_param_find(param_list, &oli_str3))) {
49 ast_copy_pj_str(buf, &oli->value, len);
50 return 0;
51 }
52 return -1;
53}
54
55/*!
56 * \internal
57 * \brief Set an ANI2 integer based on OLI data in a From header
58 *
59 * This uses the contents of a From header in order to set Originating Line information.
60 *
61 * \param rdata The incoming message
62 * \param ani2 The ANI2 field to set
63 * \retval 0 Successfully parsed OLI
64 * \retval non-zero Could not parse OLI
65 */
66static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
67{
68 char oli[AST_CHANNEL_NAME];
69
70 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
71 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
72
73 if (!from) {
74 return -1; /* This had better not happen */
75 }
76
77 /* First, check if it was provided as a header paramter */
78 if (extract_oli(&from->other_param, oli, sizeof(oli))) {
79 /* If not found, check if it was provided as a URI parameter */
80 pjsip_sip_uri *uri;
81 pjsip_name_addr *name_addr = (pjsip_name_addr *) from->uri;
82 if (!ast_sip_is_uri_sip_sips(name_addr->uri)) {
83 return -1;
84 }
85 uri = pjsip_uri_get_uri(name_addr->uri);
86 if (extract_oli(&uri->other_param, oli, sizeof(oli))) {
87 return -1; /* Not found as either type of parameter */
88 }
89 }
90
91 return ast_str_to_int(oli, ani2);
92}
93
94/*!
95 * \internal
96 * \brief Determine if a connected line update should be queued
97 *
98 * This uses information about the session and the ID that would be queued
99 * in the connected line update in order to determine if we should queue
100 * a connected line update.
101 *
102 * \param session The session whose channel we wish to queue the connected line update on
103 * \param id The identification information that would be queued on the connected line update
104 * \retval 0 We should not queue a connected line update
105 * \retval non-zero We should queue a connected line update
106 */
108{
109 /* Invalid number means no update */
110 if (!id->number.valid) {
111 return 0;
112 }
113
114 /* If the session has never communicated an update or if the
115 * new ID has a different number than the session, then we
116 * should queue an update
117 */
118 if (ast_strlen_zero(session->id.number.str) ||
119 strcmp(session->id.number.str, id->number.str)) {
120 return 1;
121 }
122
123 /* By making it to this point, it means the number is not enough
124 * to determine if an update should be sent. Now we look at
125 * the name
126 */
127
128 /* If the number couldn't warrant an update and the name is
129 * invalid, then no update
130 */
131 if (!id->name.valid) {
132 return 0;
133 }
134
135 /* If the name has changed or we don't have a name set for the
136 * session, then we should send an update
137 */
138 if (ast_strlen_zero(session->id.name.str) ||
139 strcmp(session->id.name.str, id->name.str)) {
140 return 1;
141 }
142
143 /* Neither the name nor the number have changed. No update */
144 return 0;
145}
146
147/*!
148 * \internal
149 * \brief Queue a connected line update on a session's channel.
150 * \param session The session whose channel should have the connected line update queued upon.
151 * \param id The identification information to place in the connected line update
152 */
154{
156 struct ast_party_caller caller;
157
158 /* Fill connected line information */
160 connected.id = *id;
161 connected.id.tag = session->endpoint->id.self.tag;
163
164 /* Save to channel driver copy */
166
167 /* Update our channel CALLERID() */
168 ast_party_caller_init(&caller);
169 caller.id = connected.id;
170 caller.ani = connected.id;
171 caller.ani2 = ast_channel_caller(session->channel)->ani2;
172 ast_channel_set_caller_event(session->channel, &caller, NULL);
173
174 /* Tell peer about the new connected line information. */
176}
177
178/*!
179 * \internal
180 * \brief Make updates to connected line information based on an incoming request.
181 *
182 * This will get identity information from an incoming request. Once the identification is
183 * retrieved, we will check if the new information warrants a connected line update and queue
184 * a connected line update if so.
185 *
186 * \param session The session on which we received an incoming request
187 * \param rdata The incoming request
188 */
189static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
190{
191 struct ast_party_id id;
192
193 if (!session->endpoint->id.trust_connected_line
194 || !session->endpoint->id.trust_inbound) {
195 return;
196 }
197
199 if (!ast_sip_set_id_connected_line(rdata, &id)) {
202 }
203 }
205}
206
207/*!
208 * \internal
209 * \brief Session supplement callback on an incoming INVITE request
210 *
211 * If we are receiving an initial INVITE, then we will set the session's identity
212 * based on the INVITE or configured endpoint values. If we are receiving a reinvite,
213 * then we will potentially queue a connected line update via the \ref update_incoming_connected_line
214 * function
215 *
216 * \param session The session that has received an INVITE
217 * \param rdata The incoming INVITE
218 */
219static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
220{
221 if (!session->channel) {
222 int ani2;
223 /*
224 * Since we have no channel this must be the initial inbound
225 * INVITE. Set the session ID directly because the channel
226 * has not been created yet.
227 */
228 ast_sip_set_id_from_invite(rdata, &session->id, &session->endpoint->id.self, session->endpoint->id.trust_inbound);
229 session->ani2 = set_id_from_oli(rdata, &ani2) ? 0 : ani2;
230 } else {
231 /*
232 * ReINVITE or UPDATE. Check for changes to the ID and queue
233 * a connected line update if necessary.
234 */
236 }
237 return 0;
238}
239
240/*!
241 * \internal
242 * \brief Session supplement callback on INVITE response
243 *
244 * INVITE responses could result in queuing connected line updates.
245 *
246 * \param session The session on which communication is happening
247 * \param rdata The incoming INVITE response
248 */
249static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
250{
251 if (!session->channel) {
252 return;
253 }
254
256}
257
258/*!
259 * \internal
260 * \brief Create an identity header for an outgoing message
261 * \param hdr_name The name of the header to create
262 * \param base
263 * \param tdata The message to place the header on
264 * \param id The identification information for the new header
265 * \return newly-created header
266 */
267static 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)
268{
269 pjsip_fromto_hdr *id_hdr;
270 pjsip_name_addr *id_name_addr;
271 pjsip_sip_uri *id_uri;
272
273 id_hdr = pjsip_from_hdr_create(tdata->pool);
274 id_hdr->type = PJSIP_H_OTHER;
275 id_hdr->sname = id_hdr->name = *hdr_name;
276
277 id_name_addr = pjsip_uri_clone(tdata->pool, base->uri);
278 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
279
280 if (id->name.valid && !ast_strlen_zero(id->name.str)) {
281 int name_buf_len = strlen(id->name.str) * 2 + 1;
282 char *name_buf = ast_alloca(name_buf_len);
283
284 ast_escape_quoted(id->name.str, name_buf, name_buf_len);
285 pj_strdup2(tdata->pool, &id_name_addr->display, name_buf);
286 } else {
287 /*
288 * We need to clear the remnants of the clone or it'll be left set.
289 * pj_strdup2 is safe to call with a NULL src and it resets both slen and ptr.
290 */
291 pj_strdup2(tdata->pool, &id_name_addr->display, NULL);
292 }
293
294 if (id->number.valid) {
295 pj_strdup2(tdata->pool, &id_uri->user, id->number.str);
296 } else {
297 /* Similar to name, make sure the number is also cleared when invalid */
298 pj_strdup2(tdata->pool, &id_uri->user, NULL);
299 }
300
301 id_hdr->uri = (pjsip_uri *) id_name_addr;
302 return id_hdr;
303}
304
305/*!
306 * \internal
307 * \brief Add a Privacy header to an outbound message
308 *
309 * When sending a P-Asserted-Identity header, if privacy is requested, then we
310 * will need to indicate such by adding a Privacy header. Similarly, if no
311 * privacy is requested, and a Privacy header already exists on the message,
312 * then the old Privacy header should be removed.
313 *
314 * \param tdata The outbound message to add the Privacy header to
315 * \param id The id information used to determine privacy
316 */
317static void add_privacy_header(pjsip_tx_data *tdata, const struct ast_party_id *id)
318{
319 static const pj_str_t pj_privacy_name = { "Privacy", 7 };
320 static const pj_str_t pj_privacy_value = { "id", 2 };
321 pjsip_hdr *old_privacy;
322
323 old_privacy = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_privacy_name, NULL);
324
326 if (old_privacy) {
327 pj_list_erase(old_privacy);
328 }
329 } else if (!old_privacy) {
330 pjsip_generic_string_hdr *privacy_hdr = pjsip_generic_string_hdr_create(
331 tdata->pool, &pj_privacy_name, &pj_privacy_value);
332 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)privacy_hdr);
333 }
334}
335
336/*!
337 * \internal
338 * \brief Add a P-Asserted-Identity header to an outbound message
339 * \param session The session on which communication is happening
340 * \param tdata The message to add the header to
341 * \param id The identification information used to populate the header
342 */
343static void add_pai_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
344{
345 static const pj_str_t pj_pai_name = { "P-Asserted-Identity", 19 };
346 pjsip_fromto_hdr *base;
347 pjsip_fromto_hdr *pai_hdr;
348 pjsip_fromto_hdr *old_pai;
349
350 /* Since inv_session reuses responses, we have to make sure there's not already
351 * a P-Asserted-Identity present. If there is, we just modify the old one.
352 */
353 old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name, NULL);
354 if (old_pai) {
355 /* If type is OTHER, then the existing header was most likely
356 * added by the PJSIP_HEADER dial plan function as a simple
357 * name/value pair. We can't pass this to modify_id_header because
358 * there are no virtual functions to get the uri. We could parse
359 * it into a pjsip_fromto_hdr but it isn't worth it since
360 * modify_id_header is just going to overwrite the name and number
361 * anyway. We'll just remove it from the header list instead
362 * and create a new one.
363 */
364 if (old_pai->type == PJSIP_H_OTHER) {
365 pj_list_erase(old_pai);
366 } else {
367 ast_sip_modify_id_header(tdata->pool, old_pai, id);
368 add_privacy_header(tdata, id);
369 return;
370 }
371 }
372
373 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
374 base = session->saved_from_hdr ? session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
375 } else {
376 base = PJSIP_MSG_TO_HDR(tdata->msg);
377 }
378
379 pai_hdr = create_new_id_hdr(&pj_pai_name, base, tdata, id);
380 if (!pai_hdr) {
381 return;
382 }
383 add_privacy_header(tdata, id);
384
385 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)pai_hdr);
386}
387
388/*!
389 * \internal
390 * \brief Add party parameter to a Remote-Party-ID header.
391 *
392 * \param tdata The message where the Remote-Party-ID header is
393 * \param hdr The header on which the parameters are being added
394 * \param session The session involved
395 */
396static void add_party_param(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_sip_session *session)
397{
398 static const pj_str_t party_str = { "party", 5 };
399 static const pj_str_t calling_str = { "calling", 7 };
400 static const pj_str_t called_str = { "called", 6 };
401 pjsip_param *party;
402
403 /* The party value can't change throughout the lifetime, so it is set only once */
404 party = pjsip_param_find(&hdr->other_param, &party_str);
405 if (party) {
406 return;
407 }
408
409 party = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
410 party->name = party_str;
411 party->value = (session->inv_session->role == PJSIP_ROLE_UAC) ? calling_str : called_str;
412 pj_list_insert_before(&hdr->other_param, party);
413}
414
415/*!
416 * \internal
417 * \brief Add privacy and screen parameters to a Remote-Party-ID header.
418 *
419 * If privacy is requested, then the privacy and screen parameters need to
420 * reflect this. Similarly, if no privacy or screening is to be communicated,
421 * we need to make sure that any previously set values are updated.
422 *
423 * \param tdata The message where the Remote-Party-ID header is
424 * \param hdr The header on which the parameters are being added
425 * \param id The identification information used to determine privacy
426 */
427static void add_privacy_params(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_party_id *id)
428{
429 static const pj_str_t privacy_str = { "privacy", 7 };
430 static const pj_str_t screen_str = { "screen", 6 };
431 static const pj_str_t privacy_full_str = { "full", 4 };
432 static const pj_str_t privacy_off_str = { "off", 3 };
433 static const pj_str_t screen_yes_str = { "yes", 3 };
434 static const pj_str_t screen_no_str = { "no", 2 };
435 pjsip_param *old_privacy;
436 pjsip_param *old_screen;
437 pjsip_param *privacy;
438 pjsip_param *screen;
439 int presentation;
440
441 old_privacy = pjsip_param_find(&hdr->other_param, &privacy_str);
442 old_screen = pjsip_param_find(&hdr->other_param, &screen_str);
443
444 if (!old_privacy) {
445 privacy = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
446 privacy->name = privacy_str;
447 pj_list_insert_before(&hdr->other_param, privacy);
448 } else {
449 privacy = old_privacy;
450 }
451
452 if (!old_screen) {
453 screen = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
454 screen->name = screen_str;
455 pj_list_insert_before(&hdr->other_param, screen);
456 } else {
457 screen = old_screen;
458 }
459
460 presentation = ast_party_id_presentation(id);
461 if ((presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
462 privacy->value = privacy_off_str;
463 } else {
464 privacy->value = privacy_full_str;
465 }
467 screen->value = screen_yes_str;
468 } else {
469 screen->value = screen_no_str;
470 }
471}
472
473/*!
474 * \internal
475 * \brief Add a Remote-Party-ID header to an outbound message
476 * \param session The session on which communication is happening
477 * \param tdata The message to add the header to
478 * \param id The identification information used to populate the header
479 */
480static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
481{
482 static const pj_str_t pj_rpid_name = { "Remote-Party-ID", 15 };
483 pjsip_fromto_hdr *base;
484 pjsip_fromto_hdr *rpid_hdr;
485 pjsip_fromto_hdr *old_rpid;
486
487 /* Since inv_session reuses responses, we have to make sure there's not already
488 * a P-Asserted-Identity present. If there is, we just modify the old one.
489 */
490 old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name, NULL);
491 if (old_rpid) {
492 /* If type is OTHER, then the existing header was most likely
493 * added by the PJSIP_HEADER dial plan function as a simple
494 * name/value pair. We can't pass this to modify_id_header because
495 * there are no virtual functions to get the uri. We could parse
496 * it into a pjsip_fromto_hdr but it isn't worth it since
497 * modify_id_header is just going to overwrite the name and number
498 * anyway. We'll just remove it from the header list instead
499 * and create a new one.
500 */
501 if (old_rpid->type == PJSIP_H_OTHER) {
502 pj_list_erase(old_rpid);
503 } else {
504 ast_sip_modify_id_header(tdata->pool, old_rpid, id);
505 add_party_param(tdata, old_rpid, session);
506 add_privacy_params(tdata, old_rpid, id);
507 return;
508 }
509 }
510
511 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
512 base = session->saved_from_hdr ? session->saved_from_hdr : PJSIP_MSG_FROM_HDR(tdata->msg);
513 } else {
514 base = PJSIP_MSG_TO_HDR(tdata->msg);
515 }
516
517 rpid_hdr = create_new_id_hdr(&pj_rpid_name, base, tdata, id);
518 if (!rpid_hdr) {
519 return;
520 }
521 add_party_param(tdata, rpid_hdr, session);
522 add_privacy_params(tdata, rpid_hdr, id);
523 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
524}
525
526/*!
527 * \internal
528 * \brief Add any appropriate identification headers to an outbound SIP message
529 *
530 * This will determine if an outbound message should have identification headers and
531 * will add the appropriately configured headers
532 *
533 * \param session The session on which we will be sending the message
534 * \param tdata The outbound message
535 * \param id The identity information to place on the message
536 */
537static void add_id_headers(const struct ast_sip_session *session, pjsip_tx_data *tdata, const struct ast_party_id *id)
538{
540 return;
541 }
542 if (session->endpoint->id.send_pai) {
543 add_pai_header(session, tdata, id);
544 }
545 if (session->endpoint->id.send_rpid) {
546 add_rpid_header(session, tdata, id);
547 }
548}
549
550/*!
551 * \internal
552 * \brief Session supplement callback for outgoing INVITE requests
553 *
554 * On all INVITEs (initial and reinvite) we may add other identity headers
555 * such as P-Asserted-Identity and Remote-Party-ID based on configuration
556 * and privacy settings
557 *
558 * \param session The session on which the INVITE will be sent
559 * \param tdata The outbound INVITE request
560 */
561static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
562{
563 struct ast_party_id effective_id;
564 struct ast_party_id connected_id;
565
566 if (!session->channel) {
567 return;
568 }
569
570 ast_party_id_init(&connected_id);
571 ast_channel_lock(session->channel);
572 effective_id = ast_channel_connected_effective_id(session->channel);
573 ast_party_id_copy(&connected_id, &effective_id);
574 ast_channel_unlock(session->channel);
575
576 add_id_headers(session, tdata, &connected_id);
577 ast_party_id_free(&connected_id);
578}
579
580/*!
581 * \internal
582 * \brief Session supplement for outgoing INVITE response
583 *
584 * This will add P-Asserted-Identity and Remote-Party-ID headers if necessary
585 *
586 * \param session The session on which the INVITE response is to be sent
587 * \param tdata The outbound INVITE response
588 */
589static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
590{
591 struct ast_party_id effective_id;
592 struct ast_party_id connected_id;
593
594 /*
595 * Outgoing response callbacks may execute on the PJSIP monitor
596 * thread during retransmissions, outside the session serializer.
597 * The channel pointer can change during a masquerade, potentially
598 * causing a channel mutex to remain locked.
599 *
600 * Retransmitted responses already contain the caller ID information
601 * added when the response was first sent, so skipping this callback
602 * outside the serializer does not change the response contents.
603 */
605 || !session->channel
606 || (!session->endpoint->id.send_connected_line
607 && session->inv_session
608 && session->inv_session->state >= PJSIP_INV_STATE_EARLY)) {
609 return;
610 }
611
612 /* Must do a deep copy unless we hold the channel lock the entire time. */
613 ast_party_id_init(&connected_id);
614 ast_channel_lock(session->channel);
615 effective_id = ast_channel_connected_effective_id(session->channel);
616 ast_party_id_copy(&connected_id, &effective_id);
617 ast_channel_unlock(session->channel);
618
619 add_id_headers(session, tdata, &connected_id);
620 ast_party_id_free(&connected_id);
621}
622
624 .method = "INVITE,UPDATE",
625 .priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL - 1000,
626 .incoming_request = caller_id_incoming_request,
627 .incoming_response = caller_id_incoming_response,
628 .outgoing_request = caller_id_outgoing_request,
629 .outgoing_response = caller_id_outgoing_response,
630};
631
638
639static int unload_module(void)
640{
642 return 0;
643}
644
646 .support_level = AST_MODULE_SUPPORT_CORE,
647 .load = load_module,
648 .unload = unload_module,
649 .load_pri = AST_MODPRI_APP_DEPEND,
650 .requires = "res_pjsip,res_pjsip_session",
enum queue_result id
Definition app_queue.c:1790
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
static int connected
Definition cdr_pgsql.c:73
General Asterisk PBX channel definitions.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1744
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition channel.c:1808
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:7408
#define ast_channel_lock(chan)
Definition channel.h:2983
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Definition channel.c:1798
#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:1752
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:2009
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:9282
#define ast_channel_unlock(chan)
Definition channel.h:2984
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition channel.c:1965
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 buf[BUFSIZE]
Definition eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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:2842
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:2847
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
Definition res_pjsip.h:3413
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
Definition res_pjsip.c:3487
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:2221
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:2870
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 int extract_oli(const pjsip_param *param_list, char *buf, size_t len)
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.
#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.
struct ast_module *const char * method
A structure describing a SIP session.
struct ast_taskprocessor * ast_taskpool_serializer_get_current(void)
Get the taskpool serializer currently associated with this thread.
Definition taskpool.c:842
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
Definition utils.c:815