Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ip(7) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

read(2)

write(2)

connect(3N)

getsockopt(3N)

recv(3N)

send(3N)

routing(4)

icmp(7)

inet(7)

tcp(7)

udp(7)

ip(7)                                                                 ip(7)

NAME
     ip - Internet Protocol

SYNOPSIS
     #include <sys/socket.h>
     #include <netinet/in.h>

     s = socket(AFINET, SOCKRAW, proto);

     t = topen ("/dev/rawip", ORDWR);

     d = open ("/dev/ip", ORDWR);

DESCRIPTION
     IP is the internetwork datagram delivery protocol that is central to
     the Internet protocol family. Programs may use IP through higher-level
     protocols such as the Transmission Control Protocol (TCP) or the User
     Datagram Protocol (UDP), or may interface directly to IP. See tcp(7)
     and udp(7). Direct access may be via the socket interface (using a
     "raw socket") or the Transport Level Interface (TLI). The protocol
     options defined in the IP specification may be set in outgoing
     datagrams.

     The STREAMS driver /dev/rawip is the TLI transport provider that pro-
     vides raw access to IP. The device /dev/ip is the multiplexing STREAMS
     driver that implements the protocol processing of IP. The latter con-
     nects below to datalink providers [interface drivers, see if(7)], and
     above to tranport providers such as TCP and UDP.

     Raw IP sockets are connectionless and are normally used with the
     sendto() and recvfrom() calls, [see send(2) and recv(2)] although the
     connect(2) call may also be used to fix the destination for future
     datagrams [in which case the read(2) or recv(3N) and write(2) or
     send(3N) calls may be used]. If proto is zero, the default protocol,
     IPPROTORAW, is used. If proto is non-zero, that protocol number will
     be set in outgoing datagrams and will be used to filter incoming
     datagrams. An IP header will be generated and prepended to each outgo-
     ing datagram; received datagrams are returned with the IP header and
     options intact.

     The IP level socket option IPOPTIONS may be used to set IP options to
     be included in each outgoing datagram. IP options to be sent are set
     with setsockopt() [see getsockopt(3N)]. The getsockopt(3N) call
     returns the IP options set in the last setsockopt() call. IP options
     on received datagrams are visible to user programs only using raw IP
     sockets. The format of IP options given in setsockopt() matches those
     defined in the IP specification with one exception: the list of
     addresses for the source routing options must include the first-hop
     gateway at the beginning of the list of gateways. The first-hop gate-
     way address will be extracted from the option list and the size
     adjusted accordingly before use. IP options may be used with any
     socket type in the Internet family.



Page 1                       Reliant UNIX 5.44                Printed 11/98

ip(7)                                                                 ip(7)

     At the socket level, the socket option SODONTROUTE may be applied.
     This option forces datagrams being sent to bypass the routing step in
     output. Normally, IP selects a network interface to send the datagram,
     and possibly an intermediate gateway, based on an entry in the routing
     table. See routing(4). When SODONTROUTE is set, the datagram will be
     sent using the interface whose network number or full IP address
     matches the destination address. If no interface matches, the error
     ENETUNREACH will be returned.

     Raw IP datagrams can also be sent and received using the TLI connec-
     tionless primitives.

     Datagrams flow through the IP layer in two directions: from the net-
     work up to user processes and from user processes down to the network.
     Using this orientation, IP is layered above the network interface
     drivers and below the transport protocols such as UDP and TCP. The
     Internet Control Message Protocol (ICMP) is logically a part of IP.
     See icmp(7).

     IP provides for a checksum of the header part, but not the data part
     of the datagram. The checksum value is computed and set in the process
     of sending datagrams and checked when receiving datagrams. IP header
     checksumming may be disabled for debugging purposes by patching the
     kernel variable ipcksum to have the value zero.

     IP options in received datagrams are processed in the IP layer accord-
     ing to the protocol specification. Currently recognized IP options
     include: security, loose source and record route (LSRR), strict source
     and record route (SSRR), record route, stream identifier, and internet
     timestamp.

     The IP layer will normally forward received datagrams that are not
     addressed to it. Forwarding is under the control of the kernel vari-
     able ipforwarding: if ipforwarding is zero, IP datagrams will not be
     forwarded; if ipforwarding is one, IP datagrams will be forwarded.
     ipforwarding is usually set to one only in machines with more than one
     network interface (internetwork routers). This kernel variable can be
     patched to enable or disable forwarding.

     The IP layer will send an ICMP message back to the source host in many
     cases when it receives a datagram that can not be handled. A "time
     exceeded" ICMP message will be sent if the "time to live" field in the
     IP header drops to zero in the process of forwarding a datagram. A
     "destination unreachable" message will be sent if a datagram can not
     be forwarded because there is no route to the final destination, or if
     it can not be fragmented. If the datagram is addressed to the local
     host but is destined for a protocol that is not supported or a port
     that is not in use, a destination unreachable message will also be
     sent. The IP layer may send an ICMP "source quench" message if it is
     receiving datagrams too quickly. ICMP messages are only sent for the
     first fragment of a fragmented datagram and are never returned in
     response to errors in other ICMP messages.


Page 2                       Reliant UNIX 5.44                Printed 11/98

ip(7)                                                                 ip(7)

     The IP layer supports fragmentation and reassembly. Datagrams are
     fragmented on output if the datagram is larger than the maximum
     transmission unit (MTU) of the network interface. Fragments of
     received datagrams are dropped from the reassembly queues if the com-
     plete datagram is not reconstructed within a short time period.

     Errors in sending discovered at the network interface driver layer are
     passed by IP back up to the user process.

