Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wap_events.h File Reference
#include "gwlib/gwlib.h"
#include "wap_addr.h"
#include "wap_events.def"

Go to the source code of this file.

Data Structures

struct  WAPEvent
 

Macros

#define WAPEVENT(name, prettyname, fields)   name,
 
#define WAPEVENT(name, prettyname, fields)   struct name { fields } name;
 
#define OCTSTR(name)   Octstr *name;
 
#define OPTIONAL_OCTSTR(name)   Octstr *name; /* May be NULL */
 
#define INTEGER(name)   long name;
 
#define HTTPHEADER(name)   List *name;
 
#define WTLSPDUS(name)   List *name;
 
#define ADDRTUPLE(name)   WAPAddrTuple *name;
 
#define CAPABILITIES(name)   List *name;
 
#define wap_event_create(type)   gw_claim_area(wap_event_create_real((type), __FILE__, __LINE__, __func__))
 

Typedefs

typedef struct WAPEvent WAPEvent
 

Enumerations

enum  WAPEventName { WAPEVENT, WAPEVENT }
 

Functions

WAPEventwap_event_create_real (WAPEventName type, const char *file, long line, const char *func)
 
void wap_event_destroy (WAPEvent *event)
 
void wap_event_destroy_item (void *event)
 
WAPEventwap_event_duplicate (WAPEvent *event)
 
const char * wap_event_name (WAPEventName type)
 
void wap_event_dump (WAPEvent *event)
 
void wap_event_assert (WAPEvent *event)
 

Macro Definition Documentation

#define ADDRTUPLE (   name)    WAPAddrTuple *name;

Definition at line 97 of file wap_events.h.

#define CAPABILITIES (   name)    List *name;

Definition at line 98 of file wap_events.h.

#define HTTPHEADER (   name)    List *name;

Definition at line 95 of file wap_events.h.

#define INTEGER (   name)    long name;

Definition at line 94 of file wap_events.h.

#define OCTSTR (   name)    Octstr *name;

Definition at line 92 of file wap_events.h.

#define OPTIONAL_OCTSTR (   name)    Octstr *name; /* May be NULL */

Definition at line 93 of file wap_events.h.

#define wap_event_create (   type)    gw_claim_area(wap_event_create_real((type), __FILE__, __LINE__, __func__))
#define WAPEVENT (   name,
  prettyname,
  fields 
)    name,

Definition at line 91 of file wap_events.h.

#define WAPEVENT (   name,
  prettyname,
  fields 
)    struct name { fields } name;

Definition at line 91 of file wap_events.h.

#define WTLSPDUS (   name)    List *name;

Definition at line 96 of file wap_events.h.

Typedef Documentation

typedef struct WAPEvent WAPEvent

Definition at line 72 of file wap_events.h.

Enumeration Type Documentation

Enumerator
WAPEVENT 
WAPEVENT 

Definition at line 77 of file wap_events.h.

77  {
78  #define WAPEVENT(name, prettyname, fields) name,
79  #include "wap_events.def"
80  WAPEventNameCount
81 } WAPEventName;
WAPEventName
Definition: wap_events.h:77

Function Documentation

void wap_event_assert ( WAPEvent event)

Definition at line 220 of file wap_events.c.

References debug(), gw_assert(), and WAPEvent::type.

Referenced by main_thread(), parse_document(), push_client_event_handle(), unpack_wdp_datagram_real(), wap_event_destroy(), wap_event_duplicate(), wsp_session_dispatch_event(), wsp_unit_dispatch_event(), and wtp_unpack_wdp_datagram().

220  {
221  gw_assert(event != NULL),
222  gw_assert(event->type >= 0);
223  gw_assert(event->type < WAPEventNameCount);
224 
225  switch (event->type) {
226 #define WAPEVENT(name, prettyname, fields) \
227  case name: \
228  { struct name *p = &event->u.name; fields; p = NULL; break; }
229 #define OCTSTR(name) \
230  gw_assert(p->name != NULL); \
231  /* This is a trick to make the Octstr module run its assertions */ \
232  gw_assert(octstr_len(p->name) >= 0);
233 #define OPTIONAL_OCTSTR(name) \
234  gw_assert(p->name == NULL || octstr_len(p->name) >= 0);
235 #define INTEGER(name)
236 #define WTLSPDUS(name)
237 #define HTTPHEADER(name)
238 #define ADDRTUPLE(name) \
239  gw_assert(p->name != NULL);
240 #define CAPABILITIES(name)
241 #include "wap_events.def"
242  default:
243  debug("wap.event", 0, "Unknown type");
244  }
245 }
gw_assert(wtls_machine->packet_to_send!=NULL)
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
WAPEventName type
Definition: wap_events.h:88
WAPEvent* wap_event_create_real ( WAPEventName  type,
const char *  file,
long  line,
const char *  func 
)

