如何获的关于ip,icmp等在winsock中的结构定义

oddstar 2000-03-10 09:44:00
我想在socket函数中用RAW参数,可我不知道ip,icmp,arp等的结构定义
...全文
235 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
王释之 2000-03-16
  • 打赏
  • 举报
回复
可以给我一份吗?谢谢! befresh@263.net
shuke 2000-03-12
  • 打赏
  • 举报
回复
struct arp {
short ar_hwtype; /* hardware type */
short ar_prtype; /* protocol type */
char ar_hwlen; /* hardware address length */
char ar_prlen; /* protocol address length */
short ar_op; /* ARP operation (see list above) */
char ar_addrs[1];/* sender and target hw & proto addrs */
/* char ar_sha[???]; /* sender's physical hardware address */
/* char ar_spa[???]; /* sender's protocol address (IP addr.) */
/* char ar_tha[???]; /* target's physical hardware address */
/* char ar_tpa[???]; /* target's protocol address (IP) */
};



struct ip {
char ip_verlen; /* IP version & header length (in longs)*/
char ip_tos; /* type of service */
short ip_len; /* total packet length (in octets) */
short ip_id; /* datagram id */
short ip_fragoff; /* fragment offset (in 8-octet's) */
char ip_ttl; /* time to live, in gateway hops */
char ip_proto; /* IP protocol (see IPT_* above) */
short ip_cksum; /* header checksum */
IPaddr ip_src; /* IP address of source */
IPaddr ip_dst; /* IP address of destination */
char ip_data[1]; /* variable length data */
};


struct icmp { /* ICMP packet */
char ic_type; /* type of message (ICT_* above)*/
char ic_code; /* code (ICC_* above) */
short ic_cksum; /* checksum of ICMP header+data */

union {
struct {
short ic1_id; /* for echo type, a message id */
short ic1_seq;/* for echo type, a seq. number */
} ic1;
IPaddr ic2_gw; /* for redirect, gateway */
struct {
char ic3_ptr;/* pointer, for ICT_PARAMP */
char ic3_pad[IC_PADLEN];
} ic3;
int ic4_mbz; /* must be zero */
} icu;
char ic_data[1]; /* data area of ICMP message */
};

RealTop 2000-03-11
  • 打赏
  • 举报
回复
icmp包结构
用C语言大致描述为:
typedef struct _tag_ICMP
{
BYTE PacketType;
WORD CheckSum;
WORD Identifier;
WORD SequenceNumber;
BYTE Data[];
}ICMP_PACKET;
如果需要我帮忙,MailTo:RealTop@21cn.com
oddstar 2000-03-10
  • 打赏
  • 举报
回复
king请发到oddstar@sohu.com
King 2000-03-10
  • 打赏
  • 举报
回复
我翻译了一篇ICMP数据包结构,要不要寄给你?要原文也可以,不过是E文

4,356

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