ip 21 KB

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