Annotation of ntddk/src/network/lance/loopback.c, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1990  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     loopback.c
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     The routines here indicate packets on the loopback queue and are
        !            12:     responsible for inserting and removing packets from the loopback
        !            13:     queue and the send finishing queue.
        !            14: 
        !            15: Author:
        !            16: 
        !            17:     Anthony V. Ercolano (Tonye) 12-Sept-1990
        !            18: 
        !            19: Environment:
        !            20: 
        !            21:     Operates at dpc level - or the equivalent on os2 and dos.
        !            22: 
        !            23: Revision History:
        !            24: 
        !            25: 
        !            26: --*/
        !            27: 
        !            28: #include <ndis.h>
        !            29: #include <efilter.h>
        !            30: #include <lancehrd.h>
        !            31: #include <lancesft.h>
        !            32: 
        !            33: 
        !            34: extern
        !            35: VOID
        !            36: LanceProcessLoopback(
        !            37:     IN PLANCE_ADAPTER Adapter
        !            38:     )
        !            39: 
        !            40: /*++
        !            41: 
        !            42: Routine Description:
        !            43: 
        !            44:     This routine is responsible for indicating *one* packet on
        !            45:     the loopback queue either completing it or moving on to the
        !            46:     finish send queue.
        !            47: 
        !            48:     NOTE: THIS IS CALLED WITH THE SPIN LOCK HELD!!
        !            49: 
        !            50: Arguments:
        !            51: 
        !            52:     Adapter - The adapter whose loopback queue we are processing.
        !            53: 
        !            54: Return Value:
        !            55: 
        !            56:     None.
        !            57: 
        !            58: --*/
        !            59: 
        !            60: {
        !            61:     //
        !            62:     // Packet at the head of the loopback list.
        !            63:     //
        !            64:     PNDIS_PACKET PacketToMove;
        !            65: 
        !            66:     //
        !            67:     // The reserved portion of the above packet.
        !            68:     //
        !            69:     PLANCE_RESERVED Reserved;
        !            70: 
        !            71:     //
        !            72:     // Eventually the length of the data to be indicated
        !            73:     // to the transport.
        !            74:     //
        !            75:     UINT BufferLength;
        !            76: 
        !            77:     //
        !            78:     // Length of the packet
        !            79:     //
        !            80:     UINT TotalPacketLength;
        !            81: 
        !            82:     PLANCE_OPEN Open;
        !            83: 
        !            84:     PacketToMove = Adapter->FirstLoopBack;
        !            85: 
        !            86:     Adapter->IndicatingMacReceiveContext.WholeThing = (UINT)PacketToMove;
        !            87: 
        !            88:     Adapter->IndicatedAPacket = TRUE;
        !            89: 
        !            90:     Reserved = PLANCE_RESERVED_FROM_PACKET(PacketToMove);
        !            91: 
        !            92:     Open = PLANCE_OPEN_FROM_BINDING_HANDLE(Reserved->MacBindingHandle);
        !            93: 
        !            94:     if (!Reserved->Next) {
        !            95: 
        !            96:         Adapter->LastLoopBack = NULL;
        !            97: 
        !            98:     }
        !            99: 
        !           100:     Adapter->FirstLoopBack = Reserved->Next;
        !           101: 
        !           102:     Adapter->IndicatingMacReceiveContext.WholeThing = (UINT)PacketToMove;
        !           103: 
        !           104:     NdisReleaseSpinLock(&Adapter->Lock);
        !           105: 
        !           106:     //
        !           107:     // See if we need to copy the data from the packet
        !           108:     // into the lookahead buffer.
        !           109:     //
        !           110:     // We need to copy to the adapter lookahead buffer if
        !           111:     // the first buffer of the packet is less than the
        !           112:     // minimum loopback size AND the first buffer isn't
        !           113:     // the total packet.
        !           114:     //
        !           115: 
        !           116:     NdisQueryPacket(
        !           117:         PacketToMove,
        !           118:         NULL,
        !           119:         NULL,
        !           120:         NULL,
        !           121:         &TotalPacketLength
        !           122:         );
        !           123: 
        !           124:     BufferLength = ((TotalPacketLength < (Adapter->MaxLookAhead + LANCE_HEADER_SIZE))?
        !           125:                     TotalPacketLength :
        !           126:                     Adapter->MaxLookAhead + LANCE_HEADER_SIZE);
        !           127: 
        !           128:     LanceCopyFromPacketToBuffer(
        !           129:             PacketToMove,
        !           130:             0,
        !           131:             Adapter->SizeOfReceiveBuffer,
        !           132:             Adapter->Lookahead,
        !           133:             &BufferLength
        !           134:             );
        !           135: 
        !           136:     //
        !           137:     // Indicate the packet to every open binding
        !           138:     // that could want it.
        !           139:     //
        !           140: 
        !           141:     if (BufferLength < LANCE_HEADER_SIZE) {
        !           142: 
        !           143:         if (BufferLength >= ETH_LENGTH_OF_ADDRESS) {
        !           144: 
        !           145:             //
        !           146:             // Runt packet
        !           147:             //
        !           148: 
        !           149:             EthFilterIndicateReceive(
        !           150:                 Adapter->FilterDB,
        !           151:                 PacketToMove,
        !           152:                 ((PCHAR)(Adapter->Lookahead)),
        !           153:                 Adapter->Lookahead,
        !           154:                 BufferLength,
        !           155:                 NULL,
        !           156:                 0,
        !           157:                 0
        !           158:                 );
        !           159:         }
        !           160: 
        !           161:     } else {
        !           162: 
        !           163:         EthFilterIndicateReceive(
        !           164:             Adapter->FilterDB,
        !           165:             PacketToMove,
        !           166:             ((PCHAR)(Adapter->Lookahead)),
        !           167:             Adapter->Lookahead,
        !           168:             LANCE_HEADER_SIZE,
        !           169:             Adapter->Lookahead + LANCE_HEADER_SIZE,
        !           170:             BufferLength - LANCE_HEADER_SIZE,
        !           171:             TotalPacketLength - LANCE_HEADER_SIZE
        !           172:             );
        !           173: 
        !           174:     }
        !           175: 
        !           176:     NdisCompleteSend(
        !           177:             Open->NdisBindingContext,
        !           178:             PacketToMove,
        !           179:             ((Reserved->SuccessfulTransmit)?
        !           180:              (NDIS_STATUS_SUCCESS):(NDIS_STATUS_FAILURE))
        !           181:             );
        !           182: 
        !           183: 
        !           184:     NdisAcquireSpinLock(&Adapter->Lock);
        !           185: 
        !           186:     //
        !           187:     // Remove reference for packet
        !           188:     //
        !           189: 
        !           190:     Open->References--;
        !           191: 
        !           192: }
        !           193: 

unix.superglobalmegacorp.com

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