/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1996-2007 Apple Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_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 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.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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.
+ * 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@
- */
-/*
- * Copyright (c) 1996-1998 Apple Computer, Inc.
- * All Rights Reserved.
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Modified for MP, 1996 by Tuyen Nguyen
#include <sys/malloc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/file.h>
#include <net/if.h>
#include <netat/at_pat.h>
#include <netat/debug.h>
-static int loop_cnt; /* for debugging loops */
-#define CHK_LOOP(str) { \
- if (loop_cnt++ > 100) { \
- kprintf("%s", str); \
- break; \
- } \
-}
+
+int asp_pack_bdsp(struct atp_trans *, gbuf_t **);
static int atp_pack_bdsp(struct atp_trans *, struct atpBDS *);
static int atp_unpack_bdsp(struct atp_state *, gbuf_t *, struct atp_rcb *,
int, int);
-void atp_trp_clock(), asp_clock(), asp_clock_locked(), atp_trp_clock_locked();;
+void atp_trp_clock(void *arg), atp_trp_clock_locked(void *arg);
extern struct atp_rcb_qhead atp_need_rel;
extern int atp_inited;
extern struct atp_state *atp_used_list;
extern asp_scb_t *scb_free_list;
-extern atlock_t atpgen_lock;
-extern atlock_t atpall_lock;
-extern atlock_t atptmo_lock;
extern gbuf_t *scb_resource_m;
extern gbuf_t *atp_resource_m;
#define atpBDSsize (sizeof(struct atpBDS)*ATP_TRESP_MAX)
-void atp_link()
+void atp_link(void)
{
trp_tmo_list = 0;
trp_tmo_rcb = atp_trans_alloc(0);
register gbuf_t *m;
{
register ioc_t *iocbp;
- int i, xcnt, s;
+ int i, xcnt;
struct atp_state *atp;
struct atp_trans *trp;
struct atp_rcb *rcbp;
case AT_ATP_ISSUE_REQUEST_DEF:
case AT_ATP_ISSUE_REQUEST_DEF_NOTE: {
gbuf_t *bds, *tmp, *m2;
- struct atp_rcb *rcbp;
at_ddp_t *ddp;
at_atp_t *athp;
atp->atp_msgq = 0;
}
- ATDISABLE(s, atp->atp_lock);
/*
* search for the corresponding rcb
*/
for (rcbp = atp->atp_rcb.head; rcbp; rcbp = rcbp->rc_list.next) {
- if (rcbp->rc_tid == UAS_VALUE(athp->tid) &&
+ if (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid) &&
rcbp->rc_socket.node == ddp->dst_node &&
rcbp->rc_socket.net == NET_VALUE(ddp->dst_net) &&
rcbp->rc_socket.socket == ddp->dst_socket)
break;
}
- ATENABLE(s, atp->atp_lock);
/*
* If it has already been sent then return an error
rcbp->rc_socket.socket = ddp->dst_socket;
rcbp->rc_socket.node = ddp->dst_node;
rcbp->rc_socket.net = NET_VALUE(ddp->dst_net);
- rcbp->rc_tid = UAS_VALUE(athp->tid);
+ rcbp->rc_tid = UAS_VALUE_NTOH(athp->tid);
rcbp->rc_bitmap = 0xff;
rcbp->rc_xo = 0;
- ATDISABLE(s, atp->atp_lock);
rcbp->rc_state = RCB_SENDING;
ATP_Q_APPEND(atp->atp_rcb, rcbp, rc_list);
- ATENABLE(s, atp->atp_lock);
}
xcnt = get_bds_entries(m2);
if ((i = atp_unpack_bdsp(atp, m2, rcbp, xcnt, FALSE))) {
/*
* search for a waiting request
*/
- ATDISABLE(s, atp->atp_lock);
if ((rcbp = atp->atp_attached.head)) {
/*
* Got one, move it to the active response Q
*/
atp_rcb_free(rcbp);
}
- ATENABLE(s, atp->atp_lock);
atp_iocack(atp, m);
} else {
/*
* None available - can out
*/
- ATENABLE(s, atp->atp_lock);
atp_iocnak(atp, m, EAGAIN);
}
break;
i = *(int *)gbuf_rptr(gbuf_cont(m));
gbuf_freem(gbuf_cont(m));
gbuf_cont(m) = NULL;
- ATDISABLE(s, atp->atp_lock);
for (trp = atp->atp_trans_wait.head; trp; trp = trp->tr_list.next) {
if (trp->tr_tid == i)
break;
}
- if (trp == NULL) {
- ATENABLE(s, atp->atp_lock);
+ if (trp == NULL)
atp_iocnak(atp, m, ENOENT);
- } else {
- ATENABLE(s, atp->atp_lock);
+ else {
atp_free(trp);
atp_iocack(atp, m);
}
gbuf_wset(m,TOTAL_ATP_HDR_SIZE);
ddp = AT_DDP_HDR(m);
ddp->type = DDP_ATP;
- UAS_ASSIGN(ddp->checksum, 0);
+ UAS_ASSIGN_HTON(ddp->checksum, 0);
ddp->dst_socket = trp->tr_socket.socket;
ddp->dst_node = trp->tr_socket.node;
NET_ASSIGN(ddp->dst_net, trp->tr_socket.net);
athp = AT_ATP_HDR(m);
ATP_CLEAR_CONTROL(athp);
athp->cmd = ATP_CMD_TREL;
- UAS_ASSIGN(athp->tid, trp->tr_tid);
+ UAS_ASSIGN_HTON(athp->tid, trp->tr_tid);
}
return (m);
register struct atp_rcb *rcbp;
{ register gbuf_t *m;
register int i, len;
- int s_gen, s, cnt, err, offset, space;
- unsigned char *m0_rptr = NULL, *m0_wptr = NULL;
+ int cnt, offset, space;
register at_atp_t *athp;
register struct atpBDS *bdsp;
- register gbuf_t *m2, *m1, *m0, *mhdr;
- caddr_t lastPage;
- gbuf_t *mprev, *mlist = 0;
+ register gbuf_t *m1, *m0, *mhdr;
+#if DEBUG
+ gbuf_t *m2 = NULL;
+#endif /* DEBUG */
+ gbuf_t *mprev = 0, *mlist = 0;
at_socket src_socket = (at_socket)atp->atp_socket_no;
gbuf_t *rc_xmt[ATP_TRESP_MAX];
struct ddp_atp {
};
struct timeval timenow;
- ATDISABLE(s, atp->atp_lock);
- if (rcbp->rc_queue != atp) {
- ATENABLE(s, atp->atp_lock);
+ if (rcbp->rc_queue != atp)
return;
- }
if (rcbp->rc_not_sent_bitmap == 0)
goto nothing_to_send;
*/
bdsp++;
}
- if (mlist) {
- ATENABLE(s, atp->atp_lock);
+ if (mlist)
DDP_OUTPUT(mlist);
- ATDISABLE(s, atp->atp_lock);
- }
+
nothing_to_send:
/*
* If all replies from this reply block have been sent then
* remove it from the queue and mark it so
*/
- if (rcbp->rc_queue != atp) {
- ATENABLE(s, atp->atp_lock);
+ if (rcbp->rc_queue != atp)
return;
- }
rcbp->rc_rep_waiting = 0;
/*
*/
if (rcbp->rc_xo && rcbp->rc_state != RCB_RELEASED) {
getmicrouptime(&timenow);
- ATDISABLE(s_gen, atpgen_lock);
if (rcbp->rc_timestamp == 0) {
rcbp->rc_timestamp = timenow.tv_sec;
if (rcbp->rc_timestamp == 0)
ATP_Q_APPEND(atp_need_rel, rcbp, rc_tlist);
}
rcbp->rc_state = RCB_RESPONSE_FULL;
- ATENABLE(s_gen, atpgen_lock);
} else
atp_rcb_free(rcbp);
- ATENABLE(s, atp->atp_lock);
} /* atp_send_replies */
{
register struct atpBDS *bdsp;
register gbuf_t *m2, *m1, *m0, *mhdr;
- caddr_t lastPage;
at_atp_t *athp;
- int i, len, s_gen;
+ int i, len;
at_socket src_socket;
struct ddp_atp {
char ddp_atp_hdr[TOTAL_ATP_HDR_SIZE];
};
- gbuf_t *mprev, *mlist = 0;
+ gbuf_t *mprev = 0, *mlist = 0;
gbuf_t *rc_xmt[ATP_TRESP_MAX];
- unsigned char *m0_rptr, *m0_wptr;
- int err, offset, space;
+ int offset, space = 0;
struct timeval timenow;
/*
l_send:
if (rcbp->rc_xo) {
getmicrouptime(&timenow);
- ATDISABLE(s_gen, atpgen_lock);
if (rcbp->rc_timestamp == 0) {
if ((rcbp->rc_timestamp = timenow.tv_sec) == 0)
rcbp->rc_timestamp = 1;
ATP_Q_APPEND(atp_need_rel, rcbp, rc_tlist);
}
- ATENABLE(s_gen, atpgen_lock);
}
DDP_OUTPUT(mlist);
#define ATP_SOCKET_LAST (DDP_SOCKET_LAST-6)
#define ATP_SOCKET_FIRST (DDP_SOCKET_1st_DYNAMIC)
static unsigned int sNext = 0;
+extern unsigned char asp_inpC[];
+extern asp_scb_t *asp_scbQ[];
int atp_bind(gref, sVal, flag)
gref_t *gref;
unsigned int sVal;
unsigned char *flag;
{
- extern unsigned char asp_inpC[];
- extern asp_scb_t *asp_scbQ[];
unsigned char inpC, sNextUsed = 0;
- unsigned int sMin, sMax, sSav;
+ unsigned int sMin, sMax, sSav = 0;
struct atp_state *atp;
- int s;
atp = (struct atp_state *)gref->info;
if (atp->dflag)
sMax = ATP_SOCKET_LAST;
sMin = ATP_SOCKET_FIRST;
- ATDISABLE(s, atpgen_lock);
if (flag && (*flag == 3)) {
sMin += 40;
if (sMin < sNext) {
((sVal > sMax) || (sVal < 2) || (sVal == 6) ||
(ddp_socket_inuse(sVal, DDP_ATP) &&
(atp_inputQ[sVal] != (gref_t *)1)))) {
- ATENABLE(s, atpgen_lock);
return 0;
}
sNext = 0;
*flag = (unsigned char)sSav;
}
- ATENABLE(s, atpgen_lock);
return 0;
}
}
sNext = 0;
}
- ATENABLE(s, atpgen_lock);
return (int)sVal;
}
register gbuf_t *mioc;
{
register struct atp_rcb *rcbp;
- int s;
if ((rcbp = atp->atp_attached.head) != 0) {
gbuf_cont(mioc) = rcbp->rc_ioctl;
rcbp->rc_ioctl = NULL;
- ATDISABLE(s, atp->atp_lock);
if (rcbp->rc_xo) {
ATP_Q_REMOVE(atp->atp_attached, rcbp, rc_list);
rcbp->rc_state = RCB_NOTIFIED;
ATP_Q_APPEND(atp->atp_rcb, rcbp, rc_list);
} else
atp_rcb_free(rcbp);
- ATENABLE(s, atp->atp_lock);
if (gbuf_cont(mioc))
((ioc_t *)gbuf_rptr(mioc))->ioc_count = gbuf_msgsize(gbuf_cont(mioc));
else
gref_t *gref;
unsigned short tid;
{
- int s;
struct atp_state *atp;
struct atp_trans *trp;
if (atp->dflag)
atp = (struct atp_state *)atp->atp_msgq;
- ATDISABLE(s, atp->atp_lock);
for (trp = atp->atp_trans_wait.head; trp; trp = trp->tr_list.next) {
if (trp->tr_tid == tid)
break;
}
- ATENABLE(s, atp->atp_lock);
if (trp != NULL)
atp_free(trp);
}
atp_dequeue_atp(atp)
struct atp_state *atp;
{
- int s;
- ATDISABLE(s, atpall_lock);
if (atp == atp_used_list) {
if ((atp_used_list = atp->atp_trans_waiting) != 0)
atp->atp_trans_waiting->atp_rcb_waiting = 0;
atp->atp_trans_waiting = 0;
atp->atp_rcb_waiting = 0;
- ATENABLE(s, atpall_lock);
}
void
atp_timout(func, trp, ticks)
- void (*func)();
+ atp_tmo_func func;
struct atp_trans *trp;
int ticks;
{
- int s;
unsigned int sum;
struct atp_trans *curr_trp, *prev_trp;
- ATDISABLE(s, atptmo_lock);
- if (trp->tr_tmo_func) {
- ATENABLE(s, atptmo_lock);
+ if (trp->tr_tmo_func)
return;
- }
trp->tr_tmo_func = func;
trp->tr_tmo_delta = 1+(ticks>>5);
if (trp_tmo_list == 0) {
trp->tr_tmo_next = trp->tr_tmo_prev = 0;
trp_tmo_list = trp;
- ATENABLE(s, atptmo_lock);
return;
}
trp_tmo_list->tr_tmo_prev = trp;
trp_tmo_list = trp;
}
- ATENABLE(s, atptmo_lock);
}
void
-atp_untimout(func, trp)
- void (*func)();
- struct atp_trans *trp;
+atp_untimout(
+ __unused atp_tmo_func func,
+ struct atp_trans *trp)
{
- int s;
- ATDISABLE(s, atptmo_lock);
- if (trp->tr_tmo_func == 0) {
- ATENABLE(s, atptmo_lock);
+ if (trp->tr_tmo_func == 0)
return;
- }
if (trp_tmo_list == trp) {
if ((trp_tmo_list = trp->tr_tmo_next) != 0) {
}
}
trp->tr_tmo_func = 0;
- ATENABLE(s, atptmo_lock);
}
void
atp_trp_clock(arg)
void *arg;
{
- int s;
struct atp_trans *trp;
- void (*tr_tmo_func)();
+ atp_tmo_func tr_tmo_func;
- ATDISABLE(s, atptmo_lock);
if (trp_tmo_list)
trp_tmo_list->tr_tmo_delta--;
while (((trp = trp_tmo_list) != 0) && (trp_tmo_list->tr_tmo_delta == 0)) {
trp_tmo_list->tr_tmo_prev = 0;
if ((tr_tmo_func = trp->tr_tmo_func) != 0) {
trp->tr_tmo_func = 0;
- ATENABLE(s, atptmo_lock);
(*tr_tmo_func)(trp);
- ATDISABLE(s, atptmo_lock);
}
}
- ATENABLE(s, atptmo_lock);
timeout(atp_trp_clock_locked, (void *)arg, (1<<5));
}
register at_ddp_t *ddp;
gbuf_t *m, *m2, *bds;
struct atp_set_default *sdb;
- int s, old;
+ int old;
unsigned int timer;
+ u_short temp_net;
atp = (struct atp_state *)((struct atp_state *)gref->info)->atp_msgq;
iocbp = (ioc_t *)gbuf_rptr(mioc);
*/
athp = AT_ATP_HDR(m2);
athp->cmd = ATP_CMD_TREQ;
- UAS_ASSIGN(athp->tid, trp->tr_tid);
+ UAS_ASSIGN_HTON(athp->tid, trp->tr_tid);
athp->eom = 0;
athp->sts = 0;
trp->tr_xo = athp->xo;
trp->tr_socket.net = NET_VALUE(ddp->dst_net);
trp->tr_local_socket = atp->atp_socket_no;
trp->tr_local_node = ddp->src_node;
- NET_NET(trp->tr_local_net, ddp->src_net);
+ temp_net = NET_VALUE(ddp->src_net);
+ NET_ASSIGN_NOSWAP(trp->tr_local_net, temp_net);
#ifdef NOT_YET
/* save the local information in the gref */
/*
* Put us in the transaction waiting queue
*/
- ATDISABLE(s, atp->atp_lock);
ATP_Q_APPEND(atp->atp_trans_wait, trp, tr_list);
- ATENABLE(s, atp->atp_lock);
/*
* Send the message and set the timer
register at_atp_t *athp;
register at_ddp_t *ddp;
int s, xcnt;
+ u_short temp_net;
atp = (struct atp_state *)gref->info;
if (atp->dflag)
/*
* search for the corresponding rcb
*/
- ATDISABLE(s, atp->atp_lock);
for (rcbp = atp->atp_rcb.head; rcbp; rcbp = rcbp->rc_list.next) {
- if ( (rcbp->rc_tid == UAS_VALUE(athp->tid)) &&
+ if ( (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid)) &&
(rcbp->rc_socket.node == ddp->dst_node) &&
(rcbp->rc_socket.net == NET_VALUE(ddp->dst_net)) &&
(rcbp->rc_socket.socket == ddp->dst_socket) )
*/
if ((rcbp && (rcbp->rc_state != RCB_NOTIFIED)) ||
(rcbp == NULL && athp->xo) ) {
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
return;
}
- ATENABLE(s, atp->atp_lock);
if (rcbp == NULL) { /* a response is being sent for an ALO transaction */
if ((rcbp = atp_rcb_alloc(atp)) == NULL) {
rcbp->rc_socket.socket = ddp->dst_socket;
rcbp->rc_socket.node = ddp->dst_node;
rcbp->rc_socket.net = NET_VALUE(ddp->dst_net);
- rcbp->rc_tid = UAS_VALUE(athp->tid);
+ rcbp->rc_tid = UAS_VALUE_NTOH(athp->tid);
rcbp->rc_bitmap = 0xff;
rcbp->rc_xo = 0;
rcbp->rc_state = RCB_RESPONSE_FULL;
- ATDISABLE(s, atp->atp_lock);
ATP_Q_APPEND(atp->atp_rcb, rcbp, rc_list);
- ATENABLE(s, atp->atp_lock);
}
else if (ddp->src_node == 0) {
- NET_NET(ddp->src_net, rcbp->rc_local_net);
+ temp_net = NET_VALUE_NOSWAP(rcbp->rc_local_net);
+ NET_ASSIGN(ddp->src_net, temp_net);
ddp->src_node = rcbp->rc_local_node;
}
register struct atpBDS *bdsp;
register gbuf_t *m, *m2;
register int i;
- gbuf_t *m_prev, *m_head = 0;
+ gbuf_t *m_prev = 0, *m_head = 0;
dPrintf(D_M_ATP, D_L_INFO, ("asp_pack_bdsp: socket=%d\n",
trp->tr_queue->atp_socket_no));
void *proc;
{
gref_t *gref;
- int s, rc;
+ int rc;
unsigned short tid;
unsigned int timer;
register struct atp_state *atp;
return -1;
}
+ if (len < atpBDSsize + sizeof(struct atp_set_default) + TOTAL_ATP_HDR_SIZE ||
+ len > atpBDSsize + sizeof(struct atp_set_default) + TOTAL_ATP_HDR_SIZE +
+ ATP_DATA_SIZE) {
+ file_drop(fd);
+ *err = EINVAL;
+ return -1;
+ }
while ((mioc = gbuf_alloc(sizeof(ioc_t), PRI_MED)) == 0) {
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100 *1000 * NSEC_PER_USEC;
- ATDISABLE(s, atp->atp_delay_lock);
rc = msleep(&atp->atp_delay_event, atalk_mutex, PSOCK | PCATCH, "atpmioc", &ts);
- ATENABLE(s, atp->atp_delay_lock);
if (rc != 0) {
*err = rc;
file_drop(fd);
ts.tv_sec = 0;
ts.tv_nsec = 100 *1000 * NSEC_PER_USEC;
- ATDISABLE(s, atp->atp_delay_lock);
rc = msleep(&atp->atp_delay_event, atalk_mutex, PSOCK | PCATCH, "atpm2", &ts);
- ATENABLE(s, atp->atp_delay_lock);
if (rc != 0) {
gbuf_freeb(mioc);
file_drop(fd);
ts.tv_sec = 0;
ts.tv_nsec = 100 *1000 * NSEC_PER_USEC;
- ATDISABLE(s, atp->atp_delay_lock);
rc = msleep(&atp->atp_delay_event, atalk_mutex, PSOCK | PCATCH, "atptrp", &ts);
- ATENABLE(s, atp->atp_delay_lock);
if (rc != 0) {
gbuf_freem(mioc);
file_drop(fd);
*/
athp = AT_ATP_HDR(m2);
athp->cmd = ATP_CMD_TREQ;
- UAS_ASSIGN(athp->tid, trp->tr_tid);
+ UAS_ASSIGN_HTON(athp->tid, trp->tr_tid);
athp->eom = 0;
athp->sts = 0;
trp->tr_xo = athp->xo;
/*
* Put us in the transaction waiting queue
*/
- ATDISABLE(s, atp->atp_lock);
ATP_Q_APPEND(atp->atp_trans_wait, trp, tr_list);
- ATENABLE(s, atp->atp_lock);
/*
* Send the message and set the timer
/*
* wait for the transaction to complete
*/
- ATDISABLE(s, trp->tr_lock);
while ((trp->tr_state != TRANS_DONE) && (trp->tr_state != TRANS_FAILED) &&
(trp->tr_state != TRANS_ABORTING)) {
trp->tr_rsp_wait = 1;
rc = msleep(&trp->tr_event, atalk_mutex, PSOCK | PCATCH, "atpsndreq", 0);
if (rc != 0) {
trp->tr_rsp_wait = 0;
- ATENABLE(s, trp->tr_lock);
file_drop(fd);
*err = rc;
return -1;
}
}
trp->tr_rsp_wait = 0;
- ATENABLE(s, trp->tr_lock);
if (trp->tr_state == TRANS_FAILED || trp->tr_state == TRANS_ABORTING) {
void *proc;
{
gref_t *gref;
- int s, rc;
long bufaddr;
gbuf_t *m, *mdata;
short space;
int size;
struct atp_state *atp;
struct atpBDS *bdsp;
- u_int16_t *bufsz;
- char *buf;
int bds_cnt, count, len;
caddr_t dataptr;
/*
* allocate buffer and copy in the response info
*/
+ if (resplen < 0 || resplen > TOTAL_ATP_HDR_SIZE + sizeof(struct atpBDS)*ATP_TRESP_MAX) {
+ file_drop(fd);
+ *err = EINVAL;
+ return -1;
+ }
if ((m = gbuf_alloc_wait(resplen, TRUE)) == 0) {
*err = ENOMEM;
file_drop(fd);
}
for (size = 0, count = 0; count < bds_cnt; count++) {
+ if (UAS_VALUE(bdsp[count].bdsBuffSz) > ATP_DATA_SIZE) {
+ gbuf_freem(m);
+ *err = EINVAL;
+ file_drop(fd);
+ return -1;
+ }
size += UAS_VALUE(bdsp[count].bdsBuffSz);
}
if (size > datalen) {
if (!(mdata->m_flags & M_EXT)) {
m_freem(m);
file_drop(fd);
- return(NULL);
+ return(0);
}
dataptr = mtod(mdata, caddr_t);
space = MCLBYTES;
register struct atp_state *atp;
register struct atp_rcb *rcbp;
register gbuf_t *m, *m_head;
- int s, size, len;
+ int size, len;
if ((*err = atalk_getref(0, fd, &gref, proc, 1)) != 0)
return -1;
return -1;
}
- ATDISABLE(s, atp->atp_lock);
+ if (buflen < DDP_X_HDR_SIZE + ATP_HDR_SIZE) {
+ file_drop(fd);
+ *err = EINVAL;
+ return -1;
+ }
+
if ((rcbp = atp->atp_attached.head) != NULL) {
/*
* Got one, move it to the active response Q
*/
atp_rcb_free(rcbp);
}
- ATENABLE(s, atp->atp_lock);
/*
* copyout the request data, including the protocol header
file_drop(fd);
return size;
}
- ATENABLE(s, atp->atp_lock);
file_drop(fd);
return -1;
gref_t *gref;
register struct atp_state *atp;
register struct atp_trans *trp;
- int s, tid;
+ int tid;
char bds[atpBDSsize];
if ((*err = atalk_getref(0, fd, &gref, proc, 1)) != 0)
return -1;
}
- ATDISABLE(s, atp->atp_lock);
for (trp = atp->atp_trans_wait.head; trp; trp = trp->tr_list.next) {
dPrintf(D_M_ATP, D_L_INFO,
("ATPgetrsp: atp:0x%x, trp:0x%x, state:%d\n",
switch (trp->tr_state) {
case TRANS_DONE:
- ATENABLE(s, atp->atp_lock);
if ((*err = copyin(CAST_USER_ADDR_T(bdsp),
(caddr_t)bds, sizeof(bds))) != 0) {
atp_free(trp);
/*
* transaction timed out, return error
*/
- ATENABLE(s, atp->atp_lock);
atp_free(trp);
file_drop(fd);
*err = ETIMEDOUT;
continue;
}
}
- ATENABLE(s, atp->atp_lock);
file_drop(fd);
*err = EINVAL;
gref_t *gref;
gbuf_t *m;
{
- int s;
struct atp_state *atp;
struct atp_rcb *rcbp;
at_atp_t *athp;
/*
* search for the corresponding rcb
*/
- ATDISABLE(s, atp->atp_lock);
for (rcbp = atp->atp_rcb.head; rcbp; rcbp = rcbp->rc_list.next) {
- if ( (rcbp->rc_tid == UAS_VALUE(athp->tid)) &&
+ if ( (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid)) &&
(rcbp->rc_socket.node == ddp->src_node) &&
(rcbp->rc_socket.net == NET_VALUE(ddp->src_net)) &&
(rcbp->rc_socket.socket == ddp->src_socket) )
*/
if (rcbp)
atp_rcb_free(rcbp);
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
}