Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
func_callerid.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999-2010, Digium, Inc.
5 *
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
11 *
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
15 */
16
17/*! \file
18 *
19 * \brief Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)
20 *
21 * \ingroup functions
22 *
23 * See Also:
24 * \arg \ref AstCREDITS
25 */
26
27/*** MODULEINFO
28 <support_level>core</support_level>
29 ***/
30
31#include "asterisk.h"
32
33#include "asterisk/module.h"
34#include "asterisk/channel.h"
35#include "asterisk/pbx.h"
36#include "asterisk/utils.h"
37#include "asterisk/app.h"
38#include "asterisk/callerid.h"
39
40/*
41 * The CALLERID(pres) datatype is shorthand for getting/setting the
42 * combined value of name-pres and num-pres. Some channel drivers
43 * don't make a distinction, so it makes sense to only use one property
44 * to get/set it. The same applies to CONNECTEDLINE(pres),
45 * REDIRECTING(orig-pres), REDIRECTING(from-pres) and REDIRECTING(to-pres).
46 *
47 * Do not document the CALLERID(ton) datatype.
48 * It is an alias for num-plan.
49 *
50 * Do not document the CALLERID(ANI-subaddr-...) datatype.
51 * This is not used.
52 *
53 * Do not document the CONNECTEDLINE(source) datatype.
54 * It has turned out to not be needed. The source value is really
55 * only useful as a possible tracing aid.
56 *
57 * Do not document the CONNECTEDLINE(ton) datatype.
58 * It is an alias for num-plan.
59 *
60 * Do not document the REDIRECTING(pres) datatype.
61 * It has turned out that the from-pres and to-pres values must be kept
62 * separate. They represent two different parties and there is a case when
63 * they are active at the same time. The plain pres option will simply
64 * live on as a historical relic.
65 *
66 * Do not document the REDIRECTING(orig-ton), REDIRECTING(from-ton),
67 * or REDIRECTING(to-ton) datatypes.
68 * They are aliases for orig-num-plan, from-num-plan, and to-num-plan
69 * respectively.
70 */
71/*** DOCUMENTATION
72 <function name="CALLERID" language="en_US">
73 <since>
74 <version>1.2.0</version>
75 </since>
76 <synopsis>
77 Gets or sets Caller*ID data on the channel.
78 </synopsis>
79 <syntax>
80 <parameter name="datatype" required="true">
81 <para>The allowable datatypes are:</para>
82 <enumlist>
83 <enum name = "all" />
84 <enum name = "name" />
85 <enum name = "name-valid" />
86 <enum name = "name-charset" />
87 <enum name = "name-pres" />
88 <enum name = "num" />
89 <enum name = "num-valid" />
90 <enum name = "num-plan" />
91 <enum name = "num-pres" />
92 <enum name = "pres" />
93 <enum name = "subaddr" />
94 <enum name = "subaddr-valid" />
95 <enum name = "subaddr-type" />
96 <enum name = "subaddr-odd" />
97 <enum name = "tag" />
98 <enum name = "priv-all" />
99 <enum name = "priv-name" />
100 <enum name = "priv-name-valid" />
101 <enum name = "priv-name-charset" />
102 <enum name = "priv-name-pres" />
103 <enum name = "priv-num" />
104 <enum name = "priv-num-valid" />
105 <enum name = "priv-num-plan" />
106 <enum name = "priv-num-pres" />
107 <enum name = "priv-subaddr" />
108 <enum name = "priv-subaddr-valid" />
109 <enum name = "priv-subaddr-type" />
110 <enum name = "priv-subaddr-odd" />
111 <enum name = "priv-tag" />
112 <enum name = "ANI-all" />
113 <enum name = "ANI-name" />
114 <enum name = "ANI-name-valid" />
115 <enum name = "ANI-name-charset" />
116 <enum name = "ANI-name-pres" />
117 <enum name = "ANI-num" />
118 <enum name = "ANI-num-valid" />
119 <enum name = "ANI-num-plan" />
120 <enum name = "ANI-num-pres" />
121 <enum name = "ANI-tag" />
122 <enum name = "RDNIS" />
123 <enum name = "DNID" />
124 <enum name = "dnid-num-plan" />
125 <enum name = "dnid-subaddr" />
126 <enum name = "dnid-subaddr-valid" />
127 <enum name = "dnid-subaddr-type" />
128 <enum name = "dnid-subaddr-odd" />
129 </enumlist>
130 </parameter>
131 <parameter name="CID">
132 <para>Optional Caller*ID to parse instead of using the Caller*ID from the
133 channel. This parameter is only optional when reading the Caller*ID.</para>
134 </parameter>
135 </syntax>
136 <description>
137 <para>Gets or sets Caller*ID data on the channel. Uses channel callerid by
138 default or optional callerid, if specified.</para>
139 <para>The <replaceable>pres</replaceable> field gets/sets a combined value
140 for <replaceable>name-pres</replaceable> and
141 <replaceable>num-pres</replaceable>.</para>
142 <para>The allowable values for the <replaceable>name-charset</replaceable>
143 field are the following:</para>
144 <enumlist>
145 <enum name = "unknown"><para>Unknown</para></enum>
146 <enum name = "iso8859-1"><para>ISO8859-1</para></enum>
147 <enum name = "withdrawn"><para>Withdrawn</para></enum>
148 <enum name = "iso8859-2"><para>ISO8859-2</para></enum>
149 <enum name = "iso8859-3"><para>ISO8859-3</para></enum>
150 <enum name = "iso8859-4"><para>ISO8859-4</para></enum>
151 <enum name = "iso8859-5"><para>ISO8859-5</para></enum>
152 <enum name = "iso8859-7"><para>ISO8859-7</para></enum>
153 <enum name = "bmp"><para>ISO10646 Bmp String</para></enum>
154 <enum name = "utf8"><para>ISO10646 UTF-8 String</para></enum>
155 </enumlist>
156 <para>The allowable values for the <replaceable>num-pres</replaceable>,
157 <replaceable>name-pres</replaceable>, and <replaceable>pres</replaceable>
158 fields are the following:</para>
159 <enumlist>
160 <enum name="allowed_not_screened">
161 <para>Presentation Allowed, Not Screened.</para>
162 </enum>
163 <enum name="allowed_passed_screen">
164 <para>Presentation Allowed, Passed Screen.</para>
165 </enum>
166 <enum name="allowed_failed_screen">
167 <para>Presentation Allowed, Failed Screen.</para>
168 </enum>
169 <enum name="allowed">
170 <para>Presentation Allowed, Network Number.</para>
171 </enum>
172 <enum name="prohib_not_screened">
173 <para>Presentation Prohibited, Not Screened.</para>
174 </enum>
175 <enum name="prohib_passed_screen">
176 <para>Presentation Prohibited, Passed Screen.</para>
177 </enum>
178 <enum name="prohib_failed_screen">
179 <para>Presentation Prohibited, Failed Screen.</para>
180 </enum>
181 <enum name="prohib">
182 <para>Presentation Prohibited, Network Number.</para>
183 </enum>
184 <enum name="unavailable">
185 <para>Number Unavailable.</para>
186 </enum>
187 </enumlist>
188 <variablelist>
189 <variable name="CALL_QUALIFIER">
190 <para>This is a special Caller ID-related variable
191 that can be used to enable sending the Call Qualifier
192 parameter in MDMF (Multiple Data Message Format)
193 Caller ID spills.</para>
194 <para>This variable is not automatically set by Asterisk.
195 You are responsible for setting it if/when needed.</para>
196 <para>Supporting Caller ID units will display the LDC
197 (Long Distance Call) indicator when they receive this parameter.</para>
198 <para>For incoming calls on FXO ports, if the Call Qualifier parameter is received,
199 this variable will also be set to 1.</para>
200 <para>This option must be used with a channel driver
201 that allows Asterisk to generate the Caller ID spill,
202 which currently only includes <literal>chan_dahdi</literal>.</para>
203 </variable>
204 </variablelist>
205 </description>
206 </function>
207 <function name="CONNECTEDLINE" language="en_US">
208 <since>
209 <version>1.8.0</version>
210 </since>
211 <synopsis>
212 Gets or sets Connected Line data on the channel.
213 </synopsis>
214 <syntax>
215 <parameter name="datatype" required="true">
216 <para>The allowable datatypes are:</para>
217 <enumlist>
218 <enum name = "all" />
219 <enum name = "name" />
220 <enum name = "name-valid" />
221 <enum name = "name-charset" />
222 <enum name = "name-pres" />
223 <enum name = "num" />
224 <enum name = "num-valid" />
225 <enum name = "num-plan" />
226 <enum name = "num-pres" />
227 <enum name = "pres" />
228 <enum name = "subaddr" />
229 <enum name = "subaddr-valid" />
230 <enum name = "subaddr-type" />
231 <enum name = "subaddr-odd" />
232 <enum name = "tag" />
233 <enum name = "priv-all" />
234 <enum name = "priv-name" />
235 <enum name = "priv-name-valid" />
236 <enum name = "priv-name-charset" />
237 <enum name = "priv-name-pres" />
238 <enum name = "priv-num" />
239 <enum name = "priv-num-valid" />
240 <enum name = "priv-num-plan" />
241 <enum name = "priv-num-pres" />
242 <enum name = "priv-subaddr" />
243 <enum name = "priv-subaddr-valid" />
244 <enum name = "priv-subaddr-type" />
245 <enum name = "priv-subaddr-odd" />
246 <enum name = "priv-tag" />
247 </enumlist>
248 </parameter>
249 <parameter name="i">
250 <para>If set, this will prevent the channel from sending out protocol
251 messages because of the value being set</para>
252 </parameter>
253 </syntax>
254 <description>
255 <para>Gets or sets Connected Line data on the channel.</para>
256 <para>The <replaceable>pres</replaceable> field gets/sets a combined value
257 for <replaceable>name-pres</replaceable> and
258 <replaceable>num-pres</replaceable>.</para>
259 <para>The allowable values for the <replaceable>name-charset</replaceable>
260 field are the following:</para>
261 <enumlist>
262 <enum name = "unknown"><para>Unknown</para></enum>
263 <enum name = "iso8859-1"><para>ISO8859-1</para></enum>
264 <enum name = "withdrawn"><para>Withdrawn</para></enum>
265 <enum name = "iso8859-2"><para>ISO8859-2</para></enum>
266 <enum name = "iso8859-3"><para>ISO8859-3</para></enum>
267 <enum name = "iso8859-4"><para>ISO8859-4</para></enum>
268 <enum name = "iso8859-5"><para>ISO8859-5</para></enum>
269 <enum name = "iso8859-7"><para>ISO8859-7</para></enum>
270 <enum name = "bmp"><para>ISO10646 Bmp String</para></enum>
271 <enum name = "utf8"><para>ISO10646 UTF-8 String</para></enum>
272 </enumlist>
273 <para>The allowable values for the <replaceable>num-pres</replaceable>,
274 <replaceable>name-pres</replaceable>, and <replaceable>pres</replaceable>
275 fields are the following:</para>
276 <enumlist>
277 <enum name="allowed_not_screened">
278 <para>Presentation Allowed, Not Screened.</para>
279 </enum>
280 <enum name="allowed_passed_screen">
281 <para>Presentation Allowed, Passed Screen.</para>
282 </enum>
283 <enum name="allowed_failed_screen">
284 <para>Presentation Allowed, Failed Screen.</para>
285 </enum>
286 <enum name="allowed">
287 <para>Presentation Allowed, Network Number.</para>
288 </enum>
289 <enum name="prohib_not_screened">
290 <para>Presentation Prohibited, Not Screened.</para>
291 </enum>
292 <enum name="prohib_passed_screen">
293 <para>Presentation Prohibited, Passed Screen.</para>
294 </enum>
295 <enum name="prohib_failed_screen">
296 <para>Presentation Prohibited, Failed Screen.</para>
297 </enum>
298 <enum name="prohib">
299 <para>Presentation Prohibited, Network Number.</para>
300 </enum>
301 <enum name="unavailable">
302 <para>Number Unavailable.</para>
303 </enum>
304 </enumlist>
305 </description>
306 </function>
307 <function name="REDIRECTING" language="en_US">
308 <since>
309 <version>1.8.0</version>
310 </since>
311 <synopsis>
312 Gets or sets Redirecting data on the channel.
313 </synopsis>
314 <syntax>
315 <parameter name="datatype" required="true">
316 <para>The allowable datatypes are:</para>
317 <enumlist>
318 <enum name = "orig-all" />
319 <enum name = "orig-name" />
320 <enum name = "orig-name-valid" />
321 <enum name = "orig-name-charset" />
322 <enum name = "orig-name-pres" />
323 <enum name = "orig-num" />
324 <enum name = "orig-num-valid" />
325 <enum name = "orig-num-plan" />
326 <enum name = "orig-num-pres" />
327 <enum name = "orig-pres" />
328 <enum name = "orig-subaddr" />
329 <enum name = "orig-subaddr-valid" />
330 <enum name = "orig-subaddr-type" />
331 <enum name = "orig-subaddr-odd" />
332 <enum name = "orig-tag" />
333 <enum name = "orig-reason" />
334 <enum name = "from-all" />
335 <enum name = "from-name" />
336 <enum name = "from-name-valid" />
337 <enum name = "from-name-charset" />
338 <enum name = "from-name-pres" />
339 <enum name = "from-num" />
340 <enum name = "from-num-valid" />
341 <enum name = "from-num-plan" />
342 <enum name = "from-num-pres" />
343 <enum name = "from-pres" />
344 <enum name = "from-subaddr" />
345 <enum name = "from-subaddr-valid" />
346 <enum name = "from-subaddr-type" />
347 <enum name = "from-subaddr-odd" />
348 <enum name = "from-tag" />
349 <enum name = "to-all" />
350 <enum name = "to-name" />
351 <enum name = "to-name-valid" />
352 <enum name = "to-name-charset" />
353 <enum name = "to-name-pres" />
354 <enum name = "to-num" />
355 <enum name = "to-num-valid" />
356 <enum name = "to-num-plan" />
357 <enum name = "to-num-pres" />
358 <enum name = "to-pres" />
359 <enum name = "to-subaddr" />
360 <enum name = "to-subaddr-valid" />
361 <enum name = "to-subaddr-type" />
362 <enum name = "to-subaddr-odd" />
363 <enum name = "to-tag" />
364 <enum name = "priv-orig-all" />
365 <enum name = "priv-orig-name" />
366 <enum name = "priv-orig-name-valid" />
367 <enum name = "priv-orig-name-charset" />
368 <enum name = "priv-orig-name-pres" />
369 <enum name = "priv-orig-num" />
370 <enum name = "priv-orig-num-valid" />
371 <enum name = "priv-orig-num-plan" />
372 <enum name = "priv-orig-num-pres" />
373 <enum name = "priv-orig-subaddr" />
374 <enum name = "priv-orig-subaddr-valid" />
375 <enum name = "priv-orig-subaddr-type" />
376 <enum name = "priv-orig-subaddr-odd" />
377 <enum name = "priv-orig-tag" />
378 <enum name = "priv-from-all" />
379 <enum name = "priv-from-name" />
380 <enum name = "priv-from-name-valid" />
381 <enum name = "priv-from-name-charset" />
382 <enum name = "priv-from-name-pres" />
383 <enum name = "priv-from-num" />
384 <enum name = "priv-from-num-valid" />
385 <enum name = "priv-from-num-plan" />
386 <enum name = "priv-from-num-pres" />
387 <enum name = "priv-from-subaddr" />
388 <enum name = "priv-from-subaddr-valid" />
389 <enum name = "priv-from-subaddr-type" />
390 <enum name = "priv-from-subaddr-odd" />
391 <enum name = "priv-from-tag" />
392 <enum name = "priv-to-all" />
393 <enum name = "priv-to-name" />
394 <enum name = "priv-to-name-valid" />
395 <enum name = "priv-to-name-charset" />
396 <enum name = "priv-to-name-pres" />
397 <enum name = "priv-to-num" />
398 <enum name = "priv-to-num-valid" />
399 <enum name = "priv-to-num-plan" />
400 <enum name = "priv-to-num-pres" />
401 <enum name = "priv-to-subaddr" />
402 <enum name = "priv-to-subaddr-valid" />
403 <enum name = "priv-to-subaddr-type" />
404 <enum name = "priv-to-subaddr-odd" />
405 <enum name = "priv-to-tag" />
406 <enum name = "reason" />
407 <enum name = "count" />
408 </enumlist>
409 </parameter>
410 <parameter name="i">
411 <para>If set, this will prevent the channel from sending out protocol
412 messages because of the value being set</para>
413 </parameter>
414 </syntax>
415 <description>
416 <para>Gets or sets Redirecting data on the channel.</para>
417 <para>The <replaceable>orig-pres</replaceable>,
418 <replaceable>from-pres</replaceable> and <replaceable>to-pres</replaceable>
419 fields get/set a combined value for the corresponding
420 <replaceable>...-name-pres</replaceable> and <replaceable>...-num-pres</replaceable>
421 fields.</para>
422 <para>The recognized values for the <replaceable>reason</replaceable>
423 and <replaceable>orig-reason</replaceable> fields are the following:</para>
424 <enumlist>
425 <enum name = "away"><para>Callee is Away</para></enum>
426 <enum name = "cf_dte"><para>Call Forwarding By The Called DTE</para></enum>
427 <enum name = "cfb"><para>Call Forwarding Busy</para></enum>
428 <enum name = "cfnr"><para>Call Forwarding No Reply</para></enum>
429 <enum name = "cfu"><para>Call Forwarding Unconditional</para></enum>
430 <enum name = "deflection"><para>Call Deflection</para></enum>
431 <enum name = "dnd"><para>Do Not Disturb</para></enum>
432 <enum name = "follow_me"><para>Follow Me</para></enum>
433 <enum name = "out_of_order"><para>Called DTE Out-Of-Order</para></enum>
434 <enum name = "send_to_vm"><para>Send the call to voicemail</para></enum>
435 <enum name = "time_of_day"><para>Time of Day</para></enum>
436 <enum name = "unavailable"><para>Callee is Unavailable</para></enum>
437 <enum name = "unknown"><para>Unknown</para></enum>
438 </enumlist>
439 <note><para>You can set a user defined reason string that SIP can
440 send/receive instead. The user defined reason string my need to be
441 quoted depending upon SIP or the peer's requirements. These strings
442 are treated as unknown by the non-SIP channel drivers.</para></note>
443 <para>The allowable values for the <replaceable>xxx-name-charset</replaceable>
444 field are the following:</para>
445 <enumlist>
446 <enum name = "unknown"><para>Unknown</para></enum>
447 <enum name = "iso8859-1"><para>ISO8859-1</para></enum>
448 <enum name = "withdrawn"><para>Withdrawn</para></enum>
449 <enum name = "iso8859-2"><para>ISO8859-2</para></enum>
450 <enum name = "iso8859-3"><para>ISO8859-3</para></enum>
451 <enum name = "iso8859-4"><para>ISO8859-4</para></enum>
452 <enum name = "iso8859-5"><para>ISO8859-5</para></enum>
453 <enum name = "iso8859-7"><para>ISO8859-7</para></enum>
454 <enum name = "bmp"><para>ISO10646 Bmp String</para></enum>
455 <enum name = "utf8"><para>ISO10646 UTF-8 String</para></enum>
456 </enumlist>
457 </description>
458 </function>
459 ***/
460
466
468 AST_APP_ARG(member); /*!< Member name */
469 AST_APP_ARG(opts); /*!< Options token */
470 AST_APP_ARG(other); /*!< Any remining unused arguments */
471 );
472
474 AST_APP_ARG(subnames[10]); /*!< Option member subnames */
475 );
476
479};
481 CONNECTED_LINE_OPT_DUMMY, /*!< Delete this if CONNECTED_LINE ever gets an option with parameters. */
482
483 /*! \note This entry _MUST_ be the last one in the enum */
486
490
493};
495 REDIRECTING_OPT_DUMMY, /*!< Delete this if REDIRECTING ever gets an option with parameters. */
496
497 /*! \note This entry _MUST_ be the last one in the enum */
500
504
505/*!
506 * \internal
507 * \brief Read values from the party name struct.
508 * \since 1.8
509 *
510 * \param buf Buffer to fill with read value.
511 * \param len Length of the buffer.
512 * \param argc Number of party member subnames.
513 * \param argv Party member subnames given.
514 * \param name Party name to get values from.
515 *
516 * \retval ID_FIELD_VALID on success.
517 * \retval ID_FIELD_UNKNOWN on unknown field name.
518 */
519static enum ID_FIELD_STATUS party_name_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_name *name)
520{
522
524
525 if (argc == 0) {
526 /* We want the name string */
527 if (name->valid && name->str) {
528 ast_copy_string(buf, name->str, len);
529 }
530 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
531 snprintf(buf, len, "%d", name->valid);
532 } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
534 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
535 /* Accept pres[entation] */
537 } else {
539 }
540
541 return status;
542}
543
544/*!
545 * \internal
546 * \brief Read values from the party number struct.
547 * \since 1.8
548 *
549 * \param buf Buffer to fill with read value.
550 * \param len Length of the buffer.
551 * \param argc Number of party member subnames.
552 * \param argv Party member subnames given.
553 * \param number Party number to get values from.
554 *
555 * \retval ID_FIELD_VALID on success.
556 * \retval ID_FIELD_UNKNOWN on unknown field name.
557 */
558static enum ID_FIELD_STATUS party_number_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_number *number)
559{
561
563
564 if (argc == 0) {
565 /* We want the number string */
566 if (number->valid && number->str) {
568 }
569 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
570 snprintf(buf, len, "%d", number->valid);
571 } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
572 snprintf(buf, len, "%d", number->plan);
573 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
574 /* Accept pres[entation] */
576 } else {
578 }
579
580 return status;
581}
582
583/*!
584 * \internal
585 * \brief Read values from the party subaddress struct.
586 * \since 1.8
587 *
588 * \param buf Buffer to fill with read value.
589 * \param len Length of the buffer.
590 * \param argc Number of party member subnames.
591 * \param argv Party member subnames given.
592 * \param subaddress Party subaddress to get values from.
593 *
594 * \retval ID_FIELD_VALID on success.
595 * \retval ID_FIELD_UNKNOWN on unknown field name.
596 */
597static enum ID_FIELD_STATUS party_subaddress_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
598{
600
602
603 if (argc == 0) {
604 /* We want the subaddress string */
605 if (subaddress->str) {
606 ast_copy_string(buf, subaddress->str, len);
607 }
608 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
609 snprintf(buf, len, "%d", subaddress->valid);
610 } else if (argc == 1 && !strcasecmp("type", argv[0])) {
611 snprintf(buf, len, "%d", subaddress->type);
612 } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
613 snprintf(buf, len, "%d", subaddress->odd_even_indicator);
614 } else {
616 }
617
618 return status;
619}
620
621/*!
622 * \internal
623 * \brief Read values from the party id struct.
624 * \since 1.8
625 *
626 * \param buf Buffer to fill with read value.
627 * \param len Length of the buffer.
628 * \param argc Number of party member subnames.
629 * \param argv Party member subnames given.
630 * \param id Party id to get values from.
631 *
632 * \retval ID_FIELD_VALID on success.
633 * \retval ID_FIELD_UNKNOWN on unknown field name.
634 */
635static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
636{
638
639 if (argc == 0) {
640 /* Must have at least one subname. */
641 return ID_FIELD_UNKNOWN;
642 }
643
645
646 if (argc == 1 && !strcasecmp("all", argv[0])) {
647 snprintf(buf, len, "\"%s\" <%s>",
648 S_COR(id->name.valid, id->name.str, ""),
649 S_COR(id->number.valid, id->number.str, ""));
650 } else if (!strcasecmp("name", argv[0])) {
651 status = party_name_read(buf, len, argc - 1, argv + 1, &id->name);
652 } else if (!strncasecmp("num", argv[0], 3)) {
653 /* Accept num[ber] */
654 status = party_number_read(buf, len, argc - 1, argv + 1, &id->number);
655 } else if (!strncasecmp("subaddr", argv[0], 7)) {
656 /* Accept subaddr[ess] */
657 status = party_subaddress_read(buf, len, argc - 1, argv + 1, &id->subaddress);
658 } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
659 if (id->tag) {
660 ast_copy_string(buf, id->tag, len);
661 }
662 } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
663 /* ton is an alias for num-plan */
664 snprintf(buf, len, "%d", id->number.plan);
665 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
666 /*
667 * Accept pres[entation]
668 * This is the combined name/number presentation.
669 */
672 } else {
674 }
675
676 return status;
677}
678
679/*!
680 * \internal
681 * \brief Write new values to the party name struct
682 * \since 1.8
683 *
684 * \param name Party name struct to write values
685 * \param argc Number of party member subnames.
686 * \param argv Party member subnames given.
687 * \param value Value to assign to the party name.
688 *
689 * \retval ID_FIELD_VALID on success.
690 * \retval ID_FIELD_INVALID on error with field value.
691 * \retval ID_FIELD_UNKNOWN on unknown field name.
692 */
693static enum ID_FIELD_STATUS party_name_write(struct ast_party_name *name, int argc, char *argv[], const char *value)
694{
695 char *val;
697
699
700 if (argc == 0) {
701 /* We are setting the name string */
702 name->valid = 1;
703 name->str = ast_strdup(value);
704 ast_trim_blanks(name->str);
705 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
706 name->valid = atoi(value) ? 1 : 0;
707 } else if (argc == 1 && !strcasecmp("charset", argv[0])) {
708 int char_set;
709
712
713 if (('0' <= val[0]) && (val[0] <= '9')) {
714 char_set = atoi(val);
715 } else {
717 }
718
719 if (char_set < 0) {
721 "Unknown name char-set '%s', value unchanged\n", val);
723 } else {
724 name->char_set = char_set;
725 }
726 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
727 int pres;
728
729 /* Accept pres[entation] */
732
733 if (('0' <= val[0]) && (val[0] <= '9')) {
734 pres = atoi(val);
735 } else {
737 }
738
739 if (pres < 0) {
741 "Unknown name presentation '%s', value unchanged\n", val);
743 } else {
744 name->presentation = pres;
745 }
746 } else {
748 }
749
750 return status;
751}
752
753/*!
754 * \internal
755 * \brief Write new values to the party number struct
756 * \since 1.8
757 *
758 * \param number Party number struct to write values
759 * \param argc Number of party member subnames.
760 * \param argv Party member subnames given.
761 * \param value Value to assign to the party number.
762 *
763 * \retval ID_FIELD_VALID on success.
764 * \retval ID_FIELD_INVALID on error with field value.
765 * \retval ID_FIELD_UNKNOWN on unknown field name.
766 */
767static enum ID_FIELD_STATUS party_number_write(struct ast_party_number *number, int argc, char *argv[], const char *value)
768{
769 char *val;
771
773
774 if (argc == 0) {
775 /* We are setting the number string */
776 number->valid = 1;
777 number->str = ast_strdup(value);
779 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
780 number->valid = atoi(value) ? 1 : 0;
781 } else if (argc == 1 && !strcasecmp("plan", argv[0])) {
784
785 if (('0' <= val[0]) && (val[0] <= '9')) {
786 number->plan = atoi(val);
787 } else {
789 "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
791 }
792 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
793 int pres;
794
795 /* Accept pres[entation] */
798
799 if (('0' <= val[0]) && (val[0] <= '9')) {
800 pres = atoi(val);
801 } else {
803 }
804
805 if (pres < 0) {
807 "Unknown number presentation '%s', value unchanged\n", val);
809 } else {
810 number->presentation = pres;
811 }
812 } else {
814 }
815
816 return status;
817}
818
819/*!
820 * \internal
821 * \brief Write new values to the party subaddress struct
822 * \since 1.8
823 *
824 * \param subaddress Party subaddress struct to write values
825 * \param argc Number of party member subnames.
826 * \param argv Party member subnames given.
827 * \param value Value to assign to the party subaddress.
828 *
829 * \retval ID_FIELD_VALID on success.
830 * \retval ID_FIELD_INVALID on error with field value.
831 * \retval ID_FIELD_UNKNOWN on unknown field name.
832 */
833static enum ID_FIELD_STATUS party_subaddress_write(struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
834{
836
838
839 if (argc == 0) {
840 /* We are setting the subaddress string */
841 subaddress->str = ast_strdup(value);
842 ast_trim_blanks(subaddress->str);
843 } else if (argc == 1 && !strcasecmp("valid", argv[0])) {
844 subaddress->valid = atoi(value) ? 1 : 0;
845 } else if (argc == 1 && !strcasecmp("type", argv[0])) {
846 subaddress->type = atoi(value) ? 2 : 0;
847 } else if (argc == 1 && !strcasecmp("odd", argv[0])) {
848 subaddress->odd_even_indicator = atoi(value) ? 1 : 0;
849 } else {
851 }
852
853 return status;
854}
855
856/*!
857 * \internal
858 * \brief Write new values to the party id struct
859 * \since 1.8
860 *
861 * \param id Party ID struct to write values
862 * \param argc Number of party member subnames.
863 * \param argv Party member subnames given.
864 * \param value Value to assign to the party id.
865 *
866 * \retval ID_FIELD_VALID on success.
867 * \retval ID_FIELD_INVALID on error with field value.
868 * \retval ID_FIELD_UNKNOWN on unknown field name.
869 */
870static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
871{
872 char *val;
874
875 if (argc == 0) {
876 /* Must have at least one subname. */
877 return ID_FIELD_UNKNOWN;
878 }
879
881
882 if (argc == 1 && !strcasecmp("all", argv[0])) {
883 char name[256];
884 char num[256];
885
886 ast_callerid_split(value, name, sizeof(name), num, sizeof(num));
887 id->name.valid = 1;
888 id->name.str = ast_strdup(name);
889 if (!id->name.str) {
890 return ID_FIELD_INVALID;
891 }
892 id->number.valid = 1;
893 id->number.str = ast_strdup(num);
894 if (!id->number.str) {
895 return ID_FIELD_INVALID;
896 }
897 } else if (!strcasecmp("name", argv[0])) {
898 status = party_name_write(&id->name, argc - 1, argv + 1, value);
899 } else if (!strncasecmp("num", argv[0], 3)) {
900 /* Accept num[ber] */
901 status = party_number_write(&id->number, argc - 1, argv + 1, value);
902 } else if (!strncasecmp("subaddr", argv[0], 7)) {
903 /* Accept subaddr[ess] */
904 status = party_subaddress_write(&id->subaddress, argc - 1, argv + 1, value);
905 } else if (argc == 1 && !strcasecmp("tag", argv[0])) {
906 id->tag = ast_strdup(value);
907 ast_trim_blanks(id->tag);
908 } else if (argc == 1 && !strcasecmp("ton", argv[0])) {
909 /* ton is an alias for num-plan */
910 argv[0] = "plan";
911 status = party_number_write(&id->number, argc, argv, value);
912 } else if (argc == 1 && !strncasecmp("pres", argv[0], 4)) {
913 int pres;
914
915 /*
916 * Accept pres[entation]
917 * This is the combined name/number presentation.
918 */
921
922 if (('0' <= val[0]) && (val[0] <= '9')) {
923 pres = atoi(val);
924 } else {
926 }
927
928 if (pres < 0) {
930 "Unknown combined presentation '%s', value unchanged\n", val);
932 } else {
933 id->name.presentation = pres;
934 id->number.presentation = pres;
935 }
936 } else {
938 }
939
940 return status;
941}
942
943/*!
944 * \internal
945 * \brief Read values from the caller-id information struct.
946 *
947 * \param chan Asterisk channel to read
948 * \param cmd Not used
949 * \param data Caller-id function datatype string
950 * \param buf Buffer to fill with read value.
951 * \param len Length of the buffer
952 *
953 * \retval 0 on success.
954 * \retval -1 on error.
955 */
956static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
957{
958 char *parms;
959 struct ast_party_members member = { 0, };
961 AST_APP_ARG(member); /*!< Member name */
962 AST_APP_ARG(cid); /*!< Optional caller id to parse instead of from the channel. */
963 );
964
965 /* Ensure that the buffer is empty */
966 *buf = 0;
967
968 if (!chan) {
969 return -1;
970 }
971
972 parms = ast_strdupa(data);
974 if (args.argc == 0) {
975 /* Must have at least one argument. */
976 return -1;
977 }
978
980 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
981 /* Too few or too many subnames */
982 return -1;
983 }
984
985 if (args.argc == 2) {
986 char name[80];
987 char num[80];
988
989 ast_callerid_split(args.cid, name, sizeof(name), num, sizeof(num));
990
991 if (member.argc == 1 && !strcasecmp("all", member.subnames[0])) {
992 snprintf(buf, len, "\"%s\" <%s>", name, num);
993 } else if (member.argc == 1 && !strcasecmp("name", member.subnames[0])) {
995 } else if (member.argc == 1 && !strncasecmp("num", member.subnames[0], 3)) {
996 /* Accept num[ber] */
997 ast_copy_string(buf, num, len);
998 } else {
999 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1000 }
1001 } else {
1003 ast_channel_lock(chan);
1004
1005 if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
1006 if (ast_channel_redirecting(chan)->from.number.valid
1007 && ast_channel_redirecting(chan)->from.number.str) {
1008 ast_copy_string(buf, ast_channel_redirecting(chan)->from.number.str, len);
1009 }
1010 } else if (!strcasecmp("dnid", member.subnames[0])) {
1011 if (member.argc == 1) {
1012 /* Setup as if user had given dnid-num instead. */
1013 member.argc = 2;
1014 member.subnames[1] = "num";
1015 }
1016 if (!strncasecmp("num", member.subnames[1], 3)) {
1017 /*
1018 * Accept num[ber]
1019 * dnid-num...
1020 */
1021 if (member.argc == 2) {
1022 /* dnid-num */
1023 if (ast_channel_dialed(chan)->number.str) {
1025 }
1026 } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
1027 /* dnid-num-plan */
1028 snprintf(buf, len, "%d", ast_channel_dialed(chan)->number.plan);
1029 } else {
1030 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1031 }
1032 } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
1033 /*
1034 * Accept subaddr[ess]
1035 * dnid-subaddr...
1036 */
1037 status = party_subaddress_read(buf, len, member.argc - 2, member.subnames + 2,
1038 &ast_channel_dialed(chan)->subaddress);
1039 switch (status) {
1040 case ID_FIELD_VALID:
1041 case ID_FIELD_INVALID:
1042 break;
1043 default:
1044 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1045 break;
1046 }
1047 } else {
1048 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1049 }
1050 } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
1051 snprintf(buf, len, "%d", ast_channel_caller(chan)->ani2);
1052 } else if (!strcasecmp("ani", member.subnames[0])) {
1053 if (member.argc == 1) {
1054 /* Setup as if user had given ani-num instead. */
1055 member.argc = 2;
1056 member.subnames[1] = "num";
1057 }
1058 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1059 &ast_channel_caller(chan)->ani);
1060 switch (status) {
1061 case ID_FIELD_VALID:
1062 case ID_FIELD_INVALID:
1063 break;
1064 default:
1065 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1066 break;
1067 }
1068 } else if (!strcasecmp("priv", member.subnames[0])) {
1069 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1070 &ast_channel_caller(chan)->priv);
1071 switch (status) {
1072 case ID_FIELD_VALID:
1073 case ID_FIELD_INVALID:
1074 break;
1075 default:
1076 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1077 break;
1078 }
1079 } else {
1080 status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_caller(chan)->id);
1081 switch (status) {
1082 case ID_FIELD_VALID:
1083 case ID_FIELD_INVALID:
1084 break;
1085 default:
1086 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1087 break;
1088 }
1089 }
1090
1091 ast_channel_unlock(chan);
1092 }
1093
1094 return 0;
1095}
1096
1097/*!
1098 * \internal
1099 * \brief Write new values to the caller-id information struct.
1100 *
1101 * \param chan Asterisk channel to update
1102 * \param cmd Not used
1103 * \param data Caller-id function datatype string
1104 * \param value Value to assign to the caller-id information struct.
1105 *
1106 * \retval 0 on success.
1107 * \retval -1 on error.
1108 */
1109static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
1110{
1111 struct ast_party_caller caller;
1112 struct ast_party_dialed dialed;
1114 char *val;
1115 char *parms;
1116 struct ast_party_func_args args = { 0, };
1117 struct ast_party_members member = { 0, };
1118
1119 if (!value || !chan) {
1120 return -1;
1121 }
1122
1123 parms = ast_strdupa(data);
1125 if (args.argc == 0) {
1126 /* Must have at least one argument. */
1127 return -1;
1128 }
1129
1130 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1131 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1132 /* Too few or too many subnames */
1133 return -1;
1134 }
1135
1137
1138 ast_channel_lock(chan);
1139 if (member.argc == 1 && !strcasecmp("rdnis", member.subnames[0])) {
1141 ast_free(ast_channel_redirecting(chan)->from.number.str);
1143 } else if (!strcasecmp("dnid", member.subnames[0])) {
1145 if (member.argc == 1) {
1146 /* Setup as if user had given dnid-num instead. */
1147 member.argc = 2;
1148 member.subnames[1] = "num";
1149 }
1150 if (!strncasecmp("num", member.subnames[1], 3)) {
1151 /*
1152 * Accept num[ber]
1153 * dnid-num...
1154 */
1155 if (member.argc == 2) {
1156 /* dnid-num */
1157 dialed.number.str = ast_strdup(value);
1158 ast_trim_blanks(dialed.number.str);
1160 } else if (member.argc == 3 && !strcasecmp("plan", member.subnames[2])) {
1161 /* dnid-num-plan */
1164
1165 if (('0' <= val[0]) && (val[0] <= '9')) {
1166 ast_channel_dialed(chan)->number.plan = atoi(val);
1167 } else {
1169 "Unknown type-of-number/numbering-plan '%s', value unchanged\n", val);
1170 }
1171 } else {
1172 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1173 }
1174 } else if (!strncasecmp("subaddr", member.subnames[1], 7)) {
1175 /*
1176 * Accept subaddr[ess]
1177 * dnid-subaddr...
1178 */
1179 status = party_subaddress_write(&dialed.subaddress, member.argc - 2,
1180 member.subnames + 2, value);
1181 switch (status) {
1182 case ID_FIELD_VALID:
1184 break;
1185 case ID_FIELD_INVALID:
1186 break;
1187 default:
1188 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1189 break;
1190 }
1191 } else {
1192 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1193 }
1194 ast_party_dialed_free(&dialed);
1195 } else if (member.argc == 1 && !strcasecmp("ani2", member.subnames[0])) {
1198
1199 if (('0' <= val[0]) && (val[0] <= '9')) {
1200 ast_channel_caller(chan)->ani2 = atoi(val);
1201 } else {
1202 ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
1203 }
1204 } else if (!strcasecmp("ani", member.subnames[0])) {
1206 if (member.argc == 1) {
1207 /* Setup as if user had given ani-num instead. */
1208 member.argc = 2;
1209 member.subnames[1] = "num";
1210 }
1211 status = party_id_write(&caller.ani, member.argc - 1, member.subnames + 1, value);
1212 switch (status) {
1213 case ID_FIELD_VALID:
1215 break;
1216 case ID_FIELD_INVALID:
1217 break;
1218 default:
1219 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1220 break;
1221 }
1222 ast_party_caller_free(&caller);
1223 } else if (!strcasecmp("priv", member.subnames[0])) {
1225 status = party_id_write(&caller.priv, member.argc - 1, member.subnames + 1, value);
1226 switch (status) {
1227 case ID_FIELD_VALID:
1229 break;
1230 case ID_FIELD_INVALID:
1231 break;
1232 default:
1233 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1234 break;
1235 }
1236 ast_party_caller_free(&caller);
1237 } else {
1239 status = party_id_write(&caller.id, member.argc, member.subnames, value);
1240 switch (status) {
1241 case ID_FIELD_VALID:
1242 ast_channel_set_caller_event(chan, &caller, NULL);
1243 break;
1244 case ID_FIELD_INVALID:
1245 break;
1246 default:
1247 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
1248 break;
1249 }
1250 ast_party_caller_free(&caller);
1251 }
1252 ast_channel_unlock(chan);
1253
1254 return 0;
1255}
1256
1257/*!
1258 * \internal
1259 * \brief Read values from the connected line information struct.
1260 *
1261 * \param chan Asterisk channel to read
1262 * \param cmd Not used
1263 * \param data Connected line function datatype string
1264 * \param buf Buffer to fill with read value.
1265 * \param len Length of the buffer
1266 *
1267 * \retval 0 on success.
1268 * \retval -1 on error.
1269 */
1270static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
1271{
1272 struct ast_party_members member = { 0, };
1273 char *read_what;
1275
1276 /* Ensure that the buffer is empty */
1277 *buf = 0;
1278
1279 if (!chan) {
1280 return -1;
1281 }
1282
1283 read_what = ast_strdupa(data);
1284 AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1285 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1286 /* Too few or too many subnames */
1287 return -1;
1288 }
1289
1290 ast_channel_lock(chan);
1291
1292 if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1294 } else if (!strcasecmp("priv", member.subnames[0])) {
1295 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1296 &ast_channel_connected(chan)->priv);
1297 switch (status) {
1298 case ID_FIELD_VALID:
1299 case ID_FIELD_INVALID:
1300 break;
1301 default:
1302 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1303 break;
1304 }
1305 } else {
1306 status = party_id_read(buf, len, member.argc, member.subnames, &ast_channel_connected(chan)->id);
1307 switch (status) {
1308 case ID_FIELD_VALID:
1309 case ID_FIELD_INVALID:
1310 break;
1311 default:
1312 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1313 break;
1314 }
1315 }
1316
1317 ast_channel_unlock(chan);
1318
1319 return 0;
1320}
1321
1322/*!
1323 * \internal
1324 * \brief Write new values to the connected line information struct.
1325 *
1326 * \param chan Asterisk channel to update
1327 * \param cmd Not used
1328 * \param data Connected line function datatype string
1329 * \param value Value to assign to the connected line information struct.
1330 *
1331 * \retval 0 on success.
1332 * \retval -1 on error.
1333 */
1334static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
1335{
1337 char *val;
1338 char *parms;
1339 void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
1340 struct ast_party_func_args args = { 0, };
1341 struct ast_party_members member = { 0, };
1342 struct ast_flags opts;
1343 char *opt_args[CONNECTED_LINE_OPT_ARG_ARRAY_SIZE];
1345
1346 if (!value || !chan) {
1347 return -1;
1348 }
1349
1350 parms = ast_strdupa(data);
1352 if (args.argc == 0) {
1353 /* Must have at least one argument. */
1354 return -1;
1355 }
1356
1357 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1358 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1359 /* Too few or too many subnames */
1360 return -1;
1361 }
1362
1363 if (ast_app_parse_options(connectedline_opts, &opts, opt_args, args.opts)) {
1364 /* General invalid option syntax. */
1365 return -1;
1366 }
1367
1368 /* Determine if the update indication inhibit option is present */
1371 } else {
1373 }
1374
1375 ast_channel_lock(chan);
1377 ast_channel_unlock(chan);
1378
1380
1381 if (member.argc == 1 && !strcasecmp("source", member.subnames[0])) {
1382 int source;
1383
1386
1387 if (('0' <= val[0]) && (val[0] <= '9')) {
1388 source = atoi(val);
1389 } else {
1391 }
1392
1393 if (source < 0) {
1394 ast_log(LOG_ERROR, "Unknown connectedline source '%s', value unchanged\n", val);
1395 } else {
1396 connected.source = source;
1397 set_it(chan, &connected, NULL);
1398 }
1399 } else if (!strcasecmp("priv", member.subnames[0])) {
1400 status = party_id_write(&connected.priv, member.argc - 1, member.subnames + 1, value);
1401 switch (status) {
1402 case ID_FIELD_VALID:
1403 set_it(chan, &connected, NULL);
1404 break;
1405 case ID_FIELD_INVALID:
1406 break;
1407 default:
1408 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1409 break;
1410 }
1412 } else {
1413 status = party_id_write(&connected.id, member.argc, member.subnames, value);
1414 switch (status) {
1415 case ID_FIELD_VALID:
1416 set_it(chan, &connected, NULL);
1417 break;
1418 case ID_FIELD_INVALID:
1419 break;
1420 default:
1421 ast_log(LOG_ERROR, "Unknown connectedline data type '%s'.\n", data);
1422 break;
1423 }
1425 }
1426
1427 return 0;
1428}
1429
1430/*!
1431 * \internal
1432 * \brief Read values from the redirecting information struct.
1433 *
1434 * \param chan Asterisk channel to read
1435 * \param cmd Not used
1436 * \param data Redirecting function datatype string
1437 * \param buf Buffer to fill with read value.
1438 * \param len Length of the buffer
1439 *
1440 * \retval 0 on success.
1441 * \retval -1 on error.
1442 */
1443static int redirecting_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
1444{
1445 struct ast_party_members member = { 0, };
1446 char *read_what;
1447 const struct ast_party_redirecting *ast_redirecting;
1449
1450 /* Ensure that the buffer is empty */
1451 *buf = 0;
1452
1453 if (!chan) {
1454 return -1;
1455 }
1456
1457 read_what = ast_strdupa(data);
1458 AST_NONSTANDARD_APP_ARGS(member, read_what, '-');
1459 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1460 /* Too few or too many subnames */
1461 return -1;
1462 }
1463
1464 ast_channel_lock(chan);
1465
1466 ast_redirecting = ast_channel_redirecting(chan);
1467 if (!strcasecmp("orig", member.subnames[0])) {
1468 if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1470 ast_redirecting_reason_name(&ast_redirecting->orig_reason), len);
1471 } else {
1472 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1473 &ast_redirecting->orig);
1474 switch (status) {
1475 case ID_FIELD_VALID:
1476 case ID_FIELD_INVALID:
1477 break;
1478 default:
1479 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1480 break;
1481 }
1482 }
1483 } else if (!strcasecmp("from", member.subnames[0])) {
1484 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1485 &ast_redirecting->from);
1486 switch (status) {
1487 case ID_FIELD_VALID:
1488 case ID_FIELD_INVALID:
1489 break;
1490 default:
1491 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1492 break;
1493 }
1494 } else if (!strcasecmp("to", member.subnames[0])) {
1495 status = party_id_read(buf, len, member.argc - 1, member.subnames + 1,
1496 &ast_redirecting->to);
1497 switch (status) {
1498 case ID_FIELD_VALID:
1499 case ID_FIELD_INVALID:
1500 break;
1501 default:
1502 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1503 break;
1504 }
1505 } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1506 /*
1507 * Accept pres[entation]
1508 * This is the combined from name/number presentation.
1509 */
1512 ast_party_id_presentation(&ast_redirecting->from)), len);
1513 } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1515 } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1516 snprintf(buf, len, "%d", ast_redirecting->count);
1517 } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1518 if (!strcasecmp("orig", member.subnames[1])) {
1519 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1520 &ast_redirecting->priv_orig);
1521 switch (status) {
1522 case ID_FIELD_VALID:
1523 case ID_FIELD_INVALID:
1524 break;
1525 default:
1526 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1527 break;
1528 }
1529 } else if (!strcasecmp("from", member.subnames[1])) {
1530 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1531 &ast_redirecting->priv_from);
1532 switch (status) {
1533 case ID_FIELD_VALID:
1534 case ID_FIELD_INVALID:
1535 break;
1536 default:
1537 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1538 break;
1539 }
1540 } else if (!strcasecmp("to", member.subnames[1])) {
1541 status = party_id_read(buf, len, member.argc - 2, member.subnames + 2,
1542 &ast_redirecting->priv_to);
1543 switch (status) {
1544 case ID_FIELD_VALID:
1545 case ID_FIELD_INVALID:
1546 break;
1547 default:
1548 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1549 break;
1550 }
1551 } else {
1552 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1553 }
1554 } else {
1555 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1556 }
1557
1558 ast_channel_unlock(chan);
1559
1560 return 0;
1561}
1562
1563/*!
1564 * \internal
1565 * \brief Write new values to the redirecting information struct.
1566 *
1567 * \param chan Asterisk channel to update
1568 * \param cmd Not used
1569 * \param data Redirecting function datatype string
1570 * \param value Value to assign to the redirecting information struct.
1571 *
1572 * \retval 0 on success.
1573 * \retval -1 on error.
1574 */
1575static int redirecting_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
1576{
1577 struct ast_party_redirecting redirecting;
1579 char *val;
1580 char *parms;
1581 void (*set_it)(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update);
1582 struct ast_party_func_args args = { 0, };
1583 struct ast_party_members member = { 0, };
1584 struct ast_flags opts;
1585 char *opt_args[REDIRECTING_OPT_ARG_ARRAY_SIZE];
1586
1587 if (!value || !chan) {
1588 return -1;
1589 }
1590
1591 parms = ast_strdupa(data);
1593 if (args.argc == 0) {
1594 /* Must have at least one argument. */
1595 return -1;
1596 }
1597
1598 AST_NONSTANDARD_APP_ARGS(member, args.member, '-');
1599 if (member.argc == 0 || ARRAY_LEN(member.subnames) <= member.argc) {
1600 /* Too few or too many subnames */
1601 return -1;
1602 }
1603
1604 if (ast_app_parse_options(redirecting_opts, &opts, opt_args, args.opts)) {
1605 /* General invalid option syntax. */
1606 return -1;
1607 }
1608
1609 /* Determine if the update indication inhibit option is present */
1612 } else {
1614 }
1615
1616 ast_channel_lock(chan);
1618 ast_channel_unlock(chan);
1619
1621
1622 if (!strcasecmp("orig", member.subnames[0])) {
1623 if (member.argc == 2 && !strcasecmp("reason", member.subnames[1])) {
1624 int reason;
1625
1628
1629 if (('0' <= val[0]) && (val[0] <= '9')) {
1630 reason = atoi(val);
1631 } else {
1633 }
1634
1635 if (reason < 0) {
1636 /* The argument passed into the function does not correspond to a pre-defined
1637 * reason, so we can just set the reason string to what was given and set the
1638 * code to be unknown
1639 */
1640 ast_log(LOG_WARNING, "Unknown redirecting reason '%s', defaulting to unknown\n", val);
1642 redirecting.orig_reason.str = val;
1643 set_it(chan, &redirecting, NULL);
1644 } else {
1645 redirecting.orig_reason.code = reason;
1646 redirecting.orig_reason.str = "";
1647 set_it(chan, &redirecting, NULL);
1648 }
1649 } else {
1650 status = party_id_write(&redirecting.orig, member.argc - 1, member.subnames + 1,
1651 value);
1652 switch (status) {
1653 case ID_FIELD_VALID:
1654 set_it(chan, &redirecting, NULL);
1655 break;
1656 case ID_FIELD_INVALID:
1657 break;
1658 default:
1659 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1660 break;
1661 }
1662 ast_party_redirecting_free(&redirecting);
1663 }
1664 } else if (!strcasecmp("from", member.subnames[0])) {
1665 status = party_id_write(&redirecting.from, member.argc - 1, member.subnames + 1,
1666 value);
1667 switch (status) {
1668 case ID_FIELD_VALID:
1669 set_it(chan, &redirecting, NULL);
1670 break;
1671 case ID_FIELD_INVALID:
1672 break;
1673 default:
1674 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1675 break;
1676 }
1677 ast_party_redirecting_free(&redirecting);
1678 } else if (!strcasecmp("to", member.subnames[0])) {
1679 status = party_id_write(&redirecting.to, member.argc - 1, member.subnames + 1, value);
1680 switch (status) {
1681 case ID_FIELD_VALID:
1682 set_it(chan, &redirecting, NULL);
1683 break;
1684 case ID_FIELD_INVALID:
1685 break;
1686 default:
1687 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1688 break;
1689 }
1690 ast_party_redirecting_free(&redirecting);
1691 } else if (member.argc == 1 && !strncasecmp("pres", member.subnames[0], 4)) {
1692 int pres;
1693
1696
1697 if (('0' <= val[0]) && (val[0] <= '9')) {
1698 pres = atoi(val);
1699 } else {
1701 }
1702
1703 if (pres < 0) {
1705 "Unknown redirecting combined presentation '%s', value unchanged\n", val);
1706 } else {
1707 redirecting.from.name.presentation = pres;
1708 redirecting.from.number.presentation = pres;
1709 redirecting.to.name.presentation = pres;
1710 redirecting.to.number.presentation = pres;
1711 set_it(chan, &redirecting, NULL);
1712 }
1713 } else if (member.argc == 1 && !strcasecmp("reason", member.subnames[0])) {
1714 int reason;
1715
1718
1719 if (('0' <= val[0]) && (val[0] <= '9')) {
1720 reason = atoi(val);
1721 } else {
1723 }
1724
1725 if (reason < 0) {
1726 /* The argument passed into the function does not correspond to a pre-defined
1727 * reason, so we can just set the reason string to what was given and set the
1728 * code to be unknown
1729 */
1730 ast_log(LOG_WARNING, "Unknown redirecting reason '%s', defaulting to unknown\n", val);
1732 redirecting.reason.str = val;
1733 set_it(chan, &redirecting, NULL);
1734 } else {
1735 redirecting.reason.code = reason;
1736 redirecting.reason.str = "";
1737 set_it(chan, &redirecting, NULL);
1738 }
1739 } else if (member.argc == 1 && !strcasecmp("count", member.subnames[0])) {
1742
1743 if (('0' <= val[0]) && (val[0] <= '9')) {
1744 redirecting.count = atoi(val);
1745 set_it(chan, &redirecting, NULL);
1746 } else {
1747 ast_log(LOG_ERROR, "Unknown redirecting count '%s', value unchanged\n", val);
1748 }
1749 } else if (1 < member.argc && !strcasecmp("priv", member.subnames[0])) {
1750 if (!strcasecmp("orig", member.subnames[1])) {
1751 status = party_id_write(&redirecting.priv_orig, member.argc - 2, member.subnames + 2,
1752 value);
1753 switch (status) {
1754 case ID_FIELD_VALID:
1755 set_it(chan, &redirecting, NULL);
1756 break;
1757 case ID_FIELD_INVALID:
1758 break;
1759 default:
1760 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1761 break;
1762 }
1763 ast_party_redirecting_free(&redirecting);
1764 } else if (!strcasecmp("from", member.subnames[1])) {
1765 status = party_id_write(&redirecting.priv_from, member.argc - 2, member.subnames + 2,
1766 value);
1767 switch (status) {
1768 case ID_FIELD_VALID:
1769 set_it(chan, &redirecting, NULL);
1770 break;
1771 case ID_FIELD_INVALID:
1772 break;
1773 default:
1774 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1775 break;
1776 }
1777 ast_party_redirecting_free(&redirecting);
1778 } else if (!strcasecmp("to", member.subnames[1])) {
1779 status = party_id_write(&redirecting.priv_to, member.argc - 2, member.subnames + 2, value);
1780 switch (status) {
1781 case ID_FIELD_VALID:
1782 set_it(chan, &redirecting, NULL);
1783 break;
1784 case ID_FIELD_INVALID:
1785 break;
1786 default:
1787 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1788 break;
1789 }
1790 ast_party_redirecting_free(&redirecting);
1791 } else {
1792 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1793 }
1794 } else {
1795 ast_log(LOG_ERROR, "Unknown redirecting data type '%s'.\n", data);
1796 }
1797
1798 return 0;
1799}
1800
1802 .name = "CALLERID",
1803 .read = callerid_read,
1804 .read_max = 256,
1805 .write = callerid_write,
1806};
1807
1809 .name = "CONNECTEDLINE",
1810 .read = connectedline_read,
1811 .write = connectedline_write,
1812};
1813
1815 .name = "REDIRECTING",
1816 .read = redirecting_read,
1817 .write = redirecting_write,
1818};
1819
1820/*!
1821 * \internal
1822 * \brief Unload the function module
1823 *
1824 * \retval 0 on success.
1825 * \retval -1 on error.
1826 */
1827static int unload_module(void)
1828{
1832 return 0;
1833}
1834
1835/*!
1836 * \internal
1837 * \brief Load and initialize the function module.
1838 *
1839 * \retval AST_MODULE_LOAD_SUCCESS on success.
1840 * \retval AST_MODULE_LOAD_DECLINE on error.
1841 */
1842static int load_module(void)
1843{
1844 int res;
1845
1849
1850 if (res) {
1851 unload_module();
1853 }
1854
1856}
1857
1858/* Do not wrap the following line. */
1859AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting)");
jack_status_t status
Definition: app_jack.c:149
enum queue_result id
Definition: app_queue.c:1808
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1343
const char * ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data)
Convert redirecting reason value to text code.
Definition: callerid.c:1449
const char * ast_party_name_charset_str(int data)
Convert ast_party_name.char_set value to text code.
Definition: callerid.c:1560
@ AST_REDIRECTING_REASON_UNKNOWN
Definition: callerid.h:499
int ast_party_name_charset_parse(const char *data)
Convert ast_party_name.char_set text code to value (used in config file parsing)
Definition: callerid.c:1534
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
Definition: callerid.c:1423
const char * ast_connected_line_source_name(int data)
Convert connected line update source value to text code.
Definition: callerid.c:1505
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
Definition: callerid.c:1382
int ast_connected_line_source_parse(const char *data)
Convert connected line update source text code to value (used in config file parsing)
Definition: callerid.c:1479
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1292
const char *const subnames[]
Definition: chan_dahdi.c:986
General Asterisk PBX channel definitions.
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide)
Initialize the given dialed structure using the given guide for a set update operation.
Definition: channel.c:1977
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
Definition: channel.c:9145
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition: channel.c:8334
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1848
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2099
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:7393
#define ast_channel_lock(chan)
Definition: channel.h:2970
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Definition: channel.c:2034
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Indicate that the connected line information has changed.
Definition: channel.c:9119
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
Definition: channel.c:2026
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
Definition: channel.c:1998
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation.
Definition: channel.c:2180
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
Definition: channel.c:2042
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Set the dialed information based on another dialed source.
Definition: channel.c:1985
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
Definition: channel.c:10310
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2206
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
Definition: channel.c:2072
#define ast_channel_unlock(chan)
Definition: channel.h:2971
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
char connected
Definition: eagi_proxy.c:82
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static const char name[]
Definition: format_mp3.c:68
REDIRECTING_OPT_ARGS
@ REDIRECTING_OPT_ARG_ARRAY_SIZE
@ REDIRECTING_OPT_DUMMY
static enum ID_FIELD_STATUS party_id_write(struct ast_party_id *id, int argc, char *argv[], const char *value)
static enum ID_FIELD_STATUS party_name_write(struct ast_party_name *name, int argc, char *argv[], const char *value)
static enum ID_FIELD_STATUS party_number_write(struct ast_party_number *number, int argc, char *argv[], const char *value)
static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
ID_FIELD_STATUS
@ ID_FIELD_INVALID
@ ID_FIELD_VALID
@ ID_FIELD_UNKNOWN
CONNECTED_LINE_OPT_ARGS
@ CONNECTED_LINE_OPT_ARG_ARRAY_SIZE
@ CONNECTED_LINE_OPT_DUMMY
REDIRECTING_OPT_FLAGS
@ REDIRECTING_OPT_INHIBIT
static enum ID_FIELD_STATUS party_id_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_id *id)
static int redirecting_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static enum ID_FIELD_STATUS party_subaddress_write(struct ast_party_subaddress *subaddress, int argc, char *argv[], const char *value)
static const struct ast_app_option redirecting_opts[128]
static enum ID_FIELD_STATUS party_name_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_name *name)
static enum ID_FIELD_STATUS party_subaddress_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_subaddress *subaddress)
static const struct ast_app_option connectedline_opts[128]
static enum ID_FIELD_STATUS party_number_read(char *buf, size_t len, int argc, char *argv[], const struct ast_party_number *number)
static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int load_module(void)
static struct ast_custom_function callerid_function
static int connectedline_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function connectedline_function
static int unload_module(void)
CONNECTED_LINE_OPT_FLAGS
@ CONNECTED_LINE_OPT_INHIBIT
static int redirecting_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function redirecting_function
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define END_OPTIONS
#define AST_DEFINE_APP_ARGS_TYPE(type, arglist)
Define a structure type to hold an application's arguments.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define BEGIN_OPTIONS
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:3066
#define LOG_ERROR
#define LOG_WARNING
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define NULL
Definition: resample.c:96
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
Definition: strings.h:186
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
const char * name
Definition: pbx.h:119
Structure used to handle boolean flags.
Definition: utils.h:199
Caller Party information.
Definition: channel.h:420
struct ast_party_id priv
Private caller party ID.
Definition: channel.h:432
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
Dialed/Called Party information.
Definition: channel.h:380
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
Definition: channel.h:393
struct ast_party_dialed::@210 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
Definition: channel.h:388
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:390
Information needed to identify an endpoint in a call.
Definition: channel.h:340
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
Information needed to specify a name in a call.
Definition: channel.h:264
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:279
Information needed to specify a number in a call.
Definition: channel.h:291
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:297
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:512
char * str
a string value for the redirecting reason
Definition: channel.h:509
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:524
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation.
Definition: channel.h:541
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
Definition: channel.h:547
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:544
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
Definition: channel.h:538
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:529
int count
Number of times the call was redirected.
Definition: channel.h:550
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:532
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward)
Definition: channel.h:526
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
Definition: channel.h:535
Information needed to specify a subaddress in a call.
Definition: channel.h:309
unsigned char odd_even_indicator
TRUE if odd number of address signals.
Definition: channel.h:328
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:330
char * str
Malloced subaddress string.
Definition: channel.h:315
int type
Q.931 subaddress type.
Definition: channel.h:322
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:491
Indicate what information in ast_party_redirecting should be set.
Definition: channel.h:557
Number structure.
Definition: app_followme.c:157
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37
const char * args
Utility functions.
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ARRAY_LEN(a)
Definition: utils.h:666