|
|
| 168 |
m_errno = ERROR_NOTCONN; |
168 |
m_errno = ERROR_NOTCONN; |
| 169 |
return -1; |
169 |
return -1; |
| 170 |
} |
170 |
} |
| 171 |
return DoSendTo (p, m_defaultAddress, m_defaultPort); |
171 |
return DoSend (p); |
|
|
172 |
} |
| 173 |
int |
| 174 |
UdpSocket::DoSend (const Packet &p) |
| 175 |
{ |
| 176 |
if (m_endPoint == 0) |
| 177 |
{ |
| 178 |
if (Bind () == -1) |
| 179 |
{ |
| 180 |
NS_ASSERT (m_endPoint == 0); |
| 181 |
return -1; |
| 182 |
} |
| 183 |
NS_ASSERT (m_endPoint != 0); |
| 184 |
} |
| 185 |
if (m_shutdownSend) |
| 186 |
{ |
| 187 |
m_errno = ERROR_SHUTDOWN; |
| 188 |
return -1; |
| 189 |
} |
| 190 |
m_udp->Send (p, m_endPoint->GetLocalAddress (), m_defaultAddress, |
| 191 |
m_endPoint->GetLocalPort (), m_defaultPort); |
| 192 |
NotifyDataSent (p.GetSize ()); |
| 193 |
return 0; |
| 172 |
} |
194 |
} |
| 173 |
int |
195 |
int |
| 174 |
UdpSocket::DoSendTo (const Packet &p, const Address &address) |
196 |
UdpSocket::DoSendTo (const Packet &p, const Address &address) |
|
|
| 195 |
m_errno = ERROR_SHUTDOWN; |
217 |
m_errno = ERROR_SHUTDOWN; |
| 196 |
return -1; |
218 |
return -1; |
| 197 |
} |
219 |
} |
| 198 |
m_udp->Send (p, m_endPoint->GetLocalAddress (), ipv4, |
220 |
|
| 199 |
m_endPoint->GetLocalPort (), port); |
221 |
// Duplicate this functionality from Connect() |
|
|
222 |
// on a per-packet basis for SendTo() -tjkopena |
| 223 |
Ptr<Ipv4> ipv4Interface; |
| 224 |
ipv4Interface = m_node->QueryInterface<Ipv4> (Ipv4::iid); |
| 225 |
Ipv4Address source = ipv4Interface->GetSourceAddress(ipv4); |
| 226 |
|
| 227 |
m_udp->Send (p, source, ipv4, |
| 228 |
m_endPoint->GetLocalPort (), port); |
| 200 |
NotifyDataSent (p.GetSize ()); |
229 |
NotifyDataSent (p.GetSize ()); |
| 201 |
return 0; |
230 |
return 0; |
| 202 |
} |
231 |
} |
| 203 |
int |
232 |
int |
| 204 |
UdpSocket::SendTo(const Address &address, const Packet &p) |
233 |
UdpSocket::SendTo(const Address &address, const Packet &p) |
| 205 |
{ |
234 |
{ |
| 206 |
if (m_connected) |
|
|
| 207 |
{ |
| 208 |
m_errno = ERROR_ISCONN; |
| 209 |
return -1; |
| 210 |
} |
| 211 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
235 |
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
| 212 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
236 |
Ipv4Address ipv4 = transport.GetIpv4 (); |
| 213 |
uint16_t port = transport.GetPort (); |
237 |
uint16_t port = transport.GetPort (); |