ip 24 KB

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