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

--- ../cvs/gateway/gw/smsc/smpp_pdu.h   Tue Mar  4 08:18:51 2003
+++ ../gateway-click/gw/smsc/smpp_pdu.h Tue Mar  4 07:49:10 2003
@@ -95,6 +95,7 @@

 long smpp_pdu_read_len(Connection *conn);
 Octstr *smpp_pdu_read_data(Connection *conn, long len);
+Octstr *smpp_pdu_get_opt(SMPP_PDU *pdu, unsigned long opt_tag);


#endif


--- ../cvs/gateway/gw/smsc/smpp_pdu.c   Tue Mar  4 08:18:19 2003
+++ ../gateway-click/gw/smsc/smpp_pdu.c Tue Mar  4 07:48:22 2003
@@ -275,6 +275,50 @@
     return pdu;
 }

+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;
+
+}
+

 void smpp_pdu_dump(SMPP_PDU *pdu)
 {




Reply via email to