ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pipe-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 PIPE_FD_H
22 #define PIPE_FD_H
23 
24 #include "unix-fd.h"
25 #include "fifo-buffer.h"
26 namespace ns3 {
35 class LocalSocketFdFactory;
36 
37 
38 #define LOCAL_SOCKET_MAX_BUFFER 1024 * 128
39 
40 class PipeFd : public UnixFd
41 {
42 public:
43  PipeFd ();
44  PipeFd (PipeFd *peer);
45 
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 int Setsockopt (int level, int optname,
52  const void *optval, socklen_t optlen);
53  virtual int Getsockopt (int level, int optname,
54  void *optval, socklen_t *optlen);
55  virtual int Getsockname (struct sockaddr *name, socklen_t *namelen);
56  virtual int Getpeername (struct sockaddr *name, socklen_t *namelen);
57  virtual int Ioctl (int request, char *argp);
58  virtual int Bind (const struct sockaddr *myaddr, socklen_t addrlen);
59  virtual int Connect (const struct sockaddr *my_addr, socklen_t addrlen);
60  virtual int Listen (int backlog);
61  virtual int Shutdown (int how);
62  virtual int Accept (struct sockaddr *my_addr, socklen_t *addrlen);
63  virtual void * Mmap (void *start, size_t length, int prot, int flags, off64_t offset);
64  virtual off64_t Lseek (off64_t offset, int whence);
65  virtual int Fxstat (int ver, struct ::stat *buf);
66  virtual int Fxstat64 (int ver, struct ::stat64 *buf);
67  virtual int Fcntl (int cmd, unsigned long arg);
68  virtual int Settime (int flags,
69  const struct itimerspec *new_value,
70  struct itimerspec *old_value);
71  virtual int Gettime (struct itimerspec *cur_value) const;
72  virtual int Ftruncate (off_t length);
73  virtual bool Isatty (void) const;
74 
75  // Return true if a select on this fd should return POLLHUP
76  virtual bool HangupReceived (void) const;
77 
78  virtual int Poll (PollTable* ptable);
79 
80 private:
81  ssize_t DoRecvPacket (uint8_t* buf, size_t len);
82 
84  bool m_readSide;
87 
88 };
89 } // namespace ns3
90 
91 #endif /* PIPE_FD_H */