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