]> git.saurik.com Git - apple/network_cmds.git/commitdiff
network_cmds-457.tar.gz os-x-1010 os-x-10101 os-x-10102 os-x-10103 os-x-10104 os-x-10105 v457
authorApple <opensource@apple.com>
Fri, 11 Jul 2014 19:54:46 +0000 (19:54 +0000)
committerApple <opensource@apple.com>
Fri, 11 Jul 2014 19:54:46 +0000 (19:54 +0000)
45 files changed:
arp.tproj/arp.c
cfilutil/cfilstat.c [new file with mode: 0644]
cfilutil/cfilutil.1 [new file with mode: 0644]
cfilutil/cfilutil.c [new file with mode: 0644]
dnctl/dnctl.8
ifconfig.tproj/af_inet.c
ifconfig.tproj/af_inet6.c
ifconfig.tproj/af_link.c
ifconfig.tproj/ifbridge.c
ifconfig.tproj/ifclone.c
ifconfig.tproj/ifconfig.8
ifconfig.tproj/ifconfig.c
ifconfig.tproj/ifvlan.c
kdumpd.tproj/com.apple.kdumpd.plist
kdumpd.tproj/kdumpd.c
mptcp_client/conn_lib.c [new file with mode: 0644]
mptcp_client/conn_lib.h [new file with mode: 0644]
mptcp_client/mptcp_client.1 [new file with mode: 0644]
mptcp_client/mptcp_client.c [new file with mode: 0644]
mtest.tproj/mtest.c
netstat.tproj/if.c
netstat.tproj/inet.c
netstat.tproj/inet6.c
netstat.tproj/ipsec.c
netstat.tproj/main.c
netstat.tproj/mbuf.c
netstat.tproj/mptcp.c
netstat.tproj/mroute.c [deleted file]
netstat.tproj/mroute6.c [deleted file]
netstat.tproj/netstat.h
netstat.tproj/systm.c [new file with mode: 0644]
netstat.tproj/unix.c
network-client-server-entitlements.plist [new file with mode: 0644]
network_cmds.xcodeproj/project.pbxproj
ping.tproj/ping.8
ping.tproj/ping.c
ping6.tproj/ping6.8
ping6.tproj/ping6.c
pktmnglr/packet_mangler.c [new file with mode: 0644]
rarpd.tproj/rarpd.c
route.tproj/route.c
traceroute.tproj/findsaddr-socket.c
traceroute.tproj/ifaddrlist.c
traceroute.tproj/traceroute.c
traceroute6.tproj/traceroute6.c

