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

📄 hw.c

📁 一个基于linux的TCP/IP协议栈的实现
💻 C
字号:
/* hw.c * linqianghe@163.com * 2006-10-20 */#include "net-support.h"#include <stdio.h>#include <string.h>static short sVhwinit = 0;extern struct hwtype unspec_hwtype;extern struct hwtype loop_hwtype;extern struct hwtype ether_hwtype;static struct hwtype *hwtypes[] ={	&loop_hwtype,	&ether_hwtype,	&unspec_hwtype,    NULL};void hwinit(){	loop_hwtype.title = "Local Loopback";	unspec_hwtype.title = "UNSPEC";	ether_hwtype.title = "Ethernet";	sVhwinit = 1;}struct hwtype *get_hwntype(int type){	struct hwtype **hwp;	if( !sVhwinit )		hwinit();	hwp = hwtypes;	while( *hwp != NULL ){		if( (*hwp)->type == type )			return (*hwp);		hwp++;	}	return (NULL);}int hw_null_address(struct hwtype *hw, void *ap){	unsigned int i;	unsigned char *address = (unsigned char *)ap;	for (i = 0; i < hw->alen; i++)		if( address[i] )			return 0;	return 1;}void print_hwlist(int type) {	int count = 0;	char * txt;	struct hwtype **hwp;	if (!sVhwinit)		hwinit();	hwp = hwtypes;	while( *hwp != NULL ){		if( ((type == 1) && ((*hwp)->alen == 0)) || ((*hwp)->type == -1) ){			hwp++; 			continue;		}		if ((count % 3) == 0) fprintf(stderr,count?"\n    ":"    ");		txt = (*hwp)->name; if (!txt) txt = "..";		fprintf(stderr,"%s (%s) ",txt,(*hwp)->title);		count++;		hwp++;	}	fprintf(stderr,"\n");}struct hwtype *get_hwtype(const char *name){	struct hwtype **hwp;	if( !sVhwinit )		hwinit();	hwp = hwtypes;	while( *hwp != NULL ){		if( !strcmp((*hwp)->name, name) )			return (*hwp);		hwp++;	}	return (NULL);}

⌨️ 快捷键说明

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