Commit 922e2caf authored by Alessandro Rubini's avatar Alessandro Rubini

general: avoid linux/ includes when possible

Building with musl was spitting errors for redefined data structures.
Use the standard headers when available (I found not alternatives to
linux/if_packet.h, but it spits no error).

Then, ifr.ifr_data is "caddr_t" not "void *" in musl, so cast the
pointer being assigned to silent a warning.

Finally, the fields of udphdr in musl use different names unless wi
add _GNU_SOURCE -- most likely musl is more posixly-correct, I didn't check.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent bdf91710
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <sys/select.h> #include <sys/select.h>
#include <linux/if_ether.h> #include <netinet/if_ether.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <common-fun.h> #include <common-fun.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <sys/select.h> #include <sys/select.h>
#include <linux/if_ether.h> #include <netinet/if_ether.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <common-fun.h> #include <common-fun.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <sys/select.h> #include <sys/select.h>
#include <linux/if_ether.h> #include <netinet/if_ether.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <ppsi-wrs.h> #include <ppsi-wrs.h>
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <linux/if_packet.h> #include <linux/if_packet.h>
#include <linux/if_ether.h> #include <netinet/if_ether.h>
#include <linux/if_arp.h> #include <net/if_arp.h>
#include <net/if.h>
#include <linux/net_tstamp.h> #include <linux/net_tstamp.h>
#include <linux/sockios.h> #include <linux/sockios.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -588,7 +589,7 @@ static int wrs_enable_timestamps(struct pp_instance *ppi, int fd) ...@@ -588,7 +589,7 @@ static int wrs_enable_timestamps(struct pp_instance *ppi, int fd)
strncpy(ifr.ifr_name, ppi->iface_name, sizeof(ifr.ifr_name)); strncpy(ifr.ifr_name, ppi->iface_name, sizeof(ifr.ifr_name));
hwconfig.tx_type = HWTSTAMP_TX_ON; hwconfig.tx_type = HWTSTAMP_TX_ON;
hwconfig.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; hwconfig.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
ifr.ifr_data = &hwconfig; ifr.ifr_data = (void *)&hwconfig;
if (ioctl(fd, SIOCSHWTSTAMP, &ifr) < 0) { if (ioctl(fd, SIOCSHWTSTAMP, &ifr) < 0) {
pp_diag(ppi, frames, 1, pp_diag(ppi, frames, 1,
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#define _GNU_SOURCE /* Needed with libmusl to have the udphdr we expect */
#include <net/if.h> #include <net/if.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <netinet/udp.h> #include <netinet/udp.h>
#include <linux/if_ether.h> #include <netinet/if_ether.h>
#include <linux/if_packet.h> #include <linux/if_packet.h>
#include <net/if_arp.h> #include <net/if_arp.h>
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#if __STDC_HOSTED__ #if __STDC_HOSTED__
#define _GNU_SOURCE /* Needed with libmusl to have the udphdr we expect */
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <netinet/ip.h> /* struct iphdr */ #include <netinet/ip.h> /* struct iphdr */
#include <netinet/udp.h> /* struct udphdr */ #include <netinet/udp.h> /* struct udphdr */
#include <linux/if_ether.h> /* struct ethhdr */ #include <netinet/if_ether.h> /* struct ethhdr */
#else #else
#include "../lib/network_types.h" #include "../lib/network_types.h"
#define printf pp_printf #define printf pp_printf
......
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