/*----------------------------------------------------------------------
|   NPT_TlsSessionImpl::GetSessionId
+---------------------------------------------------------------------*/
NPT_Result
NPT_TlsSessionImpl::GetSessionId(NPT_DataBuffer& session_id)
{
    if (m_SSL == NULL) {
        // no handshake done
        session_id.SetDataSize(0);
        return NPT_ERROR_INVALID_STATE;
    }

    // return the session id
    session_id.SetData(ssl_get_session_id(m_SSL),
                       ssl_get_session_id_size(m_SSL));
    return NPT_SUCCESS;
}
Exemplo n.º 2
0
void Server::sendMessage(NPT_UdpSocket* socket, std::string nt, std::string message)
{
    std::string msg = buildMsg(nt, message);

    NPT_IpAddress upnpAddress = getUPNPAddress();
    NPT_DataBuffer buffer;
    NPT_SocketAddress address;

    address.SetIpAddress(upnpAddress);
    address.SetPort(UPNP_PORT);

    buffer.SetData((NPT_Byte*)msg.c_str(), msg.length());
    socket->Send(buffer, &address);
}
Exemplo n.º 3
0
void Server::sendReply(std::string host, int port, std::string msg)
{
    NPT_UdpSocket socket;
    NPT_DataBuffer buffer;

    NPT_IpAddress ip;
    NPT_SocketAddress address;

    ip.Parse(host.c_str());
    address.SetIpAddress(ip);
    address.SetPort(port);

    buffer.SetData((NPT_Byte*)msg.c_str(), msg.length());
    socket.Send(buffer, &address);
}