68 #include <sys/types.h> 69 #include <netinet/in.h> 98 msg = gw_malloc_trace(
sizeof(
Msg),
file, line, func);
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 } 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; \ 137 #define INTEGER(name) p->name = 0; 138 #define OCTSTR(name) octstr_destroy(p->name); 139 #define UUID(name) uuid_clear(p->name); 141 #define MSG(type, stmt) { struct type *p = &msg->type; stmt } 156 debug(
"gw.msg", 0,
"%*sMsg object at %p:", level,
"", (
void *)
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); 164 uuid_unparse(p->name, buf); \ 165 debug("gw.msg", 0 , "%*s %s.%s: %s", level, "", t, #name, buf); 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 } 172 debug(
"gw.msg", 0,
"Msg object ends.");
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); 192 #define MSG(type, stmt) \ 193 case type: { struct type *p = &msg->type; stmt } break; 198 panic(0,
"Internal error: unknown message type: %d",
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; 227 if (parse_uuid(p->name, os, &off) == -1) goto error; 229 #define MSG(type, stmt) \ 230 case type: { struct type *p = &(msg->type); stmt } break; 235 error(0,
"Internal error: unknown message type: %d",
246 error(0,
"Msg packet was invalid.");
269 unsigned char buf[4];
296 unsigned char buf[4];
300 error(0,
"Packet too short while unpacking Msg.");
356 #define MSG(t, stmt) case t: return #t; 359 return "unknown type";
void msg_dump(Msg *msg, int level)
void error(int err, const char *fmt,...)
Msg * msg_duplicate(Msg *msg)
static char * type_as_str(Msg *msg)
void octstr_append_data(Octstr *ostr, const char *data, long len)
gw_assert(wtls_machine->packet_to_send !=NULL)
void encode_network_long(unsigned char *data, unsigned long value)
Msg * msg_unpack_wrapper(Octstr *os)
static void append_integer(Octstr *os, long i)
void uuid_unparse(const uuid_t uu, char *out)
void octstr_append_cstr(Octstr *ostr, const char *cstr)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
Msg * msg_create_real(enum msg_type type, const char *file, long line, const char *func)
int uuid_parse(const char *in, uuid_t uu)
static int parse_string(Octstr **os, Octstr *packed, int *off)
void msg_destroy_item(void *msg)
void octstr_insert(Octstr *ostr1, const Octstr *ostr2, long pos)
static int parse_uuid(uuid_t id, Octstr *packed, int *off)
void msg_destroy(Msg *msg)
static void append_string(Octstr *os, Octstr *field)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
long octstr_len(const Octstr *ostr)
long decode_network_long(unsigned char *data)
static int parse_integer(long *i, Octstr *packed, int *off)
void debug(const char *place, int err, const char *fmt,...)
Msg * msg_unpack_real(Octstr *os, const char *file, long line, const char *func)
Octstr * msg_pack(Msg *msg)
void octstr_get_many_chars(char *buf, Octstr *ostr, long pos, long len)
static void append_uuid(Octstr *os, uuid_t id)
static XMLRPCDocument * msg
enum msg_type msg_type(Msg *msg)