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-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) 2006,2007 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#ifndef UNIX_SOCKET_FD_H
21
#define UNIX_SOCKET_FD_H
22
23
#include "
unix-fd.h
"
24
#include "ns3/ptr.h"
25
#include "ns3/address.h"
26
#include "ns3/nstime.h"
27
#include "ns3/event-id.h"
28
#include <linux/types.h>
29
#include <linux/errqueue.h>
30
#include <netinet/in.h>
31
#include <list>
32
33
struct
sockaddr_ll;
34
35
namespace
ns3 {
36
37
class
Socket;
38
class
Thread;
39
class
Waiter;
40
class
Packet;
41
42
class
UnixSocketFd
:
public
UnixFd
43
{
44
public
:
45
virtual
~UnixSocketFd
();
46
virtual
int
Close
(
void
);
47
virtual
ssize_t
Write
(
const
void
*buf,
size_t
count);
48
virtual
ssize_t
Read
(
void
*buf,
size_t
count);
49
virtual
ssize_t
Recvmsg
(
struct
msghdr *msg,
int
flags);
50
virtual
ssize_t
Sendmsg
(
const
struct
msghdr *msg,
int
flags);
51
virtual
bool
Isatty
(
void
)
const
;
52
virtual
int
Setsockopt
(
int
level,
int
optname,
53
const
void
*optval, socklen_t optlen);
54
virtual
int
Getsockopt
(
int
level,
int
optname,
55
void
*optval, socklen_t *optlen);
56
virtual
int
Getsockname
(
struct
sockaddr *name, socklen_t *namelen);
57
virtual
int
Getpeername
(
struct
sockaddr *name, socklen_t *namelen);
58
virtual
int
Ioctl
(
int
request,
char
*argp);
59
virtual
int
Bind
(
const
struct
sockaddr *my_addr, socklen_t addrlen);
60
virtual
int
Connect
(
const
struct
sockaddr *my_addr, socklen_t addrlen);
61
virtual
void
*
Mmap
(
void
*start,
size_t
length,
int
prot,
int
flags, off64_t offset);
62
virtual
off64_t
Lseek
(off64_t offset,
int
whence);
63
virtual
int
Fxstat
(
int
ver,
struct
stat *buf);
64
virtual
int
Fxstat64
(
int
ver,
struct
stat64 *buf);
65
virtual
int
Settime
(
int
flags,
66
const
struct
itimerspec *new_value,
67
struct
itimerspec *old_value);
68
virtual
int
Gettime
(
struct
itimerspec *cur_value)
const
;
69
virtual
int
Ftruncate
(off_t length);
70
// CanRecv and CanSend return true only if a following Read or Write will not block,
71
// so a remote closed socket should return true because read or write will not block but will fail.
72
virtual
bool
CanRecv
(
void
)
const
= 0;
73
virtual
bool
CanSend
(
void
)
const
= 0;
74
75
private
:
76
virtual
ssize_t
DoRecvmsg
(
struct
msghdr *msg,
int
flags) = 0;
77
virtual
ssize_t
DoSendmsg
(
const
struct
msghdr *msg,
int
flags) = 0;
78
79
protected
:
80
UnixSocketFd
(Ptr<Socket> sock);
81
int
ErrnoToSimuErrno
(
void
)
const
;
82
Address
PosixAddressToNs3Address
(
const
struct
sockaddr *my_addr, socklen_t addrlen)
const
;
83
int
Ns3AddressToPosixAddress
(
const
Address& nsaddr,
84
struct
sockaddr *addr, socklen_t *addrlen)
const
;
85
int
Ns3AddressToDeviceIndependantPhysicalLayerAddress
(
const
Address& nsaddr,
const
Packet& pac,
86
struct
sockaddr_ll *addr, socklen_t *addrlen)
const
;
87
bool
WaitRecvDoSignal
(
bool
blocking);
88
Time
GetRecvTimeout
(
void
);
89
Time
GetSendTimeout
(
void
);
90
bool
IsRecvErr
(
void
)
const
;
91
bool
IsRecvTtl
(
void
)
const
;
92
// bool IsRecvPktInfo (void) const;
93
// bool IsRecvPktInfo6 (void) const;
94
// bool IsIpHdrIncl (void) const;
95
96
Ptr<Socket>
m_socket
;
97
void
ChangeSocket
(Ptr<Socket> socket);
98
void
ClearSocket
(
void
);
99
100
Ptr<Packet>
m_peekedData
;
101
Address
m_peekedAddress
;
102
103
void
AddPeekedData
(
const
uint8_t *buf, uint32_t count, Address from);
104
void
AddPeekedData
(Ptr<Packet> p);
105
bool
isPeekedData
(
void
);
106
Address
GetPeekedFrom
(
void
);
107
108
private
:
109
void
MainConnect
(
int
*r, Address adr);
110
void
MainClose
(
int
*r);
111
void
RecvSocketData
(Ptr<Socket> socket);
112
void
SendSocketData
(Ptr<Socket> socket, uint32_t available);
113
// Clear m_socket and its callbacks.
114
115
Time
m_sendTimeout
;
116
Time
m_recvTimeout
;
117
int
m_recvttl
;
118
int
m_recverr
;
119
// int m_recvpktinfo;
120
// int m_recvpktinfo6;
121
// int m_iphdrincl;
122
// int m_sockchecksum;
123
// int m_multicastloop;
124
// int m_unicasthops;
125
// int m_multicasthops;
126
// int m_recvhoplimit;
127
};
128
129
}
// namespace ns3
130
131
#endif
/* UNIX_SOCKET_FD_H */
model
unix-socket-fd.h
Generated on Fri Aug 30 2013 13:57:56 for ns-3-dce by
1.8.1.2