11 namespace ns3 { |
11 namespace ns3 { |
12 |
12 |
13 class NetDevice; |
13 class NetDevice; |
14 class Node; |
14 class Node; |
15 |
15 |
|
16 /** |
|
17 * \class Ipv4RawSocketImpl |
|
18 * \brief IPv4 raw socket. |
|
19 * \ingroup socket |
|
20 * |
|
21 * A RAW Socket typically is used to access specific IP layers not usually |
|
22 * available through L4 sockets, e.g., ICMP. The implementer should take |
|
23 * particular care to define the Ipv4RawSocketImpl Attributes, and in |
|
24 * particular the Protocol attribute. |
|
25 */ |
16 class Ipv4RawSocketImpl : public Socket |
26 class Ipv4RawSocketImpl : public Socket |
17 { |
27 { |
18 public: |
28 public: |
|
29 /** |
|
30 * \brief Get the type ID of this class. |
|
31 * \return type ID |
|
32 */ |
19 static TypeId GetTypeId (void); |
33 static TypeId GetTypeId (void); |
20 |
34 |
21 Ipv4RawSocketImpl (); |
35 Ipv4RawSocketImpl (); |
22 |
36 |
|
37 /** |
|
38 * \brief Set the node associated with this socket. |
|
39 * \param node node to set |
|
40 */ |
23 void SetNode (Ptr<Node> node); |
41 void SetNode (Ptr<Node> node); |
24 |
42 |
25 virtual enum Socket::SocketErrno GetErrno (void) const; |
43 virtual enum Socket::SocketErrno GetErrno () const; |
|
44 |
|
45 /** |
|
46 * \brief Get socket type (NS3_SOCK_RAW) |
|
47 * \return socket type |
|
48 */ |
26 virtual enum Socket::SocketType GetSocketType (void) const; |
49 virtual enum Socket::SocketType GetSocketType (void) const; |
|
50 |
27 virtual Ptr<Node> GetNode (void) const; |
51 virtual Ptr<Node> GetNode (void) const; |
28 virtual int Bind (const Address &address); |
52 virtual int Bind (const Address &address); |
29 virtual int Bind (); |
53 virtual int Bind (); |
30 virtual int Bind6 (); |
54 virtual int Bind6 (); |
31 virtual int GetSockName (Address &address) const; |
55 virtual int GetSockName (Address &address) const; |
41 virtual uint32_t GetRxAvailable (void) const; |
65 virtual uint32_t GetRxAvailable (void) const; |
42 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
66 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
43 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, |
67 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, |
44 Address &fromAddress); |
68 Address &fromAddress); |
45 |
69 |
|
70 |
|
71 /** |
|
72 * \brief Set protocol field. |
|
73 * \param protocol protocol to set |
|
74 */ |
46 void SetProtocol (uint16_t protocol); |
75 void SetProtocol (uint16_t protocol); |
|
76 |
|
77 /** |
|
78 * \brief Forward up to receive method. |
|
79 * \param p packet |
|
80 * \param ipHeader IPv4 header |
|
81 * \param incomingInterface incoming interface |
|
82 * \return true if forwarded, false otherwise |
|
83 */ |
47 bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface); |
84 bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface); |
48 virtual bool SetAllowBroadcast (bool allowBroadcast); |
85 virtual bool SetAllowBroadcast (bool allowBroadcast); |
49 virtual bool GetAllowBroadcast () const; |
86 virtual bool GetAllowBroadcast () const; |
50 |
87 |
51 private: |
88 private: |
52 virtual void DoDispose (void); |
89 virtual void DoDispose (void); |
53 |
90 |
|
91 /** |
|
92 * \struct Data |
|
93 * \brief IPv4 raw data and additional information. |
|
94 */ |
54 struct Data { |
95 struct Data { |
55 Ptr<Packet> packet; |
96 Ptr<Packet> packet; /**< Packet data */ |
56 Ipv4Address fromIp; |
97 Ipv4Address fromIp; /**< Source address */ |
57 uint16_t fromProtocol; |
98 uint16_t fromProtocol; /**< Protocol used */ |
58 }; |
99 }; |
59 |
100 |
60 enum Socket::SocketErrno m_err; |
101 enum Socket::SocketErrno m_err; //!< Last error number. |
61 Ptr<Node> m_node; |
102 Ptr<Node> m_node; //!< Node |
62 Ipv4Address m_src; |
103 Ipv4Address m_src; //!< Source address. |
63 Ipv4Address m_dst; |
104 Ipv4Address m_dst; //!< Destination address. |
64 uint16_t m_protocol; |
105 uint16_t m_protocol; //!< Protocol. |
65 std::list<struct Data> m_recv; |
106 std::list<struct Data> m_recv; //!< Packet waiting to be processed. |
66 bool m_shutdownSend; |
107 bool m_shutdownSend; //!< Flag to shutdown send capability. |
67 bool m_shutdownRecv; |
108 bool m_shutdownRecv; //!< Flag to shutdown receive capability. |
68 uint32_t m_icmpFilter; |
109 uint32_t m_icmpFilter; //!< ICMPv4 filter specification |
69 bool m_iphdrincl; |
110 bool m_iphdrincl; //!< Include IP Header information (a.k.a setsockopt (IP_HDRINCL)) |
70 }; |
111 }; |
71 |
112 |
72 } // namespace ns3 |
113 } // namespace ns3 |
73 |
114 |
74 #endif /* IPV4_RAW_SOCKET_IMPL_H */ |
115 #endif /* IPV4_RAW_SOCKET_IMPL_H */ |