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