Index: gw/smsc/smsc_http.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_http.c,v
retrieving revision 1.54
diff -u -r1.54 smsc_http.c
--- gw/smsc/smsc_http.c	15 Apr 2007 23:12:12 -0000	1.54
+++ gw/smsc/smsc_http.c	6 Sep 2007 03:10:11 -0000
@@ -152,6 +152,43 @@
     regex_t *success_regex;   
     regex_t *permfail_regex;
     regex_t *tempfail_regex;
+    regex_t *dlr_success_regex;   
+    regex_t *dlr_permfail_regex;
+    regex_t *dlr_tempfail_regex;
+
+    /*
+     * Parameters to configure the MO portion of 'generic' interface
+     */
+
+    Octstr *mo_user;
+    Octstr *mo_pass;
+    Octstr *mo_from;
+    Octstr *mo_to;
+    Octstr *mo_text;
+    Octstr *mo_udh;
+    Octstr *mo_account;
+    Octstr *mo_binfo;
+    Octstr *mo_dlrurl;
+    Octstr *mo_dlrmid;
+    Octstr *mo_flash;
+    Octstr *mo_mclass;
+    Octstr *mo_mwi;
+    Octstr *mo_coding;
+    Octstr *mo_validity;
+    Octstr *mo_deferred;
+    Octstr *mo_dlrmask;
+    Octstr *mo_dlrstat;
+    Octstr *mo_ret_accepted;
+    Octstr *mo_ret_denied;
+    Octstr *mo_ret_unknown_dlr;
+    Octstr *mo_ret_missing_args;
+    Octstr *mo_ret_udh_mismatch;
+    Octstr *mo_ret_udh_long;
+    Octstr *mo_ret_auth_failed;
+    Octstr *mo_ret_dlr_accepted;
+    Octstr *mo_ret_dlr_denied;
+    Octstr *id_from_reply;
+    Octstr *err_from_reply;
 
     /* callback functions set by HTTP-SMSC type */
     void (*send_sms) (SMSCConn *conn, Msg *msg);
@@ -174,6 +211,12 @@
         gw_regex_destroy(conndata->permfail_regex);
     if (conndata->tempfail_regex)
         gw_regex_destroy(conndata->tempfail_regex);
+    if (conndata->dlr_success_regex)
+        gw_regex_destroy(conndata->dlr_success_regex);
+    if (conndata->dlr_permfail_regex)
+        gw_regex_destroy(conndata->dlr_permfail_regex);
+    if (conndata->dlr_tempfail_regex)
+        gw_regex_destroy(conndata->dlr_tempfail_regex);
     octstr_destroy(conndata->allow_ip);
     octstr_destroy(conndata->send_url);
     octstr_destroy(conndata->dlr_url);
@@ -181,7 +224,8 @@
     octstr_destroy(conndata->password);
     octstr_destroy(conndata->proxy);
     octstr_destroy(conndata->system_id);
-
+    if ( conndata->mo_ret_accepted)
+    	octstr_destroy(conndata->mo_ret_accepted);
     gw_free(conndata);
 }
 
