Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored displaying of handshake HS flags. Added more logs #367

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions srtcore/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>

#include "udt.h"
#include "core.h"
#include "handshake.h"
#include "utilities.h"

Expand Down Expand Up @@ -164,23 +165,39 @@ string CHandShake::show()

// XXX HS version symbols should be probably declared inside
// CHandShake, not CUDT.
if ( m_iVersion > 4 )
if ( m_iVersion > CUDT::HS_VERSION_UDT4 )
{
string ext;

if ( m_iType & HS_EXT_HSREQ )
ext += "HSREQ ";

if ( m_iType & HS_EXT_KMREQ )
ext += "KMREQ ";
so << "EXT: ";
if (m_iType == 0) // no flags at all
so << "none";
else
so << ExtensionFlagStr(m_iType);
}

if ( ext == "" )
ext = "(no extensions)";
return so.str();
}

so << ext;
string CHandShake::ExtensionFlagStr(int32_t fl)
{
std::ostringstream out;
if ( fl & HS_EXT_HSREQ )
out << " hsx";
if ( fl & HS_EXT_KMREQ )
out << " kmx";
if ( fl & HS_EXT_CONFIG )
out << " config";

int kl = SrtHSRequest::SRT_HSTYPE_ENCFLAGS::unwrap(fl) << 6;
if (kl != 0)
{
out << " AES-" << kl;
}
else
{
out << " no-pbklen";
}

return so.str();
return out.str();
}


Expand Down
12 changes: 1 addition & 11 deletions srtcore/handshake.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,7 @@ class CHandShake
static const int32_t HS_EXT_KMREQ = BIT(1);
static const int32_t HS_EXT_CONFIG = BIT(2);

static std::string ExtensionFlagStr(int32_t fl)
{
std::string output = "";
if ( fl & HS_EXT_HSREQ )
output += " hsreq";
if ( fl & HS_EXT_KMREQ )
output += " kmreq";
if ( fl & HS_EXT_CONFIG )
output += " config";
return output;
}
static std::string ExtensionFlagStr(int32_t fl);

// Applicable only when m_iVersion == HS_VERSION_SRT1
int32_t flags() { return m_iType; }
Expand Down
7 changes: 6 additions & 1 deletion srtcore/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,8 @@ void* CRcvQueue::worker(void* param)

if ( have_received )
{
HLOGC(mglog.Debug, log << "worker: updateConnStatus (after received packet from the party)");
HLOGC(mglog.Debug, log << "worker: RECEIVED PACKET --> updateConnStatus. cst=" << ConnectStatusStr(cst)
<< " id=" << id << " pkt-payload-size=" << unit->m_Packet.getLength());
}

// Check connection requests status for all sockets in the RendezvousQueue.
Expand Down Expand Up @@ -1390,6 +1391,7 @@ int CRcvQueue::recvfrom(int32_t id, ref_t<CPacket> r_packet)
i = m_mBuffer.find(id);
if (i == m_mBuffer.end())
{
//HLOGC(dlog.Debug, log << "RcvQ:recvfrom: nothing to be received for id=" << id << " -- setting size=-1");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove dead code, please.

packet.setLength(-1);
return -1;
}
Expand All @@ -1400,6 +1402,8 @@ int CRcvQueue::recvfrom(int32_t id, ref_t<CPacket> r_packet)

if (packet.getLength() < newpkt->getLength())
{
//HLOGC(dlog.Debug, log << "RcvQ:recvfrom: IPE: spare packet for id=" << id << " size="
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove dead code, please.

// << newpkt->getLength() << " TOO SMALL for incoming size=" << packet.getLength() << " -- SETTING -1 size");
packet.setLength(-1);
return -1;
}
Expand Down Expand Up @@ -1449,6 +1453,7 @@ void CRcvQueue::removeListener(const CUDT* u)

void CRcvQueue::registerConnector(const SRTSOCKET& id, CUDT* u, int ipv, const sockaddr* addr, uint64_t ttl)
{
HLOGC(mglog.Debug, log << "registerConnector: adding %" << id << " addr=" << SockaddrToString(addr) << " TTL=" << ttl);
m_pRendezvousQueue->insert(id, u, ipv, addr, ttl);
}

Expand Down