27 #include "ns3/ipv6-address.h" |
27 #include "ns3/ipv6-address.h" |
28 #include "ns3/ipv6-header.h" |
28 #include "ns3/ipv6-header.h" |
29 |
29 |
30 namespace ns3 |
30 namespace ns3 |
31 { |
31 { |
32 |
32 |
33 class NetDevice; |
33 class NetDevice; |
34 class Node; |
34 class Node; |
35 |
35 |
36 /** |
36 /** |
37 * \class Ipv6RawSocketImpl |
37 * \class Ipv6RawSocketImpl |
38 * \brief IPv6 raw socket. |
38 * \brief IPv6 raw socket. |
39 */ |
39 */ |
40 class Ipv6RawSocketImpl : public Socket |
40 class Ipv6RawSocketImpl : public Socket |
41 { |
41 { |
42 public: |
42 public: |
43 /** |
43 /** |
44 * \brief Get the type ID of this class. |
44 * \brief Get the type ID of this class. |
45 * \return type ID |
45 * \return type ID |
46 */ |
46 */ |
47 static TypeId GetTypeId (); |
47 static TypeId GetTypeId (); |
48 |
48 |
49 /** |
49 /** |
50 * \brief Constructor. |
50 * \brief Constructor. |
51 */ |
51 */ |
52 Ipv6RawSocketImpl (); |
52 Ipv6RawSocketImpl (); |
53 |
53 |
54 /** |
54 /** |
55 * \brief Destructor. |
55 * \brief Destructor. |
56 */ |
56 */ |
57 virtual ~Ipv6RawSocketImpl (); |
57 virtual ~Ipv6RawSocketImpl (); |
58 |
58 |
59 /** |
59 /** |
60 * \brief Set the node. |
60 * \brief Set the node. |
61 * \param node node to set |
61 * \param node node to set |
62 */ |
62 */ |
63 void SetNode (Ptr<Node> node); |
63 void SetNode (Ptr<Node> node); |
64 |
64 |
65 /** |
65 /** |
66 * \brief Get last error number. |
66 * \brief Get last error number. |
67 * \return error number |
67 * \return error number |
68 */ |
68 */ |
69 virtual enum Socket::SocketErrno GetErrno () const; |
69 virtual enum Socket::SocketErrno GetErrno () const; |
70 |
70 |
71 /** |
71 /** |
72 * \brief Get node. |
72 * \brief Get node. |
73 * \return node associated with this raw socket. |
73 * \return node associated with this raw socket. |
74 */ |
74 */ |
75 virtual Ptr<Node> GetNode () const; |
75 virtual Ptr<Node> GetNode () const; |
76 |
76 |
77 /** |
77 /** |
78 * \brief Bind the socket to address. |
78 * \brief Bind the socket to address. |
79 * \param address bind to this address |
79 * \param address bind to this address |
80 * \return 0 if success, -1 otherwise |
80 * \return 0 if success, -1 otherwise |
81 */ |
81 */ |
82 virtual int Bind (const Address& address); |
82 virtual int Bind (const Address& address); |
83 |
83 |
84 /** |
84 /** |
85 * \brief Bind socket. |
85 * \brief Bind socket. |
86 * \return 0 if success, -1 otherwise |
86 * \return 0 if success, -1 otherwise |
87 */ |
87 */ |
88 virtual int Bind (); |
88 virtual int Bind (); |
89 |
89 |
90 /** |
90 /** |
91 * \brief Get socket address. |
91 * \brief Get socket address. |
92 * \param address socket address if method success |
92 * \param address socket address if method success |
93 * \return 0 if success, -1 otherwise |
93 * \return 0 if success, -1 otherwise |
94 */ |
94 */ |
95 virtual int GetSockName (Address& address) const; |
95 virtual int GetSockName (Address& address) const; |
96 |
96 |
97 /** |
97 /** |
98 * \brief Close the socket. |
98 * \brief Close the socket. |
99 * \return 0 if success, -1 otherwise |
99 * \return 0 if success, -1 otherwise |
100 */ |
100 */ |
101 virtual int Close (); |
101 virtual int Close (); |
102 |
102 |
103 /** |
103 /** |
104 * \brief Shutdown send capability. |
104 * \brief Shutdown send capability. |
105 * \return 0 if success, -1 otherwise |
105 * \return 0 if success, -1 otherwise |
106 */ |
106 */ |
107 virtual int ShutdownSend (); |
107 virtual int ShutdownSend (); |
108 |
108 |
109 /** |
109 /** |
110 * \brief Shutdown receive capability. |
110 * \brief Shutdown receive capability. |
111 * \return 0 if success, -1 otherwise |
111 * \return 0 if success, -1 otherwise |
112 */ |
112 */ |
113 virtual int ShutdownRecv (); |
113 virtual int ShutdownRecv (); |
114 |
114 |
115 /** |
115 /** |
116 * \brief Connect to address. |
116 * \brief Connect to address. |
117 * \param address address |
117 * \param address address |
118 * \return 0 if success, -1 otherwise |
118 * \return 0 if success, -1 otherwise |
119 */ |
119 */ |
120 virtual int Connect (const Address& address); |
120 virtual int Connect (const Address& address); |
121 |
121 |
122 /** |
122 /** |
123 * \brief Listen. |
123 * \brief Listen. |
124 * \return 0 if success, -1 otherwise |
124 * \return 0 if success, -1 otherwise |
125 */ |
125 */ |
126 virtual int Listen (); |
126 virtual int Listen (); |
127 |
127 |
128 /** |
128 /** |
129 * \brief Get TX size available. |
129 * \brief Get TX size available. |
130 * \return TX size |
130 * \return TX size |
131 */ |
131 */ |
132 virtual uint32_t GetTxAvailable () const; |
132 virtual uint32_t GetTxAvailable () const; |
133 |
133 |
134 /** |
134 /** |
135 * \brief Get RX size available. |
135 * \brief Get RX size available. |
136 * \return RX size |
136 * \return RX size |
137 */ |
137 */ |
138 virtual uint32_t GetRxAvailable () const; |
138 virtual uint32_t GetRxAvailable () const; |
139 |
139 |
140 /** |
140 /** |
141 * \brief Send a packet. |
141 * \brief Send a packet. |
142 * \param p packet to send |
142 * \param p packet to send |
143 * \param flags additionnal flags |
143 * \param flags additionnal flags |
144 * \return 0 if success, -1 otherwise |
144 * \return 0 if success, -1 otherwise |
145 */ |
145 */ |
146 virtual int Send (Ptr<Packet> p, uint32_t flags); |
146 virtual int Send (Ptr<Packet> p, uint32_t flags); |
147 |
147 |
148 /** |
148 /** |
149 * \brief Send a packet. |
149 * \brief Send a packet. |
150 * \param p packet to send |
150 * \param p packet to send |
151 * \param flags additionnal flags |
151 * \param flags additionnal flags |
152 * \param toAddress destination address |
152 * \param toAddress destination address |
153 * \return 0 if success, -1 otherwise |
153 * \return 0 if success, -1 otherwise |
154 */ |
154 */ |
155 virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress); |
155 virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress); |
156 |
156 |
157 /** |
157 /** |
158 * \brief Receive packet. |
158 * \brief Receive packet. |
159 * \param maxSize maximum size |
159 * \param maxSize maximum size |
160 * \param flags additionnal flags |
160 * \param flags additionnal flags |
161 * \return packet received |
161 * \return packet received |
162 */ |
162 */ |
163 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
163 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags); |
164 |
164 |
165 /** |
165 /** |
166 * \brief Receive packet. |
166 * \brief Receive packet. |
167 * \param maxSize maximum size |
167 * \param maxSize maximum size |
168 * \param flags additionnal flags |
168 * \param flags additionnal flags |
169 * \param fromAddress source address |
169 * \param fromAddress source address |
170 * \return packet received |
170 * \return packet received |
171 */ |
171 */ |
172 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress); |
172 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress); |
173 |
173 |
174 /** |
174 /** |
175 * \brief Set protocol field. |
175 * \brief Set protocol field. |
176 * \param protocol protocol to set |
176 * \param protocol protocol to set |
177 */ |
177 */ |
178 void SetProtocol (uint16_t protocol); |
178 void SetProtocol (uint16_t protocol); |
179 |
179 |
180 /** |
180 /** |
181 * \brief Forward up to receive method. |
181 * \brief Forward up to receive method. |
182 * \param p packet |
182 * \param p packet |
183 * \param hdr IPv6 header |
183 * \param hdr IPv6 header |
184 * \param device device |
184 * \param device device |
185 * \return true if forwarded, false otherwise |
185 * \return true if forwarded, false otherwise |
186 */ |
186 */ |
187 bool ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device); |
187 bool ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device); |
188 |
188 |
189 private: |
189 private: |
190 /** |
190 /** |
191 * \struct Data |
191 * \struct Data |
192 * \brief IPv6 raw data and additionnal information. |
192 * \brief IPv6 raw data and additionnal information. |
193 */ |
193 */ |
194 struct Data |
194 struct Data |
195 { |
195 { |
196 Ptr<Packet> packet; /**< Packet data */ |
196 Ptr<Packet> packet; /**< Packet data */ |
197 Ipv6Address fromIp; /**< Source address */ |
197 Ipv6Address fromIp; /**< Source address */ |
198 uint16_t fromProtocol; /**< Protocol used */ |
198 uint16_t fromProtocol; /**< Protocol used */ |
199 }; |
199 }; |
200 |
200 |
201 /** |
201 /** |
202 * \brief Dispose object. |
202 * \brief Dispose object. |
203 */ |
203 */ |
204 virtual void DoDispose (); |
204 virtual void DoDispose (); |
205 |
205 |
206 /** |
206 /** |
207 * \brief Last error number. |
207 * \brief Last error number. |
208 */ |
208 */ |
209 enum Socket::SocketErrno m_err; |
209 enum Socket::SocketErrno m_err; |
210 |
210 |
211 /** |
211 /** |
212 * \brief Node. |
212 * \brief Node. |
213 */ |
213 */ |
214 Ptr<Node> m_node; |
214 Ptr<Node> m_node; |
215 |
215 |
216 /** |
216 /** |
217 * \brief Source address. |
217 * \brief Source address. |
218 */ |
218 */ |
219 Ipv6Address m_src; |
219 Ipv6Address m_src; |
220 |
220 |
221 /** |
221 /** |
222 * \brief Destination address. |
222 * \brief Destination address. |
223 */ |
223 */ |
224 Ipv6Address m_dst; |
224 Ipv6Address m_dst; |
225 |
225 |
226 /** |
226 /** |
227 * \brief Protocol. |
227 * \brief Protocol. |
228 */ |
228 */ |
229 uint16_t m_protocol; |
229 uint16_t m_protocol; |
230 |
230 |
231 /** |
231 /** |
232 * \brief Packet waiting to be processed. |
232 * \brief Packet waiting to be processed. |
233 */ |
233 */ |
234 std::list<struct Data> m_data; |
234 std::list<struct Data> m_data; |
235 |
235 |
236 /** |
236 /** |
237 * \brief Flag to shutdown send capability. |
237 * \brief Flag to shutdown send capability. |
238 */ |
238 */ |
239 bool m_shutdownSend; |
239 bool m_shutdownSend; |
240 |
240 |
241 /** |
241 /** |
242 * \brief Flag to shutdown receive capability. |
242 * \brief Flag to shutdown receive capability. |
243 */ |
243 */ |
244 bool m_shutdownRecv; |
244 bool m_shutdownRecv; |
245 |
245 |
246 /** |
246 /** |
247 * \brief ICMPv6 filter. |
247 * \brief ICMPv6 filter. |
248 */ |
248 */ |
249 uint32_t m_icmpFilter; |
249 uint32_t m_icmpFilter; |
250 }; |
250 }; |
251 |
251 |
252 } /* namespace ns3 */ |
252 } /* namespace ns3 */ |
253 |
253 |
254 #endif /* IPV6_RAW_SOCKET_IMPL_H */ |
254 #endif /* IPV6_RAW_SOCKET_IMPL_H */ |