blob: b1617e600884145edd93d8e2e6cba82167b3242b [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
15enum esme_read_state {
16 READ_ST_IN_LEN = 0,
17 READ_ST_IN_MSG = 1,
18};
19
20struct osmo_esme {
21 struct llist_head list;
22 struct smsc *smsc;
23
Harald Weltee94db492012-11-08 20:11:05 +010024 int use;
25
Harald Welte8a1b0562012-11-09 12:51:44 +010026 uint32_t own_seq_nr;
27
Harald Weltef1033cc2012-11-08 16:14:37 +010028 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
43struct 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
51int smpp_smsc_init(struct smsc *smsc, uint16_t port);
52
Harald Weltee94db492012-11-08 20:11:05 +010053void smpp_esme_get(struct osmo_esme *esme);
54void smpp_esme_put(struct osmo_esme *esme);
55
Harald Welted4bdee72012-11-08 19:44:08 +010056int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr,
57 uint32_t command_status, char *msg_id);
58
Harald Welte8a1b0562012-11-09 12:51:44 +010059int smpp_tx_alert(struct osmo_esme *esme, uint8_t ton, uint8_t npi,
60 const char *addr, uint8_t avail_status);
61
Harald Weltef1033cc2012-11-08 16:14:37 +010062int handle_smpp_submit(struct osmo_esme *esme, struct submit_sm_t *submit,
63 struct submit_sm_resp_t *submit_r);
64
65#endif