#pragma pack(4)
//#include "stdafx.h"
#pragma comment (lib,"Ws2_32.lib")
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#include
#include
#include
#include
typedef struct iphdr
{
unsigned int headlen:4;
unsigned int version:4;
unsigned char tos;
unsigned short totallen;
unsigned short id;
unsigned short falg;
unsigned char ttl;
unsigned char prot;
unsigned short checksum;
unsigned int sourceIP;
unsigned int destIP;
}IpHeader;
typedef struct icmphdr
{
BYTE type;
BYTE code;
USHORT checksum;
USHORT id;
USHORT seg;
}IcmpHeader;
#define ICMP_RCHO 8
#define ICMP_RCHO_REPLY 0
#define ICMP_MIN 8
#define STATUS_FAILED 0xFFFF
#define DEF_PACKET_SIZE 32
#define MAX_PACKET 1024
#define MAX_PING_PACKET_SIZE (MAX_PACKET+sizeof(IpHeader))
void fill_icmp_data(char *,int);
USHORT checksum(USHORT *,int);
void decode_resp(char *,int,struct sockaddr_in *);
DWORD WINAPI FindIP(LPVOID pIPAddrTemp);
WSADATA wsaData;
SOCKET sockRaw;
struct sockaddr_in dest,from,end;
int fromlen =sizeof(from);
char *recvbuf=new char[MAX_PING_PACKET_SIZE];
unsigned int addr=0;
long ThreadNumCounter=0,ThreadNumLimit=20;
long *aa=&ThreadNumCounter;
void main(int argc,char *argv[])
{
/*if(argc!=3)
{
cout<<"输入格式错误: start_ip end_ip"<
2021-12-02 18:28:07
6KB
C程序
1