@@ -507,73 +551,121 @@
 {
     ConnData *conndata = conn->data;
     Octstr *user, *pass, *from, *to, *text, *udh, *account, *binfo;
-    Octstr *dlrurl, *dlrmid;
+    Octstr *dlrurl, *dlrmid, *dlrstat;
     Octstr *tmp_string, *retmsg;
+    Octstr *mo_user, *mo_pass, *mo_from, *mo_to, *mo_text, *mo_udh, *mo_account, *mo_binfo, *mo_dlrurl;
+    Octstr *mo_dlrmid, *mo_flash, *mo_mclass, *mo_mwi, *mo_coding, *mo_validity, *mo_deferred, *mo_dlrmask, *mo_dlrstat;
     int	mclass, mwi, coding, validity, deferred, dlrmask;
     List *reply_headers;
     int ret;
-
     mclass = mwi = coding = validity = 
         deferred = dlrmask = SMS_PARAM_UNDEFINED;
 
-    user = http_cgi_variable(cgivars, "username");
-    pass = http_cgi_variable(cgivars, "password");
-    from = http_cgi_variable(cgivars, "from");
-    to = http_cgi_variable(cgivars, "to");
-    text = http_cgi_variable(cgivars, "text");
-    udh = http_cgi_variable(cgivars, "udh");
-    account = http_cgi_variable(cgivars, "account");
-    binfo = http_cgi_variable(cgivars, "binfo");
-    dlrurl = http_cgi_variable(cgivars, "dlr-url");
-    dlrmid = http_cgi_variable(cgivars, "dlr-mid");
-    tmp_string = http_cgi_variable(cgivars, "flash");
+    mo_user = ( conndata->mo_user != NULL ) ? octstr_duplicate(conndata->mo_user):octstr_create("username");
+    mo_pass = ( conndata->mo_pass != NULL ) ? octstr_duplicate(conndata->mo_pass):octstr_create("password");
+    mo_from = ( conndata->mo_from != NULL ) ? octstr_duplicate(conndata->mo_from):octstr_create("from");
+    mo_to = ( conndata->mo_to != NULL ) ? octstr_duplicate(conndata->mo_to):octstr_create("to");
+    mo_text = ( conndata->mo_text != NULL ) ? octstr_duplicate(conndata->mo_text):octstr_create("text");
+    mo_udh = ( conndata->mo_udh != NULL ) ? octstr_duplicate(conndata->mo_udh):octstr_create("udh");
+    mo_account = ( conndata->mo_account != NULL ) ? octstr_duplicate(conndata->mo_account):octstr_create("account");
+    mo_binfo = ( conndata->mo_binfo != NULL ) ? octstr_duplicate(conndata->mo_binfo):octstr_create("binfo");
+    mo_dlrurl = ( conndata->mo_dlrurl != NULL ) ? octstr_duplicate(conndata->mo_dlrurl):octstr_create("dlr-url");
+    mo_dlrmid = ( conndata->mo_dlrmid != NULL ) ? octstr_duplicate(conndata->mo_dlrmid):octstr_create("dlr-mid");
+    mo_flash = ( conndata->mo_flash != NULL ) ? octstr_duplicate(conndata->mo_flash):octstr_create("flash");
+    mo_mclass = ( conndata->mo_mclass != NULL ) ? octstr_duplicate(conndata->mo_mclass):octstr_create("mclass");
+    mo_mwi = ( conndata->mo_mwi != NULL ) ? octstr_duplicate(conndata->mo_mwi):octstr_create("mwi");
+    mo_coding = ( conndata->mo_coding != NULL ) ? octstr_duplicate(conndata->mo_coding):octstr_create("coding");
+    mo_validity = ( conndata->mo_validity != NULL ) ? octstr_duplicate(conndata->mo_validity):octstr_create("validity");
+    mo_deferred = ( conndata->mo_deferred != NULL ) ? octstr_duplicate(conndata->mo_deferred):octstr_create("deferred");
+    mo_dlrmask = ( conndata->mo_dlrmask != NULL ) ? octstr_duplicate(conndata->mo_dlrmask):octstr_create("dlr-mask");
+    mo_dlrstat = ( conndata->mo_dlrstat != NULL ) ? octstr_duplicate(conndata->mo_dlrstat):octstr_create("dlr-stat");
+
+    user = http_cgi_variable(cgivars, octstr_get_cstr(mo_user));
+    pass = http_cgi_variable(cgivars, octstr_get_cstr(mo_pass));
+    from = http_cgi_variable(cgivars, octstr_get_cstr(mo_from));
+    to = http_cgi_variable(cgivars, octstr_get_cstr(mo_to));
+    text = http_cgi_variable(cgivars, octstr_get_cstr(mo_text));
+    udh = http_cgi_variable(cgivars, octstr_get_cstr(mo_udh));
+    account = http_cgi_variable(cgivars, octstr_get_cstr(mo_account));
+    binfo = http_cgi_variable(cgivars, octstr_get_cstr(mo_binfo));
+    dlrurl = http_cgi_variable(cgivars, octstr_get_cstr(mo_dlrurl));
+    dlrmid = http_cgi_variable(cgivars, octstr_get_cstr(mo_dlrmid));
+    dlrstat = http_cgi_variable(cgivars, octstr_get_cstr(mo_dlrstat));
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_flash));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &mclass);
     }
