126static volatile unsigned int seq;           
 
  138static const signed short wave[] = {
 
  139    0, 392, 782, 1167, 1545, 1913, 2270, 2612, 2939, 3247, 3536, 3802, 4045, 4263, 4455, 4619, 4755, 4862, 4938, 4985,
 
  140    5000, 4985, 4938, 4862, 4755, 4619, 4455, 4263, 4045, 3802, 3536, 3247, 2939, 2612, 2270, 1913, 1545, 1167, 782, 392,
 
  141    0, -392, -782, -1167,
 
  142     -1545, -1913, -2270, -2612, -2939, -3247, -3536, -3802, -4045, -4263, -4455, -4619, -4755, -4862, -4938, -4985, -5000,
 
  144    -4755, -4619, -4455, -4263, -4045, -3802, -3536, -3247, -2939, -2612, -2270, -1913, -1545, -1167, -782, -392
 
 
  148static unsigned char wavea[80];
 
  151#define __OUT_FMT ast_format_alaw 
  155#define __OUT_FMT ast_format_slin 
  198    0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC,
 
  199    0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
 
  200    0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8,
 
  201    0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
 
  202    ' ', 
'!', 
'"', 
'#', 164, 
'%', 
'&', 39, 
'(', 
')', 
'*', 
'+', 
',', 
'-', 
'.', 
'/',
 
  203    '0', 
'1', 
'2', 
'3', 
'4', 
'5', 
'6', 
'7', 
'8', 
'9', 
':', 
';', 
'<', 
'=', 
'>', 
'?',
 
  204    161, 
'A', 
'B', 
'C', 
'D', 
'E', 
'F', 
'G', 
'H', 
'I', 
'J', 
'K', 
'L', 
'M', 
'N', 
'O',
 
  205    'P', 
'Q', 
'R', 
'S', 
'T', 
'U', 
'V', 
'W', 
'X', 
'Y', 
'Z', 196, 214, 209, 220, 167,
 
  206    191, 
'a', 
'b', 
'c', 
'd', 
'e', 
'f', 
'g', 
'h', 
'i', 
'j', 
'k', 
'l', 
'm', 
'n', 
'o',
 
  207    'p', 
'q', 
'r', 
's', 
't', 
'u', 
'v', 
'w', 
'x', 
'y', 
'z', 228, 246, 241, 252, 224,
 
 
  211    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x000C, 0, 0, 0, 0, 0,
 
  212    0, 0, 0, 0, 0x005E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
  213    0, 0, 0, 0, 0, 0, 0, 0, 0x007B, 0x007D, 0, 0, 0, 0, 0, 0x005C,
 
  214    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x005B, 0x007E, 0x005D, 0,
 
  215    0x007C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
  216    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
  217    0, 0, 0, 0, 0, 0x20AC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
  218    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 
 
  287#define is7bit(dcs)  ( ((dcs) & 0xC0) ? (!((dcs) & 4) ) : (((dcs) & 0xc) == 0) ) 
  288#define is8bit(dcs)  ( ((dcs) & 0xC0) ? ( ((dcs) & 4) ) : (((dcs) & 0xc) == 4) ) 
  289#define is16bit(dcs) ( ((dcs) & 0xC0) ? 0               : (((dcs) & 0xc) == 8) ) 
  312    struct timeval local = { t, 0 };
 
 
  323    unsigned char *p = *pp;
 
  332        if (*p < 0xC2 || (p[1] & 0xC0) != 0x80) {
 
  336        return ((*p & 0x1F) << 6) + (p[1] & 0x3F);
 
  339        if ((*p == 0xE0 && p[1] < 0xA0) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80) {
 
  343        return ((*p & 0x0F) << 12) + ((p[1] & 0x3F) << 6) + (p[2] & 0x3F);
 
  346        if ((*p == 0xF0 && p[1] < 0x90) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80) {
 
  350        return ((*p & 0x07) << 18) + ((p[1] & 0x3F) << 12) + ((p[2] & 0x3F) << 6) + (p[3] & 0x3F);
 
  353        if ((*p == 0xF8 && p[1] < 0x88) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
 
  354            || (p[4] & 0xC0) != 0x80) {
 
  358        return ((*p & 0x03) << 24) + ((p[1] & 0x3F) << 18) + ((p[2] & 0x3F) << 12) + ((p[3] & 0x3F) << 6) + (p[4] & 0x3F);
 
  361        if ((*p == 0xFC && p[1] < 0x84) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
 
  362            || (p[4] & 0xC0) != 0x80 || (p[5] & 0xC0) != 0x80) {
 
  366        return ((*p & 0x01) << 30) + ((p[1] & 0x3F) << 24) + ((p[2] & 0x3F) << 18) + ((p[3] & 0x3F) << 12) + ((p[4] & 0x3F) << 6) + (p[5] & 0x3F);
 
 
  375static int packsms7(
unsigned char *o, 
int udhl, 
unsigned char *udh, 
int udl, 
unsigned short *ud)
 
  415        if (v == 128  && u && n + 1 < 
SMSLEN) {
 
  417            for (v = 0; v < 128 && 
escapes[v] != u; v++);
 
  425                    o[p] = (27 >> (7 - 
b));
 
  438            o[p] = (v >> (7 - 
b));
 
 
  452static int packsms8(
unsigned char *o, 
int udhl, 
unsigned char *udh, 
int udl, 
unsigned short *ud)
 
  472        if (u < 0 || u > 0xFF) {
 
 
  491static int packsms16(
unsigned char *o, 
int udhl, 
unsigned char *udh, 
int udl, 
unsigned short *ud)
 
 
  526static int packsms(
unsigned char dcs, 
unsigned char *base, 
unsigned int udhl, 
unsigned char *udh, 
int udl, 
unsigned short *ud)
 
  528    unsigned char *p = base;
 
  535            if ((l = 
packsms7(p + 1, udhl, udh, udl, ud)) < 0) {
 
  539            p += (l * 7 + 7) / 8;
 
  541            if ((l = 
packsms8(p + 1, udhl, udh, udl, ud)) < 0) {
 
  547            if ((l = 
packsms16(p + 1, udhl, udh, udl, ud)) < 0) {
 
 
  562    struct timeval topack = { w, 0 };
 
  566#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__) 
  569    z = timezone / 60 / 15;
 
  572    *o++ = (((t.
tm_mon + 1) % 10) << 4) + (t.
tm_mon + 1) / 10;
 
  578        *o++ = (((-z) % 10) << 4) + (-z) / 10 + 0x08;
 
  580        *o++ = ((z % 10) << 4) + z / 10;
 
 
  589    t.
tm_year = 100 + (i[0] & 0xF) * 10 + (i[0] >> 4);
 
  590    t.
tm_mon = (i[1] & 0xF) * 10 + (i[1] >> 4) - 1;
 
  591    t.
tm_mday = (i[2] & 0xF) * 10 + (i[2] >> 4);
 
  592    t.
tm_hour = (i[3] & 0xF) * 10 + (i[3] >> 4);
 
  593    t.
tm_min = (i[4] & 0xF) * 10 + (i[4] >> 4);
 
  594    t.
tm_sec = (i[5] & 0xF) * 10 + (i[5] >> 4);
 
  597        t.
tm_min += 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
 
  599        t.
tm_min -= 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
 
 
  608static void unpacksms7(
unsigned char *i, 
unsigned char l, 
unsigned char *udh, 
int *udhl, 
unsigned short *ud, 
int *udl, 
char udhi)
 
  610    unsigned char b = 0, p = 0;
 
  611    unsigned short *o = ud;
 
  641            v = ((i[p] >> 
b) & 0x7F);       
 
  643            v = ((((i[p] >> 
b) + (i[p + 1] << (8 - 
b)))) & 0x7F);
 
  651        if (o > ud && o[-1] == 0x00A0 && 
escapes[v]) {
 
 
  664static void unpacksms8(
unsigned char *i, 
unsigned char l, 
unsigned char *udh, 
int *udhl, 
unsigned short *ud, 
int *udl, 
char udhi)
 
  666    unsigned short *o = ud;
 
 
  690static void unpacksms16(
unsigned char *i, 
unsigned char l, 
unsigned char *udh, 
int *udhl, 
unsigned short *ud, 
int *udl, 
char udhi)
 
  692    unsigned short *o = ud;
 
 
  718static int unpacksms(
unsigned char dcs, 
unsigned char *i, 
unsigned char *udh, 
int *udhl, 
unsigned short *ud, 
int *udl, 
char udhi)
 
 
  736    unsigned char l = i[0], p;
 
  740    for (p = 0; p < l; p++) {
 
  742            *o++ = (i[2 + p / 2] >> 4) + 
'0';
 
  744            *o++ = (i[2 + p / 2] & 0xF) + 
'0';
 
 
  767            o[p++] |= ((*i & 0xF) << 4);
 
 
  784    if (*h->
oa == 
'\0' && *h->
da == 
'\0') {
 
  789        char line[1000], mrs[3] = 
"", *p;
 
  794            snprintf(mrs, 
sizeof(mrs), 
"%02hhX", (
unsigned char)h->
mr);
 
  796        snprintf(line, 
sizeof(line), 
"%s %c%c%c%s %s %s %s ",
 
  800        p = line + strlen(line);
 
  803            p += snprintf(p, 1000 - strlen(line), 
"udl=%d", h->
udl);
 
  805            for (n = 0; n < h->
udl; n++) {
 
  806                if (h->
ud[n] == 
'\\') {
 
  809                } 
else if (h->
ud[n] == 
'\n') {
 
  812                } 
else if (h->
ud[n] == 
'\r') {
 
  815                } 
else if (h->
ud[n] < 32 || h->
ud[n] == 127) {
 
  824        if (write(o, line, strlen(line)) < 0) {
 
 
  849        while (fgets (line, 
sizeof(line), s)) { 
 
  852            for (p = line; *p && *p != 
'\n' && *p != 
'\r'; p++);
 
  855            if (!*p || *p == 
';') {
 
  858            while (isalnum(*p)) {
 
  862            while (isspace (*p)) {
 
  867                if (!strcmp(line, 
"ud")) {  
 
  870                    while (*p && o < 
SMSLEN) {
 
  879                    while (isspace (*p)) {
 
  882                    if (!strcmp(line, 
"oa") && strlen(p) < 
sizeof(h->
oa)) {
 
  884                    } 
else if (!strcmp(line, 
"da") && strlen(p) < 
sizeof(h->
oa)) {
 
  886                    } 
else if (!strcmp(line, 
"pid")) {
 
  888                    } 
else if (!strcmp(line, 
"dcs")) {
 
  891                    } 
else if (!strcmp(line, 
"mr")) {
 
  893                    } 
else if (!strcmp(line, 
"srr")) {
 
  894                        h->
srr = (atoi(p) ? 1 : 0);
 
  895                    } 
else if (!strcmp(line, 
"vp")) {
 
  897                    } 
else if (!strcmp(line, 
"rp")) {
 
  898                        h->
rp = (atoi(p) ? 1 : 0);
 
  899                    } 
else if (!strcmp(line, 
"scts")) {    
 
  900                        int Y, m, 
d, H, M, 
S;
 
  902                        if (sscanf(p, 
"%4d-%2d-%2dT%2d:%2d:%2d", &Y, &m, &
d, &H, &M, &
S) == 6) {
 
  912                            if (h->
scts.tv_sec == 0) {
 
  920            } 
else if (*p == 
'#') {                   
 
  924                    if (!strcmp(line, 
"ud")) {        
 
  926                        while (*p && o < 
SMSLEN) {
 
  927                            if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) {
 
  929                                    (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) +
 
  930                                    (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
 
  931                                    (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF));
 
  941                } 
else if (!strcmp(line, 
"ud")) {       
 
  943                    while (*p && o < 
SMSLEN) {
 
  944                        if (isxdigit(*p) && isxdigit(p[1])) {
 
  945                            h->
ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
 
  955                } 
else if (!strcmp(line, 
"udh")) {      
 
  958                    while (*p && o < 
SMSLEN) {
 
  959                        if (isxdigit(*p) && isxdigit(p[1])) {
 
  960                            h->
udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
 
 
 1007    char fn[200] = 
"", fn2[200] = 
"";
 
 1017    snprintf(fn2 + strlen(fn2), 
sizeof(fn2) - strlen(fn2), 
"/%s.%s-%u", h->
queue, 
isodate(h->
scts.tv_sec, 
buf, 
sizeof(
buf)), 
seq++);
 
 1018    snprintf(fn + strlen(fn), 
sizeof(fn) - strlen(fn), 
"/.%s", fn2 + strlen(fn) + 1);
 
 1019    if ((o = fopen(fn, 
"w")) == 
NULL) {
 
 1024        fprintf(o, 
"oa=%s\n", h->
oa);
 
 1027        fprintf(o, 
"da=%s\n", h->
da);
 
 1032        for (p = 0; p < h->
udhl; p++) {
 
 1033            fprintf(o, 
"%02hhX", (
unsigned char)h->
udh[p]);
 
 1039        for (p = 0; p < h->
udl && h->
ud[p] >= 
' '; p++);
 
 1044        for (p = 0; p < h->
udl; p++) {
 
 1045            unsigned short v = h->
ud[p];
 
 1048            } 
else if (v < 0x80) {
 
 1050            } 
else if (v < 0x800) {
 
 1051                fputc(0xC0 + (v >> 6), o);
 
 1052                fputc(0x80 + (v & 0x3F), o);
 
 1054                fputc(0xE0 + (v >> 12), o);
 
 1055                fputc(0x80 + ((v >> 6) & 0x3F), o);
 
 1056                fputc(0x80 + (v & 0x3F), o);
 
 1060        for (p = 0; p < h->
udl && h->
ud[p] >= 
' '; p++);
 
 1062            for (p = 0; p < h->
udl && h->
ud[p] < 0x100; p++);
 
 1065                for (p = 0; p < h->
udl; p++) {
 
 1066                    fprintf(o, 
"%02hhX", (
unsigned char)h->
ud[p]);
 
 1071                for (p = 0; p < h->
udl; p++) {
 
 1072                    fprintf(o, 
"%04X", (
unsigned)h->
ud[p]);
 
 1078    if (h->
scts.tv_sec) {
 
 1080        fprintf(o, 
"scts=%s\n", 
isodate(h->
scts.tv_sec, datebuf, 
sizeof(datebuf)));
 
 1083        fprintf(o, 
"pid=%d\n", h->
pid);
 
 1085    if (h->
dcs != 0xF1) {
 
 1086        fprintf(o, 
"dcs=%d\n", h->
dcs);
 
 1089        fprintf(o, 
"vp=%u\n", h->
vp);
 
 1092        fprintf(o, 
"srr=1\n");
 
 1095        fprintf(o, 
"mr=%d\n", h->
mr);
 
 1098        fprintf(o, 
"rp=1\n");
 
 1101    if (rename(fn, fn2)) {
 
 
 1114    } 
while (f && (*f->d_name == 
'.' || strncmp(f->d_name, queue, strlen(queue)) || f->d_name[strlen(queue)] != 
'.'));
 
 
 1121    unsigned char p = 3;
 
 1123        if ((h->
imsg[2] & 3) == 1) {        
 
 1126            h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
 
 1127            h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
 
 1128            h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
 
 1135            if ((h->
imsg[2] & 0x18) == 0x10) {       
 
 1136                if (h->
imsg[p] < 144) {
 
 1137                    h->
vp = (h->
imsg[p] + 1) * 5;
 
 1138                } 
else if (h->
imsg[p] < 168) {
 
 1139                    h->
vp = 720 + (h->
imsg[p] - 143) * 30;
 
 1140                } 
else if (h->
imsg[p] < 197) {
 
 1141                    h->
vp = (h->
imsg[p] - 166) * 1440;
 
 1143                    h->
vp = (h->
imsg[p] - 192) * 10080;
 
 1146            } 
else if (h->
imsg[2] & 0x18) {
 
 1152            if (p != h->
imsg[1] + 2) {
 
 1161        if (!(h->
imsg[2] & 3)) {            
 
 1163            h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
 
 1164            h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
 
 1165            h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
 
 1175            if (p != h->
imsg[1] + 2) {
 
 
 1188#define NAME_MAX 1024 
 1197    int x = h->
omsg[1] + 2;                 
 
 1202    h->
omsg[x++] = (
unsigned char)size;     
 
 1204    for (; size > 0 ; size--) {
 
 1205        h->
omsg[x++] = *data++;
 
 
 1223    struct timeval now = h->
scts;
 
 1236            strcpy(h->
oa, 
"00000000");
 
 1245            strcpy(h->
da, 
"00000000");
 
 
 1255#define MAX_DEBUG_LEN   300 
 1261    for (p = s, f = 0; f < size && f < 
MAX_DEBUG_LEN; f++, p += 3) {
 
 1262        sprintf(p, 
"%02hhX ", (
unsigned char)
buf[f]);
 
 
 1274    struct timeval now = { 0, 0 };
 
 1277    sz = h->
imsg[1] + 2;
 
 1282    for (f = 4; f < sz; ) {
 
 1284        msgsz = h->
imsg[f++];
 
 1285        msgsz += (h->
imsg[f++] * 256);
 
 1288            ast_verb(3, 
"SMS-P2 Body#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
 
 1289            if (msgsz >= 
sizeof(h->
ud)) {
 
 1290                msgsz = 
sizeof(h->
ud) - 1;
 
 1292            for (i = 0; i < msgsz; i++) {
 
 1293                h->
ud[i] = h->
imsg[f + i];
 
 1312            ast_verb(3, 
"SMS-P2 Origin#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
 
 1319            ast_verb(3, 
"SMS-P2 Destination#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
 
 
 1337static void smssend(
sms_t *h, 
char *
c)
 
 1340    for (f = 0; f < strlen(
c); f++) {
 
 1341        sscanf(&
c[f*3], 
"%x", &x);
 
 1355#define DLL2_ACK(h) ((h->framenumber & 1) ? DLL2_SMS_ACK1: DLL2_SMS_ACK1) 
 
 1413        h->
omsg[p++] = (more ? 4 : 0) + ((h->
udhl > 0) ? 0x40 : 0);
 
 1422            0x01 + (more ? 4 : 0) + (h->
srr ? 0x20 : 0) + (h->
rp ? 0x80 : 0) + (h->
vp ? 0x10 : 0) + (h->
udhi ? 0x40 : 0);
 
 1432                h->
omsg[p++] = (h->
vp + 4) / 5 - 1;
 
 1433            } 
else if (h->
vp < 1440) {
 
 1434                h->
omsg[p++] = (h->
vp - 720 + 29) / 30 + 143;
 
 1435            } 
else if (h->
vp < 43200) {
 
 1436                h->
omsg[p++] = (h->
vp + 1439) / 1440 + 166;
 
 1437            } 
else if (h->
vp < 635040) {
 
 1438                h->
omsg[p++] = (h->
vp + 10079) / 10080 + 192;
 
 
 1451    char fn[100 + NAME_MAX] = 
"";
 
 1455    *h->
da = *h->
oa = 
'\0';                 
 
 1463            snprintf(fn + strlen(fn), 
sizeof(fn) - strlen(fn), 
"/%s", f->d_name);
 
 1471    if (*h->
da || *h->
oa) {                 
 
 
 1495    char txt[259 * 3 + 1];
 
 1500    while (q < n && q < 30) {
 
 1501        sprintf(p, 
" %02hhX", msg[q++]);
 
 
 1521    switch (h->
imsg[0]) {
 
 
 1571    unsigned char c = 0, p;
 
 1574    for (p = 0; p < 
len; p++) {             
 
 1585        if (h->
omsg[0] == 0x7F) {
 
 1597        if (h->
omsg[0] == 0x93) {
 
 
 1615#define MAXSAMPLES (800) 
 1637    for (i = 0; i < 
samples; i++) {
 
 1647            if ((h->
ophasep += 12) >= 80) { 
 
 1652                } 
else if (h->
osync) {
 
 1660                    if (h->
obitp == 1) {
 
 1662                    } 
else if (h->
obitp == 2) {
 
 1664                    } 
else if (h->
obitp == 10) {
 
 
 1734    for ( ; samples-- ; data++) {
 
 1735        unsigned long long m0, m1;
 
 1741        if (h->
imag <= 500) {               
 
 1742            if (h->
idle++ == 80000) {       
 
 1771        if ((h->
ips0 += 21) >= 80) {
 
 1774        if ((h->
ipc0 += 21) >= 80) {
 
 1777        if ((h->
ips1 += 13) >= 80) {
 
 1780        if ((h->
ipc1 += 13) >= 80) {
 
 1795        bit = ((h->
ibitt > 1) ? 1 : 0);
 
 1796        if (bit != h->
ibitl) {
 
 1806        if (bit && h->
ibitc == 200) {       
 
 1810                ast_verb(3, 
"SMS protocol 2 detected\n");
 
 1823                if (h->
ibitn++ == 9) {      
 
 
 1911    if (sms_args.argc > 1) {
 
 1915    ast_verb(1, 
"sms argc %u queue <%s> opts <%s> addr <%s> body <%s>\n",
 
 1916        sms_args.argc, 
S_OR(sms_args.queue, 
""),
 
 1917        S_OR(sms_args.options, 
""),
 
 1918        S_OR(sms_args.addr, 
""),
 
 1919        S_OR(sms_args.body, 
"") );
 
 1932    if (strlen(sms_args.queue) >= 
sizeof(h.
queue)) {
 
 1938    for (p = h.
queue; *p; p++) {
 
 1971            h.
pid = 0x40 + (*
d & 0xF);
 
 1975    if (sms_args.argc > 2) {
 
 1996        up = (
unsigned char *)sms_args.body;
 
 
 2095    for (p = 0; p < 80; p++) {
 
 
A-Law to Signed linear conversion.
static char * isodate(time_t t, char *buf, int len)
static, return a date/time in ISO format
static volatile unsigned char message_ref
static int unpacksms(unsigned char dcs, unsigned char *i, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi)
general unpack - starts with length byte (octet or septet) and returns number of bytes used,...
static int packsms7(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud)
takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) and packs in to o ...
static void sms_compose1(sms_t *h, int more)
compose a message for protocol 1
static struct ast_generator smsgen
static const output_t * wave_out
static void sms_messagerx(sms_t *h)
static const unsigned short defaultalphabet[]
static void sms_readfile(sms_t *h, char *fn)
parse and delete a file
static long utf8decode(unsigned char **pp)
Reads next UCS character from NUL terminated UTF-8 string and advance pointer.
static int packsms(unsigned char dcs, unsigned char *base, unsigned int udhl, unsigned char *udh, int udl, unsigned short *ud)
general pack, with length and data, returns number of bytes of target used
static unsigned char sms_handleincoming(sms_t *h)
handle the incoming message
static void sms_messagetx(sms_t *h)
static void sms_compose2(sms_t *h, int more)
static void numcpy(char *d, char *s)
copy number, skipping non digits apart from leading +
static void unpacksms8(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi)
unpacks bytes (8 bit encoding) at i, len l septets, and places in udh and ud setting udhl and udl....
static void putdummydata_proto2(sms_t *h)
static const unsigned short escapes[]
static int packsms16(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud)
takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) and packs in to o ...
static struct timeval unpackdate(unsigned char *i)
unpack a date and return
static volatile unsigned int seq
static char * sms_hexdump(unsigned char buf[], int size, char *s)
static void packdate(unsigned char *o, time_t w)
pack a date and return
static int sms_exec(struct ast_channel *chan, const char *data)
static void * sms_alloc(struct ast_channel *chan, void *sms_t_ptr)
static void sms_process(sms_t *h, int samples, signed short *data)
static int packsms8(unsigned char *o, int udhl, unsigned char *udh, int udl, unsigned short *ud)
takes a binary header (udhl bytes at udh) and UCS-2 message (udl characters at ud) and packs in to o ...
static void unpacksms7(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi)
unpacks bytes (7 bit encoding) at i, len l septets, and places in udh and ud setting udhl and udl....
static void sms_messagerx2(sms_t *h)
static void sms_nextoutgoing(sms_t *h)
find and fill in next message, or send a REL if none waiting
static void sms_release(struct ast_channel *chan, void *data)
static void unpacksms16(unsigned char *i, unsigned char l, unsigned char *udh, int *udhl, unsigned short *ud, int *udl, char udhi)
unpacks bytes (16 bit encoding) at i, len l septets, and places in udh and ud setting udhl and udl....
static const signed short wave[]
static int load_module(void)
static int sms_handleincoming_proto2(sms_t *h)
sms_handleincoming_proto2: handle the incoming message
static char log_file[255]
static int unload_module(void)
static unsigned char unpackaddress(char *o, unsigned char *i)
unpack an address from i, return byte length, unpack to o
static const struct ast_app_option sms_options[128]
static void sms_log(sms_t *h, char status)
Log the output, and remove file.
static void adddata_proto2(sms_t *h, unsigned char msg, char *data, int size)
static unsigned char packaddress(unsigned char *o, char *i)
store an address at o, and return number of bytes used
static struct dirent * readdirqueue(DIR *d, char *queue)
read dir skipping dot files...
static void sms_debug(int dir, sms_t *h)
static void sms_writefile(sms_t *h)
white a received text message to a file
static int sms_generate(struct ast_channel *chan, void *data, int len, int samples)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdupa(s)
duplicate a string in memory from the stack
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
static void dummy(char *unused,...)
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_deactivate_generator(struct ast_channel *chan)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
ast_channel_state
ast_channel states
Generic File Format Support. Should be included by clients of the file handling routines....
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
#define ast_verb(level,...)
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
Asterisk locking-related definitions:
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define AST_MODULE_INFO_STANDARD_EXTENDED(keystr, desc)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_SPOOL_DIR
const char * ast_config_AST_LOG_DIR
Core PBX routines and definitions.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@239 data
void *(* alloc)(struct ast_channel *chan, void *params)
unsigned char udh[SMSLEN]
unsigned short ud[SMSLEN]
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.