Lines Matching refs:pTftpSession
231 DECLINLINE(void) tftpSessionUpdate(PNATState pData, PTFTPSESSION pTftpSession)
233 pTftpSession->iTimestamp = curtime;
234 pTftpSession->fInUse = 1;
237 DECLINLINE(void) tftpSessionTerminate(PTFTPSESSION pTftpSession)
239 pTftpSession->fInUse = 0;
251 DECLINLINE(int) tftpSessionOptionParse(PTFTPSESSION pTftpSession, PCTFTPIPHDR pcTftpIpHeader)
259 AssertPtrReturn(pTftpSession, VERR_INVALID_PARAMETER);
262 LogFlowFunc(("pTftpSession:%p, pcTftpIpHeader:%p\n", pTftpSession, pcTftpIpHeader));
268 if (RTStrNLen((char *)pTftpSession->pszFilename, TFTP_FILENAME_MAX) == 0)
270 rc = RTStrCopy((char *)pTftpSession->pszFilename, TFTP_FILENAME_MAX, pszTftpRRQRaw);
277 else if (pTftpSession->enmTftpFmt == TFTPFMT_NONE)
288 pTftpSession->enmTftpFmt = g_TftpTransferFmtDesc[idxFmt].enmType;
294 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionBlkSize);
295 if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX)
301 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTSize);
306 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTimeout);
338 PTFTPSESSION pTftpSession = NULL;
347 pTftpSession = &((PTFTPSESSION)pData->pvTftpSessions)[idxSession];
349 if (!pTftpSession->fInUse)
353 if ((int)(curtime - pTftpSession->iTimestamp) > 5000)
360 memset(pTftpSession, 0, sizeof(*pTftpSession));
361 memcpy(&pTftpSession->IpClientAddress, &pcTftpIpHeader->IPv4Hdr.ip_src, sizeof(pTftpSession->IpClientAddress));
362 pTftpSession->u16ClientPort = pcTftpIpHeader->UdpHdr.uh_sport;
363 rc = tftpSessionOptionParse(pTftpSession, pcTftpIpHeader);
365 *ppTftpSession = pTftpSession;
367 tftpSessionUpdate(pData, pTftpSession);
374 PTFTPSESSION pTftpSession;
382 pTftpSession = &((PTFTPSESSION)pData->pvTftpSessions)[idxTftpSession];
384 if (pTftpSession->fInUse)
386 if (!memcmp(&pTftpSession->IpClientAddress, &pcTftpIpHeader->IPv4Hdr.ip_src, sizeof(pTftpSession->IpClientAddress)))
388 if (pTftpSession->u16ClientPort == pcTftpIpHeader->UdpHdr.uh_sport)
390 *ppTftpSessions = pTftpSession;
400 DECLINLINE(int) pftpSessionOpenFile(PNATState pData, PTFTPSESSION pTftpSession, PRTFILE pSessionFile)
407 tftp_prefix, pTftpSession->pszFilename);
426 DECLINLINE(int) tftpSessionEvaluateOptions(PNATState pData, PTFTPSESSION pTftpSession)
431 LogFlowFunc(("pTftpSession:%p\n", pTftpSession));
433 rc = pftpSessionOpenFile(pData, pTftpSession, &hSessionFile);
448 if (pTftpSession->OptionTSize.fRequested)
450 pTftpSession->OptionTSize.u64Value = cbSessionFile;
452 if ( !pTftpSession->OptionBlkSize.u64Value
453 && !pTftpSession->OptionBlkSize.fRequested)
455 pTftpSession->OptionBlkSize.u64Value = 1428;
462 PTFTPSESSION pTftpSession,
472 daddr.sin_addr = pTftpSession->IpClientAddress;
473 daddr.sin_port = pTftpSession->u16ClientPort;
482 DECLINLINE(int) tftpSendError(PNATState pData, PTFTPSESSION pTftpSession, uint16_t errorcode, const char *msg, PCTFTPIPHDR pcTftpIpHeaderRecv);
562 PTFTPSESSION pTftpSession,
569 rc = tftpSessionEvaluateOptions(pData, pTftpSession);
572 tftpSendError(pData, pTftpSession, 2, "Option negotiation failure (file not found or inaccessible?)", pcTftpIpHeaderRecv);
588 if (pTftpSession->OptionBlkSize.fRequested)
590 if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX)
593 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value);
596 && pTftpSession->OptionTSize.fRequested)
597 rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u64Value);
599 rc = tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
604 PTFTPSESSION pTftpSession,
631 tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
633 tftpSessionTerminate(pTftpSession);
640 PTFTPSESSION pTftpSession,
649 if (u16Block == pTftpSession->cTftpAck)
650 pTftpSession->cTftpAck++;
653 tftpSendError(pData, pTftpSession, 6, "ACK is wrong", pcTftpIpHeaderRecv);
654 tftpSessionTerminate(pTftpSession);
668 pTftpIpHeader->Core.u16TftpOpCode = RT_H2N_U16(pTftpSession->cTftpAck);
670 rc = tftpReadDataBlock(pData, pTftpSession, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &cbRead);
674 pTftpSession->cbTransfered += cbRead;
676 tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
678 tftpSessionUpdate(pData, pTftpSession);
680 tftpSessionTerminate(pTftpSession);
685 tftpSendError(pData, pTftpSession, 1, "File not found", pcTftpIpHeaderRecv);
695 PTFTPSESSION pTftpSession = NULL;
706 rc = tftpAllocateSession(pData, pTftpIpHeader, &pTftpSession);
708 || pTftpSession == NULL)
726 if (RT_FAILURE(tftpSecurityFilenameCheck(pData, pTftpSession)))
728 tftpSendError(pData, pTftpSession, 2, "Access violation", pTftpIpHeader);
735 if (RT_UNLIKELY(!tftpIsSupportedTransferMode(pTftpSession)))
737 tftpSendError(pData, pTftpSession, 4, "Unsupported transfer mode", pTftpIpHeader);
743 tftpSendOACK(pData, pTftpSession, pTftpIpHeader);
751 PTFTPSESSION pTftpSession = NULL;
753 rc = tftpSessionFind(pData, pTftpIpHeader, &pTftpSession);
757 if (tftpSendData(pData, pTftpSession,