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,
size_t udh_size,
609 int *udhl,
unsigned short *ud,
size_t ud_size,
int *udl,
char udhi)
611 unsigned char b = 0, p = 0;
612 unsigned short *o = ud;
613 unsigned short *o_end = ud + ud_size;
614 unsigned char *h = udh;
615 unsigned char *h_end = udh + udh_size;
616 size_t stored_udhl = 0;
624 while (hlen-- && l) {
649 v = ((i[p] >>
b) & 0x7F);
651 v = ((((i[p] >>
b) + (i[p + 1] << (8 -
b)))) & 0x7F);
659 if (o > ud && o[-1] == 0x00A0 &&
escapes[v]) {
661 }
else if (o < o_end) {
673static void unpacksms8(
unsigned char *i,
unsigned char l,
unsigned char *udh,
size_t udh_size,
674 int *udhl,
unsigned short *ud,
size_t ud_size,
int *udl,
char udhi)
676 unsigned short *o = ud;
677 unsigned short *o_end = ud + ud_size;
678 unsigned char *h = udh;
679 unsigned char *h_end = udh + udh_size;
680 size_t stored_udhl = 0;
711static void unpacksms16(
unsigned char *i,
unsigned char l,
unsigned char *udh,
size_t udh_size,
712 int *udhl,
unsigned short *ud,
size_t ud_size,
int *udl,
char udhi)
714 unsigned short *o = ud;
715 unsigned short *o_end = ud + ud_size;
716 unsigned char *h = udh;
717 unsigned char *h_end = udh + udh_size;
718 size_t stored_udhl = 0;
750static int unpacksms(
unsigned char dcs,
unsigned char *i,
unsigned char *udh,
size_t udh_size,
751 int *udhl,
unsigned short *ud,
size_t ud_size,
int *udl,
char udhi)
755 unpacksms7(i, l, udh, udh_size, udhl, ud, ud_size, udl, udhi);
758 unpacksms8(i, l, udh, udh_size, udhl, ud, ud_size, udl, udhi);
761 unpacksms16(i, l, udh, udh_size, udhl, ud, ud_size, udl, udhi);
769 unsigned char l = i[0], p;
776 o_end = o + o_size - 1;
782 for (p = 0; p < l; p++) {
785 *o++ = (i[2 + p / 2] >> 4) +
'0';
787 *o++ = (i[2 + p / 2] & 0xF) +
'0';
811 o[p++] |= ((*i & 0xF) << 4);
828 if (*h->
oa ==
'\0' && *h->
da ==
'\0') {
833 char line[1000], mrs[3] =
"", *p;
838 snprintf(mrs,
sizeof(mrs),
"%02hhX", (
unsigned char)h->
mr);
840 snprintf(line,
sizeof(line),
"%s %c%c%c%s %s %s %s ",
844 p = line + strlen(line);
847 p += snprintf(p, 1000 - strlen(line),
"udl=%d", h->
udl);
849 for (n = 0; n < h->
udl; n++) {
850 if (h->
ud[n] ==
'\\') {
853 }
else if (h->
ud[n] ==
'\n') {
856 }
else if (h->
ud[n] ==
'\r') {
859 }
else if (h->
ud[n] < 32 || h->
ud[n] == 127) {
868 if (write(o, line, strlen(line)) < 0) {
893 while (fgets (line,
sizeof(line), s)) {
896 for (p = line; *p && *p !=
'\n' && *p !=
'\r'; p++);
899 if (!*p || *p ==
';') {
902 while (isalnum(*p)) {
906 while (isspace (*p)) {
911 if (!strcmp(line,
"ud")) {
914 while (*p && o <
SMSLEN) {
923 while (isspace (*p)) {
926 if (!strcmp(line,
"oa") && strlen(p) <
sizeof(h->
oa)) {
928 }
else if (!strcmp(line,
"da") && strlen(p) <
sizeof(h->
oa)) {
930 }
else if (!strcmp(line,
"pid")) {
932 }
else if (!strcmp(line,
"dcs")) {
935 }
else if (!strcmp(line,
"mr")) {
937 }
else if (!strcmp(line,
"srr")) {
938 h->
srr = (atoi(p) ? 1 : 0);
939 }
else if (!strcmp(line,
"vp")) {
941 }
else if (!strcmp(line,
"rp")) {
942 h->
rp = (atoi(p) ? 1 : 0);
943 }
else if (!strcmp(line,
"scts")) {
944 int Y, m,
d, H, M,
S;
946 if (sscanf(p,
"%4d-%2d-%2dT%2d:%2d:%2d", &Y, &m, &
d, &H, &M, &
S) == 6) {
956 if (h->
scts.tv_sec == 0) {
964 }
else if (*p ==
'#') {
968 if (!strcmp(line,
"ud")) {
970 while (*p && o <
SMSLEN) {
971 if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) {
973 (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) +
974 (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
975 (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF));
985 }
else if (!strcmp(line,
"ud")) {
987 while (*p && o <
SMSLEN) {
988 if (isxdigit(*p) && isxdigit(p[1])) {
989 h->
ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
999 }
else if (!strcmp(line,
"udh")) {
1000 unsigned char o = 0;
1002 while (*p && o <
SMSLEN) {
1003 if (isxdigit(*p) && isxdigit(p[1])) {
1004 h->
udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
1051 char fn[200] =
"", fn2[200] =
"";
1061 snprintf(fn2 + strlen(fn2),
sizeof(fn2) - strlen(fn2),
"/%s.%s-%u", h->
queue,
isodate(h->
scts.tv_sec,
buf,
sizeof(
buf)),
seq++);
1062 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/.%s", fn2 + strlen(fn) + 1);
1063 if ((o = fopen(fn,
"w")) ==
NULL) {
1068 fprintf(o,
"oa=%s\n", h->
oa);
1071 fprintf(o,
"da=%s\n", h->
da);
1076 for (p = 0; p < h->
udhl; p++) {
1077 fprintf(o,
"%02hhX", (
unsigned char)h->
udh[p]);
1083 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1088 for (p = 0; p < h->
udl; p++) {
1089 unsigned short v = h->
ud[p];
1092 }
else if (v < 0x80) {
1094 }
else if (v < 0x800) {
1095 fputc(0xC0 + (v >> 6), o);
1096 fputc(0x80 + (v & 0x3F), o);
1098 fputc(0xE0 + (v >> 12), o);
1099 fputc(0x80 + ((v >> 6) & 0x3F), o);
1100 fputc(0x80 + (v & 0x3F), o);
1104 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1106 for (p = 0; p < h->
udl && h->
ud[p] < 0x100; p++);
1109 for (p = 0; p < h->
udl; p++) {
1110 fprintf(o,
"%02hhX", (
unsigned char)h->
ud[p]);
1115 for (p = 0; p < h->
udl; p++) {
1116 fprintf(o,
"%04X", (
unsigned)h->
ud[p]);
1122 if (h->
scts.tv_sec) {
1124 fprintf(o,
"scts=%s\n",
isodate(h->
scts.tv_sec, datebuf,
sizeof(datebuf)));
1127 fprintf(o,
"pid=%d\n", h->
pid);
1129 if (h->
dcs != 0xF1) {
1130 fprintf(o,
"dcs=%d\n", h->
dcs);
1133 fprintf(o,
"vp=%u\n", h->
vp);
1136 fprintf(o,
"srr=1\n");
1139 fprintf(o,
"mr=%d\n", h->
mr);
1142 fprintf(o,
"rp=1\n");
1145 if (rename(fn, fn2)) {
1158 }
while (f && (*f->d_name ==
'.' || strncmp(f->d_name, queue, strlen(queue)) || f->d_name[strlen(queue)] !=
'.'));
1165 unsigned char p = 3;
1167 if ((h->
imsg[2] & 3) == 1) {
1170 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1171 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1172 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1179 if ((h->
imsg[2] & 0x18) == 0x10) {
1180 if (h->
imsg[p] < 144) {
1181 h->
vp = (h->
imsg[p] + 1) * 5;
1182 }
else if (h->
imsg[p] < 168) {
1183 h->
vp = 720 + (h->
imsg[p] - 143) * 30;
1184 }
else if (h->
imsg[p] < 197) {
1185 h->
vp = (h->
imsg[p] - 166) * 1440;
1187 h->
vp = (h->
imsg[p] - 192) * 10080;
1190 }
else if (h->
imsg[2] & 0x18) {
1196 if (p != h->
imsg[1] + 2) {
1205 if (!(h->
imsg[2] & 3)) {
1207 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1208 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1209 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1219 if (p != h->
imsg[1] + 2) {
1232#define NAME_MAX 1024
1241 int x = h->
omsg[1] + 2;
1246 h->
omsg[x++] = (
unsigned char)size;
1248 for (; size > 0 ; size--) {
1249 h->
omsg[x++] = *data++;
1267 struct timeval now = h->
scts;
1280 strcpy(h->
oa,
"00000000");
1289 strcpy(h->
da,
"00000000");
1299#define MAX_DEBUG_LEN 300
1305 for (p = s, f = 0; f < size && f <
MAX_DEBUG_LEN; f++, p += 3) {
1306 sprintf(p,
"%02hhX ", (
unsigned char)
buf[f]);
1318 struct timeval now = { 0, 0 };
1321 sz = h->
imsg[1] + 2;
1326 for (f = 4; f < sz; ) {
1328 msgsz = h->
imsg[f++];
1329 msgsz += (h->
imsg[f++] * 256);
1332 ast_verb(3,
"SMS-P2 Body#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1333 if (msgsz >=
sizeof(h->
ud)) {
1334 msgsz =
sizeof(h->
ud) - 1;
1336 for (i = 0; i < msgsz; i++) {
1337 h->
ud[i] = h->
imsg[f + i];
1356 ast_verb(3,
"SMS-P2 Origin#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1363 ast_verb(3,
"SMS-P2 Destination#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1381static void smssend(
sms_t *h,
char *
c)
1384 for (f = 0; f < strlen(
c); f++) {
1385 sscanf(&
c[f*3],
"%x", &x);
1399#define DLL2_ACK(h) ((h->framenumber & 1) ? DLL2_SMS_ACK1: DLL2_SMS_ACK1)
1457 h->
omsg[p++] = (more ? 4 : 0) + ((h->
udhl > 0) ? 0x40 : 0);
1466 0x01 + (more ? 4 : 0) + (h->
srr ? 0x20 : 0) + (h->
rp ? 0x80 : 0) + (h->
vp ? 0x10 : 0) + (h->
udhi ? 0x40 : 0);
1476 h->
omsg[p++] = (h->
vp + 4) / 5 - 1;
1477 }
else if (h->
vp < 1440) {
1478 h->
omsg[p++] = (h->
vp - 720 + 29) / 30 + 143;
1479 }
else if (h->
vp < 43200) {
1480 h->
omsg[p++] = (h->
vp + 1439) / 1440 + 166;
1481 }
else if (h->
vp < 635040) {
1482 h->
omsg[p++] = (h->
vp + 10079) / 10080 + 192;
1495 char fn[100 + NAME_MAX] =
"";
1499 *h->
da = *h->
oa =
'\0';
1507 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/%s", f->d_name);
1515 if (*h->
da || *h->
oa) {
1539 char txt[259 * 3 + 1];
1544 while (q < n && q < 30) {
1545 sprintf(p,
" %02hhX", msg[q++]);
1565 switch (h->
imsg[0]) {
1615 unsigned char c = 0, p;
1618 for (p = 0; p <
len; p++) {
1629 if (h->
omsg[0] == 0x7F) {
1641 if (h->
omsg[0] == 0x93) {
1659#define MAXSAMPLES (800)
1681 for (i = 0; i <
samples; i++) {
1691 if ((h->
ophasep += 12) >= 80) {
1696 }
else if (h->
osync) {
1704 if (h->
obitp == 1) {
1706 }
else if (h->
obitp == 2) {
1708 }
else if (h->
obitp == 10) {
1778 for ( ; samples-- ; data++) {
1779 unsigned long long m0, m1;
1785 if (h->
imag <= 500) {
1786 if (h->
idle++ == 80000) {
1815 if ((h->
ips0 += 21) >= 80) {
1818 if ((h->
ipc0 += 21) >= 80) {
1821 if ((h->
ips1 += 13) >= 80) {
1824 if ((h->
ipc1 += 13) >= 80) {
1839 bit = ((h->
ibitt > 1) ? 1 : 0);
1840 if (bit != h->
ibitl) {
1850 if (bit && h->
ibitc == 200) {
1854 ast_verb(3,
"SMS protocol 2 detected\n");
1867 if (h->
ibitn++ == 9) {
1955 if (sms_args.argc > 1) {
1959 ast_verb(1,
"sms argc %u queue <%s> opts <%s> addr <%s> body <%s>\n",
1960 sms_args.argc,
S_OR(sms_args.queue,
""),
1961 S_OR(sms_args.options,
""),
1962 S_OR(sms_args.addr,
""),
1963 S_OR(sms_args.body,
"") );
1976 if (strlen(sms_args.queue) >=
sizeof(h.
queue)) {
1982 for (p = h.
queue; *p; p++) {
2015 h.
pid = 0x40 + (*
d & 0xF);
2019 if (sms_args.argc > 2) {
2040 up = (
unsigned char *)sms_args.body;
2139 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 void unpacksms8(unsigned char *i, unsigned char l, unsigned char *udh, size_t udh_size, int *udhl, unsigned short *ud, size_t ud_size, 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 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 unpacksms7(unsigned char *i, unsigned char l, unsigned char *udh, size_t udh_size, int *udhl, unsigned short *ud, size_t ud_size, 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_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 putdummydata_proto2(sms_t *h)
static const unsigned short escapes[]
static int unpacksms(unsigned char dcs, unsigned char *i, unsigned char *udh, size_t udh_size, int *udhl, unsigned short *ud, size_t ud_size, int *udl, char udhi)
general unpack - starts with length byte (octet or septet) and returns number of bytes used,...
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 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 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 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 unpackaddress(char *o, size_t o_size, unsigned char *i)
unpack an address from i, return byte length, unpack to o
static void unpacksms16(unsigned char *i, unsigned char l, unsigned char *udh, size_t udh_size, int *udhl, unsigned short *ud, size_t ud_size, 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 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::@237 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.