ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
dce-time.cc
Go to the documentation of this file.
1
#include "
dce-time.h
"
2
#include "
dce-manager.h
"
3
#include "
process.h
"
4
#include "
utils.h
"
5
#include <ns3/log.h>
6
#include <ns3/node.h>
7
#include <ns3/simulator.h>
8
#include <errno.h>
9
10
NS_LOG_COMPONENT_DEFINE
(
"DceTime"
);
11
12
using namespace
ns3;
13
14
time_t
dce_time
(time_t *t)
15
{
16
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
17
NS_ASSERT (
Current
() != 0);
18
time_t time = (time_t)
UtilsSimulationTimeToTime
(Now ()).GetSeconds ();
19
if
(t != 0)
20
{
21
*t = time;
22
}
23
return
time;
24
}
25
26
struct
tm *
dce_gmtime
(
const
time_t *timep)
27
{
28
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
29
NS_ASSERT (
Current
() != 0);
30
31
return
gmtime_r (timep, &
Current
()->process->struct_tm);
32
}
33
34
struct
tm *
dce_localtime
(
const
time_t *timep)
35
{
36
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
37
NS_ASSERT (
Current
() != 0);
38
39
return
localtime_r (timep, &
Current
()->process->struct_tm);
40
}
41
42
char
*
dce_ctime
(
const
time_t *timep)
43
{
44
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
45
NS_ASSERT (
Current
() != 0);
46
47
return
ctime_r (timep,
Current
()->process->asctime_result);
48
}
49
50
char
*
dce_asctime
(
const
struct
tm *tm)
51
{
52
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
53
NS_ASSERT (
Current
() != 0);
54
55
return
asctime_r (tm,
Current
()->process->asctime_result);
56
}
57
58
int
dce_clock_gettime
(clockid_t c,
struct
timespec *tp)
59
{
60
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
61
NS_ASSERT (
Current
() != 0);
62
if
(0 == tp)
63
{
64
Current
()->
err
= EFAULT;
65
return
-1;
66
}
67
*tp =
UtilsTimeToTimespec
(
UtilsSimulationTimeToTime
(Now ()));
68
return
0;
69
}
70
void
dce_tzset
()
71
{
72
73
}
74
75
int
dce_clock_getres
(clockid_t c,
struct
timespec *r)
76
{
77
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
78
NS_ASSERT (
Current
() != 0);
79
80
switch
(c)
81
{
82
case
CLOCK_REALTIME:
83
{
84
if
(0 == r)
85
{
86
Current
()->
err
= EFAULT;
87
return
-1;
88
}
89
r->tv_sec = 0;
90
r->tv_nsec = 1;
91
92
return
0;
93
}
94
break
;
95
96
default
:
97
{
98
Current
()->
err
= EINVAL;
99
return
-1;
100
}
101
}
102
return
0;
103
}
104
105
int
dce_utime
(
const
char
*filename,
const
struct
utimbuf *times)
106
{
107
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
());
108
NS_ASSERT (
Current
() != 0);
109
110
std::string fullpath =
UtilsGetRealFilePath
(filename);
111
112
return
utime (fullpath.c_str (), times);
113
}
model
dce-time.cc
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2