Index: gw/bb_smscconn.c
===================================================================
--- gw/bb_smscconn.c	(revision 4838)
+++ gw/bb_smscconn.c	(working copy)
@@ -251,7 +251,7 @@
             bb_smscconn_sent(conn, msg, NULL);
         else {
             debug("bb.sms.splits", 0, "Parts of concatenated message failed.");
-            bb_smscconn_send_failed(conn, msg, split->status, NULL);
+            bb_smscconn_send_failed(conn, msg, split->status, NULL, NULL);
         }
         gw_free(split);
     }
@@ -301,7 +301,7 @@
 }
 
 
-void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply)
+void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply, Octstr *meta_data)
 {
     if (sms->sms.split_parts != NULL) {
         handle_split(conn, sms, reason);
@@ -324,7 +324,7 @@
            if (sms_resend_retry >= 0 && sms->sms.resend_try >= sms_resend_retry) {
                warning(0, "Maximum retries for message exceeded, discarding it!");
                bb_smscconn_send_failed(NULL, sms, SMSCCONN_FAILED_DISCARDED, 
-                                       octstr_create("Retries Exceeded"));
+                                       octstr_create("Retries Exceeded"), NULL);
                break;
            }
            sms->sms.resend_try = (sms->sms.resend_try > 0 ? sms->sms.resend_try + 1 : 1);
@@ -352,13 +352,16 @@
 	    DLR_IS_FAIL(sms->sms.dlr_mask)) {
             Msg *dlrmsg;
 
-	    if (reply == NULL)
-	        reply = octstr_create("");
+            if (reply == NULL)
+                reply = octstr_create("");
+            if (meta_data == NULL)
+                meta_data = octstr_create("");
 
-	    octstr_insert_data(reply, 0, "NACK/", 5);
+            octstr_insert_data(reply, 0, "NACK/", 5);
             dlrmsg = create_dlr_from_msg((conn ? (conn->id?conn->id:conn->name) : NULL), sms,
 	                                 reply, DLR_SMSC_FAIL);
             if (dlrmsg != NULL) {
+                dlrmsg->sms.meta_data = octstr_duplicate(meta_data);
                 bb_smscconn_receive(conn, dlrmsg);
             }
         }
@@ -1299,7 +1302,7 @@
         }
         warning(0, "Cannot find SMSCConn for message to <%s>, rejected.",
                     octstr_get_cstr(msg->sms.receiver));
-        bb_smscconn_send_failed(NULL, msg_duplicate(msg), SMSCCONN_FAILED_DISCARDED, octstr_create("no SMSC"));
+        bb_smscconn_send_failed(NULL, msg_duplicate(msg), SMSCCONN_FAILED_DISCARDED, octstr_create("no SMSC"), NULL);
         return SMSCCONN_FAILED_DISCARDED;
     }
 
Index: gw/bb_smscconn_cb.h
===================================================================
--- gw/bb_smscconn_cb.h	(revision 4838)
+++ gw/bb_smscconn_cb.h	(working copy)
@@ -102,7 +102,7 @@
  * msgdata to generated dlr message.Reason is set accordingly.
  * callback handles 'sms' and 'reply' and MAY NOT be used by caller again
  */
-void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply);
+void bb_smscconn_send_failed(SMSCConn *conn, Msg *sms, int reason, Octstr *reply, Octstr *meta_data);
 
 enum {
     SMSCCONN_SUCCESS = 0,
Index: gw/smsc/smsc_at.c
===================================================================
--- gw/smsc/smsc_at.c	(revision 4838)
+++ gw/smsc/smsc_at.c	(working copy)
@@ -1463,7 +1463,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while ((msg = gw_prioqueue_remove(privdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
         }
     }
     gwthread_wakeup(privdata->device_thread);
@@ -2305,7 +2305,7 @@
 
             if (ret != 0) {
                 bb_smscconn_send_failed(privdata->conn, msg,
-                        SMSCCONN_FAILED_TEMPORARILY, octstr_create("ERROR"));
+                        SMSCCONN_FAILED_TEMPORARILY, octstr_create("ERROR"), NULL);
             } else {
                 /* store DLR message if needed for SMSC generated delivery reports */
                 if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask)) {
@@ -2331,7 +2331,7 @@
                   octstr_get_cstr(msg->sms.sender), octstr_get_cstr(msg->sms.receiver),
                   octstr_get_cstr(msg->sms.msgdata), octstr_get_cstr(msg->sms.udhdata));
             bb_smscconn_send_failed(privdata->conn, msg,
-                                    SMSCCONN_FAILED_TEMPORARILY, octstr_create("ERROR"));
+                                    SMSCCONN_FAILED_TEMPORARILY, octstr_create("ERROR"), NULL);
         }
         O_DESTROY(pdu);
     }
Index: gw/smsc/smsc_cgw.c
===================================================================
--- gw/smsc/smsc_cgw.c	(revision 4838)
+++ gw/smsc/smsc_cgw.c	(working copy)
@@ -575,7 +575,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
         }
     }
 
@@ -659,7 +659,7 @@
     conn_destroy(server);
 
     while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL)
-        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
     mutex_lock(conn->flow_mutex);
 
     conn->status = SMSCCONN_DEAD;
@@ -699,7 +699,7 @@
                 mutex_unlock(conn->flow_mutex);
             }
             while ((msg = gwlist_extract_first(privdata->outgoing_queue)))
-                bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+                bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
             info(0, "smsc_cgw: waiting for %d minutes before trying to connect again", wait);
             gwthread_sleep(wait * 60);
             wait = wait > 5 ? 10 : wait * 2;
@@ -1216,7 +1216,7 @@
         privdata->unacked--;
 
         bb_smscconn_send_failed(conn, privdata->sendmsg[trn],
-                            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+                            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
 
         break;
 
Index: gw/smsc/smsc_cimd2.c
===================================================================
--- gw/smsc/smsc_cimd2.c	(revision 4838)
+++ gw/smsc/smsc_cimd2.c	(working copy)
@@ -1970,7 +1970,7 @@
          * But nevermind that.
          */
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"));
+	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"), NULL);
         return -1;
     }
 
@@ -1983,11 +1983,11 @@
     
     if (ret == -1) {
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
     }
     else if (ret == -2) {
         cimd2_close_socket(pdata);
-        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
         mutex_lock(conn->flow_mutex);
         conn->status = SMSCCONN_DISCONNECTED;
         mutex_unlock(conn->flow_mutex);
@@ -2264,7 +2264,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while ((msg = gwlist_extract_first(pdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
         }
     }
 
Index: gw/smsc/smsc_emi.c
===================================================================
--- gw/smsc/smsc_emi.c	(revision 4838)
+++ gw/smsc/smsc_emi.c	(working copy)
@@ -286,7 +286,7 @@
 
     while ((msg = gw_prioqueue_remove(privdata->outgoing_queue))) {
         bb_smscconn_send_failed(conn, msg,
-                         SMSCCONN_FAILED_TEMPORARILY, NULL);
+                         SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
     }
 
     /* if there is no alternative host, sleep and try to re-connect */
@@ -1147,7 +1147,7 @@
 			else { */
 			    bb_smscconn_send_failed(conn,
 					PRIVDATA(conn)->slots[emimsg->trn].sendmsg,
-					SMSCCONN_FAILED_REJECTED, reply);
+					SMSCCONN_FAILED_REJECTED, reply, NULL);
 			/* } */
 		    }
 		} else if (emimsg->ot == 31) {
@@ -1380,7 +1380,7 @@
     }
 
     while((msg = gw_prioqueue_remove(privdata->outgoing_queue)) != NULL)
-	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
     if (privdata->rport > 0)
 	gwthread_join(privdata->receiver_thread);
     mutex_lock(conn->flow_mutex);
@@ -1573,7 +1573,7 @@
     if (finish_sending == 0) {
 	Msg *msg;
 	while((msg = gw_prioqueue_remove(privdata->outgoing_queue)) != NULL) {
-	    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+	    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
 	}
     }
 
