File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / libntp / socktohost.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

/*
 * socktoa - return a numeric host name from a sockaddr_storage structure
 */
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

#include <arpa/inet.h>

#include <stdio.h>

#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"


char *
socktohost(
	const sockaddr_u *sock
	)
{
	register char *buffer;

	LIB_GETBUF(buffer);
	if (getnameinfo(&sock->sa, SOCKLEN(sock), buffer,
	    LIB_BUFLENGTH, NULL, 0, 0))
		return stoa(sock);

	return buffer;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>