926 lines · 24.3 KB · Text
RawDownload
.TH IP 3.SH NAMEip \- network protocols over IP.SH SYNOPSIS.nf.B bind -a #I\f1[\f5\f2ifn\f1]\f5 /net .B /net/arp.B /net/bootp.B /net/iproute.B /net/ipselftab.B /net/iprouter.B /net/log .B  /net/ipifc/clone.B /net/ipifc/stats.BI /net/ipifc/ n .BI /net/ipifc/ n /data.BI /net/ipifc/ n /ctl.BI /net/ipifc/ n /local.BI /net/ipifc/ n /status .BI  /net/ proto /clone.BI /net/ proto /stats.BI /net/ proto / n .BI /net/ proto / n /ctl.BI /net/ proto / n /data.BI /net/ proto / n /err.BI /net/ proto / n /local.BI /net/ proto / n /remote.BI /net/ proto / n /status.BI /net/ proto / n /listen\&....fi.SH DESCRIPTIONThe IP device serves a directory representing a self-containedcollection of IP interfaces.There may be several instances, identified by the decimal interface number.IR ifn ,that follows the.B #Idevice name;.B #I0is assumed by default.Each instancehas a disjoint collection of IP interfaces, routes and address resolution maps.A physical or virtual device, or.IR medium ,that produces IP packets is associatedwith a logical IP network using the mechanisms described under.I "Physical and logical interfaces"below.Commonly all IP media on a host are assigned to a singleinstance of.BR #I ,which is conventionally bound to.BR /net ,but other configurations are possible: interfaces might be assignedto different device instances forming separatelogical IP networksto partition networks in firewall orgateway applications..PPHosted Inferno provides a subset of the interface described here that givesto  the TCP/IP and UDP/IP of the host system's own IP subsystem.See.IR "Hosted interfaces"below for a summary of the differences..SS ProtocolsWithin each instance,the IP device providesan interface to each IP protocol configured into the system, such as TCP/IP or UDP/IP..PPEach of the protocols is served by the IP device, which represents aconnection by a set of device files.The top level directory,.I protoin the.SM SYNOPSISabove,is named after a protocol (eg,.BR tcp ,.BR il ,.BR udp )and contains a.B clonefile, a.B statsfile,and subdirectories numbered from zero to the number of connectionsconfigured for this protocol..PPThe read-only.B statsfile contains protocol-specific statistics as one or more lines of text.There is no particular format, but the values are often a supersetof those required by the SNMP MIB..PPOpening the.B clonefile reserves a connection, represented byone of the numbered subdirectories.  The resulting file descriptorwill be open on the control file,.BR ctl ,of the newly allocated connection.Reading the.B ctlfile returns a textstring representing the number of theconnection.Connections may be used either to listen for incoming callsor to initiate calls to other machines..PPA connection is controlled by writing text strings to the associated.B ctlfile.After a connection has been established data may be read fromand written to the data file..PPBefore sending data, remote and local addresses must be set for the connection.For outgoing calls the local port number will be allocated randomly if none is set.Addresses are set by writing control messages to the.B ctlfile of the connection.The connection is not established until the data file is opened.There are two models depending on the nature of the protocol.For connection-oriented protocols, the process will block on openuntil the remote host has acknowledged the connection,either accepting it, causing a successful return from open,or rejecting it, causing open to return an appropriate error.For connectionless protocols, the open always succeeds;the `connect' request sets local parameters for the source and destination fieldsfor use by subsequent read and write requests..PPThe following control messages are provided by this interfaceto all protocols.A particular protocol can provide additional commands, orchange the interpretation or even syntax of those below,as described in the manual page for that protocol.The description below showsthe standard commands with the default argument syntax and interpretation:.TP.BI connect\  ipaddress ! port "[!r]\ [\f2lport\f5]"Set the remote IP address and port number for the connection.If the.B rflagis supplied and the optional local port.I lporthas not been specified the system will allocatea restricted port number (between 600 and 1024) for the connection to allow communicationwith Unix machines'.B loginand.B execservices..TP.BI "announce\ [" ipaddress !] portSet the local portnumber to.I portand accept calls to that port..I Portis a decimal port number or.LR * .If.I portis zero, assign a port number(the one assigned can be read from the.B localaddress file).If.I portis.LR * ,acceptcalls for any port that no process has explicitly announced.If the optional.I ipaddressis given, set the local IP address for the connectionto that address, and accept only those incoming calls to.I portthat are addressed to.IR ipaddress ..B Announcefails if the connection is already announced or connected..TP.BI bind\  port.I Portis a decimal port number or.LR * .Set the local port number to.IR port .This request exists to support emulation ofof BSD sockets and is otherwise neither needed nor used in Inferno..TP.BI tos " \f1[\f2 n \f1]\f2"Set the type-of-service value in outgooing packets to.I n(default: 0)..TP.BI ttl " \f1[\f2 n \f1]\f2"Set the time-to-live (TTL) value in packets transmitted on this conversationto.I n(default: 255)..PPPort numbers must be in the range 1 to 32767..PPSeveral read-only files report the status of aconnection.The.B remoteand.B localfiles contain the IP address and port number for the remote and local side of theconnection.The.B statusfile contains protocol-dependent information to help debug network connections.The first word on the first line gives the status of theconnection..PPHaving announced, a process may accept incoming connections by calling.B openon the.B listenfile.The.B openwill block until a new connection request arrives;it will thenreturn an open file descriptor that points to the control file of thenewly accepted connection.Repeating this procedure will accept all calls for thegiven protocol..PPIn general it should not be necessary to use the file system interface to thenetworks.The.BR dial ,.BR announce ,and.BR listenfunctions described in.IR sys-dial (2)perform the necessary I/O to establish andmanipulate network connections..SS TCP protocolThe TCP protocol is the standard Internetprotocol for reliable stream communication; it does not preserveread/writeboundaries..PPA connection is controlled by writing text strings to the associated.B ctlfile.After a connection has been established data may be read fromand written to the data file.The TCP protocol provides a stream connection that does not preserveread/writeboundaries..PPFor outgoing calls the local port number will be allocated randomly if none is set.Addresses are set by writing control messages to the.B ctlfile of the connection.The connection is not established until the data file is opened.For TCP theprocess will block until the remote host has acknowledged the connection..PPAs well as the standard control messages above,TCP accepts the following:.TP.BI hangupSend a TCP reset (RST) to the remote side and end the conversation,without waiting for untransmitted data to be acknowledged,unlike a normal close of the device..TP.BI keepalive\ [ "n" ]Enable `keep alive'mode:if no traffic crosses the link within a given period, send apacket to check that the remote party is still there, and remindit that the local connection is still live.The optional value.I ngives the keep-alive time in milliseconds (default: 120000)..PPThe.B statusfile has many lines, each containing a labelled number, giving the valuesof parameters and statistics such as:maximum allowed connections, outgoing calls, incoming calls, established but later reset,active calls, input segments, output segments, retransmitted segments, retransmitted timeouts,input errors, transmitted reset..SS UDP protocol.PPUDP provides the standard Internetprotocol for unreliable datagramcommunication..PPUDP opens always succeed.Before sending data, remote and local addresses must be set for the connection.Alternatively, the following special control requests can be used:.TP.B headersSet the connection to use an address header with IPv6 addressingon reads and writes of the data file,allowing a single connection to send datagrams to converse withmany different destination addresses and ports.The 52 byte binary header appears before the dataread or written.It contains: remote IP address, local IP address, interface IP address, remote port, and local port.The IP addresses are 16 bytes each in IPv6 format, andthe port addresses are 2 bytes each, all written in network (big-endian) order.On reads, the header gives the values from the incoming datagram,except that if the remote used a multicast destination address, the IP addressof the receiving interface is substituted.On writes, the header provides the destination for the resulting datagram,and if the local IP address corresponds to a valid local unicast interface,that address is used, otherwise the IP address of the transmitting interfaceis substituted..TP.B headers4Set the connection to use an address header with IPv4 addresseson reads and writes of the data file,allowing a single connection to send datagrams to converse withmany different destination addresses and ports.The 12 byte binary header appears before the dataread or written.It contains: remote IP address, local IP address, remote port, and local port.The IP addresses are 4 bytes each,the port addresses are 2 bytes each, all written in network (big-endian) order.On reads, the header gives the values from the incoming datagram.On writes, the header provides the destination for the resulting datagram.This mode is obsolete and destined for oblivion..PPA read of less thanthe size of the datagram will cause the entire datagram to be consumed.Each write to the data file will send a single datagram on the network..PPIn replies, in connection-oriented mode, if the remote addresshas not been set, the first arriving packet sets the followingbased on the source of the incoming datagram:the remote address and port for the conversation,and the local address is set to the destination address in thedatagram unless that is a multicast address, and then the addressof the receiving interface is used..PPIf a conversation is in.B headersmode, only the local port is relevant..PPConnection-oriented UDP is hungup if an ICMP error (eg, host or port unreachable,or time exceeded) arrives with matching port..PPThe.I udp.B statusfile contains four lines, each containing a labelled number counting an event:input datagrams, datagrams on unannounced ports, datagrams with wrong checksum, and output datagrams..SS IL ProtocolIL provides a reliable point-to-point datagram service for communication between Plan 9 andnative Inferno machines.Each read and write transfers a single datagram, as for UDP.The datagrams are delivered reliably and in order.Conversations are addressed and established as for TCP..SS Routing.PPThe.B iproutefile can be read and written.When read, it returns the contents of the IP routing tables,one line per entry,with six fields giving thedestination host or network address, address mask,gateway address, route type, tag (see below), and the number of the.B ipifcinterface owning the route(or.RB ` - 'if none).The route type is up to four characters:.B 4or.B 6(IPv4 or IPv6 route);.B i(route is interface);one of.B u(unicast),.B b(broadcast),or.B m(multicast);and lastly.B pif the route is point-to-point..PPCommands can also be written to control the routing:.TP.BI add " ip mask gw \f1[\f2 tag \f1]\f2"Add a route via the gateway identified by IP address.I gwto the address specified by.I ipand subnet mask.IR mask .Tag the resulting table entry with the.I tagprovided, or the current.I tag(see.B tagbelow),or the tag.BR none ..TP.BI flush " \f1[\f2 tag \f1]\f2"Remove all routes with the given.I tagthat do not correspond to a local interface.If.I tagis not given, flush all routes..TP.BI remove " ip mask"Remove routes to the given address..TP.BI tag " tag"Tag the routes generated by writes on the current file descriptor withthe given.IR tagof up to 4 characters.The default is.BR none ,set when.B iprouteis opened..PPThe.B ipselftabfile summarises the addresses and routes that refer to the local host.It gives an address, the number of logical interfaces, and the interface typein the same form as the route type of.BR iproute ..PPThe.B iprouterfile is provided for use by a user-level application acting as an IP gateway.It is effective only when the kernel-level gateway is not enabled(see the.B iproutinginterface control request below).Once opened, packets that are not addressed to alocal address can be read from this device.The packet contents are preceded by a 16 byte binary header thatgives the IPv6 address of the local interface that received the packet..SS Bootstrap.PPThe read-only.B bootpfile contains the results of the last BOOTPrequest transmitted on any interface (see.I "Physical and logical interfaces"below)as several lines of text,with two fields each.The first field names an entity and the second field gives its value in IPv4 address format.The current entities are:.IP.RS.TF ipaddr.TP.B auipAuthentication server address.TP.B fsipFile server address.TP.B gwipAddress of an IP gateway out of this (sub)net..TP.B ipaddrLocal IP address.TP.B ipmaskSubnet mask for the local IP address.RE.PD.PPIf any value is unknown (no reply to BOOTP, or value unspecified),the value will be zero, represented as.BR 0.0.0.0 ..SS Address resolutionThe.B arp

Lines 1–500 of 926.