getnetbyaddr_r Subroutine

Purpose

Gets network entry by address.

Library

Standard C Library (libc.a)

Syntax

#include<netdb.h>
int getnetbyaddr_r(net, type, netent, net_data)

register in_addr_t net;
register int type;
struct netent *netent;
struct netent_data *net_data;

Description

The getnetbyaddr_r subroutine retrieves information from the /etc/networks file using the Name parameter as a search key.

The getnetbyaddr_r subroutine internally calls the getnetbyaddr subroutine and stores the information in the structure data.

The getnetbyaddr subroutine overwrites the static data returned in subsequent calls. The getnetbyaddr_r subroutine does not.

Use the endnetent_r subroutine to close the /etc/networks file.

Parameters

Item Description
Net Specifies the number of the network to be located.
Type Specifies the address family for the network. The only supported values are AF_INET, and AF_INET6.
netent Points to the netent structure.
net_data Points to the net_data structure.

Return Values

The function returns a 0 if successful and a -1 if unsuccessful.

Files

Item Description
/etc/networks Contains official network names.