⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proc_v6.c

📁 Unix网络编程 基于Socket的网络编程
💻 C
字号:
#include	"ping.h"voidproc_v6(char *ptr, ssize_t len, struct timeval* tvrecv){#ifdef	IPV6	int					hlen1, icmp6len;	double				rtt;	struct ip6_hdr		*ip6;	struct icmp6_hdr	*icmp6;	struct timeval		*tvsend;	ip6 = (struct ip6_hdr *) ptr;		/* start of IPv6 header */	hlen1 = sizeof(struct ip6_hdr);	if (ip6->ip6_nxt != IPPROTO_ICMPV6)		err_quit("next header not IPPROTO_ICMPV6");	icmp6 = (struct icmp6_hdr *) (ptr + hlen1);	if ( (icmp6len = len - hlen1) < 8)		err_quit("icmp6len (%d) < 8", icmp6len);	if (icmp6->icmp6_type == ICMP6_ECHO_REPLY) {		if (icmp6->icmp6_id != pid)			return;			/* not a response to our ECHO_REQUEST */		if (icmp6len < 16)			err_quit("icmp6len (%d) < 16", icmp6len);		tvsend = (struct timeval *) (icmp6 + 1);		tv_sub(tvrecv, tvsend);		rtt = tvrecv->tv_sec * 1000.0 + tvrecv->tv_usec / 1000.0;		printf("%d bytes from %s: seq=%u, hlim=%d, rtt=%.3f ms\n",				icmp6len, Sock_ntop_host(pr->sarecv, pr->salen),				icmp6->icmp6_seq, ip6->ip6_hlim, rtt);	} else if (verbose) {		printf("  %d bytes from %s: type = %d, code = %d\n",				icmp6len, Sock_ntop_host(pr->sarecv, pr->salen),				icmp6->icmp6_type, icmp6->icmp6_code);	}#endif	/* IPV6 */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -