OLD | NEW |
1 #include "ipv4-raw-socket-impl.h" | 1 #include "ipv4-raw-socket-impl.h" |
2 #include "ipv4-l3-protocol.h" | 2 #include "ipv4-l3-protocol.h" |
3 #include "icmpv4.h" | 3 #include "icmpv4.h" |
4 #include "ns3/inet-socket-address.h" | 4 #include "ns3/inet-socket-address.h" |
5 #include "ns3/node.h" | 5 #include "ns3/node.h" |
6 #include "ns3/packet.h" | 6 #include "ns3/packet.h" |
7 #include "ns3/uinteger.h" | 7 #include "ns3/uinteger.h" |
8 #include "ns3/log.h" | 8 #include "ns3/log.h" |
9 | 9 |
10 NS_LOG_COMPONENT_DEFINE ("Ipv4RawSocketImpl"); | 10 NS_LOG_COMPONENT_DEFINE ("Ipv4RawSocketImpl"); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 m_err = Socket::ERROR_INVAL; | 163 m_err = Socket::ERROR_INVAL; |
164 return -1; | 164 return -1; |
165 } | 165 } |
166 if (m_shutdownSend) | 166 if (m_shutdownSend) |
167 { | 167 { |
168 return 0; | 168 return 0; |
169 } | 169 } |
170 InetSocketAddress ad = InetSocketAddress::ConvertFrom (toAddress); | 170 InetSocketAddress ad = InetSocketAddress::ConvertFrom (toAddress); |
171 Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); | 171 Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); |
172 Ipv4Address dst = ad.GetIpv4 (); | 172 Ipv4Address dst = ad.GetIpv4 (); |
173 uint32_t localInterface; | 173 if (ipv4->GetRoutingProtocol ()) |
174 if (ipv4->GetInterfaceForDestination(dst, localInterface)) | |
175 { | 174 { |
176 ipv4->Send (p, ipv4->GetSourceAddress (dst), dst, m_protocol); | 175 Ipv4Header header; |
177 } | 176 header.SetDestination (dst); |
178 else | 177 SocketErrno errno = ERROR_NOTERROR;; |
179 { | 178 Ptr<Ipv4Route> route; |
180 NS_LOG_DEBUG ("dropped because no outgoing route."); | 179 uint32_t oif = 0; //specify non-zero if bound to a source address |
| 180 // TBD-- we could cache the route and just check its validity |
| 181 route = ipv4->GetRoutingProtocol ()->RouteOutput (header, oif, errno); |
| 182 if (route != 0) |
| 183 { |
| 184 NS_LOG_LOGIC ("Route exists"); |
| 185 ipv4->Send (p, route->GetSource (), dst, m_protocol, route); |
| 186 } |
| 187 else |
| 188 { |
| 189 NS_LOG_DEBUG ("dropped because no outgoing route."); |
| 190 } |
181 } | 191 } |
182 return 0; | 192 return 0; |
183 } | 193 } |
184 uint32_t· | 194 uint32_t· |
185 Ipv4RawSocketImpl::GetRxAvailable (void) const | 195 Ipv4RawSocketImpl::GetRxAvailable (void) const |
186 { | 196 { |
187 NS_LOG_FUNCTION (this); | 197 NS_LOG_FUNCTION (this); |
188 uint32_t rx = 0; | 198 uint32_t rx = 0; |
189 for (std::list<Data>::const_iterator i = m_recv.begin (); i != m_recv.end ();
++i) | 199 for (std::list<Data>::const_iterator i = m_recv.begin (); i != m_recv.end ();
++i) |
190 { | 200 { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 data.fromIp = ipHeader.GetSource (); | 270 data.fromIp = ipHeader.GetSource (); |
261 data.fromProtocol = ipHeader.GetProtocol (); | 271 data.fromProtocol = ipHeader.GetProtocol (); |
262 m_recv.push_back (data); | 272 m_recv.push_back (data); |
263 NotifyDataRecv (); | 273 NotifyDataRecv (); |
264 return true; | 274 return true; |
265 } | 275 } |
266 return false; | 276 return false; |
267 } | 277 } |
268 | 278 |
269 } // namespace ns3 | 279 } // namespace ns3 |
OLD | NEW |