--- gw/smsc/smsc_smpp.c	Tue Aug 13 20:44:42 2002
+++ ../../gateway_work	Tue Aug 13 20:41:54 2002
@@ -97,6 +97,9 @@
     int version;
     int priority;       /* set default priority for messages */
     time_t throttling_err_time;
+	int smpp_msg_id_type; /* some smscs give the msg id in hex at submit and
+                           * decimal in deliver_sm (default)(0)
+                           * others use hex at submit and hex in deliver_sm (1) */
     SMSCConn *conn;
 } SMPP;

@@ -109,7 +112,8 @@
                          int dest_addr_ton, int dest_addr_npi,
                          int alt_dcs, int enquire_link_interval,
                          int max_pending_submits, int reconnect_delay,
-                         int version, int priority, Octstr *my_number)
+                         int version, int priority, Octstr *my_number,
+						  long smpp_msg_id_type)
 {
     SMPP *smpp;

@@ -143,6 +147,7 @@
     smpp->priority = priority;
     smpp->conn = conn;
     smpp->throttling_err_time = 0;
+	 smpp->smpp_msg_id_type = smpp_msg_id_type;

     return smpp;
 }
@@ -657,7 +662,16 @@

                 if (msgid != NULL) {
                     Octstr *tmp;
-                    tmp = octstr_format("%ld", strtol(octstr_get_cstr(msgid), NULL, 10));
+
+					/** some smscs give the msg id in hex at
+					 ** submit_sm_resp and decimal in deliver_sm   (default)(0)
+					 ** others use hex at submit_sm_resp and hex in deliver_sm (1)
+					*/
+					if (smpp->smpp_msg_id_type == 1)
+					tmp = octstr_format("%ld", strtol(octstr_get_cstr(msgid) , NULL, 16));
+					else
+					tmp = octstr_format("%ld", strtol(octstr_get_cstr(msgid) , NULL, 10));
+
                     dlrmsg = dlr_find(octstr_get_cstr(smpp->conn->id),
                                       octstr_get_cstr(tmp), /* smsc message id */
                                       octstr_get_cstr(pdu->u.deliver_sm.destination_addr), /* destination */
@@ -1088,6 +1102,7 @@
     long reconnect_delay;
     long version;
     long priority;
+	long smpp_msg_id_type;


     my_number = NULL;
@@ -1108,6 +1123,9 @@
     our_host = cfg_get(grp, octstr_imm("our-host"));
     my_number = cfg_get(grp, octstr_imm("my-number"));

+    if (cfg_get_integer(&smpp_msg_id_type, grp, octstr_imm("smpp-msg-id-type")) == -1)
+        smpp_msg_id_type = 0;
+
     system_id = cfg_get(grp, octstr_imm("system-id"));
     if (system_id != NULL) {
         warning(0, "SMPP: obsolete system-id variable is set, "
@@ -1185,7 +1203,7 @@
                        source_addr_ton, source_addr_npi, dest_addr_ton,
                        dest_addr_npi, alt_dcs, enquire_link_interval,
                        max_pending_submits, reconnect_delay,
-                       version, priority, my_number);
+                       version, priority, my_number, smpp_msg_id_type);

     conn->data = smpp;
     conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S",
