1.\" Copyright (c) 1983, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" from: @(#)inet.4 6.6 (Berkeley) 3/28/91 33.\" $Id: inet.4,v 1.2 1993/08/01 07:56:00 mycroft Exp $ 34.\" 35.Dd March 28, 1991 36.Dt INET 4 37.Os BSD 4.2 38.Sh NAME 39.Nm inet 40.Nd Internet protocol family 41.Sh SYNOPSIS 42.Fd #include <sys/types.h> 43.Fd #include <netinet/in.h> 44.Sh DESCRIPTION 45The Internet protocol family is a collection of protocols 46layered atop the 47.Em Internet Protocol 48.Pq Tn IP 49transport layer, and utilizing the Internet address format. 50The Internet family provides protocol support for the 51.Dv SOCK_STREAM , SOCK_DGRAM , 52and 53.Dv SOCK_RAW 54socket types; the 55.Dv SOCK_RAW 56interface provides access to the 57.Tn IP 58protocol. 59.Sh ADDRESSING 60Internet addresses are four byte quantities, stored in 61network standard format (on the 62.Tn VAX 63these are word and byte 64reversed). The include file 65.Aq Pa netinet/in.h 66defines this address 67as a discriminated union. 68.Pp 69Sockets bound to the Internet protocol family utilize 70the following addressing structure, 71.Bd -literal -offset indent 72struct sockaddr_in { 73 short sin_family; 74 u_short sin_port; 75 struct in_addr sin_addr; 76 char sin_zero[8]; 77}; 78.Ed 79.Pp 80Sockets may be created with the local address 81.Dv INADDR_ANY 82to effect 83.Dq wildcard 84matching on incoming messages. 85The address in a 86.Xr connect 2 87or 88.Xr sendto 2 89call may be given as 90.Dv INADDR_ANY 91to mean 92.Dq this host . 93The distinguished address 94.Dv INADDR_BROADCAST 95is allowed as a shorthand for the broadcast address on the primary 96network if the first network configured supports broadcast. 97.Sh PROTOCOLS 98The Internet protocol family is comprised of 99the 100.Tn IP 101transport protocol, Internet Control 102Message Protocol 103.Pq Tn ICMP , 104Transmission Control 105Protocol 106.Pq Tn TCP , 107and User Datagram Protocol 108.Pq Tn UDP . 109.Tn TCP 110is used to support the 111.Dv SOCK_STREAM 112abstraction while 113.Tn UDP 114is used to support the 115.Dv SOCK_DGRAM 116abstraction. A raw interface to 117.Tn IP 118is available 119by creating an Internet socket of type 120.Dv SOCK_RAW . 121The 122.Tn ICMP 123message protocol is accessible from a raw socket. 124.Pp 125The 32-bit Internet address contains both network and host parts. 126It is frequency-encoded; the most-significant bit is clear 127in Class A addresses, in which the high-order 8 bits are the network 128number. 129Class B addresses use the high-order 16 bits as the network field, 130and Class C addresses have a 24-bit network part. 131Sites with a cluster of local networks and a connection to the 132.Tn DARPA 133Internet may chose to use a single network number for the cluster; 134this is done by using subnet addressing. 135The local (host) portion of the address is further subdivided 136into subnet and host parts. 137Within a subnet, each subnet appears to be an individual network; 138externally, the entire cluster appears to be a single, uniform 139network requiring only a single routing entry. 140Subnet addressing is enabled and examined by the following 141.Xr ioctl 2 142commands on a datagram socket in the Internet domain; 143they have the same form as the 144.Dv SIOCIFADDR 145command (see 146.Xr intro 4 ) . 147.Pp 148.Bl -tag -width SIOCSIFNETMASK 149.It Dv SIOCSIFNETMASK 150Set interface network mask. 151The network mask defines the network part of the address; 152if it contains more of the address than the address type would indicate, 153then subnets are in use. 154.It Dv SIOCGIFNETMASK 155Get interface network mask. 156.El 157.Sh SEE ALSO 158.Xr ioctl 2 , 159.Xr socket 2 , 160.Xr intro 4 , 161.Xr tcp 4 , 162.Xr udp 4 , 163.Xr ip 4 , 164.Xr icmp 4 165.Rs 166.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" 167.%B PS1 168.%N 7 169.Re 170.Rs 171.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial" 172.%B PS1 173.%N 8 174.Re 175.Sh CAVEAT 176The Internet protocol support is subject to change as 177the Internet protocols develop. Users should not depend 178on details of the current implementation, but rather 179the services exported. 180.Sh HISTORY 181The 182.Nm 183protocol interface appeared in 184.Bx 4.2 . 185