OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2012 NICT |
| 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: Hajime Tazaki <tazaki@nict.go.jp> |
| 19 */ |
| 20 #ifndef UDP_SOCKET_IMPL_H |
| 21 #define UDP_SOCKET_IMPL_H |
| 22 |
| 23 #include "ns3/socket.h" |
| 24 #include "ns3/event-id.h" |
| 25 |
| 26 namespace ns3 { |
| 27 |
| 28 class Node; |
| 29 class Packet; |
| 30 class Task; |
| 31 class LinuxSocketFd; |
| 32 |
| 33 /** |
| 34 * \ingroup udp |
| 35 * \brief A sockets interface to UDP |
| 36 *· |
| 37 * This class subclasses ns3::UdpSocket, and provides a socket interface |
| 38 * to ns3's implementation of UDP. |
| 39 */ |
| 40 |
| 41 class LinuxSocketImpl : public Socket |
| 42 { |
| 43 public: |
| 44 static TypeId GetTypeId (void); |
| 45 /** |
| 46 * Create an unbound udp socket. |
| 47 */ |
| 48 LinuxSocketImpl (); |
| 49 virtual ~LinuxSocketImpl (); |
| 50 void CreateSocket (); |
| 51 |
| 52 virtual enum SocketErrno GetErrno (void) const; |
| 53 virtual enum SocketType GetSocketType (void) const; |
| 54 virtual void SetNode (Ptr<Node> node); |
| 55 virtual Ptr<Node> GetNode (void) const; |
| 56 virtual int Bind (void); |
| 57 virtual int Bind6 (void); |
| 58 virtual int Bind (const Address &address); |
| 59 virtual int Close (void); |
| 60 virtual int ShutdownSend (void); |
| 61 virtual int ShutdownRecv (void); |
| 62 virtual int Connect (const Address &address); |
| 63 virtual int Listen (void); |
| 64 virtual uint32_t GetTxAvailable (void) const; |
| 65 virtual int Send (Ptr<Packet> p, uint32_t flags); |
| 66 virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &address); |
| 67 virtual uint32_t GetRxAvailable (void) const; |
| 68 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
| 69 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, |
| 70 Address &fromAddress); |
| 71 virtual int GetSockName (Address &address) const;· |
| 72 virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupA
ddress); |
| 73 virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &group
Address); |
| 74 virtual void BindToNetDevice (Ptr<NetDevice> netdevice); |
| 75 virtual bool SetAllowBroadcast (bool allowBroadcast); |
| 76 virtual bool GetAllowBroadcast () const; |
| 77 void Poll (); |
| 78 |
| 79 LinuxSocketFd *m_kernsock; |
| 80 Task *m_task; |
| 81 |
| 82 private: |
| 83 // Attributes set through UdpSocket base class· |
| 84 virtual void SetRcvBufSize (uint32_t size); |
| 85 virtual uint32_t GetRcvBufSize (void) const; |
| 86 virtual void SetIpTtl (uint8_t ipTtl); |
| 87 virtual uint8_t GetIpTtl (void) const; |
| 88 virtual void SetIpMulticastTtl (uint8_t ipTtl); |
| 89 virtual uint8_t GetIpMulticastTtl (void) const; |
| 90 virtual void SetIpMulticastIf (int32_t ipIf); |
| 91 virtual int32_t GetIpMulticastIf (void) const; |
| 92 virtual void SetIpMulticastLoop (bool loop); |
| 93 virtual bool GetIpMulticastLoop (void) const; |
| 94 virtual void SetMtuDiscover (bool discover); |
| 95 virtual bool GetMtuDiscover (void) const; |
| 96 uint16_t EnterFakeTask (); |
| 97 void LeaveFakeTask (uint16_t pid); |
| 98 void ScheduleTask (EventImpl *event); |
| 99 static void ScheduleTaskTrampoline (void *context); |
| 100 |
| 101 enum SocketErrno m_errno; |
| 102 Ptr<Node> m_node; |
| 103 uint16_t m_family; |
| 104 uint16_t m_socktype; |
| 105 uint16_t m_protocol; |
| 106 bool m_listening; |
| 107 uint16_t m_pid; |
| 108 EventId m_poll; |
| 109 |
| 110 }; |
| 111 |
| 112 } // namespace ns3 |
| 113 |
| 114 #endif /* UDP_SOCKET_IMPL_H */ |
OLD | NEW |