Index: /branches/rel_ag_9_4_5/license/lib/license.c
===================================================================
--- /branches/rel_ag_9_4_5/license/lib/license.c	(revision 20431)
+++ /branches/rel_ag_9_4_5/license/lib/license.c	(working copy)
@@ -1546,26 +1546,56 @@
 			show_failed_feature( test_feature );
 		}
 
-		feactl_shm_detach( feactl_p ); 
+		feactl_shm_detach( feactl_p );
 		return ca_model_idx;
 	}
-	else 
+	else
 	{
-		feactl_shm_detach( feactl_p ); 
+		feactl_shm_detach( feactl_p );
 		if( show_flag ) show_failed_feature( test_feature );
 		return AFM_INVALID_MODEL;
 	}
-}	
+}
 
-/* 
+/* get record date from file */
+int64_t
+get_record_date(const char *license_key)
+{
+	FILE *fp;
+	record_date_t rd;
+
+	fp = fopen(RECORDDATEFN, "rb");
+	if (!fp) {
+		fp = fopen(RECORDDATEFN_BACKUP, "rb");
+		if (!fp) {
+			return -1;
+		}
+	}
+
+	memset(&rd, 0, sizeof(record_date_t));
+
+	while(fread(&rd, sizeof(record_date_t), 1, fp) == 1) {
+		/* find if this license has been recorded */
+		if (strcmp(rd.licensekey, license_key)==0) {
+			return rd.remain;
+		}
+		memset(&rd, 0, sizeof(record_date_t));
+	}
+
+	fclose(fp);
+
+	return -1;
+}
+
+/*
  * given license key, verify its hash
  * then extract various numeric fields, and populate feactl_t
  * return 0 if successful, -1 error
- * 
+ *
  * sample key:
  * tpUO0JmJ-PQfvPBGf-Zih0m6o3-sXY=#131-436f89d6-cd7698ba-dc6c7633-eaef0123-44#7a9ac-1d#0fedc-ba98765
- * 
- * unmasked key: 
+ *
+ * unmasked key:
  * tpUO0JmJPQfvPBGfZih0m6o3sXY=#0120608007d00999999990bff982700000001#02007d0
  * 
  */
@@ -1582,6 +1612,10 @@
 	struct if_info if_info;
 	int tmp_model_id = -1;
 	int permanent = 0;
+        int64_t remain_hours;
+	struct tm *p_now;
+	time_t t_now;
+	char str_today[32];
 
 	uint32_t site2site_max_tunnels = 0;
 
@@ -1591,6 +1625,14 @@
 
         license_debug_log("(%s): Original license key is %s",__FUNCTION__, licensekey);
 
+        /* TWSD-675 add license remain hours and current time in log file */
+	remain_hours = get_record_date(licensekey);
+	t_now = time(NULL);
+	p_now = localtime(&t_now);
+	memset(str_today, 0, sizeof(str_today));
+	strftime(str_today, sizeof(str_today), "%Y/%m/%d %T %Z (%z)", p_now);
+	license_debug_log("Remain hour is %ld (System current time: %s)\n", remain_hours, str_today);
+
         memset(key, 0, sizeof(key));
         snprintf(key, sizeof(key), "%s", licensekey);
         unmask_license_key(key);
@@ -2412,46 +2454,51 @@
 
 
 /*
- * given an masked license key, unmask it first, 
+ * given an masked license key, unmask it first,
  * then show the expiration date
- */ 
+ */
 void
 show_expiration_date(char *licensekey, char *outbuf, int *idx)
 {
-	char key[MAX_LICKEY_LEN], year[10], date_str[10], field[100], *p; 
+	char key[MAX_LICKEY_LEN], year[10], date_str[10], field[100], *p;
 	struct tm tm1;
 	char temp[100];
+        int64_t remain_hours;
 
 	memset(key, 0, sizeof(key));
 	snprintf(key, sizeof(key), "%s", licensekey);
-	unmask_license_key(key); 
+	unmask_license_key(key);
 
-	bzero(field, sizeof(field)); 
+	bzero(field, sizeof(field));
 	bzero(year, sizeof(year));
-	bzero(date_str, sizeof(date_str)); 
+	bzero(date_str, sizeof(date_str));
 
 	get_field(key, "#01", field, sizeof(field));
 	strncpy(date_str, field + 14, 8);
 	strncpy(year, date_str, 4);
-	
+
 	/* handle special 9999 case */
 	if (atoi(year) == 9999){
 
 		snprintf(temp, sizeof(temp), "     License Date : Permanent\n");
-		ui_printf("%s", temp); 
+		ui_printf("%s", temp);
 		return;
 	}
 
 	p = strptime(date_str, "%Y%m%d", &tm1);
 	if (p == NULL){
-		printf("Wrong date string: %s in %s\n", date_str, __FUNCTION__); 
-		return; 
+		printf("Wrong date string: %s in %s\n", date_str, __FUNCTION__);
+		return;
 	}
 
-	/* construct: License Date : expires on Tuesday Jan 31 2008 */ 
-	strftime(temp, sizeof(temp), "     License Date : Expires on %b %d %Y\n", &tm1);
+	/* construct: License Date : expires on Tuesday Jan 31 2008 */
+	strftime(temp, sizeof(temp), "     License Date : Expires on %b %d %Y", &tm1);
 
-	ui_printf("%s", temp); 
+        /* TWSD-675 add remain hours on show version */
+        remain_hours = get_record_date(licensekey);
+	sprintf(temp, "%s (Remain hour is %ld)\n", temp, remain_hours);
+
+	ui_printf("%s", temp);
 
 	return;
 }
