Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wtp.h File Reference
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdlib.h>
#include "gwlib/gwlib.h"
#include "wap_addr.h"
#include "wap_events.h"

Go to the source code of this file.

Data Structures

struct  machine_pattern
 

Macros

#define INITIATOR_TID_LIMIT   (1 << 15)
 

Typedefs

typedef struct WTPSegment WTPSegment
 
typedef struct machine_pattern machine_pattern
 

Enumerations

enum  { NUMBER_OF_ABORT_TYPES = 2, NUMBER_OF_ABORT_REASONS = 10, NUMBER_OF_TRANSACTION_CLASSES = 3 }
 
enum  {
  L_A_WITH_USER_ACK = 4, L_R_WITH_USER_ACK = 7, S_R_WITHOUT_USER_ACK = 3, S_R_WITH_USER_ACK = 4,
  G_R_WITHOUT_USER_ACK = 3, G_R_WITH_USER_ACK = 3, W_WITH_USER_ACK = 30
}
 
enum  { AEC_MAX = 6, MAX_RCR = 8 }
 
enum  { ACKNOWLEDGEMENT = 0, TID_VERIFICATION = 1 }
 
enum  { PROVIDER = 0x00, USER = 0x01 }
 
enum  {
  UNKNOWN = 0x00, PROTOERR = 0x01, INVALIDTID = 0x02, NOTIMPLEMENTEDCL2 = 0x03,
  NOTIMPLEMENTEDSAR = 0x04, NOTIMPLEMENTEDUACK = 0x05, WTPVERSIONZERO = 0x06, CAPTEMPEXCEEDED = 0x07,
  NORESPONSE = 0x08, MESSAGETOOLARGE = 0x09, NOTIMPLEMENTEDESAR = 0x0A
}
 
enum  { TRANSACTION_CLASS_0 = 0, TRANSACTION_CLASS_1 = 1, TRANSACTION_CLASS_2 = 2 }
 
enum  { PROVIDER_ACKNOWLEDGEMENT = 0, USER_ACKNOWLEDGEMENT = 1 }
 
enum  { INITIATOR_INDICATION = 0, RESPONDER_INDICATION = 1 }
 
enum  {
  TPI_ERROR = 0, TPI_INFO = 1, TPI_OPTION = 2, TPI_PSN = 3,
  TPI_SDU_BOUNDARY = 4, TPI_FRAME_BOUNDARY = 5
}
 

Functions

Listwtp_unpack_wdp_datagram (WAPEvent *datagram)
 
int wtp_event_is_for_responder (WAPEvent *event)
 

Macro Definition Documentation

#define INITIATOR_TID_LIMIT   (1 << 15)

Definition at line 183 of file wtp.h.

Referenced by wtp_event_is_for_responder().

Typedef Documentation

Definition at line 194 of file wtp.h.

typedef struct WTPSegment WTPSegment

Definition at line 77 of file wtp.h.

Enumeration Type Documentation

anonymous enum
Enumerator
TRANSACTION_CLASS_0 
TRANSACTION_CLASS_1 
TRANSACTION_CLASS_2 

Definition at line 148 of file wtp.h.

anonymous enum
Enumerator
PROVIDER_ACKNOWLEDGEMENT 
USER_ACKNOWLEDGEMENT 

Definition at line 157 of file wtp.h.

anonymous enum
Enumerator
INITIATOR_INDICATION 
RESPONDER_INDICATION 

Definition at line 165 of file wtp.h.

165  {
168 };
anonymous enum
Enumerator
TPI_ERROR 
TPI_INFO 
TPI_OPTION 
TPI_PSN 
TPI_SDU_BOUNDARY 
TPI_FRAME_BOUNDARY 

Definition at line 170 of file wtp.h.

170  {
171  TPI_ERROR = 0,
172  TPI_INFO = 1,
173  TPI_OPTION = 2,
174  TPI_PSN = 3,
175  TPI_SDU_BOUNDARY = 4,
177 };
Definition: wtp.h:171
Definition: wtp.h:174
Definition: wtp.h:172
anonymous enum
Enumerator
NUMBER_OF_ABORT_TYPES 
NUMBER_OF_ABORT_REASONS 
NUMBER_OF_TRANSACTION_CLASSES 

