ip 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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 but is now deprecated.
  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. It is no longer necessary, except to communicate with old standalone
  631. .IR fs (4)
  632. file servers.
  633. Its use is now deprecated.
  634. .SS GRE
  635. .PP
  636. GRE is the encapsulation protocol used by PPTP.
  637. The kernel implements just enough of the protocol
  638. to multiplex it.
  639. .B Announce
  640. is not allowed in GRE, only
  641. .BR connect .
  642. Since GRE has no port numbers, the port number in the connect
  643. is actually the 16 bit
  644. .B eproto
  645. field in the GRE header.
  646. .PP
  647. Reads and writes transfer a
  648. GRE datagram starting at the GRE header.
  649. On write, the kernel fills in the
  650. .B eproto
  651. field with the port number specified
  652. in the connect message.
  653. .SS ESP
  654. .PP
  655. ESP is the Encapsulating Security Payload (RFC 1827).
  656. It is used to set up an encrypted tunnel between machines.
  657. Like GRE, ESP has no port numbers. Instead, the
  658. port number in the
  659. .B connect
  660. message is the SPI (Security Association Identifier (sic)).
  661. IP packets are written to and read from
  662. .BR data .
  663. The kernel encrypts any packets written to
  664. .BR data ,
  665. appends a MAC, and prefixes an ESP header before
  666. sending to the other end of the tunnel.
  667. Received packets are checked against their MAC's,
  668. decrypted, and queued for reading from
  669. .BR data .
  670. The control messages are:
  671. .TP
  672. .BI esp\ "alg secret
  673. Encrypt with the algorithm,
  674. .IR alg ,
  675. using
  676. .I secret
  677. as the key.
  678. Possible algorithms are:
  679. .BR null ,
  680. .BR des_56_cbc ,
  681. and
  682. .BR rc4_128 .
  683. .TP
  684. .BI ah\ "alg secret
  685. Use the hash algorithm,
  686. .IR alg ,
  687. with
  688. .I secret
  689. as the key for generating the MAC.
  690. Possible algorithms are:
  691. .BR null ,
  692. .BR hmac_sha1_96 ,
  693. and
  694. .BR hmac_md5_96 .
  695. .TP
  696. .B header
  697. Turn on header mode. Every buffer read from
  698. .B data
  699. starts with 4 unused bytes, and the first 4 bytes
  700. of every buffer written to
  701. .B data
  702. are ignored.
  703. .TP
  704. .B noheader
  705. Turn off header mode.
  706. .SS "IP packet filter
  707. .PP
  708. The directory
  709. .B /net/ipmux
  710. looks like another protocol directory.
  711. It is a packet filter built on top of IP. Each numbered
  712. subdirectory represents a different filter.
  713. The connect messages written to the
  714. .I ctl
  715. file describe the filter. Packets matching the filter can be read on the
  716. .B data
  717. file. Packets written to the
  718. .B data
  719. file are routed to an interface and transmitted.
  720. .PP
  721. A filter is a semicolon-separated list of
  722. relations. Each relation describes a portion
  723. of a packet to match. The possible relations are:
  724. .TP
  725. .BI proto= n
  726. the IP protocol number must be
  727. .IR n .
  728. .TP
  729. .BI dat[ n : m ]= expr
  730. bytes
  731. .I n
  732. through
  733. .I m
  734. following the IP packet must match
  735. .IR expr .
  736. .TP
  737. .BI ifc= expr
  738. the packet must have been received on an interface whose address
  739. matches
  740. .IR expr .
  741. .TP
  742. .BI src= expr
  743. The source address in the packet must match
  744. .IR expr .
  745. .TP
  746. .BI dst= expr
  747. The destination address in the packet must match
  748. .IR expr .
  749. .PP
  750. .I Expr
  751. is of the form:
  752. .TP
  753. .I \ value
  754. .TP
  755. .IB \ value | value | ...
  756. .TP
  757. .IB \ value & mask
  758. .TP
  759. .IB \ value | value & mask
  760. .PP
  761. If a mask is given, the relevant field is first ANDed with
  762. the mask. The result is compared against the value or list
  763. of values for a match. In the case of
  764. .BR ifc ,
  765. .BR dst ,
  766. and
  767. .B src
  768. the value is a dot-formatted IP address and the mask is a dot-formatted
  769. IP mask. In the case of
  770. .BR dat ,
  771. both value and mask are strings of 2 character hexadecimal digits representing
  772. 8 bit values.
  773. .PP
  774. A packet is delivered to only one filter.
  775. The filters are merged into a single comparison tree.
  776. If two filters match the same packet, the following
  777. rules apply in order (here '>' means is preferred to):
  778. .IP 1)
  779. protocol > data > source > destination > interface
  780. .IP 2)
  781. lower data offsets > higher data offsets
  782. .IP 3)
  783. longer matches > shorter matches
  784. .IP 4)
  785. older > younger
  786. .PP
  787. So far this has just been used to implement a version of
  788. OSPF in Inferno.
  789. .SS Statistics
  790. .PP
  791. The
  792. .B stats
  793. files are read only and contain statistics useful to network
  794. monitoring.
  795. .PP
  796. Reading
  797. .B /net/ipifc/stats
  798. returns a list of 19 tagged and new line separated fields representing:
  799. .EX
  800. .ft 1
  801. forwarding status (0 and 2 mean forwarding off, 1 means on)
  802. default TTL
  803. input packets
  804. input header errors
  805. input address errors
  806. packets forwarded
  807. input packets for unknown protocols
  808. input packets discarded
  809. input packets delivered to higher level protocols
  810. output packets
  811. output packets discarded
  812. output packets with no route
  813. timed out fragments in reassembly queue
  814. requested reassemblies
  815. successful reassemblies
  816. failed reassemblies
  817. successful fragmentations
  818. unsuccessful fragmentations
  819. fragments created
  820. .ft
  821. .EE
  822. .PP
  823. Reading
  824. .B /net/icmp/stats
  825. returns a list of 25 tagged and new line separated fields representing:
  826. .EX
  827. .ft 1
  828. messages received
  829. bad received messages
  830. unreachables received
  831. time exceededs received
  832. input parameter problems received
  833. source quenches received
  834. redirects received
  835. echo requests received
  836. echo replies received
  837. timestamps received
  838. timestamp replies received
  839. address mask requests received
  840. address mask replies received
  841. messages sent
  842. transmission errors
  843. unreachables sent
  844. time exceededs sent
  845. input parameter problems sent
  846. source quenches sent
  847. redirects sent
  848. echo requests sent
  849. echo replies sent
  850. timestamps sent
  851. timestamp replies sent
  852. address mask requests sent
  853. address mask replies sent
  854. .EE
  855. .PP
  856. Reading
  857. .B /net/tcp/stats
  858. returns a list of 11 tagged and new line separated fields representing:
  859. .EX
  860. .ft 1
  861. maximum number of connections
  862. total outgoing calls
  863. total incoming calls
  864. number of established connections to be reset
  865. number of currently established connections
  866. segments received
  867. segments sent
  868. segments retransmitted
  869. retransmit timeouts
  870. bad received segments
  871. transmission failures
  872. .EE
  873. .PP
  874. Reading
  875. .B /net/udp/stats
  876. returns a list of 4 tagged and new line separated fields representing:
  877. .EX
  878. .ft 1
  879. datagrams received
  880. datagrams received for bad ports
  881. malformed datagrams received
  882. datagrams sent
  883. .EE
  884. .PP
  885. Reading
  886. .B /net/il/stats
  887. returns a list of 7 tagged and new line separated fields representing:
  888. .EX
  889. .ft 1
  890. checksum errors
  891. header length errors
  892. out of order messages
  893. retransmitted messages
  894. duplicate messages
  895. duplicate bytes
  896. .EE
  897. .PP
  898. Reading
  899. .B /net/gre/stats
  900. returns a list of 1 tagged number representing:
  901. .EX
  902. .ft 1
  903. header length errors
  904. .EE
  905. .SH "SEE ALSO"
  906. .IR listen (8),
  907. .IR dial (2),
  908. .IR ndb (6)
  909. .SH SOURCE
  910. .B /sys/src/9/ip
  911. .SH BUGS
  912. .I Ipmux
  913. has not been heavily used and should be considered experimental.
  914. It may disappear in favor of a more traditional packet filter in the future.