[PATCH] dlr_mem.c & dlr_sdb.c check for dst

Nicholas Rahn <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

This patch adds the check for the destination to dlr verification in
internal and sdb storage.  As more than one sms can be sent with the
same timestamp and smsc-id, these are not enough to ensure unicity of
the dlrs.  So, as Robert Galach did for dlr_oracle.c, this patch adds
the destination number to the check.  NOTE: mysql is now the only dlr
storage that does not use this approach.

One thing i have noticed is that the CIMD2 smsc that i connect to
accepts a destination number in international format (i.e. +41). 
However, the dlr received back from the SMSC does not contain the "+"
character.  So now (with my patch above :-), none of the received dlrs
match!  Can anyone suggest a solution to this?

Thanks,
nick
dlr.diff (text/x-patch, 3.6 KB)
Index: dlr_mem.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_mem.c,v
retrieving revision 1.4
diff -u -r1.4 dlr_mem.c
--- dlr_mem.c	22 Jan 2004 14:08:24 -0000	1.4
+++ dlr_mem.c	31 Mar 2004 08:15:21 -0000
@@ -117,7 +117,9 @@
     /* XXX: check destination addr too, because e.g. for UCP is not enough to check only
      *          smsc and timestamp (timestamp is even without milliseconds)
      */
-    if(octstr_compare(dlr->smsc,smsc) == 0 && octstr_compare(dlr->timestamp,ts) == 0)
+    if(octstr_compare(dlr->smsc,smsc) == 0 && 
+       octstr_compare(dlr->timestamp,ts) == 0 &&
+       octstr_compare(dlr->destination,dst) == 0)
         return 0;
 
     return 1;
Index: dlr_sdb.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr_sdb.c,v
retrieving revision 1.7
diff -u -r1.7 dlr_sdb.c
--- dlr_sdb.c	22 Jan 2004 14:08:24 -0000	1.7
+++ dlr_sdb.c	31 Mar 2004 08:15:21 -0000
@@ -197,13 +197,15 @@
 
     gw_assert(res != NULL);
 
-    sql = octstr_format("SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s='%s' AND %s='%s' %s",
+    sql = octstr_format("SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s='%s' AND %s='%s' AND %s='%s' %s",
                         octstr_get_cstr(fields->field_mask), octstr_get_cstr(fields->field_serv),
                         octstr_get_cstr(fields->field_url), octstr_get_cstr(fields->field_src),
                         octstr_get_cstr(fields->field_dst), octstr_get_cstr(fields->field_boxc),
                         octstr_get_cstr(fields->table),
                         octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
-                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts),
+			octstr_get_cstr(fields->field_dst), octstr_get_cstr(dst),
+			sdb_get_limit_str());
 
 #if defined(DLR_TRACE)
      debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
@@ -237,11 +239,14 @@
     int	state;
 
     debug("dlr.sdb", 0, "SDB: updating DLR status in database");
-    sql = octstr_format("UPDATE %s SET %s=%d WHERE %s='%s' AND %s='%s' %s",
+
+    sql = octstr_format("UPDATE %s SET %s=%d WHERE %s='%s' AND %s='%s' AND %s='%s' %s",
                         octstr_get_cstr(fields->table),
                         octstr_get_cstr(fields->field_status), status,
                         octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
-                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), 
+                        octstr_get_cstr(fields->field_dst), octstr_get_cstr(dst), 
+			sdb_get_limit_str());
 
 #if defined(DLR_TRACE)
      debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
@@ -262,10 +267,13 @@
     int	state;
 
     debug("dlr.sdb", 0, "removing DLR from database");
-    sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' %s",
+
+    sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s' AND %s='%s' %s",
                         octstr_get_cstr(fields->table),
                         octstr_get_cstr(fields->field_smsc), octstr_get_cstr(smsc),
-                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts), sdb_get_limit_str());
+                        octstr_get_cstr(fields->field_ts), octstr_get_cstr(ts),
+			octstr_get_cstr(fields->field_dst), octstr_get_cstr(dst),
+			sdb_get_limit_str());
 
 #if defined(DLR_TRACE)
      debug("dlr.sdb", 0, "SDB: sql: %s", octstr_get_cstr(sql));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.