1INET(4F) INET(4F)
2
3
4
6 inet - Internet protocol family
7
9 #include <sys/types.h>
10 #include <netinet/in.h>
11
13 The Internet protocol family is a collection of protocols layered atop
14 the Internet Protocol (IP) transport layer, and utilizing the Internet
15 address format. The Internet family provides protocol support for the
16 SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW socket types; the SOCK_RAW inter‐
17 face provides access to the IP protocol.
18
20 Internet addresses are four byte quantities, stored in network standard
21 format: layed out as highest to lowest order bytes in memory or ``Big
22 Endian'' (the VAX is word and byte reversed, or ``Little Endian''; the
23 PDP-11 is byte reversed within each word, or ``Middle Endian''). The
24 include file <netinet/in.h> defines this address as a discriminated
25 union.
26
27 Sockets bound to the Internet protocol family utilize the following
28 addressing structure,
29
30 struct sockaddr_in {
31 short sin_family;
32 u_short sin_port;
33 struct in_addr sin_addr;
34 char sin_zero[8];
35 };
36
37 Sockets may be created with the local address INADDR_ANY to effect
38 “wildcard” matching on incoming messages. The address in a connect(2)
39 or sendto(2) call may be given as INADDR_ANY to mean ``this host.''
40 The distinguished address INADDR_BROADCAST is allowed as a shorthand
41 for the broadcast address on the primary network if the first network
42 configured supports broadcast.
43
45 The Internet protocol family is comprised of the IP transport protocol,
46 Internet Control Message Protocol (ICMP), Transmission Control Protocol
47 (TCP), and User Datagram Protocol (UDP). TCP is used to support the
48 SOCK_STREAM abstraction while UDP is used to support the SOCK_DGRAM
49 abstraction. A raw interface to IP is available by creating an Inter‐
50 net socket of type SOCK_RAW. The ICMP message protocol is accessible
51 from a raw socket.
52
53 The 32-bit Internet address contains both network and host parts. It
54 is frequency-encoded; the most-significant bit is clear in Class A
55 addresses, in which the high-order 8 bits are the network number.
56 Class B addresses use the high-order 16 bits as the network field, and
57 Class C addresses have a 24-bit network part. Sites with a cluster of
58 local networks and a connection to the DARPA Internet may chose to use
59 a single network number for the cluster; this is done by using subnet
60 addressing. The local (host) portion of the address is further subdi‐
61 vided into subnet and host parts. Within a subnet, each subnet appears
62 to be an individual network; externally, the entire cluster appears to
63 be a single, uniform network requiring only a single routing entry.
64 Subnet addressing is enabled and examined by the following ioctl(2)
65 commands on a datagram socket in the Internet domain; they have the
66 same form as the SIOCIFADDR command (see intro(4N)).
67
68 SIOCSIFNETMASK Set interface network mask. The network mask
69 defines the network part of the address; if it con‐
70 tains more of the address than the address type
71 would indicate, then subnets are in use.
72
73 SIOCGIFNETMASK Get interface network mask.
74
76 ioctl(2), socket(2), intro(4N), tcp(4P), udp(4P), ip(4P), icmp(4P)
77
78 An Introductory 4.3BSD Interprocess Communication Tutorial (PS1:7).
79
80 An Advanced 4.3BSD Interprocess Communication Tutorial (PS1:8).
81
83 The Internet protocol support is subject to change as the Internet pro‐
84 tocols develop. Users should not depend on details of the current
85 implementation, but rather the services exported.
86
87
88
894.2 Berkeley Distribution August 1, 1987 INET(4F)