SMPP's network_error_code TLV

Victor Luchitz <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hello.

SMPP smsc handles the network_error_code TLV as 3-octets C-string,
which seems to be in accordance with the spec, at least at the first
glance. However, the spec also further refines this tag is a set of
two independent integer values: single-octet network code and
two-octets error code.
For example, a value of 0x0300ff (in hex) is a perfectly valid value
for this tag, representing an error with code 0xff in a GSM network.
I'm not 100% sure bearerbox wouldn't choke on reading such a value
(since the supposed string is prematurely terminated), but what I am
sure is that one can't write a value such as 0x0300ff into this tag if
it's represented as a C-string. So, to able to fully use this TLV in
say, smppbox, this TLV has to be represented as a 3-octets integer
value. That renders this tag unusable for the err: field in SMPP
delivery receipts but it was never intended to be used as such despite
bearing a similar name.

So I'm attaching a patch that changes representation of the
network_error_code TLV to a 3-octets integer and removes its usage for
in handle_dlr.

-- 
Best regards,
 Victor Luchitz
network_error_code.patch (application/octet-stream, 2 KB)
Index: gw/smsc/smpp_pdu.def
===================================================================
--- gw/smsc/smpp_pdu.def	(revision 4834)
+++ gw/smsc/smpp_pdu.def	(working copy)
@@ -352,7 +352,7 @@
     TLV_OCTETS(dest_subaddress, 2, 23)
     TLV_INTEGER(language_indicator, 1)
     TLV_OCTETS(its_session_info, 2, 2)
-    TLV_OCTETS(network_error_code, 3, 3)
+    TLV_INTEGER(network_error_code, 3)
     TLV_INTEGER(message_state, 1)
     TLV_NULTERMINATED(receipted_message_id, 65)
     OPTIONAL_END
Index: gw/smsc/smsc_smpp.c
===================================================================
--- gw/smsc/smsc_smpp.c	(revision 4834)
+++ gw/smsc/smsc_smpp.c	(working copy)
@@ -1474,7 +1474,7 @@
                 debug("bb.sms.smpp",0,"SMPP[%s] handle_pdu, got DLR",
                       octstr_get_cstr(smpp->conn->id));
                 dlrmsg = handle_dlr(smpp, pdu->u.data_sm.source_addr, NULL, pdu->u.data_sm.message_payload,
-                                    pdu->u.data_sm.receipted_message_id, pdu->u.data_sm.message_state, pdu->u.data_sm.network_error_code);
+                                    pdu->u.data_sm.receipted_message_id, pdu->u.data_sm.message_state, NULL);
                 if (dlrmsg != NULL) {
                     if (dlrmsg->sms.meta_data == NULL)
                         dlrmsg->sms.meta_data = octstr_create("");
@@ -1532,7 +1532,7 @@
                       octstr_get_cstr(smpp->conn->id));
 
                 dlrmsg = handle_dlr(smpp, pdu->u.deliver_sm.source_addr, pdu->u.deliver_sm.short_message, pdu->u.deliver_sm.message_payload,
-                                    pdu->u.deliver_sm.receipted_message_id, pdu->u.deliver_sm.message_state, pdu->u.deliver_sm.network_error_code);
+                                    pdu->u.deliver_sm.receipted_message_id, pdu->u.deliver_sm.message_state, NULL);
                 resp = smpp_pdu_create(deliver_sm_resp, pdu->u.deliver_sm.sequence_number);
                 if (dlrmsg != NULL) {
                     if (dlrmsg->sms.meta_data == NULL)
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.