inet_makeaddr()

The inet_makeaddr() call constructs an internet address from a network number and a local network address.

Syntax

#include <types.h>
#include <arpa\inet.h>
struct in_addr inet_makeaddr(net, lna)
u_long net;
u_long lna;

Parameters

net

lna

Description

The inet_makeaddr() call 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() call 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() call 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() call 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() call ensures that the internet address format conforms to network order, with the first byte representing the high-order byte. The inet_makeaddr() call 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() call processes any other class of address as a Class C address.

The inet_makeaddr() call 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() call is undefined.

Return Values

The internet address is returned in network-byte order. The return value points to static data that subsequent API calls can modify.

If the inet_makeaddr() call is unsuccessful, the call returns a value of -1.

Related Calls


[Back: inet_lnaof()]
[Next: inet_netof()]