new copyright notice
[unix-history] / usr / src / share / man / man4 / ip.4
CommitLineData
1324d254
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
089e2666 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
089e2666 5.\"
91cff1e1 6.\" @(#)ip.4 6.4 (Berkeley) %G%
1324d254
KB
7.\"
8.TH IP 4 ""
089e2666
KM
9.UC 5
10.SH NAME
11ip \- Internet Protocol
12.SH SYNOPSIS
13.B #include <sys/socket.h>
14.br
15.B #include <netinet/in.h>
16.PP
7787ae36 17.B s = socket(AF_INET, SOCK_RAW, proto);
089e2666
KM
18.SH DESCRIPTION
19IP is the transport layer protocol used
7787ae36
MK
20by the Internet protocol family.
21Options may be set at the IP level
22when using higher-level protocols that are based on IP
23(such as TCP and UDP).
24It may also be accessed
089e2666 25through a \*(lqraw socket\*(rq when developing new protocols, or
7787ae36
MK
26special purpose applications.
27.PP
28A single generic option is supported at the IP level, IP_OPTIONS,
29that may be used to provide IP options to be transmitted in the IP
30header of each outgoing packet.
31Options are set with
32.IR setsockopt (2)
33and examined with
34.IR getsockopt (2).
35The format of IP options to be sent is that specified by the IP protocol
36specification, with one exception:
37the list of addresses for Source Route options must include the first-hop
38gateway at the beginning of the list of gateways.
39The first-hop gateway address will be extracted from the option list
40and the size adjusted accordingly before use.
41IP options may be used with any socket type in the Internet family.
42.PP
43Raw IP sockets are connectionless,
089e2666
KM
44and are normally used with the
45.I sendto
46and
47.I recvfrom
48calls, though the
49.IR connect (2)
50call may also be used to fix the destination for future
51packets (in which case the
52.IR read (2)
53or
54.IR recv (2)
55and
56.IR write (2)
57or
58.IR send (2)
59system calls may be used).
60.PP
7787ae36
MK
61If
62.I proto
63is 0, the default protocol IPPROTO_RAW is used for outgoing
64packets, and only incoming packets destined for that protocol
65are received.
66If
67.I proto
68is non-zero, that protocol number will be used on outgoing packets
69and to filter incoming packets.
70.PP
089e2666
KM
71Outgoing packets automatically have an IP header prepended to
72them (based on the destination address and the protocol
73number the socket is created with).
7787ae36 74Incoming packets are received with IP header and options intact.
089e2666
KM
75.SH DIAGNOSTICS
76A socket operation may fail with one of the following errors returned:
77.TP 15
78[EISCONN]
79when trying to establish a connection on a socket which
80already has one, or when trying to send a datagram with the destination
81address specified and the socket is already connected;
82.TP 15
83[ENOTCONN]
84when trying to send a datagram, but
85no destination address is specified, and the socket hasn't been
86connected;
87.TP 15
88[ENOBUFS]
89when the system runs out of memory for
90an internal data structure;
91.TP 15
92[EADDRNOTAVAIL]
93when an attempt is made to create a
94socket with a network address for which no network interface
95exists.
089e2666 96.PP
7787ae36
MK
97The following errors specific to IP
98may occur when setting or getting IP options:
99.TP 15
100[EINVAL]
101An unknown socket option name was given.
102.TP 15
103[EINVAL]
104The IP option field was improperly formed;
105an option field was shorter than the minimum value
106or longer than the option buffer provided.
107.SH SEE ALSO
1324d254 108getsockopt(2), send(2), recv(2), intro(4), icmp(4), inet(4)