Fix a few msvc warnings
[reactos.git] / reactos / apps / utils / net / tracert / tracert.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS traceroute utility
4 * FILE: apps/utils/net/tracert/tracert.h
5 * PURPOSE: trace a packets route through a network
6 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
7 * REVISIONS:
8 * GM 03/05/05 Created
9 */
10
11 #define ECHO_REPLY 0
12 #define DEST_UNREACHABLE 3
13 #define ECHO_REQUEST 8
14 #define TTL_EXCEEDED 11
15
16 #define ICMP_MIN_SIZE 8
17 #define ICMP_MAX_SIZE 65535
18 #define PACKET_SIZE 32
19 /* we need this for packets which have the 'dont fragment'
20 * bit set, as they can get quite large otherwise
21 * (I've seen some reach 182 bytes */
22 #define MAX_REC_SIZE 200
23
24 /* pack the structures */
25 #include <pshpack1.h>
26
27 /* IPv4 Header, 20 bytes */
28 typedef struct IPv4Header
29 {
30 BYTE h_len:4;
31 BYTE version:4;
32 BYTE tos;
33 USHORT length;
34 USHORT id;
35 USHORT flag_frag;
36 BYTE ttl;
37 BYTE proto;
38 USHORT checksum;
39 ULONG source;
40 ULONG dest;
41 } IPv4_HEADER, *PIPv4_HEADER;
42
43 /* ICMP Header, 8 bytes */
44 typedef struct ICMPHeader
45 {
46 BYTE type;
47 BYTE code;
48 USHORT checksum;
49 USHORT id; // not used in time exceeded
50 USHORT seq; // not used in time exceeded
51 } ICMP_HEADER, *PICMP_HEADER;
52
53 /* ICMP Echo Reply Header, 12 bytes */
54 typedef struct EchoReplyHeader
55 {
56 struct ICMPHeader icmpheader;
57 struct timeval timestamp;
58 } ECHO_REPLY_HEADER, *PECHO_REPLY_HEADER;
59
60 /* ICMP Echo Reply Header, 12 bytes */
61 typedef struct TTLExceedHeader
62 {
63 struct ICMPHeader icmpheader;
64 struct IPv4Header ipheader;
65 struct ICMPHeader OrigIcmpHeader;
66 } TTL_EXCEED_HEADER, *PTTL_EXCEED_HEADER;
67
68 /* return to normal */
69 #include <poppack.h>
70
71 /* function definitions */
72 static BOOL ParseCmdline(int argc, char* argv[]);
73 static INT Driver(void);
74 static INT Setup(INT ttl);
75 static VOID SetupTimingMethod(void);
76 static VOID ResolveHostname(void);
77 static VOID PreparePacket(INT packetSize, USHORT seqNum);
78 static INT SendPacket(INT datasize);
79 static INT ReceivePacket(INT datasize);
80 static INT DecodeResponse(INT packetSize, USHORT seqNum);
81 static LONGLONG GetTime(void);
82 static WORD CheckSum(PUSHORT data, UINT size);
83 static VOID Usage(void);