enetdump.c

来自「网友张巍提供的tcpip协议栈,是一个成功稳定的以太网接口上的TCP/IP协议程」· C语言 代码 · 共 51 行

C
51
字号
/* Ethernet header tracing routines
 */
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "enet.h"
#include "trace.h"

void
ether_dump(
FILE *fp,
struct mbuf **bpp,
int check	/* Not used */
){
	struct ether ehdr;
	char s[20],d[20];

	ntohether(&ehdr,bpp);
	pether(s,ehdr.source);
	pether(d,ehdr.dest);
	fprintf(fp,"Ether: len %u %s->%s",ETHERLEN + len_p(*bpp),s,d);

	switch(ehdr.type){
		case IP_TYPE:
			fprintf(fp," type IP\n");
			ip_dump(fp,bpp,1);
			break;
		case REVARP_TYPE:
			fprintf(fp," type REVARP\n");
			arp_dump(fp,bpp);
			break;
		case ARP_TYPE:
			fprintf(fp," type ARP\n");
			arp_dump(fp,bpp);
			break;
		default:
			fprintf(fp," type 0x%x\n",ehdr.type);
			break;
	}
}
int
ether_forus(struct iface *iface,struct mbuf *bp)
{
	/* Just look at the multicast bit */

	if(bp->data[0] & 1)
		return 0;
	else
		return 1;
}

⌨️ 快捷键说明

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