/*
- * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005-2012 Apple Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (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.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * @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 OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
+ * 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/types.h>
#include <sys/unpcb.h>
#include <sys/sys_domain.h>
#include <sys/kern_event.h>
+#include <mach/vm_param.h>
#include <net/ndrv_var.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp_var.h>
sbi->sbi_mbmax = sb->sb_mbmax;
sbi->sbi_lowat = sb->sb_lowat;
sbi->sbi_flags = sb->sb_flags;
- sbi->sbi_timeo = (u_long)(sb->sb_timeo.tv_sec * hz) + sb->sb_timeo.tv_usec / tick;
+ sbi->sbi_timeo = (u_int32_t)(sb->sb_timeo.tv_sec * hz) + sb->sb_timeo.tv_usec / tick;
if (sbi->sbi_timeo == 0 && sb->sb_timeo.tv_usec != 0)
sbi->sbi_timeo = 1;
}
static void
fill_common_sockinfo(struct socket *so, struct socket_info *si)
{
- si->soi_so = (u_int64_t)((uintptr_t)so);
+ si->soi_so = (u_int64_t)VM_KERNEL_ADDRPERM(so);
si->soi_type = so->so_type;
- si->soi_options = so->so_options;
+ si->soi_options = (short)(so->so_options & 0xffff);
si->soi_linger = so->so_linger;
si->soi_state = so->so_state;
- si->soi_pcb = (u_int64_t)((uintptr_t)so->so_pcb);
+ si->soi_pcb = (u_int64_t)VM_KERNEL_ADDRPERM(so->so_pcb);
if (so->so_proto) {
si->soi_protocol = so->so_proto->pr_protocol;
if (so->so_proto->pr_domain)
insi->insi_v4.in4_tos = inp->inp_depend4.inp4_ip_tos;
insi->insi_v6.in6_hlim = inp->inp_depend6.inp6_hlim;
insi->insi_v6.in6_cksum = inp->inp_depend6.inp6_cksum;
- insi->insi_v6.in6_ifindex = inp->inp6_ifindex;
+ insi->insi_v6.in6_ifindex = inp->inp_depend6.inp6_ifindex;
insi->insi_v6.in6_hops = inp->inp_depend6.inp6_hops;
if (type == SOCK_STREAM && (protocol == 0 || protocol == IPPROTO_TCP) && inp->inp_ppcb != 0) {
tcpsi->tcpsi_timer[TCPT_2MSL] = tp->t_timer[TCPT_2MSL];
tcpsi->tcpsi_mss = tp->t_maxseg;
tcpsi->tcpsi_flags = tp->t_flags;
- tcpsi->tcpsi_tp = (u_int64_t)((uintptr_t)tp);
+ tcpsi->tcpsi_tp =
+ (u_int64_t)VM_KERNEL_ADDRPERM(tp);
}
break;
}
si->soi_kind = SOCKINFO_UN;
- unsi->unsi_conn_pcb = (uint64_t)((uintptr_t)unp->unp_conn);
+ unsi->unsi_conn_pcb =
+ (uint64_t)VM_KERNEL_ADDRPERM(unp->unp_conn);
if (unp->unp_conn)
- unsi->unsi_conn_so = (uint64_t)((uintptr_t)unp->unp_conn->unp_socket);
-
+ unsi->unsi_conn_so = (uint64_t)
+ VM_KERNEL_ADDRPERM(unp->unp_conn->unp_socket);
if (unp->unp_addr) {
size_t addrlen = unp->unp_addr->sun_len;
ndrvsi->ndrvsi_if_family = ifp->if_family;
ndrvsi->ndrvsi_if_unit = ifp->if_unit;
- strncpy(ndrvsi->ndrvsi_if_name, ifp->if_name, IFNAMSIZ);
+ strlcpy(ndrvsi->ndrvsi_if_name, ifp->if_name, IFNAMSIZ);
}
break;
kcsi->kcsi_recvbufsize = kctl->recvbufsize;
kcsi->kcsi_sendbufsize = kctl->sendbufsize;
kcsi->kcsi_unit = kcb->unit;
- strncpy(kcsi->kcsi_name, kctl->name, MAX_KCTL_NAME);
+ strlcpy(kcsi->kcsi_name, kctl->name, MAX_KCTL_NAME);
}
break;