Kannel: Open Source WAP and SMS gateway  svn-r5335
wtp_resp.c File Reference
#include "gwlib/gwlib.h"
#include "wtp_resp.h"
#include "wtp_pack.h"
#include "wtp_tid.h"
#include "wtp.h"
#include "timers.h"
#include "wap.h"
#include "wtp_resp_states.def"
#include "wtp_resp_machine.def"

Go to the source code of this file.

Macros

#define STATE_NAME(state)   case state: return #state;
 
#define ROW(state, event, condition, action, new_state)
 
#define STATE_NAME(state)
 
#define ROW(wtp_state, event_type, condition, action, next_state)
 
#define ENUM(name)   resp_machine->name = LISTEN;
 
#define EVENT(name)   resp_machine->name = NULL;
 
#define INTEGER(name)   resp_machine->name = 0;
 
#define TIMER(name)   resp_machine->name = gwtimer_create(resp_queue);
 
#define ADDRTUPLE(name)   resp_machine->name = NULL;
 
#define LIST(name)   resp_machine->name = NULL;
 
#define SARDATA(name)   resp_machine->name = NULL;
 
#define MACHINE(field)   field
 
#define ENUM(name)   resp_machine->name = LISTEN;
 
#define EVENT(name)   wap_event_destroy(resp_machine->name);
 
#define INTEGER(name)   resp_machine->name = 0;
 
#define TIMER(name)   gwtimer_destroy(resp_machine->name);
 
#define ADDRTUPLE(name)   wap_addr_tuple_destroy(resp_machine->name);
 
#define LIST(name)   gwlist_destroy(resp_machine->name,sar_info_destroy);
 
#define SARDATA(name)   sardata_destroy(resp_machine->name);
 
#define MACHINE(field)   field
 

Enumerations

enum  { limbo, running, terminating }
 

Functions

static WTPRespMachineresp_machine_create (WAPAddrTuple *tuple, long tid, long tcl)
 
static void resp_machine_destroy (void *sm)
 
static WTPRespMachineresp_machine_find_or_create (WAPEvent *event)
 
static void resp_event_handle (WTPRespMachine *machine, WAPEvent *event)
 
static char * name_resp_state (int name)
 
static WTPRespMachineresp_machine_find (WAPAddrTuple *tuple, long tid, long mid)
 
static void main_thread (void *)
 
static void start_timer_A (WTPRespMachine *machine)
 
static void start_timer_R (WTPRespMachine *machine)
 
static void start_timer_W (WTPRespMachine *machine)
 
static WAPEventcreate_tr_invoke_ind (WTPRespMachine *sm, Octstr *user_data)
 
static WAPEventcreate_tr_abort_ind (WTPRespMachine *sm, long abort_reason)
 
static WAPEventcreate_tr_result_cnf (WTPRespMachine *sm)
 
static int erroneous_field_in (WAPEvent *event)
 
static void handle_wrong_version (WAPEvent *event)
 
static WAPEventassembly_sar_event (WTPRespMachine *machine, int last_psn)
 
static int add_sar_transaction (WTPRespMachine *machine, Octstr *data, int psn)
 
static int process_sar_transaction (WTPRespMachine *machine, WAPEvent **event)
 
static void begin_sar_result (WTPRespMachine *machine, WAPEvent *event)
 
static void continue_sar_result (WTPRespMachine *machine, WAPEvent *event)
 
static void resend_sar_result (WTPRespMachine *resp_machine, WAPEvent *event)
 
static void sar_info_destroy (void *sar_info)
 
static void sardata_destroy (void *sardata)
 
static void send_abort (WTPRespMachine *machine, long type, long reason)
 
static void send_ack (WTPRespMachine *machine, long ack_type, int rid_flag)
 
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_shutdown (void)
 
void wtp_resp_dispatch_event (WAPEvent *event)
 
static void handle_erroneous_field_in (WAPEvent *event)
 
static int is_wanted_resp_machine (void *a, void *b)
 
static int is_wanted_sar_data (void *a, void *b)
 

Variables

static Listresp_machines = NULL
 
static Counterresp_machine_id_counter = NULL
 
static enum { ... }  resp_run_status = limbo
 
wap_dispatch_func_tdispatch_to_wdp
 
wap_dispatch_func_tdispatch_to_wsp
 
wap_dispatch_func_tdispatch_to_push
 
static Listresp_queue = NULL
 
static long resp_timer_freq = -1
 

Macro Definition Documentation

◆ ADDRTUPLE [1/2]

#define ADDRTUPLE (   name)    resp_machine->name = NULL;

◆ ADDRTUPLE [2/2]

#define ADDRTUPLE (   name)    wap_addr_tuple_destroy(resp_machine->name);

◆ ENUM [1/2]

#define ENUM (   name)    resp_machine->name = LISTEN;

◆ ENUM [2/2]

#define ENUM (   name)    resp_machine->name = LISTEN;

◆ EVENT [1/2]

#define EVENT (   name)    resp_machine->name = NULL;

◆ EVENT [2/2]

#define EVENT (   name)    wap_event_destroy(resp_machine->name);

◆ INTEGER [1/2]

#define INTEGER (   name)    resp_machine->name = 0;

◆ INTEGER [2/2]

#define INTEGER (   name)    resp_machine->name = 0;

◆ LIST [1/2]

#define LIST (   name)    resp_machine->name = NULL;

◆ LIST [2/2]

#define LIST (   name)    gwlist_destroy(resp_machine->name,sar_info_destroy);

◆ MACHINE [1/2]

#define MACHINE (   field)    field

◆ MACHINE [2/2]

#define MACHINE (   field)    field

◆ ROW [1/2]

#define ROW (   state,
  event,
  condition,
  action,
  new_state 
)

◆ ROW [2/2]

