comparison libfreeDiameter/messages.c @ 646:cfc8da9264f4

Prepared first part of the changes for #10
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 04 Jan 2011 16:20:50 +0900
parents 9448cba86673
children ae29bf971f20
comparison
equal deleted inserted replaced
645:d9d8f0c1875f 646:cfc8da9264f4
121 struct rt_data *msg_rtdata; /* Routing list for the query */ 121 struct rt_data *msg_rtdata; /* Routing list for the query */
122 struct session *msg_sess; /* Cached message session if any */ 122 struct session *msg_sess; /* Cached message session if any */
123 struct { 123 struct {
124 void (*fct)(void *, struct msg **); 124 void (*fct)(void *, struct msg **);
125 void * data; 125 void * data;
126 struct timespec timeout;
126 } msg_cb; /* Callback to be called when an answer is received, if not NULL */ 127 } msg_cb; /* Callback to be called when an answer is received, if not NULL */
127 char * msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */ 128 char * msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */
128 }; 129 };
129 130
130 /* Macro to compute the message header size */ 131 /* Macro to compute the message header size */
901 902
902 return 0; 903 return 0;
903 } 904 }
904 905
905 /* Associate / get answer callbacks */ 906 /* Associate / get answer callbacks */
906 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data ) 907 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data, const struct timespec *timeout )
907 { 908 {
908 TRACE_ENTRY("%p %p %p", msg, anscb, data); 909 TRACE_ENTRY("%p %p %p", msg, anscb, data);
909 910
910 /* Check the parameters */ 911 /* Check the parameters */
911 CHECK_PARAMS( CHECK_MSG(msg) && anscb ); 912 CHECK_PARAMS( CHECK_MSG(msg) && anscb );
913 CHECK_PARAMS( msg->msg_cb.fct == NULL ); /* No cb is already registered */ 914 CHECK_PARAMS( msg->msg_cb.fct == NULL ); /* No cb is already registered */
914 915
915 /* Associate callback and data with the message, if any */ 916 /* Associate callback and data with the message, if any */
916 msg->msg_cb.fct = anscb; 917 msg->msg_cb.fct = anscb;
917 msg->msg_cb.data = data; 918 msg->msg_cb.data = data;
919 if (timeout) {
920 memcpy(&msg->msg_cb.timeout, timeout, sizeof(struct timespec));
921 } else {
922 memset(&msg->msg_cb.timeout, 0, sizeof(struct timespec)); /* clear the area */
923 }
918 924
919 return 0; 925 return 0;
920 } 926 }
921 927
922 int fd_msg_anscb_get( struct msg * msg, void (**anscb)(void *, struct msg **), void ** data ) 928 int fd_msg_anscb_get( struct msg * msg, void (**anscb)(void *, struct msg **), void ** data )
"Welcome to our mercurial repository"