


INET(4F)                PROTOCOL FAMILIES                INET(4F)



NAME
     inet - Internet protocol family

SYNOPSIS
     options INET

     #include <sys/types.h>
     #include <netinet/in.h>

DESCRIPTION
     The Internet protocol family implements a collection of pro-
     tocols  which are centered around the _I_n_t_e_r_n_e_t _P_r_o_t_o_c_o_l (IP)
     and which share a common address format.  The Internet  fam-
     ily   provides   protocol   support   for  the  SOCK_STREAM,
     SOCK_DGRAM, and SOCK_RAW socket types.

PROTOCOLS
     The Internet protocol family is comprised  of  the  Internet
     Protocol  (IP),  the  Address Resolution Protocol (ARP), the
     Internet Control Message Protocol (ICMP),  the  Transmission
     Control  Protocol  (TCP),  and  the  User  Datagram Protocol
     (UDP).

     TCP is used to support the SOCK_STREAM abstraction while UDP
     is  used  to support the SOCK_DGRAM abstraction; see tcp(4P)
     and udp(4P).  A raw interface to IP is available by creating
     an  Internet  socket  of type SOCK_RAW; see ip(4P).  ICMP is
     used by the kernel to handle and report errors  in  protocol
     processing.   It  is  also  accessible to user programs; see
     icmp(4P).  ARP is used to translate 32-bit IP addresses into
     48-bit Ethernet addresses; see arp(4P).

     The 32-bit IP address is divided  into  network  number  and
     host  number  parts.   It  is  frequency-encoded;  the most-
     significant bit is zero in Class A addresses, in  which  the
     high-order 8 bits are the network number.  Class B addresses
     have their high order two bits set to 10 and use  the  high-
     order  16  bits  as  the  network  number  field.   Class  C
     addresses have a 24-bit network number  part  of  which  the
     high  order  three  bits  are  110.  Sites with a cluster of
     local networks may chose to use a single network number  for
     the  cluster;  this is done by using subnet addressing.  The
     local (host) portion of the address  is  further  subdivided
     into  subnet number and host number parts.  Within a subnet,
     each subnet appears to be an individual network; externally,
     the  entire  cluster appears to be a single, uniform network
     requiring only a single routing entry.  Subnet addressing is
     enabled and examined by the following ioctl(2) commands on a
     datagram socket in the Internet domain; they have  the  same
     form as the SIOCIFADDR command (see intro(4)).





Sun Release 4.1   Last change: 18 February 1988                 1






INET(4F)                PROTOCOL FAMILIES                INET(4F)



     SIOCSIFNETMASK      Set interface network mask.  The network
                         mask  defines  the  network  part of the
                         address; if  it  contains  more  of  the
                         address  than  the  address  type  would
                         indicate, then subnets are in use.

     SIOCGIFNETMASK      Get interface network mask.

ADDRESSING
     IP addresses are four byte  quantities,  stored  in  network
     byte  order  (on  Sun386i  systems  these  are word and byte
     reversed).

     Sockets in the Internet protocol family  use  the  following
     addressing structure:
          struct sockaddr_in {
               short     sin_family;
               u_short   sin_port;
               struct    in_addr sin_addr;
               char sin_zero[8];
          };

     Library routines are provided to  manipulate  structures  of
     this form; see intro(3).

     The sin_addr field of the sockaddr_in structure specifies  a
     local  or remote IP address.  Each network interface has its
     own unique IP address.  The special value INADDR_ANY may  be
     used  in this field to effect "wildcard" matching.  Given in
     a bind(2) call, this value leaves the local  IP  address  of
     the socket unspecified, so that the socket will receive con-
     nections or  messages  directed  at  any  of  the  valid  IP
     addresses  of the system.  This can prove useful when a pro-
     cess neither knows nor cares what the local IP address is or
     when  a  process wishes to receive requests using all of its
     network interfaces.  The sockaddr_in structure given in  the
     bind(2)  call  must  specify  an  in_addr  value  of  either
     IPADDR_ANY or  one  of  the  system's  valid  IP  addresses.
     Requests  to  bind  any  other address will elicit the error
     EADDRNOTAVAIL. When a connect(2) call is made for  a  socket
     that  has  a  wildcard  local  address,  the system sets the
     sin_addr field of the socket to the IP address of  the  net-
     work  interface  that  the  packets  for that connection are
     routed via.

     The sin_port field of the sockaddr_in structure specifies  a
     port  number  used  by  TCP  or  UDP. The local port address
     specified in a bind(2) call is restricted to be greater than
     IPPORT_RESERVED   (defined  in  <netinet/in.h>)  unless  the
     creating process is running as the super-user,  providing  a
     space  of  protected  port  numbers.  In addition, the local
     port address must not be  in  use  by  any  socket  of  same



Sun Release 4.1   Last change: 18 February 1988                 2






INET(4F)                PROTOCOL FAMILIES                INET(4F)



     address  family  and type.  Requests to bind sockets to port
     numbers being used by other sockets return  the  error  EAD-
     DRINUSE.  If  the local port address is specified as 0, then
     the  system  picks  a  unique  port  address  greater   than
     IPPORT_RESERVED.  A unique local port address is also picked
     when a socket which is not bound is used in a connect(2)  or
     send(2)  call.  This allows programs which do not care which
     local port number is used to set up TCP connections by  sim-
     ply  calling  socket(2) and then connect(2), and to send UDP
     datagrams with a socket(2) call followed by a send(2) call.

     Although this implementation  restricts  sockets  to  unique
     local port numbers, TCP allows multiple simultaneous connec-
     tions involving the same local port number so  long  as  the
     remote  IP  addresses or port numbers are different for each
     connection.  Programs may  explicitly  override  the  socket
     restriction  by  setting the SO_REUSEADDR socket option with
     setsockopt (see getsockopt(2)).

SEE ALSO
     bind(2),  connect(2),  getsockopt(2),   ioctl(2),   send(2),
     socket(2),    intro(3),    byteorder(3N),    gethostent(3N),
     getnetent(3N),  getprotoent(3N),  getservent(3N),  inet(3N),
     intro(4), arp(4P), icmp(4P), ip(4P) tcp(4P), udp(4P)

     Network Information Center, _D_D_N _P_r_o_t_o_c_o_l _H_a_n_d_b_o_o_k (3 vols.),
     Network  Information  Center, SRI International, Menlo Park,
     Calif., 1985.
     _A _4._2_B_S_D _I_n_t_e_r_p_r_o_c_e_s_s _C_o_m_m_u_n_i_c_a_t_i_o_n _P_r_i_m_e_r

WARNING
     The Internet protocol support is subject to  change  as  the
     Internet  protocols  develop.   Users  should  not depend on
     details of the current implementation, but rather  the  ser-
     vices exported.




















Sun Release 4.1   Last change: 18 February 1988                 3



