From 4743a77e097e1925a089d81c11a8e7bac6476446 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 1 Aug 2022 23:16:52 +0700 Subject: [PATCH] Use libsmpputil functions in smpp_mirror tool Related: OS#5568 Change-Id: Icb046570803acb3eff89e2a4eb979c4899d485f7 --- include/osmocom/smpp/smpp.h | 2 ++ src/libsmpputil/smpp_smsc.c | 4 ++-- src/utils/smpp_mirror.c | 31 ------------------------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/include/osmocom/smpp/smpp.h b/include/osmocom/smpp/smpp.h index db4101dfd..54e5de787 100644 --- a/include/osmocom/smpp/smpp.h +++ b/include/osmocom/smpp/smpp.h @@ -49,5 +49,7 @@ struct esme { struct esme *esme_alloc(void *ctx); uint32_t smpp_msgb_cmdid(struct msgb *msg); +uint32_t esme_inc_seq_nr(struct esme *esme); +int pack_and_send(struct esme *esme, uint32_t type, void *ptr); int smpp_openbsc_alloc_init(void *ctx); int smpp_openbsc_start(struct gsm_network *net); diff --git a/src/libsmpputil/smpp_smsc.c b/src/libsmpputil/smpp_smsc.c index bb559cd6c..a1f2b2f44 100644 --- a/src/libsmpputil/smpp_smsc.c +++ b/src/libsmpputil/smpp_smsc.c @@ -250,7 +250,7 @@ static void esme_destroy(struct smpp_esme *esme) talloc_free(esme); } -static uint32_t esme_inc_seq_nr(struct esme *esme) +uint32_t esme_inc_seq_nr(struct esme *esme) { esme->own_seq_nr++; if (esme->own_seq_nr > 0x7fffffff) @@ -326,7 +326,7 @@ int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struc } /*! \brief pack a libsmpp34 data strcutrure and send it to the ESME */ -static int pack_and_send(struct esme *esme, uint32_t type, void *ptr) +int pack_and_send(struct esme *esme, uint32_t type, void *ptr) { struct msgb *msg; int rc, rlen; diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c index 076b434ab..48b9ea292 100644 --- a/src/utils/smpp_mirror.c +++ b/src/utils/smpp_mirror.c @@ -22,37 +22,6 @@ #include -/* FIXME: merge with smpp_smsc.c */ -static uint32_t esme_inc_seq_nr(struct esme *esme) -{ - esme->own_seq_nr++; - if (esme->own_seq_nr > 0x7fffffff) - esme->own_seq_nr = 1; - - return esme->own_seq_nr; -} -static int pack_and_send(struct esme *esme, uint32_t type, void *ptr) -{ - struct msgb *msg = msgb_alloc(4096, "SMPP_Tx"); - int rc, rlen; - if (!msg) - return -ENOMEM; - - rc = smpp34_pack(type, msg->tail, msgb_tailroom(msg), &rlen, ptr); - if (rc != 0) { - LOGPESMERR(esme, "during smpp34_pack()\n"); - msgb_free(msg); - return -EINVAL; - } - msgb_put(msg, rlen); - - if (osmo_wqueue_enqueue(&esme->wqueue, msg) != 0) { - LOGPESME(esme, LOGL_ERROR, "Write queue full. Dropping message\n"); - msgb_free(msg); - return -EAGAIN; - } - return 0; -} /* FIXME: merge with smpp_smsc.c */ static struct tlv_t *find_tlv(struct tlv_t *head, uint16_t tag)