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