Max | 5346f69 | 2022-07-28 14:19:22 +0700 | [diff] [blame] | 1 | #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 | |
| 9 | enum esme_read_state { |
| 10 | READ_ST_IN_LEN = 0, |
| 11 | READ_ST_IN_MSG = 1, |
| 12 | }; |
| 13 | |
Max | 366a340 | 2022-08-01 23:01:24 +0700 | [diff] [blame^] | 14 | /* struct representing SMPP's External Short Messaging Entity */ |
| 15 | struct 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 | |
Max | 62977d0 | 2022-08-01 22:50:52 +0700 | [diff] [blame] | 29 | #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 | |
Max | 5346f69 | 2022-07-28 14:19:22 +0700 | [diff] [blame] | 35 | /*! \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 | |
Max | 366a340 | 2022-08-01 23:01:24 +0700 | [diff] [blame^] | 50 | struct esme *esme_alloc(void *ctx); |
Max | 5346f69 | 2022-07-28 14:19:22 +0700 | [diff] [blame] | 51 | uint32_t smpp_msgb_cmdid(struct msgb *msg); |
| 52 | int smpp_openbsc_alloc_init(void *ctx); |
| 53 | int smpp_openbsc_start(struct gsm_network *net); |