Definition at line 82 of file wtp.h.

anonymous enum
Enumerator
L_A_WITH_USER_ACK 
L_R_WITH_USER_ACK 
S_R_WITHOUT_USER_ACK 
S_R_WITH_USER_ACK 
G_R_WITHOUT_USER_ACK 
G_R_WITH_USER_ACK 
W_WITH_USER_ACK 

Definition at line 93 of file wtp.h.

anonymous enum
Enumerator
AEC_MAX 
MAX_RCR 

Definition at line 107 of file wtp.h.

107  {
108  AEC_MAX = 6,
109  MAX_RCR = 8
110 };
Definition: wtp.h:109
Definition: wtp.h:108
anonymous enum
Enumerator
ACKNOWLEDGEMENT 
TID_VERIFICATION 

Definition at line 115 of file wtp.h.

115  {
116  ACKNOWLEDGEMENT = 0,
117  TID_VERIFICATION = 1
118 };
anonymous enum
Enumerator
PROVIDER 
USER 

Definition at line 123 of file wtp.h.

123  {
124  PROVIDER = 0x00,
125  USER = 0x01
126 };
Definition: wtp.h:125
Definition: wtp.h:124
anonymous enum
Enumerator
UNKNOWN 
PROTOERR 
INVALIDTID 
NOTIMPLEMENTEDCL2 
NOTIMPLEMENTEDSAR 
NOTIMPLEMENTEDUACK 
WTPVERSIONZERO 
CAPTEMPEXCEEDED 
NORESPONSE 
MESSAGETOOLARGE 
NOTIMPLEMENTEDESAR 

Definition at line 131 of file wtp.h.

131  {
132  UNKNOWN = 0x00,
133  PROTOERR = 0x01,
134  INVALIDTID = 0x02,
135  NOTIMPLEMENTEDCL2 = 0x03,
136  NOTIMPLEMENTEDSAR = 0x04,
137  NOTIMPLEMENTEDUACK = 0x05,
138  WTPVERSIONZERO = 0x06,
139  CAPTEMPEXCEEDED = 0x07,
140  NORESPONSE = 0x08,
141  MESSAGETOOLARGE = 0x09,
142  NOTIMPLEMENTEDESAR = 0x0A
143 };
Definition: wtp.h:132
Definition: wtp.h:133

Function Documentation

int wtp_event_is_for_responder ( WAPEvent event)

Definition at line 156 of file wtp.c.

References error(), INITIATOR_TID_LIMIT, WAPEvent::type, and wap_event_dump().

Referenced by unpack_wdp_datagram_real(), wap_dispatch_datagram(), and wtp_event_dump().

157 {
158 
159  switch(event->type){
160 
161  case RcvInvoke:
162  return event->u.RcvInvoke.tid < INITIATOR_TID_LIMIT;
163 
164  case RcvSegInvoke:
165  return event->u.RcvSegInvoke.tid < INITIATOR_TID_LIMIT;
166 
167  case RcvResult:
168  return event->u.RcvResult.tid < INITIATOR_TID_LIMIT;
169 
170  case RcvAck:
171  return event->u.RcvAck.tid < INITIATOR_TID_LIMIT;
172 
173  case RcvNegativeAck:
174  return event->u.RcvNegativeAck.tid < INITIATOR_TID_LIMIT;
175 
176  case RcvAbort:
177  return event->u.RcvAbort.tid < INITIATOR_TID_LIMIT;
178 
179  case RcvErrorPDU:
180  return event->u.RcvErrorPDU.tid < INITIATOR_TID_LIMIT;
181 
182  default:
183  error(1, "Received an erroneous PDU corresponding an event");
184  wap_event_dump(event);
185  return -1;
186  }
187 }
void error(int err, const char *fmt,...)
Definition: log.c:612
#define INITIATOR_TID_LIMIT
Definition: wtp.h:183
void wap_event_dump(WAPEvent *event)
Definition: wap_events.c:181
WAPEventName type
Definition: wap_events.h:88
List* wtp_unpack_wdp_datagram ( WAPEvent datagram)

