Lines Matching refs:pData

132 DECLINLINE(int) tftpSecurityFilenameCheck(PNATState pData, PCTFTPSESSION pcTftpSession)
231 DECLINLINE(void) tftpSessionUpdate(PNATState pData, PTFTPSESSION pTftpSession)
336 static int tftpAllocateSession(PNATState pData, PCTFTPIPHDR pcTftpIpHeader, PPTFTPSESSION ppTftpSession)
341 AssertPtrReturn(pData, VERR_INVALID_PARAMETER);
347 pTftpSession = &((PTFTPSESSION)pData->pvTftpSessions)[idxSession];
367 tftpSessionUpdate(pData, pTftpSession);
372 static int tftpSessionFind(PNATState pData, PCTFTPIPHDR pcTftpIpHeader, PPTFTPSESSION ppTftpSessions)
376 AssertPtrReturn(pData, VERR_INVALID_PARAMETER);
382 pTftpSession = &((PTFTPSESSION)pData->pvTftpSessions)[idxTftpSession];
400 DECLINLINE(int) pftpSessionOpenFile(PNATState pData, PTFTPSESSION pTftpSession, PRTFILE pSessionFile)
426 DECLINLINE(int) tftpSessionEvaluateOptions(PNATState pData, PTFTPSESSION pTftpSession)
433 rc = pftpSessionOpenFile(pData, pTftpSession, &hSessionFile);
461 DECLINLINE(int) tftpSend(PNATState pData,
478 udp_output2(pData, NULL, pMBuf, &saddr, &daddr, IPTOS_LOWDELAY);
482 DECLINLINE(int) tftpSendError(PNATState pData, PTFTPSESSION pTftpSession, uint16_t errorcode, const char *msg, PCTFTPIPHDR pcTftpIpHeaderRecv);
484 DECLINLINE(int) tftpReadDataBlock(PNATState pData,
492 AssertPtrReturn(pData, VERR_INVALID_PARAMETER);
503 rc = pftpSessionOpenFile(pData, pcTftpSession, &hSessionFile);
537 DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint64_t u64OptValue)
555 m_copyback(pData, pMBuf, cbMBufCurrent, iOptLength, aszOptionBuffer);
561 DECLINLINE(int) tftpSendOACK(PNATState pData,
569 rc = tftpSessionEvaluateOptions(pData, pTftpSession);
572 tftpSendError(pData, pTftpSession, 2, "Option negotiation failure (file not found or inaccessible?)", pcTftpIpHeaderRecv);
577 m = slirpTftpMbufAlloc(pData);
593 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value);
597 rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u64Value);
599 rc = tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
603 DECLINLINE(int) tftpSendError(PNATState pData,
613 m = slirpTftpMbufAlloc(pData);
629 m_copyback(pData, m, sizeof(TFTPIPHDR), strlen(msg) + 1 /* copy ending zerro*/, (c_caddr_t)msg);
631 tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
639 static int tftpSendData(PNATState pData,
653 tftpSendError(pData, pTftpSession, 6, "ACK is wrong", pcTftpIpHeaderRecv);
658 m = slirpTftpMbufAlloc(pData);
670 rc = tftpReadDataBlock(pData, pTftpSession, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &cbRead);
676 tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
678 tftpSessionUpdate(pData, pTftpSession);
684 m_freem(pData, m);
685 tftpSendError(pData, pTftpSession, 1, "File not found", pcTftpIpHeaderRecv);
693 DECLINLINE(void) tftpProcessRRQ(PNATState pData, PCTFTPIPHDR pTftpIpHeader, int pktlen)
702 AssertPtrReturnVoid(pData);
706 rc = tftpAllocateSession(pData, pTftpIpHeader, &pTftpSession);
726 if (RT_FAILURE(tftpSecurityFilenameCheck(pData, pTftpSession)))
728 tftpSendError(pData, pTftpSession, 2, "Access violation", pTftpIpHeader);
737 tftpSendError(pData, pTftpSession, 4, "Unsupported transfer mode", pTftpIpHeader);
743 tftpSendOACK(pData, pTftpSession, pTftpIpHeader);
748 static void tftpProcessACK(PNATState pData, PTFTPIPHDR pTftpIpHeader)
753 rc = tftpSessionFind(pData, pTftpIpHeader, &pTftpSession);
757 if (tftpSendData(pData, pTftpSession,
763 int slirpTftpInit(PNATState pData)
765 AssertPtrReturn(pData, VERR_INVALID_PARAMETER);
766 pData->pvTftpSessions = RTMemAllocZ(sizeof(TFTPSESSION) * TFTP_SESSIONS_MAX);
767 AssertPtrReturn(pData->pvTftpSessions, VERR_NO_MEMORY);
771 void slirpTftpTerm(PNATState pData)
773 RTMemFree(pData->pvTftpSessions);
776 int slirpTftpInput(PNATState pData, struct mbuf *pMbuf)
779 AssertPtr(pData);
786 tftpProcessRRQ(pData, pTftpIpHeader, m_length(pMbuf, NULL));
790 tftpProcessACK(pData, pTftpIpHeader);