Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 1 | #ifndef _SMPP_SMSC_H |
| 2 | #define _SMPP_SMSC_H |
| 3 | |
| 4 | #include <sys/socket.h> |
| 5 | #include <netinet/in.h> |
| 6 | |
| 7 | #include <osmocom/core/utils.h> |
| 8 | #include <osmocom/core/msgb.h> |
| 9 | #include <osmocom/core/write_queue.h> |
| 10 | |
| 11 | #include <smpp34.h> |
| 12 | #include <smpp34_structs.h> |
| 13 | #include <smpp34_params.h> |
| 14 | |
| 15 | enum esme_read_state { |
| 16 | READ_ST_IN_LEN = 0, |
| 17 | READ_ST_IN_MSG = 1, |
| 18 | }; |
| 19 | |
| 20 | struct osmo_esme { |
| 21 | struct llist_head list; |
| 22 | struct smsc *smsc; |
| 23 | |
Harald Welte | e94db49 | 2012-11-08 20:11:05 +0100 | [diff] [blame] | 24 | int use; |
| 25 | |
Harald Welte | 8a1b056 | 2012-11-09 12:51:44 +0100 | [diff] [blame] | 26 | uint32_t own_seq_nr; |
| 27 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 28 | struct osmo_wqueue wqueue; |
| 29 | struct sockaddr_storage sa; |
| 30 | socklen_t sa_len; |
| 31 | |
| 32 | enum esme_read_state read_state; |
| 33 | uint32_t read_len; |
| 34 | uint32_t read_idx; |
| 35 | struct msgb *read_msg; |
| 36 | |
| 37 | uint8_t smpp_version; |
| 38 | char system_id[16+1]; |
| 39 | |
| 40 | uint8_t bind_flags; |
| 41 | }; |
| 42 | |
| 43 | struct smsc { |
| 44 | struct osmo_fd listen_ofd; |
| 45 | struct llist_head esme_list; |
| 46 | char system_id[16+1]; |
| 47 | void *priv; |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | int smpp_smsc_init(struct smsc *smsc, uint16_t port); |
| 52 | |
Harald Welte | e94db49 | 2012-11-08 20:11:05 +0100 | [diff] [blame] | 53 | void smpp_esme_get(struct osmo_esme *esme); |
| 54 | void smpp_esme_put(struct osmo_esme *esme); |
| 55 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 56 | int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr, |
| 57 | uint32_t command_status, char *msg_id); |
| 58 | |
Harald Welte | 8a1b056 | 2012-11-09 12:51:44 +0100 | [diff] [blame] | 59 | int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi, |
| 60 | const char *addr, uint8_t avail_status); |
| 61 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 62 | int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit, |
| 63 | struct submit_sm_resp_t *submit_r); |
| 64 | |
| 65 | #endif |