ip 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. .TH IP 3
  2. .SH NAME
  3. ip \- network protocols over IP
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind -a #I\fIspec\fP /net
  7. .B /net/ipifc
  8. .B /net/ipifc/clone
  9. .B /net/ipifc/stats
  10. .BI /net/ipifc/ n
  11. .BI /net/ipifc/ n /status
  12. .BI /net/ipifc/ n /ctl
  13. \&...
  14. .B /net/arp
  15. .B /net/log
  16. .B /net/ndb
  17. .B /net/iproute
  18. .B /net/ipselftab
  19. .B /net/esp
  20. .B /net/gre
  21. .B /net/icmp
  22. .B /net/il
  23. .B /net/ipmux
  24. .B /net/rudp
  25. .B /net/tcp
  26. .B /net/udp
  27. .B /net/tcp/clone
  28. .B /net/tcp/stats
  29. .BI /net/tcp/ n
  30. .BI /net/tcp/ n /data
  31. .BI /net/tcp/ n /ctl
  32. .BI /net/tcp/ n /local
  33. .BI /net/tcp/ n /remote
  34. .BI /net/tcp/ n /status
  35. .BI /net/tcp/ n /listen
  36. \&...
  37. .fi
  38. .SH DESCRIPTION
  39. The IP device provides the interface to Internet protocol stacks.
  40. .I Spec
  41. is an integer from 0 to 15 identifying a stack.
  42. Each stack is physically independent of all others:
  43. the only information transfer between them is via programs that
  44. mount multiple stacks.
  45. Normally a system uses only one stack.
  46. However multiple stacks can be used for debugging
  47. new IP networks or implementing firewalls or proxy
  48. services.
  49. .PP
  50. All addresses used are 16-byte IPv6 addresses.
  51. We implement IPv4 and IPv6.
  52. IPv4 addresses are a subset of the IPv6 addresses and both standard
  53. .SM ASCII
  54. formats
  55. are accepted. In binary, all v4 addresses start with the
  56. 12 bytes:
  57. .EX
  58. 00 00 00 00 00 00 00 00 00 00 ff ff
  59. .EE
  60. .SS "Configuring interfaces
  61. .PP
  62. Each stack may have multiple interfaces and each interface
  63. may have multiple addresses.
  64. The
  65. .B /net/ipifc
  66. directory contains a
  67. .B clone
  68. file, a
  69. .B stats
  70. file, and numbered subdirectories for each physical interface.
  71. .PP
  72. Opening the
  73. .B clone
  74. file reserves an interface.
  75. The file descriptor returned from the
  76. .IR open (2)
  77. will point to the control file,
  78. .BR ctl ,
  79. of the newly allocated interface.
  80. Reading
  81. .B ctl
  82. returns a text string representing the number of the interface.
  83. Writing
  84. .B ctl
  85. alters aspects of the interface.
  86. The possible
  87. .I ctl
  88. messages are:
  89. .TP
  90. .BI "bind ether " path
  91. Treat the device mounted at
  92. .I path
  93. as an Ethernet medium carrying IP and ARP packets
  94. and associate it with this interface.
  95. The kernel will
  96. .IR dial (2)
  97. .IR path !0x800
  98. and
  99. .IR path !0x806
  100. and use the two connections for IP and
  101. ARP respectively.
  102. .TP
  103. .B "bind pkt
  104. Treat this interface as a packet interface. Assume
  105. a user program will read and write the
  106. .I data
  107. file to receive and transmit IP packets to the kernel.
  108. This is used by programs such as
  109. .IR ppp (8)
  110. to mediate IP packet transfer between the kernel and
  111. a PPP encoded device.
  112. .TP
  113. .BI "bind netdev " path
  114. Treat this interface as a packet interface.
  115. The kernel will open
  116. .I path
  117. and read and write the resulting file descriptor
  118. to receive and transmit IP packets.
  119. .TP
  120. .BI "bind loopback "
  121. Treat this interface as a local loopback. Anything
  122. written to it will be looped back.
  123. .TP
  124. .B "unbind
  125. Disassociate the physical device from an IP interface.
  126. .TP
  127. .BI add\ "local mask remote mtu " proxy
  128. Add a local IP address to the interface. The
  129. .IR mask ,
  130. .IR remote ,
  131. .IR mtu ,
  132. and
  133. .B proxy
  134. arguments are all optional. The default mask is
  135. the class mask for the local address. The default
  136. remote address is
  137. .I local
  138. ANDed with
  139. .IR mask .
  140. The default mtu is 1514 for Ethernet and 4096 for packet
  141. media.
  142. .IR Proxy ,
  143. if specified, means that this machine should answer
  144. ARP requests for the remote address.
  145. .IR Ppp (8)
  146. does this to make remote machines appear
  147. to be connected to the local Ethernet.
  148. .TP
  149. .BI remove\ "local mask"
  150. Remove a local IP address from an interface.
  151. .TP
  152. .BI mtu\ n
  153. Set the maximum transfer unit for this device to
  154. .IR n .
  155. The mtu is the maximum size of the packet including any
  156. medium-specific headers.
  157. .TP
  158. .BI reassemble
  159. Reassemble IP fragments before forwarding to this interface
  160. .TP
  161. .BI iprouting\ n
  162. Allow
  163. .RI ( n
  164. is missing or non-zero) or disallow
  165. .RI ( n
  166. is 0) forwarding packets between this interface and
  167. others.
  168. .TP
  169. .BI addmulti\ addr
  170. Treat the multicast
  171. .I addr
  172. on this interface as a local address.
  173. .TP
  174. .BI remmulti\ addr
  175. Remove the multicast address
  176. .I addr
  177. from this interface.
  178. .PP
  179. Reading the interface's
  180. .I status
  181. file returns information about the interface, one line for each
  182. local address on that interface. The first line
  183. has 9 white-space-separated fields: device, mtu, local address,
  184. mask, remote or network address, packets in, packets out, input errors,
  185. output errors. Each subsequent line contains all but the device and mtu.
  186. See
  187. .B readipifc
  188. in
  189. .IR ip (2).
  190. .SS "Routing
  191. .PP
  192. The file
  193. .I iproute
  194. controls information about IP routing.
  195. When read, it returns one line per routing entry.
  196. Each line contains six white-space-separated fields:
  197. target address, target mask, address of next hop, flags,
  198. tag, and interface number.
  199. The entry used for routing an IP packet is the one with
  200. the longest mask for which destination address ANDed with
  201. target mask equals the target address.
  202. The one character flags are:
  203. .TP
  204. .B 4
  205. IPv4 route
  206. .TP
  207. .B 6
  208. IPv6 route
  209. .TP
  210. .B i
  211. local interface
  212. .TP
  213. .B b
  214. broadcast address
  215. .TP
  216. .B u
  217. local unicast address
  218. .TP
  219. .B m
  220. multicast route
  221. .TP
  222. .B p
  223. point-to-point route
  224. .PP
  225. The tag is an arbitrary, up to 4 character, string. It is normally used to
  226. indicate what routing protocol originated the route.
  227. .PP
  228. Writing to
  229. .B /net/iproute
  230. changes the route table. The messages are:
  231. .TP
  232. .B flush
  233. Remove all routes.
  234. .TP
  235. .BI tag\ string
  236. Associate the tag,
  237. .IR string ,
  238. with all subsequent routes added via this file descriptor.
  239. .TP
  240. .BI add\ "target mask nexthop"
  241. Add the route to the table. If one already exists with the
  242. same target and mask, replace it.
  243. .TP
  244. .BI remove\ "target mask"
  245. Remove a route with a matching target and mask.
  246. .SS "Address resolution
  247. .PP
  248. The file
  249. .B /net/arp
  250. controls information about address resolution.
  251. The kernel automatically updates the ARP information for Ethernet
  252. interfaces.
  253. When read, the file returns one line per address containing the
  254. type of medium, the status of the entry (OK, WAIT), the IP
  255. address, and the medium address.
  256. Writing to
  257. .B /net/arp
  258. administers the ARP information. The control messages are:
  259. .TP
  260. .B flush
  261. Remove all entries.
  262. .TP
  263. .BI add\ "type IP-addr Media-addr"
  264. Add an entry or replace an existing one for the
  265. same IP address.
  266. .TP
  267. .BI del\ "IP-addr"
  268. Delete an individual entry.
  269. .PP
  270. ARP entries do not time out. The ARP table is a
  271. cache with an LRU replacement policy. The IP stack
  272. listens for all ARP requests and, if the requester is in
  273. the table, the entry is updated.
  274. Also, whenever a new address is configured onto an
  275. Ethernet, an ARP request is sent to help
  276. update the table on other systems.
  277. .PP
  278. Currently, the only medium type is
  279. .BR ether .
  280. .SS "Debugging and stack information
  281. .PP
  282. If any process is holding
  283. .B /net/log
  284. open, the IP stack queues debugging information to it.
  285. This is intended primarily for debugging the IP stack.
  286. The information provided is implementation-defined;
  287. see the source for details. Generally, what is returned is error messages
  288. about bad packets.
  289. .PP
  290. Writing to
  291. .B /net/log
  292. controls debugging. The control messages
  293. are:
  294. .TP
  295. .BI set\ arglist
  296. .I Arglist
  297. is a space-separated list of items for which to enable debugging.
  298. The possible items are:
  299. .BR ppp ,
  300. .BR ip ,
  301. .BR fs ,
  302. .BR tcp ,
  303. .BR il ,
  304. .BR icmp ,
  305. .BR udb ,
  306. .BR compress ,
  307. .BR ilmsg ,
  308. .BR gre ,
  309. .BR tcpmsg ,
  310. .BR udpmsg ,
  311. .BR ipmsg ,
  312. and
  313. .BR esp .
  314. .TP
  315. .BI clear\ arglist
  316. .I Arglist
  317. is a space-separated list of items for which to disable debugging.
  318. .TP
  319. .BI only\ addr
  320. If
  321. .I addr
  322. is non-zero, restrict debugging to only those
  323. packets whose source or destination is that
  324. address.
  325. .PP
  326. The file
  327. .B /net/ndb
  328. can be read or written by
  329. programs. It is normally used by
  330. .IR ipconfig (8)
  331. to leave configuration information for other programs
  332. such as
  333. .B dns
  334. and
  335. .B cs
  336. (see
  337. .IR ndb (8)).
  338. .B /net/ndb
  339. may contain up to 1024 bytes.
  340. .PP
  341. The file
  342. .B /net/ipselftab
  343. is a read-only file containing all the IP addresses
  344. considered local. Each line in the file contains
  345. three white-space-separated fields: IP address, usage count,
  346. and flags. The usage count is the number of interfaces to which
  347. the address applies. The flags are the same as for routing
  348. entries.
  349. .SS "Protocol directories
  350. .PP
  351. The
  352. .I ip
  353. device
  354. supports IP as well as several protocols that run over it:
  355. TCP, IL, UDP, GRE, ESP, ICMP, and RUDP.
  356. TCP and UDP provide the standard Internet
  357. protocols for reliable stream and unreliable datagram
  358. communication.
  359. IL provides a reliable datagram service for communication
  360. between Plan 9 machines.
  361. GRE is a general encapsulation protocol.
  362. ESP is the encapsulation protocol for IPSEC.
  363. ICMP is IP's catch-all control protocol used to send
  364. low level error messages and to implement
  365. .IR ping (8).
  366. RUDP is a locally developed reliable datagram protocol based on
  367. UDP.
  368. .PP
  369. Each protocol is a subdirectory of the IP stack.
  370. The top level directory of each protocol contains a
  371. .B clone
  372. file, a
  373. .B stats
  374. file, and subdirectories numbered from zero to the number of connections
  375. opened for this protocol.
  376. .PP
  377. Opening the
  378. .B clone
  379. file reserves a connection. The file descriptor returned from the
  380. .IR open (2)
  381. will point to the control file,
  382. .BR ctl ,
  383. of the newly allocated connection.
  384. Reading
  385. .B ctl
  386. returns a text
  387. string representing the number of the
  388. connection.
  389. Connections may be used either to listen for incoming calls
  390. or to initiate calls to other machines.
  391. .PP
  392. A connection is controlled by writing text strings to the associated
  393. .B ctl
  394. file.
  395. After a connection has been established data may be read from
  396. and written to
  397. .BR data .
  398. A connection can be actively established using the
  399. .B connect
  400. message (see also
  401. .IR dial (2)).
  402. A connection can be established passively by first
  403. using an
  404. .B announce
  405. message (see
  406. .IR dial (2))
  407. to bind to a local port and then
  408. opening the
  409. .B listen
  410. file (see
  411. .IR dial (2))
  412. to receive incoming calls.
  413. .PP
  414. The following control messages are supported:
  415. .TP
  416. .BI connect\ ipaddress ! port "!r " local
  417. Establish a connection to the remote address
  418. .I ipaddress
  419. and remote port
  420. .IR port .
  421. If
  422. .I local
  423. is specified, it is used as the local port number.
  424. If
  425. .I local
  426. is not specified but
  427. .B !r
  428. is, the system will allocate
  429. a restricted port number (less than 1024) for the connection to allow communication
  430. with Unix
  431. .B login
  432. and
  433. .B exec
  434. services.
  435. Otherwise a free port number starting at 5000 is chosen.
  436. The connect fails if the combination of local and remote address/port pairs
  437. are already assigned to another port.
  438. .TP
  439. .BI announce\ X
  440. .I X
  441. is a decimal port number or
  442. .LR * .
  443. Set the local port
  444. number to
  445. .I X
  446. and accept calls to
  447. .IR X .
  448. If
  449. .I X
  450. is
  451. .LR * ,
  452. accept
  453. calls for any port that no process has explicitly announced.
  454. The local IP address cannot be set.
  455. .B Announce
  456. fails if the connection is already announced or connected.
  457. .TP
  458. .BI bind\ X
  459. .I X
  460. is a decimal port number or
  461. .LR * .
  462. Set the local port number to
  463. .IR X .
  464. This exists to support emulation
  465. of BSD sockets by the APE libraries (see
  466. .IR pcc (1))
  467. and is not otherwise used.
  468. .TP
  469. .BI backlog\ n
  470. Set the maximum number of unanswered (queued) incoming
  471. connections to an announced port to
  472. .IR n .
  473. By default
  474. .I n
  475. is set to five. If more than
  476. .I n
  477. connections are pending,
  478. further requests for a service will be rejected.
  479. .TP
  480. .BI ttl\ n
  481. Set the time to live IP field in outgoing packets to
  482. .IR n .
  483. .TP
  484. .BI tos\ n
  485. Set the service type IP field in outgoing packets to
  486. .IR n .
  487. .PP
  488. Port numbers must be in the range 1 to 32767.
  489. .PP
  490. Several files report the status of a
  491. connection.
  492. The
  493. .B remote
  494. and
  495. .B local
  496. files contain the IP address and port number for the remote and local side of the
  497. connection. The
  498. .B status
  499. file contains protocol-dependent information to help debug network connections.
  500. On receiving and error or EOF reading or writing the
  501. .B data
  502. file, the
  503. .B err
  504. file contains the reason for error.
  505. .PP
  506. A process may accept incoming connections by
  507. .IR open (2)ing
  508. the
  509. .B listen
  510. file.
  511. The
  512. .B open
  513. will block until a new connection request arrives.
  514. Then
  515. .B open
  516. will return an open file descriptor which points to the control file of the
  517. newly accepted connection.
  518. This procedure will accept all calls for the
  519. given protocol.
  520. See
  521. .IR dial (2).
  522. .SS TCP
  523. .PP
  524. TCP connections are reliable point-to-point byte streams; there are no
  525. message delimiters.
  526. A connection is determined by the address and port numbers of the two
  527. ends.
  528. TCP
  529. .B ctl
  530. files support the following additional messages:
  531. .TP
  532. .B hangup
  533. close down a TCP connection
  534. .TP
  535. .BI keepalive \ n
  536. turn on keep alive messages.
  537. .IR N ,
  538. if given, is the milliseconds between keepalives
  539. (default 30000).
  540. .SS UDP
  541. .PP
  542. UDP connections carry unreliable and unordered datagrams. A read from
  543. .B data
  544. will return the next datagram, discarding anything
  545. that doesn't fit in the read buffer.
  546. A write is sent as a single datagram.
  547. .PP
  548. By default, a UDP connection is a point-to-point link.
  549. Either a
  550. .B connect
  551. establishes a local and remote address/port pair or
  552. after an
  553. .BR announce ,
  554. each datagram coming from a different remote address/port pair
  555. establishes a new incoming connection.
  556. However, many-to-one semantics is also possible.
  557. .PP
  558. If, after an
  559. .BR announce ,
  560. one of the following messages is written to
  561. .BR ctl ,
  562. then all messages sent to the announced port
  563. are received on the announced connection prefixed with the given structure.
  564. .B headers
  565. .EX
  566. typedef struct Udphdr Udphdr;
  567. struct Udphdr
  568. {
  569. uchar raddr[16]; /* v6 remote address and port */
  570. uchar laddr[16]; /* v6 local address and port */
  571. uchar ifcaddr[16]; /* interface address (receive only) */
  572. uchar rport[2];
  573. uchar lport[2];
  574. };
  575. .EE
  576. .PP
  577. The only difference in the two is the type of address, IPv4 or IPv6.
  578. Before a write, a user must prefix a similar structure to each message.
  579. The system overrides the user specified local port with the announced
  580. one. If the user specifies an address that isn't a unicast address in
  581. .BR /net/ipselftab ,
  582. that too is overridden.
  583. Since the prefixed structure is the same in read and write, it is relatively
  584. easy to write a server that responds to client requests by just copying new
  585. data into the message body and then writing back the same buffer that was
  586. written.
  587. .SS RUDP
  588. .PP
  589. RUDP is a reliable datagram protocol based on UDP.
  590. Packets are delivered in order.
  591. RUDP does not support
  592. .BR listen .
  593. One must use either
  594. .B connect
  595. or
  596. .B announce
  597. followed immediately by
  598. .B headers .
  599. .PP
  600. Unlike IL or TCP, the reboot of one end of a connection does
  601. not force a closing of the connection. Communications will
  602. resume when the rebooted machine resumes talking. Any unacknowledged
  603. packets queued before the reboot will be lost. A reboot can
  604. be detected by reading the
  605. .B err
  606. file. It will have the message
  607. .IP
  608. .BI hangup\ address ! port
  609. .PP
  610. where
  611. .I address
  612. and
  613. .I port
  614. are of the far side of the connection.
  615. Retransmitting a datagram more than 10 times
  616. is treated like a reboot:
  617. all queued messages are dropped, an error is queued to the
  618. .B err
  619. file, and the conversation resumes.
  620. .SS IL
  621. .PP
  622. IL is a reliable point-to-point datagram protocol. Like TCP, IL delivers datagrams
  623. reliably and in order. Also like TCP, a connection is
  624. determined by the address and port numbers of the two ends.
  625. Like UDP, each read and write transfers a single datagram.
  626. .PP
  627. IL is efficient for LANs but doesn't have the
  628. congestion control features needed for use through
  629. the Internet.
  630. .SS GRE
  631. .PP
  632. GRE is the encapsulation protocol used by PPTP.
  633. The kernel implements just enough of the protocol
  634. to multiplex it.
  635. .B Announce
  636. is not allowed in GRE, only
  637. .BR connect .
  638. Since GRE has no port numbers, the port number in the connect
  639. is actually the 16 bit
  640. .B eproto
  641. field in the GRE header.
  642. .PP
  643. Reads and writes transfer a
  644. GRE datagram starting at the GRE header.
  645. On write, the kernel fills in the
  646. .B eproto
  647. field with the port number specified
  648. in the connect message.
  649. .SS ESP
  650. .PP
  651. ESP is the Encapsulating Security Payload (RFC 1827).
  652. It is used to set up an encrypted tunnel between machines.
  653. Like GRE, ESP has no port numbers. Instead, the
  654. port number in the
  655. .B connect
  656. message is the SPI (Security Association Identifier (sic)).
  657. IP packets are written to and read from
  658. .BR data .
  659. The kernel encrypts any packets written to
  660. .BR data ,
  661. appends a MAC, and prefixes an ESP header before
  662. sending to the other end of the tunnel.
  663. Received packets are checked against their MAC's,
  664. decrypted, and queued for reading from
  665. .BR data .
  666. The control messages are:
  667. .TP
  668. .BI esp\ "alg secret
  669. Encrypt with the algorithm,
  670. .IR alg ,
  671. using
  672. .I secret
  673. as the key.
  674. Possible algorithms are:
  675. .BR null ,
  676. .BR des_56_cbc ,
  677. and
  678. .BR rc4_128 .
  679. .TP
  680. .BI ah\ "alg secret
  681. Use the hash algorithm,
  682. .IR alg ,
  683. with
  684. .I secret
  685. as the key for generating the MAC.
  686. Possible algorithms are:
  687. .BR null ,
  688. .BR hmac_sha1_96 ,
  689. and
  690. .BR hmac_md5_96 .
  691. .TP
  692. .B header
  693. Turn on header mode. Every buffer read from
  694. .B data
  695. starts with 4 unused bytes, and the first 4 bytes
  696. of every buffer written to
  697. .B data
  698. are ignored.
  699. .TP
  700. .B noheader
  701. Turn off header mode.
  702. .SS "IP packet filter
  703. .PP
  704. The directory
  705. .B /net/ipmux
  706. looks like another protocol directory.
  707. It is a packet filter built on top of IP. Each numbered
  708. subdirectory represents a different filter.
  709. The connect messages written to the
  710. .I ctl
  711. file describe the filter. Packets matching the filter can be read on the
  712. .B data
  713. file. Packets written to the
  714. .B data
  715. file are routed to an interface and transmitted.
  716. .PP
  717. A filter is a semicolon-separated list of
  718. relations. Each relation describes a portion
  719. of a packet to match. The possible relations are:
  720. .TP
  721. .BI proto= n
  722. the IP protocol number must be
  723. .IR n .
  724. .TP
  725. .BI dat[ n : m ]= expr
  726. bytes
  727. .I n
  728. through
  729. .I m
  730. following the IP packet must match
  731. .IR expr .
  732. .TP
  733. .BI ifc= expr
  734. the packet must have been received on an interface whose address
  735. matches
  736. .IR expr .
  737. .TP
  738. .BI src= expr
  739. The source address in the packet must match
  740. .IR expr .
  741. .TP
  742. .BI dst= expr
  743. The destination address in the packet must match
  744. .IR expr .
  745. .PP
  746. .I Expr
  747. is of the form:
  748. .TP
  749. .I \ value
  750. .TP
  751. .IB \ value | value | ...
  752. .TP
  753. .IB \ value & mask
  754. .TP
  755. .IB \ value | value & mask
  756. .PP
  757. If a mask is given, the relevant field is first ANDed with
  758. the mask. The result is compared against the value or list
  759. of values for a match. In the case of
  760. .BR ifc ,
  761. .BR dst ,
  762. and
  763. .B src
  764. the value is a dot-formatted IP address and the mask is a dot-formatted
  765. IP mask. In the case of
  766. .BR dat ,
  767. both value and mask are strings of 2 character hexadecimal digits representing
  768. 8 bit values.
  769. .PP
  770. A packet is delivered to only one filter.
  771. The filters are merged into a single comparison tree.
  772. If two filters match the same packet, the following
  773. rules apply in order (here '>' means is preferred to):
  774. .IP 1)
  775. protocol > data > source > destination > interface
  776. .IP 2)
  777. lower data offsets > higher data offsets
  778. .IP 3)
  779. longer matches > shorter matches
  780. .IP 4)
  781. older > younger
  782. .PP
  783. So far this has just been used to implement a version of
  784. OSPF in Inferno.
  785. .SS Statistics
  786. .PP
  787. The
  788. .B stats
  789. files are read only and contain statistics useful to network
  790. monitoring.
  791. .PP
  792. Reading
  793. .B /net/ipifc/stats
  794. returns a list of 19 tagged and new line separated fields representing:
  795. .EX
  796. .ft 1
  797. forwarding status (0 and 2 mean forwarding off, 1 means on)
  798. default TTL
  799. input packets
  800. input header errors
  801. input address errors
  802. packets forwarded
  803. input packets for unknown protocols
  804. input packets discarded
  805. input packets delivered to higher level protocols
  806. output packets
  807. output packets discarded
  808. output packets with no route
  809. timed out fragments in reassembly queue
  810. requested reassemblies
  811. successful reassemblies
  812. failed reassemblies
  813. successful fragmentations
  814. unsuccessful fragmentations
  815. fragments created
  816. .ft
  817. .EE
  818. .PP
  819. Reading
  820. .B /net/icmp/stats
  821. returns a list of 25 tagged and new line separated fields representing:
  822. .EX
  823. .ft 1
  824. messages received
  825. bad received messages
  826. unreachables received
  827. time exceededs received
  828. input parameter problems received
  829. source quenches received
  830. redirects received
  831. echo requests received
  832. echo replies received
  833. timestamps received
  834. timestamp replies received
  835. address mask requests received
  836. address mask replies received
  837. messages sent
  838. transmission errors
  839. unreachables sent
  840. time exceededs sent
  841. input parameter problems sent
  842. source quenches sent
  843. redirects sent
  844. echo requests sent
  845. echo replies sent
  846. timestamps sent
  847. timestamp replies sent
  848. address mask requests sent
  849. address mask replies sent
  850. .EE
  851. .PP
  852. Reading
  853. .B /net/tcp/stats
  854. returns a list of 11 tagged and new line separated fields representing:
  855. .EX
  856. .ft 1
  857. maximum number of connections
  858. total outgoing calls
  859. total incoming calls
  860. number of established connections to be reset
  861. number of currently established connections
  862. segments received
  863. segments sent
  864. segments retransmitted
  865. retransmit timeouts
  866. bad received segments
  867. transmission failures
  868. .EE
  869. .PP
  870. Reading
  871. .B /net/udp/stats
  872. returns a list of 4 tagged and new line separated fields representing:
  873. .EX
  874. .ft 1
  875. datagrams received
  876. datagrams received for bad ports
  877. malformed datagrams received
  878. datagrams sent
  879. .EE
  880. .PP
  881. Reading
  882. .B /net/il/stats
  883. returns a list of 7 tagged and new line separated fields representing:
  884. .EX
  885. .ft 1
  886. checksum errors
  887. header length errors
  888. out of order messages
  889. retransmitted messages
  890. duplicate messages
  891. duplicate bytes
  892. .EE
  893. .PP
  894. Reading
  895. .B /net/gre/stats
  896. returns a list of 1 tagged number representing:
  897. .EX
  898. .ft 1
  899. header length errors
  900. .EE
  901. .SH "SEE ALSO"
  902. .IR listen (8),
  903. .IR dial (2),
  904. .IR ndb (6)
  905. .SH SOURCE
  906. .B /sys/src/9/ip
  907. .SH BUGS
  908. .I Ipmux
  909. has not been heavily used and should be considered experimental.
  910. It may disappear in favor of a more traditional packet filter in the future.