Kannel: Open Source WAP and SMS gateway  svn-r5335
sms.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2018 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  * sms.h - definitions specific to SMS but not particular to any SMSC protocol.
59  *
60  * Sms features that are currently implemented separately in each protocol
61  * should be extracted and placed here.
62  */
63 
64 /*
65  * DCS Encoding, acording to ETSI 03.38 v7.2.0
66  *
67  * 00abcdef
68  * bit 5 (a) indicates compressed text
69  * bit 4 (b) indicates Message Class value presence
70  * bits 3,2 (c,d) indicates Data Coding (00=7bit, 01=8bit, 10=UCS-2)
71  * bits 1,0 (e,f) indicates Message Class, if bit 4(b) is active
72  *
73  * 11110abc
74  * bit 2 (a) indicates 0=7bit, 1=8bit
75  * bits 1,0 (b,c) indicates Message Class
76  *
77  * 11abc0de
78  * bits 5,4 (a,b) indicates 00=discard message, 01=store message
79  * 10=store message and text is UCS-2
80  * bit 3 (c) indicates indication active
81  * bits 1,0 (d,e) indicates indicator (00=voice mail, 01=fax,
82  * 10=email, 11=other)
83  */
84 
85 
86 #ifndef SMS_H
87 #define SMS_H
88 
89 #include "msg.h"
90 
91 #define SMS_PARAM_UNDEFINED MSG_PARAM_UNDEFINED
92 
93 #define MC_UNDEF SMS_PARAM_UNDEFINED
94 #define MC_CLASS0 0
95 #define MC_CLASS1 1
96 #define MC_CLASS2 2
97 #define MC_CLASS3 3
98 
99 #define MWI_UNDEF SMS_PARAM_UNDEFINED
100 #define MWI_VOICE_ON 0
101 #define MWI_FAX_ON 1
102 #define MWI_EMAIL_ON 2
103 #define MWI_OTHER_ON 3
104 #define MWI_VOICE_OFF 4
105 #define MWI_FAX_OFF 5
106 #define MWI_EMAIL_OFF 6
107 #define MWI_OTHER_OFF 7
108 
109 #define DC_UNDEF SMS_PARAM_UNDEFINED
110 #define DC_7BIT 0
111 #define DC_8BIT 1
112 #define DC_UCS2 2
113 
114 #define COMPRESS_UNDEF SMS_PARAM_UNDEFINED
115 #define COMPRESS_OFF 0
116 #define COMPRESS_ON 1
117 
118 #define RPI_UNDEF SMS_PARAM_UNDEFINED
119 #define RPI_OFF 0
120 #define RPI_ON 1
121 
122 #define SMS_7BIT_MAX_LEN 160
123 #define SMS_8BIT_MAX_LEN 140
124 #define SMS_UCS2_MAX_LEN 70
125 /*
126  * Maximum number of octets in an SMS message. Note that this is 8 bit
127  * characters, not 7 bit characters.
128  */
129 #define MAX_SMS_OCTETS 140
130 
131 /* Encode DCS using sms fields
132  * mode = 0= encode using 00xxxxxx, 1= encode using 1111xxxx mode
133  */
134 int fields_to_dcs(Msg *msg, int mode);
135 
136 
137 /*
138  * Decode DCS to sms fields
139  * returns 0 if dcs is invalid
140  */
141 int dcs_to_fields(Msg **msg, int mode);
142 
143 
144 /*
145  * Compute length of the message data in Msg after it will be converted
146  * to the proper coding.
147  * If coding is 7 bit, then sms_msgdata_len will return the number of
148  * septets this message will convert to, taking into account GSM 03.38
149  * escape sequences of special chars, which would count as two septets.
150  */
151 int sms_msgdata_len(Msg *msg);
152 
153 
154 /*
155  * Swap an MO message to an MT message (hence swap receiver/sender addresses)
156  * and vice versa for internal bearerbox rerouting (if needed).
157  * Returns 1 if successfull, 0 otherwise.
158  */
159 int sms_swap(Msg *msg);
160 
161 
162 /*
163  *
164  * Split an SMS message into smaller ones.
165  *
166  * The original SMS message is represented as an Msg object, and the
167  * resulting list of smaller ones is represented as a List of Msg objects.
168  * A plain text header and/or footer can be added to each part, and an
169  * additional suffix can be added to each part except the last one.
170  * Optionally, a UDH prefix can be added to each part so that phones
171  * that understand this prefix can join the messages into one large one
172  * again. At most `max_messages' parts will be generated; surplus text
173  * from the original message will be silently ignored.
174  *
175  * If the original message has UDH, they will be duplicated in each part.
176  * It is an error to use catenation and UDH together, or catenation and 7
177  * bit mode toghether; in these cases, catenation is silently ignored.
178  *
179  * If `catenate' is true, `msg_sequence' is used as the sequence number for
180  * the logical message. The catenation UDH contain three numbers: the
181  * concatenated message reference, which is constant for all parts of
182  * the logical message, the total number of parts in the logical message,
183  * and the sequence number of the current part.
184  *
185  * Note that `msg_sequence' must have a value in the range 0..255.
186  *
187  * `max_octets' gives the maximum number of octets in on message, including
188  * UDH, and after 7 bit characters have been packed into octets.
189  */
190 List *sms_split(Msg *orig, Octstr *header, Octstr *footer,
191  Octstr *nonlast_suffix, Octstr *split_chars, int catenate,
192  unsigned long msg_sequence, int max_messages, int max_octets);
193 
197 void prepend_catenation_udh(Msg *sms, int part_no, int num_messages, int msg_sequence);
198 
203 int sms_priority_compare(const void *a, const void *b);
204 
205 /*
206  * Re-encode an SMSmessage , based on the 'charset' that defines the content
207  * encoding and the 'coding' that defines the desired target encoding.
208  * Return 0 on success, -1 otherwise.
209  */
211 
212 #endif
static long num_messages
Definition: test_smsc.c:90
static int coding
Definition: mtbatch.c:102
int sms_charset_processing(Octstr *charset, Octstr *body, int coding)
Definition: sms.c:419
Octstr * charset
Definition: test_ota.c:68
int sms_msgdata_len(Msg *msg)
Definition: sms.c:180
Definition: msg.h:79
int sms_swap(Msg *msg)
Definition: sms.c:201
int fields_to_dcs(Msg *msg, int mode)
Definition: sms.c:73
long max_messages
Definition: wapbox.c:116
int dcs_to_fields(Msg **msg, int mode)
Definition: sms.c:139
Definition: octstr.c:118
void prepend_catenation_udh(Msg *sms, int part_no, int num_messages, int msg_sequence)
Definition: sms.c:224
List * sms_split(Msg *orig, Octstr *header, Octstr *footer, Octstr *nonlast_suffix, Octstr *split_chars, int catenate, unsigned long msg_sequence, int max_messages, int max_octets)
Definition: sms.c:309
Definition: list.c:102
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
int sms_priority_compare(const void *a, const void *b)
Definition: sms.c:395
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.