45 #ifndef _ASTERISK_CALLERID_H
46 #define _ASTERISK_CALLERID_H
50 #define MAX_CALLERID_SIZE 32000
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)
60 #define CID_SIG_BELL 1
62 #define CID_SIG_DTMF 3
63 #define CID_SIG_V23_JP 4
64 #define CID_SIG_SMDI 5
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
73 #define CID_TYPE_SDMF 0x00
75 #define CID_TYPE_MDMF 0x01
79 #define CID_MWI_TYPE_SDMF 0x00
81 #define CID_MWI_TYPE_MDMF 0x01
83 #define CID_MWI_TYPE_MDMF_FULL 0x02
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)))
130 int flags,
int format,
int callwaiting,
struct ast_format *codec);
150 int flags,
int format,
int callwaiting,
struct ast_format *codec,
const char *tz);
255 const char *ddn,
int redirecting,
int pres,
int qualifier,
int format,
struct ast_format *codec);
273 const char *ddn,
int redirecting,
int pres,
int qualifier,
int format,
struct ast_format *codec,
const char *tz);
289 const char *
number,
int flags);
300 const char *ddn,
int redirecting,
int pres,
int qualifier,
struct ast_format *codec);
307 const char *ddn,
int redirecting,
int pres,
int qualifier,
struct ast_format *codec,
const char *tz);
359 int ast_callerid_split(
const char *src,
char *name,
int namelen,
char *num,
int numlen);
361 char *ast_callerid_merge(
char *buf,
int bufsiz,
const char *name,
const char *num,
const char *unknown);
368 extern float cid_dr[4];
369 extern float cid_di[4];
372 static inline float callerid_getcarrier(
float *cr,
float *ci,
int bit)
376 t = *cr * cid_dr[bit] - *ci * cid_di[bit];
377 *ci = *cr * cid_di[bit] + *ci * cid_dr[bit];
380 t = 2.0 - (*cr * *cr + *ci * *ci);
386 #define PUT_BYTE(a) do { \
391 #define PUT_AUDIO_SAMPLE(y) do { \
392 int __sample_idx = (short)(rint(8192.0 * (y))); \
393 *(buf++) = AST_LIN2X(__sample_idx); \
397 #define PUT_CLID_MARKMS do { \
399 for (__clid_x=0;__clid_x<8;__clid_x++) \
400 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \
403 #define PUT_CLID_BAUD(bit) do { \
404 while(scont < clidsb) { \
405 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, bit)); \
412 #define PUT_CLID(byte) do { \
414 unsigned char b = (byte); \
416 for (z=0;z<8;z++) { \
417 PUT_CLID_BAUD(b & 1); \
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
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
437 #define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
438 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED)
440 #define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
441 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
443 #define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
444 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
446 #define AST_PRES_ALLOWED_NETWORK_NUMBER \
447 (AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER)
449 #define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
450 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED)
452 #define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
453 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
455 #define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
456 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
458 #define AST_PRES_PROHIB_NETWORK_NUMBER \
459 (AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER)
461 #define AST_PRES_NUMBER_NOT_AVAILABLE \
462 (AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER)
499 AST_REDIRECTING_REASON_UNKNOWN,
500 AST_REDIRECTING_REASON_USER_BUSY,
501 AST_REDIRECTING_REASON_NO_ANSWER,
502 AST_REDIRECTING_REASON_UNAVAILABLE,
503 AST_REDIRECTING_REASON_UNCONDITIONAL,
504 AST_REDIRECTING_REASON_TIME_OF_DAY,
505 AST_REDIRECTING_REASON_DO_NOT_DISTURB,
506 AST_REDIRECTING_REASON_DEFLECTION,
507 AST_REDIRECTING_REASON_FOLLOW_ME,
508 AST_REDIRECTING_REASON_OUT_OF_ORDER,
509 AST_REDIRECTING_REASON_AWAY,
510 AST_REDIRECTING_REASON_CALL_FWD_DTE,
511 AST_REDIRECTING_REASON_SEND_TO_VM,
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) ...
AST_CONNECTED_LINE_UPDATE_SOURCE
Connected line update source code.
const char * ast_named_caller_presentation(int data)
Convert caller ID pres value to text code.
int ast_connected_line_source_parse(const char *data)
Convert connected line update source text code to value (used in config file parsing) ...
const char * ast_describe_caller_presentation(int data)
Convert caller ID pres value to explanatory string.
const char * ast_connected_line_source_name(int data)
Convert connected line update source value to text code.
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
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) ...
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.
const char * ast_redirecting_reason_name(const struct ast_party_redirecting_reason *data)
Convert redirecting reason value to text code.
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_...
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) ...
void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags)
Extract info out of callerID state machine. Flags are listed above.
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.
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
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.
void callerid_init(void)
CallerID Initialization.
int ast_party_name_charset_parse(const char *data)
Convert ast_party_name.char_set text code to value (used in config file parsing)
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) ...
AST_REDIRECTING_REASON
redirecting reason codes.
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Redirecting reason information.
const char * ast_redirecting_reason_describe(int data)
Convert redirecting reason value to explanatory string.
int ast_isphonenumber(const char *n)
Check if a string consists only of digits and + #.
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) ...
const char * ast_party_name_charset_str(int data)
Convert ast_party_name.char_set value to text code.
void callerid_free(struct callerid_state *cid)
This function frees callerid_state cid.
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.
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.
const char * ast_connected_line_source_describe(int data)
Convert connected line update source value to explanatory string.
void callerid_get_dtmf(char *cidstring, char *number, int *flags)
Get and parse DTMF-based callerid.
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
struct callerid_state * callerid_new(int cid_signalling)
Create a callerID state machine.
const char * ast_party_name_charset_describe(int data)
Convert ast_party_name.char_set value to explanatory string.
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
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) ...
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.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)