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)
