[PATCH] SMPP transceive option
"Simon Beale" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi The attached patch adds in the boolean option "transceiver-mode". If set, it will do a 'tranceive' connection instead of a transmit connection down the standard port. It doesn't do any fallback to 'transmit' if 'transceive' fails, and it only is relevant for SMPP v3.4. Simon
transceiver.diff
(application/octet-stream, 5.5 KB)
diff -ur kannel-snapshot-orig/doc/userguide/userguide.xml kannel-snapshot-transceiver/doc/userguide/userguide.xml
--- kannel-snapshot-orig/doc/userguide/userguide.xml Wed Mar 27 15:49:04 2002
+++ kannel-snapshot-transceiver/doc/userguide/userguide.xml Wed Apr 10 18:10:37 2002
@@ -2237,6 +2237,18 @@
Use value 0 to disable this I/O thread.
</entry></row>
+ <row><entry><literal>transceiver-mode</literal></entry>
+ <entry>bool</entry>
+ <entry valign=bottom>
+ Attempt to use a TRANSCEIVER mode connection
+ to the SM-SC. It uses the standard transmit 'port',
+ there is no need to set 'receive-port'.
+ This is a SMPP 3.4 only feature and will not work
+ on an earlier SM-SC.
+ This will try a bind_transceiver only and will not attempt
+ to fall back to doing transmit and receive on the same connection.
+ </entry></row>
+
<row><entry><literal>smsc-username (m)</literal></entry>
<entry><literal>string</literal></entry>
<entry valign=bottom>
diff -ur kannel-snapshot-orig/gw/smpp_pdu.def kannel-snapshot-transceiver/gw/smpp_pdu.def
--- kannel-snapshot-orig/gw/smpp_pdu.def Thu Nov 8 08:41:23 2001
+++ kannel-snapshot-transceiver/gw/smpp_pdu.def Wed Apr 10 17:37:30 2002
@@ -84,6 +84,25 @@
/* XXX not included for now: NULTERMINATED(system_id, 16) */
)
+PDU(bind_transceiver,
+ 0x00000009,
+ HEADER
+ NULTERMINATED(system_id, 16)
+ NULTERMINATED(password, 9)
+ NULTERMINATED(system_type, 13)
+ INTEGER(interface_version, 1)
+ INTEGER(addr_ton, 1)
+ INTEGER(addr_npi, 1)
+ NULTERMINATED(address_range, 41)
+)
+
+
+PDU(bind_transceiver_resp,
+ 0x80000009,
+ HEADER
+ /* XXX not included for now: NULTERMINATED(system_id, 16) */
+)
+
PDU(unbind,
0x00000006,
HEADER
diff -ur kannel-snapshot-orig/gw/smsc_smpp.c kannel-snapshot-transceiver/gw/smsc_smpp.c
--- kannel-snapshot-orig/gw/smsc_smpp.c Fri Mar 22 11:57:41 2002
+++ kannel-snapshot-transceiver/gw/smsc_smpp.c Wed Apr 10 17:37:30 2002
@@ -386,6 +386,40 @@
return conn;
}
+/*
+ * Open transceiver connection to SMS center. Return NULL for error,
+ * open Connection for OK. Caller must set smpp->conn->status correctly
+ * before calling this.
+ */
+static Connection *open_transceiver(SMPP *smpp)
+{
+ SMPP_PDU *bind;
+ Connection *conn;
+
+ conn = conn_open_tcp(smpp->host, smpp->transmit_port, smpp->our_host );
+ if (conn == NULL) {
+ error(0, "SMPP: Couldn't connect to server.");
+ return NULL;
+ }
+
+ bind = smpp_pdu_create(bind_transceiver,
+ counter_increase(smpp->message_id_counter));
+ bind->u.bind_transmitter.system_id = octstr_duplicate(smpp->username);
+ bind->u.bind_transmitter.password = octstr_duplicate(smpp->password);
+ if (smpp->system_type == NULL)
+ bind->u.bind_transmitter.system_type = octstr_create("VMA");
+ else
+ bind->u.bind_transmitter.system_type =
+ octstr_duplicate(smpp->system_type);
+ bind->u.bind_transmitter.interface_version = 0x34;
+ bind->u.bind_transmitter.address_range =
+ octstr_duplicate(smpp->address_range);
+ send_pdu(conn, bind);
+ smpp_pdu_destroy(bind);
+
+ return conn;
+}
+
/*
* Open reception connection to SMS center. Return NULL for error,
@@ -643,6 +677,19 @@
}
break;
+ case bind_transceiver_resp:
+ if (pdu->u.bind_transceiver_resp.command_status != 0) {
+ error(0, "SMPP: SMSC rejected login to transmit, "
+ "code 0x%08lx.",
+ pdu->u.bind_transceiver_resp.command_status);
+ } else {
+ *pending_submits = 0;
+ smpp->conn->status = SMSCCONN_ACTIVE;
+ smpp->conn->connect_time = time(NULL);
+ bb_smscconn_connected(smpp->conn);
+ }
+ break;
+
case bind_receiver_resp:
if (pdu->u.bind_transmitter_resp.command_status != 0) {
error(0, "SMPP: SMSC rejected login to receive, "
@@ -708,8 +755,10 @@
conn = NULL;
while (!smpp->quitting) {
- if (transmitter)
+ if (transmitter==1)
conn = open_transmitter(smpp);
+ else if (transmitter==2)
+ conn = open_transceiver(smpp);
else
conn = open_receiver(smpp);
if (conn == NULL) {
@@ -838,6 +887,7 @@
long dest_addr_npi;
Octstr *our_host;
SMPP *smpp;
+ int transceiver_mode=0;
int ok;
host = cfg_get(grp, octstr_imm("host"));
@@ -845,6 +895,7 @@
port = 0;
if (cfg_get_integer(&receive_port, grp, octstr_imm("receive-port")) == -1)
receive_port = 0;
+ cfg_get_bool(&transceiver_mode,grp,octstr_imm("transceiver-mode"));
username = cfg_get(grp, octstr_imm("smsc-username"));
password = cfg_get(grp, octstr_imm("smsc-password"));
system_type = cfg_get(grp, octstr_imm("system-type"));
@@ -915,7 +966,7 @@
* disable the creation of the corresponding thread.
*/
if (port != 0)
- smpp->transmitter = gwthread_create(io_thread, io_arg_create(smpp, 1));
+ smpp->transmitter = gwthread_create(io_thread, io_arg_create(smpp, (transceiver_mode?2:1)));
if (receive_port != 0)
smpp->receiver = gwthread_create(io_thread, io_arg_create(smpp, 0));
diff -ur kannel-snapshot-orig/gwlib/cfg.def kannel-snapshot-transceiver/gwlib/cfg.def
--- kannel-snapshot-orig/gwlib/cfg.def Sun Mar 24 15:44:07 2002
+++ kannel-snapshot-transceiver/gwlib/cfg.def Wed Apr 10 17:37:30 2002
@@ -196,6 +196,7 @@
OCTSTR(source-addr-npi)
OCTSTR(dest-addr-ton)
OCTSTR(dest-addr-npi)
+ OCTSTR(transceiver-mode)
)