that's nice  :)

is this patch going to be included in Kannel?

regards,

Juan


Enver ALTIN wrote:
Hey,

On Sat, 2005-08-27 at 04:12 -0600, Alejandro Ramirez wrote:

I really need to set up a broadcast, but telco is asking me to send
the messages with ESM CLASS of DATAGRAM MODE. I've read in the mailing
list and I've changed the line 638 of the code of smsc_smpp.c to the
corresponding type.

How ever when I try to send a SMS it STILL goes out with the ESM CLASS
of STORE & Forward???

Do i need to change the code somewhere else??


Apply the attached patch against CVS HEAD.

It implements the submission_mode sendsms CGI variable so you can set
the esm_class field of SMPP to one of:

        #define ESM_CLASS_SUBMIT_DEFAULT_SMSC_MODE        0x00000000
        #define ESM_CLASS_SUBMIT_DATAGRAM_MODE            0x00000001
        #define ESM_CLASS_SUBMIT_FORWARD_MODE             0x00000002
        #define ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE   0x00000003

via the sendsms CGI interface. Something like this to use datagram mode
should work:

        
http://localhost:10001/cgi-bin/sendsms?user=test&password=test&from=1234&to=1234&text=testing&submission_mode=1

-HTH


------------------------------------------------------------------------

Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.302
diff -u -p -d -r1.302 userguide.xml
--- doc/userguide/userguide.xml 26 Jul 2005 12:47:17 -0000      1.302
+++ doc/userguide/userguide.xml 27 Aug 2005 12:14:09 -0000
@@ -3419,6 +3419,14 @@ smsc-password = foo
                priority)
      </entry></row>
+ <row><entry><literal>submission_mode</literal><entry>
+         <entry><literal>number</literal></entry>
+         <entry valign="bottom">
+         Optional, sets the esm_class field of SMPP submit_sm request.
+         Possible values are: 0 = Default SMSC mode, 1 = Datagram Mode,
+         2 = Forward Mode, 3 = Store and Forward mode (Default).
+        </entry></row>
+
    </tbody></tgroup></informaltable>
 </sect2>
Index: gw/msg-decl.h
===================================================================
RCS file: /home/cvs/gateway/gw/msg-decl.h,v
retrieving revision 1.30
diff -u -p -d -r1.30 msg-decl.h
--- gw/msg-decl.h       11 Feb 2005 15:35:48 -0000      1.30
+++ gw/msg-decl.h       27 Aug 2005 12:14:09 -0000
@@ -106,6 +106,7 @@ MSG(sms,
                INTEGER(msg_left);
                VOID(split_parts);
                INTEGER(priority);
+               INTEGER(submission_mode);
        })
MSG(ack,
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.258
diff -u -p -d -r1.258 smsbox.c
--- gw/smsbox.c 14 Apr 2005 11:58:57 -0000      1.258
+++ gw/smsbox.c 27 Aug 2005 12:14:09 -0000
@@ -502,7 +502,8 @@ static void get_x_kannel_from_headers(Li
                                      int *validity, int *deferred,
int *dlr_mask, Octstr **dlr_url, Octstr **account, int *pid, int *alt_dcs, - int *rpi, Octstr **binfo, int *priority)
+                                     int *rpi, Octstr **binfo, int *priority,
+                                         int *submission_mode)
 {
     Octstr *name, *val;
     long l;
@@ -592,6 +593,9 @@ static void get_x_kannel_from_headers(Li
        else if (octstr_case_compare(name, octstr_imm("X-Kannel-Priority")) == 
0) {
            sscanf(octstr_get_cstr(val),"%d", priority);
        }
+       else if (octstr_case_compare(name, 
octstr_imm("X-Kannel-Submission-Mode")) == 0) {
+           sscanf(octstr_get_cstr(val),"%d", submission_mode);
+       }
        octstr_destroy(name);
        octstr_destroy(val);
     }
@@ -648,7 +652,7 @@ static void get_x_kannel_from_xml(int re
                                   int *dlr_mask, Octstr **dlr_url,
                                   Octstr **account, int *pid, int *alt_dcs,
                                   int *rpi, List **tolist, Octstr **charset,
-                                  Octstr **binfo, int *priority)
+                                  Octstr **binfo, int *priority, int 
*submission_mode)
{ Octstr *text, *tmp, *tmp2;
@@ -822,6 +826,13 @@ static void get_x_kannel_from_xml(int re
            *priority = tmplong;
        O_DESTROY(tmp);
     }
+
+    get_tag(*body, octstr_imm("submission_mode"), &tmp, 0, 0);
+    if(tmp) {
+       if(octstr_parse_long(&tmplong, tmp, 0, 10) != -1)
+           *submission_mode = tmplong;
+       O_DESTROY(tmp);
+    }
/* charset from <?xml...encoding=?> */
     tmp = find_charset_encoding(*body);
@@ -862,7 +873,8 @@ static void fill_message(Msg *msg, URLTr
                         int validity, int deferred,
                         Octstr *dlr_url, int dlr_mask, int pid, int alt_dcs,
                         int rpi, Octstr *smsc, Octstr *account,
-                        Octstr *charset, Octstr *binfo, int priority)
+                        Octstr *charset, Octstr *binfo, int priority,
+                        int submission_mode)
 {
     msg->sms.msgdata = replytext;
     msg->sms.time = time(NULL);
@@ -1020,6 +1032,13 @@ static void fill_message(Msg *msg, URLTr
         else
             warning(0, "Tried to change priority to '%d', denied.", priority);
     }
+
+    if (submission_mode != SMS_PARAM_UNDEFINED) {
+       if (urltrans_accept_x_kannel_headers(trans))
+           msg->sms.submission_mode = submission_mode;
+       else
+           warning(0, "Tried to change submission mode to '%d', denied.", 
submission_mode);
+    }
 }
