[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

inet_makeaddr Subroutine

Purpose

Returns a structure containing an Internet address based on a network ID and host ID provided by the application.

Library

Standard C Library (libc.a)

Syntax

#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


struct in_addr inet_makeaddr ( Net, LocalNetAddr)
int Net, LocalNetAddr;

Description

The inet_makeaddr subroutine forms an Internet address from the network ID and Host ID provided by the application (as integer types). If the application provides a Class A network ID, the inet_makeaddr subroutine forms the Internet address using the net ID in the highest-order byte and the logical product of the host ID and 0x00FFFFFF in the 3 lowest-order bytes. If the application provides a Class B network ID, the inet_makeaddr subroutine forms the Internet address using the net ID in the two highest-order bytes and the logical product of the host ID and 0x0000FFFF in the lowest two ordered bytes. If the application does not provide either a Class A or Class B network ID, the inet_makeaddr subroutine forms the Internet address using the network ID in the 3 highest-order bytes and the logical product of the host ID and 0x0000FFFF in the lowest-ordered byte.

The inet_makeaddr subroutine ensures that the Internet address format conforms to network order, with the first byte representing the high-order byte. The inet_makeaddr subroutine stores the Internet address in the structure as an unsigned long value.

The application must verify that the network ID and host ID for the Internet address conform to class A, B, or C. The inet_makeaddr subroutine processes any nonconforming number as a Class C address.

The inet_makeaddr subroutine expects the in_addr structure to contain only the Internet address field. If the application defines the in_addr structure otherwise, then the value returned in in_addr by the inet_makeaddr subroutine is undefined.

All applications containing the inet_makeaddr subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

Parameters

Net Contains an Internet network number.
LocalNetAddr Contains a local network address.

Return Values

Upon successful completion, the inet_makeaddr subroutine returns a structure containing an Internet address.

If the inet_makeaddr subroutine is unsuccessful, the subroutine returns a -1.

Files

/etc/hosts
                          Contains host names.

Related Information

The endhostent subroutine, endnetent subroutine, gethostbyaddr subroutine, gethostbyname subroutine, getnetbyaddr subroutine, getnetbyname subroutine, getnetent subroutine, inet_addr subroutine, inet_lnaof subroutine, inet_netof subroutine, inet_network subroutine, inet_ntoa subroutine, sethostent subroutine, setnetent subroutine.

Sockets Overview and Understanding Network Address Translation in AIX 5L Version 5.2 Communications Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]