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

smpp_pdu.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  * smpp_pdu.h - declarations for SMPP PDUs
00059  *
00060  * Lars Wirzenius
00061  * Alexander Malysh <a.malysh@centrium.de>:
00062  *     Extended optional parameters implementation.
00063  */
00064 
00065 
00066 #ifndef SMPP_PDU_H
00067 #define SMPP_PDU_H
00068 
00069 
00070 #include "gwlib/gwlib.h"
00071 #include "gwlib/dict.h"
00072 
00073 
00074 enum {
00075     #define OPTIONAL_BEGIN
00076     #define TLV_INTEGER(name, max_len)
00077     #define TLV_NULTERMINATED(name, max_len)
00078     #define TLV_OCTETS(name, min_len, max_len)
00079     #define OPTIONAL_END
00080     #define INTEGER(name, octets)
00081     #define NULTERMINATED(name, max_octets)
00082     #define OCTETS(name, field_giving_octets)
00083     #define PDU(name, id, fields) name = id,
00084     #include "smpp_pdu.def"
00085     SMPP_PDU_DUMMY_TYPE
00086 };
00087 
00088 
00089 typedef struct SMPP_PDU SMPP_PDU;
00090 struct SMPP_PDU {
00091     unsigned long type;
00092     const char *type_name;
00093     union {
00094         #define OPTIONAL_BEGIN
00095         #define TLV_INTEGER(name, octets) unsigned long name;
00096         #define TLV_NULTERMINATED(name, max_len) Octstr *name;
00097         #define TLV_OCTETS(name, min_len, max_len) Octstr *name;
00098         #define OPTIONAL_END
00099         #define INTEGER(name, octets) unsigned long name;
00100         #define NULTERMINATED(name, max_octets) Octstr *name;
00101         #define OCTETS(name, field_giving_octets) Octstr *name;
00102         #define PDU(name, id, fields) struct name { fields } name;
00103         #include "smpp_pdu.def"
00104     } u;
00105 };
00106 
00107 
00108 /******************************************************************************
00109 * Numering Plan Indicator and Type of Number codes from
00110 * GSM 03.40 Version 5.3.0 Section 9.1.2.5.
00111 * http://www.etsi.org/
00112 */
00113 #define GSM_ADDR_TON_UNKNOWN          0x00000000
00114 #define GSM_ADDR_TON_INTERNATIONAL    0x00000001
00115 #define GSM_ADDR_TON_NATIONAL         0x00000002
00116 #define GSM_ADDR_TON_NETWORKSPECIFIC  0x00000003
00117 #define GSM_ADDR_TON_SUBSCRIBER       0x00000004
00118 #define GSM_ADDR_TON_ALPHANUMERIC     0x00000005 /* GSM TS 03.38 */
00119 #define GSM_ADDR_TON_ABBREVIATED      0x00000006
00120 #define GSM_ADDR_TON_EXTENSION        0x00000007 /* Reserved */
00121 
00122 #define GSM_ADDR_NPI_UNKNOWN          0x00000000
00123 #define GSM_ADDR_NPI_E164             0x00000001
00124 #define GSM_ADDR_NPI_X121             0x00000003
00125 #define GSM_ADDR_NPI_TELEX            0x00000004
00126 #define GSM_ADDR_NPI_NATIONAL         0x00000008
00127 #define GSM_ADDR_NPI_PRIVATE          0x00000009
00128 #define GSM_ADDR_NPI_ERMES            0x0000000A /* ETSI DE/PS 3 01-3 */
00129 #define GSM_ADDR_NPI_EXTENSION        0x0000000F /* Reserved */
00130 
00131 /******************************************************************************
00132  * esm_class parameters for both submit_sm and deliver_sm PDUs
00133  */
00134 #define ESM_CLASS_SUBMIT_DEFAULT_SMSC_MODE        0x00000000
00135 #define ESM_CLASS_SUBMIT_DATAGRAM_MODE            0x00000001
00136 #define ESM_CLASS_SUBMIT_FORWARD_MODE             0x00000002
00137 #define ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE   0x00000003
00138 #define ESM_CLASS_SUBMIT_DELIVERY_ACK             0x00000008
00139 #define ESM_CLASS_SUBMIT_USER_ACK                 0x00000010
00140 #define ESM_CLASS_SUBMIT_UDH_INDICATOR            0x00000040
00141 #define ESM_CLASS_SUBMIT_RPI                      0x00000080
00142 #define ESM_CLASS_SUBMIT_UDH_AND_RPI              0x000000C0
00143 
00144 #define ESM_CLASS_DELIVER_DEFAULT_TYPE            0x00000000
00145 #define ESM_CLASS_DELIVER_SMSC_DELIVER_ACK        0x00000004
00146 #define ESM_CLASS_DELIVER_SME_DELIVER_ACK         0x00000008
00147 #define ESM_CLASS_DELIVER_SME_MANULAL_ACK         0x00000010
00148 #define ESM_CLASS_DELIVER_INTERM_DEL_NOTIFICATION 0x00000020
00149 #define ESM_CLASS_DELIVER_UDH_INDICATOR           0x00000040
00150 #define ESM_CLASS_DELIVER_RPI                     0x00000080
00151 #define ESM_CLASS_DELIVER_UDH_AND_RPI             0x000000C0
00152 
00153 
00154 /*
00155  * Some SMPP error messages we come across
00156  */
00157 enum SMPP_ERROR_MESSAGES {
00158     SMPP_ESME_ROK = 0x00000000,
00159     SMPP_ESME_RINVMSGLEN = 0x00000001,
00160     SMPP_ESME_RINVCMDLEN = 0x00000002,
00161     SMPP_ESME_RINVCMDID = 0x00000003,
00162     SMPP_ESME_RINVBNDSTS = 0x00000004,
00163     SMPP_ESME_RALYNBD = 0x00000005,
00164     SMPP_ESME_RINVPRTFLG = 0x00000006,
00165     SMPP_ESME_RINVREGDLVFLG = 0x00000007,
00166     SMPP_ESME_RSYSERR = 0x00000008,
00167     SMPP_ESME_RINVSRCADR = 0x0000000A,
00168     SMPP_ESME_RINVDSTADR = 0x0000000B,
00169     SMPP_ESME_RINVMSGID = 0x0000000C,
00170     SMPP_ESME_RBINDFAIL = 0x0000000D,
00171     SMPP_ESME_RINVPASWD = 0x0000000E,
00172     SMPP_ESME_RINVSYSID = 0x0000000F,
00173     SMPP_ESME_RCANCELFAIL = 0x00000011,
00174     SMPP_ESME_RREPLACEFAIL = 0x00000013,
00175     SMPP_ESME_RMSGQFUL   = 0x00000014,
00176     SMPP_ESME_RINVSERTYP = 0x00000015,
00177     SMPP_ESME_RINVNUMDESTS = 0x00000033,
00178     SMPP_ESME_RINVDLNAME = 0x00000034,
00179     SMPP_ESME_RINVDESTFLAG = 0x00000040,
00180     SMPP_ESME_RINVSUBREP = 0x00000042,
00181     SMPP_ESME_RINVESMCLASS = 0x00000043,
00182     SMPP_ESME_RCNTSUBDL = 0x00000044,
00183     SMPP_ESME_RSUBMITFAIL = 0x00000045,
00184     SMPP_ESME_RINVSRCTON = 0x00000048,
00185     SMPP_ESME_RINVSRCNPI = 0x00000049,
00186     SMPP_ESME_RINVDSTTON = 0x00000050,
00187     SMPP_ESME_RINVDSTNPI = 0x00000051,
00188     SMPP_ESME_RINVSYSTYP = 0x00000053,
00189     SMPP_ESME_RINVREPFLAG = 0x00000054,
00190     SMPP_ESME_RINVNUMMSGS = 0x00000055,
00191     SMPP_ESME_RTHROTTLED = 0x00000058,
00192     SMPP_ESME_RINVSCHED = 0x00000061,
00193     SMPP_ESME_RINVEXPIRY = 0x00000062,
00194     SMPP_ESME_RINVDFTMSGID = 0x00000063,
00195     SMPP_ESME_RX_T_APPN = 0x00000064,
00196     SMPP_ESME_RX_P_APPN = 0x00000065,
00197     SMPP_ESME_RX_R_APPN = 0x00000066,
00198     SMPP_ESME_RQUERYFAIL = 0x00000067,
00199     SMPP_ESME_RINVTLVSTREAM = 0x000000C0,
00200     SMPP_ESME_RTLVNOTALLWD = 0x000000C1,
00201     SMPP_ESME_RINVTLVLEN = 0x000000C2,
00202     SMPP_ESME_RMISSINGTLV = 0x000000C3,
00203     SMPP_ESME_RINVTLVVAL = 0x000000C4,
00204     SMPP_ESME_RDELIVERYFAILURE = 0x000000FE,
00205     SMPP_ESME_RUNKNOWNERR = 0x000000FF,
00206     SMPP_ESME_RSERTYPUNAUTH = 0x00000100,
00207     SMPP_ESME_RPROHIBITED = 0x00000101,
00208     SMPP_ESME_RSERTYPUNAVAIL = 0x00000102,
00209     SMPP_ESME_RSERTYPDENIED = 0x00000103,
00210     SMPP_ESME_RINVDCS = 0x00000104,
00211     SMPP_ESME_RINVSRCADDRSUBUNIT = 0x00000105,
00212     SMPP_ESME_RINVDSTADDRSUBUNIT = 0x00000106,
00213     SMPP_ESME_RINVBCASTFREQINT = 0x00000107,
00214     SMPP_ESME_RINVBCASTALIAS_NAME = 0x00000108,
00215     SMPP_ESME_RINVBCASTAREAFMT = 0x00000109,
00216     SMPP_ESME_RINVNUMBCAST_AREAS = 0x0000010A,
00217     SMPP_ESME_RINVBCASTCNTTYPE = 0x0000010B,
00218     SMPP_ESME_RINVBCASTMSGCLASS = 0x0000010C,
00219     SMPP_ESME_RBCASTFAIL = 0x0000010D,
00220     SMPP_ESME_RBCASTQUERYFAIL = 0x0000010E,
00221     SMPP_ESME_RBCASTCANCELFAIL = 0x0000010F,
00222     SMPP_ESME_RINVBCAST_REP = 0x00000110,
00223     SMPP_ESME_RINVBCASTSRVGRP = 0x00000111,
00224     SMPP_ESME_RINVBCASTCHANIND = 0x00000112,
00225 };
00226 
00227 SMPP_PDU *smpp_pdu_create(unsigned long type, unsigned long seq_no);
00228 void smpp_pdu_destroy(SMPP_PDU *pdu);
00229 int smpp_pdu_is_valid(SMPP_PDU *pdu); /* XXX */
00230 Octstr *smpp_pdu_pack(SMPP_PDU *pdu);
00231 SMPP_PDU *smpp_pdu_unpack(Octstr *data_without_len);
00232 void smpp_pdu_dump(SMPP_PDU *pdu);
00233 
00234 long smpp_pdu_read_len(Connection *conn);
00235 Octstr *smpp_pdu_read_data(Connection *conn, long len);
00236 
00237 /*
00238  * Return error string for given error code
00239  */
00240 const char *smpp_error_to_string(enum SMPP_ERROR_MESSAGES error);
00241 
00242 #endif
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.