|
|
1.1 ! root 1: .\" Copyright (c) 1983 The Regents of the University of California. ! 2: .\" All rights reserved. ! 3: .\" ! 4: .\" Redistribution and use in source and binary forms are permitted provided ! 5: .\" that: (1) source distributions retain this entire copyright notice and ! 6: .\" comment, and (2) distributions including binaries display the following ! 7: .\" acknowledgement: ``This product includes software developed by the ! 8: .\" University of California, Berkeley and its contributors'' in the ! 9: .\" documentation or other materials provided with the distribution and in ! 10: .\" all advertising materials mentioning features or use of this software. ! 11: .\" Neither the name of the University nor the names of its contributors may ! 12: .\" be used to endorse or promote products derived from this software without ! 13: .\" specific prior written permission. ! 14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 17: .\" ! 18: .\" @(#)ip.4 6.4 (Berkeley) 6/23/90 ! 19: .\" ! 20: .TH IP 4 "June 23, 1990" ! 21: .UC 5 ! 22: .SH NAME ! 23: ip \- Internet Protocol ! 24: .SH SYNOPSIS ! 25: .B #include <sys/socket.h> ! 26: .br ! 27: .B #include <netinet/in.h> ! 28: .PP ! 29: .B s = socket(AF_INET, SOCK_RAW, proto); ! 30: .SH DESCRIPTION ! 31: IP is the transport layer protocol used ! 32: by the Internet protocol family. ! 33: Options may be set at the IP level ! 34: when using higher-level protocols that are based on IP ! 35: (such as TCP and UDP). ! 36: It may also be accessed ! 37: through a \*(lqraw socket\*(rq when developing new protocols, or ! 38: special purpose applications. ! 39: .PP ! 40: A single generic option is supported at the IP level, IP_OPTIONS, ! 41: that may be used to provide IP options to be transmitted in the IP ! 42: header of each outgoing packet. ! 43: Options are set with ! 44: .IR setsockopt (2) ! 45: and examined with ! 46: .IR getsockopt (2). ! 47: The format of IP options to be sent is that specified by the IP protocol ! 48: specification, with one exception: ! 49: the list of addresses for Source Route options must include the first-hop ! 50: gateway at the beginning of the list of gateways. ! 51: The first-hop gateway address will be extracted from the option list ! 52: and the size adjusted accordingly before use. ! 53: IP options may be used with any socket type in the Internet family. ! 54: .PP ! 55: Raw IP sockets are connectionless, ! 56: and are normally used with the ! 57: .I sendto ! 58: and ! 59: .I recvfrom ! 60: calls, though the ! 61: .IR connect (2) ! 62: call may also be used to fix the destination for future ! 63: packets (in which case the ! 64: .IR read (2) ! 65: or ! 66: .IR recv (2) ! 67: and ! 68: .IR write (2) ! 69: or ! 70: .IR send (2) ! 71: system calls may be used). ! 72: .PP ! 73: If ! 74: .I proto ! 75: is 0, the default protocol IPPROTO_RAW is used for outgoing ! 76: packets, and only incoming packets destined for that protocol ! 77: are received. ! 78: If ! 79: .I proto ! 80: is non-zero, that protocol number will be used on outgoing packets ! 81: and to filter incoming packets. ! 82: .PP ! 83: Outgoing packets automatically have an IP header prepended to ! 84: them (based on the destination address and the protocol ! 85: number the socket is created with). ! 86: Incoming packets are received with IP header and options intact. ! 87: .SH DIAGNOSTICS ! 88: A socket operation may fail with one of the following errors returned: ! 89: .TP 15 ! 90: [EISCONN] ! 91: when trying to establish a connection on a socket which ! 92: already has one, or when trying to send a datagram with the destination ! 93: address specified and the socket is already connected; ! 94: .TP 15 ! 95: [ENOTCONN] ! 96: when trying to send a datagram, but ! 97: no destination address is specified, and the socket hasn't been ! 98: connected; ! 99: .TP 15 ! 100: [ENOBUFS] ! 101: when the system runs out of memory for ! 102: an internal data structure; ! 103: .TP 15 ! 104: [EADDRNOTAVAIL] ! 105: when an attempt is made to create a ! 106: socket with a network address for which no network interface ! 107: exists. ! 108: .PP ! 109: The following errors specific to IP ! 110: may occur when setting or getting IP options: ! 111: .TP 15 ! 112: [EINVAL] ! 113: An unknown socket option name was given. ! 114: .TP 15 ! 115: [EINVAL] ! 116: The IP option field was improperly formed; ! 117: an option field was shorter than the minimum value ! 118: or longer than the option buffer provided. ! 119: .SH SEE ALSO ! 120: getsockopt(2), send(2), recv(2), intro(4), icmp(4), inet(4)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.