Kannel: Open Source WAP and SMS gateway  svn-r5335
wap.h File Reference
#include "wap_events.h"
#include "wap_addr.h"

Go to the source code of this file.

Typedefs

typedef void wap_dispatch_func_t(WAPEvent *event)
 

Functions

void wap_dispatch_datagram (WAPEvent *event)
 
void wap_init (wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *application_dispatch)
 
void wap_shutdown (void)
 
void wtp_resp_init (wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *session_dispatch, wap_dispatch_func_t *push_dispatch, long timer_freq)
 
void wtp_resp_dispatch_event (WAPEvent *event)
 
void wtp_resp_shutdown (void)
 
void wtp_initiator_init (wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *session_dispatch, long timer_freq)
 
void wtp_initiator_dispatch_event (WAPEvent *event)
 
void wtp_initiator_shutdown (void)
 
void wsp_unit_init (wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *application_dispatch)
 
void wsp_unit_dispatch_event (WAPEvent *event)
 
void wsp_unit_shutdown (void)
 
void wsp_session_init (wap_dispatch_func_t *responder_dispatch, wap_dispatch_func_t *initiator_dispatch, wap_dispatch_func_t *application_dispatch, wap_dispatch_func_t *ota_dispatch)
 
void wsp_session_dispatch_event (WAPEvent *event)
 
void wsp_session_shutdown (void)
 
void wsp_push_client_init (wap_dispatch_func_t *dispatch_self, wap_dispatch_func_t *dispatch_wtp_resp)
 
void wsp_push_client_shutdown (void)
 
void wsp_push_client_dispatch_event (WAPEvent *e)
 

Typedef Documentation

◆ wap_dispatch_func_t

typedef void wap_dispatch_func_t(WAPEvent *event)

Definition at line 85 of file wap.h.

Function Documentation

◆ wap_dispatch_datagram()

void wap_dispatch_datagram ( WAPEvent event)

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
gw_assert(wtls_machine->packet_to_send !=NULL)
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:660
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:726
#define CONNECTIONLESS_PORT
Definition: wap.c:65
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

◆ wap_init()

void wap_init ( wap_dispatch_func_t datagram_dispatch,
wap_dispatch_func_t application_dispatch 
)

◆ wap_shutdown()

void wap_shutdown ( void  )

◆ wsp_push_client_dispatch_event()

void wsp_push_client_dispatch_event ( WAPEvent e)

Definition at line 177 of file wsp_push_client.c.

References gwlist_produce(), and push_client_queue.

Referenced by main().

178 {
180 }
void gwlist_produce(List *list, void *item)
Definition: list.c:411
static List * push_client_queue

◆ wsp_push_client_init()

void wsp_push_client_init ( wap_dispatch_func_t dispatch_self,
wap_dispatch_func_t dispatch_wtp_resp 
)

Definition at line 145 of file wsp_push_client.c.

References counter_create(), dispatch_to_self, dispatch_to_wtp_resp, gw_assert(), gwlist_add_producer(), gwlist_create, gwthread_create, limbo, main_thread(), push_client_machine_id_counter, push_client_machines, push_client_queue, push_client_run_status, and running.

Referenced by main().

147 {
150 
153 
154  dispatch_to_self = dispatch_self;
155  dispatch_to_wtp_resp = dispatch_wtp_resp;
156 
160 }
gw_assert(wtls_machine->packet_to_send !=NULL)
static Counter * push_client_machine_id_counter
Counter * counter_create(void)
Definition: counter.c:94
#define gwthread_create(func, arg)
Definition: gwthread.h:90
static List * push_client_machines
static void main_thread(void *)
static List * push_client_queue
wap_dispatch_func_t * dispatch_to_self
wap_dispatch_func_t * dispatch_to_wtp_resp
#define gwlist_create()
Definition: list.h:136
void gwlist_add_producer(List *list)
Definition: list.c:383
static enum @90 push_client_run_status

◆ wsp_push_client_shutdown()

void wsp_push_client_shutdown ( void  )

Definition at line 162 of file wsp_push_client.c.

References counter_destroy(), debug(), gw_assert(), gwlist_destroy(), gwlist_len(), gwlist_remove_producer(), gwthread_join_every(), main_thread(), push_client_machine_destroy(), push_client_machine_id_counter, push_client_machines, push_client_queue, push_client_run_status, running, terminating, and wap_event_destroy_item().

Referenced by main().

