start to redo tracert

svn path=/trunk/; revision=26277
This commit is contained in:
Ged Murphy 2007-04-07 15:09:57 +00:00
parent 78117fc10d
commit 2ee0f4dca0
2 changed files with 659 additions and 689 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,24 +1,24 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS traceroute utility
* FILE: apps/utils/net/tracert/tracert.h
* PURPOSE: trace a packets route through a network
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
* REVISIONS:
* GM 03/05/05 Created
*/
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <ws2tcpip.h>
#include <string.h>
#include <time.h>
#define ECHO_REPLY 0
#define DEST_UNREACHABLE 3
#define ECHO_REQUEST 8
#define TTL_EXCEEDED 11
#define ICMP_MIN_SIZE 8
#define ICMP_MAX_SIZE 65535
#define MAX_PING_PACKET_SIZE 1024
#define MAX_PING_DATA_SIZE (MAX_PING_PACKET_SIZE + sizeof(IPv4Header)
#define PACKET_SIZE 32
#define ICMP_MIN_SIZE 8
/* we need this for packets which have the 'dont fragment'
* bit set, as they can get quite large otherwise
* (I've seen some reach 182 bytes */
* bit set, as they can get quite large otherwise */
#define MAX_REC_SIZE 200
/* pack the structures */
@ -65,19 +65,24 @@ typedef struct TTLExceedHeader
struct ICMPHeader OrigIcmpHeader;
} TTL_EXCEED_HEADER, *PTTL_EXCEED_HEADER;
/* return to normal */
#include <poppack.h>
/* function definitions */
static BOOL ParseCmdline(int argc, char* argv[]);
static INT Driver(void);
static INT Setup(INT ttl);
static VOID SetupTimingMethod(void);
static VOID ResolveHostname(void);
static VOID PreparePacket(INT packetSize, USHORT seqNum);
static INT SendPacket(INT datasize);
static INT ReceivePacket(INT datasize);
static INT DecodeResponse(INT packetSize);
static LONGLONG GetTime(void);
static WORD CheckSum(PUSHORT data, UINT size);
static VOID Usage(void);
typedef struct _APPINFO
{
SOCKET icmpSock; // socket descriptor
SOCKADDR_IN source, dest; // source and destination address info
PECHO_REPLY_HEADER SendPacket; // ICMP echo packet
PIPv4_HEADER RecvPacket; // return reveive packet
BOOL bUsePerformanceCounter; // whether to use the high res performance counter
LARGE_INTEGER TicksPerMs; // number of millisecs in relation to proc freq
LARGE_INTEGER TicksPerUs; // number of microsecs in relation to proc freq
LONGLONG lTimeStart; // send packet, timer start
LONGLONG lTimeEnd; // receive packet, timer end
BOOL bResolveAddresses; // -d MS ping defaults to true.
INT iMaxHops; // -h Max number of hops before trace ends
INT iHostList; // -j Source route
INT iTimeOut; // -w time before packet times out
} APPINFO, *PAPPINFO;