36.2 Internet Address Manipulation Functions

An IP address has two formats:

IPv6 is supported only on NetWare 6.5 and later.

For the functions that convert from one format to the other, see Address Manipulation Functions.

36.2.1 Standard Dotted Decimal Notation

Values specified using IPv4 dotted decimal notation take one of the following forms:

a.b.c.d

When four parts are specified, each byte of data is assigned, from left to right, to the four bytes of an Internet address.

a.b.c

When a three-part address is specified, the last part is interpreted as a 16-bit quantity and is placed in the rightmost two bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as “128.net.host”.

a.b

When a two-part address is supplied, the last part is interpreted as a 24-bit quantity and is placed in the rightmost three bytes of the network address. This makes the two-part address format convenient for specifying Class A network addresses as “net.host”.

a

When only one part is given, the value is stored directly in the network address without any byte rearrangement.

All numbers supplied as parts in IPv4 dotted decimal notation can be decimal, octal, or hexadecimal. A leading 0x or 0X implies hexadecimal; a leading “0” implies octal; otherwise, the number is interpreted as decimal.

The inet_addr function accepts all of these forms. The inet_pton function accepts only 4 part addresses with decimal numbers.

36.2.2 Address Manipulation Functions

The following functions allow you to convert the string format of an address to the binary, numeric format:

Function

Description

inet_addr

Converts an address in IPv4 standard dotted decimal notation to an integer.

inet_network

Converts an address in IPv4 standard dotted decimal notation. If successful, its return value is the binary form of the address in network byte order.

inet_pton

Converts an address in standard text presentation to its numeric binary form. For IPv4, the address is converted to an in_addr structure. For IPv6, the address is converted to an in6_addr structure.

The following functions allow you to convert the binary address in network order to the string format of the address.

Function

Description

inet_ntoa

Converts an Internet binary address into an ASCII string in Internet standard dotted notation.

inet_ntop

Converts a binary address into a text string suitable. For IPv4, this is standard dotted decimal notation. For IPv6, this is a string appropriate for the address type.

Because NetWare platforms use host byte order, use the inet_makeaddr function to convert host address numbers into a binary address in network byte order before manipulating the address with these functions or sending the address out on the network. For functions that convert between network byte order and host byte order, see Section 36.1, Network and Host Byte Order Functions.