Makes sense to me! 

The other possibility is prepending the udh after appropriately formatting
the short_message using octstr_insert()... maybe this should be wrapped in
a call like octstr_prepend()...

I haven't even compiled this code... I'll provide a patch later if people
think this is a suitable solution.

Comments?


    /*
     * set data segments and length
     */
        
    pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata); 

    /* 
     * only re-encoding if using default smsc charset that is defined via 
     * alt-charset in smsc group and if MT is not binary
     */
    if (pdu->u.submit_sm.data_coding == 0) {

        /* 
         * convert to the given alternative charset
         * otherwise assume to convert to GSM 03.38 7-bit alphabet
         */
        if (smpp->alt_charset) {
            if (charset_convert(pdu->u.submit_sm.short_message, "ISO-8859-1",
                                octstr_get_cstr(smpp->alt_charset)) != 0)
                error(0, "Failed to convert msgdata from charset <%s> to <%s>, will 
send as is.", 
                         "ISO-8859-1", octstr_get_cstr(smpp->alt_charset));
        } else {
            charset_latin1_to_gsm(pdu->u.submit_sm.short_message);               
        }
    }

    /* prepend udh if present */
    if (octstr_len(msg->sms.udhdata)) { 
        octstr_insert(pdu->u.submit_sm.short_message, msg->sms.udhdata, 0);
    }
                        
    pdu->u.submit_sm.sm_length = octstr_len(pdu->u.submit_sm.short_message);

On Thursday, 2003-03-06 at 08:43:36 PM, Stipe Tolj scribbled:
> what about this approach?!
> 
> This should work ok, but I think it's an performance impact, because
> we copy octstr arround and this should be avoided.
> 
> Comments?!
> 
> Stipe
> 
> [EMAIL PROTECTED]
> -------------------------------------------------------------------
> Wapme Systems AG
> 
> Vogelsanger Weg 80
> 40470 D�sseldorf
> 
> Tel: +49-211-74845-0
> Fax: +49-211-74845-299
> 
> E-Mail: [EMAIL PROTECTED]
> Internet: http://www.wapme-systems.de
> -------------------------------------------------------------------
> wapme.net - wherever you are
> --- smsc_smpp.c       2003-03-06 10:41:05.000000000 +0100
> +++ smsc_smpp.c.new   2003-03-06 10:39:27.000000000 +0100
> @@ -319,7 +319,7 @@
>  static SMPP_PDU *msg_to_pdu(SMPP *smpp, Msg *msg) 
>  { 
>      SMPP_PDU *pdu; 
> -    Octstr *buffer;
> +    Octstr *buffer = NULL;
>      Octstr *relation_UTC_time = NULL;
>      struct tm gmtime, localtime, tm;
>      int gwqdiff;
> @@ -409,35 +409,36 @@
>          pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class |
>              ESM_CLASS_SUBMIT_RPI;
>  
> +    /* 
> +     * only re-encoding if using default smsc charset that is defined via 
> +     * alt-charset in smsc group and if MT is not binary
> +     */
> +    if (pdu->u.submit_sm.data_coding == 0) {
> +        buffer = octstr_duplicate(msg->sms.msgdata);
> +        /* 
> +         * convert to the given alternative charset
> +         * otherwise assume to convert to GSM 03.38 7-bit alphabet
> +         */
> +        if (smpp->alt_charset) {
> +            if (charset_convert(buffer, "ISO-8859-1",
> +                                octstr_get_cstr(smpp->alt_charset)) != 0)
> +                error(0, "Failed to convert msgdata from charset <%s> to <%s>, will 
> send as is.", 
> +                             "ISO-8859-1", octstr_get_cstr(smpp->alt_charset));
> +        } else {
> +            charset_latin1_to_gsm(buffer);            
> +        }
> +    }
> + 
>      /*
>       * set data segments and length
>       */
>      if (octstr_len(msg->sms.udhdata)) { 
>          pdu->u.submit_sm.short_message = 
> -            octstr_format("%S%S", msg->sms.udhdata, msg->sms.msgdata); 
> +            octstr_format("%S%S", msg->sms.udhdata, (buffer ? buffer : 
> msg->sms.msgdata)); 
>      } else { 
> -        pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata); 
> -
> -        /* 
> -         * only re-encoding if using default smsc charset that is defined via 
> -         * alt-charset in smsc group and if MT is not binary
> -         */
> -        if (pdu->u.submit_sm.data_coding == 0) {
> -            
> -            /* 
> -             * convert to the given alternative charset
> -             * otherwise assume to convert to GSM 03.38 7-bit alphabet
> -             */
> -            if (smpp->alt_charset) {
> -                if (charset_convert(pdu->u.submit_sm.short_message, "ISO-8859-1",
> -                                    octstr_get_cstr(smpp->alt_charset)) != 0)
> -                    error(0, "Failed to convert msgdata from charset <%s> to <%s>, 
> will send as is.", 
> -                             "ISO-8859-1", octstr_get_cstr(smpp->alt_charset));
> -            } else {
> -                charset_latin1_to_gsm(pdu->u.submit_sm.short_message);              
>   
> -            }
> -        } 
> +        pdu->u.submit_sm.short_message = octstr_duplicate((buffer ? buffer : 
> msg->sms.msgdata)); 
>      }
> +    octstr_destroy(buffer);
>      pdu->u.submit_sm.sm_length = octstr_len(pdu->u.submit_sm.short_message);
>  
>      /*


-- 
Benjamin Lee

Level 2 71-75 City Rd, South Melbourne, VIC 3006 Australia
Phone +61 3 8699 1333  Mobile +61 414 717 573  Fax +61 3 8699 1388

Reply via email to