GETPROTOENT(3N)GETPROTOENT(3N)NAME
getprotoent, getprotobynumber, getprotobyname, getprotoent_r,
getprotobynumber_r, getprotobyname_r, fgetprotoent, fgetprotoent_r,
setprotoent, endprotoent - get protocol entry
SYNOPSIS
#include <netdb.h>
struct protoent *getprotoent(void);
struct protoent *getprotoent_r(struct protoent *entry, char *buffer, int buflen);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobyname_r(const char *name, struct protoent *entry, char *buffer, int buflen);
struct protoent *getprotobynumber(int proto);
struct protoent *getprotobynumber_r(int proto, struct protoent *entry, char *buffer, int buflen);
struct protoent *fgetprotoent(FILE *f);
struct protoent *fgetprotoent_r(FILE *f, struct protoent *entry, char *buffer, int buflen);
void setprotoent(int stayopen);
void endprotoent(void)DESCRIPTION
getprotoent, getprotobyname, and getprotobynumber each return a pointer
to an object with the following structure containing the broken-out
fields of a line in the network protocol data base file, /etc/protocols,
or the NIS protocols map.
struct protoent {
char *p_name; /* official name of protocol */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
};
The members of this structure are:
p_name The official name of the protocol.
p_aliases A zero terminated list of alternate names for the protocol.
p_proto The protocol number.
Getprotoent reads the next line of the file, opening the file if
necessary.
Page 1
GETPROTOENT(3N)GETPROTOENT(3N)
Setprotoent opens and rewinds the file. If the stayopen flag is non-
zero, the net data base will not be closed after each call to
getprotobyname or getprotobynumber.
Endprotoent closes the file.
Getprotobyname and getprotobynumber sequentially search from the
beginning of the file until a matching protocol name or protocol number
is found, or until EOF is encountered.
The primitives documented in this manual entry first consult Sun's NIS
distributed lookup service, if NIS is enabled, and then the file
/etc/protocols.
getprotoent_r, getprotobynumber_r and getprotobyname_r are reentrant
versions of the corresponding function calls.
fgetprotoent and fgetprotoent_r will read entries off of the passed file
handle.
NOTE
The Mips ABI specifies nothing but local files so applications which wish
to use anything else must compile with libc prior to libnsl in the
library list. When nsd is running changes to the local protocols file
may not be noticed by getprotoent() until the enumeration cache file has
timed out.
The char buffer passed into the getprotoent functions must be aligned to
a four byte boundary, otherwise the call will trigger a bus error.
DIAGNOSTICS
All functions that return struct protoent * will return a null (0)
pointer in the case of EOF or failure.
FILES
/etc/protocols
SEE ALSOypserv(1M), protocols(4)DIAGNOSTICS
Null pointer (0) returned on EOF or error.
Page 2