Index: gw/smsc/smsc_fake.c
===================================================================
--- gw/smsc/smsc_fake.c	(revision 4838)
+++ gw/smsc/smsc_fake.c	(working copy)
@@ -304,7 +304,7 @@
 
             } else {
                 bb_smscconn_send_failed(conn, msg,
-		            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+		            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
                 goto error;
             }
 
@@ -404,7 +404,7 @@
         conn->status = SMSCCONN_RECONNECTING;
         mutex_unlock(conn->flow_mutex);
         while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
         }
     }
     if (close(privdata->listening_socket) == -1)
@@ -414,7 +414,7 @@
     conn->status = SMSCCONN_DEAD;
 
     while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL) {
-        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
     }
     gwlist_destroy(privdata->outgoing_queue, NULL);
     octstr_destroy(privdata->allow_ip);
@@ -478,7 +478,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
         }
     }
 
Index: gw/smsc/smsc_http.c
===================================================================
--- gw/smsc/smsc_http.c	(revision 4838)
+++ gw/smsc/smsc_http.c	(working copy)
@@ -568,7 +568,7 @@
         bb_smscconn_sent(conn, msg, NULL);
     } else {
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
+	            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body), NULL);
     }
 }
 
@@ -836,7 +836,7 @@
         } else {
             error(0, "HTTP[%s]: Message was malformed or error was returned. SMSC response `%s'.",
                   octstr_get_cstr(conn->id), octstr_get_cstr(body));
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body), NULL);
         }
         dict_destroy(param);
 
@@ -844,7 +844,7 @@
         error(0, "HTTP[%s]: Message was rejected. SMSC reponse `%s'.",
               octstr_get_cstr(conn->id), octstr_get_cstr(body));
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_REJECTED, octstr_duplicate(body));
+	            SMSCCONN_FAILED_REJECTED, octstr_duplicate(body), NULL);
     }
 }
 
@@ -1129,7 +1129,7 @@
             error(0, "HTTP[%s]: Message was malformed. SMSC response `%s'.",
                   octstr_get_cstr(conn->id), octstr_get_cstr(body));
             bb_smscconn_send_failed(conn, msg,
-	                SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
+	                SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body), NULL);
         }
         dict_destroy(param);
 
@@ -1137,7 +1137,7 @@
         error(0, "HTTP[%s]: Message was rejected. SMSC reponse `%s'.",
               octstr_get_cstr(conn->id), octstr_get_cstr(body));
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_REJECTED, octstr_duplicate(body));
+	            SMSCCONN_FAILED_REJECTED, octstr_duplicate(body), NULL);
     }
 }
 
@@ -1344,14 +1344,14 @@
                   "description `%s'.", octstr_get_cstr(conn->id),
                   octstr_get_cstr(code), octstr_get_cstr(desc));
             bb_smscconn_send_failed(conn, msg,
-	                SMSCCONN_FAILED_MALFORMED, octstr_duplicate(desc));
+	                SMSCCONN_FAILED_MALFORMED, octstr_duplicate(desc), NULL);
         }
     } else {
         error(0, "HTTP[%s]: Message was rejected. SMSC reponse was:",
               octstr_get_cstr(conn->id));
         octstr_dump(body, 0);
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
     }
 }
 
@@ -1505,7 +1505,7 @@
         bb_smscconn_sent(conn, msg, NULL);
     } else {
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
+	            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body), NULL);
     }
 }
 
@@ -1856,21 +1856,21 @@
         (gw_regex_exec(conndata->permfail_regex, body, 0, NULL, 0) == 0)) {
         error(0, "HTTP[%s]: Message not accepted.", octstr_get_cstr(conn->id));
         bb_smscconn_send_failed(conn, msg,
-            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body));
+            SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body), NULL);
     }
     else if ((conndata->tempfail_regex != NULL) &&        
         (gw_regex_exec(conndata->tempfail_regex, body, 0, NULL, 0) == 0)) {
         warning(0, "HTTP[%s]: Message temporary not accepted, will retry.", 
                 octstr_get_cstr(conn->id));
         bb_smscconn_send_failed(conn, msg,
-            SMSCCONN_FAILED_TEMPORARILY, octstr_duplicate(body));
+            SMSCCONN_FAILED_TEMPORARILY, octstr_duplicate(body), NULL);
     }
     else {
         error(0, "HTTP[%s]: Message was rejected. SMSC reponse was:",
               octstr_get_cstr(conn->id));
         octstr_dump(body, 0);
         bb_smscconn_send_failed(conn, msg,
-            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
     }
 }
 
