/*
- * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2014 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
#ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD: src/sbin/ifconfig/ifconfig.c,v 1.134.2.2.2.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if_mib.h>
#include <net/route.h>
#include <net/pktsched/pktsched.h>
+#include <net/network_agent.h>
/* IP */
#include <netinet/in.h>
argc -= optind;
argv += optind;
- /* -l cannot be used with -a or -q or -r or -m or -b */
+ /* -l cannot be used with -a or -q or -m or -b */
if (namesonly &&
-#ifdef TARGET_OS_EMBEDDED
- (all || supmedia || bond_details))
-#else /* TARGET_OS_EMBEDDED */
- (all || supmedia || showrtref || bond_details))
-#endif /* !TARGET_OS_EMBEDDED */
+ (all || supmedia || bond_details))
usage();
/* nonsense.. */
usage();
ifname = NULL;
- ifindex = 0;
if (argc == 1) {
afp = af_getbyname(*argv);
if (afp == NULL)
warn("ioctl (set logging parameters)");
}
+void
+setcl2k(const char *vname, int value, int s, const struct afswtch *afp)
+{
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ ifr.ifr_ifru.ifru_2kcl = value;
+
+ if (ioctl(s, SIOCSIF2KCL, (caddr_t)&ifr) < 0)
+ Perror(vname);
+}
+
+void
+setexpensive(const char *vname, int value, int s, const struct afswtch *afp)
+{
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ ifr.ifr_ifru.ifru_expensive = value;
+
+ if (ioctl(s, SIOCSIFEXPENSIVE, (caddr_t)&ifr) < 0)
+ Perror(vname);
+}
+
+
+void
+setecnmode(const char *val, int dummy __unused, int s,
+ const struct afswtch *afp)
+{
+ char *cp;
+
+ if (strcmp(val, "default") == 0)
+ ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_DEFAULT;
+ else if (strcmp(val, "enable") == 0)
+ ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_ENABLE;
+ else if (strcmp(val, "disable") == 0)
+ ifr.ifr_ifru.ifru_ecn_mode = IFRTYPE_ECN_DISABLE;
+ else {
+ ifr.ifr_ifru.ifru_ecn_mode = strtold(val, &cp);
+ if (val == cp || errno != 0) {
+ warn("Invalid ECN mode value '%s'", val);
+ return;
+ }
+ }
+
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+
+ if (ioctl(s, SIOCSECNMODE, (caddr_t)&ifr) < 0)
+ Perror("ioctl(SIOCSECNMODE)");
+}
+
+
#define IFFBITS \
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
#define IFEFBITS \
"\020\1AUTOCONFIGURING\6IPV6_DISABLED\7ACCEPT_RTADV\10TXSTART\11RXPOLL" \
-"\12VLAN\13BOND\14ARPLL\15NOWINDOWSCALE\16NOAUTOIPV6LL\20ROUTER4\21ROUTER6" \
-"\22LOCALNET_PRIVATE\23ND6ALT\24RESTRICTED_RECV\25AWDL\26NOACKPRI\35SENDLIST" \
-"\36DIRECTLINK"
+"\12VLAN\13BOND\14ARPLL\15NOWINDOWSCALE\16NOAUTOIPV6LL\17EXPENSIVE\20ROUTER4" \
+"\21ROUTER6\22LOCALNET_PRIVATE\23ND6ALT\24RESTRICTED_RECV\25AWDL\26NOACKPRI" \
+"\27AWDL_RESTRICTED\30CL2K\31ECN_ENABLE\32ECN_DISABLE\35SENDLIST\36DIRECTLINK\40UPDOWNCHANGE"
#define IFCAPBITS \
"\020\1RXCSUM\2TXCSUM\3VLAN_MTU\4VLAN_HWTAGGING\5JUMBO_MTU" \
printf("\ttype: %s\n", c);
}
+ if (verbose > 0) {
+ struct if_agentidsreq ifar;
+ memset(&ifar, 0, sizeof(ifar));
+
+ strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name));
+
+ if (ioctl(s, SIOCGIFAGENTIDS, &ifar) != -1) {
+ if (ifar.ifar_count != 0) {
+ ifar.ifar_uuids = calloc(ifar.ifar_count, sizeof(uuid_t));
+ if (ifar.ifar_uuids != NULL) {
+ if (ioctl(s, SIOCGIFAGENTIDS, &ifar) != 1) {
+ for (int agent_i = 0; agent_i < ifar.ifar_count; agent_i++) {
+ struct netagent_req nar;
+ memset(&nar, 0, sizeof(nar));
+
+ uuid_copy(nar.netagent_uuid, ifar.ifar_uuids[agent_i]);
+
+ if (ioctl(s, SIOCGIFAGENTDATA, &nar) != 1) {
+ printf("\tagent domain:%s type:%s flags:0x%x desc:\"%s\"\n",
+ nar.netagent_domain, nar.netagent_type,
+ nar.netagent_flags, nar.netagent_desc);
+ }
+ }
+ }
+ free(ifar.ifar_uuids);
+ }
+ }
+ }
+ }
+
if (ioctl(s, SIOCGIFLINKQUALITYMETRIC, &ifr) != -1) {
int lqm = ifr.ifr_link_quality_metric;
if (verbose > 1) {
printf("\tlink quality: %d ", lqm);
- if (lqm == IFNET_LQM_THRESH_OFF) {
+ if (lqm == IFNET_LQM_THRESH_OFF)
printf("(off)");
- } else if (lqm == IFNET_LQM_THRESH_UNKNOWN) {
+ else if (lqm == IFNET_LQM_THRESH_UNKNOWN)
printf("(unknown)");
- } else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
- lqm <= IFNET_LQM_THRESH_POOR)
+ else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
+ lqm <= IFNET_LQM_THRESH_BAD)
+ printf("(bad)");
+ else if (lqm > IFNET_LQM_THRESH_UNKNOWN &&
+ lqm <= IFNET_LQM_THRESH_POOR)
printf("(poor)");
else if (lqm > IFNET_LQM_THRESH_POOR &&
lqm <= IFNET_LQM_THRESH_GOOD)
printf("\n");
} else if (lqm > IFNET_LQM_THRESH_UNKNOWN) {
printf("\tlink quality: %d ", lqm);
- if (lqm <= IFNET_LQM_THRESH_POOR)
+ if (lqm <= IFNET_LQM_THRESH_BAD)
+ printf("(bad)");
+ else if (lqm <= IFNET_LQM_THRESH_POOR)
printf("(poor)");
- else if (lqm > IFNET_LQM_THRESH_POOR &&
- lqm <= IFNET_LQM_THRESH_GOOD)
+ else if (lqm <= IFNET_LQM_THRESH_GOOD)
printf("(good)");
else
printf("(?)");
}
}
+ if (verbose > 0) {
+ if (ioctl(s, SIOCGIFINTERFACESTATE, &ifr) != -1) {
+ printf("\tstate");
+ if (ifr.ifr_interface_state.valid_bitmask &
+ IF_INTERFACE_STATE_RRC_STATE_VALID) {
+ uint8_t rrc_state = ifr.ifr_interface_state.rrc_state;
+
+ printf(" rrc: %u ", rrc_state);
+ if (rrc_state == IF_INTERFACE_STATE_RRC_STATE_CONNECTED)
+ printf("(connected)");
+ else if (rrc_state == IF_INTERFACE_STATE_RRC_STATE_IDLE)
+ printf("(idle)");
+ else
+ printf("(?)");
+ }
+ if (ifr.ifr_interface_state.valid_bitmask &
+ IF_INTERFACE_STATE_INTERFACE_AVAILABILITY_VALID) {
+ uint8_t ifavail = ifr.ifr_interface_state.interface_availability;
+
+ printf(" availability: %u ", ifavail);
+ if (ifavail == IF_INTERFACE_STATE_INTERFACE_AVAILABLE)
+ printf("(true)");
+ else if (ifavail == IF_INTERFACE_STATE_INTERFACE_UNAVAILABLE)
+ printf("(false)");
+ else
+ printf("(?)");
+ } else {
+ printf(" availability: (not valid)");
+ }
+ if (verbose > 1 &&
+ ifr.ifr_interface_state.valid_bitmask &
+ IF_INTERFACE_STATE_LQM_STATE_VALID) {
+ int8_t lqm = ifr.ifr_interface_state.lqm_state;
+
+ printf(" lqm: %d", lqm);
+
+ if (lqm == IFNET_LQM_THRESH_OFF)
+ printf("(off)");
+ else if (lqm == IFNET_LQM_THRESH_UNKNOWN)
+ printf("(unknown)");
+ else if (lqm == IFNET_LQM_THRESH_BAD)
+ printf("(bad)");
+ else if (lqm == IFNET_LQM_THRESH_POOR)
+ printf("(poor)");
+ else if (lqm == IFNET_LQM_THRESH_GOOD)
+ printf("(good)");
+ else
+ printf("(?)");
+ }
+ }
+ printf("\n");
+ }
+
bzero(&iflpr, sizeof (iflpr));
strncpy(iflpr.iflpr_name, name, sizeof (iflpr.iflpr_name));
if (ioctl(s, SIOCGIFLINKPARAMS, &iflpr) != -1) {
printf("\teffective interface: %s\n", delegatedif);
}
+ if(ioctl(s, SIOCGSTARTDELAY, &ifr) != -1) {
+ if (ifr.ifr_start_delay_qlen > 0 &&
+ ifr.ifr_start_delay_timeout > 0) {
+ printf("\ttxstart qlen: %u packets "
+ "timeout: %u microseconds\n",
+ ifr.ifr_start_delay_qlen,
+ ifr.ifr_start_delay_timeout/1000);
+ }
+ }
+
done:
close(s);
return;
DEF_CMD_ARG("tbr", settbr),
DEF_CMD_ARG("throttle", setthrottle),
DEF_CMD_ARG("log", setlog),
+ DEF_CMD("cl2k", 1, setcl2k),
+ DEF_CMD("-cl2k", 0, setcl2k),
+ DEF_CMD("expensive", 1, setexpensive),
+ DEF_CMD("-expensive", 0, setexpensive),
+ DEF_CMD_ARG("ecn", setecnmode),
};
static __constructor void