@@ -3491,36 +3538,6 @@
 	return 0;
 }
 
-/* get record date from file */
-int64_t
-get_record_date(const char *license_key)
-{
-	FILE *fp;
-	record_date_t rd;
-
-	fp = fopen(RECORDDATEFN, "rb");
-	if (!fp) {
-		fp = fopen(RECORDDATEFN_BACKUP, "rb");
-		if (!fp) {
-			return -1;
-		}
-	}
-
-	memset(&rd, 0, sizeof(record_date_t));
-
-	while(fread(&rd, sizeof(record_date_t), 1, fp) == 1) {
-		/* find if this license has been recorded */
-		if (strcmp(rd.licensekey, license_key)==0) {
-			return rd.remain;
-		}
-		memset(&rd, 0, sizeof(record_date_t));
-	}
-
-	fclose(fp);
-
-	return -1;
-}
-
 /*when excute 'system date', record changed system date*/
 void update_system_date_file()
 {
Index: /branches/rel_ag_9_4_5/license/src/licenseinit.c
===================================================================
--- /branches/rel_ag_9_4_5/license/src/licenseinit.c	(revision 20431)
+++ /branches/rel_ag_9_4_5/license/src/licenseinit.c	(working copy)
@@ -43,9 +43,12 @@
 int update_record_date_boot_time(const char *license_key)
 {
 	char cmd_buf[MAX_CMD_LEN];
+        char str_today[32];
 	time_t last_check_time;
 	time_t current_time;
+        struct tm *p_now;
 	FILE *fd = NULL;
+        long long_ret;
 
 	fd = fopen(LICENSE_CHECK_SYSTEM_DATEFN, "r");
 	if (fd == NULL) {
@@ -67,6 +70,10 @@
 	fclose(fd);
 
 	current_time = time(NULL);
+        p_now = localtime(&current_time);
+	memset(str_today, 0, sizeof(str_today));
+	strftime(str_today, sizeof(str_today), "%Y/%m/%d %T %Z (%z)", p_now);
+
 	if (current_time < last_check_time) {
 		/*this means system clock has been changed, we ignore this*/
 		license_sys_log("system clock(%ld) is conflict with last license check time(%ld)", current_time, last_check_time);
@@ -90,7 +97,11 @@
 			return 0;
 		}
 
-		license_debug_log("Remain hour is %ld\n", remain_hours);
+		// license_debug_log("Remain hour is %ld\n", remain_hours);
+                /* TWSD-675 add license ETA and current time in log file */
+                long_ret = get_expiration_date();
+		license_debug_log("Expired time ETA: %d/%02d/%02d GMT (+0000) (System current time: %s)\n",
+			long_ret/10000, long_ret/100%100, long_ret%100, str_today);
 
 		if (remain_hours <= passed_hours) {
 			license_sys_log("license has expired since last license check: "
Index: /branches/rel_ag_9_4_5/tools/check_license.c
===================================================================
--- /branches/rel_ag_9_4_5/tools/check_license.c	(revision 20431)
+++ /branches/rel_ag_9_4_5/tools/check_license.c	(working copy)
@@ -349,6 +349,9 @@
 {
 	int64_t record_exist;
 	int64_t remain;
+        char str_today[32];
+	time_t t1;
+	struct tm *p_now;
 
 	record_exist = get_record_date(license_key);
 	if (record_exist == 0) {
@@ -361,8 +364,13 @@
 		init_record_date(license_key);
 		return SUCCESS;
 	}
+        /* TWSD-675 add system current time in log file each hour*/
+	t1 = time(NULL);
+	p_now = localtime(&t1);
+	memset(str_today, 0, sizeof(str_today));
+	strftime(str_today, sizeof(str_today), "%Y/%m/%d %T %Z (%z)", p_now);
 
-	license_debug_log("remain %ld hour\n", record_exist);
+	license_debug_log("remain %ld hour (System current time: %s)\n", record_exist, str_today);
 	write_record_date(license_key, (uint32_t)(record_exist-1));
 
 	remain = record_exist/24;
