Commit f6e6c3b5 authored by Ondřej Zajíček's avatar Ondřej Zajíček

Fix IP_HDRINCL usage on FreeBSD 11

FreeBSD 11 changed endianity of ip_len field from host order to network
order. Also DragonFly BSD allegedly expects network order here.

Thanks to Olivier Cochard-Labbé for the patch.
parent 017da76b
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <net/if_dl.h> #include <net/if_dl.h>
#include <netinet/in_systm.h> // Workaround for some BSDs #include <netinet/in_systm.h> // Workaround for some BSDs
#include <netinet/ip.h> #include <netinet/ip.h>
#include <sys/param.h>
#ifdef __NetBSD__ #ifdef __NetBSD__
...@@ -179,8 +180,8 @@ sk_prepare_ip_header(sock *s, void *hdr, int dlen) ...@@ -179,8 +180,8 @@ sk_prepare_ip_header(sock *s, void *hdr, int dlen)
ip->ip_src = ipa_to_in4(s->saddr); ip->ip_src = ipa_to_in4(s->saddr);
ip->ip_dst = ipa_to_in4(s->daddr); ip->ip_dst = ipa_to_in4(s->daddr);
#ifdef __OpenBSD__ #if (defined __OpenBSD__) || (defined __DragonFly__) || (defined __FreeBSD__ && (__FreeBSD_version >= 1100030))
/* OpenBSD expects ip_len in network order, other BSDs expect host order */ /* Different BSDs have different expectations of ip_len endianity */
ip->ip_len = htons(ip->ip_len); ip->ip_len = htons(ip->ip_len);
#endif #endif
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment