darwin.network_cmds: use default SDK on Darwin (14.4)
This commit is contained in:
@@ -14,6 +14,10 @@ add_global_arguments(
|
||||
'-DUSE_RFC2292BIS=1',
|
||||
'-D__APPLE_USE_RFC_3542=1',
|
||||
'-D__APPLE_API_OBSOLETE=1',
|
||||
# Define flexible array member attribute macros as nothing. Unfortunately, Apple’s usage does not work with
|
||||
# the C23 attributes supported by Clang.
|
||||
'-D__counted_by_or_null(N)=',
|
||||
'-D__sized_by_or_null(N)=',
|
||||
language : 'c',
|
||||
)
|
||||
|
||||
@@ -23,6 +27,8 @@ cc = meson.get_compiler('c')
|
||||
|
||||
libipsec = cc.find_library('ipsec')
|
||||
libresolv = cc.find_library('resolv')
|
||||
libutil = cc.find_library('util')
|
||||
|
||||
libpcap = dependency('pcap')
|
||||
openssl = dependency('openssl')
|
||||
|
||||
@@ -200,7 +206,7 @@ executable(
|
||||
dependencies : [ libnetwork_cmds ],
|
||||
install : true,
|
||||
sources : [
|
||||
# 'netstat.tproj/bpf.c',
|
||||
'netstat.tproj/bpf.c',
|
||||
'netstat.tproj/data.c',
|
||||
'netstat.tproj/if.c',
|
||||
'netstat.tproj/inet.c',
|
||||
@@ -276,29 +282,31 @@ executable(
|
||||
)
|
||||
install_man('route.tproj/route.8')
|
||||
|
||||
# Depends on a bunch of IPv6 stuff from later SDKs (>11.3). Package once those become the default.
|
||||
# executable(
|
||||
# 'rtadvd',
|
||||
# c_args : [
|
||||
# '-DINET6',
|
||||
# '-DHAVE_GETIFADDRS',
|
||||
# ],
|
||||
# install : true,
|
||||
# sources : [
|
||||
# 'rtadvd.tproj/advcap.c',
|
||||
# 'rtadvd.tproj/config.c',
|
||||
# 'rtadvd.tproj/dump.c',
|
||||
# 'rtadvd.tproj/if.c',
|
||||
# 'rtadvd.tproj/rrenum.c',
|
||||
# 'rtadvd.tproj/rtadvd.c',
|
||||
# 'rtadvd.tproj/rtadvd_logging.c',
|
||||
# 'rtadvd.tproj/timer.c',
|
||||
# ],
|
||||
# )
|
||||
# install_man(
|
||||
# 'rtadvd.tproj/rtadvd.8',
|
||||
# 'rtadvd.tproj/rtadvd.conf.5',
|
||||
# )
|
||||
executable(
|
||||
'rtadvd',
|
||||
c_args : [
|
||||
'-DINET6',
|
||||
'-DHAVE_GETIFADDRS',
|
||||
# Required for `_COMM_PAGE_CPU_CAPABILITIES` in <machine/cpu_capabilities.h>
|
||||
'-DPRIVATE',
|
||||
],
|
||||
dependencies : libutil,
|
||||
install : true,
|
||||
sources : [
|
||||
'rtadvd.tproj/advcap.c',
|
||||
'rtadvd.tproj/config.c',
|
||||
'rtadvd.tproj/dump.c',
|
||||
'rtadvd.tproj/if.c',
|
||||
'rtadvd.tproj/rrenum.c',
|
||||
'rtadvd.tproj/rtadvd.c',
|
||||
'rtadvd.tproj/rtadvd_logging.c',
|
||||
'rtadvd.tproj/timer.c',
|
||||
],
|
||||
)
|
||||
install_man(
|
||||
'rtadvd.tproj/rtadvd.8',
|
||||
'rtadvd.tproj/rtadvd.conf.5',
|
||||
)
|
||||
|
||||
executable(
|
||||
'rtsol',
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{
|
||||
lib,
|
||||
apple-sdk,
|
||||
apple-sdk_15,
|
||||
fetchurl,
|
||||
libpcap,
|
||||
libresolv,
|
||||
libutil,
|
||||
mkAppleDerivation,
|
||||
openssl,
|
||||
pkg-config,
|
||||
@@ -12,61 +13,7 @@
|
||||
}:
|
||||
|
||||
let
|
||||
# Newer releases of ifconfig use `ioctls` and undocumented APIs newer than 11.x.
|
||||
# Use files from an older release for now.
|
||||
old_ifconfig = {
|
||||
ifconfig = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/ifconfig.tproj/ifconfig.c";
|
||||
hash = "sha256-yuUpdRHRwYLnivuaQuh8HJdLj/8ppq+K1NFqA8Bg+1k=";
|
||||
};
|
||||
af_inet = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/ifconfig.tproj/af_inet.c";
|
||||
hash = "sha256-sqcCEzhTur43DG6Ac/1Rt8Kx0umWhDzlV58t+6FlzNU=";
|
||||
};
|
||||
af_inet6 = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/ifconfig.tproj/af_inet6.c";
|
||||
hash = "sha256-jp0R0Ncwvp9G/lIzKW6wBTAiO8yNyII5c49feTanbIo=";
|
||||
};
|
||||
af_link = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/ifconfig.tproj/af_link.c";
|
||||
hash = "sha256-5rXJg5azy9SjK675Djt4K1PaczsoVjQ/Lls/u5Kk1+A=";
|
||||
};
|
||||
};
|
||||
|
||||
# Newer releases of netstat use struct members that aren’t present with the 11.x headers.
|
||||
# Use files from an older release for now.
|
||||
old_netstat = {
|
||||
"if.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/if.c";
|
||||
hash = "sha256-P87rexLkoV1BCyUghVrkGoG6r9rAoWynfpvlwIj7A40=";
|
||||
};
|
||||
"main.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/main.c";
|
||||
hash = "sha256-e3n54l6Wo+G5koMhGMfOTo8+QIkJRurr2fBOjg/nFgI=";
|
||||
};
|
||||
"inet.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/inet.c";
|
||||
hash = "sha256-X1+dz+D6xR2Xqoxypjmy65pKBCh4iGVfByJGI0wVGO0=";
|
||||
};
|
||||
"inet6.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/inet6.c";
|
||||
hash = "sha256-av5K1UQE3edUbzKN9FIn/DOeibsJaTZc0xJzDu9VZ5Q=";
|
||||
};
|
||||
"netstat.h" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/netstat.h";
|
||||
hash = "sha256-UYi3lmA8G0wRJqVA2NYyMj0yCBUlxu0gMoMYW7NauJg=";
|
||||
};
|
||||
"unix.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/unix.c";
|
||||
hash = "sha256-txs/mnR4WK8JAUN3PtqZsp6q2h+nx5VFKxI/itCTBNo=";
|
||||
};
|
||||
"systm.c" = fetchurl {
|
||||
url = "https://github.com/apple-oss-distributions/network_cmds/raw/2e18102a14ab72b25caf3a5007c92b9f23e723fc/netstat.tproj/systm.c";
|
||||
hash = "sha256-bISSIsA6OYfkHNOKB4dj9KNLBHfcelGVzwGiYiVqnRM=";
|
||||
};
|
||||
};
|
||||
|
||||
xnu = apple-sdk.sourceRelease "xnu";
|
||||
xnu = apple-sdk_15.sourceRelease "xnu";
|
||||
|
||||
privateHeaders = stdenvNoCC.mkDerivation {
|
||||
name = "network_cmds-deps-private-headers";
|
||||
@@ -84,27 +31,51 @@ let
|
||||
install -D -t "$out/include" \
|
||||
'${xnu}/osfmk/kern/cs_blobs.h'
|
||||
|
||||
install -D -t "$out/firehose" \
|
||||
install -D -t "$out/include/firehose" \
|
||||
'${xnu}/libkern/firehose/firehose_types_private.h' \
|
||||
'${xnu}/libkern/firehose/tracepoint_private.h'
|
||||
|
||||
for dir in arm i386 machine; do
|
||||
mkdir -p "$out/include/$dir"
|
||||
for file in '${xnu}/osfmk/'$dir/*; do
|
||||
name=$(basename "$file")
|
||||
# Skip copying `endian.h` because it conflicts with the SDK, breaking the build on x86_64-darwin.
|
||||
test "$name" != endian.h && cp -r "$file" "$out/include/$dir/$name"
|
||||
done
|
||||
done
|
||||
|
||||
install -D -t "$out/include/net" \
|
||||
'${xnu}/bsd/net/droptap.h' \
|
||||
'${xnu}/bsd/net/if_bond_internal.h' \
|
||||
'${xnu}/bsd/net/if_bond_var.h' \
|
||||
'${xnu}/bsd/net/if_fake_var.h' \
|
||||
'${xnu}/bsd/net/if_mib_private.h' \
|
||||
'${xnu}/bsd/net/if_var_private.h' \
|
||||
'${xnu}/bsd/net/if_vlan_var.h' \
|
||||
'${xnu}/bsd/net/lacp.h' \
|
||||
'${xnu}/bsd/net/net_perf.h'
|
||||
mkdir -p "$out/include/net/classq" "$out/include/net/pktsched"
|
||||
|
||||
cat <<EOF > "$out/include/net/bpf.h"
|
||||
#pragma once
|
||||
#include_next <net/bpf.h>
|
||||
#include <net/if.h>
|
||||
$(sed -n \
|
||||
-e '/^#define BPF_D_/p' \
|
||||
-e '/^struct xbpf_d\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/net/bpf.h')
|
||||
EOF
|
||||
|
||||
# IFNET constants are defined as enums, so they have to be pre-processed and grepped from the file.
|
||||
cat <<EOF > "$out/include/net/if.h"
|
||||
#pragma once
|
||||
#include <uuid/uuid.h>
|
||||
$(sed \
|
||||
-e 's/^\s*\(IFNET_[^=]*\)=\s*\([^,]*\),*/#define \1\2/' \
|
||||
'${xnu}/bsd/net/if.h' | grep '^#define IFNET_')
|
||||
'${xnu}/bsd/net/if_private.h' | grep '^#define IFNET_')
|
||||
#include_next <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
typedef void* ifnet_t;
|
||||
#define ifreq ifreq_private
|
||||
$(sed -n \
|
||||
-e '/^#define IFEF_TXSTART/p' \
|
||||
@@ -130,10 +101,9 @@ let
|
||||
-e '/^struct if_throttlereq\s*{/,/^};/p' \
|
||||
-e '/^struct ipv6_prefix\s*{/,/^};/p' \
|
||||
-e '/^struct ifreq\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/net/if.h')
|
||||
'${xnu}/bsd/net/if_private.h')
|
||||
#undef ifreq
|
||||
EOF
|
||||
unifdef -x 1 -DPRIVATE -m "$out/include/net/if.h"
|
||||
|
||||
cat <<EOF > "$out/include/net/content_filter.h"
|
||||
#pragma once
|
||||
@@ -143,21 +113,10 @@ let
|
||||
|
||||
cat <<EOF > "$out/include/net/if_var.h"
|
||||
#pragma once
|
||||
#include <net/if_var_private.h>
|
||||
#define IF_NETEM_MODEL_IOD 2
|
||||
#define IF_NETEM_MODEL_FPD 3
|
||||
#include_next <net/if_var.h>
|
||||
$(sed -n \
|
||||
-e '/^#define IFNAMSIZ\s/p' \
|
||||
-e '/^#define IF_NETEM/p' \
|
||||
-e '/^struct if_bandwidths\s*{/,/^};/p' \
|
||||
-e '/^struct if_data_extended\s*{/,/^};/p' \
|
||||
-e '/^struct if_interface_state\s*{/,/^};/p' \
|
||||
-e '/^struct if_latencies\s*{/,/^};/p' \
|
||||
-e '/^struct if_linkparamsreq\s*{/,/^};/p' \
|
||||
-e '/^struct if_netem_params\s*{/,/^};/p' \
|
||||
-e '/^struct if_netif_stats\s*{/,/^};/p' \
|
||||
-e '/^struct if_packet_stats\s*{/,/^};/p' \
|
||||
-e '/^struct if_rxpoll_stats\s*{/,/^};/p' \
|
||||
-e '/^struct if_traffic_class\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/net/if_var.h')
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$out/include/net/route.h"
|
||||
@@ -166,11 +125,13 @@ let
|
||||
$(sed -n \
|
||||
-e '/^struct rt_msghdr_ext\s*{/,/^};/p' \
|
||||
-e '/^struct rt_reach_info\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/net/route.h')
|
||||
-e '/^struct rtstat_64\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/net/route_private.h')
|
||||
EOF
|
||||
ln -s "$out/include/net/route.h" "$out/include/net/route_private.h"
|
||||
|
||||
install -D -t "$out/include/netinet" \
|
||||
'${xnu}/bsd/netinet/icmp6.h' \
|
||||
'${xnu}/bsd/netinet/ip_flowid.h'
|
||||
|
||||
cat <<EOF > "$out/include/netinet/in.h"
|
||||
@@ -180,7 +141,7 @@ let
|
||||
-e '/^#define _DSCP/p' \
|
||||
-e '/^#define IP_NO/p' \
|
||||
-e '/^union sockaddr_in_4_6\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/netinet/in.h')
|
||||
'${xnu}/bsd/netinet/in_private.h')
|
||||
#include <uuid/uuid.h>
|
||||
EOF
|
||||
|
||||
@@ -190,7 +151,7 @@ let
|
||||
-e '/^struct tcp_info\s*{/,/^};/p' \
|
||||
-e '/^struct tcp_conn_status\s*{/,/^};/p' \
|
||||
-e '/^typedef struct conninfo_tcp\s*{/,/} conninfo_tcp_t;/p' \
|
||||
'${xnu}/bsd/netinet/tcp.h')
|
||||
'${xnu}/bsd/netinet/tcp_private.h')
|
||||
#include_next <netinet/tcp.h>
|
||||
EOF
|
||||
|
||||
@@ -202,7 +163,7 @@ let
|
||||
#pragma once
|
||||
$(sed -n \
|
||||
-e '/^#define IPV6_/p' \
|
||||
'${xnu}/bsd/netinet6/in6.h')
|
||||
'${xnu}/bsd/netinet6/in6_private.h')
|
||||
#include_next <netinet6/in6.h>
|
||||
EOF
|
||||
|
||||
@@ -228,6 +189,9 @@ let
|
||||
EOF
|
||||
|
||||
install -D -t "$out/include/os" \
|
||||
'${xnu}/libkern/os/atomic_private.h' \
|
||||
'${xnu}/libkern/os/atomic_private_arch.h' \
|
||||
'${xnu}/libkern/os/atomic_private_impl.h' \
|
||||
'${xnu}/libkern/os/log_private.h'
|
||||
|
||||
declare -a privateHeaders=(
|
||||
@@ -286,25 +250,28 @@ let
|
||||
#pragma once
|
||||
#include <sys/param.h>
|
||||
#include <sys/_types/_socklen_t.h>
|
||||
$(sed -n \
|
||||
-e '/^typedef.*sae_associd_t/p' \
|
||||
-e '/^typedef.*sae_connid_t/p' \
|
||||
'${xnu}/bsd/sys/socket.h')
|
||||
$(sed -n \
|
||||
-e '/^#define AF_MULTIPATH\s/p' \
|
||||
-e '/^#define CIAUX_TCP\s/p' \
|
||||
-e '/^#define NET_RT_/p' \
|
||||
-e '/^#define SO_RECV/p' \
|
||||
-e '/^#define SO_TRAFFIC_CLASS\s/,/^#define SO_TC_MAX/p' \
|
||||
-e '/^typedef.*sae_associd_t/p' \
|
||||
-e '/^typedef.*sae_connid_t/p' \
|
||||
-e '/^struct so_aidreq\s*{/,/^};/p' \
|
||||
-e '/^struct so_cidreq\s*{/,/^};/p' \
|
||||
-e '/^struct so_cinforeq\s*{/,/^};/p' \
|
||||
-e '/^struct so_cordreq\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/sys/socket.h')
|
||||
'${xnu}/bsd/sys/socket_private.h')
|
||||
#include_next <sys/socket.h>
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$out/include/sys/socketvar.h"
|
||||
#pragma once
|
||||
$(sed -n \
|
||||
-e '/^#define SO_STATS_/p' \
|
||||
-e '/^#define SO_TC_STATS_MAX\s/p' \
|
||||
-e '/^#define XSO_/p' \
|
||||
-e '/^struct data_stats\s*{/,/^};/p' \
|
||||
@@ -312,6 +279,7 @@ let
|
||||
-e '/^struct xsocket_n\s*{/,/^};/p' \
|
||||
-e '/^struct xsockbuf_n\s*{/,/^};/p' \
|
||||
-e '/^struct xsockstat_n\s*{/,/^};/p' \
|
||||
-e '/^typedef.*so_gen_t;/p' \
|
||||
'${xnu}/bsd/sys/socketvar.h')
|
||||
#include_next <sys/socketvar.h>
|
||||
EOF
|
||||
@@ -343,12 +311,15 @@ let
|
||||
-e '/^#define SIOCGIFTIMESTAMPENABLED\s/p' \
|
||||
-e '/^#define SIOCGIFTYPE\s/p' \
|
||||
-e '/^#define SIOCGIFXFLAGS\s/p' \
|
||||
-e '/^#define SIOCGQOSMARKINGENABLED\s/p' \
|
||||
-e '/^#define SIOCGQOSMARKINGMODE\s/p' \
|
||||
-e '/^#define SIOCGSTARTDELAY\s/p' \
|
||||
-e '/^#define SIOCSECNMODE\s/p' \
|
||||
-e '/^#define SIOCSETROUTERMODE\s/p' \
|
||||
-e '/^#define SIOCSFASTLANECAPABLE\s/p' \
|
||||
-e '/^#define SIOCSFASTLEENABLED\s/p' \
|
||||
-e '/^#define SIOCSIF2KCL\s/p' \
|
||||
-e '/^#define SIOCSIFCONSTRAINED\s/p' \
|
||||
-e '/^#define SIOCSIFDESC\s/p' \
|
||||
-e '/^#define SIOCSIFDISABLEOUTPUT\s/p' \
|
||||
-e '/^#define SIOCSIFEXPENSIVE\s/p' \
|
||||
@@ -356,7 +327,11 @@ let
|
||||
-e '/^#define SIOCSIFLINKPARAMS\s/p' \
|
||||
-e '/^#define SIOCSIFLOG\s/p' \
|
||||
-e '/^#define SIOCSIFLOWPOWER\s/p' \
|
||||
-e '/^#define SIOCSIFMARKWAKEPKT\s/p' \
|
||||
-e '/^#define SIOCSIFMPKLOG\s/p' \
|
||||
-e '/^#define SIOCSIFNOACKPRIO\s/p' \
|
||||
-e '/^#define SIOCSIFNOTRAFFICSHAPING\s/p' \
|
||||
-e '/^#define SIOCSIFDISABLEINPUT\s/p' \
|
||||
-e '/^#define SIOCSIFPROBECONNECTIVITY\s/p' \
|
||||
-e '/^#define SIOCSIFSUBFAMILY\s/p' \
|
||||
-e '/^#define SIOCSIFTHROTTLE\s/p' \
|
||||
@@ -364,7 +339,7 @@ let
|
||||
-e '/^#define SIOCSIFTIMESTAMPENABLE\s/p' \
|
||||
-e '/^#define SIOCSQOSMARKINGENABLED\s/p' \
|
||||
-e '/^#define SIOCSQOSMARKINGMODE\s/p' \
|
||||
'${xnu}/bsd/sys/sockio.h')
|
||||
'${xnu}/bsd/sys/sockio_private.h')
|
||||
#undef ifreq
|
||||
#include_next <sys/sockio.h>
|
||||
EOF
|
||||
@@ -388,10 +363,16 @@ let
|
||||
cat <<EOF > "$out/include/sys/unpcb.h"
|
||||
#pragma once
|
||||
#include_next <sys/unpcb.h>
|
||||
#define KERNEL
|
||||
#ifdef KERNEL
|
||||
$(sed -n \
|
||||
-e '/^struct unpcb_compat\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/sys/unpcb.h')
|
||||
#undef KERNEL
|
||||
$(sed -n \
|
||||
-e '/^#define xu_addr/p' \
|
||||
-e '/^struct xunpcb64_list_entry\s*{/,/^};/p' \
|
||||
-e '/^struct xunpcb64\s*{/,/^};/p' \
|
||||
-e '/^struct *xunpcb\(64\|_n\)_list_entry\s*{/,/^};/p' \
|
||||
-e '/^struct *xunpcb\(64\|_n\)\s*{/,/^};/p' \
|
||||
'${xnu}/bsd/sys/unpcb.h')
|
||||
'';
|
||||
};
|
||||
@@ -416,15 +397,6 @@ mkAppleDerivation {
|
||||
# Fix invalid pointer conversion error from trying to pass `NULL` to a `size_t`.
|
||||
substituteInPlace ndp.tproj/ndp.c --replace-fail 'NULL, NULL);' 'NULL, 0);'
|
||||
|
||||
# Copy older files that are more compatible with the current SDK.
|
||||
${lib.concatLines (
|
||||
lib.mapAttrsToList (name: path: "cp '${path}' 'ifconfig.tproj/${name}.c'") old_ifconfig
|
||||
)}
|
||||
|
||||
${lib.concatLines (
|
||||
lib.mapAttrsToList (name: path: "cp '${path}' 'netstat.tproj/${name}'") old_netstat
|
||||
)}
|
||||
|
||||
# Use private struct ifreq instead of the one defined in the system header.
|
||||
substituteInPlace ifconfig.tproj/ifconfig.c \
|
||||
--replace-fail $'struct\tifreq' 'struct ifreq' \
|
||||
@@ -449,6 +421,7 @@ mkAppleDerivation {
|
||||
buildInputs = [
|
||||
libpcap
|
||||
libresolv
|
||||
libutil
|
||||
openssl
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user