mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Removed some std::ostringstream.
To be continued. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5108 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b2ea453804
commit
9aee68a2a9
8 changed files with 140 additions and 233 deletions
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "tcpstream.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
@ -40,7 +39,7 @@
|
|||
|
||||
/* Debugging for STATE change, and Startup SYNs */
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsrandom.h"
|
||||
|
||||
const int rstcpstreamzone = 28455;
|
||||
|
@ -173,10 +172,7 @@ int TcpStream::connect(const struct sockaddr_in &raddr, uint32_t conn_period)
|
|||
std::cerr << "TcpStream STATE -> TCP_SYN_SENT" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_SYN_SENT";
|
||||
out << " (Connect)";
|
||||
rslog(RSL_WARNING,rstcpstreamzone,out.str());
|
||||
rslog(RSL_WARNING,rstcpstreamzone,"TcpStream::state => TCP_SYN_SENT (Connect)");
|
||||
}
|
||||
|
||||
tcpMtx.unlock(); /******** UNLOCK MUTEX *********/
|
||||
|
@ -997,12 +993,7 @@ int TcpStream::recv_check()
|
|||
* for max efficiency
|
||||
*/
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (kNoPktTimeout)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSED (kNoPktTimeout)");
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
|
@ -1015,11 +1006,7 @@ int TcpStream::recv_check()
|
|||
int TcpStream::cleanup()
|
||||
{
|
||||
// This shuts it all down! no matter what.
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::cleanup() state = TCP_CLOSED";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::cleanup() state = TCP_CLOSED");
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
|
@ -1181,10 +1168,7 @@ int TcpStream::handleIncoming(TcpPacket *pkt)
|
|||
state = TCP_CLOSED;
|
||||
// return incoming_TimedWait(pkt);
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (recvd TCP_TIMED_WAIT?)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSED (recvd TCP_TIMED_WAIT?)");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1257,12 +1241,8 @@ int TcpStream::incoming_Closed(TcpPacket *pkt)
|
|||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_SYN_RCVD" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_SYN_RECVD";
|
||||
out << " (recvd SYN & !ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_SYN_RECVD (recvd SYN & !ACK)");
|
||||
}
|
||||
|
||||
delete pkt;
|
||||
|
@ -1327,12 +1307,8 @@ int TcpStream::incoming_SynSent(TcpPacket *pkt)
|
|||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_ESTABLISHED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_ESTABLISHED";
|
||||
out << " (recvd SUN & ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_ESTABLISHED (recvd SUN & ACK)");
|
||||
|
||||
delete pkt;
|
||||
}
|
||||
|
@ -1356,12 +1332,9 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
|||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_CLOSED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (recvd RST)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSED (recvd RST)");
|
||||
|
||||
delete pkt;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1426,13 +1399,8 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
|||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_ESTABLISHED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_ESTABLISHED";
|
||||
out << " (have SYN, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_ESTABLISHED (have SYN, recvd ACK)");
|
||||
}
|
||||
|
||||
if (ackWithData)
|
||||
|
@ -1735,12 +1703,8 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_CLOSE_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSE_WAIT";
|
||||
out << " (recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSE_WAIT (recvd FIN)");
|
||||
}
|
||||
else if (state == TCP_FIN_WAIT_1)
|
||||
{
|
||||
|
@ -1749,12 +1713,8 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_CLOSING";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSING";
|
||||
out << " (FIN_WAIT_1, recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSING (FIN_WAIT_1, recvd FIN)");
|
||||
}
|
||||
else if (state == TCP_FIN_WAIT_2)
|
||||
{
|
||||
|
@ -1763,12 +1723,9 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_TIMED_WAIT";
|
||||
out << " (FIN_WAIT_2, recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_TIMED_WAIT (FIN_WAIT_2, recvd FIN)");
|
||||
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -1784,12 +1741,8 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_2";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_FIN_WAIT_2";
|
||||
out << " (FIN_WAIT_1, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_FIN_WAIT_2 (FIN_WAIT_1, recvd ACK)");
|
||||
}
|
||||
else if (state == TCP_LAST_ACK)
|
||||
{
|
||||
|
@ -1798,12 +1751,9 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_CLOSED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (LAST_ACK, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_CLOSED (LAST_ACK, recvd ACK)");
|
||||
|
||||
cleanup();
|
||||
}
|
||||
else if (state == TCP_CLOSING)
|
||||
|
@ -1813,12 +1763,9 @@ int TcpStream::check_InPkts()
|
|||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_TIMED_WAIT";
|
||||
out << " (TCP_CLOSING, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_TIMED_WAIT (TCP_CLOSING, recvd ACK)");
|
||||
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -2089,12 +2036,10 @@ int TcpStream::retrans()
|
|||
setTTL(getTTL() + 1);
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::retrans() Startup SYNs ";
|
||||
out << "retrans count: " << pkt->retrans;
|
||||
out << " New TTL: " << getTTL();
|
||||
std::string out;
|
||||
rs_sprintf(out, "TcpStream::retrans() Startup SYNs retrans count: %u New TTL: %d", pkt->retrans, getTTL());
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out);
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << out.str() << std::endl;
|
||||
|
@ -2128,12 +2073,8 @@ int TcpStream::retrans()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (Too Many Retransmits)";
|
||||
rslog(RSL_WARNING,rstcpstreamzone,out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING,rstcpstreamzone,"TcpStream::state => TCP_CLOSED (Too Many Retransmits)");
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
|
@ -2461,12 +2402,8 @@ int TcpStream::send()
|
|||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_1";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_FIN_WAIT_1";
|
||||
out << " (End of Stream)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_FIN_WAIT_1 (End of Stream)");
|
||||
}
|
||||
else if (state == TCP_CLOSE_WAIT)
|
||||
{
|
||||
|
@ -2475,12 +2412,8 @@ int TcpStream::send()
|
|||
std::cerr << "TcpStream::state = TCP_LAST_ACK";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_LAST_ACK";
|
||||
out << " (CLOSE_WAIT, End of Stream)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, "TcpStream::state => TCP_LAST_ACK (CLOSE_WAIT, End of Stream)");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
// DEBUG FUNCTION
|
||||
#include <sstream>
|
||||
#include "util/rsstring.h"
|
||||
#include <iomanip>
|
||||
int displayUdpRelayPacketHeader(const void *data, const int size);
|
||||
#endif
|
||||
|
@ -888,19 +888,19 @@ int displayUdpRelayPacketHeader(const void *data, const int size)
|
|||
dsize = size;
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
for(int i = 0; i < dsize; i++)
|
||||
{
|
||||
std::string out;
|
||||
for(int i = 0; i < dsize; i++)
|
||||
{
|
||||
if ((i > 0) && (i % 16 == 0))
|
||||
{
|
||||
out << std::endl;
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
out << std::setw(2) << std::setfill('0') << std::hex << (uint32_t) ((uint8_t*) data)[i];
|
||||
}
|
||||
rs_sprintf_append(out, "%02x", (uint32_t) ((uint8_t*) data)[i]);
|
||||
}
|
||||
|
||||
std::cerr << "displayUdpRelayPacketHeader()" << std::endl;
|
||||
std::cerr << out.str();
|
||||
std::cerr << out;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
|
||||
#include "tcponudp/udpstunner.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "util/rsrandom.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
static const int STUN_TTL = 64;
|
||||
|
||||
|
@ -117,7 +117,7 @@ int UdpStunner::grabExclusiveMode(std::string holder) /* returns seconds since
|
|||
|
||||
|
||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||
std::cerr << "UdpStunner::grabExclusiveMode();"
|
||||
std::cerr << "UdpStunner::grabExclusiveMode()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
@ -464,14 +464,12 @@ int UdpStunner::doStun(struct sockaddr_in stun_addr)
|
|||
}
|
||||
|
||||
#ifdef DEBUG_UDP_STUNNER
|
||||
std::ostringstream out;
|
||||
out << "UdpStunner::doStun() Sent Stun Packet(" << sentlen << ") ";
|
||||
out << " to:";
|
||||
out << inet_ntoa(stun_addr.sin_addr) << ":" << ntohs(stun_addr.sin_port);
|
||||
std::string out;
|
||||
rs_sprintf(out, "UdpStunner::doStun() Sent Stun Packet(%d) to:%s:%u", sentlen, rs_inet_ntoa(stun_addr.sin_addr).c_str(), ntohs(stun_addr.sin_port));
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
|
||||
//pqioutput(PQL_ALERT, pqistunzone, out.str());
|
||||
//pqioutput(PQL_ALERT, pqistunzone, out);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
@ -504,10 +502,9 @@ bool UdpStun_response(void *stun_pkt, int size, struct sockaddr_in &addr)
|
|||
|
||||
|
||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||
std::ostringstream out;
|
||||
out << "UdpStunner::response() Recvd a Stun Response, ext_addr: ";
|
||||
out << inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port);
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::string out;
|
||||
rs_sprintf(out, "UdpStunner::response() Recvd a Stun Response, ext_addr: %s:%u", rs_inet_ntoa(addr.sin_addr).c_str(), ntohs(addr.sin_port));
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
@ -909,13 +906,11 @@ bool UdpStunner::attemptStun()
|
|||
bool UdpStunner::locked_recvdStun(const struct sockaddr_in &remote, const struct sockaddr_in &extaddr)
|
||||
{
|
||||
#ifdef DEBUG_UDP_STUNNER
|
||||
std::ostringstream out;
|
||||
out << "UdpStunner::locked_recvdStun() from:";
|
||||
out << inet_ntoa(remote.sin_addr) << ":" << ntohs(remote.sin_port);
|
||||
out << " claiming ExtAddr is:";
|
||||
out << inet_ntoa(extaddr.sin_addr) << ":" << ntohs(extaddr.sin_port);
|
||||
std::string out;
|
||||
rs_sprintf(out, "UdpStunner::locked_recvdStun() from:%s:%u", rs_inet_ntoa(remote.sin_addr).c_str(), ntohs(remote.sin_port));
|
||||
rs_sprintf_append(out, " claiming ExtAddr is:%s:%u", rs_inet_ntoa(extaddr.sin_addr).c_str(), ntohs(extaddr.sin_port));
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef UDPSTUN_ALLOW_LOCALNET
|
||||
|
@ -1016,9 +1011,8 @@ bool UdpStunner::locked_recvdStun(const struct sockaddr_in &remote, const str
|
|||
bool UdpStunner::locked_checkExternalAddress()
|
||||
{
|
||||
#ifdef DEBUG_UDP_STUNNER
|
||||
std::ostringstream out;
|
||||
out << "UdpStunner::locked_checkExternalAddress()";
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::string out = "UdpStunner::locked_checkExternalAddress()";
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
|
||||
bool found1 = false;
|
||||
|
@ -1128,28 +1122,25 @@ bool UdpStunner::locked_checkExternalAddress()
|
|||
bool UdpStunner::locked_printStunList()
|
||||
{
|
||||
#ifdef DEBUG_UDP_STUNNER
|
||||
std::ostringstream out;
|
||||
std::string out = "locked_printStunList()\n";
|
||||
|
||||
time_t now = time(NULL);
|
||||
out << "locked_printStunList()" << std::endl;
|
||||
out << "\tLastSendStun: " << now - mStunLastSendStun << std::endl;
|
||||
out << "\tLastSendAny: " << now - mStunLastSendAny << std::endl;
|
||||
out << "\tLastRecvResp: " << now - mStunLastRecvResp << std::endl;
|
||||
out << "\tLastRecvAny: " << now - mStunLastRecvAny << std::endl;
|
||||
rs_sprintf_append(out, "\tLastSendStun: %ld\n", now - mStunLastSendStun);
|
||||
rs_sprintf_append(out, "\tLastSendAny: %ld\n", now - mStunLastSendAny);
|
||||
rs_sprintf_append(out, "\tLastRecvResp: %ld\n", now - mStunLastRecvResp);
|
||||
rs_sprintf_append(out, "\tLastRecvAny: %ld\n", now - mStunLastRecvAny);
|
||||
|
||||
std::list<TouStunPeer>::iterator it;
|
||||
for(it = mStunList.begin(); it != mStunList.end(); it++)
|
||||
{
|
||||
out << "id:" << RsUtil::BinToHex(it->id) << " addr: " << inet_ntoa(it->remote.sin_addr);
|
||||
out << ":" << htons(it->remote.sin_port);
|
||||
out << " eaddr: " << inet_ntoa(it->eaddr.sin_addr);
|
||||
out << ":" << htons(it->eaddr.sin_port);
|
||||
out << " failCount: " << it->failCount;
|
||||
out << " lastSend: " << now - it->lastsend;
|
||||
out << std::endl;
|
||||
out += "id:" + RsUtil::BinToHex(it->id);
|
||||
rs_sprintf_append(out, " addr: %s:%u", rs_inet_ntoa(it->remote.sin_addr).c_str(), htons(it->remote.sin_port));
|
||||
rs_sprintf_append(out, " eaddr: %s:%u", rs_inet_ntoa(it->eaddr.sin_addr).c_str(), htons(it->eaddr.sin_port));
|
||||
rs_sprintf_append(out, " failCount: %lu", it->failCount);
|
||||
rs_sprintf_append(out, " lastSend: %ld\n", now - it->lastsend);
|
||||
}
|
||||
|
||||
std::cerr << out.str();
|
||||
std::cerr << out;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue