unix.c

来自「一个基于linux的TCP/IP协议栈的实现」· C语言 代码 · 共 43 行

C
43
字号
/* unix.c * linqianghe@163.com * 2006-10-20 */#include "util.h"#include "net-support.h"#include <linux/socket.h>#include <stdio.h>#include <string.h>static char *UNSPEC_print(unsigned char *ptr){	static char buff[64];	char *pos;	unsigned int i;	pos = buff;	for (i = 0; i < sizeof(struct sockaddr); i++) {		pos += sprintf(pos, "%02X-", (*ptr++ & 0377));	}	buff[strlen(buff) - 1] = '\0';	return (buff);}static char *UNSPEC_sprint(struct sockaddr *sap, int numeric){	static char buf[64];	if (sap->sa_family == 0xFFFF || sap->sa_family == 0)		return safe_strncpy( buf, "[NONE SET]", sizeof(buf) );	return ( UNSPEC_print((unsigned char *)sap->sa_data) );}struct aftype unspec_aftype ={	"unspec", NULL, AF_UNSPEC, 0,	UNSPEC_print, UNSPEC_sprint, NULL, NULL,	NULL,};

⌨️ 快捷键说明

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