-    tmp_string = http_cgi_variable(cgivars, "mclass");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_mclass));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &mclass);
     }
-    tmp_string = http_cgi_variable(cgivars, "mwi");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_mwi));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &mwi);
     }
-    tmp_string = http_cgi_variable(cgivars, "coding");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_coding));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &coding);
     }
-    tmp_string = http_cgi_variable(cgivars, "validity");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_validity));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &validity);
     }
-    tmp_string = http_cgi_variable(cgivars, "deferred");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_deferred));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &deferred);
     }
-    tmp_string = http_cgi_variable(cgivars, "dlr-mask");
+    tmp_string = http_cgi_variable(cgivars, octstr_get_cstr(mo_dlrmask));
     if (tmp_string) {
         sscanf(octstr_get_cstr(tmp_string),"%d", &dlrmask);
     }
     debug("smsc.http.kannel", 0, "HTTP[%s]: Received an HTTP request",
           octstr_get_cstr(conn->id));
-    
-    if (user == NULL || pass == NULL ||
-	    octstr_compare(user, conndata->username) != 0 ||
-	    octstr_compare(pass, conndata->password) != 0) {
 
-        error(0, "HTTP[%s]: Authorization failure",
-              octstr_get_cstr(conn->id));
-        retmsg = octstr_create("Authorization failed for sendsms");
+    /*
+     * Maybe there's a more "elegant" way to fix this...
+     */
+    if (conndata->username == NULL && conndata->password == NULL) {
+    	conndata->username = octstr_create("");
+    	conndata->password = octstr_create("");
+    }
+    if (user == NULL && pass == NULL) {
+    	user = octstr_create("");
+    	pass = octstr_create("");
+    }
+    if (/*user == NULL || pass == NULL ||*/ /* we don't need this anymore */
+    	octstr_compare(user, conndata->username) != 0 ||
+	    octstr_compare(pass, conndata->password) != 0) {
+	        error(0, "HTTP[%s]: Authorization failure",
+	              octstr_get_cstr(conn->id));
+        	retmsg = ( conndata->mo_ret_auth_failed != NULL ) ? octstr_duplicate(conndata->mo_ret_auth_failed):octstr_create("Authorization failed for sendsms");
     }
-    else if (dlrurl != NULL && dlrmask != 0 && dlrmid != NULL) {
+    else if (to != NULL && dlrmid != NULL && dlrstat != NULL) {
         /* we got a DLR, and we don't require additional values */
         Msg *dlrmsg;
+        int status = -1;
+        size_t n_match = 1;
+        regmatch_t p_match[10];
         
+        if ((conndata->dlr_success_regex != NULL) && 
+            (gw_regex_exec(conndata->dlr_success_regex, dlrstat, n_match, p_match, 0) == 0)) {
+        	status = DLR_SUCCESS;
+        }
+        else if ((conndata->dlr_tempfail_regex != NULL) && 
+                (gw_regex_exec(conndata->dlr_tempfail_regex, dlrstat, n_match, p_match, 0) == 0)) {
+            	status = DLR_BUFFERED;
+        }
+        else if ((conndata->dlr_permfail_regex != NULL) && 
+                (gw_regex_exec(conndata->dlr_permfail_regex, dlrstat, n_match, p_match, 0) == 0)) {
+            	status = DLR_FAIL;
+        }
+        else {
+        	status = DLR_SMSC_FAIL;
+        }
         dlrmsg = dlr_find(conn->id,
             dlrmid, /* message id */
             to, /* destination */
-            dlrmask);
-
+            status);
         if (dlrmsg != NULL) {
             dlrmsg->sms.sms_type = report_mo;
 
@@ -582,32 +674,32 @@
     
             ret = bb_smscconn_receive(conn, dlrmsg);
             if (ret == -1)
-                retmsg = octstr_create("Not accepted");
+            	retmsg = ( conndata->mo_ret_denied != NULL ) ? octstr_duplicate(conndata->mo_ret_dlr_denied):octstr_create("Not accepted");
             else
-                retmsg = octstr_create("Sent.");
+            	retmsg = ( conndata->mo_ret_accepted != NULL ) ? octstr_duplicate(conndata->mo_ret_dlr_accepted):octstr_create("Sent.");
         } else {
             error(0,"HTTP[%s]: Got DLR but could not find message or was not interested "
-                  "in it id<%s> dst<%s>, type<%d>",
+                  "in it id<%s> dst<%s>",
                   octstr_get_cstr(conn->id), octstr_get_cstr(dlrmid),
-                  octstr_get_cstr(to), dlrmask);
-            retmsg = octstr_create("Unknown DLR, not accepted");
-        }                    
+                  octstr_get_cstr(to));
+            retmsg = ( conndata->mo_ret_unknown_dlr != NULL ) ? octstr_duplicate(conndata->mo_ret_unknown_dlr):octstr_create("Unknown DLR, not accepted");
+        }
     }
     else if (from == NULL || to == NULL || text == NULL) {
 	
         error(0, "HTTP[%s]: Insufficient args",
               octstr_get_cstr(conn->id));
-        retmsg = octstr_create("Insufficient args, rejected");
+        retmsg = ( conndata->mo_ret_missing_args != NULL ) ? octstr_duplicate(conndata->mo_ret_missing_args):octstr_create("Insufficient args, rejected");
     }
     else if (udh != NULL && (octstr_len(udh) != octstr_get_char(udh, 0) + 1)) {
         error(0, "HTTP[%s]: UDH field misformed, rejected",
               octstr_get_cstr(conn->id));
-        retmsg = octstr_create("UDH field misformed, rejected");
+        retmsg = ( conndata->mo_ret_udh_mismatch != NULL ) ? octstr_duplicate(conndata->mo_ret_udh_mismatch):octstr_create("UDH field misformed, rejected");
     }
     else if (udh != NULL && octstr_len(udh) > MAX_SMS_OCTETS) {
         error(0, "HTTP[%s]: UDH field is too long, rejected",
               octstr_get_cstr(conn->id));
-        retmsg = octstr_create("UDH field is too long, rejected");
+        retmsg = ( conndata->mo_ret_udh_long != NULL ) ? octstr_duplicate(conndata->mo_ret_udh_long):octstr_create("UDH field is too long, rejected");
     }
     else {
         /* we got a normal MO SMS */
@@ -633,10 +725,11 @@
         msg->sms.account = octstr_duplicate(account);
         msg->sms.binfo = octstr_duplicate(binfo);
         ret = bb_smscconn_receive(conn, msg);
+
         if (ret == -1)
-            retmsg = octstr_create("Not accepted");
+        	retmsg = ( conndata->mo_ret_denied != NULL ) ? octstr_duplicate(conndata->mo_ret_denied):octstr_create("Not accepted");
         else
-            retmsg = octstr_create("Sent.");
+        	retmsg = ( conndata->mo_ret_accepted != NULL ) ? octstr_duplicate(conndata->mo_ret_accepted):octstr_create("Sent.");
     }
 
     reply_headers = gwlist_create();