163 {
168 
169  debug("wap.wsp", 0, "wsp_push_client_shutdown: %ld push client machines"
173 
175 }
gw_assert(wtls_machine->packet_to_send !=NULL)
void counter_destroy(Counter *counter)
Definition: counter.c:110
long gwlist_len(List *list)
Definition: list.c:166
static void push_client_machine_destroy(void *a)
static Counter * push_client_machine_id_counter
void gwthread_join_every(gwthread_func_t *func)
void gwlist_remove_producer(List *list)
Definition: list.c:401
void wap_event_destroy_item(void *event)
Definition: wap_events.c:130
static List * push_client_machines
static void main_thread(void *)
static List * push_client_queue
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static enum @90 push_client_run_status
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ wsp_session_dispatch_event()

void wsp_session_dispatch_event ( WAPEvent event)

Definition at line 228 of file wsp_session.c.

References gwlist_produce(), queue, and wap_event_assert().

Referenced by main(), main_thread(), response_push_connection(), and return_session_reply().

228  {
229  wap_event_assert(event);
230  gwlist_produce(queue, event);
231 }
static List * queue
Definition: wsp_session.c:122
void gwlist_produce(List *list, void *item)
Definition: list.c:411
void wap_event_assert(WAPEvent *event)
Definition: wap_events.c:220

◆ wsp_session_init()

void wsp_session_init ( wap_dispatch_func_t responder_dispatch,
wap_dispatch_func_t initiator_dispatch,
wap_dispatch_func_t application_dispatch,
wap_dispatch_func_t ota_dispatch 
)

Definition at line 193 of file wsp_session.c.

References counter_create(), dispatch_to_appl, dispatch_to_ota, dispatch_to_wtp_init, dispatch_to_wtp_resp, gwlist_add_producer(), gwlist_create, gwthread_create, main_thread(), queue, run_status, running, session_id_counter, session_machines, and wsp_strings_init().

Referenced by main().

196  {
197  queue = gwlist_create();
201  dispatch_to_wtp_resp = responder_dispatch;
202  dispatch_to_wtp_init = initiator_dispatch;
203  dispatch_to_appl = application_dispatch;
204  dispatch_to_ota = push_ota_dispatch;
208 }
static List * queue
Definition: wsp_session.c:122
static List * session_machines
Definition: wsp_session.c:123
Counter * counter_create(void)
Definition: counter.c:94
static void main_thread(void *)
Definition: wsp_session.c:239
static wap_dispatch_func_t * dispatch_to_appl
Definition: wsp_session.c:110
#define gwthread_create(func, arg)
Definition: gwthread.h:90
static enum @91 run_status
void wsp_strings_init(void)
Definition: wsp_strings.c:269
static wap_dispatch_func_t * dispatch_to_wtp_resp
Definition: wsp_session.c:108
static wap_dispatch_func_t * dispatch_to_wtp_init
Definition: wsp_session.c:109
#define gwlist_create()
Definition: list.h:136
void gwlist_add_producer(List *list)
Definition: list.c:383
static Counter * session_id_counter
Definition: wsp_session.c:124
static wap_dispatch_func_t * dispatch_to_ota
Definition: wsp_session.c:111

◆ wsp_session_shutdown()

void wsp_session_shutdown ( void  )

Definition at line 211 of file wsp_session.c.

References counter_destroy(), debug(), gw_assert(), gwlist_destroy(), gwlist_len(), gwlist_remove_producer(), gwthread_join_every(), machine_destroy(), main_thread(), queue, run_status, running, session_id_counter, session_machines, terminating, wap_event_destroy_item(), and wsp_strings_shutdown().

Referenced by main().

211  {
216 
218 
219  debug("wap.wsp", 0, "WSP: %ld session machines left.",
222 
225 }
static List * queue
Definition: wsp_session.c:122
gw_assert(wtls_machine->packet_to_send !=NULL)
void counter_destroy(Counter *counter)
Definition: counter.c:110
long gwlist_len(List *list)
Definition: list.c:166
void gwthread_join_every(gwthread_func_t *func)
static List * session_machines
Definition: wsp_session.c:123
void gwlist_remove_producer(List *list)
Definition: list.c:401
void wap_event_destroy_item(void *event)
Definition: wap_events.c:130
static void machine_destroy(void *p)
Definition: wsp_session.c:535
static void main_thread(void *)
Definition: wsp_session.c:239
static enum @91 run_status
void wsp_strings_shutdown(void)
Definition: wsp_strings.c:286
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static Counter * session_id_counter
Definition: wsp_session.c:124
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ wsp_unit_dispatch_event()

void wsp_unit_dispatch_event ( WAPEvent event)

Definition at line 124 of file wsp_unit.c.

References gwlist_produce(), queue, and wap_event_assert().

Referenced by main(), return_unit_reply(), and wap_dispatch_datagram().

125 {
126  wap_event_assert(event);
127  gwlist_produce(queue, event);
128 }
void gwlist_produce(List *list, void *item)
Definition: list.c:411
void wap_event_assert(WAPEvent *event)
Definition: wap_events.c:220
static List * queue
Definition: wsp_unit.c:89

◆ wsp_unit_init()

void wsp_unit_init ( wap_dispatch_func_t datagram_dispatch,
wap_dispatch_func_t application_dispatch 
)

Definition at line 100 of file wsp_unit.c.

References dispatch_to_appl, dispatch_to_wdp, gwlist_add_producer(), gwlist_create, gwthread_create, main_thread(), queue, run_status, running, and wsp_strings_init().

Referenced by main().

102 {
103  queue = gwlist_create();
105  dispatch_to_wdp = datagram_dispatch;
106  dispatch_to_appl = application_dispatch;
110 }
static void main_thread(void *)
Definition: wsp_unit.c:217
static wap_dispatch_func_t * dispatch_to_appl
Definition: wsp_unit.c:87
#define gwthread_create(func, arg)
Definition: gwthread.h:90
static wap_dispatch_func_t * dispatch_to_wdp
Definition: wsp_unit.c:86
void wsp_strings_init(void)
Definition: wsp_strings.c:269
#define gwlist_create()
Definition: list.h:136
static enum @92 run_status
void gwlist_add_producer(List *list)
Definition: list.c:383
static List * queue
Definition: wsp_unit.c:89

◆ wsp_unit_shutdown()

void wsp_unit_shutdown ( void  )

Definition at line 113 of file wsp_unit.c.

References gw_assert(), gwlist_destroy(), gwlist_remove_producer(), gwthread_join_every(), main_thread(), queue, run_status, running, terminating, wap_event_destroy_item(), and wsp_strings_shutdown().

Referenced by main().

114 {
121 }
gw_assert(wtls_machine->packet_to_send !=NULL)
static void main_thread(void *)
Definition: wsp_unit.c:217
void gwthread_join_every(gwthread_func_t *func)
void gwlist_remove_producer(List *list)
Definition: list.c:401
void wap_event_destroy_item(void *event)
Definition: wap_events.c:130
void wsp_strings_shutdown(void)
Definition: wsp_strings.c:286
static enum @92 run_status
static List * queue
Definition: wsp_unit.c:89
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ wtp_initiator_dispatch_event()

void wtp_initiator_dispatch_event ( WAPEvent event)

Definition at line 204 of file wtp_init.c.

References gwlist_produce(), and queue.

Referenced by main(), and wap_dispatch_datagram().

205 {
206  gwlist_produce(queue, event);
207 }
void gwlist_produce(List *list, void *item)
Definition: list.c:411
static List * queue
Definition: wtp_init.c:89

◆ wtp_initiator_init()

void wtp_initiator_init ( wap_dispatch_func_t datagram_dispatch,
wap_dispatch_func_t session_dispatch,
long  timer_freq 
)

Definition at line 168 of file wtp_init.c.

References counter_create(), dispatch_to_wdp, dispatch_to_wsp, gw_assert(), gwlist_add_producer(), gwlist_create, gwthread_create, init_machine_id_counter, init_machines, init_timer_freq, initiator_run_status, limbo, main_thread(), queue, running, timer_freq, and timers_init().

Referenced by main().

170 {
173 
174  queue = gwlist_create();
176 
177  dispatch_to_wdp = datagram_dispatch;
178  dispatch_to_wsp = session_dispatch;
179 
180  timers_init();
182 
186 }
gw_assert(wtls_machine->packet_to_send !=NULL)
static List * init_machines
Definition: wtp_init.c:73
static wap_dispatch_func_t * dispatch_to_wsp
Definition: wtp_init.c:104
Counter * counter_create(void)
Definition: counter.c:94
static enum @104 initiator_run_status
static void main_thread(void *arg)
Definition: wtp_init.c:214
static Counter * init_machine_id_counter
Definition: wtp_init.c:78
#define gwthread_create(func, arg)
Definition: gwthread.h:90
void timers_init(void)
Definition: timers.c:184
#define gwlist_create()
Definition: list.h:136
static List * queue
Definition: wtp_init.c:89
static wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_init.c:103
static long init_timer_freq
Definition: wtp_init.c:109
void gwlist_add_producer(List *list)
Definition: list.c:383
static long timer_freq
Definition: wapbox.c:104

◆ wtp_initiator_shutdown()

void wtp_initiator_shutdown ( void  )

Definition at line 188 of file wtp_init.c.

References counter_destroy(), debug(), gw_assert(), gwlist_destroy(), gwlist_len(), gwlist_remove_producer(), gwthread_join_every(), init_machine_destroy(), init_machine_id_counter, init_machines, initiator_run_status, main_thread(), queue, running, terminating, timers_shutdown(), and wap_event_destroy_item().

Referenced by main().

189 {
194 
195  debug("wap.wtp", 0, "wtp_initiator_shutdown: %ld init_machines left",
199 
201  timers_shutdown();
202 }
gw_assert(wtls_machine->packet_to_send !=NULL)
void counter_destroy(Counter *counter)
Definition: counter.c:110
long gwlist_len(List *list)
Definition: list.c:166
static List * init_machines
Definition: wtp_init.c:73
void gwthread_join_every(gwthread_func_t *func)
static enum @104 initiator_run_status
static void init_machine_destroy(void *sm)
Definition: wtp_init.c:261
void gwlist_remove_producer(List *list)
Definition: list.c:401
void wap_event_destroy_item(void *event)
Definition: wap_events.c:130
static void main_thread(void *arg)
Definition: wtp_init.c:214
void timers_shutdown(void)
Definition: timers.c:196
static Counter * init_machine_id_counter
Definition: wtp_init.c:78
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static List * queue
Definition: wtp_init.c:89
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145

◆ wtp_resp_dispatch_event()

void wtp_resp_dispatch_event ( WAPEvent event)

Definition at line 253 of file wtp_resp.c.

References gwlist_produce(), and resp_queue.

Referenced by main(), push_client_event_handle(), and wap_dispatch_datagram().

254 {
255  gwlist_produce(resp_queue, event);
256 }
void gwlist_produce(List *list, void *item)
Definition: list.c:411
static List * resp_queue
Definition: wtp_resp.c:106

◆ wtp_resp_init()

void wtp_resp_init ( wap_dispatch_func_t datagram_dispatch,
wap_dispatch_func_t session_dispatch,
wap_dispatch_func_t push_dispatch,
long  timer_freq 
)

Definition at line 211 of file wtp_resp.c.

References counter_create(), dispatch_to_push, dispatch_to_wdp, dispatch_to_wsp, gw_assert(), gwlist_add_producer(), gwlist_create, gwthread_create, limbo, main_thread(), resp_machine_id_counter, resp_machines, resp_queue, resp_run_status, resp_timer_freq, running, timer_freq, timers_init(), and wtp_tid_cache_init().

Referenced by main().

215 {
218 
221 
222  dispatch_to_wdp = datagram_dispatch;
223  dispatch_to_wsp = session_dispatch;
224  dispatch_to_push = push_dispatch;
225 
226  timers_init();
229 
233 }
gw_assert(wtls_machine->packet_to_send !=NULL)
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
void wtp_tid_cache_init(void)
Definition: wtp_tid.c:102
static Counter * resp_machine_id_counter
Definition: wtp_resp.c:83
static void main_thread(void *)
Definition: wtp_resp.c:265
Counter * counter_create(void)
Definition: counter.c:94
wap_dispatch_func_t * dispatch_to_push
Definition: wtp_resp.c:101
static long resp_timer_freq
Definition: wtp_resp.c:111
#define gwthread_create(func, arg)
Definition: gwthread.h:90
static List * resp_queue
Definition: wtp_resp.c:106
void timers_init(void)
Definition: timers.c:184
Definition: wtp_resp.c:96
static List * resp_machines
Definition: wtp_resp.c:77
#define gwlist_create()
Definition: list.h:136
static enum @108 resp_run_status
void gwlist_add_producer(List *list)
Definition: list.c:383
static long timer_freq
Definition: wapbox.c:104
wap_dispatch_func_t * dispatch_to_wsp
Definition: wtp_resp.c:100

◆ wtp_resp_shutdown()

void wtp_resp_shutdown ( void  )

Definition at line 235 of file wtp_resp.c.

References counter_destroy(), debug(), gw_assert(), gwlist_destroy(), gwlist_len(), gwlist_remove_producer(), gwthread_join_every(), main_thread(), resp_machine_destroy(), resp_machine_id_counter, resp_machines, resp_queue, resp_run_status, running, terminating, timers_shutdown(), wap_event_destroy_item(), and wtp_tid_cache_shutdown().

Referenced by main().

236 {
241 
242  debug("wap.wtp", 0, "wtp_resp_shutdown: %ld resp_machines left",
246 
248 
250  timers_shutdown();
251 }
gw_assert(wtls_machine->packet_to_send !=NULL)
void counter_destroy(Counter *counter)
Definition: counter.c:110
long gwlist_len(List *list)
Definition: list.c:166
void gwthread_join_every(gwthread_func_t *func)
static Counter * resp_machine_id_counter
Definition: wtp_resp.c:83
static void main_thread(void *)
Definition: wtp_resp.c:265
void gwlist_remove_producer(List *list)
Definition: list.c:401
void wap_event_destroy_item(void *event)
Definition: wap_events.c:130
void timers_shutdown(void)
Definition: timers.c:196
static void resp_machine_destroy(void *sm)
Definition: wtp_resp.c:624
static List * resp_queue
Definition: wtp_resp.c:106
void wtp_tid_cache_shutdown(void)
Definition: wtp_tid.c:107
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static List * resp_machines
Definition: wtp_resp.c:77
static enum @108 resp_run_status
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.