MULTICAST OPTIONS
     IP multicasting is supported only on AFINET sockets of type
     SOCKDGRAM and SOCKRAW, and only on networks where the interface
     driver supports multicasting. Only Stream sockets and X sockets are
     supported.

     The IPMULTICASTTTL option changes the time-to-live (TTL) for outgo-
     ing multicast datagrams in order to control the scope of the multi-
     casts:

     uchar ttl;     /* range: 0 to 255, default = 1 */
     setsockopt(s, IPPROTOIP, IPMULTICASTTTL, &ttl, sizeof(ttl));

     Datagrams with a TTL of 1 are not forwarded beyond the local network.
     Multicast datagrams with a TTL of 0 will not be transmitted on any
     network, but may be delivered locally if the sending host belongs to
     the destination group and if multicast loopback has not been disabled
     on the sending socket (see below). Multicast datagrams with TTL
     greater than 1 may be forwarded to other networks if a multicast
     router is attached to the local network.

     For hosts with multiple interfaces, each multicast transmission is
     sent from the primary network interface.

     The IPMULTICASTIF option overrides the default for subsequent
     transmissions from a given socket:

     struct inaddr addr;
     setsockopt(s, IPPROTOIP, IPMULTICASTIF, &addr, sizeof(addr));

     where addr is the local IP address of the desired interface or
     INADDRANY to specify the default interface. An interface's local IP
     address and multicast capability can be obtained via the SIOCGIFCONF
     (returns provider configuration) and SIOCGIFFLAGS (returns the inter-
     face flags) ioctls. Normal applications should not need to use this
     option.

     If a multicast datagram is sent to a group to which the sending host
     itself belongs (on the outgoing interface), a copy of the datagram is,
     by default, looped back by the IP layer for local delivery. The
     IPMULTICASTLOOP option gives the sender explicit control over
     whether or not subsequent datagrams are looped back:



Page 3                       Reliant UNIX 5.44                Printed 11/98

ip(7)                                                                 ip(7)

     uchar loop;    /* 0 = disable, 1 = enable (default) */
     setsockopt(s, IPPROTOIP, IPMULTICASTLOOP, &loop, sizeof(loop));

     This option improves performance for applications that may have no
     more than one instance on a single host (such as a router demon), by
     eliminating the overhead of receiving their own transmissions. It
     should generally not be used by applications for which there may be
     more than one instance on a single host (such as a conferencing pro-
     gram) or for which the sender does not belong to the destination group
     (such as a time querying program).

     A multicast datagram sent with an initial TTL greater than 1 may be
     delivered to the sending host on a different interface from that on
     which it was sent, if the host belongs to the destination group on
     that other interface. The loopback control option has no effect on
     such delivery.

     A host must become a member of a multicast group before it can receive
     datagrams sent to the group. To join a multicast group, use the
     IPADDMEMBERSHIP option:

     struct ipmreq mreq;
     setsockopt(s, IPPROTOIP, IPADDMEMBERSHIP, &mreq, sizeof(mreq));

     where mreq is the following structure:

     struct ipmreq {
         struct inaddr imrmultiaddr; /* multicast group to join */
         struct inaddr imrinterface; /* interface to join on */
     }

     imrinterface should be INADDRANY to choose the default multicast
     interface, or the IP address of a particular multicast-capable inter-
     face if the host is multihomed. Membership is associated with a single
     interface; programs running on multihomed hosts may need to join the
     same group on more than one interface. Up to IPMAXMEMBERSHIPS
     (currently 20) memberships may be added on a single socket.

     To drop a membership, use:

     struct ipmreq mreq;
     setsockopt(s, IPPROTOIP, IPDROPMEMBERSHIP, &mreq, sizeof(mreq));

     where mreq contains the same values as used to add the membership.
     Memberships are dropped when the socket is closed or the process
     exits.








Page 4                       Reliant UNIX 5.44                Printed 11/98

ip(7)                                                                 ip(7)

DIAGNOSTICS
     A socket operation may fail with one of the following errors returned:

     EACCESS        A IP broadcast destination address was specified and
                    the caller was not the privileged user.

     EISCONN        An attempt was made to establish a connection on a
                    socket which already had one, or to send a datagram
                    with the destination address specified and the socket
                    was already connected.

     EMSGSIZE       An attempt was made to send a datagram that was too
                    large for an interface, but was not allowed to be frag-
                    mented (such as broadcasts).

     ENETUNREACH    An attempt was made to establish a connection or send a
                    datagram, where there was no matching entry in the
                    routing table, or if an ICMP "destination unreachable"
                    message was received.

     ENOTCONN       A datagrem was sent, but no destination address was
                    specified, and the socket had not been connected.

     ENOBUFS        The system ran out of memory for fragmentation buffers
                    or other internal data structure.

     EADDRNOTAVAIL  An attempt was made to create a socket with a local
                    address that did not match any network interface, or an
                    IP broadcast destination address was specified and the
                    network interface does not support broadcast.

     The following errors may occur when setting or getting IP options:

     EINVAL         An unknown socket option name was given.

     EINVAL         The IP option field was improperly formed; an option
                    field was shorter than the minimum value or longer than
                    the option buffer provided.
















Page 5                       Reliant UNIX 5.44                Printed 11/98

ip(7)                                                                 ip(7)

NOTES
     Raw sockets should receive ICMP error packets relating to the proto-
     col; currently such packets are simply discarded.

     Users of higher-level protocols such as TCP and UDP should be able to
     see received IP options.

SEE ALSO
     read(2), write(2), connect(3N), getsockopt(3N), recv(3N), send(3N),
     routing(4), icmp(7), inet(7), tcp(7), udp(7).

     Postel, Jon, Internet Protocol - DARPA Internet Program Protocol Spec-
     ification, RFC 791, Network Information Center, SRI International,
     Menlo Park, Calif., September 1981.








































Page 6                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026