Fixed pcap capture function const correctness

This commit is contained in:
Armin Novak 2021-01-18 09:25:03 +01:00
parent 8187ab7732
commit 87e89bc719
2 changed files with 9 additions and 5 deletions

View File

@ -49,7 +49,11 @@ typedef struct _pcap_record pcap_record;
struct _pcap_record
{
pcap_record_header header;
void* data;
union
{
void* data;
const void* cdata;
};
UINT32 length;
pcap_record* next;
};
@ -76,7 +80,7 @@ extern "C"
FREERDP_API rdpPcap* pcap_open(char* name, BOOL write);
FREERDP_API void pcap_close(rdpPcap* pcap);
FREERDP_API BOOL pcap_add_record(rdpPcap* pcap, void* data, UINT32 length);
FREERDP_API BOOL pcap_add_record(rdpPcap* pcap, const void* data, UINT32 length);
FREERDP_API BOOL pcap_has_next_record(rdpPcap* pcap);
FREERDP_API BOOL pcap_get_next_record(rdpPcap* pcap, pcap_record* record);
FREERDP_API BOOL pcap_get_next_record_header(rdpPcap* pcap, pcap_record* record);

View File

@ -95,10 +95,10 @@ static BOOL pcap_read_record(rdpPcap* pcap, pcap_record* record)
static BOOL pcap_write_record(rdpPcap* pcap, pcap_record* record)
{
return pcap_write_record_header(pcap, &record->header) &&
(fwrite(record->data, record->length, 1, pcap->fp) == 1);
(fwrite(record->cdata, record->length, 1, pcap->fp) == 1);
}
BOOL pcap_add_record(rdpPcap* pcap, void* data, UINT32 length)
BOOL pcap_add_record(rdpPcap* pcap, const void* data, UINT32 length)
{
pcap_record* record;
struct timeval tp;
@ -126,7 +126,7 @@ BOOL pcap_add_record(rdpPcap* pcap, void* data, UINT32 length)
if (pcap->record == NULL)
pcap->record = record;
record->data = data;
record->cdata = data;
record->length = length;
record->header.incl_len = length;
record->header.orig_len = length;