index a152574b225b228b0c51f1694d2f1e977f25e6a4..85796eb822121ee1ec3b21aae52b9a95ee5805e4 100644 (file)
@@ -64,12 +64,6 @@ static char const copyright[] =
 "@(#) Copyright (c) 1984, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 "@(#) Copyright (c) 1984, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
-
-#ifndef lint
-static char const sccsid[] = "@(#)from: arp.c  8.2 (Berkeley) 1/2/94";
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/arp/arp.c,v 1.65.2.1 2008/04/25 16:38:14 sam Exp $");
 #endif
 
 /*
 #endif
 
 /*
diff --git a/cfilutil/cfilstat.c b/cfilutil/cfilstat.c
new file mode 100644 (file)
index 0000000..ac4b197
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2013-2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+#include <sys/errno.h>
+#include <sys/sysctl.h>
+#include <net/content_filter.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <err.h>
+#include <unistd.h>
+#include <string.h>
+
+void
+print_filter_list()
+{
+       size_t total_len, curr_len;
+       void *buffer = NULL;
+       void *ptr;
+       uint32_t line = 0;
+       
+       if (sysctlbyname("net.cfil.filter_list", NULL, &total_len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.filter_list)");
+       
+       buffer = malloc(total_len);
+       if (buffer == NULL)
+               err(1, "malloc()");
+       if (sysctlbyname("net.cfil.filter_list", buffer, &total_len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.filter_list)");
+       
+       ptr = buffer;
+       curr_len = 0;
+       do {
+               struct cfil_filter_stat *filter_stat;
+               
+               filter_stat = (struct cfil_filter_stat *)ptr;
+               
+               if (curr_len + filter_stat->cfs_len > total_len ||
+                   filter_stat->cfs_len < sizeof(struct cfil_filter_stat))
+                       break;
+               
+               if (line % 16 == 0)
+                       printf("%10s %10s %10s %10s\n",
+                              "filter", "flags", "count", "necpunit");
+               
+               printf("%10u 0x%08x %10u %10u\n",
+                      filter_stat->cfs_filter_id,
+                      filter_stat->cfs_flags,
+                      filter_stat->cfs_sock_count,
+                      filter_stat->cfs_necp_control_unit);
+               
+               ptr += filter_stat->cfs_len;
+               curr_len += filter_stat->cfs_len;
+       } while (1);
+       
+       free(buffer);
+}
+
+void
+sprint_offset(char *str, size_t len, const char *fmt, uint64_t offset)
+{
+       if (offset == CFM_MAX_OFFSET)
+               snprintf(str, len, "%s", "MAX");
+       else
+               snprintf(str, len, fmt, offset);
+}
+
+void
+print_socket_list()
+{
+       size_t total_len, curr_len;
+       void *buffer = NULL;
+       void *ptr;
+       int i;
+       
+       if (sysctlbyname("net.cfil.sock_list", NULL, &total_len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.sock_list)");
+       
+       buffer = malloc(total_len);
+       if (buffer == NULL)
+               err(1, "malloc()");
+       if (sysctlbyname("net.cfil.sock_list", buffer, &total_len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.sock_list)");
+       
+       ptr = buffer;
+       curr_len = 0;
+       do {
+               struct cfil_sock_stat *sock_stat;
+               char opass[32];
+               char ipass[32];
+               
+               sock_stat = (struct cfil_sock_stat *)ptr;
+               
+               if (curr_len + sock_stat->cfs_len > total_len ||
+                   sock_stat->cfs_len < sizeof(struct cfil_sock_stat))
+                       break;
+
+               sprint_offset(opass, 32, "%8llu", sock_stat->cfs_snd.cbs_pass_offset);
+               sprint_offset(ipass, 32, "%8llu", sock_stat->cfs_rcv.cbs_pass_offset);
+
+               printf("%18s %10s "
+                      "%8s %8s %8s %8s %8s %8s %8s "
+                      "%8s %8s %8s %8s %8s %8s %8s "
+                      "%8s %8s\n",
+                      "sockid", "flags",
+                      "ofirst", "olast", "oqlen", " ", "opass", " ", " ",
+                      "ifirst", "ilast", "iqlen", " ", "ipass", " ", " ",
+                      "pid", "epid");
+
+               printf("0x%016llx 0x%08llx "
+                      "%8llu %8llu %8llu %8s %8s %8s %8s "
+                      "%8llu %8llu %8llu %8s %8s %8s %8s "
+                      "%8u %8u\n",
+                      
+                      sock_stat->cfs_sock_id,
+                      sock_stat->cfs_flags,
+                      
+                      sock_stat->cfs_snd.cbs_pending_first,
+                      sock_stat->cfs_snd.cbs_pending_last,
+                      sock_stat->cfs_snd.cbs_inject_q_len,
+                      " ",
+                      opass,
+                      " ",
+                      " ",
+                      
+                      sock_stat->cfs_rcv.cbs_pending_first,
+                      sock_stat->cfs_rcv.cbs_pending_last,
+                      sock_stat->cfs_rcv.cbs_inject_q_len,
+                      " ",
+                      ipass,
+                      " ",
+                      " ",
+                      sock_stat->cfs_pid,
+                      sock_stat->cfs_e_pid);
+               
+               printf("%7s %10s %10s "
+                      "%8s %8s %8s %8s %8s %8s %8s "
+                      "%8s %8s %8s %8s %8s %8s %8s\n",
+                      " ",
+                      "filter", "flags",
+                      "octlfrst", "octllast", "opndfrst", "opndlast", "opass", "opked", "opeek",
+                      "ictlfrst", "ictllast", "ipndfrst", "ipndlast", "ipass", "ipked", "ipeek");
+               for (i = 0; i < CFIL_MAX_FILTER_COUNT; i++) {
+                       struct cfil_entry_stat *estat;
+                       char spass[32];
+                       char speek[32];
+                       char spked[32];
+                       char rpass[32];
+                       char rpeek[32];
+                       char rpked[32];
+
+                       estat = &sock_stat->ces_entries[i];
+
+                       sprint_offset(spass, 32, "%8llu", estat->ces_snd.cbs_pass_offset);
+                       sprint_offset(speek, 32, "%8llu", estat->ces_snd.cbs_peek_offset);
+                       sprint_offset(spked, 32, "%8llu", estat->ces_snd.cbs_peeked);
+                       
+                       sprint_offset(rpass, 32, "%8llu", estat->ces_rcv.cbs_pass_offset);
+                       sprint_offset(rpeek, 32, "%8llu", estat->ces_rcv.cbs_peek_offset);
+                       sprint_offset(rpked, 32, "%8llu", estat->ces_rcv.cbs_peeked);
+                       
+                       printf("%7s %10u 0x%08x "
+                              "%8llu %8llu %8llu %8llu %8s %8s %8s "
+                              "%8llu %8llu %8llu %8llu %8s %8s %8s\n",
+                              
+                              " ",
+                              estat->ces_filter_id,
+                              estat->ces_flags,
+                              
+                              estat->ces_snd.cbs_ctl_first,
+                              estat->ces_snd.cbs_ctl_last,
+                              estat->ces_snd.cbs_pending_first,
+                              estat->ces_snd.cbs_pending_last,
+                              spass,
+                              spked,
+                              speek,
+                              
+                              estat->ces_rcv.cbs_ctl_first,
+                              estat->ces_rcv.cbs_ctl_last,
+                              estat->ces_rcv.cbs_pending_first,
+                              estat->ces_rcv.cbs_pending_last,
+                              rpass,
+                              rpked,
+                              rpeek);
+               }
+               
+               
+               ptr += sock_stat->cfs_len;
+               curr_len += sock_stat->cfs_len;
+       } while (1);
+       
+       free(buffer);
+}
+
+
+#define PR32(x) printf(#x " %u\n", stats-> x)
+#define PR64(x) printf(#x " %llu\n", stats-> x)
+void
+print_cfil_stats()
+{
+       size_t len, alloc_len;
+       void *buffer = NULL;
+       struct cfil_stats *stats;
+
+       if (sysctlbyname("net.cfil.stats", NULL, &len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.stats)");
+       
+       if (len < sizeof(struct cfil_stats))
+               alloc_len = sizeof(struct cfil_stats);
+       else
+               alloc_len = len;
+       
+       buffer = malloc(alloc_len);
+       if (buffer == NULL)
+               err(1, "malloc()");
+       if (sysctlbyname("net.cfil.stats", buffer, &len, NULL, 0) == -1)
+               err(1, "sysctlbyname(net.cfil.stats)");
+       stats = (struct cfil_stats *)buffer;
+
+       PR32(cfs_ctl_connect_ok);
+       PR32(cfs_ctl_connect_fail);
+       PR32(cfs_ctl_connect_ok);
+       PR32(cfs_ctl_connect_fail);
+       PR32(cfs_ctl_disconnect_ok);
+       PR32(cfs_ctl_disconnect_fail);
+       PR32(cfs_ctl_send_ok);
+       PR32(cfs_ctl_send_bad);
+       PR32(cfs_ctl_rcvd_ok);
+       PR32(cfs_ctl_rcvd_bad);
+       PR32(cfs_ctl_rcvd_flow_lift);
+       PR32(cfs_ctl_action_data_update);
+       PR32(cfs_ctl_action_drop);
+       PR32(cfs_ctl_action_bad_op);
+       PR32(cfs_ctl_action_bad_len);
+
+       PR32(cfs_sock_id_not_found);
+
+       PR32(cfs_cfi_alloc_ok);
+       PR32(cfs_cfi_alloc_fail);
+
+       PR32(cfs_sock_userspace_only);
+       PR32(cfs_sock_attach_in_vain);
+       PR32(cfs_sock_attach_already);
+       PR32(cfs_sock_attach_no_mem);
+       PR32(cfs_sock_attach_failed);
+       PR32(cfs_sock_attached);
+       PR32(cfs_sock_detached);
+
+       PR32(cfs_attach_event_ok);
+       PR32(cfs_attach_event_flow_control);
+       PR32(cfs_attach_event_fail);
+
+       PR32(cfs_closed_event_ok);
+       PR32(cfs_closed_event_flow_control);
+       PR32(cfs_closed_event_fail);
+
+       PR32(cfs_data_event_ok);
+       PR32(cfs_data_event_flow_control);
+       PR32(cfs_data_event_fail);
+
+       PR32(cfs_disconnect_in_event_ok);
+       PR32(cfs_disconnect_out_event_ok);
+       PR32(cfs_disconnect_event_flow_control);
+       PR32(cfs_disconnect_event_fail);
+
+       PR32(cfs_ctl_q_not_started);
+
+       PR32(cfs_close_wait);
+       PR32(cfs_close_wait_timeout);
+
+       PR32(cfs_flush_in_drop);
+       PR32(cfs_flush_out_drop);
+       PR32(cfs_flush_in_close);
+       PR32(cfs_flush_out_close);
+       PR32(cfs_flush_in_free);
+       PR32(cfs_flush_out_free);
+
+       PR32(cfs_inject_q_nomem);
+       PR32(cfs_inject_q_nobufs);
+       PR32(cfs_inject_q_detached);
+       PR32(cfs_inject_q_in_fail);
+       PR32(cfs_inject_q_out_fail);
+
+       PR32(cfs_inject_q_in_retry);
+       PR32(cfs_inject_q_out_retry);
+
+       PR32(cfs_data_in_control);
+       PR32(cfs_data_in_oob);
+       PR32(cfs_data_out_control);
+       PR32(cfs_data_out_oob);
+
+       PR64(cfs_ctl_q_in_enqueued);
+       PR64(cfs_ctl_q_out_enqueued);
+       PR64(cfs_ctl_q_in_peeked);
+       PR64(cfs_ctl_q_out_peeked);
+
+       PR64(cfs_pending_q_in_enqueued);
+       PR64(cfs_pending_q_out_enqueued);
+
+       PR64(cfs_inject_q_in_enqueued);
+       PR64(cfs_inject_q_out_enqueued);
+       PR64(cfs_inject_q_in_passed);
+       PR64(cfs_inject_q_out_passed);
+}
diff --git a/cfilutil/cfilutil.1 b/cfilutil/cfilutil.1
new file mode 100644 (file)
index 0000000..0d97adf
--- /dev/null
@@ -0,0 +1,56 @@
+.Dd 2/10/14\r
+.Dt cfilutil 1\r
+.Os Darwin\r
+.Sh NAME\r
+.Nm cfilutil\r
+.Nd Tool to exercise the content filter subsystem.\r
+.Sh SYNOPSIS\r
+.Nm\r
+.Op Fl hilqsv\r
+.Fl u Ar unit\r
+.Op Fl a Ar offset \r
+.Op Fl d Ar offset value \r
+.Op Fl k Ar increment\r
+.Op Fl m Ar length\r
+.Op Fl p Ar offset\r
+.Op Fl r Ar random\r
+.Op Fl t Ar delay\r
+.Sh DESCRIPTION\r
+Use\r
+.Nm\r
+to exercise the content filter subsystem.\r
+.Pp\r
+The flags have the following meaning:\r
+.Bl -tag -width -indent\r
+.It Fl a Ar offset\r
+Auto start filtering with given offset.\r
+.It Fl a Ar offset value\r
+Default values for offset passin, peekin, passout, peekout, pass or peek.\r
+.It Fl h\r
+Display this help.\r
+.It Fl i\r
+Interactive mode.\r
+.It Fl k Ar increment\r
+Peek mode with increment.\r
+.It Fl l\r
+Pass loopback traffic.\r
+.It Fl m Ar length\r
+Maximum dump length.\r
+.It Fl p Ar offset\r
+Pass mode (all or after given offset if it is > 0).\r
+.It Fl q\r
+Decrease verbosity.\r
+.It Fl r Ar rate\r
+Random drop rate.\r
+.It Fl s\r
+display content filter statistics (all, sock, filt, cfil).\r
+.It Fl t Ar delay\r
+Pass delay in microseconds.\r
+.It Fl u Ar unit\r
+NECP filter control unit.\r
+.It Fl v\r
+Increase verbosity.\r
+.El\r
+.Pp\r
+.Sh SEE ALSO \r
+.Xr neutil 1              \" rdar://16115914\r
diff --git a/cfilutil/cfilutil.c b/cfilutil/cfilutil.c
new file mode 100644 (file)
index 0000000..546604c
--- /dev/null
@@ -0,0 +1,982 @@
+/*
+ * Copyright (c) 2013-2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/event.h>
+#include <sys/time.h>
+#include <sys/sys_domain.h>
+#include <sys/ioctl.h>
+#include <sys/kern_control.h>
+#include <sys/queue.h>
+#include <net/content_filter.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <sysexits.h>
+
+extern void print_filter_list(void);
+extern void print_socket_list(void);
+extern void print_cfil_stats(void);
+
+#define MAX_BUFFER (65536 + 1024)
+
+#define MAXHEXDUMPCOL 16
+
+
+enum {
+       MODE_NONE = 0,
+       MODE_INTERACTIVE = 0x01,
+       MODE_PEEK = 0x02,
+       MODE_PASS = 0x04,
+       MODE_DELAY = 0x08
+};
+int mode = MODE_NONE;
+
+unsigned long delay_ms = 0;
+struct timeval delay_tv = { 0, 0 };
+long verbosity = 0;
+uint32_t necp_control_unit = 0;
+unsigned long auto_start = 0;
+uint64_t peek_inc = 0;
+uint64_t pass_offset = 0;
+struct timeval now, deadline;
+int sf = -1;
+int pass_loopback = 0;
+uint32_t random_drop = 0;
+uint32_t event_total = 0;
+uint32_t event_dropped = 0;
+
+uint64_t default_in_pass = 0;
+uint64_t default_in_peek = 0;
+uint64_t default_out_pass = 0;
+uint64_t default_out_peek = 0;
+
+unsigned long max_dump_len = 32;
+
+TAILQ_HEAD(sock_info_head, sock_info) sock_info_head = TAILQ_HEAD_INITIALIZER(sock_info_head);
+
+
+struct sock_info {
+       TAILQ_ENTRY(sock_info)  si_link;
+       cfil_sock_id_t          si_sock_id;
+       struct timeval          si_deadline;
+       uint64_t                si_in_pass;
+       uint64_t                si_in_peek;
+       uint64_t                si_out_pass;
+       uint64_t                si_out_peek;
+};
+
+static void
+HexDump(void *data, size_t len)
+{
+       size_t i, j, k;
+       unsigned char *ptr = (unsigned char *)data;
+       unsigned char buf[32 + 3 * MAXHEXDUMPCOL + 2 + MAXHEXDUMPCOL + 1];
+       
+       for (i = 0; i < len; i += MAXHEXDUMPCOL) {
+               k = snprintf((char *)buf, sizeof(buf), "\t0x%04lx:  ", i);
+               for (j = i; j < i + MAXHEXDUMPCOL; j++) {
+                       if (j < len) {
+                               unsigned char msnbl = ptr[j] >> 4;
+                               unsigned char lsnbl = ptr[j] & 0x0f;
+                               
+                               buf[k++] = msnbl < 10 ? msnbl + '0' : msnbl + 'a' - 10;
+                               buf[k++] = lsnbl < 10 ? lsnbl + '0' : lsnbl + 'a' - 10;
+                       } else {
+                               buf[k++] = ' ';
+                               buf[k++] = ' ';
+                       }
+                       if ((j % 2) == 1)
+                               buf[k++] = ' ';
+                       if ((j % MAXHEXDUMPCOL) == MAXHEXDUMPCOL - 1)
+                               buf[k++] = ' ';
+               }
+               
+               buf[k++] = ' ';
+               buf[k++] = ' ';
+               
+               for (j = i; j < i + MAXHEXDUMPCOL && j < len; j++) {
+                       if (isprint(ptr[j]))
+                               buf[k++] = ptr[j];
+                       else
+                               buf[k++] = '.';
+               }
+               buf[k] = 0;
+               printf("%s\n", buf);
+       }
+}
+
+void
+print_hdr(struct cfil_msg_hdr *hdr)
+{
+       const char *typestr = "unknown";
+       const char *opstr = "unknown";
+       
+       if (hdr->cfm_type == CFM_TYPE_EVENT) {
+               typestr = "event";
+               switch (hdr->cfm_op) {
+                       case CFM_OP_SOCKET_ATTACHED:
+                               opstr = "attached";
+                               break;
+                       case CFM_OP_SOCKET_CLOSED:
+                               opstr = "closed";
+                               break;
+                       case CFM_OP_DATA_OUT:
+                               opstr = "dataout";
+                               break;
+                       case CFM_OP_DATA_IN:
+                               opstr = "datain";
+                               break;
+                       case CFM_OP_DISCONNECT_OUT:
+                               opstr = "disconnectout";
+                               break;
+                       case CFM_OP_DISCONNECT_IN:
+                               opstr = "disconnectin";
+                               break;
+                               
+                       default:
+                               break;
+               }
+       } else if (hdr->cfm_type == CFM_TYPE_ACTION) {
+               typestr = "action";
+               switch (hdr->cfm_op) {
+                       case CFM_OP_DATA_UPDATE:
+                               opstr = "update";
+                               break;
+                       case CFM_OP_DROP:
+                               opstr = "drop";
+                               break;
+                               
+                       default:
+                               break;
+               }
+               
+       }
+       printf("%s %s len %u version %u type %u op %u sock_id 0x%llx\n",
+              typestr, opstr,
+              hdr->cfm_len, hdr->cfm_version, hdr->cfm_type,
+              hdr->cfm_op, hdr->cfm_sock_id);
+}
+
+void
+print_data_req(struct cfil_msg_data_event *data_req)
+{
+       size_t datalen;
+       void *databuf;
+       
+       if (verbosity <= 0)
+               return;
+       
+       print_hdr(&data_req->cfd_msghdr);
+       
+       printf(" start %llu end %llu\n",
+              data_req->cfd_start_offset, data_req->cfd_end_offset);
+       
+       datalen = (size_t)(data_req->cfd_end_offset - data_req->cfd_start_offset);
+       
+       databuf = (void *)(data_req + 1);
+       
+       if (verbosity > 1)
+               HexDump(databuf, MIN(datalen, max_dump_len));
+}
+
+void
+print_action_msg(struct cfil_msg_action *action)
+{
+       if (verbosity <= 0)
+               return;
+       
+       print_hdr(&action->cfa_msghdr);
+       
+       if (action->cfa_msghdr.cfm_op == CFM_OP_DATA_UPDATE)
+               printf(" out pass %llu peek %llu in pass %llu peek %llu\n",
+                      action->cfa_out_pass_offset, action->cfa_out_peek_offset,
+                      action->cfa_in_pass_offset, action->cfa_in_peek_offset);
+}
+
+struct sock_info *
+find_sock_info(cfil_sock_id_t sockid)
+{
+       struct sock_info *sock_info;
+       
+       TAILQ_FOREACH(sock_info, &sock_info_head, si_link) {
+               if (sock_info->si_sock_id == sockid)
+                       return (sock_info);
+       }
+       return (NULL);
+}
+
+struct sock_info *
+add_sock_info(cfil_sock_id_t sockid)
+{
+       struct sock_info *sock_info;
+       
+       if (find_sock_info(sockid) != NULL)
+               return (NULL);
+       
+       sock_info = calloc(1, sizeof(struct sock_info));
+       if (sock_info == NULL)
+               err(EX_OSERR, "calloc()");
+       sock_info->si_sock_id = sockid;
+       TAILQ_INSERT_TAIL(&sock_info_head, sock_info, si_link);
+       
+       return (sock_info);
+}
+
+void
+remove_sock_info(cfil_sock_id_t sockid)
+{
+       struct sock_info *sock_info = find_sock_info(sockid);
+       
+       if (sock_info != NULL) {
+               TAILQ_REMOVE(&sock_info_head, sock_info, si_link);
+               free(sock_info);
+       }
+}
+
+/* return 0 if timer is already set */
+int
+set_sock_info_deadline(struct sock_info *sock_info)
+{
+       if (timerisset(&sock_info->si_deadline))
+               return (0);
+       
+       timeradd(&now, &sock_info->si_deadline, &sock_info->si_deadline);
+       
+       if (!timerisset(&deadline)) {
+               timeradd(&now, &delay_tv, &deadline);
+       }
+       
+       return (1);
+}
+
+void
+send_action_message(uint32_t op, struct sock_info *sock_info, int nodelay)
+{
+       struct cfil_msg_action action;
+
+       if (!nodelay && delay_ms) {
+               set_sock_info_deadline(sock_info);
+               return;
+       }
+       bzero(&action, sizeof(struct cfil_msg_action));
+       action.cfa_msghdr.cfm_len = sizeof(struct cfil_msg_action);
+       action.cfa_msghdr.cfm_version = CFM_VERSION_CURRENT;
+       action.cfa_msghdr.cfm_type = CFM_TYPE_ACTION;
+       action.cfa_msghdr.cfm_op = op;
+       action.cfa_msghdr.cfm_sock_id = sock_info->si_sock_id;
+       switch (op) {
+               case CFM_OP_DATA_UPDATE:
+                       action.cfa_out_pass_offset = sock_info->si_out_pass;
+                       action.cfa_out_peek_offset = sock_info->si_out_peek;
+                       action.cfa_in_pass_offset = sock_info->si_in_pass;
+                       action.cfa_in_peek_offset = sock_info->si_in_peek;
+                       break;
+                       
+               default:
+                       break;
+       }
+
+       if (verbosity > -1)
+               print_action_msg(&action);
+       
+       if (send(sf, &action, sizeof(struct cfil_msg_action), 0) == -1)
+               warn("send()");
+       
+       timerclear(&sock_info->si_deadline);
+}
+
+void
+process_delayed_actions()
+{
+       struct sock_info *sock_info;
+       
+       TAILQ_FOREACH(sock_info, &sock_info_head, si_link) {
+               if (timerisset(&sock_info->si_deadline) &&
+                   timercmp(&sock_info->si_deadline, &now, >=))
+                   send_action_message(CFM_OP_DATA_UPDATE, sock_info, 1);
+       }
+}
+
+int
+set_non_blocking(int fd)
+{
+       int flags;
+       
+       flags = fcntl(fd, F_GETFL);
+       if (flags == -1) {
+               warn("fcntl(F_GETFL)");
+               return (-1);
+       }
+       flags |= O_NONBLOCK;
+       if (fcntl(fd, F_SETFL, flags) == -1) {
+               warn("fcntl(F_SETFL)");
+               return (-1);
+       }
+       return (0);
+}
+
+int
+offset_from_str(const char *str, uint64_t *ret_val)
+{
+       char *endptr;
+       uint64_t offset;
+       int success = 1;
+       
+       if (strcasecmp(str, "max") == 0 || strcasecmp(str, "all") == 0)
+               offset = CFM_MAX_OFFSET;
+       else {
+               offset = strtoull(str, &endptr, 0);
+               if (*str == '\0' || *endptr != '\0')
+                       success = 0;
+       }
+       if (success)
+               *ret_val = offset;
+       return (success);
+}
+
+#define IN6_IS_ADDR_V4MAPPED_LOOPBACK(a)               \
+       ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+       (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+       (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)) && \
+       (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(INADDR_LOOPBACK)))
+
+
+int
+is_loopback(struct cfil_msg_data_event *data_req)
+{
+       if (data_req->cfc_dst.sa.sa_family == AF_INET &&
+           ntohl(data_req->cfc_dst.sin.sin_addr.s_addr) == INADDR_LOOPBACK)
+               return (1);
+       if (data_req->cfc_dst.sa.sa_family == AF_INET6 &&
+           IN6_IS_ADDR_LOOPBACK(&data_req->cfc_dst.sin6.sin6_addr))
+               return (1);
+       if (data_req->cfc_dst.sa.sa_family == AF_INET6 &&
+           IN6_IS_ADDR_V4MAPPED_LOOPBACK(&data_req->cfc_dst.sin6.sin6_addr))
+               return (1);
+
+       if (data_req->cfc_src.sa.sa_family == AF_INET &&
+           ntohl(data_req->cfc_src.sin.sin_addr.s_addr) == INADDR_LOOPBACK)
+               return (1);
+       if (data_req->cfc_src.sa.sa_family == AF_INET6 &&
+           IN6_IS_ADDR_LOOPBACK(&data_req->cfc_src.sin6.sin6_addr))
+               return (1);
+       if (data_req->cfc_src.sa.sa_family == AF_INET6 &&
+           IN6_IS_ADDR_V4MAPPED_LOOPBACK(&data_req->cfc_src.sin6.sin6_addr))
+               return (1);
+
+       return (0);
+}
+
+int
+drop(struct sock_info *sock_info)
+{
+       event_total++;
+       if (random_drop > 0) {
+               uint32_t r = arc4random();
+               if (r <= random_drop) {
+                       event_dropped++;
+                       printf("dropping 0x%llx dropped %u total %u rate %f\n",
+                              sock_info->si_sock_id,
+                              event_dropped, event_total,
+                              (double)event_dropped/(double)event_total * 100);
+                       send_action_message(CFM_OP_DROP, sock_info, 0);
+                       return (1);
+               }
+       }
+       return (0);
+}
+
+int
+doit()
+{
+       struct sockaddr_ctl sac;
+       struct ctl_info ctl_info;
+       void *buffer = NULL;
+       struct cfil_msg_hdr *hdr;
+       int kq = -1;
+       struct kevent kv;
+       int fdin = fileno(stdin);
+       char *linep = NULL;
+       size_t linecap = 0;
+       char *cmdptr = NULL;
+       char *argptr = NULL;
+       size_t cmdlen = 0;
+       struct cfil_msg_action action;
+       cfil_sock_id_t last_sock_id = 0;
+       struct sock_info *sock_info = NULL;
+       struct timeval last_time, elapsed, delta;
+       struct timespec interval, *timeout = NULL;
+       
+       kq = kqueue();
+       if (kq == -1)
+               err(1, "kqueue()");
+       
+       sf = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
+       if (sf == -1)
+               err(1, "socket()");
+       
+       bzero(&ctl_info, sizeof(struct ctl_info));
+       strlcpy(ctl_info.ctl_name, CONTENT_FILTER_CONTROL_NAME, sizeof(ctl_info.ctl_name));
+       if (ioctl(sf, CTLIOCGINFO, &ctl_info) == -1)
+               err(1, "ioctl(CTLIOCGINFO)");
+       
+       if (fcntl(sf, F_SETNOSIGPIPE, 1) == -1)
+               err(1, "fcntl(F_SETNOSIGPIPE)");
+       
+       bzero(&sac, sizeof(struct sockaddr_ctl));
+       sac.sc_len = sizeof(struct sockaddr_ctl);
+       sac.sc_family = AF_SYSTEM;
+       sac.ss_sysaddr = AF_SYS_CONTROL;
+       sac.sc_id = ctl_info.ctl_id;
+       
+       if (connect(sf, (struct sockaddr *)&sac, sizeof(struct sockaddr_ctl)) == -1)
+               err(1, "connect()");
+       
+       if (set_non_blocking(sf) == -1)
+               err(1, "set_non_blocking(sf)");
+       
+       if (setsockopt(sf, SYSPROTO_CONTROL, CFIL_OPT_NECP_CONTROL_UNIT,
+                      &necp_control_unit, sizeof(uint32_t)) == -1)
+               err(1, "setsockopt(CFIL_OPT_NECP_CONTROL_UNIT, %u)", necp_control_unit);
+       
+       bzero(&kv, sizeof(struct kevent));
+       kv.ident = sf;
+       kv.filter = EVFILT_READ;
+       kv.flags = EV_ADD;
+       if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1)
+               err(1, "kevent(sf)");
+       
+       bzero(&kv, sizeof(struct kevent));
+       kv.ident = fdin;
+       kv.filter = EVFILT_READ;
+       kv.flags = EV_ADD;
+       if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1)
+               err(1, "kevent(sf)");
+       
+       buffer = malloc(MAX_BUFFER);
+       if (buffer == NULL)
+               err(1, "malloc()");
+
+       gettimeofday(&now, NULL);
+       
+       while (1) {
+               last_time = now;
+               if (delay_ms && timerisset(&deadline)) {
+                       timersub(&deadline, &now, &delta);
+                       TIMEVAL_TO_TIMESPEC(&delta, &interval);
+                       timeout = &interval;
+               } else {
+                       timeout = NULL;
+               }
+               
+               if (kevent(kq, NULL, 0, &kv, 1, timeout) == -1) {
+                       if (errno == EINTR)
+                               continue;
+                       err(1, "kevent()");
+               }
+               gettimeofday(&now, NULL);
+               timersub(&now, &last_time, &elapsed);
+               if (delay_ms && timerisset(&deadline)) {
+                       if (timercmp(&now, &deadline, >=)) {
+                               process_delayed_actions();
+                               interval.tv_sec = 0;
+                               interval.tv_nsec = 0;
+                       }
+               }
+               
+               if (kv.ident == sf && kv.filter == EVFILT_READ) {
+                       while (1) {
+                               ssize_t nread;
+                               
+                               nread = recv(sf, buffer, MAX_BUFFER, 0);
+                               if (nread == 0) {
+                                       warnx("recv(sf) returned 0, connection closed");
+                                       break;
+                               }
+                               if (nread == -1) {
+                                       if (errno == EINTR)
+                                               continue;
+                                       if (errno == EWOULDBLOCK)
+                                               break;
+                                       err(1, "recv()");
+                                       
+                               }
+                               if (nread < sizeof(struct cfil_msg_hdr))
+                                       errx(1, "too small");
+                               hdr = (struct cfil_msg_hdr *)buffer;
+                               
+                               
+                               if (hdr->cfm_type != CFM_TYPE_EVENT) {
+                                       warnx("not a content filter event type %u", hdr->cfm_type);
+                                       continue;
+                               }
+                               switch (hdr->cfm_op) {
+                                       case CFM_OP_SOCKET_ATTACHED: {
+                                               struct cfil_msg_sock_attached *msg_attached = (struct cfil_msg_sock_attached *)hdr;
+                                               
+                                               if (verbosity > -2)
+                                                       print_hdr(hdr);
+                                               if (verbosity > -1)
+                                                       printf(" fam %d type %d proto %d pid %u epid %u\n",
+                                                              msg_attached->cfs_sock_family,
+                                                              msg_attached->cfs_sock_type,
+                                                              msg_attached->cfs_sock_protocol,
+                                                              msg_attached->cfs_pid,
+                                                      msg_attached->cfs_e_pid);
+                                               break;
+                                       }
+                                       case CFM_OP_SOCKET_CLOSED:
+                                       case CFM_OP_DISCONNECT_IN:
+                                       case CFM_OP_DISCONNECT_OUT:
+                                               if (verbosity > -2)
+                                                       print_hdr(hdr);
+                                               break;
+                                       case CFM_OP_DATA_OUT:
+                                       case CFM_OP_DATA_IN:
+                                               if (verbosity > -3)
+                                                       print_data_req((struct cfil_msg_data_event *)hdr);
+                                               break;
+                                       default:
+                                               warnx("unknown content filter event op %u", hdr->cfm_op);
+                                               continue;
+                               }
+                               switch (hdr->cfm_op) {
+                                       case CFM_OP_SOCKET_ATTACHED:
+                                               sock_info = add_sock_info(hdr->cfm_sock_id);
+                                               if (sock_info == NULL) {
+                                                       warnx("sock_id %llx already exists", hdr->cfm_sock_id);
+                                                       continue;
+                                               }
+                                               break;
+                                       case CFM_OP_DATA_OUT:
+                                       case CFM_OP_DATA_IN:
+                                       case CFM_OP_DISCONNECT_IN:
+                                       case CFM_OP_DISCONNECT_OUT:
+                                       case CFM_OP_SOCKET_CLOSED:
+                                               sock_info = find_sock_info(hdr->cfm_sock_id);
+                                               
+                                               if (sock_info == NULL) {
+                                                       warnx("unexpected data message, sock_info is NULL");
+                                                       continue;
+                                               }
+                                               break;
+                                       default:
+                                               warnx("unknown content filter event op %u", hdr->cfm_op);
+                                               continue;
+                               }
+                               
+
+                               switch (hdr->cfm_op) {
+                                       case CFM_OP_SOCKET_ATTACHED: {
+                                               if ((mode & MODE_PASS) || (mode & MODE_PEEK) || auto_start) {
+                                                       sock_info->si_out_pass = default_out_pass;
+                                                       sock_info->si_out_peek = (mode & MODE_PEEK) ? peek_inc : (mode & MODE_PASS) ? CFM_MAX_OFFSET : default_out_peek;
+                                                       sock_info->si_in_pass = default_in_pass;
+                                                       sock_info->si_in_peek = (mode & MODE_PEEK) ? peek_inc : (mode & MODE_PASS) ? CFM_MAX_OFFSET : default_in_peek;
+                                                       
+                                                       send_action_message(CFM_OP_DATA_UPDATE, sock_info, 0);
+                                               }
+                                               break;
+                                       }
+                                       case CFM_OP_SOCKET_CLOSED: {
+                                               remove_sock_info(hdr->cfm_sock_id);
+                                               sock_info = NULL;
+                                               break;
+                                       }
+                                       case CFM_OP_DATA_OUT:
+                                       case CFM_OP_DATA_IN: {
+                                               struct cfil_msg_data_event *data_req = (struct cfil_msg_data_event *)hdr;
+                                                                                               
+                                               if (pass_loopback && is_loopback(data_req)) {
+                                                       sock_info->si_out_pass = CFM_MAX_OFFSET;
+                                                       sock_info->si_in_pass = CFM_MAX_OFFSET;
+                                               } else {
+                                                       if (drop(sock_info))
+                                                               continue;
+                                                       
+                                                       if ((mode & MODE_PASS)) {
+                                                               if (data_req->cfd_msghdr.cfm_op == CFM_OP_DATA_OUT) {
+                                                                       if (pass_offset == 0 || pass_offset == CFM_MAX_OFFSET)
+                                                                               sock_info->si_out_pass = data_req->cfd_end_offset;
+                                                                       else if (data_req->cfd_end_offset > pass_offset) {
+                                                                               sock_info->si_out_pass = CFM_MAX_OFFSET;
+                                                                               sock_info->si_in_pass = CFM_MAX_OFFSET;
+                                                                       }
+                                                                       sock_info->si_out_peek = (mode & MODE_PEEK) ?
+                                                                       data_req->cfd_end_offset + peek_inc : 0;
+                                                               } else {
+                                                                       if (pass_offset == 0 || pass_offset == CFM_MAX_OFFSET)
+                                                                               sock_info->si_in_pass = data_req->cfd_end_offset;
+                                                                       else if (data_req->cfd_end_offset > pass_offset) {
+                                                                               sock_info->si_out_pass = CFM_MAX_OFFSET;
+                                                                               sock_info->si_in_pass = CFM_MAX_OFFSET;
+                                                                       }
+                                                                       sock_info->si_in_peek = (mode & MODE_PEEK) ?
+                                                                       data_req->cfd_end_offset + peek_inc : 0;
+                                                               }
+                                                       } else {
+                                                               break;
+                                                       }
+                                               }
+                                               send_action_message(CFM_OP_DATA_UPDATE, sock_info, 0);
+                                               
+                                               break;
+                                       }
+                                       case CFM_OP_DISCONNECT_IN:
+                                       case CFM_OP_DISCONNECT_OUT: {
+                                               if (drop(sock_info))
+                                                       continue;
+                                               
+                                               if ((mode & MODE_PASS)) {
+                                                       sock_info->si_out_pass = CFM_MAX_OFFSET;
+                                                       sock_info->si_in_pass = CFM_MAX_OFFSET;
+                                                       
+                                                       send_action_message(CFM_OP_DATA_UPDATE, sock_info, 0);
+                                               }
+                                               break;
+                                       }
+                                       default:
+                                               warnx("unkown message op %u", hdr->cfm_op);
+                                               break;
+                               }
+                               if (sock_info)
+                                       last_sock_id = sock_info->si_sock_id;
+                       }
+               }
+               if (kv.ident == fdin && kv.filter == EVFILT_READ) {
+                       ssize_t nread;
+                       uint64_t offset = 0;
+                       int nitems;
+                       int op = 0;
+                       
+                       nread = getline(&linep, &linecap, stdin);
+                       if (nread == -1)
+                               errx(1, "getline()");
+                       
+                       if (verbosity > 2)
+                               printf("linecap %lu nread %lu\n", linecap, nread);
+                       if (nread > 0)
+                               linep[nread - 1] = '\0';
+                       
+                       if (verbosity > 2)
+                               HexDump(linep, linecap);
+                       
+                       if (*linep == 0)
+                               continue;
+                       
+                       if (cmdptr == NULL || argptr == NULL || linecap > cmdlen) {
+                               cmdlen = linecap;
+                               cmdptr = realloc(cmdptr, cmdlen);
+                               argptr = realloc(argptr, cmdlen);
+                       }
+                       
+                       /* 
+                        * Trick to support unisgned and hexadecimal arguments
+                        * as I can't figure out sscanf() conversions
+                        */
+                       nitems = sscanf(linep, "%s %s", cmdptr, argptr);
+                       if (nitems == 0) {
+                               warnx("I didn't get that...");
+                               continue;
+                       } else if (nitems > 1) {
+                               if (offset_from_str(argptr, &offset) == 0) {
+                                       warnx("I didn't get that either...");
+                                       continue;
+                               }
+                       }
+                       if (verbosity > 2)
+                               printf("nitems %d %s %s\n", nitems, cmdptr, argptr);
+
+                       bzero(&action, sizeof(struct cfil_msg_action));
+                       action.cfa_msghdr.cfm_len = sizeof(struct cfil_msg_action);
+                       action.cfa_msghdr.cfm_version = CFM_VERSION_CURRENT;
+                       action.cfa_msghdr.cfm_type = CFM_TYPE_ACTION;
+
+                       if (strcasecmp(cmdptr, "passout") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_pass_offset = offset;
+                       } else if (strcasecmp(cmdptr, "passin") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_in_pass_offset = offset;
+                       } else if (strcasecmp(cmdptr, "pass") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_pass_offset = offset;
+                               action.cfa_in_pass_offset = offset;
+                       } else if (strcasecmp(cmdptr, "peekout") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_peek_offset = offset;
+                       } else if (strcasecmp(cmdptr, "peekin") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_in_peek_offset = offset;
+                       } else if (strcasecmp(cmdptr, "peek") == 0 && nitems > 1) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_peek_offset = offset;
+                               action.cfa_in_peek_offset = offset;
+                       } else if (strcasecmp(cmdptr, "start") == 0) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_pass_offset = 0;
+                               action.cfa_out_peek_offset = CFM_MAX_OFFSET;
+                               action.cfa_in_pass_offset = 0;
+                               action.cfa_in_peek_offset = CFM_MAX_OFFSET;
+                       } else if (strcasecmp(cmdptr, "peekall") == 0) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_peek_offset = CFM_MAX_OFFSET;
+                               action.cfa_in_peek_offset = CFM_MAX_OFFSET;
+                       } else if (strcasecmp(cmdptr, "passall") == 0) {
+                               op = CFM_OP_DATA_UPDATE;
+                               action.cfa_out_pass_offset = CFM_MAX_OFFSET;
+                               action.cfa_out_peek_offset = CFM_MAX_OFFSET;
+                               action.cfa_in_pass_offset = CFM_MAX_OFFSET;
+                               action.cfa_in_peek_offset = CFM_MAX_OFFSET;
+                       } else if (strcasecmp(cmdptr, "drop") == 0)
+                               op = CFM_OP_DROP;
+                       else if (strcasecmp(cmdptr, "sock") == 0) {
+                               last_sock_id = offset;
+                               printf("last_sock_id 0x%llx\n", last_sock_id);
+                       } else
+                               warnx("syntax error");
+                       
+                       if (op == CFM_OP_DATA_UPDATE || op == CFM_OP_DROP) {
+                               action.cfa_msghdr.cfm_op = op;
+                               action.cfa_msghdr.cfm_sock_id = last_sock_id;
+                               print_action_msg(&action);
+                               
+                               if (send(sf, &action, sizeof(struct cfil_msg_action), 0) == -1)
+                                       warn("send()");
+                       }
+               }
+       }
+       
+       return 0;
+}
+
+static const char *
+basename(const char * str)
+{
+       const char *last_slash = strrchr(str, '/');
+       
+       if (last_slash == NULL)
+               return (str);
+       else
+               return (last_slash + 1);
+}
+
+struct option_desc {
+       const char *option;
+       const char *description;
+       int required;
+};
+
+struct option_desc option_desc_list[] = {
+       { "-a offset", "auto start with offset", 0 },
+       { "-d offset value", "default offset value for passin, peekin, passout, peekout, pass, peek", 0 },
+       { "-h", "dsiplay this help", 0 },
+       { "-i", "interactive mode", 0 },
+       { "-k increment", "peek mode with increment", 0 },
+       {"-l", "pass loopback", 0 },
+       { "-m length", "max dump length", 0 },
+       { "-p offset", "pass mode (all or after given offset if > 0)", 0 },
+       { "-q", "decrease verbose level", 0 },
+       { "-r random", "random drop rate", 0 },
+       { "-s ", "display content filter statistics (all, sock, filt, cfil)", 0 },
+       { "-t delay", "pass delay in microseconds", 0 },
+       { "-u unit", "NECP filter control unit", 1 },
+       { "-v", "increase verbose level", 0 },
+       { NULL, NULL, 0 }  /* Mark end of list */
+};
+
+static void
+usage(const char *cmd)
+{
+       struct option_desc *option_desc;
+       char *usage_str = malloc(LINE_MAX);
+       size_t usage_len;
+       
+       if (usage_str == NULL)
+               err(1, "%s: malloc(%d)", __func__, LINE_MAX);
+       
+       usage_len = snprintf(usage_str, LINE_MAX, "# usage: %s ", basename(cmd));
+       
+       for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+               int len;
+               
+               if (option_desc->required)
+                       len = snprintf(usage_str + usage_len, LINE_MAX - usage_len, "%s ", option_desc->option);
+               else
+                       len = snprintf(usage_str + usage_len, LINE_MAX - usage_len, "[%s] ", option_desc->option);
+               if (len < 0)
+                       err(1, "%s: snprintf(", __func__);
+               
+               usage_len += len;
+               if (usage_len > LINE_MAX)
+                       break;
+       }
+       printf("%s\n", usage_str);
+       printf("options:\n");
+       
+       for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+               printf(" %-20s # %s\n", option_desc->option, option_desc->description);
+       }
+       
+}
+
+int
+main(int argc, char * const argv[])
+{
+       int ch;
+       double d;
+       int stats_sock_list = 0;
+       int stats_filt_list = 0;
+       int stats_cfil_stats = 0;
+       
+       while ((ch = getopt(argc, argv, "a:d:hik:lm:p:qr:s:t:u:v")) != -1) {
+               switch (ch) {
+                       case 'a':
+                               auto_start = strtoul(optarg, NULL, 0);
+                               break;
+                       case 'd': {
+                               if (optind >= argc)
+                                       errx(1, "'-d' needs 2 parameters");
+                               if (strcasecmp(optarg, "passout") == 0) {
+                                       if (offset_from_str(argv[optind], &default_out_pass) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                               } else if (strcasecmp(optarg, "passin") == 0) {
+                                       if (offset_from_str(argv[optind], &default_in_pass) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                               } else if (strcasecmp(optarg, "pass") == 0) {
+                                       if (offset_from_str(argv[optind], &default_out_pass) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                                       default_in_pass = default_out_pass;
+                               } else if (strcasecmp(optarg, "peekout") == 0) {
+                                       if (offset_from_str(argv[optind], &default_out_peek) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                               } else if (strcasecmp(optarg, "peekin") == 0) {
+                                       if (offset_from_str(argv[optind], &default_in_peek) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                               } else if (strcasecmp(optarg, "peek") == 0) {
+                                       if (offset_from_str(argv[optind], &default_out_peek) == 0)
+                                               errx(1, "bad %s offset: %s", optarg, argv[optind + 1]);
+                                       default_in_peek = default_out_peek;
+                               } else
+                                       errx(1, "syntax error");
+                               break;
+                       }
+                       case 'h':
+                               usage(argv[0]);
+                               exit(0);
+                       case 'i':
+                               mode |= MODE_INTERACTIVE;
+                               break;
+                       case 'k':
+                               mode |= MODE_PEEK;
+                               if (offset_from_str(optarg, &peek_inc) == 0)
+                                       errx(1, "bad peek offset: %s", optarg);
+                               break;
+                       case 'l':
+                               pass_loopback = 1;
+                               break;
+                       case 'm':
+                               max_dump_len = strtoul(optarg, NULL, 0);
+                               break;
+                       case 'p':
+                               mode |= MODE_PASS;
+                               if (offset_from_str(optarg, &pass_offset) == 0)
+                                       errx(1, "bad pass offset: %s", optarg);
+                               break;
+                       case 'q':
+                               verbosity--;
+                               break;
+                       case 'r':
+                               d = strtod(optarg, NULL);
+                               if (d < 0 || d > 1)
+                                       errx(1, "bad drop rate: %s -- it must be between 0 and 1", optarg);
+                               random_drop = (uint32_t)(d * UINT32_MAX);
+                               break;
+                       case 's':
+                               if (strcasecmp(optarg, "all") == 0) {
+                                       stats_sock_list = 1;
+                                       stats_filt_list = 1;
+                                       stats_cfil_stats = 1;
+                               } else if (strcasecmp(optarg, "sock") == 0) {
+                                       stats_sock_list = 1;
+                               } else if (strcasecmp(optarg, "filt") == 0) {
+                                       stats_filt_list = 1;
+                               } else if (strcasecmp(optarg, "cfil") == 0) {
+                                       stats_cfil_stats = 1;
+                               } else {
+                                       warnx("# Error: unknown type of statistic: %s", optarg);
+                                       usage(argv[0]);
+                                       exit(0);
+                               }
+                               break;
+                       case 't':
+                               mode |= MODE_DELAY;
+                               delay_ms = strtoul(optarg, NULL, 0);
+                               delay_tv.tv_sec = delay_ms / 1000;
+                               delay_tv.tv_usec = (delay_ms % 1000) * 1000;
+                               break;
+                       case 'u':
+                               necp_control_unit = (uint32_t)strtoul(optarg, NULL, 0);
+                               break;
+                       case 'v':
+                               verbosity++;
+                               break;
+                       default:
+                               errx(1, "# syntax error, unknow option '%d'", ch);
+                               usage(argv[0]);
+                               exit(0);
+               }
+       }
+       
+       if (stats_filt_list)
+               print_filter_list();
+       if (stats_sock_list)
+               print_socket_list();
+       if (stats_cfil_stats)
+               print_cfil_stats();
+       if (necp_control_unit == 0 && (stats_filt_list || stats_sock_list || stats_cfil_stats))
+               return (0);
+       
+       if (necp_control_unit == 0) {
+               warnx("necp filter control unit is 0");
+               usage(argv[0]);
+               exit(EX_USAGE);
+       }
+       doit();
+       
+       
+       return (0);
+}
+
index 19c09d4d69fab7c66d76cd8bc52e119d3dc23c93..4da47241e2431603dd57707c7904c0c271b15867 100644 (file)
@@ -1,6 +1,3 @@
-.\"
-.\" $FreeBSD: /repoman/r/ncvs/src/sbin/ipfw/ipfw.8,v 1.63.2.38 2003/07/28 07:15:13 luigi Exp $
-.\"
 .Dd August 13, 2002
 .Dt DNCTL 8
 .Os Darwin
 .Dd August 13, 2002
 .Dt DNCTL 8
 .Os Darwin
@@ -361,9 +358,6 @@ Most connections need packets going in both directions.
 .It
 Remember to test very carefully.
 It is a good idea to be near the console when doing this.
 .It
 Remember to test very carefully.
 It is a good idea to be near the console when doing this.
-If you cannot be near the console,
-use an auto-recovery script such as the one in
-.Pa /usr/share/examples/ipfw/change_rules.sh .
 .It
 Don't forget the loopback interface.
 .El
 .It
 Don't forget the loopback interface.
 .El
@@ -402,40 +396,28 @@ for the RED algorithm.
 .El
 .Sh EXAMPLES
 The following rules show some of the applications of
 .El
 .Sh EXAMPLES
 The following rules show some of the applications of
-.Xr dummynet 4
-for simulations and the like. The examples use the obsolete 
-.Nm ipfw 
-command for illustration only as the use of 
-.Nm ipfw 
-is discouraged.
-.Pp
-This rule drops random incoming packets with a probability
-of 5%:
-.Pp
-.Dl "ipfw add pipe 10 ip from any to any"
+for simulations and the like by using 
+.Em dummynet
+rules in
+.Xr pf.conf 8
+configuration files.
+.Pp
+To drop random incoming IPv4 and IPv6 ICMP packets with a probability of 5%, 
+create a pipe:
 .Dl "dnctl pipe 10 config plr 0.05"
 .Pp
 .Dl "dnctl pipe 10 config plr 0.05"
 .Pp
-We can use pipes to artificially limit bandwidth, e.g. on a
-machine acting as a router, if we want to limit traffic from
-local clients on 192.168.2.0/24 we do:
-.Pp
-.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out"
-.Dl "dnctl pipe 1 config bw 300Kbit/s queue 50KBytes"
-.Pp
-note that we use the
-.Cm out
-modifier so that the rule is not used twice.
-Remember in fact that
-.Nm
-rules are checked both on incoming and outgoing packets.
+and add these rules in your pf.conf file:
+.Dl "dummynet in inet proto icmp all pipe 10"
+.Dl "dummynet in inet6 proto ipv6-icmp all pipe 10"
 .Pp
 Should we want to simulate a bidirectional link with bandwidth
 .Pp
 Should we want to simulate a bidirectional link with bandwidth
-limitations, the correct way is the following:
+limitations, the correct way is to create a pipe for each direction:
+.Dl "dnctl pipe 1 config bw 14Kbit/s queue 10Kbytes"
+.Dl "dnctl pipe 2 config bw 1Kbit/s queue 10Kbytes"
 .Pp
 .Pp
-.Dl "ipfw add pipe 1 ip from any to any out"
-.Dl "ipfw add pipe 2 ip from any to any in"
-.Dl "dnctl pipe 1 config bw 64Kbit/s queue 10Kbytes"
-.Dl "dnctl pipe 2 config bw 64Kbit/s queue 10Kbytes"
+and add these rules in your pf.conf file:
+.Dl "dummynet in all pipe 1"
+.Dl "dummynet out all pipe 2"
 .Pp
 The above can be very useful, e.g. if you want to see how
 your fancy Web page will look for a residential user who
 .Pp
 The above can be very useful, e.g. if you want to see how
 your fancy Web page will look for a residential user who
@@ -443,80 +425,59 @@ is connected only through a slow link.
 You should not use only one pipe for both directions, unless
 you want to simulate a half-duplex medium (e.g. AppleTalk,
 Ethernet, IRDA).
 You should not use only one pipe for both directions, unless
 you want to simulate a half-duplex medium (e.g. AppleTalk,
 Ethernet, IRDA).
-It is not necessary that both pipes have the same configuration,
-so we can also simulate asymmetric links.
 .Pp
 .Pp
-Should we want to verify network performance with the RED queue
-management algorithm:
+Note that with the above rules the pipes receive traffic for both the 
+IPv4 and IPv6 protocols.
 .Pp
 .Pp
-.Dl "ipfw add pipe 1 ip from any to any"
+Should we want to verify network performance with the RED queue
+management algorithm, create this pipe:
 .Dl "dnctl pipe 1 config bw 500Kbit/s queue 100 red 0.002/30/80/0.1"
 .Pp
 .Dl "dnctl pipe 1 config bw 500Kbit/s queue 100 red 0.002/30/80/0.1"
 .Pp
+and then add these rules to you pf.conf file:
+.Dl "dummynet all pipe 1"
+.Pp
 Another typical application of the traffic shaper is to
 introduce some delay in the communication.
 This can significantly affect applications which do a lot of Remote
 Procedure Calls, and where the round-trip-time of the
 connection often becomes a limiting factor much more than
 bandwidth:
 Another typical application of the traffic shaper is to
 introduce some delay in the communication.
 This can significantly affect applications which do a lot of Remote
 Procedure Calls, and where the round-trip-time of the
 connection often becomes a limiting factor much more than
 bandwidth:
-.Pp
-.Dl "ipfw add pipe 1 ip from any to any out"
-.Dl "ipfw add pipe 2 ip from any to any in"
 .Dl "dnctl pipe 1 config delay 250ms bw 1Mbit/s"
 .Dl "dnctl pipe 2 config delay 250ms bw 1Mbit/s"
 .Pp
 .Dl "dnctl pipe 1 config delay 250ms bw 1Mbit/s"
 .Dl "dnctl pipe 2 config delay 250ms bw 1Mbit/s"
 .Pp
+and add these rules in your pf.conf file:
+.Dl "dummynet in all pipe 1"
+.Dl "dummynet out all pipe 2"
+.Pp
 Per-flow queueing can be useful for a variety of purposes.
 A very simple one is counting traffic:
 Per-flow queueing can be useful for a variety of purposes.
 A very simple one is counting traffic:
-.Pp
-.Dl "ipfw add pipe 1 tcp from any to any"
-.Dl "ipfw add pipe 1 udp from any to any"
-.Dl "ipfw add pipe 1 ip from any to any"
 .Dl "dnctl pipe 1 config mask all"
 .Pp
 .Dl "dnctl pipe 1 config mask all"
 .Pp
+and add these statements in your pf.conf file:
+.Dl "dummynet in quick proto tcp all pipe 1"
+.Dl "dummynet out quick proto tcp all pipe 1"
+.Dl "dummynet in quick proto udp all pipe 1"
+.Dl "dummynet out quick proto udp all pipe 1"
+.Dl "dummynet in quick all pipe 1"
+.Dl "dummynet out quick all pipe 1"
+.Pp
 The above set of rules will create queues (and collect
 statistics) for all traffic.
 Because the pipes have no limitations, the only effect is
 collecting statistics.
 The above set of rules will create queues (and collect
 statistics) for all traffic.
 Because the pipes have no limitations, the only effect is
 collecting statistics.
-Note that we need 3 rules, not just the last one, because
+Note that we need six rules, not just the last two one, because
 when
 .Nm
 tries to match IP packets it will not consider ports, so we
 would not see connections on separate ports as different
 ones.
 when
 .Nm
 tries to match IP packets it will not consider ports, so we
 would not see connections on separate ports as different
 ones.
-.Pp
-A more sophisticated example is limiting the outbound traffic
-on a net with per-host limits, rather than per-network limits:
-.Pp
-.Dl "ipfw add pipe 1 ip from 192.168.2.0/24 to any out"
-.Dl "ipfw add pipe 2 ip from any to 192.168.2.0/24 in"
-.Dl "dnctl pipe 1 config mask src-ip 0x000000ff bw 200Kbit/s queue 20Kbytes"
-.Dl "dnctl pipe 2 config mask dst-ip 0x000000ff bw 200Kbit/s queue 20Kbytes"
-.Ss SETS OF RULES
-To add a set of rules atomically, e.g. set 18:
-.Pp
-.Dl "ipfw set disable 18"
-.Dl "ipfw add NN set 18 ...         # repeat as needed"
-.Dl "ipfw set enable 18"
-.Pp
-To delete a set of rules atomically the command is simply:
-.Pp
-.Dl "ipfw delete set 18"
-.Pp
-To test a ruleset and disable it and regain control if something goes wrong:
-.Pp
-.Dl "ipfw set disable 18"
-.Dl "ipfw add NN set 18 ...         # repeat as needed"
-.Dl "ipfw set enable 18; echo done; sleep 30 && ipfw set disable 18"
-.Pp
-Here if everything goes well, you press control-C before the "sleep"
-terminates, and your ruleset will be left active. Otherwise, e.g. if
-you cannot access your box, the ruleset will be disabled after
-the sleep terminates thus restoring the previous situation.
 .Sh SEE ALSO
 .Xr cpp 1 ,
 .Sh SEE ALSO
 .Xr cpp 1 ,
-.Xr m4 1 ,
 .Xr dummynet 4 ,
 .Xr dummynet 4 ,
+.Xr m4 1 ,
 .Xr ip 4 ,
 .Xr ip 4 ,
-.Xr ipfirewall 4 ,
+.Xr pfctl 8 ,
+.Xr pf.conf 5 ,
 .Xr protocols 5 ,
 .Xr services 5 ,
 .Xr sysctl 8
 .Xr protocols 5 ,
 .Xr services 5 ,
 .Xr sysctl 8
@@ -545,5 +506,3 @@ was introduced in
 .Fx 2.2.8 .
 Stateful extensions were introduced in
 .Fx 4.0 .
 .Fx 2.2.8 .
 Stateful extensions were introduced in
 .Fx 4.0 .
-.Nm ipfw2
-was introduced in Summer 2002.
index 9ad175e305608b94d0cf14325b269cab1eb62199..ae05970409dbae4a59377440e124348cabdaf634 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/af_inet.c,v 1.3.6.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
-
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
index 14e2a60299e50b83a28e6c0c897395dfb651c406..6462597bf3a0e5abc1901d6b0cfda5b9ec1aeb3b 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/af_inet6.c,v 1.6.6.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -345,6 +341,8 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
                printf("autoconf ");
        if ((flags6 & IN6_IFF_TEMPORARY) != 0)
                printf("temporary ");
                printf("autoconf ");
        if ((flags6 & IN6_IFF_TEMPORARY) != 0)
                printf("temporary ");
+       if ((flags6 & IN6_IFF_DYNAMIC) != 0)
+               printf("dynamic ");
        if ((flags6 & IN6_IFF_SECURED) != 0)
                printf("secured ");
 
        if ((flags6 & IN6_IFF_SECURED) != 0)
                printf("secured ");
 
index b855242f649a43ba9696cd627b20b728e64121e4..ca9444c852a1e282ac75827f096aefb7df42ee54 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/af_link.c,v 1.4.6.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
-
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
index 7a3c1b7a8a46adc3597e1d0e660153dc9dbf2dd4..0b610ceafa18c00aba41f419d7c73fe9d29898f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2009-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2014 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -82,6 +82,8 @@
 #include <err.h>
 #include <errno.h>
 
 #include <err.h>
 #include <errno.h>
 
+#include <arpa/inet.h>
+
 #include "ifconfig.h"
 
 #define PV2ID(pv, epri, eaddr)  do {           \
 #include "ifconfig.h"
 
 #define PV2ID(pv, epri, eaddr)  do {           \
@@ -172,7 +174,7 @@ bridge_interfaces(int s, const char *prefix)
        char *inbuf = NULL, *ninbuf;
        char *p, *pad;
        int i, len = 8192;
        char *inbuf = NULL, *ninbuf;
        char *p, *pad;
        int i, len = 8192;
-
+       
        pad = strdup(prefix);
        if (pad == NULL)
                err(1, "strdup");
        pad = strdup(prefix);
        if (pad == NULL)
                err(1, "strdup");
@@ -230,9 +232,36 @@ bridge_interfaces(int s, const char *prefix)
                                    req->ifbr_state);
                }
                printf("\n");
                                    req->ifbr_state);
                }
                printf("\n");
+               
+               if (verbose) {
+                       struct ifbrhostfilter ifbrfh;
+                       struct in_addr in;
+                       struct ether_addr ea;
+                       
+                       bzero(&ifbrfh, sizeof(struct ifbrhostfilter));
+                       strlcpy(ifbrfh.ifbrhf_ifsname, req->ifbr_ifsname, sizeof(ifbrfh.ifbrhf_ifsname));
+                       if (do_cmd(s, BRDGGHOSTFILTER, &ifbrfh, sizeof(ifbrfh), 0) < 0)
+                               err(1, "unable to get host filter settings for %s",
+                                   ifbrfh.ifbrhf_ifsname);
+                       
+                       if (ifbrfh.ifbrhf_flags & IFBRHF_ENABLED) {
+                               in.s_addr = ifbrfh.ifbrhf_ipsrc;
+                               bcopy(ifbrfh.ifbrhf_hwsrca, ea.octet, ETHER_ADDR_LEN);
+                       } else {
+                               in.s_addr = INADDR_ANY;
+                               bzero(ea.octet, ETHER_ADDR_LEN);
+                       }
+                       printf("%s", pad);
+                       printf("hostfilter %d hw: %s ip: %s",
+                              ifbrfh.ifbrhf_flags & IFBRHF_ENABLED ? 1 : 0,
+                               ether_ntoa(&ea), inet_ntoa(in));
+                       
+                       printf("\n");
+               }
        }
 
        free(inbuf);
        }
 
        free(inbuf);
