Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
smsc_p.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*
58  * smsc_p.h - private interface to SMS center subsystem
59  *
60  * Lars Wirzenius
61  *
62  * New API by Kalle Marjola 1999
63  */
64 
65 #ifndef SMSC_P_H
66 #define SMSC_P_H
67 
68 
69 #include <stddef.h>
70 #include <stdio.h>
71 #include <signal.h>
72 #include <time.h>
73 
74 #include "smsc.h"
75 
76 /*
77  * List of SMS center types that we support.
78  */
79 enum {
85 };
86 
87 /*
88  * The implementation of the SMSCenter object.
89  */
90 #define DIAL_PREFIX_MAX_LEN 1024
91 struct SMSCenter {
92 
93  int type;
94  int transport;
95 
96  char name[1024];
97  int id;
98 
99  /* Routing prefixes (based on phone number) */
103 
104 
105  /* Alternative charset */
107 
108  /* For locking/unlocking. */
110 
111  /* for dying */
112  volatile sig_atomic_t killed;
113 
114  /* General IO device */
115  int socket;
116 
117  /* Maximum minutes idle time before ping is sent. 0 for no pings. */
119 
120  /* TCP/IP */
121  char *hostname;
122  int port;
123  int receive_port; /* if used, with EMI 2.0/OIS 4.5 */
124 
125  /* PSTN/ISDN */
126  char *phonenum;
128 
129  /* X.31 */
132 
133  /* Unix pipes */
135 
136  /* CIMD */
143 
144  /* EMI_X25 */
145  int emi_fd;
146  FILE *emi_fp;
150  int emi_port;
156  int emi_backup_port; /* different one! rename! */
158  int emi_our_port; /* port to bind us when connecting smsc */
160 
161  /* SEMA SMS2000 OIS 4.5 X28 */
162 
163  char * sema_smscnua;
164  char * sema_homenua;
167  int sema_fd;
168 
169  /* SEMA SMS2000 OIS 5.0 (TCP/IP to X.25 router) */
170 
171  time_t ois_alive;
172  time_t ois_alive2;
178  char *ois_buffer;
179  size_t ois_bufsize;
180  size_t ois_buflen;
182 
183  /* For buffering input. */
184  char *buffer;
185  size_t bufsize;
186  size_t buflen;
187 };
188 
189 
190 /*
191  * Operations on an SMSCenter object.
192  */
194 void smscenter_destruct(SMSCenter *smsc);
196 void smscenter_remove_from_buffer(SMSCenter *smsc, size_t n);
197 
198 /* Send an SMS message via an SMS center. Return -1 for error,
199  0 for OK. */
201 
202 
203 /* Receive an SMS message from an SMS center. Return -1 for error,
204  0 end of messages (other end closed their end of the connection),
205  or 1 for a message was received. If a message was received, a
206  pointer to it is returned via `*msg'. Note that this operation
207  blocks until there is a message. */
208 int smscenter_receive_msg(SMSCenter *smsc, Msg **msg);
209 
210 
211 /* Is there an SMS message pending from an SMS center? Return -1 for
212  error, 0 for no, 1 for yes. This operation won't block, but may
213  not be instantaneous, if it has to read a few characters to see
214  if there is a message. Use smscenter_receive_smsmessage to actually receive
215  the message. */
217 
218 
219 /*
220  * Interface to Nokia SMS centers using CIMD.
221  */
222 SMSCenter *cimd_open(char *hostname, int port, char *username, char *password);
223 int cimd_reopen(SMSCenter *smsc);
224 int cimd_close(SMSCenter *smsc);
226 int cimd_submit_msg(SMSCenter *smsc, Msg *msg);
227 int cimd_receive_msg(SMSCenter *smsc, Msg **msg);
228 
229 /*
230  * Interface to CMG SMS centers using EMI_X25.
231  */
232 SMSCenter *emi_open(char *phonenum, char *serialdevice, char *username, char *password);
233 int emi_reopen(SMSCenter *smsc);
234 int emi_close(SMSCenter *smsc);
235 SMSCenter *emi_open_ip(char *hostname, int port, char *username,
236  char *password, int receive_port, char *allow_ip, int our_port);
237 int emi_reopen_ip(SMSCenter *smsc);
238 int emi_close_ip(SMSCenter *smsc);
240 int emi_submit_msg(SMSCenter *smsc, Msg *msg);
241 int emi_receive_msg(SMSCenter *smsc, Msg **msg);
242 
243 /*
244  * Interface to Sema SMS centers using SM2000
245  */
246 SMSCenter *sema_open(char *smscnua, char *homenua, char* serialdevice,
247  int waitreport);
248 int sema_reopen(SMSCenter *smsc);
249 int sema_close(SMSCenter *smsc);
251 int sema_submit_msg(SMSCenter *smsc, Msg *msg);
252 int sema_receive_msg(SMSCenter *smsc, Msg **msg);
253 
254 /*
255  * Interface to Sema SMS centers using OIS 5.0.
256  * Interface to Sema SMS centers using SM2000
257  */
258 SMSCenter *ois_open(int receiveport, const char *hostname, int port,
259  int debug_level);
260 int ois_reopen(SMSCenter *smsc);
261 int ois_close(SMSCenter *smsc);
263 int ois_submit_msg(SMSCenter *smsc, const Msg *msg);
264 int ois_receive_msg(SMSCenter *smsc, Msg **msg);
265 void ois_delete_queue(SMSCenter *smsc);
266 
267 #endif
int ois_receive_msg(SMSCenter *smsc, Msg **msg)
Definition: smsc_ois.c:396
int ois_ack_debt
Definition: smsc_p.h:174
int sema_reopen(SMSCenter *smsc)
Definition: smsc_sema.c:162
int cimd_receive_msg(SMSCenter *smsc, Msg **msg)
Definition: smsc_cimd.c:470
static long our_port
Definition: radius_acct.c:87
Definition: http.c:1998
int sema_receive_msg(SMSCenter *smsc, Msg **msg)
Definition: smsc_sema.c:323
int emi_receive_msg(SMSCenter *smsc, Msg **msg)
Definition: smsc_emi_x25.c:408
size_t bufsize
Definition: smsc_p.h:185
SMSCenter * emi_open_ip(char *hostname, int port, char *username, char *password, int receive_port, char *allow_ip, int our_port)
volatile sig_atomic_t killed
Definition: smsc_p.h:112
int id
Definition: smsc_p.h:97
FILE * emi_fp
Definition: smsc_p.h:146
struct sema_msglist * sema_mo
Definition: smsc_p.h:166
int ois_pending_smsmessage(SMSCenter *smsc)
Definition: smsc_ois.c:318
char * preferred_prefix
Definition: smsc_p.h:100
char * emi_password
Definition: smsc_p.h:152
size_t ois_bufsize
Definition: smsc_p.h:179
int ois_submit_msg(SMSCenter *smsc, const Msg *msg)
Definition: smsc_ois.c:346
int ois_flags
Definition: smsc_p.h:175
int sema_fd
Definition: smsc_p.h:167
char * emi_hostname
Definition: smsc_p.h:149
SMSCenter * emi_open(char *phonenum, char *serialdevice, char *username, char *password)
Definition: smsc_emi_x25.c:153
size_t buflen
Definition: smsc_p.h:186
char * serialdevice
Definition: smsc_p.h:127
Mutex * mutex
Definition: smsc_p.h:109
int ois_reopen(SMSCenter *smsc)
Definition: smsc_ois.c:287
char * pipe_command
Definition: smsc_p.h:134
SMSCenter * sema_open(char *smscnua, char *homenua, char *serialdevice, int waitreport)
Definition: smsc_sema.c:113
int emi_pending_smsmessage(SMSCenter *smsc)
Definition: smsc_emi_x25.c:319
char * x31_phonenum
Definition: smsc_p.h:130
int cimd_close(SMSCenter *smsc)
Definition: smsc_cimd.c:228
void * ois_received_mo
Definition: smsc_p.h:173
int receive_port
Definition: smsc_p.h:123
int cimd_pending_smsmessage(SMSCenter *smsc)
Definition: smsc_cimd.c:264
unsigned char * username
Definition: test_cimd2.c:99
int sema_submit_msg(SMSCenter *smsc, Msg *msg)
Definition: smsc_sema.c:210
int emi_close(SMSCenter *smsc)
Definition: smsc_emi_x25.c:194
int sema_pending_smsmessage(SMSCenter *smsc)
Definition: smsc_sema.c:365
void smscenter_destruct(SMSCenter *smsc)
Definition: smsc.c:168
int emi_secondary_fd
Definition: smsc_p.h:159
unsigned char * password
Definition: test_cimd2.c:100
Definition: msg.h:79
int smscenter_receive_msg(SMSCenter *smsc, Msg **msg)
Definition: smsc.c:251
int port
Definition: smsc_p.h:122
int ois_listening_socket
Definition: smsc_p.h:176
char * x31_serialdevice
Definition: smsc_p.h:131
int cimd_config_bits
Definition: smsc_p.h:142
char * allowed_prefix
Definition: smsc_p.h:101
char * emi_phonenum
Definition: smsc_p.h:147
void ois_delete_queue(SMSCenter *smsc)
Definition: smsc_ois.c:423
int sema_close(SMSCenter *smsc)
Definition: smsc_sema.c:199
Octstr * sender_prefix
Definition: smsc_p.h:181
int emi_backup_fd
Definition: smsc_p.h:155
char * emi_username
Definition: smsc_p.h:151
Octstr * hostname
Definition: fakewap.c:232
int emi_submit_msg(SMSCenter *smsc, Msg *msg)
Definition: smsc_emi_x25.c:372
char * phonenum
Definition: smsc_p.h:126
char * sema_smscnua
Definition: smsc_p.h:163
SMSCenter * cimd_open(char *hostname, int port, char *username, char *password)
Definition: smsc_cimd.c:174
int cimd_reopen(SMSCenter *smsc)
Definition: smsc_cimd.c:210
void smscenter_remove_from_buffer(SMSCenter *smsc, size_t n)
Definition: smsc.c:412
char * emi_serialdevice
Definition: smsc_p.h:148
char * denied_prefix
Definition: smsc_p.h:102
int smscenter_pending_smsmessage(SMSCenter *smsc)
Definition: smsc.c:302
int emi_close_ip(SMSCenter *smsc)
Definition: smsc_emi_x25.c:302
static Octstr * allow_ip
Definition: bb_udp.c:111
int socket
Definition: smsc_p.h:115
char * sema_serialdevice
Definition: smsc_p.h:165
int emi_reopen_ip(SMSCenter *smsc)
Definition: smsc_emi_x25.c:294
int ois_close(SMSCenter *smsc)
Definition: smsc_ois.c:263
int transport
Definition: smsc_p.h:94
struct sema_msglist * sema_mt
Definition: smsc_p.h:166
size_t ois_buflen
Definition: smsc_p.h:180
int cimd_port
Definition: smsc_p.h:138
Definition: octstr.c:118
char * ois_buffer
Definition: smsc_p.h:178
char * emi_backup_allow_ip
Definition: smsc_p.h:157
char * cimd_hostname
Definition: smsc_p.h:137
time_t ois_alive2
Definition: smsc_p.h:172
time_t emi_last_spoke
Definition: smsc_p.h:154
char * sema_homenua
Definition: smsc_p.h:164
int type
Definition: smsc_p.h:93
char * buffer
Definition: smsc_p.h:184
char * cimd_username
Definition: smsc_p.h:139
long alt_charset
Definition: smsc_p.h:106
SMSCenter * smscenter_construct(void)
Definition: smsc.c:101
Definition: thread.h:76
int emi_fd
Definition: smsc_p.h:145
int cimd_submit_msg(SMSCenter *smsc, Msg *msg)
Definition: smsc_cimd.c:358
SMSCenter * ois_open(int receiveport, const char *hostname, int port, int debug_level)
Definition: smsc_ois.c:222
int emi_our_port
Definition: smsc_p.h:158
int smscenter_read_into_buffer(SMSCenter *)
Definition: smsc.c:348
char name[1024]
Definition: smsc_p.h:96
int emi_reopen(SMSCenter *smsc)
Definition: smsc_emi_x25.c:183
char * hostname
Definition: smsc_p.h:121
char * cimd_password
Definition: smsc_p.h:140
int ois_socket
Definition: smsc_p.h:177
int emi_backup_port
Definition: smsc_p.h:156
int smscenter_submit_msg(SMSCenter *smsc, Msg *msg)
Definition: smsc.c:209
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
int keepalive
Definition: smsc_p.h:118
int emi_current_msg_number
Definition: smsc_p.h:153
time_t ois_alive
Definition: smsc_p.h:171
time_t cimd_last_spoke
Definition: smsc_p.h:141
int emi_port
Definition: smsc_p.h:150
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.