Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
msg.h File Reference
#include "gwlib/gwlib.h"
#include "msg-decl.h"

Go to the source code of this file.

Data Structures

struct  Msg
 
struct  split_parts
 

Macros

#define MSG_PARAM_UNDEFINED   -1
 
#define MSG(type, stmt)   type,
 
#define INTEGER(name)   long name;
 
#define OCTSTR(name)   Octstr *name;
 
#define UUID(name)   uuid_t name;
 
#define VOID(name)   void *name;
 
#define MSG(type, stmt)   struct type stmt type;
 
#define msg_create(type)   gw_claim_area(msg_create_real((type), __FILE__, __LINE__, __func__))
 
#define msg_unpack(os)   gw_claim_area(msg_unpack_real((os), __FILE__, __LINE__, __func__))
 

Enumerations

enum  msg_type { MSG, MSG }
 
enum  {
  mo = 0, mt_reply = 1, mt_push = 2, report_mo = 3,
  report_mt = 4
}
 
enum  {
  cmd_shutdown = 0, cmd_suspend = 1, cmd_resume = 2, cmd_identify = 3,
  cmd_restart = 4, cmd_feature = 5
}
 
enum  ack_status_t { ack_success = 0, ack_failed = 1, ack_failed_tmp = 2, ack_buffered = 3 }
 

Functions

Msgmsg_create_real (enum msg_type type, const char *file, long line, const char *func)
 
Msgmsg_duplicate (Msg *msg)
 
enum msg_type msg_type (Msg *msg)
 
void msg_destroy (Msg *msg)
 
void msg_destroy_item (void *msg)
 
void msg_dump (Msg *msg, int level)
 
Octstrmsg_pack (Msg *msg)
 
Msgmsg_unpack_real (Octstr *os, const char *file, long line, const char *func)
 
Msgmsg_unpack_wrapper (Octstr *os)
 

Macro Definition Documentation

#define INTEGER (   name)    long name;

Definition at line 82 of file msg.h.

#define MSG (   type,
  stmt 
)    type,

Definition at line 86 of file msg.h.

#define MSG (   type,
  stmt 
)    struct type stmt type;

Definition at line 86 of file msg.h.

#define MSG_PARAM_UNDEFINED   -1
#define msg_unpack (   os)    gw_claim_area(msg_unpack_real((os), __FILE__, __LINE__, __func__))
#define OCTSTR (   name)    Octstr *name;

Definition at line 83 of file msg.h.

#define UUID (   name)    uuid_t name;

Definition at line 84 of file msg.h.

#define VOID (   name)    void *name;

Definition at line 85 of file msg.h.

Enumeration Type Documentation

anonymous enum
Enumerator
mo 
mt_reply 
mt_push 
report_mo 
report_mt 

Definition at line 105 of file msg.h.

105  {
106  mo = 0,
107  mt_reply = 1,
108  mt_push = 2,
109  report_mo = 3,
110  report_mt = 4
111 };
Definition: msg.h:106
Definition: msg.h:109
Definition: msg.h:110
Definition: msg.h:108
Definition: msg.h:107
anonymous enum
Enumerator
cmd_shutdown 
cmd_suspend 
cmd_resume 
cmd_identify 
cmd_restart 
cmd_feature 

Definition at line 114 of file msg.h.

114  {
115  cmd_shutdown = 0,
116  cmd_suspend = 1,
117  cmd_resume = 2,
118  cmd_identify = 3,
119  cmd_restart = 4,
120  cmd_feature = 5,
121 };
Enumerator
ack_success 
ack_failed 
ack_failed_tmp 
ack_buffered 

Definition at line 124 of file msg.h.

124  {
125  ack_success = 0,
126  ack_failed = 1, /* do not try again (e.g. no route) */
127  ack_failed_tmp = 2, /* temporary failed, try again (e.g. queue full) */
128  ack_buffered = 3
129 } ack_status_t;
ack_status_t
Definition: msg.h:124
Enumerator
MSG 
MSG 

Definition at line 73 of file msg.h.

73  {
74  #define MSG(type, stmt) type,
75  #include "msg-decl.h"
76  msg_type_count
77 };

Function Documentation

Msg* msg_create_real ( enum msg_type  type,
const char *  file,
long  line,
const char *  func 
)

Definition at line 93 of file msg.c.

References msg, Msg::type, and type.

Referenced by msg_unpack_real().

