From e403a7fdfbbb87301ce2576b595ddc060c23ddd2 Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Fri, 26 Jun 2009 20:52:19 +0000
Subject: [PATCH] Add timestamp to response to "Ping" manager action.

(closes issue #14596)
Reported by: JimDickenson
Patches:
      pong2.diff uploaded by JimDickenson (license 710)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203783 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 doc/manager_1_1.txt | 3 +++
 main/manager.c      | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/manager_1_1.txt b/doc/manager_1_1.txt
index 5a674e596d..d07edcdc60 100644
--- a/doc/manager_1_1.txt
+++ b/doc/manager_1_1.txt
@@ -133,6 +133,9 @@ Changes to manager version 1.1:
 - Action IAXpeers
 	Now includes if the IAX link is a trunk or not
 
+- Action Ping
+	Response now includes a timestamp
+
 * NEW ACTIONS
 -------------
 - Action: ModuleLoad
diff --git a/main/manager.c b/main/manager.c
index 76e24d170f..0670da36d8 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1808,12 +1808,13 @@ static int authenticate(struct mansession *s, const struct message *m)
 static int action_ping(struct mansession *s, const struct message *m)
 {
 	const char *actionid = astman_get_header(m, "ActionID");
+	struct timeval now = ast_tvnow();
 
 	astman_append(s, "Response: Success\r\n");
 	if (!ast_strlen_zero(actionid)){
 		astman_append(s, "ActionID: %s\r\n", actionid);
 	}
-	astman_append(s, "Ping: Pong\r\n\r\n");
+	astman_append(s, "Ping: Pong\r\nTimestamp:%ld.%06lu\r\n", now.tv_sec, (unsigned long) now.tv_usec);
 	return 0;
 }
 
-- 
GitLab