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)
59 #define CID_SIG_BELL 1
61 #define CID_SIG_DTMF 3
62 #define CID_SIG_V23_JP 4
63 #define CID_SIG_SMDI 5
65 #define CID_START_RING 1
66 #define CID_START_POLARITY 2
67 #define CID_START_POLARITY_IN 3
68 #define CID_START_DTMF_NOALERT 4
72 #define CID_MWI_TYPE_SDMF 0x00
74 #define CID_MWI_TYPE_MDMF 0x01
76 #define CID_MWI_TYPE_MDMF_FULL 0x02
78 #define AST_LIN2X(a) ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a)))
79 #define AST_XLAW(a) ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a)))
269 *ci = *cr * cid_di[bit] + *ci *
cid_dr[bit];
272 t = 2.0 - (*cr * *cr + *ci * *ci);
278 #define PUT_BYTE(a) do { \
283 #define PUT_AUDIO_SAMPLE(y) do { \
284 int __sample_idx = (short)(rint(8192.0 * (y))); \
285 *(buf++) = AST_LIN2X(__sample_idx); \
289 #define PUT_CLID_MARKMS do { \
291 for (__clid_x=0;__clid_x<8;__clid_x++) \
292 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \
295 #define PUT_CLID_BAUD(bit) do { \
296 while(scont < clidsb) { \
297 PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, bit)); \
304 #define PUT_CLID(byte) do { \
306 unsigned char b = (byte); \
308 for (z=0;z<8;z++) { \
309 PUT_CLID_BAUD(b & 1); \
317 #define AST_PRES_NUMBER_TYPE 0x03
318 #define AST_PRES_USER_NUMBER_UNSCREENED 0x00
319 #define AST_PRES_USER_NUMBER_PASSED_SCREEN 0x01
320 #define AST_PRES_USER_NUMBER_FAILED_SCREEN 0x02
321 #define AST_PRES_NETWORK_NUMBER 0x03
323 #define AST_PRES_RESTRICTION 0x60
324 #define AST_PRES_ALLOWED 0x00
325 #define AST_PRES_RESTRICTED 0x20
326 #define AST_PRES_UNAVAILABLE 0x40
327 #define AST_PRES_RESERVED 0x60
329 #define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED \
330 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_UNSCREENED)
332 #define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN \
333 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
335 #define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN \
336 (AST_PRES_ALLOWED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
338 #define AST_PRES_ALLOWED_NETWORK_NUMBER \
339 (AST_PRES_ALLOWED | AST_PRES_NETWORK_NUMBER)
341 #define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED \
342 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_UNSCREENED)
344 #define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN \
345 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_PASSED_SCREEN)
347 #define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN \
348 (AST_PRES_RESTRICTED | AST_PRES_USER_NUMBER_FAILED_SCREEN)
350 #define AST_PRES_PROHIB_NETWORK_NUMBER \
351 (AST_PRES_RESTRICTED | AST_PRES_NETWORK_NUMBER)
353 #define AST_PRES_NUMBER_NOT_AVAILABLE \
354 (AST_PRES_UNAVAILABLE | AST_PRES_NETWORK_NUMBER)
AST_CONNECTED_LINE_UPDATE_SOURCE
Connected line update source code.
static char exten[AST_MAX_EXTENSION]
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) ...
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
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_callerid_vmwi_generate(unsigned char *buf, int active, int type, format_t codec, const char *name, const char *number, int flags)
Generate message waiting indicator.
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
int ast_is_shrinkable_phonenumber(const char *exten)
Check if a string consists only of digits and and + # ( ) - . (meaning it can be cleaned with ast_shr...
const char * ast_redirecting_reason_name(int data)
Convert redirecting reason value to text code.
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 ast_callerid_generate(unsigned char *buf, const char *name, const char *number, format_t codec)
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format) ...
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
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 callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec)
Read samples into the state machine.
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec)
Read samples into the state machine.
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)
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, format_t codec)
Generates a CallerID FSK stream in ulaw format suitable for transmission.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const char * ast_redirecting_reason_describe(int data)
Convert redirecting reason value to explanatory string.
int ast_gen_cas(unsigned char *outbuf, int sas, int len, format_t codec)
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, format_t codec)
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) ...
static float callerid_getcarrier(float *cr, float *ci, int bit)
int ast_isphonenumber(const char *n)
Check if a string consists only of digits and + #.
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.
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.
Asterisk internal frame definitions.
const char * ast_party_name_charset_describe(int data)
Convert ast_party_name.char_set value to explanatory string.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)