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