Asterisk - The Open Source Telephony Project GIT-master-d856a3e
callerid.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2005, Digium, Inc.
5 *
6 * Mark Spencer <markster@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/*! \file
20 * \brief CallerID (and other GR30) management and generation
21 * Includes code and algorithms from the Zapata library.
22 *
23 * \ref CID
24 *
25 */
26
27/*!
28 * \page CID Caller ID names and numbers
29 *
30 * Caller ID names are currently 8 bit characters, propably
31 * ISO8859-1, depending on what your channel drivers handle.
32 *
33 * IAX2 and SIP caller ID names are UTF8
34 * On ISDN Caller ID names are 7 bit, Almost ASCII
35 * (See http://www.zytrax.com/tech/ia5.html )
36 *
37 * \note Asterisk does not currently support SIP utf8 caller ID names or caller ID's.
38 *
39 * \par See also
40 * \arg \ref callerid.c
41 * \arg \ref callerid.h
42 * \arg \ref Def_CallerPres
43 */
44
45#ifndef _ASTERISK_CALLERID_H
46#define _ASTERISK_CALLERID_H
47
48#include "asterisk/format.h"
49
50#define MAX_CALLERID_SIZE 32000
51
52#define CID_PRIVATE_NAME (1 << 0)
53#define CID_PRIVATE_NUMBER (1 << 1)
54#define CID_UNKNOWN_NAME (1 << 2)
55#define CID_UNKNOWN_NUMBER (1 << 3)
56#define CID_MSGWAITING (1 << 4)
57#define CID_NOMSGWAITING (1 << 5)
58#define CID_QUALIFIER (1 << 6)
59
60#define CID_SIG_BELL 1
61#define CID_SIG_V23 2
62#define CID_SIG_DTMF 3
63#define CID_SIG_V23_JP 4
64#define CID_SIG_SMDI 5
65
66#define CID_START_RING 1
67#define CID_START_POLARITY 2
68#define CID_START_POLARITY_IN 3
69#define CID_START_DTMF_NOALERT 4
70
71/* Caller ID message formats */
72/*! SDMF - number only */
73#define CID_TYPE_SDMF 0x00
74/*! MDMF - name, number, etc. */
75#define CID_TYPE_MDMF 0x01
76
77/* defines dealing with message waiting indication generation */
78/*! MWI SDMF format */
79#define CID_MWI_TYPE_SDMF 0x00
80/*! MWI MDMF format -- generate only MWI field */
81#define CID_MWI_TYPE_MDMF 0x01
82/*! MWI MDMF format -- generate name, callerid, date and MWI fields */
83#define CID_MWI_TYPE_MDMF_FULL 0x02
84
85#define AST_LIN2X(a) ((ast_format_cmp(codec, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) ? (AST_LIN2A(a)) : (AST_LIN2MU(a)))
86#define AST_XLAW(a) ((ast_format_cmp(codec, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) ? (AST_ALAW(a)) : (AST_MULAW(a)))
87
88
89struct callerid_state;
90typedef struct callerid_state CIDSTATE;
91
92/*! \brief CallerID Initialization
93 * \par
94 * Initializes the callerid system. Mostly stuff for inverse FFT
95 */
96void callerid_init(void);
97
98/*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.
99 * \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own.
100 * "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.
101 * \param number Use NULL for no number or "P" for "private"
102 * \param name name to be used
103 * \param flags passed flags
104 * \param callwaiting callwaiting flag
105 * \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW
106 * \details
107 * This function creates a stream of callerid (a callerid spill) data in ulaw format.
108 * \return It returns the size
109 * (in bytes) of the data (if it returns a size of 0, there is probably an error)
110 */
111int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec);
112
113/*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.
114 * \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own.
115 * "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.
116 * \param number Use NULL for no number or "P" for "private"
117 * \param name name to be used
118 * \param ddn Dialable Directory Number (or NULL)
119 * \param redirecting Redirecting reason
120 * \param flags passed flags
121 * \param format Message format
122 * \param callwaiting callwaiting flag
123 * \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW
124 * \details
125 * This function creates a stream of callerid (a callerid spill) data in ulaw format.
126 * \return It returns the size
127 * (in bytes) of the data (if it returns a size of 0, there is probably an error)
128 */
129int callerid_full_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting,
130 int flags, int format, int callwaiting, struct ast_format *codec);
131
132/*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.
133 * \param buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own.
134 * "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.
135 * \param number Use NULL for no number or "P" for "private"
136 * \param name name to be used
137 * \param ddn Dialable Directory Number (or NULL)
138 * \param redirecting Redirecting reason
139 * \param flags passed flags
140 * \param format Message format
141 * \param callwaiting callwaiting flag
142 * \param codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW
143 * \param tz TZ-format time zone to use for date/time (NULL for system default)
144 * \details
145 * This function creates a stream of callerid (a callerid spill) data in ulaw format.
146 * \return It returns the size
147 * (in bytes) of the data (if it returns a size of 0, there is probably an error)
148 */
149int callerid_full_tz_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting,
150 int flags, int format, int callwaiting, struct ast_format *codec, const char *tz);
151
152/*! \brief Create a callerID state machine
153 * \param cid_signalling Type of signalling in use
154 *
155 * \details
156 * This function returns a malloc'd instance of the callerid_state data structure.
157 * \return Returns a pointer to a malloc'd callerid_state structure, or NULL on error.
158 */
159struct callerid_state *callerid_new(int cid_signalling);
160
161/*! \brief Read samples into the state machine.
162 * \param cid Which state machine to act upon
163 * \param ubuf containing your samples
164 * \param samples number of samples contained within the buffer.
165 * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
166 *
167 * \details
168 * Send received audio to the Caller*ID demodulator.
169 * \retval -1 on error
170 * \retval 0 for "needs more samples"
171 * \retval 1 if the CallerID spill reception is complete.
172 */
173int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec);
174
175/*! \brief Read samples into the state machine.
176 * \param cid Which state machine to act upon
177 * \param ubuf containing your samples
178 * \param samples number of samples contained within the buffer.
179 * \param codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
180 *
181 * \details
182 * Send received audio to the Caller*ID demodulator (for japanese style lines).
183 * \retval -1 on error
184 * \retval 0 for "needs more samples"
185 * \retval 1 if the CallerID spill reception is complete.
186 */
187int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec);
188
189/*! \brief Extract info out of callerID state machine. Flags are listed above
190 * \param cid Callerid state machine to act upon
191 * \param number Pass the address of a pointer-to-char (will contain the phone number)
192 * \param name Pass the address of a pointer-to-char (will contain the name)
193 * \param flags Pass the address of an int variable (will contain the various callerid flags - presentation flags and call qualifier)
194 *
195 * \details
196 * This function extracts a callerid string out of a callerid_state state machine.
197 * If no number is found, *number will be set to NULL. Likewise for the name.
198 * Flags can contain any of the following: CID_PRIVATE_NAME, CID_PRIVATE_NUMBER, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, CID_MSGWAITING, CID_NOMSGWAITING, CID_QUALIFIER
199 */
200void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags);
201
202/*! \brief Extract info out of callerID state machine. Flags are listed above
203 * \param cid Callerid state machine to act upon
204 * \param[out] number Pass the address of a pointer-to-char (will contain the phone number)
205 * \param[out] name Pass the address of a pointer-to-char (will contain the name)
206 * \param[out] flags Pass the address of an int variable (will contain the various callerid flags)
207 * \param[out] redirecting Pass the address of an int variable (will contain the redirecting reason, if received - presentation flags and call qualifier)
208 *
209 * \details
210 * This function extracts a callerid string out of a callerid_state state machine.
211 * If no number is found, *number will be set to NULL. Likewise for the name.
212 * Flags can contain any of the following: CID_PRIVATE_NAME, CID_PRIVATE_NUMBER, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, CID_MSGWAITING, CID_NOMSGWAITING, CID_QUALIFIER
213 */
214void callerid_get_with_redirecting(struct callerid_state *cid, char **name, char **number, int *flags, int *redirecting);
215
216/*!
217 * \brief Get and parse DTMF-based callerid
218 * \param cidstring The actual transmitted string.
219 * \param number The cid number is returned here.
220 * \param flags The cid flags are returned here.
221 */
222void callerid_get_dtmf(char *cidstring, char *number, int *flags);
223
224/*! \brief This function frees callerid_state cid.
225 * \param cid This is the callerid_state state machine to free
226 */
227void callerid_free(struct callerid_state *cid);
228
229/*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
230 * \param buf buffer for output samples. See callerid_generate() for details regarding buffer.
231 * \param name Caller-ID Name
232 * \param number Caller-ID Number
233 * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
234 *
235 * \details
236 * Acts like callerid_generate except uses an asterisk format callerid string.
237 */
238int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
239
240/*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
241 * \param buf buffer for output samples. See callerid_generate() for details regarding buffer.
242 * \param name Caller-ID Name
243 * \param number Caller-ID Number
244 * \param ddn Dialable Directory Number (or NULL)
245 * \param redirecting Redirecting Reason (-1 if N/A)
246 * \param pres Presentation (0 for default)
247 * \param qualifier Call Qualifier (0 for no, 1 for yes)
248 * \param format Message Format
249 * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
250 *
251 * \details
252 * Like ast_callerid_generate but with additional parameters.
253 */
254int ast_callerid_full_generate(unsigned char *buf, const char *name, const char *number,
255 const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec);
256
257/*! \brief Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
258 * \param buf buffer for output samples. See callerid_generate() for details regarding buffer.
259 * \param name Caller-ID Name
260 * \param number Caller-ID Number
261 * \param ddn Dialable Directory Number (or NULL)
262 * \param redirecting Redirecting Reason (-1 if N/A)
263 * \param pres Presentation (0 for default)
264 * \param qualifier Call Qualifier (0 for no, 1 for yes)
265 * \param format Message Format
266 * \param codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
267 * \param tz TZ-format time zone name to use for date/time (NULL for system default)
268 *
269 * \details
270 * Like ast_callerid_generate but with additional parameters.
271 */
272int ast_callerid_full_tz_generate(unsigned char *buf, const char *name, const char *number,
273 const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec, const char *tz);
274
275/*!
276 * \brief Generate message waiting indicator
277 * \param buf
278 * \param active The message indicator state
279 * -- either 0 no messages in mailbox or 1 messages in mailbox
280 * \param type Format of message (any of CID_MWI_TYPE_*)
281 * \param codec
282 * \param name
283 * \param number
284 * \param flags
285 * \see callerid_generate() for more info as it uses the same encoding
286 * \version 1.6.1 changed mdmf parameter to type, added name, number and flags for caller id message generation
287 */
288int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec, const char *name,
289 const char *number, int flags);
290
291/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
292 * \see ast_callerid_generate() for other details
293 */
294int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec);
295
296/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
297 * \see ast_callerid_generate() for other details
298 */
299int ast_callerid_callwaiting_full_generate(unsigned char *buf, const char *name, const char *number,
300 const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec);
301
302/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
303 * \param tz TZ-format time zone for date/time (NULL for system default)
304 * \see ast_callerid_generate() for other details
305 */
306int ast_callerid_callwaiting_full_tz_generate(unsigned char *buf, const char *name, const char *number,
307 const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec, const char *tz);
308
309/*! \brief Destructively parse inbuf into name and location (or number)
310 * \details
311 * Parses callerid stream from inbuf and changes into useable form, outputted in name and location.
312 * \param instr buffer of callerid stream (in audio form) to be parsed. Warning, data in buffer is changed.
313 * \param name address of a pointer-to-char for the name value of the stream.
314 * \param location address of a pointer-to-char for the phone number value of the stream.
315 * \note XXX 'name' is not parsed consistently e.g. we have
316 * input location name
317 * " foo bar " <123> 123 ' foo bar ' (with spaces around)
318 * " foo bar " NULL 'foo bar' (without spaces around)
319 * The parsing of leading and trailing space/quotes should be more consistent.
320 * \retval 0 on success
321 * \retval -1 on failure
322 */
323int ast_callerid_parse(char *instr, char **name, char **location);
324
325/*!
326 * \brief Generate a CAS (CPE Alert Signal) tone for 'n' samples
327 * \param outbuf Allocated buffer for data. Must be at least 2400 bytes unless no SAS is desired
328 * \param sas Non-zero if CAS should be preceeded by SAS
329 * \param len How many samples to generate.
330 * \param codec Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
331 * \retval -1 on error (if len is less than 2400)
332 * \retval 0 on success
333 */
334int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec);
335
336/*!
337 * \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
338 * \param n The number to be stripped/shrunk
339 */
340void ast_shrink_phone_number(char *n);
341
342/*!
343 * \brief Check if a string consists only of digits and + \#
344 * \param n number to be checked.
345 * \retval 0 if \p n is a number
346 * \retval 1 if not
347 */
348int ast_isphonenumber(const char *n);
349
350/*!
351 * \brief Check if a string consists only of digits and + \# ( ) - .
352 * (meaning it can be cleaned with ast_shrink_phone_number)
353 * \param exten The extension (or URI) to be checked.
354 * \retval 1 if \p exten is valid AST shrinkable phone number
355 * \retval 0 if not
356 */
357int ast_is_shrinkable_phonenumber(const char *exten);
358
359int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen);
360
361char *ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown);
362
363/*
364 * Caller*ID and other GR-30 compatible generation
365 * routines (used by ADSI for example)
366 */
367
368extern float cid_dr[4];
369extern float cid_di[4];
370extern float clidsb;
371
372static inline float callerid_getcarrier(float *cr, float *ci, int bit)
373{
374 /* Move along. There's nothing to see here... */
375 float t;
376 t = *cr * cid_dr[bit] - *ci * cid_di[bit];
377 *ci = *cr * cid_di[bit] + *ci * cid_dr[bit];
378 *cr = t;
379
380 t = 2.0 - (*cr * *cr + *ci * *ci);
381 *cr *= t;
382 *ci *= t;
383 return *cr;
384}
385
386#define PUT_BYTE(a) do { \
387 *(buf++) = (a); \
388 bytes++; \
389} while(0)
390
391#define PUT_AUDIO_SAMPLE(y) do { \
392 int __sample_idx = (short)(rint(8192.0 * (y))); \
393 *(buf++) = AST_LIN2X(__sample_idx); \
394 bytes++; \
395} while(0)
396
397#define PUT_CLID_MARKMS do { \
398 int __clid_x; \
399 for (__clid_x=0;__clid_x<8;__clid_x++) \
400 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \
401} while(0)
402
403#define PUT_CLID_BAUD(bit) do { \
404 while(scont < clidsb) { \
405 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, bit)); \
406 scont += 1.0; \
407 } \
408 scont -= clidsb; \
409} while(0)
410
411
412#define PUT_CLID(byte) do { \
413 int z; \
414 unsigned char b = (byte); \
415 PUT_CLID_BAUD(0); /* Start bit */ \
416 for (z=0;z<8;z++) { \
417 PUT_CLID_BAUD(b & 1); \
418 b >>= 1; \
419 } \
420 PUT_CLID_BAUD(1); /* Stop bit */ \
421} while(0)
422
423/* Various defines and bits for handling PRI- and SS7-type restriction */
424
425#define AST_PRES_NUMBER_TYPE 0x03
426#define AST_PRES_USER_NUMBER_UNSCREENED 0x00
427#define AST_PRES_USER_NUMBER_PASSED_SCREEN 0x01
428#define AST_PRES_USER_NUMBER_FAILED_SCREEN 0x02
429#define AST_PRES_NETWORK_NUMBER 0x03
430
431#define AST_PRES_RESTRICTION 0x60
432#define AST_PRES_ALLOWED 0x00
433#define AST_PRES_RESTRICTED 0x20
434#define AST_PRES_UNAVAILABLE 0x40
435#define AST_PRES_RESERVED 0x60
436
437#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
438 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED)
439
440#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
441 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
442
443#define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
444 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
445
446#define AST_PRES_ALLOWED_NETWORK_NUMBER \
447 (AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER)
448
449#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
450 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED)
451
452#define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
453 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
454
455#define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
456 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
457
458#define AST_PRES_PROHIB_NETWORK_NUMBER \
459 (AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER)
460
461#define AST_PRES_NUMBER_NOT_AVAILABLE \
462 (AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER)
463
464int ast_parse_caller_presentation(const char *data);
465const char *ast_describe_caller_presentation(int data);
466const char *ast_named_caller_presentation(int data);
467
468/*!
469 * \page Def_CallerPres Caller ID Presentation
470 *
471 * Caller ID presentation values are used to set properties to a
472 * caller ID in PSTN networks, and as RPID value in SIP transactions.
473 *
474 * The following values are available to use:
475 * \arg \b Defined value, text string in config file, explanation
476 *
477 * \arg \b AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", Presentation Allowed, Not Screened,
478 * \arg \b AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", Presentation Allowed, Passed Screen,
479 * \arg \b AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", Presentation Allowed, Failed Screen,
480 * \arg \b AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", Presentation Allowed, Network Number,
481 * \arg \b AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", Presentation Prohibited, Not Screened,
482 * \arg \b AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", Presentation Prohibited, Passed Screen,
483 * \arg \b AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", Presentation Prohibited, Failed Screen,
484 * \arg \b AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", Presentation Prohibited, Network Number,
485 *
486 * \par References
487 * \arg \ref callerid.h Definitions
488 * \arg \ref callerid.c Functions
489 * \arg \ref CID Caller ID names and numbers
490 */
491
492/*!
493 * \brief redirecting reason codes.
494 *
495 * This list attempts to encompass redirecting reasons
496 * as defined by several channel technologies.
497 */
510 AST_REDIRECTING_REASON_CALL_FWD_DTE, /* This is something defined in Q.931, and no I don't know what it means */
512};
513
514/*!
515 * \since 1.8
516 * \brief Convert redirecting reason text code to value (used in config file parsing)
517 *
518 * \param data text string from config file
519 *
520 * \retval Q931_REDIRECTING_REASON from callerid.h
521 * \retval -1 if not in table
522 */
523int ast_redirecting_reason_parse(const char *data);
524
525/*!
526 * \since 1.8
527 * \brief Convert redirecting reason value to explanatory string
528 *
529 * \param data Q931_REDIRECTING_REASON from callerid.h
530 *
531 * \return string for human presentation
532 */
533const char *ast_redirecting_reason_describe(int data);
534
536
537/*!
538 * \since 1.8
539 * \brief Convert redirecting reason value to text code
540 *
541 * \param data ast_party_redirecting_reason structure from channel.h
542 *
543 * \return string for config file
544 */
545const char *ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data);
546
547/*!
548 * \brief Connected line update source code
549 */
551 /*! Update for unknown reason (May be interpreted to mean from answer) */
553 /*! Update from normal call answering */
555 /*! Update from call diversion (Deprecated, use REDIRECTING updates instead.) */
557 /*! Update from call transfer(active) (Party has already answered) */
559 /*! Update from call transfer(alerting) (Party has not answered yet) */
562
563/*!
564 * \since 1.8
565 * \brief Convert connected line update source text code to value (used in config file parsing)
566 *
567 * \param data text string from config file
568 *
569 * \retval AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h
570 * \retval -1 if not in table
571 */
572int ast_connected_line_source_parse(const char *data);
573
574/*!
575 * \since 1.8
576 * \brief Convert connected line update source value to explanatory string
577 *
578 * \param data AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h
579 *
580 * \return string for human presentation
581 */
582const char *ast_connected_line_source_describe(int data);
583
584/*!
585 * \since 1.8
586 * \brief Convert connected line update source value to text code
587 *
588 * \param data AST_CONNECTED_LINE_UPDATE_SOURCE from callerid.h
589 *
590 * \return string for config file
591 */
592const char *ast_connected_line_source_name(int data);
593
594/*!
595 * \since 1.8
596 * \brief Convert ast_party_name.char_set text code to value (used in config file parsing)
597 *
598 * \param data text string from config file
599 *
600 * \retval AST_PARTY_CHAR_SET from channel.h
601 * \retval -1 if not in table
602 */
603int ast_party_name_charset_parse(const char *data);
604
605/*!
606 * \since 1.8
607 * \brief Convert ast_party_name.char_set value to explanatory string
608 *
609 * \param data AST_PARTY_CHAR_SET from channel.h
610 *
611 * \return string for human presentation
612 */
613const char *ast_party_name_charset_describe(int data);
614
615/*!
616 * \since 1.8
617 * \brief Convert ast_party_name.char_set value to text code
618 *
619 * \param data AST_PARTY_CHAR_SET from channel.h
620 *
621 * \return string for config file
622 */
623const char *ast_party_name_charset_str(int data);
624
625
626#endif /* _ASTERISK_CALLERID_H */
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
Definition: callerid.c:1273
int ast_callerid_callwaiting_full_generate(unsigned char *buf, const char *name, const char *number, const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec)
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
Definition: callerid.c:1253
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1343
int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec)
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
Definition: callerid.c:271
const char * ast_connected_line_source_describe(int data)
Convert connected line update source value to explanatory string.
Definition: callerid.c:1492
int ast_callerid_full_generate(unsigned char *buf, const char *name, const char *number, const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec)
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
Definition: callerid.c:1247
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
Definition: callerid.c:316
float cid_dr[4]
Definition: callerid.c:65
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec, const char *name, const char *number, int flags)
Generate message waiting indicator.
Definition: callerid.c:952
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1162
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, struct ast_format *codec)
Generates a CallerID FSK stream in ulaw format suitable for transmission.
Definition: callerid.c:1039
void callerid_free(struct callerid_state *cid)
This function frees callerid_state cid.
Definition: callerid.c:833
void callerid_get_with_redirecting(struct callerid_state *cid, char **name, char **number, int *flags, int *redirecting)
Extract info out of callerID state machine. Flags are listed above.
Definition: callerid.c:189
const char * ast_describe_caller_presentation(int data)
Convert caller ID pres value to explanatory string.
Definition: callerid.c:1364
const char * ast_party_name_charset_describe(int data)
Convert ast_party_name.char_set value to explanatory string.
Definition: callerid.c:1547
const char * ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data)
Convert redirecting reason value to text code.
Definition: callerid.c:1449
AST_CONNECTED_LINE_UPDATE_SOURCE
Connected line update source code.
Definition: callerid.h:550
@ AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER
Definition: callerid.h:558
@ AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN
Definition: callerid.h:552
@ AST_CONNECTED_LINE_UPDATE_SOURCE_DIVERSION
Definition: callerid.h:556
@ AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING
Definition: callerid.h:560
@ AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER
Definition: callerid.h:554
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
Definition: callerid.c:1101
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
Definition: callerid.c:1242
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
redirecting reason codes.
Definition: callerid.h:498
@ AST_REDIRECTING_REASON_AWAY
Definition: callerid.h:509
@ AST_REDIRECTING_REASON_UNKNOWN
Definition: callerid.h:499
@ AST_REDIRECTING_REASON_SEND_TO_VM
Definition: callerid.h:511
@ AST_REDIRECTING_REASON_NO_ANSWER
Definition: callerid.h:501
@ AST_REDIRECTING_REASON_DO_NOT_DISTURB
Definition: callerid.h:505
@ AST_REDIRECTING_REASON_FOLLOW_ME
Definition: callerid.h:507
@ AST_REDIRECTING_REASON_DEFLECTION
Definition: callerid.h:506
@ AST_REDIRECTING_REASON_UNAVAILABLE
Definition: callerid.h:502
@ AST_REDIRECTING_REASON_UNCONDITIONAL
Definition: callerid.h:503
@ AST_REDIRECTING_REASON_CALL_FWD_DTE
Definition: callerid.h:510
@ AST_REDIRECTING_REASON_OUT_OF_ORDER
Definition: callerid.h:508
@ AST_REDIRECTING_REASON_TIME_OF_DAY
Definition: callerid.h:504
@ AST_REDIRECTING_REASON_USER_BUSY
Definition: callerid.h:500
static float callerid_getcarrier(float *cr, float *ci, int bit)
Definition: callerid.h:372
struct callerid_state * callerid_new(int cid_signalling)
Create a callerID state machine.
Definition: callerid.c:130
void callerid_init(void)
CallerID Initialization.
Definition: callerid.c:116
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
Definition: callerid.c:570
int callerid_full_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting, int flags, int format, int callwaiting, struct ast_format *codec)
Generates a CallerID FSK stream in ulaw format suitable for transmission.
Definition: callerid.c:1044
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
void callerid_get_dtmf(char *cidstring, char *number, int *flags)
Get and parse DTMF-based callerid.
Definition: callerid.c:211
int ast_isphonenumber(const char *n)
Check if a string consists only of digits and + #.
Definition: callerid.c:1152
const char * ast_redirecting_reason_describe(int data)
Convert redirecting reason value to explanatory string.
Definition: callerid.c:1436
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_full_tz_generate(unsigned char *buf, const char *name, const char *number, const char *ddn, int redirecting, int pres, int qualifier, int format, struct ast_format *codec, const char *tz)
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
Definition: callerid.c:1260
void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags)
Extract info out of callerID state machine. Flags are listed above.
Definition: callerid.c:205
float cid_di[4]
Definition: callerid.c:65
int callerid_full_tz_generate(unsigned char *buf, const char *number, const char *name, const char *ddn, int redirecting, int flags, int format, int callwaiting, struct ast_format *codec, const char *tz)
Generates a CallerID FSK stream in ulaw format suitable for transmission.
Definition: callerid.c:1051
int ast_is_shrinkable_phonenumber(const char *exten)
Check if a string consists only of digits and + # ( ) - . (meaning it can be cleaned with ast_shrink_...
Definition: callerid.c:1157
float clidsb
Definition: callerid.c:66
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
Definition: callerid.c:1292
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format)
Definition: callerid.c:1237
int ast_callerid_callwaiting_full_tz_generate(unsigned char *buf, const char *name, const char *number, const char *ddn, int redirecting, int pres, int qualifier, struct ast_format *codec, const char *tz)
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
Definition: callerid.c:1266
static char * tz
Definition: cdr_pgsql.c:71
static const char type[]
Definition: chan_ooh323.c:109
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
Media Format API.
static const char name[]
Definition: format_mp3.c:68
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Definition of a media format.
Definition: format.c:43
Redirecting reason information.
Definition: channel.h:503
int redirecting
Definition: callerid.c:56
Number structure.
Definition: app_followme.c:154
static struct ast_codec unknown