Definition at line 71 of file wap_events.c.

References gw_assert(), panic, WAPEvent::type, and type.

72  {
73  WAPEvent *event;
74 
75  gw_assert(type >= 0);
76  gw_assert(type < WAPEventNameCount);
77 
78  event = gw_malloc_trace(sizeof(WAPEvent), file, line, func);
79  event->type = type;
80 
81  switch (event->type) {
82  #define WAPEVENT(name, prettyname, fields) \
83  case name: \
84  { struct name *p = &event->u.name; fields } \
85  break;
86  #define OCTSTR(name) p->name = NULL;
87  #define OPTIONAL_OCTSTR(name) p->name = NULL;
88  #define INTEGER(name) p->name = 0;
89  #define WTLSPDUS(name) p->name = NULL;
90  #define HTTPHEADER(name) p->name = NULL;
91  #define ADDRTUPLE(name) p->name = NULL;
92  #define CAPABILITIES(name) p->name = NULL;
93  #include "wap_events.def"
94  default:
95  panic(0, "Unknown WAP event type %d", event->type);
96  }
97 
98  return event;
99 }
int type
Definition: smsc_cimd2.c:215
FILE * file
Definition: log.c:133
gw_assert(wtls_machine->packet_to_send!=NULL)
#define panic
Definition: log.h:87
WAPEventName type
Definition: wap_events.h:88
void wap_event_destroy ( WAPEvent event)

Definition at line 102 of file wap_events.c.

References panic, WAPEvent::type, and wap_event_assert().

Referenced by abort_elapsed(), abort_methods(), abort_pushes(), continue_sar_result(), dispatch_datagram(), gwtimer_destroy(), gwtimer_start(), handle_init_event(), handle_internal_event(), handle_ota_event(), handle_push_message(), handle_session_event(), main(), main_thread(), pap_compile(), process_sar_transaction(), push_client_event_handle(), push_client_machine_find_or_create(), receive_push_reply(), release_holding_methods(), resp_event_handle(), return_replies_thread(), send_push_response(), start_fetch(), tell_fatal_error(), unpack_datagram(), unpack_wdp_datagram_real(), wap_dispatch_datagram(), wap_event_destroy_item(), wdp_event_dump(), wtp_event_dump(), and wtp_unpack_wdp_datagram().

102  {
103  if (event == NULL)
104  return;
105 
106  wap_event_assert(event);
107 
108  switch (event->type) {
109  #define WAPEVENT(name, prettyname, fields) \
110  case name: \
111  { struct name *p = &event->u.name; fields; } \
112  break;
113  #define OCTSTR(name) octstr_destroy(p->name);
114  #define OPTIONAL_OCTSTR(name) octstr_destroy(p->name);
115  #define INTEGER(name) p->name = 0;
116 #ifdef HAVE_WTLS_OPENSSL
117  #define WTLSPDUS(name) wtls_pldList_destroy(p->name);
118 #endif /* HAVE_WTLS_OPENSSL */
119  #define HTTPHEADER(name) http_destroy_headers(p->name);
120  #define ADDRTUPLE(name) wap_addr_tuple_destroy(p->name);
121  #define CAPABILITIES(name) wsp_cap_destroy_list(p->name);
122  #include "wap_events.def"
123  default:
124  panic(0, "Unknown WAPEvent type %d", (int) event->type);
125  }
126  gw_free(event);
127 }
void wap_event_assert(WAPEvent *event)
Definition: wap_events.c:220
#define panic
Definition: log.h:87
WAPEventName type
Definition: wap_events.h:88
void wap_event_destroy_item ( void *  event)
void wap_event_dump ( WAPEvent event)

Definition at line 181 of file wap_events.c.

References debug(), WAPEvent::type, and wap_event_name().

Referenced by add_push_flag(), cant_handle_event(), dispatch_datagram(), find_session_machine(), handle_init_event(), handle_internal_event(), handle_method_event(), handle_ota_event(), handle_push_event(), init_machine_find_or_create(), main(), parse_pap_value(), push_client_event_handle(), push_client_machine_find_or_create(), resp_event_handle(), resp_machine_find_or_create(), truncated_datagram(), unpack_wdp_datagram_real(), wap_dispatch_datagram(), wdp_event_dump(), wtp_event_dump(), and wtp_event_is_for_responder().

