X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..e2fac8b15b12a7979f72090454d850e612fc5b13:/bsd/netat/atp_read.c diff --git a/bsd/netat/atp_read.c b/bsd/netat/atp_read.c index 200577dbf..940a58ae3 100644 --- a/bsd/netat/atp_read.c +++ b/bsd/netat/atp_read.c @@ -1,23 +1,29 @@ /* * Copyright (c) 2000 Apple Computer, 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@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * Copyright (c) 1996-1998 Apple Computer, Inc. @@ -41,31 +47,35 @@ #include #include +#include + #include #include #include #include +#include #include +#include #include -static void atp_trans_complete(); -void atp_x_done(); -void atp_x_done_funnel(); -extern void atp_req_timeout(); +__private_extern__ int atp_resp_seqno2big = 0; + +static void atp_trans_complete(struct atp_trans *); +void atp_x_done_locked(void *); +void atp_treq_event(void *); /* * Decide what to do about received messages * Version 1.7 of atp_read.c on 89/02/09 17:53:16 */ -void atp_treq_event(gref) -register gref_t *gref; +void atp_treq_event(void *arg) { + register gref_t *gref = (gref_t *)arg; register gbuf_t *m; register struct atp_state *atp; - boolean_t funnel_state; - funnel_state = thread_funnel_set(network_flock, TRUE); + atalk_lock(); atp = (struct atp_state *)gref->info; if (atp->dflag) atp = (struct atp_state *)atp->atp_msgq; @@ -86,7 +96,7 @@ register gref_t *gref; if (m == 0) timeout(atp_treq_event, gref, 10); - (void) thread_funnel_set(network_flock, FALSE); + atalk_unlock(); } void atp_rput(gref, m) @@ -95,8 +105,9 @@ gbuf_t *m; { register at_atp_t *athp; register struct atp_state *atp; - register int s, s_gen; gbuf_t *m_asp = NULL; + struct timeval timenow; + u_short temp_net; atp = (struct atp_state *)gref->info; if (atp->dflag) @@ -130,16 +141,15 @@ gbuf_t *m; case ATP_CMD_TRESP: { register struct atp_trans *trp; - register int seqno; - register at_ddp_t *ddp; + register unsigned int seqno; + register at_ddp_t *ddp; /* * we just got a response, find the trans record */ - ATDISABLE(s, atp->atp_lock); for (trp = atp->atp_trans_wait.head; trp; trp = trp->tr_list.next) { - if (trp->tr_tid == UAS_VALUE(athp->tid)) + if (trp->tr_tid == UAS_VALUE_NTOH(athp->tid)) break; } @@ -147,13 +157,22 @@ gbuf_t *m; * If we can't find one then ignore the message */ seqno = athp->bitmap; + if (seqno > 7) { + atp_resp_seqno2big++; + ddp = AT_DDP_HDR(m); + dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR), + ("atp_rput: dropping TRESP seqno too big, tid=%d,loc=%d,rem=%d.%d,seqno=%u\n", + UAS_VALUE_NTOH(athp->tid), + ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno)); + gbuf_freem(m); + return; + } if (trp == NULL) { - ATENABLE(s, atp->atp_lock); ddp = AT_DDP_HDR(m); dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR), - ("atp_rput: dropping TRESP, no trp,tid=%d,loc=%d,rem=%d.%d,seqno=%d\n", - UAS_VALUE(athp->tid), - ddp->dst_socket,ddp->src_node,ddp->src_socket,seqno)); + ("atp_rput: dropping TRESP, no trp,tid=%d,loc=%d,rem=%d.%d,seqno=%u\n", + UAS_VALUE_NTOH(athp->tid), + ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno)); gbuf_freem(m); return; } @@ -162,11 +181,10 @@ gbuf_t *m; * If no longer valid, drop it */ if (trp->tr_state == TRANS_FAILED) { - ATENABLE(s, atp->atp_lock); ddp = AT_DDP_HDR(m); dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR), ("atp_rput: dropping TRESP, failed trp,tid=%d,loc=%d,rem=%d.%d\n", - UAS_VALUE(athp->tid), + UAS_VALUE_NTOH(athp->tid), ddp->dst_socket, ddp->src_node, ddp->src_socket)); gbuf_freem(m); return; @@ -176,11 +194,10 @@ gbuf_t *m; * If we have already received it, ignore it */ if (!(trp->tr_bitmap&atp_mask[seqno]) || trp->tr_rcv[seqno]) { - ATENABLE(s, atp->atp_lock); ddp = AT_DDP_HDR(m); dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR), - ("atp_rput: dropping TRESP, duplicate,tid=%d,loc=%d,rem=%d.%d,seqno=%d\n", - UAS_VALUE(athp->tid), + ("atp_rput: dropping TRESP, duplicate,tid=%d,loc=%d,rem=%d.%d,seqno=%u\n", + UAS_VALUE_NTOH(athp->tid), ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno)); gbuf_freem(m); return; @@ -211,7 +228,6 @@ gbuf_t *m; * the message to the user */ if (trp->tr_bitmap == 0) { - ATENABLE(s, atp->atp_lock); /* * Cancel the request timer and any @@ -229,12 +245,10 @@ gbuf_t *m; /* * If they want treq again, send them */ - ATENABLE(s, atp->atp_lock); atp_untimout(atp_req_timeout, trp); atp_send(trp); return; } - ATENABLE(s, atp->atp_lock); return; } @@ -247,9 +261,8 @@ gbuf_t *m; */ ddp = AT_DDP_HDR(m); - 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) { @@ -263,14 +276,11 @@ gbuf_t *m; { ddp = 0; atp_rcb_free(rcbp); - ATENABLE(s, atp->atp_lock); } break; } } - if (ddp) - ATENABLE(s, atp->atp_lock); gbuf_freem(m); return; } @@ -289,9 +299,8 @@ gbuf_t *m; */ ddp = AT_DDP_HDR(m); - 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) @@ -310,11 +319,10 @@ gbuf_t *m; */ /* we just did this, why do again? -jjs 4-10-95 */ for (rcbp = atp->atp_attached.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) { - ATENABLE(s, atp->atp_lock); gbuf_freem(m); dPrintf(D_M_ATP_LOW, D_L_INPUT, ("atp_rput: dropping TREQ, matches req queue\n")); @@ -326,20 +334,19 @@ gbuf_t *m; * assume someone is interested in * in an asynchronous incoming request */ - ATENABLE(s, atp->atp_lock); if ((rcbp = atp_rcb_alloc(atp)) == NULL) { gbuf_freem(m); return; } rcbp->rc_state = RCB_UNQUEUED; - ATDISABLE(s, atp->atp_lock); rcbp->rc_local_node = ddp->dst_node; - NET_NET(rcbp->rc_local_net, ddp->dst_net); + temp_net = NET_VALUE(ddp->dst_net); + NET_ASSIGN_NOSWAP(rcbp->rc_local_net, temp_net); rcbp->rc_socket.socket = ddp->src_socket; rcbp->rc_socket.node = ddp->src_node; rcbp->rc_socket.net = NET_VALUE(ddp->src_net); - rcbp->rc_tid = UAS_VALUE(athp->tid); + rcbp->rc_tid = UAS_VALUE_NTOH(athp->tid); rcbp->rc_bitmap = athp->bitmap; rcbp->rc_not_sent_bitmap = athp->bitmap; rcbp->rc_xo = athp->xo; @@ -376,7 +383,6 @@ gbuf_t *m; rcbp->rc_state = RCB_PENDING; ATP_Q_APPEND(atp->atp_attached, rcbp, rc_list); if (m_asp != NULL) { - ATENABLE(s, atp->atp_lock); atp_req_ind(atp, m_asp); return; } @@ -399,16 +405,14 @@ gbuf_t *m; * update the bitmap and resend * the replies */ - ATDISABLE(s_gen, atpgen_lock); + getmicrouptime(&timenow); if (rcbp->rc_timestamp) { - rcbp->rc_timestamp = time.tv_sec; + rcbp->rc_timestamp = timenow.tv_sec; if (rcbp->rc_timestamp == 0) rcbp->rc_timestamp = 1; } - ATENABLE(s_gen, atpgen_lock); rcbp->rc_bitmap = athp->bitmap; rcbp->rc_not_sent_bitmap = athp->bitmap; - ATENABLE(s, atp->atp_lock); gbuf_freem(m); atp_reply(rcbp); return; @@ -420,12 +424,10 @@ gbuf_t *m; * we haven't sent any data yet * ignore the request */ - ATENABLE(s, atp->atp_lock); gbuf_freem(m); return; } } - ATENABLE(s, atp->atp_lock); return; } @@ -455,12 +457,12 @@ gbuf_t *m; } /* atp_rput */ void -atp_x_done_funnel(trp) -register struct atp_trans *trp; +atp_x_done_locked(trp) +void *trp; { - thread_funnel_set(network_flock, TRUE); - atp_x_done(trp); - (void) thread_funnel_set(network_flock, FALSE); + atalk_lock(); + atp_x_done((struct atp_trans *)trp); + atalk_unlock(); } @@ -491,7 +493,7 @@ register struct atp_trans *trp; atp = trp->tr_queue; trp->tr_state = TRANS_RELEASE; - timeout(atp_x_done_funnel, trp, 10); + timeout(atp_x_done_locked, trp, 10); } } } @@ -539,7 +541,7 @@ register struct atp_trans *trp; if (trp->tr_bdsp == NULL) { gbuf_freem(m); if (trp->tr_rsp_wait) - thread_wakeup(&trp->tr_event); + wakeup(&trp->tr_event); } else { gbuf_set_type(m, MSG_IOCACK); ((ioc_t *)gbuf_rptr(m))->ioc_count = 0;