Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/tli.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
static void tli_hostname(); | static void tli_hostname(); | ||||
static void tli_hostaddr(); | static void tli_hostaddr(); | ||||
static void tli_cleanup(); | static void tli_cleanup(); | ||||
static char *tli_error(); | static char *tli_error(); | ||||
static void tli_sink(); | static void tli_sink(); | ||||
/* tli_host - look up endpoint addresses and install conversion methods */ | /* tli_host - look up endpoint addresses and install conversion methods */ | ||||
void tli_host(request) | void tli_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 All 37 Lines | #endif | ||||
request->hostname = tli_hostname; | request->hostname = tli_hostname; | ||||
request->hostaddr = tli_hostaddr; | request->hostaddr = tli_hostaddr; | ||||
request->cleanup = tli_cleanup; | request->cleanup = tli_cleanup; | ||||
} | } | ||||
} | } | ||||
/* tli_cleanup - cleanup some dynamically-allocated data structures */ | /* tli_cleanup - cleanup some dynamically-allocated data structures */ | ||||
static void tli_cleanup(request) | static void tli_cleanup(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
if (request->config != 0) | if (request->config != 0) | ||||
freenetconfigent(request->config); | freenetconfigent(request->config); | ||||
if (request->client->unit != 0) | if (request->client->unit != 0) | ||||
t_free((char *) request->client->unit, T_UNITDATA); | t_free((char *) request->client->unit, T_UNITDATA); | ||||
if (request->server->unit != 0) | if (request->server->unit != 0) | ||||
t_free((char *) request->server->unit, T_UNITDATA); | t_free((char *) request->server->unit, T_UNITDATA); | ||||
} | } | ||||
/* tli_endpoints - determine TLI client and server endpoint information */ | /* tli_endpoints - determine TLI client and server endpoint information */ | ||||
static void tli_endpoints(request) | static void tli_endpoints(struct request_info *request) | ||||
struct request_info *request; | |||||
{ | { | ||||
struct t_unitdata *server; | struct t_unitdata *server; | ||||
struct t_unitdata *client; | struct t_unitdata *client; | ||||
int fd = request->fd; | int fd = request->fd; | ||||
int flags; | int flags; | ||||
/* | /* | ||||
* Determine the client endpoint address. With unconnected services, peek | * Determine the client endpoint address. With unconnected services, peek | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | #endif | ||||
tcpd_warn("getnetconfigent(%s): %s", config->nc_netid, nc_sperror()); | tcpd_warn("getnetconfigent(%s): %s", config->nc_netid, nc_sperror()); | ||||
return (0); | return (0); | ||||
} | } | ||||
return (config); | return (config); | ||||
} | } | ||||
/* tli_hostaddr - map TLI transport address to printable address */ | /* tli_hostaddr - map TLI transport address to printable address */ | ||||
static void tli_hostaddr(host) | static void tli_hostaddr(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
struct request_info *request = host->request; | struct request_info *request = host->request; | ||||
struct netconfig *config = request->config; | struct netconfig *config = request->config; | ||||
struct t_unitdata *unit = host->unit; | struct t_unitdata *unit = host->unit; | ||||
char *uaddr; | char *uaddr; | ||||
if (config != 0 && unit != 0 | if (config != 0 && unit != 0 | ||||
&& (uaddr = taddr2uaddr(config, &unit->addr)) != 0) { | && (uaddr = taddr2uaddr(config, &unit->addr)) != 0) { | ||||
STRN_CPY(host->addr, uaddr, sizeof(host->addr)); | STRN_CPY(host->addr, uaddr, sizeof(host->addr)); | ||||
free(uaddr); | free(uaddr); | ||||
} | } | ||||
} | } | ||||
/* tli_hostname - map TLI transport address to hostname */ | /* tli_hostname - map TLI transport address to hostname */ | ||||
static void tli_hostname(host) | static void tli_hostname(struct host_info *host) | ||||
struct host_info *host; | |||||
{ | { | ||||
struct request_info *request = host->request; | struct request_info *request = host->request; | ||||
struct netconfig *config = request->config; | struct netconfig *config = request->config; | ||||
struct t_unitdata *unit = host->unit; | struct t_unitdata *unit = host->unit; | ||||
struct nd_hostservlist *servlist; | struct nd_hostservlist *servlist; | ||||
if (config != 0 && unit != 0 | if (config != 0 && unit != 0 | ||||
&& netdir_getbyaddr(config, &servlist, &unit->addr) == ND_OK) { | && netdir_getbyaddr(config, &servlist, &unit->addr) == ND_OK) { | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static char *tli_error() | ||||
} else { | } else { | ||||
return (sys_errlist[errno]); | return (sys_errlist[errno]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* tli_sink - absorb unreceived datagram */ | /* tli_sink - absorb unreceived datagram */ | ||||
static void tli_sink(fd) | static void tli_sink(int fd) | ||||
int fd; | |||||
{ | { | ||||
struct t_unitdata *unit; | struct t_unitdata *unit; | ||||
int flags; | int flags; | ||||
/* | /* | ||||
* Something went wrong. Absorb the datagram to keep inetd from looping. | * Something went wrong. Absorb the datagram to keep inetd from looping. | ||||
* Allocate storage for address, control and data. If that fails, sleep | * Allocate storage for address, control and data. If that fails, sleep | ||||
* for a couple of seconds in an attempt to keep inetd from looping too | * for a couple of seconds in an attempt to keep inetd from looping too | ||||
Show All 13 Lines |