Skip to content

Commit 43ff116

Browse files
committed
Handle BSD vs GLIBC differences in udp.h
1 parent 021c37d commit 43ff116

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/udpreplay.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,22 @@ int main(int argc, char *argv[]) {
222222
}
223223
}
224224

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

229233
sockaddr_in addr;
230234
memset(&addr, 0, sizeof(addr));
231235
addr.sin_family = AF_INET;
236+
#ifdef __GLIBC__
237+
addr.sin_port = udp->dest;
238+
#else
232239
addr.sin_port = udp->uh_dport;
240+
#endif
233241
addr.sin_addr = {ip->ip_dst};
234242
auto n = sendto(fd, d, len, 0, reinterpret_cast<sockaddr *>(&addr),
235243
sizeof(addr));

0 commit comments

Comments
 (0)