透析ICMP协议(三): 牛刀初试之一 应用篇ping(ICMP.dll)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 bugfree 的 blog

                int(lobyte(loword(pipe->address))) << "." <<
                int(hibyte(loword(pipe->address))) << "." <<
                int(lobyte(hiword(pipe->address))) << "." <<
                int(hibyte(hiword(pipe->address))) << ", " <<
                "rtt: " << int(pipe->roundtriptime) << "ms, " <<
                "ttl: " << int(pipe->options.ttl) << endl;
    }
    else {
        cerr << "error obtaining info from ping packet." << endl;
    }

    // 关闭,回收资源
    globalfree(pipe);
    freelibrary(hicmp);
    return 0;
}
==================主函数==================
int main(int argc, char* argv[])
{
    wsadata wsadata;
    if (wsastartup(makeword(1, 1), &wsadata) != 0) {
        return 255;
    }

    int retval = doit(argc, argv);

    wsacleanup();
    return retval;
}

==================头文件==================
icmpdefs.h
//icmp.dll 函数中需要的结构


typedef struct {
    unsigned char ttl;                         // time to live
    unsigned char tos;                         // type of service
    unsigned char flags;                       // ip header flags
    unsigned char optionssize;                 // size in bytes of options data
    unsigned char *optionsdata;                // pointer to options data
} ip_option_information, * pip_option_information;

typedef struct {
    dword address;                             // replying address
    unsigned long  status;                     // reply status
    unsigned long  roundtriptime;              // rtt in milliseconds
    unsigned short datasize;                   // echo data size
    unsigned short reserved;                   // reserved for system use
    void *data;                                // pointer to the echo data
    ip_option_information options;             // reply options
} ip_echo_reply, * pip_echo_reply;
  

链接:
-------
我的其它文章,<<透析icmp协议>>, 和其它文章参见:
http://www.csdn.net/develop/author/netauthor/bugfree/

联系方式:
-------

本文关键:ICMP ping tracert
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top