123static volatile unsigned int seq;
135static const signed short wave[] = {
136 0, 392, 782, 1167, 1545, 1913, 2270, 2612, 2939, 3247, 3536, 3802, 4045, 4263, 4455, 4619, 4755, 4862, 4938, 4985,
137 5000, 4985, 4938, 4862, 4755, 4619, 4455, 4263, 4045, 3802, 3536, 3247, 2939, 2612, 2270, 1913, 1545, 1167, 782, 392,
138 0, -392, -782, -1167,
139 -1545, -1913, -2270, -2612, -2939, -3247, -3536, -3802, -4045, -4263, -4455, -4619, -4755, -4862, -4938, -4985, -5000,
141 -4755, -4619, -4455, -4263, -4045, -3802, -3536, -3247, -2939, -2612, -2270, -1913, -1545, -1167, -782, -392
145static unsigned char wavea[80];
148#define __OUT_FMT ast_format_alaw
152#define __OUT_FMT ast_format_slin
195 0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC,
196 0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
197 0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8,
198 0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
199 ' ',
'!',
'"',
'#', 164,
'%',
'&', 39,
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
200 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
201 161,
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
202 'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z', 196, 214, 209, 220, 167,
203 191,
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
204 'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z', 228, 246, 241, 252, 224,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x000C, 0, 0, 0, 0, 0,
209 0, 0, 0, 0, 0x005E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
210 0, 0, 0, 0, 0, 0, 0, 0, 0x007B, 0x007D, 0, 0, 0, 0, 0, 0x005C,
211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x005B, 0x007E, 0x005D, 0,
212 0x007C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 0, 0, 0x20AC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
284#define is7bit(dcs) ( ((dcs) & 0xC0) ? (!((dcs) & 4) ) : (((dcs) & 0xc) == 0) )
285#define is8bit(dcs) ( ((dcs) & 0xC0) ? ( ((dcs) & 4) ) : (((dcs) & 0xc) == 4) )
286#define is16bit(dcs) ( ((dcs) & 0xC0) ? 0 : (((dcs) & 0xc) == 8) )
309 struct timeval local = { t, 0 };
320 unsigned char *p = *pp;
329 if (*p < 0xC2 || (p[1] & 0xC0) != 0x80) {
333 return ((*p & 0x1F) << 6) + (p[1] & 0x3F);
336 if ((*p == 0xE0 && p[1] < 0xA0) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80) {
340 return ((*p & 0x0F) << 12) + ((p[1] & 0x3F) << 6) + (p[2] & 0x3F);
343 if ((*p == 0xF0 && p[1] < 0x90) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80) {
347 return ((*p & 0x07) << 18) + ((p[1] & 0x3F) << 12) + ((p[2] & 0x3F) << 6) + (p[3] & 0x3F);
350 if ((*p == 0xF8 && p[1] < 0x88) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
351 || (p[4] & 0xC0) != 0x80) {
355 return ((*p & 0x03) << 24) + ((p[1] & 0x3F) << 18) + ((p[2] & 0x3F) << 12) + ((p[3] & 0x3F) << 6) + (p[4] & 0x3F);
358 if ((*p == 0xFC && p[1] < 0x84) || (p[1] & 0xC0) != 0x80 || (p[2] & 0xC0) != 0x80 || (p[3] & 0xC0) != 0x80
359 || (p[4] & 0xC0) != 0x80 || (p[5] & 0xC0) != 0x80) {
363 return ((*p & 0x01) << 30) + ((p[1] & 0x3F) << 24) + ((p[2] & 0x3F) << 18) + ((p[3] & 0x3F) << 12) + ((p[4] & 0x3F) << 6) + (p[5] & 0x3F);
372static int packsms7(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
412 if (v == 128 && u && n + 1 <
SMSLEN) {
414 for (v = 0; v < 128 &&
escapes[v] != u; v++);
422 o[p] = (27 >> (7 -
b));
435 o[p] = (v >> (7 -
b));
449static int packsms8(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
469 if (u < 0 || u > 0xFF) {
488static int packsms16(
unsigned char *o,
int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
523static int packsms(
unsigned char dcs,
unsigned char *base,
unsigned int udhl,
unsigned char *udh,
int udl,
unsigned short *ud)
525 unsigned char *p = base;
532 if ((l =
packsms7(p + 1, udhl, udh, udl, ud)) < 0) {
536 p += (l * 7 + 7) / 8;
538 if ((l =
packsms8(p + 1, udhl, udh, udl, ud)) < 0) {
544 if ((l =
packsms16(p + 1, udhl, udh, udl, ud)) < 0) {
559 struct timeval topack = { w, 0 };
563#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
566 z = timezone / 60 / 15;
569 *o++ = (((t.
tm_mon + 1) % 10) << 4) + (t.
tm_mon + 1) / 10;
575 *o++ = (((-z) % 10) << 4) + (-z) / 10 + 0x08;
577 *o++ = ((z % 10) << 4) + z / 10;
586 t.
tm_year = 100 + (i[0] & 0xF) * 10 + (i[0] >> 4);
587 t.
tm_mon = (i[1] & 0xF) * 10 + (i[1] >> 4) - 1;
588 t.
tm_mday = (i[2] & 0xF) * 10 + (i[2] >> 4);
589 t.
tm_hour = (i[3] & 0xF) * 10 + (i[3] >> 4);
590 t.
tm_min = (i[4] & 0xF) * 10 + (i[4] >> 4);
591 t.
tm_sec = (i[5] & 0xF) * 10 + (i[5] >> 4);
594 t.
tm_min += 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
596 t.
tm_min -= 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
605static void unpacksms7(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
607 unsigned char b = 0, p = 0;
608 unsigned short *o = ud;
638 v = ((i[p] >>
b) & 0x7F);
640 v = ((((i[p] >>
b) + (i[p + 1] << (8 -
b)))) & 0x7F);
648 if (o > ud && o[-1] == 0x00A0 &&
escapes[v]) {
661static void unpacksms8(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
663 unsigned short *o = ud;
687static void unpacksms16(
unsigned char *i,
unsigned char l,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
689 unsigned short *o = ud;
715static int unpacksms(
unsigned char dcs,
unsigned char *i,
unsigned char *udh,
int *udhl,
unsigned short *ud,
int *udl,
char udhi)
733 unsigned char l = i[0], p;
737 for (p = 0; p < l; p++) {
739 *o++ = (i[2 + p / 2] >> 4) +
'0';
741 *o++ = (i[2 + p / 2] & 0xF) +
'0';
764 o[p++] |= ((*i & 0xF) << 4);
781 if (*h->
oa ==
'\0' && *h->
da ==
'\0') {
786 char line[1000], mrs[3] =
"", *p;
791 snprintf(mrs,
sizeof(mrs),
"%02hhX", (
unsigned char)h->
mr);
793 snprintf(line,
sizeof(line),
"%s %c%c%c%s %s %s %s ",
797 p = line + strlen(line);
800 p += snprintf(p, 1000 - strlen(line),
"udl=%d", h->
udl);
802 for (n = 0; n < h->
udl; n++) {
803 if (h->
ud[n] ==
'\\') {
806 }
else if (h->
ud[n] ==
'\n') {
809 }
else if (h->
ud[n] ==
'\r') {
812 }
else if (h->
ud[n] < 32 || h->
ud[n] == 127) {
821 if (write(o, line, strlen(line)) < 0) {
846 while (fgets (line,
sizeof(line), s)) {
849 for (p = line; *p && *p !=
'\n' && *p !=
'\r'; p++);
852 if (!*p || *p ==
';') {
855 while (isalnum(*p)) {
859 while (isspace (*p)) {
864 if (!strcmp(line,
"ud")) {
867 while (*p && o <
SMSLEN) {
875 while (isspace (*p)) {
878 if (!strcmp(line,
"oa") && strlen(p) <
sizeof(h->
oa)) {
880 }
else if (!strcmp(line,
"da") && strlen(p) <
sizeof(h->
oa)) {
882 }
else if (!strcmp(line,
"pid")) {
884 }
else if (!strcmp(line,
"dcs")) {
887 }
else if (!strcmp(line,
"mr")) {
889 }
else if (!strcmp(line,
"srr")) {
890 h->
srr = (atoi(p) ? 1 : 0);
891 }
else if (!strcmp(line,
"vp")) {
893 }
else if (!strcmp(line,
"rp")) {
894 h->
rp = (atoi(p) ? 1 : 0);
895 }
else if (!strcmp(line,
"scts")) {
896 int Y, m,
d, H, M,
S;
898 if (sscanf(p,
"%4d-%2d-%2dT%2d:%2d:%2d", &Y, &m, &
d, &H, &M, &
S) == 6) {
908 if (h->
scts.tv_sec == 0) {
916 }
else if (*p ==
'#') {
920 if (!strcmp(line,
"ud")) {
922 while (*p && o <
SMSLEN) {
923 if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) {
925 (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) +
926 (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
927 (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF));
937 }
else if (!strcmp(line,
"ud")) {
939 while (*p && o <
SMSLEN) {
940 if (isxdigit(*p) && isxdigit(p[1])) {
941 h->
ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
951 }
else if (!strcmp(line,
"udh")) {
954 while (*p && o <
SMSLEN) {
955 if (isxdigit(*p) && isxdigit(p[1])) {
956 h->
udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
1003 char fn[200] =
"", fn2[200] =
"";
1013 snprintf(fn2 + strlen(fn2),
sizeof(fn2) - strlen(fn2),
"/%s.%s-%u", h->
queue,
isodate(h->
scts.tv_sec,
buf,
sizeof(
buf)),
seq++);
1014 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/.%s", fn2 + strlen(fn) + 1);
1015 if ((o = fopen(fn,
"w")) ==
NULL) {
1020 fprintf(o,
"oa=%s\n", h->
oa);
1023 fprintf(o,
"da=%s\n", h->
da);
1028 for (p = 0; p < h->
udhl; p++) {
1029 fprintf(o,
"%02hhX", (
unsigned char)h->
udh[p]);
1035 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1040 for (p = 0; p < h->
udl; p++) {
1041 unsigned short v = h->
ud[p];
1044 }
else if (v < 0x80) {
1046 }
else if (v < 0x800) {
1047 fputc(0xC0 + (v >> 6), o);
1048 fputc(0x80 + (v & 0x3F), o);
1050 fputc(0xE0 + (v >> 12), o);
1051 fputc(0x80 + ((v >> 6) & 0x3F), o);
1052 fputc(0x80 + (v & 0x3F), o);
1056 for (p = 0; p < h->
udl && h->
ud[p] >=
' '; p++);
1058 for (p = 0; p < h->
udl && h->
ud[p] < 0x100; p++);
1061 for (p = 0; p < h->
udl; p++) {
1062 fprintf(o,
"%02hhX", (
unsigned char)h->
ud[p]);
1067 for (p = 0; p < h->
udl; p++) {
1068 fprintf(o,
"%04X", (
unsigned)h->
ud[p]);
1074 if (h->
scts.tv_sec) {
1076 fprintf(o,
"scts=%s\n",
isodate(h->
scts.tv_sec, datebuf,
sizeof(datebuf)));
1079 fprintf(o,
"pid=%d\n", h->
pid);
1081 if (h->
dcs != 0xF1) {
1082 fprintf(o,
"dcs=%d\n", h->
dcs);
1085 fprintf(o,
"vp=%u\n", h->
vp);
1088 fprintf(o,
"srr=1\n");
1091 fprintf(o,
"mr=%d\n", h->
mr);
1094 fprintf(o,
"rp=1\n");
1097 if (rename(fn, fn2)) {
1110 }
while (f && (*f->d_name ==
'.' || strncmp(f->d_name, queue, strlen(queue)) || f->d_name[strlen(queue)] !=
'.'));
1117 unsigned char p = 3;
1119 if ((h->
imsg[2] & 3) == 1) {
1122 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1123 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1124 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1131 if ((h->
imsg[2] & 0x18) == 0x10) {
1132 if (h->
imsg[p] < 144) {
1133 h->
vp = (h->
imsg[p] + 1) * 5;
1134 }
else if (h->
imsg[p] < 168) {
1135 h->
vp = 720 + (h->
imsg[p] - 143) * 30;
1136 }
else if (h->
imsg[p] < 197) {
1137 h->
vp = (h->
imsg[p] - 166) * 1440;
1139 h->
vp = (h->
imsg[p] - 192) * 10080;
1142 }
else if (h->
imsg[2] & 0x18) {
1148 if (p != h->
imsg[1] + 2) {
1157 if (!(h->
imsg[2] & 3)) {
1159 h->
srr = ((h->
imsg[2] & 0x20) ? 1 : 0);
1160 h->
udhi = ((h->
imsg[2] & 0x40) ? 1 : 0);
1161 h->
rp = ((h->
imsg[2] & 0x80) ? 1 : 0);
1171 if (p != h->
imsg[1] + 2) {
1184#define NAME_MAX 1024
1193 int x = h->
omsg[1] + 2;
1198 h->
omsg[x++] = (
unsigned char)size;
1200 for (; size > 0 ; size--) {
1201 h->
omsg[x++] = *data++;
1219 struct timeval now = h->
scts;
1232 strcpy(h->
oa,
"00000000");
1241 strcpy(h->
da,
"00000000");
1251#define MAX_DEBUG_LEN 300
1257 for (p = s, f = 0; f < size && f <
MAX_DEBUG_LEN; f++, p += 3) {
1258 sprintf(p,
"%02hhX ", (
unsigned char)
buf[f]);
1270 struct timeval now = { 0, 0 };
1273 sz = h->
imsg[1] + 2;
1278 for (f = 4; f < sz; ) {
1280 msgsz = h->
imsg[f++];
1281 msgsz += (h->
imsg[f++] * 256);
1284 ast_verb(3,
"SMS-P2 Body#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1285 if (msgsz >=
sizeof(h->
ud)) {
1286 msgsz =
sizeof(h->
ud) - 1;
1288 for (i = 0; i < msgsz; i++) {
1289 h->
ud[i] = h->
imsg[f + i];
1308 ast_verb(3,
"SMS-P2 Origin#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1315 ast_verb(3,
"SMS-P2 Destination#%02X=[%.*s]\n", (
unsigned)msg, msgsz, &h->
imsg[f]);
1333static void smssend(
sms_t *h,
char *
c)
1336 for (f = 0; f < strlen(
c); f++) {
1337 sscanf(&
c[f*3],
"%x", &x);
1351#define DLL2_ACK(h) ((h->framenumber & 1) ? DLL2_SMS_ACK1: DLL2_SMS_ACK1)
1409 h->
omsg[p++] = (more ? 4 : 0) + ((h->
udhl > 0) ? 0x40 : 0);
1418 0x01 + (more ? 4 : 0) + (h->
srr ? 0x20 : 0) + (h->
rp ? 0x80 : 0) + (h->
vp ? 0x10 : 0) + (h->
udhi ? 0x40 : 0);
1428 h->
omsg[p++] = (h->
vp + 4) / 5 - 1;
1429 }
else if (h->
vp < 1440) {
1430 h->
omsg[p++] = (h->
vp - 720 + 29) / 30 + 143;
1431 }
else if (h->
vp < 43200) {
1432 h->
omsg[p++] = (h->
vp + 1439) / 1440 + 166;
1433 }
else if (h->
vp < 635040) {
1434 h->
omsg[p++] = (h->
vp + 10079) / 10080 + 192;
1447 char fn[100 + NAME_MAX] =
"";
1451 *h->
da = *h->
oa =
'\0';
1459 snprintf(fn + strlen(fn),
sizeof(fn) - strlen(fn),
"/%s", f->d_name);
1467 if (*h->
da || *h->
oa) {
1490 char txt[259 * 3 + 1];
1495 while (q < n && q < 30) {
1496 sprintf(p,
" %02hhX", msg[q++]);
1516 switch (h->
imsg[0]) {
1566 unsigned char c = 0, p;
1569 for (p = 0; p <
len; p++) {
1580 if (h->
omsg[0] == 0x7F) {
1592 if (h->
omsg[0] == 0x93) {
1610#define MAXSAMPLES (800)
1632 for (i = 0; i <
samples; i++) {
1642 if ((h->
ophasep += 12) >= 80) {
1647 }
else if (h->
osync) {
1655 if (h->
obitp == 1) {
1657 }
else if (h->
obitp == 2) {
1659 }
else if (h->
obitp == 10) {
1729 for ( ; samples-- ; data++) {
1730 unsigned long long m0, m1;
1736 if (h->
imag <= 500) {
1737 if (h->
idle++ == 80000) {
1766 if ((h->
ips0 += 21) >= 80) {
1769 if ((h->
ipc0 += 21) >= 80) {
1772 if ((h->
ips1 += 13) >= 80) {
1775 if ((h->
ipc1 += 13) >= 80) {
1790 bit = ((h->
ibitt > 1) ? 1 : 0);
1791 if (bit != h->
ibitl) {
1801 if (bit && h->
ibitc == 200) {
1805 ast_verb(3,
"SMS protocol 2 detected\n");
1818 if (h->
ibitn++ == 9) {
1906 if (sms_args.argc > 1) {
1910 ast_verb(1,
"sms argc %u queue <%s> opts <%s> addr <%s> body <%s>\n",
1911 sms_args.argc,
S_OR(sms_args.queue,
""),
1912 S_OR(sms_args.options,
""),
1913 S_OR(sms_args.addr,
""),
1914 S_OR(sms_args.body,
"") );
1927 if (strlen(sms_args.queue) >=
sizeof(h.
queue)) {
1933 for (p = h.
queue; *p; p++) {
1966 h.
pid = 0x40 + (*
d & 0xF);
1970 if (sms_args.argc > 2) {
1991 up = (
unsigned char *)sms_args.body;
2090 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)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "SMS/PSTN handler")
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_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.
union ast_frame::@228 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
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.