181  {
182  debug("wap.event", 0, "Dumping WAPEvent %p", (void *) event);
183  if (event != NULL) {
184  debug("wap.event", 0, " type = %s",
185  wap_event_name(event->type));
186  switch (event->type) {
187  #define WAPEVENT(name, prettyname, fields) \
188  case name: \
189  { struct name *p = &event->u.name; fields; break; }
190  #define OCTSTR(name) \
191  debug("wap.event", 0, "%s =", #name); \
192  octstr_dump(p->name, 1);
193  #define OPTIONAL_OCTSTR(name) \
194  if (p->name == NULL) \
195  debug("wap.event", 0, "%s = NULL", #name); \
196  else { \
197  debug("wap.event", 0, "%s =", #name); \
198  octstr_dump(p->name, 1); \
199  }
200  #define INTEGER(name) \
201  debug("wap.event", 0, " %s = %ld", #name, p->name);
202  #define WTLSPDUS(name) \
203  debug("wap.event",0,"You need to implement wtls_payloadlist_dump!");
204  #define HTTPHEADER(name) \
205  if (p->name == NULL) \
206  debug("wap.event", 0, "%s = NULL", #name); \
207  else \
208  http_header_dump(p->name);
209  #define ADDRTUPLE(name) wap_addr_tuple_dump(p->name);
210  #define CAPABILITIES(name) wsp_cap_dump_list(p->name);
211  #include "wap_events.def"
212  default:
213  debug("wap.event", 0, "Unknown type");
214  }
215  }
216  debug("wap.event", 0, "WAPEvent dump ends.");
217 }
const char * wap_event_name(WAPEventName type)
Definition: wap_events.c:169
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
WAPEventName type
Definition: wap_events.h:88
WAPEvent* wap_event_duplicate ( WAPEvent event)

Definition at line 135 of file wap_events.c.

References panic, WAPEvent::type, and wap_event_assert().

Referenced by assembly_sar_event(), begin_sar_result(), continue_sar_result(), elapse_timer(), process_sar_transaction(), and wtp_unpack_wdp_datagram().

135  {
136  WAPEvent *new;
137 
138  if (event == NULL)
139  return NULL;
140 
141  wap_event_assert(event);
142 
143  new = gw_malloc(sizeof(WAPEvent));
144  new->type = event->type;
145 
146  switch (event->type) {
147  #define WAPEVENT(name, prettyname, fields) \
148  case name: \
149  { struct name *p = &new->u.name; \
150  struct name *q = &event->u.name; \
151  fields } \
152  break;
153  #define OCTSTR(name) p->name = octstr_duplicate(q->name);
154  #define OPTIONAL_OCTSTR(name) p->name = octstr_duplicate(q->name);
155  #define INTEGER(name) p->name = q->name;
156  #define WTLSPDUS(name) debug("wap.events",0,"You need to implement wtls_pdulist_duplicate!");
157  #define HTTPHEADER(name) p->name = http_header_duplicate(q->name);
158  #define ADDRTUPLE(name) p->name = wap_addr_tuple_duplicate(q->name);
159  #define CAPABILITIES(name) p->name = wsp_cap_duplicate_list(q->name);
160  #include "wap_events.def"
161  default:
162  panic(0, "Unknown WAP event type %d", event->type);
163  }
164 
165  return new;
166 }
void wap_event_assert(WAPEvent *event)
Definition: wap_events.c:220
#define panic
Definition: log.h:87
WAPEventName type
Definition: wap_events.h:88
const char* wap_event_name ( WAPEventName  type)

Definition at line 169 of file wap_events.c.

References panic.

Referenced by abort_elapsed(), elapse_timer(), find_session_machine(), handle_init_event(), handle_method_event(), handle_push_event(), handle_session_event(), main_thread(), push_client_event_handle(), push_client_machine_find_or_create(), resp_event_handle(), wap_event_dump(), and wtp_event_dump().

169  {
170  switch (type) {
171  #define WAPEVENT(name, prettyname, fields) \
172  case name: return prettyname;
173  #include "wap_events.def"
174  default:
175  panic(0, "Unknown WAPEvent type %d", (int) type);
176  return "unknown WAPEventName";
177  }
178 }
int type
Definition: smsc_cimd2.c:215
#define panic
Definition: log.h:87
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.