#define ROW (   wtp_state,
  event_type,
  condition,
  action,
  next_state 
)
Value:
if (resp_machine->state == wtp_state && \
event->type == event_type && \
(condition)) { \
action \
resp_machine->state = next_state; \
debug("wap.wtp", 0, "WTP %ld: New state %s", resp_machine->mid, #next_state); \
} else

◆ SARDATA [1/2]

#define SARDATA (   name)    resp_machine->name = NULL;

◆ SARDATA [2/2]

#define SARDATA (   name)    sardata_destroy(resp_machine->name);

◆ STATE_NAME [1/2]

#define STATE_NAME (   state)    case state: return #state;

◆ STATE_NAME [2/2]

#define STATE_NAME (   state)

◆ TIMER [1/2]

#define TIMER (   name)    resp_machine->name = gwtimer_create(resp_queue);

◆ TIMER [2/2]

#define TIMER (   name)    gwtimer_destroy(resp_machine->name);

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
limbo 
running 
terminating 

Definition at line 96 of file wtp_resp.c.

Definition: wtp_resp.c:96
static enum @108 resp_run_status

Function Documentation

◆ add_sar_transaction()

static int add_sar_transaction ( WTPRespMachine machine,
Octstr data,
int  psn 
)
static

Definition at line 833 of file wtp_resp.c.

References debug(), gwlist_append(), gwlist_create, gwlist_search(), is_wanted_sar_data(), octstr_duplicate, sar_info_t::sar_data, and sar_info_t::sar_psn.

Referenced by process_sar_transaction().

834 {
835  sar_info_t *sar_info;
836 
837  if (machine->sar_info == NULL) {
838  machine->sar_info = gwlist_create();
839  }
840 
841  if (gwlist_search(machine->sar_info, &psn, is_wanted_sar_data) == NULL) {
842  sar_info = gw_malloc(sizeof(sar_info_t));
843  sar_info->sar_psn = psn;
844  sar_info->sar_data = octstr_duplicate(data);
845  gwlist_append(machine->sar_info, sar_info);
846  return 0;
847  } else {
848  debug("wap.wtp", 0, "Duplicated psn found, ignore packet");
849  return 1;
850  }
851 }
static int is_wanted_sar_data(void *a, void *b)
Definition: wtp_resp.c:815
void * gwlist_search(List *list, void *pattern, int(*cmp)(void *, void *))
Definition: list.c:486
void gwlist_append(List *list, void *item)
Definition: list.c:179
Octstr * sar_data
Definition: wtp_resp.h:74
#define octstr_duplicate(ostr)
Definition: octstr.h:187
int sar_psn
Definition: wtp_resp.h:73
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
#define gwlist_create()
Definition: list.h:136

◆ assembly_sar_event()

static WAPEvent * assembly_sar_event ( WTPRespMachine machine,
int  last_psn 
)
static

Definition at line 853 of file wtp_resp.c.

References debug(), gwlist_search(), is_wanted_sar_data(), octstr_append(), WAPEvent::RcvInvoke, sar_info_t::sar_data, WAPEvent::u, and wap_event_duplicate().

Referenced by process_sar_transaction().

854 {
855  WAPEvent *e;
856  int i;
857  sar_info_t *sar_info;
858 
859  e = wap_event_duplicate(machine->sar_invoke);
860 
861  for (i = 1; i <= last_psn; i++) {
862  if ((sar_info = gwlist_search(machine->sar_info, &i, is_wanted_sar_data)) != NULL) {
863  octstr_append(e->u.RcvInvoke.user_data,sar_info->sar_data);
864  } else {
865  debug("wap.wtp", 0, "Packet with psn %d not found", i);
866  return e;
867  }
868  }
869 
870  return e;
871 }
static int is_wanted_sar_data(void *a, void *b)
Definition: wtp_resp.c:815
void * gwlist_search(List *list, void *pattern, int(*cmp)(void *, void *))
Definition: list.c:486
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1504
Octstr * sar_data
Definition: wtp_resp.h:74
WAPEvent * wap_event_duplicate(WAPEvent *event)
Definition: wap_events.c:135
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvInvoke
Definition: wap_events.h:491
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
union WAPEvent::@87 u

◆ begin_sar_result()

static void begin_sar_result ( WTPRespMachine machine,
WAPEvent event 
)
static

Definition at line 894 of file wtp_resp.c.

References WTPSARData::csegm, WTPSARData::data, debug(), dispatch_to_wdp, gw_assert(), WTPSARData::lsegm, WTPSARData::nsegm, octstr_duplicate, octstr_len(), SAR_SEGM_SIZE, WTPSARData::tr, WAPEvent::u, wap_event_duplicate(), and wtp_pack_sar_result().

895 {
896  WAPEvent *result;
897  WTPSARData *sar;
898  int psn;
899 
900  gw_assert(resp_machine->sar != NULL);
901 
902  sar = resp_machine->sar;
903  sar->data = octstr_duplicate(event->u.TR_Result_Req.user_data);
904  sar->nsegm = (octstr_len(sar->data)-1)/SAR_SEGM_SIZE;
905  sar->tr = sar->lsegm = 0;
906  sar->csegm = -1;
907 
908  debug("wap.wtp", 0, "WTP: begin_sar_result(): data len = %lu",
909  octstr_len(sar->data));
910 
911  for (psn = 0; !sar->tr; psn++) {
912  result = wtp_pack_sar_result(resp_machine, psn);
913  if (sar->tr)
914  resp_machine->result = wap_event_duplicate(result);
915 
916  debug("wap.wtp", 0, "WTP: dispath_to_wdp(): psn = %u", psn);
917  dispatch_to_wdp(result);
918  sar->lsegm = psn;
919  }
920 
921  resp_machine->rid = 1;
922 }
WAPEvent * wtp_pack_sar_result(WTPRespMachine *machine, int psn)
Definition: wtp_pack.c:167
gw_assert(wtls_machine->packet_to_send !=NULL)
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
int csegm
Definition: wtp_resp.h:83
#define SAR_SEGM_SIZE
Definition: fakewap.c:221
int nsegm
Definition: wtp_resp.h:82
#define octstr_duplicate(ostr)
Definition: octstr.h:187
Octstr * data
Definition: wtp_resp.h:86
WAPEvent * wap_event_duplicate(WAPEvent *event)
Definition: wap_events.c:135
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
int tr
Definition: wtp_resp.h:85
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
union WAPEvent::@87 u
int lsegm
Definition: wtp_resp.h:84

◆ continue_sar_result()

static void continue_sar_result ( WTPRespMachine machine,
WAPEvent event 
)
static

Definition at line 924 of file wtp_resp.c.

References WTPSARData::csegm, debug(), dispatch_to_wdp, gw_assert(), WTPSARData::lsegm, WTPSARData::nsegm, WAPEvent::RcvAck, start_timer_R(), WTPSARData::tr, WAPEvent::type, WAPEvent::u, wap_event_destroy(), wap_event_duplicate(), and wtp_pack_sar_result().

925 {
926  WAPEvent *result;
927  WTPSARData *sar;
928  int psn;
929 
930  gw_assert(resp_machine->sar != NULL && event->type == RcvAck);
931 
932  sar = resp_machine->sar;
933 
934  debug("wap.wtp", 0, "WTP: continue_sar_result(): lsegm=%d, nsegm=%d, csegm=%d",
935  sar->lsegm, sar->nsegm, sar->csegm);
936 
937  start_timer_R(resp_machine);
938 
939  if (event->u.RcvAck.psn>sar->csegm) {
940  sar->csegm = event->u.RcvAck.psn;
941  }
942 
943  sar->tr = 0;
944  wap_event_destroy(resp_machine->result);
945  resp_machine->result = NULL;
946 
947  for (psn = sar->csegm + 1; !sar->tr; psn++) {
948  result = wtp_pack_sar_result(resp_machine, psn);
949  if (sar->tr)
950  resp_machine->result = wap_event_duplicate(result);
951 
952  debug("wap.wtp", 0, "WTP: dispath_to_wdp(): psn = %u",psn);
953  dispatch_to_wdp(result);
954  sar->lsegm = psn;
955  }
956 }
WAPEvent * wtp_pack_sar_result(WTPRespMachine *machine, int psn)
Definition: wtp_pack.c:167
gw_assert(wtls_machine->packet_to_send !=NULL)
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
int csegm
Definition: wtp_resp.h:83
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvAck
Definition: wap_events.h:532
static void start_timer_R(WTPRespMachine *machine)
Definition: wtp_resp.c:712
int nsegm
Definition: wtp_resp.h:82
WAPEvent * wap_event_duplicate(WAPEvent *event)
Definition: wap_events.c:135
int tr
Definition: wtp_resp.h:85
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
WAPEventName type
Definition: wap_events.h:88
union WAPEvent::@87 u
int lsegm
Definition: wtp_resp.h:84
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102

◆ create_tr_abort_ind()

static WAPEvent * create_tr_abort_ind ( WTPRespMachine sm,
long  abort_reason 
)
static

Definition at line 682 of file wtp_resp.c.

References WTPRespMachine::mid, RESPONDER_INDICATION, wap_addr_tuple_duplicate(), and wap_event_create.

682  {
683  WAPEvent *event;
684 
685  event = wap_event_create(TR_Abort_Ind);
686  event->u.TR_Abort_Ind.abort_code = abort_reason;
687  event->u.TR_Abort_Ind.addr_tuple =
688  wap_addr_tuple_duplicate(sm->addr_tuple);
689  event->u.TR_Abort_Ind.handle = sm->mid;
690  event->u.TR_Abort_Ind.ir_flag = RESPONDER_INDICATION;
691 
692  return event;
693 }
WAPAddrTuple * wap_addr_tuple_duplicate(WAPAddrTuple *tuple)
Definition: wap_addr.c:125
unsigned long mid
Definition: wtp_resp.h:116
#define wap_event_create(type)
Definition: wap_events.h:107

◆ create_tr_invoke_ind()

static WAPEvent * create_tr_invoke_ind ( WTPRespMachine sm,
Octstr user_data 
)
static

Definition at line 649 of file wtp_resp.c.

References WTPRespMachine::mid, octstr_duplicate, wap_addr_tuple_duplicate(), and wap_event_create.

650 {
651  WAPEvent *event;
652 
653  event = wap_event_create(TR_Invoke_Ind);
654  event->u.TR_Invoke_Ind.ack_type = sm->u_ack;
655  event->u.TR_Invoke_Ind.user_data = octstr_duplicate(user_data);
656  event->u.TR_Invoke_Ind.tcl = sm->tcl;
657  event->u.TR_Invoke_Ind.addr_tuple =
658  wap_addr_tuple_duplicate(sm->addr_tuple);
659  event->u.TR_Invoke_Ind.handle = sm->mid;
660  return event;
661 }
WAPAddrTuple * wap_addr_tuple_duplicate(WAPAddrTuple *tuple)
Definition: wap_addr.c:125
unsigned long mid
Definition: wtp_resp.h:116
#define octstr_duplicate(ostr)
Definition: octstr.h:187
#define wap_event_create(type)
Definition: wap_events.h:107

◆ create_tr_result_cnf()

static WAPEvent * create_tr_result_cnf ( WTPRespMachine sm)
static

Definition at line 667 of file wtp_resp.c.

References WTPRespMachine::mid, wap_addr_tuple_duplicate(), and wap_event_create.

668 {
669  WAPEvent *event;
670 
671  event = wap_event_create(TR_Result_Cnf);
672  event->u.TR_Result_Cnf.addr_tuple =
673  wap_addr_tuple_duplicate(sm->addr_tuple);
674  event->u.TR_Result_Cnf.handle = sm->mid;
675  return event;
676 }
WAPAddrTuple * wap_addr_tuple_duplicate(WAPAddrTuple *tuple)
Definition: wap_addr.c:125
unsigned long mid
Definition: wtp_resp.h:116
#define wap_event_create(type)
Definition: wap_events.h:107

◆ erroneous_field_in()

static int erroneous_field_in ( WAPEvent event)
static

Definition at line 365 of file wtp_resp.c.

Referenced by resp_machine_find_or_create().

366 {
367  return event->type == RcvInvoke && event->u.RcvInvoke.version != 0;
368 }

◆ handle_erroneous_field_in()

static void handle_erroneous_field_in ( WAPEvent event)
static

Definition at line 374 of file wtp_resp.c.

References debug(), handle_wrong_version(), WAPEvent::RcvInvoke, WAPEvent::type, and WAPEvent::u.

Referenced by resp_machine_find_or_create().

375 {
376  if (event->type == RcvInvoke) {
377  if (event->u.RcvInvoke.version != 0) {
378  debug("wap.wtp_resp", 0, "WTP_RESP: wrong version, aborting"
379  "transaction");
380  handle_wrong_version(event);
381  }
382  }
383 }
static void handle_wrong_version(WAPEvent *event)
Definition: wtp_resp.c:351
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvInvoke
Definition: wap_events.h:491
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
WAPEventName type
Definition: wap_events.h:88
union WAPEvent::@87 u

◆ handle_wrong_version()

static void handle_wrong_version ( WAPEvent event)
static

Definition at line 351 of file wtp_resp.c.

References dispatch_to_wdp, PROVIDER, WAPEvent::RcvInvoke, WAPEvent::type, WAPEvent::u, wtp_pack_abort(), and WTPVERSIONZERO.

Referenced by handle_erroneous_field_in().

352 {
353  WAPEvent *ab;
354 
355  if (event->type == RcvInvoke) {
356  ab = wtp_pack_abort(PROVIDER, WTPVERSIONZERO, event->u.RcvInvoke.tid,
357  event->u.RcvInvoke.addr_tuple);
358  dispatch_to_wdp(ab);
359  }
360 }
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
Definition: wtp.h:124
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvInvoke
Definition: wap_events.h:491
WAPEventName type
Definition: wap_events.h:88
WAPEvent * wtp_pack_abort(long abort_type, long abort_reason, long tid, WAPAddrTuple *address)
Definition: wtp_pack.c:223
union WAPEvent::@87 u

◆ is_wanted_resp_machine()

static int is_wanted_resp_machine ( void *  a,
void *  b 
)
static

Definition at line 555 of file wtp_resp.c.

References WTPRespMachine::mid, machine_pattern::mid, machine_pattern::tid, machine_pattern::tuple, and wap_addr_tuple_same().

Referenced by resp_machine_find().

556 {
557  machine_pattern *pat;
558  WTPRespMachine *m;
559 
560  m = a;
561  pat = b;
562 
563  if (m->mid == pat->mid)
564  return 1;
565 
566  if (pat->mid != -1)
567  return 0;
568 
569  return m->tid == pat->tid &&
570  wap_addr_tuple_same(m->addr_tuple, pat->tuple);
571 }
long tid
Definition: wtp.h:190
WAPAddrTuple * tuple
Definition: wtp.h:189
unsigned long mid
Definition: wtp_resp.h:116
long mid
Definition: wtp.h:191
int wap_addr_tuple_same(WAPAddrTuple *a, WAPAddrTuple *b)
Definition: wap_addr.c:118

◆ is_wanted_sar_data()

static int is_wanted_sar_data ( void *  a,
void *  b 
)
static

Definition at line 815 of file wtp_resp.c.

References sar_info_t::sar_psn.

Referenced by add_sar_transaction(), and assembly_sar_event().

816 {
817  sar_info_t *s;
818  int *i;
819 
820  s = a;
821  i = b;
822 
823  if (*i == s->sar_psn) {
824  return 1;
825  } else {
826  return 0;
827  }
828 }
int sar_psn
Definition: wtp_resp.h:73

◆ main_thread()

static void main_thread ( void *  arg)
static

Definition at line 265 of file wtp_resp.c.

References gwlist_consume(), resp_event_handle(), resp_machine_find_or_create(), resp_queue, resp_run_status, running, and wap_event_destroy().

Referenced by wtp_resp_init(), and wtp_resp_shutdown().

266 {
267  WTPRespMachine *sm;
268  WAPEvent *e;
269 
270  while (resp_run_status == running &&
271  (e = gwlist_consume(resp_queue)) != NULL) {
272 
274  if (sm == NULL) {
276  } else {
277  resp_event_handle(sm, e);
278  }
279  }
280 }
static WTPRespMachine * resp_machine_find_or_create(WAPEvent *event)
Definition: wtp_resp.c:397
static void resp_event_handle(WTPRespMachine *machine, WAPEvent *event)
Definition: wtp_resp.c:302
static List * resp_queue
Definition: wtp_resp.c:106
void * gwlist_consume(List *list)
Definition: list.c:427
static enum @108 resp_run_status
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102

◆ name_resp_state()

static char * name_resp_state ( int  name)
static

Definition at line 285 of file wtp_resp.c.

Referenced by resp_event_handle().

286 {
287  switch (s) {
288  #define STATE_NAME(state) case state: return #state;
289  #define ROW(state, event, condition, action, new_state)
290  #include "wtp_resp_states.def"
291  default:
292  return "unknown state";
293  }
294 }

◆ process_sar_transaction()

static int process_sar_transaction ( WTPRespMachine machine,
WAPEvent **  event 
)
static

Definition at line 755 of file wtp_resp.c.

References ACKNOWLEDGEMENT, add_sar_transaction(), assembly_sar_event(), dispatch_to_wdp, gw_assert(), WAPEvent::RcvInvoke, WAPEvent::type, WAPEvent::u, wap_event_destroy(), wap_event_duplicate(), and wtp_pack_sar_ack().

Referenced by resp_event_handle().

756 {
757  WAPEvent *e, *orig_event;
758  int psn;
759 
760  orig_event = *event;
761 
762  if (orig_event->type == RcvInvoke) {
763  if (!orig_event->u.RcvInvoke.ttr || !orig_event->u.RcvInvoke.gtr) { /* SAR */
764  /* Ericcson set TTR flag even if we have the only part */
765  if (orig_event->u.RcvInvoke.ttr == 1) {
766  return 1; /* Not SAR although TTR flag was set */
767  } else {
768  /* save initial event */
769  machine->sar_invoke = wap_event_duplicate(orig_event);
770 
771  /* save data into list with psn = 0 */
772  add_sar_transaction(machine, orig_event->u.RcvInvoke.user_data, 0);
773 
774  if (orig_event->u.RcvInvoke.gtr == 1) { /* Need to acknowledge */
775  e = wtp_pack_sar_ack(ACKNOWLEDGEMENT, machine->tid,
776  machine->addr_tuple, 0);
777  dispatch_to_wdp(e);
778  }
779  return 0;
780  }
781  } else {
782  return 1; /* Not SAR */
783  }
784  }
785 
786  if (orig_event->type == RcvSegInvoke) {
787  add_sar_transaction(machine, orig_event->u.RcvSegInvoke.user_data,
788  orig_event->u.RcvSegInvoke.psn);
789 
790  if (orig_event->u.RcvSegInvoke.gtr == 1) { /* Need to acknowledge */
791  e = wtp_pack_sar_ack(ACKNOWLEDGEMENT, machine->tid, machine->addr_tuple,
792  orig_event->u.RcvSegInvoke.psn);
793  dispatch_to_wdp(e);
794  }
795 
796  if (orig_event->u.RcvSegInvoke.ttr == 1) { /* Need to feed to WSP */
797 
798  /* Create assembled event */
799  psn = orig_event->u.RcvSegInvoke.psn;
800  wap_event_destroy(orig_event);
801 
802  *event = assembly_sar_event(machine,psn);
803 
804  gw_assert(event != NULL);
805 
806  return 1;
807  }
808  return 0;
809  }
810 
811  /* Not SAR message */
812  return 1;
813 }
gw_assert(wtls_machine->packet_to_send !=NULL)
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
WAPEvent * wtp_pack_sar_ack(long ack_type, long tid, WAPAddrTuple *address, int psn)
Definition: wtp_pack.c:263
static WAPEvent * assembly_sar_event(WTPRespMachine *machine, int last_psn)
Definition: wtp_resp.c:853
static int add_sar_transaction(WTPRespMachine *machine, Octstr *data, int psn)
Definition: wtp_resp.c:833
WAPEvent * wap_event_duplicate(WAPEvent *event)
Definition: wap_events.c:135
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvInvoke
Definition: wap_events.h:491
WAPEventName type
Definition: wap_events.h:88
union WAPEvent::@87 u
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102

◆ resend_sar_result()

static void resend_sar_result ( WTPRespMachine resp_machine,
WAPEvent event 
)
static

Definition at line 958 of file wtp_resp.c.

References WTPSARData::csegm, debug(), dispatch_to_wdp, gw_assert(), WTPSARData::lsegm, WTPSARData::nsegm, octstr_get_char(), start_timer_R(), WTPSARData::tr, WAPEvent::type, WAPEvent::u, wtp_pack_sar_result(), and wtp_pack_set_rid().

959 {
960  WAPEvent *result;
961  WTPSARData *sar;
962  int psn, i;
963 
964  gw_assert(resp_machine->sar != NULL && event->type == RcvNegativeAck);
965 
966  sar = resp_machine->sar;
967 
968  debug("wap.wtp", 0, "WTP: resend_sar_result(): lsegm=%d, nsegm=%d, csegm=%d",
969  sar->lsegm, sar->nsegm, sar->csegm);
970 
971  start_timer_R(resp_machine);
972 
973  if (event->u.RcvNegativeAck.nmissing) {
974  /* if we have a list of missed packets */
975  for(i = 0; i < event->u.RcvNegativeAck.nmissing; i++) {
976  if ((psn = octstr_get_char(event->u.RcvNegativeAck.missing, i)) >= 0) {
977  result = wtp_pack_sar_result(resp_machine, psn);
978  wtp_pack_set_rid(result, 1);
979  debug("wap.wtp", 0, "WTP: dispath_to_wdp(): psn = %u", psn);
980  dispatch_to_wdp(result);
981  }
982  }
983  } else {
984  /* if we have to resend a whole group */
985  sar->tr = 0;
986  for (psn = sar->csegm+1; !sar->tr; psn++) {
987  result = wtp_pack_sar_result(resp_machine, psn);
988  wtp_pack_set_rid(result, 1);
989  debug("wap.wtp", 0, "WTP: dispath_to_wdp(): psn = %u", psn);
990  dispatch_to_wdp(result);
991  }
992  }
993 }
WAPEvent * wtp_pack_sar_result(WTPRespMachine *machine, int psn)
Definition: wtp_pack.c:167
gw_assert(wtls_machine->packet_to_send !=NULL)
void wtp_pack_set_rid(WAPEvent *dgram, long rid)
Definition: wtp_pack.c:215
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
int csegm
Definition: wtp_resp.h:83
static void start_timer_R(WTPRespMachine *machine)
Definition: wtp_resp.c:712
int nsegm
Definition: wtp_resp.h:82
int tr
Definition: wtp_resp.h:85
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
WAPEventName type
Definition: wap_events.h:88
union WAPEvent::@87 u
int lsegm
Definition: wtp_resp.h:84
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:406

◆ resp_event_handle()

static void resp_event_handle ( WTPRespMachine machine,
WAPEvent event 
)
static

Definition at line 302 of file wtp_resp.c.

References debug(), error(), WTPRespMachine::mid, name_resp_state(), process_sar_transaction(), resp_machine_destroy(), start_timer_W(), WAPEvent::type, wap_event_destroy(), wap_event_dump(), and wap_event_name().

Referenced by main_thread().

303 {
304  WAPEvent *wsp_event = NULL;
305 
306  /*
307  * We don't feed sar packets into state machine
308  * until we got the whole message
309  */
310  if (process_sar_transaction(resp_machine,&event) == 0) {
311  debug("wap.wtp", 0, "SAR event received, wait for continue");
312  /* For removing state machine in case of incomplete sar */
313  start_timer_W(resp_machine);
314  if (event != NULL) {
315  wap_event_destroy(event);
316  }
317  return;
318  }
319 
320  debug("wap.wtp", 0, "WTP: resp_machine %ld, state %s, event %s.",
321  resp_machine->mid,
322  name_resp_state(resp_machine->state),
323  wap_event_name(event->type));
324 
325  #define STATE_NAME(state)
326  #define ROW(wtp_state, event_type, condition, action, next_state) \
327  if (resp_machine->state == wtp_state && \
328  event->type == event_type && \
329  (condition)) { \
330  action \
331  resp_machine->state = next_state; \
332  debug("wap.wtp", 0, "WTP %ld: New state %s", resp_machine->mid, #next_state); \
333  } else
334  #include "wtp_resp_states.def"
335  {
336  error(0, "WTP: handle_event: unhandled event!");
337  debug("wap.wtp", 0, "WTP: handle_event: Unhandled event was:");
338  wap_event_dump(event);
339  wap_event_destroy(event);
340  return;
341  }
342 
343  if (event != NULL) {
344  wap_event_destroy(event);
345  }
346 
347  if (resp_machine->state == LISTEN)
348  resp_machine_destroy(resp_machine);
349 }
void error(int err, const char *fmt,...)
Definition: log.c:648
static int process_sar_transaction(WTPRespMachine *machine, WAPEvent **event)
Definition: wtp_resp.c:755
static void start_timer_W(WTPRespMachine *machine)
Definition: wtp_resp.c:726
void wap_event_dump(WAPEvent *event)
Definition: wap_events.c:181
const char * wap_event_name(WAPEventName type)
Definition: wap_events.c:169
static void resp_machine_destroy(void *sm)
Definition: wtp_resp.c:624
static char * name_resp_state(int name)
Definition: wtp_resp.c:285
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
WAPEventName type
Definition: wap_events.h:88
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102

◆ resp_machine_create()

static WTPRespMachine * resp_machine_create ( WAPAddrTuple tuple,
long  tid,
long  tcl 
)
static

Definition at line 589 of file wtp_resp.c.

References counter_increase(), debug(), gwlist_append(), WTPRespMachine::mid, resp_machine_id_counter, resp_machines, and wap_addr_tuple_duplicate().

Referenced by resp_machine_find_or_create().

591 {
592  WTPRespMachine *resp_machine;
593 
594  resp_machine = gw_malloc(sizeof(WTPRespMachine));
595 
596  #define ENUM(name) resp_machine->name = LISTEN;
597  #define EVENT(name) resp_machine->name = NULL;
598  #define INTEGER(name) resp_machine->name = 0;
599  #define TIMER(name) resp_machine->name = gwtimer_create(resp_queue);
600  #define ADDRTUPLE(name) resp_machine->name = NULL;
601  #define LIST(name) resp_machine->name = NULL;
602  #define SARDATA(name) resp_machine->name = NULL;
603  #define MACHINE(field) field
604  #include "wtp_resp_machine.def"
605 
606  gwlist_append(resp_machines, resp_machine);
607 
609  resp_machine->addr_tuple = wap_addr_tuple_duplicate(tuple);
610  resp_machine->tid = tid;
611  resp_machine->tcl = tcl;
612 
613  debug("wap.wtp", 0, "WTP: Created WTPRespMachine %p (%ld)",
614  (void *) resp_machine, resp_machine->mid);
615 
616  return resp_machine;
617 }
void gwlist_append(List *list, void *item)
Definition: list.c:179
long tid
Definition: wtp.h:190
unsigned long counter_increase(Counter *counter)
Definition: counter.c:123
WAPAddrTuple * wap_addr_tuple_duplicate(WAPAddrTuple *tuple)
Definition: wap_addr.c:125
WAPAddrTuple * tuple
Definition: wtp.h:189
unsigned long mid
Definition: wtp_resp.h:116
static Counter * resp_machine_id_counter
Definition: wtp_resp.c:83
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static List * resp_machines
Definition: wtp_resp.c:77

◆ resp_machine_destroy()

static void resp_machine_destroy ( void *  sm)
static

Definition at line 624 of file wtp_resp.c.

References debug(), gwlist_delete_equal(), WTPRespMachine::mid, and resp_machines.

Referenced by resp_event_handle(), and wtp_resp_shutdown().

625 {
626  WTPRespMachine *resp_machine;
627 
628  resp_machine = p;
629  debug("wap.wtp", 0, "WTP: Destroying WTPRespMachine %p (%ld)",
630  (void *) resp_machine, resp_machine->mid);
631 
632  gwlist_delete_equal(resp_machines, resp_machine);
633 
634  #define ENUM(name) resp_machine->name = LISTEN;
635  #define EVENT(name) wap_event_destroy(resp_machine->name);
636  #define INTEGER(name) resp_machine->name = 0;
637  #define TIMER(name) gwtimer_destroy(resp_machine->name);
638  #define ADDRTUPLE(name) wap_addr_tuple_destroy(resp_machine->name);
639  #define LIST(name) gwlist_destroy(resp_machine->name,sar_info_destroy);
640  #define SARDATA(name) sardata_destroy(resp_machine->name);
641  #define MACHINE(field) field
642  #include "wtp_resp_machine.def"
643  gw_free(resp_machine);
644 }
long gwlist_delete_equal(List *list, void *item)
Definition: list.c:266
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
static List * resp_machines
Definition: wtp_resp.c:77

◆ resp_machine_find()

static WTPRespMachine * resp_machine_find ( WAPAddrTuple tuple,
long  tid,
long  mid 
)
static

Definition at line 574 of file wtp_resp.c.

References gwlist_search(), is_wanted_resp_machine(), machine_pattern::mid, resp_machines, machine_pattern::tid, and machine_pattern::tuple.

Referenced by resp_machine_find_or_create().

576 {
577  machine_pattern pat;
578  WTPRespMachine *m;
579 
580  pat.tuple = tuple;
581  pat.tid = tid;
582  pat.mid = mid;
583 
585  return m;
586 }
void * gwlist_search(List *list, void *pattern, int(*cmp)(void *, void *))
Definition: list.c:486
long tid
Definition: wtp.h:190
WAPAddrTuple * tuple
Definition: wtp.h:189
static int is_wanted_resp_machine(void *a, void *b)
Definition: wtp_resp.c:555
long mid
Definition: wtp.h:191
static List * resp_machines
Definition: wtp_resp.c:77

◆ resp_machine_find_or_create()

static WTPRespMachine * resp_machine_find_or_create ( WAPEvent event)
static

Definition at line 397 of file wtp_resp.c.

References debug(), erroneous_field_in(), error(), gw_assert(), handle_erroneous_field_in(), info(), WAPEvent::RcvInvoke, resp_machine_create(), resp_machine_find(), WAPEvent::type, WAPEvent::u, and wap_event_dump().

Referenced by main_thread().

398 {
399  WTPRespMachine *resp_machine = NULL;
400  long tid, mid;
402 
403  tid = -1;
404  tuple = NULL;
405  mid = -1;
406 
407  switch (event->type) {
408  case RcvInvoke:
409  /* check if erroneous fields are given */
410  if (erroneous_field_in(event)) {
412  return NULL;
413  } else {
414  tid = event->u.RcvInvoke.tid;
415  tuple = event->u.RcvInvoke.addr_tuple;
416  }
417  break;
418 
419  case RcvSegInvoke:
420  tid = event->u.RcvSegInvoke.tid;
421  tuple = event->u.RcvSegInvoke.addr_tuple;
422  break;
423 
424  case RcvAck:
425  tid = event->u.RcvAck.tid;
426  tuple = event->u.RcvAck.addr_tuple;
427  break;
428 
429  case RcvNegativeAck:
430  tid = event->u.RcvAck.tid;
431  tuple = event->u.RcvAck.addr_tuple;
432  break;
433 
434  case RcvAbort:
435  tid = event->u.RcvAbort.tid;
436  tuple = event->u.RcvAbort.addr_tuple;
437  break;
438 
439  case RcvErrorPDU:
440  tid = event->u.RcvErrorPDU.tid;
441  tuple = event->u.RcvErrorPDU.addr_tuple;
442  break;
443 
444  case TR_Invoke_Res:
445  mid = event->u.TR_Invoke_Res.handle;
446  break;
447 
448  case TR_Result_Req:
449  mid = event->u.TR_Result_Req.handle;
450  break;
451 
452  case TR_Abort_Req:
453  mid = event->u.TR_Abort_Req.handle;
454  break;
455 
456  case TimerTO_A:
457  mid = event->u.TimerTO_A.handle;
458  break;
459 
460  case TimerTO_R:
461  mid = event->u.TimerTO_R.handle;
462  break;
463 
464  case TimerTO_W:
465  mid = event->u.TimerTO_W.handle;
466  break;
467 
468  default:
469  debug("wap.wtp", 0, "WTP: resp_machine_find_or_create:"
470  "unhandled event");
471  wap_event_dump(event);
472  return NULL;
473  }
474 
475  gw_assert(tuple != NULL || mid != -1);
476  resp_machine = resp_machine_find(tuple, tid, mid);
477 
478  if (resp_machine == NULL){
479 
480  switch (event->type) {
481 
482  /*
483  * When PDU with an illegal header is received, its tcl-field is
484  * irrelevant and possibly meaningless). In this case we must create
485  * a new machine, if there is any. There is a machine for all events
486  * handled stateful manner.
487  */
488  case RcvErrorPDU:
489  debug("wap.wtp_resp", 0, "an erronous pdu received");
490  wap_event_dump(event);
491  resp_machine = resp_machine_create(tuple, tid,
492  event->u.RcvInvoke.tcl);
493  break;
494 
495  case RcvInvoke:
496  resp_machine = resp_machine_create(tuple, tid,
497  event->u.RcvInvoke.tcl);
498  /* if SAR requested */
499  if (!event->u.RcvInvoke.gtr || !event->u.RcvInvoke.ttr) {
500  resp_machine->sar = gw_malloc(sizeof(WTPSARData));
501  resp_machine->sar->nsegm = 0;
502  resp_machine->sar->csegm = 0;
503  resp_machine->sar->lsegm = 0;
504  resp_machine->sar->data = NULL;
505  }
506 
507  break;
508 
509  case RcvSegInvoke:
510  info(0, "WTP_RESP: resp_machine_find_or_create:"
511  " segmented invoke received, yet having no machine");
512  break;
513 
514  /*
515  * This and the following branch implement test nro 3 in WTP 10.2.
516  */
517  case RcvAck:
518  info(0, "WTP_RESP: resp_machine_find_or_create:"
519  " ack received, yet having no machine");
520  break;
521 
522  case RcvNegativeAck:
523  info(0, "WTP_RESP: resp_machine_find_or_create:"
524  " negative ack received, yet having no machine");
525  break;
526 
527  case RcvAbort:
528  info(0, "WTP_RESP: resp_machine_find_or_create:"
529  " abort received, yet having no machine");
530  break;
531 
532  case TR_Invoke_Res:
533  case TR_Result_Req:
534  case TR_Abort_Req:
535  error(0, "WTP_RESP: resp_machine_find_or_create: WSP primitive to"
536  " a wrong WTP machine");
537  break;
538 
539  case TimerTO_A:
540  case TimerTO_R:
541  case TimerTO_W:
542  error(0, "WTP_RESP: resp_machine_find_or_create: timer event"
543  " without a corresponding machine");
544  break;
545 
546  default:
547  error(0, "WTP_RESP: resp_machine_find_or_create: unhandled event");
548  wap_event_dump(event);
549  break;
550  }
551  } /* if machine == NULL */
552  return resp_machine;
553 }
void error(int err, const char *fmt,...)
Definition: log.c:648
void info(int err, const char *fmt,...)
Definition: log.c:672
static WTPRespMachine * resp_machine_create(WAPAddrTuple *tuple, long tid, long tcl)
Definition: wtp_resp.c:589
gw_assert(wtls_machine->packet_to_send !=NULL)
long tid
Definition: wtp.h:190
static WTPRespMachine * resp_machine_find(WAPAddrTuple *tuple, long tid, long mid)
Definition: wtp_resp.c:574
void wap_event_dump(WAPEvent *event)
Definition: wap_events.c:181
WAPAddrTuple * tuple
Definition: wtp.h:189
long mid
Definition: wtp.h:191
static int erroneous_field_in(WAPEvent *event)
Definition: wtp_resp.c:365
T DUnitdata TR Invoke TR Invoke TR Result TR Abort S Connect S Suspend S Resume S Suspend S Resume S Disconnect S MethodInvoke S MethodInvoke S MethodResult S MethodInvoke S MethodResult S MethodAbort S Push S ConfirmedPush S ConfirmedPush S PushAbort RcvInvoke
Definition: wap_events.h:491
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:726
WAPEventName type
Definition: wap_events.h:88
static void handle_erroneous_field_in(WAPEvent *event)
Definition: wtp_resp.c:374
union WAPEvent::@87 u

◆ sar_info_destroy()

static void sar_info_destroy ( void *  sar_info)
static

Definition at line 873 of file wtp_resp.c.

References octstr_destroy(), and sar_info_t::sar_data.

874 {
875  sar_info_t *sar_info;
876 
877  sar_info = p;
878 
879  octstr_destroy(sar_info->sar_data);
880  gw_free(sar_info);
881 }
Octstr * sar_data
Definition: wtp_resp.h:74
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324

◆ sardata_destroy()

static void sardata_destroy ( void *  sardata)
static

Definition at line 883 of file wtp_resp.c.

References WTPSARData::data, and octstr_destroy().

884 {
885  WTPSARData * sardata;
886 
887  if (p) {
888  sardata = p;
889  octstr_destroy(sardata->data);
890  gw_free(sardata);
891  }
892 }
Octstr * data
Definition: wtp_resp.h:86
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324

◆ send_abort()

static void send_abort ( WTPRespMachine machine,
long  type,
long  reason 
)
static

Definition at line 736 of file wtp_resp.c.

References dispatch_to_wdp, type, and wtp_pack_abort().

737 {
738  WAPEvent *e;
739 
740  e = wtp_pack_abort(type, reason, machine->tid, machine->addr_tuple);
741  dispatch_to_wdp(e);
742 }
int type
Definition: smsc_cimd2.c:215
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
WAPEvent * wtp_pack_abort(long abort_type, long abort_reason, long tid, WAPAddrTuple *address)
Definition: wtp_pack.c:223

◆ send_ack()

static void send_ack ( WTPRespMachine machine,
long  ack_type,
int  rid_flag 
)
static

Definition at line 744 of file wtp_resp.c.

References dispatch_to_wdp, and wtp_pack_ack().

745 {
746  WAPEvent *e;
747 
748  e = wtp_pack_ack(ack_type, rid_flag, machine->tid, machine->addr_tuple);
749  dispatch_to_wdp(e);
750 }
wap_dispatch_func_t * dispatch_to_wdp
Definition: wtp_resp.c:99
WAPEvent * wtp_pack_ack(long ack_type, int rid_flag, long tid, WAPAddrTuple *address)
Definition: wtp_pack.c:243

◆ start_timer_A()

static void start_timer_A ( WTPRespMachine machine)
static

Definition at line 699 of file wtp_resp.c.

References gwtimer_start(), L_A_WITH_USER_ACK, WTPRespMachine::mid, resp_timer_freq, WAPEvent::u, and wap_event_create.

700 {
701  WAPEvent *timer_event;
702 
703  timer_event = wap_event_create(TimerTO_A);
704  timer_event->u.TimerTO_A.handle = machine->mid;
706  timer_event);
707 }
unsigned long mid
Definition: wtp_resp.h:116
void gwtimer_start(Timer *timer, int interval, WAPEvent *event)
Definition: timers.c:254
#define wap_event_create(type)
Definition: wap_events.h:107
static long resp_timer_freq
Definition: wtp_resp.c:111
union WAPEvent::@87 u

◆ start_timer_R()

static void start_timer_R ( WTPRespMachine machine)
static

Definition at line 712 of file wtp_resp.c.

References gwtimer_start(), L_R_WITH_USER_ACK, WTPRespMachine::mid, resp_timer_freq, WAPEvent::u, and wap_event_create.

Referenced by continue_sar_result(), and resend_sar_result().

713 {
714  WAPEvent *timer_event;
715 
716  timer_event = wap_event_create(TimerTO_R);
717  timer_event->u.TimerTO_R.handle = machine->mid;
719  timer_event);
720 }
unsigned long mid
Definition: wtp_resp.h:116
void gwtimer_start(Timer *timer, int interval, WAPEvent *event)
Definition: timers.c:254
#define wap_event_create(type)
Definition: wap_events.h:107
static long resp_timer_freq
Definition: wtp_resp.c:111
union WAPEvent::@87 u

