X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e5568f75972dfc723778653c11cb6b4dc825716a..2d21ac55c334faf3a56e5634905ed6987fc787d4:/bsd/netat/adsp_Packet.c diff --git a/bsd/netat/adsp_Packet.c b/bsd/netat/adsp_Packet.c index 2b9a8f0ff..c73d82e58 100644 --- a/bsd/netat/adsp_Packet.c +++ b/bsd/netat/adsp_Packet.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@ */ /* * Packet.c @@ -67,6 +73,8 @@ extern at_ifaddr_t *ifID_home; * OUTPUTS: * none */ +static void GleanSession(CCBPtr); + static void GleanSession(sp) /* (CCBPtr sp) */ CCBPtr sp; { @@ -392,6 +400,7 @@ typedef struct { * request/ack/req+ack/deny packet. * */ +static boolean MatchStream(CCBPtr, MATCHPtr); static boolean MatchStream(sp, m) /* (CCBPtr sp, MATCHPtr m) */ @@ -496,6 +505,8 @@ MatchStream(sp, m) /* (CCBPtr sp, MATCHPtr m) */ * */ +static boolean MatchListener(CCBPtr, MATCHPtr); + static boolean MatchListener(sp, m) /* (CCBPtr sp, MATCHPtr m) */ CCBPtr sp; MATCHPtr m; @@ -525,14 +536,13 @@ static boolean MatchListener(sp, m) /* (CCBPtr sp, MATCHPtr m) */ * OUTPUTS: * Returns 1 if packet was ignored */ -static int RXConnection(gref, spPtr, f, len, addr, dsoc) - /* (CCBPtr *spPtr, ADSP_FRAMEPtr f, word len, AddrUnion addr, byte dsoc) */ - gref_t *gref; /* READ queue */ - CCBPtr *spPtr; - ADSP_FRAMEPtr f; - int len; - AddrUnion addr; - unsigned char dsoc; +static int RXConnection( + __unused gref_t *gref, /* READ queue */ + CCBPtr *spPtr, + ADSP_FRAMEPtr f, + int len, + AddrUnion addr, + unsigned char dsoc) { CCBPtr sp; ADSP_OPEN_DATAPtr op; @@ -541,7 +551,6 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) gbuf_t *mp; ADSP_FRAMEPtr adspp; ADSP_OPEN_DATAPtr adspop; - int s; op = (ADSP_OPEN_DATAPtr)&f->data[0]; /* Point to Open-Connection parms */ len -= ADSP_FRAME_LEN; @@ -567,7 +576,7 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) adspop = (ADSP_OPEN_DATAPtr)gbuf_wptr(mp); gbuf_winc(mp,ADSP_OPEN_FRAME_LEN); UAS_UAS(adspop->dstCID, f->CID); - UAS_ASSIGN(adspop->version, 0x100); + UAS_ASSIGN_HTON(adspop->version, 0x100); adsp_sendddp(0, mp, DDPL_FRAME_LEN + ADSP_FRAME_LEN + ADSP_OPEN_FRAME_LEN, &addr, DDP_ADSP); @@ -576,14 +585,14 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) m.addr = addr; m.socket = dsoc; m.descriptor = f->descriptor; - m.srcCID = UAS_VALUE(f->CID); - m.dstCID = UAS_VALUE(op->dstCID); /* On even-byte boundry */ + m.srcCID = UAS_VALUE_NTOH(f->CID); + m.dstCID = UAS_VALUE_NTOH(op->dstCID); /* On even-byte boundry */ m.idx = ((f->descriptor & ADSP_CONTROL_MASK) - 1) * 4; /* * See if we can find a stream that knows what to do with this packet */ - if ((sp = (CCBPtr)qfind_m(AT_ADSP_STREAMS, &m, (ProcPtr)MatchStream)) == 0) + if ((sp = (CCBPtr)qfind_m((CCB *)AT_ADSP_STREAMS, &m, (ProcPtr)MatchStream)) == 0) { struct adspcmd *p; struct adspcmd *n; @@ -594,13 +603,12 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) if ((f->descriptor & ADSP_CONTROL_MASK) != (byte)ADSP_CTL_OREQ) return 1; - if ((sp = (CCBPtr)qfind_m(AT_ADSP_STREAMS, &m, + if ((sp = (CCBPtr)qfind_m((CCB *)AT_ADSP_STREAMS, &m, (ProcPtr)MatchListener)) == 0) return 1; - ATDISABLE(s, sp->lock); p = (struct adspcmd *)&sp->opb; - while (n = (struct adspcmd *)p->qLink) /* Hunt down list of listens */ + while ((n = (struct adspcmd *)p->qLink)) /* Hunt down list of listens */ { /* Check address filter */ if (((n->u.openParams.filterAddress.net == 0) || @@ -615,11 +623,10 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) p->qLink = n->qLink; /* Unlink this param block */ n->u.openParams.remoteCID = m.srcCID; *((AddrUnionPtr)&n->u.openParams.remoteAddress) = addr; - n->u.openParams.sendSeq = netdw(UAL_VALUE(f->pktNextRecvSeq)); - n->u.openParams.sendWindow = netw(UAS_VALUE(f->pktRecvWdw)); - n->u.openParams.attnSendSeq = netdw(UAL_VALUE(op->pktAttnRecvSeq)); + n->u.openParams.sendSeq = UAL_VALUE_NTOH(f->pktNextRecvSeq); + n->u.openParams.sendWindow = UAS_VALUE_NTOH(f->pktRecvWdw); + n->u.openParams.attnSendSeq = UAL_VALUE_NTOH(op->pktAttnRecvSeq); n->ioResult = 0; - ATENABLE(s, sp->lock); completepb(sp, n); /* complete copy of request */ /* complete(n, 0); */ return 0; @@ -629,29 +636,26 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) } /* while */ - ATENABLE(s, sp->lock); return 1; } *spPtr = sp; /* Save ptr to stream we just found */ - ATDISABLE(s, sp->lock); sp->openState = m.t->openState; /* Move to next state (may be same) */ sp->state = m.t->state; /* Move to next state (may be same) */ if (m.t->action & A_SAVEPARMS) { /* Need to Save open-conn parms */ - sp->firstRtmtSeq = sp->sendSeq = netdw(UAL_VALUE(f->pktNextRecvSeq)); - sp->sendWdwSeq = netdw(UAL_VALUE(f->pktNextRecvSeq)) + netw(UAS_VALUE(f->pktRecvWdw)) - 1; - sp->attnSendSeq = netdw(UAL_VALUE(op->pktAttnRecvSeq)); /* on even boundry */ + sp->firstRtmtSeq = sp->sendSeq = UAL_VALUE_NTOH(f->pktNextRecvSeq); + sp->sendWdwSeq = UAL_VALUE_NTOH(f->pktNextRecvSeq) + UAS_VALUE_NTOH(f->pktRecvWdw) - 1; + sp->attnSendSeq = UAL_VALUE_NTOH(op->pktAttnRecvSeq); /* on even boundry */ - sp->remCID = UAS_VALUE(f->CID); /* Save Source CID as RemCID */ + sp->remCID = UAS_VALUE_NTOH(f->CID); /* Save Source CID as RemCID */ UAS_UAS(sp->of.dstCID, f->CID); /* Save CID in open ctl packet */ sp->remoteAddress = addr; /* Save his address */ } - ATENABLE(s, sp->lock); if (m.t->action & A_DENY) { /* We've been denied ! */ DoClose(sp, errOpenDenied, -1); @@ -675,7 +679,7 @@ static int RXConnection(gref, spPtr, f, len, addr, dsoc) if (m.t->action & A_COMPLETE) { /* Need to complete open param blk */ RemoveTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer); - if (pb = sp->opb) { + if ((pb = sp->opb)) { sp->opb = 0; pb->u.openParams.localCID = sp->locCID; pb->u.openParams.remoteCID = sp->remCID; @@ -725,7 +729,6 @@ int adspPacket(gref, mp) int len; AddrUnion a; int dsoc; - int s; register DDPX_FRAME *ddp; /* DDP frame pointer */ register ADSP_FRAMEPtr f; /* Frame */ CCBPtr sp; @@ -737,7 +740,7 @@ int adspPacket(gref, mp) return -1; f = (ADSP_FRAMEPtr)(bp + DDPL_FRAME_LEN); - len = UAS_VALUE(ddp->ddpx_length) & 0x3ff; /* (ten bits of length) */ + len = UAS_VALUE_NTOH(ddp->ddpx_length) & 0x3ff; /* (ten bits of length) */ len -= DDPL_FRAME_LEN; if (len < (sizeof(ADSP_FRAME) - 1)) /* Packet too small */ return -1; /* mark the failure */ @@ -748,7 +751,7 @@ int adspPacket(gref, mp) dsoc = ddp->ddpx_dest; - if (sp = (CCBPtr)FindSender(f, a)) + if ((sp = (CCBPtr)FindSender(f, a))) GleanSession(sp); if (f->descriptor & ADSP_ATTENTION_BIT) { /* ATTN packet */ @@ -799,12 +802,10 @@ int adspPacket(gref, mp) /* This pkt may also ack some data we sent */ CheckRecvSeq(sp, f); RemoveTimerElem(&adspGlobal.fastTimers, &sp->RetryTimer); - ATDISABLE(s, sp->lock); sp->sendSeq = sp->firstRtmtSeq; sp->pktSendCnt = 0; sp->waitingAck = 0; sp->callSend = 1; - ATENABLE(s, sp->lock); } else goto ignore; break; @@ -824,7 +825,7 @@ int adspPacket(gref, mp) if (mp) gbuf_freem(mp); -checksend: /* incoming data was not ignored */ + /* incoming data was not ignored */ if (sp && sp->callSend) /* If we have a stream & we need to send */ CheckSend(sp);