Mercurial > hg > freeDiameter
diff libfdproto/messages.c @ 1103:d8591b1c56cd
Implemented a few hooks
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Fri, 10 May 2013 18:48:57 +0800 |
parents | 40b48a3997a2 |
children | eb4ce68b6e5c |
line wrap: on
line diff
--- a/libfdproto/messages.c Thu May 09 16:40:02 2013 +0800 +++ b/libfdproto/messages.c Fri May 10 18:48:57 2013 +0800 @@ -201,6 +201,9 @@ memset(msg, 0, sizeof(struct msg)); init_chain( &msg->msg_chain, MSG_MSG); msg->msg_eyec = MSG_MSG_EYEC; + + fd_list_init(&msg->msg_pmdl.sentinel, NULL); + CHECK_POSIX_DO( pthread_mutex_init(&msg->msg_pmdl.lock, NULL), ); } @@ -1951,23 +1954,20 @@ CHECK_PARAMS( buffer && *buffer && msg && (buflen >= GETMSGHDRSZ()) ); buf = *buffer; - *buffer = NULL; if ( buf[0] != DIAMETER_VERSION) { TRACE_DEBUG(INFO, "Invalid version in message: %d (supported: %d)", buf[0], DIAMETER_VERSION); - free(buf); return EBADMSG; } msglen = ntohl(*(uint32_t *)buf) & 0x00ffffff; if ( buflen < msglen ) { TRACE_DEBUG(INFO, "Truncated message (%zd / %d)", buflen, msglen ); - free(buf); return EBADMSG; } /* Create a new object */ - CHECK_MALLOC_DO( new = malloc (sizeof(struct msg)), { free(buf); return ENOMEM; } ); + CHECK_MALLOC( new = malloc (sizeof(struct msg)) ); /* Initialize the fields */ init_msg(new); @@ -1983,11 +1983,12 @@ new->msg_public.msg_hbhid = ntohl(*(uint32_t *)(buf+12)); new->msg_public.msg_eteid = ntohl(*(uint32_t *)(buf+16)); - new->msg_rawbuffer = buf; - /* Parse the AVP list */ CHECK_FCT_DO( ret = parsebuf_list(buf + GETMSGHDRSZ(), buflen - GETMSGHDRSZ(), &new->msg_chain.children), { destroy_tree(_C(new)); return ret; } ); + /* Parsing successful */ + new->msg_rawbuffer = buf; + *buffer = NULL; *msg = new; return 0; }