| 1154 | } |
| 1155 | |
| 1156 | void ClientDestination::HandleDataMessage (const uint8_t * buf, size_t len, |
| 1157 | i2p::garlic::ECIESX25519AEADRatchetSession * from) |
| 1158 | { |
| 1159 | uint32_t length = bufbe32toh (buf); |
| 1160 | if(length > len - 4) |
| 1161 | { |
| 1162 | LogPrint(eLogError, "Destination: Data message length ", length, " exceeds buffer length ", len); |
| 1163 | return; |
| 1164 | } |
| 1165 | buf += 4; |
| 1166 | // we assume I2CP payload |
| 1167 | uint16_t fromPort = bufbe16toh (buf + 4), // source |
| 1168 | toPort = bufbe16toh (buf + 6); // destination |
| 1169 | switch (buf[9]) |
| 1170 | { |
| 1171 | case PROTOCOL_TYPE_STREAMING: |
| 1172 | { |
| 1173 | // streaming protocol |
| 1174 | if (toPort != m_LastPort || !m_LastStreamingDestination) |
| 1175 | { |
| 1176 | m_LastStreamingDestination = GetStreamingDestination (toPort); |
| 1177 | if (!m_LastStreamingDestination) |
| 1178 | m_LastStreamingDestination = m_StreamingDestination; // if no destination on port use default |
| 1179 | m_LastPort = toPort; |
| 1180 | } |
| 1181 | if (m_LastStreamingDestination) |
| 1182 | m_LastStreamingDestination->HandleDataMessagePayload (buf, length, from); |
| 1183 | else |
| 1184 | LogPrint (eLogError, "Destination: Missing streaming destination"); |
| 1185 | } |
| 1186 | break; |
| 1187 | case PROTOCOL_TYPE_DATAGRAM: |
| 1188 | case PROTOCOL_TYPE_RAW: |
| 1189 | case PROTOCOL_TYPE_DATAGRAM2: |
| 1190 | case PROTOCOL_TYPE_DATAGRAM3: |
| 1191 | // datagram protocol |
| 1192 | if (m_DatagramDestination) |
| 1193 | m_DatagramDestination->HandleDataMessagePayload (fromPort, toPort, buf, length, buf[9], from); |
| 1194 | else |
| 1195 | LogPrint (eLogError, "Destination: Missing datagram destination"); |
| 1196 | break; |
| 1197 | default: |
| 1198 | LogPrint (eLogError, "Destination: Data: Unexpected protocol ", buf[9]); |
| 1199 | } |
| 1200 | } |
| 1201 | |
| 1202 | void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, uint16_t port) |
| 1203 | { |
nothing calls this directly
no test coverage detected