95 {
96  Msg *msg;
97 
98  msg = gw_malloc_trace(sizeof(Msg), file, line, func);
99 
100  msg->type = type;
101 #define INTEGER(name) p->name = MSG_PARAM_UNDEFINED;
102 #define OCTSTR(name) p->name = NULL;
103 #define UUID(name) uuid_generate(p->name);
104 #define VOID(name) p->name = NULL;
105 #define MSG(type, stmt) { struct type *p = &msg->type; stmt }
106 #include "msg-decl.h"
107 
108  return msg;
109 }
int type
Definition: smsc_cimd2.c:215
FILE * file
Definition: log.c:133
Definition: msg.h:79
enum msg_type type
Definition: msg.h:80
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
void msg_destroy ( Msg msg)

Definition at line 132 of file msg.c.

Referenced by bb_remove_message(), bb_smscconn_receive(), bb_smscconn_receive_internal(), bb_smscconn_send_failed(), bb_smscconn_sent(), boxc_receiver(), boxc_sender(), boxc_sent_pop(), cimd2_accept_message(), concat_handling_check_and_handle(), concat_handling_clear_old_parts(), data_sm_to_msg(), deliver_sms_to_queue(), deliver_to_bearerbox_real(), destroy_concatMsg(), dispatch_datagram(), dispatch_into_queue(), dlr_spool_add(), dlr_spool_get(), emi_receive_msg(), empty_msg_lists(), generic_receive_sms(), handle_pdu(), handle_split(), http_queue_thread(), main(), main_connection_loop(), msg_destroy_item(), msg_to_bb(), msg_unpack_real(), obey_request_thread(), ois_deliver_sm_invoke(), oisd_accept_message(), pdu_to_msg(), read_messages_from_bearerbox(), run_batch(), run_requests(), send_message(), send_pdu(), smpp_msg_destroy(), sms_receive(), sms_router(), sms_split(), smsbox_req_handle(), smsbox_req_sendota(), smsbox_sendota_post(), smsbox_thread(), smsc2_rout(), status_cb(), store_file_load(), store_file_save_ack(), store_spool_save_ack(), store_to_dict(), udp_sender(), url_result_thread(), wdp_to_wapboxes(), wrapper_sender(), and write_to_bearerbox_real().

133 {
134  if (msg == NULL)
135  return;
136 
137 #define INTEGER(name) p->name = 0;
138 #define OCTSTR(name) octstr_destroy(p->name);
139 #define UUID(name) uuid_clear(p->name);
140 #define VOID(name)
141 #define MSG(type, stmt) { struct type *p = &msg->type; stmt }
142 #include "msg-decl.h"
143 
144  gw_free(msg);
145 }
void msg_destroy_item ( void *  msg)

Definition at line 147 of file msg.c.

References msg_destroy().

Referenced by cimd2_destroy(), empty_msg_lists(), oisd_destroy(), send_message(), smasi_destroy(), smpp_destroy(), smscconn_send(), and store_file_init().

148 {
149  msg_destroy(msg);
150 }
void msg_destroy(Msg *msg)
Definition: msg.c:132
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
void msg_dump ( Msg msg,
int  level 
)

Definition at line 152 of file msg.c.

References debug(), type_as_str(), and UUID_STR_LEN.

Referenced by boxc_sent_pop(), concat_handling_check_and_handle(), dump(), handle_pdu(), main(), obey_request_thread(), print_msg(), and store_file_load().

