[PATCH] KSMPPD (and other?) utility methods for smpp_pdu.c
Donald Jackson <[email protected]> Sat, 24 Sep 2016 12:06:42 +0200
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <CALzQDrAxJYV7sM_1U+YSkrdDC_cu-m=Wz2Yq6GZhDgsOvNXQRQ@mail.gmail.com> |
Hi all, Currently KSMPPD runs a patch against Kannel SVN trunk, I believe it would be better if we could just include this patch in the mainline Kannel as they don't have any negative implications. Currently the smpp_pdu_unpack() function takes data without length but the smpp_pdu_pack() function provides length so these two functions are not compatible with each other. This simple patch just allows for compatibility convenience. Thanks, Donald
smpp_pdu_pack.patch
(application/octet-stream, 1.6 KB)
Index: gw/smsc/smpp_pdu.c
===================================================================
--- gw/smsc/smpp_pdu.c (revision 5173)
+++ gw/smsc/smpp_pdu.c (working copy)
@@ -402,7 +402,7 @@
}
-Octstr *smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu)
+Octstr *smpp_pdu_pack_real(Octstr *smsc_id, SMPP_PDU *pdu, int include_len)
{
Octstr *os;
Octstr *temp;
@@ -532,15 +532,16 @@
break;
}
- temp = octstr_create("");
- append_encoded_integer(temp, octstr_len(os) + 4, 4);
- octstr_insert(os, temp, 0);
- octstr_destroy(temp);
+ if(include_len) {
+ temp = octstr_create("");
+ append_encoded_integer(temp, octstr_len(os) + 4, 4);
+ octstr_insert(os, temp, 0);
+ octstr_destroy(temp);
+ }
return os;
}
-
SMPP_PDU *smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len)
{
SMPP_PDU *pdu;
Index: gw/smsc/smpp_pdu.h
===================================================================
--- gw/smsc/smpp_pdu.h (revision 5173)
+++ gw/smsc/smpp_pdu.h (working copy)
@@ -234,7 +234,8 @@
SMPP_PDU *smpp_pdu_create(unsigned long type, unsigned long seq_no);
void smpp_pdu_destroy(SMPP_PDU *pdu);
int smpp_pdu_is_valid(SMPP_PDU *pdu); /* XXX */
-Octstr *smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu);
+Octstr *smpp_pdu_pack_real(Octstr *smsc_id, SMPP_PDU *pdu, int include_len);
+#define smpp_pdu_pack(smsc_id, pdu) smpp_pdu_pack_real(smsc_id, pdu, 1)
SMPP_PDU *smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len);
void smpp_pdu_dump(Octstr *smsc_id, SMPP_PDU *pdu);
void smpp_pdu_dump_line(Octstr *smsc_id, SMPP_PDU *pdu);