Index: gw/smsc/smsc_oisd.c
===================================================================
--- gw/smsc/smsc_oisd.c	(revision 4838)
+++ gw/smsc/smsc_oisd.c	(working copy)
@@ -1163,7 +1163,7 @@
          * But nevermind that.
          */
         bb_smscconn_send_failed(conn, msg,
-                SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"));
+                SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"), NULL);
         return -1;
     }
 
@@ -1176,11 +1176,11 @@
 
     if (ret == -1) {
         bb_smscconn_send_failed(conn, msg,
-                SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+                SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
     }
     else if (ret == -2) {
         oisd_close_socket(pdata);
-        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
         mutex_lock(conn->flow_mutex);
         conn->status = SMSCCONN_DISCONNECTED;
         mutex_unlock(conn->flow_mutex);
@@ -1441,7 +1441,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while ((msg = gwlist_extract_first(pdata->outgoing_queue)) != NULL) {
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
         }
     }
 
Index: gw/smsc/smsc_smasi.c
===================================================================
--- gw/smsc/smsc_smasi.c	(revision 4838)
+++ gw/smsc/smsc_smasi.c	(working copy)
@@ -784,7 +784,7 @@
             } else {
                 reason = SMSCCONN_FAILED_REJECTED;
                 bb_smscconn_send_failed(smasi->conn, msg, reason,
-		            octstr_create("REJECTED"));
+		            octstr_create("REJECTED"), NULL);
                 --(*pending_submits);
             }
             break;
Index: gw/smsc/smsc_smpp.c
===================================================================
--- gw/smsc/smsc_smpp.c	(revision 4838)
+++ gw/smsc/smsc_smpp.c	(working copy)
@@ -1067,7 +1067,7 @@
         /* Send PDU, record it as waiting for ack from SMS center */
         pdu = msg_to_pdu(smpp, msg);
         if (pdu == NULL) {
-            bb_smscconn_send_failed(smpp->conn, msg, SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED SMS"));
+            bb_smscconn_send_failed(smpp->conn, msg, SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED SMS"), NULL);
             continue;
         }
         /* check for write errors */
@@ -1082,7 +1082,7 @@
         }
         else { /* write error occurs */
             smpp_pdu_destroy(pdu);
-            bb_smscconn_send_failed(smpp->conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+            bb_smscconn_send_failed(smpp->conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
             return -1;
         }
     }
@@ -1612,7 +1612,7 @@
                     smpp->throttling_err_time = 0;
 
                 bb_smscconn_send_failed(smpp->conn, msg, reason, octstr_format("0x%08lx/%s", pdu->u.submit_sm_resp.command_status,
-                                        smpp_error_to_string(pdu->u.submit_sm_resp.command_status)));
+                                        smpp_error_to_string(pdu->u.submit_sm_resp.command_status)), NULL);
                 --(*pending_submits);
             } else {
                 Octstr *tmp;
@@ -1762,7 +1762,7 @@
 
                 reason = smpp_status_to_smscconn_failure_reason(cmd_stat);
                 bb_smscconn_send_failed(smpp->conn, msg, reason,
-                                        octstr_format("0x%08lx/%s", cmd_stat, smpp_error_to_string(cmd_stat)));
+                                        octstr_format("0x%08lx/%s", cmd_stat, smpp_error_to_string(cmd_stat)), NULL);
                 --(*pending_submits);
             }
             break;
@@ -1845,7 +1845,7 @@
                                    (long)difftime(now, smpp_msg->sent_time) ,
                                    octstr_get_cstr(key),
                                    octstr_get_cstr(smpp_msg->msg->sms.receiver));
