diff -crB mbuni-current-online/doc/userguide.shtml mbuni-current-patched/doc/userguide.shtml
*** mbuni-current-online/doc/userguide.shtml	2012-04-09 19:45:30.000000000 -0400
--- mbuni-current-patched/doc/userguide.shtml	2013-11-29 06:26:31.615517372 -0500
***************
*** 3257,3263 ****
      in a <tt>X-Mbuni-CarrierID</tt> header.
  </td>
   </tr>
! 1
  </table>
  
  
--- 3257,3278 ----
      in a <tt>X-Mbuni-CarrierID</tt> header.
  </td>
   </tr>
! 
!  <tr>
!   <td  valign=top >
!   <tt>retry-statuses
!   </tt>
!   &nbsp; &nbsp;</td>
! 
!   <td valign=top >
!   String
!   </td>
! 
!   <td  valign=top >
!   Optional. Semicolon separated list of HTTP and MM7 statuses that makes MBUNI to retry sending to MMSC. 
!   MM7 statuses are checked only when HTTP 200 is received from MMSC (HTTP 200 is always assumed as retry status).</td>
!  </tr>
! 
  </table>
  
  
diff -crB mbuni-current-online/mmlib/mms_cfg.def mbuni-current-patched/mmlib/mms_cfg.def
*** mbuni-current-online/mmlib/mms_cfg.def	2012-04-09 19:45:30.000000000 -0400
--- mbuni-current-patched/mmlib/mms_cfg.def	2013-11-29 06:27:55.230040230 -0500
***************
*** 198,203 ****
--- 198,204 ----
  	OCTSTR(max-recipients)
  
  	OCTSTR(strip-prefixes)
+ 	OCTSTR(retry-statuses)
  	OCTSTR(mm1-http-proxy)
  	OCTSTR(mm1-gprs-on-command)
  	OCTSTR(mm1-gprs-off-command)
diff -crB mbuni-current-online/mmsbox/bearerbox.c mbuni-current-patched/mmsbox/bearerbox.c
*** mbuni-current-online/mmsbox/bearerbox.c	2012-04-09 19:45:30.000000000 -0400
--- mbuni-current-patched/mmsbox/bearerbox.c	2013-11-29 06:46:00.311003926 -0500
***************
*** 1112,1117 ****
--- 1112,1141 ----
  }
  
  
+ /* This function check if there is custom retry statuses list setup for mmc, 
+  * if not it returns -1, 
+  * if it is set check if current status should be retried (returns 1) or not (returns 0)
+  */
+ 
+ int check_custom_retry_statuses(MmscGrp *mmc, int hstatus) {
+     int retry_sending = -1, i, n;
+     Octstr *res_str = octstr_format("%d", hstatus);
+     if (mmc && mmc->retry_statuses != NULL) {
+         retry_sending = 0;
+         for (i = 0, n = gwlist_len(mmc->retry_statuses); i<n; i++) {
+     	    Octstr *retry_status = gwlist_get(mmc->retry_statuses, i);
+     	    if (octstr_compare(res_str, retry_status) == 0) {
+     		retry_sending = 1;
+     		break;
+     	    }
+ 	}
+     }
+     octstr_destroy(res_str);
+     
+     return retry_sending;
+ }
+ 
+ 
  /* XXX Returns msgid in mmsc or NULL if error. Caller uses this for DLR issues. 
   * Caller must make sure throughput issues
   * are observed!
***************
*** 1137,1142 ****
--- 1161,1167 ----
       Octstr *s, *r, *status_details = NULL;
       char *xvasid = vasid ? vasid : (mmc->default_vasid ? octstr_get_cstr(mmc->default_vasid) : NULL);
       Octstr *to;
+      int retry_sending = -1;
  
       LINEARISE_STR_LIST(to,lto,", ");
  
***************
*** 1173,1178 ****
--- 1198,1207 ----
  				 mmc->mmsc_url, hstatus);
  	  if (hstatus < 0)
  	       MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
+ 	
+ 	  /* Now check if we should retry */
+ 	  retry_sending = check_custom_retry_statuses(mmc, hstatus);
+ 	
  	  MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
  	  goto done1;
       } else {
***************
*** 1227,1232 ****
--- 1256,1264 ----
  	  tstatus = MM7_SOAP_FORMAT_CORRUPT; 
       }
       
+      /* Now check if we should retry */
+      retry_sending = check_custom_retry_statuses(mmc, tstatus);
+      
       if (!MM7_SOAP_STATUS_OK(tstatus) && tstatus != MM7_SOAP_COMMAND_REJECTED) {
  	  char *tmp = (char *)mms_soap_status_to_cstr(tstatus);
  
***************
*** 1263,1269 ****
       if (ret)
  	  mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
  done1:
!      *retry = (ret == NULL && (!MM7_SOAP_CLIENT_ERROR(tstatus) || tstatus < 0));
       
       mm7_soap_destroy(mreq);
       mm7_soap_destroy(mresp);	  
--- 1295,1304 ----
       if (ret)
  	  mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
  done1:
!      //DEFAULT when retry_sending < 0
!      //otherwise we rely on retry_status list
!      if (retry_sending < 0) *retry = (ret == NULL && (!MM7_SOAP_CLIENT_ERROR(tstatus) || tstatus < 0));
!      else *retry = retry_sending;
       
       mm7_soap_destroy(mreq);
       mm7_soap_destroy(mresp);	  
***************
*** 1295,1300 ****
--- 1330,1336 ----
       MmsMsg *mresp = NULL;
       int mresp_type = -1, i;
       Octstr *to;
+      int retry_sending = -1;
  
       LINEARISE_STR_LIST(to,lto,", ");
  
***************
*** 1351,1356 ****
--- 1387,1396 ----
  				 mmc->mmsc_url, hstatus);
  	  if (hstatus < 0)
  	       MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
+ 	
+ 	  /* Now check if we should retry */
+ 	  retry_sending = check_custom_retry_statuses(mmc, hstatus);
+ 	
  	  MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
       } else {
  	  MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT);
***************
*** 1377,1383 ****
  	  else if (!ret) 
  	       ret = http_header_value(ph, octstr_imm("X-Nokia-MMSC-Message-Id"));
       }
!      *retry = (ret == NULL && (hstatus == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
       
       mmsbox_event_cb(mmc->id, 
  		     mm7_msgtype_to_soaptype(mresp_type,1), 0, xver, hstatus, 
--- 1417,1427 ----
  	  else if (!ret) 
  	       ret = http_header_value(ph, octstr_imm("X-Nokia-MMSC-Message-Id"));
       }
!      
!      //DEFAULT when retry_sending < 0
!      //otherwise we rely on retry_status list
!      if (retry_sending < 0) *retry = (ret == NULL && (hstatus == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
!      else *retry = retry_sending;
       
       mmsbox_event_cb(mmc->id, 
  		     mm7_msgtype_to_soaptype(mresp_type,1), 0, xver, hstatus, 
***************
*** 1423,1428 ****
--- 1467,1473 ----
       Octstr *transid = e ? octstr_create(e->xqfname) : NULL;
       int mm7type = mm7_msgtype_to_soaptype(mtype,1);
       Octstr *to;
+      int retry_sending = -1;
  
       LINEARISE_STR_LIST(to,lto," ");
  
***************
*** 1453,1458 ****
--- 1498,1507 ----
  				 mmc->mmsc_url, hstatus);
  	  if (hstatus < 0)
  	       MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
+ 	
+ 	  /* Now check if we should retry */
+ 	  retry_sending = check_custom_retry_statuses(mmc, hstatus);
+ 	
  	  MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
       } else {
  	  ret = rbody ? octstr_duplicate(rbody) : NULL;
***************
*** 1467,1473 ****
  		     0, e->attempts, e->from, 
  		     to, ret, transid, hdrs, NULL);     
  
!      *retry = (ret == NULL && (http_status_class(hstatus) == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
  
       if (ret)
  	  mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
--- 1516,1525 ----
  		     0, e->attempts, e->from, 
  		     to, ret, transid, hdrs, NULL);     
  
!      //DEFAULT when retry_sending < 0
!      //otherwise we rely on retry_status list
!      if (retry_sending < 0) *retry = (ret == NULL && (http_status_class(hstatus) == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
!      else *retry = retry_sending;
  
       if (ret)
  	  mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
diff -crB mbuni-current-online/mmsbox/mmsbox_cfg.c mbuni-current-patched/mmsbox/mmsbox_cfg.c
*** mbuni-current-online/mmsbox/mmsbox_cfg.c	2012-04-09 19:45:30.000000000 -0400
--- mbuni-current-patched/mmsbox/mmsbox_cfg.c	2013-11-29 06:32:11.693518712 -0500
***************
*** 635,640 ****
--- 635,648 ----
  	  octstr_destroy(s);
       } else 
  	  m->strip_prefixes = NULL;
+ 	  
+      if ((s = mms_cfg_get(cfg, x, octstr_imm("retry-statuses"))) != NULL) {
+ 	  m->retry_statuses = octstr_split(s, octstr_imm(";"));
+ 	  octstr_destroy(s);
+      } else 
+ 	  m->retry_statuses = NULL;
+ 
+ 
  
       if (mms_cfg_get_int(cfg,x, octstr_imm("maximum-request-size"), &m->max_pkt_size) < 0 || 
  	 m->max_pkt_size <= 0)
***************
*** 1299,1304 ****
--- 1307,1313 ----
       octstr_destroy(m->settings);
       mutex_destroy(m->mutex);
       gwlist_destroy(m->strip_prefixes, (void *)octstr_destroy);
+      gwlist_destroy(m->retry_statuses, (void *)octstr_destroy);
  
       octstr_destroy(m->mm1.proxy);
       octstr_destroy(m->mm1.gprs_on);
diff -crB mbuni-current-online/mmsbox/mmsbox_cfg.h mbuni-current-patched/mmsbox/mmsbox_cfg.h
*** mbuni-current-online/mmsbox/mmsbox_cfg.h	2012-04-09 19:45:30.000000000 -0400
--- mbuni-current-patched/mmsbox/mmsbox_cfg.h	2013-11-29 06:29:02.492852402 -0500
***************
*** 89,94 ****
--- 89,96 ----
  
       List *strip_prefixes; /* List of prefixes to be stripped before sending out*/
  
+      List *retry_statuses; /* List of HTTP/MM7 statuses we do retry on, MM7 statuses are checked only on HTTP 200 - they do not overlap*/
+ 
       struct MM1Info_t {               /* Stuff used only by the MM1 MMSC */
  	  Octstr *proxy;    /* Proxy within the operator network, form of host:port */
  	  Octstr *gprs_on;  /* Command to start GPRS link. Must not exit. */
