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: I61910651bc7c188dc2fb67d96189a66a47e7e8fb
diff --git a/include/osmocom/smpp/smpp.h b/include/osmocom/smpp/smpp.h
new file mode 100644
index 0000000..cc0e800
--- /dev/null
+++ b/include/osmocom/smpp/smpp.h
@@ -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);