OpenVAS Libraries  9.0.3
time.c File Reference

time handling functions More...

#include <time.h>
#include <sys/time.h>
#include <utime.h>
#include "byteorder.h"
#include "smb.h"
#include <limits.h>
Include dependency graph for time.c:

Go to the source code of this file.

Macros

#define uint32   uint32_t
 
#define TIME_T_MIN
 
#define TIME_T_MAX   LONG_MAX
 
#define NTTIME_INFINITY   (NTTIME)0x8000000000000000LL
 
#define TIME_FIXUP_CONSTANT_INT   11644473600LL
 

Functions

void unix_timespec_to_nt_time_ntlmssp (NTTIME *nt, struct timespec ts)
 
void GetTimeOfDay_ntlmssp (struct timeval *tval)
 
void put_long_date_timespec_ntlmssp (char *p, struct timespec ts)
 
void put_long_date_ntlmssp (char *p, time_t t)
 

Detailed Description

time handling functions

Definition in file time.c.

Macro Definition Documentation

◆ NTTIME_INFINITY

#define NTTIME_INFINITY   (NTTIME)0x8000000000000000LL

Definition at line 50 of file time.c.

◆ TIME_FIXUP_CONSTANT_INT

#define TIME_FIXUP_CONSTANT_INT   11644473600LL

Definition at line 52 of file time.c.

Referenced by unix_timespec_to_nt_time_ntlmssp().

◆ TIME_T_MAX

#define TIME_T_MAX   LONG_MAX

Definition at line 47 of file time.c.

Referenced by unix_timespec_to_nt_time_ntlmssp().

◆ TIME_T_MIN

#define TIME_T_MIN
Value:
((time_t)0 < (time_t) -1 ? (time_t) 0 \
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))

Definition at line 43 of file time.c.

◆ uint32

#define uint32   uint32_t

Definition at line 33 of file time.c.

Function Documentation

◆ GetTimeOfDay_ntlmssp()

void GetTimeOfDay_ntlmssp ( struct timeval tval)

Definition at line 92 of file time.c.

93 {
94  gettimeofday(tval,NULL);
95 }

◆ put_long_date_ntlmssp()

void put_long_date_ntlmssp ( char *  p,
time_t  t 
)

Definition at line 111 of file time.c.

References put_long_date_timespec_ntlmssp().

Referenced by NTLMv2_generate_client_data_ntlmssp().

112 {
113  struct timespec ts;
114  ts.tv_sec = t;
115  ts.tv_nsec = 0;
117 }
void put_long_date_timespec_ntlmssp(char *p, struct timespec ts)
Definition: time.c:103
Here is the call graph for this function:
Here is the caller graph for this function:

◆ put_long_date_timespec_ntlmssp()

void put_long_date_timespec_ntlmssp ( char *  p,
struct timespec  ts 
)

Definition at line 103 of file time.c.

References SIVAL, and unix_timespec_to_nt_time_ntlmssp().

Referenced by put_long_date_ntlmssp().

104 {
105  NTTIME nt;
107  SIVAL(p, 0, nt & 0xFFFFFFFF);
108  SIVAL(p, 4, nt >> 32);
109 }
uint64_t NTTIME
Definition: smb.h:166
#define SIVAL(buf, pos, val)
Definition: byteorder.h:123
void unix_timespec_to_nt_time_ntlmssp(NTTIME *nt, struct timespec ts)
Definition: time.c:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unix_timespec_to_nt_time_ntlmssp()

void unix_timespec_to_nt_time_ntlmssp ( NTTIME nt,
struct timespec  ts 
)

Definition at line 58 of file time.c.

References TIME_FIXUP_CONSTANT_INT, and TIME_T_MAX.

Referenced by put_long_date_timespec_ntlmssp().

59 {
60  uint64_t d;
61 
62  if (ts.tv_sec ==0 && ts.tv_nsec == 0) {
63  *nt = 0;
64  return;
65  }
66  if (ts.tv_sec == TIME_T_MAX) {
67  *nt = 0x7fffffffffffffffLL;
68  return;
69  }
70  if (ts.tv_sec == (time_t)-1) {
71  *nt = (uint64_t)-1;
72  return;
73  }
74 
75  d = ts.tv_sec;
76  d += (uint64_t)TIME_FIXUP_CONSTANT_INT;
77  d *= 1000*1000*10;
78  /* d is now in 100ns units. */
79  d += (ts.tv_nsec / 100);
80 
81  *nt = d;
82 }
#define TIME_FIXUP_CONSTANT_INT
Definition: time.c:52
#define TIME_T_MAX
Definition: time.c:47
Here is the caller graph for this function: