1IP(4P)                                                                  IP(4P)
2
3
4

NAME

6       ip - Internet Protocol
7

SYNOPSIS

9       #include <sys/socket.h>
10       #include <netinet/in.h>
11
12       s = socket(AF_INET, SOCK_RAW, proto);
13

DESCRIPTION

15       IP  is  the transport layer protocol used by the Internet protocol fam‐
16       ily.  Options may be set at the IP level when using higher-level proto‐
17       cols  that  are  based  on  IP  (such  as TCP and UDP).  It may also be
18       accessed through a “raw socket” when developing new protocols, or  spe‐
19       cial purpose applications.
20
21       A  single generic option is supported at the IP level, IP_OPTIONS, that
22       may be used to provide IP options to be transmitted in the IP header of
23       each  outgoing packet.  Options are set with setsockopt(2) and examined
24       with getsockopt(2).  The format of IP options to be sent is that speci‐
25       fied  by the IP protocol specification, with one exception: the list of
26       addresses for Source Route options must include the  first-hop  gateway
27       at  the  beginning  of  the  list  of  gateways.  The first-hop gateway
28       address will be extracted from the option list and  the  size  adjusted
29       accordingly before use.  IP options may be used with any socket type in
30       the Internet family.
31
32       Raw IP sockets are connectionless,  and  are  normally  used  with  the
33       sendto  and recvfrom calls, though the connect(2) call may also be used
34       to fix the destination for future packets (in which case the read(2) or
35       recv(2) and write(2) or send(2) system calls may be used).
36
37       If  proto  is  0, the default protocol IPPROTO_RAW is used for outgoing
38       packets, and only incoming  packets  destined  for  that  protocol  are
39       received.   If  proto is non-zero, that protocol number will be used on
40       outgoing packets and to filter incoming packets.
41
42       Outgoing packets automatically have an  IP  header  prepended  to  them
43       (based on the destination address and the protocol number the socket is
44       created with).  Incoming  packets  are  received  with  IP  header  and
45       options intact.
46

DIAGNOSTICS

48       A socket operation may fail with one of the following errors returned:
49
50       [EISCONN]      when  trying to establish a connection on a socket which
51                      already has one, or when trying to send a datagram  with
52                      the  destination  address  specified  and  the socket is
53                      already connected;
54
55       [ENOTCONN]     when trying to  send  a  datagram,  but  no  destination
56                      address  is  specified,  and the socket hasn't been con‐
57                      nected;
58
59       [ENOBUFS]      when the system runs out of memory for an internal  data
60                      structure;
61
62       [EADDRNOTAVAIL]
63                      when  an  attempt is made to create a socket with a net‐
64                      work address for which no network interface exists.
65
66       The following errors specific to IP may occur when setting  or  getting
67       IP options:
68
69       [EINVAL]       An unknown socket option name was given.
70
71       [EINVAL]       The  IP  option  field  was improperly formed; an option
72                      field was shorter than the minimum value or longer  than
73                      the option buffer provided.
74

SEE ALSO

76       getsockopt(2), send(2), recv(2), intro(4N), icmp(4P), inet(4F)
77
78
79
804.2 Berkeley Distribution        May 16, 1986                           IP(4P)
Impressum