NetSim Source Code Help
Loading...
Searching...
No Matches
PacketHeader.h
Go to the documentation of this file.
1/************************************************************************************
2 * Copyright (C) 2020 *
3 * TETCOS, Bangalore. India *
4 * *
5 * Tetcos owns the intellectual property rights in the Product and its content. *
6 * The copying, redistribution, reselling or publication of any or all of the *
7 * Product or its content without express prior written consent of Tetcos is *
8 * prohibited. Ownership and / or any other right relating to the software and all *
9 * intellectual property rights therein shall remain at all times with Tetcos. *
10 * *
11 * Author: Shashi kant suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14#ifndef _PACKET_HEADER_H_
15#define _PACKET_HEADER_H_
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#ifndef _WIN32
21#include <sys/socket.h>
22#include <netinet/in.h>
23#include <netinet/tcp.h>
24
25#define ERROR_INVALID_PARAMETER EINVAL
26#else
27
28#define INT8 char
29#define UINT8 unsigned char
30#define INT16 short
31#define UINT16 unsigned short
32#define INT32 int
33#define UINT32 unsigned int
34#define INT64 long long int
35#define UINT64 unsigned long long int
36#define UINT unsigned int
37
38#endif
39
40
41
42/*
43 * Flags for DivertHelperCalcChecksums()
44 */
45#define WINDIVERT_HELPER_NO_IP_CHECKSUM 1
46#define WINDIVERT_HELPER_NO_ICMP_CHECKSUM 2
47#define WINDIVERT_HELPER_NO_ICMPV6_CHECKSUM 4
48#define WINDIVERT_HELPER_NO_TCP_CHECKSUM 8
49#define WINDIVERT_HELPER_NO_UDP_CHECKSUM 16
50
51
52#ifndef _WIN32
53//****** From ipmib.h from windows ******/
54// ICMP4_TYPE
55//
56// There are no RFC-specified defines for ICMPv4 message types, so we try to
57// use the ICMP6 values from RFC 2292 modified to be prefixed with ICMP4.
58//
59typedef enum {
60 ICMP4_ECHO_REPLY = 0, // Echo Reply.
61 ICMP4_DST_UNREACH = 3, // Destination Unreachable.
62 ICMP4_SOURCE_QUENCH = 4, // Source Quench.
63 ICMP4_REDIRECT = 5, // Redirect.
64 ICMP4_ECHO_REQUEST = 8, // Echo Request.
65 ICMP4_ROUTER_ADVERT = 9, // Router Advertisement.
66 ICMP4_ROUTER_SOLICIT = 10, // Router Solicitation.
67 ICMP4_TIME_EXCEEDED = 11, // Time Exceeded.
68 ICMP4_PARAM_PROB = 12, // Parameter Problem.
69 ICMP4_TIMESTAMP_REQUEST = 13, // Timestamp Request.
70 ICMP4_TIMESTAMP_REPLY = 14, // Timestamp Reply.
71 ICMP4_MASK_REQUEST = 17, // Address Mask Request.
72 ICMP4_MASK_REPLY = 18, // Address Mask Reply.
74
75#endif
76/*
77 * IPv4/IPv6/ICMP/ICMPv6/TCP/UDP header definitions.
78 */
79typedef struct
80{
93
94
95
96typedef struct
97{
106 UINT32 SrcAddr[4];
107 UINT32 DstAddr[4];
109
110#define IPV6_HDR_SIZE 40 //Bytes
111
112typedef struct
113{
119
120typedef struct
121{
127
128typedef struct
129{
147
148typedef struct
149{
155
156
158 PWINDIVERT_IPHDR *ppIpHdr, PWINDIVERT_IPV6HDR *ppIpv6Hdr,
159 PWINDIVERT_ICMPHDR *ppIcmpHdr, PWINDIVERT_ICMPV6HDR *ppIcmpv6Hdr,
160 PWINDIVERT_TCPHDR *ppTcpHdr, PWINDIVERT_UDPHDR *ppUdpHdr, PVOID *ppData,
161 UINT *pDataLen);
162
164 UINT64 flags);
165BOOL WinDivertHelperParseIPv4Address(const char *str, UINT32 *addr_ptr);
166BOOL WinDivertHelperParseIPv6Address(const char *str, UINT32 *addr_ptr);
167
168#ifdef __cplusplus
169}
170#endif
171#endif //_PACKET_HEADER_H_
172
#define PVOID
Definition: Linux.h:46
#define UINT64
Definition: Linux.h:37
BOOL
Definition: Linux.h:62
#define UINT
Definition: Linux.h:38
#define UINT32
Definition: Linux.h:35
#define UINT16
Definition: Linux.h:33
#define UINT8
Definition: Linux.h:31
struct WINDIVERT_TCPHDR * PWINDIVERT_TCPHDR
struct WINDIVERT_ICMPV6HDR * PWINDIVERT_ICMPV6HDR
struct WINDIVERT_UDPHDR * PWINDIVERT_UDPHDR
ICMP4_TYPE
Definition: PacketHeader.h:59
@ ICMP4_SOURCE_QUENCH
Definition: PacketHeader.h:62
@ ICMP4_TIMESTAMP_REPLY
Definition: PacketHeader.h:70
@ ICMP4_MASK_REPLY
Definition: PacketHeader.h:72
@ ICMP4_ROUTER_ADVERT
Definition: PacketHeader.h:65
@ ICMP4_ROUTER_SOLICIT
Definition: PacketHeader.h:66
@ ICMP4_TIMESTAMP_REQUEST
Definition: PacketHeader.h:69
@ ICMP4_MASK_REQUEST
Definition: PacketHeader.h:71
@ ICMP4_REDIRECT
Definition: PacketHeader.h:63
@ ICMP4_ECHO_REPLY
Definition: PacketHeader.h:60
@ ICMP4_TIME_EXCEEDED
Definition: PacketHeader.h:67
@ ICMP4_ECHO_REQUEST
Definition: PacketHeader.h:64
@ ICMP4_PARAM_PROB
Definition: PacketHeader.h:68
@ ICMP4_DST_UNREACH
Definition: PacketHeader.h:61
BOOL WinDivertHelperParsePacket(PVOID pPacket, UINT packetLen, PWINDIVERT_IPHDR *ppIpHdr, PWINDIVERT_IPV6HDR *ppIpv6Hdr, PWINDIVERT_ICMPHDR *ppIcmpHdr, PWINDIVERT_ICMPV6HDR *ppIcmpv6Hdr, PWINDIVERT_TCPHDR *ppTcpHdr, PWINDIVERT_UDPHDR *ppUdpHdr, PVOID *ppData, UINT *pDataLen)
UINT WinDivertHelperCalcChecksums(PVOID pPacket, UINT packetLen, UINT64 flags)
struct WINDIVERT_IPV6HDR * PWINDIVERT_IPV6HDR
BOOL WinDivertHelperParseIPv4Address(const char *str, UINT32 *addr_ptr)
BOOL WinDivertHelperParseIPv6Address(const char *str, UINT32 *addr_ptr)
struct WINDIVERT_IPHDR * PWINDIVERT_IPHDR
struct WINDIVERT_ICMPHDR * PWINDIVERT_ICMPHDR
enum ICMP4_TYPE * PICMP4_TYPE