|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: #undef T_IDLE ! 26: ! 27: /* ! 28: * Default Behavior for ADSP ! 29: */ ! 30: #define ocIntervalDefault 6 ! 31: #define ocMaximumDefault 10 ! 32: #define probeIntervalDefault 180 ! 33: ! 34: /* ! 35: * MACROS for comparing 32-bit sequence numbers ! 36: */ ! 37: #define GT(x,y) (((long)(x-y)) > (long) 0) ! 38: #define LT(x,y) (((long)(x-y)) < (long) 0) ! 39: #define GTE(x,y) (((long)(x-y)) >= (long) 0) ! 40: #define LTE(x,y) (((long)(x-y)) <= (long) 0) ! 41: #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z)) ! 42: ! 43: /* ! 44: * Use the kernel tick counter for SysTicks. ! 45: */ ! 46: ! 47: #define SysTicks() lbolt ! 48: ! 49: /* ! 50: * Timer element used for handling timings ! 51: */ ! 52: typedef struct timerelem { ! 53: struct timerelem *link; ! 54: short timer; ! 55: char type; ! 56: unsigned onQ:1; /* Bit-fields are faster than booleans */ ! 57: } TimerElem; ! 58: ! 59: typedef TimerElem *TimerElemPtr; ! 60: ! 61: /* ! 62: * For AppleTalk Phase 2 event queue ! 63: */ ! 64: typedef struct { ! 65: Ptr qLink; ! 66: unsigned short qType; ! 67: ProcPtr callAddr; ! 68: } LAPEventElem; ! 69: ! 70: typedef LAPEventElem *LAPEventElemPtr; ! 71: ! 72: /* ! 73: * The Event types we're passed when an AppleTalk transition occurs ! 74: */ ! 75: #define AOpenTransition 0 ! 76: #define ACloseTransition 2 ! 77: #define ANetworkTransition 5 ! 78: ! 79: /* ! 80: * The element we're passed when a NetworkTransaction event occurs ! 81: */ ! 82: typedef struct TNetworkTransition { ! 83: Ptr private; /* pointer used internally by NetShare */ ! 84: ProcPtr netValidProc; /* pointer to the network valid procedure */ ! 85: } TNetworkTransition, *TPNetworkTransition; ! 86: ! 87: typedef long (*NetworkTransitionProcPtr)(); ! 88: /* (TPNetworkTransition nettrans, ! 89: unsigned long thenet); */ ! 90: /* ! 91: * This is the connection control block ! 92: */ ! 93: typedef struct ccb { ! 94: /*---These fields may not change order or size-----------*/ ! 95: ! 96: struct ccb *ccbLink; /* link to next ccb */ ! 97: unsigned short state; /* state of the connection end */ ! 98: unsigned char userFlags; /* flags for unsolicited connection events */ ! 99: unsigned char localSocket; /* socket number of this connection end */ ! 100: AddrUnion remoteAddress; /* internet address of remote end */ ! 101: unsigned short attnCode; /* attention code received */ ! 102: unsigned short attnSize; /* size of received attention data */ ! 103: unsigned char *attnPtr; /* ptr to received attention data */ ! 104: unsigned short recvQPending; /* # bytes in receive queue %%% */ ! 105: /*------------------------------------------------------ */ ! 106: ! 107: struct adspcmd *opb; /* Outstanding open/close/remove/listens */ ! 108: struct adspcmd *spb; /* Outstanding Sends */ ! 109: struct adspcmd *sapb; /* Outstanding Send Attentions */ ! 110: struct adspcmd *frpb; /* Outstanding Forward Resets */ ! 111: struct adspcmd *rpb; /* Outstanding Read Requests */ ! 112: ! 113: struct ccb *otccbLink; /* link to next ccb */ ! 114: int pid; /* Process ID for CCB owner */ ! 115: ! 116: unsigned short remCID; /* Remote Connection ID */ ! 117: unsigned short locCID; /* Local Connection ID */ ! 118: int sendSeq; /* Seq number of next char to send to remote */ ! 119: int firstRtmtSeq; /* oldest seq # in local send queue */ ! 120: int sendWdwSeq; /* Seq # of last char remote has bfr for */ ! 121: int recvSeq; /* Seq of # of next char expected from rmte */ ! 122: int recvWdw; /* # of bytes local end has buffer space for */ ! 123: int attnSendSeq; /* Seq # of next attn pkt to send to remote */ ! 124: int attnRecvSeq; /* Seq # of next packet local end expects */ ! 125: int maxSendSeq; /* Highest seq # we ever sent on connection */ ! 126: ! 127: /* These must be in the first 255 bytes of the CCB */ ! 128: TimerElem ProbeTimer; /* Timer element for probes (and open) */ ! 129: TimerElem FlushTimer; /* Timer element for flushing data */ ! 130: TimerElem RetryTimer; /* Timer element for retransmissions */ ! 131: TimerElem AttnTimer; /* Timer element for attention packets */ ! 132: TimerElem ResetTimer; /* Timer element for forward resets */ ! 133: ! 134: short openInterval; /* Interval between open connection packets */ ! 135: short probeInterval; /* Interval between probes */ ! 136: short sendInterval; /* Interval before automatic flush */ ! 137: short rtmtInterval; /* Rexmit interval (dynamically determined) */ ! 138: ! 139: short sendCtl; /* Send control message bits */ ! 140: short sendBlocking; /* Flush unsent data if > than sendBlocking */ ! 141: short openRetrys; /* # of retrys for Connect & Accept */ ! 142: short rbuflen; /* Total size of receive buffer */ ! 143: short sbuflen; /* Total size of receive buffer */ ! 144: char pad; ! 145: char lockFlag; ! 146: char badSeqMax; /* retransmit advice send threshold */ ! 147: char badSeqCnt; /* # of of out-of-order packets received */ ! 148: char useCheckSum; /* true to use DDP checksums */ ! 149: char openState; /* Used for opening a connection (see below) */ ! 150: ! 151: gbuf_t *rbuf_mb; /* message block for the recv buffer */ ! 152: gbuf_t *crbuf_mb; ! 153: gbuf_t *sbuf_mb; /* message block for the send buffer */ ! 154: gbuf_t *csbuf_mb; ! 155: gbuf_t *attn_mb; /* message block for the attention buffer */ ! 156: gbuf_t *deferred_mb; /* message block deferred for later processing */ ! 157: ! 158: char ioDone; /* flag for when the adsp header is busy */ ! 159: char probeCntr; /* # of probes we can miss (counts down) */ ! 160: char pktSendMax; /* Max # of packets to send without an ack */ ! 161: char pktSendCnt; /* # of packets sent so far */ ! 162: ! 163: int sendStamp; /* Time of last ackRequest */ ! 164: int timerSeq; /* Seq # of char corresponding to above time stamp */ ! 165: short roundTrip; /* Average Round-Trip time (in 6ths of a second) */ ! 166: short deviation; /* deviation from roundTrip time */ ! 167: ! 168: unsigned sData:1; /* There's data in the send queue */ ! 169: unsigned waitingAck:1; /* We're waiting for an ack packet */ ! 170: unsigned rData:1; /* There's data in the receive queue */ ! 171: unsigned resentData:1; /* True when we resend data due to timeout */ ! 172: unsigned sendDataAck:1; /* True if he requested an ack */ ! 173: unsigned sendAttnAck:1; /* Must send attn acknowlege */ ! 174: unsigned sendAttnData:1; /* Must send attn data */ ! 175: unsigned callSend:1; /* Must call CheckSend() */ ! 176: unsigned rbufFull:1; /* We've closed our receive window. */ ! 177: unsigned noXmitFlow:1; /* True stops incrementing # of xmit ! 178: * packets to send in a row after receiving ! 179: * an ack packet. */ ! 180: unsigned secureCCB:1; /* True if this is a secure connection */ ! 181: unsigned removing:1; /* There is a dspRemove pending */ ! 182: unsigned writeFlush:1; /* Flush send queue even if # bytes to ! 183: * send is less than send blocking. */ ! 184: unsigned delay:1; /* do not complete commands until user ! 185: * */ ! 186: ADSP_FRAME f; /* Used to send every packet */ ! 187: ADSP_OPEN_DATA of; /* Holds the data for the open exchange */ ! 188: gref_t *gref; /* The queue associated with the CCB */ ! 189: gbuf_t *sp_mp; ! 190: atlock_t lock; ! 191: atlock_t lockClose; ! 192: atlock_t lockRemove; ! 193: } CCB, *CCBPtr; ! 194: ! 195: ! 196: /* ! 197: * Change order and die !!! --- See the receive open packet code ! 198: */ ! 199: #define O_STATE_NOTHING 0 /* Not opening */ ! 200: #define O_STATE_LISTEN 1 /* Listening for open request */ ! 201: #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open ! 202: * request */ ! 203: #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */ ! 204: #define O_STATE_OPEN 4 /* Connection is open */ ! 205: ! 206: /* ! 207: * These bits are used in the sendCtl field to indicate what needs to be sent ! 208: */ ! 209: #define B_CTL_PROBE 0x0001 ! 210: #define B_CTL_OREQ 0x0002 ! 211: #define B_CTL_OACK 0x0004 ! 212: #define B_CTL_OREQACK 0x0008 ! 213: #define B_CTL_ODENY 0x0010 ! 214: #define B_CTL_CLOSE 0x0020 ! 215: #define B_CTL_FRESET 0x0040 ! 216: #define B_CTL_FRESETACK 0x0080 ! 217: #define B_CTL_RETRANSMIT 0x0100 ! 218: ! 219: ! 220: #define kProbeTimerType offsetof(CCB, ProbeTimer) ! 221: #define kFlushTimerType offsetof(CCB, FlushTimer) ! 222: #define kRetryTimerType offsetof(CCB, RetryTimer) ! 223: #define kAttnTimerType offsetof(CCB, AttnTimer) ! 224: #define kResetTimerType offsetof(CCB, ResetTimer) ! 225: ! 226: /* ! 227: * Used to manage the send receive queue ! 228: */ ! 229: typedef struct { ! 230: short len; /* # of bytes in this fragment */ ! 231: char flags; /* See #define's below */ ! 232: char data[1]; ! 233: } HDR, *HDRPtr; ! 234: ! 235: #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */ ! 236: ! 237: #define F_GAP 0x03 ! 238: #define F_EOM 0x04 ! 239: #define F_WRAP 0x08 ! 240: #define F_VALID 0x10 ! 241: #define F_ENCRYPTED 0x20 /* %%% Needed ??? */ ! 242: #define F_LAST 0x40 /* This is last block in buffer */ ! 243: ! 244: ! 245: /* %%% Are these two used anymore? */ ! 246: #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)]) ! 247: #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)]) ! 248: ! 249: /* End Internal.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.