![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
callerid.h File Reference
Definition in file callerid.h.
This graph shows which files directly or indirectly include this file:

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_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) |
| 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 + #. | |
| const char * | ast_named_caller_presentation (int data) |
| Convert caller ID pres value to text code. | |
| 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. | |
| int | vmwi_generate (unsigned char *buf, int active, int mdmf, int codec) |
| Generate message waiting indicator (stutter tone). | |
Variables | |
| float | cid_di [4] |
| float | cid_dr [4] |
| float | clidsb |
|
|
Definition at line 63 of file callerid.h. Referenced by gen_tone(), and gen_tones(). |
|
|
Definition at line 280 of file callerid.h. Referenced by build_rpid(), and cb_events(). |
|
|
Definition at line 294 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 291 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 285 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 288 of file callerid.h. Referenced by build_rpid(), and check_access(). |
|
|
Definition at line 277 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 309 of file callerid.h. Referenced by build_rpid(), check_access(), and iax2_call(). |
|
|
Definition at line 273 of file callerid.h. |
|
|
Definition at line 306 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 303 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 297 of file callerid.h. Referenced by build_rpid(), and get_rpid_num(). |
|
|
Definition at line 300 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 283 of file callerid.h. |
|
|
Definition at line 281 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 279 of file callerid.h. Referenced by build_rpid(). |
|
|
Definition at line 282 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 276 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 275 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 274 of file callerid.h. Referenced by cb_events(), and update_config(). |
|
|
Definition at line 64 of file callerid.h. Referenced by callerid_feed(), and callerid_feed_jp(). |
|
|
Definition at line 48 of file callerid.h. Referenced by callerid_get(). |
|
|
Definition at line 49 of file callerid.h. Referenced by callerid_genmsg(), callerid_get(), and callerid_get_dtmf(). |
|
|
Definition at line 53 of file callerid.h. Referenced by zt_chan_conf_default(). |
|
|
Definition at line 55 of file callerid.h. Referenced by ss_thread(). |
|
|
Definition at line 57 of file callerid.h. Referenced by ss_thread(). |
|
|
Definition at line 54 of file callerid.h. Referenced by ss_thread(). |
|
|
Definition at line 56 of file callerid.h. Referenced by ss_thread(). |
|
|
Definition at line 60 of file callerid.h. Referenced by handle_init_event(), and ss_thread(). |
|
|
Definition at line 59 of file callerid.h. Referenced by zt_chan_conf_default(). |
|
|
Definition at line 50 of file callerid.h. Referenced by callerid_genmsg(), callerid_get(), and callerid_new(). |
|
|
Definition at line 51 of file callerid.h. Referenced by callerid_feed_jp(), callerid_genmsg(), callerid_get(), callerid_get_dtmf(), and callerid_new(). |
|
|
Definition at line 46 of file callerid.h. Referenced by send_cwcidspill(), and zt_call(). |
|
|
Value: do { \ int index = (short)(rint(8192.0 * (y))); \ *(buf++) = AST_LIN2X(index); \ bytes++; \ } while(0) Definition at line 239 of file callerid.h. |
|
|
Value: do { \ *(buf++) = (a); \ bytes++; \ } while(0) Definition at line 234 of file callerid.h. |
|
|
Definition at line 260 of file callerid.h. Referenced by adsi_generate(), callerid_generate(), vmwi_generate(), and zt_sendtext(). |
|
|
Definition at line 251 of file callerid.h. |
|
|
Value: do { \ int x; \ for (x=0;x<8;x++) \ PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \ } while(0) Definition at line 245 of file callerid.h. Referenced by adsi_generate(), callerid_generate(), vmwi_generate(), and zt_sendtext(). |
|
|
Definition at line 68 of file callerid.h. |
|
||||||||||||||||||||
|
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 994 of file callerid.c. References __ast_callerid_generate(). Referenced by send_cwcidspill(). 00995 { 00996 return __ast_callerid_generate(buf, name, number, 1, codec); 00997 }
|
|
||||||||||||||||||||
|
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format).
Definition at line 989 of file callerid.c. References __ast_callerid_generate(). Referenced by zt_call(). 00990 { 00991 return __ast_callerid_generate(buf, name, number, 0, codec); 00992 }
|
|
||||||||||||||||||||||||
|
Definition at line 999 of file callerid.c. Referenced by _sip_show_device(), _sip_show_peer(), iax2_show_peer(), and sip_show_user(). 01000 { 01001 if (!unknown) 01002 unknown = "<unknown>"; 01003 if (name && num) 01004 snprintf(buf, bufsiz, "\"%s\" <%s>", name, num); 01005 else if (name) 01006 ast_copy_string(buf, name, bufsiz); 01007 else if (num) 01008 ast_copy_string(buf, num, bufsiz); 01009 else 01010 ast_copy_string(buf, unknown, bufsiz); 01011 return buf; 01012 }
|
|
||||||||||||||||
|
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 942 of file callerid.c. References ast_isphonenumber(), and ast_shrink_phone_number(). Referenced by action_originate(), ast_callerid_split(), ast_privacy_check(), ast_privacy_set(), and handle_setcallerid(). 00943 { 00944 char *ns, *ne, *ls, *le; 00945 00946 /* Try "name" <location> format or name <location> format */ 00947 if ((ls = strchr(instr, '<')) && (le = strchr(ls, '>'))) { 00948 *ls = *le = '\0'; /* location found, trim off the brackets */ 00949 *location = ls + 1; /* and this is the result */ 00950 if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) { 00951 *ns = *ne = '\0'; /* trim off the quotes */ 00952 *name = ns + 1; /* and this is the name */ 00953 } else { /* no quotes, trim off leading and trailing spaces */ 00954 *name = ast_skip_blanks(instr); 00955 ast_trim_blanks(*name); 00956 } 00957 } else { /* no valid brackets */ 00958 char tmp[256]; 00959 00960 ast_copy_string(tmp, instr, sizeof(tmp)); 00961 ast_shrink_phone_number(tmp); 00962 if (ast_isphonenumber(tmp)) { /* Assume it's just a location */ 00963 *name = NULL; 00964 strcpy(instr, tmp); /* safe, because tmp will always be the same size or smaller than instr */ 00965 *location = instr; 00966 } else { /* Assume it's just a name. */ 00967 *location = NULL; 00968 if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) { 00969 *ns = *ne = '\0'; /* trim off the quotes */ 00970 *name = ns + 1; /* and this is the name */ 00971 } else { /* no quotes, trim off leading and trailing spaces */ 00972 *name = ast_skip_blanks(instr); 00973 ast_trim_blanks(*name); 00974 } 00975 } 00976 } 00977 return 0; 00978 }
|
|
||||||||||||||||||||||||
|
Definition at line 1014 of file callerid.c. References ast_callerid_parse(), ast_shrink_phone_number(), and ast_strdupa. Referenced by apply_outgoing(), build_device(), build_gateway(), build_peer(), build_user(), load_module(), set_device_cid(), store_callerid(), and update_common_options(). 01015 { 01016 char *tmp; 01017 char *l = NULL, *n = NULL; 01018 01019 tmp = ast_strdupa(buf); 01020 ast_callerid_parse(tmp, &n, &l); 01021 if (n) 01022 ast_copy_string(name, n, namelen); 01023 else 01024 name[0] = '\0'; 01025 if (l) { 01026 ast_shrink_phone_number(l); 01027 ast_copy_string(num, l, numlen); 01028 } else 01029 num[0] = '\0'; 01030 return 0; 01031 }
|
|
|
Convert caller ID pres value to explanatory string.
Definition at line 1071 of file callerid.c. References pres_types. Referenced by _sip_show_device(), _sip_show_peer(), ast_set_callerid(), and sip_show_user(). 01072 { 01073 int i; 01074 01075 for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) { 01076 if (pres_types[i].val == data) 01077 return pres_types[i].description; 01078 } 01079 01080 return "unknown"; 01081 }
|
|
||||||||||||||||||||
|
Definition at line 235 of file callerid.c. References casdi1, casdi2, casdr1, casdr2, gen_tone(), gen_tones(), callerid_state::pos, sasdi, and sasdr. Referenced by __adsi_transmit_messages(), and zt_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 00244 if (sendsas) { 00245 if (len < saslen) 00246 return -1; 00247 gen_tone(outbuf, saslen, codec, sasdr, sasdi, &cr1, &ci1); 00248 len -= saslen; 00249 pos += saslen; 00250 cr2 = cr1; 00251 ci2 = ci1; 00252 } 00253 gen_tones(outbuf + pos, len, codec, casdr1, casdi1, casdr2, casdi2, &cr1, &ci1, &cr2, &ci2); 00254 return 0; 00255 }
|
|
|
Check if a string consists only of digits and and + # ( ) - . (meaning it can be cleaned with ast_shrink_phone_number).
Definition at line 927 of file callerid.c. References ast_is_valid_string(). Referenced by check_peer_ok(), check_user_full(), check_user_ok(), and replace_cid(). 00928 { 00929 return ast_is_valid_string(exten, "0123456789*#+()-."); 00930 }
|
|
|
Check if a string consists only of digits and + #.
Definition at line 917 of file callerid.c. References ast_is_valid_string(). Referenced by ast_callerid_parse(). 00918 { 00919 return ast_is_valid_string(n, "0123456789*#+"); 00920 }
|
|
|
Convert caller ID pres value to text code.
Definition at line 1087 of file callerid.c. References pres_types. 01088 { 01089 int i; 01090 01091 for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) { 01092 if (pres_types[i].val == data) 01093 return pres_types[i].name; 01094 } 01095 01096 return "unknown"; 01097 }
|
|
|
Convert caller ID text code to value used in config file parsing.
Definition at line 1055 of file callerid.c. References name, and pres_types. Referenced by build_device(), and build_peer(). 01056 { 01057 int i; 01058 01059 for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) { 01060 if (!strcasecmp(pres_types[i].name, data)) 01061 return pres_types[i].val; 01062 } 01063 01064 return -1; 01065 }
|
|
|
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
Definition at line 865 of file callerid.c. Referenced by action_originate(), ast_callerid_parse(), ast_callerid_split(), ast_privacy_check(), ast_privacy_set(), check_access(), check_peer_ok(), check_user_full(), check_user_ok(), handle_setcallerid(), and replace_cid(). 00866 { 00867 int x, y=0; 00868 int bracketed = 0; 00869 00870 for (x = 0; n[x]; x++) { 00871 switch (n[x]) { 00872 case '[': 00873 bracketed++; 00874 n[y++] = n[x]; 00875 break; 00876 case ']': 00877 bracketed--; 00878 n[y++] = n[x]; 00879 break; 00880 case '-': 00881 if (bracketed) 00882 n[y++] = n[x]; 00883 break; 00884 case '.': 00885 if (!n[x+1]) 00886 n[y++] = n[x]; 00887 break; 00888 default: 00889 if (!strchr("()", n[x])) 00890 n[y++] = n[x]; 00891 } 00892 } 00893 n[y] = '\0'; 00894 }
|
|
||||||||||||||||||||
|
Read samples into the state machine.
Definition at line 523 of file callerid.c. References ast_log(), ast_strlen_zero(), AST_XLAW, callerid_state::cksum, fsk_serial(), 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(). 00524 { 00525 int mylen = len; 00526 int olen; 00527 int b = 'X'; 00528 int res; 00529 int x; 00530 short *buf; 00531 00532 buf = alloca(2 * len + cid->oldlen); 00533 00534 memcpy(buf, cid->oldstuff, cid->oldlen); 00535 mylen += cid->oldlen/2; 00536 00537 for (x = 0; x < len; x++) 00538 buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]); 00539 while (mylen >= 160) { 00540 olen = mylen; 00541 res = fsk_serial(&cid->fskd, buf, &mylen, &b); 00542 if (mylen < 0) { 00543 ast_log(LOG_ERROR, "fsk_serial made mylen < 0 (%d)\n", mylen); 00544 return -1; 00545 } 00546 buf += (olen - mylen); 00547 if (res < 0) { 00548 ast_log(LOG_NOTICE, "fsk_serial failed\n"); 00549 return -1; 00550 } 00551 if (res == 1) { 00552 /* Ignore invalid bytes */ 00553 if (b > 0xff) 00554 continue; 00555 switch (cid->sawflag) { 00556 case 0: /* Look for flag */ 00557 if (b == 'U') 00558 cid->sawflag = 2; 00559 break; 00560 case 2: /* Get lead-in */ 00561 if ((b == 0x04) || (b == 0x80)) { 00562 cid->type = b; 00563 cid->sawflag = 3; 00564 cid->cksum = b; 00565 } 00566 break; 00567 case 3: /* Get length */ 00568 /* Not a lead in. We're ready */ 00569 cid->sawflag = 4; 00570 cid->len = b; 00571 cid->pos = 0; 00572 cid->cksum += b; 00573 break; 00574 case 4: /* Retrieve message */ 00575 if (cid->pos >= 128) { 00576 ast_log(LOG_WARNING, "Caller ID too long???\n"); 00577 return -1; 00578 } 00579 cid->rawdata[cid->pos++] = b; 00580 cid->len--; 00581 cid->cksum += b; 00582 if (!cid->len) { 00583 cid->rawdata[cid->pos] = '\0'; 00584 cid->sawflag = 5; 00585 } 00586 break; 00587 case 5: /* Check checksum */ 00588 if (b != (256 - (cid->cksum & 0xff))) { 00589 ast_log(LOG_NOTICE, "Caller*ID failed checksum\n"); 00590 /* Try again */ 00591 cid->sawflag = 0; 00592 break; 00593 } 00594 00595 cid->number[0] = '\0'; 00596 cid->name[0] = '\0'; 00597 /* If we get this far we're fine. */ 00598 if (cid->type == 0x80) { 00599 /* MDMF */ 00600 /* Go through each element and process */ 00601 for (x = 0; x < cid->pos;) { 00602 switch (cid->rawdata[x++]) { 00603 case 1: 00604 /* Date */ 00605 break; 00606 case 2: /* Number */ 00607 case 3: /* Number (for Zebble) */ 00608 case 4: /* Number */ 00609 res = cid->rawdata[x]; 00610 if (res > 32) { 00611 ast_log(LOG_NOTICE, "Truncating long caller ID number from %d bytes to 32\n", cid->rawdata[x]); 00612 res = 32; 00613 } 00614 if (ast_strlen_zero(cid->number)) { 00615 memcpy(cid->number, cid->rawdata + x + 1, res); 00616 /* Null terminate */ 00617 cid->number[res] = '\0'; 00618 } 00619 break; 00620 case 6: /* Stentor Call Qualifier (ie. Long Distance call) */ 00621 break; 00622 case 7: /* Name */ 00623 case 8: /* Name */ 00624 res = cid->rawdata[x]; 00625 if (res > 32) { 00626 ast_log(LOG_NOTICE, "Truncating long caller ID name from %d bytes to 32\n", cid->rawdata[x]); 00627 res = 32; 00628 } 00629 memcpy(cid->name, cid->rawdata + x + 1, res); 00630 cid->name[res] = '\0'; 00631 break; 00632 case 17: /* UK: Call type, 1=Voice Call, 2=Ringback when free, 129=Message waiting */ 00633 case 19: /* UK: Network message system status (Number of messages waiting) */ 00634 case 22: /* Something French */ 00635 break; 00636 default: 00637 ast_log(LOG_NOTICE, "Unknown IE %d\n", cid->rawdata[x - 1]); 00638 } 00639 x += cid->rawdata[x]; 00640 x++; 00641 } 00642 } else { 00643 |