Use libsmpputil functions in smpp_mirror tool

Related: OS#5568
Change-Id: Icb046570803acb3eff89e2a4eb979c4899d485f7
This commit is contained in:
Max 2022-08-01 23:16:52 +07:00
parent 366a340ee1
commit 4743a77e09
3 changed files with 4 additions and 33 deletions

View File

@ -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);

View File

@ -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;

View File

@ -22,37 +22,6 @@
#include <osmocom/smpp/smpp.h>
/* 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)