/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
+ * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * @APPLE_LICENSE_OSREFERENCE_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. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
+ * 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
+ *
+ * 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_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
*/
/*
* Copyright (c) 1995 Apple Computer, Inc.
#include <sys/mbuf.h>
#include <sys/ioctl.h>
#include <sys/malloc.h>
+#include <kern/locks.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
void asp_ack_reply();
void asp_nak_reply();
void asp_clock();
-void asp_clock_funnel(void *);
+void asp_clock_locked(void *);
int asp_open();
int asp_close();
int asp_wput();
StaticProc void asp_untimout();
StaticProc void asp_hangup();
StaticProc void asp_send_tickle();
-StaticProc void asp_send_tickle_funnel(void *);
+StaticProc void asp_send_tickle_locked(void *);
StaticProc void asp_accept();
StaticProc int asp_send_req();
extern at_ifaddr_t *ifID_home;
extern int atp_pidM[];
extern gref_t *atp_inputQ[];
+extern lck_mtx_t *atalk_mutex;
gbuf_t *scb_resource_m = 0;
unsigned char asp_inpC[256];
asp_scb_t *asp_scbQ[256];
*/
scb->tmo_cnt = 0;
asp_untimout(asp_hangup, scb);
- untimeout(asp_send_tickle_funnel, (void *)scb); /* added for 2225395 */
+ untimeout(asp_send_tickle_locked, (void *)scb); /* added for 2225395 */
/*
* free the asp session control block
case ASPIOC_GetLocEntity:
if ((gbuf_cont(mioc) == 0) || (scb->atp_state == 0)) {
- asp_iocnak(gref, mioc, EPROTO);
+ asp_iocnak(gref, mioc, EPROTOTYPE);
return 0;
}
*(at_inet_t *)gbuf_rptr(gbuf_cont(mioc)) = scb->loc_addr;
case ASPIOC_GetRemEntity:
if ((gbuf_cont(mioc) == 0) || (scb->atp_state == 0)) {
- asp_iocnak(gref, mioc, EPROTO);
+ asp_iocnak(gref, mioc, EPROTOTYPE);
return 0;
}
*(at_inet_t *)gbuf_rptr(gbuf_cont(mioc)) = scb->rem_addr;
case ASPIOC_GetSession:
if ((mdata = gbuf_cont(mioc)) == 0) {
- asp_iocnak(gref, mioc, EPROTO);
+ asp_iocnak(gref, mioc, EPROTOTYPE);
return 0;
}
addr = (at_inet_t *)gbuf_rptr(mdata);
server_scb = asp_scbQ[addr->socket];
/*### LD 10/28/97: changed to make sure we're not accessing a null server_scb */
if (server_scb == 0) {
- asp_iocnak(gref, mioc, EPROTO);
+ asp_iocnak(gref, mioc, EPROTOTYPE);
return 0;
}
if (server_scb->sess_ioc == 0) {
- asp_iocnak(gref, mioc, EPROTO);
+ asp_iocnak(gref, mioc, EPROTOTYPE);
return 0;
}
}
/*
- * send tickle routine - funnelled version
+ * send tickle routine - locked version
*/
StaticProc void
-asp_send_tickle_funnel(scb)
+asp_send_tickle_locked(scb)
void *scb;
{
- thread_funnel_set(network_flock, TRUE);
+ atalk_lock();
asp_send_tickle((asp_scb_t *)scb);
- thread_funnel_set(network_flock, FALSE);
+ atalk_unlock();
}
dPrintf(D_M_ASP, D_L_WARNING,
("asp_send_tickle: ENOBUFS 0, loc=%d, rem=%d\n",
scb->loc_addr.socket,scb->rem_addr.socket));
- timeout(asp_send_tickle_funnel, (void *)scb, 10);
+ timeout(asp_send_tickle_locked, (void *)scb, 10);
return;
}
gbuf_wset(mioc,sizeof(ioc_t));
("asp_send_tickle: ENOBUFS 1, loc=%d, rem=%d\n",
scb->loc_addr.socket,scb->rem_addr.socket));
- timeout(asp_send_tickle_funnel, (void *)scb, 10);
+ timeout(asp_send_tickle_locked, (void *)scb, 10);
return;
}
}
} /* asp_accept */
/*
- * timer routine - funneled version
+ * timer routine - locked version
*/
-void asp_clock_funnel(arg)
+void asp_clock_locked(arg)
void *arg;
{
- thread_funnel_set(network_flock, TRUE);
+ atalk_lock();
asp_clock(arg);
- thread_funnel_set(network_flock, FALSE);
+ atalk_unlock();
}
/*
ATENABLE(s, asptmo_lock);
if (++scb_tmo_cnt == 0) scb_tmo_cnt++;
- timeout(asp_clock_funnel, (void *)arg, (1<<SESS_TMO_RES)*TICKS_PER_SEC);
+ timeout(asp_clock_locked, (void *)arg, (1<<SESS_TMO_RES)*TICKS_PER_SEC);
}
/* last remaining use of MSG_ERROR */
gbuf_set_type(mioc, MSG_ERROR);
- *gbuf_rptr(mioc) = (u_char)EPROTO;
+ *gbuf_rptr(mioc) = (u_char)EPROTOTYPE;
gbuf_wset(mioc, 1);
if (gbuf_cont(mioc)) {
gbuf_freem(gbuf_cont(mioc));
bcopy (datptr, &datbuf, sizeof (strbuf_t));
} else {
/* being called from user space */
- if ((err = copyin((caddr_t)ctlptr, (caddr_t)&ctlbuf, sizeof(ctlbuf))) != 0)
+ if ((err = copyin(CAST_USER_ADDR_T(ctlptr), (caddr_t)&ctlbuf, sizeof(ctlbuf))) != 0)
goto l_err;
- if ((err = copyin((caddr_t)datptr, (caddr_t)&datbuf, sizeof(datbuf))) != 0)
+ if ((err = copyin(CAST_USER_ADDR_T(datptr), (caddr_t)&datbuf, sizeof(datbuf))) != 0)
goto l_err;
}
bcopy (ctlbuf.buf, gbuf_rptr(mioc), ctlbuf.len);
} else {
/* being called from user space */
- if ((err = copyin((caddr_t)ctlbuf.buf, (caddr_t)gbuf_rptr(mioc), ctlbuf.len)) != 0) {
+ if ((err = copyin(CAST_USER_ADDR_T(ctlbuf.buf), (caddr_t)gbuf_rptr(mioc), ctlbuf.len)) != 0) {
gbuf_freem(mioc);
goto l_err;
}
remain -= copy_len;
if (mreq != NULL)
bcopy (dataptr, (gbuf_rptr(mdata) + offset), copy_len);
- else if ((err = copyin(dataptr, (caddr_t)(gbuf_rptr(mdata) + offset), copy_len)) != 0) {
+ else if ((err = copyin(CAST_USER_ADDR_T(dataptr), (caddr_t)(gbuf_rptr(mdata) + offset), copy_len)) != 0) {
gbuf_freem(mioc);
goto l_err;
}
*/
while ((mproto = scb->sess_ioc) == 0) {
scb->get_wait = 1;
- err = tsleep(&scb->event, PSOCK | PCATCH, "aspgetmsg", 0);
+ lck_mtx_assert(atalk_mutex, LCK_MTX_ASSERT_OWNED);
+ err = msleep(&scb->event, atalk_mutex, PSOCK | PCATCH, "aspgetmsg", 0);
if (err != 0) {
scb->get_wait = 0;
ATENABLE(s, scb->lock);
bcopy (datptr, &datbuf, sizeof(datbuf));
} else {
/* called from user space */
- if ((err = copyin((caddr_t)ctlptr,
+ if ((err = copyin(CAST_USER_ADDR_T(ctlptr),
(caddr_t)&ctlbuf, sizeof(ctlbuf))) != 0)
goto l_err;
- if ((err = copyin((caddr_t)datptr,
+ if ((err = copyin(CAST_USER_ADDR_T(datptr),
(caddr_t)&datbuf, sizeof(datbuf))) != 0)
goto l_err;
}
} else {
/* called from user space */
if ((err = copyout((caddr_t)gbuf_rptr(mproto),
- (caddr_t)ctlbuf.buf, ctlbuf.len)) != 0)
+ CAST_USER_ADDR_T(ctlbuf.buf), ctlbuf.len)) != 0)
goto l_err;
if ((err = copyout((caddr_t)&ctlbuf,
- (caddr_t)ctlptr, sizeof(ctlbuf))) != 0)
+ CAST_USER_ADDR_T(ctlptr), sizeof(ctlbuf))) != 0)
goto l_err;
}
if (mreply == NULL) {
/* called from user space */
- if ((err = copyout((caddr_t)gbuf_rptr(mdata), (caddr_t)&datbuf.buf[sum], len)) != 0)
+ if ((err = copyout((caddr_t)gbuf_rptr(mdata), CAST_USER_ADDR_T(&datbuf.buf[sum]), len)) != 0)
goto l_err;
}
sum += len;
bcopy (&datbuf, datptr, sizeof(datbuf));
} else {
/* called from user space */
- if ((err = copyout((caddr_t)&datbuf, (caddr_t)datptr, sizeof(datbuf))) != 0)
+ if ((err = copyout((caddr_t)&datbuf, CAST_USER_ADDR_T(datptr), sizeof(datbuf))) != 0)
goto l_err;
}