wsp_server_session_states.def
上传用户:gzpyjq
上传日期:2013-01-31
资源大小:1852k
文件大小:26k
源码类别:

手机WAP编程

开发平台:

WINDOWS

  1. /*
  2.  * wsp_server_session_states.def - states for WSP session state machines
  3.  *
  4.  * Macro calls to generate rows of the state table. See the documentation for
  5.  * guidance how to use and update these.
  6.  *
  7.  * Note that `NULL' state is renamed to `NULL_SESSION' because NULL is
  8.  * reserved by C.
  9.  *
  10.  * Lars Wirzenius
  11.  */
  12. STATE_NAME(NULL_SESSION)
  13. STATE_NAME(CONNECTING)
  14. STATE_NAME(TERMINATING)
  15. STATE_NAME(CONNECTING_2)
  16. STATE_NAME(CONNECTED)
  17. STATE_NAME(SUSPENDED)
  18. STATE_NAME(RESUMING)
  19. STATE_NAME(RESUMING_2)
  20. ROW(NULL_SESSION,
  21. TR_Invoke_Ind,
  22. e->tcl == 2 && pdu->type == Connect,
  23. {
  24. WAPEvent *new_event;
  25. WAPEvent *wtp_event;
  26. /* Send TR-Invoke.res to WTP */
  27. wtp_event = wap_event_create(TR_Invoke_Res);
  28. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  29. dispatch_to_wtp_resp(wtp_event);
  30. /* Assign a session ID for this session.  We do this
  31.  * early, instead of in the CONNECTING state, because
  32.  * we want to use the session id as a way for the
  33.  * application layer to refer back to this machine. */
  34. sm->session_id = next_wsp_session_id();
  35. if (pdu->u.Connect.capabilities_len > 0) {
  36. sm->request_caps = wsp_cap_unpack_list(
  37. pdu->u.Connect.capabilities);
  38. } else {
  39. sm->request_caps = list_create();
  40. }
  41. if (pdu->u.Connect.headers_len > 0) {
  42. List *hdrs;
  43. hdrs = wsp_headers_unpack(pdu->u.Connect.headers, 0);
  44. http_header_pack(hdrs);
  45. gw_assert(sm->http_headers == NULL);
  46. sm->http_headers = hdrs;
  47. }
  48. /* Send S-Connect.ind to application layer */
  49. new_event = wap_event_create(S_Connect_Ind);
  50. new_event->u.S_Connect_Ind.addr_tuple =
  51. wap_addr_tuple_duplicate(e->addr_tuple);
  52. new_event->u.S_Connect_Ind.client_headers =
  53. http_header_duplicate(sm->http_headers);
  54. new_event->u.S_Connect_Ind.requested_capabilities =
  55. wsp_cap_duplicate_list(sm->request_caps);
  56. new_event->u.S_Connect_Ind.session_id = sm->session_id;
  57. dispatch_to_appl(new_event);
  58. },
  59. CONNECTING)
  60. ROW(CONNECTING,
  61. S_Connect_Res,
  62. 1,
  63. {
  64. WAPEvent *wtp_event;
  65. Octstr *ospdu;
  66. sm->reply_caps = wsp_cap_duplicate_list(
  67. e->negotiated_capabilities);
  68. /* Send Disconnect event to existing sessions for client. */
  69. disconnect_other_sessions(sm);
  70. /* Assign a Session_ID for this session. */
  71. /* We've already done that in the NULL_STATE. */
  72. /* TR-Result.req(ConnectReply) */
  73. ospdu = make_connectreply_pdu(sm);
  74. wtp_event = wap_event_create(TR_Result_Req);
  75. wtp_event->u.TR_Result_Req.user_data = ospdu;
  76. wtp_event->u.TR_Result_Req.handle = sm->connect_handle;
  77. dispatch_to_wtp_resp(wtp_event);
  78. /* Release all method transactions in HOLDING state. */
  79. release_holding_methods(sm);
  80. },
  81. CONNECTING_2)
  82. /* MISSING: CONNECTING, S_Disconnect_Req, reason == 301 (moved permanently) or
  83.  * 302 (moved temporarily). */
  84. /* MISSING: CONNECTING, S_Disconnect_Req, reason == anything else */
  85. ROW(CONNECTING,
  86. Disconnect_Event,
  87. 1,
  88. {
  89. /* TR-Abort.req(DISCONNECT) the Connect transaction */
  90. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  91. /* Abort(DISCONNECT) all method transactions */
  92. abort_methods(sm, WSP_ABORT_DISCONNECT);
  93. /* S-Disconnect.ind(DISCONNECT) */
  94. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  95. },
  96. NULL_SESSION)
  97. ROW(CONNECTING,
  98. Suspend_Event,
  99. 1,
  100. {
  101. /* TR-Abort.req(DISCONNECT) the Connect transaction */
  102. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  103. /* Abort(DISCONNECT) all method transactions */
  104. abort_methods(sm, WSP_ABORT_DISCONNECT);
  105. /* S-Disconnect.ind(SUSPEND) */
  106. indicate_disconnect(sm, WSP_ABORT_SUSPEND);
  107. },
  108. NULL_SESSION)
  109. ROW(CONNECTING,
  110. TR_Invoke_Ind,
  111. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  112. WSPMethodMachine *msm;
  113. /* Start new method transaction */
  114. msm = method_machine_create(sm, e->handle);
  115. /* Hand off the event to the new method machine */
  116. handle_method_event(sm, msm, current_event, pdu);
  117. },
  118. CONNECTING)
  119. ROW(CONNECTING,
  120. TR_Invoke_Ind,
  121. e->tcl == 2 && pdu->type == Resume,
  122. {
  123. /* TR-Abort.req(DISCONNECT) the TR-Invoke */
  124. send_abort(WSP_ABORT_DISCONNECT, e->handle);
  125. },
  126. CONNECTING)
  127. ROW(CONNECTING,
  128. TR_Abort_Ind,
  129. e->handle == sm->connect_handle,
  130. {
  131. /* Abort(DISCONNECT) all method transactions */
  132. abort_methods(sm, WSP_ABORT_DISCONNECT);
  133. /* S-Disconnect.ind(abort reason) */
  134. indicate_disconnect(sm, e->abort_code);
  135. },
  136. NULL_SESSION)
  137. ROW(CONNECTING,
  138. TR_Abort_Ind,
  139. e->handle != sm->connect_handle,
  140. {
  141. WSPMethodMachine *msm;
  142. /* See method state table  */
  143. msm = find_method_machine(sm, e->handle);
  144. handle_method_event(sm, msm, current_event, pdu);
  145. },
  146. CONNECTING)
  147. ROW(TERMINATING,
  148. Disconnect_Event,
  149. 1,
  150. {
  151. /* TR-Abort.req(DISCONNECT) remaining transport transaction */
  152. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  153. },
  154. NULL_SESSION)
  155. ROW(TERMINATING,
  156. Suspend_Event,
  157. 1,
  158. {
  159. /* TR-Abort.req(SUSPEND) remaining transport transaction */
  160. send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
  161. },
  162. NULL_SESSION)
  163. ROW(TERMINATING,
  164. TR_Result_Cnf,
  165. 1,
  166. {
  167. /* Ignore */
  168. },
  169. NULL_SESSION)
  170. ROW(TERMINATING,
  171. TR_Abort_Ind,
  172. 1,
  173. {
  174. /* Ignore */
  175. },
  176. NULL_SESSION)
  177. /* MISSING: CONNECTING_2, S-Disconnect.req */
  178. ROW(CONNECTING_2,
  179. Disconnect_Event,
  180. 1,
  181. {
  182. /* TR-Abort.req(DISCONNECT) the Connect transaction */
  183. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  184. /* Abort(DISCONNECT) all method and push transactions */
  185. abort_methods(sm, WSP_ABORT_DISCONNECT);
  186. /* S-Disconnect.ind(DISCONNECT) */
  187. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  188. },
  189. NULL_SESSION)
  190. ROW(CONNECTING_2,
  191. S_MethodInvoke_Res,
  192. 1,
  193. {
  194. WSPMethodMachine *msm;
  195. /* See method state table */
  196. msm = find_method_machine(sm, e->server_transaction_id);
  197. handle_method_event(sm, msm, current_event, pdu);
  198. },
  199. CONNECTING_2)
  200. ROW(CONNECTING_2,
  201. S_MethodResult_Req,
  202. 1,
  203. {
  204. WSPMethodMachine *msm;
  205. /* See method state table */
  206. msm = find_method_machine(sm, e->server_transaction_id);
  207. handle_method_event(sm, msm, current_event, pdu);
  208. },
  209. CONNECTING_2)
  210. ROW(CONNECTING_2,
  211.         S_Push_Req,
  212.         1,
  213.         {
  214.                 WSP_PDU *pdu;
  215.                 pdu = make_push_pdu(current_event);
  216.                 send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
  217.         },
  218.         CONNECTING_2)
  219. ROW(CONNECTING_2,
  220.         S_ConfirmedPush_Req,
  221.         1,
  222.         {
  223.                 /* Start new push transaction*/
  224.                 WSPPushMachine *spm;
  225.                 spm = push_machine_create(sm, e->server_push_id);
  226.                 handle_push_event(sm, spm, current_event);   
  227.         },
  228.         CONNECTING_2)
  229. ROW(CONNECTING_2,
  230. Suspend_Event,
  231. !resume_enabled,
  232. {
  233. /* Session Resume facility disabled */
  234. /* TR-Abort.req(DISCONNECT) the Connect transaction */
  235. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  236. /* Abort(DISCONNECT) all method and push transactions */
  237. abort_methods(sm, WSP_ABORT_DISCONNECT);
  238. /* S-Disconnect.ind(SUSPEND) */
  239. indicate_disconnect(sm, WSP_ABORT_SUSPEND);
  240. },
  241. NULL_SESSION)
  242. ROW(CONNECTING_2,
  243. Suspend_Event,
  244. resume_enabled,
  245. {
  246. /* Session Resume facility enabled */
  247. /* TR-Abort.req(SUSPEND) the Connect transaction */
  248. send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
  249. /* Abort(SUSPEND) all method and push transactions */
  250. abort_methods(sm, WSP_ABORT_SUSPEND);
  251. /* S-Suspend.ind(SUSPEND) */
  252. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  253. },
  254. SUSPENDED)
  255. ROW(CONNECTING_2,
  256. TR_Invoke_Ind,
  257. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  258. {
  259. WSPMethodMachine *msm;
  260. WAPEvent *new_event;
  261. /* Start new method transaction */
  262. msm = method_machine_create(sm, e->handle);
  263. /* Hand off the event to the new method machine */
  264. handle_method_event(sm, msm, current_event, pdu);
  265. /* Release the new method transaction */
  266. new_event = wap_event_create(Release_Event);
  267. handle_method_event(sm, msm, new_event, NULL);
  268. wap_event_destroy(new_event);
  269. },
  270. CONNECTING_2)
  271. ROW(CONNECTING_2,
  272. TR_Invoke_Ind,
  273. e->tcl == 2 && pdu->type == Resume && !resume_enabled,
  274. {
  275. /* Resume facility disabled */
  276. /* TR-Abort.req(DISCONNECT) the TR-Invoke */
  277. send_abort(WSP_ABORT_DISCONNECT, e->handle);
  278. },
  279. CONNECTING_2)
  280. ROW(CONNECTING_2,
  281. TR_Invoke_Ind,
  282. e->tcl == 2 && pdu->type == Resume && resume_enabled,
  283. {
  284. /* Resume facility enabled */
  285. WAPEvent *wtp_event;
  286. List *new_headers;
  287. /* TR-Invoke.res */
  288. wtp_event = wap_event_create(TR_Invoke_Res);
  289. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  290. dispatch_to_wtp_resp(wtp_event);
  291. /* TR-Abort.req(RESUME) the Connect transaction */
  292. send_abort(WSP_ABORT_RESUME, sm->connect_handle);
  293. /* Abort(RESUME) all method and push transactions */
  294. abort_methods(sm, WSP_ABORT_RESUME);
  295. /* S-Suspend.ind(RESUME) */
  296. indicate_suspend(sm, WSP_ABORT_RESUME);
  297. /* S-Resume.ind */
  298. new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
  299. indicate_resume(sm, e->addr_tuple, new_headers);
  300. http_destroy_headers(new_headers);
  301. sm->resume_handle = e->handle;
  302. },
  303. RESUMING)
  304. ROW(CONNECTING_2,
  305. TR_Invoke_Ind,
  306. e->tcl == 0 && pdu->type == Disconnect,
  307. {
  308. /* TR-Abort.req(DISCONNECT) the Connect transaction */
  309. send_abort(WSP_ABORT_DISCONNECT, sm->connect_handle);
  310. /* Abort(DISCONNECT) all method and push transactions */
  311. abort_methods(sm, WSP_ABORT_DISCONNECT);
  312. /* S-Disconnect.ind(DISCONNECT) */
  313. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  314. },
  315. NULL_SESSION)
  316. ROW(CONNECTING_2,
  317. TR_Invoke_Ind,
  318. e->tcl == 0 && pdu->type == Suspend && resume_enabled,
  319. {
  320. /* Resume facility enabled */
  321. /* TR-Abort.req(SUSPEND) the Connect transaction */
  322. send_abort(WSP_ABORT_SUSPEND, sm->connect_handle);
  323. /* Abort(SUSPEND) all method and push transactions */
  324. abort_methods(sm, WSP_ABORT_SUSPEND);
  325. /* S-Suspend.ind(SUSPEND) */
  326. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  327. },
  328. SUSPENDED)
  329. ROW(CONNECTING_2,
  330.         TR_Invoke_Cnf,
  331.         1,
  332.         {
  333.                 /* See push state table*/
  334.                 WSPPushMachine *spm;
  335.                 spm = find_push_machine(sm, e->handle);
  336.                 handle_push_event(sm, spm, current_event);
  337.         },
  338.         CONNECTING_2)
  339. ROW(CONNECTING_2,
  340. TR_Result_Cnf,
  341. e->handle == sm->connect_handle,
  342. {
  343. },
  344. CONNECTED)
  345. ROW(CONNECTING_2,
  346. TR_Result_Cnf,
  347. e->handle != sm->connect_handle,
  348. {
  349. WSPMethodMachine *msm;
  350. /* See method state table */
  351. msm = find_method_machine(sm, e->handle);
  352. handle_method_event(sm, msm, current_event, pdu);
  353. },
  354. CONNECTING_2)
  355. ROW(CONNECTING_2,
  356. TR_Abort_Ind,
  357. e->handle == sm->connect_handle,
  358. {
  359. /* Abort(DISCONNECT) all method and push transactions */
  360. abort_methods(sm, WSP_ABORT_DISCONNECT);
  361. /* S-Disconnect.ind(abort reason) */
  362. indicate_disconnect(sm, e->abort_code);
  363. },
  364. NULL_SESSION)
  365. /* 
  366.  * A separate flag tells is the indicator the initiator or the responder.
  367.  */
  368. ROW(CONNECTING_2,
  369. TR_Abort_Ind,
  370. e->handle != sm->connect_handle && e->ir_flag == RESPONDER_INDICATION,
  371. {
  372. WSPMethodMachine *msm;
  373. /* See method state table */
  374. msm = find_method_machine(sm, e->handle);
  375. handle_method_event(sm, msm, current_event, pdu);
  376. },
  377. CONNECTING_2)
  378. ROW(CONNECTING_2,
  379. TR_Abort_Ind,
  380. e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
  381. {
  382. WSPPushMachine *m;
  383. /* See push state table */
  384. m = find_push_machine(sm, e->handle);
  385. handle_push_event(sm, m, current_event);
  386. },
  387. CONNECTING_2)
  388. /* MISSING: CONNECTED, S-Disconnect.req */
  389. ROW(CONNECTED,
  390. Disconnect_Event,
  391. 1,
  392. {
  393. /* Abort(DISCONNECT) all method and push transactions */
  394. abort_methods(sm, WSP_ABORT_DISCONNECT);
  395. /* S-Disconnect.ind(DISCONNECT) */
  396. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  397. },
  398. NULL_SESSION)
  399. ROW(CONNECTED,
  400. S_MethodInvoke_Res,
  401. 1,
  402. {
  403. WSPMethodMachine *msm;
  404. /* See method state table */
  405. msm = find_method_machine(sm, e->server_transaction_id);
  406. handle_method_event(sm, msm, current_event, pdu);
  407. },
  408. CONNECTED)
  409. ROW(CONNECTED,
  410. S_MethodResult_Req,
  411. 1,
  412. {
  413. WSPMethodMachine *msm;
  414. /* See method state table */
  415. msm = find_method_machine(sm, e->server_transaction_id);
  416. handle_method_event(sm, msm, current_event, pdu);
  417. },
  418. CONNECTED)
  419. ROW(CONNECTED,
  420.         S_Push_Req,
  421.         1,
  422.         {
  423.                WSP_PDU *pdu;
  424.                pdu = make_push_pdu(current_event);
  425.                send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
  426.         },
  427.         CONNECTED)
  428. ROW(CONNECTED,
  429.         S_ConfirmedPush_Req,
  430.         1,
  431.         {
  432.                /* Start new push transaction*/
  433.                 WSPPushMachine *spm;
  434.                 spm = push_machine_create(sm, e->server_push_id);
  435.                 handle_push_event(sm, spm, current_event);
  436.         },
  437.         CONNECTED)
  438. ROW(CONNECTED,
  439. Suspend_Event,
  440. !resume_enabled,
  441. {
  442. /* Session Resume facility disabled */
  443. /* Abort(SUSPEND) all method and push transactions */
  444. abort_methods(sm, WSP_ABORT_SUSPEND);
  445. /* S-Disconnect.ind(SUSPEND) */
  446. indicate_disconnect(sm, WSP_ABORT_SUSPEND);
  447. },
  448. NULL_SESSION)
  449. ROW(CONNECTED,
  450. Suspend_Event,
  451. resume_enabled,
  452. {
  453. /* Session Resume facility enabled */
  454. /* Abort(SUSPEND) all method and push transactions */
  455. abort_methods(sm, WSP_ABORT_SUSPEND);
  456. /* S-Suspend.ind(SUSPEND) */
  457. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  458. },
  459. SUSPENDED)
  460. ROW(CONNECTED,
  461. TR_Invoke_Ind,
  462. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  463. {
  464. WSPMethodMachine *msm;
  465. WAPEvent *new_event;
  466. /* Start new method transaction */
  467. msm = method_machine_create(sm, e->handle);
  468. /* Hand off the event to the new method machine */
  469. handle_method_event(sm, msm, current_event, pdu);
  470. /* Release the new method transaction */
  471. new_event = wap_event_create(Release_Event);
  472. handle_method_event(sm, msm, new_event, NULL);
  473. wap_event_destroy(new_event);
  474. },
  475. CONNECTED)
  476. ROW(CONNECTED,
  477. TR_Invoke_Ind,
  478. e->tcl == 2 && pdu->type == Resume && !resume_enabled,
  479. {
  480. /* Resume facility disabled */
  481. /* TR-Abort.req(DISCONNECT) the TR-Invoke */
  482. send_abort(WSP_ABORT_DISCONNECT, e->handle);
  483. },
  484. CONNECTED)
  485. ROW(CONNECTED,
  486. TR_Invoke_Ind,
  487. e->tcl == 2 && pdu->type == Resume && resume_enabled,
  488. {
  489. /* Resume facility enabled */
  490. WAPEvent *wtp_event;
  491. List *new_headers;
  492. /* TR-Invoke.res */
  493. wtp_event = wap_event_create(TR_Invoke_Res);
  494. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  495. dispatch_to_wtp_resp(wtp_event);
  496. /* Abort(RESUME) all method and push transactions */
  497. abort_methods(sm, WSP_ABORT_RESUME);
  498. /* S-Suspend.ind(RESUME) */
  499. indicate_suspend(sm, WSP_ABORT_RESUME);
  500. /* S-Resume.ind */
  501. new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
  502. indicate_resume(sm, e->addr_tuple, new_headers);
  503. http_destroy_headers(new_headers);
  504. sm->resume_handle = e->handle;
  505. },
  506. RESUMING)
  507. ROW(CONNECTED,
  508. TR_Invoke_Ind,
  509. e->tcl == 0 && pdu->type == Disconnect,
  510. {
  511. /* Abort(DISCONNECT) all method and push transactions */
  512. abort_methods(sm, WSP_ABORT_DISCONNECT);
  513. /* S-Disconnect.ind(DISCONNECT) */
  514. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  515. },
  516. NULL_SESSION)
  517. ROW(CONNECTED,
  518. TR_Invoke_Ind,
  519. e->tcl == 0 && pdu->type == Suspend && resume_enabled,
  520. {
  521. /* Abort(SUSPEND) all method and push transactions */
  522. abort_methods(sm, WSP_ABORT_SUSPEND);
  523. /* S-Suspend.ind(SUSPEND) */
  524. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  525. },
  526. SUSPENDED)
  527. ROW(CONNECTED,
  528.        TR_Invoke_Cnf,
  529.        1,
  530.        {
  531.                 /* See push state table*/
  532.                 WSPPushMachine *spm;
  533.                 spm = find_push_machine(sm, e->handle);
  534.                 handle_push_event(sm, spm, current_event);
  535.        },
  536.        CONNECTED)
  537. ROW(CONNECTED,
  538. TR_Result_Cnf,
  539. e->handle != sm->connect_handle,
  540. {
  541. WSPMethodMachine *msm;
  542. /* See method state table */
  543. msm = find_method_machine(sm, e->handle);
  544. handle_method_event(sm, msm, current_event, pdu);
  545. },
  546. CONNECTED)
  547. /* 
  548.  * Event TR-Abort.ind has a separate flag telling is the indicator the 
  549.  * initiator or the responder.
  550.  */
  551. ROW(CONNECTED,
  552. TR_Abort_Ind,
  553. e->handle != sm->connect_handle  && e->ir_flag == RESPONDER_INDICATION,
  554. {
  555. WSPMethodMachine *msm;
  556. /* See method state table */
  557. msm = find_method_machine(sm, e->handle);
  558. handle_method_event(sm, msm, current_event, pdu);
  559. },
  560. CONNECTED)
  561. ROW(CONNECTED,
  562. TR_Abort_Ind,
  563. e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
  564. {
  565. WSPPushMachine *m;
  566. /* See push state table */
  567. m = find_push_machine(sm, e->handle);
  568. handle_push_event(sm, m, current_event);
  569. },
  570. CONNECTED)
  571. /* MISSING: SUSPENDED, S-Disconnect.req */
  572. ROW(SUSPENDED,
  573. Disconnect_Event,
  574. 1,
  575. {
  576. /* S-Disconnect.ind(DISCONNECT) */
  577. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  578. },
  579. NULL_SESSION)
  580. ROW(SUSPENDED,
  581. TR_Invoke_Ind,
  582. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  583. {
  584. /* TR-Abort.req(SUSPEND) the TR-Invoke */
  585. send_abort(WSP_ABORT_SUSPEND, e->handle);
  586. },
  587. SUSPENDED)
  588. ROW(SUSPENDED,
  589. TR_Invoke_Ind,
  590. e->tcl == 2 && pdu->type == Resume,
  591. {
  592. WAPEvent *wtp_event;
  593. List *new_headers;
  594. /* TR-Invoke.res */
  595. wtp_event = wap_event_create(TR_Invoke_Res);
  596. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  597. dispatch_to_wtp_resp(wtp_event);
  598. /* S-Resume.ind */
  599. new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
  600. indicate_resume(sm, e->addr_tuple, new_headers);
  601. http_destroy_headers(new_headers);
  602. sm->resume_handle = e->handle;
  603. },
  604. RESUMING)
  605. ROW(SUSPENDED,
  606. TR_Invoke_Ind,
  607. e->tcl == 0 && pdu->type == Disconnect,
  608. {
  609. /* S-Disconnect.ind(DISCONNECT) */
  610. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  611. },
  612. NULL_SESSION)
  613. /* MISSING: RESUMING, S-Disconnect.req */
  614. ROW(RESUMING,
  615. Disconnect_Event,
  616. 1,
  617. {
  618. /* TR-Abort.req(DISCONNECT) the Resume transaction */
  619. send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
  620. /* Abort(DISCONNECT) all method transactions */
  621. abort_methods(sm, WSP_ABORT_DISCONNECT);
  622. /* S-Disconnect.ind(DISCONNECT) */
  623. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  624. },
  625. NULL_SESSION)
  626. ROW(RESUMING,
  627. S_Resume_Res,
  628. 1,
  629. {
  630. WAPEvent *wtp_event;
  631. Octstr *ospdu;
  632. /* Disconnect any other session for the peer address quadruplet */
  633. disconnect_other_sessions(sm);
  634. /* Bind session to new peer address quadruplet */
  635. /* this happens automatically XXX Not true */
  636. /* TR-Result.req(Reply) */
  637. if (e->server_headers == NULL)
  638. e->server_headers = http_create_empty_headers();
  639. ospdu = make_resume_reply_pdu(sm, e->server_headers);
  640. wtp_event = wap_event_create(TR_Result_Req);
  641. wtp_event->u.TR_Result_Req.user_data = ospdu;
  642. wtp_event->u.TR_Result_Req.handle = sm->resume_handle;
  643. dispatch_to_wtp_resp(wtp_event);
  644. /* Release all method transactions in HOLDING state */
  645. release_holding_methods(sm);
  646. },
  647. RESUMING_2)
  648. ROW(RESUMING,
  649. Suspend_Event,
  650. 1,
  651. {
  652. /* TR-Abort.req(SUSPEND) the Resume transaction */
  653. send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
  654. /* Abort(SUSPEND) all method transactions */
  655. abort_methods(sm, WSP_ABORT_SUSPEND);
  656. /* S-Suspend.ind(SUSPEND) */
  657. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  658. },
  659. SUSPENDED)
  660. ROW(RESUMING,
  661. TR_Invoke_Ind,
  662. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  663. {
  664. /* Start new method transaction (see method state table) */
  665. WSPMethodMachine *msm;
  666. msm = method_machine_create(sm, e->handle);
  667. handle_method_event(sm, msm, current_event, pdu);
  668. },
  669. RESUMING)
  670. ROW(RESUMING,
  671. TR_Invoke_Ind,
  672. e->tcl == 2 && pdu->type == Resume,
  673. {
  674. WAPEvent *wtp_event;
  675. List *new_headers;
  676. /* TR-Invoke.res */
  677. wtp_event = wap_event_create(TR_Invoke_Res);
  678. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  679. dispatch_to_wtp_resp(wtp_event);
  680. /* TR-Abort.req(RESUME) the old Resume transaction */
  681. send_abort(WSP_ABORT_RESUME, sm->resume_handle);
  682. /* Abort(RESUME) all method transactions */
  683. abort_methods(sm, WSP_ABORT_RESUME);
  684. /* S-Suspend.ind(RESUME) */
  685. indicate_suspend(sm, WSP_ABORT_RESUME);
  686. /* S-Resume.ind */
  687. new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
  688. indicate_resume(sm, e->addr_tuple, new_headers);
  689. http_destroy_headers(new_headers);
  690. sm->resume_handle = e->handle;
  691. },
  692. RESUMING)
  693. ROW(RESUMING,
  694. TR_Invoke_Ind,
  695. e->tcl == 0 && pdu->type == Suspend,
  696. {
  697. /* TR-Abort.req(SUSPEND) the Resume transaction */
  698. send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
  699. /* Abort(SUSPEND) all method transactions */
  700. abort_methods(sm, WSP_ABORT_SUSPEND);
  701. /* S-Suspend.ind(SUSPEND) */
  702. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  703. },
  704. SUSPENDED)
  705. ROW(RESUMING,
  706. TR_Invoke_Ind,
  707. e->tcl == 0 && pdu->type == Disconnect,
  708. {
  709. /* TR-Abort.req(DISCONNECT) the Resume transaction */
  710. send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
  711. /* Abort(DISCONNECT) all method transactions */
  712. abort_methods(sm, WSP_ABORT_DISCONNECT);
  713. /* S-Disconnect.ind(DISCONNECT) */
  714. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  715. },
  716. NULL_SESSION)
  717. ROW(RESUMING,
  718. TR_Abort_Ind,
  719. e->handle == sm->resume_handle,
  720. {
  721. /* Abort(SUSPEND) all method transactions */
  722. abort_methods(sm, WSP_ABORT_SUSPEND);
  723. /* S-Suspend.ind(abort reason) */
  724. indicate_suspend(sm, e->abort_code);
  725. },
  726. SUSPENDED)
  727. /* MISSING: RESUMING_2, S-Disconnect.req */
  728. ROW(RESUMING_2,
  729. Disconnect_Event,
  730. 1,
  731. {
  732. /* TR-Abort.req(DISCONNECT) the Resume */
  733. send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
  734. /* Abort(DISCONNECT) all method and push transactions */
  735. abort_methods(sm, WSP_ABORT_DISCONNECT);
  736. /* S-Disconnect.ind(DISCONNECT) */
  737. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  738. },
  739. NULL_SESSION)
  740. ROW(RESUMING_2,
  741. S_MethodInvoke_Res,
  742. 1,
  743. {
  744. WSPMethodMachine *msm;
  745. /* See method state table */
  746. msm = find_method_machine(sm, e->server_transaction_id);
  747. handle_method_event(sm, msm, current_event, pdu);
  748. },
  749. RESUMING_2)
  750. ROW(RESUMING_2,
  751. S_MethodResult_Req,
  752. 1,
  753. {
  754. WSPMethodMachine *msm;
  755. /* See method state table */
  756. msm = find_method_machine(sm, e->server_transaction_id);
  757. handle_method_event(sm, msm, current_event, pdu);
  758. },
  759. RESUMING_2)
  760. ROW(RESUMING_2,
  761.         S_Push_Req,
  762.         1,
  763.         {
  764.                 WSP_PDU *pdu;
  765.                 pdu = make_push_pdu(current_event);
  766.                 send_invoke(sm, pdu, current_event, TRANSACTION_CLASS_0);
  767.         },
  768.         RESUMING_2)
  769. ROW(RESUMING_2,
  770.         S_ConfirmedPush_Req,
  771.         1,
  772.         {
  773.                 /* Start new push transaction*/
  774.                 WSPPushMachine *spm;
  775.                 spm = push_machine_create(sm, e->server_push_id);
  776.                 handle_push_event(sm, spm, current_event);
  777.         },
  778.         RESUMING_2)
  779. ROW(RESUMING_2,
  780. Suspend_Event,
  781. 1,
  782. {
  783. /* TR-Abort.req(SUSPEND) the Resume transaction */
  784. send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
  785. /* Abort(SUSPEND) all method and push transactions */
  786. abort_methods(sm, WSP_ABORT_SUSPEND);
  787. /* S-Suspend.ind(SUSPEND) */
  788. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  789. },
  790. SUSPENDED)
  791. ROW(RESUMING_2,
  792. TR_Invoke_Ind,
  793. e->tcl == 2 && (pdu->type == Get || pdu->type == Post),
  794. {
  795. WSPMethodMachine *msm;
  796. WAPEvent *new_event;
  797. /* Start new method transaction (see method state table) */
  798. msm = method_machine_create(sm, e->handle);
  799. handle_method_event(sm, msm, current_event, pdu);
  800. /* Release the new method transaction */
  801. new_event = wap_event_create(Release_Event);
  802. handle_method_event(sm, msm, new_event, NULL);
  803. wap_event_destroy(new_event);
  804. },
  805. RESUMING_2)
  806. ROW(RESUMING_2,
  807. TR_Invoke_Ind,
  808. e->tcl == 2 && pdu->type == Resume,
  809. {
  810. WAPEvent *wtp_event;
  811. List *new_headers;
  812. /* TR-Invoke.res */
  813. wtp_event = wap_event_create(TR_Invoke_Res);
  814. wtp_event->u.TR_Invoke_Res.handle = e->handle;
  815. dispatch_to_wtp_resp(wtp_event);
  816. /* TR-Abort.req(RESUME) the old Resume transaction*/
  817. send_abort(WSP_ABORT_RESUME, sm->resume_handle);
  818. /* Abort(RESUME) all method and push transactions */
  819. abort_methods(sm, WSP_ABORT_RESUME);
  820. /* S-Suspend.ind(RESUME) */
  821. indicate_suspend(sm, WSP_ABORT_RESUME);
  822. /* S-Resume.ind */
  823. new_headers = unpack_new_headers(sm, pdu->u.Resume.headers);
  824. indicate_resume(sm, e->addr_tuple, new_headers);
  825. http_destroy_headers(new_headers);
  826. sm->resume_handle = e->handle;
  827. },
  828. RESUMING)
  829. ROW(RESUMING_2,
  830. TR_Invoke_Ind,
  831. e->tcl == 0 && pdu->type == Suspend,
  832. {
  833. /* TR-Abort.req(SUSPEND) the Resume transaction */
  834. send_abort(WSP_ABORT_SUSPEND, sm->resume_handle);
  835. /* Abort(SUSPEND) all method and push transactions */
  836. abort_methods(sm, WSP_ABORT_SUSPEND);
  837. /* S-Suspend.ind(SUSPEND) */
  838. indicate_suspend(sm, WSP_ABORT_SUSPEND);
  839. },
  840. SUSPENDED)
  841. ROW(RESUMING_2,
  842. TR_Invoke_Ind,
  843. e->tcl == 0 && pdu->type == Disconnect,
  844. {
  845. /* TR-Abort.req(DISCONNECT) the Resume */
  846. send_abort(WSP_ABORT_DISCONNECT, sm->resume_handle);
  847. /* Abort(DISCONNECT) all method and push transactions */
  848. abort_methods(sm, WSP_ABORT_DISCONNECT);
  849. /* S-Disconnect.ind(DISCONNECT) */
  850. indicate_disconnect(sm, WSP_ABORT_DISCONNECT);
  851. },
  852. NULL_SESSION)
  853. ROW(RESUMING_2,
  854.         TR_Invoke_Cnf,
  855.         1,
  856.         {
  857.                 /* See push state table*/
  858.                 WSPPushMachine *spm;
  859.                 spm = find_push_machine(sm, e->handle);
  860.                 handle_push_event(sm, spm, current_event);
  861.         },
  862.         RESUMING_2)
  863. ROW(RESUMING_2,
  864. TR_Result_Cnf,
  865. e->handle == sm->resume_handle,
  866. {
  867. },
  868. CONNECTED)
  869. ROW(RESUMING_2,
  870. TR_Result_Cnf,
  871. e->handle != sm->resume_handle,
  872. {
  873. WSPMethodMachine *msm;
  874. /* See method state table */
  875. msm = find_method_machine(sm, e->handle);
  876. handle_method_event(sm, msm, current_event, pdu);
  877. },
  878. RESUMING_2)
  879. ROW(RESUMING_2,
  880. TR_Abort_Ind,
  881. e->handle == sm->resume_handle,
  882. {
  883. /* Abort(SUSPEND) all method and push transactions */
  884. abort_methods(sm, WSP_ABORT_SUSPEND);
  885. /* S-Suspend.ind(abort reason) */
  886. indicate_suspend(sm, e->abort_code);
  887. },
  888. SUSPENDED)
  889. /* 
  890.  * A separate flag tells is the indicator the initiator or the responder
  891.  */
  892. ROW(RESUMING_2,
  893. TR_Abort_Ind,
  894. e->handle != sm->resume_handle && e->ir_flag == RESPONDER_INDICATION,
  895. {
  896. WSPMethodMachine *msm;
  897. /* See method state table */
  898. msm = find_method_machine(sm, e->handle);
  899. handle_method_event(sm, msm, current_event, pdu);
  900. },
  901. RESUMING_2)
  902. ROW(CONNECTING_2,
  903. TR_Abort_Ind,
  904. e->handle != sm->connect_handle && e->ir_flag == INITIATOR_INDICATION,
  905. {
  906. WSPPushMachine *m;
  907. /* See push state table */
  908. m = find_push_machine(sm, e->handle);
  909. handle_push_event(sm, m, current_event);
  910. },
  911. CONNECTING_2)
  912. #undef ROW
  913. #undef STATE_NAME