1.\" Copyright (c) 1983, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)inet.4 6.6 (Berkeley) 03/28/91 7.\" 8.Dd 9.Dt INET 4 10.Os BSD 4.2 11.Sh NAME 12.Nm inet 13.Nd Internet protocol family 14.Sh SYNOPSIS 15.Fd #include <sys/types.h> 16.Fd #include <netinet/in.h> 17.Sh DESCRIPTION 18The Internet protocol family is a collection of protocols 19layered atop the 20.Em Internet Protocol 21.Pq Tn IP 22transport layer, and utilizing the Internet address format. 23The Internet family provides protocol support for the 24.Dv SOCK_STREAM , SOCK_DGRAM , 25and 26.Dv SOCK_RAW 27socket types; the 28.Dv SOCK_RAW 29interface provides access to the 30.Tn IP 31protocol. 32.Sh ADDRESSING 33Internet addresses are four byte quantities, stored in 34network standard format (on the 35.Tn VAX 36these are word and byte 37reversed). The include file 38.Aq Pa netinet/in.h 39defines this address 40as a discriminated union. 41.Pp 42Sockets bound to the Internet protocol family utilize 43the following addressing structure, 44.Bd -literal -offset indent 45struct sockaddr_in { 46 short sin_family; 47 u_short sin_port; 48 struct in_addr sin_addr; 49 char sin_zero[8]; 50}; 51.Ed 52.Pp 53Sockets may be created with the local address 54.Dv INADDR_ANY 55to effect 56.Dq wildcard 57matching on incoming messages. 58The address in a 59.Xr connect 2 60or 61.Xr sendto 2 62call may be given as 63.Dv INADDR_ANY 64to mean 65.Dq this host . 66The distinguished address 67.Dv INADDR_BROADCAST 68is allowed as a shorthand for the broadcast address on the primary 69network if the first network configured supports broadcast. 70.Sh PROTOCOLS 71The Internet protocol family is comprised of 72the 73.Tn IP 74transport protocol, Internet Control 75Message Protocol 76.Pq Tn ICMP , 77Transmission Control 78Protocol 79.Pq Tn TCP , 80and User Datagram Protocol 81.Pq Tn UDP . 82.Tn TCP 83is used to support the 84.Dv SOCK_STREAM 85abstraction while 86.Tn UDP 87is used to support the 88.Dv SOCK_DGRAM 89abstraction. A raw interface to 90.Tn IP 91is available 92by creating an Internet socket of type 93.Dv SOCK_RAW . 94The 95.Tn ICMP 96message protocol is accessible from a raw socket. 97.Pp 98The 32-bit Internet address contains both network and host parts. 99It is frequency-encoded; the most-significant bit is clear 100in Class A addresses, in which the high-order 8 bits are the network 101number. 102Class B addresses use the high-order 16 bits as the network field, 103and Class C addresses have a 24-bit network part. 104Sites with a cluster of local networks and a connection to the 105.Tn DARPA 106Internet may chose to use a single network number for the cluster; 107this is done by using subnet addressing. 108The local (host) portion of the address is further subdivided 109into subnet and host parts. 110Within a subnet, each subnet appears to be an individual network; 111externally, the entire cluster appears to be a single, uniform 112network requiring only a single routing entry. 113Subnet addressing is enabled and examined by the following 114.Xr ioctl 2 115commands on a datagram socket in the Internet domain; 116they have the same form as the 117.Dv SIOCIFADDR 118command (see 119.Xr intro 4 ) . 120.Pp 121.Bl -tag -width SIOCSIFNETMASK 122.It Dv SIOCSIFNETMASK 123Set interface network mask. 124The network mask defines the network part of the address; 125if it contains more of the address than the address type would indicate, 126then subnets are in use. 127.It Dv SIOCGIFNETMASK 128Get interface network mask. 129.El 130.Sh SEE ALSO 131.Xr ioctl 2 , 132.Xr socket 2 , 133.Xr intro 4 , 134.Xr tcp 4 , 135.Xr udp 4 , 136.Xr ip 4 , 137.Xr icmp 4 138.Rs 139.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" 140.%B PS1 141.%N 7 142.Re 143.Rs 144.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial" 145.%B PS1 146.%N 8 147.Re 148.Sh CAVEAT 149The Internet protocol support is subject to change as 150the Internet protocols develop. Users should not depend 151on details of the current implementation, but rather 152the services exported. 153.Sh HISTORY 154The 155.Nm 156protocol interface appeared in 157.Bx 4.2 . 158