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 | |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 15 | #define SMPP_SYS_ID_LEN 16 |
| 16 | #define SMPP_PASSWD_LEN 16 |
| 17 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 18 | enum esme_read_state { |
| 19 | READ_ST_IN_LEN = 0, |
| 20 | READ_ST_IN_MSG = 1, |
| 21 | }; |
| 22 | |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 23 | struct osmo_smpp_acl; |
| 24 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 25 | struct osmo_esme { |
| 26 | struct llist_head list; |
| 27 | struct smsc *smsc; |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 28 | struct osmo_smpp_acl *acl; |
Harald Welte | e94db49 | 2012-11-08 20:11:05 +0100 | [diff] [blame] | 29 | int use; |
| 30 | |
Harald Welte | 8a1b056 | 2012-11-09 12:51:44 +0100 | [diff] [blame] | 31 | uint32_t own_seq_nr; |
| 32 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 33 | struct osmo_wqueue wqueue; |
| 34 | struct sockaddr_storage sa; |
| 35 | socklen_t sa_len; |
| 36 | |
| 37 | enum esme_read_state read_state; |
| 38 | uint32_t read_len; |
| 39 | uint32_t read_idx; |
| 40 | struct msgb *read_msg; |
| 41 | |
| 42 | uint8_t smpp_version; |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 43 | char system_id[SMPP_SYS_ID_LEN+1]; |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 44 | |
| 45 | uint8_t bind_flags; |
| 46 | }; |
| 47 | |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 48 | struct osmo_smpp_acl { |
| 49 | struct llist_head list; |
| 50 | struct smsc *smsc; |
| 51 | char *description; |
| 52 | char system_id[SMPP_SYS_ID_LEN+1]; |
| 53 | char passwd[SMPP_PASSWD_LEN+1]; |
| 54 | int default_route; |
| 55 | }; |
| 56 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 57 | struct smsc { |
| 58 | struct osmo_fd listen_ofd; |
| 59 | struct llist_head esme_list; |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 60 | struct llist_head acl_list; |
| 61 | uint16_t listen_port; |
| 62 | char system_id[SMPP_SYS_ID_LEN+1]; |
| 63 | int accept_all; |
| 64 | struct osmo_esme *def_route; |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 65 | void *priv; |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | int smpp_smsc_init(struct smsc *smsc, uint16_t port); |
| 70 | |
Harald Welte | e94db49 | 2012-11-08 20:11:05 +0100 | [diff] [blame] | 71 | void smpp_esme_get(struct osmo_esme *esme); |
| 72 | void smpp_esme_put(struct osmo_esme *esme); |
| 73 | |
Harald Welte | 338e3b3 | 2012-11-20 22:22:04 +0100 | [diff] [blame^] | 74 | struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id); |
| 75 | struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc, |
| 76 | const char *sys_id); |
| 77 | void smpp_acl_delete(struct osmo_smpp_acl *acl); |
| 78 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 79 | int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr, |
| 80 | uint32_t command_status, char *msg_id); |
| 81 | |
Harald Welte | 8a1b056 | 2012-11-09 12:51:44 +0100 | [diff] [blame] | 82 | int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi, |
| 83 | const char *addr, uint8_t avail_status); |
| 84 | |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 85 | int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit, |
| 86 | struct submit_sm_resp_t *submit_r); |
| 87 | |
| 88 | #endif |