Make esme struct shared
This helps to merge similar code from smpp_mirror and smpp_* in follow-up patches.
Related: OS#5568
Change-Id: I8f7ac2c00d16660925dd0b03aa1a0973edf9eb70
diff --git a/include/osmocom/smpp/smpp.h b/include/osmocom/smpp/smpp.h
index df5e163..db4101d 100644
--- a/include/osmocom/smpp/smpp.h
+++ b/include/osmocom/smpp/smpp.h
@@ -11,6 +11,21 @@
READ_ST_IN_MSG = 1,
};
+/* struct representing SMPP's External Short Messaging Entity */
+struct esme {
+ uint32_t own_seq_nr;
+
+ struct osmo_wqueue wqueue;
+ enum esme_read_state read_state;
+ uint32_t read_len;
+ uint32_t read_idx;
+ struct msgb *read_msg;
+
+ uint8_t smpp_version;
+ char system_id[SMPP_SYS_ID_LEN + 1];
+ char password[SMPP_SYS_ID_LEN + 1];
+};
+
#define LOGPESME(ESME, LEVEL, FMT, ARGS...) \
LOGP(DSMPP, LEVEL, "[%s] " FMT, (ESME)->system_id, ##ARGS)
@@ -32,6 +47,7 @@
(resp)->command_status = ESME_ROK; \
(resp)->sequence_number = (req)->sequence_number; }
+struct esme *esme_alloc(void *ctx);
uint32_t smpp_msgb_cmdid(struct msgb *msg);
int smpp_openbsc_alloc_init(void *ctx);
int smpp_openbsc_start(struct gsm_network *net);
diff --git a/include/osmocom/smpp/smpp_smsc.h b/include/osmocom/smpp/smpp_smsc.h
index fb5164f..9607079 100644
--- a/include/osmocom/smpp/smpp_smsc.h
+++ b/include/osmocom/smpp/smpp_smsc.h
@@ -26,33 +26,24 @@
char addr[21+1];
};
-struct osmo_esme {
+/* struct wrapping ESME struct with additional SMSC-specific things like ACL, command list etc */
+struct smpp_esme {
struct llist_head list;
struct smsc *smsc;
+ struct esme *esme;
struct osmo_smpp_acl *acl;
int use;
struct llist_head smpp_cmd_list;
- uint32_t own_seq_nr;
-
- struct osmo_wqueue wqueue;
-
- enum esme_read_state read_state;
- uint32_t read_len;
- uint32_t read_idx;
- struct msgb *read_msg;
-
uint8_t smpp_version;
- char system_id[SMPP_SYS_ID_LEN+1];
-
uint8_t bind_flags;
};
struct osmo_smpp_acl {
struct llist_head list;
struct smsc *smsc;
- struct osmo_esme *esme;
+ struct smpp_esme *esme;
char *description;
char system_id[SMPP_SYS_ID_LEN+1];
char passwd[SMPP_PASSWD_LEN+1];
@@ -89,11 +80,11 @@
struct osmo_timer_list response_timer;
};
-struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme,
+struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct smpp_esme *esme,
uint32_t sequence_number);
void smpp_cmd_ack(struct osmo_smpp_cmd *cmd);
void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status);
-void smpp_cmd_flush_pending(struct osmo_esme *esme);
+void smpp_cmd_flush_pending(struct smpp_esme *esme);
struct smsc {
struct osmo_fd listen_ofd;
@@ -118,25 +109,25 @@
int smpp_smsc_restart(struct smsc *smsc, const char *bind_addr, uint16_t port);
void smpp_smsc_stop(struct smsc *smsc);
-void smpp_esme_get(struct osmo_esme *esme);
-void smpp_esme_put(struct osmo_esme *esme);
+void smpp_esme_get(struct smpp_esme *esme);
+void smpp_esme_put(struct smpp_esme *esme);
-int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struct osmo_esme **emse);
+int smpp_route(const struct smsc *smsc, const struct osmo_smpp_addr *dest, struct smpp_esme **emse);
struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id);
struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc,
const char *sys_id);
void smpp_acl_delete(struct osmo_smpp_acl *acl);
-int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr,
+int smpp_tx_submit_r(struct smpp_esme *esme, uint32_t sequence_nr,
uint32_t command_status, char *msg_id);
-int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi,
+int smpp_tx_alert(struct smpp_esme *esme, uint8_t ton, uint8_t npi,
const char *addr, uint8_t avail_status);
-int smpp_tx_deliver(struct osmo_esme *esme, struct deliver_sm_t *deliver);
+int smpp_tx_deliver(struct smpp_esme *esme, struct deliver_sm_t *deliver);
-int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit,
+int handle_smpp_submit(struct smpp_esme *esme, struct submit_sm_t *submit,
struct submit_sm_resp_t *submit_r);
int smpp_route_pfx_add(struct osmo_smpp_acl *acl,