getnodeent(3dn)
NAME
getnodeent − get node information from network node database
SYNTAX
#include <sys/dnetdb.h>
struct nodeent *getnodeent()
struct nodeent *getnodebyname (name)
char *name;
struct nodeent *getnodebyaddr (addr,len,type)
char *addr;
int len,type;
int setnodeent()
endnodeent()
ARGUMENTS
Input Arguments
name Specifies the address of the buffer containing the node name string.
addr Specifies the address of the buffer containing the node address string in the form returned by the dnet_addr subroutine.
len is the length of the node’s address string. Use sizeof (unsigned short).
type Specifies the address type. This must be specified as AF_DECnet.
The getnodeent subroutine returns a pointer to a structure of type nodeent with the following members:
struct nodeent {
char *n_name; /* name of node */
int n_addrtype; /* node address type */
int n_length; /* length of address */
char *n_addr; /* address */
};
nodeent Specifies the node address database structure. The following data fields are filled in by this subroutine:
n_name Specifies the name of the node.
n_addrtype Specifies the returned address type as AF_DECnet.
n_length Specifies the length of the address.
n_addr Specifies the network address for the node.
DESCRIPTION
Given a node name or node address, the getnodebyname and getnodebyaddr subroutines respectively access the network node database and return nodes information. Both return a pointer to a nodeent structure. This structure contains an entry from the network node database. The returned nodeent structure is stored in static memory allocated in the getnodeent subroutine. Therefore, to save it, you must copy it to user memory.
The getnodebyname and getnodebyaddr search sequentially from the beginning of the database until a matching host name or host address is found, or until the end of the database is found. Node addresses are always arranged in ascending numeric order.
The setnodeent, getnodeent, and endnodeent functions are similar to the sethostent, gethostent, and endhostent functions. They read through the node database and perform functions in the following order:
1. The setnodeent subroutine sets the pointer to the beginning of the database.
2. The getnodeent subroutine reads the next entry in the database.
3. The endnodeent subroutine closes the database.
RETURN VALUE
The setnodeent subroutine returns a valued of 0 if the subroutine completes successfully; if it fails, a value of −1 is returned.
If getnodeent completes successfully, a pointer to a nodeent structure is returned. If an error or an end of file (EOF) occurs, a value of 0 is returned.
DIAGNOSTICS
NULL pointer (0) is returned on EOF or error. set
The following error messages can be returned by the database routines getnodebyname, getnodebyaddr, getnodeent, and setnodeent:
errno Value Description
[ENAMETOOLONG]
The node name is too long
[EADDRNOTAVAIL]
No such node name in database
[ENOBUFS] Insufficient Resources to complete request
[EPROTONOSUPPORT] Type not supported or length not a valid length
[EFAULT] Incompatible database version number