Introduce libsmpputil
As part of preparation for libosmo-netif migration let's move common SMPP code into separate build-time library and use it for both smpp_mirror and OsmoMSC renaming the files if necessary. While at it we also fix id/password legth limits in smpp_mirror and drop unused fields from ESME struct. Related: OS#5568 Change-Id: I61910651bc7c188dc2fb67d96189a66a47e7e8fbchanges/44/28844/13
parent
3948fcc476
commit
5346f69a54
|
@ -234,9 +234,11 @@ AC_OUTPUT(
|
|||
include/Makefile
|
||||
include/osmocom/Makefile
|
||||
include/osmocom/msc/Makefile
|
||||
include/osmocom/smpp/Makefile
|
||||
src/Makefile
|
||||
src/libmsc/Makefile
|
||||
src/libvlr/Makefile
|
||||
src/libsmpputil/Makefile
|
||||
src/osmo-msc/Makefile
|
||||
src/utils/Makefile
|
||||
tests/Makefile
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
SUBDIRS = \
|
||||
msc \
|
||||
smpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -45,7 +45,6 @@ noinst_HEADERS = \
|
|||
sgs_vty.h \
|
||||
signal.h \
|
||||
silent_call.h \
|
||||
smpp.h \
|
||||
sms_queue.h \
|
||||
transaction.h \
|
||||
vlr.h \
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
int smpp_openbsc_alloc_init(void *ctx);
|
||||
int smpp_openbsc_start(struct gsm_network *net);
|
|
@ -0,0 +1,4 @@
|
|||
noinst_HEADERS = \
|
||||
smpp.h \
|
||||
smpp_smsc.h \
|
||||
$(NULL)
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <osmocom/msc/gsm_data.h>
|
||||
|
||||
/* Length limits according to SMPP 3.4 spec including NUL-byte: */
|
||||
#define SMPP_SYS_ID_LEN 15
|
||||
#define SMPP_PASSWD_LEN 8
|
||||
|
||||
enum esme_read_state {
|
||||
READ_ST_IN_LEN = 0,
|
||||
READ_ST_IN_MSG = 1,
|
||||
};
|
||||
|
||||
/*! \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); }
|
||||
|
||||
#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr)
|
||||
|
||||
/*! \brief initialize the libsmpp34 data structure for a response */
|
||||
#define INIT_RESP(type, resp, req) { \
|
||||
memset((resp), 0, sizeof(*(resp))); \
|
||||
(resp)->command_length = 0; \
|
||||
(resp)->command_id = type; \
|
||||
(resp)->command_status = ESME_ROK; \
|
||||
(resp)->sequence_number = (req)->sequence_number; }
|
||||
|
||||
uint32_t smpp_msgb_cmdid(struct msgb *msg);
|
||||
int smpp_openbsc_alloc_init(void *ctx);
|
||||
int smpp_openbsc_start(struct gsm_network *net);
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef _SMPP_SMSC_H
|
||||
#define _SMPP_SMSC_H
|
||||
#pragma once
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -8,24 +7,17 @@
|
|||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/write_queue.h>
|
||||
#include <osmocom/core/timer.h>
|
||||
#include <osmocom/smpp/smpp.h>
|
||||
|
||||
#include <smpp34.h>
|
||||
#include <smpp34_structs.h>
|
||||
#include <smpp34_params.h>
|
||||
|
||||
#define SMPP_SYS_ID_LEN 15
|
||||
#define SMPP_PASSWD_LEN 8
|
||||
|
||||
#define MODE_7BIT 7
|
||||
#define MODE_8BIT 8
|
||||
|
||||
struct msc_a;
|
||||
|
||||
enum esme_read_state {
|
||||
READ_ST_IN_LEN = 0,
|
||||
READ_ST_IN_MSG = 1,
|
||||
};
|
||||
|
||||
struct osmo_smpp_acl;
|
||||
|
||||
struct osmo_smpp_addr {
|
||||
|
@ -164,4 +156,3 @@ struct ran_conn;
|
|||
|
||||
bool smpp_route_smpp_first();
|
||||
int smpp_try_deliver(struct gsm_sms *sms, struct msc_a *msc_a);
|
||||
#endif
|
|
@ -25,8 +25,16 @@ SUBDIRS = \
|
|||
libmsc \
|
||||
$(NULL)
|
||||
|
||||
if BUILD_SMPP
|
||||
|
||||
SUBDIRS += \
|
||||
libsmpputil \
|
||||
utils \
|
||||
$(NULL)
|
||||
|
||||
endif
|
||||
|
||||
# Programs
|
||||
SUBDIRS += \
|
||||
osmo-msc \
|
||||
utils \
|
||||
$(NULL)
|
||||
|
|
|
@ -20,9 +20,6 @@ AM_CFLAGS = \
|
|||
$(LIBOSMONETIF_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
noinst_HEADERS = \
|
||||
$(NULL)
|
||||
|
||||
noinst_LIBRARIES = \
|
||||
libmsc.a \
|
||||
$(NULL)
|
||||
|
@ -81,16 +78,3 @@ libmsc_a_SOURCES += \
|
|||
ran_msg_iu.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
if BUILD_SMPP
|
||||
noinst_HEADERS += \
|
||||
smpp_smsc.h \
|
||||
$(NULL)
|
||||
|
||||
libmsc_a_SOURCES += \
|
||||
smpp_smsc.c \
|
||||
smpp_openbsc.c \
|
||||
smpp_vty.c \
|
||||
smpp_utils.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include <osmocom/msc/paging.h>
|
||||
|
||||
#ifdef BUILD_SMPP
|
||||
#include "smpp_smsc.h"
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
#endif
|
||||
|
||||
void *tall_gsms_ctx;
|
||||
|
@ -1389,4 +1389,3 @@ void gsm411_sapi_n_reject(struct msc_a *msc_a)
|
|||
trans_free(trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
|
||||
AM_CFLAGS= \
|
||||
-Wall \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOVTY_CFLAGS) \
|
||||
$(LIBOSMOSCCP_CFLAGS) \
|
||||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(LIBOSMONETIF_CFLAGS) \
|
||||
$(LIBOSMOMGCPCLIENT_CFLAGS) \
|
||||
$(LIBOSMOGSUPCLIENT_CFLAGS) \
|
||||
$(LIBSMPP34_CFLAGS) \
|
||||
$(COVERAGE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
noinst_HEADERS = \
|
||||
$(NULL)
|
||||
|
||||
noinst_LIBRARIES = libsmpputil.a
|
||||
|
||||
libsmpputil_a_SOURCES = \
|
||||
smpp_utils.c \
|
||||
smpp_vty.c \
|
||||
smpp_msc.c \
|
||||
smpp_smsc.c \
|
||||
$(NULL)
|
|
@ -48,8 +48,7 @@
|
|||
#include <osmocom/msc/gsm_subscriber.h>
|
||||
#include <osmocom/msc/vlr.h>
|
||||
#include <osmocom/msc/msc_a.h>
|
||||
|
||||
#include "smpp_smsc.h"
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
|
||||
#define VSUB_USE_SMPP "SMPP"
|
||||
#define VSUB_USE_SMPP_CMD "SMPP-cmd"
|
||||
|
@ -862,4 +861,3 @@ int smpp_openbsc_start(struct gsm_network *net)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -40,15 +40,9 @@
|
|||
#include <osmocom/core/talloc.h>
|
||||
#include <osmocom/gsm/protocol/gsm_04_11.h>
|
||||
|
||||
#include "smpp_smsc.h"
|
||||
|
||||
#include <osmocom/msc/debug.h>
|
||||
#include <osmocom/msc/gsm_data.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)
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
|
||||
enum emse_bind {
|
||||
ESME_BIND_RX = 0x01,
|
||||
|
@ -333,18 +327,7 @@ int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struc
|
|||
return GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;
|
||||
}
|
||||
|
||||
|
||||
/*! \brief initialize the libsmpp34 data structure for a response */
|
||||
#define INIT_RESP(type, resp, req) { \
|
||||
memset((resp), 0, sizeof(*(resp))); \
|
||||
(resp)->command_length = 0; \
|
||||
(resp)->command_id = type; \
|
||||
(resp)->command_status = ESME_ROK; \
|
||||
(resp)->sequence_number = (req)->sequence_number; \
|
||||
}
|
||||
|
||||
/*! \brief pack a libsmpp34 data strcutrure and send it to the ESME */
|
||||
#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr)
|
||||
static int pack_and_send(struct osmo_esme *esme, uint32_t type, void *ptr)
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
@ -394,13 +377,6 @@ static int smpp_tx_gen_nack(struct osmo_esme *esme, uint32_t seq, uint32_t statu
|
|||
return PACK_AND_SEND(esme, &nack);
|
||||
}
|
||||
|
||||
/*! \brief retrieve SMPP command ID from a msgb */
|
||||
static inline uint32_t smpp_msgb_cmdid(struct msgb *msg)
|
||||
{
|
||||
uint8_t *tmp = msgb_data(msg) + 4;
|
||||
return ntohl(*(uint32_t *)tmp);
|
||||
}
|
||||
|
||||
/*! \brief retrieve SMPP sequence number from a msgb */
|
||||
static inline uint32_t smpp_msgb_seq(struct msgb *msg)
|
||||
{
|
|
@ -21,8 +21,16 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#include "smpp_smsc.h"
|
||||
#include <osmocom/core/logging.h>
|
||||
#include <osmocom/netif/stream.h>
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
|
||||
/*! \brief retrieve SMPP command ID from a msgb */
|
||||
uint32_t smpp_msgb_cmdid(struct msgb *msg)
|
||||
{
|
||||
uint8_t *tmp = msgb_data(msg) + 4;
|
||||
return ntohl(*(uint32_t *)tmp);
|
||||
}
|
||||
|
||||
int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode)
|
||||
{
|
|
@ -34,8 +34,7 @@
|
|||
#include <osmocom/core/talloc.h>
|
||||
|
||||
#include <osmocom/msc/vty.h>
|
||||
|
||||
#include "smpp_smsc.h"
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
|
||||
struct smsc *smsc_from_vty(struct vty *v);
|
||||
|
|
@ -43,7 +43,6 @@ osmo_msc_LDADD = \
|
|||
$(LIBOSMOCTRL_LIBS) \
|
||||
$(LIBOSMOABIS_LIBS) \
|
||||
$(LIBOSMONETIF_LIBS) \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(LIBOSMORANAP_LIBS) \
|
||||
$(LIBASN1C_LIBS) \
|
||||
$(LIBOSMOSIGTRAN_LIBS) \
|
||||
|
@ -52,3 +51,12 @@ osmo_msc_LDADD = \
|
|||
$(LIBSQLITE3_LIBS) \
|
||||
-lsctp \
|
||||
$(NULL)
|
||||
|
||||
if BUILD_SMPP
|
||||
|
||||
osmo_msc_LDADD += \
|
||||
$(top_builddir)/src/libsmpputil/libsmpputil.a \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
endif
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include <osmocom/ctrl/control_if.h>
|
||||
#include <osmocom/ctrl/control_vty.h>
|
||||
#include <osmocom/ctrl/ports.h>
|
||||
#include <osmocom/msc/smpp.h>
|
||||
#include <osmocom/smpp/smpp.h>
|
||||
#include <osmocom/sigtran/osmo_ss7.h>
|
||||
#include <osmocom/mgcp_client/mgcp_client.h>
|
||||
#include <osmocom/msc/sgs_iface.h>
|
||||
|
|
|
@ -34,12 +34,16 @@ smpp_mirror_SOURCES = \
|
|||
|
||||
smpp_mirror_CFLAGS = \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOSCCP_CFLAGS) \
|
||||
$(LIBOSMOMGCPCLIENT_CFLAGS) \
|
||||
$(LIBSMPP34_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
smpp_mirror_LDADD = \
|
||||
$(top_builddir)/src/libsmpputil/libsmpputil.a \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMONETIF_LIBS) \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
|
|
@ -19,18 +19,11 @@
|
|||
#include <osmocom/core/write_queue.h>
|
||||
|
||||
#include <osmocom/msc/debug.h>
|
||||
#include <osmocom/smpp/smpp.h>
|
||||
|
||||
/* FIXME: merge with smpp_smsc.c */
|
||||
#define SMPP_SYS_ID_LEN 16
|
||||
enum esme_read_state {
|
||||
READ_ST_IN_LEN = 0,
|
||||
READ_ST_IN_MSG = 1,
|
||||
};
|
||||
/* FIXME: merge with smpp_smsc.c */
|
||||
|
||||
struct esme {
|
||||
struct osmo_fd ofd;
|
||||
|
||||
uint32_t own_seq_nr;
|
||||
|
||||
struct osmo_wqueue wqueue;
|
||||
|
@ -45,22 +38,6 @@ struct esme {
|
|||
};
|
||||
|
||||
/* FIXME: merge with smpp_smsc.c */
|
||||
#define SMPP34_UNPACK(rc, type, str, data, len) \
|
||||
memset(str, 0, sizeof(*str)); \
|
||||
rc = smpp34_unpack(type, str, data, len)
|
||||
#define INIT_RESP(type, resp, req) { \
|
||||
memset((resp), 0, sizeof(*(resp))); \
|
||||
(resp)->command_length = 0; \
|
||||
(resp)->command_id = type; \
|
||||
(resp)->command_status = ESME_ROK; \
|
||||
(resp)->sequence_number = (req)->sequence_number; \
|
||||
}
|
||||
#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr)
|
||||
static inline uint32_t smpp_msgb_cmdid(struct msgb *msg)
|
||||
{
|
||||
uint8_t *tmp = msgb_data(msg) + 4;
|
||||
return ntohl(*(uint32_t *)tmp);
|
||||
}
|
||||
static uint32_t esme_inc_seq_nr(struct esme *esme)
|
||||
{
|
||||
esme->own_seq_nr++;
|
||||
|
|
|
@ -14,7 +14,6 @@ AM_CFLAGS = \
|
|||
$(LIBOSMOSIGTRAN_CFLAGS) \
|
||||
$(LIBOSMORANAP_CFLAGS) \
|
||||
$(LIBOSMONETIF_CFLAGS) \
|
||||
$(LIBSMPP34_CFLAGS) \
|
||||
$(LIBOSMOMGCPCLIENT_CFLAGS) \
|
||||
$(LIBOSMOGSUPCLIENT_CFLAGS) \
|
||||
$(LIBSQLITE3_CFLAGS) \
|
||||
|
@ -37,7 +36,6 @@ db_sms_test_SOURCES = \
|
|||
db_sms_test_LDADD = \
|
||||
$(top_builddir)/src/libmsc/libmsc.a \
|
||||
$(top_builddir)/src/libvlr/libvlr.a \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
|
|
|
@ -8,7 +8,6 @@ AM_CFLAGS = \
|
|||
-ggdb3 \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(LIBSMPP34_CFLAGS) \
|
||||
$(LIBOSMOVTY_CFLAGS) \
|
||||
$(LIBOSMOABIS_CFLAGS) \
|
||||
$(LIBOSMOSIGTRAN_CFLAGS) \
|
||||
|
@ -32,7 +31,6 @@ AM_LDFLAGS = \
|
|||
LDADD = \
|
||||
$(top_builddir)/src/libmsc/libmsc.a \
|
||||
$(top_builddir)/src/libvlr/libvlr.a \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
|
|
|
@ -11,6 +11,8 @@ AM_CFLAGS = \
|
|||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(LIBOSMOSCCP_CFLAGS) \
|
||||
$(LIBOSMOABIS_CFLAGS) \
|
||||
$(LIBOSMOSCCP_CFLAGS) \
|
||||
$(LIBOSMOMGCPCLIENT_CFLAGS) \
|
||||
$(COVERAGE_CFLAGS) \
|
||||
$(LIBSMPP34_CFLAGS) \
|
||||
$(NULL)
|
||||
|
@ -30,10 +32,10 @@ check_PROGRAMS = \
|
|||
|
||||
smpp_test_SOURCES = \
|
||||
smpp_test.c \
|
||||
$(top_builddir)/src/libmsc/smpp_utils.c \
|
||||
$(NULL)
|
||||
|
||||
smpp_test_LDADD = \
|
||||
$(top_builddir)/src/libsmpputil/libsmpputil.a \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(NULL)
|
||||
|
|
|
@ -22,12 +22,10 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <osmocom/msc/debug.h>
|
||||
|
||||
#include <osmocom/smpp/smpp_smsc.h>
|
||||
#include <osmocom/core/application.h>
|
||||
#include <osmocom/core/backtrace.h>
|
||||
|
||||
#include "smpp_smsc.h"
|
||||
|
||||
struct coding_test {
|
||||
uint8_t dcs;
|
||||
uint8_t coding;
|
||||
|
|
|
@ -36,7 +36,6 @@ sms_queue_test_SOURCES = \
|
|||
sms_queue_test_LDADD = \
|
||||
$(top_builddir)/src/libmsc/libmsc.a \
|
||||
$(top_builddir)/src/libvlr/libvlr.a \
|
||||
$(LIBSMPP34_LIBS) \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
|
|
|
@ -43,3 +43,11 @@ char *osmo_stream_srv_link_get_sockname(const struct osmo_stream_srv_link *link)
|
|||
void osmo_stream_srv_link_set_port(struct osmo_stream_srv_link *link, uint16_t port) {}
|
||||
void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr) {}
|
||||
int sctp_recvmsg(int sd, void *msg, size_t len, void *from, void *fromlen, void *info, int *msg_flags) { return 0; }
|
||||
struct gsm_sms;
|
||||
struct msc_a;
|
||||
struct gsm_trans;
|
||||
struct osmo_esme;
|
||||
bool smpp_route_smpp_first() { return false; }
|
||||
void smpp_esme_put(struct osmo_esme *esme) { return; }
|
||||
int smpp_try_deliver(struct gsm_sms *sms, struct msc_a *msc_a) { return 0; }
|
||||
int sms_route_mt_sms(struct gsm_trans *trans, struct gsm_sms *gsms) { return 0; }
|
||||
|
|
Loading…
Reference in New Issue