diff include/freeDiameter/libfdproto.h @ 895:fbf77629cb7b

Added received and sent timestamps in the messages; added logs on emission and reception
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 30 Nov 2012 00:44:10 +0100
parents 43fb27a9037f
children d8d0772586ad
line wrap: on
line diff
--- a/include/freeDiameter/libfdproto.h	Thu Nov 29 22:51:49 2012 +0100
+++ b/include/freeDiameter/libfdproto.h	Fri Nov 30 00:44:10 2012 +0100
@@ -203,8 +203,6 @@
 #define FCTS 6  /* Display entry parameters of most functions */
 #define CALL 9  /* Display calls to most functions (with CHECK macros) */
 
-#define TIMING INFO /* Display the message handing time information with this level */
-
 /* Increment the debug level for a file at compilation time by defining -DTRACE_LEVEL=FULL for example. */
 #ifndef TRACE_LEVEL 
 #define TRACE_LEVEL NONE
@@ -595,6 +593,17 @@
 	(    ((ts1)->tv_sec  < (ts2)->tv_sec ) 	\
 	  || (((ts1)->tv_sec  == (ts2)->tv_sec ) && ((ts1)->tv_nsec < (ts2)->tv_nsec) ))
 
+/* Compute diff between two timespecs (pointers) */
+#define TS_DIFFERENCE( tsdiff, tsstart, tsend )	{					\
+	if ((tsend)->tv_nsec < (tsstart)->tv_nsec ) {					\
+		(tsdiff)->tv_sec = (tsend)->tv_sec - (tsstart)->tv_sec - 1;		\
+		(tsdiff)->tv_nsec = (tsend)->tv_nsec + 1000000000 - (tsstart)->tv_nsec;	\
+	} else {									\
+		(tsdiff)->tv_sec  = (tsend)->tv_sec  - (tsstart)->tv_sec;		\
+		(tsdiff)->tv_nsec = (tsend)->tv_nsec - (tsstart)->tv_nsec;		\
+	}}
+		
+
 /* This gives a good size for buffered reads */
 #ifndef BUFSIZ
 #define BUFSIZ 96
@@ -2220,9 +2229,10 @@
 	FD_MSG_LOG_DROPPED = 0,  /* message has been dropped by the framework */ 
 	FD_MSG_LOG_RECEIVED,     /* message received from the network */ 
 	FD_MSG_LOG_SENT,         /* message sent to another peer */ 
-	FD_MSG_LOG_NODELIVER     /* message could not be delivered to any peer */ 
+	FD_MSG_LOG_NODELIVER,    /* message could not be delivered to any peer */
+	FD_MSG_LOG_TIMING	 /* profiling messages */
 };
-#define FD_MSG_LOG_MAX FD_MSG_LOG_NODELIVER
+#define FD_MSG_LOG_MAX FD_MSG_LOG_TIMING
 void fd_msg_log( enum fd_msg_log_cause cause, struct msg * msg, const char * prefix_format, ... );
 
 /* configure the msg_log facility */
@@ -2385,6 +2395,28 @@
 int fd_msg_source_get( struct msg * msg, DiamId_t *diamid, size_t * diamidlen );
 
 /*
+ * FUNCTION:	fd_msg_ts_*
+ *
+ * PARAMETERS:
+ *  msg		: A msg object.
+ *  ts		: A struct timespec pointer, indexed on CLOCK_REALTIME
+ *
+ * DESCRIPTION: 
+ *   Associate or retrieve timestamps meaningful for the message.
+ *  A timestamp with a value of { 0, 0 } means: not set.
+ *
+ * RETURN VALUE:
+ *  0      	: Operation complete.
+ *  !0      	: an error occurred.
+ */
+/* when msg was received from network */
+int fd_msg_ts_set_recv( struct msg * msg, struct timespec * ts );
+int fd_msg_ts_get_recv( struct msg * msg, struct timespec * ts );
+int fd_msg_ts_set_sent( struct msg * msg, struct timespec * ts );
+int fd_msg_ts_get_sent( struct msg * msg, struct timespec * ts );
+
+
+/*
  * FUNCTION:	fd_msg_eteid_get
  *
  * PARAMETERS:
"Welcome to our mercurial repository"