aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-05-23 11:50:26 -0400
committerCameron Katri <me@cameronkatri.com>2021-05-23 11:50:26 -0400
commita5d67cf8b3beb8310964dc989d6bc95ac6503fe9 (patch)
tree0e537152aae6cb5bc568f45e4c04adf43bdd7b3f
parent5daaae50763dba0e91d9f80d4b341ee413d22796 (diff)
downloadapple_cmds-a5d67cf8b3beb8310964dc989d6bc95ac6503fe9.tar.gz
apple_cmds-a5d67cf8b3beb8310964dc989d6bc95ac6503fe9.tar.zst
apple_cmds-a5d67cf8b3beb8310964dc989d6bc95ac6503fe9.zip
network_cmds: Fix compilation for lower targets
-rw-r--r--network_cmds/Makefile10
-rw-r--r--network_cmds/ifconfig.tproj/if6lowpan.c2
-rw-r--r--network_cmds/ifconfig.tproj/ifbridge.c8
-rw-r--r--network_cmds/ifconfig.tproj/ifconfig.c30
-rw-r--r--network_cmds/ifconfig.tproj/ifmedia.c4
-rw-r--r--network_cmds/ifconfig.tproj/nexus.c5
-rw-r--r--network_cmds/ndp.tproj/ndp.c2
7 files changed, 60 insertions, 1 deletions
diff --git a/network_cmds/Makefile b/network_cmds/Makefile
index 4d21c8e..296ddb4 100644
--- a/network_cmds/Makefile
+++ b/network_cmds/Makefile
@@ -10,7 +10,6 @@ SUBDIR= arp.tproj \
mptcp_client \
mtest.tproj \
ndp.tproj \
- netstat.tproj \
ping.tproj \
ping6.tproj \
pktapctl \
@@ -23,4 +22,13 @@ SUBDIR= arp.tproj \
traceroute.tproj \
traceroute6.tproj
+.if !defined(MK_NETSTAT)
+MK_NETSTAT=no
+.endif
+
+# netstat doesnt build on iOS 12, if building for higher set MK_NETSTAT to yes
+.if ${MK_NETSTAT} == "yes"
+SUBDIR+= netstat.tproj
+.endif
+
.include <bsd.subdir.mk>
diff --git a/network_cmds/ifconfig.tproj/if6lowpan.c b/network_cmds/ifconfig.tproj/if6lowpan.c
index f0f4b2e..ee63896 100644
--- a/network_cmds/ifconfig.tproj/if6lowpan.c
+++ b/network_cmds/ifconfig.tproj/if6lowpan.c
@@ -58,6 +58,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -176,3 +177,4 @@ sixlowpan_ctor(void)
callback_register(sixlowpan_clone_cb, NULL);
#undef N
}
+#endif
diff --git a/network_cmds/ifconfig.tproj/ifbridge.c b/network_cmds/ifconfig.tproj/ifbridge.c
index 951c56b..19ce8ff 100644
--- a/network_cmds/ifconfig.tproj/ifbridge.c
+++ b/network_cmds/ifconfig.tproj/ifbridge.c
@@ -300,6 +300,7 @@ bridge_addresses(int s, const char *prefix)
}
#define MAX_IPv6_STR_LEN INET6_ADDRSTRLEN
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
static void
bridge_mac_nat(int s, const char *prefix)
{
@@ -348,6 +349,7 @@ bridge_mac_nat(int s, const char *prefix)
}
free(buf);
}
+#endif
static void
bridge_status(int s)
@@ -399,7 +401,9 @@ bridge_status(int s)
if (!all || verbose > 1) {
printf("\tAddress cache:\n");
bridge_addresses(s, "\t\t");
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
bridge_mac_nat(s, "\t\t");
+#endif
}
return;
@@ -865,6 +869,7 @@ unsetbridge_hostfilter(const char *ifn, int d, int s, const struct afswtch *afp)
err(1, "BRDGSHOSTFILTER");
}
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
static void
setbridge_macnat(const char *val, int d, int s, const struct afswtch *afp)
{
@@ -878,6 +883,7 @@ unsetbridge_macnat(const char *val, int d, int s, const struct afswtch *afp)
do_bridgeflag(s, val, IFBIF_MAC_NAT, 0);
}
+#endif
static struct cmd bridge_cmds[] = {
DEF_CMD_ARG("addm", setbridge_add),
@@ -930,8 +936,10 @@ static struct cmd bridge_cmds[] = {
#endif
DEF_CMD_ARG2("hostfilter", setbridge_hostfilter),
DEF_CMD_ARG("-hostfilter", unsetbridge_hostfilter),
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
DEF_CMD_ARG("macnat", setbridge_macnat),
DEF_CMD_ARG("-macnat", unsetbridge_macnat),
+#endif
};
static struct afswtch af_bridge = {
.af_name = "af_bridge",
diff --git a/network_cmds/ifconfig.tproj/ifconfig.c b/network_cmds/ifconfig.tproj/ifconfig.c
index 3449301..3acc59c 100644
--- a/network_cmds/ifconfig.tproj/ifconfig.c
+++ b/network_cmds/ifconfig.tproj/ifconfig.c
@@ -109,6 +109,10 @@ __unused static const char copyright[] =
#include <TargetConditionals.h>
#endif
+#ifndef IF_NETEM_PARAMS_PSCALE
+#define IF_NETEM_PARAMS_PSCALE 100000
+#endif
+
/*
* Since "struct ifreq" is composed of various union members, callers
* should pay special attention to interprete the value.
@@ -935,6 +939,7 @@ settbr(const char *val, int dummy __unused, int s, const struct afswtch *afp)
}
}
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
static int
get_int64(uint64_t *i, char const *s)
{
@@ -1255,6 +1260,7 @@ bad_args:
"\t\tnetem\n\n");
return (-1);
}
+#endif
static void
setthrottle(const char *val, int dummy __unused, int s,
@@ -1363,6 +1369,7 @@ setconstrained(const char *vname, int value, int s, const struct afswtch *afp)
}
#endif
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
static void
setifmpklog(const char *vname, int value, int s, const struct afswtch *afp)
{
@@ -1372,6 +1379,7 @@ setifmpklog(const char *vname, int value, int s, const struct afswtch *afp)
if (ioctl(s, SIOCSIFMPKLOG, (caddr_t)&ifr) < 0)
Perror(vname);
}
+#endif
void
settimestamp(const char *vname, int value, int s, const struct afswtch *afp)
@@ -1441,8 +1449,10 @@ setqosmarking(const char *cmd, const char *arg, int s, const struct afswtch *afp
if (strcmp(arg, "fastlane") == 0)
ifr.ifr_qosmarking_mode = IFRTYPE_QOSMARKING_FASTLANE;
+#if defined(IFRTYPE_QOSMARKING_RFC4594)
else if (strcmp(arg, "rfc4594") == 0)
ifr.ifr_qosmarking_mode = IFRTYPE_QOSMARKING_RFC4594;
+#endif
else if (strcasecmp(arg, "none") == 0 || strcasecmp(arg, "off") == 0)
ifr.ifr_qosmarking_mode = IFRTYPE_QOSMARKING_MODE_NONE;
else
@@ -1567,6 +1577,7 @@ setlowpowermode(const char *vname, int value, int s, const struct afswtch *afp)
Perror(vname);
}
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
struct str2num {
const char *str;
uint32_t num;
@@ -1633,6 +1644,7 @@ setifavailability(const char *vname, int value, int s, const struct afswtch *afp
if (ioctl(s, SIOCSIFINTERFACESTATE, (caddr_t)&ifr) < 0)
warn("ioctl(SIOCSIFINTERFACESTATE)");
}
+#endif
static void
show_routermode(int s)
@@ -1750,11 +1762,13 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
putchar('\n');
}
+#if defined(SIOCGIFXFLAGS)
if (verbose && ioctl(s, SIOCGIFXFLAGS, (caddr_t)&ifr) != -1 &&
(xflags = ifr.ifr_xflags) != 0) {
printb("\txflags", xflags, IFXFBITS);
putchar('\n');
}
+#endif
if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
if (ifr.ifr_curcap != 0) {
@@ -2116,9 +2130,11 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
case IFRTYPE_QOSMARKING_FASTLANE:
printf("fastlane\n");
break;
+#if defined(IFRTYPE_QOSMARKING_RFC4594)
case IFRTYPE_QOSMARKING_RFC4594:
printf("RFC4594\n");
break;
+#endif
case IFRTYPE_QOSMARKING_MODE_NONE:
printf("none\n");
break;
@@ -2134,10 +2150,12 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
printf("\tlow power mode: %s\n",
(ifr.ifr_low_power_mode != 0) ? "enabled" : "disabled");
}
+#if defined(SIOCGIFMPKLOG)
if (ioctl(s, SIOCGIFMPKLOG, &ifr) != -1) {
printf("\tmulti layer packet logging (mpklog): %s\n",
(ifr.ifr_mpk_log != 0) ? "enabled" : "disabled");
}
+#endif
show_routermode(s);
show_routermode6();
@@ -2424,8 +2442,10 @@ static struct cmd basic_cmds[] = {
DEF_CMD("monitor", IFF_MONITOR:, setifflags),
DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
#endif /* IFF_MONITOR */
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
DEF_CMD("mpklog", 1, setifmpklog),
DEF_CMD("-mpklog", 0, setifmpklog),
+#endif
#ifdef IFF_STATICARP
DEF_CMD("staticarp", IFF_STATICARP, setifflags),
DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
@@ -2486,7 +2506,9 @@ static struct cmd basic_cmds[] = {
DEF_CMD_VA("routermode", routermode),
DEF_CMD_ARG("desc", setifdesc),
DEF_CMD_ARG("tbr", settbr),
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
DEF_CMD_VA("netem", setnetem),
+#endif
DEF_CMD_ARG("throttle", setthrottle),
DEF_CMD_ARG("log", setlog),
DEF_CMD("cl2k", 1, setcl2k),
@@ -2507,10 +2529,14 @@ static struct cmd basic_cmds[] = {
DEF_CMD("-probe_connectivity", 0, setprobeconnectivity),
DEF_CMD("lowpowermode", 1, setlowpowermode),
DEF_CMD("-lowpowermode", 0, setlowpowermode),
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
DEF_CMD_ARG("subfamily", setifsubfamily),
+#endif
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 135000
DEF_CMD("available", 1, setifavailability),
DEF_CMD("-available", 0, setifavailability),
DEF_CMD("unavailable", 0, setifavailability),
+#endif
};
static __constructor void
@@ -2604,6 +2630,7 @@ ift2str(unsigned int t, unsigned int f, unsigned int sf)
c = "Cellular";
break;
+#if defined(APPLE_IF_FAM_IPSEC)
case IFT_OTHER:
if (ifr.ifr_type.ift_family == APPLE_IF_FAM_IPSEC) {
if (ifr.ifr_type.ift_subfamily == IFRTYPE_SUBFAMILY_BLUETOOTH) {
@@ -2617,6 +2644,7 @@ ift2str(unsigned int t, unsigned int f, unsigned int sf)
}
}
break;
+#endif
case IFT_BRIDGE:
case IFT_PFLOG:
@@ -2681,9 +2709,11 @@ iffunct2str(u_int32_t functional_type)
case IFRTYPE_FUNCTIONAL_INTCOPROC:
break;
+#if defined(IFRTYPE_FUNCTIONAL_COMPANIONLINK)
case IFRTYPE_FUNCTIONAL_COMPANIONLINK:
str = "companionlink";
break;
+#endif
default:
break;
diff --git a/network_cmds/ifconfig.tproj/ifmedia.c b/network_cmds/ifconfig.tproj/ifmedia.c
index 713c136..4f9ade1 100644
--- a/network_cmds/ifconfig.tproj/ifmedia.c
+++ b/network_cmds/ifconfig.tproj/ifmedia.c
@@ -87,6 +87,10 @@
#include <string.h>
#include <unistd.h>
+#ifndef SIOCGIFXMEDIA
+#define SIOCGIFXMEDIA SIOCGIFMEDIA
+#endif
+
#include "ifconfig.h"
static void domediaopt(const char *, int, int);
diff --git a/network_cmds/ifconfig.tproj/nexus.c b/network_cmds/ifconfig.tproj/nexus.c
index 3df9842..3717c15 100644
--- a/network_cmds/ifconfig.tproj/nexus.c
+++ b/network_cmds/ifconfig.tproj/nexus.c
@@ -56,6 +56,11 @@
#include "ifconfig.h"
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 135000
+#define flowswitch multistack
+#define ifnr_flowswitch ifnr_multistack
+#endif
+
static void
nexus_status(int s)
{
diff --git a/network_cmds/ndp.tproj/ndp.c b/network_cmds/ndp.tproj/ndp.c
index b485fa1..e3e51b8 100644
--- a/network_cmds/ndp.tproj/ndp.c
+++ b/network_cmds/ndp.tproj/ndp.c
@@ -443,7 +443,9 @@ set(int argc, char **argv)
!(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) {
case IFT_ETHER: case IFT_FDDI: case IFT_ISO88023:
case IFT_ISO88024: case IFT_ISO88025:
+#if defined(IFT_6LOWPAN)
case IFT_6LOWPAN:
+#endif
goto overwrite;
}
/*