+       free(pad);
 }
 
 static void
 }
 
 static void
@@ -745,6 +774,46 @@ unsetbridge_private(const char *val, int d, int s, const struct afswtch *afp)
 }
 #endif
 
 }
 #endif
 
+
+static void
+setbridge_hostfilter(const char *ifn, const char *addr, int s,
+                    const struct afswtch *afp)
+{
+       struct ifbrhostfilter req;
+       struct ether_addr *ea;
+       struct in_addr in;
+       
+       memset(&req, 0, sizeof(req));
+       req.ifbrhf_flags = IFBRHF_ENABLED;
+       
+       strlcpy(req.ifbrhf_ifsname, ifn, sizeof(req.ifbrhf_ifsname));
+       
+       ea = ether_aton(addr);
+       if (ea != NULL) {
+               req.ifbrhf_flags |= IFBRHF_HWSRC;
+               bcopy(ea, req.ifbrhf_hwsrca, sizeof(req.ifbrhf_hwsrca));
+       } else if (inet_aton(addr, &in) != 0) {
+               req.ifbrhf_flags |= IFBRHF_IPSRC;
+               req.ifbrhf_ipsrc = in.s_addr;
+       } else
+               errx(1, "invalid address: %s", addr);
+       
+       if (do_cmd(s, BRDGSHOSTFILTER, &req, sizeof(req), 1) < 0)
+               err(1, "BRDGSHOSTFILTER %s %s", ifn, addr);
+}
+
+static void
+unsetbridge_hostfilter(const char *ifn, int d, int s, const struct afswtch *afp)
+{
+       struct ifbrhostfilter req;
+       
+       memset(&req, 0, sizeof(req));
+       strlcpy(req.ifbrhf_ifsname, ifn, sizeof(req.ifbrhf_ifsname));
+       
+       if (do_cmd(s, BRDGSHOSTFILTER, &req, sizeof(req), 1) < 0)
+               err(1, "BRDGSHOSTFILTER");
+}
+
 static struct cmd bridge_cmds[] = {
        DEF_CMD_ARG("addm",             setbridge_add),
        DEF_CMD_ARG("deletem",          setbridge_delete),
 static struct cmd bridge_cmds[] = {
        DEF_CMD_ARG("addm",             setbridge_add),
        DEF_CMD_ARG("deletem",          setbridge_delete),
@@ -794,6 +863,8 @@ static struct cmd bridge_cmds[] = {
        DEF_CMD_ARG("private",          setbridge_private),
        DEF_CMD_ARG("-private",         unsetbridge_private),
 #endif
        DEF_CMD_ARG("private",          setbridge_private),
        DEF_CMD_ARG("-private",         unsetbridge_private),
 #endif
+        DEF_CMD_ARG2("hostfilter",     setbridge_hostfilter),
+        DEF_CMD_ARG("-hostfilter",     unsetbridge_hostfilter),
 };
 static struct afswtch af_bridge = {
        .af_name        = "af_bridge",
 };
 static struct afswtch af_bridge = {
        .af_name        = "af_bridge",
index 16c66438937f6815d0f8d21c60bea9e19c9495af..f6b8c072ea463b01826834fa7b60c6b87eb9f952 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/ifclone.c,v 1.3.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif /* not lint */
-
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
index 91a2926b1431e35bd478022345d0af3340a280b6..6a7ea05bb0b51d8ad882f656c13238e40c2e9420 100644 (file)
@@ -864,6 +864,13 @@ Set the maximum number of hosts allowed from an interface, packets with unknown
 source addresses are dropped until an existing host cache entry expires or is
 removed.
 Set to 0 to disable.
 source addresses are dropped until an existing host cache entry expires or is
 removed.
 Set to 0 to disable.
+.It Cm hostfilter Ar interface Ar address
+Configure the bridge to accept incoming packet on the interface
+only if they match the given MAC address and IP address
+-- use the command twice to set both type of addresses.
+Other filtering restrictions apply.
+.It Cm -hostfilter Ar interface
+Allow traffic from any host on that interface.
 .El
 .Pp
 The following parameters are specific to vlan interfaces:
 .El
 .Pp
 The following parameters are specific to vlan interfaces:
index ecc5fd4dbd8f1acbd5586a7234d2f1ff0e98dc12..98ae666d2c01dfcd692132016f83d53cda4ec777 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2009-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2014 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+
 #ifndef lint
 #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 */
 
 "@(#) 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 <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -257,13 +251,9 @@ main(int argc, char *argv[])
        argc -= optind;
        argv += optind;
 
        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 &&
        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();
 
        /* nonsense.. */
@@ -971,6 +961,16 @@ setlog(const char *val, int dummy __unused, int s,
                warn("ioctl (set logging parameters)");
 }
 
                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);
+}
+
 #define        IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
 #define        IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
@@ -978,9 +978,9 @@ setlog(const char *val, int dummy __unused, int s,
 
 #define        IFEFBITS \
 "\020\1AUTOCONFIGURING\6IPV6_DISABLED\7ACCEPT_RTADV\10TXSTART\11RXPOLL" \
 
 #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\35SENDLIST\36DIRECTLINK\40UPDOWNCHANGE"
 
 #define        IFCAPBITS \
 "\020\1RXCSUM\2TXCSUM\3VLAN_MTU\4VLAN_HWTAGGING\5JUMBO_MTU" \
 
 #define        IFCAPBITS \
 "\020\1RXCSUM\2TXCSUM\3VLAN_MTU\4VLAN_HWTAGGING\5JUMBO_MTU" \
@@ -1576,6 +1576,8 @@ static struct cmd basic_cmds[] = {
        DEF_CMD_ARG("tbr",                      settbr),
        DEF_CMD_ARG("throttle",                 setthrottle),
        DEF_CMD_ARG("log",                      setlog),
        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),
 };
 
 static __constructor void
 };
 
 static __constructor void
index 8e78ccb68d497e8977fc0c7348b9db86fbfed2f4..9ec0a0ae84f88267df03c0ea3996a50d308da733 100644 (file)
 
 #include "ifconfig.h"
 
 
 #include "ifconfig.h"
 
-#ifndef lint
-static const char rcsid[] =
-  "$FreeBSD: src/sbin/ifconfig/ifvlan.c,v 1.12.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $";
-#endif
+#include <sys/cdefs.h>
 
 #define        NOTAG   ((u_short) -1)
 
 
 #define        NOTAG   ((u_short) -1)
 
index a6ed8b2fd377b9b413dff14d2c7ec2e9f0093e68..2a3dd90c427fbfbf4a7ebd728058f2d905ad285c 100644 (file)
@@ -25,6 +25,8 @@
        </dict>
        <key>UserName</key>
        <string>nobody</string>
        </dict>
        <key>UserName</key>
        <string>nobody</string>
+       <key>Umask</key>
+       <integer>7</integer>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
index 5f06353acff9742f51777ee0c2c785b08b10fff3..040def3346a057b5b325ab3acf3954a952cd0aab 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+
 #ifndef lint
 #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 */
 "@(#) Copyright (c) 1983, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
@@ -433,7 +435,7 @@ validate_access(char **filep, int mode)
     return (errno);
 
 
     return (errno);
 
 
-  fd = open(filename, O_RDWR|O_CREAT|O_TRUNC , S_IRUSR | S_IWUSR);
+  fd = open(filename, O_RDWR|O_CREAT|O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 
   if (fd < 0)
     return (errno + 100);
 
   if (fd < 0)
     return (errno + 100);
@@ -442,8 +444,6 @@ validate_access(char **filep, int mode)
   if (file == NULL) {
     return errno+100;
   }
   if (file == NULL) {
     return errno+100;
   }
-  if (fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) < 0)
-    return errno+100;
 
   return (0);  
 }
 
   return (0);  
 }
diff --git a/mptcp_client/conn_lib.c b/mptcp_client/conn_lib.c
new file mode 100644 (file)
index 0000000..56bfd46
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+//
+//  Created by Anumita Biswas on 10/30/12.
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+
+#include "conn_lib.h"
+
+int
+copyassocids(int s, associd_t **aidpp, uint32_t *cnt)
+{
+       struct so_aidreq aidr;
+       associd_t *buf;
+       int err;
+       
+       if (aidpp == NULL || cnt == NULL) {
+               errno = EINVAL;
+               return (-1);
+       }
+       *aidpp = NULL;
+       *cnt = 0;
+       
+       bzero(&aidr, sizeof (aidr));
+       
+       err = ioctl(s, SIOCGASSOCIDS, &aidr);
+       if (err != 0)
+               return (-1);
+       
+       /* none, just return */
+       if (aidr.sar_cnt == 0)
+               return (0);
+       
+       buf = calloc(aidr.sar_cnt, sizeof (associd_t));
+       if (buf == NULL)
+               return (-1);
+       
+       aidr.sar_aidp = buf;
+       err = ioctl(s, SIOCGASSOCIDS, &aidr);
+       if (err != 0) {
+               free(buf);
+               return (-1);
+       }
+       
+       *aidpp = buf;
+       *cnt = aidr.sar_cnt;
+       
+       return (0);
+}
+
+void
+freeassocids(associd_t *aidp)
+{
+       free(aidp);
+}
+
+int
+copyconnids(int s, associd_t aid, connid_t **cidp, uint32_t *cnt)
+{
+       struct so_cidreq cidr;
+       connid_t *buf;
+       int err;
+       
+       if (cidp == NULL || cnt == NULL) {
+               errno = EINVAL;
+               return (-1);
+       }
+       *cidp = NULL;
+       *cnt = 0;
+       
+       bzero(&cidr, sizeof (cidr));
+       
+       cidr.scr_aid = aid;
+       err = ioctl(s, SIOCGCONNIDS, &cidr);
+       if (err != 0)
+               return (-1);
+       
+       /* none, just return */
+       if (cidr.scr_cnt == 0)
+               return (0);
+       
+       buf = calloc(cidr.scr_cnt, sizeof (connid_t));
+       if (buf == NULL)
+               return (-1);
+       
+       cidr.scr_cidp = buf;
+       err = ioctl(s, SIOCGCONNIDS, &cidr);
+       if (err != 0) {
+               free(buf);
+               return (-1);
+       }
+       
+       *cidp = buf;
+       *cnt = cidr.scr_cnt;
+       
+       return (0);
+}
+
+void
+freeconnids(connid_t *cidp)
+{
+       free(cidp);
+}
+
+int
+copyconninfo(int s, connid_t cid, conninfo_t **cfop)
+{
+       struct sockaddr *src = NULL, *dst = NULL, *aux = NULL;
+       struct so_cinforeq scir;
+       conninfo_t *buf = NULL;
+       
+       if (cfop == NULL) {
+               errno = EINVAL;
+               goto error;
+       }
+       *cfop = NULL;
+       
+       bzero(&scir, sizeof (scir));
+       
+       scir.scir_cid = cid;
+       if (ioctl(s, SIOCGCONNINFO, &scir) != 0)
+               goto error;
+       
+       if (scir.scir_src_len != 0) {
+               src = calloc(1, scir.scir_src_len);
+               if (src == NULL)
+                       goto error;
+               scir.scir_src = src;
+       }
+       if (scir.scir_dst_len != 0) {
+               dst = calloc(1, scir.scir_dst_len);
+               if (dst == NULL)
+                       goto error;
+               scir.scir_dst = dst;
+       }
+       if (scir.scir_aux_len != 0) {
+               aux = calloc(1, scir.scir_aux_len);
+               if (aux == NULL)
+                       goto error;
+               scir.scir_aux_data = aux;
+       }
+       
+       if (ioctl(s, SIOCGCONNINFO, &scir) != 0)
+               goto error;
+       
+       buf = calloc(1, sizeof (*buf));
+       if (buf == NULL)
+               goto error;
+       
+       // When we query for the length using the first ioctl call above, the kernel
+       // tells us the length of the aux structure so we know how much to allocate
+       // memory. There may not be any aux data, which will be indicated by the aux
+       // data length using the second ioctl call.
+       if (scir.scir_aux_len == 0 && aux != NULL) {
+               free(aux);
+               aux = NULL;
+               scir.scir_aux_data = NULL;
+       }
+       
+       buf->ci_flags = scir.scir_flags;
+       buf->ci_ifindex = scir.scir_ifindex;
+       buf->ci_src = src;
+       buf->ci_dst = dst;
+       buf->ci_error = scir.scir_error;
+       buf->ci_aux_type = scir.scir_aux_type;
+       buf->ci_aux_data = aux;
+       *cfop = buf;
+       
+       return (0);
+       
+error:
+       if (src != NULL)
+               free(src);
+       if (dst != NULL)
+               free(dst);
+       if (aux != NULL)
+               free(aux);
+       if (buf != NULL)
+               free(buf);
+       
+       return (-1);
+}
+
+void
+freeconninfo(conninfo_t *cfo)
+{
+       if (cfo->ci_src != NULL)
+               free(cfo->ci_src);
+       
+       if (cfo->ci_dst != NULL)
+               free(cfo->ci_dst);
+       
+       if (cfo->ci_aux_data != NULL)
+               free(cfo->ci_aux_data);
+       
+       free(cfo);
+}
diff --git a/mptcp_client/conn_lib.h b/mptcp_client/conn_lib.h
new file mode 100644 (file)
index 0000000..b9c54a3
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+//
+//  Created by Anumita Biswas on 10/30/12.
+//
+
+#ifndef mptcp_client_conn_lib_h
+#define mptcp_client_conn_lib_h
+
+typedef struct conninfo {
+       __uint32_t                      ci_flags;                       /* see flags in sys/socket.h (CIF_CONNECTING, etc...) */
+       __uint32_t                      ci_ifindex;                     /* outbound interface */
+       struct sockaddr         *ci_src;                        /* source address */
+       struct sockaddr         *ci_dst;                        /* destination address */
+       int                                     ci_error;                       /* saved error */
+       __uint32_t                      ci_aux_type;            /* auxiliary data type */
+       void                            *ci_aux_data;           /* auxiliary data */
+} conninfo_t;
+
+extern int copyassocids(int, associd_t **, uint32_t *);
+extern void freeassocids(associd_t *);
+extern int copyconnids(int, associd_t, connid_t **, uint32_t *);
+extern void freeconnids(connid_t *);
+extern int copyconninfo(int, connid_t, conninfo_t **);
+extern void freeconninfo(conninfo_t *);
+
+#endif
\ No newline at end of file
diff --git a/mptcp_client/mptcp_client.1 b/mptcp_client/mptcp_client.1
new file mode 100644 (file)
index 0000000..eb9f15c
--- /dev/null
@@ -0,0 +1,23 @@
+.Dd 6/12/14\r
+.Dt mptcp_client 1\r
+.Os Darwin\r
+.Sh NAME\r
+.Nm mptcp_client\r
+.Nd Tool to exercise MPTCP.\r
+.Sh SYNOPSIS\r
+.Nm\r
+.Ar hostname\r
+.Ar port\r
+.Ar reqlen\r
+.Ar rsplen\r
+.Ar times\r
+.Ar alt_addr\r
+.Ar 0\r
+.Ar connorder\r
+.Ar longlived\r
+.Ar fastjoin\r
+.Sh DESCRIPTION\r
+.Nm\r
+is as an MPTCP client test tool that use the\r
+.Xr socket 2\r
+API.\r
diff --git a/mptcp_client/mptcp_client.c b/mptcp_client/mptcp_client.c
new file mode 100644 (file)
index 0000000..b432a1d
--- /dev/null
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1997
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+//
+//  Created by Anumita Biswas on 7/17/12.
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <err.h>
+#include <sysexits.h>
+#include <getopt.h>
+
+#include "conn_lib.h"
+
+struct so_cordreq socorder;
+static void showmpinfo(int s);
+
+#define MSG_HDR "Message Header"
+#define RESPONSE "I got your message"
+
+static int verbose = 0;
+
+static int32_t thiszone = 0;   /* time difference with gmt */
+
+char* setup_buffer1(int bufsz)
+{
+       int i = 0, j = 1;
+        char *buf = malloc(bufsz);
+        if (buf) {
+                bzero(buf, bufsz);
+                strlcpy(buf, MSG_HDR, sizeof(MSG_HDR));
+        }
+       for (i = sizeof(MSG_HDR); i < bufsz; i++) {
+               buf[i] = j;
+               j++;
+               if (j >= 255)
+                       j = 1;
+       }
+        return buf;
+}
+
+char* setup_buffer2(int bufsz)
+{
+       int i = 0;
+       char j = 'A';
+        char *buf = malloc(bufsz);
+        if (buf) {
+                bzero(buf, bufsz);
+                strlcpy(buf, MSG_HDR, sizeof(MSG_HDR));
+        }
+       for (i = sizeof(MSG_HDR); i < bufsz; i++) {
+               buf[i] = j;
+               j++;
+               if (j >= 'z')
+                       j = 'A';
+       }
+        return buf;
+}
+
+char *setup_buffer3(int bufsz)
+{
+       char *buf = malloc(bufsz);
+       if (buf) {
+               bzero(buf, bufsz);
+       }
+       return buf;
+}
+
+/*
+ * Returns the difference between gmt and local time in seconds.
+ * Use gmtime() and localtime() to keep things simple.
+ * from tcpdump/gmt2local.c
+ */
+static int32_t
+gmt2local(time_t t)
+{
+       int dt, dir;
+       struct tm *gmt, *loc;
+       struct tm sgmt;
+       
+       if (t == 0)
+               t = time(NULL);
+       gmt = &sgmt;
+       *gmt = *gmtime(&t);
+       loc = localtime(&t);
+       dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
+       (loc->tm_min - gmt->tm_min) * 60;
+       
+       /*
+        * If the year or julian day is different, we span 00:00 GMT
+        * and must add or subtract a day. Check the year first to
+        * avoid problems when the julian day wraps.
+        */
+       dir = loc->tm_year - gmt->tm_year;
+       if (dir == 0)
+               dir = loc->tm_yday - gmt->tm_yday;
+       dt += dir * 24 * 60 * 60;
+       
+       return (dt);
+}
+
+/*
+ * Print the timestamp
+ * from tcpdump/util.c
+ */
+static void
+ts_print(void)
+{
+       int s;
+       struct timeval tv;
+       
+       gettimeofday(&tv, NULL);
+       
+       /* Default */
+       s = (tv.tv_sec + thiszone) % 86400;
+       printf("%02d:%02d:%02d.%06u ", s / 3600, (s % 3600) / 60, s % 60,
+              (u_int32_t)tv.tv_usec);
+}
+
+static const char *
+basename(const char * str)
+{
+       const char *last_slash = strrchr(str, '/');
+       
+       if (last_slash == NULL)
+               return (str);
+       else
+               return (last_slash + 1);
+}
+
+struct option_desc {
+       const char *option;
+       const char *description;
+       int required;
+};
+
+struct option_desc option_desc_list[] = {
+       { "--host addr", "address of server to connect to", 1 },
+       { "--port n", "port of server to connect to", 1 },
+       { "--reqlen n", "length of request (256 by default)", 0 },
+       { "--rsplen n", "length of response (256 by default)", 0 },
+       { "--ntimes n", "number of time to send request (1 by default)", 0 },
+       { "--alt_addr addr", "alternate server to connect to", 0 },
+       { "--connorder add", "alternate server to connect to", 0 },
+       { "--longlived n", "number of reconnection for long lived (default 0)", 0 },
+       { "--fastjoin (0|1)", "use fast join (default 0)", 0 },
+       { "--nowaitforjoin (0|1)", "do not wait for join (default 0 -- i.e. wait)", 0 },
+       { "--verbose", "increase verbosity", 0 },
+       { "--help", "display this help", 0 },
+
+       { NULL, NULL, 0 }  /* Mark end of list */
+};
+
+static void
+usage(const char *cmd)
+{
+       struct option_desc *option_desc;
+       char *usage_str = malloc(LINE_MAX);
+       size_t usage_len;
+       
+       if (usage_str == NULL)
+               err(1, "%s: malloc(%d)", __func__, LINE_MAX);
+       
+       usage_len = snprintf(usage_str, LINE_MAX, "# usage: %s ", basename(cmd));
+       
+       for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+               int len;
+               
+               if (option_desc->required)
+                       len = snprintf(usage_str + usage_len, LINE_MAX - usage_len, "%s ", option_desc->option);
+               else
+                       len = snprintf(usage_str + usage_len, LINE_MAX - usage_len, "[%s] ", option_desc->option);
+               if (len < 0)
+                       err(1, "%s: snprintf(", __func__);
+               
+               usage_len += len;
+               if (usage_len > LINE_MAX)
+                       break;
+       }
+       printf("%s\n", usage_str);
+       printf("options:\n");
+       
+       for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+               printf(" %-24s # %s\n", option_desc->option, option_desc->description);
+       }
+       printf("\n");
+       printf("# legacy usage: ");
+       printf("%s hostname port reqlen rsplen ntimes alt_addr 0 connorder longlived fastjoin nowaitforjoin\n",
+               basename(cmd));
+}
+
+static struct option longopts[] = {
+       { "host",               required_argument,      NULL,           'c' },
+       { "port",               required_argument,      NULL,           'p' },
+       { "reqlen",             required_argument,      NULL,           'r' },
+       { "rsplen",             required_argument,      NULL,           'R' },
+       { "ntimes",             required_argument,      NULL,           'n' },
+       { "alt_addr",           required_argument,      NULL,           'a' },
+       { "connorder",          required_argument,      NULL,           'o' },
+       { "longlived",          required_argument,      NULL,           'l' },
+       { "fastjoin",           required_argument,      NULL,           'f' },
+       { "nowaitforjoin",      required_argument,      NULL,           'w' },
+       { "help",               no_argument,            NULL,           'h' },
+       { "verbose",            no_argument,            NULL,           'v' },
+       { "quiet",              no_argument,            NULL,           'q' },
+       { NULL,                 0,                      NULL,           0 }
+       
+};
+
+static int
+sprint_sockaddr(char *str, socklen_t strlen, struct sockaddr *sa)
+{
+       int retval = 0;
+
+       if (sa->sa_family == AF_INET) {
+               struct sockaddr_in      *sin = (struct sockaddr_in*)sa;
+               char str4[INET_ADDRSTRLEN];
+               
+               inet_ntop(AF_INET, &sin->sin_addr, str4, sizeof(str4));
+               
+               retval = snprintf(str, strlen, "%s:%u", str4, ntohs(sin->sin_port));
+       } else  if (sa->sa_family == AF_INET6) {
+               struct sockaddr_in6     *sin6 = (struct sockaddr_in6*)sa;
+               char                    str6[INET6_ADDRSTRLEN];
+               char                    ifname[IF_NAMESIZE];
+               char                    scopestr[2 + IF_NAMESIZE];
+               
+               inet_ntop(AF_INET6, &sin6->sin6_addr, str6, sizeof(str6));
+
+               if (sin6->sin6_scope_id == 0)
+                       *scopestr = '\0';
+               else {
+                       if_indextoname(sin6->sin6_scope_id, ifname);
+                       snprintf(scopestr, sizeof(scopestr), "%%%s", ifname);
+               }
+               
+               retval = snprintf(str, strlen, "%s%s:%u",
+                       str6,
+                       scopestr,
+                       ntohs(sin6->sin6_port));
+       }
+       return (retval);
+}
+
+int main(int argc, char * const *argv)
+{
+       int sockfd, ps, portno;
+       ssize_t n;
+       int reqlen = 256;
+       int rsplen = 256;
+       int ntimes = 1;
+       int connordrtest = 0;
+       int longlived = 0;
+       int fastjoin = 0;
+       char *buffer = NULL;
+       char *buffer1;
+       char *buffer2;
+       char *buffer3;
+       struct addrinfo *ares = NULL, ahints;
+       struct addrinfo *altres = NULL;
+       int retval = 0;
+       int which_buf = 0;
+       connid_t cid1, cid2;
+       int iter;
+       int bytes_to_rdwr;
+       int peeled_off = 0;
+       int nowaitforjoin = 0;
+       int ch;
+       const char *host_arg = NULL;
+       const char *port_arg = NULL;
+       const char *reqlen_arg = "256";
+       const char *rsplen_arg = "256";
+       const char *ntimes_arg = "1";
+       const char *alt_addr_arg = NULL;
+       const char *alt_port_arg = "0";
+       const char *connorder_arg = NULL;
+       const char *longlived_arg = NULL;
+       const char *fastjoin_arg = NULL;
+       const char *nowaitforjoin_arg = NULL;
+       int gotopt = 0;
+
+       thiszone = gmt2local(0);
+       
+       while ((ch = getopt_long(argc, argv, "a:c:f:hl:n:o:p:qr:R:vw:", longopts, NULL)) != -1) {
+               gotopt = 1;
+               switch (ch) {
+                       case 'a':
+                               alt_addr_arg = optarg;
+                               break;
+                       case 'c':
+                               host_arg = optarg;
+                               break;
+                       case 'f':
+                               fastjoin_arg = optarg;
+                               break;
+                       case 'l':
+                               longlived_arg = optarg;
+                               break;
+                       case 'n':
+                               ntimes_arg = optarg;
+                               break;
+                       case 'o':
+                               connorder_arg = optarg;
+                               break;
+                       case 'p':
+                               port_arg = optarg;
+                               break;
+                       case 'q':
+                               verbose--;
+                               break;
+                       case 'r':
+                               reqlen_arg = optarg;
+                               break;
+                       case 'R':
+                               rsplen_arg = optarg;
+                               break;
+                       case 'v':
+                               verbose++;
+                               break;
+                       case 'w':
+                               nowaitforjoin_arg = optarg;
+                               break;
+                               
+                       default:
+                               usage(argv[0]);
+                               exit(EX_USAGE);
+                       
+               }
+       }
+       
+       if (gotopt == 0) {
+               if (argc == 12) {
+                       host_arg = argv[1];
+                       port_arg = argv[2];
+                       reqlen_arg = argv[3];
+                       rsplen_arg = argv[4];
+                       ntimes_arg = argv[5];
+                       alt_addr_arg = argv[6];
+                       connorder_arg = argv[8];
+                       longlived_arg = argv[9];
+                       fastjoin_arg = argv[10];
+                       nowaitforjoin_arg = argv[11];
+               } else {
+                       usage(argv[0]);
+                       exit(EX_USAGE);
+               }
+       }
+       
+       if (host_arg == NULL)
+               errx(EX_USAGE, "missing required host option\n");
+
+       if (port_arg == NULL)
+               errx(EX_USAGE, "missing required port option\n");
+       portno = atoi(port_arg);
+       if (portno < 0 || portno > 65535)
+               errx(EX_USAGE, "invalid port %s\n", port_arg);
+
+       if (reqlen_arg != NULL) {
+               reqlen = atoi(reqlen_arg);
+               if (reqlen < 0)
+                       errx(EX_USAGE, "invalid request length %s\n", reqlen_arg);
+       }
+
+       if (rsplen_arg != NULL) {
+               rsplen = atoi(rsplen_arg);
+               if (rsplen < 0)
+                       errx(EX_USAGE, "invalid response length %s\n", rsplen_arg);
+       }
+       
+       if (ntimes_arg != NULL) {
+               ntimes = atoi(ntimes_arg);
+               if (ntimes < 1)
+                       errx(EX_USAGE, "invalid ntimes option %s\n", ntimes_arg);
+       }
+       
+       if (connorder_arg != NULL) {
+               connordrtest = atoi(connorder_arg);
+               if (connordrtest != 0 && connordrtest != 1)
+                       errx(EX_USAGE, "invalid connorder count %s\n", connorder_arg);
+       }
+       
+       if (longlived_arg != NULL) {
+               longlived = atoi(longlived_arg);
+               if (longlived < 0)
+                       errx(EX_USAGE, "invalid longlived count %s\n", longlived_arg);
+       }
+       
+       if (fastjoin_arg != NULL) {
+               fastjoin = atoi(fastjoin_arg);
+               if (fastjoin != 0 && fastjoin != 1)
+                       errx(EX_USAGE, "invalid fastjoin option %s\n", fastjoin_arg);
+       }
+       
+       if (nowaitforjoin_arg != NULL) {
+               nowaitforjoin = atoi(nowaitforjoin_arg);
+               if (nowaitforjoin != 0 && nowaitforjoin != 1)
+                       errx(EX_USAGE, "invalid nowaitforjoin option %s\n", nowaitforjoin_arg);
+       }
+       
+       buffer1 = setup_buffer1(reqlen);
+       if (!buffer1) {
+               printf("client: failed to alloc buffer space \n");
+               return -1;
+       }
+       
+       buffer2 = setup_buffer2(reqlen);
+       if (!buffer2) {
+               printf("client: failed to alloc buffer space \n");
+               return -1;
+       }
+       
+       buffer3 = setup_buffer3(rsplen);
+       if (!buffer3) {
+               printf("client: failed to alloc buffer space \n");
+               return -1;
+       }
+       
+       if (verbose > 0)
+               printf("host: %s port: %s reqlen: %d rsplen: %d ntimes: %d alt_addr: %s connorder: %d longlived: %d fasjoin: %d nowaitforjoin: %d\n",
+                       host_arg, port_arg, reqlen, rsplen, ntimes, alt_addr_arg, connordrtest, longlived, fastjoin, nowaitforjoin);
+       
+       sockfd = socket(AF_MULTIPATH, SOCK_STREAM, 0);
+       if (sockfd < 0)
+               err(EX_OSERR, "ERROR opening socket");
+#define SO_MPTCP_FASTJOIN 0x1111
+       opterr = setsockopt(sockfd, SOL_SOCKET, SO_MPTCP_FASTJOIN, &fastjoin, sizeof(fastjoin));
+       if (opterr != 0)
+               warn("setsockopt(SO_MPTCP_FASTJOIN, %d)", fastjoin);
+       
+       memset(&ahints, 0, sizeof(struct addrinfo));
+       ahints.ai_family = AF_INET;
+       ahints.ai_socktype = SOCK_STREAM;
+       ahints.ai_protocol = IPPROTO_TCP;
+       
+       retval = getaddrinfo(host_arg, port_arg, &ahints, &ares);
+       if (retval != 0)
+               printf("getaddrinfo(%s, %s) failed %d\n", host_arg, port_arg, retval);
+       
+       bytes_to_rdwr = reqlen;
+connect_again:
+       
+       cid1 = cid2 = CONNID_ANY;
+       int ifscope = 0;
+       int error = 0;
+       
+       if (verbose > 0) {
+               char str[2 * INET6_ADDRSTRLEN];
+               
+               ts_print();
+               
+               sprint_sockaddr(str, sizeof(str), ares->ai_addr);
+               printf("connectx(%s, %d, %d)\n", str, ifscope, cid1);
+       }
+       
+       error = connectx(sockfd, NULL, 0, ares->ai_addr,
+                      ares->ai_addrlen, ifscope, ASSOCID_ANY, &cid1);
+       if ((error != 0) && (errno != EPROTO)) {
+               err(EX_OSERR, "ERROR connecting");
+       } else if ((error != 0) && (errno == EPROTO)) {
+               ps = peeloff(sockfd, ASSOCID_ANY);
+               
+               if (ps != -1) {
+                       close(sockfd);
+                       sockfd = ps;
+               }
+               peeled_off = 1;
+               ts_print();
+               printf("%s: peeled off\n", __func__);
+       }
+       
+       
+       iter = 0;
+       
+       while (ntimes) {
+               
+               if ((iter == 0) && (peeled_off == 0)) {
+                       /* Add alternate path if available */
+                       
+                       if (alt_addr_arg && alt_addr_arg[0] != 0) {
+                               retval = getaddrinfo(alt_addr_arg, alt_port_arg, &ahints, &altres);
+                               
+                               if (retval != 0)
+                                       printf("client: alternate address resolution failed. \n");
+                               else {
+                                       printf("client: connecting to alternate address (ifscope %d)\n", ifscope);
+
+                                       if (verbose > 0) {
+                                               char str[2 * INET6_ADDRSTRLEN];
+
+                                               ts_print();
+                                               
+                                               sprint_sockaddr(str, sizeof(str), altres->ai_addr);
+                                               printf("connectx(%s, %d, %d)\n", str, ifscope, cid1);
+                                       }
+                                       
+                                       error = connectx(sockfd, altres->ai_addr, altres->ai_addrlen,
+                                                      ares->ai_addr, ares->ai_addrlen,
+                                                      ifscope, ASSOCID_ANY, &cid2);
+                                       if (error < 0) {
+                                               err(EX_OSERR, "ERROR setting up alternate path");
+                                       }
+                               }
+                       }
+                       
+               }
+               
+               if ((iter == 10) && (connordrtest == 1)) {
+                       int retval = 0;
+
+                       socorder.sco_cid = cid2;
+                       socorder.sco_rank = 1;
+                       retval = ioctl(sockfd, SIOCSCONNORDER, &socorder);
+                       if (retval != 0)
+                               warn("Error in changing priority");
+
+                       bzero(&socorder, sizeof(socorder));
+                       socorder.sco_cid = cid2;
+                       retval = ioctl(sockfd, SIOCGCONNORDER, &socorder);
+                       printf("cid %d rank %d", socorder.sco_cid, socorder.sco_rank);
+
+                       socorder.sco_cid = cid1;
+                       socorder.sco_rank = 0;
+                       retval = ioctl(sockfd, SIOCSCONNORDER, &socorder);
+                       if (retval != 0)
+                               warn("Error in changing priority");
+
+                       bzero(&socorder, sizeof(socorder));
+                       socorder.sco_cid = cid1;
+                       retval = ioctl(sockfd, SIOCGCONNORDER, &socorder);
+                       printf("cid %d rank %d \n", socorder.sco_cid, socorder.sco_rank);
+               }
+               
+               if (which_buf == 0) {
+                       buffer = buffer1;
+                       which_buf = 1;
+               } else {
+                       buffer = buffer2;
+                       which_buf = 0;
+               }
+               
+               while (bytes_to_rdwr) {
+                       if (verbose) {
+                               ts_print();
+                               printf("writing %d bytes\n", bytes_to_rdwr);
+                       }
+                       n = write(sockfd, buffer, bytes_to_rdwr);
+                       if (n <= 0) {
+                               err(EX_OSERR, "ERROR writing to socket");
+                       }
+                       if (n <= bytes_to_rdwr)
+                               bytes_to_rdwr -= n;
+                       else {
+                               errx(EX_DATAERR, "ERROR extra data write %zd %d\n", n, bytes_to_rdwr);
+                       }
+               }
+               bytes_to_rdwr = rsplen;
+               while (bytes_to_rdwr) {
+                       if (verbose) {
+                               ts_print();
+                               printf("reading %d bytes\n", rsplen);
+                       }
+                       n = read(sockfd, buffer3, rsplen);
+                       
+                       if (n <= 0) {
+                               err(EX_OSERR, "ERROR reading from socket");
+                       }
+                       if (n <= bytes_to_rdwr)
+                               bytes_to_rdwr -= n;
+                       else {
+                               errx(EX_DATAERR, "ERROR extra bytes read n:%zd expected:%d\n", n, bytes_to_rdwr);
+                       }
+               }
+               bytes_to_rdwr = reqlen;
+               ntimes--;
+               iter++;
+       }
+       
+       printf("client: Req size %d Rsp size %d Read/Write %d times \n", reqlen, rsplen, iter);
+       
+       showmpinfo(sockfd);
+       
+       if ((!longlived) || (peeled_off == 1)) {
+               if (verbose) {
+                       ts_print();
+                       printf("close(%d)\n", sockfd);
+               }
+               close(sockfd);
+       } else {
+               printf("Longlived countdown # %d. \n", longlived);
+               if (verbose) {
+                       ts_print();
+                       printf("disconnectx(%d, %d)\n", sockfd, cid1);
+               }
+               disconnectx(sockfd, ASSOCID_ANY, cid1);
+               if (cid2 != CONNID_ANY) {
+                       if (verbose) {
+                               ts_print();
+                               printf("disconnectx(%d, %d)\n", sockfd, cid2);
+                       }
+                       disconnectx(sockfd, ASSOCID_ANY, cid2);
+               }
+               if (!nowaitforjoin) {
+                       if (verbose) {
+                               ts_print();
+                               printf("sleep(10)\n");
+                       }
+                       sleep(10);
+               }
+               longlived--;
+               
+               ntimes = atoi(ntimes_arg);
+               
+               /* If fastjoin must be tested, write some data before doing the next connectx() */
+               bytes_to_rdwr = reqlen / 2;
+               if (verbose) {
+                       ts_print();
+                       printf("fastjoin writing %d bytes\n", bytes_to_rdwr);
+               }
+               n = write(sockfd, buffer, bytes_to_rdwr);
+               if (n <= 0) {
+                       warnx("Fastjoin: Error writing to socket. \n");
+               } else {
+                       bytes_to_rdwr = reqlen - (int)n;
+                       printf("FastJoin: Wrote %zd bytes, remaining %d of %d \n", n, bytes_to_rdwr, reqlen);
+               }
+               
+               goto connect_again;
+       }
+       if (ares)
+               freeaddrinfo(ares);
+       if (altres)
+               freeaddrinfo(altres);
+       return 0;
+}
+
+#define        CIF_BITS        \
+"\020\1CONNECTING\2CONNECTED\3DISCONNECTING\4DISCONNECTED\5BOUND_IF"\
+"\6BOUND_IP\7BOUND_PORT\10PREFERRED\11MP_CAPABLE\12MP_READY" \
+"\13MP_DEGRADED"
+
+/*
+ * Print a value a la the %b format of the kernel's printf
+ */
+static void
+printb(const char *s, unsigned v, const char *bits)
+{
+       int i, any = 0;
+       char c;
+       
+       if (bits && *bits == 8)
+               printf("%s=%o", s, v);
+       else
+               printf("%s=%x", s, v);
+       bits++;
+       if (bits) {
+               putchar('<');
+               while ((i = *bits++) != '\0') {
+                       if (v & (1 << (i-1))) {
+                               if (any)
+                                       putchar(',');
+                               any = 1;
+                               for (; (c = *bits) > 32; bits++)
+                                       putchar(c);
+                       } else {
+                               for (; *bits > 32; bits++)
+                                       ;
+                       }
+               }
+               putchar('>');
+       }
+}
+
+static int
+showconninfo(int s, connid_t cid)
+{
+       char buf[INET6_ADDRSTRLEN];
+       conninfo_t *cfo = NULL;
+       int err;
+       
+       err = copyconninfo(s, cid, &cfo);
+       if (err != 0) {
+               printf("getconninfo failed for cid %d\n", cid);
+               goto out;
+       }
+       
+       printf("%6d:\t", cid);
+       printb("flags", cfo->ci_flags, CIF_BITS);
+       printf("\n");
+       //printf("\toutif %s\n", if_indextoname(cfo->ci_ifindex, buf));
+#if 1
+       if (cfo->ci_src != NULL) {
+               printf("\tsrc %s port %d\n", inet_ntop(cfo->ci_src->sa_family,
+                                                      (cfo->ci_src->sa_family == AF_INET) ?
+                                                      (void *)&((struct sockaddr_in *)cfo->ci_src)->
+                                                      sin_addr.s_addr :
+                                                      (void *)&((struct sockaddr_in6 *)cfo->ci_src)->sin6_addr,
+                                                      buf, sizeof (buf)),
+                      (cfo->ci_src->sa_family == AF_INET) ?
+                      ntohs(((struct sockaddr_in *)cfo->ci_src)->sin_port) :
+                      ntohs(((struct sockaddr_in6 *)cfo->ci_src)->sin6_port));
+       }
+       if (cfo->ci_dst != NULL) {
+               printf("\tdst %s port %d\n", inet_ntop(cfo->ci_dst->sa_family,
+                                                      (cfo->ci_dst->sa_family == AF_INET) ?
+                                                      (void *)&((struct sockaddr_in *)cfo->ci_dst)->
+                                                      sin_addr.s_addr :
+                                                      (void *)&((struct sockaddr_in6 *)cfo->ci_dst)->sin6_addr,
+                                                      buf, sizeof (buf)),
+                      (cfo->ci_dst->sa_family == AF_INET) ?
+                      ntohs(((struct sockaddr_in *)cfo->ci_dst)->sin_port) :
+                      ntohs(((struct sockaddr_in6 *)cfo->ci_dst)->sin6_port));
+       }
+       if (cfo->ci_aux_data != NULL) {
+               switch (cfo->ci_aux_type) {
+                       case CIAUX_TCP:
+                               printf("\tTCP aux info available\n");
+                               break;
+                       default:
+                               printf("\tUnknown aux type %d\n", cfo->ci_aux_type);
+                               break;
+               }
+       }
+#endif
+out:
+       if (cfo != NULL)
+               freeconninfo(cfo);
+       
+       return (err);
+}
+
+static void
+showmpinfo(int s)
+{
+       uint32_t aid_cnt, cid_cnt;
+       associd_t *aid = NULL;
+       connid_t *cid = NULL;
+       int i, error;
+       
+       error = copyassocids(s, &aid, &aid_cnt);
+       if (error != 0) {
+               printf("copyassocids failed\n");
+               goto done;
+       } else {
+               printf("found %d associations", aid_cnt);
+               if (aid_cnt > 0) {
+                       printf(" with IDs:");
+                       for (i = 0; i < aid_cnt; i++)
+                               printf(" %d\n", aid[i]);
+               }
+               printf("\n");
+       }
+       
+       /* just do an association for now */
+       error = copyconnids(s, ASSOCID_ANY, &cid, &cid_cnt);
+       if (error != 0) {
+               warn("getconnids failed\n");
+               goto done;
+       } else {
+               printf("found %d connections", cid_cnt);
+               if (cid_cnt > 0) {
+                       printf(":\n");
+                       for (i = 0; i < cid_cnt; i++) {
+                               if (showconninfo(s, cid[i]) != 0)
+                                       break;
+                       }
+               }
+               printf("\n");
+       }
+       
+done:
+       if (aid != NULL)
+               freeassocids(aid);
+       if (cid != NULL)
+               freeconnids(cid);
+}
index 12eb891160d8a32e5336d89b52d364ebc596c080..e5a7442ba2e3609eb9b64a39e23081f3fb9cfe5e 100644 (file)
@@ -347,19 +347,6 @@ af2sock(const int af, int s, int s6)
        return (-1);
 }
 
        return (-1);
 }
 
