Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wsp_server_method_states.def
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*
58  * wsp_server_method_states.def
59  *
60  * Macro calls to generate rows of the state table. See the documentation for
61  * guidance how to use and update these.
62  *
63  * Note that the `NULL' state has been renamed to `NULL_METHOD' because
64  * NULL is reserved by C.
65  */
66 
67 STATE_NAME(NULL_METHOD)
68 STATE_NAME(HOLDING)
69 STATE_NAME(REQUESTING)
70 STATE_NAME(PROCESSING)
71 STATE_NAME(REPLYING)
72 
73 /* MISSING: TR_Invoke.ind, N_Methods == MOM */
74 
75 ROW(NULL_METHOD,
76  TR_Invoke_Ind,
77  e->tcl == 2 && pdu->type == Get,
78  {
79  List *headers;
80  WAPEvent *invoke;
81  int method;
82  Octstr *method_name;
83 
84  /* Prepare the MethodInvoke here, because we have all
85  * the information nicely available. */
86 
87  if (octstr_len(pdu->u.Get.headers) > 0)
88  headers = wsp_headers_unpack(pdu->u.Get.headers, 0);
89  else
90  headers = NULL;
91 
92  invoke = wap_event_create(S_MethodInvoke_Ind);
93  invoke->u.S_MethodInvoke_Ind.server_transaction_id =
94  msm->transaction_id;
95  method = GET_METHODS + pdu->u.Get.subtype;
96  method_name = wsp_method_to_string(method);
97  if (method_name == NULL)
98  method_name = octstr_format("UNKNOWN%02X", method);
99  invoke->u.S_MethodInvoke_Ind.method = method_name;
100  invoke->u.S_MethodInvoke_Ind.request_uri =
101  octstr_duplicate(pdu->u.Get.uri);
102  invoke->u.S_MethodInvoke_Ind.request_headers = headers;
103  invoke->u.S_MethodInvoke_Ind.request_body = NULL;
104  invoke->u.S_MethodInvoke_Ind.session_headers =
105  http_header_duplicate(sm->http_headers);
106  invoke->u.S_MethodInvoke_Ind.addr_tuple =
107  wap_addr_tuple_duplicate(sm->addr_tuple);
108  invoke->u.S_MethodInvoke_Ind.client_SDU_size =
109  sm->client_SDU_size;
110  invoke->u.S_MethodInvoke_Ind.session_id =
111  msm->session_id;
112 
113  msm->invoke = invoke;
114  },
115  HOLDING)
116 
117 ROW(NULL_METHOD,
118  TR_Invoke_Ind,
119  e->tcl == 2 && pdu->type == Post,
120  {
121  List *headers;
122  WAPEvent *invoke;
123  int method;
124  Octstr *method_name;
125 
126  /* Prepare the MethodInvoke here, because we have all
127  * the information nicely available. */
128 
129  if (octstr_len(pdu->u.Post.headers) > 0)
130  headers = wsp_headers_unpack(pdu->u.Post.headers, 1);
131  else
132  headers = NULL;
133 
134  invoke = wap_event_create(S_MethodInvoke_Ind);
135  invoke->u.S_MethodInvoke_Ind.server_transaction_id =
136  msm->transaction_id;
137  method = POST_METHODS + pdu->u.Get.subtype;
138  method_name = wsp_method_to_string(method);
139  if (method_name == NULL)
140  method_name = octstr_format("UNKNOWN%02X", method);
141  invoke->u.S_MethodInvoke_Ind.method = method_name;
142  invoke->u.S_MethodInvoke_Ind.request_uri =
143  octstr_duplicate(pdu->u.Post.uri);
144  invoke->u.S_MethodInvoke_Ind.request_headers = headers;
145 
146  invoke->u.S_MethodInvoke_Ind.request_body =
147  octstr_duplicate(pdu->u.Post.data);
148 
149  invoke->u.S_MethodInvoke_Ind.session_headers =
150  http_header_duplicate(sm->http_headers);
151  invoke->u.S_MethodInvoke_Ind.addr_tuple =
152  wap_addr_tuple_duplicate(sm->addr_tuple);
153  invoke->u.S_MethodInvoke_Ind.client_SDU_size =
154  sm->client_SDU_size;
155  invoke->u.S_MethodInvoke_Ind.session_id =
156  msm->session_id;
157 
158  msm->invoke = invoke;
159  },
160  HOLDING)
161 
162 ROW(HOLDING,
163  Release_Event,
164  1,
165  {
166  /* S-MethodInvoke.ind */
167  dispatch_to_appl(msm->invoke);
168  msm->invoke = NULL;
169  },
170  REQUESTING)
171 
172 ROW(HOLDING,
173  Abort_Event,
174  1,
175  {
176  /* Decrement N_Methods */
177  /* we don't keep track of N_Methods because it's unlimited */
178 
179  /* Tr-Abort.req(abort reason) the method */
180  method_abort(msm, e->reason);
181  },
182  NULL_METHOD)
183 
184 ROW(HOLDING,
185  TR_Abort_Ind,
186  e->abort_code == WSP_ABORT_DISCONNECT,
187  {
188  WAPEvent *wsp_event;
189 
190  /* Disconnect the session */
191  wsp_event = wap_event_create(Disconnect_Event);
192  wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
193  /* We put this on the queue instead of doing it right away,
194  * because the session machine is currently our caller and
195  * we don't want to recurse. We put it in the front of
196  * the queue because the state machine definitions expect
197  * an event to be handled completely before the next is
198  * started. */
199  gwlist_insert(queue, 0, wsp_event);
200  },
201  HOLDING)
202 
203 ROW(HOLDING,
204  TR_Abort_Ind,
205  e->abort_code == WSP_ABORT_SUSPEND,
206  {
207  WAPEvent *wsp_event;
208 
209  /* Suspend the session */
210  wsp_event = wap_event_create(Suspend_Event);
211  wsp_event->u.Suspend_Event.session_handle = msm->session_id;
212  /* See story for Disconnect, above */
213  gwlist_insert(queue, 0, wsp_event);
214  },
215  HOLDING)
216 
217 ROW(HOLDING,
218  TR_Abort_Ind,
219  e->abort_code != WSP_ABORT_DISCONNECT
220  && e->abort_code != WSP_ABORT_SUSPEND,
221  {
222  /* Decrement N_Methods */
223  /* we don't keep track of N_Methods because it's unlimited */
224  },
225  NULL_METHOD)
226 
227 ROW(REQUESTING,
228  S_MethodInvoke_Res,
229  1,
230  {
231  WAPEvent *wtp_event;
232 
233  /* Send TR-Invoke.res to WTP */
234  wtp_event = wap_event_create(TR_Invoke_Res);
235  wtp_event->u.TR_Invoke_Res.handle = msm->transaction_id;
236  dispatch_to_wtp_resp(wtp_event);
237  },
238  PROCESSING)
239 
240 /* MISSING: REQUESTING, S-MethodAbort.req */
241 
242 ROW(REQUESTING,
243  Abort_Event,
244  1,
245  {
246  /* Decrement N_Methods */
247  /* we don't keep track of N_Methods because it's unlimited */
248 
249  /* TR-Abort.req(abort reason) the method */
250  method_abort(msm, e->reason);
251 
252  /* S-MethodAbort.ind(abort reason) */
253  indicate_method_abort(msm, e->reason);
254  },
255  NULL_METHOD)
256 
257 ROW(REQUESTING,
258  TR_Abort_Ind,
259  e->abort_code == WSP_ABORT_DISCONNECT,
260  {
261  WAPEvent *wsp_event;
262 
263  /* Disconnect the session */
264  wsp_event = wap_event_create(Disconnect_Event);
265  wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
266  gwlist_insert(queue, 0, wsp_event);
267  },
268  REQUESTING)
269 
270 ROW(REQUESTING,
271  TR_Abort_Ind,
272  e->abort_code == WSP_ABORT_SUSPEND,
273  {
274  WAPEvent *wsp_event;
275 
276  /* Suspend the session */
277  wsp_event = wap_event_create(Suspend_Event);
278  wsp_event->u.Suspend_Event.session_handle = msm->session_id;
279  gwlist_insert(queue, 0, wsp_event);
280  },
281  REQUESTING)
282 
283 ROW(REQUESTING,
284  TR_Abort_Ind,
285  e->abort_code != WSP_ABORT_DISCONNECT
286  && e->abort_code != WSP_ABORT_SUSPEND,
287  {
288  /* Decrement N_Methods */
289  /* we don't keep track of N_Methods because it's unlimited */
290 
291  /* S-MethodAbort.ind(abort reason) */
292  indicate_method_abort(msm, e->abort_code);
293  },
294  NULL_METHOD)
295 
296 ROW(PROCESSING,
297  S_MethodResult_Req,
298  1,
299  {
300  WAPEvent *wtp_event;
301  WSP_PDU *new_pdu;
302 
303  /* TR-Result.req */
304  new_pdu = wsp_pdu_create(Reply);
305  new_pdu->u.Reply.status =
306  wsp_convert_http_status_to_wsp_status(e->status);
307  new_pdu->u.Reply.headers =
308  wsp_headers_pack(e->response_headers, 1, sm->encoding_version);
309  new_pdu->u.Reply.data = octstr_duplicate(e->response_body);
310 
311  /* Send TR-Result.req to WTP */
312  wtp_event = wap_event_create(TR_Result_Req);
313  wtp_event->u.TR_Result_Req.user_data = wsp_pdu_pack(new_pdu);
314  wtp_event->u.TR_Result_Req.handle = msm->transaction_id;
315  dispatch_to_wtp_resp(wtp_event);
316  wsp_pdu_destroy(new_pdu);
317  },
318  REPLYING)
319 
320 /* MISSING: PROCESSING, S-MethodAbort.req */
321 
322 ROW(PROCESSING,
323  Abort_Event,
324  1,
325  {
326  /* Decrement N_Methods */
327  /* we don't keep track of N_Methods because it's unlimited */
328 
329  /* TR-Abort.req(abort reason) the method */
330  method_abort(msm, e->reason);
331 
332  /* S-MethodAbort.ind(abort reason) */
333  indicate_method_abort(msm, e->reason);
334  },
335  NULL_METHOD)
336 
337 ROW(PROCESSING,
338  TR_Abort_Ind,
339  e->abort_code == WSP_ABORT_DISCONNECT,
340  {
341  WAPEvent *wsp_event;
342 
343  /* Disconnect the session */
344  wsp_event = wap_event_create(Disconnect_Event);
345  wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
346  gwlist_insert(queue, 0, wsp_event);
347  },
348  PROCESSING)
349 
350 ROW(PROCESSING,
351  TR_Abort_Ind,
352  e->abort_code == WSP_ABORT_SUSPEND,
353  {
354  WAPEvent *wsp_event;
355 
356  /* Suspend the session */
357  wsp_event = wap_event_create(Suspend_Event);
358  wsp_event->u.Suspend_Event.session_handle = msm->session_id;
359  gwlist_insert(queue, 0, wsp_event);
360  },
361  PROCESSING)
362 
363 ROW(PROCESSING,
364  TR_Abort_Ind,
365  e->abort_code != WSP_ABORT_DISCONNECT
366  && e->abort_code != WSP_ABORT_SUSPEND,
367  {
368  /* Decrement N_Methods */
369  /* we don't keep track of N_Methods because it's unlimited */
370 
371  /* S-MethodAbort.ind(abort reason) */
372  indicate_method_abort(msm, e->abort_code);
373  },
374  NULL_METHOD)
375 
376 /* MISSING: REPLYING, S-MethodAbort.req */
377 
378 ROW(REPLYING,
379  Abort_Event,
380  1,
381  {
382  /* Decrement N_Methods */
383  /* we don't keep track of N_Methods because it's unlimited */
384 
385  /* TR-Abort.req(abort reason) the method */
386  method_abort(msm, e->reason);
387 
388  /* S-MethodAbort.ind(abort reason) */
389  indicate_method_abort(msm, e->reason);
390  },
391  NULL_METHOD)
392 
393 ROW(REPLYING,
394  TR_Result_Cnf,
395  1,
396  {
397  WAPEvent *new_event;
398 
399  /* Decrement N_Methods */
400  /* we don't keep track of N_Methods because it's unlimited */
401 
402  /* S-MethodResult.cnf */
403  /* we don't do acknowledgement headers */
404  new_event = wap_event_create(S_MethodResult_Cnf);
405  new_event->u.S_MethodResult_Cnf.server_transaction_id =
406  msm->transaction_id;
407  new_event->u.S_MethodResult_Cnf.session_id = msm->session_id;
408  dispatch_to_appl(new_event);
409  },
410  NULL_METHOD)
411 
412 ROW(REPLYING,
413  TR_Abort_Ind,
414  e->abort_code == WSP_ABORT_DISCONNECT,
415  {
416  WAPEvent *wsp_event;
417 
418  /* Disconnect the session */
419  wsp_event = wap_event_create(Disconnect_Event);
420  wsp_event->u.Disconnect_Event.session_handle = msm->session_id;
421  gwlist_insert(queue, 0, wsp_event);
422  },
423  REPLYING)
424 
425 ROW(REPLYING,
426  TR_Abort_Ind,
427  e->abort_code == WSP_ABORT_SUSPEND,
428  {
429  WAPEvent *wsp_event;
430 
431  /* Suspend the session */
432  wsp_event = wap_event_create(Suspend_Event);
433  wsp_event->u.Suspend_Event.session_handle = msm->session_id;
434  gwlist_insert(queue, 0, wsp_event);
435  },
436  REPLYING)
437 
438 ROW(REPLYING,
439  TR_Abort_Ind,
440  e->abort_code != WSP_ABORT_DISCONNECT
441  && e->abort_code != WSP_ABORT_SUSPEND,
442  {
443  /* Decrement N_Methods */
444  /* we don't keep track of N_Methods because it's unlimited */
445 
446  /* S-MethodAbort.ind(abort reason) */
447  indicate_method_abort(msm, e->abort_code);
448  },
449  NULL_METHOD)
450 
451 #undef ROW
452 #undef STATE_NAME
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.