Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wsp_server_session_states.def

Go to the documentation of this file.
00001 /* ==================================================================== 
00002  * The Kannel Software License, Version 1.0 
00003  * 
00004  * Copyright (c) 2001-2008 Kannel Group  
00005  * Copyright (c) 1998-2001 WapIT Ltd.   
00006  * All rights reserved. 
00007  * 
00008  * Redistribution and use in source and binary forms, with or without 
00009  * modification, are permitted provided that the following conditions 
00010  * are met: 
00011  * 
00012  * 1. Redistributions of source code must retain the above copyright 
00013  *    notice, this list of conditions and the following disclaimer. 
00014  * 
00015  * 2. Redistributions in binary form must reproduce the above copyright 
00016  *    notice, this list of conditions and the following disclaimer in 
00017  *    the documentation and/or other materials provided with the 
00018  *    distribution. 
00019  * 
00020  * 3. The end-user documentation included with the redistribution, 
00021  *    if any, must include the following acknowledgment: 
00022  *       "This product includes software developed by the 
00023  *        Kannel Group (http://www.kannel.org/)." 
00024  *    Alternately, this acknowledgment may appear in the software itself, 
00025  *    if and wherever such third-party acknowledgments normally appear. 
00026  * 
00027  * 4. The names "Kannel" and "Kannel Group" must not be used to 
00028  *    endorse or promote products derived from this software without 
00029  *    prior written permission. For written permission, please  
00030  *    contact org@kannel.org. 
00031  * 
00032  * 5. Products derived from this software may not be called "Kannel", 
00033  *    nor may "Kannel" appear in their name, without prior written 
00034  *    permission of the Kannel Group. 
00035  * 
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00039  * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS 
00040  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  
00041  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
00042  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
00043  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
00044  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
00045  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  
00046  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00047  * ==================================================================== 
00048  * 
00049  * This software consists of voluntary contributions made by many 
00050  * individuals on behalf of the Kannel Group.  For more information on  
00051  * the Kannel Group, please see <http://www.kannel.org/>. 
00052  * 
00053  * Portions of this software are based upon software originally written at  
00054  * WapIT Ltd., Helsinki, Finland for the Kannel project.  
00055  */ 
00056 
00057 /*
00058  * wsp_server_session_states.def - states for WSP session state machines
00059  *
00060  * Macro calls to generate rows of the state table. See the documentation for
00061  * guidance how to use and update these.
00062  *
00063  * Note that `NULL' state is renamed to `NULL_SESSION' because NULL is
00064  * reserved by C.
00065  *
00066  * Lars Wirzenius
00067  */
00068 
00069 STATE_NAME(NULL_SESSION)
00070 STATE_NAME(CONNECTING)
00071 STATE_NAME(TERMINATING)
00072 STATE_NAME(CONNECTING_2)
00073 STATE_NAME(CONNECTED)
00074 STATE_NAME(SUSPENDED)
00075 STATE_NAME(RESUMING)
00076 STATE_NAME(RESUMING_2)
00077 
00078 ROW(NULL_SESSION,
00079     TR_Invoke_Ind,
00080     e->tcl == 2 && pdu->type == Connect,
00081     {
00082         WAPEvent *new_event;
00083         WAPEvent *wtp_event;
00084 
00085         /* Send TR-Invoke.res to WTP */
00086         wtp_event = wap_event_create(TR_Invoke_Res);
00087         wtp_event->u.TR_Invoke_Res.handle = e->handle;
00088         dispatch_to_wtp_resp(wtp_event);
00089 
00090         /* Assign a session ID for this session.  We do this
00091          * early, instead of in the CONNECTING state, because
00092          * we want to use the session id as a way for the
00093          * application layer to refer back to this machine. */
00094         sm->session_id = next_wsp_session_id();
00095 
00096         if (pdu->u.Connect.capabilities_len > 0) {
00097             unsigned long sdu;
00098             sm->request_caps = wsp_cap_unpack_list(
00099                 pdu->u.Connect.capabilities);
00100             if (wsp_cap_get_client_sdu(sm->request_caps,&sdu)) {
00101                 sm->client_SDU_size = sdu;
00102             }
00103         } else {
00104             sm->request_caps = gwlist_create();
00105         }
00106 
00107         if (pdu->u.Connect.headers_len > 0) {
00108             List *hdrs;
00109             Octstr *encoding;
00110             
00111             hdrs = wsp_headers_unpack(pdu->u.Connect.headers, 0);
00112             http_header_pack(hdrs);
00113             gw_assert(sm->http_headers == NULL);
00114             sm->http_headers = hdrs;
00115 
00116             /*
00117              * Get WSP encoding version if provided by device and remember in
00118              * session machine for later use in encoding tokenized values.
00119              */
00120             encoding = http_header_value(sm->http_headers, octstr_imm("Encoding-Version"));
00121             if (encoding != NULL) {
00122                 debug("wsp",0,"WSP: Session machine: Encoding-Version: %s", 
00123                       octstr_get_cstr(encoding));
00124                 sm->encoding_version = wsp_encoding_string_to_version(encoding);
00125             } else {
00126                 /* WAP-230-WSP-20010705-a, section 8.4.2.70, page 97 defines
00127                  * by a MUST argument that a non-present Encoding-Version header 
00128                  * should be interpreted as WSP 1.2 compliant.
00129                  */
00130                 sm->encoding_version = WSP_1_2; 
00131             }
00132             octstr_destroy(encoding);
00133         }
00134 
00135         /* Send S-Connect.ind to application layer */
00136         new_event = wap_event_create(S_Connect_Ind);
00137         new_event->u.S_Connect_Ind.addr_tuple =
00138             wap_addr_tuple_duplicate(e->addr_tuple);
00139         new_event->u.S_Connect_Ind.client_headers =
00140             http_header_duplicate(sm->http_headers);
00141         new_event->u.S_Connect_Ind.requested_capabilities =
00142             wsp_cap_duplicate_list(sm->request_caps);
00143         new_event->u.S_Connect_Ind.session_id = sm->session_id;
00144         dispatch_to_appl(new_event);
00145     },
00146     CONNECTING)
00147 
00148 
00149 ROW(CONNECTING,
00150     S_Connect_Res,
00151     1,
00152     {
00153         WAPEvent *wtp_event;
00154         Octstr *ospdu;
00155 
00156         sm->reply_caps = wsp_cap_duplicate_list(
00157                 e->negotiated_capabilities);
00158         
00159         /* Send Disconnect event to existing sessions for client. */
00160         disconnect_other_sessions(sm);
00161 
00162         /* Assign a Session_ID for this session. */
00163         /* We've already done that in the NULL_STATE. */
00164 
00165         /* TR-Result.req(ConnectReply) */
00166         ospdu = make_connectreply_pdu(sm);
00167 
00168         wtp_event = wap_event_create(TR_Result_Req);
00169         wtp_event->u.TR_Result_Req.user_data = ospdu;
00170         wtp_event->u.TR_Result_Req.handle = sm->connect_handle;
00171         dispatch_to_wtp_resp(wtp_event);
00172 
00173         /* Release all method transactions in HOLDING state. */
00174         release_holding_methods(sm);
00175     },
00176     CONNECTING_2)
00177 
00178 /* MISSING: CONNECTING, S_Disconnect_Req, reason == 301 (moved permanently) or
00179  * 302 (moved temporarily). */
00180 
00181 /* MISSING: CONNECTING, S_Disconnect_Req, reason == anything else */
00182 
00183 ROW(CONNECTING,
00184     Disconnect_Event,
00185     1,
00186     {
00187         /* TR-Abort.req(DISCONNECT) the Connect transaction */
00188         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00189 
00190         /* Abort(DISCONNECT) all method transactions */
00191         abort_methods(sm, WSP_ABORT_DISCONNECT);
00192 
00193         /* S-Disconnect.ind(DISCONNECT) */
00194         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00195     },
00196     NULL_SESSION)
00197 
00198 ROW(CONNECTING,
00199     Suspend_Event,
00200     1,
00201     {
00202         /* TR-Abort.req(DISCONNECT) the Connect transaction */
00203         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00204 
00205         /* Abort(DISCONNECT) all method transactions */
00206         abort_methods(sm, WSP_ABORT_DISCONNECT);
00207 
00208         /* S-Disconnect.ind(SUSPEND) */
00209         indicate_disconnect(sm, WSP_ABORT_SUSPEND);
00210     },
00211     NULL_SESSION)
00212 
00213 ROW(CONNECTING,
00214     TR_Invoke_Ind,
00215     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
00216     { 
00217         WSPMethodMachine *msm;
00218 
00219         /* Start new method transaction */
00220         msm = method_machine_create(sm, e->handle);
00221 
00222         /* Hand off the event to the new method machine */
00223         handle_method_event(sm, msm, current_event, pdu);
00224     },
00225     CONNECTING)
00226 
00227 ROW(CONNECTING,
00228     TR_Invoke_Ind,
00229     e->tcl == 2 && pdu->type == Resume,
00230     {
00231         /* TR-Abort.req(DISCONNECT) the TR-Invoke */
00232         send_abort(WSP_ABORT_DISCONNECT, e->handle);
00233     },
00234     CONNECTING)
00235         
00236 ROW(CONNECTING,
00237     TR_Abort_Ind,
00238     e->handle == sm->connect_handle,
00239     {
00240         /* Abort(DISCONNECT) all method transactions */
00241         abort_methods(sm, WSP_ABORT_DISCONNECT);
00242 
00243         /* S-Disconnect.ind(abort reason) */
00244         indicate_disconnect(sm, e->abort_code);
00245     },
00246     NULL_SESSION)
00247 
00248 ROW(CONNECTING,
00249     TR_Abort_Ind,
00250     e->handle != sm->connect_handle,
00251     {
00252         WSPMethodMachine *msm;
00253 
00254         /* See method state table  */
00255         msm = find_method_machine(sm, e->handle);
00256         handle_method_event(sm, msm, current_event, pdu);
00257     },
00258     CONNECTING)
00259 
00260 ROW(TERMINATING,
00261     Disconnect_Event,
00262     1,
00263     {
00264         /* TR-Abort.req(DISCONNECT) remaining transport transaction */
00265         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00266     },
00267     NULL_SESSION)
00268         
00269 ROW(TERMINATING,
00270     Suspend_Event,
00271     1,
00272     {
00273         /* TR-Abort.req(SUSPEND) remaining transport transaction */
00274         send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
00275     },
00276     NULL_SESSION)
00277 
00278 ROW(TERMINATING,
00279     TR_Result_Cnf,
00280     1,
00281     {
00282         /* Ignore */
00283     },
00284     NULL_SESSION)
00285 
00286 ROW(TERMINATING,
00287     TR_Abort_Ind,
00288     1,
00289     {
00290         /* Ignore */
00291     },
00292     NULL_SESSION)
00293 
00294 /* MISSING: CONNECTING_2, S-Disconnect.req */
00295 
00296 ROW(CONNECTING_2,
00297     Disconnect_Event,
00298     1,
00299     {
00300         /* TR-Abort.req(DISCONNECT) the Connect transaction */
00301         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00302 
00303         /* Abort(DISCONNECT) all method and push transactions */
00304         abort_methods(sm, WSP_ABORT_DISCONNECT);
00305 
00306         /* S-Disconnect.ind(DISCONNECT) */
00307         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00308     },
00309     NULL_SESSION)
00310 
00311 ROW(CONNECTING_2,
00312     S_MethodInvoke_Res,
00313     1,
00314     {
00315         WSPMethodMachine *msm;
00316 
00317         /* See method state table */
00318         msm = find_method_machine(sm, e->server_transaction_id);
00319         handle_method_event(sm, msm, current_event, pdu);
00320     },
00321     CONNECTING_2)
00322 
00323 ROW(CONNECTING_2,
00324     S_MethodResult_Req,
00325     1,
00326     {
00327         WSPMethodMachine *msm;
00328 
00329         /* See method state table */
00330         msm = find_method_machine(sm, e->server_transaction_id);
00331         handle_method_event(sm, msm, current_event, pdu);
00332     },
00333     CONNECTING_2)
00334 
00335 ROW(CONNECTING_2,
00336         S_Push_Req,
00337         1,
00338         {
00339                 WSP_PDU *pdu;
00340 
00341                 pdu = make_push_pdu(current_event);
00342                 send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
00343         },
00344         CONNECTING_2)
00345 
00346 ROW(CONNECTING_2,
00347         S_ConfirmedPush_Req,
00348         1,
00349         {
00350                 /* Start new push transaction*/
00351                 WSPPushMachine *spm;
00352 
00353                 spm = push_machine_create(sm, e->server_push_id);
00354                 handle_push_event(sm, spm, current_event);   
00355         },
00356         CONNECTING_2)
00357 
00358 ROW(CONNECTING_2,
00359     Suspend_Event,
00360     !resume_enabled,
00361     {
00362         /* Session Resume facility disabled */
00363 
00364         /* TR-Abort.req(DISCONNECT) the Connect transaction */
00365         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00366 
00367         /* Abort(DISCONNECT) all method and push transactions */
00368         abort_methods(sm, WSP_ABORT_DISCONNECT);
00369 
00370         /* S-Disconnect.ind(SUSPEND) */
00371         indicate_disconnect(sm, WSP_ABORT_SUSPEND);
00372     },
00373     NULL_SESSION)
00374 
00375 ROW(CONNECTING_2,
00376     Suspend_Event,
00377     resume_enabled,
00378     {
00379         /* Session Resume facility enabled */
00380 
00381         /* TR-Abort.req(SUSPEND) the Connect transaction */
00382         send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
00383 
00384         /* Abort(SUSPEND) all method and push transactions */
00385         abort_methods(sm, WSP_ABORT_SUSPEND);
00386 
00387         /* S-Suspend.ind(SUSPEND) */
00388         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00389     },
00390     SUSPENDED)
00391 
00392 ROW(CONNECTING_2,
00393     TR_Invoke_Ind,
00394     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
00395     {
00396         WSPMethodMachine *msm;
00397         WAPEvent *new_event;
00398 
00399         /* Start new method transaction */
00400         msm = method_machine_create(sm, e->handle);
00401 
00402         /* Hand off the event to the new method machine */
00403         handle_method_event(sm, msm, current_event, pdu);
00404 
00405         /* Release the new method transaction */
00406         new_event = wap_event_create(Release_Event);
00407         handle_method_event(sm, msm, new_event, NULL);
00408         wap_event_destroy(new_event);
00409     },
00410     CONNECTING_2)
00411 
00412 ROW(CONNECTING_2,
00413     TR_Invoke_Ind,
00414     e->tcl == 2 && pdu->type == Resume && !resume_enabled,
00415     {
00416         /* Resume facility disabled */
00417 
00418         /* TR-Abort.req(DISCONNECT) the TR-Invoke */
00419         send_abort(WSP_ABORT_DISCONNECT, e->handle);
00420     },
00421     CONNECTING_2)
00422 
00423 ROW(CONNECTING_2,
00424     TR_Invoke_Ind,
00425     e->tcl == 2 && pdu->type == Resume && resume_enabled,
00426     {
00427         /* Resume facility enabled */
00428 
00429         WAPEvent *wtp_event;
00430         List *new_headers;
00431 
00432         /* TR-Invoke.res */
00433         wtp_event = wap_event_create(TR_Invoke_Res);
00434         wtp_event->u.TR_Invoke_Res.handle = e->handle;
00435         dispatch_to_wtp_resp(wtp_event);
00436 
00437         /* TR-Abort.req(RESUME) the Connect transaction */
00438         send_abort(WSP_ABORT_RESUME, sm->connect_handle);
00439 
00440         /* Abort(RESUME) all method and push transactions */
00441         abort_methods(sm, WSP_ABORT_RESUME);
00442 
00443         /* S-Suspend.ind(RESUME) */
00444         indicate_suspend(sm, WSP_ABORT_RESUME);
00445 
00446         /* S-Resume.ind */
00447         new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
00448         indicate_resume(sm, e->addr_tuple, new_headers);
00449         http_destroy_headers(new_headers);
00450 
00451         sm->resume_handle = e->handle;
00452     },
00453     RESUMING)
00454 
00455 ROW(CONNECTING_2,
00456     TR_Invoke_Ind,
00457     e->tcl == 0 && pdu->type == Disconnect,
00458     {
00459         /* TR-Abort.req(DISCONNECT) the Connect transaction */
00460         send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
00461 
00462         /* Abort(DISCONNECT) all method and push transactions */
00463         abort_methods(sm, WSP_ABORT_DISCONNECT);
00464 
00465         /* S-Disconnect.ind(DISCONNECT) */
00466         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00467     },
00468     NULL_SESSION)
00469 
00470 ROW(CONNECTING_2,
00471     TR_Invoke_Ind,
00472     e->tcl == 0 && pdu->type == Suspend && resume_enabled,
00473     {
00474         /* Resume facility enabled */
00475 
00476         /* TR-Abort.req(SUSPEND) the Connect transaction */
00477         send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
00478 
00479         /* Abort(SUSPEND) all method and push transactions */
00480         abort_methods(sm, WSP_ABORT_SUSPEND);
00481 
00482         /* S-Suspend.ind(SUSPEND) */
00483         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00484     },
00485     SUSPENDED)
00486 
00487 ROW(CONNECTING_2,
00488         TR_Invoke_Cnf,
00489         1,
00490         {
00491                 /* See push state table*/
00492                 WSPPushMachine *spm;
00493 
00494                 spm = find_push_machine(sm, e->handle);
00495                 handle_push_event(sm, spm, current_event);
00496         },
00497         CONNECTING_2)
00498 
00499 ROW(CONNECTING_2,
00500     TR_Result_Cnf,
00501     e->handle == sm->connect_handle,
00502     {
00503     },
00504     CONNECTED)
00505 
00506 ROW(CONNECTING_2,
00507     TR_Result_Cnf,
00508     e->handle != sm->connect_handle,
00509     {
00510         WSPMethodMachine *msm;
00511 
00512         /* See method state table */
00513         msm = find_method_machine(sm, e->handle);
00514         handle_method_event(sm, msm, current_event, pdu);
00515     },
00516     CONNECTING_2)
00517 
00518 ROW(CONNECTING_2,
00519     TR_Abort_Ind,
00520     e->handle == sm->connect_handle,
00521     {
00522         /* Abort(DISCONNECT) all method and push transactions */
00523         abort_methods(sm, WSP_ABORT_DISCONNECT);
00524 
00525         /* S-Disconnect.ind(abort reason) */
00526         indicate_disconnect(sm, e->abort_code);
00527     },
00528     NULL_SESSION)
00529 
00530 /* 
00531  * A separate flag tells is the indicator the initiator or the responder.
00532  */
00533 
00534 ROW(CONNECTING_2,
00535     TR_Abort_Ind,
00536     e->handle != sm->connect_handle && e->ir_flag == RESPONDER_INDICATION,
00537     {
00538         WSPMethodMachine *msm;
00539 
00540         /* See method state table */
00541         msm = find_method_machine(sm, e->handle);
00542         handle_method_event(sm, msm, current_event, pdu);
00543     },
00544     CONNECTING_2)
00545 
00546 ROW(CONNECTING_2,
00547     TR_Abort_Ind,
00548     e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
00549     {
00550         WSPPushMachine *m;
00551 
00552         /* See push state table */
00553         m = find_push_machine(sm, e->handle);
00554         handle_push_event(sm, m, current_event);
00555     },
00556     CONNECTING_2)
00557 
00558 /* MISSING: CONNECTED, S-Disconnect.req */
00559 
00560 ROW(CONNECTED,
00561     Disconnect_Event,
00562     1,
00563     {
00564         /* Abort(DISCONNECT) all method and push transactions */
00565         abort_methods(sm, WSP_ABORT_DISCONNECT);
00566 
00567         /* S-Disconnect.ind(DISCONNECT) */
00568         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00569     },
00570     NULL_SESSION)
00571 
00572 ROW(CONNECTED,
00573     S_MethodInvoke_Res,
00574     1,
00575     {
00576         WSPMethodMachine *msm;
00577 
00578         /* See method state table */
00579         msm = find_method_machine(sm, e->server_transaction_id);
00580         handle_method_event(sm, msm, current_event, pdu);
00581     },
00582     CONNECTED)
00583         
00584 ROW(CONNECTED,
00585     S_MethodResult_Req,
00586     1,
00587     {
00588         WSPMethodMachine *msm;
00589 
00590         /* See method state table */
00591         msm = find_method_machine(sm, e->server_transaction_id);
00592         handle_method_event(sm, msm, current_event, pdu);
00593     },
00594     CONNECTED)
00595 
00596 ROW(CONNECTED,
00597         S_Push_Req,
00598         1,
00599         {
00600                WSP_PDU *pdu;
00601 
00602                pdu = make_push_pdu(current_event);
00603                send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
00604         },
00605         CONNECTED)
00606 
00607 ROW(CONNECTED,
00608         S_ConfirmedPush_Req,
00609         1,
00610         {
00611                /* Start new push transaction*/
00612                 WSPPushMachine *spm;
00613 
00614                 spm = push_machine_create(sm, e->server_push_id);
00615                 handle_push_event(sm, spm, current_event);
00616         },
00617         CONNECTED)
00618 
00619 ROW(CONNECTED,
00620     Suspend_Event,
00621     !resume_enabled,
00622     {
00623         /* Session Resume facility disabled */
00624 
00625         /* Abort(SUSPEND) all method and push transactions */
00626         abort_methods(sm, WSP_ABORT_SUSPEND);
00627 
00628         /* S-Disconnect.ind(SUSPEND) */
00629         indicate_disconnect(sm, WSP_ABORT_SUSPEND);
00630     },
00631     NULL_SESSION)
00632 
00633 ROW(CONNECTED,
00634     Suspend_Event,
00635     resume_enabled,
00636     {
00637         /* Session Resume facility enabled */
00638 
00639         /* Abort(SUSPEND) all method and push transactions */
00640         abort_methods(sm, WSP_ABORT_SUSPEND);
00641 
00642         /* S-Suspend.ind(SUSPEND) */
00643         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00644     },
00645     SUSPENDED)
00646 
00647 ROW(CONNECTED,
00648     TR_Invoke_Ind,
00649     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
00650     {
00651         WSPMethodMachine *msm;
00652         WAPEvent *new_event;
00653 
00654         /* Start new method transaction */
00655         msm = method_machine_create(sm, e->handle);
00656 
00657         /* Hand off the event to the new method machine */
00658         handle_method_event(sm, msm, current_event, pdu);
00659 
00660         /* Release the new method transaction */
00661         new_event = wap_event_create(Release_Event);
00662         handle_method_event(sm, msm, new_event, NULL);
00663         wap_event_destroy(new_event);
00664     },
00665     CONNECTED)
00666 
00667 ROW(CONNECTED,
00668     TR_Invoke_Ind,
00669     e->tcl == 2 && pdu->type == Resume && !resume_enabled,
00670     {
00671         /* Resume facility disabled */
00672 
00673         /* TR-Abort.req(DISCONNECT) the TR-Invoke */
00674         send_abort(WSP_ABORT_DISCONNECT, e->handle);
00675     },
00676     CONNECTED)
00677 
00678 ROW(CONNECTED,
00679     TR_Invoke_Ind,
00680     e->tcl == 2 && pdu->type == Resume && resume_enabled,
00681     {
00682         /* Resume facility enabled */
00683 
00684         WAPEvent *wtp_event;
00685         List *new_headers;
00686 
00687         /* TR-Invoke.res */
00688         wtp_event = wap_event_create(TR_Invoke_Res);
00689         wtp_event->u.TR_Invoke_Res.handle = e->handle;
00690         dispatch_to_wtp_resp(wtp_event);
00691 
00692         /* Abort(RESUME) all method and push transactions */
00693         abort_methods(sm, WSP_ABORT_RESUME);
00694 
00695         /* S-Suspend.ind(RESUME) */
00696         indicate_suspend(sm, WSP_ABORT_RESUME);
00697 
00698         /* S-Resume.ind */
00699         new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
00700         indicate_resume(sm, e->addr_tuple, new_headers);
00701         http_destroy_headers(new_headers);
00702 
00703         sm->resume_handle = e->handle;
00704     },
00705     RESUMING)
00706 
00707 ROW(CONNECTED,
00708     TR_Invoke_Ind,
00709     e->tcl == 0 && pdu->type == Disconnect,
00710     {
00711         /* Abort(DISCONNECT) all method and push transactions */
00712         abort_methods(sm, WSP_ABORT_DISCONNECT);
00713 
00714         /* S-Disconnect.ind(DISCONNECT) */
00715         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00716     },
00717     NULL_SESSION)
00718 
00719 ROW(CONNECTED,
00720     TR_Invoke_Ind,
00721     e->tcl == 0 && pdu->type == Suspend && resume_enabled,
00722     {
00723         /* Abort(SUSPEND) all method and push transactions */
00724         abort_methods(sm, WSP_ABORT_SUSPEND);
00725 
00726         /* S-Suspend.ind(SUSPEND) */
00727         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00728     },
00729     SUSPENDED)
00730 
00731 ROW(CONNECTED,
00732        TR_Invoke_Cnf,
00733        1,
00734        {
00735                 /* See push state table*/
00736                 WSPPushMachine *spm;
00737 
00738                 spm = find_push_machine(sm, e->handle);
00739                 handle_push_event(sm, spm, current_event);
00740        },
00741        CONNECTED)
00742 
00743 ROW(CONNECTED,
00744     TR_Result_Cnf,
00745     e->handle != sm->connect_handle,
00746     {
00747         WSPMethodMachine *msm;
00748 
00749         /* See method state table */
00750         msm = find_method_machine(sm, e->handle);
00751         handle_method_event(sm, msm, current_event, pdu);
00752     },
00753     CONNECTED)
00754         
00755 /* 
00756  * Event TR-Abort.ind has a separate flag telling is the indicator the 
00757  * initiator or the responder.
00758  */
00759 ROW(CONNECTED,
00760     TR_Abort_Ind,
00761     e->handle != sm->connect_handle  && e->ir_flag == RESPONDER_INDICATION,
00762     {
00763         WSPMethodMachine *msm;
00764 
00765         /* See method state table */
00766         msm = find_method_machine(sm, e->handle);
00767         handle_method_event(sm, msm, current_event, pdu);
00768     },
00769     CONNECTED)
00770 
00771 ROW(CONNECTED,
00772     TR_Abort_Ind,
00773     e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
00774     {
00775         WSPPushMachine *m;
00776 
00777         /* See push state table */
00778         m = find_push_machine(sm, e->handle);
00779         handle_push_event(sm, m, current_event);
00780     },
00781     CONNECTED)
00782 
00783 /* MISSING: SUSPENDED, S-Disconnect.req */
00784 
00785 ROW(SUSPENDED,
00786     Disconnect_Event,
00787     1,
00788     {
00789         /* S-Disconnect.ind(DISCONNECT) */
00790         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00791     },
00792     NULL_SESSION)
00793 
00794 ROW(SUSPENDED,
00795     TR_Invoke_Ind,
00796     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
00797     {
00798         /* TR-Abort.req(SUSPEND) the TR-Invoke */
00799         send_abort(WSP_ABORT_SUSPEND, e->handle);
00800     },
00801     SUSPENDED)
00802 
00803 ROW(SUSPENDED,
00804     TR_Invoke_Ind,
00805     e->tcl == 2 && pdu->type == Resume,
00806     {
00807         WAPEvent *wtp_event;
00808         List *new_headers;
00809 
00810         /* TR-Invoke.res */
00811         wtp_event = wap_event_create(TR_Invoke_Res);
00812         wtp_event->u.TR_Invoke_Res.handle = e->handle;
00813         dispatch_to_wtp_resp(wtp_event);
00814 
00815         /* S-Resume.ind */
00816         new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
00817         indicate_resume(sm, e->addr_tuple, new_headers);
00818         http_destroy_headers(new_headers);
00819 
00820 
00821         sm->resume_handle = e->handle;
00822     },
00823     RESUMING)
00824 
00825 ROW(SUSPENDED,
00826     TR_Invoke_Ind,
00827     e->tcl == 0 && pdu->type == Disconnect,
00828     {
00829         /* S-Disconnect.ind(DISCONNECT) */
00830         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00831     },
00832     NULL_SESSION)
00833 
00834 /* MISSING: RESUMING, S-Disconnect.req */
00835 
00836 ROW(RESUMING,
00837     Disconnect_Event,
00838     1,
00839     {
00840         /* TR-Abort.req(DISCONNECT) the Resume transaction */
00841         send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
00842 
00843         /* Abort(DISCONNECT) all method transactions */
00844         abort_methods(sm, WSP_ABORT_DISCONNECT);
00845 
00846         /* S-Disconnect.ind(DISCONNECT) */
00847         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00848     },
00849     NULL_SESSION)
00850 
00851 ROW(RESUMING,
00852     S_Resume_Res,
00853     1,
00854     {
00855         WAPEvent *wtp_event;
00856         Octstr *ospdu;
00857 
00858         /* Disconnect any other session for the peer address quadruplet */
00859         disconnect_other_sessions(sm);
00860 
00861         /* Bind session to new peer address quadruplet */
00862         /* this happens automatically XXX Not true */
00863 
00864         /* TR-Result.req(Reply) */
00865         if (e->server_headers == NULL)
00866             e->server_headers = http_create_empty_headers();
00867 
00868         ospdu = make_resume_reply_pdu(sm, e->server_headers);
00869         wtp_event = wap_event_create(TR_Result_Req);
00870         wtp_event->u.TR_Result_Req.user_data = ospdu;
00871         wtp_event->u.TR_Result_Req.handle = sm->resume_handle;
00872         dispatch_to_wtp_resp(wtp_event);
00873         
00874         /* Release all method transactions in HOLDING state */
00875         release_holding_methods(sm);
00876     },
00877     RESUMING_2)
00878 
00879 ROW(RESUMING,
00880     Suspend_Event,
00881     1,
00882     {
00883         /* TR-Abort.req(SUSPEND) the Resume transaction */
00884         send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
00885 
00886         /* Abort(SUSPEND) all method transactions */
00887         abort_methods(sm, WSP_ABORT_SUSPEND);
00888 
00889         /* S-Suspend.ind(SUSPEND) */
00890         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00891     },
00892     SUSPENDED)
00893 
00894 ROW(RESUMING,
00895     TR_Invoke_Ind,
00896     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
00897     {
00898         /* Start new method transaction (see method state table) */
00899         WSPMethodMachine *msm;
00900         msm = method_machine_create(sm, e->handle);
00901         handle_method_event(sm, msm, current_event, pdu);
00902     },
00903     RESUMING)
00904 
00905 ROW(RESUMING,
00906     TR_Invoke_Ind,
00907     e->tcl == 2 && pdu->type == Resume,
00908     {
00909         WAPEvent *wtp_event;
00910         List *new_headers;
00911 
00912         /* TR-Invoke.res */
00913         wtp_event = wap_event_create(TR_Invoke_Res);
00914         wtp_event->u.TR_Invoke_Res.handle = e->handle;
00915         dispatch_to_wtp_resp(wtp_event);
00916 
00917         /* TR-Abort.req(RESUME) the old Resume transaction */
00918         send_abort(WSP_ABORT_RESUME, sm->resume_handle);
00919 
00920         /* Abort(RESUME) all method transactions */
00921         abort_methods(sm, WSP_ABORT_RESUME);
00922 
00923         /* S-Suspend.ind(RESUME) */
00924         indicate_suspend(sm, WSP_ABORT_RESUME);
00925 
00926         /* S-Resume.ind */
00927         new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
00928         indicate_resume(sm, e->addr_tuple, new_headers);
00929         http_destroy_headers(new_headers);
00930 
00931 
00932         sm->resume_handle = e->handle;
00933     },
00934     RESUMING)
00935 
00936 ROW(RESUMING,
00937     TR_Invoke_Ind,
00938     e->tcl == 0 && pdu->type == Suspend,
00939     {
00940         /* TR-Abort.req(SUSPEND) the Resume transaction */
00941         send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
00942 
00943         /* Abort(SUSPEND) all method transactions */
00944         abort_methods(sm, WSP_ABORT_SUSPEND);
00945 
00946         /* S-Suspend.ind(SUSPEND) */
00947         indicate_suspend(sm, WSP_ABORT_SUSPEND);
00948     },
00949     SUSPENDED)
00950 
00951 ROW(RESUMING,
00952     TR_Invoke_Ind,
00953     e->tcl == 0 && pdu->type == Disconnect,
00954     {
00955         /* TR-Abort.req(DISCONNECT) the Resume transaction */
00956         send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
00957 
00958         /* Abort(DISCONNECT) all method transactions */
00959         abort_methods(sm, WSP_ABORT_DISCONNECT);
00960 
00961         /* S-Disconnect.ind(DISCONNECT) */
00962         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00963     },
00964     NULL_SESSION)
00965 
00966 ROW(RESUMING,
00967     TR_Abort_Ind,
00968     e->handle == sm->resume_handle,
00969     {
00970         /* Abort(SUSPEND) all method transactions */
00971         abort_methods(sm, WSP_ABORT_SUSPEND);
00972 
00973         /* S-Suspend.ind(abort reason) */
00974         indicate_suspend(sm, e->abort_code);
00975     },
00976     SUSPENDED)
00977 
00978 /* MISSING: RESUMING_2, S-Disconnect.req */
00979 
00980 ROW(RESUMING_2,
00981     Disconnect_Event,
00982     1,
00983     {
00984         /* TR-Abort.req(DISCONNECT) the Resume */
00985         send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
00986 
00987         /* Abort(DISCONNECT) all method and push transactions */
00988         abort_methods(sm, WSP_ABORT_DISCONNECT);
00989 
00990         /* S-Disconnect.ind(DISCONNECT) */
00991         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
00992     },
00993     NULL_SESSION)
00994 
00995 ROW(RESUMING_2,
00996     S_MethodInvoke_Res,
00997     1,
00998     {
00999         WSPMethodMachine *msm;
01000 
01001         /* See method state table */
01002         msm = find_method_machine(sm, e->server_transaction_id);
01003         handle_method_event(sm, msm, current_event, pdu);
01004     },
01005     RESUMING_2)
01006 
01007 ROW(RESUMING_2,
01008     S_MethodResult_Req,
01009     1,
01010     {
01011         WSPMethodMachine *msm;
01012 
01013         /* See method state table */
01014         msm = find_method_machine(sm, e->server_transaction_id);
01015         handle_method_event(sm, msm, current_event, pdu);
01016     },
01017     RESUMING_2)
01018 
01019 ROW(RESUMING_2,
01020         S_Push_Req,
01021         1,
01022         {
01023                 WSP_PDU *pdu;
01024 
01025                 pdu = make_push_pdu(current_event);
01026                 send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
01027         },
01028         RESUMING_2)
01029 
01030 ROW(RESUMING_2,
01031         S_ConfirmedPush_Req,
01032         1,
01033         {
01034                 /* Start new push transaction*/
01035                 WSPPushMachine *spm;
01036 
01037                 spm = push_machine_create(sm, e->server_push_id);
01038                 handle_push_event(sm, spm, current_event);
01039         },
01040         RESUMING_2)
01041 
01042 ROW(RESUMING_2,
01043     Suspend_Event,
01044     1,
01045     {
01046         /* TR-Abort.req(SUSPEND) the Resume transaction */
01047         send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
01048 
01049         /* Abort(SUSPEND) all method and push transactions */
01050         abort_methods(sm, WSP_ABORT_SUSPEND);
01051 
01052         /* S-Suspend.ind(SUSPEND) */
01053         indicate_suspend(sm, WSP_ABORT_SUSPEND);
01054     },
01055     SUSPENDED)
01056 
01057 ROW(RESUMING_2,
01058     TR_Invoke_Ind,
01059     e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
01060     {
01061         WSPMethodMachine *msm;
01062         WAPEvent *new_event;
01063 
01064         /* Start new method transaction (see method state table) */
01065         msm = method_machine_create(sm, e->handle);
01066         handle_method_event(sm, msm, current_event, pdu);
01067 
01068         /* Release the new method transaction */
01069         new_event = wap_event_create(Release_Event);
01070         handle_method_event(sm, msm, new_event, NULL);
01071         wap_event_destroy(new_event);
01072     },
01073     RESUMING_2)
01074 
01075 ROW(RESUMING_2,
01076     TR_Invoke_Ind,
01077     e->tcl == 2 && pdu->type == Resume,
01078     {
01079         WAPEvent *wtp_event;
01080         List *new_headers;
01081 
01082         /* TR-Invoke.res */
01083         wtp_event = wap_event_create(TR_Invoke_Res);
01084         wtp_event->u.TR_Invoke_Res.handle = e->handle;
01085         dispatch_to_wtp_resp(wtp_event);
01086 
01087         /* TR-Abort.req(RESUME) the old Resume transaction*/
01088         send_abort(WSP_ABORT_RESUME, sm->resume_handle);
01089 
01090         /* Abort(RESUME) all method and push transactions */
01091         abort_methods(sm, WSP_ABORT_RESUME);
01092 
01093         /* S-Suspend.ind(RESUME) */
01094         indicate_suspend(sm, WSP_ABORT_RESUME);
01095 
01096         /* S-Resume.ind */
01097         new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
01098         indicate_resume(sm, e->addr_tuple, new_headers);
01099         http_destroy_headers(new_headers);
01100 
01101 
01102         sm->resume_handle = e->handle;
01103     },
01104     RESUMING)
01105 
01106 ROW(RESUMING_2,
01107     TR_Invoke_Ind,
01108     e->tcl == 0 && pdu->type == Suspend,
01109     {
01110         /* TR-Abort.req(SUSPEND) the Resume transaction */
01111         send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
01112 
01113         /* Abort(SUSPEND) all method and push transactions */
01114         abort_methods(sm, WSP_ABORT_SUSPEND);
01115 
01116         /* S-Suspend.ind(SUSPEND) */
01117         indicate_suspend(sm, WSP_ABORT_SUSPEND);
01118     },
01119     SUSPENDED)
01120 
01121 ROW(RESUMING_2,
01122     TR_Invoke_Ind,
01123     e->tcl == 0 && pdu->type == Disconnect,
01124     {
01125         /* TR-Abort.req(DISCONNECT) the Resume */
01126         send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
01127 
01128         /* Abort(DISCONNECT) all method and push transactions */
01129         abort_methods(sm, WSP_ABORT_DISCONNECT);
01130 
01131         /* S-Disconnect.ind(DISCONNECT) */
01132         indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
01133     },
01134     NULL_SESSION)
01135 
01136 ROW(RESUMING_2,
01137         TR_Invoke_Cnf,
01138         1,
01139         {
01140                 /* See push state table*/
01141                 WSPPushMachine *spm;
01142 
01143                 spm = find_push_machine(sm, e->handle);
01144                 handle_push_event(sm, spm, current_event);
01145         },
01146         RESUMING_2)
01147 
01148 ROW(RESUMING_2,
01149     TR_Result_Cnf,
01150     e->handle == sm->resume_handle,
01151     {
01152     },
01153     CONNECTED)
01154 
01155 ROW(RESUMING_2,
01156     TR_Result_Cnf,
01157     e->handle != sm->resume_handle,
01158     {
01159         WSPMethodMachine *msm;
01160 
01161         /* See method state table */
01162         msm = find_method_machine(sm, e->handle);
01163         handle_method_event(sm, msm, current_event, pdu);
01164     },
01165     RESUMING_2)
01166 
01167 ROW(RESUMING_2,
01168     TR_Abort_Ind,
01169     e->handle == sm->resume_handle,
01170     {
01171         /* Abort(SUSPEND) all method and push transactions */
01172         abort_methods(sm, WSP_ABORT_SUSPEND);
01173 
01174         /* S-Suspend.ind(abort reason) */
01175         indicate_suspend(sm, e->abort_code);
01176     },
01177     SUSPENDED)
01178 
01179 /* 
01180  * A separate flag tells is the indicator the initiator or the responder
01181  */
01182 
01183 ROW(RESUMING_2,
01184     TR_Abort_Ind,
01185     e->handle != sm->resume_handle && e->ir_flag == RESPONDER_INDICATION,
01186     {
01187         WSPMethodMachine *msm;
01188 
01189         /* See method state table */
01190         msm = find_method_machine(sm, e->handle);
01191         handle_method_event(sm, msm, current_event, pdu);
01192     },
01193     RESUMING_2)
01194 
01195 ROW(CONNECTING_2,
01196     TR_Abort_Ind,
01197     e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
01198     {
01199         WSPPushMachine *m;
01200 
01201         /* See push state table */
01202         m = find_push_machine(sm, e->handle);
01203         handle_push_event(sm, m, current_event);
01204     },
01205     CONNECTING_2)
01206 
01207 #undef ROW
01208 #undef STATE_NAME
01209 
01210 
01211 
01212 
01213 
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.