1inet(7P)                           Protocols                          inet(7P)
2
3
4

NAME

6       inet - Internet protocol family
7

SYNOPSIS

9       #include <sys/types.h>
10
11
12       #include <netinet/in.h>
13
14

DESCRIPTION

16       The Internet protocol family implements a collection of protocols which
17       are centered around the Internet Protocol ("IP") and which share a com‐
18       mon address format. The Internet family protocols can be accessed using
19       the socket interface, where they support the  SOCK_STREAM,  SOCK_DGRAM,
20       and  SOCK_RAW  socket  types,  or  the Transport Level Interface (TLI),
21       where they support the connectionless (T_CLTS)  and connection oriented
22       (T_COTS_ORD) service types.
23

PROTOCOLS

25       The  Internet  protocol  family  is  comprised of the Internet Protocol
26       ("IP"), the Address Resolution Protocol ("ARP"), the  Internet  Control
27       Message  Protocol  ("ICMP"), the Transmission Control Protocol ("TCP"),
28       and the User Datagram Protocol ("UDP").
29
30
31       TCP supports the socket interface's SOCK_STREAM abstraction  and  TLI's
32       T_COTS_ORD service type. UDP supports the SOCK_DGRAM socket abstraction
33       and the TLI T_CLTS service type. See  tcp(7P)  and  udp(7P).  A  direct
34       interface  to  IP  is available using both TLI and the socket interface
35       (see ip(7P)). ICMP is used by the kernel to handle and report errors in
36       protocol  processing.  It  is  also  accessible  to  user programs (see
37       icmp(7P)). ARP is used to translate 32-bit  IP  addresses  into  48-bit
38       Ethernet addresses. See arp(7P).
39
40
41       The  32-bit  IP  address is divided into network number and host number
42       parts. It is frequency-encoded. The most-significant  bit  is  zero  in
43       Class A addresses, in which the high-order 8 bits represent the network
44       number. Class B addresses have their high order two bits set to 10  and
45       use  the  high-order  16  bits  as  the  network  number field. Class C
46       addresses have a 24-bit network number part of  which  the  high  order
47       three  bits  are  110. Sites with a cluster of IP networks may chose to
48       use a single network number for the cluster; this is done by using sub‐
49       net  addressing. The host number portion of the address is further sub‐
50       divided into subnet number and host number parts. Within a subnet, each
51       subnet  appears  to  be  an  individual network. Externally, the entire
52       cluster appears to be a single, uniform network requiring only a single
53       routing entry. Subnet addressing is enabled and examined by the follow‐
54       ing ioctl(2) commands. They have the same form as the SIOCSIFADDR  com‐
55       mand.
56
57       SIOCSIFNETMASK    Set  interface network mask. The network mask defines
58                         the network part of the address; if it contains  more
59                         of  the address than the address type would indicate,
60                         then subnets are in use.
61
62
63       SIOCGIFNETMASK    Get interface network mask.
64
65

ADDRESSING

67       IP addresses are four byte quantities, stored in network byte order. IP
68       addresses  should  be  manipulated using the byte order conversion rou‐
69       tines. See  byteorder(3SOCKET).
70
71
72       Addresses in the Internet protocol family use the   sockaddr_in  struc‐
73       ture, which has that following members:
74
75         short    sin_family;
76         ushort_t sin_port;
77         struct   in_addr  sin_addr;
78         char     sin_zero[8];
79
80
81
82       Library  routines  are  provided to manipulate structures of this form;
83       See inet(3SOCKET).
84
85
86       The sin_addr field of the sockaddr_in structure specifies  a  local  or
87       remote  IP  address.   Each  network  interface  has  its own unique IP
88       address.  The special value INADDR_ANY may be used  in  this  field  to
89       effect  "wildcard"  matching. Given in a bind(3SOCKET) call, this value
90       leaves the local IP address of the  socket  unspecified,  so  that  the
91       socket  will  receive  connections  or  messages directed at any of the
92       valid IP addresses of the system. This can prove useful when a  process
93       neither  knows nor cares what the local IP address is or when a process
94       wishes to receive requests using all of  its  network  interfaces.  The
95       sockaddr_in  structure  given in the bind(3SOCKET) call must specify an
96       in_addr value of either INADDR_ANY or one  of  the  system's  valid  IP
97       addresses.  Requests  to  bind  any other address will elicit the error
98       EADDRNOTAVAIL. When a connect(3SOCKET) call is made for a  socket  that
99       has a wildcard local address, the system sets the sin_addr field of the
100       socket to the IP address of the network interface that the packets  for
101       that connection are routed through.
102
103
104       The sin_port field of the sockaddr_in structure specifies a port number
105       used by TCP or UDP. The local port address specified in a bind(3SOCKET)
106       call  is  restricted  to  be  greater  than IPPORT_RESERVED (defined in
107       <<netinet/in.h>>) unless the creating process is running as  the  supe‐
108       ruser,  providing  a  space of protected port numbers. In addition, the
109       local port address must not be in use by any  socket  of  same  address
110       family and type. Requests to bind sockets to port numbers being used by
111       other sockets return the error EADDRINUSE. If the local port address is
112       specified  as  0,  then  the system picks a unique port address greater
113       than IPPORT_RESERVED. A unique local port address is also picked when a
114       socket  which is not bound is used in a connect(3SOCKET) or sendto (see
115       send(3SOCKET)) call. This allows programs which do not care which local
116       port  number  is  used  to  set  up  TCP  connections by simply calling
117       socket(3SOCKET) and then connect(3SOCKET), and to  send  UDP  datagrams
118       with a socket(3SOCKET) call followed by a sendto() call.
119
120
121       Although  this  implementation  restricts  sockets to unique local port
122       numbers, TCP allows multiple  simultaneous  connections  involving  the
123       same  local port number so long as the remote IP addresses or port num‐
124       bers are different for each connection. Programs may  explicitly  over‐
125       ride  the  socket restriction by setting the SO_REUSEADDR socket option
126       with setsockopt (see getsockopt(3SOCKET)).
127
128
129       TLI applies somewhat different semantics to the binding of  local  port
130       numbers.  These semantics apply when Internet family protocols are used
131       using the TLI.
132

SEE ALSO

134       ioctl(2), bind(3SOCKET), byteorder(3SOCKET), connect(3SOCKET), gethost‐
135       byname(3NSL),   getnetbyname(3SOCKET),   getprotobyname(3SOCKET),  get‐
136       servbyname(3SOCKET),        getsockopt(3SOCKET),         send(3SOCKET),
137       socket(3SOCKET), arp(7P), icmp(7P), ip(7P), tcp(7P), udp(7P)
138
139
140       Network  Information  Center,  DDN Protocol Handbook (3 vols.), Network
141       Information Center, SRI International, Menlo Park, Calif., 1985.
142

NOTES

144       The Internet protocol support is subject to change as the Internet pro‐
145       tocols  develop.   Users  should  not  depend on details of the current
146       implementation, but rather the services exported.
147
148
149
150SunOS 5.11                        3 Aug 2000                          inet(7P)
Impressum