Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/udpreplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ int main(int argc, char *argv[]) {
}
}

#ifdef __GLIBC__
ssize_t len = ntohs(udp->len) - 8;
#else
ssize_t len = ntohs(udp->uh_ulen) - 8;
#endif
const u_char *d =
&p[sizeof(ether_header) + ip->ip_hl * 4 + sizeof(udphdr)];

sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
#ifdef __GLIBC__
addr.sin_port = udp->dest;
#else
addr.sin_port = udp->uh_dport;
#endif
addr.sin_addr = {ip->ip_dst};
auto n = sendto(fd, d, len, 0, reinterpret_cast<sockaddr *>(&addr),
sizeof(addr));
Expand Down