@@ -1097,7 +1116,7 @@ static void url_result_thread(void *arg)
     Octstr *reply_body, *charset;
     Octstr *udh, *from, *to, *dlr_url, *account, *smsc, *binfo;
     int dlr_mask, mclass, mwi, coding, compress, pid, alt_dcs, rpi;
-    int validity, deferred, priority;
+    int validity, deferred, priority, submission_mode;
text_html = octstr_imm("text/html");
     text_wml = octstr_imm("text/vnd.wap.wml");
@@ -1115,7 +1134,7 @@ static void url_result_thread(void *arg)
        octets = 0;
         from = to = udh = smsc = dlr_url = account = binfo = charset = NULL;
mclass = mwi = coding = compress = pid = alt_dcs = rpi = dlr_mask - = validity = deferred = priority = SMS_PARAM_UNDEFINED;
+            = validity = deferred = priority = submission_mode = 
SMS_PARAM_UNDEFINED;
get_receiver(id, &msg, &trans, &method, &req_url, &req_headers, &req_body, &retries); @@ -1133,7 +1152,7 @@ static void url_result_thread(void *arg)
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo, &priority);
+                                         &binfo, &priority, &submission_mode);
             } else if (octstr_case_compare(type, text_plain) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -1143,7 +1162,7 @@ static void url_result_thread(void *arg)
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo, &priority);
+                                         &binfo, &priority, &submission_mode);
             } else if (octstr_case_compare(type, text_xml) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -1152,7 +1171,7 @@ static void url_result_thread(void *arg)
                         &from, &to, &udh, NULL, NULL, &smsc, &mclass, &mwi,
                         &coding, &compress, &validity, &deferred, &dlr_mask,
                         &dlr_url, &account, &pid, &alt_dcs, &rpi, NULL, 
&charset,
-                        &binfo, &priority);
+                        &binfo, &priority, &submission_mode);
             } else if (octstr_case_compare(type, octet_stream) == 0) {
                 replytext = octstr_duplicate(reply_body);
                 octstr_destroy(reply_body);
@@ -1163,7 +1182,7 @@ static void url_result_thread(void *arg)
                                          &coding, &compress, &validity,
                                          &deferred, &dlr_mask, &dlr_url,
                                          &account, &pid, &alt_dcs, &rpi,
-                                         &binfo, &priority);
+                                         &binfo, &priority, &submission_mode);
             } else {
                 replytext = octstr_duplicate(reply_couldnotrepresent);
             }
@@ -1183,7 +1202,7 @@ static void url_result_thread(void *arg)
         fill_message(msg, trans, replytext, octets, from, to, udh, mclass,
             mwi, coding, compress, validity, deferred, dlr_url,
             dlr_mask, pid, alt_dcs, rpi, smsc, account, charset,
-            binfo, priority);
+            binfo, priority, submission_mode);
if (final_url == NULL)
             final_url = octstr_imm("");
