[PATCH] a few of patches
"Oded Arbel" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi list. I'm taking the time to try to sync m-Wise's local CVS repository with Kannel official tree. during the course of our work with Kannel we introduced some small changes into Kannel as a result of developing new driver modules, some of which didnot make it into the official tree, for many reasons. I'd like to take this oppertunity to submit a few minor patches at the same time, and hopefully to get them all into the official tree. I hope sending more then one patch at a time won't offend any one, but anyway - don't feel obliged to comment on all of the patches - if you comment on one patch in an area you are familiar with, it would be great help :-) - charset.patch We needed to get support for iconv charset covnersion library into Kannel, as we need arbitary character set conversions for our SOAP module (some providers dont use unicode with XML), and libxml simply does not provide all the capabilities of iconv. iconv is available in any recent glibc version, and also is available as a stand alone library. this patch adds the ability for configure to detect if iconv is available on the system and set up a compile time setting to compile in iconv support in charset.[ch]/ - smpp_pdu.patch Add more debugging, so when an unkown packet is received, its type will be seen in the logs. this will make it easier to develop support for new packet types. Also clean up error handling in smpp_pdu_pack so it returns NULL when trying to pack an undefined packet instead of an empty or broken Octstr. - dlr.patch Added handling of SMSC_SUCCESS and SMSC_FAIL dlr types. modules should not need to store those types of DLRs, but in case they do - this will make sure that nothing would break. - smsc_at2.patch Added 115200 speed support (contributed by Anupama R [[email protected]]). its tested by me on production not to cause any problems , at least when not using 115200 speed. its nicely #ifdef so I feel it is safe. Cleaned up DLR messages as a result of Stipe's DLR behaviour change Cleaned up tabs as per CodingStyle document guidelines That's all for now , more later ;-) TIA -- Oded Arbel m-Wise mobile solutions [email protected] +972-9-9581711 (116) +972-67-340014 ::.. She often gave herself very good advice (though she very seldom followed it). -- Lewis Carroll
charset.patch
(application/octet-stream, 3.5 KB)
--- gateway/configure.in 2002-08-11 12:12:22.000000000 +0300
+++ gateway/configure.in 2002-08-11 12:43:13.000000000 +0300
@@ -95,7 +95,7 @@
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/ioctl.h sys/time.h sys/types.h unistd.h sys/poll.h)
-AC_CHECK_HEADERS(pthread.h getopt.h syslog.h)
+AC_CHECK_HEADERS(pthread.h getopt.h syslog.h iconv.h)
dnl Checks for typedefs, structures, and compiler characteristics.
--- gateway/configure 2002-08-11 12:12:22.000000000 +0300
+++ gateway/configure 2002-08-11 12:42:59.000000000 +0300
@@ -1781,7 +1781,7 @@
fi
done
-for ac_hdr in pthread.h getopt.h syslog.h
+for ac_hdr in pthread.h getopt.h syslog.h iconv.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
--- gateway/config.h.in 2002-08-07 10:56:44.000000000 +0300
+++ gateway/config.h.in 2002-08-07 11:37:23.000000000 +0300
@@ -113,6 +113,9 @@
/* Define if you have <syslog.h>. */
#undef HAVE_SYSLOG_H
+/* Define if you have <iconv.h>. */
+#undef HAVE_ICONV_H
+
/* Define if you have and want to use the ssl library (-lssl) */
#undef HAVE_LIBSSL
--- gateway/gwlib/charset.h 2001-12-07 15:48:57.000000000 +0200
+++ gateway/gwlib/charset.h 2002-06-25 17:18:07.000000000 +0300
@@ -72,4 +72,9 @@
*/
int charset_from_utf8(Octstr *utf8, Octstr **to, Octstr *charset_to);
+/* use iconv library to convert an Octstr in place, from source character set to
+ * destination character set
+ */
+int charset_convert(Octstr* string, char* charset_from, char* charset_to);
+
#endif
--- gateway/gwlib/charset.c 2002-01-25 13:49:05.000000000 +0200
+++ gateway/gwlib/charset.c 2002-09-03 14:18:38.000000000 +0300
@@ -7,6 +7,11 @@
*/
#include "gwlib/gwlib.h"
+#include <errno.h>
+
+#if HAVE_ICONV_H
+#include <iconv.h>
+#endif
/* Map GSM default alphabet characters to ISO-Latin-1 characters.
* The greek characters at positions 16 and 18 through 26 are not
@@ -401,3 +406,49 @@
return ret;
}
+
+int charset_convert(Octstr* string, char* charset_from, char* charset_to)
+{
+#if HAVE_ICONV_H
+ char *from_buf, *to_buf, *pointer;
+ size_t inbytes, outbytes;
+ int ret;
+ iconv_t cd;
+
+ if (!charset_from || !charset_to || !string) /* sanity check */
+ return -1;
+
+ cd = iconv_open(charset_to, charset_from);
+ /* Did I succeed in getting a conversion descriptor ? */
+ if (cd == (iconv_t)(-1)) {
+ /* I guess not */
+ error(0,"Failed to convert string from %s to %s - probably broken type names.",
+ charset_from, charset_to);
+ return -1;
+ }
+ from_buf = octstr_get_cstr(string);
+ /* allocate max sized buffer, assuming target encoding may be 4 byte unicode */
+ inbytes = octstr_len(string);
+ outbytes = sizeof(char) * octstr_len(string) * 4;
+ pointer = to_buf = gw_malloc(outbytes + 1);
+ memset(to_buf,0,outbytes+1);
+ ret = iconv(cd, (const char**)&from_buf, &inbytes, &pointer, &outbytes);
+ iconv_close(cd);
+ if (ret != -1) {
+ /* conversion succeeded */
+ octstr_delete(string,0,octstr_len(string));
+ octstr_append_cstr(string, to_buf);
+ if (ret)
+ debug("charset",0,"charset_convert did %d non-reversible conversions",ret);
+ ret = 0;
+ } else
+ error(0,"Failed to convert string from %s to %s, errno: %d",charset_from, charset_to, errno);
+ if (errno == EILSEQ)
+ {
+ debug("charset_convert",0,"found an invalid multibyte sequence at position %d",from_buf - octstr_get_cstr(string));
+ }
+ gw_free(to_buf);
+ return ret;
+#endif
+ return 0;
+}
smpp_pdu.patch
(application/octet-stream, 1.9 KB)
--- gateway/gw/smsc/smpp_pdu.c 2002-09-04 20:42:56.000000000 +0300
+++ gateway/gw/smsc/smpp_pdu.c 2002-09-05 10:40:52.000000000 +0300
@@ -79,7 +79,7 @@
} break;
#include "smpp_pdu.def"
default:
- error(0, "Unknown SMPP_PDU type, internal error.");
+ error(0, "Unknown SMPP_PDU type, internal error, please implement type %0lx.", type);
gw_free(pdu);
return NULL;
}
@@ -101,7 +101,7 @@
case id: { struct name *p = &pdu->u.name; fields } break;
#include "smpp_pdu.def"
default:
- error(0, "Unknown SMPP_PDU type, internal error while destroying.");
+ error(0, "Unknown SMPP_PDU type, internal error while destroying, please implement type %0lx.", pdu->type);
}
gw_free(pdu);
}
@@ -126,7 +126,8 @@
case id: { struct name *p = &pdu->u.name; fields } break;
#include "smpp_pdu.def"
default:
- error(0, "Unknown SMPP_PDU type, internal error while packing.");
+ error(0, "Unknown SMPP_PDU type, internal error while packing, please implement type %0lx.", pdu->type);
+ goto error;
}
switch (pdu->type) {
@@ -151,7 +152,8 @@
case id: { struct name *p = &pdu->u.name; fields } break;
#include "smpp_pdu.def"
default:
- error(0, "Unknown SMPP_PDU type, internal error while packing.");
+ error(0, "Unknown SMPP_PDU type, internal error while packing, please implement type %0lx.", pdu->type);
+ goto error;
}
temp = octstr_create("");
@@ -160,6 +162,10 @@
octstr_destroy(temp);
return os;
+
+error:
+ octstr_destroy(os);
+ return NULL;
}
@@ -220,7 +226,7 @@
case id: { struct name *p = &pdu->u.name; fields } break;
#include "smpp_pdu.def"
default:
- error(0, "Unknown SMPP_PDU type, internal error.");
+ error(0, "Unknown SMPP_PDU type, internal error, please implement type %0lx.", pdu->type);
break;
}
debug("sms.smpp", 0, "SMPP PDU dump ends.");
dlr.patch
(application/octet-stream, 1.4 KB)
--- gateway/gw/dlr.c 2002-09-04 20:42:56.000000000 +0300
+++ gateway/gw/dlr.c 2002-09-05 10:34:54.000000000 +0300
@@ -530,7 +530,9 @@
/* ok that was a status report but we where not interested in having it */
msg = NULL;
}
- if ((typ & DLR_BUFFERED) && ((dlr_mask & DLR_SUCCESS) || (dlr_mask & DLR_FAIL))) {
+ if (( (typ & DLR_SMSC_SUCCESS) && (dlr_mask & (DLR_SUCCESS | DLR_BUFFERED | DLR_FAIL)) )
+ ||
+ ( (typ & DLR_BUFFERED) && (dlr_mask & (DLR_SUCCESS | DLR_FAIL)) ) ) {
info(0, "dlr not destroyed, still waiting for other delivery report");
} else {
list_delete(dlr_waiting_list, i, 1);
@@ -628,8 +630,10 @@
debug("dlr.dlr", 0, "ignoring DLR message because of mask");
}
- if ((typ & DLR_BUFFERED) && ((dlr_mask & DLR_SUCCESS) || (dlr_mask & DLR_FAIL))) {
- debug("dlr.mysql", 0, "DLR not deleted because we wait on more reports");
+ if (( (typ & DLR_SMSC_SUCCESS) && (dlr_mask & (DLR_SUCCESS | DLR_BUFFERED | DLR_FAIL)) )
+ ||
+ ( (typ & DLR_BUFFERED) && (dlr_mask & (DLR_SUCCESS | DLR_FAIL)) ) ) {
+ debug("dlr.mysql", 0, "dlr not deleted because we wait on more reports");
} else {
debug("dlr.mysql", 0, "removing DLR from database");
sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' LIMIT 1;",
smsc_at2.patch
(application/octet-stream, 21.3 KB)
--- gateway/gw/smsc/smsc_at2.c 2002-09-04 20:42:56.000000000 +0300
+++ gateway/gw/smsc/smsc_at2.c 2002-09-05 11:08:51.000000000 +0300
@@ -51,7 +51,7 @@
}
-int at2_open_device(PrivAT2data *privdata)
+int at2_open_device(PrivAT2data *privdata)
{
struct termios tios;
int ret;
@@ -77,7 +77,7 @@
/*
if ( ModemTypes[privdata->modemid].enable_parity )
- tios.c_cflag ^= PARODD;
+ tios.c_cflag ^= PARODD;
*/
ret = tcsetattr(privdata->fd, TCSANOW, &tios); /* apply changes now */
@@ -243,13 +243,13 @@
count = octstr_len(linestr);
while (1) {
- errno = 0;
- s = write(privdata->fd, octstr_get_cstr(linestr), count);
- if (s < 0 && errno == EAGAIN && write_count < RETRY_SEND) {
- gwthread_sleep(1);
- ++write_count;
- } else
- break;
+ errno = 0;
+ s = write(privdata->fd, octstr_get_cstr(linestr), count);
+ if (s < 0 && errno == EAGAIN && write_count < RETRY_SEND) {
+ gwthread_sleep(1);
+ ++write_count;
+ } else
+ break;
};
O_DESTROY(linestr);
if (s < 0) {
@@ -272,13 +272,13 @@
debug("bb.smsc.at2", 0, "AT2[%s]: --> ^Z", octstr_get_cstr(privdata->name));
while (1) {
- errno = 0;
- s = write(privdata->fd, ctrlz, 1);
- if (s < 0 && errno == EAGAIN && write_count < RETRY_SEND) {
- gwthread_sleep(1);
- ++write_count;
- } else
- break;
+ errno = 0;
+ s = write(privdata->fd, ctrlz, 1);
+ if (s < 0 && errno == EAGAIN && write_count < RETRY_SEND) {
+ gwthread_sleep(1);
+ ++write_count;
+ } else
+ break;
};
if (s < 0) {
debug("bb.smsc.at2", 0, "AT2[%s]: write failed with errno %d",
@@ -572,12 +572,12 @@
continue;
}
if ((octstr_search(line, octstr_imm("+CMGS:"),0) != -1) && (output)) {
- /* found response to a +CMGS command, read the message id and return it in output */
- long temp;
- if (octstr_parse_long(&temp, line, octstr_search(line, octstr_imm("+CMGS:"),0)+6,10) == -1)
- error(0,"AT2[%s]: got +CMGS but failed to read message id", octstr_get_cstr(privdata->name));
- else
- *output = temp;
+ /* found response to a +CMGS command, read the message id and return it in output */
+ long temp;
+ if (octstr_parse_long(&temp, line, octstr_search(line, octstr_imm("+CMGS:"),0)+6,10) == -1)
+ error(0,"AT2[%s]: got +CMGS but failed to read message id", octstr_get_cstr(privdata->name));
+ else
+ *output = temp;
}
if ( -1 != octstr_search(line, octstr_imm("ERROR"), 0)) {
@@ -800,6 +800,11 @@
speed = B57600;
break;
#endif
+#ifdef B115200
+ case 115200:
+ speed = B115200;
+ break;
+#endif
default:
speed = B9600;
}
@@ -846,26 +851,26 @@
/* If modems->speed is defined, try to use it, else autodetect */
if (privdata->speed == 0 && privdata->modem != NULL &&
- privdata->modem->speed != 0) {
+ privdata->modem->speed != 0) {
- info(0, "AT2[%s]: trying to use speed <%ld> from modem definition",
- octstr_get_cstr(privdata->name), privdata->modem->speed);
- if(0 == at2_test_speed(privdata, privdata->modem->speed)) {
- privdata->speed = privdata->modem->speed;
- info(0, "AT2[%s]: speed is %ld",
- octstr_get_cstr(privdata->name), privdata->speed);
- } else {
- info(0, "AT2[%s]: speed in modem definition don't work, will autodetect",
- octstr_get_cstr(privdata->name));
- }
- }
+ info(0, "AT2[%s]: trying to use speed <%ld> from modem definition",
+ octstr_get_cstr(privdata->name), privdata->modem->speed);
+ if(0 == at2_test_speed(privdata, privdata->modem->speed)) {
+ privdata->speed = privdata->modem->speed;
+ info(0, "AT2[%s]: speed is %ld",
+ octstr_get_cstr(privdata->name), privdata->speed);
+ } else {
+ info(0, "AT2[%s]: speed in modem definition don't work, will autodetect",
+ octstr_get_cstr(privdata->name));
+ }
+ }
if (privdata->speed == 0) {
- if (at2_detect_speed(privdata) == -1) {
- if (!privdata->retry)
- return;
- else
- continue;
+ if (at2_detect_speed(privdata) == -1) {
+ if (!privdata->retry)
+ return;
+ else
+ continue;
}
}
@@ -1146,25 +1151,25 @@
/* find the beginning of a message from the modem*/
if ((pos = octstr_search(buffer, octstr_imm("+CDS:"), 0)) != -1)
- pos += 5;
+ pos += 5;
else {
- if ((pos = octstr_search(buffer, octstr_imm("+CMT:"), 0)) != -1)
- pos += 5;
- else if ((pos = octstr_search(buffer, octstr_imm("+CMGR:"), 0)) != -1) {
- /* skip status field in +CMGR response */
- if ((pos = octstr_search(buffer, octstr_imm(","), pos + 6)) != -1)
- pos++;
- else
- goto nomsg;
- } else
- goto nomsg;
-
- /* skip the next comma in CMGR and CMT responses */
- tmp = octstr_search(buffer, octstr_imm(","), pos);
- if (! privdata->modem->broken && tmp == -1)
- goto nomsg;
- if (tmp != -1)
- pos = tmp + 1;
+ if ((pos = octstr_search(buffer, octstr_imm("+CMT:"), 0)) != -1)
+ pos += 5;
+ else if ((pos = octstr_search(buffer, octstr_imm("+CMGR:"), 0)) != -1) {
+ /* skip status field in +CMGR response */
+ if ((pos = octstr_search(buffer, octstr_imm(","), pos + 6)) != -1)
+ pos++;
+ else
+ goto nomsg;
+ } else
+ goto nomsg;
+
+ /* skip the next comma in CMGR and CMT responses */
+ tmp = octstr_search(buffer, octstr_imm(","), pos);
+ if (! privdata->modem->broken && tmp == -1)
+ goto nomsg;
+ if (tmp != -1)
+ pos = tmp + 1;
}
/* read the message length */
@@ -1226,8 +1231,8 @@
msg = at2_pdu_decode_deliver_sm(data, privdata);
break;
case AT_STATUS_REPORT_SM:
- msg = at2_pdu_decode_report_sm(data, privdata);
- break;
+ msg = at2_pdu_decode_report_sm(data, privdata);
+ break;
/* Add other message types here: */
@@ -1432,7 +1437,7 @@
octstr_get_cstr(privdata->name), octstr_get_cstr(receiver));
pos += (len + 1) / 2;
} else {
- int i;
+ int i;
receiver = octstr_create("");
if ((ntype & 0x90) == 0x90) {
/* International number */
@@ -1451,54 +1456,54 @@
pos += 14; /* skip time stamps for now */
if ((type = octstr_get_char(pdu, pos)) == -1 ) {
- error(1,"AT2[%s]: STATUS-REPORT pdu too short to have TP-Status field !",
- octstr_get_cstr(privdata->name));
- goto error;
+ error(1,"AT2[%s]: STATUS-REPORT pdu too short to have TP-Status field !",
+ octstr_get_cstr(privdata->name));
+ goto error;
}
- /* check DLR type:
- * 3GPP TS 23.040 defines this a bit mapped field with lots of options
- * most of which are not really intersting to us, as we are only interested
- * in one of three conditions : failed, held in SC for delivery later, or delivered successfuly
- * and here's how I suggest to test it (read the 3GPP reference for further detailes) -
- * we'll test the 6th and 5th bits (7th bit when set making all other values 'reseved' so I want to test it).
- */
+ /* check DLR type:
+ * 3GPP TS 23.040 defines this a bit mapped field with lots of options
+ * most of which are not really intersting to us, as we are only interested
+ * in one of three conditions : failed, held in SC for delivery later, or delivered successfuly
+ * and here's how I suggest to test it (read the 3GPP reference for further detailes) -
+ * we'll test the 6th and 5th bits (7th bit when set making all other values 'reseved' so I want to test it).
+ */
type = type & 0xE0; /* filter out everything but the 7th, 6th and 5th bits */
switch (type) {
- case 0x00:
- /* 0 0 : success class */
- type = DLR_SUCCESS;
- tmpstr = octstr_create("Success/");
- break;
- case 0x20:
- /* 0 1 : buffered class (temporary error) */
- type = DLR_BUFFERED;
- tmpstr = octstr_create("Buffered/");
- break;
- case 0x40:
- case 0x60:
- default:
- /* 1 0 : failed class */
- /* 1 1 : failed class (actually, temporary error but timed out) */
- /* and any other value (can't think of any) is considered failure */
- type = DLR_FAIL;
- tmpstr = octstr_create("Failed/");
- break;
+ case 0x00:
+ /* 0 0 : success class */
+ type = DLR_SUCCESS;
+ tmpstr = octstr_create("Success");
+ break;
+ case 0x20:
+ /* 0 1 : buffered class (temporary error) */
+ type = DLR_BUFFERED;
+ tmpstr = octstr_create("Buffered");
+ break;
+ case 0x40:
+ case 0x60:
+ default:
+ /* 1 0 : failed class */
+ /* 1 1 : failed class (actually, temporary error but timed out) */
+ /* and any other value (can't think of any) is considered failure */
+ type = DLR_FAIL;
+ tmpstr = octstr_create("Failed");
+ break;
}
/* Actually, the above implementation is not correct, as the reference says that implementations should consider
* any "reserved" values to be "failure", but most reserved values fall into one of the three categories. it will catch
* "reserved" values where the first 3 MSBits are not set as "Success" which may not be correct. */
if ((dlrmsg = dlr_find(octstr_get_cstr(privdata->conn->id),
- octstr_get_cstr(msg_id), octstr_get_cstr(receiver), type)) == NULL) {
- debug("bb.smsc.at2",1,"AT2[%s]: Received delivery notification but can't find that ID in the DLR storage",
- octstr_get_cstr(privdata->name));
- goto error;
+ octstr_get_cstr(msg_id), octstr_get_cstr(receiver), type)) == NULL) {
+ debug("bb.smsc.at2",1,"AT2[%s]: Received delivery notification but can't find that ID in the DLR storage",
+ octstr_get_cstr(privdata->name));
+ goto error;
}
/* Beware DLR URL is now in msg->sms.dlr_url given by dlr_find() */
dlrmsg->sms.msgdata = octstr_duplicate(tmpstr);
-
+
error:
O_DESTROY(tmpstr);
O_DESTROY(pdu);
@@ -1575,7 +1580,7 @@
do {
if (privdata->modem->enable_mms &&
- list_len(privdata->outgoing_queue) > 1)
+ list_len(privdata->outgoing_queue) > 1)
at2_send_modem_command(privdata, "AT+CMMS=2", 0, 0);
if ((msg = list_extract_first(privdata->outgoing_queue)))
@@ -1608,17 +1613,17 @@
strcpy(sc, "00");
if (msg_type(msg) == sms) {
- Octstr* pdu;
+ Octstr* pdu;
- if ((pdu = at2_pdu_encode(msg, privdata)) == NULL) {
- error(2, "AT2[%s]: Error encoding PDU!",octstr_get_cstr(privdata->name));
- return;
- }
+ if ((pdu = at2_pdu_encode(msg, privdata)) == NULL) {
+ error(2, "AT2[%s]: Error encoding PDU!",octstr_get_cstr(privdata->name));
+ return;
+ }
ret = -99;
retries = RETRY_SEND;
while ((ret != 0) && (retries-- > 0)) {
- int msg_id = -1;
+ int msg_id = -1;
/*
* send the initial command and then wait for >
*/
@@ -1646,13 +1651,13 @@
if (ret != 0) /* OK only */
continue;
- /* gen DLR_SMSC_SUCCESS */
- if (msg->sms.dlr_mask & DLR_SMSC_SUCCESS)
- {
- Msg* dlrmsg;
+ /* gen DLR_SMSC_SUCCESS */
+ if (msg->sms.dlr_mask & DLR_SMSC_SUCCESS)
+ {
+ Msg* dlrmsg;
- dlrmsg = msg_create(sms);
- dlrmsg->sms.id = msg->sms.id;
+ dlrmsg = msg_create(sms);
+ dlrmsg->sms.id = msg->sms.id;
dlrmsg->sms.service = octstr_duplicate(msg->sms.service);
dlrmsg->sms.dlr_mask = DLR_SMSC_SUCCESS;
dlrmsg->sms.sms_type = report;
@@ -1663,41 +1668,41 @@
octstr_append(dlrmsg->sms.msgdata,msg->sms.dlr_url);
time(&dlrmsg->sms.time);
- debug("bb.smsc.at2",0,"AT2[%s]: sending DLR type ACK", octstr_get_cstr(privdata->name));
- bb_smscconn_receive(privdata->conn, dlrmsg);
+ debug("bb.smsc.at2",0,"AT2[%s]: sending DLR type ACK", octstr_get_cstr(privdata->name));
+ bb_smscconn_receive(privdata->conn, dlrmsg);
- }
+ }
- /* store DLR message if needed for SMSC generated delivery reports */
- if (msg->sms.dlr_mask & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED)) {
- if (msg_id == -1)
- error(0,"AT2[%s]: delivery notification requested, but I have no message ID!",
- octstr_get_cstr(privdata->name));
- else {
+ /* store DLR message if needed for SMSC generated delivery reports */
+ if (msg->sms.dlr_mask & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED)) {
+ if (msg_id == -1)
+ error(0,"AT2[%s]: delivery notification requested, but I have no message ID!",
+ octstr_get_cstr(privdata->name));
+ else {
Octstr *dlrmsgid = octstr_format("%d", msg_id);
dlr_add(octstr_get_cstr(privdata->conn->id),
octstr_get_cstr(dlrmsgid),
- octstr_get_cstr(msg->sms.sender),
- octstr_get_cstr(msg->sms.receiver),
- octstr_get_cstr(msg->sms.service),
- octstr_get_cstr(msg->sms.dlr_url),
- msg->sms.dlr_mask);
-
- O_DESTROY(dlrmsgid);
- }
- }
+ octstr_get_cstr(msg->sms.sender),
+ octstr_get_cstr(msg->sms.receiver),
+ octstr_get_cstr(msg->sms.service),
+ octstr_get_cstr(msg->sms.dlr_url),
+ msg->sms.dlr_mask);
+
+ O_DESTROY(dlrmsgid);
+ }
+ }
counter_increase(privdata->conn->sent);
bb_smscconn_sent(privdata->conn, msg);
}
if (ret != 0) {
- /* gen DLR_SMSC_FAIL */
- if (msg->sms.dlr_mask & DLR_SMSC_FAIL) {
- Msg* dlrmsg;
+ /* gen DLR_SMSC_FAIL */
+ if (msg->sms.dlr_mask & DLR_SMSC_FAIL) {
+ Msg* dlrmsg;
- dlrmsg = msg_create(sms);
+ dlrmsg = msg_create(sms);
dlrmsg->sms.service = octstr_duplicate(msg->sms.service);
dlrmsg->sms.dlr_mask = DLR_SMSC_FAIL;
dlrmsg->sms.sms_type = report;
@@ -1708,9 +1713,9 @@
octstr_append(dlrmsg->sms.msgdata,msg->sms.dlr_url);
time(&dlrmsg->sms.time);
- debug("bb.smsc.at2",0,"AT2[%s]: sending DLR type NACK", octstr_get_cstr(privdata->name));
- bb_smscconn_receive(privdata->conn, dlrmsg);
- }
+ debug("bb.smsc.at2",0,"AT2[%s]: sending DLR type NACK", octstr_get_cstr(privdata->name));
+ bb_smscconn_receive(privdata->conn, dlrmsg);
+ }
/*
* no need to do counter_increase(privdata->conn->failed) here,
@@ -1741,25 +1746,25 @@
* TP-RP , TP-UDHI, TP-SRR, TP-VPF(4), TP-VPF(3), TP-RD, TP-MTI(1), TP-MTI(0)
*/
octstr_append_char(buffer,
- ((msg->sms.rpi ? 1 : 0) << 7) /* TP-RP */
- | ((octstr_len(msg->sms.udhdata) ? 1 : 0) << 6) /* TP-UDHI */
- | (((msg->sms.dlr_mask & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED)) ? 1 : 0) << 5) /* TP-SRR */
- | 16 /* TP-VP(Rel)*/
- | 1 /* TP-MTI: SUBMIT_SM */
- );
+ ((msg->sms.rpi ? 1 : 0) << 7) /* TP-RP */
+ | ((octstr_len(msg->sms.udhdata) ? 1 : 0) << 6) /* TP-UDHI */
+ | (((msg->sms.dlr_mask & (DLR_SUCCESS | DLR_FAIL | DLR_BUFFERED)) ? 1 : 0) << 5) /* TP-SRR */
+ | 16 /* TP-VP(Rel)*/
+ | 1 /* TP-MTI: SUBMIT_SM */
+ );
/* message reference (0 for now) */
octstr_append_char(buffer, 0);
/* destination address */
if ((temp = at2_format_address_field(msg->sms.receiver)) == NULL)
- goto error;
+ goto error;
octstr_append(buffer, temp);
O_DESTROY(temp);
octstr_append_char(buffer, msg->sms.pid); /* protocol identifier */
octstr_append_char(buffer, fields_to_dcs(msg, /* data coding scheme */
- (msg->sms.alt_dcs ? 2 - msg->sms.alt_dcs : privdata->alt_dcs)));
+ (msg->sms.alt_dcs ? 2 - msg->sms.alt_dcs : privdata->alt_dcs)));
/*
* Validity-Period (TP-VP)
@@ -1832,7 +1837,7 @@
octstr_append_char(buffer,len);
if (octstr_len(msg->sms.udhdata)) /* udh */
- octstr_append(buffer, msg->sms.udhdata);
+ octstr_append(buffer, msg->sms.udhdata);
/* user data */
if (msg->sms.coding == DC_8BIT || msg->sms.coding == DC_UCS2) {
@@ -1852,7 +1857,7 @@
charset_latin1_to_gsm(msg->sms.msgdata);
if ((temp = at2_encode7bituncompressed(msg->sms.msgdata, offset)) != NULL)
- octstr_append(buffer, temp);
+ octstr_append(buffer, temp);
O_DESTROY(temp);
}
@@ -1880,24 +1885,24 @@
/* start packing the septet stream into an octet stream */
for (posS = 0, posT = 0; (source_chr = octstr_get_char(source, posS++)) != -1;) {
- /* grab least significant bits from current septet and store them packed to the right */
- target_chr |= (source_chr & LSBmask[i]) << iStore;
- /* store current byte if last command filled it */
- if (iStore != 0) {
- octstr_append_char(target, target_chr);
- target_chr = 0;
- }
- /* grab most significant bits from current septet and store them packed to the left */
- target_chr |= (source_chr & MSBmask[7 - i]) >> (8 - iStore) % 8;
- /* advance target bit index by 7 ( modulo 8 addition ) */
- iStore = (--iStore < 0 ? 7 : iStore);
- if (iStore != 0) /* if just finished packing 8 septets (into 7 octets) don't advance mask index */
- i = (++i > 7 ? 1 : i);
+ /* grab least significant bits from current septet and store them packed to the right */
+ target_chr |= (source_chr & LSBmask[i]) << iStore;
+ /* store current byte if last command filled it */
+ if (iStore != 0) {
+ octstr_append_char(target, target_chr);
+ target_chr = 0;
+ }
+ /* grab most significant bits from current septet and store them packed to the left */
+ target_chr |= (source_chr & MSBmask[7 - i]) >> (8 - iStore) % 8;
+ /* advance target bit index by 7 ( modulo 8 addition ) */
+ iStore = (--iStore < 0 ? 7 : iStore);
+ if (iStore != 0) /* if just finished packing 8 septets (into 7 octets) don't advance mask index */
+ i = (++i > 7 ? 1 : i);
}
/* don't forget to pack the leftovers ;-) */
if (target_chr)
- octstr_append_char(target, target_chr);
+ octstr_append_char(target, target_chr);
return target;
}
@@ -1938,10 +1943,10 @@
octstr_get_cstr(privdata->name));
for (i = 0; i < (sizeof(autospeeds) / sizeof(int)); i++) {
- if(at2_test_speed(privdata, autospeeds[i]) == 0) {
- privdata->speed = autospeeds[i];
- break;
- }
+ if(at2_test_speed(privdata, autospeeds[i]) == 0) {
+ privdata->speed = autospeeds[i];
+ break;
+ }
}
if (privdata->speed == 0) {
info(0, "AT2[%s]: cannot detect speed", octstr_get_cstr(privdata->name));
@@ -1956,7 +1961,7 @@
int res;
if (at2_open_device1(privdata) == -1)
- return -1;
+ return -1;
at2_set_speed(privdata, speed);
/* send a return so the modem can detect the speed */
@@ -1964,9 +1969,9 @@
res = at2_send_modem_command(privdata, "AT", 0, 0);
if (res != 0)
- res = at2_send_modem_command(privdata, "AT", 0, 0);
+ res = at2_send_modem_command(privdata, "AT", 0, 0);
if (res != 0)
- res = at2_send_modem_command(privdata, "AT", 0, 0);
+ res = at2_send_modem_command(privdata, "AT", 0, 0);
at2_close_device(privdata);
return res;
@@ -2228,7 +2233,7 @@
* others are national.
*/
if (strncmp(octstr_get_cstr(msisdn), "+", 1) == 0) {
- octstr_delete(temp, 0, 1);
+ octstr_delete(temp, 0, 1);
ntype = PNT_INTER; /* international */
} else if (strncmp(octstr_get_cstr(msisdn), "00", 2) == 0) {
octstr_delete(temp, 0, 2);
@@ -2240,19 +2245,19 @@
/* Type of address : bit mapped values */
octstr_append_char(out, 0x80 /* Type-of-address prefix */ |
- 0x01 /* Numbering-plan: MSISDN */ |
- (ntype == PNT_INTER ? 0x10 : 0x00) /* Type-of-number: International or National */
- );
+ 0x01 /* Numbering-plan: MSISDN */ |
+ (ntype == PNT_INTER ? 0x10 : 0x00) /* Type-of-number: International or National */
+ );
/* grab the digits from the MSISDN and encode as swapped semi-octets */
while (octstr_len(temp)) {
- int digit1, digit2;
- /* get the first two digit */
- digit1 = octstr_get_char(temp,0) - 48;
- if ((digit2 = octstr_get_char(temp,1) - 48) < 0)
- digit2 = 0x0F;
- octstr_append_char(out, (digit2 << 4) | digit1);
- octstr_delete(temp, 0, 2);
+ int digit1, digit2;
+ /* get the first two digit */
+ digit1 = octstr_get_char(temp,0) - 48;
+ if ((digit2 = octstr_get_char(temp,1) - 48) < 0)
+ digit2 = 0x0F;
+ octstr_append_char(out, (digit2 << 4) | digit1);
+ octstr_delete(temp, 0, 2);
}
O_DESTROY(temp);