2013-10-09 07:18:59 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* WinPR Logger
|
|
|
|
*
|
|
|
|
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WINPR_WLOG_PACKET_MESSAGE_PRIVATE_H
|
|
|
|
#define WINPR_WLOG_PACKET_MESSAGE_PRIVATE_H
|
|
|
|
|
2015-11-09 19:56:44 +03:00
|
|
|
#include "wlog.h"
|
2013-10-09 07:18:59 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#define PCAP_MAGIC_NUMBER 0xA1B2C3D4
|
2013-10-09 07:18:59 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 07:18:59 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT32 magic_number; /* magic number */
|
2013-10-09 07:18:59 +04:00
|
|
|
UINT16 version_major; /* major version number */
|
|
|
|
UINT16 version_minor; /* minor version number */
|
2019-11-06 17:24:51 +03:00
|
|
|
INT32 thiszone; /* GMT to local correction */
|
|
|
|
UINT32 sigfigs; /* accuracy of timestamps */
|
|
|
|
UINT32 snaplen; /* max length of captured packets, in octets */
|
|
|
|
UINT32 network; /* data link type */
|
2022-02-14 16:59:22 +03:00
|
|
|
} wPcapHeader;
|
2013-10-09 07:18:59 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 07:18:59 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
UINT32 ts_sec; /* timestamp seconds */
|
|
|
|
UINT32 ts_usec; /* timestamp microseconds */
|
2013-10-09 07:18:59 +04:00
|
|
|
UINT32 incl_len; /* number of octets of packet saved in file */
|
|
|
|
UINT32 orig_len; /* actual length of packet */
|
2022-02-14 16:59:22 +03:00
|
|
|
} wPcapRecordHeader;
|
2013-10-09 07:18:59 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct s_wPcapRecort
|
2013-10-09 07:18:59 +04:00
|
|
|
{
|
|
|
|
wPcapRecordHeader header;
|
|
|
|
void* data;
|
2021-06-16 19:09:14 +03:00
|
|
|
size_t length;
|
2022-02-14 16:59:22 +03:00
|
|
|
struct s_wPcapRecort* next;
|
|
|
|
} wPcapRecord;
|
2013-10-09 07:18:59 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 07:18:59 +04:00
|
|
|
{
|
|
|
|
FILE* fp;
|
|
|
|
char* name;
|
|
|
|
BOOL write;
|
2021-06-16 15:43:07 +03:00
|
|
|
SSIZE_T file_size;
|
|
|
|
size_t record_count;
|
2013-10-09 07:18:59 +04:00
|
|
|
wPcapHeader header;
|
|
|
|
wPcapRecord* head;
|
|
|
|
wPcapRecord* tail;
|
|
|
|
wPcapRecord* record;
|
2022-02-14 16:59:22 +03:00
|
|
|
} wPcap;
|
2013-10-09 07:18:59 +04:00
|
|
|
|
|
|
|
wPcap* Pcap_Open(char* name, BOOL write);
|
|
|
|
void Pcap_Close(wPcap* pcap);
|
|
|
|
|
|
|
|
void Pcap_Flush(wPcap* pcap);
|
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 21:37:53 +04:00
|
|
|
{
|
|
|
|
BYTE Destination[6];
|
|
|
|
BYTE Source[6];
|
|
|
|
UINT16 Type;
|
2022-02-14 16:59:22 +03:00
|
|
|
} wEthernetHeader;
|
2013-10-09 21:37:53 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 21:37:53 +04:00
|
|
|
{
|
|
|
|
BYTE Version;
|
|
|
|
BYTE InternetHeaderLength;
|
|
|
|
BYTE TypeOfService;
|
|
|
|
UINT16 TotalLength;
|
|
|
|
UINT16 Identification;
|
|
|
|
BYTE InternetProtocolFlags;
|
|
|
|
UINT16 FragmentOffset;
|
|
|
|
BYTE TimeToLive;
|
|
|
|
BYTE Protocol;
|
|
|
|
UINT16 HeaderChecksum;
|
|
|
|
UINT32 SourceAddress;
|
|
|
|
UINT32 DestinationAddress;
|
2022-02-14 16:59:22 +03:00
|
|
|
} wIPv4Header;
|
2013-10-09 21:37:53 +04:00
|
|
|
|
2022-02-14 16:59:22 +03:00
|
|
|
typedef struct
|
2013-10-09 21:37:53 +04:00
|
|
|
{
|
|
|
|
UINT16 SourcePort;
|
|
|
|
UINT16 DestinationPort;
|
|
|
|
UINT32 SequenceNumber;
|
|
|
|
UINT32 AcknowledgementNumber;
|
|
|
|
BYTE Offset;
|
|
|
|
BYTE Reserved;
|
|
|
|
BYTE TcpFlags;
|
|
|
|
UINT16 Window;
|
|
|
|
UINT16 Checksum;
|
|
|
|
UINT16 UrgentPointer;
|
2022-02-14 16:59:22 +03:00
|
|
|
} wTcpHeader;
|
2013-10-09 21:37:53 +04:00
|
|
|
|
2021-06-16 19:09:14 +03:00
|
|
|
BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flags);
|
2013-10-09 07:18:59 +04:00
|
|
|
|
|
|
|
#endif /* WINPR_WLOG_PACKET_MESSAGE_PRIVATE_H */
|