-static __inline int
-af2socklen(const int af)
-{
-       
-       if (af == AF_INET)
-               return (sizeof(struct sockaddr_in));
-#ifdef INET6
-       if (af == AF_INET6)
-               return (sizeof(struct sockaddr_in6));
-#endif
-       return (-1);
-}
-
 static void
 process_cmd(char *cmd, int s, int s6 __unused, FILE *fp __unused)
 {
 static void
 process_cmd(char *cmd, int s, int s6 __unused, FILE *fp __unused)
 {
index 6428d96dc2221884eb48bb2908e94825a162296b..1fc4c3afcae80b988e328db7fd005d4aa337226c 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-/*
-static char sccsid[] = "@(#)if.c       8.3 (Berkeley) 4/28/95";
-*/
-static const char rcsid[] =
-       "$Id: if.c,v 1.7 2006/01/16 04:53:59 lindak Exp $";
-#endif /* not lint */
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
@@ -1710,6 +1702,10 @@ print_sfbstats(struct sfb_stats *sfb)
        int i, j, cur = sfb->current;
 
        printf("\n");
        int i, j, cur = sfb->current;
 
        printf("\n");
+       printf("     [target delay: %14s   ",
+           nsec_to_str(sfb->target_qdelay));
+       printf("update interval: %14s]\n",
+           nsec_to_str(sfb->update_interval));
        printf("     [ early drop: %12llu  rlimit drop: %11llu  "
            "marked: %11llu ]\n",
            sp->drop_early, sp->drop_pbox, sp->marked_packets);
        printf("     [ early drop: %12llu  rlimit drop: %11llu  "
            "marked: %11llu ]\n",
            sp->drop_early, sp->drop_pbox, sp->marked_packets);
@@ -1723,6 +1719,10 @@ print_sfbstats(struct sfb_stats *sfb)
            sfb->allocation, sfb->dropthresh);
        printf("     [ flow controlled: %7llu  adv feedback: %10llu ]\n",
            sp->flow_controlled, sp->flow_feedback);
            sfb->allocation, sfb->dropthresh);
        printf("     [ flow controlled: %7llu  adv feedback: %10llu ]\n",
            sp->flow_controlled, sp->flow_feedback);
+       printf("     [ min queue delay: %10s   delay_fcthreshold: %12llu]\n "
+           "     [stalls: %12lu]\n",
+           nsec_to_str(sfb->min_estdelay), sfb->delay_fcthreshold,
+           sp->dequeue_stall);
 
        printf("\n\t\t\t\tCurrent bins (set %d)", cur);
        for (i = 0; i < SFB_LEVELS; ++i) {
 
        printf("\n\t\t\t\tCurrent bins (set %d)", cur);
        for (i = 0; i < SFB_LEVELS; ++i) {
index fe69a5495da9be83575f4c39d776bcaf34e5a268..cbfc035cd62cbc800f5dafa8d2c835314c124a93 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2008-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2014 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-/*
-static char sccsid[] = "@(#)inet.c     8.5 (Berkeley) 5/24/95";
-*/
-static const char rcsid[] =
-       "$Id: inet.c,v 1.9 2006/04/04 04:36:27 lindak Exp $";
-#endif /* not lint */
-
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
@@ -311,8 +303,8 @@ protopr(uint32_t proto,             /* for sysctl version we pass proto # */
                                        break;
                        }               
                } else {
                                        break;
                        }               
                } else {
-            if (vflag)
-                printf("got %d twice\n", xgn->xgn_kind);
+                       if (vflag)
+                               printf("got %d twice\n", xgn->xgn_kind);
                }
                
                if ((istcp && which != ALL_XGN_KIND_TCP) || (!istcp && which != ALL_XGN_KIND_INP))
                }
                
                if ((istcp && which != ALL_XGN_KIND_TCP) || (!istcp && which != ALL_XGN_KIND_INP))
@@ -382,6 +374,9 @@ protopr(uint32_t proto,             /* for sysctl version we pass proto # */
                                        printf(" %10.10s %10.10s", "rxbytes", "txbytes");
                                if (prioflag >= 0)
                                        printf(" %7.7s[%1d] %7.7s[%1d]", "rxbytes", prioflag, "txbytes", prioflag);
                                        printf(" %10.10s %10.10s", "rxbytes", "txbytes");
                                if (prioflag >= 0)
                                        printf(" %7.7s[%1d] %7.7s[%1d]", "rxbytes", prioflag, "txbytes", prioflag);
+                               if (vflag > 0)
+                                       printf(" %6.6s %6.6s %6.6s %6.6s",
+                                           "rhiwat", "shiwat", "pid", "epid");
                                printf("\n");
                        }
                        first = 0;
                                printf("\n");
                        }
                        first = 0;
@@ -512,6 +507,13 @@ protopr(uint32_t proto,            /* for sysctl version we pass proto # */
                                   prioflag < SO_TC_STATS_MAX ? so_stat->xst_tc_stats[prioflag].rxbytes : 0, 
                                   prioflag < SO_TC_STATS_MAX ? so_stat->xst_tc_stats[prioflag].txbytes : 0);
                }
                                   prioflag < SO_TC_STATS_MAX ? so_stat->xst_tc_stats[prioflag].rxbytes : 0, 
                                   prioflag < SO_TC_STATS_MAX ? so_stat->xst_tc_stats[prioflag].txbytes : 0);
                }
+               if (vflag > 0) {
+                       printf(" %6u %6u %6u %6u",
+                              so_rcv->sb_hiwat,
+                              so_snd->sb_hiwat,
+                              so->so_last_pid,
+                              so->so_e_pid);
+               }
                putchar('\n');
        }
        if (xig != oxig && xig->xig_gen != oxig->xig_gen) {
                putchar('\n');
        }
        if (xig != oxig && xig->xig_gen != oxig->xig_gen) {
@@ -553,8 +555,8 @@ tcp_stats(uint32_t off , char *name, int af)
                tcp_done = 1;
 #endif
 
                tcp_done = 1;
 #endif
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf ("%s:\n", name);
 
 #define        TCPDIFF(f) (tcpstat.f - ptcpstat.f)
        printf ("%s:\n", name);
 
 #define        TCPDIFF(f) (tcpstat.f - ptcpstat.f)
@@ -600,6 +602,7 @@ tcp_stats(uint32_t off , char *name, int af)
        p2(tcps_rcvduppack, tcps_rcvdupbyte,
                "\t\t%u completely duplicate packet%s (%u byte%s)\n");
        p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n");
        p2(tcps_rcvduppack, tcps_rcvdupbyte,
                "\t\t%u completely duplicate packet%s (%u byte%s)\n");
        p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n");
+       p(tcps_rcvmemdrop, "\t\t%u received packet%s dropped due to low memory\n");
        p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
                "\t\t%u packet%s with some dup. data (%u byte%s duped)\n");
        p2(tcps_rcvoopack, tcps_rcvoobyte,
        p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
                "\t\t%u packet%s with some dup. data (%u byte%s duped)\n");
        p2(tcps_rcvoopack, tcps_rcvoobyte,
@@ -671,6 +674,19 @@ tcp_stats(uint32_t off , char *name, int af)
        p(tcps_limited_txt, "\t%u limited transmit%s done\n");
        p(tcps_early_rexmt, "\t%u early retransmit%s done\n");
        p(tcps_sack_ackadv, "\t%u time%s cumulative ack advanced along with SACK\n");
        p(tcps_limited_txt, "\t%u limited transmit%s done\n");
        p(tcps_early_rexmt, "\t%u early retransmit%s done\n");
        p(tcps_sack_ackadv, "\t%u time%s cumulative ack advanced along with SACK\n");
+       p(tcps_pto, "\t%u probe timeout%s\n");
+       p(tcps_rto_after_pto, "\t\t%u time%s retransmit timeout triggered after probe\n");
+       p(tcps_tlp_recovery, "\t\t%u time%s fast recovery after tail loss\n");
+       p(tcps_tlp_recoverlastpkt, "\t\t%u time%s recovered last packet \n");
+       p(tcps_ecn_setup, "\t%u connection%s negotiated ECN\n");
+       p(tcps_sent_ece, "\t\t%u time%s congestion notification was sent using ECE\n");
+       p(tcps_sent_cwr, "\t\t%u time%s CWR was sent in response to ECE\n");
+
+       p(tcps_detect_reordering, "\t%u time%s packet reordering was detected on a connection\n");
+       p(tcps_reordered_pkts, "\t\t%u time%s transmitted packets were reordered\n");
+       p(tcps_delay_recovery, "\t\t%u time%s fast recovery was delayed to handle reordering\n");
+       p(tcps_avoid_rxmt, "\t\t%u time%s retransmission was avoided by delaying recovery\n");
+       p(tcps_unnecessary_rxmt, "\t\t%u retransmission%s not needed \n");
 
        if (interval > 0) {
                bcopy(&tcpstat, &ptcpstat, len);
 
        if (interval > 0) {
                bcopy(&tcpstat, &ptcpstat, len);
@@ -686,7 +702,6 @@ tcp_stats(uint32_t off , char *name, int af)
 #undef p3
 }
 
 #undef p3
 }
 
-#if TARGET_OS_EMBEDDED
 /*
  * Dump MPTCP statistics
  */
 /*
  * Dump MPTCP statistics
  */
@@ -754,7 +769,6 @@ mptcp_stats(uint32_t off , char *name, int af)
 #undef p2a
 #undef p3
 }
 #undef p2a
 #undef p3
 }
-#endif /* TARGET_OS_EMBEDDED */
 
 /*
  * Dump UDP statistics structure.
 
 /*
  * Dump UDP statistics structure.
@@ -781,8 +795,8 @@ udp_stats(uint32_t off , char *name, int af )
                udp_done = 1;
 #endif
 
                udp_done = 1;
 #endif
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf("%s:\n", name);
 
 #define        UDPDIFF(f) (udpstat.f - pudpstat.f)
        printf("%s:\n", name);
 
 #define        UDPDIFF(f) (udpstat.f - pudpstat.f)
@@ -861,8 +875,8 @@ ip_stats(uint32_t off , char *name, int af )
                return;
        }
 
                return;
        }
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf("%s:\n", name);
 
 #define        IPDIFF(f) (ipstat.f - pipstat.f)
        printf("%s:\n", name);
 
 #define        IPDIFF(f) (ipstat.f - pipstat.f)
@@ -941,8 +955,8 @@ arp_stats(uint32_t off, char *name, int af)
                return;
        }
 
                return;
        }
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf("%s:\n", name);
 
 #define        ARPDIFF(f) (arpstat.f - parpstat.f)
        printf("%s:\n", name);
 
 #define        ARPDIFF(f) (arpstat.f - parpstat.f)
@@ -1017,8 +1031,8 @@ icmp_stats(uint32_t off , char *name, int af )
        if (sysctl(mib, 4, &icmpstat, &len, (void *)0, 0) < 0)
                return;         /* XXX should complain, but not traditional */
 
        if (sysctl(mib, 4, &icmpstat, &len, (void *)0, 0) < 0)
                return;         /* XXX should complain, but not traditional */
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf("%s:\n", name);
 
 #define        ICMPDIFF(f) (icmpstat.f - picmpstat.f)
        printf("%s:\n", name);
 
 #define        ICMPDIFF(f) (icmpstat.f - picmpstat.f)
@@ -1094,8 +1108,8 @@ igmp_stats(uint32_t off , char *name, int af )
                    igmpstat.igps_len, IGPS_VERSION3_LEN);
        }
 
                    igmpstat.igps_len, IGPS_VERSION3_LEN);
        }
 
-    if (interval && vflag > 0)
-        print_time();
+       if (interval && vflag > 0)
+               print_time();
        printf("%s:\n", name);
 
 #define        IGMPDIFF(f) ((uintmax_t)(igmpstat.f - pigmpstat.f))
        printf("%s:\n", name);
 
 #define        IGMPDIFF(f) ((uintmax_t)(igmpstat.f - pigmpstat.f))
index b4f68678837ab02292b48a3330bf09c314b3041c..e1483939c5ce72fb76890cd5c573f468fb3aaf7d 100644 (file)
  * $FreeBSD: src/usr.bin/netstat/inet6.c,v 1.3.2.9 2001/08/10 09:07:09 ru Exp $
  */
 
  * $FreeBSD: src/usr.bin/netstat/inet6.c,v 1.3.2.9 2001/08/10 09:07:09 ru Exp $
  */
 
-#ifndef lint
-/*
-static char sccsid[] = "@(#)inet6.c    8.4 (Berkeley) 4/20/94";
-*/
-#endif /* not lint */
-
 #ifdef INET6
 #include <sys/param.h>
 #include <sys/socket.h>
 #ifdef INET6
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -85,7 +79,6 @@ static char sccsid[] = "@(#)inet6.c   8.4 (Berkeley) 4/20/94";
 #include <netinet6/in6_pcb.h>
 #include <netinet6/in6_var.h>
 #include <netinet6/ip6_var.h>
 #include <netinet6/in6_pcb.h>
 #include <netinet6/in6_var.h>
 #include <netinet6/ip6_var.h>
-#include <netinet6/pim6_var.h>
 #include <netinet6/raw_ip6.h>
 
 #include <arpa/inet.h>
 #include <netinet6/raw_ip6.h>
 
 #include <arpa/inet.h>
@@ -1013,42 +1006,6 @@ icmp6_ifstats(char *ifname)
 #undef p
 }
 
 #undef p
 }
 
-/*
- * Dump PIM statistics structure.
- */
-#ifdef notyet 
-void
-pim6_stats(void)
-{
-       static struct pim6stat ppim6stat;
-       struct pim6stat pim6stat;
-       size_t len = sizeof(struct pim6stat);
-
-       if (sysctlbyname("net.inet6.ip6.pim6stat", &pim6stat, &len, 0, 0) == -1)
-               return;
-    if (interval && vflag > 0)
-        print_time();
-       printf("%s:\n", name);
-
-#define        PIM6DIFF(f) (pim6stat.f - ppim6stat.f)
-#define        p(f, m) if (PIM6DIFF(f) || sflag <= 1) \
-    printf(m, (unsigned long long)PIM6DIFF(f), plural(PIM6DIFF(f)))
-       p(pim6s_rcv_total, "\t%llu message%s received\n");
-       p(pim6s_rcv_tooshort, "\t%llu message%s received with too few bytes\n");
-       p(pim6s_rcv_badsum, "\t%llu message%s received with bad checksum\n");
-       p(pim6s_rcv_badversion, "\t%llu message%s received with bad version\n");
-       p(pim6s_rcv_registers, "\t%llu register%s received\n");
-       p(pim6s_rcv_badregisters, "\t%llu bad register%s received\n");
-       p(pim6s_snd_registers, "\t%llu register%s sent\n");
-
-       if (interval > 0)
-               bcopy(&pim6stat, &ppim6stat, len);
-
-#undef PIM6DIFF
-#undef p
-}
-#endif
-
 /*
  * Dump raw ip6 statistics structure.
  */
 /*
  * Dump raw ip6 statistics structure.
  */
index 62ece4b4f0303db5c4c62ee7b888e1002df8ce24..0eab1623f1d3a8b18855da304cd2d3ce41b4c68b 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-#ifndef lint
-/*
-static char sccsid[] = "@(#)inet.c     8.5 (Berkeley) 5/24/95";
-*/
-static const char rcsid[] =
-  "$FreeBSD: src/usr.bin/netstat/ipsec.c,v 1.1.2.3 2001/08/10 09:07:09 ru Exp $";
-#endif /* not lint */
-
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
index e097bc665f41e1f580ff5af1e9822ff90b8312cc..0e40e348ea45682e1aa750b82facc5e531019a72 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2014 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -67,6 +67,7 @@ char const copyright[] =
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
+#include <sys/sys_domain.h>
 
 #include <netinet/in.h>
 #include <net/pfkeyv2.h>
 
 #include <netinet/in.h>
 #include <net/pfkeyv2.h>
