| 1059 | } |
| 1060 | |
| 1061 | bool TUdpHost::ProcessInConnectionPacket(const EUdpCmd cmd, const char* pktData, const char* pktEnd, const ui8 originalCmd, |
| 1062 | const sockaddr_in6& fromAddress, const sockaddr_in6& dstAddress, TAutoPtr<TUdpRecvPacket> recvBuf) { |
| 1063 | Y_ASSERT(IsInConnectionCmd(cmd)); |
| 1064 | Y_ASSERT(pktData <= pktEnd); |
| 1065 | |
| 1066 | TGUID connectionGuid; |
| 1067 | TConnectionSettings settings; |
| 1068 | TOptionsVector opt; |
| 1069 | |
| 1070 | TGUID thatSideGuid; |
| 1071 | if (!ReadInConnectionPacketHeaderTail(&pktData, pktEnd, originalCmd, &connectionGuid, &thatSideGuid, &settings, &opt) || |
| 1072 | connectionGuid.IsEmpty() || thatSideGuid.IsEmpty()) // validation |
| 1073 | { |
| 1074 | Y_ASSERT(false); |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | TConnection* connection = nullptr; |
| 1079 | if (const TIntrusivePtr<IConnection>* c = Connections.FindPtr(connectionGuid)) { |
| 1080 | connection = CheckedCast<TConnection*>(c->Get()); |
| 1081 | //Y_ASSERT(memcmp(&connection->GetWinsockAddress(), &fromAddress, sizeof(fromAddress)) == 0); |
| 1082 | |
| 1083 | // ignore imitator |
| 1084 | if (GetUdpAddress(fromAddress) != connection->GetAddress()) { |
| 1085 | Y_ASSERT(false); |
| 1086 | return true; |
| 1087 | } |
| 1088 | |
| 1089 | } else if (IsAckCmd(cmd)) { |
| 1090 | // OK, it seems we already deleted connection and got late duplicate ACK |
| 1091 | return true; |
| 1092 | |
| 1093 | } else { |
| 1094 | const TUdpAddress udpFromAddress = GetUdpAddress(fromAddress); |
| 1095 | const TUdpAddress toAddress = GetUdpAddress(dstAddress); |
| 1096 | |
| 1097 | connection = new TConnection(udpFromAddress, toAddress, settings, connectionGuid, UdpTransferTimeout); |
| 1098 | Connections[connectionGuid] = connection; |
| 1099 | } |
| 1100 | |
| 1101 | const bool thatSideHasChanged = !connection->CheckThatSideGuid(thatSideGuid); |
| 1102 | |
| 1103 | // actually GetAlivePeerLink would be enough |
| 1104 | connection->GetAlivePeerLink().GetUdpCongestion()->MarkAlive(); |
| 1105 | |
| 1106 | Y_ASSERT(IsTransferCmd(cmd) || IsPingCmd(cmd)); |
| 1107 | return IsTransferCmd(cmd) ? ProcessTransferPacket(cmd, pktData, pktEnd, recvBuf, connection, thatSideHasChanged, opt) : ProcessPingPacket(cmd, pktData, pktEnd, fromAddress, connection); |
| 1108 | } |
| 1109 | |
| 1110 | bool TUdpHost::ProcessTransferPacket(const EUdpCmd cmd, const char* pktData, const char* pktEnd, |
| 1111 | TAutoPtr<TUdpRecvPacket> recvBuf, TConnection* connection, const bool thatSideHasChanged, const TOptionsVector& opt) { |
nothing calls this directly
no test coverage detected