man-pages/man3/getnetent.3.html
2021-03-31 01:06:50 +01:00

303 lines
5.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GETNETENT</TITLE>
</HEAD><BODY>
<H1>GETNETENT</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent -
get network entry
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/netdb.h">netdb.h</A>&gt;</B>
<B>struct netent *getnetent(void);</B>
<B>struct netent *getnetbyname(const char *</B><I>name</I><B>);</B>
<B>struct netent *getnetbyaddr(uint32_t </B><I>net</I><B>, int </B><I>type</I><B>);</B>
<B>void setnetent(int </B><I>stayopen</I><B>);</B>
<B>void endnetent(void);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>getnetent</B>()
function reads the next entry from the networks database
and returns a
<I>netent</I>
structure containing
the broken-out fields from the entry.
A connection is opened to the database if necessary.
<P>
The
<B>getnetbyname</B>()
function returns a
<I>netent</I>
structure
for the entry from the database
that matches the network
<I>name</I>.
<P>
The
<B>getnetbyaddr</B>()
function returns a
<I>netent</I>
structure
for the entry from the database
that matches the network number
<I>net</I>
of type
<I>type</I>.
The
<I>net</I>
argument must be in host byte order.
<P>
The
<B>setnetent</B>()
function opens a connection to the database,
and sets the next entry to the first entry.
If
<I>stayopen</I>
is nonzero,
then the connection to the database
will not be closed between calls to one of the
<B>getnet*</B>()
functions.
<P>
The
<B>endnetent</B>()
function closes the connection to the database.
<P>
The
<I>netent</I>
structure is defined in
<I>&lt;<A HREF="file:///usr/include/netdb.h">netdb.h</A>&gt;</I>
as follows:
<P>
struct netent {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*n_name;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;official&nbsp;network&nbsp;name&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**n_aliases;&nbsp;&nbsp;/*&nbsp;alias&nbsp;list&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n_addrtype;&nbsp;/*&nbsp;net&nbsp;address&nbsp;type&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uint32_t&nbsp;&nbsp;&nbsp;n_net;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;network&nbsp;number&nbsp;*/
}
<P>
The members of the
<I>netent</I>
structure are:
<DL COMPACT>
<DT id="1"><I>n_name</I>
<DD>
The official name of the network.
<DT id="2"><I>n_aliases</I>
<DD>
A NULL-terminated list of alternative names for the network.
<DT id="3"><I>n_addrtype</I>
<DD>
The type of the network number; always
<B>AF_INET</B>.
<DT id="4"><I>n_net</I>
<DD>
The network number in host byte order.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The
<B>getnetent</B>(),
<B>getnetbyname</B>()
and
<B>getnetbyaddr</B>()
functions return a pointer to a
statically allocated
<I>netent</I>
structure, or a null pointer if an
error occurs or the end of the file is reached.
<A NAME="lbAF">&nbsp;</A>
<H2>FILES</H2>
<DL COMPACT>
<DT id="5"><I>/etc/networks</I>
<DD>
networks database file
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>getnetent</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netent
<BR>
race:netentbuf env locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getnetbyname</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netbyname
<BR>
env locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getnetbyaddr</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netbyaddr
<BR>
locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>setnetent</B>(),
<BR>
<B>endnetent</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netent env
<BR>
locale
<BR></TD></TR>
</TABLE>
<P>
In the above table,
<I>netent</I>
in
<I>race:netent</I>
signifies that if any of the functions
<B>setnetent</B>(),
<B>getnetent</B>(),
or
<B>endnetent</B>()
are used in parallel in different threads of a program,
then data races could occur.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008, 4.3BSD.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
In glibc versions before 2.2, the
<I>net</I>
argument of
<B>getnetbyaddr</B>()
was of type
<I>long</I>.
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+getnetent_r">getnetent_r</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getprotoent">getprotoent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getservent">getservent</A></B>(3)
<BR>
RFC&nbsp;1101
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="10"><A HREF="#lbAF">FILES</A><DD>
<DT id="11"><A HREF="#lbAG">ATTRIBUTES</A><DD>
<DT id="12"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="13"><A HREF="#lbAI">NOTES</A><DD>
<DT id="14"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="15"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:44 GMT, March 31, 2021
</BODY>
</HTML>