@@ -121,9 +122,7 @@ struct protox {
        { NULL,         ipsec_stats,    NULL,   "ipsec", IPPROTO_ESP},
 #endif
        { NULL,         arp_stats,      NULL,   "arp",  0 },
        { NULL,         ipsec_stats,    NULL,   "ipsec", IPPROTO_ESP},
 #endif
        { NULL,         arp_stats,      NULL,   "arp",  0 },
-#if TARGET_OS_EMBEDDED
        { mptcppr,      mptcp_stats,    NULL,   "mptcp", IPPROTO_TCP },
        { mptcppr,      mptcp_stats,    NULL,   "mptcp", IPPROTO_TCP },
-#endif
        { NULL,         NULL,           NULL,   NULL,   0 }
 };
 
        { NULL,         NULL,           NULL,   NULL,   0 }
 };
 
@@ -135,14 +134,9 @@ struct protox ip6protox[] = {
        { protopr,      icmp6_stats,    icmp6_ifstats,  "icmp6",IPPROTO_ICMPV6 },
 #ifdef IPSEC
        { NULL,         ipsec_stats,    NULL,   "ipsec6", IPPROTO_ESP },
        { protopr,      icmp6_stats,    icmp6_ifstats,  "icmp6",IPPROTO_ICMPV6 },
 #ifdef IPSEC
        { NULL,         ipsec_stats,    NULL,   "ipsec6", IPPROTO_ESP },
-#endif
-#ifdef notyet
-       { NULL,         pim6_stats,     NULL,   "pim6", 0 },
 #endif
        { NULL,         rip6_stats,     NULL,   "rip6", IPPROTO_RAW },
 #endif
        { NULL,         rip6_stats,     NULL,   "rip6", IPPROTO_RAW },
-#if TARGET_OS_EMBEDDED
        { mptcppr,      mptcp_stats,    NULL,   "mptcp", IPPROTO_TCP },
        { mptcppr,      mptcp_stats,    NULL,   "mptcp", IPPROTO_TCP },
-#endif
        { NULL,         NULL,           NULL,   NULL,   0 }
 };
 #endif /*INET6*/
        { NULL,         NULL,           NULL,   NULL,   0 }
 };
 #endif /*INET6*/
@@ -154,6 +148,14 @@ struct protox pfkeyprotox[] = {
 };
 #endif
 
 };
 #endif
 
+
+struct protox systmprotox[] = {
+       { systmpr,      NULL,           NULL,   "reg", 0 },
+       { systmpr,      kevt_stats,             NULL,   "kevt", SYSPROTO_EVENT },
+       { systmpr,      kctl_stats,     NULL,   "kctl", SYSPROTO_CONTROL },
+       { NULL,         NULL,           NULL,   NULL,   0 }
+};
+
 struct protox *protoprotox[] = {
        protox,
 #ifdef INET6
 struct protox *protoprotox[] = {
        protox,
 #ifdef INET6
@@ -162,6 +164,7 @@ struct protox *protoprotox[] = {
 #ifdef IPSEC
        pfkeyprotox,
 #endif
 #ifdef IPSEC
        pfkeyprotox,
 #endif
+       systmprotox,
        NULL
 };
 
        NULL
 };
 
@@ -251,8 +254,10 @@ main(argc, argv)
                        else if (strcmp(optarg, "pfkey") == 0)
                                af = PF_KEY;
 #endif /*INET6*/
                        else if (strcmp(optarg, "pfkey") == 0)
                                af = PF_KEY;
 #endif /*INET6*/
-                       else if (strcmp(optarg, "unix") == 0)
-                               af = AF_UNIX;
+                        else if (strcmp(optarg, "unix") == 0)
+                                af = AF_UNIX;
+                        else if (strcmp(optarg, "systm") == 0)
+                                af = AF_SYSTEM;
                        else {
                                errx(1, "%s: unknown address family", optarg);
                        }
                        else {
                                errx(1, "%s: unknown address family", optarg);
                        }
@@ -385,23 +390,6 @@ main(argc, argv)
 
 #if defined(__APPLE__)
        if (gflag) {
 
 #if defined(__APPLE__)
        if (gflag) {
-#if !TARGET_OS_EMBEDDED
-               if (sflag) {
-                       if (af == AF_INET || af == AF_UNSPEC)
-                               mrt_stats();
-#ifdef INET6
-                       if (af == AF_INET6 || af == AF_UNSPEC)
-                               mrt6_stats();
-#endif
-               } else {
-                       if (af == AF_INET || af == AF_UNSPEC)
-                               mroutepr();
-#ifdef INET6
-                       if (af == AF_INET6 || af == AF_UNSPEC)
-                               mroute6pr();
-#endif
-               }
-#endif /* !TARGET_OS_EMBEDDED */
                ifmalist_dump();
                exit(0);
        }
                ifmalist_dump();
                exit(0);
        }
@@ -426,6 +414,11 @@ main(argc, argv)
 #endif /*IPSEC*/
        if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag)
                unixpr();
 #endif /*IPSEC*/
        if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag)
                unixpr();
+               
+       if ((af == AF_SYSTEM || af == AF_UNSPEC) && !Lflag)
+               for (tp = systmprotox; tp->pr_name; tp++)
+                       printproto(tp, tp->pr_name);
+                       
 #ifdef SRVCACHE
        _serv_cache_close();
 #endif
 #ifdef SRVCACHE
        _serv_cache_close();
 #endif
index e130ef5e83c2bc1dc82f697e091f6e7f4496c431..38645e92dc422e292a84c4d5d81ae5ea91975050 100644 (file)
@@ -139,7 +139,7 @@ static int mbpr_getdata(void);
 void
 mbpr(void)
 {
 void
 mbpr(void)
 {
-       unsigned long totmem = 0, totfree = 0, totmbufs, totused;
+       unsigned long totmem = 0, totfree = 0, totmbufs, totused, totreturned = 0;
        double totpct;
        u_int32_t m_msize, m_mbufs = 0, m_clfree = 0, m_bigclfree = 0;
        u_int32_t m_mbufclfree = 0, m_mbufbigclfree = 0;
        double totpct;
        u_int32_t m_msize, m_mbufs = 0, m_clfree = 0, m_bigclfree = 0;
        u_int32_t m_mbufclfree = 0, m_mbufbigclfree = 0;
@@ -183,6 +183,7 @@ mbpr(void)
 
                mem = cp->mbcl_ctotal * cp->mbcl_size;
                totmem += mem;
 
                mem = cp->mbcl_ctotal * cp->mbcl_size;
                totmem += mem;
+               totreturned += cp->mbcl_release_cnt;
                totfree += (cp->mbcl_mc_cached + cp->mbcl_infree) *
                    cp->mbcl_size;
                if (mflag > 1) {
                totfree += (cp->mbcl_mc_cached + cp->mbcl_infree) *
                    cp->mbcl_size;
                if (mflag > 1) {
@@ -270,6 +271,7 @@ mbpr(void)
        }
        printf("%lu KB allocated to network (%.1f%% in use)\n",
                totmem / 1024, totpct);
        }
        printf("%lu KB allocated to network (%.1f%% in use)\n",
                totmem / 1024, totpct);
+       printf("%lu KB returned to the system\n", totreturned / 1024);
 
        printf("%u requests for memory denied\n", (unsigned int)mbstat.m_drops);
        printf("%u requests for memory delayed\n", (unsigned int)mbstat.m_wait);
 
        printf("%u requests for memory denied\n", (unsigned int)mbstat.m_drops);
        printf("%u requests for memory delayed\n", (unsigned int)mbstat.m_wait);
index 5aca9b6ebcc2b7b8196a10a91bd03110e18bf8b2..26e82dda3423bd6e5cdd7c52771e071ba7273a32 100644 (file)
@@ -30,7 +30,6 @@
 #include <TargetConditionals.h>
 #endif
 
 #include <TargetConditionals.h>
 #endif
 
-#if TARGET_OS_EMBEDDED
 #include <stdio.h>
 #include <err.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <err.h>
 #include <stdlib.h>
@@ -154,4 +153,3 @@ mptcppr(uint32_t off, char *name, int af)
        }
        free(buf);
 }
        }
        free(buf);
 }
-#endif /* TARGET_OS_EMBEDDED */
diff --git a/netstat.tproj/mroute.c b/netstat.tproj/mroute.c
deleted file mode 100644 (file)
index 04a9fe5..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
- *
- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. The rights granted to you under the License
- * may not be used to create, or enable the creation or redistribution of,
- * unlawful or unlicensed copies of an Apple operating system, or to
- * circumvent, violate, or enable the circumvention or violation of, any
- * terms of an Apple operating system software license agreement.
- * 
- * Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- * 
- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1989 Stephen Deering
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Stephen Deering of Stanford University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)mroute.c    8.2 (Berkeley) 4/28/95
- */
-
-/*
- * Print DVMRP multicast routing structures and statistics.
- *
- * MROUTING 1.0
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/mbuf.h>
-#include <sys/time.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/igmp.h>
-#include <net/route.h>
-#include <netinet/ip_mroute.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "netstat.h"
-
-void
-mroutepr(void)
-{
-       struct mfc **mfctable = 0;
-       struct vif viftable[CONFIG_MAXVIFS];
-       struct mfc *m;
-       register struct vif *v;
-       register vifi_t vifi;
-       register int i;
-       register int banner_printed;
-       register int saved_nflag;
-       vifi_t maxvif = 0;
-       size_t len;
-
-       saved_nflag = nflag;
-       nflag = 1;
-
-       len = CONFIG_MAXVIFS * sizeof(struct vif);
-       if (sysctlbyname("net.inet.ip.viftable", viftable, &len, 0, 0) == -1) {
-               //printf("No IPv4 multicast routing compiled into this system.\n");
-               return;
-       }
-
-       banner_printed = 0;
-       for (vifi = 0, v = viftable; vifi < CONFIG_MAXVIFS; ++vifi, ++v) {
-               if (v->v_lcl_addr.s_addr == 0)
-                       continue;
-
-               maxvif = vifi;
-               if (!banner_printed) {
-                       printf("\nVirtual Interface Table\n"
-                              " Vif   Thresh   Rate   Local-Address   "
-                              "Remote-Address    Pkts-In   Pkts-Out\n");
-                       banner_printed = 1;
-               }
-
-               printf(" %2u    %6u   %4d   %-15.15s",
-                                       /* opposite math of add_vif() */
-                   vifi, v->v_threshold, v->v_rate_limit * 1000 / 1024, 
-                   routename(v->v_lcl_addr.s_addr));
-               printf(" %-15.15s", (v->v_flags & VIFF_TUNNEL) ?
-                   routename(v->v_rmt_addr.s_addr) : "");
-
-               printf(" %9u  %9u\n", v->v_pkt_in, v->v_pkt_out);
-       }
-       if (!banner_printed)
-               printf("\nVirtual Interface Table is empty\n");
-
-       if (sysctlbyname("net.inet.ip.mfctable", 0, &len, 0, 0) == -1) {
-               //printf("No IPv4 multicast routing compiled into this system.\n");
-               return;
-       }
-       mfctable = malloc(len);
-       if (mfctable == 0)
-               return;
-       if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, 0, 0) == -1) {
-               //printf("No IPv4 multicast routing compiled into this system.\n");
-               return;
-       }
-       banner_printed = 0;
-       for (i = 0; i < CONFIG_MFCTBLSIZ; ++i) {
-               m = mfctable[i];
-               while(m) {
-                       if (!banner_printed) {
-                               printf("\nIPv4 Multicast Forwarding Cache\n"
-                                      " Origin          Group            "
-                                      " Packets In-Vif  Out-Vifs:Ttls\n");
-                               banner_printed = 1;
-                       }
-
-                       printf(" %-15.15s", routename(m->mfc_origin.s_addr));
-                       printf(" %-15.15s", routename(m->mfc_mcastgrp.s_addr));
-                       printf(" %9u", m->mfc_pkt_cnt);
-                       printf("  %3d   ", m->mfc_parent);
-                       for (vifi = 0; vifi <= maxvif; vifi++) {
-                               if (m->mfc_ttls[vifi] > 0)
-                                       printf(" %u:%u", vifi, 
-                                              m->mfc_ttls[vifi]);
-                       }
-                       printf("\n");
-                       m = m->mfc_next;
-               }
-       }
-       if (!banner_printed)
-               printf("\nMulticast Routing Table is empty\n");
-
-       printf("\n");
-       nflag = saved_nflag;
-       
-       free(mfctable);
-}
-
-
-void
-mrt_stats()
-{
-       struct mrtstat mrtstat;
-       size_t len = sizeof(struct mrtstat);
-
-       if(sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, 0, 0) == -1) {
-               //printf("No IPv4 multicast routing compiled into this system.\n");
-               return;
-       }
-
-       printf("IPv4 multicast forwarding:\n");
-       printf(" %10u multicast forwarding cache lookup%s\n",
-         mrtstat.mrts_mfc_lookups, plural(mrtstat.mrts_mfc_lookups));
-       printf(" %10u multicast forwarding cache miss%s\n",
-         mrtstat.mrts_mfc_misses, plurales(mrtstat.mrts_mfc_misses));
-       printf(" %10u upcall%s to mrouted\n",
-         mrtstat.mrts_upcalls, plural(mrtstat.mrts_upcalls));
-       printf(" %10u upcall queue overflow%s\n",
-         mrtstat.mrts_upq_ovflw, plural(mrtstat.mrts_upq_ovflw));
-       printf(" %10u upcall%s dropped due to full socket buffer\n",
-         mrtstat.mrts_upq_sockfull, plural(mrtstat.mrts_upq_sockfull));
-       printf(" %10u cache cleanup%s\n",
-         mrtstat.mrts_cache_cleanups, plural(mrtstat.mrts_cache_cleanups));
-       printf(" %10u datagram%s with no route for origin\n",
-         mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route));
-       printf(" %10u datagram%s arrived with bad tunneling\n",
-         mrtstat.mrts_bad_tunnel, plural(mrtstat.mrts_bad_tunnel));
-       printf(" %10u datagram%s could not be tunneled\n",
-         mrtstat.mrts_cant_tunnel, plural(mrtstat.mrts_cant_tunnel));
-       printf(" %10u datagram%s arrived on wrong interface\n",
-         mrtstat.mrts_wrong_if, plural(mrtstat.mrts_wrong_if));
-       printf(" %10u datagram%s selectively dropped\n",
-         mrtstat.mrts_drop_sel, plural(mrtstat.mrts_drop_sel));
-       printf(" %10u datagram%s dropped due to queue overflow\n",
-         mrtstat.mrts_q_overflow, plural(mrtstat.mrts_q_overflow));
-       printf(" %10u datagram%s dropped for being too large\n",
-         mrtstat.mrts_pkt2large, plural(mrtstat.mrts_pkt2large));
-}
diff --git a/netstat.tproj/mroute6.c b/netstat.tproj/mroute6.c
deleted file mode 100644 (file)
index 549740f..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
- *
- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. The rights granted to you under the License
- * may not be used to create, or enable the creation or redistribution of,
- * unlawful or unlicensed copies of an Apple operating system, or to
- * circumvent, violate, or enable the circumvention or violation of, any
- * terms of an Apple operating system software license agreement.
- *
- * Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
- *
- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (C) 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1989 Stephen Deering
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Stephen Deering of Stanford University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)mroute.c    8.2 (Berkeley) 4/28/95
- *     $FreeBSD: src/usr.bin/netstat/mroute6.c,v 1.1.2.5 2001/08/10 09:07:09 ru Exp $
- */
-
-#ifdef INET6
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <err.h>
-
-#define        KERNEL 1
-#include <netinet6/ip6_mroute.h>
-#undef KERNEL
-
-#include "netstat.h"
-
-#define        WID_ORG (lflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */
-#define        WID_GRP (lflag ? 18 : (nflag ? 16 : 18)) /* width of group column */
-
-void
-mroute6pr(void)
-{
-#if 0
-       struct mf6c **mf6ctable = 0, *mfcp;
-       struct mif6 mif6table[MAXMIFS];
-       struct mf6c mfc;
-       struct rtdetq *rtep;
-       register struct mif6 *mifp;
-       register mifi_t mifi;
-       register int i;
-       register int banner_printed;
-       register int saved_nflag;
-       mifi_t maxmif = 0;
-       long waitings;
-       size_t len;
-
-       len = sizeof(mif6table);
-       if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len, 0, 9) == -1) {
-               //printf("No IPv6 multicast routing compiled into this system.\n");
-               return;
-       }
-
-       saved_nflag = nflag;
-       nflag = 1;
-
-       banner_printed = 0;
-       for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
-               struct ifnet ifnet      = { 0 } ;
-               char ifname[IFNAMSIZ];
-
-               if (mifp->m6_ifp == NULL)
-                       continue;
-
-               /*
-                *      m6_ifp should be ifindex instead of ifnet pointer
-                *      
-                *      kread((u_long)mifp->m6_ifp, (char *)&ifnet, sizeof(ifnet));
-                */
-               maxmif = mifi;
-               if (!banner_printed) {
-                       printf("\nIPv6 Multicast Interface Table\n"
-                              " Mif   Rate   PhyIF   "
-                              "Pkts-In   Pkts-Out\n");
-                       banner_printed = 1;
-               }
-
-               printf("  %2u   %4d",
-                      mifi, mifp->m6_rate_limit);
-               printf("   %5s", (mifp->m6_flags & MIFF_REGISTER) ?
-                      "reg0" : if_indextoname(ifnet.if_index, ifname));
-
-               printf(" %9llu  %9llu\n", (unsigned long long)mifp->m6_pkt_in,
-                   (unsigned long long)mifp->m6_pkt_out);
-       }
-       if (!banner_printed)
-               printf("\nIPv6 Multicast Interface Table is empty\n");
-
-       len = sizeof(MF6CTBLSIZ * sizeof(struct mf6c));
-       mf6ctable = malloc(len);
-       if (mf6ctable == 0)
-               return;
-       if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len, 0, 0) == -1) {
-               //printf("No IPv6 multicast routing compiled into this system.\n");
-               free(mf6ctable);
-               return;
-       }
-       banner_printed = 0;
-       for (i = 0; i < MF6CTBLSIZ; ++i) {
-               mfcp = mf6ctable[i];
-               while(mfcp) {
-                       if (!banner_printed) {
-                               printf ("\nIPv6 Multicast Forwarding Cache\n");
-                               printf(" %-*.*s %-*.*s %s",
-                                      WID_ORG, WID_ORG, "Origin",
-                                      WID_GRP, WID_GRP, "Group",
-                                      "  Packets Waits In-Mif  Out-Mifs\n");
-                               banner_printed = 1;
-                       }
-
-                       printf(" %-*.*s", WID_ORG, WID_ORG,
-                              routename6(&mfc.mf6c_origin));
-                       printf(" %-*.*s", WID_GRP, WID_GRP,
-                              routename6(&mfc.mf6c_mcastgrp));
-                       printf(" %9llu", (unsigned long long)mfc.mf6c_pkt_cnt);
-
-                       for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
-                               /* The sysctl should return the number of packet waiting
-                                *      struct rtdetq rte;
-                                *      kread((u_long)rtep, (char *)&rte, sizeof(rte));
-                                *      rtep = rte.next;
-                                */
-                               waitings++;
-                       }
-                       printf("   %3ld", waitings);
-
-                       if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)
-                               printf(" ---   ");
-                       else
-                               printf("  %3d   ", mfc.mf6c_parent);
-                       for (mifi = 0; mifi <= maxmif; mifi++) {
-                               if (IF_ISSET(mifi, &mfc.mf6c_ifset))
-                                       printf(" %u", mifi);
-                       }
-                       printf("\n");
-
-                       mfcp = mfc.mf6c_next;
-               }
-       }
-       if (!banner_printed)
-               printf("\nIPv6 Multicast Routing Table is empty\n");
-
-       printf("\n");
-       nflag = saved_nflag;
-
-       free(mf6ctable);
-#endif
-}
-
-void
-mrt6_stats(void)
-{
-       struct mrt6stat mrtstat;
-       size_t len;
-
-       len = sizeof(mrtstat);
-       if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len, 0, 0) == -1) {
-               //printf("No IPv6 multicast routing compiled into this system\n");
-               return;
-       }
-       printf("IPv6 multicast forwarding:\n");
-       printf(" %10llu multicast forwarding cache lookup%s\n",
-           (unsigned long long)mrtstat.mrt6s_mfc_lookups,
-           plural(mrtstat.mrt6s_mfc_lookups));
-       printf(" %10llu multicast forwarding cache miss%s\n",
-           (unsigned long long)mrtstat.mrt6s_mfc_misses,
-           plurales(mrtstat.mrt6s_mfc_misses));
-       printf(" %10llu upcall%s to mrouted\n",
-           (unsigned long long)mrtstat.mrt6s_upcalls,
-           plural(mrtstat.mrt6s_upcalls));
-       printf(" %10llu upcall queue overflow%s\n",
-           (unsigned long long)mrtstat.mrt6s_upq_ovflw,
-           plural(mrtstat.mrt6s_upq_ovflw));
-       printf(" %10llu upcall%s dropped due to full socket buffer\n",
-           (unsigned long long)mrtstat.mrt6s_upq_sockfull,
-           plural(mrtstat.mrt6s_upq_sockfull));
-       printf(" %10llu cache cleanup%s\n",
-           (unsigned long long)mrtstat.mrt6s_cache_cleanups,
-           plural(mrtstat.mrt6s_cache_cleanups));
-       printf(" %10llu datagram%s with no route for origin\n",
-           (unsigned long long)mrtstat.mrt6s_no_route,
-           plural(mrtstat.mrt6s_no_route));
-       printf(" %10llu datagram%s arrived with bad tunneling\n",
-           (unsigned long long)mrtstat.mrt6s_bad_tunnel,
-           plural(mrtstat.mrt6s_bad_tunnel));
-       printf(" %10llu datagram%s could not be tunneled\n",
-           (unsigned long long)mrtstat.mrt6s_cant_tunnel,
-           plural(mrtstat.mrt6s_cant_tunnel));
-       printf(" %10llu datagram%s arrived on wrong interface\n",
-           (unsigned long long)mrtstat.mrt6s_wrong_if,
-           plural(mrtstat.mrt6s_wrong_if));
-       printf(" %10llu datagram%s selectively dropped\n",
-           (unsigned long long)mrtstat.mrt6s_drop_sel,
-           plural(mrtstat.mrt6s_drop_sel));
-       printf(" %10llu datagram%s dropped due to queue overflow\n",
-           (unsigned long long)mrtstat.mrt6s_q_overflow,
-           plural(mrtstat.mrt6s_q_overflow));
-       printf(" %10llu datagram%s dropped for being too large\n",
-           (unsigned long long)mrtstat.mrt6s_pkt2large,
-           plural(mrtstat.mrt6s_pkt2large));
-}
-#endif /*INET6*/
index 86aec500f63410f662bd437237af32f8a70973ce..e64776f93c86c30341cb1f8fcc60bbe00afffad4 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2014 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -121,14 +121,7 @@ extern void        ip6_stats(uint32_t, char *, int);
 extern void    ip6_ifstats(char *);
 extern void    icmp6_stats(uint32_t, char *, int);
 extern void    icmp6_ifstats(char *);
 extern void    ip6_ifstats(char *);
 extern void    icmp6_stats(uint32_t, char *, int);
 extern void    icmp6_ifstats(char *);
-#ifdef notyet
-extern void    pim6_stats(uint32_t, char *, int);
-#endif
 extern void    rip6_stats(uint32_t, char *, int);
 extern void    rip6_stats(uint32_t, char *, int);
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
-extern void    mroute6pr(void);
-extern void    mrt6_stats(void);
-#endif
 
 /* forward references */
 struct sockaddr_in6;
 
 /* forward references */
 struct sockaddr_in6;
@@ -143,6 +136,10 @@ extern char        *netname6(struct sockaddr_in6 *, struct sockaddr *);
 extern void    pfkey_stats(uint32_t, char *, int);
 #endif
 
 extern void    pfkey_stats(uint32_t, char *, int);
 #endif
 
+extern void    systmpr(uint32_t, char *, int);
+extern void    kctl_stats(uint32_t, char *, int);
+extern void    kevt_stats(uint32_t, char *, int);
+
 extern void    mbpr(void);
 
 extern void    intpr(void (*)(char *));
 extern void    mbpr(void);
 
 extern void    intpr(void (*)(char *));
@@ -162,11 +159,6 @@ extern void        unixpr(void);
 extern void    aqstatpr(void);
 extern void    rxpollstatpr(void);
 
 extern void    aqstatpr(void);
 extern void    rxpollstatpr(void);
 
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
-extern void    mroutepr(void);
-extern void    mrt_stats(void);
-#endif
-
 extern void    ifmalist_dump(void);
 
 extern int print_time(void);
 extern void    ifmalist_dump(void);
 
 extern int print_time(void);
diff --git a/netstat.tproj/systm.c b/netstat.tproj/systm.c
new file mode 100644 (file)
index 0000000..7c23476
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/*-
+ * Copyright (c) 1983, 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/sysctl.h>
+#include <sys/sys_domain.h>
+#include <sys/kern_control.h>
+#include <sys/kern_event.h>
+
+#include <errno.h>
+#include <err.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+#include "netstat.h"
+
+#define ROUNDUP64(a) \
+((a) > 0 ? (1 + (((a) - 1) | (sizeof(uint64_t) - 1))) : sizeof(uint64_t))
+#define ADVANCE64(x, n) (((char *)x) += ROUNDUP64(n))
+
+struct xgen_n {
+       u_int32_t       xgn_len;                        /* length of this structure */
+       u_int32_t       xgn_kind;               /* number of PCBs at this time */
+};
+
+#define        ALL_XGN_KIND_KCREG (XSO_KCREG)
+#define        ALL_XGN_KIND_EVT (XSO_SOCKET | XSO_RCVBUF | XSO_SNDBUF | XSO_STATS | XSO_EVT)
+#define        ALL_XGN_KIND_KCB (XSO_SOCKET | XSO_RCVBUF | XSO_SNDBUF | XSO_STATS | XSO_KCB)
+
+void
+systmpr(uint32_t proto,
+       char *name, int af)
+{
+       const char *mibvar;
+       size_t len;
+       char *buf, *next;
+       struct xsystmgen *xig, *oxig;
+       struct xgen_n *xgn;
+       int which = 0;
+       struct xsocket_n *so = NULL;
+       struct xsockbuf_n *so_rcv = NULL;
+       struct xsockbuf_n *so_snd = NULL;
+       struct xsockstat_n *so_stat = NULL;
+       struct xkctl_reg *kctl = NULL;
+       struct xkctlpcb *kcb = NULL;
+       struct xkevtpcb *kevb = NULL;
+       int first = 1;
+       
+       switch (proto) {
+               case SYSPROTO_EVENT:
+                        mibvar = "net.systm.kevt.pcblist";
+                       break;
+               case SYSPROTO_CONTROL:
+                       mibvar = "net.systm.kctl.pcblist";
+                       break;
+               case 0:
+                       mibvar = "net.systm.kctl.reg_list";
+                       break;
+               default:
+                       mibvar = NULL;
+                       break;
+       }
+       if (mibvar == NULL)
+               return;
+       len = 0;
+       if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
+               if (errno != ENOENT)
+                       warn("sysctl: %s", mibvar);
+               return;
+       }
+       if ((buf = malloc(len)) == 0) {
+               warn("malloc %lu bytes", (u_long)len);
+               return;
+       }
+       if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
+               warn("sysctl: %s", mibvar);
+               free(buf);
+               return;
+       }
+       /*
+        * Bail-out to avoid logic error in the loop below when
+        * there is in fact no more control block to process
+        */
+       if (len <= sizeof(struct xsystmgen)) {
+               free(buf);
+               return;
+       }
+       oxig = xig = (struct xsystmgen *)buf;
+       for (next = buf + ROUNDUP64(xig->xg_len); next < buf + len;
+            next += ROUNDUP64(xgn->xgn_len)) {
+               xgn = (struct xgen_n*)next;
+               if (xgn->xgn_len <= sizeof(struct xsystmgen))
+                       break;
+               
+               if ((which & xgn->xgn_kind) == 0) {
+                       which |= xgn->xgn_kind;
+                       switch (xgn->xgn_kind) {
+                               case XSO_SOCKET:
+                                       so = (struct xsocket_n *)xgn;
+                                       break;
+                               case XSO_RCVBUF:
+                                       so_rcv = (struct xsockbuf_n *)xgn;
+                                       break;
+                               case XSO_SNDBUF:
+                                       so_snd = (struct xsockbuf_n *)xgn;
+                                       break;
+                               case XSO_STATS:
+                                       so_stat = (struct xsockstat_n *)xgn;
+                                       break;
+                               case XSO_KCREG:
+                                       kctl = (struct xkctl_reg *)xgn;
+                                       break;
+                               case XSO_KCB:
+                                       kcb = (struct xkctlpcb *)xgn;
+                                       break;
+                               case XSO_EVT:
+                                       kevb = (struct xkevtpcb *)xgn;
+                                       break;
+                               default:
+                                       printf("unexpected kind %d\n", xgn->xgn_kind);
+                                       break;
+                       }
+               } else {
+                       if (vflag)
+                               printf("got %d twice\n", xgn->xgn_kind);
+               }
+               
+               if (which == ALL_XGN_KIND_KCREG) {
+                       which = 0;
+                       
+                       if (first) {
+                               printf("Registered kernel control modules\n");
+                               if (Aflag)
+                                       printf("%-16.16s ", "kctlref");
+                               printf("%-8.8s ", "id");
+                               if (Aflag)
+                                       printf("%-8.8s ", "unit");
+                               printf("%-8.8s ", "flags");
+                               printf("%-8.8s ", "pcbcount");
+                               printf("%-8.8s ", "rcvbuf");
+                               printf("%-8.8s ", "sndbuf");
+                               printf("%s ", "name");
+                               printf("\n");
+                               first = 0;
+                       }
+                       if (Aflag)
+                               printf("%16llx ", kctl->xkr_kctlref);
+                       printf("%8x ", kctl->xkr_id);
+                       if (Aflag)
+                               printf("%8d ", kctl->xkr_reg_unit);
+                       printf("%8x ", kctl->xkr_flags);
+                       printf("%8d ", kctl->xkr_pcbcount);
+                       printf("%8d ", kctl->xkr_recvbufsize);
+                       printf("%8d ", kctl->xkr_sendbufsize);
+                       printf("%s ", kctl->xkr_name);
+                       printf("\n");
+               } else if (which == ALL_XGN_KIND_KCB) {
+                       which = 0;
+                       
+                       if (first) {
+                               printf("Active kernel control sockets\n");
+                               if (Aflag)
+                                       printf("%16.16s ", "pcb");
+                               printf("%-5.5s %-6.6s %-6.6s ",
+                                       "Proto", "Recv-Q", "Send-Q");
+                               if (bflag > 0)
+                                       printf("%10.10s %10.10s ",
+                                             "rxbytes", "txbytes");
+                               if (vflag > 0)
+                                       printf("%6.6s %6.6s %6.6s %6.6s ",
+                                              "rhiwat", "shiwat", "pid", "epid");
+                               printf("%6.6s ", "unit");
+                               printf("%6.6s ", "id");
+                               printf("%s", "name");
+                               printf("\n");
+                               first = 0;
+                       }
+                       if (Aflag)
+                               printf("%16llx ", kcb->xkp_kctpcb);
+                       printf("%-5.5s %6u %6u ", name,
+                              so_rcv->sb_cc,
+                              so_snd->sb_cc);
+                       if (bflag > 0) {
+                               int i;
+                               u_int64_t rxbytes = 0;
+                               u_int64_t txbytes = 0;
+                               
+                               for (i = 0; i < SO_TC_STATS_MAX; i++) {
+                                       rxbytes += so_stat->xst_tc_stats[i].rxbytes;
+                                       txbytes += so_stat->xst_tc_stats[i].txbytes;
+                               }
+                               printf("%10llu %10llu ", rxbytes, txbytes);
+                       }
+                       if (vflag > 0) {
+                               printf("%6u %6u %6u %6u ",
+                                      so_rcv->sb_hiwat,
+                                      so_snd->sb_hiwat,
+                                      so->so_last_pid,
+                                      so->so_e_pid);
+                       }
+                       printf("%6d ", kcb->xkp_unit);
+                       printf("%6d ", kcb->xkp_kctlid);
+                       printf("%s", kcb->xkp_kctlname);
+                       printf("\n");
+                       
+               } else if (which == ALL_XGN_KIND_EVT) {
+                       which = 0;
+                       if (first) {
+                               printf("Active kernel event sockets\n");
+                               if (Aflag)
+                                       printf("%16.16s ", "pcb");
+                               printf("%-5.5s %-6.6s %-6.6s ",
+                                      "Proto", "Recv-Q", "Send-Q");
+                               printf("%6.6s ", "vendor");
+                               printf("%6.6s ", "class");
+                               printf("%6.6s", "subclass");
+                               if (bflag > 0)
+                                       printf("%10.10s %10.10s ",
+                                              "rxbytes", "txbytes");
+                               if (vflag > 0)
+                                       printf("%6.6s %6.6s %6.6s %6.6s",
+                                              "rhiwat", "shiwat", "pid", "epid");
+                               printf("\n");
+                               first = 0;
+                       }
+                       if (Aflag)
+                               printf("%16llx ", kevb->kep_evtpcb);
+                       printf("%-5.5s %6u %6u ", name,
+                              so_rcv->sb_cc,
+                              so_snd->sb_cc);
+                       printf("%6d ", kevb->kep_vendor_code_filter);
+                       printf("%6d ", kevb->kep_class_filter);
+                       printf("%6d", kevb->kep_subclass_filter);
+                       if (bflag > 0) {
+                               int i;
+                               u_int64_t rxbytes = 0;
+                               u_int64_t txbytes = 0;
+                               
+                               for (i = 0; i < SO_TC_STATS_MAX; i++) {
+                                       rxbytes += so_stat->xst_tc_stats[i].rxbytes;
+                                       txbytes += so_stat->xst_tc_stats[i].txbytes;
+                               }
+                               printf("%10llu %10llu ", rxbytes, txbytes);
+                       }
+                       if (vflag > 0) {
+                               printf("%6u %6u %6u %6u",
+                                      so_rcv->sb_hiwat,
+                                      so_snd->sb_hiwat,
+                                      so->so_last_pid,
+                                      so->so_e_pid);
+                       }
+                       printf("\n");
+               }
+                       
+       }
+       if (xig != oxig && xig->xg_gen != oxig->xg_gen) {
+               if (oxig->xg_count > xig->xg_count) {
+                       printf("Some %s sockets may have been deleted.\n",
+                              name);
+               } else if (oxig->xg_count < xig->xg_count) {
+                       printf("Some %s sockets may have been created.\n",
+                              name);
+               } else {
+                       printf("Some %s sockets may have been created or deleted",
+                              name);
+               }
+       }
+       free(buf);
+}
+
+void
+kctl_stats(uint32_t off __unused, char *name, int af __unused)
+{
+       static struct kctlstat pkctlstat;
+       struct kctlstat kctlstat;
+       size_t len = sizeof(struct kctlstat);
+       const char *mibvar = "net.systm.kctl.stats";
+       
+       if (sysctlbyname(mibvar, &kctlstat, &len, 0, 0) < 0) {
+               warn("sysctl: %s", mibvar);
+               return;
+       }
+       if (interval && vflag > 0)
+               print_time();
+       printf ("%s:\n", name);
+       
+#define        STATDIFF(f) (kctlstat.f - pkctlstat.f)
+#define        p(f, m) if (STATDIFF(f) || sflag <= 1) \
+       printf(m, STATDIFF(f), plural(STATDIFF(f)))
+#define        p1a(f, m) if (STATDIFF(f) || sflag <= 1) \
+       printf(m, STATDIFF(f))
+       
+       p(kcs_reg_total, "\t%llu total kernel control module%s registered\n");
+       p(kcs_reg_count, "\t%llu current kernel control module%s registered\n");
+       p(kcs_pcbcount, "\t%llu current kernel control socket%s\n");
+       p1a(kcs_gencnt, "\t%llu kernel control generation count\n");
+       p(kcs_connections, "\t%llu connection attempt%s\n");
+       p(kcs_conn_fail, "\t%llu connection failure%s\n");
+       p(kcs_send_fail, "\t%llu send failure%s\n");
+       p(kcs_send_list_fail, "\t%llu send list failure%s\n");
+       p(kcs_enqueue_fail, "\t%llu enqueus failure%s\n");
+       p(kcs_enqueue_fullsock, "\t%llu packet%s dropped due to full socket buffers\n");
+       
+#undef STATDIFF
+#undef p
+#undef p1a
+       
+       if (interval > 0)
+               bcopy(&kctlstat, &pkctlstat, len);
+}
+
+void
+kevt_stats(uint32_t off __unused, char *name, int af __unused)
+{
+       static struct kevtstat pkevtstat;
+       struct kevtstat kevtstat;
+       size_t len = sizeof(struct kctlstat);
+       const char *mibvar = "net.systm.kevt.stats";
+       
+       if (sysctlbyname(mibvar, &kevtstat, &len, 0, 0) < 0) {
+               warn("sysctl: %s", mibvar);
+               return;
+       }
+       if (interval && vflag > 0)
+               print_time();
+       printf ("%s:\n", name);
+       
+#define        STATDIFF(f) (kevtstat.f - pkevtstat.f)
+#define        p(f, m) if (STATDIFF(f) || sflag <= 1) \
+       printf(m, STATDIFF(f), plural(STATDIFF(f)))
+#define        p1a(f, m) if (STATDIFF(f) || sflag <= 1) \
+       printf(m, STATDIFF(f))
+       
+       p(kes_pcbcount, "\t%llu current kernel control socket%s\n");
+       p1a(kes_gencnt, "\t%llu kernel control generation count\n");
+       p(kes_badvendor, "\t%llu bad vendor failure%s\n");
+       p(kes_toobig, "\t%llu message too big failure%s\n");
+       p(kes_nomem, "\t%llu out of memeory failure%s\n");
+       p(kes_fullsock, "\t%llu message%s dropped due to full socket buffers\n");
+       p(kes_posted, "\t%llu message posted%s\n");
+       
+       if (interval > 0)
+               bcopy(&kevtstat, &pkevtstat, len);
+}
index 0e4960857459258b9188b2d113f297cc82670a55..215480947e68b852e4d3d3f17f8852551d5f53f9 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-       "$Id: unix.c,v 1.4 2006/02/07 06:22:20 lindak Exp $";
-#endif /* not lint */
-
 /*
  * Display protocol blocks in the unix domain.
  */
 /*
  * Display protocol blocks in the unix domain.
  */
diff --git a/network-client-server-entitlements.plist b/network-client-server-entitlements.plist
new file mode 100644 (file)
index 0000000..c326c83
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>com.apple.security.network.client</key>
+       <true/>
+       <key>com.apple.security.network.server</key>
+       <true/>
+</dict>
+</plist>
index 962376f80526cbc37cb272fe12659f8d103757aa..f9c2212e6ae73e454f412308067aa2be14442261 100644 (file)
                        );
                        dependencies = (
                                034E4464100BDCA3009CA3DC /* PBXTargetDependency */,
                        );
                        dependencies = (
                                034E4464100BDCA3009CA3DC /* PBXTargetDependency */,
+                               72B732EB1899B19A0060E6D4 /* PBXTargetDependency */,
                                72179EAE146233390098FB3E /* PBXTargetDependency */,
                                034E4469100BDD00009CA3DC /* PBXTargetDependency */,
                                565825AF13392239003E5FA5 /* PBXTargetDependency */,
                                72179EAE146233390098FB3E /* PBXTargetDependency */,
                                034E4469100BDD00009CA3DC /* PBXTargetDependency */,
                                565825AF13392239003E5FA5 /* PBXTargetDependency */,
+                               72311F4D194A34F500EB4788 /* PBXTargetDependency */,
                                690D97BC12DE7151004323A7 /* PBXTargetDependency */,
                                03B2DBD1100BE626005349BC /* PBXTargetDependency */,
                                034E4475100BDEC6009CA3DC /* PBXTargetDependency */,
                                7250E1491616642900A11A76 /* PBXTargetDependency */,
                                690D97BC12DE7151004323A7 /* PBXTargetDependency */,
                                03B2DBD1100BE626005349BC /* PBXTargetDependency */,
                                034E4475100BDEC6009CA3DC /* PBXTargetDependency */,
                                7250E1491616642900A11A76 /* PBXTargetDependency */,
+                               7200F3051958A4FA0033E22C /* PBXTargetDependency */,
                                034E447B100BDF0D009CA3DC /* PBXTargetDependency */,
                                03B2DBD3100BE645005349BC /* PBXTargetDependency */,
                                18515B85133D1DBF000148A4 /* PBXTargetDependency */,
                                034E447B100BDF0D009CA3DC /* PBXTargetDependency */,
                                03B2DBD3100BE645005349BC /* PBXTargetDependency */,
                                18515B85133D1DBF000148A4 /* PBXTargetDependency */,
                        );
                        dependencies = (
                                726121490EE8717B00AFED1B /* PBXTargetDependency */,
                        );
                        dependencies = (
                                726121490EE8717B00AFED1B /* PBXTargetDependency */,
+                               72B732E91899B18F0060E6D4 /* PBXTargetDependency */,
                                723C7074142BB003007C87E9 /* PBXTargetDependency */,
                                7261217D0EE8896800AFED1B /* PBXTargetDependency */,
                                4D2B05141208C6BB0004A3F3 /* PBXTargetDependency */,
                                723C7074142BB003007C87E9 /* PBXTargetDependency */,
                                7261217D0EE8896800AFED1B /* PBXTargetDependency */,
                                4D2B05141208C6BB0004A3F3 /* PBXTargetDependency */,
-                               724DAB9A0EE88F5D008900D0 /* PBXTargetDependency */,
-                               724DAB790EE88EA6008900D0 /* PBXTargetDependency */,
                                724DABC30EE890A6008900D0 /* PBXTargetDependency */,
                                565825AD13392232003E5FA5 /* PBXTargetDependency */,
                                724DABC30EE890A6008900D0 /* PBXTargetDependency */,
                                565825AD13392232003E5FA5 /* PBXTargetDependency */,
+                               72311F4B194A34EB00EB4788 /* PBXTargetDependency */,
                                690D97BE12DE7166004323A7 /* PBXTargetDependency */,
                                690D97BE12DE7166004323A7 /* PBXTargetDependency */,
-                               724DABEC0EE891DF008900D0 /* PBXTargetDependency */,
                                724DAC240EE89525008900D0 /* PBXTargetDependency */,
                                7216D2670EE8978F00AE70E4 /* PBXTargetDependency */,
                                7250E1471616642000A11A76 /* PBXTargetDependency */,
                                724DAC240EE89525008900D0 /* PBXTargetDependency */,
                                7216D2670EE8978F00AE70E4 /* PBXTargetDependency */,
                                7250E1471616642000A11A76 /* PBXTargetDependency */,
+                               7200F3031958A4F10033E22C /* PBXTargetDependency */,
                                7216D2C00EE89ADF00AE70E4 /* PBXTargetDependency */,
                                7216D2C20EE89ADF00AE70E4 /* PBXTargetDependency */,
                                7216D2DA0EE89BE900AE70E4 /* PBXTargetDependency */,
                                7216D2C00EE89ADF00AE70E4 /* PBXTargetDependency */,
                                7216D2C20EE89ADF00AE70E4 /* PBXTargetDependency */,
                                7216D2DA0EE89BE900AE70E4 /* PBXTargetDependency */,
                        dependencies = (
                                72ABD0A41083D818008C721C /* PBXTargetDependency */,
                                72ABD0881083D750008C721C /* PBXTargetDependency */,
                        dependencies = (
                                72ABD0A41083D818008C721C /* PBXTargetDependency */,
                                72ABD0881083D750008C721C /* PBXTargetDependency */,
-                               690D97BA12DE7130004323A7 /* PBXTargetDependency */,
                                565825B113392242003E5FA5 /* PBXTargetDependency */,
                                565825B113392242003E5FA5 /* PBXTargetDependency */,
+                               72311F4F194A34FE00EB4788 /* PBXTargetDependency */,
+                               690D97BA12DE7130004323A7 /* PBXTargetDependency */,
                                72ABD08C1083D75D008C721C /* PBXTargetDependency */,
                                72ABD08E1083D75F008C721C /* PBXTargetDependency */,
                                7250E14B1616643000A11A76 /* PBXTargetDependency */,
                                72ABD08C1083D75D008C721C /* PBXTargetDependency */,
                                72ABD08E1083D75F008C721C /* PBXTargetDependency */,
                                7250E14B1616643000A11A76 /* PBXTargetDependency */,
+                               7200F3071958A5040033E22C /* PBXTargetDependency */,
                                72ABD0901083D762008C721C /* PBXTargetDependency */,
                                72ABD0921083D764008C721C /* PBXTargetDependency */,
                                72ABD0941083D767008C721C /* PBXTargetDependency */,
                                72ABD0901083D762008C721C /* PBXTargetDependency */,
                                72ABD0921083D764008C721C /* PBXTargetDependency */,
                                72ABD0941083D767008C721C /* PBXTargetDependency */,
 
 /* Begin PBXBuildFile section */
                03EB2F9A120A1DDA0007C1A0 /* ip6addrctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4D2B04E41208C12F0004A3F3 /* ip6addrctl.8 */; };
 
 /* Begin PBXBuildFile section */
                03EB2F9A120A1DDA0007C1A0 /* ip6addrctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4D2B04E41208C12F0004A3F3 /* ip6addrctl.8 */; };
-               03EB2F9D120A1E690007C1A0 /* ip6addrctl.conf in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4D2B04E61208C12F0004A3F3 /* ip6addrctl.conf */; };
                4D2B04F81208C21B0004A3F3 /* ip6addrctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D2B04E51208C12F0004A3F3 /* ip6addrctl.c */; };
                565825A4133921A3003E5FA5 /* mnc_error.c in Sources */ = {isa = PBXBuildFile; fileRef = 565825961339217B003E5FA5 /* mnc_error.c */; };
                565825A5133921A3003E5FA5 /* mnc_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 565825971339217B003E5FA5 /* mnc_main.c */; };
                4D2B04F81208C21B0004A3F3 /* ip6addrctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D2B04E51208C12F0004A3F3 /* ip6addrctl.c */; };
                565825A4133921A3003E5FA5 /* mnc_error.c in Sources */ = {isa = PBXBuildFile; fileRef = 565825961339217B003E5FA5 /* mnc_error.c */; };
                565825A5133921A3003E5FA5 /* mnc_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 565825971339217B003E5FA5 /* mnc_main.c */; };
                56B6B66816F79A1C00D8A7A9 /* mptcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 56B6B66716F79A1C00D8A7A9 /* mptcp.c */; };
                690D97A612DE6F96004323A7 /* mtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 690D979412DE6E6B004323A7 /* mtest.c */; };
                690D97AE12DE70AE004323A7 /* mtest.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 690D979512DE6E76004323A7 /* mtest.8 */; };
                56B6B66816F79A1C00D8A7A9 /* mptcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 56B6B66716F79A1C00D8A7A9 /* mptcp.c */; };
                690D97A612DE6F96004323A7 /* mtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 690D979412DE6E6B004323A7 /* mtest.c */; };
                690D97AE12DE70AE004323A7 /* mtest.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 690D979512DE6E76004323A7 /* mtest.8 */; };
+               7200F2FD1958A34D0033E22C /* packet_mangler.c in Sources */ = {isa = PBXBuildFile; fileRef = 7200F2FC1958A34D0033E22C /* packet_mangler.c */; };
                7216D24C0EE896F300AE70E4 /* data.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208B0EE86F4800AFED1B /* data.c */; };
                7216D24D0EE896F300AE70E4 /* if.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208D0EE86F4800AFED1B /* if.c */; };
                7216D24E0EE896F300AE70E4 /* inet.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208E0EE86F4800AFED1B /* inet.c */; };
                7216D24C0EE896F300AE70E4 /* data.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208B0EE86F4800AFED1B /* data.c */; };
                7216D24D0EE896F300AE70E4 /* if.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208D0EE86F4800AFED1B /* if.c */; };
                7216D24E0EE896F300AE70E4 /* inet.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261208E0EE86F4800AFED1B /* inet.c */; };
                7216D2510EE896F300AE70E4 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120910EE86F4800AFED1B /* main.c */; };
                7216D2520EE896F300AE70E4 /* mbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120930EE86F4800AFED1B /* mbuf.c */; };
                7216D2530EE896F300AE70E4 /* mcast.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120940EE86F4800AFED1B /* mcast.c */; };
                7216D2510EE896F300AE70E4 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120910EE86F4800AFED1B /* main.c */; };
                7216D2520EE896F300AE70E4 /* mbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120930EE86F4800AFED1B /* mbuf.c */; };
                7216D2530EE896F300AE70E4 /* mcast.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120940EE86F4800AFED1B /* mcast.c */; };
-               7216D2540EE896F300AE70E4 /* mroute.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120950EE86F4800AFED1B /* mroute.c */; };
-               7216D2550EE896F300AE70E4 /* mroute6.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120960EE86F4800AFED1B /* mroute6.c */; };
                7216D2560EE896F300AE70E4 /* route.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120990EE86F4800AFED1B /* route.c */; };
                7216D2570EE896F300AE70E4 /* tp_astring.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261209A0EE86F4800AFED1B /* tp_astring.c */; };
                7216D2580EE896F300AE70E4 /* unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261209B0EE86F4800AFED1B /* unix.c */; };
                7216D2560EE896F300AE70E4 /* route.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120990EE86F4800AFED1B /* route.c */; };
                7216D2570EE896F300AE70E4 /* tp_astring.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261209A0EE86F4800AFED1B /* tp_astring.c */; };
                7216D2580EE896F300AE70E4 /* unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 7261209B0EE86F4800AFED1B /* unix.c */; };
                7216D3700EE8A05B00AE70E4 /* rtsol.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120D70EE86F9100AFED1B /* rtsol.8 */; };
                7216D3AB0EE8A3C400AE70E4 /* spray.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120E00EE86F9D00AFED1B /* spray.c */; };
                7216D3AF0EE8A3D800AE70E4 /* spray.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120DF0EE86F9D00AFED1B /* spray.8 */; };
                7216D3700EE8A05B00AE70E4 /* rtsol.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120D70EE86F9100AFED1B /* rtsol.8 */; };
                7216D3AB0EE8A3C400AE70E4 /* spray.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120E00EE86F9D00AFED1B /* spray.c */; };
                7216D3AF0EE8A3D800AE70E4 /* spray.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120DF0EE86F9D00AFED1B /* spray.8 */; };
+               7218B54A191D4202001B7B52 /* systm.c in Sources */ = {isa = PBXBuildFile; fileRef = 7218B549191D4202001B7B52 /* systm.c */; };
+               72311F54194A354F00EB4788 /* conn_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 72311F50194A354F00EB4788 /* conn_lib.c */; };
+               72311F55194A354F00EB4788 /* mptcp_client.c in Sources */ = {isa = PBXBuildFile; fileRef = 72311F53194A354F00EB4788 /* mptcp_client.c */; };
+               72311F56194A76DA00EB4788 /* mptcp_client.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 72311F52194A354F00EB4788 /* mptcp_client.1 */; };
                724753E7144905E300F6A941 /* dnctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 724753E61448E1EF00F6A941 /* dnctl.8 */; };
                7247B83616165EDC00873B3C /* pktapctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7247B83516165EDC00873B3C /* pktapctl.8 */; };
                7247B83C16165F0100873B3C /* pktapctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 7247B83B16165F0100873B3C /* pktapctl.c */; };
                724753E7144905E300F6A941 /* dnctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 724753E61448E1EF00F6A941 /* dnctl.8 */; };
                7247B83616165EDC00873B3C /* pktapctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7247B83516165EDC00873B3C /* pktapctl.8 */; };
                7247B83C16165F0100873B3C /* pktapctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 7247B83B16165F0100873B3C /* pktapctl.c */; };
                7294F1080EE8BBB10052EC88 /* traceroute.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120F00EE86FA700AFED1B /* traceroute.8 */; };
                7294F12E0EE8BD2F0052EC88 /* traceroute6.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120FB0EE86FB500AFED1B /* traceroute6.c */; };
                7294F1320EE8BD430052EC88 /* traceroute6.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120FA0EE86FB500AFED1B /* traceroute6.8 */; };
                7294F1080EE8BBB10052EC88 /* traceroute.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120F00EE86FA700AFED1B /* traceroute.8 */; };
                7294F12E0EE8BD2F0052EC88 /* traceroute6.c in Sources */ = {isa = PBXBuildFile; fileRef = 726120FB0EE86FB500AFED1B /* traceroute6.c */; };
                7294F1320EE8BD430052EC88 /* traceroute6.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 726120FA0EE86FB500AFED1B /* traceroute6.8 */; };
+               72B732DF1899B0380060E6D4 /* cfilutil.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 72B732DE1899B0380060E6D4 /* cfilutil.1 */; };
+               72B732EF1899B23A0060E6D4 /* cfilutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 72B732EE1899B23A0060E6D4 /* cfilutil.c */; };
+               72B732F11899B2430060E6D4 /* cfilstat.c in Sources */ = {isa = PBXBuildFile; fileRef = 72B732F01899B2430060E6D4 /* cfilstat.c */; };
                72B894EC0EEDB17C00C218D6 /* libipsec.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72CD1DB50EE8C619005F825D /* libipsec.dylib */; };
                72D000C4142BB11100151981 /* dnctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 72D000C3142BB11100151981 /* dnctl.c */; };
                72E42BA314B7CF3D003AAE28 /* network_cmds.plist in Install OSS Plist */ = {isa = PBXBuildFile; fileRef = 72E42BA214B7CF37003AAE28 /* network_cmds.plist */; };
                72B894EC0EEDB17C00C218D6 /* libipsec.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72CD1DB50EE8C619005F825D /* libipsec.dylib */; };
                72D000C4142BB11100151981 /* dnctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 72D000C3142BB11100151981 /* dnctl.c */; };
                72E42BA314B7CF3D003AAE28 /* network_cmds.plist in Install OSS Plist */ = {isa = PBXBuildFile; fileRef = 72E42BA214B7CF37003AAE28 /* network_cmds.plist */; };
                        remoteGlobalIDString = 690D978012DE6034004323A7;
                        remoteInfo = mtest;
                };
                        remoteGlobalIDString = 690D978012DE6034004323A7;
                        remoteInfo = mtest;
                };
+               7200F3021958A4F10033E22C /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 7200F2F91958A34D0033E22C;
+                       remoteInfo = pktmnglr;
+               };
+               7200F3041958A4FA0033E22C /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 7200F2F91958A34D0033E22C;
+                       remoteInfo = pktmnglr;
+               };
+               7200F3061958A5040033E22C /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 7200F2F91958A34D0033E22C;
+                       remoteInfo = pktmnglr;
+               };
                7216D2660EE8978F00AE70E4 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                7216D2660EE8978F00AE70E4 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        remoteGlobalIDString = 723C7067142BAFEA007C87E9;
                        remoteInfo = dnctl;
                };
                        remoteGlobalIDString = 723C7067142BAFEA007C87E9;
                        remoteInfo = dnctl;
                };
-               723C7073142BB003007C87E9 /* PBXContainerItemProxy */ = {
+               72311F4A194A34EB00EB4788 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 723C7067142BAFEA007C87E9;
-                       remoteInfo = dnctl;
+                       remoteGlobalIDString = 72311F41194A349000EB4788;
+                       remoteInfo = mptcp_client;
                };
                };
-               724DAB780EE88EA6008900D0 /* PBXContainerItemProxy */ = {
+               72311F4C194A34F500EB4788 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 724DAB5E0EE88E2A008900D0;
-                       remoteInfo = ipfw;
+                       remoteGlobalIDString = 72311F41194A349000EB4788;
+                       remoteInfo = mptcp_client;
                };
                };
-               724DAB990EE88F5D008900D0 /* PBXContainerItemProxy */ = {
+               72311F4E194A34FE00EB4788 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 724DAB810EE88EFA008900D0;
-                       remoteInfo = ip6fw;
+                       remoteGlobalIDString = 72311F41194A349000EB4788;
+                       remoteInfo = mptcp_client;
                };
                };
-               724DABC20EE890A6008900D0 /* PBXContainerItemProxy */ = {
+               723C7073142BB003007C87E9 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 724DABA10EE88FE3008900D0;
-                       remoteInfo = kdumpd;
+                       remoteGlobalIDString = 723C7067142BAFEA007C87E9;
+                       remoteInfo = dnctl;
                };
                };
-               724DABEB0EE891DF008900D0 /* PBXContainerItemProxy */ = {
+               724DABC20EE890A6008900D0 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 724DABDA0EE8912D008900D0;
-                       remoteInfo = natd;
+                       remoteGlobalIDString = 724DABA10EE88FE3008900D0;
+                       remoteInfo = kdumpd;
                };
                724DAC230EE89525008900D0 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                };
                724DAC230EE89525008900D0 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        remoteGlobalIDString = 7261212C0EE8710B00AFED1B;
                        remoteInfo = arp;
                };
                        remoteGlobalIDString = 7261212C0EE8710B00AFED1B;
                        remoteInfo = arp;
                };
+               72B732E81899B18F0060E6D4 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 72B732D91899B0380060E6D4;
+                       remoteInfo = cfilutil;
+               };
+               72B732EA1899B19A0060E6D4 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 72B732D91899B0380060E6D4;
+                       remoteInfo = cfilutil;
+               };
                72C77D3C1484199C002D2577 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
                72C77D3C1484199C002D2577 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 724862310EE86EB7001D0DE9 /* Project object */;
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXCopyFilesBuildPhase section */
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXCopyFilesBuildPhase section */
-               03EB2FB6120A1E740007C1A0 /* CopyFiles */ = {
-                       isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 8;
-                       dstPath = /private/etc;
-                       dstSubfolderSpec = 0;
-                       files = (
-                               03EB2F9D120A1E690007C1A0 /* ip6addrctl.conf in CopyFiles */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 1;
-               };
                4D2B05221208CB410004A3F3 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
                4D2B05221208CB410004A3F3 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
-                       dstPath = /usr/share/man/man8;
+                       dstPath = /usr/local/share/man/man8;
                        dstSubfolderSpec = 0;
                        files = (
                                03EB2F9A120A1DDA0007C1A0 /* ip6addrctl.8 in CopyFiles */,
                        dstSubfolderSpec = 0;
                        files = (
                                03EB2F9A120A1DDA0007C1A0 /* ip6addrctl.8 in CopyFiles */,
                        name = "Install OSS Plist";
                        runOnlyForDeploymentPostprocessing = 1;
                };
                        name = "Install OSS Plist";
                        runOnlyForDeploymentPostprocessing = 1;
                };
+               7200F2F81958A34D0033E22C /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /usr/share/man/man1/;
+                       dstSubfolderSpec = 0;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+               };
                7216D2750EE8979500AE70E4 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
                7216D2750EE8979500AE70E4 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
+               72311F40194A349000EB4788 /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /usr/share/man/man1/;
+                       dstSubfolderSpec = 0;
+                       files = (
+                               72311F56194A76DA00EB4788 /* mptcp_client.1 in CopyFiles */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+               };
                723C7066142BAFEA007C87E9 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 2147483647;
                723C7066142BAFEA007C87E9 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 2147483647;
-                       dstPath = /usr/local/share/man/man8/;
+                       dstPath = /usr/share/man/man8;
                        dstSubfolderSpec = 0;
                        files = (
                                724753E7144905E300F6A941 /* dnctl.8 in CopyFiles */,
                        dstSubfolderSpec = 0;
                        files = (
                                724753E7144905E300F6A941 /* dnctl.8 in CopyFiles */,
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                };
+               72B732D81899B0380060E6D4 /* CopyFiles */ = {
+                       isa = PBXCopyFilesBuildPhase;
+                       buildActionMask = 2147483647;
+                       dstPath = /usr/share/man/man1/;
+                       dstSubfolderSpec = 0;
+                       files = (
+                               72B732DF1899B0380060E6D4 /* cfilutil.1 in CopyFiles */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 1;
+               };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
                690D979412DE6E6B004323A7 /* mtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mtest.c; sourceTree = "<group>"; };
                690D979512DE6E76004323A7 /* mtest.8 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mtest.8; sourceTree = "<group>"; };
                69C10A7912DF80F200BCDF4C /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING; sourceTree = "<group>"; };
                690D979412DE6E6B004323A7 /* mtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mtest.c; sourceTree = "<group>"; };
                690D979512DE6E76004323A7 /* mtest.8 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mtest.8; sourceTree = "<group>"; };
                69C10A7912DF80F200BCDF4C /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING; sourceTree = "<group>"; };
+               7200F2FA1958A34D0033E22C /* pktmnglr */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = pktmnglr; sourceTree = BUILT_PRODUCTS_DIR; };
+               7200F2FC1958A34D0033E22C /* packet_mangler.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = packet_mangler.c; sourceTree = "<group>"; };
+               7211D9B2190713A60086EF20 /* network-client-server-entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "network-client-server-entitlements.plist"; sourceTree = "<group>"; };
                7216D2460EE896C000AE70E4 /* netstat */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = netstat; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D27C0EE8980A00AE70E4 /* ping */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ping; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D29A0EE898BD00AE70E4 /* ping6 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ping6; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D2460EE896C000AE70E4 /* netstat */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = netstat; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D27C0EE8980A00AE70E4 /* ping */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ping; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D29A0EE898BD00AE70E4 /* ping6 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ping6; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3140EE89E9E00AE70E4 /* rtadvd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rtadvd; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3590EE8A02200AE70E4 /* rtsol */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rtsol; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3A70EE8A3BB00AE70E4 /* spray */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = spray; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3140EE89E9E00AE70E4 /* rtadvd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rtadvd; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3590EE8A02200AE70E4 /* rtsol */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = rtsol; sourceTree = BUILT_PRODUCTS_DIR; };
                7216D3A70EE8A3BB00AE70E4 /* spray */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = spray; sourceTree = BUILT_PRODUCTS_DIR; };
+               7218B549191D4202001B7B52 /* systm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = systm.c; sourceTree = "<group>"; };
+               72311F42194A349000EB4788 /* mptcp_client */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mptcp_client; sourceTree = BUILT_PRODUCTS_DIR; };
+               72311F50194A354F00EB4788 /* conn_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = conn_lib.c; sourceTree = "<group>"; };
+               72311F51194A354F00EB4788 /* conn_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = conn_lib.h; sourceTree = "<group>"; };
+               72311F52194A354F00EB4788 /* mptcp_client.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = mptcp_client.1; sourceTree = "<group>"; };
+               72311F53194A354F00EB4788 /* mptcp_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mptcp_client.c; sourceTree = "<group>"; };
                723C7068142BAFEA007C87E9 /* dnctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dnctl; sourceTree = BUILT_PRODUCTS_DIR; };
                724753E61448E1EF00F6A941 /* dnctl.8 */ = {isa = PBXFileReference; lastKnownFileType = text; path = dnctl.8; sourceTree = "<group>"; };
                7247B83116165EDC00873B3C /* pktapctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = pktapctl; sourceTree = BUILT_PRODUCTS_DIR; };
                723C7068142BAFEA007C87E9 /* dnctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dnctl; sourceTree = BUILT_PRODUCTS_DIR; };
                724753E61448E1EF00F6A941 /* dnctl.8 */ = {isa = PBXFileReference; lastKnownFileType = text; path = dnctl.8; sourceTree = "<group>"; };
                7247B83116165EDC00873B3C /* pktapctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = pktapctl; sourceTree = BUILT_PRODUCTS_DIR; };
                726120910EE86F4800AFED1B /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
                726120930EE86F4800AFED1B /* mbuf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mbuf.c; sourceTree = "<group>"; };
                726120940EE86F4800AFED1B /* mcast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcast.c; sourceTree = "<group>"; };
                726120910EE86F4800AFED1B /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
                726120930EE86F4800AFED1B /* mbuf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mbuf.c; sourceTree = "<group>"; };
                726120940EE86F4800AFED1B /* mcast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcast.c; sourceTree = "<group>"; };
-               726120950EE86F4800AFED1B /* mroute.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mroute.c; sourceTree = "<group>"; };
-               726120960EE86F4800AFED1B /* mroute6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mroute6.c; sourceTree = "<group>"; };
                726120970EE86F4800AFED1B /* netstat.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = netstat.1; sourceTree = "<group>"; };
                726120980EE86F4800AFED1B /* netstat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netstat.h; sourceTree = "<group>"; };
                726120990EE86F4800AFED1B /* route.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = route.c; sourceTree = "<group>"; };
                726120970EE86F4800AFED1B /* netstat.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = netstat.1; sourceTree = "<group>"; };
                726120980EE86F4800AFED1B /* netstat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netstat.h; sourceTree = "<group>"; };
                726120990EE86F4800AFED1B /* route.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = route.c; sourceTree = "<group>"; };
                726121540EE8881700AFED1B /* ifconfig */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ifconfig; sourceTree = BUILT_PRODUCTS_DIR; };
                7294F0F90EE8BB460052EC88 /* traceroute */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = traceroute; sourceTree = BUILT_PRODUCTS_DIR; };
                7294F12A0EE8BD280052EC88 /* traceroute6 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = traceroute6; sourceTree = BUILT_PRODUCTS_DIR; };
                726121540EE8881700AFED1B /* ifconfig */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ifconfig; sourceTree = BUILT_PRODUCTS_DIR; };
                7294F0F90EE8BB460052EC88 /* traceroute */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = traceroute; sourceTree = BUILT_PRODUCTS_DIR; };
                7294F12A0EE8BD280052EC88 /* traceroute6 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = traceroute6; sourceTree = BUILT_PRODUCTS_DIR; };
+               72B732DA1899B0380060E6D4 /* cfilutil */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cfilutil; sourceTree = BUILT_PRODUCTS_DIR; };
+               72B732DE1899B0380060E6D4 /* cfilutil.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = cfilutil.1; sourceTree = "<group>"; };
+               72B732EE1899B23A0060E6D4 /* cfilutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cfilutil.c; sourceTree = "<group>"; };
+               72B732F01899B2430060E6D4 /* cfilstat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cfilstat.c; sourceTree = "<group>"; };
                72CD1DB50EE8C619005F825D /* libipsec.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libipsec.dylib; path = /usr/lib/libipsec.dylib; sourceTree = "<absolute>"; };
                72D000C3142BB11100151981 /* dnctl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dnctl.c; sourceTree = "<group>"; };
                72E42BA214B7CF37003AAE28 /* network_cmds.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = network_cmds.plist; sourceTree = "<group>"; };
                72CD1DB50EE8C619005F825D /* libipsec.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libipsec.dylib; path = /usr/lib/libipsec.dylib; sourceTree = "<absolute>"; };
                72D000C3142BB11100151981 /* dnctl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dnctl.c; sourceTree = "<group>"; };
                72E42BA214B7CF37003AAE28 /* network_cmds.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = network_cmds.plist; sourceTree = "<group>"; };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               7200F2F71958A34D0033E22C /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                7216D2440EE896C000AE70E4 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                7216D2440EE896C000AE70E4 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               72311F3F194A349000EB4788 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                723C7065142BAFEA007C87E9 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                723C7065142BAFEA007C87E9 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               72B732D71899B0380060E6D4 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
                        path = mtest.tproj;
                        sourceTree = "<group>";
                };
                        path = mtest.tproj;
                        sourceTree = "<group>";
                };
+               7200F2FB1958A34D0033E22C /* pktmnglr */ = {
+                       isa = PBXGroup;
+                       children = (
+                               7200F2FC1958A34D0033E22C /* packet_mangler.c */,
+                       );
+                       path = pktmnglr;
+                       sourceTree = "<group>";
+               };
+               72311F43194A349100EB4788 /* mptcp_client */ = {
+                       isa = PBXGroup;
+                       children = (
+                               72311F53194A354F00EB4788 /* mptcp_client.c */,
+                               72311F50194A354F00EB4788 /* conn_lib.c */,
+                               72311F51194A354F00EB4788 /* conn_lib.h */,
+                               72311F52194A354F00EB4788 /* mptcp_client.1 */,
+                       );
+                       path = mptcp_client;
+                       sourceTree = "<group>";
+               };
                723C706A142BAFEA007C87E9 /* dnctl */ = {
                        isa = PBXGroup;
                        children = (
                723C706A142BAFEA007C87E9 /* dnctl */ = {
                        isa = PBXGroup;
                        children = (
                        isa = PBXGroup;
                        children = (
                                72E42BA214B7CF37003AAE28 /* network_cmds.plist */,
                        isa = PBXGroup;
                        children = (
                                72E42BA214B7CF37003AAE28 /* network_cmds.plist */,
+                               7211D9B2190713A60086EF20 /* network-client-server-entitlements.plist */,
                                E01AB08F1368880F008C66FF /* libutil.dylib */,
                                726120380EE86EEB00AFED1B /* alias */,
                                7261204C0EE86EF900AFED1B /* arp.tproj */,
                                E01AB08F1368880F008C66FF /* libutil.dylib */,
                                726120380EE86EEB00AFED1B /* alias */,
                                7261204C0EE86EF900AFED1B /* arp.tproj */,
+                               72B732DB1899B0380060E6D4 /* cfilutil */,
                                723C706A142BAFEA007C87E9 /* dnctl */,
                                726120540EE86F0900AFED1B /* ifconfig.tproj */,
                                4D2B04E31208C12F0004A3F3 /* ip6addrctl.tproj */,
                                723C706A142BAFEA007C87E9 /* dnctl */,
                                726120540EE86F0900AFED1B /* ifconfig.tproj */,
                                4D2B04E31208C12F0004A3F3 /* ip6addrctl.tproj */,
                                726120FE0EE8701100AFED1B /* ipfw.tproj */,
                                7261206D0EE86F2D00AFED1B /* kdumpd.tproj */,
                                56582591133920B5003E5FA5 /* mnc.tproj */,
                                726120FE0EE8701100AFED1B /* ipfw.tproj */,
                                7261206D0EE86F2D00AFED1B /* kdumpd.tproj */,
                                56582591133920B5003E5FA5 /* mnc.tproj */,
+                               72311F43194A349100EB4788 /* mptcp_client */,
                                690D973F12DE5A21004323A7 /* mtest.tproj */,
                                726120770EE86F3600AFED1B /* natd.tproj */,
                                726120830EE86F4000AFED1B /* ndp.tproj */,
                                7261208A0EE86F4800AFED1B /* netstat.tproj */,
                                7247B83216165EDC00873B3C /* pktapctl */,
                                690D973F12DE5A21004323A7 /* mtest.tproj */,
                                726120770EE86F3600AFED1B /* natd.tproj */,
                                726120830EE86F4000AFED1B /* ndp.tproj */,
                                7261208A0EE86F4800AFED1B /* netstat.tproj */,
                                7247B83216165EDC00873B3C /* pktapctl */,
+                               7200F2FB1958A34D0033E22C /* pktmnglr */,
                                7261209E0EE86F5000AFED1B /* ping.tproj */,
                                726120A40EE86F5C00AFED1B /* ping6.tproj */,
                                726120AC0EE86F6700AFED1B /* rarpd.tproj */,
                                7261209E0EE86F5000AFED1B /* ping.tproj */,
                                726120A40EE86F5C00AFED1B /* ping6.tproj */,
                                726120AC0EE86F6700AFED1B /* rarpd.tproj */,
                                726120930EE86F4800AFED1B /* mbuf.c */,
                                726120940EE86F4800AFED1B /* mcast.c */,
                                56B6B66716F79A1C00D8A7A9 /* mptcp.c */,
                                726120930EE86F4800AFED1B /* mbuf.c */,
                                726120940EE86F4800AFED1B /* mcast.c */,
                                56B6B66716F79A1C00D8A7A9 /* mptcp.c */,
-                               726120950EE86F4800AFED1B /* mroute.c */,
-                               726120960EE86F4800AFED1B /* mroute6.c */,
                                726120970EE86F4800AFED1B /* netstat.1 */,
                                726120980EE86F4800AFED1B /* netstat.h */,
                                726120990EE86F4800AFED1B /* route.c */,
                                7261209A0EE86F4800AFED1B /* tp_astring.c */,
                                7261209B0EE86F4800AFED1B /* unix.c */,
                                726120970EE86F4800AFED1B /* netstat.1 */,
                                726120980EE86F4800AFED1B /* netstat.h */,
                                726120990EE86F4800AFED1B /* route.c */,
                                7261209A0EE86F4800AFED1B /* tp_astring.c */,
                                7261209B0EE86F4800AFED1B /* unix.c */,
+                               7218B549191D4202001B7B52 /* systm.c */,
                        );
                        path = netstat.tproj;
                        sourceTree = "<group>";
                        );
                        path = netstat.tproj;
                        sourceTree = "<group>";
                                5658259F1339218F003E5FA5 /* mnc */,
                                723C7068142BAFEA007C87E9 /* dnctl */,
                                7247B83116165EDC00873B3C /* pktapctl */,
                                5658259F1339218F003E5FA5 /* mnc */,
                                723C7068142BAFEA007C87E9 /* dnctl */,
                                7247B83116165EDC00873B3C /* pktapctl */,
+                               72B732DA1899B0380060E6D4 /* cfilutil */,
+                               72311F42194A349000EB4788 /* mptcp_client */,
+                               7200F2FA1958A34D0033E22C /* pktmnglr */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                };
                        );
                        name = Products;
                        sourceTree = "<group>";
                };
+               72B732DB1899B0380060E6D4 /* cfilutil */ = {
+                       isa = PBXGroup;
+                       children = (
+                               72B732EE1899B23A0060E6D4 /* cfilutil.c */,
+                               72B732F01899B2430060E6D4 /* cfilstat.c */,
+                               72B732DE1899B0380060E6D4 /* cfilutil.1 */,
+                       );
+                       path = cfilutil;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                        buildPhases = (
                                4D2B04F01208C2040004A3F3 /* Sources */,
                                4D2B05221208CB410004A3F3 /* CopyFiles */,
                        buildPhases = (
                                4D2B04F01208C2040004A3F3 /* Sources */,
                                4D2B05221208CB410004A3F3 /* CopyFiles */,
-                               03EB2FB6120A1E740007C1A0 /* CopyFiles */,
                                039D6A11120A2CF60006B8C8 /* ShellScript */,
                        );
                        buildRules = (
                                039D6A11120A2CF60006B8C8 /* ShellScript */,
                        );
                        buildRules = (
                        productReference = 690D978112DE6034004323A7 /* mtest */;
                        productType = "com.apple.product-type.tool";
                };
                        productReference = 690D978112DE6034004323A7 /* mtest */;
                        productType = "com.apple.product-type.tool";
                };
+               7200F2F91958A34D0033E22C /* pktmnglr */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 7200F3011958A34E0033E22C /* Build configuration list for PBXNativeTarget "pktmnglr" */;
+                       buildPhases = (
+                               7200F2F61958A34D0033E22C /* Sources */,
+                               7200F2F71958A34D0033E22C /* Frameworks */,
+                               7200F2F81958A34D0033E22C /* CopyFiles */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = pktmnglr;
+                       productName = pktmnglr;
+                       productReference = 7200F2FA1958A34D0033E22C /* pktmnglr */;
+                       productType = "com.apple.product-type.tool";
+               };
                7216D2450EE896C000AE70E4 /* netstat */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 7216D24B0EE896EC00AE70E4 /* Build configuration list for PBXNativeTarget "netstat" */;
                7216D2450EE896C000AE70E4 /* netstat */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 7216D24B0EE896EC00AE70E4 /* Build configuration list for PBXNativeTarget "netstat" */;
                        productReference = 7216D3A70EE8A3BB00AE70E4 /* spray */;
                        productType = "com.apple.product-type.tool";
                };
                        productReference = 7216D3A70EE8A3BB00AE70E4 /* spray */;
                        productType = "com.apple.product-type.tool";
                };
+               72311F41194A349000EB4788 /* mptcp_client */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 72311F46194A349100EB4788 /* Build configuration list for PBXNativeTarget "mptcp_client" */;
+                       buildPhases = (
+                               72311F3E194A349000EB4788 /* Sources */,
+                               72311F3F194A349000EB4788 /* Frameworks */,
+                               72311F40194A349000EB4788 /* CopyFiles */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = mptcp_client;
+                       productName = mptcp_client;
+                       productReference = 72311F42194A349000EB4788 /* mptcp_client */;
+                       productType = "com.apple.product-type.tool";
+               };
                723C7067142BAFEA007C87E9 /* dnctl */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 723C706F142BAFEA007C87E9 /* Build configuration list for PBXNativeTarget "dnctl" */;
                723C7067142BAFEA007C87E9 /* dnctl */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 723C706F142BAFEA007C87E9 /* Build configuration list for PBXNativeTarget "dnctl" */;
                        productReference = 7294F12A0EE8BD280052EC88 /* traceroute6 */;
                        productType = "com.apple.product-type.tool";
                };
                        productReference = 7294F12A0EE8BD280052EC88 /* traceroute6 */;
                        productType = "com.apple.product-type.tool";
                };
+               72B732D91899B0380060E6D4 /* cfilutil */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 72B732E31899B0380060E6D4 /* Build configuration list for PBXNativeTarget "cfilutil" */;
+                       buildPhases = (
+                               72B732D61899B0380060E6D4 /* Sources */,
+                               72B732D71899B0380060E6D4 /* Frameworks */,
+                               72B732D81899B0380060E6D4 /* CopyFiles */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = cfilutil;
+                       productName = cfilutil;
+                       productReference = 72B732DA1899B0380060E6D4 /* cfilutil */;
+                       productType = "com.apple.product-type.tool";
+               };
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
                        isa = PBXProject;
                        attributes = {
                                LastUpgradeCheck = 0500;
                        isa = PBXProject;
                        attributes = {
                                LastUpgradeCheck = 0500;
+                               TargetAttributes = {
+                                       7200F2F91958A34D0033E22C = {
+                                               CreatedOnToolsVersion = 6.0;
+                                       };
+                                       72311F41194A349000EB4788 = {
+                                               CreatedOnToolsVersion = 6.0;
+                                       };
+                               };
                        };
                        buildConfigurationList = 724862340EE86EB7001D0DE9 /* Build configuration list for PBXProject "network_cmds" */;
                        compatibilityVersion = "Xcode 3.2";
                        };
                        buildConfigurationList = 724862340EE86EB7001D0DE9 /* Build configuration list for PBXProject "network_cmds" */;
                        compatibilityVersion = "Xcode 3.2";
                                7261210B0EE8707500AFED1B /* alias */,
                                7261212C0EE8710B00AFED1B /* arp */,
                                723C7067142BAFEA007C87E9 /* dnctl */,
                                7261210B0EE8707500AFED1B /* alias */,
                                7261212C0EE8710B00AFED1B /* arp */,
                                723C7067142BAFEA007C87E9 /* dnctl */,
+                               72B732D91899B0380060E6D4 /* cfilutil */,
                                726121530EE8881700AFED1B /* ifconfig */,
                                4D2B04F21208C2040004A3F3 /* ip6addrctl */,
                                724DAB810EE88EFA008900D0 /* ip6fw */,
                                724DAB5E0EE88E2A008900D0 /* ipfw */,
                                724DABA10EE88FE3008900D0 /* kdumpd */,
                                5658259E1339218F003E5FA5 /* mnc */,
                                726121530EE8881700AFED1B /* ifconfig */,
                                4D2B04F21208C2040004A3F3 /* ip6addrctl */,
                                724DAB810EE88EFA008900D0 /* ip6fw */,
                                724DAB5E0EE88E2A008900D0 /* ipfw */,
                                724DABA10EE88FE3008900D0 /* kdumpd */,
                                5658259E1339218F003E5FA5 /* mnc */,
+                               72311F41194A349000EB4788 /* mptcp_client */,
                                690D978012DE6034004323A7 /* mtest */,
                                724DABDA0EE8912D008900D0 /* natd */,
                                724DAC0C0EE8940D008900D0 /* ndp */,
                                7216D2450EE896C000AE70E4 /* netstat */,
                                7247B83016165EDC00873B3C /* pktapctl */,
                                690D978012DE6034004323A7 /* mtest */,
                                724DABDA0EE8912D008900D0 /* natd */,
                                724DAC0C0EE8940D008900D0 /* ndp */,
                                7216D2450EE896C000AE70E4 /* netstat */,
                                7247B83016165EDC00873B3C /* pktapctl */,
+                               7200F2F91958A34D0033E22C /* pktmnglr */,
                                7216D27B0EE8980A00AE70E4 /* ping */,
                                7216D2990EE898BD00AE70E4 /* ping6 */,
                                7216D2CC0EE89B7900AE70E4 /* rarpd */,
                                7216D27B0EE8980A00AE70E4 /* ping */,
                                7216D2990EE898BD00AE70E4 /* ping6 */,
                                7216D2CC0EE89B7900AE70E4 /* rarpd */,
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                        shellPath = /bin/sh;
                        );
                        runOnlyForDeploymentPostprocessing = 1;
                        shellPath = /bin/sh;
-                       shellScript = "/bin/chmod 0444 $DSTROOT/usr/share/man/man8/ip6addrctl.8\n/bin/chmod 0644 $DSTROOT/private/etc/ip6addrctl.conf";
+                       shellScript = "/bin/chmod 0444 $DSTROOT/usr/local/share/man/man8/ip6addrctl.8";
                };
                690D97C212DE71CF004323A7 /* ShellScript */ = {
                        isa = PBXShellScriptBuildPhase;
                };
                690D97C212DE71CF004323A7 /* ShellScript */ = {
                        isa = PBXShellScriptBuildPhase;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               7200F2F61958A34D0033E22C /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               7200F2FD1958A34D0033E22C /* packet_mangler.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                7216D2430EE896C000AE70E4 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                7216D2430EE896C000AE70E4 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                                7216D2510EE896F300AE70E4 /* main.c in Sources */,
                                7216D2520EE896F300AE70E4 /* mbuf.c in Sources */,
                                7216D2530EE896F300AE70E4 /* mcast.c in Sources */,
                                7216D2510EE896F300AE70E4 /* main.c in Sources */,
                                7216D2520EE896F300AE70E4 /* mbuf.c in Sources */,
                                7216D2530EE896F300AE70E4 /* mcast.c in Sources */,
-                               7216D2540EE896F300AE70E4 /* mroute.c in Sources */,
-                               7216D2550EE896F300AE70E4 /* mroute6.c in Sources */,
+                               7218B54A191D4202001B7B52 /* systm.c in Sources */,
                                7216D2560EE896F300AE70E4 /* route.c in Sources */,
                                7216D2570EE896F300AE70E4 /* tp_astring.c in Sources */,
                                56B6B66816F79A1C00D8A7A9 /* mptcp.c in Sources */,
                                7216D2560EE896F300AE70E4 /* route.c in Sources */,
                                7216D2570EE896F300AE70E4 /* tp_astring.c in Sources */,
                                56B6B66816F79A1C00D8A7A9 /* mptcp.c in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               72311F3E194A349000EB4788 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               72311F54194A354F00EB4788 /* conn_lib.c in Sources */,
+                               72311F55194A354F00EB4788 /* mptcp_client.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                723C7064142BAFEA007C87E9 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                723C7064142BAFEA007C87E9 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
+               72B732D61899B0380060E6D4 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               72B732EF1899B23A0060E6D4 /* cfilutil.c in Sources */,
+                               72B732F11899B2430060E6D4 /* cfilstat.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
                        target = 690D978012DE6034004323A7 /* mtest */;
                        targetProxy = 690D97BD12DE7166004323A7 /* PBXContainerItemProxy */;
                };
                        target = 690D978012DE6034004323A7 /* mtest */;
                        targetProxy = 690D97BD12DE7166004323A7 /* PBXContainerItemProxy */;
                };
+               7200F3031958A4F10033E22C /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 7200F2F91958A34D0033E22C /* pktmnglr */;
+                       targetProxy = 7200F3021958A4F10033E22C /* PBXContainerItemProxy */;
+               };
+               7200F3051958A4FA0033E22C /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 7200F2F91958A34D0033E22C /* pktmnglr */;
+                       targetProxy = 7200F3041958A4FA0033E22C /* PBXContainerItemProxy */;
+               };
+               7200F3071958A5040033E22C /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 7200F2F91958A34D0033E22C /* pktmnglr */;
+                       targetProxy = 7200F3061958A5040033E22C /* PBXContainerItemProxy */;
+               };
                7216D2670EE8978F00AE70E4 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 7216D2450EE896C000AE70E4 /* netstat */;
                7216D2670EE8978F00AE70E4 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 7216D2450EE896C000AE70E4 /* netstat */;
                        target = 723C7067142BAFEA007C87E9 /* dnctl */;
                        targetProxy = 72179EAD146233390098FB3E /* PBXContainerItemProxy */;
                };
                        target = 723C7067142BAFEA007C87E9 /* dnctl */;
                        targetProxy = 72179EAD146233390098FB3E /* PBXContainerItemProxy */;
                };
-               723C7074142BB003007C87E9 /* PBXTargetDependency */ = {
+               72311F4B194A34EB00EB4788 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        isa = PBXTargetDependency;
-                       target = 723C7067142BAFEA007C87E9 /* dnctl */;
-                       targetProxy = 723C7073142BB003007C87E9 /* PBXContainerItemProxy */;
+                       target = 72311F41194A349000EB4788 /* mptcp_client */;
+                       targetProxy = 72311F4A194A34EB00EB4788 /* PBXContainerItemProxy */;
                };
                };
-               724DAB790EE88EA6008900D0 /* PBXTargetDependency */ = {
+               72311F4D194A34F500EB4788 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        isa = PBXTargetDependency;
-                       target = 724DAB5E0EE88E2A008900D0 /* ipfw */;
-                       targetProxy = 724DAB780EE88EA6008900D0 /* PBXContainerItemProxy */;
+                       target = 72311F41194A349000EB4788 /* mptcp_client */;
+                       targetProxy = 72311F4C194A34F500EB4788 /* PBXContainerItemProxy */;
                };
                };
-               724DAB9A0EE88F5D008900D0 /* PBXTargetDependency */ = {
+               72311F4F194A34FE00EB4788 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        isa = PBXTargetDependency;
-                       target = 724DAB810EE88EFA008900D0 /* ip6fw */;
-                       targetProxy = 724DAB990EE88F5D008900D0 /* PBXContainerItemProxy */;
+                       target = 72311F41194A349000EB4788 /* mptcp_client */;
+                       targetProxy = 72311F4E194A34FE00EB4788 /* PBXContainerItemProxy */;
+               };
+               723C7074142BB003007C87E9 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 723C7067142BAFEA007C87E9 /* dnctl */;
+                       targetProxy = 723C7073142BB003007C87E9 /* PBXContainerItemProxy */;
                };
                724DABC30EE890A6008900D0 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 724DABA10EE88FE3008900D0 /* kdumpd */;
                        targetProxy = 724DABC20EE890A6008900D0 /* PBXContainerItemProxy */;
                };
                };
                724DABC30EE890A6008900D0 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 724DABA10EE88FE3008900D0 /* kdumpd */;
                        targetProxy = 724DABC20EE890A6008900D0 /* PBXContainerItemProxy */;
                };
-               724DABEC0EE891DF008900D0 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = 724DABDA0EE8912D008900D0 /* natd */;
-                       targetProxy = 724DABEB0EE891DF008900D0 /* PBXContainerItemProxy */;
-               };
                724DAC240EE89525008900D0 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 724DAC0C0EE8940D008900D0 /* ndp */;
                724DAC240EE89525008900D0 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 724DAC0C0EE8940D008900D0 /* ndp */;
                        target = 7261212C0EE8710B00AFED1B /* arp */;
                        targetProxy = 72ABD0A31083D818008C721C /* PBXContainerItemProxy */;
                };
                        target = 7261212C0EE8710B00AFED1B /* arp */;
                        targetProxy = 72ABD0A31083D818008C721C /* PBXContainerItemProxy */;
                };
+               72B732E91899B18F0060E6D4 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 72B732D91899B0380060E6D4 /* cfilutil */;
+                       targetProxy = 72B732E81899B18F0060E6D4 /* PBXContainerItemProxy */;
+               };
+               72B732EB1899B19A0060E6D4 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 72B732D91899B0380060E6D4 /* cfilutil */;
+                       targetProxy = 72B732EA1899B19A0060E6D4 /* PBXContainerItemProxy */;
+               };
                72C77D3B1484199C002D2577 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 7261210B0EE8707500AFED1B /* alias */;
                72C77D3B1484199C002D2577 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 7261210B0EE8707500AFED1B /* alias */;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
-                               ARCHS = "$(NATIVE_ARCH_ACTUAL)";
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               COMBINE_HIDPI_IMAGES = YES;
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                03B2DBEB100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBEB100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                03B2DBEF100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBEF100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                03B2DBF0100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBF0100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                03B2DBF3100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBF3100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                03B2DBF4100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBF4100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                03B2DBF7100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                03B2DBF7100BE71D005349BC /* Ignore Me */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                COPY_PHASE_STRIP = NO;
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                COPY_PHASE_STRIP = NO;
                                GCC_DYNAMIC_NO_PIC = NO;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                COPY_PHASE_STRIP = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                GCC_ENABLE_FIX_AND_CONTINUE = NO;
                                COPY_PHASE_STRIP = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                GCC_ENABLE_FIX_AND_CONTINUE = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
                                INSTALL_PATH = /usr/local/bin;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
                                INSTALL_PATH = /usr/local/bin;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                COPY_PHASE_STRIP = NO;
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                                GCC_DYNAMIC_NO_PIC = NO;
                                COPY_PHASE_STRIP = NO;
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                                GCC_DYNAMIC_NO_PIC = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                COPY_PHASE_STRIP = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                                COPY_PHASE_STRIP = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
                                "DEBUG_INFORMATION_FORMAT[sdk=iphoneos*][arch=*]" = dwarf;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
                                GCC_MODEL_TUNING = G5;
                        };
                        name = "Ignore Me";
                };
                        };
                        name = "Ignore Me";
                };
+               7200F2FE1958A34D0033E22C /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_PREPROCESSOR_DEFINITIONS = (
+                                       "DEBUG=1",
+                                       "$(inherited)",
+                               );
+                               GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = YES;
+                               ONLY_ACTIVE_ARCH = YES;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx.internal;
+                       };
+                       name = Debug;
+               };
+               7200F2FF1958A34D0033E22C /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               ENABLE_NS_ASSERTIONS = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = NO;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx.internal;
+                       };
+                       name = Release;
+               };
+               7200F3001958A34D0033E22C /* Ignore Me */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               ENABLE_NS_ASSERTIONS = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = NO;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx.internal;
+                       };
+                       name = "Ignore Me";
+               };
                7216D2480EE896C100AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D2480EE896C100AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D27E0EE8980B00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D27E0EE8980B00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                7216D27F0EE8980B00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D27F0EE8980B00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                7216D29C0EE898BE00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D29C0EE898BE00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                7216D29D0EE898BE00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D29D0EE898BE00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        "TFTP_DIR=\\\"/tftpboot\\\"",
                7216D3160EE89E9F00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D3160EE89E9F00AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                7216D3170EE89E9F00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D3170EE89E9F00AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                7216D35B0EE8A02300AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D35B0EE8A02300AE70E4 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                7216D35C0EE8A02300AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7216D35C0EE8A02300AE70E4 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                        };
                        name = Release;
                };
                        };
                        name = Release;
                };
+               72311F47194A349100EB4788 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_PREPROCESSOR_DEFINITIONS = (
+                                       "DEBUG=1",
+                                       "$(inherited)",
+                               );
+                               GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = YES;
+                               ONLY_ACTIVE_ARCH = YES;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx;
+                       };
+                       name = Debug;
+               };
+               72311F48194A349100EB4788 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
+                               ENABLE_NS_ASSERTIONS = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = NO;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx;
+                       };
+                       name = Release;
+               };
+               72311F49194A349100EB4788 /* Ignore Me */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_MODULES = NO;
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN_UNREACHABLE_CODE = YES;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
+                               ENABLE_NS_ASSERTIONS = NO;
+                               ENABLE_STRICT_OBJC_MSGSEND = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               MACOSX_DEPLOYMENT_TARGET = 10.10;
+                               METAL_ENABLE_DEBUG_INFO = NO;
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                               SDKROOT = macosx;
+                       };
+                       name = "Ignore Me";
+               };
                723C7070142BAFEA007C87E9 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                723C7070142BAFEA007C87E9 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