Definition at line 98 of file wtp.c.

References concatenated_message(), gw_assert(), GW_WARNING, gwlist_append(), gwlist_create, octstr_copy, octstr_delete(), octstr_destroy(), octstr_dump, octstr_duplicate, octstr_get_bits(), octstr_get_char(), octstr_len(), WAPEvent::type, WAPEvent::u, unpack_wdp_datagram_real(), wap_event_assert(), wap_event_destroy(), wap_event_duplicate(), and warning().

Referenced by wap_dispatch_datagram(), and wtp_event_dump().

99 {
100  List *events = NULL;
101  WAPEvent *event = NULL;
102  WAPEvent *subdgram = NULL;
103  Octstr *data = NULL;
104  long pdu_len;
105 
106  gw_assert(datagram->type == T_DUnitdata_Ind);
107 
108  events = gwlist_create();
109 
110  if (concatenated_message(datagram->u.T_DUnitdata_Ind.user_data)) {
111  data = octstr_duplicate(datagram->u.T_DUnitdata_Ind.user_data);
112  octstr_delete(data, 0, 1);
113 
114  while (octstr_len(data) != 0) {
115 
116  if (octstr_get_bits(data, 0, 1) == 0) {
117  pdu_len = octstr_get_char(data, 0);
118  octstr_delete(data, 0, 1);
119  } else {
120  pdu_len = octstr_get_bits(data, 1, 15);
121  octstr_delete(data, 0, 2);
122  }
123 
124  subdgram = wap_event_duplicate(datagram);
125  octstr_destroy(subdgram->u.T_DUnitdata_Ind.user_data);
126  subdgram->u.T_DUnitdata_Ind.user_data = octstr_copy(data, 0, pdu_len);
127  wap_event_assert(subdgram);
128  if ((event = unpack_wdp_datagram_real(subdgram)) != NULL) {
129  wap_event_assert(event);
130  gwlist_append(events, event);
131  }
132  octstr_delete(data, 0, pdu_len);
133  wap_event_destroy(subdgram);
134  }
135 
136  octstr_destroy(data);
137 
138  } else if ((event = unpack_wdp_datagram_real(datagram)) != NULL) {
139  wap_event_assert(event);
140  gwlist_append(events, event);
141  } else {
142  warning(0, "WTP: Dropping unhandled datagram data:");
143  octstr_dump(datagram->u.T_DUnitdata_Ind.user_data, 0, GW_WARNING);
144  }
145 
146  return events;
147 }
void gwlist_append(List *list, void *item)
Definition: list.c:179
static int concatenated_message(Octstr *user_data)
Definition: wtp.c:434
#define octstr_copy(ostr, from, len)
Definition: octstr.h:178
long octstr_get_bits(Octstr *ostr, long bitpos, int numbits)
Definition: octstr.c:1801
void wap_event_assert(WAPEvent *event)
Definition: wap_events.c:220
void octstr_delete(Octstr *ostr1, long pos, long len)
Definition: octstr.c:1525
static WAPEvent * unpack_wdp_datagram_real(WAPEvent *datagram)
Definition: wtp.c:342
Definition: log.h:69
#define octstr_duplicate(ostr)
Definition: octstr.h:187
#define octstr_dump(ostr, level,...)
Definition: octstr.h:564
void warning(int err, const char *fmt,...)
Definition: log.c:624
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
gw_assert(wtls_machine->packet_to_send!=NULL)
WAPEvent * wap_event_duplicate(WAPEvent *event)
Definition: wap_events.c:135
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
Definition: octstr.c:118
WAPEventName type
Definition: wap_events.h:88
#define gwlist_create()
Definition: list.h:136
union WAPEvent::@87 u
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:404
Definition: list.c:102
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.