e2sim: add support for Resource Status Request, Response, Update
[it/test.git] / simulators / e2sim / src / DEF / e2sim_defs.cpp
index f80977d..f1730d3 100644 (file)
 
 #include "e2sim_defs.h"
 #include <getopt.h>
+#include <sys/time.h>
+#include <time.h>
+
+char* time_stamp(void)
+{
+  timeval curTime;
+  gettimeofday(&curTime, NULL);
+  int milli = curTime.tv_usec / 1000;
+
+  char buffer [80];
+  strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localtime(&curTime.tv_sec));
+
+  const int time_buffer_len = 84;
+  static char currentTime[time_buffer_len] = "";
+  snprintf(currentTime, time_buffer_len, "%s:%03d", buffer, milli);
+
+  return currentTime;
+}
 
 options_t read_input_options_old(int argc, char* argv[])
 {