version 1.7, 1997/06/23 01:03:57 |
version 1.8, 1997/07/21 19:12:46 |
|
|
/* $OpenBSD$ |
/* $OpenBSD$ */ |
/* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */ |
/* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */ |
|
|
/* |
/* |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
|
|
|
#include <sys/socket.h> |
|
#include <netinet/in.h> |
|
#include <arpa/inet.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
#include <string.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <netdb.h> |
#include <netdb.h> |
|
#include <err.h> |
|
|
#include <rpc/rpc.h> |
#include <rpc/rpc.h> |
#include <rpc/xdr.h> |
#include <rpc/xdr.h> |
#include <rpcsvc/yp.h> |
#include <rpcsvc/yp.h> |
|
|
{ "ethers", "ethers.byname" }, |
{ "ethers", "ethers.byname" }, |
}; |
}; |
|
|
|
void |
usage() |
usage() |
{ |
{ |
fprintf(stderr, "Usage:\n"); |
fprintf(stderr, "Usage:\n"); |
|
|
/* |
/* |
* Like yp_bind except can query a specific host |
* Like yp_bind except can query a specific host |
*/ |
*/ |
|
int |
bind_host(dom, sin) |
bind_host(dom, sin) |
char *dom; |
char *dom; |
struct sockaddr_in *sin; |
struct sockaddr_in *sin; |
{ |
{ |
struct hostent *hent = NULL; |
struct hostent *hent = NULL; |
struct ypbind_resp ypbr; |
struct ypbind_resp ypbr; |
struct dom_binding *ysd; |
|
struct timeval tv; |
struct timeval tv; |
CLIENT *client; |
CLIENT *client; |
int sock, r; |
int sock, r; |
u_int32_t ss_addr; |
struct in_addr ss_addr; |
|
|
sock = RPC_ANYSOCK; |
sock = RPC_ANYSOCK; |
tv.tv_sec = 15; |
tv.tv_sec = 15; |
|
|
} |
} |
clnt_destroy(client); |
clnt_destroy(client); |
|
|
bcopy(&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, |
memmove(&ss_addr.s_addr, &ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, |
&ss_addr, sizeof (ss_addr)); |
sizeof (ss_addr)); |
|
|
hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET); |
hent = gethostbyaddr((char *)&ss_addr.s_addr, sizeof(ss_addr.s_addr), |
|
AF_INET); |
if (hent != NULL) |
if (hent != NULL) |
printf("%s\n", hent->h_name); |
printf("%s\n", hent->h_name); |
else |
else |
|
|
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
char **argv; |
int argc; |
|
char **argv; |
{ |
{ |
char *domain, *master, *map; |
char *domain, *master, *map; |
struct ypmaplist *ypml, *y; |
struct ypmaplist *ypml, *y; |
|
|
getmap = notrans = mode = 0; |
getmap = notrans = mode = 0; |
|
|
yp_get_default_domain(&domain); |
yp_get_default_domain(&domain); |
|
if (domain == NULL) |
|
errx(1, "YP domain name not set"); |
|
|
while ((c = getopt(argc, argv, "xd:mt")) != -1) |
while ((c = getopt(argc, argv, "xd:mt")) != -1) |
switch(c) { |
switch(c) { |
case 'x': |
case 'x': |
|
|
if (mode == 0) { |
if (mode == 0) { |
switch(argc) { |
switch(argc) { |
case 0: |
case 0: |
bzero(&sin, sizeof sin); |
memset(&sin, 0, sizeof sin); |
sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
|
|