◆ start_timer_W()

static void start_timer_W ( WTPRespMachine machine)
static

Definition at line 726 of file wtp_resp.c.

References gwtimer_start(), WTPRespMachine::mid, resp_timer_freq, WAPEvent::u, W_WITH_USER_ACK, and wap_event_create.

Referenced by resp_event_handle().

727 {
728  WAPEvent *timer_event;
729 
730  timer_event = wap_event_create(TimerTO_W);
731  timer_event->u.TimerTO_W.handle = machine->mid;
732  gwtimer_start(machine->timer, W_WITH_USER_ACK * resp_timer_freq,
733  timer_event);
734 }
unsigned long mid
Definition: wtp_resp.h:116
void gwtimer_start(Timer *timer, int interval, WAPEvent *event)
Definition: timers.c:254
#define wap_event_create(type)
Definition: wap_events.h:107
static long resp_timer_freq
Definition: wtp_resp.c:111
union WAPEvent::@87 u

◆ 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

Variable Documentation

◆ dispatch_to_push

wap_dispatch_func_t* dispatch_to_push

Definition at line 101 of file wtp_resp.c.

Referenced by wtp_resp_init().

◆ dispatch_to_wdp

◆ dispatch_to_wsp

wap_dispatch_func_t* dispatch_to_wsp

Definition at line 100 of file wtp_resp.c.

Referenced by wtp_resp_init().

◆ resp_machine_id_counter

Counter* resp_machine_id_counter = NULL
static

Definition at line 83 of file wtp_resp.c.

Referenced by resp_machine_create(), wtp_resp_init(), and wtp_resp_shutdown().

◆ resp_machines

List* resp_machines = NULL
static

◆ resp_queue

List* resp_queue = NULL
static

Definition at line 106 of file wtp_resp.c.

Referenced by main_thread(), wtp_resp_dispatch_event(), wtp_resp_init(), and wtp_resp_shutdown().

◆ resp_run_status

enum { ... } resp_run_status

◆ resp_timer_freq

long resp_timer_freq = -1
static

Definition at line 111 of file wtp_resp.c.

Referenced by start_timer_A(), start_timer_R(), start_timer_W(), and wtp_resp_init().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.