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

sms.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  * sms.h - definitions specific to SMS but not particular to any SMSC protocol.
00059  *
00060  * Sms features that are currently implemented separately in each protocol 
00061  * should be extracted and placed here.
00062  */
00063 
00064 /*
00065  * DCS Encoding, acording to ETSI 03.38 v7.2.0
00066  *
00067  * 00abcdef
00068  *      bit 5 (a) indicates compressed text
00069  *      bit 4 (b) indicates Message Class value presence
00070  *      bits 3,2 (c,d) indicates Data Coding (00=7bit, 01=8bit, 10=UCS-2)
00071  *      bits 1,0 (e,f) indicates Message Class, if bit 4(b) is active
00072  *
00073  * 11110abc
00074  *      bit 2 (a) indicates 0=7bit, 1=8bit
00075  *      bits 1,0 (b,c) indicates Message Class
00076  *
00077  * 11abc0de
00078  *      bits 5,4 (a,b) indicates 00=discard message, 01=store message
00079  *                               10=store message and text is UCS-2
00080  *      bit 3 (c) indicates indication active
00081  *      bits 1,0 (d,e) indicates indicator (00=voice mail, 01=fax,
00082  *                                          10=email, 11=other)
00083  */
00084 
00085 
00086 #ifndef SMS_H
00087 #define SMS_H
00088 
00089 #include "msg.h"
00090 
00091 #define SMS_PARAM_UNDEFINED  MSG_PARAM_UNDEFINED
00092 
00093 #define MC_UNDEF   SMS_PARAM_UNDEFINED
00094 #define MC_CLASS0  0
00095 #define MC_CLASS1  1
00096 #define MC_CLASS2  2
00097 #define MC_CLASS3  3
00098 
00099 #define MWI_UNDEF      SMS_PARAM_UNDEFINED
00100 #define MWI_VOICE_ON   0
00101 #define MWI_FAX_ON     1
00102 #define MWI_EMAIL_ON   2
00103 #define MWI_OTHER_ON   3
00104 #define MWI_VOICE_OFF  4
00105 #define MWI_FAX_OFF    5
00106 #define MWI_EMAIL_OFF  6
00107 #define MWI_OTHER_OFF  7
00108 
00109 #define DC_UNDEF  SMS_PARAM_UNDEFINED
00110 #define DC_7BIT   0
00111 #define DC_8BIT   1
00112 #define DC_UCS2   2
00113 
00114 #define COMPRESS_UNDEF  SMS_PARAM_UNDEFINED
00115 #define COMPRESS_OFF    0
00116 #define COMPRESS_ON     1
00117 
00118 #define RPI_UNDEF  SMS_PARAM_UNDEFINED
00119 #define RPI_OFF    0
00120 #define RPI_ON     1
00121 
00122 #define SMS_7BIT_MAX_LEN 160
00123 #define SMS_8BIT_MAX_LEN 140
00124 #define SMS_UCS2_MAX_LEN 70
00125 /*
00126  * Maximum number of octets in an SMS message. Note that this is 8 bit
00127  * characters, not 7 bit characters.
00128  */
00129 #define MAX_SMS_OCTETS 140
00130 
00131 /* Encode DCS using sms fields
00132  * mode = 0= encode using 00xxxxxx, 1= encode using 1111xxxx mode
00133  */
00134 int fields_to_dcs(Msg *msg, int mode);
00135 
00136 
00137 /*
00138  * Decode DCS to sms fields
00139  *  returns 0 if dcs is invalid
00140  */
00141 int dcs_to_fields(Msg **msg, int mode);
00142 
00143 
00144 /*
00145  * Compute length of the message data in Msg after it will be converted 
00146  * to the proper coding. 
00147  * If coding is 7 bit, then sms_msgdata_len will return the number of 
00148  * septets this message will convert to, taking into account GSM 03.38
00149  * escape sequences of special chars, which would count as two septets.
00150  */
00151 int sms_msgdata_len(Msg *msg);
00152 
00153 
00154 /*
00155  * Swap an MO message to an MT message (hence swap receiver/sender addresses)
00156  * and vice versa for internal bearerbox rerouting (if needed).
00157  * Returns 1 if successfull, 0 otherwise.
00158  */
00159 int sms_swap(Msg *msg);
00160 
00161 
00162 /*
00163  *
00164  * Split an SMS message into smaller ones.
00165  *
00166  * The original SMS message is represented as an Msg object, and the
00167  * resulting list of smaller ones is represented as a List of Msg objects.
00168  * A plain text header and/or footer can be added to each part, and an
00169  * additional suffix can be added to each part except the last one.
00170  * Optionally, a UDH prefix can be added to each part so that phones
00171  * that understand this prefix can join the messages into one large one
00172  * again. At most `max_messages' parts will be generated; surplus text
00173  * from the original message will be silently ignored.
00174  *
00175  * If the original message has UDH, they will be duplicated in each part.
00176  * It is an error to use catenation and UDH together, or catenation and 7
00177  * bit mode toghether; in these cases, catenation is silently ignored.
00178  *
00179  * If `catenate' is true, `msg_sequence' is used as the sequence number for
00180  * the logical message. The catenation UDH contain three numbers: the
00181  * concatenated message reference, which is constant for all parts of
00182  * the logical message, the total number of parts in the logical message,
00183  * and the sequence number of the current part.
00184  *
00185  * Note that `msg_sequence' must have a value in the range 0..255.
00186  *
00187  * `max_octets' gives the maximum number of octets in on message, including
00188  * UDH, and after 7 bit characters have been packed into octets.
00189  */
00190 List *sms_split(Msg *orig, Octstr *header, Octstr *footer,
00191                 Octstr *nonlast_suffix, Octstr *split_chars, int catenate,
00192                 unsigned long msg_sequence, int max_messages, int max_octets);
00193 
00198 int sms_priority_compare(const void *a, const void *b);
00199 
00200 #endif
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.