Annotation of ntddk/src/network/sonic/transfer.c, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1990-1992  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     transfer.c
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     This file contains the code to implement the MacTransferData
        !            12:     API for the NDIS 3.0 interface.
        !            13: 
        !            14: Author:
        !            15: 
        !            16:     Anthony V. Ercolano (Tonye) 12-Sept-1990
        !            17: 
        !            18: Environment:
        !            19: 
        !            20:     Kernel Mode - Or whatever is the equivalent.
        !            21: 
        !            22: Revision History:
        !            23: 
        !            24: 
        !            25: --*/
        !            26: 
        !            27: #include <ndis.h>
        !            28: #include <efilter.h>
        !            29: 
        !            30: #include <sonichrd.h>
        !            31: #include <sonicsft.h>
        !            32: 
        !            33: 
        !            34: extern
        !            35: NDIS_STATUS
        !            36: SonicTransferData(
        !            37:     IN NDIS_HANDLE MacBindingHandle,
        !            38:     IN NDIS_HANDLE MacReceiveContext,
        !            39:     IN UINT ByteOffset,
        !            40:     IN UINT BytesToTransfer,
        !            41:     OUT PNDIS_PACKET Packet,
        !            42:     OUT PUINT BytesTransferred
        !            43:     )
        !            44: 
        !            45: /*++
        !            46: 
        !            47: Routine Description:
        !            48: 
        !            49:     A protocol calls the SonicTransferData request (indirectly via
        !            50:     NdisTransferData) from within its Receive event handler
        !            51:     to instruct the MAC to copy the contents of the received packet
        !            52:     a specified paqcket buffer.
        !            53: 
        !            54: Arguments:
        !            55: 
        !            56:     MacBindingHandle - The context value returned by the MAC when the
        !            57:     adapter was opened.  In reality this is a pointer to SONIC_OPEN.
        !            58: 
        !            59:     MacReceiveContext - The context value passed by the MAC on its call
        !            60:     to NdisIndicateReceive.  The MAC can use this value to determine
        !            61:     which packet, on which adapter, is being received.
        !            62: 
        !            63:     ByteOffset - An unsigned integer specifying the offset within the
        !            64:     received packet at which the copy is to begin.  If the entire packet
        !            65:     is to be copied, ByteOffset must be zero.
        !            66: 
        !            67:     BytesToTransfer - An unsigned integer specifying the number of bytes
        !            68:     to copy.  It is legal to transfer zero bytes; this has no effect.  If
        !            69:     the sum of ByteOffset and BytesToTransfer is greater than the size
        !            70:     of the received packet, then the remainder of the packet (starting from
        !            71:     ByteOffset) is transferred, and the trailing portion of the receive
        !            72:     buffer is not modified.
        !            73: 
        !            74:     Packet - A pointer to a descriptor for the packet storage into which
        !            75:     the MAC is to copy the received packet.
        !            76: 
        !            77:     BytesTransfered - A pointer to an unsigned integer.  The MAC writes
        !            78:     the actual number of bytes transferred into this location.  This value
        !            79:     is not valid if the return status is STATUS_PENDING.
        !            80: 
        !            81: Return Value:
        !            82: 
        !            83:     The function value is the status of the operation.
        !            84: 
        !            85: 
        !            86: --*/
        !            87: 
        !            88: {
        !            89: 
        !            90:     PSONIC_ADAPTER Adapter;
        !            91: 
        !            92:     NDIS_STATUS StatusToReturn;
        !            93: 
        !            94:     Adapter = PSONIC_ADAPTER_FROM_BINDING_HANDLE(MacBindingHandle);
        !            95: 
        !            96:     NdisAcquireSpinLock(&Adapter->Lock);
        !            97:     Adapter->References++;
        !            98: 
        !            99:     if (!Adapter->ResetInProgress) {
        !           100: 
        !           101:         PSONIC_OPEN Open = PSONIC_OPEN_FROM_BINDING_HANDLE(MacBindingHandle);
        !           102: 
        !           103:         if (!Open->BindingShuttingDown) {
        !           104: 
        !           105:             Open->References++;
        !           106: 
        !           107:             NdisReleaseSpinLock(&Adapter->Lock);
        !           108: 
        !           109:             //
        !           110:             // Determine if this was a loopback packet.
        !           111:             //
        !           112: 
        !           113:             if (MacReceiveContext == (NDIS_HANDLE)NULL) {
        !           114: 
        !           115:                 NdisCopyFromPacketToPacket(
        !           116:                     Packet,
        !           117:                     0,
        !           118:                     BytesToTransfer,
        !           119:                     Adapter->CurrentLoopbackPacket,
        !           120:                     ByteOffset + 14,
        !           121:                     BytesTransferred
        !           122:                     );
        !           123: 
        !           124:             } else {
        !           125: 
        !           126:                 SonicCopyFromBufferToPacket(
        !           127:                     (PCHAR)MacReceiveContext + ByteOffset,
        !           128:                     BytesToTransfer,
        !           129:                     Packet,
        !           130:                     0,
        !           131:                     BytesTransferred
        !           132:                     );
        !           133: 
        !           134:             }
        !           135: 
        !           136:             NdisAcquireSpinLock(&Adapter->Lock);
        !           137:             Open->References--;
        !           138:             StatusToReturn = NDIS_STATUS_SUCCESS;
        !           139: 
        !           140:         } else {
        !           141: 
        !           142:             StatusToReturn = NDIS_STATUS_REQUEST_ABORTED;
        !           143: 
        !           144:         }
        !           145: 
        !           146:     } else {
        !           147: 
        !           148:         StatusToReturn = NDIS_STATUS_RESET_IN_PROGRESS;
        !           149: 
        !           150:     }
        !           151: 
        !           152:     SONIC_DO_DEFERRED(Adapter);
        !           153:     return StatusToReturn;
        !           154: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.