I've noticed that Kannel seems to think that the service description
parameter is only one character long.  However, reading the CIMD2 spec
from Nokia, in the large table in section 7.2, page 56(74) it says:

Name           ID Max     Type   Values  Description
                  Length

Service        065 2      Integer 0 - 99 Defines the service description 
Description                              of the message, which can be used
                                         for billing.

It's TWO characters long.  I'm using the current Kannel CVS with a small
hack to add the service description along with tariff class (for a
4-digit binfo parameter, with tariff class as the first two digits and
service description as the last two) as our provider requires both the
tariff class and service description parameters to be set.  However, I
keep getting these messages in my logs:

2004-03-05 14:28:58 [29781] [7] WARNING: CIMD2[smart-incoming]: service
description parameter too long, truncating from 2 to 1 characters

I've made a patch that's attached here.

diff -uNr gateway/gw/smsc/smsc_cimd2.c gateway-patched/gw/smsc/smsc_cimd2.c
--- gateway/gw/smsc/smsc_cimd2.c        2004-02-17 03:46:55.000000000 +0800
+++ gateway-patched/gw/smsc/smsc_cimd2.c        2004-03-05 14:51:10.000000000 +0800
@@ -243,7 +243,7 @@
     { "status error code", P_STATUS_ERROR_CODE, 3, P_INT, 0, 999 },
     { "discharge time", P_DISCHARGE_TIME, 12, P_TIME },
     { "tariff class", P_TARIFF_CLASS, 2, P_INT, 0, 99 },
-    { "service description", P_SERVICE_DESCRIPTION, 1, P_INT, 0, 9 },
+    { "service description", P_SERVICE_DESCRIPTION, 2, P_INT, 0, 99 },
     { "message count", P_MESSAGE_COUNT, 3, P_INT, 0, 999 },
     { "priority", P_PRIORITY, 1, P_INT, 1, 9 },
     { "delivery request mode", P_DELIVERY_REQUEST_MODE, 1, P_INT, 0, 2 },
@@ -1326,6 +1326,7 @@
     long truncated;
     int dcs = 0;
     int setvalidity = 0;
+    int binfo_len;             /* length of billing info string */
 
     gw_assert(msg != NULL);
     gw_assert(msg->type == sms);
@@ -1439,9 +1440,35 @@
        else
        packet_add_int_parm(packet, P_REPLY_PATH, 0, conn);
 
-       /* Use binfo to set the tariff class */
-       if (octstr_len(msg->sms.binfo))
-               packet_add_parm(packet, P_INT, P_TARIFF_CLASS, msg->sms.binfo, conn);
+       /* Use binfo to set the tariff class and service description
+          [EMAIL PROTECTED], 2004-03-02 */
+       binfo_len = octstr_len(msg->sms.binfo);
+       if (binfo_len > 0 && binfo_len <= 2) {
+         /* if the length of the binfo string is less than or
+            equal to 2 then set only the tariff class. */
+         packet_add_parm(packet, P_INT, P_TARIFF_CLASS, msg->sms.binfo, conn);
+       } else if (binfo_len == 4) {
+         /* if the length of the binfo string is exactly 4 characters,
+            then the first two characters will be taken as the tariff
+            class and the next characters will be taken as the service
+            description. */
+         Octstr *tcsd = octstr_create("00");
+
+         /* tariff class */
+         octstr_set_char(tcsd, 0, octstr_get_char(msg->sms.binfo, 0));
+         octstr_set_char(tcsd, 1, octstr_get_char(msg->sms.binfo, 1));
+         packet_add_parm(packet, P_INT, P_TARIFF_CLASS, tcsd, conn);
+
+         /* service description */
+         octstr_set_char(tcsd, 0, octstr_get_char(msg->sms.binfo, 2));
+         octstr_set_char(tcsd, 1, octstr_get_char(msg->sms.binfo, 3));
+         packet_add_parm(packet, P_INT, P_SERVICE_DESCRIPTION, tcsd, conn);
+         octstr_destroy(tcsd);
+       }
+       /* Do not add any tariff class or service description parameters
+          otherwise.  TC or SD parameters can only go from 0-99 as per
+          the CIMD 2 spec, so a longer than 4 character string would
+          be invalid anyway. */
 
     truncated = 0;

Reply via email to