|
Packit Service |
fa4841 |
/**
|
|
Packit Service |
fa4841 |
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
Packit Service |
fa4841 |
* Heartbeat PDUs
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
fa4841 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
fa4841 |
* You may obtain a copy of the License at
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
fa4841 |
*
|
|
Packit Service |
fa4841 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
fa4841 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
fa4841 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
fa4841 |
* See the License for the specific language governing permissions and
|
|
Packit Service |
fa4841 |
* limitations under the License.
|
|
Packit Service |
fa4841 |
*/
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
fa4841 |
#include "config.h"
|
|
Packit Service |
fa4841 |
#endif
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#define WITH_DEBUG_HEARTBEAT
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
#include "heartbeat.h"
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
int rdp_recv_heartbeat_packet(rdpRdp* rdp, wStream* s)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
fa4841 |
BYTE reserved;
|
|
Packit Service |
fa4841 |
BYTE period;
|
|
Packit Service |
fa4841 |
BYTE count1;
|
|
Packit Service |
fa4841 |
BYTE count2;
|
|
Packit Service |
b1ea74 |
BOOL rc;
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
if (Stream_GetRemainingLength(s) < 4)
|
|
Packit Service |
fa4841 |
return -1;
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
Stream_Read_UINT8(s, reserved); /* reserved (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Read_UINT8(s, period); /* period (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Read_UINT8(s, count1); /* count1 (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Read_UINT8(s, count2); /* count2 (1 byte) */
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
WLog_DBG(HEARTBEAT_TAG,
|
|
Packit Service |
b1ea74 |
"received Heartbeat PDU -> period=%" PRIu8 ", count1=%" PRIu8 ", count2=%" PRIu8 "",
|
|
Packit Service |
b1ea74 |
period, count1, count2);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
rc = IFCALLRESULT(TRUE, rdp->heartbeat->ServerHeartbeat, rdp->instance, period, count1, count2);
|
|
Packit Service |
b1ea74 |
if (!rc)
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
b1ea74 |
WLog_ERR(HEARTBEAT_TAG, "heartbeat->ServerHeartbeat callback failed!");
|
|
Packit Service |
b1ea74 |
return -1;
|
|
Packit Service |
b1ea74 |
}
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
return 0;
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
b1ea74 |
BOOL freerdp_heartbeat_send_heartbeat_pdu(freerdp_peer* peer, BYTE period, BYTE count1, BYTE count2)
|
|
Packit Service |
b1ea74 |
{
|
|
Packit Service |
b1ea74 |
rdpRdp* rdp = peer->context->rdp;
|
|
Packit Service |
b1ea74 |
wStream* s = rdp_message_channel_pdu_init(rdp);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
if (!s)
|
|
Packit Service |
b1ea74 |
return FALSE;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
Stream_Seek_UINT8(s); /* reserved (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Write_UINT8(s, period); /* period (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Write_UINT8(s, count1); /* count1 (1 byte) */
|
|
Packit Service |
b1ea74 |
Stream_Write_UINT8(s, count2); /* count2 (1 byte) */
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
WLog_DBG(HEARTBEAT_TAG,
|
|
Packit Service |
b1ea74 |
"sending Heartbeat PDU -> period=%" PRIu8 ", count1=%" PRIu8 ", count2=%" PRIu8 "",
|
|
Packit Service |
b1ea74 |
period, count1, count2);
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
if (!rdp_send_message_channel_pdu(rdp, s, SEC_HEARTBEAT))
|
|
Packit Service |
b1ea74 |
return FALSE;
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
b1ea74 |
return TRUE;
|
|
Packit Service |
b1ea74 |
}
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
fa4841 |
rdpHeartbeat* heartbeat_new(void)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
b1ea74 |
rdpHeartbeat* heartbeat = (rdpHeartbeat*)calloc(1, sizeof(rdpHeartbeat));
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
if (heartbeat)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
bb5c11 |
}
|
|
Packit Service |
b1ea74 |
|
|
Packit Service |
fa4841 |
return heartbeat;
|
|
Packit Service |
fa4841 |
}
|
|
Packit Service |
fa4841 |
|
|
Packit Service |
fa4841 |
void heartbeat_free(rdpHeartbeat* heartbeat)
|
|
Packit Service |
fa4841 |
{
|
|
Packit Service |
fa4841 |
free(heartbeat);
|
|
Packit Service |
fa4841 |
}
|