@@ -1965,7 +1984,8 @@ static Octstr *smsbox_req_handle(URLTran
                                 int validity, int deferred,
int *status, int dlr_mask, Octstr *dlr_url, Octstr *account, int pid, int alt_dcs, int rpi,
-                                List *receiver, Octstr *binfo, int priority)
+                                List *receiver, Octstr *binfo, int priority,
+                                int submission_mode)
{ Msg *msg = NULL;
     Octstr *newfrom, *returnerror, *receiv;
@@ -2260,6 +2280,11 @@ static Octstr *smsbox_req_handle(URLTran
     }
     msg->sms.priority = priority;
+ if (submission_mode != SMS_PARAM_UNDEFINED && (submission_mode < 0 || submission_mode > 3)) {
+       returnerror = octstr_create("Submission mode field misformed, 
rejected");
+       goto fielderror;
+    }
+    msg->sms.submission_mode = submission_mode;
/* new smsc-id argument - we should check this one, if able,
        but that's advanced logics -- Kalle */
@@ -2477,11 +2502,11 @@ static Octstr *smsbox_req_sendsms(List *
     Octstr *from, *to, *charset, *text, *udh, *smsc, *dlr_url, *account;
     Octstr *binfo;
     int        dlr_mask, mclass, mwi, coding, compress, validity, deferred, 
pid;
-    int alt_dcs, rpi, priority;
+    int alt_dcs, rpi, priority, submission_mode;
from = to = udh = text = smsc = account = dlr_url = charset = binfo = NULL; mclass = mwi = coding = compress = validity = deferred = dlr_mask = - pid = alt_dcs = rpi = priority = SMS_PARAM_UNDEFINED;
+        pid = alt_dcs = rpi = priority = submission_mode = SMS_PARAM_UNDEFINED;
/* check the username and password */
     t = authorise_user(args, client_ip);
@@ -2552,6 +2577,10 @@ static Octstr *smsbox_req_sendsms(List *
     tmp_string = http_cgi_variable(args, "priority");
     if(tmp_string != NULL)
         sscanf(octstr_get_cstr(tmp_string),"%d", &priority);
+
+    tmp_string = http_cgi_variable(args, "submission_mode");
+    if(tmp_string != NULL)
+       sscanf(octstr_get_cstr(tmp_string),"%d", &submission_mode);
/*
      * we required "to" to be defined
@@ -2571,7 +2600,7 @@ static Octstr *smsbox_req_sendsms(List *
     return smsbox_req_handle(t, client_ip, stored_uuid, from, to, text, 
charset, udh,
smsc, mclass, mwi, coding, compress, validity, deferred, status, dlr_mask, dlr_url, account,
-                            pid, alt_dcs, rpi, NULL, binfo, priority);
+                            pid, alt_dcs, rpi, NULL, binfo, priority, 
submission_mode);
} @@ -2591,7 +2620,7 @@ static Octstr *smsbox_sendsms_post(List Octstr *text;
     Octstr *from, *to, *udh, *smsc, *charset, *dlr_url, *account, *binfo;
     int dlr_mask, mclass, mwi, coding, compress, validity, deferred;
-    int pid, alt_dcs, rpi, priority;
+    int pid, alt_dcs, rpi, priority, submission_mode;
text_html = octstr_imm("text/html");
     text_wml = octstr_imm("text/vnd.wap.wml");
@@ -2603,7 +2632,7 @@ static Octstr *smsbox_sendsms_post(List tolist = NULL;
     from = to = udh = smsc = account = dlr_url = charset = binfo = NULL;
mclass = mwi = coding = compress = validity = deferred = dlr_mask = - pid = alt_dcs = rpi = priority = SMS_PARAM_UNDEFINED;
+        pid = alt_dcs = rpi = priority = submission_mode = SMS_PARAM_UNDEFINED;
http_header_get_content_type(headers, &type, &charset);
     if (octstr_case_compare(type, text_html) == 0 ||
@@ -2617,7 +2646,7 @@ static Octstr *smsbox_sendsms_post(List &coding, &compress, &validity, &deferred, &dlr_mask, &dlr_url, &account, &pid, &alt_dcs, &rpi,
-                                 &binfo, &priority);
+                                 &binfo, &priority, &submission_mode);
     } else if (octstr_case_compare(type, text_plain) == 0 ||
                octstr_case_compare(type, octet_stream) == 0) {
        get_x_kannel_from_headers(headers, &from, &to, &udh,
@@ -2625,13 +2654,14 @@ static Octstr *smsbox_sendsms_post(List &coding, &compress, &validity, &deferred, &dlr_mask, &dlr_url, &account, &pid, &alt_dcs, &rpi,
-                                 &binfo, &priority);
+                                 &binfo, &priority, &submission_mode);
     } else if (octstr_case_compare(type, text_xml) == 0) {
get_x_kannel_from_xml(mt_push, &type, &body, headers, &from, &to, &udh, &user, &pass, &smsc, &mclass, &mwi, &coding, &compress, &validity, &deferred,
                              &dlr_mask, &dlr_url, &account, &pid, &alt_dcs,
-                             &rpi, &tolist, &charset, &binfo, &priority);
+                             &rpi, &tolist, &charset, &binfo, &priority,
+                             &submission_mode);
     } else {
        *status = HTTP_BAD_REQUEST;
        ret = octstr_create("Invalid content-type");
@@ -2682,7 +2712,7 @@ static Octstr *smsbox_sendsms_post(List udh, smsc, mclass, mwi, coding, compress, validity, deferred, status, dlr_mask, dlr_url, account, pid, alt_dcs, rpi, tolist,
-                                   binfo, priority);
+                                   binfo, priority, submission_mode);
}
 error2:
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.82
diff -u -p -d -r1.82 smsc_smpp.c
--- gw/smsc/smsc_smpp.c 12 Aug 2005 16:12:58 -0000      1.82
+++ gw/smsc/smsc_smpp.c 27 Aug 2005 12:14:09 -0000
@@ -667,7 +667,10 @@ static SMPP_PDU *msg_to_pdu(SMPP *smpp, * set the esm_class field
      * default is store and forward, plus udh and rpi if requested
      */
-    pdu->u.submit_sm.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE;
+    if (msg->sms.submission_mode != SMS_PARAM_UNDEFINED)
+       pdu->u.submit_sm.esm_class = msg->sms.submission_mode;
+    else
+       pdu->u.submit_sm.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE;
     if (octstr_len(msg->sms.udhdata))
         pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class |
             ESM_CLASS_SUBMIT_UDH_INDICATOR;


Reply via email to