File:  [Research Unix] / researchv10no / netfs / libnetb / bsdgetpeer.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/*
 * who called me over a socket, 4BSD-style
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

char *
_rfbsdpeer(f)
int f;
{
	register struct hostent *hp;
	int len;
	struct sockaddr_in s;

	/*
	 * sleaze away, as UCB code usually does:
	 * assume it's internet family in various places
	 */
	len = sizeof(s);
	if (getpeername(f, &s, &len) < 0)
		return (0);
	if ((hp = gethostbyaddr(&s.sin_addr, sizeof(struct in_addr), s.sin_family)) == 0)
		return (0);
	return (hp->h_name);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.