|
|
| 39 |
#include <dlfcn.h> |
39 |
#include <dlfcn.h> |
| 40 |
#include <iomanip> |
40 |
#include <iomanip> |
| 41 |
|
41 |
|
| 42 |
#include <netinet/ip.h> |
42 |
#include <arpa/inet.h> // ntohl/htonl |
| 43 |
#include <netinet/tcp.h> |
43 |
#include <netinet/in.h> // "Some systems require the inclusion of <netinet/in.h> instead" (man byteorder(3)) |
| 44 |
|
44 |
|
| 45 |
NS_LOG_COMPONENT_DEFINE ("NscTcpL4Protocol"); |
45 |
NS_LOG_COMPONENT_DEFINE ("NscTcpL4Protocol"); |
| 46 |
|
46 |
|
|
|
| 314 |
void NscTcpL4Protocol::send_callback(const void* data, int datalen) |
314 |
void NscTcpL4Protocol::send_callback(const void* data, int datalen) |
| 315 |
{ |
315 |
{ |
| 316 |
Ptr<Packet> p; |
316 |
Ptr<Packet> p; |
|
|
317 |
const uint32_t *ipHdr = reinterpret_cast<const uint32_t *>(data); |
| 318 |
const uint8_t *rawdata = reinterpret_cast<const uint8_t *>(data); |
| 317 |
|
319 |
|
| 318 |
NS_ASSERT(datalen > (int)sizeof(struct iphdr)); |
320 |
NS_ASSERT (datalen > 20); |
| 319 |
|
321 |
rawdata += 20; // skips stacks IP header |
| 320 |
const uint8_t *rawdata = reinterpret_cast<const uint8_t *>(data); |
|
|
| 321 |
rawdata += sizeof(struct iphdr); |
| 322 |
|
| 323 |
const struct iphdr *ipHdr = reinterpret_cast<const struct iphdr *>(data); |
| 324 |
|
322 |
|
| 325 |
// create packet, without IP header. The TCP header is not touched. |
323 |
// create packet, without IP header. The TCP header is not touched. |
| 326 |
// Not using the IP header makes integration easier, but it destroys |
324 |
// Not using the IP header makes integration easier, but it destroys |
| 327 |
// eg. ECN. |
325 |
// eg. ECN. |
| 328 |
p = Create<Packet> (rawdata, datalen - sizeof(struct iphdr)); |
326 |
p = Create<Packet> (rawdata, datalen - 20); |
| 329 |
|
327 |
|
| 330 |
Ipv4Address saddr(ntohl(ipHdr->saddr)); |
328 |
Ipv4Address saddr(ntohl(ipHdr[3])); |
| 331 |
Ipv4Address daddr(ntohl(ipHdr->daddr)); |
329 |
Ipv4Address daddr(ntohl(ipHdr[4])); |
| 332 |
|
330 |
|
| 333 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); |
331 |
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> (); |
| 334 |
if (ipv4 != 0) |
332 |
if (ipv4 != 0) |