Kannel: Open Source WAP and SMS gateway  svn-r5335
wsp_server_session_states.def
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2018 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_session_states.def - states for WSP session state machines
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 `NULL' state is renamed to `NULL_SESSION' because NULL is
64  * reserved by C.
65  *
66  * Lars Wirzenius
67  */
68 
69 STATE_NAME(NULL_SESSION)
70 STATE_NAME(CONNECTING)
71 STATE_NAME(TERMINATING)
72 STATE_NAME(CONNECTING_2)
73 STATE_NAME(CONNECTED)
74 STATE_NAME(SUSPENDED)
75 STATE_NAME(RESUMING)
76 STATE_NAME(RESUMING_2)
77 
78 ROW(NULL_SESSION,
79  TR_Invoke_Ind,
80  e->tcl == 2 && pdu->type == Connect,
81  {
82  WAPEvent *new_event;
83  WAPEvent *wtp_event;
84 
85  /* Send TR-Invoke.res to WTP */
86  wtp_event = wap_event_create(TR_Invoke_Res);
87  wtp_event->u.TR_Invoke_Res.handle = e->handle;
88  dispatch_to_wtp_resp(wtp_event);
89 
90  /* Assign a session ID for this session. We do this
91  * early, instead of in the CONNECTING state, because
92  * we want to use the session id as a way for the
93  * application layer to refer back to this machine. */
94  sm->session_id = next_wsp_session_id();
95 
96  if (pdu->u.Connect.capabilities_len > 0) {
97  unsigned long sdu;
98  sm->request_caps = wsp_cap_unpack_list(
99  pdu->u.Connect.capabilities);
100  if (wsp_cap_get_client_sdu(sm->request_caps,&sdu)) {
101  sm->client_SDU_size = sdu;
102  }
103  } else {
104  sm->request_caps = gwlist_create();
105  }
106 
107  if (pdu->u.Connect.headers_len > 0) {
108  List *hdrs;
109  Octstr *encoding;
110 
111  hdrs = wsp_headers_unpack(pdu->u.Connect.headers, 0);
112  http_header_pack(hdrs);
113  gw_assert(sm->http_headers == NULL);
114  sm->http_headers = hdrs;
115 
116  /*
117  * Get WSP encoding version if provided by device and remember in
118  * session machine for later use in encoding tokenized values.
119  */
120  encoding = http_header_value(sm->http_headers, octstr_imm("Encoding-Version"));
121  if (encoding != NULL) {
122  debug("wsp",0,"WSP: Session machine: Encoding-Version: %s",
123  octstr_get_cstr(encoding));
124  sm->encoding_version = wsp_encoding_string_to_version(encoding);
125  } else {
126  /* WAP-230-WSP-20010705-a, section 8.4.2.70, page 97 defines
127  * by a MUST argument that a non-present Encoding-Version header
128  * should be interpreted as WSP 1.2 compliant.
129  */
130  sm->encoding_version = WSP_1_2;
131  }
132  octstr_destroy(encoding);
133  }
134 
135  /* Send S-Connect.ind to application layer */
136  new_event = wap_event_create(S_Connect_Ind);
137  new_event->u.S_Connect_Ind.addr_tuple =
138  wap_addr_tuple_duplicate(e->addr_tuple);
139  new_event->u.S_Connect_Ind.client_headers =
140  http_header_duplicate(sm->http_headers);
141  new_event->u.S_Connect_Ind.requested_capabilities =
142  wsp_cap_duplicate_list(sm->request_caps);
143  new_event->u.S_Connect_Ind.session_id = sm->session_id;
144  dispatch_to_appl(new_event);
145  },
146  CONNECTING)
147 
148 
149 ROW(CONNECTING,
150  S_Connect_Res,
151  1,
152  {
153  WAPEvent *wtp_event;
154  Octstr *ospdu;
155 
156  sm->reply_caps = wsp_cap_duplicate_list(
157  e->negotiated_capabilities);
158 
159  /* Send Disconnect event to existing sessions for client. */
160  disconnect_other_sessions(sm);
161 
162  /* Assign a Session_ID for this session. */
163  /* We've already done that in the NULL_STATE. */
164 
165  /* TR-Result.req(ConnectReply) */
166  ospdu = make_connectreply_pdu(sm);
167 
168  wtp_event = wap_event_create(TR_Result_Req);
169  wtp_event->u.TR_Result_Req.user_data = ospdu;
170  wtp_event->u.TR_Result_Req.handle = sm->connect_handle;
171  dispatch_to_wtp_resp(wtp_event);
172 
173  /* Release all method transactions in HOLDING state. */
174  release_holding_methods(sm);
175  },
176  CONNECTING_2)
177 
178 /* MISSING: CONNECTING, S_Disconnect_Req, reason == 301 (moved permanently) or
179  * 302 (moved temporarily). */
180 
181 /* MISSING: CONNECTING, S_Disconnect_Req, reason == anything else */
182 
183 ROW(CONNECTING,
184  Disconnect_Event,
185  1,
186  {
187  /* TR-Abort.req(DISCONNECT) the Connect transaction */
188  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
189 
190  /* Abort(DISCONNECT) all method transactions */
191  abort_methods(sm, WSP_ABORT_DISCONNECT);
192 
193  /* S-Disconnect.ind(DISCONNECT) */
194  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
195  },
196  NULL_SESSION)
197 
198 ROW(CONNECTING,
199  Suspend_Event,
200  1,
201  {
202  /* TR-Abort.req(DISCONNECT) the Connect transaction */
203  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
204 
205  /* Abort(DISCONNECT) all method transactions */
206  abort_methods(sm, WSP_ABORT_DISCONNECT);
207 
208  /* S-Disconnect.ind(SUSPEND) */
209  indicate_disconnect(sm, WSP_ABORT_SUSPEND);
210  },
211  NULL_SESSION)
212 
213 ROW(CONNECTING,
214  TR_Invoke_Ind,
215  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
216  {
217  WSPMethodMachine *msm;
218 
219  /* Start new method transaction */
220  msm = method_machine_create(sm, e->handle);
221 
222  /* Hand off the event to the new method machine */
223  handle_method_event(sm, msm, current_event, pdu);
224  },
225  CONNECTING)
226 
227 ROW(CONNECTING,
228  TR_Invoke_Ind,
229  e->tcl == 2 && pdu->type == Resume,
230  {
231  /* TR-Abort.req(DISCONNECT) the TR-Invoke */
232  send_abort(WSP_ABORT_DISCONNECT, e->handle);
233  },
234  CONNECTING)
235 
236 ROW(CONNECTING,
237  TR_Abort_Ind,
238  e->handle == sm->connect_handle,
239  {
240  /* Abort(DISCONNECT) all method transactions */
241  abort_methods(sm, WSP_ABORT_DISCONNECT);
242 
243  /* S-Disconnect.ind(abort reason) */
244  indicate_disconnect(sm, e->abort_code);
245  },
246  NULL_SESSION)
247 
248 ROW(CONNECTING,
249  TR_Abort_Ind,
250  e->handle != sm->connect_handle,
251  {
252  WSPMethodMachine *msm;
253 
254  /* See method state table */
255  msm = find_method_machine(sm, e->handle);
256  handle_method_event(sm, msm, current_event, pdu);
257  },
258  CONNECTING)
259 
260 ROW(TERMINATING,
261  Disconnect_Event,
262  1,
263  {
264  /* TR-Abort.req(DISCONNECT) remaining transport transaction */
265  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
266  },
267  NULL_SESSION)
268 
269 ROW(TERMINATING,
270  Suspend_Event,
271  1,
272  {
273  /* TR-Abort.req(SUSPEND) remaining transport transaction */
274  send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
275  },
276  NULL_SESSION)
277 
278 ROW(TERMINATING,
279  TR_Result_Cnf,
280  1,
281  {
282  /* Ignore */
283  },
284  NULL_SESSION)
285 
286 ROW(TERMINATING,
287  TR_Abort_Ind,
288  1,
289  {
290  /* Ignore */
291  },
292  NULL_SESSION)
293 
294 /* MISSING: CONNECTING_2, S-Disconnect.req */
295 
296 ROW(CONNECTING_2,
297  Disconnect_Event,
298  1,
299  {
300  /* TR-Abort.req(DISCONNECT) the Connect transaction */
301  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
302 
303  /* Abort(DISCONNECT) all method and push transactions */
304  abort_methods(sm, WSP_ABORT_DISCONNECT);
305 
306  /* S-Disconnect.ind(DISCONNECT) */
307  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
308  },
309  NULL_SESSION)
310 
311 ROW(CONNECTING_2,
312  S_MethodInvoke_Res,
313  1,
314  {
315  WSPMethodMachine *msm;
316 
317  /* See method state table */
318  msm = find_method_machine(sm, e->server_transaction_id);
319  handle_method_event(sm, msm, current_event, pdu);
320  },
321  CONNECTING_2)
322 
323 ROW(CONNECTING_2,
324  S_MethodResult_Req,
325  1,
326  {
327  WSPMethodMachine *msm;
328 
329  /* See method state table */
330  msm = find_method_machine(sm, e->server_transaction_id);
331  handle_method_event(sm, msm, current_event, pdu);
332  },
333  CONNECTING_2)
334 
335 ROW(CONNECTING_2,
336  S_Push_Req,
337  1,
338  {
339  WSP_PDU *pdu;
340 
341  pdu = make_push_pdu(current_event);
342  send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
343  },
344  CONNECTING_2)
345 
346 ROW(CONNECTING_2,
347  S_ConfirmedPush_Req,
348  1,
349  {
350  /* Start new push transaction*/
351  WSPPushMachine *spm;
352 
353  spm = push_machine_create(sm, e->server_push_id);
354  handle_push_event(sm, spm, current_event);
355  },
356  CONNECTING_2)
357 
358 ROW(CONNECTING_2,
359  Suspend_Event,
360  !resume_enabled,
361  {
362  /* Session Resume facility disabled */
363 
364  /* TR-Abort.req(DISCONNECT) the Connect transaction */
365  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
366 
367  /* Abort(DISCONNECT) all method and push transactions */
368  abort_methods(sm, WSP_ABORT_DISCONNECT);
369 
370  /* S-Disconnect.ind(SUSPEND) */
371  indicate_disconnect(sm, WSP_ABORT_SUSPEND);
372  },
373  NULL_SESSION)
374 
375 ROW(CONNECTING_2,
376  Suspend_Event,
377  resume_enabled,
378  {
379  /* Session Resume facility enabled */
380 
381  /* TR-Abort.req(SUSPEND) the Connect transaction */
382  send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
383 
384  /* Abort(SUSPEND) all method and push transactions */
385  abort_methods(sm, WSP_ABORT_SUSPEND);
386 
387  /* S-Suspend.ind(SUSPEND) */
388  indicate_suspend(sm, WSP_ABORT_SUSPEND);
389  },
390  SUSPENDED)
391 
392 ROW(CONNECTING_2,
393  TR_Invoke_Ind,
394  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
395  {
396  WSPMethodMachine *msm;
397  WAPEvent *new_event;
398 
399  /* Start new method transaction */
400  msm = method_machine_create(sm, e->handle);
401 
402  /* Hand off the event to the new method machine */
403  handle_method_event(sm, msm, current_event, pdu);
404 
405  /* Release the new method transaction */
406  new_event = wap_event_create(Release_Event);
407  handle_method_event(sm, msm, new_event, NULL);
408  wap_event_destroy(new_event);
409  },
410  CONNECTING_2)
411 
412 ROW(CONNECTING_2,
413  TR_Invoke_Ind,
414  e->tcl == 2 && pdu->type == Resume && !resume_enabled,
415  {
416  /* Resume facility disabled */
417 
418  /* TR-Abort.req(DISCONNECT) the TR-Invoke */
419  send_abort(WSP_ABORT_DISCONNECT, e->handle);
420  },
421  CONNECTING_2)
422 
423 ROW(CONNECTING_2,
424  TR_Invoke_Ind,
425  e->tcl == 2 && pdu->type == Resume && resume_enabled,
426  {
427  /* Resume facility enabled */
428 
429  WAPEvent *wtp_event;
430  List *new_headers;
431 
432  /* TR-Invoke.res */
433  wtp_event = wap_event_create(TR_Invoke_Res);
434  wtp_event->u.TR_Invoke_Res.handle = e->handle;
435  dispatch_to_wtp_resp(wtp_event);
436 
437  /* TR-Abort.req(RESUME) the Connect transaction */
438  send_abort(WSP_ABORT_RESUME, sm->connect_handle);
439 
440  /* Abort(RESUME) all method and push transactions */
441  abort_methods(sm, WSP_ABORT_RESUME);
442 
443  /* S-Suspend.ind(RESUME) */
444  indicate_suspend(sm, WSP_ABORT_RESUME);
445 
446  /* S-Resume.ind */
447  new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
448  indicate_resume(sm, e->addr_tuple, new_headers);
449  http_destroy_headers(new_headers);
450 
451  sm->resume_handle = e->handle;
452  },
453  RESUMING)
454 
455 ROW(CONNECTING_2,
456  TR_Invoke_Ind,
457  e->tcl == 0 && pdu->type == Disconnect,
458  {
459  /* TR-Abort.req(DISCONNECT) the Connect transaction */
460  send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
461 
462  /* Abort(DISCONNECT) all method and push transactions */
463  abort_methods(sm, WSP_ABORT_DISCONNECT);
464 
465  /* S-Disconnect.ind(DISCONNECT) */
466  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
467  },
468  NULL_SESSION)
469 
470 ROW(CONNECTING_2,
471  TR_Invoke_Ind,
472  e->tcl == 0 && pdu->type == Suspend && resume_enabled,
473  {
474  /* Resume facility enabled */
475 
476  /* TR-Abort.req(SUSPEND) the Connect transaction */
477  send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
478 
479  /* Abort(SUSPEND) all method and push transactions */
480  abort_methods(sm, WSP_ABORT_SUSPEND);
481 
482  /* S-Suspend.ind(SUSPEND) */
483  indicate_suspend(sm, WSP_ABORT_SUSPEND);
484  },
485  SUSPENDED)
486 
487 ROW(CONNECTING_2,
488  TR_Invoke_Cnf,
489  1,
490  {
491  /* See push state table*/
492  WSPPushMachine *spm;
493 
494  spm = find_push_machine(sm, e->handle);
495  handle_push_event(sm, spm, current_event);
496  },
497  CONNECTING_2)
498 
499 ROW(CONNECTING_2,
500  TR_Result_Cnf,
501  e->handle == sm->connect_handle,
502  {
503  },
504  CONNECTED)
505 
506 ROW(CONNECTING_2,
507  TR_Result_Cnf,
508  e->handle != sm->connect_handle,
509  {
510  WSPMethodMachine *msm;
511 
512  /* See method state table */
513  msm = find_method_machine(sm, e->handle);
514  handle_method_event(sm, msm, current_event, pdu);
515  },
516  CONNECTING_2)
517 
518 ROW(CONNECTING_2,
519  TR_Abort_Ind,
520  e->handle == sm->connect_handle,
521  {
522  /* Abort(DISCONNECT) all method and push transactions */
523  abort_methods(sm, WSP_ABORT_DISCONNECT);
524 
525  /* S-Disconnect.ind(abort reason) */
526  indicate_disconnect(sm, e->abort_code);
527  },
528  NULL_SESSION)
529 
530 /*
531  * A separate flag tells is the indicator the initiator or the responder.
532  */
533 
534 ROW(CONNECTING_2,
535  TR_Abort_Ind,
536  e->handle != sm->connect_handle && e->ir_flag == RESPONDER_INDICATION,
537  {
538  WSPMethodMachine *msm;
539 
540  /* See method state table */
541  msm = find_method_machine(sm, e->handle);
542  handle_method_event(sm, msm, current_event, pdu);
543  },
544  CONNECTING_2)
545 
546 ROW(CONNECTING_2,
547  TR_Abort_Ind,
548  e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
549  {
550  WSPPushMachine *m;
551 
552  /* See push state table */
553  m = find_push_machine(sm, e->handle);
554  handle_push_event(sm, m, current_event);
555  },
556  CONNECTING_2)
557 
558 /* MISSING: CONNECTED, S-Disconnect.req */
559 
560 ROW(CONNECTED,
561  Disconnect_Event,
562  1,
563  {
564  /* Abort(DISCONNECT) all method and push transactions */
565  abort_methods(sm, WSP_ABORT_DISCONNECT);
566 
567  /* S-Disconnect.ind(DISCONNECT) */
568  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
569  },
570  NULL_SESSION)
571 
572 ROW(CONNECTED,
573  S_MethodInvoke_Res,
574  1,
575  {
576  WSPMethodMachine *msm;
577 
578  /* See method state table */
579  msm = find_method_machine(sm, e->server_transaction_id);
580  handle_method_event(sm, msm, current_event, pdu);
581  },
582  CONNECTED)
583 
584 ROW(CONNECTED,
585  S_MethodResult_Req,
586  1,
587  {
588  WSPMethodMachine *msm;
589 
590  /* See method state table */
591  msm = find_method_machine(sm, e->server_transaction_id);
592  handle_method_event(sm, msm, current_event, pdu);
593  },
594  CONNECTED)
595 
596 ROW(CONNECTED,
597  S_Push_Req,
598  1,
599  {
600  WSP_PDU *pdu;
601 
602  pdu = make_push_pdu(current_event);
603  send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
604  },
605  CONNECTED)
606 
607 ROW(CONNECTED,
608  S_ConfirmedPush_Req,
609  1,
610  {
611  /* Start new push transaction*/
612  WSPPushMachine *spm;
613 
614  spm = push_machine_create(sm, e->server_push_id);
615  handle_push_event(sm, spm, current_event);
616  },
617  CONNECTED)
618 
619 ROW(CONNECTED,
620  Suspend_Event,
621  !resume_enabled,
622  {
623  /* Session Resume facility disabled */
624 
625  /* Abort(SUSPEND) all method and push transactions */
626  abort_methods(sm, WSP_ABORT_SUSPEND);
627 
628  /* S-Disconnect.ind(SUSPEND) */
629  indicate_disconnect(sm, WSP_ABORT_SUSPEND);
630  },
631  NULL_SESSION)
632 
633 ROW(CONNECTED,
634  Suspend_Event,
635  resume_enabled,
636  {
637  /* Session Resume facility enabled */
638 
639  /* Abort(SUSPEND) all method and push transactions */
640  abort_methods(sm, WSP_ABORT_SUSPEND);
641 
642  /* S-Suspend.ind(SUSPEND) */
643  indicate_suspend(sm, WSP_ABORT_SUSPEND);
644  },
645  SUSPENDED)
646 
647 ROW(CONNECTED,
648  TR_Invoke_Ind,
649  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
650  {
651  WSPMethodMachine *msm;
652  WAPEvent *new_event;
653 
654  /* Start new method transaction */
655  msm = method_machine_create(sm, e->handle);
656 
657  /* Hand off the event to the new method machine */
658  handle_method_event(sm, msm, current_event, pdu);
659 
660  /* Release the new method transaction */
661  new_event = wap_event_create(Release_Event);
662  handle_method_event(sm, msm, new_event, NULL);
663  wap_event_destroy(new_event);
664  },
665  CONNECTED)
666 
667 ROW(CONNECTED,
668  TR_Invoke_Ind,
669  e->tcl == 2 && pdu->type == Resume && !resume_enabled,
670  {
671  /* Resume facility disabled */
672 
673  /* TR-Abort.req(DISCONNECT) the TR-Invoke */
674  send_abort(WSP_ABORT_DISCONNECT, e->handle);
675  },
676  CONNECTED)
677 
678 ROW(CONNECTED,
679  TR_Invoke_Ind,
680  e->tcl == 2 && pdu->type == Resume && resume_enabled,
681  {
682  /* Resume facility enabled */
683 
684  WAPEvent *wtp_event;
685  List *new_headers;
686 
687  /* TR-Invoke.res */
688  wtp_event = wap_event_create(TR_Invoke_Res);
689  wtp_event->u.TR_Invoke_Res.handle = e->handle;
690  dispatch_to_wtp_resp(wtp_event);
691 
692  /* Abort(RESUME) all method and push transactions */
693  abort_methods(sm, WSP_ABORT_RESUME);
694 
695  /* S-Suspend.ind(RESUME) */
696  indicate_suspend(sm, WSP_ABORT_RESUME);
697 
698  /* S-Resume.ind */
699  new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
700  indicate_resume(sm, e->addr_tuple, new_headers);
701  http_destroy_headers(new_headers);
702 
703  sm->resume_handle = e->handle;
704  },
705  RESUMING)
706 
707 ROW(CONNECTED,
708  TR_Invoke_Ind,
709  e->tcl == 0 && pdu->type == Disconnect,
710  {
711  /* Abort(DISCONNECT) all method and push transactions */
712  abort_methods(sm, WSP_ABORT_DISCONNECT);
713 
714  /* S-Disconnect.ind(DISCONNECT) */
715  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
716  },
717  NULL_SESSION)
718 
719 ROW(CONNECTED,
720  TR_Invoke_Ind,
721  e->tcl == 0 && pdu->type == Suspend && resume_enabled,
722  {
723  /* Abort(SUSPEND) all method and push transactions */
724  abort_methods(sm, WSP_ABORT_SUSPEND);
725 
726  /* S-Suspend.ind(SUSPEND) */
727  indicate_suspend(sm, WSP_ABORT_SUSPEND);
728  },
729  SUSPENDED)
730 
731 ROW(CONNECTED,
732  TR_Invoke_Cnf,
733  1,
734  {
735  /* See push state table*/
736  WSPPushMachine *spm;
737 
738  spm = find_push_machine(sm, e->handle);
739  handle_push_event(sm, spm, current_event);
740  },
741  CONNECTED)
742 
743 ROW(CONNECTED,
744  TR_Result_Cnf,
745  e->handle != sm->connect_handle,
746  {
747  WSPMethodMachine *msm;
748 
749  /* See method state table */
750  msm = find_method_machine(sm, e->handle);
751  handle_method_event(sm, msm, current_event, pdu);
752  },
753  CONNECTED)
754 
755 /*
756  * Event TR-Abort.ind has a separate flag telling is the indicator the
757  * initiator or the responder.
758  */
759 ROW(CONNECTED,
760  TR_Abort_Ind,
761  e->handle != sm->connect_handle && e->ir_flag == RESPONDER_INDICATION,
762  {
763  WSPMethodMachine *msm;
764 
765  /* See method state table */
766  msm = find_method_machine(sm, e->handle);
767  handle_method_event(sm, msm, current_event, pdu);
768  },
769  CONNECTED)
770 
771 ROW(CONNECTED,
772  TR_Abort_Ind,
773  e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
774  {
775  WSPPushMachine *m;
776 
777  /* See push state table */
778  m = find_push_machine(sm, e->handle);
779  handle_push_event(sm, m, current_event);
780  },
781  CONNECTED)
782 
783 /* MISSING: SUSPENDED, S-Disconnect.req */
784 
785 ROW(SUSPENDED,
786  Disconnect_Event,
787  1,
788  {
789  /* S-Disconnect.ind(DISCONNECT) */
790  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
791  },
792  NULL_SESSION)
793 
794 ROW(SUSPENDED,
795  TR_Invoke_Ind,
796  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
797  {
798  /* TR-Abort.req(SUSPEND) the TR-Invoke */
799  send_abort(WSP_ABORT_SUSPEND, e->handle);
800  },
801  SUSPENDED)
802 
803 ROW(SUSPENDED,
804  TR_Invoke_Ind,
805  e->tcl == 2 && pdu->type == Resume,
806  {
807  WAPEvent *wtp_event;
808  List *new_headers;
809 
810  /* TR-Invoke.res */
811  wtp_event = wap_event_create(TR_Invoke_Res);
812  wtp_event->u.TR_Invoke_Res.handle = e->handle;
813  dispatch_to_wtp_resp(wtp_event);
814 
815  /* S-Resume.ind */
816  new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
817  indicate_resume(sm, e->addr_tuple, new_headers);
818  http_destroy_headers(new_headers);
819 
820 
821  sm->resume_handle = e->handle;
822  },
823  RESUMING)
824 
825 ROW(SUSPENDED,
826  TR_Invoke_Ind,
827  e->tcl == 0 && pdu->type == Disconnect,
828  {
829  /* S-Disconnect.ind(DISCONNECT) */
830  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
831  },
832  NULL_SESSION)
833 
834 /* MISSING: RESUMING, S-Disconnect.req */
835 
836 ROW(RESUMING,
837  Disconnect_Event,
838  1,
839  {
840  /* TR-Abort.req(DISCONNECT) the Resume transaction */
841  send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
842 
843  /* Abort(DISCONNECT) all method transactions */
844  abort_methods(sm, WSP_ABORT_DISCONNECT);
845 
846  /* S-Disconnect.ind(DISCONNECT) */
847  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
848  },
849  NULL_SESSION)
850 
851 ROW(RESUMING,
852  S_Resume_Res,
853  1,
854  {
855  WAPEvent *wtp_event;
856  Octstr *ospdu;
857 
858  /* Disconnect any other session for the peer address quadruplet */
859  disconnect_other_sessions(sm);
860 
861  /* Bind session to new peer address quadruplet */
862  /* this happens automatically XXX Not true */
863 
864  /* TR-Result.req(Reply) */
865  if (e->server_headers == NULL)
866  e->server_headers = http_create_empty_headers();
867 
868  ospdu = make_resume_reply_pdu(sm, e->server_headers);
869  wtp_event = wap_event_create(TR_Result_Req);
870  wtp_event->u.TR_Result_Req.user_data = ospdu;
871  wtp_event->u.TR_Result_Req.handle = sm->resume_handle;
872  dispatch_to_wtp_resp(wtp_event);
873 
874  /* Release all method transactions in HOLDING state */
875  release_holding_methods(sm);
876  },
877  RESUMING_2)
878 
879 ROW(RESUMING,
880  Suspend_Event,
881  1,
882  {
883  /* TR-Abort.req(SUSPEND) the Resume transaction */
884  send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
885 
886  /* Abort(SUSPEND) all method transactions */
887  abort_methods(sm, WSP_ABORT_SUSPEND);
888 
889  /* S-Suspend.ind(SUSPEND) */
890  indicate_suspend(sm, WSP_ABORT_SUSPEND);
891  },
892  SUSPENDED)
893 
894 ROW(RESUMING,
895  TR_Invoke_Ind,
896  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
897  {
898  /* Start new method transaction (see method state table) */
899  WSPMethodMachine *msm;
900  msm = method_machine_create(sm, e->handle);
901  handle_method_event(sm, msm, current_event, pdu);
902  },
903  RESUMING)
904 
905 ROW(RESUMING,
906  TR_Invoke_Ind,
907  e->tcl == 2 && pdu->type == Resume,
908  {
909  WAPEvent *wtp_event;
910  List *new_headers;
911 
912  /* TR-Invoke.res */
913  wtp_event = wap_event_create(TR_Invoke_Res);
914  wtp_event->u.TR_Invoke_Res.handle = e->handle;
915  dispatch_to_wtp_resp(wtp_event);
916 
917  /* TR-Abort.req(RESUME) the old Resume transaction */
918  send_abort(WSP_ABORT_RESUME, sm->resume_handle);
919 
920  /* Abort(RESUME) all method transactions */
921  abort_methods(sm, WSP_ABORT_RESUME);
922 
923  /* S-Suspend.ind(RESUME) */
924  indicate_suspend(sm, WSP_ABORT_RESUME);
925 
926  /* S-Resume.ind */
927  new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
928  indicate_resume(sm, e->addr_tuple, new_headers);
929  http_destroy_headers(new_headers);
930 
931 
932  sm->resume_handle = e->handle;
933  },
934  RESUMING)
935 
936 ROW(RESUMING,
937  TR_Invoke_Ind,
938  e->tcl == 0 && pdu->type == Suspend,
939  {
940  /* TR-Abort.req(SUSPEND) the Resume transaction */
941  send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
942 
943  /* Abort(SUSPEND) all method transactions */
944  abort_methods(sm, WSP_ABORT_SUSPEND);
945 
946  /* S-Suspend.ind(SUSPEND) */
947  indicate_suspend(sm, WSP_ABORT_SUSPEND);
948  },
949  SUSPENDED)
950 
951 ROW(RESUMING,
952  TR_Invoke_Ind,
953  e->tcl == 0 && pdu->type == Disconnect,
954  {
955  /* TR-Abort.req(DISCONNECT) the Resume transaction */
956  send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
957 
958  /* Abort(DISCONNECT) all method transactions */
959  abort_methods(sm, WSP_ABORT_DISCONNECT);
960 
961  /* S-Disconnect.ind(DISCONNECT) */
962  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
963  },
964  NULL_SESSION)
965 
966 ROW(RESUMING,
967  TR_Abort_Ind,
968  e->handle == sm->resume_handle,
969  {
970  /* Abort(SUSPEND) all method transactions */
971  abort_methods(sm, WSP_ABORT_SUSPEND);
972 
973  /* S-Suspend.ind(abort reason) */
974  indicate_suspend(sm, e->abort_code);
975  },
976  SUSPENDED)
977 
978 /* MISSING: RESUMING_2, S-Disconnect.req */
979 
980 ROW(RESUMING_2,
981  Disconnect_Event,
982  1,
983  {
984  /* TR-Abort.req(DISCONNECT) the Resume */
985  send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
986 
987  /* Abort(DISCONNECT) all method and push transactions */
988  abort_methods(sm, WSP_ABORT_DISCONNECT);
989 
990  /* S-Disconnect.ind(DISCONNECT) */
991  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
992  },
993  NULL_SESSION)
994 
995 ROW(RESUMING_2,
996  S_MethodInvoke_Res,
997  1,
998  {
999  WSPMethodMachine *msm;
1000 
1001  /* See method state table */
1002  msm = find_method_machine(sm, e->server_transaction_id);
1003  handle_method_event(sm, msm, current_event, pdu);
1004  },
1005  RESUMING_2)
1006 
1007 ROW(RESUMING_2,
1008  S_MethodResult_Req,
1009  1,
1010  {
1011  WSPMethodMachine *msm;
1012 
1013  /* See method state table */
1014  msm = find_method_machine(sm, e->server_transaction_id);
1015  handle_method_event(sm, msm, current_event, pdu);
1016  },
1017  RESUMING_2)
1018 
1019 ROW(RESUMING_2,
1020  S_Push_Req,
1021  1,
1022  {
1023  WSP_PDU *pdu;
1024 
1025  pdu = make_push_pdu(current_event);
1026  send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
1027  },
1028  RESUMING_2)
1029 
1030 ROW(RESUMING_2,
1031  S_ConfirmedPush_Req,
1032  1,
1033  {
1034  /* Start new push transaction*/
1035  WSPPushMachine *spm;
1036 
1037  spm = push_machine_create(sm, e->server_push_id);
1038  handle_push_event(sm, spm, current_event);
1039  },
1040  RESUMING_2)
1041 
1042 ROW(RESUMING_2,
1043  Suspend_Event,
1044  1,
1045  {
1046  /* TR-Abort.req(SUSPEND) the Resume transaction */
1047  send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
1048 
1049  /* Abort(SUSPEND) all method and push transactions */
1050  abort_methods(sm, WSP_ABORT_SUSPEND);
1051 
1052  /* S-Suspend.ind(SUSPEND) */
1053  indicate_suspend(sm, WSP_ABORT_SUSPEND);
1054  },
1055  SUSPENDED)
1056 
1057 ROW(RESUMING_2,
1058  TR_Invoke_Ind,
1059  e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
1060  {
1061  WSPMethodMachine *msm;
1062  WAPEvent *new_event;
1063 
1064  /* Start new method transaction (see method state table) */
1065  msm = method_machine_create(sm, e->handle);
1066  handle_method_event(sm, msm, current_event, pdu);
1067 
1068  /* Release the new method transaction */
1069  new_event = wap_event_create(Release_Event);
1070  handle_method_event(sm, msm, new_event, NULL);
1071  wap_event_destroy(new_event);
1072  },
1073  RESUMING_2)
1074 
1075 ROW(RESUMING_2,
1076  TR_Invoke_Ind,
1077  e->tcl == 2 && pdu->type == Resume,
1078  {
1079  WAPEvent *wtp_event;
1080  List *new_headers;
1081 
1082  /* TR-Invoke.res */
1083  wtp_event = wap_event_create(TR_Invoke_Res);
1084  wtp_event->u.TR_Invoke_Res.handle = e->handle;
1085  dispatch_to_wtp_resp(wtp_event);
1086 
1087  /* TR-Abort.req(RESUME) the old Resume transaction*/
1088  send_abort(WSP_ABORT_RESUME, sm->resume_handle);
1089 
1090  /* Abort(RESUME) all method and push transactions */
1091  abort_methods(sm, WSP_ABORT_RESUME);
1092 
1093  /* S-Suspend.ind(RESUME) */
1094  indicate_suspend(sm, WSP_ABORT_RESUME);
1095 
1096  /* S-Resume.ind */
1097  new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
1098  indicate_resume(sm, e->addr_tuple, new_headers);
1099  http_destroy_headers(new_headers);
1100 
1101 
1102  sm->resume_handle = e->handle;
1103  },
1104  RESUMING)
1105 
1106 ROW(RESUMING_2,
1107  TR_Invoke_Ind,
1108  e->tcl == 0 && pdu->type == Suspend,
1109  {
1110  /* TR-Abort.req(SUSPEND) the Resume transaction */
1111  send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
1112 
1113  /* Abort(SUSPEND) all method and push transactions */
1114  abort_methods(sm, WSP_ABORT_SUSPEND);
1115 
1116  /* S-Suspend.ind(SUSPEND) */
1117  indicate_suspend(sm, WSP_ABORT_SUSPEND);
1118  },
1119  SUSPENDED)
1120 
1121 ROW(RESUMING_2,
1122  TR_Invoke_Ind,
1123  e->tcl == 0 && pdu->type == Disconnect,
1124  {
1125  /* TR-Abort.req(DISCONNECT) the Resume */
1126  send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
1127 
1128  /* Abort(DISCONNECT) all method and push transactions */
1129  abort_methods(sm, WSP_ABORT_DISCONNECT);
1130 
1131  /* S-Disconnect.ind(DISCONNECT) */
1132  indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
1133  },
1134  NULL_SESSION)
1135 
1136 ROW(RESUMING_2,
1137  TR_Invoke_Cnf,
1138  1,
1139  {
1140  /* See push state table*/
1141  WSPPushMachine *spm;
1142 
1143  spm = find_push_machine(sm, e->handle);
1144  handle_push_event(sm, spm, current_event);
1145  },
1146  RESUMING_2)
1147 
1148 ROW(RESUMING_2,
1149  TR_Result_Cnf,
1150  e->handle == sm->resume_handle,
1151  {
1152  },
1153  CONNECTED)
1154 
1155 ROW(RESUMING_2,
1156  TR_Result_Cnf,
1157  e->handle != sm->resume_handle,
1158  {
1159  WSPMethodMachine *msm;
1160 
1161  /* See method state table */
1162  msm = find_method_machine(sm, e->handle);
1163  handle_method_event(sm, msm, current_event, pdu);
1164  },
1165  RESUMING_2)
1166 
1167 ROW(RESUMING_2,
1168  TR_Abort_Ind,
1169  e->handle == sm->resume_handle,
1170  {
1171  /* Abort(SUSPEND) all method and push transactions */
1172  abort_methods(sm, WSP_ABORT_SUSPEND);
1173 
1174  /* S-Suspend.ind(abort reason) */
1175  indicate_suspend(sm, e->abort_code);
1176  },
1177  SUSPENDED)
1178 
1179 /*
1180  * A separate flag tells is the indicator the initiator or the responder
1181  */
1182 
1183 ROW(RESUMING_2,
1184  TR_Abort_Ind,
1185  e->handle != sm->resume_handle && e->ir_flag == RESPONDER_INDICATION,
1186  {
1187  WSPMethodMachine *msm;
1188 
1189  /* See method state table */
1190  msm = find_method_machine(sm, e->handle);
1191  handle_method_event(sm, msm, current_event, pdu);
1192  },
1193  RESUMING_2)
1194 
1195 ROW(CONNECTING_2,
1196  TR_Abort_Ind,
1197  e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
1198  {
1199  WSPPushMachine *m;
1200 
1201  /* See push state table */
1202  m = find_push_machine(sm, e->handle);
1203  handle_push_event(sm, m, current_event);
1204  },
1205  CONNECTING_2)
1206 
1207 #undef ROW
1208 #undef STATE_NAME
1209 
1210 
1211 
1212 
1213 
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.