Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

smsc_p.h

Go to the documentation of this file.
00001 /* ==================================================================== 
00002  * The Kannel Software License, Version 1.0 
00003  * 
00004  * Copyright (c) 2001-2008 Kannel Group  
00005  * Copyright (c) 1998-2001 WapIT Ltd.   
00006  * All rights reserved. 
00007  * 
00008  * Redistribution and use in source and binary forms, with or without 
00009  * modification, are permitted provided that the following conditions 
00010  * are met: 
00011  * 
00012  * 1. Redistributions of source code must retain the above copyright 
00013  *    notice, this list of conditions and the following disclaimer. 
00014  * 
00015  * 2. Redistributions in binary form must reproduce the above copyright 
00016  *    notice, this list of conditions and the following disclaimer in 
00017  *    the documentation and/or other materials provided with the 
00018  *    distribution. 
00019  * 
00020  * 3. The end-user documentation included with the redistribution, 
00021  *    if any, must include the following acknowledgment: 
00022  *       "This product includes software developed by the 
00023  *        Kannel Group (http://www.kannel.org/)." 
00024  *    Alternately, this acknowledgment may appear in the software itself, 
00025  *    if and wherever such third-party acknowledgments normally appear. 
00026  * 
00027  * 4. The names "Kannel" and "Kannel Group" must not be used to 
00028  *    endorse or promote products derived from this software without 
00029  *    prior written permission. For written permission, please  
00030  *    contact org@kannel.org. 
00031  * 
00032  * 5. Products derived from this software may not be called "Kannel", 
00033  *    nor may "Kannel" appear in their name, without prior written 
00034  *    permission of the Kannel Group. 
00035  * 
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00039  * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
00040  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
00041  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
00042  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
00043  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
00044  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
00045  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
00046  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00047  * ==================================================================== 
00048  * 
00049  * This software consists of voluntary contributions made by many 
00050  * individuals on behalf of the Kannel Group.  For more information on  
00051  * the Kannel Group, please see <http://www.kannel.org/>. 
00052  * 
00053  * Portions of this software are based upon software originally written at  
00054  * WapIT Ltd., Helsinki, Finland for the Kannel project.  
00055  */ 
00056 
00057 /*
00058  * smsc_p.h - private interface to SMS center subsystem
00059  *
00060  * Lars Wirzenius
00061  *
00062  * New API by Kalle Marjola 1999
00063  */
00064 
00065 #ifndef SMSC_P_H
00066 #define SMSC_P_H
00067 
00068 
00069 #include <stddef.h>
00070 #include <stdio.h>
00071 #include <signal.h>
00072 #include <time.h>
00073 
00074 #include "smsc.h"
00075 
00076 /*
00077  * List of SMS center types that we support.
00078  */
00079 enum {
00080     SMSC_TYPE_DELETED,
00081     SMSC_TYPE_CIMD,
00082     SMSC_TYPE_EMI_X25,
00083     SMSC_TYPE_SEMA_X28,
00084     SMSC_TYPE_OIS,
00085 };
00086 
00087 /*
00088  * The implementation of the SMSCenter object. 
00089  */
00090 #define DIAL_PREFIX_MAX_LEN 1024
00091 struct SMSCenter {
00092 
00093     int type;
00094     int transport;
00095     
00096     char name[1024];
00097     int id;
00098 
00099         /* Routing prefixes (based on phone number) */
00100     char *preferred_prefix;
00101     char *allowed_prefix;
00102     char *denied_prefix;
00103 
00104 
00105     /* Alternative charset */
00106         long alt_charset;
00107 
00108     /* For locking/unlocking. */
00109     Mutex *mutex;
00110 
00111         /* for dying */
00112         volatile sig_atomic_t killed;
00113 
00114     /* General IO device */
00115     int socket;
00116 
00117     /* Maximum minutes idle time before ping is sent. 0 for no pings. */
00118     int keepalive;
00119 
00120     /* TCP/IP */
00121     char *hostname;
00122     int port;
00123         int receive_port; /* if used, with EMI 2.0/OIS 4.5 */
00124     
00125     /* PSTN/ISDN */
00126     char *phonenum;
00127     char *serialdevice;
00128 
00129     /* X.31 */
00130     char *x31_phonenum;
00131     char *x31_serialdevice;
00132 
00133     /* Unix pipes */
00134     char *pipe_command;
00135 
00136     /* CIMD */
00137     char *cimd_hostname;
00138     int cimd_port;
00139     char *cimd_username;
00140     char *cimd_password;
00141     time_t cimd_last_spoke;
00142     int cimd_config_bits;
00143 
00144     /* EMI_X25 */
00145     int emi_fd;
00146     FILE *emi_fp;
00147     char *emi_phonenum;
00148     char *emi_serialdevice;
00149     char *emi_hostname;
00150     int  emi_port;
00151     char *emi_username;
00152     char *emi_password;
00153     int emi_current_msg_number;
00154     time_t emi_last_spoke;
00155     int emi_backup_fd;
00156         int emi_backup_port;        /* different one! rename! */
00157         char *emi_backup_allow_ip;     
00158         int emi_our_port;       /* port to bind us when connecting smsc */
00159         int emi_secondary_fd;
00160 
00161         /* SEMA SMS2000 OIS 4.5 X28 */
00162 
00163         char * sema_smscnua;
00164         char * sema_homenua;
00165         char * sema_serialdevice;
00166         struct sema_msglist *sema_mt, *sema_mo;
00167         int sema_fd;
00168 
00169         /* SEMA SMS2000 OIS 5.0 (TCP/IP to X.25 router) */
00170 
00171         time_t ois_alive;
00172         time_t ois_alive2;
00173         void *ois_received_mo;
00174         int ois_ack_debt;
00175         int ois_flags;
00176         int ois_listening_socket;
00177         int ois_socket;
00178         char *ois_buffer;
00179         size_t ois_bufsize;
00180         size_t ois_buflen;
00181         Octstr *sender_prefix;
00182 
00183     /* For buffering input. */
00184     char *buffer;
00185     size_t bufsize;
00186     size_t buflen;
00187 };
00188 
00189 
00190 /*
00191  * Operations on an SMSCenter object.
00192  */
00193 SMSCenter *smscenter_construct(void);
00194 void smscenter_destruct(SMSCenter *smsc);
00195 int smscenter_read_into_buffer(SMSCenter *);
00196 void smscenter_remove_from_buffer(SMSCenter *smsc, size_t n);
00197 
00198 /* Send an SMS message via an SMS center. Return -1 for error,
00199    0 for OK. */
00200 int smscenter_submit_msg(SMSCenter *smsc, Msg *msg);
00201 
00202 
00203 /* Receive an SMS message from an SMS center. Return -1 for error,
00204    0 end of messages (other end closed their end of the connection),
00205    or 1 for a message was received. If a message was received, a 
00206    pointer to it is returned via `*msg'. Note that this operation
00207    blocks until there is a message. */
00208 int smscenter_receive_msg(SMSCenter *smsc, Msg **msg);
00209 
00210 
00211 /* Is there an SMS message pending from an SMS center? Return -1 for
00212    error, 0 for no, 1 for yes. This operation won't block, but may
00213    not be instantaneous, if it has to read a few characters to see
00214    if there is a message. Use smscenter_receive_smsmessage to actually receive
00215    the message. */
00216 int smscenter_pending_smsmessage(SMSCenter *smsc);
00217 
00218 
00219 /*
00220  * Interface to Nokia SMS centers using CIMD.
00221  */
00222 SMSCenter *cimd_open(char *hostname, int port, char *username, char *password);
00223 int cimd_reopen(SMSCenter *smsc);
00224 int cimd_close(SMSCenter *smsc);
00225 int cimd_pending_smsmessage(SMSCenter *smsc);
00226 int cimd_submit_msg(SMSCenter *smsc, Msg *msg);
00227 int cimd_receive_msg(SMSCenter *smsc, Msg **msg);
00228 
00229 /*
00230  * Interface to CMG SMS centers using EMI_X25.
00231  */
00232 SMSCenter *emi_open(char *phonenum, char *serialdevice, char *username, char *password);
00233 int emi_reopen(SMSCenter *smsc);
00234 int emi_close(SMSCenter *smsc);
00235 SMSCenter *emi_open_ip(char *hostname, int port, char *username,
00236                char *password, int receive_port, char *allow_ip, int our_port);
00237 int emi_reopen_ip(SMSCenter *smsc);
00238 int emi_close_ip(SMSCenter *smsc);
00239 int emi_pending_smsmessage(SMSCenter *smsc);
00240 int emi_submit_msg(SMSCenter *smsc, Msg *msg);
00241 int emi_receive_msg(SMSCenter *smsc, Msg **msg);
00242 
00243 /*
00244  * Interface to Sema SMS centers using SM2000
00245  */
00246 SMSCenter *sema_open(char *smscnua,  char *homenua, char* serialdevice,
00247              int waitreport);
00248 int sema_reopen(SMSCenter *smsc);
00249 int sema_close(SMSCenter *smsc);
00250 int sema_pending_smsmessage(SMSCenter *smsc);
00251 int sema_submit_msg(SMSCenter *smsc, Msg *msg);
00252 int sema_receive_msg(SMSCenter *smsc, Msg **msg);
00253 
00254 /*
00255  * Interface to Sema SMS centers using OIS 5.0.
00256  * Interface to Sema SMS centers using SM2000
00257  */
00258 SMSCenter *ois_open(int receiveport, const char *hostname, int port,
00259             int debug_level);
00260 int ois_reopen(SMSCenter *smsc);
00261 int ois_close(SMSCenter *smsc);
00262 int ois_pending_smsmessage(SMSCenter *smsc);
00263 int ois_submit_msg(SMSCenter *smsc, const Msg *msg);
00264 int ois_receive_msg(SMSCenter *smsc, Msg **msg);
00265 void ois_delete_queue(SMSCenter *smsc);
00266 
00267 #endif
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.