1bc7413d0SPeter Wemm.\" Copyright (c) 1983, 1991, 1993 2bc7413d0SPeter Wemm.\" The Regents of the University of California. All rights reserved. 3bc7413d0SPeter Wemm.\" 4bc7413d0SPeter Wemm.\" Redistribution and use in source and binary forms, with or without 5bc7413d0SPeter Wemm.\" modification, are permitted provided that the following conditions 6bc7413d0SPeter Wemm.\" are met: 7bc7413d0SPeter Wemm.\" 1. Redistributions of source code must retain the above copyright 8bc7413d0SPeter Wemm.\" notice, this list of conditions and the following disclaimer. 9bc7413d0SPeter Wemm.\" 2. Redistributions in binary form must reproduce the above copyright 10bc7413d0SPeter Wemm.\" notice, this list of conditions and the following disclaimer in the 11bc7413d0SPeter Wemm.\" documentation and/or other materials provided with the distribution. 12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 13bc7413d0SPeter Wemm.\" may be used to endorse or promote products derived from this software 14bc7413d0SPeter Wemm.\" without specific prior written permission. 15bc7413d0SPeter Wemm.\" 16bc7413d0SPeter Wemm.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17bc7413d0SPeter Wemm.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18bc7413d0SPeter Wemm.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19bc7413d0SPeter Wemm.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20bc7413d0SPeter Wemm.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21bc7413d0SPeter Wemm.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22bc7413d0SPeter Wemm.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23bc7413d0SPeter Wemm.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24bc7413d0SPeter Wemm.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25bc7413d0SPeter Wemm.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26bc7413d0SPeter Wemm.\" SUCH DAMAGE. 27bc7413d0SPeter Wemm.\" 284a3c598fSFernando Apesteguía.Dd June 27, 2022 29bc7413d0SPeter Wemm.Dt GETNETENT 3 30a307d598SRuslan Ermilov.Os 31bc7413d0SPeter Wemm.Sh NAME 32bc7413d0SPeter Wemm.Nm getnetent , 33bc7413d0SPeter Wemm.Nm getnetbyaddr , 34bc7413d0SPeter Wemm.Nm getnetbyname , 35bc7413d0SPeter Wemm.Nm setnetent , 36bc7413d0SPeter Wemm.Nm endnetent 37bc7413d0SPeter Wemm.Nd get network entry 3825bb73e0SAlexey Zelkin.Sh LIBRARY 3925bb73e0SAlexey Zelkin.Lb libc 40bc7413d0SPeter Wemm.Sh SYNOPSIS 4132eef9aeSRuslan Ermilov.In netdb.h 42bc7413d0SPeter Wemm.Ft struct netent * 431eda21cbSBruce Evans.Fn getnetent void 44bc7413d0SPeter Wemm.Ft struct netent * 45c293d821SPeter Wemm.Fn getnetbyname "const char *name" 46bc7413d0SPeter Wemm.Ft struct netent * 47360a23abSHajimu UMEMOTO.Fn getnetbyaddr "uint32_t net" "int type" 481eda21cbSBruce Evans.Ft void 49bc7413d0SPeter Wemm.Fn setnetent "int stayopen" 501eda21cbSBruce Evans.Ft void 511eda21cbSBruce Evans.Fn endnetent void 529acb1d7bSFernando Apesteguía.Ft int 539acb1d7bSFernando Apesteguía.Fn getnetent_r "struct netent *ne" "char *buffer" "size_t buflen" "struct netent **result" "int *h_errnop" 549acb1d7bSFernando Apesteguía.Ft int 559acb1d7bSFernando Apesteguía.Fn getnetbyaddr_r "uint32_t net" "int type" "struct netent *ne" "char *buffer" "size_t buflen" "struct netent **result" int *h_errorp" 569acb1d7bSFernando Apesteguía.Ft int 579acb1d7bSFernando Apesteguía.Fn getnetbyname_r "const char *name" "struct netent *ne" "char *buffer" "size_t buflen" "struct netent **result" "int *h_errorp" 58bc7413d0SPeter Wemm.Sh DESCRIPTION 59fdf4c7afSPeter WemmThe 60bc7413d0SPeter Wemm.Fn getnetent , 61bc7413d0SPeter Wemm.Fn getnetbyname , 62fdf4c7afSPeter Wemmand 63bc7413d0SPeter Wemm.Fn getnetbyaddr 64bc7413d0SPeter Wemmfunctions 65fdf4c7afSPeter Wemmeach return a pointer to an object with the 66248aee62SJacques Vidrinefollowing structure describing an internet network. 67248aee62SJacques VidrineThis structure contains either the information obtained 68942e234dSFernando Apesteguíafrom the nameserver, broken-out fields of a line in the network data base 69248aee62SJacques Vidrine.Pa /etc/networks , 70248aee62SJacques Vidrineor entries supplied by the 71491a8429SRuslan Ermilov.Xr yp 8 721a0a9345SRuslan Ermilovsystem. 731a0a9345SRuslan ErmilovThe order of the lookups is controlled by the 74248aee62SJacques Vidrine`networks' entry in 75248aee62SJacques Vidrine.Xr nsswitch.conf 5 . 76bc7413d0SPeter Wemm.Bd -literal -offset indent 77fdf4c7afSPeter Wemmstruct netent { 78fdf4c7afSPeter Wemm char *n_name; /* official name of net */ 79fdf4c7afSPeter Wemm char **n_aliases; /* alias list */ 80fdf4c7afSPeter Wemm int n_addrtype; /* net number type */ 81360a23abSHajimu UMEMOTO uint32_t n_net; /* net number */ 82fdf4c7afSPeter Wemm}; 83bc7413d0SPeter Wemm.Ed 84bc7413d0SPeter Wemm.Pp 85fdf4c7afSPeter WemmThe members of this structure are: 86bc7413d0SPeter Wemm.Bl -tag -width n_addrtype 87bc7413d0SPeter Wemm.It Fa n_name 88fdf4c7afSPeter WemmThe official name of the network. 89bc7413d0SPeter Wemm.It Fa n_aliases 90fdf4c7afSPeter WemmA zero terminated list of alternate names for the network. 91bc7413d0SPeter Wemm.It Fa n_addrtype 92bc7413d0SPeter WemmThe type of the network number returned; currently only AF_INET. 93bc7413d0SPeter Wemm.It Fa n_net 941a0a9345SRuslan ErmilovThe network number. 951a0a9345SRuslan ErmilovNetwork numbers are returned in machine byte 96fdf4c7afSPeter Wemmorder. 97bc7413d0SPeter Wemm.El 98bc7413d0SPeter Wemm.Pp 99fdf4c7afSPeter WemmThe 100bc7413d0SPeter Wemm.Fn getnetent 101bc7413d0SPeter Wemmfunction 102bc7413d0SPeter Wemmreads the next line of the file, opening the file if necessary. 103bc7413d0SPeter Wemm.Pp 104fdf4c7afSPeter WemmThe 105bc7413d0SPeter Wemm.Fn setnetent 106bc7413d0SPeter Wemmfunction 1071a0a9345SRuslan Ermilovopens and rewinds the file. 1081a0a9345SRuslan ErmilovIf the 109bc7413d0SPeter Wemm.Fa stayopen 110bc7413d0SPeter Wemmflag is non-zero, 111bc7413d0SPeter Wemmthe net data base will not be closed after each call to 112bc7413d0SPeter Wemm.Fn getnetbyname 113fdf4c7afSPeter Wemmor 114bc7413d0SPeter Wemm.Fn getnetbyaddr . 115bc7413d0SPeter Wemm.Pp 116fdf4c7afSPeter WemmThe 117bc7413d0SPeter Wemm.Fn endnetent 118bc7413d0SPeter Wemmfunction 119bc7413d0SPeter Wemmcloses the file. 120bc7413d0SPeter Wemm.Pp 121bc7413d0SPeter WemmThe 122bc7413d0SPeter Wemm.Fn getnetbyname 123bc7413d0SPeter Wemmfunction 124fdf4c7afSPeter Wemmand 125bc7413d0SPeter Wemm.Fn getnetbyaddr 126bc7413d0SPeter Wemmsequentially search from the beginning 127bc7413d0SPeter Wemmof the file until a matching 128bc7413d0SPeter Wemmnet name or 129bc7413d0SPeter Wemmnet address and type is found, 130bc7413d0SPeter Wemmor until 131bc7413d0SPeter Wemm.Dv EOF 132c6ff3a1bSSheldon Hearnis encountered. 133c6ff3a1bSSheldon HearnThe 134c293d821SPeter Wemm.Fa type 1352efeeba5SRuslan Ermilovargument 136c293d821SPeter Wemmmust be 137c293d821SPeter Wemm.Dv AF_INET . 138bc7413d0SPeter WemmNetwork numbers are supplied in host order. 1399acb1d7bSFernando Apesteguía.Pp 1409acb1d7bSFernando ApesteguíaFunctions with the 1419acb1d7bSFernando Apesteguía.Em _r 1429acb1d7bSFernando Apesteguíasuffix provide reentrant versions of their respective counterparts. 1439acb1d7bSFernando ApesteguíaThe caller must supply five additional parameters: a 1449acb1d7bSFernando Apesteguía.Vt struct netent 1459acb1d7bSFernando Apesteguíavariable to be filled on success, a 1469acb1d7bSFernando Apesteguía.Va buffer 1479acb1d7bSFernando Apesteguíaof 1489acb1d7bSFernando Apesteguía.Va buflen 1499acb1d7bSFernando Apesteguíabytes in size, a 1509acb1d7bSFernando Apesteguía.Vt struct netent 1519acb1d7bSFernando Apesteguía.Va result 1529acb1d7bSFernando Apesteguíavariable that will point to the result on success or be set to 1539acb1d7bSFernando Apesteguía.Dv NULL 1549acb1d7bSFernando Apesteguíaon failure or if the name is not found. 1559acb1d7bSFernando ApesteguíaThe 1569acb1d7bSFernando Apesteguía.Va h_errnop 1579acb1d7bSFernando Apesteguíavariable will be filled with the error code if any. 1589acb1d7bSFernando ApesteguíaAll these functions return 0 on success. 159bc7413d0SPeter Wemm.Sh FILES 160248aee62SJacques Vidrine.Bl -tag -width /etc/nsswitch.conf -compact 161bc7413d0SPeter Wemm.It Pa /etc/networks 162248aee62SJacques Vidrine.It Pa /etc/nsswitch.conf 163248aee62SJacques Vidrine.It Pa /etc/resolv.conf 164bc7413d0SPeter Wemm.El 165bc7413d0SPeter Wemm.Sh DIAGNOSTICS 16657446011SKevin LoNull pointer returned on 167bc7413d0SPeter Wemm.Dv EOF 168bc7413d0SPeter Wemmor error. 169bc7413d0SPeter Wemm.Sh SEE ALSO 17075141cc9SWolfram Schneider.Xr networks 5 17175141cc9SWolfram Schneider.Pp 172c293d821SPeter Wemm.%T RFC 1101 173bc7413d0SPeter Wemm.Sh HISTORY 174bc7413d0SPeter WemmThe 175bc7413d0SPeter Wemm.Fn getnetent , 176bc7413d0SPeter Wemm.Fn getnetbyaddr , 177bc7413d0SPeter Wemm.Fn getnetbyname , 178bc7413d0SPeter Wemm.Fn setnetent , 179fdf4c7afSPeter Wemmand 180bc7413d0SPeter Wemm.Fn endnetent 181bc7413d0SPeter Wemmfunctions appeared in 182bc7413d0SPeter Wemm.Bx 4.2 . 183bc7413d0SPeter Wemm.Sh BUGS 184bc7413d0SPeter WemmThe data space used by 185f789cb82SRuslan Ermilovthese functions is thread-specific; if future use requires the data, it should be 186bc7413d0SPeter Wemmcopied before any subsequent calls to these functions overwrite it. 187bc7413d0SPeter WemmOnly Internet network 188bc7413d0SPeter Wemmnumbers are currently understood. 189bc7413d0SPeter WemmExpecting network numbers to fit 190bc7413d0SPeter Wemmin no more than 32 bits is probably 191bc7413d0SPeter Wemmnaive. 192