-                        bb_smscconn_send_failed(smpp->conn, smpp_msg->msg, SMSCCONN_FAILED_TEMPORARILY,NULL);
+                        bb_smscconn_send_failed(smpp->conn, smpp_msg->msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
                         smpp_msg_destroy(smpp_msg, 0);
                         (*pending_submits)--;
                     }
@@ -2052,13 +2052,13 @@
             long reason = (smpp->quitting?SMSCCONN_FAILED_SHUTDOWN:SMSCCONN_FAILED_TEMPORARILY);
 
             while((msg = gw_prioqueue_remove(smpp->msgs_to_send)) != NULL)
-                bb_smscconn_send_failed(smpp->conn, msg, reason, NULL);
+                bb_smscconn_send_failed(smpp->conn, msg, reason, NULL, NULL);
 
             noresp = dict_keys(smpp->sent_msgs);
             while((key = gwlist_extract_first(noresp)) != NULL) {
                 smpp_msg = dict_remove(smpp->sent_msgs, key);
                 if (smpp_msg != NULL) {
-                    bb_smscconn_send_failed(smpp->conn, smpp_msg->msg, reason, NULL);
+                    bb_smscconn_send_failed(smpp->conn, smpp_msg->msg, reason, NULL, NULL);
                     smpp_msg_destroy(smpp_msg, 0);
                 }
                 octstr_destroy(key);
Index: gw/smsc/smsc_soap.c
===================================================================
--- gw/smsc/smsc_soap.c	(revision 4838)
+++ gw/smsc/smsc_soap.c	(working copy)
@@ -613,7 +613,7 @@
     if (finish_sending == 0) {
         Msg *msg;
         while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL)
-            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+            bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
     }
 
     thread = privdata->listener_thread;
@@ -790,7 +790,7 @@
           octstr_get_cstr(privdata->name));
 
     while ((msg = gwlist_extract_first(privdata->outgoing_queue)) != NULL)
-        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+        bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
 
     /* lock module public state data */
     mutex_lock(conn->flow_mutex);
@@ -983,7 +983,7 @@
             debug("bb.soap.client",0,"SOAP[%s]: client - failed to format message for sending", 
                   octstr_get_cstr(privdata->name));
             bb_smscconn_send_failed(conn, msg,
-	                SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"));
+	                SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"), NULL);
             continue;
         }
 
@@ -1148,7 +1148,7 @@
         debug("bb.soap.read_response",0,"SOAP[%s]: HTTP connection failed - blame the server (requeing msg)",
               octstr_get_cstr(privdata->name));
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"));
+	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"), NULL);
         /*    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY); */
         /*      gwlist_append(privdata->outgoing_queue, msg); */
         return;
@@ -1184,7 +1184,7 @@
 
         /* send msg back to bearerbox for recycling */
         bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"));
+	            SMSCCONN_FAILED_MALFORMED, octstr_create("MALFORMED"), NULL);
     }
 
     http_destroy_headers(responseHeaders);
Index: gw/smsc/smsc_wrapper.c
===================================================================
--- gw/smsc/smsc_wrapper.c	(revision 4838)
+++ gw/smsc/smsc_wrapper.c	(working copy)
@@ -119,7 +119,7 @@
 	  octstr_get_cstr(conn->name));
 
     while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {
-	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);
+	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL, NULL);
     }
     conn->status = SMSCCONN_RECONNECTING;
     
@@ -243,7 +243,7 @@
     ret = smscenter_submit_msg(wrap->smsc, msg);
     if (ret == -1) {
 	bb_smscconn_send_failed(conn, msg,
-	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));
+	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"), NULL);
 
 	if (reconnect(conn) == -1)
 	    smscconn_shutdown(conn, 0);
@@ -322,7 +322,7 @@
     conn->status = SMSCCONN_DEAD;
 
     while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {
-	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
     }
     smscwrapper_destroy(wrap);
     conn->data = NULL;
@@ -356,7 +356,7 @@
     if (finish_sending == 0) {
 	Msg *msg; 
 	while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {
-	    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);
+	    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL, NULL);
 	}
     }
     gwlist_remove_producer(wrap->outgoing_queue);
