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
00058
00059
00060
00061
00062 #include <string.h>
00063 #include <unistd.h>
00064 #include <signal.h>
00065
00066 #include "gwlib/gwlib.h"
00067 #include "gw/smsc/emimsg.c"
00068 #include "gw/alt_charsets.h"
00069
00070 static char *emi_typeop(int typeop)
00071 {
00072 switch (typeop) {
00073 case 31:
00074 return "Alert Operation";
00075 case 51:
00076 return "Submit Short Message operation";
00077 case 52:
00078 return "Delivery Short Message operation";
00079 case 53:
00080 return "Delivery notification operation";
00081 case 54:
00082 return "Modify Short Message operation";
00083 case 55:
00084 return "Inquiry message operation";
00085 case 56:
00086 return "Delete message operation";
00087 case 57:
00088 return "Response Inquiry message operation";
00089 case 58:
00090 return "Response delete message operation";
00091 case 60:
00092 return "Session management operation";
00093 case 61:
00094 return "Provisioning actions operation";
00095 default:
00096 return "!UNRECOGNIZED CODE!";
00097 }
00098 }
00099
00100 int main (int argc, char **argv)
00101 {
00102 Octstr *message, *whoami;
00103 struct emimsg *emimsg;
00104
00105 gwlib_init();
00106
00107 if (argc < 2) {
00108 printf("Syntax: %s <msg>\n", argv[0]);
00109 return -1;
00110 }
00111
00112 message = octstr_format("\02%s\03", argv[1]);
00113 whoami = octstr_create("DECODE");
00114
00115 printf(" /* decode_emimsg - Decoding an EMI message. <vincent@telemaque.fr> */ \n\n");
00116
00117 emimsg = get_fields(message, whoami);
00118
00119 if (emimsg != NULL) {
00120 printf("\n");
00121 printf("TRN \t%d\n", emimsg->trn);
00122 printf("TYPE \t%c\n", emimsg->or);
00123 printf("OPERATION\t%d (%s)\n", emimsg->ot, emi_typeop (emimsg->ot));
00124
00125 if (emimsg->ot == 01) {
00126 printf("E01_ADC \t%s\n",
00127 octstr_get_cstr(emimsg->fields[E01_ADC]));
00128 printf("E01_OADC \t%s\n",
00129 octstr_get_cstr(emimsg->fields[E01_OADC]));
00130 printf("E01_AC \t%s\n",
00131 octstr_get_cstr(emimsg->fields[E01_AC]));
00132 printf("E01_ADC \t%s\n",
00133 octstr_get_cstr(emimsg->fields[E01_ADC]));
00134 printf("E01_MT \t%s\n",
00135 octstr_get_cstr(emimsg->fields[E01_MT]));
00136 if (octstr_get_char(emimsg->fields[E01_MT], 0) == '3') {
00137 charset_gsm_to_latin1(emimsg->fields[E01_AMSG]);
00138 }
00139 printf("E01_AMSG \t%s\n",
00140 octstr_get_cstr(emimsg->fields[E01_AMSG]));
00141 }
00142
00143 if ((emimsg->ot == 31 || (emimsg->ot >= 50 && emimsg->ot <= 59)) &&
00144 emimsg->or == 'R' &&
00145 (octstr_get_char(emimsg->fields[E50_ADC], 0) == 'A' ||
00146 octstr_get_char(emimsg->fields[E50_ADC], 0) == 'N')) {
00147 printf("E50_ACK \t%s\n",
00148 octstr_get_cstr(emimsg->fields[E50_ADC]));
00149 printf("E50_SM \t%s\n",
00150 octstr_get_cstr(emimsg->fields[E50_OADC]));
00151 }
00152
00153 if (emimsg->ot == 31 && emimsg->or == 'O') {
00154 printf("E50_ADC \t%s\n",
00155 octstr_get_cstr(emimsg->fields[E50_ADC]));
00156 printf("E50_PID \t%s\n",
00157 octstr_get_cstr(emimsg->fields[E50_OADC]));
00158 }
00159
00160 if (emimsg->ot >= 50 && emimsg->ot <= 59 &&
00161 octstr_get_char(emimsg->fields[E50_ADC], 0) != 'A' &&
00162 octstr_get_char(emimsg->fields[E50_ADC], 0) != 'N') {
00163 printf("E50_ADC \t%s\n",
00164 octstr_get_cstr(emimsg->fields[E50_ADC]));
00165 printf("E50_OADC \t%s\n",
00166 octstr_get_cstr(emimsg->fields[E50_OADC]));
00167 printf("E50_AC \t%s\n",
00168 octstr_get_cstr(emimsg->fields[E50_AC]));
00169 printf("E50_NRQ \t%s\n",
00170 octstr_get_cstr(emimsg->fields[E50_NRQ]));
00171 printf("E50_NADC \t%s\n",
00172 octstr_get_cstr(emimsg->fields[E50_NADC]));
00173 printf("E50_NT \t%s\n",
00174 octstr_get_cstr(emimsg->fields[E50_NT]));
00175 printf("E50_NPID \t%s\n",
00176 octstr_get_cstr(emimsg->fields[E50_NPID]));
00177 printf("E50_LRQ \t%s\n",
00178 octstr_get_cstr(emimsg->fields[E50_LRQ]));
00179 printf("E50_LRAD \t%s\n",
00180 octstr_get_cstr(emimsg->fields[E50_LRAD]));
00181 printf("E50_LPID \t%s\n",
00182 octstr_get_cstr(emimsg->fields[E50_LPID]));
00183 printf("E50_DD \t%s\n",
00184 octstr_get_cstr(emimsg->fields[E50_DD]));
00185 printf("E50_DDT \t%s\n",
00186 octstr_get_cstr(emimsg->fields[E50_DDT]));
00187 printf("E50_VP \t%s\n",
00188 octstr_get_cstr(emimsg->fields[E50_VP]));
00189 printf("E50_RPID \t%s\n",
00190 octstr_get_cstr(emimsg->fields[E50_RPID]));
00191 printf("E50_SCTS \t%s\n",
00192 octstr_get_cstr(emimsg->fields[E50_SCTS]));
00193 printf("E50_DST \t%s\n",
00194 octstr_get_cstr(emimsg->fields[E50_DST]));
00195 printf("E50_RSN \t%s\n",
00196 octstr_get_cstr(emimsg->fields[E50_RSN]));
00197 printf("E50_DSCTS\t%s\n",
00198 octstr_get_cstr(emimsg->fields[E50_DSCTS]));
00199 printf("E50_MT \t%s\n",
00200 octstr_get_cstr(emimsg->fields[E50_MT]));
00201 printf("E50_NB \t%s\n",
00202 octstr_get_cstr(emimsg->fields[E50_NB]));
00203 printf("E50_NMSG \t%s\n",
00204 octstr_get_cstr(emimsg->fields[E50_NMSG]));
00205 if (emimsg->fields[E50_AMSG])
00206 octstr_hex_to_binary (emimsg->fields[E50_AMSG]);
00207 if (octstr_get_char(emimsg->fields[E50_MT], 0) == '3') {
00208 charset_gsm_to_latin1(emimsg->fields[E50_AMSG]);
00209 }
00210
00211 printf("E50_AMSG \t%s\n",
00212 octstr_get_cstr(emimsg->fields[E50_AMSG]));
00213 printf("E50_TMSG \t%s\n",
00214 octstr_get_cstr(emimsg->fields[E50_TMSG]));
00215 printf("E50_MMS \t%s\n",
00216 octstr_get_cstr(emimsg->fields[E50_MMS]));
00217 printf("E50_PR \t%s\n",
00218 octstr_get_cstr(emimsg->fields[E50_PR]));
00219 printf("E50_DCS \t%s\n",
00220 octstr_get_cstr(emimsg->fields[E50_DCS]));
00221 printf("E50_MCLS \t%s\n",
00222 octstr_get_cstr(emimsg->fields[E50_MCLS]));
00223 printf("E50_RPI \t%s\n",
00224 octstr_get_cstr(emimsg->fields[E50_RPI]));
00225 printf("E50_CPG \t%s\n",
00226 octstr_get_cstr(emimsg->fields[E50_CPG]));
00227 printf("E50_RPLY \t%s\n",
00228 octstr_get_cstr(emimsg->fields[E50_RPLY]));
00229 printf("E50_OTOA \t%s\n",
00230 octstr_get_cstr(emimsg->fields[E50_OTOA]));
00231 printf("E50_HPLMN\t%s\n",
00232 octstr_get_cstr(emimsg->fields[E50_HPLMN]));
00233 printf("E50_XSER \t%s\n",
00234 octstr_get_cstr(emimsg->fields[E50_XSER]));
00235 printf("E50_RES4 \t%s\n",
00236 octstr_get_cstr(emimsg->fields[E50_RES4]));
00237 printf("E50_RES5 \t%s\n",
00238 octstr_get_cstr(emimsg->fields[E50_RES5]));
00239 }
00240
00241 if (emimsg->ot == 60 || emimsg->ot == 61 || emimsg->ot == 62) {
00242 printf("E60_OADC \t%s\n",
00243 octstr_get_cstr(emimsg->fields[E60_OADC]));
00244 printf("E60_OTON \t%s\n",
00245 octstr_get_cstr(emimsg->fields[E60_OTON]));
00246 printf("E60_ONPI \t%s\n",
00247 octstr_get_cstr(emimsg->fields[E60_ONPI]));
00248 printf("E60_STYP \t%s\n",
00249 octstr_get_cstr(emimsg->fields[E60_STYP]));
00250 if (emimsg->fields[E60_PWD])
00251 octstr_hex_to_binary (emimsg->fields[E60_PWD]);
00252 printf("E60_PWD \t%s\n",
00253 octstr_get_cstr(emimsg->fields[E60_PWD]));
00254 printf("E60_NPWD \t%s\n",
00255 octstr_get_cstr(emimsg->fields[E60_NPWD]));
00256 printf("E60_VERS \t%s\n",
00257 octstr_get_cstr(emimsg->fields[E60_VERS]));
00258 printf("E60_LADC \t%s\n",
00259 octstr_get_cstr(emimsg->fields[E60_LADC]));
00260 printf("E60_LTON \t%s\n",
00261 octstr_get_cstr(emimsg->fields[E60_LTON]));
00262 printf("E60_LNPI \t%s\n",
00263 octstr_get_cstr(emimsg->fields[E60_LNPI]));
00264 printf("E60_OPID \t%s\n",
00265 octstr_get_cstr(emimsg->fields[E60_OPID]));
00266 printf("E60_RES1 \t%s\n",
00267 octstr_get_cstr(emimsg->fields[E60_RES1]));
00268 }
00269 }
00270
00271 octstr_destroy(message);
00272 octstr_destroy(whoami);
00273 gwlib_shutdown();
00274
00275 return 0;
00276 }
See file LICENSE for details about the license agreement for using,
modifying, copying or deriving work from this software.