[PATCH ]Validity and Scheduled support in SMPP

Dedy Sutanto <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Sorry, I resubmit with [PATCH] subject. 
Here I attach patch for validty and scheduled SM support in SMPP. (actually
I grab and modify code from smsc_emi2.c  =)  )
This patch working for CVS per Mar 13 14:44 2002.
 
This patch will add one parameter in config file named "relation-time".
Valid values for this "relation-time"  are "p", "+", "-" and "R" (for SMPP
3.4 suppor).
 
If this relation-time is not given, value "+" will be used as default.
 
This patch compatible with parameter validity and deferred (minute) in
kannel http interface.
 
Regard
-dedy-
validity.patch.txt (text/plain, 6 KB)
2002-03-13 14:02 *-lines -u gwlib/cfg.def gwlib/cfg.def.latest Page    1


--- gwlib/cfg.def       Wed Mar 13 14:01:34 2002
+++ gwlib/cfg.def.latest        Wed Mar 13 13:16:35 2002
@@ -172,6 +172,9 @@
     OCTSTR(system-id)
     OCTSTR(system-type)
     OCTSTR(address-range)
+    /* Begin - Validity (DS) */ 
+    OCTSTR(relation-time)
+    /* End - Validity (DS) */ 
     OCTSTR(smsc_nua)
     OCTSTR(home_nua)
     OCTSTR(wait_report)

2002-03-13 14:32 *ines -u gw/smsc_smpp.c gw/smsc_smpp.c.latest Page    1


--- gw/smsc_smpp.c      Wed Mar 13 14:32:02 2002
+++ gw/smsc_smpp.c.latest       Wed Mar 13 14:30:03 2002
@@ -70,6 +70,9 @@
     Octstr *username;
     Octstr *password;
     Octstr *address_range;
+    /* Begin - Validity (DS) */
+    Octstr *relation_time;
+    /* End - Validity (DS) */
     int transmit_port;
     int receive_port;
     int quitting;
@@ -80,7 +83,10 @@
 static SMPP *smpp_create(SMSCConn *conn, Octstr *host, int transmit_port, 
                         int receive_port, Octstr *system_type, 
                         Octstr *username, Octstr *password,
-                        Octstr *address_range) 
+/*                      Octstr *address_range) */
+    /* Begin - Validity (DS) */
+                        Octstr *address_range, Octstr *relation_time)
+    /* End - Validity (DS) */
 {
     SMPP *smpp;
     
@@ -97,6 +103,9 @@
     smpp->username = octstr_duplicate(username);
     smpp->password = octstr_duplicate(password);
     smpp->address_range = octstr_duplicate(address_range);
+    /* Begin - Validity (DS) */ 
+    smpp->relation_time = octstr_duplicate(relation_time);
+    /* End - Validity (DS) */ 
     smpp->transmit_port = transmit_port;
     smpp->receive_port = receive_port;
     smpp->quitting = 0;
@@ -118,6 +127,9 @@
        octstr_destroy(smpp->password);
        octstr_destroy(smpp->system_type);
        octstr_destroy(smpp->address_range);
+    /* Begin - Validity (DS) */ 
+        octstr_destroy(smpp->relation_time);
+    /* End - Validity (DS) */ 
        gw_free(smpp);
     }
 }
@@ -204,11 +216,17 @@
 static SMPP_PDU *msg_to_pdu(SMPP *smpp, Msg *msg)
 {
     SMPP_PDU *pdu;
+    struct tm tm;
+    Octstr *str;
+    char p[20];
+
     pdu = smpp_pdu_create(submit_sm, 
                          counter_increase(smpp->message_id_counter));
                   
-    pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
-    pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
+    //pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
+    pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_UNKNOWN; /* unknown */
+    //pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */
+    pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_UNKNOWN; /* unknown */
     pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
     pdu->u.submit_sm.dest_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */
     
@@ -244,6 +262,32 @@
 
     pdu->u.submit_sm.data_coding = fields_to_dcs(msg, 0);
 
+    /* Begin - Validity (DS) */ 
+    if (msg->sms.validity) {
+        tm = gw_localtime(time(NULL) + msg->sms.validity * 60);
+        sprintf(p, "%02d%02d%02d%02d%02d%02d0%02d%1s",
+           tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
+           tm.tm_hour, tm.tm_min, tm.tm_sec,
+           /* TimeZone times 4 : SMPP 3.4 Time Format Specification*/
+           (tm.tm_gmtoff/3600)*4, octstr_get_cstr(smpp->relation_time) );
+        str = octstr_create(p);
+        pdu->u.submit_sm.validity_period = str;
+    }
+    /* End - Validity (DS) */ 
+
+    /* Begin - Schedule (DS) */
+    if (msg->sms.deferred) {
+        tm = gw_localtime(time(NULL) + msg->sms.deferred * 60);
+        sprintf(p, "%02d%02d%02d%02d%02d%02d0%02d%1s",
+           tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
+           tm.tm_hour, tm.tm_min, tm.tm_sec,
+           /* TimeZone times 4 : SMPP 3.4 Time Format Specification*/
+           (tm.tm_gmtoff/3600)*4, octstr_get_cstr(smpp->relation_time) );
+        str = octstr_create(p);
+        pdu->u.submit_sm.schedule_delivery_time = str;
+    }
+    /* End - Schedule (DS) */
+
     if (octstr_len(msg->sms.udhdata)) {
        pdu->u.submit_sm.short_message =
            octstr_format("%S%S", msg->sms.udhdata, msg->sms.msgdata);
@@ -804,6 +848,9 @@
     Octstr *system_id;
     Octstr *system_type;
     Octstr *address_range;
+    /* Begin - Validity (DS) */
+    Octstr *relation_time;
+    /* End - Validity (DS) */
     SMPP *smpp;
     int ok;
     
@@ -816,7 +863,15 @@
     password = cfg_get(grp, octstr_imm("smsc-password"));
     system_type = cfg_get(grp, octstr_imm("system-type"));
     address_range = cfg_get(grp, octstr_imm("address-range"));
-    
+
+    /* Begin - Validity (DS) */
+    relation_time = cfg_get(grp, octstr_imm("relation-time"));
+    if (relation_time == NULL) {
+        warning(0, "SMPP: relation-time not set, using \"+\" instead");
+        relation_time = octstr_create_real("+");
+    }
+    /* End - Validity (DS) */
+
     system_id = cfg_get(grp, octstr_imm("system-id"));
     if (system_id != NULL) {
        warning(0, "SMPP: obsolete system-id variable is set, "
@@ -826,7 +881,7 @@
            username = system_id;
        } else
            octstr_destroy(system_id);
-    }
+    }    
     
     /* Check that config is OK */
     ok = 1;
@@ -845,7 +900,10 @@
        return -1;
 
     smpp = smpp_create(conn, host, port, receive_port, system_type, 
-                      username, password, address_range);
+/*                    username, password, address_range); */
+    /* Begin - Validity (DS) */
+                      username, password, address_range, relation_time);
+    /* End - Validity (DS) */
     conn->data = smpp;
     conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S", 
                               host, port,
@@ -857,6 +915,9 @@
     octstr_destroy(password);
     octstr_destroy(system_type);
     octstr_destroy(address_range);
+    /* Begin - Validity (DS) */
+    octstr_destroy(relation_time);
+    /* End - Validity (DS) */
 
     conn->status = SMSCCONN_CONNECTING;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.