Blame include/freerdp/utils/pcap.h

Packit Service fa4841
/**
Packit Service fa4841
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit Service fa4841
 * pcap File Format Utils
Packit Service fa4841
 *
Packit Service fa4841
 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.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
#ifndef FREERDP_UTILS_PCAP_H
Packit Service fa4841
#define FREERDP_UTILS_PCAP_H
Packit Service fa4841
Packit Service fa4841
#include <freerdp/api.h>
Packit Service fa4841
#include <freerdp/types.h>
Packit Service fa4841
Packit Service fa4841
struct _pcap_header
Packit Service fa4841
{
Packit Service fa4841
	UINT32 magic_number;  /* magic number */
Packit Service fa4841
	UINT16 version_major; /* major version number */
Packit Service fa4841
	UINT16 version_minor; /* minor version number */
Packit Service fa4841
	INT32 thiszone;       /* GMT to local correction */
Packit Service fa4841
	UINT32 sigfigs;       /* accuracy of timestamps */
Packit Service fa4841
	UINT32 snaplen;       /* max length of captured packets, in octets */
Packit Service fa4841
	UINT32 network;       /* data link type */
Packit Service fa4841
};
Packit Service fa4841
typedef struct _pcap_header pcap_header;
Packit Service fa4841
Packit Service fa4841
struct _pcap_record_header
Packit Service fa4841
{
Packit Service fa4841
	UINT32 ts_sec;   /* timestamp seconds */
Packit Service fa4841
	UINT32 ts_usec;  /* timestamp microseconds */
Packit Service fa4841
	UINT32 incl_len; /* number of octets of packet saved in file */
Packit Service fa4841
	UINT32 orig_len; /* actual length of packet */
Packit Service fa4841
};
Packit Service fa4841
typedef struct _pcap_record_header pcap_record_header;
Packit Service fa4841
Packit Service fa4841
typedef struct _pcap_record pcap_record;
Packit Service fa4841
Packit Service fa4841
struct _pcap_record
Packit Service fa4841
{
Packit Service fa4841
	pcap_record_header header;
Packit Service fa4841
	void* data;
Packit Service fa4841
	UINT32 length;
Packit Service fa4841
	pcap_record* next;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
struct rdp_pcap
Packit Service fa4841
{
Packit Service fa4841
	FILE* fp;
Packit Service fa4841
	char* name;
Packit Service fa4841
	BOOL write;
Packit Service fa4841
	INT64 file_size;
Packit Service fa4841
	int record_count;
Packit Service fa4841
	pcap_header header;
Packit Service fa4841
	pcap_record* head;
Packit Service fa4841
	pcap_record* tail;
Packit Service fa4841
	pcap_record* record;
Packit Service fa4841
};
Packit Service fa4841
typedef struct rdp_pcap rdpPcap;
Packit Service fa4841
Packit Service fa4841
#ifdef __cplusplus
Packit Service fa4841
extern "C"
Packit Service fa4841
{
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
	FREERDP_API rdpPcap* pcap_open(char* name, BOOL write);
Packit Service fa4841
	FREERDP_API void pcap_close(rdpPcap* pcap);
Packit Service fa4841
Packit Service fa4841
	FREERDP_API BOOL pcap_add_record(rdpPcap* pcap, void* data, UINT32 length);
Packit Service fa4841
	FREERDP_API BOOL pcap_has_next_record(rdpPcap* pcap);
Packit Service fa4841
	FREERDP_API BOOL pcap_get_next_record(rdpPcap* pcap, pcap_record* record);
Packit Service fa4841
	FREERDP_API BOOL pcap_get_next_record_header(rdpPcap* pcap, pcap_record* record);
Packit Service fa4841
	FREERDP_API BOOL pcap_get_next_record_content(rdpPcap* pcap, pcap_record* record);
Packit Service fa4841
	FREERDP_API void pcap_flush(rdpPcap* pcap);
Packit Service fa4841
Packit Service fa4841
#ifdef __cplusplus
Packit Service fa4841
}
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#endif /* FREERDP_UTILS_PCAP_H */