Go to the source code of this file.
Defines | |
#define | AST_LIN2X(a) ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a))) |
#define | AST_PRES_ALLOWED 0x00 |
#define | AST_PRES_ALLOWED_NETWORK_NUMBER AST_PRES_NETWORK_NUMBER + AST_PRES_ALLOWED |
#define | AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_ALLOWED |
#define | AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_ALLOWED |
#define | AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_ALLOWED |
#define | AST_PRES_NETWORK_NUMBER 0x03 |
#define | AST_PRES_NUMBER_NOT_AVAILABLE AST_PRES_NETWORK_NUMBER + AST_PRES_UNAVAILABLE |
#define | AST_PRES_NUMBER_TYPE 0x03 |
#define | AST_PRES_PROHIB_NETWORK_NUMBER AST_PRES_NETWORK_NUMBER + AST_PRES_RESTRICTED |
#define | AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_RESTRICTED |
#define | AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_RESTRICTED |
#define | AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_RESTRICTED |
#define | AST_PRES_RESERVED 0x60 |
#define | AST_PRES_RESTRICTED 0x20 |
#define | AST_PRES_RESTRICTION 0x60 |
#define | AST_PRES_UNAVAILABLE 0x40 |
#define | AST_PRES_USER_NUMBER_FAILED_SCREEN 0x02 |
#define | AST_PRES_USER_NUMBER_PASSED_SCREEN 0x01 |
#define | AST_PRES_USER_NUMBER_UNSCREENED 0x00 |
#define | AST_XLAW(a) ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a))) |
#define | CID_PRIVATE_NAME (1 << 0) |
#define | CID_PRIVATE_NUMBER (1 << 1) |
#define | CID_SIG_BELL 1 |
#define | CID_SIG_DTMF 3 |
#define | CID_SIG_SMDI 5 |
#define | CID_SIG_V23 2 |
#define | CID_SIG_V23_JP 4 |
#define | CID_START_DTMF_NOALERT 4 |
#define | CID_START_POLARITY 2 |
#define | CID_START_RING 1 |
#define | CID_UNKNOWN_NAME (1 << 2) |
#define | CID_UNKNOWN_NUMBER (1 << 3) |
#define | MAX_CALLERID_SIZE 32000 |
#define | PUT_AUDIO_SAMPLE(y) |
#define | PUT_BYTE(a) |
#define | PUT_CLID(byte) |
#define | PUT_CLID_BAUD(bit) |
#define | PUT_CLID_MARKMS |
Typedefs | |
typedef callerid_state | CIDSTATE |
Functions | |
int | ast_callerid_callwaiting_generate (unsigned char *buf, const char *name, const char *number, int codec) |
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) See ast_callerid_generate() for other details. | |
int | ast_callerid_generate (unsigned char *buf, const char *name, const char *number, int 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) |
int | ast_callerid_parse (char *instr, char **name, char **location) |
Destructively parse inbuf into name and location (or number) Parses callerid stream from inbuf and changes into useable form, outputed in name and location. | |
int | ast_callerid_split (const char *src, char *name, int namelen, char *num, int numlen) |
int | ast_callerid_vmwi_generate (unsigned char *buf, int active, int mdmf, int codec) |
Generate message waiting indicator (stutter tone). | |
const char * | ast_describe_caller_presentation (int data) |
Convert caller ID pres value to explanatory string. | |
int | ast_gen_cas (unsigned char *outbuf, int sas, int len, int codec) |
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_shrink_phone_number). | |
int | ast_isphonenumber (const char *n) |
Check if a string consists only of digits and + #. | |
int | ast_parse_caller_presentation (const char *data) |
Convert caller ID text code to value used in config file parsing. | |
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... | |
int | callerid_feed (struct callerid_state *cid, unsigned char *ubuf, int samples, int codec) |
Read samples into the state machine. | |
int | callerid_feed_jp (struct callerid_state *cid, unsigned char *ubuf, int samples, int codec) |
Read samples into the state machine. | |
void | callerid_free (struct callerid_state *cid) |
Free a callerID state. | |
int | callerid_generate (unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec) |
Generates a CallerID FSK stream in ulaw format suitable for transmission. | |
void | callerid_get (struct callerid_state *cid, char **number, char **name, int *flags) |
Extract info out of callerID state machine. Flags are listed above. | |
void | callerid_get_dtmf (char *cidstring, char *number, int *flags) |
static float | callerid_getcarrier (float *cr, float *ci, int bit) |
void | callerid_init (void) |
CallerID Initialization. | |
callerid_state * | callerid_new (int cid_signalling) |
Create a callerID state machine. | |
Variables | |
float | cid_di [4] |
float | cid_dr [4] |
float | clidsb |
Definition in file callerid.h.
#define AST_LIN2X | ( | a | ) | ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a))) |
#define AST_PRES_ALLOWED 0x00 |
Definition at line 281 of file callerid.h.
Referenced by build_rpid(), cb_events(), and initreqprep().
#define AST_PRES_ALLOWED_NETWORK_NUMBER AST_PRES_NETWORK_NUMBER + AST_PRES_ALLOWED |
#define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_ALLOWED |
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_ALLOWED |
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_ALLOWED |
#define AST_PRES_NETWORK_NUMBER 0x03 |
#define AST_PRES_NUMBER_NOT_AVAILABLE AST_PRES_NETWORK_NUMBER + AST_PRES_UNAVAILABLE |
Definition at line 310 of file callerid.h.
Referenced by build_rpid(), check_access(), and iax2_call().
#define AST_PRES_NUMBER_TYPE 0x03 |
Definition at line 274 of file callerid.h.
#define AST_PRES_PROHIB_NETWORK_NUMBER AST_PRES_NETWORK_NUMBER + AST_PRES_RESTRICTED |
#define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_RESTRICTED |
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_RESTRICTED |
#define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_RESTRICTED |
#define AST_PRES_RESERVED 0x60 |
Definition at line 284 of file callerid.h.
#define AST_PRES_RESTRICTED 0x20 |
#define AST_PRES_RESTRICTION 0x60 |
#define AST_PRES_UNAVAILABLE 0x40 |
Definition at line 283 of file callerid.h.
Referenced by cb_events(), privacy_exec(), and update_config().
#define AST_PRES_USER_NUMBER_FAILED_SCREEN 0x02 |
#define AST_PRES_USER_NUMBER_PASSED_SCREEN 0x01 |
#define AST_PRES_USER_NUMBER_UNSCREENED 0x00 |
#define AST_XLAW | ( | a | ) | ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a))) |
#define CID_PRIVATE_NAME (1 << 0) |
Definition at line 48 of file callerid.h.
Referenced by callerid_feed(), callerid_genmsg(), and callerid_get().
#define CID_PRIVATE_NUMBER (1 << 1) |
Definition at line 49 of file callerid.h.
Referenced by callerid_feed(), callerid_genmsg(), callerid_get(), and callerid_get_dtmf().
#define CID_SIG_BELL 1 |
Definition at line 53 of file callerid.h.
Referenced by dahdi_chan_conf_default(), and process_dahdi().
#define CID_SIG_DTMF 3 |
#define CID_SIG_SMDI 5 |
#define CID_SIG_V23 2 |
#define CID_SIG_V23_JP 4 |
#define CID_START_DTMF_NOALERT 4 |
Definition at line 61 of file callerid.h.
Referenced by dahdi_read(), do_monitor(), process_dahdi(), and ss_thread().
#define CID_START_POLARITY 2 |
Definition at line 60 of file callerid.h.
Referenced by dahdi_read(), handle_init_event(), process_dahdi(), and ss_thread().
#define CID_START_RING 1 |
Definition at line 59 of file callerid.h.
Referenced by dahdi_chan_conf_default(), and process_dahdi().
#define CID_UNKNOWN_NAME (1 << 2) |
Definition at line 50 of file callerid.h.
Referenced by callerid_feed(), callerid_genmsg(), callerid_get(), and callerid_new().
#define CID_UNKNOWN_NUMBER (1 << 3) |
Definition at line 51 of file callerid.h.
Referenced by callerid_feed(), callerid_feed_jp(), callerid_genmsg(), callerid_get(), callerid_get_dtmf(), and callerid_new().
#define MAX_CALLERID_SIZE 32000 |
#define PUT_AUDIO_SAMPLE | ( | y | ) |
Value:
do { \ int index = (short)(rint(8192.0 * (y))); \ *(buf++) = AST_LIN2X(index); \ bytes++; \ } while(0)
Definition at line 240 of file callerid.h.
#define PUT_BYTE | ( | a | ) |
#define PUT_CLID | ( | byte | ) |
Definition at line 261 of file callerid.h.
Referenced by adsi_generate(), ast_callerid_vmwi_generate(), callerid_generate(), and dahdi_sendtext().
#define PUT_CLID_BAUD | ( | bit | ) |
Definition at line 252 of file callerid.h.
#define PUT_CLID_MARKMS |
Value:
do { \ int x; \ for (x=0;x<8;x++) \ PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \ } while(0)
Definition at line 246 of file callerid.h.
Referenced by adsi_generate(), ast_callerid_vmwi_generate(), callerid_generate(), and dahdi_sendtext().
typedef struct callerid_state CIDSTATE |
Definition at line 69 of file callerid.h.
int ast_callerid_callwaiting_generate | ( | unsigned char * | buf, | |
const char * | name, | |||
const char * | number, | |||
int | codec | |||
) |
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) See ast_callerid_generate() for other details.
Definition at line 1045 of file callerid.c.
References __ast_callerid_generate().
Referenced by send_cwcidspill().
01046 { 01047 return __ast_callerid_generate(buf, name, number, 1, codec); 01048 }
int ast_callerid_generate | ( | unsigned char * | buf, | |
const char * | name, | |||
const char * | number, | |||
int | codec | |||
) |
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format).
buf | buffer for output samples. See callerid_generate() for details regarding buffer. | |
name | Caller-ID Name | |
number | Caller-ID Number | |
codec | Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW) |
Definition at line 1040 of file callerid.c.
References __ast_callerid_generate().
Referenced by dahdi_call().
01041 { 01042 return __ast_callerid_generate(buf, name, number, 0, codec); 01043 }
char* ast_callerid_merge | ( | char * | buf, | |
int | bufsiz, | |||
const char * | name, | |||
const char * | num, | |||
const char * | unknown | |||
) |
Definition at line 1050 of file callerid.c.
References ast_copy_string().
Referenced by _sip_show_peer(), iax2_show_peer(), leave_voicemail(), prep_email_sub_vars(), and sip_show_user().
01051 { 01052 if (!unknown) 01053 unknown = "<unknown>"; 01054 if (name && num) 01055 snprintf(buf, bufsiz, "\"%s\" <%s>", name, num); 01056 else if (name) 01057 ast_copy_string(buf, name, bufsiz); 01058 else if (num) 01059 ast_copy_string(buf, num, bufsiz); 01060 else 01061 ast_copy_string(buf, unknown, bufsiz); 01062 return buf; 01063 }
int ast_callerid_parse | ( | char * | instr, | |
char ** | name, | |||
char ** | location | |||
) |
Destructively parse inbuf into name and location (or number) Parses callerid stream from inbuf and changes into useable form, outputed in name and location.
Definition at line 982 of file callerid.c.
References ast_copy_string(), ast_isphonenumber(), ast_shrink_phone_number(), ast_skip_blanks(), and ast_trim_blanks().
Referenced by action_originate(), advanced_options(), ast_callerid_split(), ast_privacy_check(), ast_privacy_set(), handle_setcallerid(), misdn_new(), play_message_callerid(), rpt_call(), and write_metadata().
00983 { 00984 char *ns, *ne, *ls, *le; 00985 00986 /* Try "name" <location> format or name <location> format */ 00987 if ((ls = strrchr(instr, '<')) && (le = strrchr(ls, '>'))) { 00988 *ls = *le = '\0'; /* location found, trim off the brackets */ 00989 *location = ls + 1; /* and this is the result */ 00990 if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) { 00991 *ns = *ne = '\0'; /* trim off the quotes */ 00992 *name = ns + 1; /* and this is the name */ 00993 } else if (ns) { 00994 /* An opening quote was found but no closing quote was. The closing 00995 * quote may actually be after the end of the bracketed number 00996 */ 00997 if (strchr(le + 1, '\"')) { 00998 *ns = '\0'; 00999 *name = ns + 1; 01000 ast_trim_blanks(*name); 01001 } else { 01002 *name = NULL; 01003 } 01004 } else { /* no quotes, trim off leading and trailing spaces */ 01005 *name = ast_skip_blanks(instr); 01006 ast_trim_blanks(*name); 01007 } 01008 } else { /* no valid brackets */ 01009 char tmp[256]; 01010 01011 ast_copy_string(tmp, instr, sizeof(tmp)); 01012 ast_shrink_phone_number(tmp); 01013 if (ast_isphonenumber(tmp)) { /* Assume it's just a location */ 01014 *name = NULL; 01015 strcpy(instr, tmp); /* safe, because tmp will always be the same size or smaller than instr */ 01016 *location = instr; 01017 } else { /* Assume it's just a name. */ 01018 *location = NULL; 01019 if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) { 01020 *ns = *ne = '\0'; /* trim off the quotes */ 01021 *name = ns + 1; /* and this is the name */ 01022 } else { /* no quotes, trim off leading and trailing spaces */ 01023 *name = ast_skip_blanks(instr); 01024 ast_trim_blanks(*name); 01025 } 01026 } 01027 } 01028 return 0; 01029 }
int ast_callerid_split | ( | const char * | src, | |
char * | name, | |||
int | namelen, | |||
char * | num, | |||
int | numlen | |||
) |
Definition at line 1065 of file callerid.c.
References ast_callerid_parse(), ast_copy_string(), ast_shrink_phone_number(), and ast_strdupa.
Referenced by apply_outgoing(), build_device(), build_gateway(), build_peer(), build_user(), callerid_read(), callerid_write(), disa_exec(), load_module(), prep_email_sub_vars(), process_dahdi(), setcallerid_exec(), store_callerid(), and update_common_options().
01066 { 01067 char *tmp; 01068 char *l = NULL, *n = NULL; 01069 01070 tmp = ast_strdupa(buf); 01071 ast_callerid_parse(tmp, &n, &l); 01072 if (n) 01073 ast_copy_string(name, n, namelen); 01074 else 01075 name[0] = '\0'; 01076 if (l) { 01077 ast_shrink_phone_number(l); 01078 ast_copy_string(num, l, numlen); 01079 } else 01080 num[0] = '\0'; 01081 return 0; 01082 }
int ast_callerid_vmwi_generate | ( | unsigned char * | buf, | |
int | active, | |||
int | mdmf, | |||
int | codec | |||
) |
Generate message waiting indicator (stutter tone).
Definition at line 797 of file callerid.c.
References len(), PUT_BYTE, PUT_CLID, and PUT_CLID_MARKMS.
00798 { 00799 unsigned char msg[256]; 00800 int len=0; 00801 int sum; 00802 int x; 00803 int bytes = 0; 00804 float cr = 1.0; 00805 float ci = 0.0; 00806 float scont = 0.0; 00807 if (mdmf) { 00808 /* MDMF Message waiting */ 00809 msg[len++] = 0x82; 00810 /* Length is 3 */ 00811 msg[len++] = 3; 00812 /* IE is "Message Waiting Parameter" */ 00813 msg[len++] = 0xb; 00814 /* Length of IE is one */ 00815 msg[len++] = 1; 00816 /* Active or not */ 00817 if (active) 00818 msg[len++] = 0xff; 00819 else 00820 msg[len++] = 0x00; 00821 } else { 00822 /* SDMF Message waiting */ 00823 msg[len++] = 0x6; 00824 /* Length is 3 */ 00825 msg[len++] = 3; 00826 if (active) { 00827 msg[len++] = 0x42; 00828 msg[len++] = 0x42; 00829 msg[len++] = 0x42; 00830 } else { 00831 msg[len++] = 0x6f; 00832 msg[len++] = 0x6f; 00833 msg[len++] = 0x6f; 00834 } 00835 } 00836 sum = 0; 00837 for (x=0; x<len; x++) 00838 sum += msg[x]; 00839 sum = (256 - (sum & 255)); 00840 msg[len++] = sum; 00841 /* Wait a half a second */ 00842 for (x=0; x<4000; x++) 00843 PUT_BYTE(0x7f); 00844 /* Transmit 30 0x55's (looks like a square wave) for channel seizure */ 00845 for (x=0; x<30; x++) 00846 PUT_CLID(0x55); 00847 /* Send 170ms of callerid marks */ 00848 for (x=0; x<170; x++) 00849 PUT_CLID_MARKMS; 00850 for (x=0; x<len; x++) { 00851 PUT_CLID(msg[x]); 00852 } 00853 /* Send 50 more ms of marks */ 00854 for (x=0; x<50; x++) 00855 PUT_CLID_MARKMS; 00856 return bytes; 00857 }
const char* ast_describe_caller_presentation | ( | int | data | ) |
Convert caller ID pres value to explanatory string.
data | value (see callerid.h AST_PRES_ ) |
Definition at line 1126 of file callerid.c.
References pres_types.
Referenced by _sip_show_peer(), report_new_callerid(), and sip_show_user().
01127 { 01128 int i; 01129 01130 for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) { 01131 if (pres_types[i].val == data) 01132 return pres_types[i].description; 01133 } 01134 01135 return "unknown"; 01136 }
int ast_gen_cas | ( | unsigned char * | outbuf, | |
int | sas, | |||
int | len, | |||
int | codec | |||
) |
outbuf | Allocated buffer for data. Must be at least 2400 bytes unless no SAS is desired | |
sas | Non-zero if CAS should be preceeded by SAS | |
len | How many samples to generate. | |
codec | Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) |
Definition at line 235 of file callerid.c.
References gen_tone(), gen_tones(), and callerid_state::pos.
Referenced by __adsi_transmit_messages(), and dahdi_callwait().
00236 { 00237 int pos = 0; 00238 int saslen=2400; 00239 float cr1 = 1.0; 00240 float ci1 = 0.0; 00241 float cr2 = 1.0; 00242 float ci2 = 0.0; 00243 if (sendsas) { 00244 if (len < saslen) 00245 return -1; 00246 gen_tone(outbuf, saslen, codec, sasdr, sasdi, &cr1, &ci1); 00247 len -= saslen; 00248 pos += saslen; 00249 cr2 = cr1; 00250 ci2 = ci1; 00251 } 00252 gen_tones(outbuf + pos, len, codec, casdr1, casdi1, casdr2, casdi2, &cr1, &ci1, &cr2, &ci2); 00253 return 0; 00254 }
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_shrink_phone_number).
0 if not
Definition at line 968 of file callerid.c.
References ast_is_valid_string().
Referenced by check_user_full().
00969 { 00970 return ast_is_valid_string(exten, "0123456789*#+()-."); 00971 }
int ast_isphonenumber | ( | const char * | n | ) |
Check if a string consists only of digits and + #.
0 if not
Definition at line 958 of file callerid.c.
References ast_is_valid_string().
Referenced by ast_callerid_parse().
00959 { 00960 return ast_is_valid_string(n, "0123456789*#+"); 00961 }
int ast_parse_caller_presentation | ( | const char * | data | ) |
Convert caller ID text code to value used in config file parsing.
data | text string |
Definition at line 1106 of file callerid.c.
References name, and pres_types.
Referenced by build_peer(), build_user(), and setcallerid_pres_exec().
01107 { 01108 int i; 01109 01110 if (!data) { 01111 return -1; 01112 } 01113 01114 for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) { 01115 if (!strcasecmp(pres_types[i].name, data)) 01116 return pres_types[i].val; 01117 } 01118 01119 return -1; 01120 }
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...
n | The number to be stripped/shrunk |
Definition at line 906 of file callerid.c.
Referenced by action_originate(), ast_callerid_parse(), ast_callerid_split(), ast_privacy_check(), ast_privacy_set(), check_access(), check_user_full(), handle_setcallerid(), pbx_load_config(), and write_metadata().
00907 { 00908 int x, y=0; 00909 int bracketed = 0; 00910 00911 for (x=0; n[x]; x++) { 00912 switch(n[x]) { 00913 case '[': 00914 bracketed++; 00915 n[y++] = n[x]; 00916 break; 00917 case ']': 00918 bracketed--; 00919 n[y++] = n[x]; 00920 break; 00921 case '-': 00922 if (bracketed) 00923 n[y++] = n[x]; 00924 break; 00925 case '.': 00926 if (!n[x+1]) 00927 n[y++] = n[x]; 00928 break; 00929 default: 00930 if (!strchr("( )", n[x])) 00931 n[y++] = n[x]; 00932 } 00933 } 00934 n[y] = '\0'; 00935 }
int callerid_feed | ( | struct callerid_state * | cid, | |
unsigned char * | ubuf, | |||
int | samples, | |||
int | codec | |||
) |
Read samples into the state machine.
cid | Which state machine to act upon | |
ubuf | containing your samples | |
samples | number of samples contained within the buffer. | |
codec | which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) |
Definition at line 540 of file callerid.c.
References ast_calloc, ast_copy_string(), ast_log(), ast_strlen_zero(), AST_XLAW, CID_PRIVATE_NAME, CID_PRIVATE_NUMBER, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, callerid_state::cksum, callerid_state::flags, free, fsk_serie(), callerid_state::fskd, callerid_state::len, LOG_ERROR, LOG_NOTICE, LOG_WARNING, callerid_state::name, callerid_state::number, callerid_state::oldlen, callerid_state::oldstuff, callerid_state::pos, callerid_state::rawdata, callerid_state::sawflag, and callerid_state::type.
Referenced by ss_thread().
00541 { 00542 int mylen = len; 00543 int olen; 00544 int b = 'X'; 00545 int res; 00546 int x; 00547 short *buf; 00548 short *obuf; 00549 00550 if (!(buf = ast_calloc(1, 2 * len + cid->oldlen))) { 00551 return -1; 00552 } 00553 00554 obuf = buf; 00555 memcpy(buf, cid->oldstuff, cid->oldlen); 00556 mylen += cid->oldlen/2; 00557 00558 for (x=0;x<len;x++) 00559 buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]); 00560 while(mylen >= 160) { 00561 olen = mylen; 00562 res = fsk_serie(&cid->fskd, buf, &mylen, &b); 00563 if (mylen < 0) { 00564 ast_log(LOG_ERROR, "No start bit found in fsk data.\n"); 00565 free(obuf); 00566 return -1; 00567 } 00568 buf += (olen - mylen); 00569 if (res < 0) { 00570 ast_log(LOG_NOTICE, "fsk_serie failed\n"); 00571 free(obuf); 00572 return -1; 00573 } 00574 if (res == 1) { 00575 if (b > 0xff) { 00576 if (cid->sawflag != 5) { 00577 /* Ignore invalid bytes */ 00578 continue; 00579 } 00580 /* 00581 * We can tollerate an error on the checksum character since the 00582 * checksum character is the last character in the message and 00583 * it validates the message. 00584 * 00585 * Remove character error flags. 00586 * Bit 8 : Parity error 00587 * Bit 9 : Framing error 00588 */ 00589 b &= 0xff; 00590 } 00591 switch(cid->sawflag) { 00592 case 0: /* Look for flag */ 00593 if (b == 'U') 00594 cid->sawflag = 2; 00595 break; 00596 case 2: /* Get lead-in */ 00597 if ((b == 0x04) || (b == 0x80)) { 00598 cid->type = b; 00599 cid->sawflag = 3; 00600 cid->cksum = b; 00601 } 00602 break; 00603 case 3: /* Get length */ 00604 /* Not a lead in. We're ready */ 00605 cid->sawflag = 4; 00606 cid->len = b; 00607 cid->pos = 0; 00608 cid->cksum += b; 00609 break; 00610 case 4: /* Retrieve message */ 00611 if (cid->pos >= 128) { 00612 ast_log(LOG_WARNING, "Caller ID too long???\n"); 00613 free(obuf); 00614 return -1; 00615 } 00616 cid->rawdata[cid->pos++] = b; 00617 cid->len--; 00618 cid->cksum += b; 00619 if (!cid->len) { 00620 cid->rawdata[cid->pos] = '\0'; 00621 cid->sawflag = 5; 00622 } 00623 break; 00624 case 5: /* Check checksum */ 00625 if (b != (256 - (cid->cksum & 0xff))) { 00626 ast_log(LOG_NOTICE, "Caller*ID failed checksum\n"); 00627 /* Try again */ 00628 cid->sawflag = 0; 00629 break; 00630 } 00631 00632 cid->number[0] = '\0'; 00633 cid->name[0] = '\0'; 00634 /* If we get this far we're fine. */ 00635 if (cid->type == 0x80) { 00636 /* MDMF */ 00637 /* Go through each element and process */ 00638 for (x=0;x< cid->pos;) { 00639 switch(cid->rawdata[x++]) { 00640 case 1: 00641 /* Date */ 00642 break; 00643 case 2: /* Number */ 00644 case 3: /* Number (for Zebble) */ 00645 case 4: /* Number */ 00646 res = cid->rawdata[x]; 00647 if (res > 32) { 00648 ast_log(LOG_NOTICE, "Truncating long caller ID number from %d bytes to 32\n", cid->rawdata[x]); 00649 res = 32; 00650 } 00651 if (ast_strlen_zero(cid->number)) { 00652 memcpy(cid->number, cid->rawdata + x + 1, res); 00653 /* Null terminate */ 00654 cid->number[res] = '\0'; 00655 } 00656 break; 00657 case 6: /* Stentor Call Qualifier (ie. Long Distance call) */ 00658 break; 00659 case 7: /* Name */ 00660 case 8: /* Name */ 00661 res = cid->rawdata[x]; 00662 if (res > 32) { 00663 ast_log(LOG_NOTICE, "Truncating long caller ID name from %d bytes to 32\n", cid->rawdata[x]); 00664 res = 32; 00665 } 00666 memcpy(cid->name, cid->rawdata + x + 1, res); 00667 cid->name[res] = '\0'; 00668 break; 00669 case 17: /* UK: Call type, 1=Voice Call, 2=Ringback when free, 129=Message waiting */ 00670 case 19: /* UK: Network message system status (Number of messages waiting) */ 00671 case 22: /* Something French */ 00672 break; 00673 default: 00674 ast_log(LOG_NOTICE, "Unknown IE %d\n", cid->rawdata[x-1]); 00675 } 00676 res = cid->rawdata[x]; 00677 if (0 > res){ /* Negative offset in the CID Spill */ 00678 ast_log(LOG_NOTICE, "IE %d has bad field length of %d at offset %d\n", cid->rawdata[x-1], cid->rawdata[x], x); 00679 /* Try again */ 00680 cid->sawflag = 0; 00681 break; /* Exit the loop */ 00682 } 00683 x += cid->rawdata[x]; 00684 x++; 00685 } 00686 } else { 00687 /* SDMF */ 00688 ast_copy_string(cid->number, cid->rawdata + 8, sizeof(cid->number)); 00689 } 00690 /* Update flags */ 00691 cid->flags = 0; 00692 if (!strcmp(cid->number, "P")) { 00693 strcpy(cid->number, ""); 00694 cid->flags |= CID_PRIVATE_NUMBER; 00695 } else if (!strcmp(cid->number, "O") || ast_strlen_zero(cid->number)) { 00696 strcpy(cid->number, ""); 00697 cid->flags |= CID_UNKNOWN_NUMBER; 00698 } 00699 if (!strcmp(cid->name, "P")) { 00700 strcpy(cid->name, ""); 00701 cid->flags |= CID_PRIVATE_NAME; 00702 } else if (!strcmp(cid->name, "O") || ast_strlen_zero(cid->name)) { 00703 strcpy(cid->name, ""); 00704 cid->flags |= CID_UNKNOWN_NAME; 00705 } 00706 free(obuf); 00707 return 1; 00708 break; 00709 default: 00710 ast_log(LOG_ERROR, "Dunno what to do with a digit in sawflag %d\n", cid->sawflag); 00711 } 00712 } 00713 } 00714 if (mylen) { 00715 memcpy(cid->oldstuff, buf, mylen * 2); 00716 cid->oldlen = mylen * 2; 00717 } else 00718 cid->oldlen = 0; 00719 free(obuf); 00720 return 0; 00721 }
int callerid_feed_jp | ( | struct callerid_state * | cid, | |
unsigned char * | ubuf, | |||
int | samples, | |||
int | codec | |||
) |
Read samples into the state machine.
cid | Which state machine to act upon | |
ubuf | containing your samples | |
samples | number of samples contained within the buffer. | |
codec | which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW) |
Definition at line 280 of file callerid.c.
References ast_calloc, ast_copy_string(), ast_log(), AST_XLAW, calc_crc(), CID_UNKNOWN_NUMBER, callerid_state::crc, callerid_state::flags, free, fsk_serie(), callerid_state::fskd, callerid_state::len, LOG_DEBUG, LOG_ERROR, LOG_NOTICE, LOG_WARNING, callerid_state::name, callerid_state::number, callerid_state::oldlen, callerid_state::oldstuff, option_debug, callerid_state::pos, callerid_state::rawdata, callerid_state::sawflag, and callerid_state::skipflag.
Referenced by ss_thread().
00281 { 00282 int mylen = len; 00283 int olen; 00284 int b = 'X'; 00285 int b2 ; 00286 int res; 00287 int x; 00288 short *buf; 00289 short *obuf; 00290 00291 if (!(buf = ast_calloc(1, 2 * len + cid->oldlen))) { 00292 return -1; 00293 } 00294 00295 obuf = buf; 00296 memcpy(buf, cid->oldstuff, cid->oldlen); 00297 mylen += cid->oldlen/2; 00298 00299 for (x=0;x<len;x++) 00300 buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]); 00301 00302 while (mylen >= 160) { 00303 b = b2 = 0; 00304 olen = mylen; 00305 res = fsk_serie(&cid->fskd, buf, &mylen, &b); 00306 00307 if (mylen < 0) { 00308 ast_log(LOG_ERROR, "No start bit found in fsk data.\n"); 00309 free(obuf); 00310 return -1; 00311 } 00312 00313 buf += (olen - mylen); 00314 00315 if (res < 0) { 00316 ast_log(LOG_NOTICE, "fsk_serie failed\n"); 00317 free(obuf); 00318 return -1; 00319 } 00320 00321 if (res == 1) { 00322 00323 b2 = b ; 00324 b = b & 0x7f ; 00325 00326 /* crc checksum calculation */ 00327 if ( cid->sawflag > 1 ) { 00328 cid->crc = calc_crc(cid->crc, (unsigned char)b2); 00329 } 00330 00331 /* Ignore invalid bytes */ 00332 if (b > 0xff) { 00333 continue; 00334 } 00335 00336 /* skip DLE if needed */ 00337 if ( cid->sawflag > 0 ) { 00338 if ( cid->sawflag != 5 && cid->skipflag == 0 && b == 0x10 ) { 00339 cid->skipflag = 1 ; 00340 continue ; 00341 } 00342 } 00343 if ( cid->skipflag == 1 ) { 00344 cid->skipflag = 0 ; 00345 } 00346 00347 /* caller id retrieval */ 00348 switch(cid->sawflag) { 00349 case 0: /* DLE */ 00350 if (b == 0x10) { 00351 cid->sawflag = 1; 00352 cid->skipflag = 0; 00353 cid->crc = 0; 00354 } 00355 break; 00356 case 1: /* SOH */ 00357 if (b == 0x01) { 00358 cid->sawflag = 2; 00359 } 00360 break ; 00361 case 2: /* HEADER */ 00362 if (b == 0x07) { 00363 cid->sawflag = 3; 00364 } 00365 break; 00366 case 3: /* STX */ 00367 if (b == 0x02) { 00368 cid->sawflag = 4; 00369 } 00370 break; 00371 case 4: /* SERVICE TYPE */ 00372 if (b == 0x40) { 00373 cid->sawflag = 5; 00374 } 00375 break; 00376 case 5: /* Frame Length */ 00377 cid->sawflag = 6; 00378 break; 00379 case 6: /* NUMBER TYPE */ 00380 cid->sawflag = 7; 00381 cid->pos = 0; 00382 cid->rawdata[cid->pos++] = b; 00383 break; 00384 case 7: /* NUMBER LENGTH */ 00385 cid->sawflag = 8; 00386 cid->len = b; 00387 if ( (cid->len+2) >= sizeof( cid->rawdata ) ) { 00388 ast_log(LOG_WARNING, "too long caller id string\n" ) ; 00389 free(obuf); 00390 return -1; 00391 } 00392 cid->rawdata[cid->pos++] = b; 00393 break; 00394 case 8: /* Retrieve message */ 00395 cid->rawdata[cid->pos++] = b; 00396 cid->len--; 00397 if (cid->len<=0) { 00398 cid->rawdata[cid->pos] = '\0'; 00399 cid->sawflag = 9; 00400 } 00401 break; 00402 case 9: /* ETX */ 00403 cid->sawflag = 10; 00404 break; 00405 case 10: /* CRC Checksum 1 */ 00406 cid->sawflag = 11; 00407 break; 00408 case 11: /* CRC Checksum 2 */ 00409 cid->sawflag = 12; 00410 if ( cid->crc != 0 ) { 00411 ast_log(LOG_WARNING, "crc checksum error\n" ) ; 00412 free(obuf); 00413 return -1; 00414 } 00415 /* extract caller id data */ 00416 for (x=0; x<cid->pos; ) { 00417 switch (cid->rawdata[x++]) { 00418 case 0x02: /* caller id number */ 00419 cid->number[0] = '\0'; 00420 cid->name[0] = '\0'; 00421 cid->flags = 0; 00422 res = cid->rawdata[x++]; 00423 ast_copy_string(cid->number, &cid->rawdata[x], res+1 ); 00424 x += res; 00425 break; 00426 case 0x21: /* additional information */ 00427 /* length */ 00428 x++; 00429 /* number type */ 00430 switch (cid->rawdata[x]) { 00431 case 0x00: /* unknown */ 00432 case 0x01: /* international number */ 00433 case 0x02: /* domestic number */ 00434 case 0x03: /* network */ 00435 case 0x04: /* local call */ 00436 case 0x06: /* short dial number */ 00437 case 0x07: /* reserved */ 00438 default: /* reserved */ 00439 if (option_debug > 1) 00440 ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]); 00441 break ; 00442 } 00443 x++; 00444 /* numbering plan octed 4 */ 00445 x++; 00446 /* numbering plan octed 5 */ 00447 switch (cid->rawdata[x]) { 00448 case 0x00: /* unknown */ 00449 case 0x01: /* recommendation E.164 ISDN */ 00450 case 0x03: /* recommendation X.121 */ 00451 case 0x04: /* telex dial plan */ 00452 case 0x08: /* domestic dial plan */ 00453 case 0x09: /* private dial plan */ 00454 case 0x05: /* reserved */ 00455 default: /* reserved */ 00456 if (option_debug > 1) 00457 ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]); 00458 break ; 00459 } 00460 x++; 00461 break ; 00462 case 0x04: /* no callerid reason */ 00463 /* length */ 00464 x++; 00465 /* no callerid reason code */ 00466 switch (cid->rawdata[x]) { 00467 case 'P': /* caller id denied by user */ 00468 case 'O': /* service not available */ 00469 case 'C': /* pay phone */ 00470 case 'S': /* service congested */ 00471 cid->flags |= CID_UNKNOWN_NUMBER; 00472 if (option_debug > 1) 00473 ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]); 00474 break ; 00475 } 00476 x++; 00477 break ; 00478 case 0x09: /* dialed number */ 00479 /* length */ 00480 res = cid->rawdata[x++]; 00481 /* dialed number */ 00482 x += res; 00483 break ; 00484 case 0x22: /* dialed number additional information */ 00485 /* length */ 00486 x++; 00487 /* number type */ 00488 switch (cid->rawdata[x]) { 00489 case 0x00: /* unknown */ 00490 case 0x01: /* international number */ 00491 case 0x02: /* domestic number */ 00492 case 0x03: /* network */ 00493 case 0x04: /* local call */ 00494 case 0x06: /* short dial number */ 00495 case 0x07: /* reserved */ 00496 default: /* reserved */ 00497 if (option_debug > 1) 00498 ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]); 00499 break ; 00500 } 00501 x++; 00502 /* numbering plan octed 4 */ 00503 x++; 00504 /* numbering plan octed 5 */ 00505 switch (cid->rawdata[x]) { 00506 case 0x00: /* unknown */ 00507 case 0x01: /* recommendation E.164 ISDN */ 00508 case 0x03: /* recommendation X.121 */ 00509 case 0x04: /* telex dial plan */ 00510 case 0x08: /* domestic dial plan */ 00511 case 0x09: /* private dial plan */ 00512 case 0x05: /* reserved */ 00513 default: /* reserved */ 00514 if (option_debug > 1) 00515 ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]); 00516 break ; 00517 } 00518 x++; 00519 break ; 00520 } 00521 } 00522 free(obuf); 00523 return 1; 00524 break; 00525 default: 00526 ast_log(LOG_ERROR, "invalid value in sawflag %d\n", cid->sawflag); 00527 } 00528 } 00529 } 00530 if (mylen) { 00531 memcpy(cid->oldstuff, buf, mylen * 2); 00532 cid->oldlen = mylen * 2; 00533 } else 00534 cid->oldlen = 0; 00535 free(obuf); 00536 return 0; 00537 }
void callerid_free | ( | struct callerid_state * | cid | ) |
Free a callerID state.
cid | This is the callerid_state state machine to free This function frees callerid_state cid. |
Definition at line 723 of file callerid.c.
References free.
Referenced by ss_thread().
00724 { 00725 free(cid); 00726 }
int callerid_generate | ( | unsigned char * | buf, | |
const char * | number, | |||
const char * | name, | |||
int | flags, | |||
int | callwaiting, | |||
int | codec | |||
) |
Generates a CallerID FSK stream in ulaw format suitable for transmission.
buf | Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own. "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun. | |
number | Use NULL for no number or "P" for "private" | |
name | name to be used | |
flags | passed flags | |
callwaiting | callwaiting flag | |
codec | -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW This function creates a stream of callerid (a callerid spill) data in ulaw format. |
Definition at line 859 of file callerid.c.
References callerid_genmsg(), len(), PUT_BYTE, PUT_CLID, and PUT_CLID_MARKMS.
Referenced by __ast_callerid_generate().
00860 { 00861 int bytes=0; 00862 int x, sum; 00863 int len; 00864 00865 /* Initial carriers (real/imaginary) */ 00866 float cr = 1.0; 00867 float ci = 0.0; 00868 float scont = 0.0; 00869 char msg[256]; 00870 len = callerid_genmsg(msg, sizeof(msg), number, name, flags); 00871 if (!callwaiting) { 00872 /* Wait a half a second */ 00873 for (x=0; x<4000; x++) 00874 PUT_BYTE(0x7f); 00875 /* Transmit 30 0x55's (looks like a square wave) for channel seizure */ 00876 for (x=0; x<30; x++) 00877 PUT_CLID(0x55); 00878 } 00879 /* Send 150ms of callerid marks */ 00880 for (x=0; x<150; x++) 00881 PUT_CLID_MARKMS; 00882 /* Send 0x80 indicating MDMF format */ 00883 PUT_CLID(0x80); 00884 /* Put length of whole message */ 00885 PUT_CLID(len); 00886 sum = 0x80 + strlen(msg); 00887 /* Put each character of message and update checksum */ 00888 for (x=0; x<len; x++) { 00889 PUT_CLID(msg[x]); 00890 sum += msg[x]; 00891 } 00892 /* Send 2's compliment of sum */ 00893 PUT_CLID(256 - (sum & 255)); 00894 00895 /* Send 50 more ms of marks */ 00896 for (x=0; x<50; x++) 00897 PUT_CLID_MARKMS; 00898 00899 return bytes; 00900 }
void callerid_get | ( | struct callerid_state * | cid, | |
char ** | number, | |||
char ** | name, | |||
int * | flags | |||
) |
Extract info out of callerID state machine. Flags are listed above.
cid | Callerid state machine to act upon | |
number | Pass the address of a pointer-to-char (will contain the phone number) | |
name | Pass the address of a pointer-to-char (will contain the name) | |
flags | Pass the address of an int variable(will contain the various callerid flags) |
Definition at line 161 of file callerid.c.
References CID_PRIVATE_NAME, CID_PRIVATE_NUMBER, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, callerid_state::flags, callerid_state::name, and callerid_state::number.
Referenced by ss_thread().
00162 { 00163 *flags = cid->flags; 00164 if (cid->flags & (CID_UNKNOWN_NAME | CID_PRIVATE_NAME)) 00165 *name = NULL; 00166 else 00167 *name = cid->name; 00168 if (cid->flags & (CID_UNKNOWN_NUMBER | CID_PRIVATE_NUMBER)) 00169 *number = NULL; 00170 else 00171 *number = cid->number; 00172 }
void callerid_get_dtmf | ( | char * | cidstring, | |
char * | number, | |||
int * | flags | |||
) |
cidstring | The actual transmitted string. | |
number | The cid number is returned here. | |
flags | The cid flags are returned here. This function parses DTMF callerid. |
Definition at line 174 of file callerid.c.
References ast_log(), CID_PRIVATE_NUMBER, CID_UNKNOWN_NUMBER, LOG_DEBUG, and LOG_WARNING.
Referenced by ss_thread().
00175 { 00176 int i; 00177 int code; 00178 00179 /* "Clear" the number-buffer. */ 00180 number[0] = 0; 00181 00182 if (strlen(cidstring) < 2) { 00183 ast_log(LOG_DEBUG, "No cid detected\n"); 00184 *flags = CID_UNKNOWN_NUMBER; 00185 return; 00186 } 00187 00188 /* Detect protocol and special types */ 00189 if (cidstring[0] == 'B') { 00190 /* Handle special codes */ 00191 code = atoi(&cidstring[1]); 00192 if (code == 0) 00193 *flags = CID_UNKNOWN_NUMBER; 00194 else if (code == 10) 00195 *flags = CID_PRIVATE_NUMBER; 00196 else 00197 ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code); 00198 } else if (cidstring[0] == 'D' && cidstring[2] == '#') { 00199 /* .DK special code */ 00200 if (cidstring[1] == '1') 00201 *flags = CID_PRIVATE_NUMBER; 00202 if (cidstring[1] == '2' || cidstring[1] == '3') 00203 *flags = CID_UNKNOWN_NUMBER; 00204 } else if (cidstring[0] == 'D' || cidstring[0] == 'A') { 00205 /* "Standard" callerid */ 00206 for (i = 1; i < strlen(cidstring); i++ ) { 00207 if (cidstring[i] == 'C' || cidstring[i] == '#') 00208 break; 00209 if (isdigit(cidstring[i])) 00210 number[i-1] = cidstring[i]; 00211 else 00212 ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n", 00213 cidstring[i]); 00214 } 00215 number[i-1] = 0; 00216 } else if (isdigit(cidstring[0])) { 00217 /* It begins with a digit, so we parse it as a number and hope 00218 * for the best */ 00219 ast_log(LOG_WARNING, "Couldn't detect start-character. CID " 00220 "parsing might be unreliable\n"); 00221 for (i = 0; i < strlen(cidstring); i++) { 00222 if (isdigit(cidstring[i])) 00223 number[i] = cidstring[i]; 00224 else 00225 break; 00226 } 00227 number[i] = 0; 00228 } else { 00229 ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", 00230 cidstring[0]); 00231 *flags = CID_UNKNOWN_NUMBER; 00232 } 00233 }
static float callerid_getcarrier | ( | float * | cr, | |
float * | ci, | |||
int | bit | |||
) | [inline, static] |
Definition at line 221 of file callerid.h.
References cid_di, cid_dr, and t.
00222 { 00223 /* Move along. There's nothing to see here... */ 00224 float t; 00225 t = *cr * cid_dr[bit] - *ci * cid_di[bit]; 00226 *ci = *cr * cid_di[bit] + *ci * cid_dr[bit]; 00227 *cr = t; 00228 00229 t = 2.0 - (*cr * *cr + *ci * *ci); 00230 *cr *= t; 00231 *ci *= t; 00232 return *cr; 00233 }
void callerid_init | ( | void | ) |
CallerID Initialization.
Definition at line 118 of file callerid.c.
References CALLERID_MARK, CALLERID_SPACE, CAS_FREQ1, CAS_FREQ2, and SAS_FREQ.
Referenced by main().
00119 { 00120 cid_dr[0] = cos(CALLERID_SPACE * 2.0 * M_PI / 8000.0); 00121 cid_di[0] = sin(CALLERID_SPACE * 2.0 * M_PI / 8000.0); 00122 cid_dr[1] = cos(CALLERID_MARK * 2.0 * M_PI / 8000.0); 00123 cid_di[1] = sin(CALLERID_MARK * 2.0 * M_PI / 8000.0); 00124 sasdr = cos(SAS_FREQ * 2.0 * M_PI / 8000.0); 00125 sasdi = sin(SAS_FREQ * 2.0 * M_PI / 8000.0); 00126 casdr1 = cos(CAS_FREQ1 * 2.0 * M_PI / 8000.0); 00127 casdi1 = sin(CAS_FREQ1 * 2.0 * M_PI / 8000.0); 00128 casdr2 = cos(CAS_FREQ2 * 2.0 * M_PI / 8000.0); 00129 casdi2 = sin(CAS_FREQ2 * 2.0 * M_PI / 8000.0); 00130 }
struct callerid_state* callerid_new | ( | int | cid_signalling | ) |
Create a callerID state machine.
cid_signalling | Type of signalling in use |
Definition at line 132 of file callerid.c.
References ast_calloc, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, callerid_state::fskd, and fsk_data::spb.
Referenced by ss_thread().
00133 { 00134 struct callerid_state *cid; 00135 00136 if ((cid = ast_calloc(1, sizeof(*cid)))) { 00137 cid->fskd.spb = 7.0; /* 1200 baud */ 00138 /* cid->fskd.hdlc = 0; */ /* Async */ 00139 cid->fskd.nbit = 8; /* 8 bits */ 00140 cid->fskd.nstop = 1.0; /* 1 stop bit */ 00141 /* cid->fskd.paridad = 0; */ /* No parity */ 00142 cid->fskd.bw = 1; /* Filter 800 Hz */ 00143 if (cid_signalling == 2) { /* v23 signalling */ 00144 cid->fskd.f_mark_idx = 4; /* 1300 Hz */ 00145 cid->fskd.f_space_idx = 5; /* 2100 Hz */ 00146 } else { /* Bell 202 signalling as default */ 00147 cid->fskd.f_mark_idx = 2; /* 1200 Hz */ 00148 cid->fskd.f_space_idx = 3; /* 2200 Hz */ 00149 } 00150 /* cid->fskd.pcola = 0; */ /* No clue */ 00151 /* cid->fskd.cont = 0.0; */ /* Digital PLL reset */ 00152 /* cid->fskd.x0 = 0.0; */ 00153 /* cid->fskd.state = 0; */ 00154 cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER; 00155 /* cid->pos = 0; */ 00156 } 00157 00158 return cid; 00159 }
float cid_di[4] |
float cid_dr[4] |
float clidsb |
Definition at line 68 of file callerid.c.