[PATCH] Get all available TLV's as Meta-Data

Alejandro Guerrieri <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

This patch allows meta-data to carry all available TLV's not only the  
User-Defined.

All TLV's defined on smpp_pdu.def were "hijacked" by the main pdu  
structure, so they never reached the tlv dictionary. What this patch  
does is to check for defined TLV's on the smpp-tlv group and copy them  
to the tlv dictionary. Those TLV's are then available on the meta-data  
parameter.

It only copies the TLV's explicitly defined, otherwise the meta-data  
parameter would be unnecessary cluttered with all available TLV's.

This solves the "receipted_message_id" issue with deliver_sm (to name  
one), but does _not_ solve the "message_id" param on submit/deliver/ 
data_sm_response, since message_id is not a TLV.

For that parameter I could add a call for meta_data_set_value to  
inject it into the meta data (already tried and works), but then it  
would be always available.

To avoid this, I could use the same filtering mechanism as with the  
TLV's, but that would mean defining a dummy tag address, since this is  
not a TLV so it doesn't have a documented address. I could filter  
using tag_by_name, so the address wouldn't matter anyways, but it's  
somewhat ugly imho.

Ideas? Opinions?

Regards,
--
Alejandro Guerrieri
[email protected]
meta_data_extra_tlvs.diff (application/octet-stream, 2.1 KB)
Index: smpp_pdu.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smpp_pdu.c,v
retrieving revision 1.28.2.2
diff -u -r1.28.2.2 smpp_pdu.c
--- smpp_pdu.c	24 Jan 2008 16:47:04 -0000	1.28.2.2
+++ smpp_pdu.c	26 Nov 2008 04:54:15 -0000
@@ -467,6 +467,13 @@
                         continue; \
                     } \
                     INTEGER(name, opt_len); \
+                    Octstr *tmp = octstr_create(#name); \
+                    struct smpp_tlv *tlv = dict_get(tlv_by_name, tmp); \
+                    if (tlv != NULL) {\
+                        Octstr *val = octstr_format("%ld", p->name); \
+                        dict_put(p->tlv, tmp, val); \
+                    } \
+                    octstr_destroy(tmp); \
                 } else
     #define TLV_NULTERMINATED(name, max_len) \
                 if (SMPP_##name == opt_tag) { \
@@ -477,6 +484,13 @@
                         continue; \
                     } \
                     copy_until_nul(#name, data_without_len, &pos, opt_len, &p->name); \
+                    Octstr *tmp = octstr_create(#name); \
+                    struct smpp_tlv *tlv = dict_get(tlv_by_name, tmp); \
+                    if (tlv != NULL) {\
+                        Octstr *val = octstr_duplicate(p->name); \
+                        dict_put(p->tlv, tmp, val); \
+                    } \
+                    octstr_destroy(tmp); \
                 } else
     #define TLV_OCTETS(name, min_len, max_len) \
                 if (SMPP_##name == opt_tag) { \
@@ -488,6 +502,13 @@
                         continue; \
                     } \
                     p->name = octstr_copy(data_without_len, pos, opt_len); \
+                    Octstr *tmp = octstr_create(#name); \
+                    struct smpp_tlv *tlv = dict_get(tlv_by_name, tmp); \
+                    if (tlv != NULL) {\
+                        Octstr *val = octstr_duplicate(p->name); \
+                        dict_put(p->tlv, tmp, val); \
+                    } \
+                    octstr_destroy(tmp); \
                     pos += opt_len; \
                 } else
     #define OPTIONAL_END \
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.