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
unix-fd.cc
Go to the documentation of this file.
1
#include "
unix-fd.h
"
2
#include "
waiter.h
"
3
#include "ns3/log.h"
4
#include "
process.h
"
5
#include "
utils.h
"
6
#include <fcntl.h>
7
#include <errno.h>
8
9
NS_LOG_COMPONENT_DEFINE
(
"UnixFd"
);
10
11
namespace
ns3 {
12
13
TypeId
14
UnixFd::GetTypeId
(
void
)
15
{
16
static
TypeId tid = TypeId (
"ns3::UnixFd"
)
17
.SetParent<Object> ()
18
;
19
return
tid;
20
}
21
22
UnixFd::UnixFd
() : m_fdCount (0),
23
m_fdFlags (0),
24
m_statusFlags (0)
25
{
26
}
27
void
28
UnixFd::RemoveWaitQueue
(
WaitQueueEntry
* old,
bool
andUnregister)
29
{
30
m_waitQueueList
.remove (old);
31
if
(andUnregister)
32
{
33
Current
()->
ioWait
= std::make_pair ((
UnixFd
*)0,(
WaitQueueEntry
*)0);
34
}
35
}
36
void
37
UnixFd::AddWaitQueue
(
WaitQueueEntry
* newOne,
bool
andRegister)
38
{
39
m_waitQueueList
.push_back (newOne);
40
if
(andRegister)
41
{
42
Current
()->
ioWait
= std::make_pair (
this
, newOne);
43
}
44
}
45
void
46
UnixFd::WakeWaiters
(
void
* key)
47
{
48
for
(std::list<WaitQueueEntry*>::iterator i =
m_waitQueueList
.begin ();
49
i !=
m_waitQueueList
.end (); ++i)
50
{
51
(*i)->WakeUp (key);
52
}
53
}
54
void
55
UnixFd::IncFdCount
(
void
)
56
{
57
m_fdCount
++;
58
}
59
void
60
UnixFd::DecFdCount
(
void
)
61
{
62
m_fdCount
--;
63
}
64
int
65
UnixFd::GetFdCount
(
void
)
const
66
{
67
return
m_fdCount
;
68
}
69
char
*
70
UnixFd::Ttyname
(
void
)
71
{
72
return
0;
73
}
74
int
75
UnixFd::GetRealFd
(
void
)
const
76
{
77
return
-1;
78
}
79
int
80
UnixFd::Fcntl
(
int
cmd,
unsigned
long
arg)
81
{
82
switch
(cmd)
83
{
84
case
F_GETFL:
85
return
m_statusFlags
;
86
break
;
87
case
F_SETFL:
88
m_statusFlags
= arg;
89
return
0;
90
break
;
91
92
case
F_GETFD:
93
return
m_fdFlags
;
94
break
;
95
case
F_SETFD:
96
m_fdFlags
= arg;
97
return
0;
98
break
;
99
100
default
:
101
//XXX commands missing
102
NS_FATAL_ERROR (
"fcntl not implemented on socket"
);
103
return
-1;
104
}
105
}
106
}
// namespace ns3
model
unix-fd.cc
Generated on Fri Aug 30 2013 13:57:56 for ns-3-dce by
1.8.1.2