Skip to content
Snippets Groups Projects
Commit a6a0a8a2 authored by Olle Johansson's avatar Olle Johansson
Browse files

- Formatting fixes

- Doxygen


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16011 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 1caeee1c
No related branches found
No related tags found
No related merge requests found
...@@ -219,7 +219,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags) ...@@ -219,7 +219,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
"parsing might be unreliable\n"); "parsing might be unreliable\n");
for (i = 0; i < strlen(cidstring); i++) { for (i = 0; i < strlen(cidstring); i++) {
if (isdigit(cidstring[i])) if (isdigit(cidstring[i]))
number[i] = cidstring[i]; number[i] = cidstring[i];
else else
break; break;
} }
...@@ -254,21 +254,24 @@ int ast_gen_cas(unsigned char *outbuf, int sendsas, int len, int codec) ...@@ -254,21 +254,24 @@ int ast_gen_cas(unsigned char *outbuf, int sendsas, int len, int codec)
static unsigned short calc_crc(unsigned short crc, unsigned char data) static unsigned short calc_crc(unsigned short crc, unsigned char data)
{ {
unsigned int i, j, org, dst; unsigned int i, j, org, dst;
org = data; org = data;
dst = 0; dst = 0;
for (i=0; i<CHAR_BIT; i++) {
org <<= 1; for (i=0; i < CHAR_BIT; i++) {
dst >>= 1; org <<= 1;
if (org & 0x100) { dst >>= 1;
dst |= 0x80; if (org & 0x100) {
} dst |= 0x80;
} }
data = (unsigned char)dst; }
data = (unsigned char)dst;
crc ^= (unsigned int)data << (16 - CHAR_BIT); crc ^= (unsigned int)data << (16 - CHAR_BIT);
for ( j=0; j<CHAR_BIT; j++ ) { for ( j=0; j<CHAR_BIT; j++ ) {
if ( crc & 0x8000U ) crc = (crc << 1) ^ 0x1021U ; if ( crc & 0x8000U )
else crc <<= 1 ; crc = (crc << 1) ^ 0x1021U ;
else
crc <<= 1 ;
} }
return crc; return crc;
} }
...@@ -296,7 +299,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i ...@@ -296,7 +299,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]); buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
while (mylen >= 160) { while (mylen >= 160) {
b = b2 = 0 ; b = b2 = 0 ;
olen = mylen; olen = mylen;
res = fsk_serie(&cid->fskd, buf, &mylen, &b); res = fsk_serie(&cid->fskd, buf, &mylen, &b);
...@@ -407,103 +410,108 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i ...@@ -407,103 +410,108 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
/* extract caller id data */ /* extract caller id data */
for (x=0; x<cid->pos; ) { for (x=0; x<cid->pos; ) {
switch (cid->rawdata[x++]) { switch (cid->rawdata[x++]) {
case 0x02: /* caller id number */ case 0x02: /* caller id number */
cid->number[0] = '\0'; cid->number[0] = '\0';
cid->name[0] = '\0'; cid->name[0] = '\0';
cid->flags = 0; cid->flags = 0;
res = cid->rawdata[x++]; res = cid->rawdata[x++];
ast_copy_string(cid->number, &cid->rawdata[x], res+1 ); ast_copy_string(cid->number, &cid->rawdata[x], res+1 );
x += res; x += res;
break; break;
case 0x21: /* additional information */ case 0x21: /* additional information */
/* length */ /* length */
x++; x++;
/* number type */ /* number type */
switch (cid->rawdata[x]) { switch (cid->rawdata[x]) {
case 0x00: /* unknown */ case 0x00: /* unknown */
case 0x01: /* international number */ case 0x01: /* international number */
case 0x02: /* domestic number */ case 0x02: /* domestic number */
case 0x03: /* network */ case 0x03: /* network */
case 0x04: /* local call */ case 0x04: /* local call */
case 0x06: /* short dial number */ case 0x06: /* short dial number */
case 0x07: /* reserved */ case 0x07: /* reserved */
default: /* reserved */ default: /* reserved */
ast_log(LOG_NOTICE, "cid info:#1=%X\n", cid->rawdata[x]); if (option_debug > 1)
break ; ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]);
}
x++;
/* numbering plan octed 4 */
x++;
/* numbering plan octed 5 */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* recommendation E.164 ISDN */
case 0x03: /* recommendation X.121 */
case 0x04: /* telex dial plan */
case 0x08: /* domestic dial plan */
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
ast_log(LOG_NOTICE, "cid info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
break ; break ;
case 0x04: /* no callerid reason */ }
/* length */ x++;
x++; /* numbering plan octed 4 */
/* no callerid reason code */ x++;
switch (cid->rawdata[x]) { /* numbering plan octed 5 */
case 'P': /* caller id denied by user */ switch (cid->rawdata[x]) {
case 'O': /* service not available */ case 0x00: /* unknown */
case 'C': /* pay phone */ case 0x01: /* recommendation E.164 ISDN */
case 'S': /* service congested */ case 0x03: /* recommendation X.121 */
cid->flags |= CID_UNKNOWN_NUMBER; case 0x04: /* telex dial plan */
ast_log(LOG_NOTICE, "no cid reason:%c\n",cid->rawdata[x]); case 0x08: /* domestic dial plan */
break ; case 0x09: /* private dial plan */
} case 0x05: /* reserved */
x++; default: /* reserved */
if (option_debug > 1)
ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
break ;
case 0x04: /* no callerid reason */
/* length */
x++;
/* no callerid reason code */
switch (cid->rawdata[x]) {
case 'P': /* caller id denied by user */
case 'O': /* service not available */
case 'C': /* pay phone */
case 'S': /* service congested */
cid->flags |= CID_UNKNOWN_NUMBER;
if (option_debug > 1)
ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]);
break ;
}
x++;
break ;
case 0x09: /* dialed number */
/* length */
res = cid->rawdata[x++];
/* dialed number */
x += res;
break ;
case 0x22: /* dialed number additional information */
/* length */
x++;
/* number type */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* international number */
case 0x02: /* domestic number */
case 0x03: /* network */
case 0x04: /* local call */
case 0x06: /* short dial number */
case 0x07: /* reserved */
default: /* reserved */
if (option_debug > 1)
ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]);
break ; break ;
case 0x09: /* dialed number */ }
/* length */ x++;
res = cid->rawdata[x++]; /* numbering plan octed 4 */
/* dialed number */ x++;
x += res; /* numbering plan octed 5 */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* recommendation E.164 ISDN */
case 0x03: /* recommendation X.121 */
case 0x04: /* telex dial plan */
case 0x08: /* domestic dial plan */
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
if (option_debug > 1)
ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]);
break ; break ;
case 0x22: /* dialed number additional information */ }
/* length */ x++;
x++; break ;
/* number type */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* international number */
case 0x02: /* domestic number */
case 0x03: /* network */
case 0x04: /* local call */
case 0x06: /* short dial number */
case 0x07: /* reserved */
default: /* reserved */
ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]);
break ;
}
x++;
/* numbering plan octed 4 */
x++;
/* numbering plan octed 5 */
switch (cid->rawdata[x]) {
case 0x00: /* unknown */
case 0x01: /* recommendation E.164 ISDN */
case 0x03: /* recommendation X.121 */
case 0x04: /* telex dial plan */
case 0x08: /* domestic dial plan */
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
ast_log(LOG_NOTICE, "did info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
break ;
} }
} }
return 1; return 1;
...@@ -722,7 +730,7 @@ static int callerid_genmsg(char *msg, int size, char *number, char *name, int fl ...@@ -722,7 +730,7 @@ static int callerid_genmsg(char *msg, int size, char *number, char *name, int fl
res = snprintf(ptr, size, "\002%c", i); res = snprintf(ptr, size, "\002%c", i);
size -= res; size -= res;
ptr += res; ptr += res;
for (x=0;x<i;x++) for (x = 0; x < i; x++)
ptr[x] = number[x]; ptr[x] = number[x];
ptr[i] = '\0'; ptr[i] = '\0';
ptr += i; ptr += i;
...@@ -796,24 +804,24 @@ int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec) ...@@ -796,24 +804,24 @@ int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec)
} }
} }
sum = 0; sum = 0;
for (x=0;x<len;x++) for (x=0; x<len; x++)
sum += msg[x]; sum += msg[x];
sum = (256 - (sum & 255)); sum = (256 - (sum & 255));
msg[len++] = sum; msg[len++] = sum;
/* Wait a half a second */ /* Wait a half a second */
for (x=0;x<4000;x++) for (x=0; x<4000; x++)
PUT_BYTE(0x7f); PUT_BYTE(0x7f);
/* Transmit 30 0x55's (looks like a square wave) for channel seizure */ /* Transmit 30 0x55's (looks like a square wave) for channel seizure */
for (x=0;x<30;x++) for (x=0; x<30; x++)
PUT_CLID(0x55); PUT_CLID(0x55);
/* Send 170ms of callerid marks */ /* Send 170ms of callerid marks */
for (x=0;x<170;x++) for (x=0; x<170; x++)
PUT_CLID_MARKMS; PUT_CLID_MARKMS;
for (x=0;x<len;x++) { for (x=0; x<len; x++) {
PUT_CLID(msg[x]); PUT_CLID(msg[x]);
} }
/* Send 50 more ms of marks */ /* Send 50 more ms of marks */
for (x=0;x<50;x++) for (x=0; x<50; x++)
PUT_CLID_MARKMS; PUT_CLID_MARKMS;
return bytes; return bytes;
} }
...@@ -823,6 +831,7 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i ...@@ -823,6 +831,7 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i
int bytes=0; int bytes=0;
int x, sum; int x, sum;
int len; int len;
/* Initial carriers (real/imaginary) */ /* Initial carriers (real/imaginary) */
float cr = 1.0; float cr = 1.0;
float ci = 0.0; float ci = 0.0;
...@@ -831,14 +840,14 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i ...@@ -831,14 +840,14 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i
len = callerid_genmsg(msg, sizeof(msg), number, name, flags); len = callerid_genmsg(msg, sizeof(msg), number, name, flags);
if (!callwaiting) { if (!callwaiting) {
/* Wait a half a second */ /* Wait a half a second */
for (x=0;x<4000;x++) for (x=0; x<4000; x++)
PUT_BYTE(0x7f); PUT_BYTE(0x7f);
/* Transmit 30 0x55's (looks like a square wave) for channel seizure */ /* Transmit 30 0x55's (looks like a square wave) for channel seizure */
for (x=0;x<30;x++) for (x=0; x<30; x++)
PUT_CLID(0x55); PUT_CLID(0x55);
} }
/* Send 150ms of callerid marks */ /* Send 150ms of callerid marks */
for (x=0;x<150;x++) for (x=0; x<150; x++)
PUT_CLID_MARKMS; PUT_CLID_MARKMS;
/* Send 0x80 indicating MDMF format */ /* Send 0x80 indicating MDMF format */
PUT_CLID(0x80); PUT_CLID(0x80);
...@@ -846,7 +855,7 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i ...@@ -846,7 +855,7 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i
PUT_CLID(len); PUT_CLID(len);
sum = 0x80 + strlen(msg); sum = 0x80 + strlen(msg);
/* Put each character of message and update checksum */ /* Put each character of message and update checksum */
for (x=0;x<len; x++) { for (x=0; x<len; x++) {
PUT_CLID(msg[x]); PUT_CLID(msg[x]);
sum += msg[x]; sum += msg[x];
} }
...@@ -854,21 +863,22 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i ...@@ -854,21 +863,22 @@ int callerid_generate(unsigned char *buf, char *number, char *name, int flags, i
PUT_CLID(256 - (sum & 255)); PUT_CLID(256 - (sum & 255));
/* Send 50 more ms of marks */ /* Send 50 more ms of marks */
for (x=0;x<50;x++) for (x=0; x<50; x++)
PUT_CLID_MARKMS; PUT_CLID_MARKMS;
return bytes; return bytes;
} }
/* /*! \brief Clean up phone string
* remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets. * remove '(', ' ', ')', non-trailing '.', and '-' not in square brackets.
* Basically, remove anything that could be invalid in a pattern. * Basically, remove anything that could be invalid in a pattern.
*/ */
void ast_shrink_phone_number(char *n) void ast_shrink_phone_number(char *n)
{ {
int x,y=0; int x, y=0;
int bracketed=0; int bracketed = 0;
for (x=0;n[x];x++) {
for (x=0; n[x]; x++) {
switch(n[x]) { switch(n[x]) {
case '[': case '[':
bracketed++; bracketed++;
...@@ -936,6 +946,7 @@ int ast_callerid_parse(char *instr, char **name, char **location) ...@@ -936,6 +946,7 @@ int ast_callerid_parse(char *instr, char **name, char **location)
} }
} else { /* no valid brackets */ } else { /* no valid brackets */
char tmp[256]; char tmp[256];
ast_copy_string(tmp, instr, sizeof(tmp)); ast_copy_string(tmp, instr, sizeof(tmp));
ast_shrink_phone_number(tmp); ast_shrink_phone_number(tmp);
if (ast_isphonenumber(tmp)) { /* Assume it's just a location */ if (ast_isphonenumber(tmp)) { /* Assume it's just a location */
...@@ -994,6 +1005,7 @@ int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int ...@@ -994,6 +1005,7 @@ int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int
{ {
char *tmp; char *tmp;
char *l = NULL, *n = NULL; char *l = NULL, *n = NULL;
tmp = ast_strdupa(buf); tmp = ast_strdupa(buf);
if (!tmp) { if (!tmp) {
name[0] = '\0'; name[0] = '\0';
...@@ -1013,6 +1025,7 @@ int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int ...@@ -1013,6 +1025,7 @@ int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int
return 0; return 0;
} }
/*! \brief Translation table for Caller ID Presentation settings */
static struct { static struct {
int val; int val;
char *name; char *name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment