/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @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. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * 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
* 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
* OUTPUTS:
* none
*/
+static void GleanSession(CCBPtr);
+
static void GleanSession(sp) /* (CCBPtr sp) */
CCBPtr sp;
{
* request/ack/req+ack/deny packet.
*
*/
+static boolean MatchStream(CCBPtr, MATCHPtr);
static boolean
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;
* 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;
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;
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);
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;
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) ||
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;
} /* 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);
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;
int len;
AddrUnion a;
int dsoc;
- int s;
register DDPX_FRAME *ddp; /* DDP frame pointer */
register ADSP_FRAMEPtr f; /* Frame */
CCBPtr sp;
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 */
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 */
/* 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;
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);