@@ -644,7 +737,6 @@
     debug("smsc.http.kannel", 0, "HTTP[%s]: Sending reply",
           octstr_get_cstr(conn->id));
     http_send_reply(client, HTTP_ACCEPTED, reply_headers, retmsg);
-
     octstr_destroy(retmsg);
     http_destroy_headers(reply_headers);
 }
@@ -1439,7 +1531,7 @@
 
 
 /*----------------------------------------------------------------
- * (Semi-)generic HTTP interface
+ * Generic HTTP interface
  *
  * This 'generic' type will handle the 'send-url' directive in the 
  * group the same way the 'sms-service' for smsbox does, via 
@@ -1447,11 +1539,6 @@
  * regex value that match against the reponse body. The HTTP reponse
  * code is not obeyed.
  * 
- * It handles mainly MT messages, due to the fact that MO traffic
- * can't be abstracted in a universal way. Therefor we use the
- * Kannel sendsms interface layout as generic fallback. So if your
- * SMSC provider needs to send MO messages, he needs to implement
- * the Kannel sendsms HTTP interface variables.
  * 
  * Example config group:
  * 
@@ -1462,6 +1549,9 @@
  *  status-success-regex = "ok"
  *  status-permfail-regex = "failure"
  *  status-tempfail-regex = "retry later"
+ *  mo-from = "msg_from"
+ *  mo-to = "recipient"
+ *  mo-text = "message"
  * 
  * Note that neither 'smsc-username' nor 'smsc-password' is required,
  * since they are coded into the the 'send-url' value directly. 
@@ -1490,13 +1580,40 @@
     http_destroy_headers(headers);
 }
 
+static Dict *generic_parse_body(Octstr *body, Octstr *id_reply, Octstr *err_reply)
+{
+    Dict *param = NULL;
+    List *words = NULL;
+    long len;
+    Octstr *word, *value;
+
+    words = octstr_split_words(body);
+    if ((len = gwlist_len(words)) > 1) {
+	word = gwlist_extract_first(words);
+	if (octstr_compare(word, id_reply) == 0) {
+	    value = gwlist_extract_first(words);
+	    param = dict_create(4, NULL);
+	    dict_put(param, octstr_imm("ID"), value);
+	} else if (octstr_compare(word, err_reply) == 0) {
+	    value = gwlist_extract_first(words);
+	    param = dict_create(4, NULL);
+	    dict_put(param, octstr_imm("ERR"), value);
+	}
+        octstr_destroy(word);
+    }
+    gwlist_destroy(words, (void(*)(void *)) octstr_destroy);
+
+    return param;
+}
+
 static void generic_parse_reply(SMSCConn *conn, Msg *msg, int status,
                                 List *headers, Octstr *body)
 {
     ConnData *conndata = conn->data;
     size_t n_match = 1;
     regmatch_t p_match[10];
-    
+    Dict *param;
+    Octstr *msgid;    
     /* 
      * Our generic type checks only content on the HTTP reponse body.
      * We use the pre-compiled regex to match against the states.
@@ -1504,7 +1621,29 @@
      */
     if ((conndata->success_regex != NULL) && 
         (gw_regex_exec(conndata->success_regex, body, n_match, p_match, 0) == 0)) {
-        bb_smscconn_sent(conn, msg, NULL);
+    	
+        if ((conndata->id_from_reply != NULL) && (conndata->err_from_reply != NULL)) {
+
+        	debug("smsc.http.generic", 0, "HTTP[%s]: Parsing message ID from body", octstr_get_cstr(conn->id) );
+	        if ((param = generic_parse_body(body, conndata->id_from_reply, conndata->err_from_reply)) != NULL &&
+	            (msgid = dict_get(param, octstr_imm("ID"))) != NULL &&
+	            msgid != NULL) {
+	
+	            /* SMSC ACK.. now we have the message id. */
+	            if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))        	
+	                dlr_add(conn->id, msgid, msg);
+	
+	            bb_smscconn_sent(conn, msg, NULL);
+	
+	        } 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));
+	        }
+	        dict_destroy(param);
+        } else {
+        	bb_smscconn_sent(conn, msg, NULL);
+        }
     } 
     else if ((conndata->permfail_regex != NULL) &&        
         (gw_regex_exec(conndata->permfail_regex, body, n_match, p_match, 0) == 0)) {
@@ -1528,7 +1667,6 @@
     }
 }
 
