118 static volatile unsigned int seq;
130 static const signed short wave[] = {
131 0, 392, 782, 1167, 1545, 1913, 2270, 2612, 2939, 3247, 3536, 3802, 4045, 4263, 4455, 4619, 4755, 4862, 4938, 4985,
132 5000, 4985, 4938, 4862, 4755, 4619, 4455, 4263, 4045, 3802, 3536, 3247, 2939, 2612, 2270, 1913, 1545, 1167, 782, 392,
133 0, -392, -782, -1167,
134 -1545, -1913, -2270, -2612, -2939, -3247, -3536, -3802, -4045, -4263, -4455, -4619, -4755, -4862, -4938, -4985, -5000,
136 -4755, -4619, -4455, -4263, -4045, -3802, -3536, -3247, -2939, -2612, -2270, -1913, -1545, -1167, -782, -392
140 static unsigned char wavea[80];
142 static const output_t *
wave_out = wavea;
143 #define __OUT_FMT AST_FORMAT_ALAW;
146 static const output_t *wave_out =
wave;
147 #define __OUT_FMT AST_FORMAT_SLINEAR
150 #define OSYNC_BITS 80
190 0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC,
191 0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
192 0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8,
193 0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
194 ' ',
'!',
'"',
'#', 164,
'%',
'&', 39,
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
195 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
196 161,
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
197 'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z', 196, 214, 209, 220, 167,
198 191,
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
199 'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z', 228, 246, 241, 252, 224,
203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x000C, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 0x005E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0, 0, 0, 0, 0x007B, 0x007D, 0, 0, 0, 0, 0, 0x005C,
206 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x005B, 0x007E, 0x005D, 0,
207 0x007C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
209 0, 0, 0, 0, 0, 0x20AC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
278 #define is7bit(dcs) ( ((dcs) & 0xC0) ? (!((dcs) & 4) ) : (((dcs) & 0xc) == 0) )
279 #define is8bit(dcs) ( ((dcs) & 0xC0) ? ( ((dcs) & 4) ) : (((dcs) & 0xc) == 4) )
280 #define is16bit(dcs) ( ((dcs) & 0xC0) ? 0 : (((dcs) & 0xc) == 8) )
303 struct timeval local = { t, 0 };
314 unsigned char *p = *pp;
323 if (*p < 0xC2 || (p[1] & 0xC0) != 0x80) {
327 return ((*p & 0x1F) << 6) + (p[1] & 0x3F);
330 if ((*p == 0xE0 && p[1] < 0xA0) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80) {
334 return ((*p & 0x0F) << 12) + ((p[1] & 0x3F) << 6) + (p[2] & 0x3F);
337 if ((*p == 0xF0 && p[1] < 0x90) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80) {
341 return ((*p & 0x07) << 18) + ((p[1] & 0x3F) << 12) + ((p[2] & 0x3F) << 6) + (p[3] & 0x3F);
344 if ((*p == 0xF8 && p[1] < 0x88) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
345 || (p[4] & 0xC0) != 0x80) {
349 return ((*p & 0x03) << 24) + ((p[1] & 0x3F) << 18) + ((p[2] & 0x3F) << 12) + ((p[3] & 0x3F) << 6) + (p[4] & 0x3F);
352 if ((*p == 0xFC && p[1] < 0x84) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
353 || (p[4] & 0xC0) != 0x80 || (p[5] & 0xC0) != 0x80) {
357 return ((*p & 0x01) << 30) + ((p[1] & 0x3F) << 24) + ((p[2] & 0x3F) << 18) + ((p[3] & 0x3F) << 12) + ((p[4] & 0x3F) << 6) + (p[5] & 0x3F);
366 static int packsms7(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
405 for (v = 0; v < 128 && defaultalphabet[v] != u; v++);
406 if (v == 128 && u && n + 1 <
SMSLEN) {
408 for (v = 0; v < 128 && escapes[v] != u; v++);
416 o[p] = (27 >> (7 - b));
429 o[p] = (v >> (7 - b));
443 static int packsms8(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
463 if (u < 0 || u > 0xFF) {
482 static int packsms16(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
517 static int packsms(
unsigned char dcs,
unsigned char *base,
unsigned int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
519 unsigned char *p = base;
526 if ((l =
packsms7(p + 1, udhl, udh, udl, ud)) < 0) {
530 p += (l * 7 + 7) / 8;
532 if ((l =
packsms8(p + 1, udhl, udh, udl, ud)) < 0) {
538 if ((l =
packsms16(p + 1, udhl, udh, udl, ud)) < 0) {
553 struct timeval topack = { w, 0 };
557 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
560 z = timezone / 60 / 15;
563 *o++ = (((t.
tm_mon + 1) % 10) << 4) + (t.
tm_mon + 1) / 10;
569 *o++ = (((-z) % 10) << 4) + (-z) / 10 + 0x08;
571 *o++ = ((z % 10) << 4) + z / 10;
580 t.
tm_year = 100 + (i[0] & 0xF) * 10 + (i[0] >> 4);
581 t.
tm_mon = (i[1] & 0xF) * 10 + (i[1] >> 4) - 1;
582 t.
tm_mday = (i[2] & 0xF) * 10 + (i[2] >> 4);
583 t.
tm_hour = (i[3] & 0xF) * 10 + (i[3] >> 4);
584 t.
tm_min = (i[4] & 0xF) * 10 + (i[4] >> 4);
585 t.
tm_sec = (i[5] & 0xF) * 10 + (i[5] >> 4);
588 t.
tm_min += 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
590 t.
tm_min -= 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
599 static void unpacksms7(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
601 unsigned char b = 0, p = 0;
602 unsigned short *o = ud;
632 v = ((i[p] >> b) & 0x7F);
634 v = ((((i[p] >> b) + (i[p + 1] << (8 - b)))) & 0x7F);
642 if (o > ud && o[-1] == 0x00A0 && escapes[v]) {
645 *o++ = defaultalphabet[v];
655 static void unpacksms8(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
657 unsigned short *o = ud;
681 static void unpacksms16(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
683 unsigned short *o = ud;
709 static int unpacksms(
unsigned char dcs,
unsigned char *i,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
727 unsigned char l = i[0], p;
731 for (p = 0; p < l; p++) {
733 *o++ = (i[2 + p / 2] >> 4) +
'0';
735 *o++ = (i[2 + p / 2] & 0xF) +
'0';
758 o[p++] |= ((*i & 0xF) << 4);
775 if (*h->
oa ==
'\0' && *h->
da ==
'\0') {
778 o = open(log_file, O_CREAT | O_APPEND | O_WRONLY,
AST_FILE_MODE);
780 char line[1000], mrs[3] =
"", *p;
785 snprintf(mrs,
sizeof(mrs),
"%02X", (
unsigned)h->
mr);
787 snprintf(line,
sizeof(line),
"%s %c%c%c%s %s %s %s ",
788 isodate(time(NULL), buf,
sizeof(buf)),
789 status, h->
rx ?
'I' :
'O', h->
smsc ?
'S' :
'M', mrs, h->
queue,
791 p = line + strlen(line);
792 for (n = 0; n < h->
udl; n++) {
793 if (h->
ud[n] ==
'\\') {
796 }
else if (h->
ud[n] ==
'\n') {
799 }
else if (h->
ud[n] ==
'\r') {
802 }
else if (h->
ud[n] < 32 || h->
ud[n] == 127) {
810 if (write(o, line, strlen(line)) < 0) {
835 while (fgets (line,
sizeof(line), s)) {
838 for (p = line; *p && *p !=
'\n' && *p !=
'\r'; p++);
841 if (!*p || *p ==
';') {
844 while (isalnum(*p)) {
848 while (isspace (*p)) {
853 if (!strcmp(line,
"ud")) {
856 while (*p && o <
SMSLEN) {
864 while (isspace (*p)) {
867 if (!strcmp(line,
"oa") && strlen(p) <
sizeof(h->
oa)) {
869 }
else if (!strcmp(line,
"da") && strlen(p) <
sizeof(h->
oa)) {
871 }
else if (!strcmp(line,
"pid")) {
873 }
else if (!strcmp(line,
"dcs")) {
876 }
else if (!strcmp(line,
"mr")) {
878 }
else if (!strcmp(line,
"srr")) {
879 h->
srr = (atoi(p) ? 1 : 0);
880 }
else if (!strcmp(line,
"vp")) {
882 }
else if (!strcmp(line,
"rp")) {
883 h->
rp = (atoi(p) ? 1 : 0);
884 }
else if (!strcmp(line,
"scts")) {
885 int Y, m, d, H, M,
S;
887 if (sscanf(p,
"%4d-%2d-%2dT%2d:%2d:%2d", &Y, &m, &d, &H, &M, &S) == 6) {
897 if (h->
scts.tv_sec == 0) {
905 }
else if (*p ==
'#') {
909 if (!strcmp(line,
"ud")) {
911 while (*p && o <
SMSLEN) {
912 if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) {
914 (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) +
915 (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
916 (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF));
926 }
else if (!strcmp(line,
"ud")) {
928 while (*p && o <
SMSLEN) {
929 if (isxdigit(*p) && isxdigit(p[1])) {
930 h->
ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
940 }
else if (!strcmp(line,
"udh")) {
943 while (*p && o <
SMSLEN) {
944 if (isxdigit(*p) && isxdigit(p[1])) {
945 h->
udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
992 char fn[200] =
"", fn2[200] =
"";
1002 snprintf(fn2 + strlen(fn2),
sizeof(fn2) - strlen(fn2),
"/%s.%s-%u", h->
queue,
isodate(h->
scts.tv_sec, buf,
sizeof(buf)), seq++);
1003 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/.%s", fn2 + strlen(fn) + 1);
1004 if ((o = fopen(fn,
"w")) == NULL) {
1009 fprintf(o,
"oa=%s\n", h->
oa);
1012 fprintf(o,
"da=%s\n", h->
da);
1017 for (p = 0; p < h->
udhl; p++) {
1018 fprintf(o,
"%02X", (
unsigned)h->
udh[p]);
1024 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1029 for (p = 0; p < h->
udl; p++) {
1030 unsigned short v = h->
ud[p];
1033 }
else if (v < 0x80) {
1035 }
else if (v < 0x800) {
1036 fputc(0xC0 + (v >> 6), o);
1037 fputc(0x80 + (v & 0x3F), o);
1039 fputc(0xE0 + (v >> 12), o);
1040 fputc(0x80 + ((v >> 6) & 0x3F), o);
1041 fputc(0x80 + (v & 0x3F), o);
1045 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1047 for (p = 0; p < h->
udl && h->
ud[p] < 0x100; p++);
1050 for (p = 0; p < h->
udl; p++) {
1051 fprintf(o,
"%02X", (
unsigned)h->
ud[p]);
1056 for (p = 0; p < h->
udl; p++) {
1057 fprintf(o,
"%04X", (
unsigned)h->
ud[p]);
1063 if (h->
scts.tv_sec) {
1065 fprintf(o,
"scts=%s\n",
isodate(h->
scts.tv_sec, datebuf,
sizeof(datebuf)));
1068 fprintf(o,
"pid=%d\n", h->
pid);
1070 if (h->
dcs != 0xF1) {
1071 fprintf(o,
"dcs=%d\n", h->
dcs);
1074 fprintf(o,
"vp=%u\n", h->
vp);
1077 fprintf(o,
"srr=1\n");
1080 fprintf(o,
"mr=%d\n", h->
mr);
1083 fprintf(o,
"rp=1\n");
1086 if (rename(fn, fn2)) {
1099 }
while (f && (*f->d_name ==
'.' || strncmp(f->d_name, queue, strlen(queue)) || f->d_name[strlen(queue)] !=
'.'));
1106 unsigned char p = 3;
1108 if ((h->
imsg[2] & 3) == 1) {
1111 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1112 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1113 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1120 if ((h->
imsg[2] & 0x18) == 0x10) {
1121 if (h->
imsg[p] < 144) {
1122 h->
vp = (h->
imsg[p] + 1) * 5;
1123 }
else if (h->
imsg[p] < 168) {
1124 h->
vp = 720 + (h->
imsg[p] - 143) * 30;
1125 }
else if (h->
imsg[p] < 197) {
1126 h->
vp = (h->
imsg[p] - 166) * 1440;
1128 h->
vp = (h->
imsg[p] - 192) * 10080;
1131 }
else if (h->
imsg[2] & 0x18) {
1137 if (p != h->
imsg[1] + 2) {
1146 if (!(h->
imsg[2] & 3)) {
1148 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1149 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1150 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1160 if (p != h->
imsg[1] + 2) {
1173 #define NAME_MAX 1024
1182 int x = h->
omsg[1] + 2;
1187 h->
omsg[x++] = (
unsigned char)size;
1189 for (; size > 0 ; size--) {
1190 h->
omsg[x++] = *data++;
1208 struct timeval now = h->
scts;
1221 strcpy(h->
oa,
"00000000");
1230 strcpy(h->
da,
"00000000");
1240 #define MAX_DEBUG_LEN 300
1246 for (p = s, f = 0; f < size && f <
MAX_DEBUG_LEN; f++, p += 3) {
1247 sprintf(p,
"%02X ", (
unsigned)buf[f]);
1259 struct timeval now = { 0, 0 };
1262 sz = h->
imsg[1] + 2;
1267 for (f = 4; f < sz; ) {
1269 msgsz = h->
imsg[f++];
1270 msgsz += (h->
imsg[f++] * 256);
1273 ast_verb(3,
"SMS-P2 Body#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1274 if (msgsz >=
sizeof(h->
ud)) {
1275 msgsz =
sizeof(h->
ud) - 1;
1277 for (i = 0; i < msgsz; i++) {
1278 h->
ud[i] = h->
imsg[f + i];
1297 ast_verb(3,
"SMS-P2 Origin#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1304 ast_verb(3,
"SMS-P2 Destination#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1322 static void smssend(
sms_t *h,
char *c)
1325 for (f = 0; f < strlen(c); f++) {
1326 sscanf(&c[f*3],
"%x", &x);
1340 #define DLL2_ACK(h) ((h->framenumber & 1) ? DLL2_SMS_ACK1: DLL2_SMS_ACK1)
1398 h->
omsg[p++] = (more ? 4 : 0) + ((h->
udhl > 0) ? 0x40 : 0);
1407 0x01 + (more ? 4 : 0) + (h->
srr ? 0x20 : 0) + (h->
rp ? 0x80 : 0) + (h->
vp ? 0x10 : 0) + (h->
udhi ? 0x40 : 0);
1409 h->
mr = message_ref++;
1417 h->
omsg[p++] = (h->
vp + 4) / 5 - 1;
1418 }
else if (h->
vp < 1440) {
1419 h->
omsg[p++] = (h->
vp - 720 + 29) / 30 + 143;
1420 }
else if (h->
vp < 43200) {
1421 h->
omsg[p++] = (h->
vp + 1439) / 1440 + 166;
1422 }
else if (h->
vp < 635040) {
1423 h->
omsg[p++] = (h->
vp + 10079) / 10080 + 192;
1436 char fn[100 + NAME_MAX] =
"";
1440 *h->
da = *h->
oa =
'\0';
1448 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/%s", f->d_name);
1456 if (*h->
da || *h->
oa) {
1479 char txt[259 * 3 + 1];
1484 while (q < n && q < 30) {
1485 sprintf(p,
" %02X", (
unsigned)msg[q++]);
1505 switch (h->
imsg[0]) {
1555 unsigned char c = 0, p;
1558 for (p = 0; p <
len; p++) {
1569 if (h->
omsg[0] == 0x7F) {
1581 if (h->
omsg[0] == 0x93) {
1599 #define MAXSAMPLES (800)
1614 f.
datalen = samples *
sizeof(*buf);
1621 for (i = 0; i <
samples; i++) {
1622 buf[i] = wave_out[0];
1627 buf[i] = wave_out[h->
ophase];
1631 if ((h->
ophasep += 12) >= 80) {
1636 }
else if (h->
osync) {
1644 if (h->
obitp == 1) {
1646 }
else if (h->
obitp == 2) {
1648 }
else if (h->
obitp == 10) {
1716 for ( ; samples-- ; data++) {
1717 unsigned long long m0, m1;
1718 if (abs(*data) > h->
imag) {
1719 h->
imag = abs(*data);
1723 if (h->
imag <= 500) {
1724 if (h->
idle++ == 80000) {
1753 if ((h->
ips0 += 21) >= 80) {
1756 if ((h->
ipc0 += 21) >= 80) {
1759 if ((h->
ips1 += 13) >= 80) {
1762 if ((h->
ipc1 += 13) >= 80) {
1777 bit = ((h->
ibitt > 1) ? 1 : 0);
1778 if (bit != h->
ibitl) {
1788 if (bit && h->
ibitc == 200) {
1792 ast_verb(3,
"SMS protocol 2 detected\n");
1805 if (h->
ibitn++ == 9) {
1891 if (sms_args.argc > 1) {
1895 ast_verb(1,
"sms argc %u queue <%s> opts <%s> addr <%s> body <%s>\n",
1896 sms_args.argc,
S_OR(sms_args.queue,
""),
1897 S_OR(sms_args.options,
""),
1898 S_OR(sms_args.addr,
""),
1899 S_OR(sms_args.body,
"") );
1912 if (strlen(sms_args.queue) >=
sizeof(h.
queue)) {
1918 for (p = h.
queue; *p; p++) {
1927 h.
opause_0 = atoi(sms_opts[OPTION_ARG_PAUSE]);
1950 h.
pid = 0x40 + (*d & 0xF);
1954 if (sms_args.argc > 2) {
1975 up = (
unsigned char *)sms_args.body;
2074 for (p = 0; p < 80; p++) {
A-Law to Signed linear conversion.
union ast_frame_subclass subclass
static void sms_messagerx(sms_t *h)
static void sms_messagetx(sms_t *h)
Main Channel structure associated with a channel.
static int load_module(void)
char * str
Subscriber phone number (Malloced)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
struct ast_party_caller caller
Channel Caller ID information.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_test_flag(p, flag)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
static long utf8decode(unsigned char **pp)
Reads next UCS character from NUL terminated UTF-8 string and advance pointer.
static void dummy(char *unused,...)
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.
static void packdate(unsigned char *o, time_t w)
pack a date and return
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
static unsigned char packaddress(unsigned char *o, char *i)
store an address at o, and return number of bytes used
static int sms_handleincoming_proto2(sms_t *h)
sms_handleincoming_proto2: handle the incoming message
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
static void sms_compose1(sms_t *h, int more)
compose a message for protocol 1
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static void sms_debug(int dir, sms_t *h)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int sms_exec(struct ast_channel *chan, const char *data)
static unsigned char unpackaddress(char *o, unsigned char *i)
unpack an address from i, return byte length, unpack to o
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_verb(level,...)
static void sms_readfile(sms_t *h, char *fn)
parse and delete a file
static void sms_process(sms_t *h, int samples, signed short *data)
static int sms_generate(struct ast_channel *chan, void *data, int len, int samples)
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...
struct ast_party_id id
Caller party ID.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
static struct dirent * readdirqueue(DIR *d, char *queue)
read dir skipping dot files...
static volatile unsigned char message_ref
static void sms_compose2(sms_t *h, int more)
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
Asterisk file paths, configured in asterisk.conf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
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 char * isodate(time_t t, char *buf, int len)
static, return a date/time in ISO format
#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 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 void sms_release(struct ast_channel *chan, void *data)
static const signed short wave[]
static void * sms_alloc(struct ast_channel *chan, void *sms_t_ptr)
static const output_t * wave_out
static void sms_writefile(sms_t *h)
white a received text message to a file
Core PBX routines and definitions.
static char log_file[255]
#define ast_strdupa(s)
duplicate a string in memory from the stack
static const unsigned short defaultalphabet[]
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static struct ast_app_option sms_options[128]
static struct ast_generator smsgen
unsigned short ud[SMSLEN]
const char * ast_config_AST_LOG_DIR
static char * sms_hexdump(unsigned char buf[], int size, char *s)
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...
void *(* alloc)(struct ast_channel *chan, void *params)
static void parse(struct mgcp_request *req)
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 void sms_log(sms_t *h, char status)
Log the output, and remove file.
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.
const char * ast_config_AST_SPOOL_DIR
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...
static void adddata_proto2(sms_t *h, unsigned char msg, char *data, int size)
Structure used to handle boolean flags.
static void sms_messagerx2(sms_t *h)
void ast_deactivate_generator(struct ast_channel *chan)
static volatile unsigned int seq
static struct timeval unpackdate(unsigned char *i)
unpack a date and return
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 int unload_module(void)
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
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 ...
Data structure associated with a single frame of data.
#define AST_APP_ARG(name)
Define an application argument.
enum ast_frame_type frametype
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
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 putdummydata_proto2(sms_t *h)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
union ast_frame::@172 data
unsigned char valid
TRUE if the number information is valid/present.
static void numcpy(char *d, char *s)
copy number, skipping non digits apart from leading +
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static void sms_nextoutgoing(sms_t *h)
find and fill in next message, or send a REL if none waiting
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
static const unsigned short escapes[]
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
static unsigned char sms_handleincoming(sms_t *h)
handle the incoming message
unsigned char udh[SMSLEN]
struct ast_party_number number
Subscriber phone number.