1afe61c15SRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993 2afe61c15SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 3afe61c15SRodney W. Grimes.\" 4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions 6afe61c15SRodney W. Grimes.\" are met: 7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 8afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 10afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 11afe61c15SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 13afe61c15SRodney W. Grimes.\" must display the following acknowledgement: 14afe61c15SRodney W. Grimes.\" This product includes software developed by the University of 15afe61c15SRodney W. Grimes.\" California, Berkeley and its contributors. 16afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 17afe61c15SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 18afe61c15SRodney W. Grimes.\" without specific prior written permission. 19afe61c15SRodney W. Grimes.\" 20afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23afe61c15SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30afe61c15SRodney W. Grimes.\" SUCH DAMAGE. 31afe61c15SRodney W. Grimes.\" 32a2cc1fa2SGarrett Wollman.\" From: @(#)inet.4 8.1 (Berkeley) 6/5/93 330b992c1dSWolfram Schneider.\" $Id: inet.4,v 1.4 1996/08/22 23:51:13 mpp Exp $ 34afe61c15SRodney W. Grimes.\" 35a2cc1fa2SGarrett Wollman.Dd February 14, 1995 36afe61c15SRodney W. Grimes.Dt INET 4 37afe61c15SRodney W. Grimes.Os BSD 4.2 38afe61c15SRodney W. Grimes.Sh NAME 39afe61c15SRodney W. Grimes.Nm inet 40afe61c15SRodney W. Grimes.Nd Internet protocol family 41afe61c15SRodney W. Grimes.Sh SYNOPSIS 42afe61c15SRodney W. Grimes.Fd #include <sys/types.h> 43afe61c15SRodney W. Grimes.Fd #include <netinet/in.h> 44afe61c15SRodney W. Grimes.Sh DESCRIPTION 45afe61c15SRodney W. GrimesThe Internet protocol family is a collection of protocols 46afe61c15SRodney W. Grimeslayered atop the 47afe61c15SRodney W. Grimes.Em Internet Protocol 48afe61c15SRodney W. Grimes.Pq Tn IP 49afe61c15SRodney W. Grimestransport layer, and utilizing the Internet address format. 50afe61c15SRodney W. GrimesThe Internet family provides protocol support for the 51afe61c15SRodney W. Grimes.Dv SOCK_STREAM , SOCK_DGRAM , 52afe61c15SRodney W. Grimesand 53afe61c15SRodney W. Grimes.Dv SOCK_RAW 54afe61c15SRodney W. Grimessocket types; the 55afe61c15SRodney W. Grimes.Dv SOCK_RAW 56afe61c15SRodney W. Grimesinterface provides access to the 57afe61c15SRodney W. Grimes.Tn IP 58afe61c15SRodney W. Grimesprotocol. 59afe61c15SRodney W. Grimes.Sh ADDRESSING 60afe61c15SRodney W. GrimesInternet addresses are four byte quantities, stored in 61afe61c15SRodney W. Grimesnetwork standard format (on the 62afe61c15SRodney W. Grimes.Tn VAX 63afe61c15SRodney W. Grimesthese are word and byte 64afe61c15SRodney W. Grimesreversed). The include file 65afe61c15SRodney W. Grimes.Aq Pa netinet/in.h 66afe61c15SRodney W. Grimesdefines this address 67afe61c15SRodney W. Grimesas a discriminated union. 68afe61c15SRodney W. Grimes.Pp 69afe61c15SRodney W. GrimesSockets bound to the Internet protocol family utilize 70afe61c15SRodney W. Grimesthe following addressing structure, 71afe61c15SRodney W. Grimes.Bd -literal -offset indent 72afe61c15SRodney W. Grimesstruct sockaddr_in { 73afe61c15SRodney W. Grimes short sin_family; 74afe61c15SRodney W. Grimes u_short sin_port; 75afe61c15SRodney W. Grimes struct in_addr sin_addr; 76afe61c15SRodney W. Grimes char sin_zero[8]; 77afe61c15SRodney W. Grimes}; 78afe61c15SRodney W. Grimes.Ed 79afe61c15SRodney W. Grimes.Pp 80afe61c15SRodney W. GrimesSockets may be created with the local address 81afe61c15SRodney W. Grimes.Dv INADDR_ANY 82afe61c15SRodney W. Grimesto effect 83afe61c15SRodney W. Grimes.Dq wildcard 84afe61c15SRodney W. Grimesmatching on incoming messages. 85afe61c15SRodney W. GrimesThe address in a 86afe61c15SRodney W. Grimes.Xr connect 2 87afe61c15SRodney W. Grimesor 88afe61c15SRodney W. Grimes.Xr sendto 2 89afe61c15SRodney W. Grimescall may be given as 90afe61c15SRodney W. Grimes.Dv INADDR_ANY 91afe61c15SRodney W. Grimesto mean 92afe61c15SRodney W. Grimes.Dq this host . 93afe61c15SRodney W. GrimesThe distinguished address 94afe61c15SRodney W. Grimes.Dv INADDR_BROADCAST 95afe61c15SRodney W. Grimesis allowed as a shorthand for the broadcast address on the primary 96afe61c15SRodney W. Grimesnetwork if the first network configured supports broadcast. 97afe61c15SRodney W. Grimes.Sh PROTOCOLS 98afe61c15SRodney W. GrimesThe Internet protocol family is comprised of 99afe61c15SRodney W. Grimesthe 100afe61c15SRodney W. Grimes.Tn IP 101a2cc1fa2SGarrett Wollmannetwork protocol, Internet Control 102afe61c15SRodney W. GrimesMessage Protocol 103afe61c15SRodney W. Grimes.Pq Tn ICMP , 104a2cc1fa2SGarrett WollmanInternet Group Management Protocol 105a2cc1fa2SGarrett Wollman.Pq Tn IGMP , 106afe61c15SRodney W. GrimesTransmission Control 107afe61c15SRodney W. GrimesProtocol 108afe61c15SRodney W. Grimes.Pq Tn TCP , 109afe61c15SRodney W. Grimesand User Datagram Protocol 110afe61c15SRodney W. Grimes.Pq Tn UDP . 111afe61c15SRodney W. Grimes.Tn TCP 112afe61c15SRodney W. Grimesis used to support the 113afe61c15SRodney W. Grimes.Dv SOCK_STREAM 114afe61c15SRodney W. Grimesabstraction while 115afe61c15SRodney W. Grimes.Tn UDP 116afe61c15SRodney W. Grimesis used to support the 117afe61c15SRodney W. Grimes.Dv SOCK_DGRAM 118afe61c15SRodney W. Grimesabstraction. A raw interface to 119afe61c15SRodney W. Grimes.Tn IP 120afe61c15SRodney W. Grimesis available 121afe61c15SRodney W. Grimesby creating an Internet socket of type 122afe61c15SRodney W. Grimes.Dv SOCK_RAW . 123afe61c15SRodney W. GrimesThe 124afe61c15SRodney W. Grimes.Tn ICMP 125afe61c15SRodney W. Grimesmessage protocol is accessible from a raw socket. 126afe61c15SRodney W. Grimes.Pp 127afe61c15SRodney W. GrimesThe 32-bit Internet address contains both network and host parts. 128a2cc1fa2SGarrett WollmanHowever, direct examination of addresses is discouraged. For those 129a2cc1fa2SGarrett Wollmanprograms which absolutely need to break addresses into their component 130a2cc1fa2SGarrett Wollmanparts, the following 131afe61c15SRodney W. Grimes.Xr ioctl 2 132a2cc1fa2SGarrett Wollmancommands are provided for a datagram socket in the Internet domain; 133afe61c15SRodney W. Grimesthey have the same form as the 134afe61c15SRodney W. Grimes.Dv SIOCIFADDR 135afe61c15SRodney W. Grimescommand (see 136afe61c15SRodney W. Grimes.Xr intro 4 ) . 137afe61c15SRodney W. Grimes.Pp 138afe61c15SRodney W. Grimes.Bl -tag -width SIOCSIFNETMASK 139afe61c15SRodney W. Grimes.It Dv SIOCSIFNETMASK 140afe61c15SRodney W. GrimesSet interface network mask. 141afe61c15SRodney W. GrimesThe network mask defines the network part of the address; 142afe61c15SRodney W. Grimesif it contains more of the address than the address type would indicate, 143afe61c15SRodney W. Grimesthen subnets are in use. 144afe61c15SRodney W. Grimes.It Dv SIOCGIFNETMASK 145afe61c15SRodney W. GrimesGet interface network mask. 146afe61c15SRodney W. Grimes.El 147a2cc1fa2SGarrett Wollman.Sh ROUTING 148a2cc1fa2SGarrett WollmanThe current implementation of Internet protocols includes some routing-table 149a2cc1fa2SGarrett Wollmanadaptations to provide enhanced caching of certain end-to-end 150a2cc1fa2SGarrett Wollmaninformation necessary for Transaction TCP and Path MTU Discovery. The 151a2cc1fa2SGarrett Wollmanfollowing changes are the most significant: 152a2cc1fa2SGarrett Wollman.Bl -enum 153a2cc1fa2SGarrett Wollman.It 154a2cc1fa2SGarrett WollmanAll IP routes, except those with the 155a2cc1fa2SGarrett Wollman.Dv RTF_CLONING 156a2cc1fa2SGarrett Wollmanflag and those to multicast destinations, have the 157a2cc1fa2SGarrett Wollman.Dv RTF_PRCLONING 158a2cc1fa2SGarrett Wollmanflag forcibly enabled (they are thus said to be 159a2cc1fa2SGarrett Wollman.Dq "protocol cloning" ). 160a2cc1fa2SGarrett Wollman.It 161a2cc1fa2SGarrett WollmanWhen the last reference to an IP route is dropped, the route is 162a2cc1fa2SGarrett Wollmanexamined to determine if it was created by cloning such a route. If 163a2cc1fa2SGarrett Wollmanthis is the case, the 164a2cc1fa2SGarrett Wollman.Dv RTF_PROTO3 165a2cc1fa2SGarrett Wollmanflag is turned on, and the expiration timer is initialized to go off 166a2cc1fa2SGarrett Wollmanin net.inet.ip.rtexpire seconds. If such a route is re-referenced, 167a2cc1fa2SGarrett Wollmanthe flag and expiration timer are reset. 168a2cc1fa2SGarrett Wollman.It 169a2cc1fa2SGarrett WollmanA kernel timeout runs once every ten minutes, or sooner if there are 170a2cc1fa2SGarrett Wollmansoon-to-expire routes in the kernel routing table, and deletes the 171a2cc1fa2SGarrett Wollmanexpired routes. 172a2cc1fa2SGarrett Wollman.El 173a2cc1fa2SGarrett Wollman.Pp 174a2cc1fa2SGarrett WollmanA dynamic process is in place to modify the value of 175a2cc1fa2SGarrett Wollmannet.inet.ip.rtexpire if the number of cached routes grows too large. 176a2cc1fa2SGarrett WollmanIf after an expiration run there are still more than 177a2cc1fa2SGarrett Wollmannet.inet.ip.rtmaxcache unreferenced routes remaining, the rtexpire 178a2cc1fa2SGarrett Wollmanvalue is multiplied by 3/4, and any routes which have longer 179a2cc1fa2SGarrett Wollmanexpiration times have those times adjusted. This process is damped 180a2cc1fa2SGarrett Wollmansomewhat by specification of a minimum rtexpire value 181a2cc1fa2SGarrett Wollman(net.inet.ip.rtminexpire), and by restricting the reduction to once in 182a2cc1fa2SGarrett Wollmana ten-minute period. 183a2cc1fa2SGarrett Wollman.Pp 184a2cc1fa2SGarrett WollmanIf some external process deletes the original route from which a 185a2cc1fa2SGarrett Wollmanprotocol-cloned route was generated, the ``child route'' is deleted. 186a2cc1fa2SGarrett Wollman(This is actually a generic mechanism in the routing code support for 187a2cc1fa2SGarrett Wollmanprotocol-requested cloning.) 188a2cc1fa2SGarrett Wollman.Pp 189a2cc1fa2SGarrett WollmanNo attempt is made to manage routes which were not created by protocol 190a2cc1fa2SGarrett Wollmancloning; these are assumed to be static, under the management of an 191a2cc1fa2SGarrett Wollmanexternal routing process, or under the management of a link layer 192a2cc1fa2SGarrett Wollman(e.g., 193a2cc1fa2SGarrett Wollman.Tn ARP 194a2cc1fa2SGarrett Wollmanfor Ethernets). 195a2cc1fa2SGarrett Wollman.Pp 196a2cc1fa2SGarrett WollmanOnly certain types of network activity will result in the cloning of a 197a2cc1fa2SGarrett Wollmanroute using this mechanism. Specifically, those protocols (such as 198a2cc1fa2SGarrett Wollman.Tn TCP 199a2cc1fa2SGarrett Wollmanand 200a2cc1fa2SGarrett Wollman.Tn UDP ) 201a2cc1fa2SGarrett Wollmanwhich themselves cache a long-lasting reference to route for a destination 202a2cc1fa2SGarrett Wollmanwill trigger the mechanism; whereas raw 203a2cc1fa2SGarrett Wollman.Tn IP 204a2cc1fa2SGarrett Wollmanpackets, whether locally-generated or forwarded, will not. 205a2cc1fa2SGarrett Wollman.Sh MIB VARIABLES 206a2cc1fa2SGarrett WollmanA number of variables are implemented in the net.inet branch of the 207a2cc1fa2SGarrett Wollman.Xr sysctl 3 208a2cc1fa2SGarrett WollmanMIB. In addition to the variables supported by the transport 209a2cc1fa2SGarrett Wollmanprotocols (for which see the respective manual pages), the following 210a2cc1fa2SGarrett Wollmangeneral variables are defined: 211a2cc1fa2SGarrett Wollman.Bl -tag -width IPCTL_SENDREDIRECTS 212a2cc1fa2SGarrett Wollman.It Dv IPCTL_FORWARDING 213a2cc1fa2SGarrett Wollman.Pq ip.forwarding 214a2cc1fa2SGarrett WollmanBoolean: enable/disable forwarding of IP packets (default depends on 215a2cc1fa2SGarrett Wollmanthe 216a2cc1fa2SGarrett Wollman.Dv GATEWAY 217a2cc1fa2SGarrett Wollmankernel configuration option). 218a2cc1fa2SGarrett Wollman.It Dv IPCTL_SENDREDIRECTS 219a2cc1fa2SGarrett Wollman.Pq ip.redirect 220a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to 221a2cc1fa2SGarrett Wollmanunforwardable 222a2cc1fa2SGarrett Wollman.Tn IP 223a2cc1fa2SGarrett Wollmanpackets (default true). 224a2cc1fa2SGarrett Wollman.It Dv IPCTL_DEFTTL 225a2cc1fa2SGarrett Wollman.Pq ip.ttl 226a2cc1fa2SGarrett WollmanInteger: default time-to-live 227a2cc1fa2SGarrett Wollman.Pq Dq TTL 228a2cc1fa2SGarrett Wollmanto use for outgoing 229a2cc1fa2SGarrett Wollman.Tn IP 230a2cc1fa2SGarrett Wollmanpackets. 2310e5ca0d8SGarrett Wollman.It Dv IPCTL_SOURCEROUTE 2320e5ca0d8SGarrett Wollman.Pq ip.sourceroute 2330e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false). 234a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTEXPIRE 235a2cc1fa2SGarrett Wollman.Pq ip.rtexpire 236a2cc1fa2SGarrett WollmanInteger: lifetime in seconds of protocol-cloned 237a2cc1fa2SGarrett Wollman.Tn IP 238a2cc1fa2SGarrett Wollmanroutes after the last reference drops (default one hour). This value 239a2cc1fa2SGarrett Wollmanvaries dynamically as described above. 240a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMINEXPIRE 241a2cc1fa2SGarrett Wollman.Pq ip.rtminexpire 242a2cc1fa2SGarrett WollmanInteger: minimum value of ip.rtexpire (default ten seconds). This 243a2cc1fa2SGarrett Wollmanvalue has no effect on user modifications, but restricts the dynamic 244a2cc1fa2SGarrett Wollmanadaptation described above. 245a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMAXCACHE 246a2cc1fa2SGarrett Wollman.Pq ip.rtmaxcache 247a2cc1fa2SGarrett WollmanInteger: trigger level of cached, unreferenced, protocol-cloned routes 248a2cc1fa2SGarrett Wollmanwhich initiates dynamic adaptation (default 128). 249a2cc1fa2SGarrett Wollman.El 250afe61c15SRodney W. Grimes.Sh SEE ALSO 251afe61c15SRodney W. Grimes.Xr ioctl 2 , 252afe61c15SRodney W. Grimes.Xr socket 2 , 253a2cc1fa2SGarrett Wollman.Xr sysctl 3 , 2540b992c1dSWolfram Schneider.Xr icmp 4 , 2550b992c1dSWolfram Schneider.Xr igmp 4 , 256afe61c15SRodney W. Grimes.Xr intro 4 , 2570b992c1dSWolfram Schneider.Xr ip 4 , 258afe61c15SRodney W. Grimes.Xr tcp 4 , 259a2cc1fa2SGarrett Wollman.Xr ttcp 4 , 2600b992c1dSWolfram Schneider.Xr udp 4 261afe61c15SRodney W. Grimes.Rs 262afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" 263afe61c15SRodney W. Grimes.%B PS1 264afe61c15SRodney W. Grimes.%N 7 265afe61c15SRodney W. Grimes.Re 266afe61c15SRodney W. Grimes.Rs 267afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial" 268afe61c15SRodney W. Grimes.%B PS1 269afe61c15SRodney W. Grimes.%N 8 270afe61c15SRodney W. Grimes.Re 271afe61c15SRodney W. Grimes.Sh CAVEAT 272afe61c15SRodney W. GrimesThe Internet protocol support is subject to change as 273afe61c15SRodney W. Grimesthe Internet protocols develop. Users should not depend 274afe61c15SRodney W. Grimeson details of the current implementation, but rather 275afe61c15SRodney W. Grimesthe services exported. 276afe61c15SRodney W. Grimes.Sh HISTORY 277afe61c15SRodney W. GrimesThe 278afe61c15SRodney W. Grimes.Nm 279afe61c15SRodney W. Grimesprotocol interface appeared in 280afe61c15SRodney W. Grimes.Bx 4.2 . 281a2cc1fa2SGarrett WollmanThe 282a2cc1fa2SGarrett Wollman.Dq protocol cloning 283a2cc1fa2SGarrett Wollmancode appeared in 28446f84fcbSMike Pritchard.Fx 2.1 . 285