aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/smpp_smsc.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-11-08 22:12:45 +0100
committerHarald Welte <laforge@gnumonks.org>2012-11-16 22:00:09 +0100
commit4dbcdad9031c8fd7f95ceb88ba2d9b6148a1476d (patch)
tree09070642c345611f3924874a9ca4ad89ae7fe183 /openbsc/src/libmsc/smpp_smsc.c
parente94db496984b072e8bddacd93e3bd25f4e67dadf (diff)
SMPP: Introduce wrapper macro to memset all structures to zero
For some reason, libsmpp34 is too smart to zero out the entire structure to which it is unpacking. This introduces an ugly wrapper macro to work around. This needs discussion with the libsmpp34 maintainer.
Diffstat (limited to 'openbsc/src/libmsc/smpp_smsc.c')
-rw-r--r--openbsc/src/libmsc/smpp_smsc.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/openbsc/src/libmsc/smpp_smsc.c b/openbsc/src/libmsc/smpp_smsc.c
index fc38925cb..765cb517a 100644
--- a/openbsc/src/libmsc/smpp_smsc.c
+++ b/openbsc/src/libmsc/smpp_smsc.c
@@ -41,6 +41,11 @@
#include <openbsc/debug.h>
+/*! \brief Ugly wrapper. libsmpp34 should do this itself! */
+#define SMPP34_UNPACK(rc, type, str, data, len) \
+ memset(str, 0, sizeof(*str)); \
+ rc = smpp34_unpack(type, str, data, len)
+
enum emse_bind {
ESME_BIND_RX = 0x01,
ESME_BIND_TX = 0x02,
@@ -148,8 +153,8 @@ static int smpp_handle_gen_nack(struct osmo_esme *esme, struct msgb *msg)
char buf[SMALL_BUFF];
int rc;
- rc = smpp34_unpack(GENERIC_NACK, &nack, msgb_data(msg),
- msgb_length(msg));
+ SMPP34_UNPACK(rc, GENERIC_NACK, &nack, msgb_data(msg),
+ msgb_length(msg));
if (rc < 0)
return rc;
@@ -166,7 +171,7 @@ static int smpp_handle_bind_rx(struct osmo_esme *esme, struct msgb *msg)
struct bind_receiver_resp_t bind_r;
int rc;
- rc = smpp34_unpack(BIND_RECEIVER, &bind, msgb_data(msg),
+ SMPP34_UNPACK(rc, BIND_RECEIVER, &bind, msgb_data(msg),
msgb_length(msg));
if (rc < 0)
return rc;
@@ -204,7 +209,7 @@ static int smpp_handle_bind_tx(struct osmo_esme *esme, struct msgb *msg)
struct tlv_t tlv;
int rc;
- rc = smpp34_unpack(BIND_TRANSMITTER, &bind, msgb_data(msg),
+ SMPP34_UNPACK(rc, BIND_TRANSMITTER, &bind, msgb_data(msg),
msgb_length(msg));
if (rc < 0) {
printf("error during unpack: %s\n", smpp34_strerror);
@@ -251,7 +256,7 @@ static int smpp_handle_bind_trx(struct osmo_esme *esme, struct msgb *msg)
struct bind_transceiver_resp_t bind_r;
int rc;
- rc = smpp34_unpack(BIND_TRANSCEIVER, &bind, msgb_data(msg),
+ SMPP34_UNPACK(rc, BIND_TRANSCEIVER, &bind, msgb_data(msg),
msgb_length(msg));
if (rc < 0)
return rc;
@@ -287,7 +292,7 @@ static int smpp_handle_unbind(struct osmo_esme *esme, struct msgb *msg)
struct unbind_resp_t unbind_r;
int rc;
- rc = smpp34_unpack(UNBIND, &unbind, msgb_data(msg),
+ SMPP34_UNPACK(rc, UNBIND, &unbind, msgb_data(msg),
msgb_length(msg));
if (rc < 0)
return rc;
@@ -313,7 +318,7 @@ static int smpp_handle_enq_link(struct osmo_esme *esme, struct msgb *msg)
struct enquire_link_resp_t enq_r;
int rc;
- rc = smpp34_unpack(ENQUIRE_LINK, &enq, msgb_data(msg),
+ SMPP34_UNPACK(rc, ENQUIRE_LINK, &enq, msgb_data(msg),
msgb_length(msg));
if (rc < 0)
return rc;
@@ -348,7 +353,8 @@ static int smpp_handle_submit(struct osmo_esme *esme, struct msgb *msg)
struct submit_sm_resp_t submit_r;
int rc;
- rc = smpp34_unpack(SUBMIT_SM, &submit, msgb_data(msg),
+ memset(&submit, 0, sizeof(submit));
+ SMPP34_UNPACK(rc, SUBMIT_SM, &submit, msgb_data(msg),
msgb_length(msg));
if (rc < 0)
return rc;