1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-26 16:19:03 +00:00

Add nmap.clock() for providing scripts with the current time in floating

point seconds since the epoch, and add clock_ms() and clock_us() to stdnse
for convenience (millisecond and microsecond).

qscan.nse now provides microsecond resolution.
This commit is contained in:
kris
2010-07-23 19:49:42 +00:00
parent 33845f104c
commit cc33a59ca4
6 changed files with 53 additions and 16 deletions

View File

@@ -177,6 +177,15 @@ static int l_clock_ms (lua_State *L)
return 1;
}
static int l_clock (lua_State *L)
{
struct timeval tv;
gettimeofday(&tv, NULL);
/* floating point seconds since Epoch */
lua_pushnumber(L, TIMEVAL_SECS(tv));
return 1;
}
/* The actual mutex returned by the nmap.mutex function.
* This function has 4 upvalues:
* (1) Table (array) of waiting threads.
@@ -672,6 +681,7 @@ int luaopen_nmap (lua_State *L)
{"new_dnet", l_dnet_new},
{"get_interface_link", l_dnet_get_interface_link},
{"clock_ms", l_clock_ms},
{"clock", l_clock},
{"log_write", l_log_write},
{"new_try", l_new_try},
{"verbosity", l_get_verbosity},