blob: 4b5bd85beb4f288bec7dba04dc843d780c561c7c [file] [log] [blame]
Harald Weltef1033cc2012-11-08 16:14:37 +01001#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 Welte338e3b32012-11-20 22:22:04 +010015#define SMPP_SYS_ID_LEN 16
16#define SMPP_PASSWD_LEN 16
17
Harald Weltef1033cc2012-11-08 16:14:37 +010018enum esme_read_state {
19 READ_ST_IN_LEN = 0,
20 READ_ST_IN_MSG = 1,
21};
22
Harald Welte338e3b32012-11-20 22:22:04 +010023struct osmo_smpp_acl;
24
Harald Weltef1033cc2012-11-08 16:14:37 +010025struct osmo_esme {
26 struct llist_head list;
27 struct smsc *smsc;
Harald Welte338e3b32012-11-20 22:22:04 +010028 struct osmo_smpp_acl *acl;
Harald Weltee94db492012-11-08 20:11:05 +010029 int use;
30
Harald Welte8a1b0562012-11-09 12:51:44 +010031 uint32_t own_seq_nr;
32
Harald Weltef1033cc2012-11-08 16:14:37 +010033 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 Welte338e3b32012-11-20 22:22:04 +010043 char system_id[SMPP_SYS_ID_LEN+1];
Harald Weltef1033cc2012-11-08 16:14:37 +010044
45 uint8_t bind_flags;
46};
47
Harald Welte338e3b32012-11-20 22:22:04 +010048struct 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 Weltef1033cc2012-11-08 16:14:37 +010057struct smsc {
58 struct osmo_fd listen_ofd;
59 struct llist_head esme_list;
Harald Welte338e3b32012-11-20 22:22:04 +010060 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 Weltef1033cc2012-11-08 16:14:37 +010065 void *priv;
66};
67
68
69int smpp_smsc_init(struct smsc *smsc, uint16_t port);
70
Harald Weltee94db492012-11-08 20:11:05 +010071void smpp_esme_get(struct osmo_esme *esme);
72void smpp_esme_put(struct osmo_esme *esme);
73
Harald Welte338e3b32012-11-20 22:22:04 +010074struct osmo_smpp_acl *smpp_acl_alloc(struct smsc *smsc, const char *sys_id);
75struct osmo_smpp_acl *smpp_acl_by_system_id(struct smsc *smsc,
76 const char *sys_id);
77void smpp_acl_delete(struct osmo_smpp_acl *acl);
78
Harald Welted4bdee72012-11-08 19:44:08 +010079int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr,
80 uint32_t command_status, char *msg_id);
81
Harald Welte8a1b0562012-11-09 12:51:44 +010082int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi,
83 const char *addr, uint8_t avail_status);
84
Harald Weltef1033cc2012-11-08 16:14:37 +010085int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit,
86 struct submit_sm_resp_t *submit_r);
87
88#endif