153 {
154  char buf[UUID_STR_LEN + 1];
155 
156  debug("gw.msg", 0, "%*sMsg object at %p:", level, "", (void *) msg);
157  debug("gw.msg", 0, "%*s type: %s", level, "", type_as_str(msg));
158 #define INTEGER(name) \
159  debug("gw.msg", 0, "%*s %s.%s: %ld", level, "", t, #name, (long) p->name);
160 #define OCTSTR(name) \
161  debug("gw.msg", 0, "%*s %s.%s:", level, "", t, #name); \
162  octstr_dump(p->name, level + 1);
163 #define UUID(name) \
164  uuid_unparse(p->name, buf); \
165  debug("gw.msg", 0 , "%*s %s.%s: %s", level, "", t, #name, buf);
166 #define VOID(name) \
167  debug("gw.msg", 0, "%*s %s.%s: %p", level, "", t, #name, p->name);
168 #define MSG(tt, stmt) \
169  if (tt == msg->type) \
170  { char *t = #tt; struct tt *p = &msg->tt; stmt }
171 #include "msg-decl.h"
172  debug("gw.msg", 0, "Msg object ends.");
173 }
static char * type_as_str(Msg *msg)
Definition: msg.c:353
#define UUID_STR_LEN
Definition: gw_uuid.h:19
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
Msg* msg_duplicate ( Msg msg)

Definition at line 111 of file msg.c.

References msg_create, and Msg::type.

Referenced by add_msg_cb(), at2_add_msg_cb(), bb_smscconn_receive_internal(), boxc_sent_push(), cgw_add_msg_cb(), cimd2_add_msg_cb(), concat_handling_check_and_handle(), concat_handling_clear_old_parts(), generic_receive_sms(), httpsmsc_send(), main(), main_connection_loop(), msg_cb(), oisd_add_msg_cb(), send_message(), send_msg_cb(), sms_split(), smsc2_rout(), smscconn_send(), soap_add_msg_cb(), store_to_dict(), wrapper_add_msg(), and wrapper_sender().

112 {
113  Msg *new;
114 
115  new = msg_create(msg->type);
116 
117 #define INTEGER(name) p->name = q->name;
118 #define OCTSTR(name) \
119  if (q->name == NULL) p->name = NULL; \
120  else p->name = octstr_duplicate(q->name);
121 #define UUID(name) uuid_copy(p->name, q->name);
122 #define VOID(name) p->name = q->name;
123 #define MSG(type, stmt) { \
124  struct type *p = &new->type; \
125  struct type *q = &msg->type; \
126  stmt }
127 #include "msg-decl.h"
128 
129  return new;
130 }
#define msg_create(type)
Definition: msg.h:136
Definition: msg.h:79
enum msg_type type
Definition: msg.h:80
Octstr* msg_pack ( Msg msg)

Definition at line 181 of file msg.c.

References append_integer(), octstr_create, panic, and Msg::type.

Referenced by deliver_to_bearerbox_real(), init_bearerbox(), main(), send_msg(), send_pdu(), smsbox_thread(), and write_to_bearerbox_real().

182 {
183  Octstr *os;
184 
185  os = octstr_create("");
186  append_integer(os, msg->type);
187 
188 #define INTEGER(name) append_integer(os, p->name);
189 #define OCTSTR(name) append_string(os, p->name);
190 #define UUID(name) append_uuid(os, p->name);
191 #define VOID(name)
192 #define MSG(type, stmt) \
193  case type: { struct type *p = &msg->type; stmt } break;
194 
195  switch (msg->type) {
196 #include "msg-decl.h"
197  default:
198  panic(0, "Internal error: unknown message type: %d",
199  msg->type);
200  }
201 
202  return os;
203 }
static void append_integer(Octstr *os, long i)
Definition: msg.c:267
#define octstr_create(cstr)
Definition: octstr.h:125
Definition: octstr.c:118
#define panic
Definition: log.h:87
enum msg_type type
Definition: msg.h:80
enum msg_type msg_type ( Msg msg)

Definition at line 176 of file msg.c.

References Msg::type.

177 {
178  return msg->type;
179 }
enum msg_type type
Definition: msg.h:80
Msg* msg_unpack_real ( Octstr os,
const char *  file,
long  line,
const char *  func 
)

Definition at line 206 of file msg.c.

References error(), msg, msg_create_real(), msg_destroy(), parse_integer(), and Msg::type.

207 {
208  Msg *msg;
209  int off;
210  long i;
211 
212  msg = msg_create_real(0, file, line, func);
213  if (msg == NULL)
214  goto error;
215 
216  off = 0;
217 
218  if (parse_integer(&i, os, &off) == -1)
219  goto error;
220  msg->type = i;
221 
222 #define INTEGER(name) \
223  if (parse_integer(&(p->name), os, &off) == -1) goto error;
224 #define OCTSTR(name) \
225  if (parse_string(&(p->name), os, &off) == -1) goto error;
226 #define UUID(name) \
227  if (parse_uuid(p->name, os, &off) == -1) goto error;
228 #define VOID(name)
229 #define MSG(type, stmt) \
230  case type: { struct type *p = &(msg->type); stmt } break;
231 
232  switch (msg->type) {
233 #include "msg-decl.h"
234  default:
235  error(0, "Internal error: unknown message type: %d",
236  msg->type);
237  msg->type = 0;
238  msg_destroy(msg);
239  return NULL;
240  }
241 
242  return msg;
243 
244 error:
245  if (msg != NULL) msg_destroy(msg);
246  error(0, "Msg packet was invalid.");
247  return NULL;
248 }
void error(int err, const char *fmt,...)
Definition: log.c:612
Msg * msg_create_real(enum msg_type type, const char *file, long line, const char *func)
Definition: msg.c:93
FILE * file
Definition: log.c:133
Definition: msg.h:79
void msg_destroy(Msg *msg)
Definition: msg.c:132
static int parse_integer(long *i, Octstr *packed, int *off)
Definition: msg.c:294
enum msg_type type
Definition: msg.h:80
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
Msg* msg_unpack_wrapper ( Octstr os)
inline

Definition at line 256 of file msg.c.

References msg_unpack.

Referenced by init_bearerbox(), and main().

257 {
258  return msg_unpack(os);
259 }
#define msg_unpack(os)
Definition: msg.h:183
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.