equal
deleted
inserted
replaced
21 |
21 |
22 #include "packet-socket.h" |
22 #include "packet-socket.h" |
23 #include "packet-socket-address.h" |
23 #include "packet-socket-address.h" |
24 #include "ns3/log.h" |
24 #include "ns3/log.h" |
25 #include "ns3/node.h" |
25 #include "ns3/node.h" |
|
26 #include "ns3/packet.h" |
26 |
27 |
27 NS_LOG_COMPONENT_DEFINE ("PacketSocket"); |
28 NS_LOG_COMPONENT_DEFINE ("PacketSocket"); |
28 |
29 |
29 namespace ns3 { |
30 namespace ns3 { |
30 |
31 |
201 NotifyConnectionFailed (); |
202 NotifyConnectionFailed (); |
202 return -1; |
203 return -1; |
203 } |
204 } |
204 |
205 |
205 int |
206 int |
206 PacketSocket::Send (const Packet &p) |
207 PacketSocket::Send (Ptr<Packet> p) |
207 { |
208 { |
208 NS_LOG_FUNCTION; |
209 NS_LOG_FUNCTION; |
209 if (m_state == STATE_OPEN || |
210 if (m_state == STATE_OPEN || |
210 m_state == STATE_BOUND) |
211 m_state == STATE_BOUND) |
211 { |
212 { |
214 } |
215 } |
215 return SendTo (m_destAddr, p); |
216 return SendTo (m_destAddr, p); |
216 } |
217 } |
217 |
218 |
218 int |
219 int |
219 PacketSocket::SendTo(const Address &address, const Packet &p) |
220 PacketSocket::SendTo(const Address &address, Ptr<Packet> p) |
220 { |
221 { |
221 NS_LOG_FUNCTION; |
222 NS_LOG_FUNCTION; |
222 PacketSocketAddress ad; |
223 PacketSocketAddress ad; |
223 if (m_state == STATE_CLOSED) |
224 if (m_state == STATE_CLOSED) |
224 { |
225 { |
264 } |
265 } |
265 } |
266 } |
266 } |
267 } |
267 if (!error) |
268 if (!error) |
268 { |
269 { |
269 NotifyDataSent (p.GetSize ()); |
270 NotifyDataSent (p->GetSize ()); |
270 } |
271 } |
271 |
272 |
272 if (error) |
273 if (error) |
273 { |
274 { |
274 m_errno = ERROR_INVAL; |
275 m_errno = ERROR_INVAL; |
279 return 0; |
280 return 0; |
280 } |
281 } |
281 } |
282 } |
282 |
283 |
283 void |
284 void |
284 PacketSocket::ForwardUp (Ptr<NetDevice> device, const Packet &packet, |
285 PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, |
285 uint16_t protocol, const Address &from) |
286 uint16_t protocol, const Address &from) |
286 { |
287 { |
287 NS_LOG_FUNCTION; |
288 NS_LOG_FUNCTION; |
288 if (m_shutdownRecv) |
289 if (m_shutdownRecv) |
289 { |
290 { |
290 return; |
291 return; |
291 } |
292 } |
292 |
|
293 Packet p = packet; |
|
294 |
293 |
295 PacketSocketAddress address; |
294 PacketSocketAddress address; |
296 address.SetPhysicalAddress (from); |
295 address.SetPhysicalAddress (from); |
297 address.SetSingleDevice (device->GetIfIndex ()); |
296 address.SetSingleDevice (device->GetIfIndex ()); |
298 address.SetProtocol (protocol); |
297 address.SetProtocol (protocol); |
299 |
298 |
300 NS_LOG_LOGIC ("UID is " << packet.GetUid() << " PacketSocket " << this); |
299 NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this); |
301 NotifyDataReceived (p, address); |
300 NotifyDataReceived (packet, address); |
302 } |
301 } |
303 |
302 |
304 }//namespace ns3 |
303 }//namespace ns3 |