Mercurial > hg > waaad
changeset 250:b1a387363d95
Changed the prototype to avoid erroneous msg management
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 05 Dec 2008 11:55:12 +0900 |
parents | d3e799cbb0e4 |
children | e489577dda1a |
files | include/waaad/message-api.h waaad/message.c |
diffstat | 2 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/include/waaad/message-api.h Fri Dec 05 11:38:21 2008 +0900 +++ b/include/waaad/message-api.h Fri Dec 05 11:55:12 2008 +0900 @@ -197,7 +197,7 @@ * FUNCTION: msg_send * * PARAMETERS: - * msg : The message to be sent on the network. + * msg : Location of the message to be sent on the network (set to NULL on function return). * anscb : A callback to be called with answer (if msg is a request) (optional) * anscb_data : opaque data to be passed back to the anscb when it is called. * @@ -224,7 +224,7 @@ * EINVAL : A parameter is invalid (ex: anscb provided but message is not a request). * ... */ -int msg_send ( msg_t * msg, void (*anscb)(void *, msg_t **), void * data ); +int msg_send ( msg_t ** msg, void (*anscb)(void *, msg_t **), void * data ); /***************************************/
--- a/waaad/message.c Fri Dec 05 11:38:21 2008 +0900 +++ b/waaad/message.c Fri Dec 05 11:55:12 2008 +0900 @@ -121,6 +121,10 @@ int msg_routable; /* Is this a routable message? (0: undef, 1: routable, 2: non routable) */ msg_t *msg_query; /* the associated query if the message is a received answer */ rt_dpl_t *msg_rtlist; /* Routing list for the query */ + struct { + void (*fct)(void *, msg_t **); + void * data; + } msg_cb; /* Callback to be called when an answer is received, if not NULL */ char * msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */ uint32_t msg_src_hash; /* Hash of the msg_src_id value */ } _msg_t; @@ -2364,9 +2368,25 @@ } /* Send a message and optionaly register a callback for an answer */ -int msg_send ( msg_t * msg, void (*anscb)(void *, msg_t **), void * data ) +int msg_send ( msg_t ** msg, void (*anscb)(void *, msg_t **), void * data ) { - return ENOTSUP; + TRACE_ENTRY("%p %p %p", msg, anscb, data); + + /* Check the parameters */ + CHECK_PARAMS( CHECK_MSG(msg) ); + CHECK_PARAMS( (anscb == NULL) || (_M(msg)->msg_public.msg_flags & CMD_FLAG_REQUEST) ); + CHECK_PARAMS( (anscb == NULL) || (_M(msg)->msg_cb.fct == NULL) ); /* No cb is already registered */ + + /* Associate callback and data with the message, if any */ + if (anscb) { + _M(msg)->msg_cb.fct = anscb; + _M(msg)->msg_cb.data = data; + } + + /* Now push the message in the global outgoing queue */ + + + return 0; }