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