-
 /*-----------------------------------------------------------------
  * functions to implement various smscconn operations
  */
@@ -1600,6 +1738,8 @@
     conndata->http_ref = NULL;
     conndata->success_regex = 
         conndata->permfail_regex = conndata->tempfail_regex = NULL;
+    conndata->dlr_success_regex = 
+        conndata->dlr_permfail_regex = conndata->dlr_tempfail_regex = NULL;
 
     conndata->allow_ip = cfg_get(cfg, octstr_imm("connect-allow-ip"));
     conndata->send_url = cfg_get(cfg, octstr_imm("send-url"));
@@ -1607,6 +1747,33 @@
     conndata->username = cfg_get(cfg, octstr_imm("smsc-username"));
     conndata->password = cfg_get(cfg, octstr_imm("smsc-password"));
     conndata->system_id = cfg_get(cfg, octstr_imm("system-id"));
+    conndata->mo_from = cfg_get(cfg, octstr_imm("mo-from"));
+    conndata->mo_to = cfg_get(cfg, octstr_imm("mo-to"));
+    conndata->mo_text = cfg_get(cfg, octstr_imm("mo-text"));;
+    conndata->mo_udh = cfg_get(cfg, octstr_imm("mo-udh"));
+    conndata->mo_account = cfg_get(cfg, octstr_imm("mo-account"));
+    conndata->mo_binfo = cfg_get(cfg, octstr_imm("mo-binfo"));
+    conndata->mo_dlrurl = cfg_get(cfg, octstr_imm("mo-dlr-url"));
+    conndata->mo_dlrmid = cfg_get(cfg, octstr_imm("mo-dlr-mid"));
+    conndata->mo_flash = cfg_get(cfg, octstr_imm("mo-flash"));
+    conndata->mo_mclass = cfg_get(cfg, octstr_imm("mo-mclass"));
+    conndata->mo_mwi = cfg_get(cfg, octstr_imm("mo-mwi"));
+    conndata->mo_coding = cfg_get(cfg, octstr_imm("mo-coding"));
+    conndata->mo_validity = cfg_get(cfg, octstr_imm("mo-validity"));
+    conndata->mo_deferred = cfg_get(cfg, octstr_imm("mo-dlr-url"));
+    conndata->mo_dlrmask = cfg_get(cfg, octstr_imm("mo-dlr-mask"));
+    conndata->mo_dlrstat = cfg_get(cfg, octstr_imm("mo-dlr-stat"));
+    conndata->mo_ret_accepted = cfg_get(cfg, octstr_imm("mo-ret-accepted"));
+    conndata->mo_ret_denied = cfg_get(cfg, octstr_imm("mo-ret-denied"));
+    conndata->mo_ret_unknown_dlr = cfg_get(cfg, octstr_imm("mo-ret-unknown-dlr"));
+    conndata->mo_ret_missing_args = cfg_get(cfg, octstr_imm("mo-ret-missing-args"));
+    conndata->mo_ret_udh_mismatch = cfg_get(cfg, octstr_imm("mo-ret-udh-mismatch"));
+    conndata->mo_ret_udh_long = cfg_get(cfg, octstr_imm("mo-ret-udh-long"));
+    conndata->mo_ret_auth_failed = cfg_get(cfg, octstr_imm("mo-ret-auth-failed"));
+    conndata->mo_ret_dlr_accepted = cfg_get(cfg, octstr_imm("mo-ret-dlr-accepted"));
+    conndata->mo_ret_dlr_denied = cfg_get(cfg, octstr_imm("mo-ret-dlr-denied"));
+    conndata->id_from_reply = cfg_get(cfg, octstr_imm("id-from-reply"));
+    conndata->err_from_reply = cfg_get(cfg, octstr_imm("err-from-reply"));
     cfg_get_bool(&conndata->no_sender, cfg, octstr_imm("no-sender"));
     cfg_get_bool(&conndata->no_coding, cfg, octstr_imm("no-coding"));
     cfg_get_bool(&conndata->no_sep, cfg, octstr_imm("no-sep"));
