00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef SMSC_SEMA_H
00058 #define SMSC_SEMA_H
00059
00060 #include "gwlib/gwlib.h"
00061 #include "smsc.h"
00062 #include "smsc_p.h"
00063
00064 #define SM_RESULT_SUCCESS 0
00065 #define SM_RESULT_FAIL_ARGS 1
00066 #define SM_RESLUT_FAIL_SMSC_DB 2
00067 #define SM_RESULT_FAIL_SMSC_BUSY 3
00068 #define SM_RESULT_FAIL_SM_NOTFOUND 4
00069 #define SM_RESULT_FAIL_SM_DUPLICATE 5
00070
00071 #define SME_RESULT_SUCCESS 0
00072 #define SME_RESULT_INVALIDDATA 1
00073 #define SME_RESULT_DBFULL 2
00074 #define SME_RESULT_SMEBUSY 3
00075 #define SME_RESULT_NOTUSED 4
00076 #define SME_RESULT_DUPLICATESM 5
00077 #define SME_RESULT_DESTUNAVAILABLE 6
00078 #define SME_RESULT_CALLBARREDUSER 7
00079 #define SME_RESULT_TRANSMISSION 21
00080 #define SME_RESULT_FACILITYNOTSUPPORT 22
00081 #define SME_RESULT_ERRORINSME 23
00082 #define SME_RESULT_UNKNOWNSUBSCRIBER 24
00083 #define SME_RESULT_CALLBARREDOPERATOR 25
00084 #define SME_RESULT_CUGVIOLATION 26
00085 #define SME_RESULT_NETWORKFAIL 120
00086
00087 #define ENCODE_IA5 15
00088 #define ENCODE_GSM 0
00089
00090
00091
00092 #define LINE_ENCODE_IA5 1
00093 #define LINE_ENCODE_HEX 2
00094 #define LINE_ENCODE_BIN 3
00095
00096 #define X28_COMMAND_MODE 0
00097 #define X28_MT_DATA_MODE 1
00098 #define X28_MO_DATA_MODE 2
00099
00100 #define INTERNAL_DISCONNECT_TIMEVAL 3
00101 #define INTERNAL_READFD_TIMEVAL 1
00102 #define INTERNAL_CONNECT_TIMEVAL 5
00103 #define INTERNAL_SESSION_MT_TIMEVAL 20
00104
00105 #define SESSION_MT_RECEIVE_ERR 0
00106 #define SESSION_MT_RECEIVE_TIMEOUT 1
00107 #define SESSION_MT_RECEIVE_SUCCESS 2
00108
00109
00110 typedef struct msg_hash{
00111 int key;
00112 Octstr* content;
00113 } msg_hash;
00114
00115
00116
00117 typedef struct sema_msg{
00118 unsigned char type;
00119 unsigned char continuebyte;
00120 unsigned char optref[4];
00121 int encodetype;
00122 time_t logtime;
00123
00124 void *msgbody;
00125
00126 struct sema_msg *prev, *next;
00127 } sema_msg;
00128
00129
00130 typedef struct sema_msglist{
00131 int count;
00132 sema_msg* first;
00133 sema_msg* last;
00134
00135 }sema_msglist;
00136
00137
00138
00139 typedef struct sm_statusreport_result{
00140 unsigned int smeresult;
00141 }sm_statusreport_result;
00142
00143 typedef struct sm_statusreport_invoke{
00144 unsigned int msisdnlen;
00145 Octstr* msisdn;
00146 unsigned int smetype;
00147 unsigned char smerefnum[4];
00148 unsigned char smscrefnum[4];
00149 char accepttime[14];
00150 unsigned int status;
00151 char completetime[14];
00152 char intermediatime[14];
00153 unsigned int failreason;
00154 unsigned int origaddlen;
00155 Octstr* origadd;
00156 char invoketime[14];
00157 }sm_statusreport_invoke;
00158
00159
00160
00161 typedef struct sm_submit_result{
00162 unsigned int smeresult;
00163
00164
00165
00166
00167 unsigned char smscrefnum[4];
00168 char accepttime[14];
00169 } sm_submit_result;
00170
00171 typedef struct sm_submit_invoke{
00172 unsigned int msisdnlen;
00173 Octstr* msisdn;
00174 unsigned int smereftype;
00175 unsigned char smerefnum[4];
00176 unsigned int priority;
00177 unsigned int origaddlen;
00178 Octstr* origadd;
00179
00180 unsigned int validperiodtype;
00181 char validperiodabs[14];
00182 unsigned int validperiodrela;
00183
00184 unsigned int DCS;
00185 unsigned int statusreportrequest;
00186
00187
00188 unsigned int protocal;
00189 unsigned int replypath;
00190 unsigned int textsizeseptet;
00191 unsigned int textsizeoctect;
00192 Octstr* shortmsg;
00193
00194 unsigned char smscrefnum[4];
00195 }sm_submit_invoke;
00196
00197
00198 typedef struct sm_deliver_result{
00199 unsigned int smeresult;
00200
00201 } sm_deliver_result;
00202
00203 typedef struct sm_deliver_invoke{
00204 unsigned int destaddlen;
00205 Octstr* destadd;
00206 unsigned char smscrefnum[4];
00207 unsigned int origaddlen;
00208 Octstr* origadd;
00209
00210
00211 unsigned int DCS;
00212 unsigned int protocal;
00213 unsigned int replypath;
00214 unsigned int textsizeseptet;
00215 unsigned int textsizeoctect;
00216 Octstr* shortmsg;
00217 char accepttime[14];
00218 char invoketime[14];
00219
00220
00221
00222 }sm_deliver_invoke;
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 static int sema_submit_result(SMSCenter*, sema_msg*, int);
00334
00335 static int X28_open_data_link(char*);
00336
00337 static int X28_reopen_data_link(int,char*);
00338
00339 static int X28_close_send_link(int);
00340
00341 static int X28_open_send_link(int,char*);
00342
00343 static int X28_data_read(int, char*);
00344
00345 static int X28_data_send(int, char*, int);
00346
00347 static int X28_msg_pop(char *, char *);
00348
00349 static int sema_msg_session_mt(SMSCenter*, sema_msg*);
00350
00351 static int sema_msg_session_mo(SMSCenter*, char*);
00352
00353 static sema_msg* sema_msg_new(void);
00354
00355 static int sema_msg_free(sema_msg *msg);
00356
00357 static sema_msglist* sema_msglist_new(void);
00358
00359 static void sema_msglist_free(sema_msglist*);
00360
00361 static int sema_msglist_push(sema_msglist*, sema_msg*);
00362
00363 static int sema_msglist_pop(sema_msglist*, sema_msg**);
00364
00365
00366
00367 static int sema_decode_msg(sema_msg**, char*);
00368
00369 static int sema_encode_msg(sema_msg*, char*);
00370
00371 static int line_append_hex_IA5(Octstr* , unsigned char*, int);
00372
00373 static int line_scan_IA5_hex(char*, int, unsigned char*);
00374
00375 static int line_scan_hex_GSM7(unsigned char*,int,int,unsigned char*);
00376
00377 static int internal_char_IA5_to_hex(char *, unsigned char *);
00378
00379 static int internal_char_hex_to_IA5(unsigned char, unsigned char *);
00380
00381 static unsigned char internal_char_hex_to_gsm(unsigned char from);
00382
00383 static int unpack_continous_byte(unsigned char, int *, int * , int *);
00384
00385 static unsigned char pack_continous_byte(int, int, int);
00386
00387 static void increment_counter(void);
00388
00389 #endif
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
See file LICENSE for details about the license agreement for using,
modifying, copying or deriving work from this software.