#include "gwlib/gwlib.h"Include dependency graph for emimsg.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | emimsg |
Enumerations | |
| enum | { E01_ADC, E01_OADC, E01_AC, E01_MT, E01_AMSG, SZ01 } |
| enum | { E50_ADC, E50_OADC, E50_AC, E50_NRQ, E50_NADC, E50_NT, E50_NPID, E50_LRQ, E50_LRAD, E50_LPID, E50_DD, E50_DDT, E50_VP, E50_RPID, E50_SCTS, E50_DST, E50_RSN, E50_DSCTS, E50_MT, E50_NB, E50_NMSG = 20, E50_AMSG = 20, E50_TMSG = 20, E50_MMS, E50_PR, E50_DCS, E50_MCLS, E50_RPI, E50_CPG, E50_RPLY, E50_OTOA, E50_HPLMN, E50_XSER, E50_RES4, E50_RES5, SZ50 } |
| enum | { E60_OADC, E60_OTON, E60_ONPI, E60_STYP, E60_PWD, E60_NPWD, E60_VERS, E60_LADC, E60_LTON, E60_LNPI, E60_OPID, E60_RES1, SZ60 } |
Functions | |
| emimsg * | emimsg_create_op (int ot, int trn, Octstr *whoami) |
| emimsg * | emimsg_create_reply (int ot, int trn, int positive, Octstr *whoami) |
| void | emimsg_destroy (struct emimsg *emimsg) |
| emimsg * | emimsg_duplicate (struct emimsg *emimsg) |
| emimsg * | get_fields (Octstr *message, Octstr *whoami) |
| int | emimsg_send (Connection *conn, struct emimsg *emimsg, Octstr *whoami) |
|
|
Definition at line 80 of file emimsg.h. 00080 {
00081 E01_ADC, E01_OADC, E01_AC, E01_MT, E01_AMSG, SZ01
00082 };
|
|
|
Definition at line 86 of file emimsg.h. 00086 {
00087 E50_ADC, E50_OADC, E50_AC, E50_NRQ, E50_NADC, E50_NT, E50_NPID, E50_LRQ,
00088 E50_LRAD, E50_LPID, E50_DD, E50_DDT, E50_VP, E50_RPID, E50_SCTS, E50_DST,
00089 E50_RSN, E50_DSCTS, E50_MT, E50_NB, E50_NMSG=20, E50_AMSG=20, E50_TMSG=20,
00090 E50_MMS, E50_PR, E50_DCS, E50_MCLS, E50_RPI, E50_CPG, E50_RPLY, E50_OTOA,
00091 E50_HPLMN, E50_XSER, E50_RES4, E50_RES5, SZ50
00092 };
|
|
|
Definition at line 95 of file emimsg.h. 00095 {
00096 E60_OADC, E60_OTON, E60_ONPI, E60_STYP, E60_PWD, E60_NPWD, E60_VERS,
00097 E60_LADC, E60_LTON, E60_LNPI, E60_OPID, E60_RES1, SZ60
00098 };
|
|
||||||||||||||||
|
Definition at line 166 of file emimsg.c. References emimsg_create_withlen(), field_count_op(), emimsg::or, emimsg::ot, and emimsg::trn. Referenced by get_fields(), make_emi31(), make_emi60(), and msg_to_emimsg(). 00167 {
00168 int len;
00169 struct emimsg *ret;
00170
00171 len = field_count_op(ot, whoami);
00172 if (len < 0)
00173 return NULL;
00174 ret = emimsg_create_withlen(len);
00175 ret->ot = ot;
00176 ret->or = 'O';
00177 ret->trn = trn;
00178 return ret;
00179 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 199 of file emimsg.c. References emimsg_create_reply_s(), emimsg::fields, and octstr_create. Referenced by handle_operation(). 00201 {
00202 struct emimsg *ret;
00203
00204 ret = emimsg_create_reply_s(ot, trn, positive, whoami);
00205 if (ret) {
00206 if (positive)
00207 ret->fields[0] = octstr_create("A");
00208 else
00209 ret->fields[0] = octstr_create("N");
00210 }
00211 return ret;
00212 }
|
Here is the call graph for this function:

|
|
Definition at line 215 of file emimsg.c. References emimsg::fields, emimsg::num_fields, and octstr_destroy(). Referenced by emi2_do_send(), emi2_handle_smscreq(), emi2_keepalive_handling(), emi2_receiver(), get_fields(), handle_operation(), open_send_connection(), and wait_for_ack(). 00216 {
00217 int len;
00218
00219 len = emimsg->num_fields;
00220 while (--len >= 0) {
00221 octstr_destroy(emimsg->fields[len]); /* octstr_destroy(NULL) is ok */
00222 emimsg->fields[len] = NULL;
00223 }
00224 gw_free(emimsg->fields);
00225 gw_free(emimsg);
00226 }
|
Here is the call graph for this function:

|
|
Definition at line 229 of file emimsg.c. References emimsg::fields, emimsg::num_fields, octstr_duplicate, emimsg::or, emimsg::ot, and emimsg::trn. 00230 {
00231 int len;
00232 struct emimsg *ret;
00233
00234 len = emimsg->num_fields;
00235 if (len < 0)
00236 return NULL;
00237 ret = gw_malloc(sizeof(struct emimsg));
00238 ret->fields = gw_malloc(len * sizeof(Octstr *));
00239 ret->num_fields = len;
00240 while (--len >= 0)
00241 ret->fields[len] = octstr_duplicate(emimsg->fields[len]);
00242 ret->ot = emimsg->ot;
00243 ret->or = emimsg->or;
00244 ret->trn = emimsg->trn;
00245
00246 return ret;
00247 }
|
|
||||||||||||||||
|
Definition at line 368 of file emimsg.c. References conn_write(), debug(), emimsg_tostring(), error(), octstr_destroy(), octstr_get_cstr, emimsg::ot, and string. Referenced by emi2_emimsg_send(). 00369 {
00370 Octstr *string;
00371
00372 string = emimsg_tostring(emimsg);
00373 if (!string) {
00374 error(0, "EMI2[%s]: emimsg_send: conversion to string failed",
00375 octstr_get_cstr(whoami));
00376 return -1;
00377 }
00378 if (emimsg->ot == 60)
00379 debug("smsc.emi2", 0, "EMI2[%s]: Sending operation type 60, message with "
00380 "password not shown in log file.", octstr_get_cstr(whoami));
00381 else
00382 debug("smsc.emi2", 0, "EMI2[%s]: emi2 sending packet: <%s>",
00383 octstr_get_cstr(whoami), octstr_get_cstr(string));
00384 if (conn_write(conn, string) == -1) {
00385 octstr_destroy(string);
00386 error(0, "EMI2[%s]: emimsg_send: write failed",
00387 octstr_get_cstr(whoami));
00388 return -1;
00389 }
00390 octstr_destroy(string);
00391 return 1;
00392 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 290 of file emimsg.c. References calculate_checksum(), debug(), emi_strerror(), emimsg_create_op(), emimsg_create_reply_s(), emimsg_destroy(), error(), emimsg::fields, message, emimsg::num_fields, octstr_copy, octstr_get_char(), octstr_get_cstr, octstr_len(), octstr_parse_long(), octstr_search_char(), emimsg::or, emimsg::ot, result, emimsg::trn, and warning(). Referenced by emi2_handle_smscreq(), emi2_receiver(), main(), and wait_for_ack(). 00291 {
00292 long trn, len, ot, checksum; /* because of Octstr_parse_long... */
00293 char or, posit;
00294 long fieldno, pos, pos2;
00295 struct emimsg *result = NULL;
00296
00297 debug("smsc.emi2", 0, "EMI2[%s]: emi2 parsing packet: <%s>",
00298 octstr_get_cstr(whoami), octstr_get_cstr(message));
00299 if (octstr_get_char(message, 0) != 2 ||
00300 octstr_get_char(message, octstr_len(message) - 1) != 3)
00301 goto error;
00302 if (octstr_parse_long(&trn, message, 1, 10) != 3)
00303 goto error;
00304 if (octstr_parse_long(&len, message, 4, 10) != 9)
00305 goto error;
00306 if (octstr_len(message) != len + 2) /* +2 for start/end markers */
00307 goto error;
00308 if ( (or = octstr_get_char(message, 10)) != 'O' && or != 'R')
00309 goto error;
00310 if (octstr_parse_long(&ot, message, 12, 10) != 14)
00311 goto error;
00312 if (or == 'O')
00313 result = emimsg_create_op(ot, trn, whoami);
00314 else {
00315 posit = octstr_get_char(message, 15);
00316 if (posit == 'A')
00317 result = emimsg_create_reply_s(ot, trn, 1, whoami);
00318 else if (posit == 'N')
00319 result = emimsg_create_reply_s(ot, trn, 0, whoami);
00320 else
00321 goto error;
00322 }
00323 if (result == NULL)
00324 goto error;
00325 pos2 = 14;
00326 for (fieldno = 0; fieldno < result->num_fields; fieldno++) {
00327 pos = pos2 + 1;
00328 if ( (pos2 = octstr_search_char(message, '/', pos)) == -1)
00329 goto error;
00330 if (pos2 > pos)
00331 result->fields[fieldno] = octstr_copy(message, pos, pos2 - pos);
00332 }
00333 if (octstr_search_char(message, '/', pos2 + 1) != -1) {
00334 int extrafields = 0;
00335
00336 pos = pos2;
00337 while ((pos = octstr_search_char(message, '/', pos + 1)) != -1) {
00338 extrafields++;
00339 pos2 = pos;
00340 }
00341 /* The extra fields are ignored */
00342 warning(0, "get_fields: EMI message of type %d/%c has %d more fields "
00343 "than expected.", result->ot, result->or, extrafields);
00344 }
00345 if (octstr_parse_long(&checksum, message, pos2 + 1, 16) !=
00346 octstr_len(message) - 1 || checksum != calculate_checksum(message))
00347 goto error;
00348 if (result->or == 'R' && octstr_get_char(result->fields[0], 0) == 'N') {
00349 long errcode;
00350 if (!result->fields[1] ||
00351 octstr_parse_long(&errcode, result->fields[1], 0, 10) != 2)
00352 goto error;
00353 error(0, "EMI2[%s]: Got negative ack. op:%d, trn:%d, error:%ld (%s), message:%s",
00354 octstr_get_cstr(whoami),
00355 result->ot, result->trn, errcode, emi_strerror(errcode),
00356 result->fields[2] ? octstr_get_cstr(result->fields[2]) : "");
00357 }
00358 return result;
00359 error:
00360 error(0, "EMI2[%s]: Invalid EMI packet: %s", octstr_get_cstr(whoami),
00361 octstr_get_cstr(message));
00362 if (result)
00363 emimsg_destroy(result);
00364 return NULL;
00365 }
|
Here is the call graph for this function:
