[PATCH] SMPP get Optional params

Nisan Bloch <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi All

A small patch to get the values of the optional SMPP params.
Added: smpp_pdu_get_opt(SMPP_PDU *pdu, unsigned long opt_tag);

Nisan
smpp_pdu.c.diff (text/plain, 1.6 KB)
--- ../../cvs/gateway/gw/smsc/smpp_pdu.c	Mon Mar 17 07:29:56 2003
+++ ../../gateway-clickcvs/gw/smsc/smpp_pdu.c	Wed Mar 26 16:48:47 2003
@@ -310,6 +310,50 @@
 }
 
 
+Octstr *smpp_pdu_get_opt(SMPP_PDU *pdu, unsigned long opt_tag)
+{
+
+        Octstr *ret=NULL;
+
+    debug("sms.smpp", 0, "SMPP PDU %p get_opt:", (void *) pdu);
+    debug("sms.smpp", 0, "  type_name: %s", pdu->type_name);
+
+    switch (pdu->type) {
+    #define OPTIONAL_BEGIN(num_expected) \
+        if (p->optional_parameters != NULL) { \
+            Octstr *key = NULL, *tag_val = NULL;
+            unsigned long id;
+    #define TLV(tag_id, min_len, max_len) \
+            id = tag_id; \
+                        if (opt_tag == id) \
+                        { \
+            key = octstr_create_from_data((char*)&id, 2); \
+            tag_val = dict_get(p->optional_parameters, key); \
+            if (tag_val != NULL) \
+                                ret = octstr_duplicate(tag_val); \
+                        else \
+                                ret = NULL;     \
+            octstr_destroy(key); \
+                        }
+    #define OPTIONAL_END \
+        }
+    #define INTEGER(name, octets)
+    #define NULTERMINATED(name, max_octets)
+    #define OCTETS(name, field_giving_octets)
+
+    #define PDU(name, id, fields) \
+        case id: { struct name *p = &pdu->u.name; fields } break;
+        #include "smpp_pdu.def"
+        default:
+                break;
+
+        }
+
+    debug("sms.smpp", 0, "SMPP PDU get_opt ends.");
+        return ret;
+
+}
+
 long smpp_pdu_read_len(Connection *conn)
 {
     Octstr *os;
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.