|
|
1.1 ! root 1: .TH IP 4 ! 2: .CT 2 comm_mach ! 3: .SH NAME ! 4: ip, ip_ld \- DARPA internet protocol ! 5: .SH SYNOPSIS ! 6: .B #include <sys/inio.h> ! 7: .br ! 8: .B #include <sys/inet/in.h> ! 9: .br ! 10: .B #include <sys/inet/ip_var.h> ! 11: .SH DESCRIPTION ! 12: .PP ! 13: The ! 14: .I ip_ld ! 15: line discipline and the ! 16: .F /dev/ip* ! 17: files together implement the DARPA IP datagram protocol. ! 18: They are used by ! 19: the programs described in ! 20: .IR ipconfig (8) ! 21: and ! 22: .IR route (8). ! 23: .PP ! 24: Each Ethernet device, ! 25: Datakit channel, ! 26: or other stream ! 27: that is to send and receive IP packets ! 28: must be registered as an ! 29: `IP interface' ! 30: by pushing ! 31: .I ip_ld ! 32: and setting local and remote addresses ! 33: with ! 34: .I ioctl ! 35: calls. ! 36: Thereafter, ! 37: data received from the network ! 38: are assumed to be IP packets, ! 39: and are intercepted by the line discipline. ! 40: Packets destined for the local address of an active IP interface ! 41: are routed for reading on one of the ! 42: .I ip ! 43: device files. ! 44: Other packets are routed to the IP interface ! 45: with a matching remote address ! 46: and retransmitted. ! 47: .PP ! 48: Data written on ! 49: .I ip ! 50: devices ! 51: are taken to be IP packets, ! 52: are handed to the IP interface ! 53: with a matching address, ! 54: and are sent. ! 55: Packets destined for unreachable places ! 56: are quietly dropped. ! 57: .PP ! 58: A packet consists of a single stream record, ! 59: followed by a delimiter: ! 60: at most one packet is returned by a ! 61: .I read ! 62: call; ! 63: an entire packet must be presented in a single ! 64: .IR write . ! 65: A packet includes the IP header. ! 66: Numbers in the header are in host byte order. ! 67: .PP ! 68: Different ! 69: .I ip ! 70: devices handle different protocols atop IP. ! 71: The minor device is the protocol number in the IP header; ! 72: e.g. 6 for TCP or 17 for UDP. ! 73: While an ! 74: .I ip ! 75: device is open, ! 76: it may not be opened again. ! 77: IP packets are often processed by pushing a line discipline ! 78: such as ! 79: .IR tcp_ld ! 80: on an ! 81: .I ip ! 82: device, ! 83: rather than by explicit ! 84: .I read ! 85: and ! 86: .I write ! 87: calls; ! 88: see ! 89: .IR tcp (4). ! 90: .PP ! 91: The following ! 92: .IR ioctl (2) ! 93: calls, defined in ! 94: .BR <sys/inio.h> , ! 95: apply to an IP interface. ! 96: .B IPIOLOCAL ! 97: and either ! 98: .B IPIOHOST ! 99: or ! 100: .B IPIONET ! 101: must be called on each interface ! 102: before packets will be routed correctly. ! 103: Type ! 104: .BR in_addr , ! 105: defined in ! 106: .BR <sys/inet/in.h> , ! 107: is a 32-bit integer ! 108: representing an IP address ! 109: in host byte order. ! 110: .nr Pw \w'\f5IPIORESOLVE 'u ! 111: .TP \n(Pwu ! 112: .B IPIOLOCAL ! 113: The third argument points to an ! 114: .BR in_addr : ! 115: the local IP address for this interface. ! 116: .TP ! 117: .B IPIOHOST ! 118: The third argument points to an ! 119: .BR in_addr : ! 120: the remote IP address of the single host ! 121: reachable through this interface. ! 122: .TP ! 123: .B IPIONET ! 124: The third argument ! 125: points to an ! 126: .BR in_addr : ! 127: the remote IP address of the network of many hosts ! 128: reachable through this interface. ! 129: IP addresses are matched to the network address ! 130: by applying an internal bit-mask: ! 131: any IP address for which ! 132: .BI ( address & mask )== net-address ! 133: is part of the network. ! 134: The default mask depends on ! 135: the IP address class; ! 136: see the IP protocol standard for details. ! 137: .TP ! 138: .B IPIOMASK ! 139: The third argument points to an ! 140: .B in_addr ! 141: containing a new network mask for this interface. ! 142: .TP ! 143: .B IPIOMTU ! 144: The third argument points to an integer number of bytes. ! 145: IP packets larger than this size (1500 by default) ! 146: will be split into smaller ones ! 147: before being sent through this interface. ! 148: .TP ! 149: .B IPIOARP ! 150: The network device for this interface ! 151: is an Ethernet. ! 152: Discard the Ethernet header from each incoming packet. ! 153: When sending a packet, ! 154: prefix an Ethernet header ! 155: containing protocol type ! 156: .B 0x8 ! 157: and a destination address ! 158: obtained by looking up the IP destination address ! 159: in a table. ! 160: If the IP address is not in the table, ! 161: discard the packet, ! 162: and make an ! 163: .B in_addr ! 164: containing the offending address ! 165: available for reading ! 166: on this file descriptor ! 167: (the one on which ! 168: .I ip_ld ! 169: was pushed). ! 170: .TP ! 171: .B IPIORESOLVE ! 172: The third argument points to a structure: ! 173: .EX ! 174: struct { ! 175: in_addr inaddr; ! 176: unsigned char enaddr[6]; ! 177: }; ! 178: .EE ! 179: Add an entry to the table consulted after ! 180: .BR IPIOARP , ! 181: mapping IP address ! 182: .B inaddr ! 183: to Ethernet address ! 184: .BR enaddr . ! 185: .LP ! 186: The following ! 187: .I ioctl ! 188: calls, define in ! 189: .BR <sys/inio.h> , ! 190: apply to the entire IP subsystem; ! 191: they may be used on any file with ! 192: .I ip_ld ! 193: pushed. ! 194: .TP \n(Pwu ! 195: .B IPIOROUTE ! 196: The third argument points to a structure: ! 197: .EX ! 198: struct route { ! 199: in_addr dst; ! 200: in_addr gate; ! 201: }; ! 202: .EE ! 203: Arrange that henceforth, ! 204: any IP packet destined for address ! 205: .B dst ! 206: will be routed as if destined for ! 207: .BR gate . ! 208: .TP ! 209: .B IPIOGETIFS ! 210: The third argument points to a union as follows. ! 211: The structure is defined in ! 212: .BR <sys/inet/ip_var.h> . ! 213: .EX ! 214: union { ! 215: int index; ! 216: struct ipif { ! 217: struct queue *queue; ! 218: int flags; ! 219: int mtu; ! 220: in_addr thishost; ! 221: in_addr that; ! 222: in_addr mask; ! 223: in_addr broadcast; ! 224: int ipackets, ierrors; ! 225: int opackets, oerrors; ! 226: int arp; ! 227: int dev; ! 228: } ipif; ! 229: }; ! 230: .EE ! 231: Before the call, ! 232: .B index ! 233: should contain an integer ! 234: naming an entry in the system's table ! 235: of active interfaces. ! 236: Interfaces are numbered in a continuous sequence starting at 0. ! 237: Out-of-range numbers return an error. ! 238: After the call, ! 239: .B ipif ! 240: is filled in with various numbers ! 241: about that interface. ! 242: .SH FILES ! 243: .B /dev/ip* ! 244: .SH SEE ALSO ! 245: .IR ioctl (2), ! 246: .IR internet (3), ! 247: .IR ipconfig (8), ! 248: .IR route (8) ! 249: .br ! 250: DARPA standards RFC 791, RFC 1122 ! 251: .SH BUGS ! 252: The ARP mechanism should be generalized ! 253: to deal with networks other than Ethernet. ! 254: There is only one ARP table for the entire system; ! 255: there should be one for each interface. ! 256: .br ! 257: The structures used by ! 258: .B IPIOROUTE ! 259: and ! 260: .B IPIORESOLVE ! 261: should appear in a header file somewhere.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.