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

📄 af.c

📁 一个基于linux的TCP/IP协议栈的实现
💻 C
字号:
/* af.c * linqianghe@163.com * 2006-10-20 */#include "net-support.h"#include <stdio.h>#include <string.h>static short sVafinit = 0;extern struct aftype unspec_aftype;extern struct aftype myinet_aftype;struct aftype *aftypes[] ={    &myinet_aftype,	&unspec_aftype,	NULL};void afinit(){	unspec_aftype.title = "UNSPEC";	myinet_aftype.title = "DARPA Internet";	sVafinit = 1;}struct aftype *get_afntype(int af){	struct aftype **afp;	if( !sVafinit )		afinit();	afp = aftypes;	while( *afp != NULL ){		if( (*afp)->af == af )			return (*afp);		afp++;	}	return ( NULL );}int get_socket_for_af(int af){	struct aftype **afp;	if (!sVafinit)		afinit();	afp = aftypes;	while( *afp != NULL ){		if ((*afp)->af == af)			return (*afp)->fd;		afp++;	}	return -1;}void print_aflist(int type) {	int count = 0;	char * txt;	struct aftype **afp;	if (!sVafinit)		afinit();	afp = aftypes;	while( *afp != NULL ){		if( (type == 1 && ((*afp)->rprint == NULL)) || ((*afp)->af == 0) ){			afp++; 			continue;		}		if( (count % 3) == 0 ) fprintf(stderr,count?"\n    ":"    ");		txt = (*afp)->name; if (!txt) txt = "..";		fprintf(stderr,"%s (%s) ",txt,(*afp)->title);		count++;		afp++;	}	fprintf(stderr,"\n");}struct aftype *get_aftype(const char *name){	struct aftype **afp;	if (!sVafinit)		afinit();	afp = aftypes;	while (*afp != NULL) {		if( !strcmp((*afp)->name, name) )			return (*afp);		afp++;	}	if (index(name, ','))		fprintf(stderr, "Please don't supply more than one address family.\n");	return (NULL);}

⌨️ 快捷键说明

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