Hello folks,

at opensmppbox i found that it not support validity periode handling when from pdu makes msg for bb.

attached patch solve that. i am not well C++ coder, so please make an review, if there are no left some memory leaks. or may be there is an nicer way to make it.

But it's tested and working ;)

PS: acording this, deffered parameter have same problem, is not passing trought. and handling of DLR need some improvement too, coz from smsc i will get EXPIRED msg, but opensmpp client is sending UNDELIV with err:000. I will try to prepare next patches to handle it, but if someone is working on it, it would be twice made ;)

Slavoj.

--- opensmppbox.c.old   2010-10-06 19:05:13.000000000 +0200
+++ opensmppbox.c       2010-10-27 13:56:46.000000000 +0200
@@ -992,7 +992,12 @@
 static Msg *pdu_to_msg(Boxc *box, SMPP_PDU *pdu, long *reason)
 {
     Msg *msg;
-    int ton, npi;
+    int ton, npi, validity;
+    time_t start,end;
+    struct tm tm_val;
+    struct tm tm_now;
+    struct tm tm_now2;
+    
 
     gw_assert(pdu->type == submit_sm);
 
@@ -1165,6 +1170,50 @@
     }
 
     msg->sms.time = time(NULL);
+    
+    /* set validity period if needed */
+    if (pdu->u.submit_sm.validity_period != NULL) {
+
+       tm_now2 = gw_gmtime(time(NULL));
+       tm_now.tm_year = tm_now2.tm_year; 
+       tm_now.tm_mon = tm_now2.tm_mon; 
+       tm_now.tm_mday = tm_now2.tm_mday; 
+       tm_now.tm_hour = tm_now2.tm_hour; 
+       tm_now.tm_min = tm_now2.tm_min; 
+       tm_now.tm_sec = tm_now2.tm_sec; 
+
+        debug("bb.sms.smpp",0,"SMPP[%s]: in pdu validity period was %s", 
+              octstr_get_cstr(box->boxc_id), 
octstr_get_cstr(pdu->u.submit_sm.validity_period));
+       sscanf(octstr_get_cstr(pdu->u.submit_sm.validity_period), 
"%02d%02d%02d%02d%02d%02d",
+                       &tm_val.tm_year, &tm_val.tm_mon, &tm_val.tm_mday,
+                       &tm_val.tm_hour, &tm_val.tm_min, &tm_val.tm_sec
+       );
+
+       tm_val.tm_year = tm_val.tm_year + 100;
+       tm_val.tm_mon = tm_val.tm_mon - 1; 
+        debug("bb.sms.smpp",0,"SMPP[%s]: tm_val %d %d %d %d %d %d ", 
+                       octstr_get_cstr(box->boxc_id), 
+                       tm_val.tm_year, tm_val.tm_mon, tm_val.tm_mday,
+                       tm_val.tm_hour, tm_val.tm_min, tm_val.tm_sec
+              );
+        debug("bb.sms.smpp",0,"SMPP[%s]: tm_now %d %d %d %d %d %d ", 
+                       octstr_get_cstr(box->boxc_id), 
+                       tm_now.tm_year, tm_now.tm_mon, tm_now.tm_mday,
+                       tm_now.tm_hour, tm_now.tm_min, tm_now.tm_sec
+              );
+       
+       start = gw_mktime(&tm_now);
+       end = gw_mktime(&tm_val);
+       validity = ceil ( difftime (end,start) / 60 ); // needed to ceil, 
because 119 seconds is near to 2 minutes than to 1
+       msg->sms.validity = validity;
+        debug("bb.sms.smpp",0,"SMPP[%s]: validity period in minutes setted to 
%d", 
+              octstr_get_cstr(box->boxc_id), msg->sms.validity );
+              
+    }
+
+    
+    /* TODO: set deferred */
+    // msg->sms.deferred =
 
     return msg;
 

Reply via email to