Kannel: Open Source WAP and SMS gateway  svn-r5335
smpp_pdu.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  * smpp_pdu.h - declarations for SMPP PDUs
59  *
60  * Lars Wirzenius
61  * Alexander Malysh <a.malysh@centrium.de>:
62  * Extended optional parameters implementation.
63  */
64 
65 
66 #ifndef SMPP_PDU_H
67 #define SMPP_PDU_H
68 
69 
70 #include "gwlib/gwlib.h"
71 #include "gwlib/dict.h"
72 
73 
74 enum {
75  #define OPTIONAL_BEGIN
76  #define TLV_INTEGER(name, max_len)
77  #define TLV_NULTERMINATED(name, max_len)
78  #define TLV_OCTETS(name, min_len, max_len)
79  #define OPTIONAL_END
80  #define INTEGER(name, octets)
81  #define NULTERMINATED(name, max_octets)
82  #define OCTETS(name, field_giving_octets)
83  #define PDU(name, id, fields) name = id,
84  #include "smpp_pdu.def"
85  SMPP_PDU_DUMMY_TYPE
86 };
87 
88 
89 typedef struct SMPP_PDU SMPP_PDU;
90 struct SMPP_PDU {
91  unsigned long type;
92  const char *type_name;
93  union {
94  #define OPTIONAL_BEGIN
95  #define TLV_INTEGER(name, octets) long name;
96  #define TLV_NULTERMINATED(name, max_len) Octstr *name;
97  #define TLV_OCTETS(name, min_len, max_len) Octstr *name;
98  #define OPTIONAL_END Dict *tlv;
99  #define INTEGER(name, octets) unsigned long name;
100  #define NULTERMINATED(name, max_octets) Octstr *name;
101  #define OCTETS(name, field_giving_octets) Octstr *name;
102  #define PDU(name, id, fields) struct name { fields } name;
103  #include "smpp_pdu.def"
104  } u;
105 };
106 
107 
108 /******************************************************************************
109 * Numbering Plan Indicator and Type of Number codes from
110 * GSM 03.40 Version 5.3.0 Section 9.1.2.5.
111 * http://www.etsi.org/
112 */
113 #define GSM_ADDR_TON_UNKNOWN 0x00000000
114 #define GSM_ADDR_TON_INTERNATIONAL 0x00000001
115 #define GSM_ADDR_TON_NATIONAL 0x00000002
116 #define GSM_ADDR_TON_NETWORKSPECIFIC 0x00000003
117 #define GSM_ADDR_TON_SUBSCRIBER 0x00000004
118 #define GSM_ADDR_TON_ALPHANUMERIC 0x00000005 /* GSM TS 03.38 */
119 #define GSM_ADDR_TON_ABBREVIATED 0x00000006
120 #define GSM_ADDR_TON_EXTENSION 0x00000007 /* Reserved */
121 
122 #define GSM_ADDR_NPI_UNKNOWN 0x00000000
123 #define GSM_ADDR_NPI_E164 0x00000001
124 #define GSM_ADDR_NPI_X121 0x00000003
125 #define GSM_ADDR_NPI_TELEX 0x00000004
126 #define GSM_ADDR_NPI_NATIONAL 0x00000008
127 #define GSM_ADDR_NPI_PRIVATE 0x00000009
128 #define GSM_ADDR_NPI_ERMES 0x0000000A /* ETSI DE/PS 3 01-3 */
129 #define GSM_ADDR_NPI_INTERNET 0x0000000E /* SMPP v5.0, sec. 4.7.2, page 113 */
130 #define GSM_ADDR_NPI_EXTENSION 0x0000000F /* Reserved */
131 #define GSM_ADDR_NPI_WAP_CLIENT_ID 0x00000012 /* SMPP v5.0, sec. 4.7.2, page 113 */
132 
133 /******************************************************************************
134  * esm_class parameters for both submit_sm and deliver_sm PDUs
135  */
136 #define ESM_CLASS_SUBMIT_DEFAULT_SMSC_MODE 0x00000000
137 #define ESM_CLASS_SUBMIT_DATAGRAM_MODE 0x00000001
138 #define ESM_CLASS_SUBMIT_FORWARD_MODE 0x00000002
139 #define ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE 0x00000003
140 #define ESM_CLASS_SUBMIT_DELIVERY_ACK 0x00000008
141 #define ESM_CLASS_SUBMIT_USER_ACK 0x00000010
142 #define ESM_CLASS_SUBMIT_UDH_INDICATOR 0x00000040
143 #define ESM_CLASS_SUBMIT_RPI 0x00000080
144 #define ESM_CLASS_SUBMIT_UDH_AND_RPI 0x000000C0
145 
146 #define ESM_CLASS_DELIVER_DEFAULT_TYPE 0x00000000
147 #define ESM_CLASS_DELIVER_SMSC_DELIVER_ACK 0x00000004
148 #define ESM_CLASS_DELIVER_SME_DELIVER_ACK 0x00000008
149 #define ESM_CLASS_DELIVER_SME_MANULAL_ACK 0x00000010
150 #define ESM_CLASS_DELIVER_INTERM_DEL_NOTIFICATION 0x00000020
151 #define ESM_CLASS_DELIVER_UDH_INDICATOR 0x00000040
152 #define ESM_CLASS_DELIVER_RPI 0x00000080
153 #define ESM_CLASS_DELIVER_UDH_AND_RPI 0x000000C0
154 
155 
156 /*
157  * Some SMPP error messages we come across
158  */
160  SMPP_ESME_ROK = 0x00000000,
161  SMPP_ESME_RINVMSGLEN = 0x00000001,
162  SMPP_ESME_RINVCMDLEN = 0x00000002,
163  SMPP_ESME_RINVCMDID = 0x00000003,
164  SMPP_ESME_RINVBNDSTS = 0x00000004,
165  SMPP_ESME_RALYBND = 0x00000005,
166  SMPP_ESME_RINVPRTFLG = 0x00000006,
168  SMPP_ESME_RSYSERR = 0x00000008,
169  SMPP_ESME_RINVSRCADR = 0x0000000A,
170  SMPP_ESME_RINVDSTADR = 0x0000000B,
171  SMPP_ESME_RINVMSGID = 0x0000000C,
172  SMPP_ESME_RBINDFAIL = 0x0000000D,
173  SMPP_ESME_RINVPASWD = 0x0000000E,
174  SMPP_ESME_RINVSYSID = 0x0000000F,
175  SMPP_ESME_RCANCELFAIL = 0x00000011,
177  SMPP_ESME_RMSGQFUL = 0x00000014,
178  SMPP_ESME_RINVSERTYP = 0x00000015,
180  SMPP_ESME_RINVDLNAME = 0x00000034,
182  SMPP_ESME_RINVSUBREP = 0x00000042,
184  SMPP_ESME_RCNTSUBDL = 0x00000044,
185  SMPP_ESME_RSUBMITFAIL = 0x00000045,
186  SMPP_ESME_RINVSRCTON = 0x00000048,
187  SMPP_ESME_RINVSRCNPI = 0x00000049,
188  SMPP_ESME_RINVDSTTON = 0x00000050,
189  SMPP_ESME_RINVDSTNPI = 0x00000051,
190  SMPP_ESME_RINVSYSTYP = 0x00000053,
191  SMPP_ESME_RINVREPFLAG = 0x00000054,
192  SMPP_ESME_RINVNUMMSGS = 0x00000055,
193  SMPP_ESME_RTHROTTLED = 0x00000058,
194  SMPP_ESME_RINVSCHED = 0x00000061,
195  SMPP_ESME_RINVEXPIRY = 0x00000062,
197  SMPP_ESME_RX_T_APPN = 0x00000064,
198  SMPP_ESME_RX_P_APPN = 0x00000065,
199  SMPP_ESME_RX_R_APPN = 0x00000066,
200  SMPP_ESME_RQUERYFAIL = 0x00000067,
203  SMPP_ESME_RINVTLVLEN = 0x000000C2,
204  SMPP_ESME_RMISSINGTLV = 0x000000C3,
205  SMPP_ESME_RINVTLVVAL = 0x000000C4,
207  SMPP_ESME_RUNKNOWNERR = 0x000000FF,
209  SMPP_ESME_RPROHIBITED = 0x00000101,
212  SMPP_ESME_RINVDCS = 0x00000104,
221  SMPP_ESME_RBCASTFAIL = 0x0000010D,
227 };
228 
229 /* initialize SMPP PDU */
230 int smpp_pdu_init(Cfg *cfg);
231 /* shutdown SMPP PDU */
232 int smpp_pdu_shutdown(void);
233 
234 SMPP_PDU *smpp_pdu_create(unsigned long type, unsigned long seq_no);
235 void smpp_pdu_destroy(SMPP_PDU *pdu);
236 int smpp_pdu_is_valid(SMPP_PDU *pdu); /* XXX */
238 SMPP_PDU *smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len);
239 void smpp_pdu_dump(Octstr *smsc_id, SMPP_PDU *pdu);
241 
242 long smpp_pdu_read_len(Connection *conn);
243 Octstr *smpp_pdu_read_data(Connection *conn, long len);
244 
245 /*
246  * Return error string for given error code
247  */
249 
250 /* add constant TLVs to TLV dictionary */
252 
253 #endif
void smpp_pdu_dump_line(Octstr *smsc_id, SMPP_PDU *pdu)
Definition: smpp_pdu.c:816
void error(int err, const char *fmt,...)
Definition: log.c:648
SMPP_PDU * smpp_pdu_create(unsigned long type, unsigned long seq_no)
Definition: smpp_pdu.c:400
const char * type_name
Definition: smpp_pdu.h:92
int type
Definition: smsc_cimd2.c:215
unsigned long type
Definition: smpp_pdu.h:91
static Cfg * cfg
Definition: opensmppbox.c:95
void smpp_tlv_add_constant(Octstr *smsc_id, Dict **tlvs)
Definition: smpp_pdu.c:102
long smpp_pdu_read_len(Connection *conn)
Definition: smpp_pdu.c:869
void smpp_pdu_destroy(SMPP_PDU *pdu)
Definition: smpp_pdu.c:434
Definition: cfg.c:164
int smpp_pdu_is_valid(SMPP_PDU *pdu)
Octstr * smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu)
Definition: smpp_pdu.c:458
SMPP_PDU * smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len)
Definition: smpp_pdu.c:597
void smpp_pdu_dump(Octstr *smsc_id, SMPP_PDU *pdu)
Definition: smpp_pdu.c:766
Definition: dict.c:116
static Octstr * smsc_id
Definition: mtbatch.c:98
int smpp_pdu_init(Cfg *cfg)
Definition: smpp_pdu.c:184
Octstr * smpp_pdu_read_data(Connection *conn, long len)
Definition: smpp_pdu.c:895
union SMPP_PDU::@15 u
Definition: octstr.c:118
const char * smpp_error_to_string(enum SMPP_ERROR_MESSAGES error)
Definition: smpp_pdu.c:911
SMPP_ERROR_MESSAGES
Definition: smpp_pdu.h:159
static List * tlvs
Definition: smpp_pdu.c:88
int smpp_pdu_shutdown(void)
Definition: smpp_pdu.c:314
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.