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

wsp_server_method_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_method_states.def
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 the `NULL' state has been renamed to `NULL_METHOD' because
00064  * NULL is reserved by C.
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 /* MISSING: TR_Invoke.ind, N_Methods == MOM */
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         /* Prepare the MethodInvoke here, because we have all
00085          * the information nicely available. */
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         /* Prepare the MethodInvoke here, because we have all
00127          * the information nicely available. */
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         /* S-MethodInvoke.ind */
00167         dispatch_to_appl(msm->invoke);
00168         msm->invoke = NULL;
00169     },
00170     REQUESTING)
00171 
00172 ROW(HOLDING,
00173     Abort_Event,
00174     1,
00175     {
00176         /* Decrement N_Methods */
00177         /* we don't keep track of N_Methods because it's unlimited */
00178 
00179         /* Tr-Abort.req(abort reason) the method */
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         /* Disconnect the session */
00191         wsp_event = wap_event_create(Disconnect_Event);
00192         wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
00193         /* We put this on the queue instead of doing it right away,
00194          * because the session machine is currently our caller and
00195          * we don't want to recurse.  We put it in the front of
00196          * the queue because the state machine definitions expect
00197          * an event to be handled completely before the next is
00198          * started. */
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         /* Suspend the session */
00210         wsp_event = wap_event_create(Suspend_Event);
00211         wsp_event->u.Suspend_Event.session_handle = msm->session_id;
00212         /* See story for Disconnect, above */
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         /* Decrement N_Methods */
00223         /* we don't keep track of N_Methods because it's unlimited */
00224     },
00225     NULL_METHOD)
00226 
00227 ROW(REQUESTING,
00228     S_MethodInvoke_Res,
00229     1,
00230     {
00231         WAPEvent *wtp_event;
00232         
00233         /* Send TR-Invoke.res to WTP */
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 /* MISSING: REQUESTING, S-MethodAbort.req */
00241 
00242 ROW(REQUESTING,
00243     Abort_Event,
00244     1,
00245     {
00246         /* Decrement N_Methods */
00247         /* we don't keep track of N_Methods because it's unlimited */
00248 
00249         /* TR-Abort.req(abort reason) the method */
00250         method_abort(msm, e->reason);
00251 
00252         /* S-MethodAbort.ind(abort reason) */
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         /* Disconnect the session */
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         /* Suspend the session */
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         /* Decrement N_Methods */
00289         /* we don't keep track of N_Methods because it's unlimited */
00290 
00291         /* S-MethodAbort.ind(abort reason) */
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         /* TR-Result.req */
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         /* Send TR-Result.req to WTP */
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 /* MISSING: PROCESSING, S-MethodAbort.req */
00321 
00322 ROW(PROCESSING,
00323     Abort_Event,
00324     1,
00325     {
00326         /* Decrement N_Methods */
00327         /* we don't keep track of N_Methods because it's unlimited */
00328 
00329         /* TR-Abort.req(abort reason) the method */
00330         method_abort(msm, e->reason);
00331 
00332         /* S-MethodAbort.ind(abort reason) */
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         /* Disconnect the session */
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         /* Suspend the session */
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         /* Decrement N_Methods */
00369         /* we don't keep track of N_Methods because it's unlimited */
00370 
00371         /* S-MethodAbort.ind(abort reason) */
00372         indicate_method_abort(msm, e->abort_code);
00373     },
00374     NULL_METHOD)
00375 
00376 /* MISSING: REPLYING, S-MethodAbort.req */
00377 
00378 ROW(REPLYING,
00379     Abort_Event,
00380     1,
00381     {
00382         /* Decrement N_Methods */
00383         /* we don't keep track of N_Methods because it's unlimited */
00384 
00385         /* TR-Abort.req(abort reason) the method */
00386         method_abort(msm, e->reason);
00387 
00388         /* S-MethodAbort.ind(abort reason) */
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         /* Decrement N_Methods */
00400         /* we don't keep track of N_Methods because it's unlimited */
00401 
00402         /* S-MethodResult.cnf */
00403         /* we don't do acknowledgement headers */
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         /* Disconnect the session */
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         /* Suspend the session */
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         /* Decrement N_Methods */
00444         /* we don't keep track of N_Methods because it's unlimited */
00445 
00446         /* S-MethodAbort.ind(abort reason) */
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.