Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

gethostbyaddr, gethostbyname, sethostent, endhostent

getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent



INET_ADDR(3n,L)             AIX Technical Reference             INET_ADDR(3n,L)



-------------------------------------------------------------------------------
inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof



PURPOSE

Manipulation subroutines for Internet addresses.

LIBRARY

Internet Library (libc.a)

SYNTAX

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




            unsigned long inet_addr (cp)struct in_addr inet_makeaddr (net, lna)
            char *cp;                   unsigned long net, lna;

            unsigned long inet_network (unsigned long inet_lnaof (in)
            char *cp;                   struct in_addr in;

            char *inet_ntoa (in)        unsigned long inet_netof (in)
            struct in_addr in;          struct in_addr in;



DESCRIPTION

The inet_addr subroutine interprets a character string as a full Internet
address in dot (.) notation and returns a number suitable for use as an
Internet address.  The inet_network subroutine interprets a character string as
the network portion of an Internet address in dot notation, and returns the
network number.

The inet_ntoa subroutine takes an Internet address and returns an ASCII string
representing the address in dot notation.  The in parameter contains the
Internet address to be converted to ASCII.

The inet_makeaddr takes an Internet network number and a local network address
and constructs an Internet address from it.  The net parameter contains an
Internet network number, while the lna parameter contains a local network
address.






Processed November 7, 1990      INET_ADDR(3n,L)                               1





INET_ADDR(3n,L)             AIX Technical Reference             INET_ADDR(3n,L)



The inet_netof and inet_lnaof subroutines break apart Internet addresses,
returning the network number and local network address part.  The in parameter
represents the Internet address to separate.

All Internet addresses are returned in network byte order.  All network numbers
and local addresses are returned as unsigned integer values in host order.  The
values specified using the dot notation take one of the following forms:

   "a.b.c.d"
   "a.b.c"
   "a.b"
   "a"

The inet_addr subroutine interprets input strings in the following way.

When four parts are specified, each is interpreted as a byte of data and
assigned to the four bytes of an Internet address.

When a three-part address is specified, the last part is interpreted as a
16-bit quantity and placed in the right two bytes of the Internet address.
This makes the three-part address format convenient for specifying Class B
network addresses as B0.B1.HOST, where 128 <= B0 <= 191, 0 <= B1 <= 255, and 0
<= HOST <= 65535.

When a two-part address is supplied, the last part is interpreted as a 24-bit
quantity and placed in the right three bytes of the Internet address.  This
makes the two-part address format convenient for specifying Class A network
addresses as A0.HOST, where 0 <= A0 <= 127, and 0 <= HOST <= 16777215.

The interpretation of a one-part address is undefined; such addresses should
not be passed to inet_addr.

The inet_network subroutine interprets input strings in the following way.

When a one part address is specified it is interpreted as a Class A address.
When a two-part part address is specified it is interpreted as a Class B
address.  When a three-part part address is specified it is interpreted as a
Class C address.

The interpretation of a four-part address is undefined; such addresses should
not be passed to inet_network.  To obtain the network number from a full
Internet address, use the subroutine inet_netof in conjuction with inet_addr;
for example, "net = inet_netof( inet_addr( cp ))".

All numbers supplied for each part of a dot notation may be decimal, octal, or
hexadecimal, as specified in C language.  A leading "0x" or "0X" implies
hexadecimal, a leading "0" implies octal, and anything else is interpreted as
decimal.

RETURN VALUE





Processed November 7, 1990      INET_ADDR(3n,L)                               2





INET_ADDR(3n,L)             AIX Technical Reference             INET_ADDR(3n,L)



The inet_addr and inet_network subroutines return numbers suitable for use as
Internet addresses and Internet network numbers, respectively, on success.

If the inet_addr or inet_network subroutine fails, a value of (unsigned long)
-1 is returned.  To test for failure it is necessary to cast -1 to an unsigned
long when comparing with the return value.  Note that for inet_addr the value
returned for addresses "255.255.255.255" and "255.255.255.254" is
indistinguishable from (unsigned long) -1 on two's complement and one's
complement machines respectively.

RELATED INFORMATION

In this book:  "gethostbyaddr, gethostbyname, sethostent, endhostent," and
"getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent."

The discussion of /etc/hosts and /etc/networks in AIX TCP/IP User's Guide.







































Processed November 7, 1990      INET_ADDR(3n,L)                               3



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