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

wap.h

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  * wap.h - public interface to WAP protocol library
00059  *
00060  * The WAP protocol library consists of separate layers, which each run
00061  * in their own thread.  The layers are normally used together and will
00062  * communicate with each other, but they can be used separately by
00063  * specialized applications.
00064  *
00065  * Communication between layers is done by sending WAPEvent structures.
00066  * These events are passed to dispatch functions.  Each layer has its
00067  * own dispatch function which is responsible for queueing the event
00068  * for that layer.
00069  * 
00070  * The application using this library has to provide an application layer
00071  * and a datagram layer.  These layers do not have to be implemented in
00072  * any particular way and do not have to run in their own threads, but
00073  * they do have to provide dispatch functions.
00074  *
00075  * In general, if a layer receives an event that it does not know how
00076  * to handle, it will report this and ignore the event.
00077  */
00078 
00079 #ifndef WAP_H
00080 #define WAP_H
00081 
00082 #include "wap_events.h"
00083 #include "wap_addr.h"
00084 
00085 typedef void wap_dispatch_func_t(WAPEvent *event);
00086 
00087 /*
00088  * Generic dispatch function that takes T_DUnitdata_Ind events and
00089  * figures out to which layer they should be sent, by recognizing
00090  * well-known port numbers and by inspecting the datagram contents.
00091  * It also unpacks WTP events before dispatching, so that the WTP
00092  * thread is not burdened by this.
00093  */
00094 void wap_dispatch_datagram(WAPEvent *event);
00095 
00096 /*
00097  * Generic startup function that initializes all the layers and
00098  * chains their dispatch functions together.
00099  */
00100 void wap_init(wap_dispatch_func_t *datagram_dispatch,
00101               wap_dispatch_func_t *application_dispatch);
00102 
00103 /*
00104  * Undoes what wap_init did.
00105  */
00106 void wap_shutdown(void);
00107 
00108 
00109 /*
00110  * Datagram layer
00111  *
00112  * This layer is not provided by libwap itself.  The application is
00113  * expected to create one, by:
00114  *  - providing a dispatch function that takes T_DUnitdata_Req
00115  *    events (outgoing datagrams)
00116  *  - passing incoming datagrams to the right layer, either by
00117  *    calling the layer's dispatch function directly or by calling
00118  *    wap_dispatch_datagram().
00119  */
00120 
00121 
00122 /*
00123  * Transaction layer, responder
00124  *
00125  * This layer implements the Responder side of WTP.
00126  * Its dispatch function takes events of these types:
00127  *
00128  *   RcvInvoke, RcvAck, RcvAbort, RcvErrorPDU,
00129  *   TR_Invoke_Res, TR_Result_Req, TR_Abort_Req,
00130  *   TimerTO_A, TimerTO_R, TimerTO_W
00131  *
00132  * FIXME It also takes T_DUnitdata_Ind events, which it will unpack into one
00133  * of the Rcv* events and then process.
00134  *
00135  * This layer will dispatch T_DUnitdata_Req events to the datagram layer,
00136  * and these event types to the session layer:
00137  *
00138  *   TR_Invoke_Ind, TR_Result_Cnf, TR_Abort_Ind
00139  *
00140  * Timer_freq is the timer 'tick' used. All wtp responder timers are 
00141  * multiplies of this value.
00142  */
00143 void wtp_resp_init(wap_dispatch_func_t *datagram_dispatch,
00144                    wap_dispatch_func_t *session_dispatch,
00145                    wap_dispatch_func_t *push_dispatch, 
00146                    long timer_freq);
00147 void wtp_resp_dispatch_event(WAPEvent *event);
00148 void wtp_resp_shutdown(void);
00149 
00150 /*
00151  * Transaction layer, initiator
00152  *
00153  * This layer implements the Initiator side of WTP.
00154  * FIXME Currently only class 0 and 1 are implemented.
00155  * Its dispatch function takes events of these types:
00156  *
00157  *   RcvAck, RcvAbort, RcvErrorPDU
00158  *   TR_Invoke_Req, TR_Abort_Req
00159  *   TimerTO_R
00160  *
00161  * FIXME It also takes T_DUnitdata_Ind events, which it will unpack into one
00162  * of the Rcv* events and then process.
00163  *
00164  * This layer will dispatch T_DUnitdata_Req events to the datagram layer,
00165  * and these event types to the session layer:
00166  *
00167  *   TR_Invoke_Cnf, TR_Abort_Ind
00168  *
00169  * Timer_freq is a timer 'tick'. All initiator timer values are multiplies 
00170  * of it.
00171  */
00172 void wtp_initiator_init(wap_dispatch_func_t *datagram_dispatch,
00173                         wap_dispatch_func_t *session_dispatch,
00174                         long timer_freq);
00175 void wtp_initiator_dispatch_event(WAPEvent *event);
00176 void wtp_initiator_shutdown(void);
00177 
00178 /*
00179  * Session layer, connectionless mode
00180  *
00181  * This layer implements Connectionless WSP.
00182  * FIXME Currently only the server side is implemented.
00183  * Its dispatch function takes events of these types:
00184  *
00185  *   T_DUnitdata_Ind
00186  *   S_Unit_MethodResult_Req
00187  *
00188  * This layer will dispatch T_DUnitdata_Req events to the datagram layer,
00189  * and S_Unit_MethodInvoke_Ind events to the application layer.
00190  */
00191 void wsp_unit_init(wap_dispatch_func_t *datagram_dispatch,
00192                    wap_dispatch_func_t *application_dispatch);
00193 void wsp_unit_dispatch_event(WAPEvent *event);
00194 void wsp_unit_shutdown(void);
00195 
00196 
00197 /*
00198  * Session layer, connection-oriented mode, server side
00199  *
00200  * This layer implements the server side of connection-oriented WSP.
00201  * FIXME Not all defined service primitives are supported yet.
00202  * Its dispatch function takes events of these types:
00203  *
00204  *   TR_Invoke_Ind, TR_Result_Cnf, TR_Abort_Ind
00205  *   S_Connect_Res, S_Resume_Res
00206  *   S_MethodInvoke_Res, S_MethodResult_Res
00207  *   Disconnect_Event, Suspend_Event  (internal)
00208  *
00209  * This layer will dispatch events of these types to the application layer:
00210  *
00211  *   S_Connect_Ind, S_Disconnect_Ind,
00212  *   S_Suspend_Ind, S_Resume_Ind,
00213  *   S_MethodInvoke_Ind, S_MethodResult_Cnf, S_MethodAbort_Ind
00214  *
00215  * and events of these types to the WTP Responder layer:
00216  *
00217  *   TR_Invoke_Res, TR_Result_Req, TR_Abort_Req
00218  *
00219  * and events of these types to the WTP Initiator layer:
00220  *
00221  *   (none yet)
00222  */
00223 void wsp_session_init(wap_dispatch_func_t *responder_dispatch,
00224               wap_dispatch_func_t *initiator_dispatch,
00225                       wap_dispatch_func_t *application_dispatch,
00226                       wap_dispatch_func_t *ota_dispatch);
00227 void wsp_session_dispatch_event(WAPEvent *event);
00228 void wsp_session_shutdown(void);
00229 
00230 
00231 /*
00232  * Session layer, connection-oriented mode, client side
00233  *
00234  * FIXME Not implemented yet.
00235  */
00236 
00237 void wsp_push_client_init(wap_dispatch_func_t *dispatch_self, 
00238                           wap_dispatch_func_t *dispatch_wtp_resp);
00239 void wsp_push_client_shutdown(void);
00240 void wsp_push_client_dispatch_event(WAPEvent *e);
00241 
00242 /*
00243  * Application layer
00244  *
00245  * This layer is not provided by libwap itself.  The application is
00246  * expected to create one, by providing a dispatch function to the
00247  * session layer that takes events of these types:
00248  *
00249  *   S_Connect_Ind, S_Disconnect_Ind,
00250  *   S_Suspend_Ind, S_Resume_Ind,
00251  *   S_MethodInvoke_Ind, S_MethodResult_Cnf, S_MethodAbort_Ind
00252  *   S_Unit_MethodInvoke_Ind   (from wsp_unit)
00253  *
00254  * For most of these events the application layer is expected to send
00255  * a response back to the session layer.
00256  */
00257 
00258 #endif
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.