Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wap.c File Reference
#include "gwlib/gwlib.h"
#include "wap.h"
#include "wtp.h"

Go to the source code of this file.

Macros

#define CONNECTIONLESS_PORT   9200
 
#define WTLS_CONNECTIONLESS_PORT   9202
 

Functions

void wap_dispatch_datagram (WAPEvent *dgram)
 

Macro Definition Documentation

#define CONNECTIONLESS_PORT   9200

Definition at line 65 of file wap.c.

Referenced by wap_dispatch_datagram().

#define WTLS_CONNECTIONLESS_PORT   9202

Definition at line 66 of file wap.c.

Referenced by wap_dispatch_datagram().

Function Documentation

void wap_dispatch_datagram ( WAPEvent dgram)

Definition at line 68 of file wap.c.

References CONNECTIONLESS_PORT, debug(), Timer::event, gw_assert(), gwlist_destroy(), gwlist_extract_first(), gwlist_len(), WAPEvent::type, WAPEvent::u, wap_event_destroy(), wap_event_dump(), warning(), wsp_unit_dispatch_event(), WTLS_CONNECTIONLESS_PORT, wtp_event_is_for_responder(), wtp_initiator_dispatch_event(), wtp_resp_dispatch_event(), and wtp_unpack_wdp_datagram().

Referenced by main().

69 {
70  long len;
71  gw_assert(dgram != NULL);
72 
73  if (dgram->type != T_DUnitdata_Ind) {
74  warning(0, "wap_dispatch_datagram got event of unexpected type.");
75  wap_event_dump(dgram);
76  wap_event_destroy(dgram);
77  return;
78  }
79 
80  /* XXX Assumption does not hold for client side */
81  if (dgram->u.T_DUnitdata_Ind.addr_tuple->local->port ==
82  CONNECTIONLESS_PORT || dgram->u.T_DUnitdata_Ind.addr_tuple->
83  local->port == WTLS_CONNECTIONLESS_PORT) {
85  } else {
86  List *events;
87 
88  events = wtp_unpack_wdp_datagram(dgram);
89 
90  if (!events) {
91  debug("wap.wap", 0, "ignoring truncated datagram");
92  wap_event_dump(dgram);
93  wap_event_destroy(dgram);
94  return;
95  }
96 
97  len = gwlist_len(events);
98  while (len-- > 0)
99  {
100  WAPEvent *event;
101 
102  event = gwlist_extract_first(events);
103  if (wtp_event_is_for_responder(event))
105  else
107  }
108 
109  wap_event_destroy(dgram);
110  gwlist_destroy(events, NULL);
111  }
112 }
List * wtp_unpack_wdp_datagram(WAPEvent *datagram)
Definition: wtp.c:98
long gwlist_len(List *list)
Definition: list.c:166
void wap_event_dump(WAPEvent *event)
Definition: wap_events.c:181
void wsp_unit_dispatch_event(WAPEvent *event)
Definition: wsp_unit.c:124
void * gwlist_extract_first(List *list)
Definition: list.c:305
#define WTLS_CONNECTIONLESS_PORT
Definition: wap.c:66
int wtp_event_is_for_responder(WAPEvent *event)
Definition: wtp.c:156
void warning(int err, const char *fmt,...)
Definition: log.c:624
gw_assert(wtls_machine->packet_to_send!=NULL)
void wtp_resp_dispatch_event(WAPEvent *event)
Definition: wtp_resp.c:253
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
WAPEventName type
Definition: wap_events.h:88
#define CONNECTIONLESS_PORT
Definition: wap.c:65
union WAPEvent::@87 u
Definition: list.c:102
void wtp_initiator_dispatch_event(WAPEvent *event)
Definition: wtp_init.c:204
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.