Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getnetbyaddr_r(3) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getnetent(3)

getnetbyname(3)

setnetent(3)

,endnetent(3)

getnetbyaddr(3)  —  Subroutines

NAME

getnetbyaddr, getnetbyaddr_r − Get a network entry by address

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <netdb.h>

struct netent ∗getnetbyaddr(
long num,
int type);

int getnetbyaddr_r(
long num,
int type,
struct netent ∗net,
struct netent_data ∗net_data);

PARAMETERS

numSpecifies the number of the network in host-byte order. 

typeSpecifies the Internet domain address format. The value AF_INET must be used. 

netPoints to the netent structure. 

net_dataIs data for the networks database. 

DESCRIPTION

The getnetbyaddr() function returns a pointer to a structure of type netent.  Its members specify data in fields from a record line in the /etc/networks network name database file. The netdb.h header file defines the netent structure. 

The getnetbyaddr() function searches the /etc/networks file sequentially until a match with the num and type parameters occurs. The num parameter must specify the network number in host-byte order. The type parameter must be the constant AF_INET. When EOF (End-of-File) is reached without a match, an error value is returned by this parameter. 

Use the endnetent() function to close the /etc/networks file. 

The getnetbyaddr_r() function is the reentrant version of the getnetbyaddr() function.  Upon successful completion, the returned structure is pointed to by net.  The netdb.h header file defines the netent and netent_data structures. 

NOTES

The getnetbyaddr() return value points to static data, which is overwritten by any subsequently called functions using the same structure. 

Before the first access (by either the setnetent_r() or getnetbyaddr_r() functions), set to NULL the net_fp field of the netent_data structure.  In addition, the _net_stayopen flag of the netent_data structure should be initialized if the setnetent() function is not used. 

RETURN VALUES

Upon successful completion, the getnetbyaddr() function returns a pointer to a netent structure.  A value of 0 (zero) is returned when an error occurs or when the end of the /etc/networks name file is reached. 

Upon successful completion, the getnetbyaddr_r() function returns a value of 0 (zero).  Otherwise, a value of -1 is returned. 

ERRORS

If any of the following conditions occurs, the getnetbyaddr_r() function sets errno to the corresponding value:

[EINVAL]The net or net_data parameter is invalid. 

[ESRCH]The search failed. 

FILES

/etc/networks
The DARPA Internet network name database file. Each record in the file occupies a single line and has three fields: the official network name, the network number, and alias.

RELATED INFORMATION

Functions: getnetent(3), getnetbyname(3), setnetent(3),endnetent(3). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026