Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/socket.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
#ifdef APPEND_DOT | #ifdef APPEND_DOT | ||||
/* | /* | ||||
* Speed up DNS lookups by terminating the host name with a dot. Should be | * Speed up DNS lookups by terminating the host name with a dot. Should be | ||||
* done with care. The speedup can give problems with lookups from sources | * done with care. The speedup can give problems with lookups from sources | ||||
* that lack DNS-style trailing dot magic, such as local files or NIS maps. | * that lack DNS-style trailing dot magic, such as local files or NIS maps. | ||||
*/ | */ | ||||
static struct hostent *gethostbyname_dot(name) | static struct hostent *gethostbyname_dot(char *name) | ||||
char *name; | |||||
{ | { | ||||
char dot_name[MAXHOSTNAMELEN + 1]; | char dot_name[MAXHOSTNAMELEN + 1]; | ||||
/* | /* | ||||
* Don't append dots to unqualified names. Such names are likely to come | * Don't append dots to unqualified names. Such names are likely to come | ||||
* from local hosts files or from NIS. | * from local hosts files or from NIS. | ||||
*/ | */ | ||||
if (strchr(name, '.') == 0 || strlen(name) >= MAXHOSTNAMELEN - 1) { | if (strchr(name, '.') == 0 || strlen(name) >= MAXHOSTNAMELEN - 1) { | ||||
return (gethostbyname(name)); | return (gethostbyname(name)); | ||||
} else { | } else { | ||||
sprintf(dot_name, "%s.", name); | sprintf(dot_name, "%s.", name); | ||||
return (gethostbyname(dot_name)); | return (gethostbyname(dot_name)); | ||||
} | } | ||||
} | } | ||||
#define gethostbyname gethostbyname_dot | #define gethostbyname gethostbyname_dot | ||||
#endif | #endif | ||||
/* sock_host - look up endpoint addresses and install conversion methods */ | /* sock_host - look up endpoint addresses and install conversion methods */ | ||||
void sock_host(request) | void sock_host(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
static struct sockaddr_storage client; | static struct sockaddr_storage client; | ||||
static struct sockaddr_storage server; | static struct sockaddr_storage server; | ||||
#else | #else | ||||
static struct sockaddr_in client; | static struct sockaddr_in client; | ||||
static struct sockaddr_in server; | static struct sockaddr_in server; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | #ifdef INET6 | ||||
request->server->sin = (struct sockaddr *)&server; | request->server->sin = (struct sockaddr *)&server; | ||||
#else | #else | ||||
request->server->sin = &server; | request->server->sin = &server; | ||||
#endif | #endif | ||||
} | } | ||||
/* sock_hostaddr - map endpoint address to printable form */ | /* sock_hostaddr - map endpoint address to printable form */ | ||||
void sock_hostaddr(host) | void sock_hostaddr(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct sockaddr *sin = host->sin; | struct sockaddr *sin = host->sin; | ||||
int salen; | int salen; | ||||
if (!sin) | if (!sin) | ||||
return; | return; | ||||
#ifdef SIN6_LEN | #ifdef SIN6_LEN | ||||
Show All 9 Lines | #else | ||||
if (sin != 0) | if (sin != 0) | ||||
STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr)); | STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr)); | ||||
#endif | #endif | ||||
} | } | ||||
/* sock_hostname - map endpoint address to host name */ | /* sock_hostname - map endpoint address to host name */ | ||||
void sock_hostname(host) | void sock_hostname(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct sockaddr *sin = host->sin; | struct sockaddr *sin = host->sin; | ||||
struct sockaddr_in sin4; | struct sockaddr_in sin4; | ||||
struct addrinfo hints, *res, *res0 = NULL; | struct addrinfo hints, *res, *res0 = NULL; | ||||
int salen, alen, err = 1; | int salen, alen, err = 1; | ||||
char *ap = NULL, *rap, hname[NI_MAXHOST]; | char *ap = NULL, *rap, hname[NI_MAXHOST]; | ||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |