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

📄 lib-libc-net

📁 被广泛使用的域名服务(DNS)软件
💻
📖 第 1 页 / 共 5 页
字号:
X  		return (&host);X  	} else {X  		h_errno = TRY_AGAIN;! 		return (NULL);X  	}X  }****************** 273,276 ****--- 378,389 ----X  X  	/*+ 	 * if there aren't any dots, it could be a user-level alias.+ 	 * this is also done in res_query() since we are not the only+ 	 * function that looks up host names.+ 	 */+ 	if (!strchr(name, '.') && (cp = __hostalias(name)))+ 		name = cp;+ + 	/*X  	 * disallow names consisting only of digits/dots, unlessX  	 * they end in a dot.****************** 288,292 ****X  				if (!inet_aton(name, &host_addr)) {X  					h_errno = HOST_NOT_FOUND;! 					return((struct hostent *) NULL);X  				}X  				host.h_name = (char *)name;--- 401,405 ----X  				if (!inet_aton(name, &host_addr)) {X  					h_errno = HOST_NOT_FOUND;! 					return (NULL);X  				}X  				host.h_name = (char *)name;****************** 294,300 ****X  				host_aliases[0] = NULL;X  				host.h_addrtype = AF_INET;! 				host.h_length = sizeof(u_int32_t);X  				h_addr_ptrs[0] = (char *)&host_addr;! 				h_addr_ptrs[1] = (char *)0;X  #if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */X  				host.h_addr_list = h_addr_ptrs;--- 407,413 ----X  				host_aliases[0] = NULL;X  				host.h_addrtype = AF_INET;! 				host.h_length = INT32SZ;X  				h_addr_ptrs[0] = (char *)&host_addr;! 				h_addr_ptrs[1] = NULL;X  #if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */X  				host.h_addr_list = h_addr_ptrs;****************** 302,305 ****--- 415,419 ----X  				host.h_addr = h_addr_ptrs[0];X  #endif+ 				h_errno = NETDB_SUCCESS;X  				return (&host);X  			}****************** 309,322 ****X  X  	if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) {! #ifdef DEBUG! 		if (_res.options & RES_DEBUG)! 			printf("res_search failed\n");! #endifX  		if (errno == ECONNREFUSED)X  			return (_gethtbyname(name));! 		else! 			return ((struct hostent *) NULL);X  	}! 	return (getanswer(&buf, n, 0));X  }X  --- 423,432 ----X  X  	if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) {! 		dprintf("res_search failed (%d)\n", n);X  		if (errno == ECONNREFUSED)X  			return (_gethtbyname(name));! 		return (NULL);X  	}! 	return (getanswer(&buf, n, name, C_IN, T_A));X  }X  ****************** 329,342 ****X  	querybuf buf;X  	register struct hostent *hp;! 	char qbuf[MAXDNAME];X  #ifdef SUNSECURITYX  	register struct hostent *rhp;X  	char **haddr;! 	u_int32_t old_options;! #endifX  	extern struct hostent *_gethtbyaddr();X  	! 	if (type != AF_INET)! 		return ((struct hostent *) NULL);X  	(void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",X  		((unsigned)addr[3] & 0xff),--- 439,456 ----X  	querybuf buf;X  	register struct hostent *hp;! 	char qbuf[MAXDNAME+1];X  #ifdef SUNSECURITYX  	register struct hostent *rhp;X  	char **haddr;! 	u_long old_options;! 	char hname2[MAXDNAME+1];! #endif /*SUNSECURITY*/X  	extern struct hostent *_gethtbyaddr();X  	! 	if (type != AF_INET) {! 		errno = EAFNOSUPPORT;! 		h_errno = NETDB_INTERNAL;! 		return (NULL);! 	}X  	(void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",X  		((unsigned)addr[3] & 0xff),****************** 344,394 ****X  		((unsigned)addr[1] & 0xff),X  		((unsigned)addr[0] & 0xff));! 	n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf));X  	if (n < 0) {! #ifdef DEBUG! 		if (_res.options & RES_DEBUG)! 			printf("res_query failed\n");! #endifX  		if (errno == ECONNREFUSED)X  			return (_gethtbyaddr(addr, len, type));! 		return ((struct hostent *) NULL);X  	}! 	hp = getanswer(&buf, n, 1);! 	if (hp == NULL)! 		return ((struct hostent *) NULL);X  #ifdef SUNSECURITYX  	/*! 	 * Turn off search as the name should be absolute,! 	 * 'localhost' should be matched by defnames.X  	 */X  	old_options = _res.options;X  	_res.options &= ~RES_DNSRCH;! 	if ((rhp = gethostbyname(hp->h_name)) == NULL) {X  		syslog(LOG_NOTICE|LOG_AUTH,! 		    "gethostbyaddr: No A record for %s", hp->h_name);X  		_res.options = old_options;X  		return (NULL);X  	}X  	_res.options = old_options;! 	for (haddr = hp->h_addr_list; *haddr != NULL; haddr++)! 		if (!memcmp(*haddr, addr, len))X  			break;! 	if (*haddr == NULL) {X  		syslog(LOG_NOTICE|LOG_AUTH,! 		    "gethostbyaddr: A record of %s != PTR record [%s]",! 		    hp->h_name, inet_ntoa(*((struct in_addr *)addr)));X  		h_errno = HOST_NOT_FOUND;X  		return (NULL);X  	}! #endifX  	hp->h_addrtype = type;X  	hp->h_length = len;X  	h_addr_ptrs[0] = (char *)&host_addr;! 	h_addr_ptrs[1] = (char *)0;X  	host_addr = *(struct in_addr *)addr;! #if BSD < 43 && !defined(h_addr)	/* new-style hostent structure */! 	hp->h_addr = h_addr_ptrs[0];! #endif! 	return(hp);X  }X  --- 458,507 ----X  		((unsigned)addr[1] & 0xff),X  		((unsigned)addr[0] & 0xff));! 	n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf);X  	if (n < 0) {! 		dprintf("res_query failed (%d)\n", n);X  		if (errno == ECONNREFUSED)X  			return (_gethtbyaddr(addr, len, type));! 		return (NULL);X  	}! 	if (!(hp = getanswer(&buf, n, qbuf, C_IN, T_PTR)))! 		return (NULL);	/* h_errno was set by getanswer() */X  #ifdef SUNSECURITYX  	/*! 	 * turn off search as the name should be absolute,! 	 * 'localhost' should be matched by defnamesX  	 */+ 	strncpy(hname2, hp->h_name, MAXDNAME);+ 	hname2[MAXDNAME] = '\0';X  	old_options = _res.options;X  	_res.options &= ~RES_DNSRCH;! 	_res.options |= RES_DEFNAMES;! 	if (!(rhp = gethostbyname(hp->h_name))) {X  		syslog(LOG_NOTICE|LOG_AUTH,! 		       "gethostbyaddr: No A record for %s (verifying [%s])",! 		       hname2, inet_ntoa(*((struct in_addr *)addr)));X  		_res.options = old_options;+ 		h_errno = HOST_NOT_FOUND;X  		return (NULL);X  	}X  	_res.options = old_options;! 	for (haddr = rhp->h_addr_list; *haddr; haddr++)! 		if (!memcmp(*haddr, addr, INADDRSZ))X  			break;! 	if (!*haddr) {X  		syslog(LOG_NOTICE|LOG_AUTH,! 		       "gethostbyaddr: A record of %s != PTR record [%s]",! 		       hname2, inet_ntoa(*((struct in_addr *)addr)));X  		h_errno = HOST_NOT_FOUND;X  		return (NULL);X  	}! #endif /*SUNSECURITY*/X  	hp->h_addrtype = type;X  	hp->h_length = len;X  	h_addr_ptrs[0] = (char *)&host_addr;! 	h_addr_ptrs[1] = NULL;X  	host_addr = *(struct in_addr *)addr;! 	h_errno = NETDB_SUCCESS;! 	return (hp);X  }X  ****************** 397,401 ****X  	int f;X  {! 	if (hostf == NULL)X  		hostf = fopen(_PATH_HOSTS, "r" );X  	else--- 510,514 ----X  	int f;X  {! 	if (!hostf)X  		hostf = fopen(_PATH_HOSTS, "r" );X  	else****************** 419,444 ****X  	register char *cp, **q;X  ! 	if (hostf == NULL && (hostf = fopen(_PATH_HOSTS, "r" )) == NULL)X  		return (NULL);X  again:! 	if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL)X  		return (NULL);X  	if (*p == '#')X  		goto again;! 	cp = strpbrk(p, "#\n");! 	if (cp == NULL)X  		goto again;X  	*cp = '\0';! 	cp = strpbrk(p, " \t");! 	if (cp == NULL)X  		goto again;X  	*cp++ = '\0';X  	/* THIS STUFF IS INTERNET SPECIFIC */X  #if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */! 	host.h_addr_list = host_addrs;X  #endif! 	host.h_addr = hostaddr;! 	*((u_int32_t *)host.h_addr) = inet_addr(p);! 	host.h_length = sizeof (u_int32_t);X  	host.h_addrtype = AF_INET;X  	while (*cp == ' ' || *cp == '\t')--- 532,563 ----X  	register char *cp, **q;X  ! 	if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {! 		h_errno = NETDB_INTERNAL;X  		return (NULL);+ 	}X  again:! 	if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {! 		h_errno = HOST_NOT_FOUND;X  		return (NULL);+ 	}X  	if (*p == '#')X  		goto again;! 	if (!(cp = strpbrk(p, "#\n")))X  		goto again;X  	*cp = '\0';! 	if (!(cp = strpbrk(p, " \t")))X  		goto again;X  	*cp++ = '\0';X  	/* THIS STUFF IS INTERNET SPECIFIC */+ 	if (!inet_aton(p, &host_addr))+ 		goto again;+ 	h_addr_ptrs[0] = (char *)&host_addr;+ 	h_addr_ptrs[1] = NULL;X  #if BSD >= 43 || defined(h_addr)	/* new-style hostent structure */! 	host.h_addr_list = h_addr_ptrs;! #else! 	host.h_addr = h_addr_ptrs[0];X  #endif! 	host.h_length = INT32SZ;X  	host.h_addrtype = AF_INET;X  	while (*cp == ' ' || *cp == '\t')****************** 446,451 ****X  	host.h_name = cp;X  	q = host.h_aliases = host_aliases;! 	cp = strpbrk(cp, " \t");! 	if (cp != NULL) X  		*cp++ = '\0';X  	while (cp && *cp) {--- 565,569 ----X  	host.h_name = cp;X  	q = host.h_aliases = host_aliases;! 	if (cp = strpbrk(cp, " \t"))X  		*cp++ = '\0';X  	while (cp && *cp) {****************** 456,464 ****X  		if (q < &host_aliases[MAXALIASES - 1])X  			*q++ = cp;! 		cp = strpbrk(cp, " \t");! 		if (cp != NULL)X  			*cp++ = '\0';X  	}X  	*q = NULL;X  	return (&host);X  }--- 574,582 ----X  		if (q < &host_aliases[MAXALIASES - 1])X  			*q++ = cp;! 		if (cp = strpbrk(cp, " \t"))X  			*cp++ = '\0';X  	}X  	*q = NULL;+ 	h_errno = NETDB_SUCCESS;X  	return (&host);X  }****************** 500,520 ****X  X  #ifdef RESOLVSORT! static int! qcomp(v1, v2)! 	void *v1, *v2;X  {! 	struct in_addr **a1 = (struct in_addr **)v1;! 	struct in_addr **a2 = (struct in_addr **)v2;! 	int pos1, pos2;! ! 	for (pos1 = 0; pos1 < _res.nsort; pos1++)! 		if (_res.sort_list[pos1].addr.s_addr == ! 		    ((*a1)->s_addr & _res.sort_list[pos1].mask))X  			break;! 	for (pos2 = 0; pos2 < _res.nsort; pos2++)! 		if (_res.sort_list[pos2].addr.s_addr == ! 		    ((*a2)->s_addr & _res.sort_list[pos2].mask))! 			break;! 	return (pos1 - pos2);X  }X  #endif--- 618,662 ----X  X  #ifdef RESOLVSORT! static void! addrsort(ap, num)! 	char **ap;! 	int num;X  {! 	int i, j;! 	char **p;! 	short aval[MAXADDRS];! 	int needsort = 0;! ! 	p = ap;! 	for (i = 0; i < num; i++, p++) {! 	    for (j = 0 ; j < _res.nsort; j++)! 		if (_res.sort_list[j].addr.s_addr == ! 		    (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask))X  			break;! 	    aval[i] = j;! 	    if (needsort == 0 && i > 0 && j < aval[i-1])! 		needsort = i;! 	}! 	if (!needsort)! 	    return;! ! 	while (needsort < num) {! 	    for (j = needsort - 1; j >= 0; j--) {! 		if (aval[j] > aval[j+1]) {! 		    char *hp;! ! 		    i = aval[j];! 		    aval[j] = aval[j+1];! 		    aval[j+1] = i;! ! 		    hp = ap[j];! 		    ap[j] = ap[j+1];! 		    ap[j+1] = hp;! ! 		} else! 		    break;! 	    }! 	    needsort++;! 	}X  }X  #endif*** ../net-2.0b1/getnetbyaddr.c	Mon Nov  7 10:54:16 1994--- getnetbyaddr.c	Sun Dec 11 18:32:14 1994****************** 36,39 ****--- 36,41 ----X  #if defined(LIBC_SCCS) && !defined(lint)X  static char sccsid[] = "@(#)getnetbyaddr.c	8.1 (Berkeley) 6/4/93";+ static char sccsid_[] = "from getnetbyaddr.c	1.1 (Coimbra) 93/06/02";+ static char rcsid[] = "=Id: getnetbyaddr.c,v 1.4 1993/11/12 01:23:34 vixie Exp =";X  #endif /* LIBC_SCCS and not lint */X  *** ../net-2.0b1/getnetbyname.c	Mon Nov  7 10:54:17 1994--- getnetbyname.c	Mon Dec 12 01:28:13 1994****************** 36,39 ****--- 36,41 ----X  #if defined(LIBC_SCCS) && !defined(lint)X  static char sccsid[] = "@(#)getnetbyname.c	8.1 (Berkeley) 6/4/93";+ static char sccsid_[] = "from getnetbyname.c	1.1 (Coimbra) 93/06/02";+ static char rcsid[] = "=Id: getnetbyname.c,v 1.6 1994/05/31 01:49:35 vixie Exp =";X  #endif /* LIBC_SCCS and not lint */X  ****************** 52,59 ****X  	setnetent(_net_stayopen);X  	while (p = getnetent()) {! 		if (strcmp(p->n_name, name) == 0)X  			break;X  		for (cp = p->n_aliases; *cp != 0; cp++)! 			if (strcmp(*cp, name) == 0)X  				goto found;X  	}--- 54,61 ----X  	setnetent(_net_stayopen);X  	while (p = getnetent()) {! 		if (strcasecmp(p->n_name, name) == 0)X  			break;X  		for (cp = p->n_aliases; *cp != 0; cp++)! 			if (strcasecmp(*cp, name) == 0)X  				goto found;X  	}*** ../net-2.0b1/getnetnamadr.c	Mon Nov  7 10:54:21 1994--- getnetnamadr.c	Mon Dec 12 01:36:59 1994****************** 43,47 ****X  #if defined(LIBC_SCCS) && !defined(lint)X  static char sccsid[] = "@(#)getnetnamadr.c	1.4 (Coimbra) 93/06/03";! static char rcsid[] = "=Id: getnetnamadr.c,v 1.3 1993/11/12 01:23:34 vixie Exp =";X  #endif /* LIBC_SCCS and not lint */X  --- 43,47 ----X  #if defined(LIBC_SCCS) && !defined(lint)X  static char sccsid[] = "@(#)getnetnamadr.c	1.4 (Coimbra) 93/06/03";! static char rcsid[] = "=Id: getnetnamadr.c,v 1.10 1994/12/01 09:38:18 vixie Exp vixie =";X  #endif /* LIBC_SCCS and not lint */X  ****************** 63,66 ****--- 63,68 ----X  struct netent *_getnetbyname __P((const char *name));X  + #define DEBUG 1+ X  #define BYADDR 0X  #define BYNAME 1****************** 89,107 ****X  	int net_i;X  {X  	register HEADER *hp;X  	register u_char *cp;X  	register int n;X  	u_char *eom;! 	int type, class, buflen, ancount, qdcount;! 	int haveanswer, i, nchar;! 	int getclass = C_ANY;! 	int net_length = 0;! 	char aux1[30], aux2[30], ans[30];! 	char *in, *st, *pauxt, *bp, **ap;! 	char *paux1 = &aux1[0];! 	char *paux2 = &aux2[0];! 	char flag = 0;! 	static struct netent net_entry;! 	static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];X  X  	/*--- 91,105 ----X  	int net_i;X  {+ X  	register HEADER *hp;X  	register u_char *cp;X  	register int n;X  	u_char *eom;! 	int type, class, buflen, ancount, qdcount, haveanswer, i, nchar,! 		getclass = C_ANY, net_length = 0;! 	char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap,! 		*paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;! static	struct netent net_entry;! static	char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];X  X  	/******************* 125,129 ****X  	bp = netbuf;X  	buflen = sizeof(netbuf);! 	cp = answer->buf + sizeof(HEADER);X  	if (!qdcount) {X  		if (hp->aa)--- 123,127 ----X  	bp = netbuf;X  	buflen = sizeof(netbuf);! 	cp = answer->buf + HFIXEDSZ;X  	if (!qdcount) {X  		if (hp->aa)

⌨️ 快捷键说明

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