void LLHost::getIPString(char* buffer, S32 length) const { if ( ((U32) length) < MAXADDRSTR) { llerrs << "LLHost::getIPString - string too short" << llendl; return; } snprintf(buffer, length, "%s", u32_to_ip_string(mIP)); /* Flawfinder: ignore */ }
// Returns TRUE on success. BOOL send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, int nPort) { // Sends a packet to the address set in initNet // int nRet = 0; U32 last_error = 0; stDstAddr.sin_addr.s_addr = recipient; stDstAddr.sin_port = htons(nPort); do { nRet = sendto(hSocket, sendBuffer, size, 0, (struct sockaddr*)&stDstAddr, sizeof(stDstAddr)); if (nRet == SOCKET_ERROR ) { last_error = WSAGetLastError(); if (last_error != WSAEWOULDBLOCK) { // WSAECONNRESET - I think this is caused by an ICMP "connection refused" // message being sent back from a Linux box... I'm not finding helpful // documentation or web pages on this. The question is whether the packet // actually got sent or not. Based on the structure of this code, I would // assume it is. JNC 2002.01.18 if (WSAECONNRESET == WSAGetLastError()) { return TRUE; } llinfos << "sendto() failed to " << u32_to_ip_string(recipient) << ":" << nPort << ", Error " << last_error << llendl; } } } while ( (nRet == SOCKET_ERROR) &&(last_error == WSAEWOULDBLOCK)); return (nRet != SOCKET_ERROR); }
std::string LLHost::getIPString() const { return std::string( u32_to_ip_string( mIP ) ); }
std::string LLHost::getString() const { return llformat("%s:%u", u32_to_ip_string(mIP), mPort); }
std::ostream& operator<< (std::ostream& os, const LLHost &hh) { os << u32_to_ip_string(hh.mIP) << ":" << hh.mPort ; return os; }
// static void LLViewerImageList::receiveImagePacket(LLMessageSystem *msg, void **user_data) { LLMemType mt1(LLMemType::MTYPE_APPFMTIMAGE); LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); // Receives image packet, copy into image object, // checks if all packets received, decompresses if so. LLUUID id; U16 packet_num; char ip_string[256]; u32_to_ip_string(msg->getSenderIP(),ip_string); if (msg->getReceiveCompressedSize()) { gImageList.sTextureBits += msg->getReceiveCompressedSize() * 8; } else { gImageList.sTextureBits += msg->getReceiveSize() * 8; } gImageList.sTexturePackets++; //llprintline("Start decode, image header..."); msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id); msg->getU16Fast(_PREHASH_ImageID, _PREHASH_Packet, packet_num); S32 data_size = msg->getSizeFast(_PREHASH_ImageData, _PREHASH_Data); if (!data_size) { return; } if (data_size < 0) { // msg->getSizeFast() is probably trying to tell us there // was an error. llerrs << "image data chunk size was negative: " << data_size << llendl; return; } if (data_size > MTUBYTES) { llerrs << "image data chunk too large: " << data_size << " bytes" << llendl; return; } U8 *data = new U8[data_size]; msg->getBinaryDataFast(_PREHASH_ImageData, _PREHASH_Data, data, data_size); LLViewerImage *image = gImageList.getImage(id); if (!image) { delete [] data; return; } image->mLastPacketTimer.reset(); bool res = LLAppViewer::getTextureFetch()->receiveImagePacket(msg->getSender(), id, packet_num, data_size, data); if (!res) { delete[] data; } }
// static void LLViewerImageList::receiveImageHeader(LLMessageSystem *msg, void **user_data) { LLFastTimer t(LLFastTimer::FTM_PROCESS_IMAGES); // Receive image header, copy into image object and decompresses // if this is a one-packet image. LLUUID id; char ip_string[256]; u32_to_ip_string(msg->getSenderIP(),ip_string); if (msg->getReceiveCompressedSize()) { gImageList.sTextureBits += msg->getReceiveCompressedSize() * 8; } else { gImageList.sTextureBits += msg->getReceiveSize() * 8; } gImageList.sTexturePackets++; U8 codec; U16 packets; U32 totalbytes; msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id); msg->getU8Fast(_PREHASH_ImageID, _PREHASH_Codec, codec); msg->getU16Fast(_PREHASH_ImageID, _PREHASH_Packets, packets); msg->getU32Fast(_PREHASH_ImageID, _PREHASH_Size, totalbytes); S32 data_size = msg->getSizeFast(_PREHASH_ImageData, _PREHASH_Data); if (!data_size) { return; } if (data_size < 0) { // msg->getSizeFast() is probably trying to tell us there // was an error. llerrs << "image header chunk size was negative: " << data_size << llendl; return; } // this buffer gets saved off in the packet list U8 *data = new U8[data_size]; msg->getBinaryDataFast(_PREHASH_ImageData, _PREHASH_Data, data, data_size); LLViewerImage *image = gImageList.getImage(id); if (!image) { delete [] data; return; } image->mLastPacketTimer.reset(); bool res = LLAppViewer::getTextureFetch()->receiveImageHeader(msg->getSender(), id, codec, packets, totalbytes, data_size, data); if (!res) { delete[] data; } }