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
utils.h
Go to the documentation of this file.
1
#ifndef UTILS_H
2
#define UTILS_H
3
4
#include <string>
5
#include <list>
6
#include <sys/time.h>
7
#include <sys/stat.h>
8
#include "ns3/nstime.h"
9
10
#define GET_CURRENT(x) \
11
Thread * current; \
12
current = Current (); \
13
do { \
14
NS_LOG_FUNCTION (current << UtilsGetNodeId () << x); \
15
NS_ASSERT (current != 0); \
16
} while (false)
17
#define GET_CURRENT_NOLOG() \
18
Thread * current; \
19
current = Current (); \
20
do { \
21
NS_LOG_FUNCTION (current << UtilsGetNodeId ()); \
22
NS_ASSERT (current != 0); \
23
} while (false)
24
25
26
namespace
ns3 {
27
28
class
Thread;
29
class
Process;
30
31
// Little hack in order to have a context usable when disposing the Task Manager and the hidden goal is to flush the open FILEs.
32
extern
Thread *
gDisposingThreadContext
;
33
34
void
UtilsEnsureDirectoryExists
(std::string realPath);
35
void
UtilsEnsureAllDirectoriesExist
(std::string realPath);
36
std::string
UtilsGetRealFilePath
(std::string path);
37
std::string
UtilsGetAbsRealFilePath
(uint32_t node, std::string path);
38
std::string
UtilsGetVirtualFilePath
(std::string path);
39
uint32_t
UtilsGetNodeId
(
void
);
40
Thread *
Current
(
void
);
41
bool
HasPendingSignal
(
void
);
42
Time
UtilsTimeToSimulationTime
(Time time);
43
Time
UtilsSimulationTimeToTime
(Time time);
44
struct
timeval UtilsTimeToTimeval (Time time);
45
struct
timespec UtilsTimeToTimespec (Time time);
46
Time
UtilsTimespecToTime
(
struct
timespec tm);
47
Time
UtilsTimevalToTime
(
struct
timeval tv);
48
Time
UtilsTimevalToTime
(
const
struct
timeval *tv);
49
void
UtilsSendSignal
(Process *process,
int
signum);
50
void
UtilsDoSignal
(
void
);
51
int
UtilsAllocateFd
(
void
);
52
// Little hack to advance time when detecting a possible infinite loop.
53
void
UtilsAdvanceTime
(Thread *current);
54
std::string
GetTimeStamp
();
55
bool
CheckExeMode
(
struct
stat *st, uid_t uid, gid_t gid);
56
std::string
FindExecFile
(std::string root, std::string envPath, std::string fileName, uid_t uid, gid_t gid,
int
*errNo);
57
std::list<std::string>
Split
(std::string input, std::string sep);
58
void
FdDecUsage
(
int
fd);
59
bool
CheckFdExists
(Process*
const
p,
int
const
fd,
bool
const
opened);
60
int
getRealFd
(
int
fd, Thread *current);
61
std::string
PathOfFd
(
int
fd);
62
bool
CheckShellScript
(std::string fileName,
63
std::ostringstream &shellName, std::ostringstream &optionalArg);
64
char
*
seek_env
(
const
char
*name,
char
**array);
65
std::string
UtilsGetCurrentDirName
(
void
);
66
67
#define MAX_FDS 1024
68
69
#define OPENED_FD_METHOD_ERR(errCode, rettype, args) \
70
std::map < int,FileUsage * > ::iterator it = current->process->openFiles.find (fd); \
71
if (current->process->openFiles.end () == it) \
72
{ \
73
current->err = EBADF; \
74
return (rettype) errCode; \
75
} \
76
FileUsage *fu = it->second; \
77
if (fu->IsClosed ()) \
78
{ \
79
current->err = EBADF; \
80
return (rettype) errCode; \
81
} \
82
UnixFd *unixFd = fu->GetFileInc (); \
83
rettype retval = unixFd->args; \
84
if (fu && fu->DecUsage ()) \
85
{ \
86
current->process->openFiles.erase (fd); \
87
delete fu; \
88
fu = 0; \
89
} \
90
\
91
return retval;
92
93
#define OPENED_FD_METHOD(rettype, args) OPENED_FD_METHOD_ERR (-1, rettype, args)
94
95
}
// namespace ns3
96
97
#endif
/* UTILS_H */
model
utils.h
Generated on Fri Aug 30 2013 13:57:56 for ns-3-dce by
1.8.1.2