*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * 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. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
+ * Reserved. 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 1.0 (the 'License'). You may not use this file
+ * except in compliance with the License. Please obtain a copy of the
+ * License at http://www.apple.com/publicsource 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.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License."
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/param.h>
-#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
+#include <sys/sysctl.h>
#include <stdio.h>
#include "netstat.h"
* Print mbuf statistics.
*/
void
-mbpr(mbaddr)
- u_long mbaddr;
+mbpr(void)
{
- register int totmem, totfree, totmbufs;
- register int i;
- register struct mbtypes *mp;
+ int totmem, totfree, totmbufs;
+ int i;
+ struct mbtypes *mp;
+ size_t len;
if (nmbtypes != 256) {
fprintf(stderr,
"netstat: unexpected change to mbstat; check source\n");
return;
}
- if (mbaddr == 0) {
- fprintf(stderr, "netstat: mbstat: symbol not in namelist\n");
- return;
- }
- if (kread(mbaddr, (char *)&mbstat, sizeof (mbstat)))
+ len = sizeof(mbstat);
+ if (sysctlbyname("kern.ipc.mbstat", &mbstat, &len, 0, 0) == -1)
return;
totmbufs = 0;
printf("%u/%u mbuf clusters in use\n",
(unsigned int)(mbstat.m_clusters - mbstat.m_clfree),
(unsigned int)mbstat.m_clusters);
- totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES;
- totfree = mbstat.m_clfree * MCLBYTES;
+ printf("%u/%u mbuf 4KB clusters in use\n",
+ (unsigned int)(mbstat.m_bigclusters - mbstat.m_bigclfree),
+ (unsigned int)mbstat.m_bigclusters);
+ totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES + mbstat.m_bigclusters * mbstat.m_bigmclbytes;
+ totfree = mbstat.m_clfree * MCLBYTES + mbstat.m_bigclfree * mbstat.m_bigmclbytes;
printf("%u Kbytes allocated to network (%d%% in use)\n",
totmem / 1024, (totmem - totfree) * 100 / totmem);
printf("%u requests for memory denied\n",