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

手机WAP编程

开发平台:

WINDOWS

  1. /*
  2.  * wap.c - Generic functions for wap library
  3.  */
  4. #include "gwlib/gwlib.h"
  5. #include "wap.h"
  6. #include "wtp.h"
  7. #define CONNECTIONLESS_PORT 9200
  8. void wap_dispatch_datagram(WAPEvent *dgram)
  9. {
  10.     gw_assert(dgram != NULL);
  11.     if (dgram->type != T_DUnitdata_Ind) {
  12. warning(0, "wap_dispatch_datagram got event of unexpected type.");
  13. wap_event_dump(dgram);
  14. wap_event_destroy(dgram);
  15.         return;
  16.     }
  17.     /* XXX Assumption does not hold for client side */
  18.     if (dgram->u.T_DUnitdata_Ind.addr_tuple->local->port
  19.         == CONNECTIONLESS_PORT) {
  20. wsp_unit_dispatch_event(dgram);
  21.     } else {
  22.         List *events;
  23.         events = wtp_unpack_wdp_datagram(dgram);
  24. wap_event_destroy(dgram);
  25.         while (list_len(events) > 0) {
  26.     WAPEvent *event;
  27.     event = list_extract_first(events);
  28.             if (wtp_event_is_for_responder(event))
  29.                 wtp_resp_dispatch_event(event);
  30.             else
  31.                 wtp_initiator_dispatch_event(event);
  32.         }
  33.         list_destroy(events, NULL);
  34.     }
  35. }