@@ -1669,6 +1836,7 @@
                   octstr_get_cstr(conn->id));
             goto error;
         }
+
         conndata->receive_sms = kannel_receive_sms; /* emulate sendsms interface */
         conndata->send_sms = generic_send_sms;
         conndata->parse_reply = generic_parse_reply;
@@ -1689,6 +1857,21 @@
                 panic(0, "Could not compile regex pattern '%s'", octstr_get_cstr(os));
             octstr_destroy(os);
         }
+        if ((os = cfg_get(cfg, octstr_imm("dlr-success-regex"))) != NULL) {
+            if ((conndata->dlr_success_regex = gw_regex_comp(os, REG_EXTENDED)) == NULL)
+                panic(0, "Could not compile regex pattern '%s'", octstr_get_cstr(os));
+            octstr_destroy(os);
+        }
+        if ((os = cfg_get(cfg, octstr_imm("dlr-permfail-regex"))) != NULL) {
+            if ((conndata->dlr_permfail_regex = gw_regex_comp(os, REG_EXTENDED)) == NULL)
+                panic(0, "Could not compile regex pattern '%s'", octstr_get_cstr(os));
+            octstr_destroy(os);
+        }
+        if ((os = cfg_get(cfg, octstr_imm("dlr-tempfail-regex"))) != NULL) {
+            if ((conndata->dlr_tempfail_regex = gw_regex_comp(os, REG_EXTENDED)) == NULL)
+                panic(0, "Could not compile regex pattern '%s'", octstr_get_cstr(os));
+            octstr_destroy(os);
+        }
     }
     /*
      * ADD NEW HTTP SMSC TYPES HERE
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.129
diff -u -r1.129 cfg.def
--- gwlib/cfg.def	1 Jun 2007 11:25:42 -0000	1.129
+++ gwlib/cfg.def	6 Sep 2007 03:10:12 -0000
@@ -380,6 +380,36 @@
     OCTSTR(status-success-regex)
     OCTSTR(status-permfail-regex)
     OCTSTR(status-tempfail-regex)
+    OCTSTR(dlr-success-regex)
+    OCTSTR(dlr-permfail-regex)
+    OCTSTR(dlr-tempfail-regex)
+    OCTSTR(mo-from)
+    OCTSTR(mo-to)
+    OCTSTR(mo-text)
+    OCTSTR(mo-udh)
+    OCTSTR(mo-account)
+    OCTSTR(mo-binfo)
+    OCTSTR(mo-dlr-url)
+    OCTSTR(mo-dlr-mid)
+    OCTSTR(mo-flash)
+    OCTSTR(mo-mclass)
+    OCTSTR(mo-mwi)
+    OCTSTR(mo-coding)
+    OCTSTR(mo-validity)
+    OCTSTR(mo-deferred)
+    OCTSTR(mo-dlr-mask)
+    OCTSTR(mo-dlr-stat)
+    OCTSTR(mo-ret-accepted)
+    OCTSTR(mo-ret-denied)
+    OCTSTR(mo-ret-unknown-dlr)
+    OCTSTR(mo-ret-missing-args)
+    OCTSTR(mo-ret-udh-mismatch)
+    OCTSTR(mo-ret-udh-long)
+    OCTSTR(mo-ret-auth-failed)
+    OCTSTR(mo-ret-dlr-accepted)
+    OCTSTR(mo-ret-dlr-denied)
+    OCTSTR(id-from-reply)
+    OCTSTR(err-from-reply)
 )
 
 
