1INET(3N)                                                              INET(3N)
2
3
4

NAME

6       inet_addr,    inet_network,   inet_ntoa,   inet_makeaddr,   inet_lnaof,
7       inet_netof - Internet address manipulation routines
8

SYNOPSIS

10       #include <sys/socket.h>
11       #include <netinet/in.h>
12       #include <arpa/inet.h>
13
14       unsigned long inet_addr(cp)
15       char *cp;
16
17       unsigned long inet_network(cp)
18       char *cp;
19
20       char *inet_ntoa(in)
21       struct in_addr in;
22
23       struct in_addr inet_makeaddr(net, lna)
24       long net, lna;
25
26       long inet_lnaof(in)
27       struct in_addr in;
28
29       long inet_netof(in)
30       struct in_addr in;
31

DESCRIPTION

33       The  routines  inet_addr  and  inet_network  each  interpret  character
34       strings  representing  numbers  expressed  in the Internet standard “.”
35       notation, returning numbers suitable for use as Internet addresses  and
36       Internet network numbers, respectively.  The routine inet_ntoa takes an
37       Internet address and returns an ASCII string representing  the  address
38       in  “.”  notation.  The routine inet_makeaddr takes an Internet network
39       number and a local network address and constructs an  Internet  address
40       from  it.   The routines inet_netof and inet_lnaof break apart Internet
41       host addresses, returning the network number and local network  address
42       part, respectively.
43
44       All  Internet address are returned in network order (bytes ordered from
45       left to right).  All  network  numbers  and  local  address  parts  are
46       returned as machine format integer values.
47

INTERNET ADDRESSES

49       Values  specified  using  the  “.”  notation  take one of the following
50       forms:
51              a.b.c.d
52              a.b.c
53              a.b
54              a
55       When four parts are specified, each is interpreted as a  byte  of  data
56       and  assigned,  from  left  to  right, to the four bytes of an Internet
57       address.  Note that when an Internet address  is  viewed  as  a  32-bit
58       integer  quantity  on  the  VAX  the  bytes referred to above appear as
59       “d.c.b.a”.  That is, VAX bytes are ordered from right to left.
60
61       When a three part address is specified, the last part is interpreted as
62       a 16-bit quantity and placed in the right most two bytes of the network
63       address.  This makes the three part address format convenient for spec‐
64       ifying Class B network addresses as “128.net.host”.
65
66       When  a two part address is supplied, the last part is interpreted as a
67       24-bit quantity and placed in the right most three bytes of the network
68       address.   This makes the two part address format convenient for speci‐
69       fying Class A network addresses as “net.host”.
70
71       When only one part is given, the value is stored directly in  the  net‐
72       work address without any byte rearrangement.
73
74       All  numbers  supplied  as  “parts”  in  a “.” notation may be decimal,
75       octal, or hexadecimal, as specified in the C language (i.e., a  leading
76       0x  or  0X  implies  hexadecimal; otherwise, a leading 0 implies octal;
77       otherwise, the number is interpreted as decimal).
78

SEE ALSO

80       gethostbyname(3N), getnetent(3N), hosts(5), networks(5),
81

DIAGNOSTICS

83       The value -1 is returned by inet_addr and  inet_network  for  malformed
84       requests.
85

BUGS

87       The  problem of host byte ordering versus network byte ordering is con‐
88       fusing.  A simple way to specify Class C network addresses in a  manner
89       similar to that for Class B and Class A is needed.  The string returned
90       by inet_ntoa resides in a static memory area.
91       Inet_addr should return a struct in_addr.
92
93
94
954.2 Berkeley Distribution        May 27, 1986                         INET(3N)
Impressum