Purpose
Converts an operating-system-independent network name to a domain-specific host name.
Library
C Library (libc.a)
Syntax
Description
The netname2host subroutine converts an operating-system-independent network name to a domain-specific host name.
This subroutine is the inverse of the host2netname subroutine.
Parameters
Item | Description |
---|---|
name | Specifies the network name (or netname) of the server process owner. The name parameter can be either the host name derived from the host2netname subroutine or the user name derived from the user2netname subroutine. |
host | Points to the name of the machine on which the permissions were created. |
hostlen | Specifies the size of the host name. |
Return Values
Upon successful completion, this subroutine returns a value of 1. If unsuccessful, it returns a value of 0.
Purpose
Converts an operating-system-independent network name to a domain-specific host name.
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
int netname2host( name, host, hostlen)
const char *name;
const char *host;
const int hostlen;
Description
The netname2host subroutine, which belongs to the secure remote procedure call (RPC) category, is used in applications that use the AUTH_DES authentication flavor. This subroutine is usually used on server side to convert the network name of a host to the domain-specific host name.
This subroutine is the inverse of the host2netname subroutine.
Parameters
Item | Description |
---|---|
name | Specifies the network name of the host. |
host | Represents the domain-specific host name after successful completion. |
hostlen | Specifies the maximum length of the host name. |
Return Values
Item | Description |
---|---|
1 | successful |
0 | unsuccessful |
Examples
#include <rpc/rpc.h>
static void dispatch(struct svc_req *, SVCXPRT *);
main()
{
rpcprog_t RPROGNUM = 0x3fffffffL;
rpcvers_t RPROGVER = 0x1L;
/* Create service handle for RPROGNUM, RPROGVER and tcp transport */
if(!svc_create( dispatch, RPROGNUM, RPROGVER, "tcp")) {
fprintf(stderr,"\nsvc_create() failed\n");
exit(EXIT_FAILURE);
}
svc_run();
}
/* The server dispatch function */
static void dispatch(struct svc_req *rqstp, SVCXPRT *transp)
{
char hostp[300];
struct authdes_cred *des_cred;
switch (rqstp->rq_cred.oa_flavor) {
case AUTH_DES :
/* AUTH_DES Authentication flavor */
des_cred = (struct authdes_cred *) rqstp->rq_clntcred;
if (!netname2host(des_cred->adc_fullname.name, hostp, 300)) {
svcerr_systemerr(transp);
return;
}
fprintf(stdout,"The domain-specific host name is %s",hostp);
break;
default :
/* Other Authentication flavor */
break;
}
/* The Dispatch Routine code continues .. */
}