Lines Matching defs:pContext
24 @param [in] pContext Connection context structure address
31 IN TSDT_CONNECTION_CONTEXT * pContext
48 LengthInBytes = DIM ( pContext->FileData ) >> 1;
49 if (( pContext->ValidBytes > LengthInBytes )
50 || ( 0 == pContext->BytesRemaining )) {
57 if ( LengthInBytes > pContext->BytesRemaining ) {
58 LengthInBytes = pContext->BytesRemaining;
64 BytesRead = fread ( pContext->pFill,
67 pContext->File );
76 pContext->BytesRemaining -= BytesRead;
77 pContext->ValidBytes += BytesRead;
80 pContext->pFill,
82 pContext->BytesRemaining ));
87 pContext->pFill += BytesRead;
88 if ( pContext->pEnd <= pContext->pFill ) {
89 pContext->pFill = &pContext->FileData[ 0 ];
95 ASSERT ( 0 == ( DIM ( pContext->FileData ) & 1 ));
122 TSDT_CONNECTION_CONTEXT * pContext;
131 pContext = (TSDT_CONNECTION_CONTEXT *)AllocateZeroPool ( sizeof ( *pContext ));
132 if ( NULL != pContext ) {
136 pContext->SocketFd = SocketFd;
137 CopyMem ( &pContext->RemoteAddress,
139 sizeof ( pContext->RemoteAddress ));
140 pContext->BlockSize = 512;
145 pContext->pFill = &pContext->FileData[ 0 ];
146 pContext->pEnd = &pContext->FileData[ sizeof ( pContext->FileData )];
147 pContext->pBuffer = pContext->pFill;
152 pContext->MaxTimeout = MultU64x32 ( PcdGet32 ( Tftp_MaxTimeoutInSec ),
154 pContext->Rtt2x = pContext->MaxTimeout;
155 pContext->WindowSize = MAX_PACKETS;
156 WindowTimeout ( pContext );
161 pPacket = &pContext->Tx[ 0 ];
162 pEnd = &pPacket[ DIM ( pContext->Tx )];
164 PacketFree ( pContext, pPacket );
174 pContext,
184 pContext,
207 pContext->pNext = pTftpServer->pContextList;
208 pTftpServer->pContextList = pContext;
214 DBG_EXIT_STATUS ( pContext );
215 return pContext;
234 TSDT_CONNECTION_CONTEXT * pContext;
241 pContext = pTftpServer->pContextList;
242 while ( NULL != pContext ) {
247 &pContext->RemoteAddress,
253 "0x%08x: pContext found\r\n",
254 pContext ));
261 pContext = pContext->pNext;
267 DBG_EXIT_HEX ( pContext );
268 return pContext;
276 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
282 IN TSDT_CONNECTION_CONTEXT * pContext
299 if ( pNextContext == pContext ) {
304 pTftpServer->pContextList = pContext->pNext;
307 pPreviousContext->pNext = pContext->pNext;
322 if ( NULL != pContext ) {
326 gBS->FreePool ( pContext );
336 @param [in] pContext Connection context structure address
343 IN TSDT_CONNECTION_CONTEXT * pContext
361 bReadError = BufferFill ( pContext );
372 SendError ( pContext,
381 if ( pContext->bEofSent
382 || ( NULL == pContext->pFreeList )) {
392 pPacket = PacketGet ( pContext );
396 *pBuffer++ = (UINT8)( pContext->BlockNumber >> 8 );
397 *pBuffer++ = (UINT8)pContext->BlockNumber;
402 LengthInBytes = pContext->BlockSize;
403 if (( pContext->BytesToSend < TFTP_MAX_BLOCK_SIZE )
404 && ( LengthInBytes > pContext->BytesToSend )) {
405 LengthInBytes = pContext->BytesToSend;
406 pContext->bEofSent = TRUE;
411 pContext->BlockNumber,
420 pContext->pBuffer,
424 pContext->pBuffer,
430 pContext->ValidBytes -= LengthInBytes;
431 pContext->BytesToSend -= LengthInBytes;
432 pContext->pBuffer += LengthInBytes;
433 if ( pContext->pEnd <= pContext->pBuffer ) {
434 pContext->pBuffer = &pContext->FileData[ 0 ];
441 PacketQueue ( pContext, pPacket );
455 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
461 IN TSDT_CONNECTION_CONTEXT * pContext,
470 if ( pPacket != &pContext->ErrorPacket ) {
474 pPacket->pNext = pContext->pFreeList;
475 pContext->pFreeList = pPacket;
488 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
495 IN TSDT_CONNECTION_CONTEXT * pContext
505 pPacket = pContext->pFreeList;
507 pContext->pFreeList = pPacket->pNext;
525 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
533 IN TSDT_CONNECTION_CONTEXT * pContext,
546 pPacket->BlockNumber = pContext->BlockNumber;
547 pContext->BlockNumber += 1;
552 pTail = pContext->pTxTail;
554 pContext->pTxHead = pPacket;
559 pContext->pTxTail = pPacket;
569 if ( pContext->PacketsInWindow < pContext->WindowSize ) {
570 Status = PacketTx ( pContext, pPacket );
585 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
590 IN TSDT_CONNECTION_CONTEXT * pContext
602 pPacket = pContext->pTxHead;
605 pContext->pTxHead = pNext;
607 pContext->pTxTail = NULL;
616 pContext->PacketsInWindow -= 1;
630 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
638 IN TSDT_CONNECTION_CONTEXT * pContext,
665 "0x%08x: pContext sending 0x%08x bytes\r\n",
666 pContext,
679 pContext->PacketsInWindow += 1;
680 LengthInBytes = sendto ( pContext->SocketFd,
684 (struct sockaddr *)&pContext->RemoteAddress,
685 pContext->RemoteAddress.sin6_len );
690 pContext->PacketsInWindow -= 1;
725 TSDT_CONNECTION_CONTEXT * pContext;
797 pContext = ContextFind ( pTftpServer );
802 TftpProcessRequest ( pTftpServer, pContext, pTftpPort->fd );
838 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
847 IN TSDT_CONNECTION_CONTEXT * pContext,
862 pPacket = &pContext->ErrorPacket;
882 Status = PacketTx ( pContext, pPacket );
931 @param [in] pContext Connection context structure address
939 IN TSDT_CONNECTION_CONTEXT * pContext
959 if ( NULL == pContext ) {
996 pPacket = pContext->pTxHead;
1002 "ERROR - Expecting data not ACKs for pContext 0x%08x\r\n",
1003 pContext ));
1020 if (( 0 > AckNumber ) || ( AckNumber >= (INTN)pContext->PacketsInWindow )){
1035 pPacket = PacketRemove ( pContext );
1047 WindowAck ( pTftpServer, pContext, pPacket );
1053 PacketFree ( pContext, pPacket );
1054 } while (( NULL != pContext->pTxHead ) && ( AckNumber != BlockNumber ));
1059 pPacket = pContext->pTxHead;
1061 && ( pContext->PacketsInWindow < pContext->WindowSize )
1063 Status = PacketTx ( pContext, pPacket );
1071 PacketFill ( pContext );
1076 if ( 0 == pContext->PacketsInWindow ) {
1093 DeltaTime = DeltaTime - pContext->TimeStart;
1096 DeltaTime = pContext->TimeStart - DeltaTime;
1099 Bandwidth = pContext->LengthInBytes;
1248 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
1255 IN TSDT_CONNECTION_CONTEXT * pContext,
1271 pPacket = PacketGet ( pContext );
1322 pContext->BlockSize = Value;
1325 pContext->BlockSize ));
1339 pOack = TftpOptionSet ( pOack, pContext->BlockSize );
1360 pContext->MaxTimeout = Value;
1363 pContext->MaxTimeout ));
1377 pOack = TftpOptionSet ( pOack, pContext->MaxTimeout );
1400 pContext->LengthInBytes ));
1412 pOack = TftpOptionSet ( pOack, pContext->LengthInBytes );
1438 PacketQueue ( pContext, pPacket );
1441 PacketFree ( pContext, pPacket );
1508 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
1515 IN TSDT_CONNECTION_CONTEXT * pContext,
1544 bCloseContext = TftpAck ( pTftpServer, pContext );
1548 bCloseContext = TftpRead ( pTftpServer, pContext, SocketFd );
1555 if ( NULL == pContext ) {
1588 if ( 0 != pContext->PacketsInWindow ) {
1590 "ERROR - Expecting ACKs not data for pContext 0x%08x\r\n",
1591 pContext ));
1594 if ( pTftpServer->RxBytes > (ssize_t)( pContext->BlockSize + 2 + 2 )) {
1596 "ERROR - Receive data length of %d > %d bytes (maximum block size) for pContext 0x%08x\r\n",
1598 pContext->BlockSize,
1599 pContext ));
1605 if ( NULL == pContext ) {
1644 ContextRemove ( pTftpServer, pContext );
1655 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
1664 IN TSDT_CONNECTION_CONTEXT * pContext,
1692 if ( NULL != pContext ) {
1693 ContextRemove ( pTftpServer, pContext );
1703 pContext = ContextAdd ( pTftpServer, SocketFd );
1704 if ( NULL == pContext ) {
1712 pContext->TimeStart = TimeStart;
1734 SendError ( pContext,
1760 SendError ( pContext,
1784 pContext->File = fopen ((const char *)pFileName, pReadMode );
1785 if (( NULL == pContext->File )
1791 ( NULL == pContext->File )
1799 SendError ( pContext,
1804 pContext->LengthInBytes = FileStatus.st_size;
1805 pContext->BytesRemaining = pContext->LengthInBytes;
1806 pContext->BytesToSend = pContext->LengthInBytes;
1814 if ( 1024 > pContext->LengthInBytes ) {
1815 Value = (UINT32)pContext->LengthInBytes;
1821 else if (( 1024 * 1024 ) > pContext->LengthInBytes ) {
1822 Value = (UINT32)pContext->LengthInBytes;
1828 pContext->LengthInBytes ));
1830 else if (( 1024 * 1024 * 1024 ) > pContext->LengthInBytes ) {
1831 Value = (UINT32)DivU64x32 ( pContext->LengthInBytes, 1024 );
1837 pContext->LengthInBytes ));
1840 Value = (UINT32)DivU64x32 ( pContext->LengthInBytes, 1024 * 1024 );
1846 pContext->LengthInBytes ));
1854 TftpOptions ( pContext, pOption, pEnd );
1860 pContext->BlockNumber = 1;
1866 bCloseContext = PacketFill ( pContext );
1979 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
1986 IN TSDT_CONNECTION_CONTEXT * pContext,
2010 DeltaTime = RShiftU64 ( pContext->Rtt2x, ACK_SHIFT );
2011 pContext->Rtt2x += NanoSeconds + NanoSeconds - DeltaTime;
2012 if ( pContext->Rtt2x > pContext->MaxTimeout ) {
2013 pContext->Rtt2x = pContext->MaxTimeout;
2019 if ( pContext->WindowSize < MAX_PACKETS ) {
2020 pContext->AckCount -= 1;
2021 if ( 0 == pContext->AckCount ) {
2025 pContext->WindowSize += 1;
2030 if ( pContext->WindowSize < pContext->Threshold ) {
2031 pContext->AckCount = pContext->WindowSize * PcdGet32 ( Tftp_AckMultiplier );
2034 pContext->AckCount = PcdGet32 ( Tftp_AckLogBase ) << pContext->WindowSize;
2043 DeltaTime = RShiftU64 ( pContext->Rtt2x, 1 );
2047 pContext->WindowSize,
2048 pContext->Threshold,
2049 pContext->AckCount,
2056 pContext->WindowSize,
2057 pContext->Threshold,
2058 pContext->AckCount,
2066 pContext->WindowSize,
2067 pContext->Threshold,
2068 pContext->AckCount,
2076 pContext->WindowSize,
2077 pContext->Threshold,
2078 pContext->AckCount,
2094 @param [in] pContext Address of a ::TSDT_CONNECTION_CONTEXT structure
2099 IN TSDT_CONNECTION_CONTEXT * pContext
2110 pContext->Threshold = ( pContext->WindowSize + 1 ) >> 1;
2115 pContext->WindowSize = 1;
2116 pContext->PacketsInWindow = 0;
2121 pContext->Rtt2x = LShiftU64 ( pContext->Rtt2x, 1 );
2122 if ( pContext->Rtt2x > pContext->MaxTimeout ) {
2123 pContext->Rtt2x = pContext->MaxTimeout;
2129 if ( pContext->WindowSize < pContext->Threshold ) {
2130 pContext->AckCount = pContext->WindowSize * PcdGet32 ( Tftp_AckMultiplier );
2133 pContext->AckCount = PcdGet32 ( Tftp_AckLogBase ) << pContext->WindowSize;
2143 DeltaTime = RShiftU64 ( pContext->Rtt2x, 1 );
2147 pContext->WindowSize,
2148 pContext->Threshold,
2149 pContext->AckCount,
2156 pContext->WindowSize,
2157 pContext->Threshold,
2158 pContext->AckCount,
2166 pContext->WindowSize,
2167 pContext->Threshold,
2168 pContext->AckCount,
2176 pContext->WindowSize,
2177 pContext->Threshold,
2178 pContext->AckCount,
2187 pPacket = pContext->pTxHead;
2189 PacketTx ( pContext, pPacket );
2296 TSDT_CONNECTION_CONTEXT * pContext;
2311 pContext = pTftpServer->pContextList;
2312 while ( NULL != pContext )
2317 pPacket = pContext
2333 if ( ElapsedTime >= pContext->Rtt2x ) {
2336 pContext,
2338 pContext->WindowSize ));
2339 WindowTimeout ( pContext );
2346 pContext = pContext->pNext;