-                               INSTALL_PATH = /usr/local/bin;
+                               INSTALL_PATH = /usr/sbin;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Debug;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Debug;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
-                               INSTALL_PATH = /usr/local/bin;
+                               INSTALL_PATH = /usr/sbin;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Release;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Release;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
-                               INSTALL_PATH = /usr/local/bin;
+                               INSTALL_PATH = /usr/sbin;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = "Ignore Me";
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = "Ignore Me";
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
-                               ARCHS = "$(NATIVE_ARCH_ACTUAL)";
                                COPY_PHASE_STRIP = NO;
                                DEAD_CODE_STRIPPING = YES;
                                GCC_DYNAMIC_NO_PIC = NO;
                                COPY_PHASE_STRIP = NO;
                                DEAD_CODE_STRIPPING = YES;
                                GCC_DYNAMIC_NO_PIC = NO;
                                );
                                GCC_TREAT_WARNINGS_AS_ERRORS = YES;
                                GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
                                );
                                GCC_TREAT_WARNINGS_AS_ERRORS = YES;
                                GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
+                               ONLY_ACTIVE_ARCH = YES;
                                PREBINDING = NO;
                                SDKROOT = "";
                                WARNING_CFLAGS = "-Wall";
                                PREBINDING = NO;
                                SDKROOT = "";
                                WARNING_CFLAGS = "-Wall";
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
-                               ARCHS = "$(NATIVE_ARCH_ACTUAL)";
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
                                        "$(inherited)",
                                        "TARGET_OS_EMBEDDED=1",
                                );
                                        "$(inherited)",
                                        "TARGET_OS_EMBEDDED=1",
                                );
-                               GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+                               GCC_TREAT_WARNINGS_AS_ERRORS = NO;
                                GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
                                PREBINDING = NO;
                                SDKROOT = "";
                                GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
                                PREBINDING = NO;
                                SDKROOT = "";
                724DABA40EE88FE3008900D0 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                724DABA40EE88FE3008900D0 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                724DABA50EE88FE3008900D0 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                724DABA50EE88FE3008900D0 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = 0555;
                                INSTALL_OWNER = root;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               COMBINE_HIDPI_IMAGES = YES;
                                COPY_PHASE_STRIP = NO;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                                COPY_PHASE_STRIP = NO;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALWAYS_SEARCH_USER_PATHS = NO;
+                               COMBINE_HIDPI_IMAGES = YES;
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                                COPY_PHASE_STRIP = YES;
                                DEAD_CODE_STRIPPING = YES;
                                DYLIB_CURRENT_VERSION = 1;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                ALTERNATE_MODE = 04555;
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        HAVE_SOCKADDR_SA_LEN,
                7294F12C0EE8BD290052EC88 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7294F12C0EE8BD290052EC88 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                7294F12D0EE8BD290052EC88 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                7294F12D0EE8BD290052EC88 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/network-client-server-entitlements.plist";
+                               CODE_SIGN_IDENTITY = "-";
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        "$(inherited)",
                                        INET6,
                        };
                        name = "Ignore Me";
                };
                        };
                        name = "Ignore Me";
                };
+               72B732E01899B0380060E6D4 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+                               GCC_PREPROCESSOR_DEFINITIONS = (
+                                       "DEBUG=1",
+                                       "$(inherited)",
+                               );
+                               GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               INSTALL_GROUP = wheel;
+                               INSTALL_MODE_FLAG = 0555;
+                               INSTALL_OWNER = root;
+                               MACOSX_DEPLOYMENT_TARGET = "";
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                       };
+                       name = Debug;
+               };
+               72B732E11899B0380060E6D4 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               ENABLE_NS_ASSERTIONS = NO;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               INSTALL_GROUP = wheel;
+                               INSTALL_MODE_FLAG = 0555;
+                               INSTALL_OWNER = root;
+                               MACOSX_DEPLOYMENT_TARGET = "";
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                       };
+                       name = Release;
+               };
+               72B732E21899B0380060E6D4 /* Ignore Me */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+                               CLANG_CXX_LIBRARY = "libc++";
+                               CLANG_ENABLE_OBJC_ARC = YES;
+                               CLANG_WARN_BOOL_CONVERSION = YES;
+                               CLANG_WARN_CONSTANT_CONVERSION = YES;
+                               CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+                               CLANG_WARN_EMPTY_BODY = YES;
+                               CLANG_WARN_ENUM_CONVERSION = YES;
+                               CLANG_WARN_INT_CONVERSION = YES;
+                               CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+                               CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+                               ENABLE_NS_ASSERTIONS = NO;
+                               GCC_C_LANGUAGE_STANDARD = gnu99;
+                               GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+                               GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+                               GCC_WARN_UNDECLARED_SELECTOR = YES;
+                               GCC_WARN_UNINITIALIZED_AUTOS = YES;
+                               GCC_WARN_UNUSED_FUNCTION = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               HEADER_SEARCH_PATHS = /System/Library/Frameworks/System.framework/PrivateHeaders;
+                               INSTALL_GROUP = wheel;
+                               INSTALL_MODE_FLAG = 0555;
+                               INSTALL_OWNER = root;
+                               MACOSX_DEPLOYMENT_TARGET = "";
+                               PRODUCT_NAME = "$(TARGET_NAME)";
+                       };
+                       name = "Ignore Me";
+               };
                72C77D681484199C002D2577 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72C77D681484199C002D2577 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               7200F3011958A34E0033E22C /* Build configuration list for PBXNativeTarget "pktmnglr" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7200F2FE1958A34D0033E22C /* Debug */,
+                               7200F2FF1958A34D0033E22C /* Release */,
+                               7200F3001958A34D0033E22C /* Ignore Me */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+               };
                7216D24B0EE896EC00AE70E4 /* Build configuration list for PBXNativeTarget "netstat" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                7216D24B0EE896EC00AE70E4 /* Build configuration list for PBXNativeTarget "netstat" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               72311F46194A349100EB4788 /* Build configuration list for PBXNativeTarget "mptcp_client" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               72311F47194A349100EB4788 /* Debug */,
+                               72311F48194A349100EB4788 /* Release */,
+                               72311F49194A349100EB4788 /* Ignore Me */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                723C706F142BAFEA007C87E9 /* Build configuration list for PBXNativeTarget "dnctl" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                723C706F142BAFEA007C87E9 /* Build configuration list for PBXNativeTarget "dnctl" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               72B732E31899B0380060E6D4 /* Build configuration list for PBXNativeTarget "cfilutil" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               72B732E01899B0380060E6D4 /* Debug */,
+                               72B732E11899B0380060E6D4 /* Release */,
+                               72B732E21899B0380060E6D4 /* Ignore Me */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                72C77D671484199C002D2577 /* Build configuration list for PBXAggregateTarget "network_cmds_libs" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
                72C77D671484199C002D2577 /* Build configuration list for PBXAggregateTarget "network_cmds_libs" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
index 9bf8c1b0fa0b03802345e850ffb08e94c10f7931..6c60deeed4aa417bb426c019a8f3c00e76965f6d 100644 (file)
@@ -70,6 +70,7 @@ packets to network hosts
 .Op Fl g Ar sweepminsize
 .Op Fl h Ar sweepincrsize
 .Op Fl i Ar wait
 .Op Fl g Ar sweepminsize
 .Op Fl h Ar sweepincrsize
 .Op Fl i Ar wait
+.Op Fl k Ar trafficclass
 .Op Fl l Ar preload
 .Op Fl M Cm mask | time
 .Op Fl m Ar ttl
 .Op Fl l Ar preload
 .Op Fl M Cm mask | time
 .Op Fl m Ar ttl
@@ -87,6 +88,7 @@ packets to network hosts
 .Op Fl c Ar count
 .Op Fl I Ar iface
 .Op Fl i Ar wait
 .Op Fl c Ar count
 .Op Fl I Ar iface
 .Op Fl i Ar wait
+.Op Fl k Ar trafficclass
 .Op Fl l Ar preload
 .Op Fl M Cm mask | time
 .Op Fl m Ar ttl
 .Op Fl l Ar preload
 .Op Fl M Cm mask | time
 .Op Fl m Ar ttl
@@ -210,6 +212,13 @@ values less than 0.1 second.
 This option is incompatible with the
 .Fl f
 option.
 This option is incompatible with the
 .Fl f
 option.
+.It Fl k Ar trafficlass
+Specifies the traffic class to use for sending ICMP packets.
+The supported traffic classes are
+BK_SYS, BK, BE, RD, OAM, AV, RV, VI, VO and CTL.
+By default 
+.Nm
+uses the control traffic class (CTL).
 .It Fl L
 Suppress loopback of multicast packets.
 This flag only applies if the ping destination is a multicast address.
 .It Fl L
 Suppress loopback of multicast packets.
 This flag only applies if the ping destination is a multicast address.
index 4480408c50179fb198796a2da7d4648e0d49c7bc..7701b7bd3195061f832cba8627d4d9c9619af47c 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#if 0
+#include <sys/cdefs.h>
+
 #ifndef lint
 #ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
 "@(#) Copyright (c) 1989, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 "@(#) Copyright (c) 1989, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
-#ifndef lint
-static char sccsid[] = "@(#)ping.c     8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-
 /*
  *                     P I N G . C
  *
 /*
  *                     P I N G . C
  *
@@ -248,6 +243,7 @@ static void pr_retip(struct ip *);
 static void status(int);
 static void stopit(int);
 static void tvsub(struct timeval *, const struct timeval *);
 static void status(int);
 static void stopit(int);
 static void tvsub(struct timeval *, const struct timeval *);
+static uint32_t str2svc(const char *);
 static void usage(void) __dead2;
 
 int
 static void usage(void) __dead2;
 
 int
@@ -425,7 +421,10 @@ main(int argc, char *const *argv)
                        break;
                case 'k':
                        how_traffic_class++;
                        break;
                case 'k':
                        how_traffic_class++;
-                       traffic_class = atoi(optarg);
+                       traffic_class = str2svc(optarg);
+                       if (traffic_class == UINT32_MAX)
+                               errx(EX_USAGE, "bad traffic class: `%s'",
+                                    optarg);
                        break;
                case 'L':
                        options |= F_NOLOOP;
                        break;
                case 'L':
                        options |= F_NOLOOP;
@@ -1849,6 +1848,42 @@ fill(char *bp, char *patp)
        }
 }
 
        }
 }
 
+uint32_t
+str2svc(const char *str)
+{
+       uint32_t svc;
+       char *endptr;
+       
+       if (str == NULL || *str == '\0')
+               svc = UINT32_MAX;
+       else if (strcasecmp(str, "BK_SYS") == 0)
+               return SO_TC_BK_SYS;
+       else if (strcasecmp(str, "BK") == 0)
+               return SO_TC_BK;
+       else if (strcasecmp(str, "BE") == 0)
+               return SO_TC_BE;
+       else if (strcasecmp(str, "RD") == 0)
+               return SO_TC_RD;
+       else if (strcasecmp(str, "OAM") == 0)
+               return SO_TC_OAM;
+       else if (strcasecmp(str, "AV") == 0)
+               return SO_TC_AV;
+       else if (strcasecmp(str, "RV") == 0)
+               return SO_TC_RV;
+       else if (strcasecmp(str, "VI") == 0)
+               return SO_TC_VI;
+       else if (strcasecmp(str, "VO") == 0)
+               return SO_TC_VO;
+       else if (strcasecmp(str, "CTL") == 0)
+               return SO_TC_CTL;
+       else {
+               svc = strtoul(str, &endptr, 0);
+               if (*endptr != '\0')
+                       svc = UINT32_MAX;
+       }
+       return (svc);
+}
+
 #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
 #define        SECOPT          " [-P policy]"
 #else
 #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
 #define        SECOPT          " [-P policy]"
 #else
@@ -1858,13 +1893,14 @@ static void
 usage(void)
 {
 
 usage(void)
 {
 
-       (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: ping [-AaDdfnoQqRrv] [-b boundif] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
-"            [-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m ttl]",
-"           " SECOPT " [-p pattern] [-S src_addr] [-s packetsize] [-t timeout]",
-"            [-W waittime] [-z tos] host",
-"       ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]",
-"            [-M mask | time] [-m ttl]" SECOPT " [-p pattern] [-S src_addr]",
+       (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+"usage: ping [-AaDdfnoQqRrv] [-b boundif] [-c count] [-G sweepmaxsize]",
+"            [-g sweepminsize] [-h sweepincrsize] [-i wait] [−k trafficclass]",
+"            [-l preload] [-M mask | time] [-m ttl]" SECOPT " [-p pattern]",
+"            [-S src_addr] [-s packetsize] [-t timeout][-W waittime] [-z tos]",
+"            host",
+"       ping [-AaDdfLnoQqRrv] [-b boundif] [-c count] [-I iface] [-i wait]",
+"            [−k trafficclass] [-l preload] [-M mask | time] [-m ttl]" SECOPT " [-p pattern] [-S src_addr]",
 "            [-s packetsize] [-T ttl] [-t timeout] [-W waittime]",
 "            [-z tos] mcast-group");
        exit(EX_USAGE);
 "            [-s packetsize] [-T ttl] [-t timeout] [-W waittime]",
 "            [-z tos] mcast-group");
        exit(EX_USAGE);
index f4c18bb489abac6d43b8ae60f9b47f51fc6ee3d7..716668cf6529ed705027247b6df784a4a1891269 100644 (file)
@@ -91,6 +91,9 @@ packets to network hosts
 .Op Fl i Ar wait
 .Ek
 .Bk -words
 .Op Fl i Ar wait
 .Ek
 .Bk -words
+.Op Fl k Ar trafficclass
+.Ek
+.Bk -words
 .Op Fl l Ar preload
 .Ek
 .Bk -words
 .Op Fl l Ar preload
 .Ek
 .Bk -words
@@ -228,6 +231,13 @@ values less than 0.1 second.
 This option is incompatible with the
 .Fl f
 option.
 This option is incompatible with the
 .Fl f
 option.
+.It Fl k Ar trafficlass
+Specifies the traffic class to use for sending ICMPv6 packets.
+The supported traffic classes are
+BK_SYS, BK, BE, RD, OAM, AV, RV, VI, VO and CTL.
+By default 
+.Nm
+uses the control traffic class (CTL).
 .It Fl l Ar preload
 If
 .Ar preload
 .It Fl l Ar preload
 If
 .Ar preload
index 419552b44986187b0c2d8281aba5e2b53ce31d8a..90da21a9f726341617dccd6f5e8315d2304124bf 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+
 #ifndef lint
 #ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
 "@(#) Copyright (c) 1989, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 "@(#) Copyright (c) 1989, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
@@ -148,6 +150,7 @@ static const char copyright[] =
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #endif
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #endif
+#include <sysexits.h>
 
 #ifdef IPSEC
 #include <netinet6/ah.h>
 
 #ifdef IPSEC
 #include <netinet6/ah.h>
@@ -319,6 +322,7 @@ void         summary(void);
 void    tvsub(struct timeval *, struct timeval *);
 int     setpolicy(int, char *);
 char   *nigroup(char *);
 void    tvsub(struct timeval *, struct timeval *);
 int     setpolicy(int, char *);
 char   *nigroup(char *);
+static uint32_t str2svc(const char *);
 void    usage(void);
 
 int
 void    usage(void);
 
 int
@@ -507,7 +511,10 @@ main(int argc, char *argv[])
                        break;
                case 'k':
                        how_so_traffic_class++;
                        break;
                case 'k':
                        how_so_traffic_class++;
-                       so_traffic_class = atoi(optarg);
+                       so_traffic_class = str2svc(optarg);
+                       if (so_traffic_class == UINT32_MAX)
+                               errx(EX_USAGE, "bad traffic class: `%s'",
+                                    optarg);
                        break;
 
                case 'l':
                        break;
 
                case 'l':
@@ -2988,6 +2995,42 @@ nigroup(char *name)
        return strdup(hbuf);
 }
 
        return strdup(hbuf);
 }
 
+uint32_t
+str2svc(const char *str)
+{
+       uint32_t svc;
+       char *endptr;
+       
+       if (str == NULL || *str == '\0')
+               svc = UINT32_MAX;
+       else if (strcasecmp(str, "BK_SYS") == 0)
+               return SO_TC_BK_SYS;
+       else if (strcasecmp(str, "BK") == 0)
+               return SO_TC_BK;
+       else if (strcasecmp(str, "BE") == 0)
+               return SO_TC_BE;
+       else if (strcasecmp(str, "RD") == 0)
+               return SO_TC_RD;
+       else if (strcasecmp(str, "OAM") == 0)
+               return SO_TC_OAM;
+       else if (strcasecmp(str, "AV") == 0)
+               return SO_TC_AV;
+       else if (strcasecmp(str, "RV") == 0)
+               return SO_TC_RV;
+       else if (strcasecmp(str, "VI") == 0)
+               return SO_TC_VI;
+       else if (strcasecmp(str, "VO") == 0)
+               return SO_TC_VO;
+       else if (strcasecmp(str, "CTL") == 0)
+               return SO_TC_CTL;
+       else {
+               svc = strtoul(str, &endptr, 0);
+               if (*endptr != '\0')
+                       svc = UINT32_MAX;
+       }
+       return (svc);
+}
+
 void
 usage(void)
 {
 void
 usage(void)
 {
diff --git a/pktmnglr/packet_mangler.c b/pktmnglr/packet_mangler.c
new file mode 100644 (file)
index 0000000..fab5ce9
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2014 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+//
+//  Created by Prabhakar Lakhera on 06/23/14.
+//
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <sys/errno.h>
+#include <sys/sys_domain.h>
+#include <sys/ioctl.h>
+#include <sys/kern_control.h>
+#include <sys/queue.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <sysexits.h>
+#include <net/packet_mangler.h>
+
+
+#define BUF_MAX 1000
+int doit();
+
+Pkt_Mnglr_Flow dir = INOUT;
+struct addrinfo * p_localaddr = NULL;
+struct addrinfo * p_remoteaddr = NULL;
+struct sockaddr_storage l_saddr = {0};
+struct sockaddr_storage r_saddr = {0};
+
+int sf = -1;
+uint32_t duration  = 0;
+uint32_t protocol = 0;
+uint32_t proto_act_mask = 0;
+uint32_t ip_act_mask = 0;
+uint16_t local_port = 0;
+uint16_t remote_port = 0;
+uint8_t activate = 1;
+
+static const char *
+basename(const char * str)
+{
+    const char *last_slash = strrchr(str, '/');
+    
+    if (last_slash == NULL)
+        return (str);
+    else
+        return (last_slash + 1);
+}
+
+struct option_desc {
+    const char *option;
+    const char *description;
+    int required;
+};
+
+struct option_desc option_desc_list[] = {
+    { "-h ", "Help", 0 },
+    { "-f flow", "flow direction to apply mangler on. Values can be: in/out/inout. default is inout", 0 },
+    { "-l IP address ", "Local IP we are interested in ", 0 },
+    { "-r IP address ", "Remote IP we are interested in", 0 },
+    { "-m IP action mask ", "IP action mask", 0 },
+    { "-t time", "Run duration for which packet mangler will run. A value of 0 means forever (till program is killed).", 0 },
+    { "-p IP Protocol ", "IP protocol i.e. one of tcp, udp, icmp, icmpv6", 0 },
+    { "-L Local port ", "Local port", 0 },
+    { "-R Remote port ", "Remote port", 0 },
+    { "-M Protocol action mask ", "Protocol action mask", 0 },
+    { NULL, NULL, 0 }  /* Mark end of list */
+};
+
+
+static void
+usage(const char *cmd)
+{
+    struct option_desc *option_desc;
+    char * usage_str = (char *)malloc(BUF_MAX);
+    size_t usage_len;
+    
+    if (usage_str == NULL)
+        err(1, "%s: malloc(%d)", __func__, BUF_MAX);
+    
+    usage_len = snprintf(usage_str, BUF_MAX, "# usage: %s ", basename(cmd));
+    
+    for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+        int len;
+        
+        if (option_desc->required)
+            len = snprintf(usage_str + usage_len, BUF_MAX - usage_len, "%s ", option_desc->option);
+        else
+            len = snprintf(usage_str + usage_len, BUF_MAX - usage_len, "[%s] ", option_desc->option);
+        if (len < 0)
+            err(1, "%s: snprintf(", __func__);
+        
+        usage_len += len;
+        if (usage_len > BUF_MAX)
+            break;
+    }
+    printf("%s\n", usage_str);
+    printf("options:\n");
+    
+    for (option_desc = option_desc_list; option_desc->option != NULL; option_desc++) {
+        printf(" %-20s # %s\n", option_desc->option, option_desc->description);
+    }
+    
+}
+
+int
+main(int argc, char * const argv[]) {
+    int ch;
+    int error;
+    
+    if (argc == 1) {
+        usage(argv[0]);
+        exit(0);
+    }
+    
+    while ((ch = getopt(argc, argv, "hf:l:r:t:p:m:M:L:R")) != -1) {
+        switch (ch) {
+            case 'h':
+                usage(argv[0]);
+                exit(0);
+                break;
+            case 'f': {
+                if (strcasecmp(optarg, "in") == 0) {
+                    dir = IN;
+                } else if (strcasecmp(optarg, "out") == 0) {
+                    dir = OUT;
+                } else if (strcasecmp(optarg, "inout") == 0) {
+                    dir = INOUT;
+                } else {
+                    usage(argv[0]);
+                    errx(1, "syntax error");
+                }
+            }
+                break;
+            case 'l':
+                if ((error = getaddrinfo(optarg, NULL, NULL, &p_localaddr)))
+                    errx(1, "getaddrinfo returned error: %s", gai_strerror(error));
+                
+                break;
+            case 'r':
+                if ((error = getaddrinfo(optarg, NULL, NULL, &p_remoteaddr)))
+                    errx(1, "getaddrinfo returned error: %s", gai_strerror(error));
+                
+                break;
+            case 'm':
+                ip_act_mask = (uint32_t)atoi(optarg);
+                break;
+            case 't':
+                duration = (uint32_t)atoi(optarg);
+                break;
+            case 'p':
+                /* Only support tcp for now */
+                if (strcasecmp(optarg, "tcp") == 0) {
+                    protocol = IPPROTO_TCP;
+                } else if (strcasecmp(optarg, "udp") == 0) {
+                    protocol = IPPROTO_UDP;
+                    errx(1, "Protocol not supported.");
+                } else if (strcasecmp(optarg, "icmp") == 0) {
+                    protocol = IPPROTO_ICMP;
+                    errx(1, "Protocol not supported.");
+                } else if (strcasecmp(optarg, "icmpv6") == 0) {
+                    protocol = IPPROTO_ICMPV6;
+                    errx(1, "Protocol not supported.");
+                } else {
+                    errx(1, "Protocol not supported.");
+                }
+                break;
+                
+            case 'L':
+                local_port = (uint16_t)atoi(optarg);
+                break;
+            case 'R':
+                remote_port = (uint16_t)atoi(optarg);
+                break;
+            case 'M':
+                proto_act_mask = (uint32_t)atoi(optarg);
+                break;
+                
+            default:
+                warnx("# syntax error, unknow option '%d'", ch);
+                usage(argv[0]);
+                exit(0);
+        }
+    }
+    
+    if (p_localaddr && p_remoteaddr) {
+        if (p_localaddr->ai_family!=p_remoteaddr->ai_family) {
+            errx(1, "The address families for local and remote address"
+                 " when both present, must be equal");
+        }
+    }
+    
+    
+    doit();
+    
+    return (0);
+}
+
+
+int
+doit()
+{
+    struct sockaddr_ctl addr;
+    
+    sf = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
+    if (sf == -1) {
+        err(1, "socket()");
+    }
+    
+    /* Connect the socket */
+    bzero(&addr, sizeof(addr));
+    addr.sc_len = sizeof(addr);
+    addr.sc_family = AF_SYSTEM;
+    addr.ss_sysaddr = AF_SYS_CONTROL;
+    
+    {
+        struct ctl_info info;
+        memset(&info, 0, sizeof(info));
+        strncpy(info.ctl_name, PACKET_MANGLER_CONTROL_NAME, sizeof(info.ctl_name));
+        if (ioctl(sf, CTLIOCGINFO, &info)) {
+            perror("Could not get ID for kernel control.\n");
+            exit(-1);
+        }
+        addr.sc_id = info.ctl_id;
+        addr.sc_unit = 1;
+    }
+    
+    if (connect(sf, (struct sockaddr *)&addr, sizeof(struct sockaddr_ctl)) == -1) {
+        err(1, "connect()");
+    }
+    
+    if (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_DIRECTION,
+                   &dir, sizeof(uint32_t)) == -1) {
+        err(1, "setsockopt could not set direction.");
+    }
+    
+    /* Set the IP addresses for the flow */
+    if (p_localaddr) {
+        l_saddr = *((struct sockaddr_storage *)(p_localaddr->ai_addr));
+        
+        if (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_LOCAL_IP,
+                       &l_saddr, sizeof(struct sockaddr_storage)) == -1) {
+            err(1, "setsockopt could not set local address.");
+        }
+        freeaddrinfo(p_localaddr);
+        p_localaddr = NULL;
+    }
+    
+    if (p_remoteaddr) {
+        r_saddr = *((struct sockaddr_storage *)(p_remoteaddr->ai_addr));
+        
+        if (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_REMOTE_IP,
+                       &r_saddr, sizeof(struct sockaddr_storage)) == -1) {
+            err(1, "setsockopt could not set remote address.");
+        }
+        freeaddrinfo(p_remoteaddr);
+        p_remoteaddr = NULL;
+    }
+    
+    /* Set ports for the flow */
+    if (local_port && (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_LOCAL_PORT,
+                                  &local_port, sizeof(uint16_t)) == -1)) {
+        err(1, "setsockopt could not set local port.");
+        
+    }
+    
+    if (remote_port && (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_REMOTE_PORT,
+                                   &remote_port, sizeof(uint16_t)) == -1)) {
+        err(1, "setsockopt could not set remote port.");
+        
+    }
+    
+    if (protocol && setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_PROTOCOL,
+                               &protocol, sizeof(uint32_t)) == -1) {
+        err(1, "setsockopt could not set protocol.");
+    }
+    
+    if (proto_act_mask &&
+        (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_PROTO_ACT_MASK,
+                    &proto_act_mask, sizeof(uint32_t))==-1)) {
+        err(1, "setsockopt could not set protocol action mask.");
+    }
+    
+    if (setsockopt(sf, SYSPROTO_CONTROL, PKT_MNGLR_OPT_ACTIVATE,
+                   &activate, sizeof(uint8_t))== -1) {
+        err(1, "setsockopt could not activate packet mangler.");
+    }
+    
+    if (!duration) {
+        pause();
+    } else {
+        sleep(duration);
+    }
+    
+    close(sf);
+    return 0;
+}
index fcea9bcb3a573b3c42121da13230a351d1da69a8..6c42b6c1b1fe71743ee94de0467b5a6703b5c01f 100644 (file)
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
+
 #include <sys/cdefs.h>
 #include <sys/cdefs.h>
+
 #ifndef lint
 __unused char    copyright[] =
 "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
  All rights reserved.\n";
 #endif                         /* not lint */
 
 #ifndef lint
 __unused char    copyright[] =
 "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
  All rights reserved.\n";
 #endif                         /* not lint */
 
-#ifndef lint
-__unused static char rcsid[] =
-"@(#) $Id: rarpd.c,v 1.3 2006/04/05 03:13:14 lindak Exp $";
-#endif
-
-
 /*
  * rarpd - Reverse ARP Daemon
  *
 /*
  * rarpd - Reverse ARP Daemon
  *
index 8a60ed878f71bc297364f15de275c6b1876e6664..c2508bdef7e2140610dc5eea9437b2a32af1a103 100644 (file)
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
+
 #ifndef lint
 __unused static const char copyright[] =
 "@(#) Copyright (c) 1983, 1989, 1991, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
 __unused static const char copyright[] =
 "@(#) Copyright (c) 1983, 1989, 1991, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)route.c    8.3 (Berkeley) 3/19/94";
-#endif
-__unused static const char rcsid[] =
-       "$Id: route.c,v 1.4 2006/02/07 06:22:29 lindak Exp $";
-#endif /* not lint */
-
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
index 88ca8bfe2c72119f3d51b8ab5ba1564bdb06bd8e..01dcef1fd1bbc392fb7bc448517e37efb85cfe35 100644 (file)
 
 /* XXX Yes this is WAY too complicated */
 
 
 /* XXX Yes this is WAY too complicated */
 
-#ifndef lint
-static const char rcsid[] =
-    "@(#) $Id: findsaddr-socket.c,v 1.3 2005/02/12 00:04:09 lindak Exp $ (LBL)";
-#endif
-
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
index ed45494f62b7d54a7d4e19ec2eb2b90c5ee8681b..2d19c78b613d51340893fbcc3be7a4039b1bb2f6 100644 (file)
  * SUCH DAMAGE.
  */
 
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-    "@(#) $Id: ifaddrlist.c,v 1.3 2006/02/07 06:22:57 lindak Exp $ (LBL)";
-#endif
-
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
index d556fb4a43102cedd6bbee106aaa3e017ba8d14c..38e6cef3d647b97e4c6f42eb2043f742ff2d0663 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#include <sys/cdefs.h>
+
 #ifndef lint
 #ifndef lint
-static const char copyright[] =
+__unused static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
     "@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
-#if 0
-static const char rcsid[] =
-    "@(#)$Id: traceroute.c,v 1.4 2006/02/07 06:22:57 lindak Exp $ (LBL)";
-#endif
-static const char rcsid[] =
-    "$FreeBSD: src/contrib/traceroute/traceroute.c,v 1.35 2008/02/20 23:29:52 rpaulo Exp $";
 #endif
 
 /*
 #endif
 
 /*
index 373b7c59eba31750849575b0ef68b3b6336f5f96..1de78091e399f1b7046ffe03f31a397a7d1171ae 100644 (file)
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
+
 #ifndef lint
 __unused static char copyright[] =
 "@(#) Copyright (c) 1990, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
 __unused static char copyright[] =
 "@(#) Copyright (c) 1990, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)traceroute.c       8.1 (Berkeley) 6/6/93";
-#endif
-__unused static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/traceroute6/traceroute6.c,v 1.22 2008/02/10 21:06:38 dwmalone Exp $";
-#endif /* not lint */
-
 /*
  * traceroute host  - trace the route ip packets follow going to "host".
  *
 /*
  * traceroute host  - trace the route ip packets follow going to "host".
  *