Go to the source code of this file.
Defines | |
| #define | MAX_CALLERID_SIZE 32000 |
| #define | CID_PRIVATE_NAME (1 << 0) |
| #define | CID_PRIVATE_NUMBER (1 << 1) |
| #define | CID_UNKNOWN_NAME (1 << 2) |
| #define | CID_UNKNOWN_NUMBER (1 << 3) |
| #define | CID_SIG_BELL 1 |
| #define | CID_SIG_V23 2 |
| #define | CID_SIG_DTMF 3 |
| #define | CID_START_RING 1 |
| #define | CID_START_POLARITY 2 |
| #define | AST_LIN2X(a) ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a))) |
| #define | AST_XLAW(a) ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a))) |
| #define | AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED 0x00 |
| #define | AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN 0x01 |
| #define | AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN 0x02 |
| #define | AST_PRES_ALLOWED_NETWORK_NUMBER 0x03 |
| #define | AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED 0x20 |
| #define | AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN 0x21 |
| #define | AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN 0x22 |
| #define | AST_PRES_PROHIB_NETWORK_NUMBER 0x23 |
| #define | AST_PRES_NUMBER_NOT_AVAILABLE 0x43 |
| #define | PUT_BYTE(a) |
| #define | PUT_AUDIO_SAMPLE(y) |
| #define | PUT_CLID_MARKMS |
| #define | PUT_CLID_BAUD(bit) |
| #define | PUT_CLID(byte) |
Typedefs | |
| typedef callerid_state | CIDSTATE |
Functions | |
| void | callerid_init (void) |
| CallerID Initialization. | |
| int | callerid_generate (unsigned char *buf, char *number, char *name, int flags, int callwaiting, int codec) |
| Generates a CallerID FSK stream in ulaw format suitable for transmission. | |
| callerid_state * | callerid_new (int cid_signalling) |
| Create a callerID state machine. | |
| int | callerid_feed (struct callerid_state *cid, unsigned char *ubuf, int samples, int codec) |
| Read samples into the state machine. | |
| 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) |
| Get and parse DTMF-based callerid. | |
| void | callerid_free (struct callerid_state *cid) |
| Free a callerID state. | |
| int | ast_callerid_generate (unsigned char *buf, char *astcid, int codec) |
| Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format). | |
| int | vmwi_generate (unsigned char *buf, int active, int mdmf, int codec) |
| Generate message waiting indicator. | |
| int | ast_callerid_callwaiting_generate (unsigned char *buf, char *astcid, int codec) |
| Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format) but in a format suitable for Call Waiting(tm)'s Caller*ID(tm). | |
| int | ast_callerid_parse (char *instr, char **name, char **location) |
| Destructively parse inbuf into name and location (or number). | |
| int | ast_gen_cas (unsigned char *outbuf, int sas, int len, int codec) |
| Generate a CAS (CPE Alert Signal) tone for 'n' samples. | |
| 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 | ast_isphonenumber (char *n) |
| Check if a string consists only of digits. Returns non-zero if so. | |
Variables | |
| float | cid_dr [4] |
| float | cid_di [4] |
| float | clidsb |
|
|
Definition at line 35 of file callerid.h. |
|
|
Definition at line 193 of file callerid.h. |
|
|
Definition at line 192 of file callerid.h. |
|
|
Definition at line 190 of file callerid.h. |
|
|
Definition at line 191 of file callerid.h. |
|
|
Definition at line 198 of file callerid.h. |
|
|
Definition at line 197 of file callerid.h. |
|
|
Definition at line 196 of file callerid.h. |
|
|
Definition at line 194 of file callerid.h. |
|
|
Definition at line 195 of file callerid.h. |
|
|
Definition at line 36 of file callerid.h. Referenced by callerid_feed(). |
|
|
Definition at line 22 of file callerid.h. Referenced by callerid_feed(). |
|
|
Definition at line 23 of file callerid.h. Referenced by callerid_feed(), callerid_get(), and callerid_get_dtmf(). |
|
|
Definition at line 27 of file callerid.h. |
|
|
Definition at line 29 of file callerid.h. |
|
|
Definition at line 28 of file callerid.h. |
|
|
Definition at line 32 of file callerid.h. |
|
|
Definition at line 31 of file callerid.h. |
|
|
Definition at line 24 of file callerid.h. Referenced by callerid_feed(), callerid_get(), and callerid_new(). |
|
|
Definition at line 25 of file callerid.h. Referenced by callerid_feed(), callerid_get(), callerid_get_dtmf(), and callerid_new(). |
|
|
Definition at line 20 of file callerid.h. |
|
|
Value: do { \ int index = (short)(rint(8192.0 * (y))); \ *(buf++) = AST_LIN2X(index); \ bytes++; \ } while(0) Definition at line 205 of file callerid.h. |
|
|
Value: do { \ *(buf++) = (a); \ bytes++; \ } while(0) Definition at line 200 of file callerid.h. |
|
|
Definition at line 226 of file callerid.h. Referenced by callerid_generate(), and vmwi_generate(). |
|
|
Definition at line 217 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 211 of file callerid.h. Referenced by callerid_generate(), and vmwi_generate(). |
|
|
Definition at line 40 of file callerid.h. |
|
||||||||||||||||
|
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format) but in a format suitable for Call Waiting(tm)'s Caller*ID(tm). See ast_callerid_generate for other details Definition at line 664 of file callerid.c. 00665 {
00666 return __ast_callerid_generate(buf, callerid, 1, codec);
00667 }
|
|
||||||||||||||||
|
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format).
Definition at line 659 of file callerid.c. 00660 {
00661 return __ast_callerid_generate(buf, callerid, 0, codec);
00662 }
|
|
||||||||||||||||
|
Destructively parse inbuf into name and location (or number).
Definition at line 593 of file callerid.c. References ast_isphonenumber(), and ast_shrink_phone_number(). Referenced by ast_cdr_init(), ast_cdr_setcid(), ast_cdr_update(), ast_privacy_check(), and ast_privacy_set(). 00594 {
00595 char *ns, *ne;
00596 char *ls, *le;
00597 char tmp[256];
00598 /* Try for "name" <location> format or
00599 name <location> format */
00600 if ((ls = strchr(instr, '<')) && (le = strchr(ls, '>'))) {
00601 /* Found the location */
00602 *le = '\0';
00603 *ls = '\0';
00604 *location = ls + 1;
00605 if ((ns = strchr(instr, '\"')) && (ne = strchr(ns + 1, '\"'))) {
00606 /* Get name out of quotes */
00607 *ns = '\0';
00608 *ne = '\0';
00609 *name = ns + 1;
00610 return 0;
00611 } else {
00612 /* Just trim off any trailing spaces */
00613 *name = instr;
00614 while(!ast_strlen_zero(instr) && (instr[strlen(instr) - 1] < 33))
00615 instr[strlen(instr) - 1] = '\0';
00616 /* And leading spaces */
00617 while(**name && (**name < 33))
00618 (*name)++;
00619 return 0;
00620 }
00621 } else {
00622 strncpy(tmp, instr, sizeof(tmp)-1);
00623 ast_shrink_phone_number(tmp);
00624 if (ast_isphonenumber(tmp)) {
00625 /* Assume it's just a location */
00626 *name = NULL;
00627 *location = instr;
00628 } else {
00629 /* Assume it's just a name. Make sure it's not quoted though */
00630 *name = instr;
00631 while(*(*name) && ((*(*name) < 33) || (*(*name) == '\"'))) (*name)++;
00632 ne = *name + strlen(*name) - 1;
00633 while((ne > *name) && ((*ne < 33) || (*ne == '\"'))) { *ne = '\0'; ne--; }
00634 *location = NULL;
00635 }
00636 return 0;
00637 }
00638 return -1;
00639 }
|
|
||||||||||||||||||||
|
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
Definition at line 217 of file callerid.c. References casdi1, casdi2, casdr1, casdr2, callerid_state::pos, sasdi, and sasdr. 00218 {
00219 int pos = 0;
00220 int saslen=2400;
00221 float cr1 = 1.0;
00222 float ci1 = 0.0;
00223 float cr2 = 1.0;
00224 float ci2 = 0.0;
00225 if (sendsas) {
00226 if (len < saslen)
00227 return -1;
00228 gen_tone(outbuf, saslen, codec, sasdr, sasdi, &cr1, &ci1);
00229 len -= saslen;
00230 pos += saslen;
00231 cr2 = cr1;
00232 ci2 = ci1;
00233 }
00234 gen_tones(outbuf + pos, len, codec, casdr1, casdi1, casdr2, casdi2, &cr1, &ci1, &cr2, &ci2);
00235 return 0;
00236 }
|
|
|
Check if a string consists only of digits. Returns non-zero if so.
Definition at line 582 of file callerid.c. Referenced by ast_callerid_parse(). 00583 {
00584 int x;
00585 if (!n || ast_strlen_zero(n))
00586 return 0;
00587 for (x=0;n[x];x++)
00588 if (!strchr("0123456789*#+", n[x]))
00589 return 0;
00590 return 1;
00591 }
|
|
|
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
Definition at line 573 of file callerid.c. Referenced by ast_callerid_parse(), ast_cdr_init(), ast_cdr_setcid(), ast_cdr_update(), ast_privacy_check(), and ast_privacy_set(). 00574 {
00575 int x,y=0;
00576 for (x=0;n[x];x++)
00577 if (!strchr("( )-.", n[x]))
00578 n[y++] = n[x];
00579 n[y] = '\0';
00580 }
|
|
||||||||||||||||||||
|
Read samples into the state machine.
Definition at line 238 of file callerid.c. References ast_log(), 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, malloc, 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. 00239 {
00240 int mylen = len;
00241 int olen;
00242 int b = 'X';
00243 int res;
00244 int x;
00245 short *buf = malloc(2 * len + cid->oldlen);
00246 short *obuf = buf;
00247 if (!buf) {
00248 ast_log(LOG_WARNING, "Out of memory\n");
00249 return -1;
00250 }
00251 memset(buf, 0, 2 * len + cid->oldlen);
00252 memcpy(buf, cid->oldstuff, cid->oldlen);
00253 mylen += cid->oldlen/2;
00254 for (x=0;x<len;x++)
00255 buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
00256 while(mylen >= 160) {
00257 olen = mylen;
00258 res = fsk_serie(&cid->fskd, buf, &mylen, &b);
00259 if (mylen < 0) {
00260 ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d)\n", mylen);
00261 return -1;
00262 }
00263 buf += (olen - mylen);
00264 if (res < 0) {
00265 ast_log(LOG_NOTICE, "fsk_serie failed\n");
00266 return -1;
00267 }
00268 if (res == 1) {
00269 /* Ignore invalid bytes */
00270 if (b > 0xff)
00271 continue;
00272 switch(cid->sawflag) {
00273 case 0: /* Look for flag */
00274 if (b == 'U')
00275 cid->sawflag = 2;
00276 break;
00277 case 2: /* Get lead-in */
00278 if ((b == 0x04) || (b == 0x80)) {
00279 cid->type = b;
00280 cid->sawflag = 3;
00281 cid->cksum = b;
00282 }
00283 break;
00284 case 3: /* Get length */
00285 /* Not a lead in. We're ready */
00286 cid->sawflag = 4;
00287 cid->len = b;
00288 cid->pos = 0;
00289 cid->cksum += b;
00290 break;
00291 case 4: /* Retrieve message */
00292 if (cid->pos >= 128) {
00293 ast_log(LOG_WARNING, "Caller ID too long???\n");
00294 return -1;
00295 }
00296 cid->rawdata[cid->pos++] = b;
00297 cid->len--;
00298 cid->cksum += b;
00299 if (!cid->len) {
00300 cid->rawdata[cid->pos] = '\0';
00301 cid->sawflag = 5;
00302 }
00303 break;
00304 case 5: /* Check checksum */
00305 if (b != (256 - (cid->cksum & 0xff))) {
00306 ast_log(LOG_NOTICE, "Caller*ID failed checksum\n");
00307 /* Try again */
00308 cid->sawflag = 0;
00309 break;
00310 }
00311
00312 cid->number[0] = '\0';
00313 cid->name[0] = '\0';
00314 /* If we get this far we're fine. */
00315 if (cid->type == 0x80) {
00316 /* MDMF */
00317 /* Go through each element and process */
00318 for (x=0;x< cid->pos;) {
00319 switch(cid->rawdata[x++]) {
00320 case 1:
00321 /* Date */
00322 break;
00323 case 2: /* Number */
00324 case 3: /* Number (for Zebble) */
00325 case 4: /* Number */
00326 res = cid->rawdata[x];
00327 if (res > 32) {
00328 ast_log(LOG_NOTICE, "Truncating long caller ID number from %d bytes to 32\n", cid->rawdata[x]);
00329 res = 32;
00330 }
00331 if (ast_strlen_zero(cid->number)) {
00332 memcpy(cid->number, cid->rawdata + x + 1, res);
00333 /* Null terminate */
00334 cid->number[res] = '\0';
00335 }
00336 break;
00337 case 6: /* Stentor Call Qualifier (ie. Long Distance call) */
00338 break;
00339 case 7: /* Name */
00340 case 8: /* Name */
00341 res = cid->rawdata[x];
00342 if (res > 32) {
00343 ast_log(LOG_NOTICE, "Truncating long caller ID name from %d bytes to 32\n", cid->rawdata[x]);
00344 res = 32;
00345 }
00346 memcpy(cid->name, cid->rawdata + x + 1, res);
00347 cid->name[res] = '\0';
00348 break;
00349 case 17: /* UK: Call type, 1=Voice Call, 2=Ringback when free, 129=Message waiting */
00350 case 19: /* UK: Network message system status (Number of messages waiting) */
00351 case 22: /* Something French */
00352 break;
00353 default:
00354 ast_log(LOG_NOTICE, "Unknown IE %d\n", cid->rawdata[x-1]);
00355 }
00356 x += cid->rawdata[x];
00357 x++;
00358 }
00359 } else {
00360 /* SDMF */
00361 strncpy(cid->number, cid->rawdata + 8, sizeof(cid->number)-1);
00362 }
00363 /* Update flags */
00364 cid->flags = 0;
00365 if (!strcmp(cid->number, "P")) {
00366 strcpy(cid->number, "");
00367 cid->flags |= CID_PRIVATE_NUMBER;
00368 } else if (!strcmp(cid->number, "O") || ast_strlen_zero(cid->number)) {
00369 strcpy(cid->number, "");
00370 cid->flags |= CID_UNKNOWN_NUMBER;
00371 }
00372 if (!strcmp(cid->name, "P")) {
00373 strcpy(cid->name, "");
00374 cid->flags |= CID_PRIVATE_NAME;
00375 } else if (!strcmp(cid->name, "O") || ast_strlen_zero(cid->name)) {
00376 strcpy(cid->name, "");
00377 cid->flags |= CID_UNKNOWN_NAME;
00378 }
00379 return 1;
00380 break;
00381 default:
00382 ast_log(LOG_ERROR, "Dunno what to do with a digit in sawflag %d\n", cid->sawflag);
00383 }
00384 }
00385 }
00386 if (mylen) {
00387 memcpy(cid->oldstuff, buf, mylen * 2);
00388 cid->oldlen = mylen * 2;
00389 } else
00390 cid->oldlen = 0;
00391 free(obuf);
00392 return 0;
00393 }
|
|
|
Free a callerID state.
Definition at line 395 of file callerid.c. References free. 00396 {
00397 free(cid);
00398 }
|
|
||||||||||||||||||||||||||||
|
Generates a CallerID FSK stream in ulaw format suitable for transmission.
Definition at line 531 of file callerid.c. References PUT_BYTE, PUT_CLID, and PUT_CLID_MARKMS. 00532 {
00533 int bytes=0;
00534 int x, sum;
00535 int len;
00536 /* Initial carriers (real/imaginary) */
00537 float cr = 1.0;
00538 float ci = 0.0;
00539 float scont = 0.0;
00540 unsigned char msg[256];
00541 len = callerid_genmsg(msg, sizeof(msg), number, name, flags);
00542 if (!callwaiting) {
00543 /* Wait a half a second */
00544 for (x=0;x<4000;x++)
00545 PUT_BYTE(0x7f);
00546 /* Transmit 30 0x55's (looks like a square wave) for channel seizure */
00547 for (x=0;x<30;x++)
00548 PUT_CLID(0x55);
00549 }
00550 /* Send 150ms of callerid marks */
00551 for (x=0;x<150;x++)
00552 PUT_CLID_MARKMS;
00553 /* Send 0x80 indicating MDMF format */
00554 PUT_CLID(0x80);
00555 /* Put length of whole message */
00556 PUT_CLID(len);
00557 sum = 0x80 + strlen(msg);
00558 /* Put each character of message and update checksum */
00559 for (x=0;x<len; x++) {
00560 PUT_CLID(msg[x]);
00561 sum += msg[x];
00562 }
00563 /* Send 2's compliment of sum */
00564 PUT_CLID(256 - (sum & 255));
00565
00566 /* Send 50 more ms of marks */
00567 for (x=0;x<50;x++)
00568 PUT_CLID_MARKMS;
00569
00570 return bytes;
00571 }
|
|
||||||||||||||||||||
|
Extract info out of callerID state machine. Flags are listed above.
Returns nothing. Definition at line 143 of file callerid.c. References CID_PRIVATE_NUMBER, CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, callerid_state::flags, callerid_state::name, and callerid_state::number. 00144 {
00145 *flags = cid->flags;
00146 if (cid->flags & (CID_UNKNOWN_NAME | CID_PRIVATE_NUMBER))
00147 *name = NULL;
00148 else
00149 *name = cid->name;
00150 if (cid->flags & (CID_UNKNOWN_NUMBER | CID_PRIVATE_NUMBER))
00151 *number = NULL;
00152 else
00153 *number = cid->number;
00154 }
|
|
||||||||||||||||
|
Get and parse DTMF-based callerid.
Definition at line 156 of file callerid.c. References ast_log(), CID_PRIVATE_NUMBER, CID_UNKNOWN_NUMBER, LOG_DEBUG, and LOG_WARNING. 00157 {
00158 int i;
00159 int code;
00160
00161 /* "Clear" the number-buffer. */
00162 number[0] = 0;
00163
00164 if (strlen(cidstring) < 2) {
00165 ast_log(LOG_DEBUG, "No cid detected\n");
00166 *flags = CID_UNKNOWN_NUMBER;
00167 return;
00168 }
00169
00170 /* Detect protocol and special types */
00171 if (cidstring[0] == 'B') {
00172 /* Handle special codes */
00173 code = atoi(&cidstring[1]);
00174 if (code == 0)
00175 *flags = CID_UNKNOWN_NUMBER;
00176 else if (code == 10)
00177 *flags = CID_PRIVATE_NUMBER;
00178 else
00179 ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code);
00180 } else if (cidstring[0] == 'D' && cidstring[2] == '#') {
00181 /* .DK special code */
00182 if (cidstring[1] == '1')
00183 *flags = CID_PRIVATE_NUMBER;
00184 if (cidstring[1] == '2' || cidstring[1] == '3')
00185 *flags = CID_UNKNOWN_NUMBER;
00186 } else if (cidstring[0] == 'D' || cidstring[0] == 'A') {
00187 /* "Standard" callerid */
00188 for (i = 1; i < strlen(cidstring); i++ ) {
00189 if (cidstring[i] == 'C' || cidstring[i] == '#')
00190 break;
00191 if (isdigit(cidstring[i]))
00192 number[i-1] = cidstring[i];
00193 else
00194 ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n",
00195 cidstring[i]);
00196 }
00197 number[i-1] = 0;
00198 } else if (isdigit(cidstring[0])) {
00199 /* It begins with a digit, so we parse it as a number and hope
00200 * for the best */
00201 ast_log(LOG_WARNING, "Couldn't detect start-character. CID "
00202 "parsing might be unreliable\n");
00203 for (i = 0; i < strlen(cidstring); i++) {
00204 if (isdigit(cidstring[i]))
00205 number[i] = cidstring[i];
00206 else
00207 break;
00208 }
00209 number[i] = 0;
00210 } else {
00211 ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n",
00212 cidstring[0]);
00213 *flags = CID_UNKNOWN_NUMBER;
00214 }
00215 }
|
|
|
CallerID Initialization. Initializes the callerid system. Mostly stuff for inverse FFT Definition at line 96 of file callerid.c. References CALLERID_MARK, CALLERID_SPACE, CAS_FREQ1, CAS_FREQ2, casdi1, casdi2, casdr1, casdr2, cid_di, cid_dr, SAS_FREQ, sasdi, and sasdr. Referenced by main(). 00097 {
00098 /* Initialize stuff for inverse FFT */
00099 cid_dr[0] = cos(CALLERID_SPACE * 2.0 * M_PI / 8000.0);
00100 cid_di[0] = sin(CALLERID_SPACE * 2.0 * M_PI / 8000.0);
00101 cid_dr[1] = cos(CALLERID_MARK * 2.0 * M_PI / 8000.0);
00102 cid_di[1] = sin(CALLERID_MARK * 2.0 * M_PI / 8000.0);
00103 sasdr = cos(SAS_FREQ * 2.0 * M_PI / 8000.0);
00104 sasdi = sin(SAS_FREQ * 2.0 * M_PI / 8000.0);
00105 casdr1 = cos(CAS_FREQ1 * 2.0 * M_PI / 8000.0);
00106 casdi1 = sin(CAS_FREQ1 * 2.0 * M_PI / 8000.0);
00107 casdr2 = cos(CAS_FREQ2 * 2.0 * M_PI / 8000.0);
00108 casdi2 = sin(CAS_FREQ2 * 2.0 * M_PI / 8000.0);
00109 }
|
|
|
Create a callerID state machine.
Definition at line 111 of file callerid.c. References ast_log(), CID_UNKNOWN_NAME, CID_UNKNOWN_NUMBER, LOG_WARNING, and malloc. 00112 {
00113 struct callerid_state *cid;
00114 cid = malloc(sizeof(struct callerid_state));
00115 if (cid) {
00116 memset(cid, 0, sizeof(struct callerid_state));
00117 cid->fskd.spb = 7; /* 1200 baud */
00118 cid->fskd.hdlc = 0; /* Async */
00119 cid->fskd.nbit = 8; /* 8 bits */
00120 cid->fskd.nstop = 1; /* 1 stop bit */
00121 cid->fskd.paridad = 0; /* No parity */
00122 cid->fskd.bw=1; /* Filter 800 Hz */
00123 if (cid_signalling == 2) { /* v23 signalling */
00124 cid->fskd.f_mark_idx = 4; /* 1300 Hz */
00125 cid->fskd.f_space_idx = 5; /* 2100 Hz */
00126 } else { /* Bell 202 signalling as default */
00127 cid->fskd.f_mark_idx = 2; /* 1200 Hz */
00128 cid->fskd.f_space_idx = 3; /* 2200 Hz */
00129 }
00130 cid->fskd.pcola = 0; /* No clue */
00131 cid->fskd.cont = 0; /* Digital PLL reset */
00132 cid->fskd.x0 = 0.0;
00133 cid->fskd.state = 0;
00134 memset(cid->name, 0, sizeof(cid->name));
00135 memset(cid->number, 0, sizeof(cid->number));
00136 cid->flags = CID_UNKNOWN_NAME | CID_UNKNOWN_NUMBER;
00137 cid->pos = 0;
00138 } else
00139 ast_log(LOG_WARNING, "Out of memory\n");
00140 return cid;
00141 }
|
|
||||||||||||||||||||
|
Generate message waiting indicator.
Definition at line 469 of file callerid.c. References PUT_BYTE, PUT_CLID, and PUT_CLID_MARKMS. 00470 {
00471 unsigned char msg[256];
00472 int len=0;
00473 int sum;
00474 int x;
00475 int bytes = 0;
00476 float cr = 1.0;
00477 float ci = 0.0;
00478 float scont = 0.0;
00479 if (mdmf) {
00480 /* MDMF Message waiting */
00481 msg[len++] = 0x82;
00482 /* Length is 3 */
00483 msg[len++] = 3;
00484 /* IE is "Message Waiting Parameter" */
00485 msg[len++] = 0xb;
00486 /* Length of IE is one */
00487 msg[len++] = 1;
00488 /* Active or not */
00489 if (active)
00490 msg[len++] = 0xff;
00491 else
00492 msg[len++] = 0x00;
00493 } else {
00494 /* SDMF Message waiting */
00495 msg[len++] = 0x6;
00496 /* Length is 3 */
00497 msg[len++] = 3;
00498 if (active) {
00499 msg[len++] = 0x42;
00500 msg[len++] = 0x42;
00501 msg[len++] = 0x42;
00502 } else {
00503 msg[len++] = 0x6f;
00504 msg[len++] = 0x6f;
00505 msg[len++] = 0x6f;
00506 }
00507 }
00508 sum = 0;
00509 for (x=0;x<len;x++)
00510 sum += msg[x];
00511 sum = (256 - (sum & 255));
00512 msg[len++] = sum;
00513 /* Wait a half a second */
00514 for (x=0;x<4000;x++)
00515 PUT_BYTE(0x7f);
00516 /* Transmit 30 0x55's (looks like a square wave) for channel seizure */
00517 for (x=0;x<30;x++)
00518 PUT_CLID(0x55);
00519 /* Send 170ms of callerid marks */
00520 for (x=0;x<170;x++)
00521 PUT_CLID_MARKMS;
00522 for (x=0;x<len;x++) {
00523 PUT_CLID(msg[x]);
00524 }
00525 /* Send 50 more ms of marks */
00526 for (x=0;x<50;x++)
00527 PUT_CLID_MARKMS;
00528 return bytes;
00529 }
|
|
|
Definition at line 48 of file callerid.c. Referenced by callerid_init(). |
|
|
Definition at line 48 of file callerid.c. Referenced by callerid_init(). |
|
|
Definition at line 49 of file callerid.c. |
1.4.2