[PATCH] Re: SMPP deliver_sm arrives before submit_sm_resp

Ben Suffolk <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi Stipe,

I'm always willing to share any improvements, and I did actually send  
the first of the 2 patch files I spoke about below for review in Jan/  
Feb 2007, where it got quite a few +1's but it never got committed,  
can;t remember why. Here is the thread with them in, doe snot seem to  
mention the reason for no commit though :-

http://www.nabble.com/Multiple-SMSCs-and-a-DLR-group- 
td8655999.html#a8655999

Anyway, I've been using it now over  a year, and not had any problems  
with it.

This patch is the the group dlr patch to enable multiple smscs with  
different smsc-ids to be part of the same dlr-group. This solves the  
problem where the dlr comes back on a different connection from the  
one it was sent in on.




The second patch to fix the dlr delay issue (in the email below),  
clearly contains the first patch as well since it was not committed  
to CVS. Clearly if the first patch gets committed the the second one  
can be recreated as a standalone one easily enough if required. This  
has also been running for over a year on my production system without  
any issues.



Regards

Ben



On 14 Mar 2008, at 00:09, Stipe Tolj wrote:

> Ben Suffolk schrieb:
>> Dave,
>> I had this problem somewhile back myself (Oct 2006 ) :-
>> http://www.nabble.com/Interesting-issue-with-DLRs- 
>> td6851347.html#a6923001
>> Anyway, I wrote a patch and have had no problems since. There were  
>> 2 different issues, one is the one you suggest, where it can come  
>> in a lot later, the other was because of the 2 different threads  
>> that process the TX & RX. My patch fixes them both.
>> Your more than welcome to the patch, but as I had already applied  
>> another patch I wrote to allow multiple SMSCs to be grouped (I had  
>> a situation where I had 3 SMSC connections, and the DLR could come  
>> back from a different on that I submitted to) you will either need  
>> to apply that patch as well, or fiddle a bit with it.
>> The smsc dlr group thing was discussed here, the patch never got  
>> committed though for some reason :-
>> http://www.nabble.com/Multiple-SMSCs-and-a-DLR-group- 
>> td8655999.html#a8655999 I think the reason I didn't submit the DLR  
>> delay fix patch was because the DLR group patch did not get  
>> committed, and I did not have time to take out the first patches  
>> bits to create the clean patch against CVS head.
>> Email me directly if you want the 2 patch files.
>
> Ben, can you please do us all a favor and send a the patches as  
> 'diff -u' format with [PATCH] as subject prefix to the 'devel'  
> mailing list, so we can review and see how to commit to CVS.
>
> So everyone can benefit from your contribution.
>
> In any case, I'd like to move this topic to the 'devel' list, since  
> its more related to there.
>
> Thanks,
> Stipe
>
> -------------------------------------------------------------------
> Kölner Landstrasse 419
> 40589 Düsseldorf, NRW, Germany
>
> tolj.org system architecture      Kannel Software Foundation (KSF)
> http://www.tolj.org/              http://www.kannel.org/
>
> mailto:st_{at}_tolj.org           mailto:stolj_{at}_kannel.org
> -------------------------------------------------------------------
dlr_group_smsc.patch (application/octet-stream, 6.3 KB)
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.331
diff -r1.331 userguide.xml
2425a2426,2436
>    <row><entry><literal>dlr-group-id</literal></entry>
>      <entry><literal>string</literal></entry>
>      <entry valign="bottom">
>         An optional name or id for grouping more than one SMSC together for the purposes
>         of Delivery Reports.  e.g. if you have multiple SMSC connections to the same provider
>         and there is the possibility that you can receive the DLR on a different connection to 
>         the one you sent the message on, then you should group the SMSCs together. This allows
>         you to have different <literal>smsc-id</literal> specified for each SMSC whilst mainting
>         functional DLRs.
>      </entry></row>
> 
Index: gw/smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn.c,v
retrieving revision 1.57
diff -r1.57 smscconn.c
186a187,190
>     GET_OPTIONAL_VAL(conn->dlr_group_id, "dlr-group-id");
>     if (conn->dlr_group_id == NULL)
>      conn->dlr_group_id = octstr_duplicate(conn->id);
>      
332a337
>     octstr_destroy(conn->dlr_group_id);
Index: gw/smscconn_p.h
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn_p.h,v
retrieving revision 1.51
diff -r1.51 smscconn_p.h
170a171
>     Octstr *dlr_group_id;  /* ID used for DLRs specified in configuration */
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.46
diff -r1.46 smsc_at.c
1916c1916
<     if ((dlrmsg = dlr_find(privdata->conn->id, msg_id, receiver, type)) == NULL) {
---
>     if ((dlrmsg = dlr_find(privdata->conn->dlr_group_id, msg_id, receiver, type)) == NULL) {
2111c2111
<                         dlr_add(privdata->conn->id, dlrmsgid, msg);
---
>                         dlr_add(privdata->conn->dlr_group_id, dlrmsgid, msg);
Index: gw/smsc/smsc_cgw.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cgw.c,v
retrieving revision 1.16
diff -r1.16 smsc_cgw.c
1137c1137
<                 dlrmsg = dlr_find(conn->id,
---
>                 dlrmsg = dlr_find(conn->dlr_group_id,
1143c1143
<                 dlrmsg = dlr_find(conn->id,
---
>                 dlrmsg = dlr_find(conn->dlr_group_id,
1149c1149
<                 dlrmsg = dlr_find(conn->id,
---
>                 dlrmsg = dlr_find(conn->dlr_group_id,
1184c1184
<             dlr_add(conn->id, ts, msg);
---
>             dlr_add(conn->dlr_group_id, ts, msg);
Index: gw/smsc/smsc_cimd2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cimd2.c,v
retrieving revision 1.33
diff -r1.33 smsc_cimd2.c
1979c1979
<         dlr_add(conn->name, ts, msg);
---
>         dlr_add(conn->dlr_group_id, ts, msg);
2117c2117
<     	msg = dlr_find(conn->name, timestamp, destination, code);
---
>     	msg = dlr_find(conn->dlr_group_id, timestamp, destination, code);
Index: gw/smsc/smsc_emi.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_emi.c,v
retrieving revision 1.20
diff -r1.20 smsc_emi.c
842c842
< 		msg = dlr_find((conn->id ? conn->id : privdata->name),
---
> 		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
848c848
< 		msg = dlr_find((conn->id ? conn->id : privdata->name),
---
> 		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
854c854
< 		msg = dlr_find((conn->id ? conn->id : privdata->name),
---
> 		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
1107c1107
< 				    dlr_add((conn->id ? conn->id : privdata->name), ts, m);
---
> 				    dlr_add((conn->dlr_group_id ? conn->dlr_group_id : privdata->name), ts, m);
Index: gw/smsc/smsc_fake.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_fake.c,v
retrieving revision 1.21
diff -r1.21 smsc_fake.c
291c291
<                     dlrmsg = dlr_find(conn->id,
---
>                     dlrmsg = dlr_find(conn->dlr_group_id,
449c449
<         dlr_add(conn->id, tmp, sms);
---
>         dlr_add(conn->dlr_group_id, tmp, sms);
Index: gw/smsc/smsc_http.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_http.c,v
retrieving revision 1.55
diff -r1.55 smsc_http.c
493c493
<             dlr_add(conn->id, mid, msg);
---
>             dlr_add(conn->dlr_group_id, mid, msg);
572c572
<         dlrmsg = dlr_find(conn->id,
---
>         dlrmsg = dlr_find(conn->dlr_group_id,
751c751
<                 dlr_add(conn->id, msgid, msg);
---
>                 dlr_add(conn->dlr_group_id, msgid, msg);
850c850
<         dlrmsg = dlr_find(conn->id,
---
>         dlrmsg = dlr_find(conn->dlr_group_id,
1255c1255
<                 dlr_add(conn->id, mid, msg);
---
>                 dlr_add(conn->dlr_group_id, mid, msg);
1329c1329
<         dlrmsg = dlr_find(conn->id,
---
>         dlrmsg = dlr_find(conn->dlr_group_id,
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.102
diff -r1.102 smsc_smpp.c
1276c1276
<         dlrmsg = dlr_find(smpp->conn->id,
---
>         dlrmsg = dlr_find(smpp->conn->dlr_group_id,
1504c1504
<                     dlr_add(smpp->conn->id, tmp, msg);
---
>                     dlr_add(smpp->conn->dlr_group_id, tmp, msg);
Index: gw/smsc/smsc_soap.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_soap.c,v
retrieving revision 1.20
diff -r1.20 smsc_soap.c
1177c1177
<         dlr_add(conn->id, octstr_imm(tmpid), msg);
---
>         dlr_add(conn->dlr_group_id, octstr_imm(tmpid), msg);
1619c1619
<     dlrmsg = dlr_find(conn->id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
---
>     dlrmsg = dlr_find(conn->dlr_group_id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.131
diff -r1.131 cfg.def
295a296
>     OCTSTR(dlr-group-id)
dlr_delay.patch (application/octet-stream, 22.4 KB)
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.331
diff -u -r1.331 userguide.xml
--- doc/userguide/userguide.xml	3 Aug 2007 15:09:23 -0000	1.331
+++ doc/userguide/userguide.xml	14 Mar 2008 09:17:28 -0000
@@ -2399,6 +2399,17 @@
    <row><entry><literal>smsc (m)</literal></entry>
      <entry><literal>string</literal></entry>
      <entry valign="bottom">
+   <row><entry><literal>dlr-group-id</literal></entry>
+     <entry><literal>string</literal></entry>
+     <entry valign="bottom">
+        An optional name or id for grouping more than one SMSC together for the purposes
+        of Delivery Reports.  e.g. if you have multiple SMSC connections to the same provider
+        and there is the possibility that you can receive the DLR on a different connection to 
+        the one you sent the message on, then you should group the SMSCs together. This allows
+        you to have different <literal>smsc-id</literal> specified for each SMSC whilst mainting
+        functional DLRs.
+     </entry></row>
+
        Identifies the SMS center type. See below
        for a complete list.
      </entry></row>
@@ -2423,6 +2434,17 @@
 
      </entry></row>
 
+   <row><entry><literal>dlr-group-id</literal></entry>
+     <entry><literal>string</literal></entry>
+     <entry valign="bottom">
+        An optional name or id for grouping more than one SMSC together for the purposes
+        of Delivery Reports.  e.g. if you have multiple SMSC connections to the same provider
+        and there is the possibility that you can receive the DLR on a different connection to 
+        the one you sent the message on, then you should group the SMSCs together. This allows
+        you to have different <literal>smsc-id</literal> specified for each SMSC whilst mainting
+        functional DLRs.
+     </entry></row>
+
     <row><entry><literal>throughput</literal></entry>
       <entry><literal>number (messages/sec)</literal></entry>
       <entry valign="bottom">
Index: gw/dlr.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr.c,v
retrieving revision 1.56
diff -u -r1.56 dlr.c
--- gw/dlr.c	19 Feb 2008 11:12:30 -0000	1.56
+++ gw/dlr.c	14 Mar 2008 09:17:28 -0000
@@ -93,6 +93,10 @@
 /* Our callback functions */
 static struct dlr_storage *handles = NULL;
 
+/* Mutex to make sure we don't miss any DLRs */
+static Mutex *dlr_mutex;
+
+
 /*
  * Function to allocate a new struct dlr_entry entry
  * and intialize it to zero
@@ -229,6 +233,8 @@
     CfgGroup *grp;
     Octstr *dlr_type;
 
+    dlr_mutex = mutex_create();
+
     /* check which DLR storage type we are using */
     grp = cfg_get_single_group(cfg, octstr_imm("core"));
     if(grp == NULL)
@@ -284,6 +290,8 @@
 {
     if (handles != NULL && handles->dlr_shutdown != NULL)
         handles->dlr_shutdown();
+    
+    mutex_destroy(dlr_mutex);
 }
 
 /* 
@@ -311,9 +319,12 @@
 /*
  * Add new dlr entry into dlr storage
  */
-void dlr_add(const Octstr *smsc, const Octstr *ts, const Msg *msg)
+void dlr_add(SMSCConn *conn, const Octstr *smsc, const Octstr *ts, const Msg *msg)
 {
     struct dlr_entry *dlr = NULL;
+    Octstr *dst;
+    Msg *dlrmsg;
+    int typ, done = 0;
 
     if(octstr_len(smsc) == 0) {
 	warning(0, "DLR[%s]: Can't add a dlr without smsc-id", dlr_type());
@@ -323,11 +334,75 @@
     /* sanity check */
     if (handles == NULL || handles->dlr_add == NULL || msg == NULL)
         return;
+    
+    mutex_lock(dlr_mutex);
+    
+    /*
+     * It's posible that if a DLR came in before this ACK we may already
+     * have one stored so we need to check that first. If we have then we
+     * must action each of the ones that have been in, and if any were
+     * finals then we must also remove the DLR
+     */
+    if ( handles->dlr_get != NULL) {
+        dst = (msg->sms.receiver ? octstr_duplicate(msg->sms.receiver) : octstr_create(""));
+        dlr = handles->dlr_get(smsc, ts, dst);
+       
+        if(dlr && octstr_len(dlr->url) == 0) {
+
+           	info(0, "DLR[%s]: Found delayed DLR mask:%d", dlr_type(), dlr->mask);
+
+            /* If DLRs and not requested then simply delete any that we found */
+            if (!DLR_IS_ENABLED(msg->sms.dlr_mask)) {
+                if (handles->dlr_remove != NULL)
+                    handles->dlr_remove(smsc, ts, dst);
+                dlr_entry_destroy(dlr);
+                octstr_destroy(dst);
+                mutex_unlock(dlr_mutex);
+                return;
+            }
+         
+            /* Process each of the DLRs that were recorded */
+            for(typ = DLR_SUCCESS; typ < (DLR_SMSC_FAIL + 1); typ <<= 1) {
+                if ((typ & dlr->mask) > 0) {
+                    dlrmsg = msg_duplicate(msg);   
+                    /* This is normally added by the SMSC layer, but we don't know that bit here */
+                    dlrmsg->sms.msgdata = octstr_format("Delayed DLR: id:%s status:%d", octstr_get_cstr(ts), typ);
+                    dlrmsg->sms.sms_type = report_mo;
+                    dlrmsg->sms.dlr_mask = typ;
+
+                    /* Pass it up to bb */
+                    bb_smscconn_receive(conn, dlrmsg);
+                    
+                    /* Check if this we have had a final DLR */
+                    if (typ == DLR_SUCCESS || typ == DLR_FAIL)
+                        done = 1;
+                }
+            }   
+           
+        }
+
+       /* Delete the DLR so we can add the real mask now */
+       if (dlr) {
+           if (handles->dlr_remove != NULL)
+               handles->dlr_remove(smsc, ts, dst);
+            dlr_entry_destroy(dlr);
+       }
+       octstr_destroy(dst);
+                   
+       /* If we have already processed the final DLR, then no need to add the mask anymore */
+       if (done) {
+           mutex_unlock(dlr_mutex);
+           return;
+       }
+    }
+    
 
     /* check if delivery receipt requested */
-    if (!DLR_IS_ENABLED(msg->sms.dlr_mask))
+    if (!DLR_IS_ENABLED(msg->sms.dlr_mask)) {
+        mutex_unlock(dlr_mutex);
         return;
-
+    }
+    
      /* allocate new struct dlr_entry struct */
     dlr = dlr_entry_create();
     gw_assert(dlr != NULL);
@@ -348,6 +423,8 @@
 	
     /* call registered function */
     handles->dlr_add(dlr);
+
+    mutex_unlock(dlr_mutex);
 }
 
 /*
@@ -369,6 +446,7 @@
     if (handles == NULL || handles->dlr_get == NULL)
         return NULL;
 
+    mutex_lock(dlr_mutex);
     debug("dlr.dlr", 0, "DLR[%s]: Looking for DLR smsc=%s, ts=%s, dst=%s, type=%d",
                                  dlr_type(), octstr_get_cstr(smsc), octstr_get_cstr(ts), octstr_get_cstr(dst), typ);
 
@@ -376,6 +454,31 @@
     if (dlr == NULL)  {
         warning(0, "DLR[%s]: DLR from SMSC<%s> for DST<%s> not found.",
                 dlr_type(), octstr_get_cstr(smsc), octstr_get_cstr(dst));         
+                      
+        /*
+         * This can happen if the ACK is being processed in a different thread
+         * and has not been added before the next DLR comes in.
+         *
+         * Add the DLR so we can process it later when we get the ACK
+         */              
+        if (handles == NULL || handles->dlr_add == NULL)
+            return NULL;
+
+        dlr = dlr_entry_create();
+        gw_assert(dlr != NULL);
+
+        dlr->smsc = (smsc ? octstr_duplicate(smsc) : octstr_create(""));
+        dlr->timestamp = (ts ? octstr_duplicate(ts) : octstr_create(""));
+        dlr->source = octstr_create("");
+        dlr->destination = (dst ? octstr_duplicate(dst) : octstr_create(""));
+        dlr->service = octstr_create("");
+        dlr->url = octstr_create("");
+        dlr->boxc_id = octstr_create("");
+        dlr->mask = typ;
+
+        handles->dlr_add(dlr);
+                      
+        mutex_unlock(dlr_mutex);
         return NULL;
     }
 
@@ -407,6 +510,21 @@
         debug("dlr.dlr", 0, "DLR[%s]: created DLR message for URL <%s>",
                       dlr_type(), (msg->sms.dlr_url?octstr_get_cstr(msg->sms.dlr_url):""));
     } else {
+        
+        /*
+         * Its possible that we still have not had the ACK, in which case
+         * we should update the DLR with this status as well (sice we don't
+         * yet know which DLRs we are actually interested in)
+         */
+        if (octstr_len(dlr->url) > 0) {
+            if (handles->dlr_update != NULL)
+                handles->dlr_update(smsc, ts, dst, (dlr->mask | typ));
+
+            dlr_entry_destroy(dlr);
+            mutex_unlock(dlr_mutex);
+            return NULL;
+        }
+
         debug("dlr.dlr", 0, "DLR[%s]: Ignoring DLR message because of mask type=%d dlr->mask=%d", dlr_type(), typ, dlr->mask);
         /* ok that was a status report but we where not interested in having it */
         msg = NULL;
@@ -432,6 +550,7 @@
     /* destroy struct dlr_entry */
     dlr_entry_destroy(dlr);
 
+    mutex_unlock(dlr_mutex);
     return msg;
 }
     
Index: gw/dlr.h
===================================================================
RCS file: /home/cvs/gateway/gw/dlr.h,v
retrieving revision 1.25
diff -u -r1.25 dlr.h
--- gw/dlr.h	9 Jan 2008 20:06:57 -0000	1.25
+++ gw/dlr.h	14 Mar 2008 09:17:28 -0000
@@ -86,6 +86,8 @@
 #define DLR_IS_SMSC_SUCCESS(dlr)     (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_SUCCESS))
 #define DLR_IS_SMSC_FAIL(dlr)        (DLR_IS_DEFINED(dlr) && (dlr & DLR_SMSC_FAIL))
 
+#include "smscconn.h"
+
 /* DLR initialization routine (abstracted) */
 void dlr_init(Cfg *cfg);
 
@@ -95,7 +97,7 @@
 /* 
  * Add a new entry to the list
  */
-void dlr_add(const Octstr *smsc, const Octstr *ts, const Msg *msg);
+void dlr_add(SMSCConn *conn, const Octstr *smsc, const Octstr *ts, const Msg *msg);
 
 /* 
  * Find an entry in the list. If there is one a message is returned and 
Index: gw/smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn.c,v
retrieving revision 1.57
diff -u -r1.57 smscconn.c
--- gw/smscconn.c	9 Jan 2008 20:06:57 -0000	1.57
+++ gw/smscconn.c	14 Mar 2008 09:17:29 -0000
@@ -184,6 +184,10 @@
         }while(0)
 
     GET_OPTIONAL_VAL(conn->id, "smsc-id");
+    GET_OPTIONAL_VAL(conn->dlr_group_id, "dlr-group-id");
+    if (conn->dlr_group_id == NULL)
+     conn->dlr_group_id = octstr_duplicate(conn->id);
+     
     SPLIT_OPTIONAL_VAL(conn->allowed_smsc_id, "allowed-smsc-id");
     SPLIT_OPTIONAL_VAL(conn->denied_smsc_id, "denied-smsc-id");
     SPLIT_OPTIONAL_VAL(conn->preferred_smsc_id, "preferred-smsc-id");
@@ -330,6 +334,7 @@
 
     octstr_destroy(conn->name);
     octstr_destroy(conn->id);
+    octstr_destroy(conn->dlr_group_id);
     gwlist_destroy(conn->allowed_smsc_id, octstr_destroy_item);
     gwlist_destroy(conn->denied_smsc_id, octstr_destroy_item);
     gwlist_destroy(conn->preferred_smsc_id, octstr_destroy_item);
Index: gw/smscconn_p.h
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn_p.h,v
retrieving revision 1.51
diff -u -r1.51 smscconn_p.h
--- gw/smscconn_p.h	9 Jan 2008 20:06:57 -0000	1.51
+++ gw/smscconn_p.h	14 Mar 2008 09:17:29 -0000
@@ -168,6 +168,7 @@
     Octstr *name;		/* Descriptive name filled from connection info */
     Octstr *id;			/* Abstract name specified in configuration and
 				   used for logging and routing */
+    Octstr *dlr_group_id;  /* ID used for DLRs specified in configuration */
     List *allowed_smsc_id;
     List *denied_smsc_id;
     List *preferred_smsc_id;
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.46
diff -u -r1.46 smsc_at.c
--- gw/smsc/smsc_at.c	10 Mar 2008 09:37:42 -0000	1.46
+++ gw/smsc/smsc_at.c	14 Mar 2008 09:17:30 -0000
@@ -1913,7 +1913,7 @@
      * 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(privdata->conn->id, msg_id, receiver, type)) == NULL) {
+    if ((dlrmsg = dlr_find(privdata->conn->dlr_group_id, msg_id, 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;
@@ -2108,7 +2108,7 @@
                     else {
                         Octstr *dlrmsgid = octstr_format("%d", msg_id);
 
-                        dlr_add(privdata->conn->id, dlrmsgid, msg);
+                        dlr_add(privdata->conn, privdata->conn->dlr_group_id, dlrmsgid, msg);
 
                         O_DESTROY(dlrmsgid);
 
Index: gw/smsc/smsc_cgw.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cgw.c,v
retrieving revision 1.16
diff -u -r1.16 smsc_cgw.c
--- gw/smsc/smsc_cgw.c	9 Jan 2008 20:06:52 -0000	1.16
+++ gw/smsc/smsc_cgw.c	14 Mar 2008 09:17:30 -0000
@@ -1134,19 +1134,19 @@
 
             switch (stat) {
             case 0:     /* delivered */
-                dlrmsg = dlr_find(conn->id,
+                dlrmsg = dlr_find(conn->dlr_group_id,
                                             ts,     /* timestamp */
                                             msid,   /* destination */
                                   DLR_SUCCESS);
                 break;
             case 1:     /* buffered */
-                dlrmsg = dlr_find(conn->id,
+                dlrmsg = dlr_find(conn->dlr_group_id,
                                             ts,     /* timestamp */
                                             msid,   /* destination */
                                   DLR_BUFFERED);
                 break;
             case 2:     /* not delivered */
-                dlrmsg = dlr_find(conn->id,
+                dlrmsg = dlr_find(conn->dlr_group_id,
                                             ts,     /* timestamp */
                                             msid,   /* destination */
                                   DLR_FAIL);
@@ -1181,7 +1181,7 @@
             octstr_append_char(ts, '-');
             octstr_append_decimal(ts, trn);
 
-            dlr_add(conn->id, ts, msg);
+            dlr_add(conn, conn->dlr_group_id, ts, msg);
 
             octstr_destroy(ts);
             privdata->dlr[trn] = 1;
Index: gw/smsc/smsc_cimd2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cimd2.c,v
retrieving revision 1.33
diff -u -r1.33 smsc_cimd2.c
--- gw/smsc/smsc_cimd2.c	10 Mar 2008 09:37:42 -0000	1.33
+++ gw/smsc/smsc_cimd2.c	14 Mar 2008 09:17:31 -0000
@@ -1976,7 +1976,7 @@
 
     ret = cimd2_request(packet, conn, &ts);
     if((ret == 0) && (ts) && DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask) && !pdata->no_dlr) {
-        dlr_add(conn->name, ts, msg);
+        dlr_add(conn, conn->dlr_group_id, ts, msg);
     }
     octstr_destroy(ts);
     packet_destroy(packet);
@@ -2114,7 +2114,7 @@
         code = 0;
     }
     if(code)
-    	msg = dlr_find(conn->name, timestamp, destination, code);
+    	msg = dlr_find(conn->dlr_group_id, timestamp, destination, code);
     else
         msg = NULL;
 
Index: gw/smsc/smsc_emi.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_emi.c,v
retrieving revision 1.20
diff -u -r1.20 smsc_emi.c
--- gw/smsc/smsc_emi.c	9 Jan 2008 20:06:52 -0000	1.20
+++ gw/smsc/smsc_emi.c	14 Mar 2008 09:17:32 -0000
@@ -839,19 +839,19 @@
 	switch(st_code)
 	{
 	case 0: /* delivered */
-		msg = dlr_find((conn->id ? conn->id : privdata->name),
+		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
 			emimsg->fields[E50_SCTS], /* timestamp */
 			emimsg->fields[E50_OADC], /* destination */
 			DLR_SUCCESS);
 		break;
 	case 1: /* buffered */
-		msg = dlr_find((conn->id ? conn->id : privdata->name),
+		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
 			emimsg->fields[E50_SCTS], /* timestamp */
 			emimsg->fields[E50_OADC], /* destination */
 			DLR_BUFFERED);
 		break;
 	case 2: /* not delivered */
-		msg = dlr_find((conn->id ? conn->id : privdata->name),
+		msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
 			emimsg->fields[E50_SCTS], /* timestamp */
 			emimsg->fields[E50_OADC], /* destination */
 			DLR_FAIL);
@@ -1104,7 +1104,7 @@
 				    info(0,"EMI2[%s]: uhhh m is NULL, very bad",
 					 octstr_get_cstr(privdata->name));
 				} else if (DLR_IS_ENABLED_DEVICE(m->sms.dlr_mask)) {
-				    dlr_add((conn->id ? conn->id : privdata->name), ts, m);
+				    dlr_add(conn, (conn->dlr_group_id ? conn->dlr_group_id : privdata->name), ts, m);
 				}
 				octstr_destroy(ts);
 				octstr_destroy(adc);
Index: gw/smsc/smsc_fake.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_fake.c,v
retrieving revision 1.21
diff -u -r1.21 smsc_fake.c
--- gw/smsc/smsc_fake.c	9 Jan 2008 20:06:52 -0000	1.21
+++ gw/smsc/smsc_fake.c	14 Mar 2008 09:17:32 -0000
@@ -288,7 +288,7 @@
 
                     uuid_unparse(copy->sms.id, id);
                     tmp = octstr_create(id);
-                    dlrmsg = dlr_find(conn->id,
+                    dlrmsg = dlr_find(conn->dlr_group_id,
                                       tmp, /* smsc message id */
                                       copy->sms.receiver, /* destination */
                                       dlrstat);
@@ -446,7 +446,7 @@
         char id[UUID_STR_LEN + 1];
         uuid_unparse(sms->sms.id, id);
         tmp = octstr_format("%s", id);
-        dlr_add(conn->id, tmp, sms);
+        dlr_add(conn, conn->dlr_group_id, tmp, sms);
         octstr_destroy(tmp);
     }
     gwlist_produce(privdata->outgoing_queue, copy);
Index: gw/smsc/smsc_http.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_http.c,v
retrieving revision 1.55
diff -u -r1.55 smsc_http.c
--- gw/smsc/smsc_http.c	9 Jan 2008 20:06:52 -0000	1.55
+++ gw/smsc/smsc_http.c	14 Mar 2008 09:17:33 -0000
@@ -490,7 +490,7 @@
     
         /* add to our own DLR storage */               
         if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
-            dlr_add(conn->id, mid, msg);
+            dlr_add(conn, conn->dlr_group_id, mid, msg);
 
         octstr_destroy(mid);            
             
@@ -569,7 +569,7 @@
         /* we got a DLR, and we don't require additional values */
         Msg *dlrmsg;
         
-        dlrmsg = dlr_find(conn->id,
+        dlrmsg = dlr_find(conn->dlr_group_id,
             dlrmid, /* message id */
             to, /* destination */
             dlrmask);
@@ -748,7 +748,7 @@
 
             /* SMSC ACK.. now we have the message id. */
             if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
-                dlr_add(conn->id, msgid, msg);
+                dlr_add(conn, conn->dlr_group_id, msgid, msg);
 
             bb_smscconn_sent(conn, msg, NULL);
 
@@ -847,7 +847,7 @@
 	    dlrstat = 16; /* smsc reject */
 	    break;
 	}
-        dlrmsg = dlr_find(conn->id,
+        dlrmsg = dlr_find(conn->dlr_group_id,
             apimsgid, /* smsc message id */
             dest , /* destination */
             dlrstat);
@@ -1252,7 +1252,7 @@
 
             /* SMSC ACK.. now we have the message id. */
             if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
-                dlr_add(conn->id, mid, msg);
+                dlr_add(conn, conn->dlr_group_id, mid, msg);
 
             octstr_destroy(mid);
             bb_smscconn_sent(conn, msg, NULL);
@@ -1326,7 +1326,7 @@
         else
             dlrstat = DLR_FAIL;
 
-        dlrmsg = dlr_find(conn->id,
+        dlrmsg = dlr_find(conn->dlr_group_id,
             mid, /* smsc message id */
             dest , /* destination */
             dlrstat);
Index: gw/smsc/smsc_oisd.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_oisd.c,v
retrieving revision 1.15
diff -u -r1.15 smsc_oisd.c
--- gw/smsc/smsc_oisd.c	10 Mar 2008 09:37:42 -0000	1.15
+++ gw/smsc/smsc_oisd.c	14 Mar 2008 09:17:33 -0000
@@ -1171,7 +1171,7 @@
 
     ret = oisd_request(packet, conn, &ts);
     if((ret == 0) && (ts) && DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask) && !pdata->no_dlr) {
-        dlr_add(conn->name, ts, msg);
+        dlr_add(conn, conn->name, ts, msg);
     }
     octstr_destroy(ts);
     packet_destroy(packet);
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.102
diff -u -r1.102 smsc_smpp.c
--- gw/smsc/smsc_smpp.c	9 Jan 2008 20:06:52 -0000	1.102
+++ gw/smsc/smsc_smpp.c	14 Mar 2008 09:17:34 -0000
@@ -1273,7 +1273,7 @@
             }
         }
 
-        dlrmsg = dlr_find(smpp->conn->id,
+        dlrmsg = dlr_find(smpp->conn->dlr_group_id,
             tmp, /* smsc message id */
             destination_addr, /* destination */
             dlrstat);
@@ -1501,7 +1501,7 @@
 
                 /* SMSC ACK.. now we have the message id. */
                 if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
-                    dlr_add(smpp->conn->id, tmp, msg);
+                    dlr_add(smpp->conn, smpp->conn->dlr_group_id, tmp, msg);
 
                 octstr_destroy(tmp);
                 bb_smscconn_sent(smpp->conn, msg, NULL);
Index: gw/smsc/smsc_soap.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_soap.c,v
retrieving revision 1.20
diff -u -r1.20 smsc_soap.c
--- gw/smsc/smsc_soap.c	10 Mar 2008 09:37:42 -0000	1.20
+++ gw/smsc/smsc_soap.c	14 Mar 2008 09:17:35 -0000
@@ -1174,7 +1174,7 @@
         sprintf(tmpid,"%lld",msgID);
         debug("bb.soap.read_response",0,"SOAP[%s]: ACK - id: %lld", octstr_get_cstr(privdata->name), msgID);
 
-        dlr_add(conn->id, octstr_imm(tmpid), msg);
+        dlr_add(conn, conn->dlr_group_id, octstr_imm(tmpid), msg);
 
         /* send msg back to bearerbox for recycling */
         bb_smscconn_sent(conn, msg, NULL);
@@ -1616,7 +1616,7 @@
 
     /* fetch the DLR */
 
-    dlrmsg = dlr_find(conn->id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
+    dlrmsg = dlr_find(conn->dlr_group_id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
                       dlrtype);
 
     if (!dlrmsg) {
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.131
diff -u -r1.131 cfg.def
--- gwlib/cfg.def	9 Jan 2008 20:06:56 -0000	1.131
+++ gwlib/cfg.def	14 Mar 2008 09:17:35 -0000
@@ -289,6 +289,7 @@
     OCTSTR(shortcode)
 )
 
+    OCTSTR(dlr-group-id)
 
 MULTI_GROUP(smsc,
     OCTSTR(smsc)
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.