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 all commits
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