考试网 >> IT认证 >> 微软 >> MCSE指导 >> 微软ping命令的源代码

微软ping命令的源代码

发布时间:2006-06-28 06:09     点击:
分页:[1] 2 3  下一页

 ping.c - Simple ping utility using SOCK_RAW

*

* This is a part of the Microsoft Source Code Samples.

* Copyright 1996-1997 Microsoft Corporation.

* All rights reserved.

* This source code is only intended as a supplement to

* Microsoft Development Tools and/or WinHelp documentation.

* See these sources for detailed information regarding the

* Microsoft samples programs.

\******************************************************************************/

#pragma pack(4)

#define WIN32_LEAN_AND_MEAN

#include

#include

#include

#define ICMP_ECHO 8

#define ICMP_ECHOREPLY 0

#define ICMP_MIN 8 // minimum 8 byte icmp packet (just header)

/* The IP header */

typedef struct iphdr {

unsigned int h_len:4; // length of the header

unsigned int version:4; // Version of IP

unsigned char tos; // Type of service

unsigned short total_len; // total length of the packet

unsigned short ident; // unique identifier

unsigned short frag_and_flags; // flags

unsigned char ttl;

unsigned char proto; // protocol (TCP, UDP etc)

unsigned short checksum; // IP checksum

unsigned int sourceIP;

unsigned int destIP;

}IpHeader;

//

// ICMP header

//

typedef struct _ihdr {

BYTE i_type;

BYTE i_code; /* type sub code */

USHORT i_cksum;

USHORT i_id;

USHORT i_seq;

/* This is not the std header, but we reserve space for time */

ULONG timestamp;

}IcmpHeader;

#define STATUS_FAILED 0xFFFF

#define DEF_PACKET_SIZE 32
分页:[1] 2 3  下一页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有