1 /* ==================================================================== 2 * The Kannel Software License, Version 1.0 3 * 4 * Copyright (c) 2001-2014 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 */ 159 enum SMPP_ERROR_MESSAGES { 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_RALYNBD = 0x00000005, 166 SMPP_ESME_RINVPRTFLG = 0x00000006, 167 SMPP_ESME_RINVREGDLVFLG = 0x00000007, 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, 176 SMPP_ESME_RREPLACEFAIL = 0x00000013, 177 SMPP_ESME_RMSGQFUL = 0x00000014, 178 SMPP_ESME_RINVSERTYP = 0x00000015, 179 SMPP_ESME_RINVNUMDESTS = 0x00000033, 180 SMPP_ESME_RINVDLNAME = 0x00000034, 181 SMPP_ESME_RINVDESTFLAG = 0x00000040, 182 SMPP_ESME_RINVSUBREP = 0x00000042, 183 SMPP_ESME_RINVESMCLASS = 0x00000043, 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, 196 SMPP_ESME_RINVDFTMSGID = 0x00000063, 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, 201 SMPP_ESME_RINVTLVSTREAM = 0x000000C0, 202 SMPP_ESME_RTLVNOTALLWD = 0x000000C1, 203 SMPP_ESME_RINVTLVLEN = 0x000000C2, 204 SMPP_ESME_RMISSINGTLV = 0x000000C3, 205 SMPP_ESME_RINVTLVVAL = 0x000000C4, 206 SMPP_ESME_RDELIVERYFAILURE = 0x000000FE, 207 SMPP_ESME_RUNKNOWNERR = 0x000000FF, 208 SMPP_ESME_RSERTYPUNAUTH = 0x00000100, 209 SMPP_ESME_RPROHIBITED = 0x00000101, 210 SMPP_ESME_RSERTYPUNAVAIL = 0x00000102, 211 SMPP_ESME_RSERTYPDENIED = 0x00000103, 212 SMPP_ESME_RINVDCS = 0x00000104, 213 SMPP_ESME_RINVSRCADDRSUBUNIT = 0x00000105, 214 SMPP_ESME_RINVDSTADDRSUBUNIT = 0x00000106, 215 SMPP_ESME_RINVBCASTFREQINT = 0x00000107, 216 SMPP_ESME_RINVBCASTALIAS_NAME = 0x00000108, 217 SMPP_ESME_RINVBCASTAREAFMT = 0x00000109, 218 SMPP_ESME_RINVNUMBCAST_AREAS = 0x0000010A, 219 SMPP_ESME_RINVBCASTCNTTYPE = 0x0000010B, 220 SMPP_ESME_RINVBCASTMSGCLASS = 0x0000010C, 221 SMPP_ESME_RBCASTFAIL = 0x0000010D, 222 SMPP_ESME_RBCASTQUERYFAIL = 0x0000010E, 223 SMPP_ESME_RBCASTCANCELFAIL = 0x0000010F, 224 SMPP_ESME_RINVBCAST_REP = 0x00000110, 225 SMPP_ESME_RINVBCASTSRVGRP = 0x00000111, 226 SMPP_ESME_RINVBCASTCHANIND = 0x00000112, 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 */ 237 Octstr *smpp_pdu_pack(Octstr *smsc_id, SMPP_PDU *pdu); 238 SMPP_PDU *smpp_pdu_unpack(Octstr *smsc_id, Octstr *data_without_len); 239 void smpp_pdu_dump(Octstr *smsc_id, SMPP_PDU *pdu); 240 241 long smpp_pdu_read_len(Connection *conn); 242 Octstr *smpp_pdu_read_data(Connection *conn, long len); 243 244 /* 245 * Return error string for given error code 246 */ 247 const char *smpp_error_to_string(enum SMPP_ERROR_MESSAGES error); 248 249 #endif 250