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
00063
00064
00065
00066
00067 STATE_NAME(NULL_METHOD)
00068 STATE_NAME(HOLDING)
00069 STATE_NAME(REQUESTING)
00070 STATE_NAME(PROCESSING)
00071 STATE_NAME(REPLYING)
00072
00073
00074
00075 ROW(NULL_METHOD,
00076 TR_Invoke_Ind,
00077 e->tcl == 2 && pdu->type == Get,
00078 {
00079 List *headers;
00080 WAPEvent *invoke;
00081 int method;
00082 Octstr *method_name;
00083
00084
00085
00086
00087 if (octstr_len(pdu->u.Get.headers) > 0)
00088 headers = wsp_headers_unpack(pdu->u.Get.headers, 0);
00089 else
00090 headers = NULL;
00091
00092 invoke = wap_event_create(S_MethodInvoke_Ind);
00093 invoke->u.S_MethodInvoke_Ind.server_transaction_id =
00094 msm->transaction_id;
00095 method = GET_METHODS + pdu->u.Get.subtype;
00096 method_name = wsp_method_to_string(method);
00097 if (method_name == NULL)
00098 method_name = octstr_format("UNKNOWN%02X", method);
00099 invoke->u.S_MethodInvoke_Ind.method = method_name;
00100 invoke->u.S_MethodInvoke_Ind.request_uri =
00101 octstr_duplicate(pdu->u.Get.uri);
00102 invoke->u.S_MethodInvoke_Ind.request_headers = headers;
00103 invoke->u.S_MethodInvoke_Ind.request_body = NULL;
00104 invoke->u.S_MethodInvoke_Ind.session_headers =
00105 http_header_duplicate(sm->http_headers);
00106 invoke->u.S_MethodInvoke_Ind.addr_tuple =
00107 wap_addr_tuple_duplicate(sm->addr_tuple);
00108 invoke->u.S_MethodInvoke_Ind.client_SDU_size =
00109 sm->client_SDU_size;
00110 invoke->u.S_MethodInvoke_Ind.session_id =
00111 msm->session_id;
00112
00113 msm->invoke = invoke;
00114 },
00115 HOLDING)
00116
00117 ROW(NULL_METHOD,
00118 TR_Invoke_Ind,
00119 e->tcl == 2 && pdu->type == Post,
00120 {
00121 List *headers;
00122 WAPEvent *invoke;
00123 int method;
00124 Octstr *method_name;
00125
00126
00127
00128
00129 if (octstr_len(pdu->u.Post.headers) > 0)
00130 headers = wsp_headers_unpack(pdu->u.Post.headers, 1);
00131 else
00132 headers = NULL;
00133
00134 invoke = wap_event_create(S_MethodInvoke_Ind);
00135 invoke->u.S_MethodInvoke_Ind.server_transaction_id =
00136 msm->transaction_id;
00137 method = POST_METHODS + pdu->u.Get.subtype;
00138 method_name = wsp_method_to_string(method);
00139 if (method_name == NULL)
00140 method_name = octstr_format("UNKNOWN%02X", method);
00141 invoke->u.S_MethodInvoke_Ind.method = method_name;
00142 invoke->u.S_MethodInvoke_Ind.request_uri =
00143 octstr_duplicate(pdu->u.Post.uri);
00144 invoke->u.S_MethodInvoke_Ind.request_headers = headers;
00145
00146 invoke->u.S_MethodInvoke_Ind.request_body =
00147 octstr_duplicate(pdu->u.Post.data);
00148
00149 invoke->u.S_MethodInvoke_Ind.session_headers =
00150 http_header_duplicate(sm->http_headers);
00151 invoke->u.S_MethodInvoke_Ind.addr_tuple =
00152 wap_addr_tuple_duplicate(sm->addr_tuple);
00153 invoke->u.S_MethodInvoke_Ind.client_SDU_size =
00154 sm->client_SDU_size;
00155 invoke->u.S_MethodInvoke_Ind.session_id =
00156 msm->session_id;
00157
00158 msm->invoke = invoke;
00159 },
00160 HOLDING)
00161
00162 ROW(HOLDING,
00163 Release_Event,
00164 1,
00165 {
00166
00167 dispatch_to_appl(msm->invoke);
00168 msm->invoke = NULL;
00169 },
00170 REQUESTING)
00171
00172 ROW(HOLDING,
00173 Abort_Event,
00174 1,
00175 {
00176
00177
00178
00179
00180 method_abort(msm, e->reason);
00181 },
00182 NULL_METHOD)
00183
00184 ROW(HOLDING,
00185 TR_Abort_Ind,
00186 e->abort_code == WSP_ABORT_DISCONNECT,
00187 {
00188 WAPEvent *wsp_event;
00189
00190
00191 wsp_event = wap_event_create(Disconnect_Event);
00192 wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
00193
00194
00195
00196
00197
00198
00199 gwlist_insert(queue, 0, wsp_event);
00200 },
00201 HOLDING)
00202
00203 ROW(HOLDING,
00204 TR_Abort_Ind,
00205 e->abort_code == WSP_ABORT_SUSPEND,
00206 {
00207 WAPEvent *wsp_event;
00208
00209
00210 wsp_event = wap_event_create(Suspend_Event);
00211 wsp_event->u.Suspend_Event.session_handle = msm->session_id;
00212
00213 gwlist_insert(queue, 0, wsp_event);
00214 },
00215 HOLDING)
00216
00217 ROW(HOLDING,
00218 TR_Abort_Ind,
00219 e->abort_code != WSP_ABORT_DISCONNECT
00220 && e->abort_code != WSP_ABORT_SUSPEND,
00221 {
00222
00223
00224 },
00225 NULL_METHOD)
00226
00227 ROW(REQUESTING,
00228 S_MethodInvoke_Res,
00229 1,
00230 {
00231 WAPEvent *wtp_event;
00232
00233
00234 wtp_event = wap_event_create(TR_Invoke_Res);
00235 wtp_event->u.TR_Invoke_Res.handle = msm->transaction_id;
00236 dispatch_to_wtp_resp(wtp_event);
00237 },
00238 PROCESSING)
00239
00240
00241
00242 ROW(REQUESTING,
00243 Abort_Event,
00244 1,
00245 {
00246
00247
00248
00249
00250 method_abort(msm, e->reason);
00251
00252
00253 indicate_method_abort(msm, e->reason);
00254 },
00255 NULL_METHOD)
00256
00257 ROW(REQUESTING,
00258 TR_Abort_Ind,
00259 e->abort_code == WSP_ABORT_DISCONNECT,
00260 {
00261 WAPEvent *wsp_event;
00262
00263
00264 wsp_event = wap_event_create(Disconnect_Event);
00265 wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
00266 gwlist_insert(queue, 0, wsp_event);
00267 },
00268 REQUESTING)
00269
00270 ROW(REQUESTING,
00271 TR_Abort_Ind,
00272 e->abort_code == WSP_ABORT_SUSPEND,
00273 {
00274 WAPEvent *wsp_event;
00275
00276
00277 wsp_event = wap_event_create(Suspend_Event);
00278 wsp_event->u.Suspend_Event.session_handle = msm->session_id;
00279 gwlist_insert(queue, 0, wsp_event);
00280 },
00281 REQUESTING)
00282
00283 ROW(REQUESTING,
00284 TR_Abort_Ind,
00285 e->abort_code != WSP_ABORT_DISCONNECT
00286 && e->abort_code != WSP_ABORT_SUSPEND,
00287 {
00288
00289
00290
00291
00292 indicate_method_abort(msm, e->abort_code);
00293 },
00294 NULL_METHOD)
00295
00296 ROW(PROCESSING,
00297 S_MethodResult_Req,
00298 1,
00299 {
00300 WAPEvent *wtp_event;
00301 WSP_PDU *new_pdu;
00302
00303
00304 new_pdu = wsp_pdu_create(Reply);
00305 new_pdu->u.Reply.status =
00306 wsp_convert_http_status_to_wsp_status(e->status);
00307 new_pdu->u.Reply.headers =
00308 wsp_headers_pack(e->response_headers, 1, sm->encoding_version);
00309 new_pdu->u.Reply.data = octstr_duplicate(e->response_body);
00310
00311
00312 wtp_event = wap_event_create(TR_Result_Req);
00313 wtp_event->u.TR_Result_Req.user_data = wsp_pdu_pack(new_pdu);
00314 wtp_event->u.TR_Result_Req.handle = msm->transaction_id;
00315 dispatch_to_wtp_resp(wtp_event);
00316 wsp_pdu_destroy(new_pdu);
00317 },
00318 REPLYING)
00319
00320
00321
00322 ROW(PROCESSING,
00323 Abort_Event,
00324 1,
00325 {
00326
00327
00328
00329
00330 method_abort(msm, e->reason);
00331
00332
00333 indicate_method_abort(msm, e->reason);
00334 },
00335 NULL_METHOD)
00336
00337 ROW(PROCESSING,
00338 TR_Abort_Ind,
00339 e->abort_code == WSP_ABORT_DISCONNECT,
00340 {
00341 WAPEvent *wsp_event;
00342
00343
00344 wsp_event = wap_event_create(Disconnect_Event);
00345 wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
00346 gwlist_insert(queue, 0, wsp_event);
00347 },
00348 PROCESSING)
00349
00350 ROW(PROCESSING,
00351 TR_Abort_Ind,
00352 e->abort_code == WSP_ABORT_SUSPEND,
00353 {
00354 WAPEvent *wsp_event;
00355
00356
00357 wsp_event = wap_event_create(Suspend_Event);
00358 wsp_event->u.Suspend_Event.session_handle = msm->session_id;
00359 gwlist_insert(queue, 0, wsp_event);
00360 },
00361 PROCESSING)
00362
00363 ROW(PROCESSING,
00364 TR_Abort_Ind,
00365 e->abort_code != WSP_ABORT_DISCONNECT
00366 && e->abort_code != WSP_ABORT_SUSPEND,
00367 {
00368
00369
00370
00371
00372 indicate_method_abort(msm, e->abort_code);
00373 },
00374 NULL_METHOD)
00375
00376
00377
00378 ROW(REPLYING,
00379 Abort_Event,
00380 1,
00381 {
00382
00383
00384
00385
00386 method_abort(msm, e->reason);
00387
00388
00389 indicate_method_abort(msm, e->reason);
00390 },
00391 NULL_METHOD)
00392
00393 ROW(REPLYING,
00394 TR_Result_Cnf,
00395 1,
00396 {
00397 WAPEvent *new_event;
00398
00399
00400
00401
00402
00403
00404 new_event = wap_event_create(S_MethodResult_Cnf);
00405 new_event->u.S_MethodResult_Cnf.server_transaction_id =
00406 msm->transaction_id;
00407 new_event->u.S_MethodResult_Cnf.session_id = msm->session_id;
00408 dispatch_to_appl(new_event);
00409 },
00410 NULL_METHOD)
00411
00412 ROW(REPLYING,
00413 TR_Abort_Ind,
00414 e->abort_code == WSP_ABORT_DISCONNECT,
00415 {
00416 WAPEvent *wsp_event;
00417
00418
00419 wsp_event = wap_event_create(Disconnect_Event);
00420 wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
00421 gwlist_insert(queue, 0, wsp_event);
00422 },
00423 REPLYING)
00424
00425 ROW(REPLYING,
00426 TR_Abort_Ind,
00427 e->abort_code == WSP_ABORT_SUSPEND,
00428 {
00429 WAPEvent *wsp_event;
00430
00431
00432 wsp_event = wap_event_create(Suspend_Event);
00433 wsp_event->u.Suspend_Event.session_handle = msm->session_id;
00434 gwlist_insert(queue, 0, wsp_event);
00435 },
00436 REPLYING)
00437
00438 ROW(REPLYING,
00439 TR_Abort_Ind,
00440 e->abort_code != WSP_ABORT_DISCONNECT
00441 && e->abort_code != WSP_ABORT_SUSPEND,
00442 {
00443
00444
00445
00446
00447 indicate_method_abort(msm, e->abort_code);
00448 },
00449 NULL_METHOD)
00450
00451 #undef ROW
00452 #undef STATE_NAME
See file LICENSE for details about the license agreement for using,
modifying, copying or deriving work from this software.