libfreerdp-core: add option to dump remotefx to pcap

This commit is contained in:
Marc-André Moreau 2011-08-26 20:26:40 -04:00
parent a863c107ab
commit 9f256c8374
9 changed files with 45 additions and 1 deletions

View File

@ -718,7 +718,7 @@ int main(int argc, char* argv[])
chanman = freerdp_chanman_new();
SET_CHANMAN(instance, chanman);
instance->settings->sw_gdi = False;
instance->settings->sw_gdi = True;
if (freerdp_parse_args(instance->settings, argc, argv,
xf_process_plugin_args, chanman, xf_process_ui_args, NULL) < 0)

View File

@ -76,7 +76,9 @@ void test_pcap(void)
pcap = pcap_open("/tmp/test.pcap", True);
pcap_add_record(pcap, test_packet_1, sizeof(test_packet_1));
pcap_flush(pcap);
pcap_add_record(pcap, test_packet_2, sizeof(test_packet_2));
pcap_flush(pcap);
pcap_add_record(pcap, test_packet_3, sizeof(test_packet_3));
pcap_close(pcap);
@ -90,6 +92,8 @@ void test_pcap(void)
i++;
}
CU_ASSERT(i == 3);
pcap_close(pcap);
}

View File

@ -297,6 +297,9 @@ struct rdp_settings
uint8 rfx_codec_id;
boolean frame_acknowledge;
boolean dump_rfx;
char* dump_rfx_file;
boolean remote_app;
uint8 num_icon_caches;
uint16 num_icon_cache_entries;

View File

@ -22,6 +22,7 @@
#include <freerdp/rail.h>
#include <freerdp/types.h>
#include <freerdp/utils/pcap.h>
/* Common */
@ -1072,6 +1073,9 @@ struct rdp_update
void* param1;
void* param2;
boolean dump_rfx;
rdpPcap* pcap_rfx;
pcBeginPaint BeginPaint;
pcEndPaint EndPaint;
pcSetBounds SetBounds;

View File

@ -76,5 +76,6 @@ FREERDP_API void pcap_close(rdpPcap* pcap);
FREERDP_API void pcap_add_record(rdpPcap* pcap, void* data, uint32 length);
FREERDP_API boolean pcap_has_next_record(rdpPcap* pcap);
FREERDP_API boolean pcap_get_next_record(rdpPcap* pcap, pcap_record* record);
FREERDP_API void pcap_flush(rdpPcap* pcap);
#endif /* __UTILS_PCAP_H */

View File

@ -34,9 +34,19 @@ boolean freerdp_connect(freerdp* instance)
rdp = (rdpRdp*) instance->rdp;
IFCALL(instance->PreConnect, instance);
status = rdp_client_connect((rdpRdp*) instance->rdp);
if (status)
{
if (instance->settings->dump_rfx)
{
instance->update->dump_rfx = instance->settings->dump_rfx;
instance->update->pcap_rfx = pcap_open(instance->settings->dump_rfx_file, True);
}
IFCALL(instance->PostConnect, instance);
}
return status;
}

View File

@ -17,6 +17,8 @@
* limitations under the License.
*/
#include <freerdp/utils/pcap.h>
#include "surface.h"
static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s)
@ -62,6 +64,12 @@ boolean update_recv_surfcmds(rdpUpdate* update, uint16 size, STREAM* s)
while (size > 2)
{
if (update->dump_rfx)
{
pcap_add_record(update->pcap_rfx, s->p, size);
pcap_flush(update->pcap_rfx);
}
stream_read_uint16(s, cmdType);
size -= 2;

View File

@ -242,6 +242,17 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
settings->performance_flags = PERF_FLAG_NONE;
settings->large_pointer = True;
}
else if (strcmp("--dump-rfx", argv[index]) == 0)
{
index++;
if (index == argc)
{
printf("missing file name\n");
return -1;
}
settings->dump_rfx_file = xstrdup(argv[index]);
settings->dump_rfx = True;
}
else if (strcmp("-m", argv[index]) == 0)
{
settings->mouse_motion = 0;

View File

@ -80,6 +80,9 @@ void pcap_add_record(rdpPcap* pcap, void* data, uint32 length)
pcap->tail = record;
}
if (pcap->record == NULL)
pcap->record = record;
record->data = data;
record->length = length;
record->header.incl_len = length;