blob: a2832d304acfbd1308e58aaf58c3df451f8e15d6 [file] [log] [blame]
Max5346f692022-07-28 14:19:22 +07001#pragma once
2
3#include <osmocom/msc/gsm_data.h>
4
5/* Length limits according to SMPP 3.4 spec including NUL-byte: */
6#define SMPP_SYS_ID_LEN 15
7#define SMPP_PASSWD_LEN 8
8
9enum esme_read_state {
10 READ_ST_IN_LEN = 0,
11 READ_ST_IN_MSG = 1,
12};
13
Max366a3402022-08-01 23:01:24 +070014/* struct representing SMPP's External Short Messaging Entity */
15struct esme {
16 uint32_t own_seq_nr;
17
18 struct osmo_wqueue wqueue;
19 enum esme_read_state read_state;
20 uint32_t read_len;
21 uint32_t read_idx;
22 struct msgb *read_msg;
23
24 uint8_t smpp_version;
25 char system_id[SMPP_SYS_ID_LEN + 1];
26 char password[SMPP_SYS_ID_LEN + 1];
27};
28
Max62977d02022-08-01 22:50:52 +070029#define LOGPESME(ESME, LEVEL, FMT, ARGS...) \
30 LOGP(DSMPP, LEVEL, "[%s] " FMT, (ESME)->system_id, ##ARGS)
31
32#define LOGPESMERR(ESME, FMT, ARGS...) \
33 LOGPESME(ESME, LOGL_ERROR, "Error (%s) " FMT, smpp34_strerror, ##ARGS)
34
Max5346f692022-07-28 14:19:22 +070035/*! \brief Ugly wrapper. libsmpp34 should do this itself! */
36#define SMPP34_UNPACK(rc, type, str, data, len) { \
37 memset(str, 0, sizeof(*str)); \
38 rc = smpp34_unpack(type, str, data, len); }
39
40#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr)
41
42/*! \brief initialize the libsmpp34 data structure for a response */
43#define INIT_RESP(type, resp, req) { \
44 memset((resp), 0, sizeof(*(resp))); \
45 (resp)->command_length = 0; \
46 (resp)->command_id = type; \
47 (resp)->command_status = ESME_ROK; \
48 (resp)->sequence_number = (req)->sequence_number; }
49
Max366a3402022-08-01 23:01:24 +070050struct esme *esme_alloc(void *ctx);
Max5346f692022-07-28 14:19:22 +070051uint32_t smpp_msgb_cmdid(struct msgb *msg);
Max4743a772022-08-01 23:16:52 +070052uint32_t esme_inc_seq_nr(struct esme *esme);
53int pack_and_send(struct esme *esme, uint32_t type, void *ptr);
Maxdfb1cb82022-08-01 23:47:20 +070054int smpp_msc_alloc_init(void *ctx);
55int smpp_msc_start(struct gsm_network *net);