1*61597Sbostic.\" Copyright (c) 1983, 1991, 1993 2*61597Sbostic.\" The Regents of the University of California. All rights reserved. 320724Smckusick.\" 443581Strent.\" %sccs.include.redist.man% 520724Smckusick.\" 6*61597Sbostic.\" @(#)inet.4 8.1 (Berkeley) 06/05/93 736752Sbostic.\" 847675Scael.Dd 947675Scael.Dt INET 4 1047675Scael.Os BSD 4.2 1147675Scael.Sh NAME 1247675Scael.Nm inet 1347675Scael.Nd Internet protocol family 1447675Scael.Sh SYNOPSIS 1547675Scael.Fd #include <sys/types.h> 1647675Scael.Fd #include <netinet/in.h> 1747675Scael.Sh DESCRIPTION 1820724SmckusickThe Internet protocol family is a collection of protocols 1920724Smckusicklayered atop the 2047675Scael.Em Internet Protocol 2147675Scael.Pq Tn IP 2247675Scaeltransport layer, and utilizing the Internet address format. 2320724SmckusickThe Internet family provides protocol support for the 2447675Scael.Dv SOCK_STREAM , SOCK_DGRAM , 2547675Scaeland 2647675Scael.Dv SOCK_RAW 2747675Scaelsocket types; the 2847675Scael.Dv SOCK_RAW 2947675Scaelinterface provides access to the 3047675Scael.Tn IP 3147675Scaelprotocol. 3247675Scael.Sh ADDRESSING 3320724SmckusickInternet addresses are four byte quantities, stored in 3447675Scaelnetwork standard format (on the 3547675Scael.Tn VAX 3647675Scaelthese are word and byte 3720724Smckusickreversed). The include file 3847675Scael.Aq Pa netinet/in.h 3920724Smckusickdefines this address 4020724Smckusickas a discriminated union. 4147675Scael.Pp 4220724SmckusickSockets bound to the Internet protocol family utilize 4320724Smckusickthe following addressing structure, 4447675Scael.Bd -literal -offset indent 4520724Smckusickstruct sockaddr_in { 4620724Smckusick short sin_family; 4720724Smckusick u_short sin_port; 4820724Smckusick struct in_addr sin_addr; 4920724Smckusick char sin_zero[8]; 5020724Smckusick}; 5147675Scael.Ed 5247675Scael.Pp 5347675ScaelSockets may be created with the local address 5447675Scael.Dv INADDR_ANY 5547675Scaelto effect 5647675Scael.Dq wildcard 5747675Scaelmatching on incoming messages. 5828255SkarelsThe address in a 5947675Scael.Xr connect 2 6028255Skarelsor 6147675Scael.Xr sendto 2 6247675Scaelcall may be given as 6347675Scael.Dv INADDR_ANY 6447675Scaelto mean 6547675Scael.Dq this host . 6647675ScaelThe distinguished address 6747675Scael.Dv INADDR_BROADCAST 6828255Skarelsis allowed as a shorthand for the broadcast address on the primary 6928255Skarelsnetwork if the first network configured supports broadcast. 7047675Scael.Sh PROTOCOLS 7120724SmckusickThe Internet protocol family is comprised of 7247675Scaelthe 7347675Scael.Tn IP 7447675Scaeltransport protocol, Internet Control 7547675ScaelMessage Protocol 7647675Scael.Pq Tn ICMP , 7747675ScaelTransmission Control 7847675ScaelProtocol 7947675Scael.Pq Tn TCP , 8047675Scaeland User Datagram Protocol 8147675Scael.Pq Tn UDP . 8247675Scael.Tn TCP 8347675Scaelis used to support the 8447675Scael.Dv SOCK_STREAM 8547675Scaelabstraction while 8647675Scael.Tn UDP 8747675Scaelis used to support the 8847675Scael.Dv SOCK_DGRAM 8947675Scaelabstraction. A raw interface to 9047675Scael.Tn IP 9147675Scaelis available 9247675Scaelby creating an Internet socket of type 9347675Scael.Dv SOCK_RAW . 9447675ScaelThe 9547675Scael.Tn ICMP 9647675Scaelmessage protocol is accessible from a raw socket. 9747675Scael.Pp 9828255SkarelsThe 32-bit Internet address contains both network and host parts. 9928255SkarelsIt is frequency-encoded; the most-significant bit is clear 10028255Skarelsin Class A addresses, in which the high-order 8 bits are the network 10128255Skarelsnumber. 10228255SkarelsClass B addresses use the high-order 16 bits as the network field, 10328255Skarelsand Class C addresses have a 24-bit network part. 10447675ScaelSites with a cluster of local networks and a connection to the 10528255SkarelsInternet may chose to use a single network number for the cluster; 10628255Skarelsthis is done by using subnet addressing. 10728255SkarelsThe local (host) portion of the address is further subdivided 10828255Skarelsinto subnet and host parts. 10928255SkarelsWithin a subnet, each subnet appears to be an individual network; 11028255Skarelsexternally, the entire cluster appears to be a single, uniform 11128255Skarelsnetwork requiring only a single routing entry. 11228255SkarelsSubnet addressing is enabled and examined by the following 11347675Scael.Xr ioctl 2 11428255Skarelscommands on a datagram socket in the Internet domain; 11528255Skarelsthey have the same form as the 11647675Scael.Dv SIOCIFADDR 11747675Scaelcommand (see 11847675Scael.Xr intro 4 ) . 11947675Scael.Pp 12047675Scael.Bl -tag -width SIOCSIFNETMASK 12147675Scael.It Dv SIOCSIFNETMASK 12228255SkarelsSet interface network mask. 12328255SkarelsThe network mask defines the network part of the address; 12428255Skarelsif it contains more of the address than the address type would indicate, 12528255Skarelsthen subnets are in use. 12647675Scael.It Dv SIOCGIFNETMASK 12728255SkarelsGet interface network mask. 12847675Scael.El 12947675Scael.Sh SEE ALSO 13047675Scael.Xr ioctl 2 , 13147675Scael.Xr socket 2 , 13247675Scael.Xr intro 4 , 13347675Scael.Xr tcp 4 , 13447675Scael.Xr udp 4 , 13547675Scael.Xr ip 4 , 13647675Scael.Xr icmp 4 13747675Scael.Rs 13847675Scael.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" 13947675Scael.%B PS1 14047675Scael.%N 7 14147675Scael.Re 14247675Scael.Rs 14347675Scael.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial" 14447675Scael.%B PS1 14547675Scael.%N 8 14647675Scael.Re 14747675Scael.Sh CAVEAT 14820724SmckusickThe Internet protocol support is subject to change as 14920724Smckusickthe Internet protocols develop. Users should not depend 15020724Smckusickon details of the current implementation, but rather 15120724Smckusickthe services exported. 15247675Scael.Sh HISTORY 15347675ScaelThe 15447675Scael.Nm 15547675Scaelprotocol interface appeared in 15647675Scael.Bx 4.2 . 157