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
local-socket-fd.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Frederic Urbani <frederic.urbani@inria.fr>
19
*
20
*/
21
#ifndef LOCAL_SOCKET_FD_H
22
#define LOCAL_SOCKET_FD_H
23
24
#include "
unix-fd.h
"
25
#include "ns3/ptr.h"
26
#include <list>
27
#include "ns3/nstime.h"
28
#include "ns3/object.h"
29
30
namespace
ns3 {
31
32
class
Waiter;
33
42
class
LocalSocketFdFactory;
43
44
#define LOCAL_SOCKET_MAX_BUFFER 1024 * 128
45
46
class
LocalSocketFd
:
public
UnixFd
47
{
48
public
:
49
static
TypeId
GetTypeId
(
void
);
50
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
51
52
LocalSocketFd
();
53
virtual
~LocalSocketFd
();
54
55
virtual
int
Close
(
void
) = 0;
56
virtual
ssize_t
Write
(
const
void
*buf,
size_t
count) = 0;
57
virtual
ssize_t
Read
(
void
*buf,
size_t
count) = 0;
58
virtual
ssize_t
Recvmsg
(
struct
msghdr *msg,
int
flags) = 0;
59
virtual
ssize_t
Sendmsg
(
const
struct
msghdr *msg,
int
flags) = 0;
60
virtual
bool
Isatty
(
void
)
const
;
61
virtual
int
Setsockopt
(
int
level,
int
optname,
62
const
void
*optval, socklen_t optlen) = 0;
63
virtual
int
Getsockopt
(
int
level,
int
optname,
64
void
*optval, socklen_t *optlen) = 0;
65
virtual
int
Getsockname
(
struct
sockaddr *name, socklen_t *namelen) = 0;
66
virtual
int
Getpeername
(
struct
sockaddr *name, socklen_t *namelen) = 0;
67
virtual
int
Ioctl
(
int
request,
char
*argp);
68
virtual
int
Bind
(
const
struct
sockaddr *my_addr, socklen_t addrlen) = 0;
69
virtual
int
Connect
(
const
struct
sockaddr *my_addr, socklen_t addrlen) = 0;
70
virtual
int
Listen
(
int
backlog) = 0;
71
virtual
int
Shutdown
(
int
how) = 0;
72
virtual
int
Accept
(
struct
sockaddr *my_addr, socklen_t *addrlen) = 0;
73
virtual
void
*
Mmap
(
void
*start,
size_t
length,
int
prot,
int
flags, off64_t offset);
74
virtual
off64_t
Lseek
(off64_t offset,
int
whence);
75
virtual
int
Fxstat
(
int
ver, struct ::stat *buf);
76
virtual
int
Fxstat64
(
int
ver, struct ::stat64 *buf);
77
virtual
int
Fcntl
(
int
cmd,
unsigned
long
arg);
78
virtual
int
Settime
(
int
flags,
79
const
struct
itimerspec *new_value,
80
struct
itimerspec *old_value);
81
virtual
int
Gettime
(
struct
itimerspec *cur_value)
const
;
82
virtual
int
Ftruncate
(off_t length);
83
84
virtual
bool
CanRecv
(
void
)
const
= 0;
85
virtual
bool
CanSend
(
void
)
const
= 0;
86
virtual
bool
HangupReceived
(
void
)
const
= 0;
87
88
protected
:
89
void
ClearReadBuffer
(
void
);
90
virtual
void
ClearAll
(
bool
andWakeUp) = 0;
91
virtual
bool
IsClosed
(
void
)
const
= 0;
92
93
Time
GetRecvTimeout
(
void
);
94
Time
GetSendTimeout
(
void
);
95
// Return :
96
// the size readed ,
97
// or 0 if no more space available,
98
// or -1 if fatal error occurs
99
// or -2 if read part is shuted down
100
ssize_t
DoRecvPacket
(uint8_t* buf,
size_t
len);
101
102
size_t
ReadData
(uint8_t* buf,
size_t
len,
bool
peek);
103
104
struct
Buffer
105
{
106
uint8_t *
data
;
107
size_t
size
;
108
size_t
readOffset
;
109
};
110
typedef
std::list<struct Buffer*>
FifoData
;
111
112
FifoData
m_readBuffer
;
113
size_t
m_readBufferSize
;
114
115
Time
m_sendTimeout
;
116
Time
m_recvTimeout
;
117
Ptr<LocalSocketFdFactory>
m_factory
;
118
int32_t
m_linger
;
119
std::string
m_bindPath
;
120
std::string
m_connectPath
;
121
bool
m_shutRead
;
122
bool
m_shutWrite
;
123
};
124
125
}
// namespace ns3
126
127
#endif
/* LOCAL_SOCKET_FD_H */
model
local-socket-fd.h
Generated on Fri Aug 30 2013 13:57:56 for ns-3-dce by
1.8.1.2