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

📄 ethera2n.c

📁 minux的源代码,一个非常小的操作系统
💻 C
字号:
/*
ethera2n.c

Convert an ASCII string with an ethernet address into a struct ether_addr.

Created:	Nov 17, 1992 by Philip Homburg
*/

#include <sys/types.h>
#include <stdlib.h>
#include <net/netlib.h>
#include <net/gen/ether.h>
#include <net/gen/if_ether.h>

struct ether_addr *ether_aton(s)
char *s;
{
	static struct ether_addr ea;

	int i;
	long v;
	char *check;

	if (s == NULL)
		return NULL;

	for (i=0; i<6; i++)
	{
		v= strtol(s, &check, 16);
		if (v<0 || v>255)
			return NULL;
		if ((i<5 && check[0] != ':') || (i == 5 && check[0] != '\0'))
			return NULL;
		ea.ea_addr[i]= v;
		s= check+1;
	}
	return &ea;
}

⌨️ 快捷键说明

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