You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1111 lines

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Jingle File Transfer</title>
  10. <abstract>This specification defines a Jingle application type for transferring a file from one entity to another. The protocol provides a modular framework that enables the exchange of information about the file to be transferred as well as the negotiation of parameters such as the transport to be used.</abstract>
  12. <number>0234</number>
  13. <status>Proposed</status>
  14. <lastcall>2017-12-12</lastcall>
  15. <type>Standards Track</type>
  16. <sig>Standards</sig>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0166</spec>
  20. <spec>XEP-0261</spec>
  21. <spec>XEP-0300</spec>
  22. </dependencies>
  23. <supersedes><spec>XEP-0096</spec></supersedes>
  24. <supersededby/>
  25. <shortname>jingle-ft</shortname>
  26. &stpeter;
  27. &lance;
  28. <revision>
  29. <version>0.18.3</version>
  30. <date>2017-08-24</date>
  31. <initials>ps</initials>
  32. <remark><p>Make use of &lt;hash-used/&gt; from XEP-0300.</p></remark>
  33. </revision>
  34. <revision>
  35. <version>0.18.2</version>
  36. <date>2017-08-23</date>
  37. <initials>editor (jwi)</initials>
  38. <remark><ul>
  39. <li>Fix a date missing its timezone in examples. (egp)</li>
  40. <li>Remove the mention of UTC, timestamps are already properly described in XEP-0082. (egp)</li>
  41. <li>Add missing length attribute to XML schema. (ps)</li>
  42. <li>Fix incorrect XML in examples. (ps)</li>
  43. </ul></remark>
  44. </revision>
  45. <revision>
  46. <version>0.18.1</version>
  47. <date>2017-05-20</date>
  48. <initials>egp</initials>
  49. <remark><ul>
  50. <li>Add missing anchor to the <link url='#received'>Received</link> section.</li>
  51. <li>Add missing received and desc elements in schema.</li>
  52. </ul></remark>
  53. </revision>
  54. <revision>
  55. <version>0.18.0</version>
  56. <date>2017-01-30</date>
  57. <initials>ls</initials>
  58. <remark>
  59. <ul>
  60. <li>Update dependency on XEP-0300 to require the 'urn:xmpp:hashes:2' namespace that mandates base64 encoding.</li>
  61. <li>Clarify that a &lt;range/&gt; element with a limit or offset value in a 'session-accept' should be honored by the file sender.</li>
  62. <li>Namespace version bumped to ':5'.</li>
  63. </ul>
  64. </remark>
  65. </revision>
  66. <revision>
  67. <version>0.17.2</version>
  68. <date>2016-07-15</date>
  69. <initials>ph (XEP Editor: ssw)</initials>
  70. <remark><p>Fix references to ICE-TCP.</p></remark>
  71. </revision>
  72. <revision>
  73. <version>0.17.1</version>
  74. <date>2016-03-08</date>
  75. <initials>ls</initials>
  76. <remark><p>Corrected some instances of transport-info to instead be session-info.</p></remark>
  77. </revision>
  78. <revision>
  79. <version>0.17</version>
  80. <date>2015-09-08</date>
  81. <initials>ls/psa</initials>
  82. <remark>
  83. <ul>
  84. <li>Recast the document to match the registration procedure defined by XEP-0166 for new application types.</li>
  85. <li>Explicitly defined the schema of the &lt;file/&gt; element instead of referencing XEP-0096.</li>
  86. <li>Defined the use of a 'length' attribute on &lt;range/&gt; elements. This attribute was always there because the &lt;file/&gt; and &lt;range/&gt; elements had been defined as the same as the parallel elements in XEP-0096, but the 'length' attribute was not explicitly referenced in this document.</li>
  87. <li>Clarified the need for the 'senders' attribute on Jingle &lt;content/&gt; elements to distinguish between File Offers and File Requests.</li>
  88. <li>Added the &lt;file-not-found/&gt; and &lt;file-too-large/&gt; reason types.</li>
  89. <li>Clarified how to abort a file transfer via 'content-remove' or 'session-terminate' actions.</li>
  90. <li>Added &lt;received/&gt; element for indicating that a transfer was successful, particularly when there are multiple transfers.</li>
  91. <li>Added SDP mapping.</li>
  92. </ul>
  93. </remark>
  94. </revision>
  95. <revision>
  96. <version>0.16</version>
  97. <date>2014-08-11</date>
  98. <initials>psa</initials>
  99. <remark>
  100. <ul>
  101. <li>Modified protocol to support sending only one file at a time (multi-file adds unnecessary complexity).</li>
  102. <li>Removed &lt;request/&gt; flow in favor of a dedicated protocol similar to XEP-0137 ("jingle-pub").</li>
  103. <li>Removed &lt;offer/&gt; wrapper since it is no longer necessary (with the removal of the request flow).</li>
  104. <li>Removed the &lt;abort/&gt; element since it was related to the transfer of multiple files.</li>
  105. <li>Changed &lt;candidate-used/&gt; to &gt;remote-candidate/&gt; for consistency with XEP-0176.</li>
  106. <li>Added media-type child to &lt;file/&gt; element.</li>
  107. <li>Added example for communicating empty &lt;hash/&gt; element in the session-initiate message.</li>
  108. <li>Incremented namespace version from 3 to 4.</li>
  109. </ul>
  110. </remark>
  111. </revision>
  112. <revision>
  113. <version>0.15</version>
  114. <date>2012-02-08</date>
  115. <initials>psa</initials>
  116. <remark><p>Updated to track revisions to XEP-0300.</p></remark>
  117. </revision>
  118. <revision>
  119. <version>0.14</version>
  120. <date>2011-06-29</date>
  121. <initials>psa</initials>
  122. <remark>
  123. <ul>
  124. <li>Defined file description format separate from XEP-0096</li>
  125. <li>Modified the checksum format to reuse the &lt;hashes/&gt; element from XEP-0300</li>
  126. <li>Described the process of aborting a file transfer</li>
  127. <li>Clarified the order of events (Jingle, then transport) when the session is terminated</li>
  128. <li>Added section on determining spport, including service discovery feature for multi-file support</li>
  129. <li>Removed the 'urn:xmpp:jingle:apps:file-transfer:info:2' namespace by putting all elements into the 'urn:xmpp:jingle:apps:file-transfer:4' namespace</li>
  130. <li>Incremented namespace version from 2 to 3</li>
  131. </ul>
  132. </remark>
  133. </revision>
  134. <revision>
  135. <version>0.13</version>
  136. <date>2011-06-01</date>
  137. <initials>psa</initials>
  138. <remark><p>Added multi-file use case; updated spec to reflect XEP-0260 and XEP-0261; added algorithm attribute from XEP-0096; increased namespace versions from 1 to 2.</p></remark>
  139. </revision>
  140. <revision>
  141. <version>0.12</version>
  142. <date>2011-01-05</date>
  143. <initials>psa</initials>
  144. <remark><p>Clarified usage of Jingle actions as well as several ambiguous points in the text, including use of the range feature from XEP-0096.</p></remark>
  145. </revision>
  146. <revision>
  147. <version>0.11</version>
  148. <date>2010-02-19</date>
  149. <initials>psa</initials>
  150. <remark><p>Added session-info message and namespace for communicating the file hash.</p></remark>
  151. </revision>
  152. <revision>
  153. <version>0.10</version>
  154. <date>2010-02-11</date>
  155. <initials>psa</initials>
  156. <remark><p>Described the file retrieval case; updated referenced namespaces.</p></remark>
  157. </revision>
  158. <revision>
  159. <version>0.9</version>
  160. <date>2009-02-19</date>
  161. <initials>psa</initials>
  162. <remark>
  163. <ul>
  164. <li>Moved Jingle definitions of S5B and IBB transports to standalone documents.</li>
  165. <li>Because the jingle-s5b and jingle-ibb transport methods are backward-incompatible, incremented protocol version number from 0 to 1 and changed namespace from urn:xmpp:jingle:apps:file-transfer:0 to urn:xmpp:jingle:apps:file-transfer:2.</li>
  166. <li>Moved transport fallback scenario to XEP-0260.</li>
  167. </ul>
  168. </remark>
  169. </revision>
  170. <revision>
  171. <version>0.8</version>
  172. <date>2008-09-30</date>
  173. <initials>psa</initials>
  174. <remark><p>Corrected fallback scenario to use transport-replace and transport-accept.</p></remark>
  175. </revision>
  176. <revision>
  177. <version>0.7</version>
  178. <date>2008-09-25</date>
  179. <initials>psa</initials>
  180. <remark>
  181. <ul>
  182. <li>Deleted content-replace from session flows.</li>
  183. <li>Modified namespaces to incorporate namespace versioning.</li>
  184. <li>Cleaned up XML schemas.</li>
  185. </ul>
  186. </remark>
  187. </revision>
  188. <revision>
  189. <version>0.6</version>
  190. <date>2008-07-31</date>
  191. <initials>psa</initials>
  192. <remark><p>Harmonized with XEP-0166; modified fallback to use transport-replace and transport-accept.</p></remark>
  193. </revision>
  194. <revision>
  195. <version>0.5</version>
  196. <date>2008-06-05</date>
  197. <initials>psa</initials>
  198. <remark><p>Modified fallback scenario to use content-replace action during pending state.</p></remark>
  199. </revision>
  200. <revision>
  201. <version>0.4</version>
  202. <date>2008-06-04</date>
  203. <initials>psa</initials>
  204. <remark><p>Harmonized negotiation flows with other Jingle application types.</p></remark>
  205. </revision>
  206. <revision>
  207. <version>0.3</version>
  208. <date>2008-05-29</date>
  209. <initials>psa</initials>
  210. <remark><p>Corrected and more clearly explained negotiation flows for consistency with XEP-0166 and other Jingle specifications.</p></remark>
  211. </revision>
  212. <revision>
  213. <version>0.2</version>
  214. <date>2008-03-20</date>
  215. <initials>psa</initials>
  216. <remark><p>Added transport negotiation scenario.</p></remark>
  217. </revision>
  218. <revision>
  219. <version>0.1</version>
  220. <date>2008-03-05</date>
  221. <initials>psa</initials>
  222. <remark><p>Initial published version.</p></remark>
  223. </revision>
  224. <revision>
  225. <version>0.0.3</version>
  226. <date>2008-02-29</date>
  227. <initials>psa</initials>
  228. <remark><p>Corrected use of content-replace action; specified that the In-Band Bytestreams transport method is mandatory-to-implement but must have the lowest preference order.</p></remark>
  229. </revision>
  230. <revision>
  231. <version>0.0.2</version>
  232. <date>2008-02-28</date>
  233. <initials>psa</initials>
  234. <remark><p>Modified negotiation flow to use new content-replace action.</p></remark>
  235. </revision>
  236. <revision>
  237. <version>0.0.1</version>
  238. <date>2008-01-29</date>
  239. <initials>psa</initials>
  240. <remark><p>First draft.</p></remark>
  241. </revision>
  242. </header>
  243. <section1 topic='Introduction' anchor='intro'>
  244. <p>&xep0166; can be used to initiate and negotiate a wide range of peer-to-peer sessions. One session type of interest is file transfer. This document specifies an application format for negotiating Jingle file transfer sessions, where files are exchanged via any available reliable transport.</p>
  245. </section1>
  246. <section1 topic='Requirements'>
  247. <p>&xep0096; was the original XMPP protocol extension for file transfer negotiation. However, that protocol has several drawbacks, most related to the &xep0095; protocol on which it depends:</p>
  248. <ol>
  249. <li><p>It does not enable a true, bidirectional negotiation; instead, the initiator sets the terms for the file transfer and the responder either accepts the terms or cancels the negotiation.</p></li>
  250. <li><p>It is the only technology in the Jabber/XMPP protocol "stack" that uses <cite>XEP-0095: Stream Initiation</cite>. More modern technologies such as voice and video session negotiation use &xep0166;, and it would be helpful if implementors could re-use the same code for all negotiation use cases.</p></li>
  251. </ol>
  252. <p>To overcome these drawbacks, this specification defines a file transfer negotiation method that meets the following requirements:</p>
  253. <ul>
  254. <li><p>Use the session negotiation semantics from <cite>XEP-0166</cite>.</p></li>
  255. <li>
  256. <p>Use any reliable Jingle transport mechanism, including but not limited to:</p>
  257. <ul>
  258. <li>ICE-TCP &rfc6544;</li>
  259. <li>SOCKS5 Bytestreams &xep0260;</li>
  260. <li>In-Band Bytestreams &xep0261;</li>
  261. </ul>
  262. </li>
  263. <li><p>Define a file description format that, unlike <cite>XEP-0096</cite>, enables hash agility (via &xep0300;).</p></li>
  264. <li><p>Define a clear upgrade path from SI File Transfer to Jingle File Transfer.</p></li>
  265. </ul>
  266. <p>Note that Jingle file transfer is only as reliable as the transports on which it depends. In particular, SOCKS5 Bytestreams ("S5B") does not always result in NAT or firewall traversal. To work around that problem, this specification requires all implementations to support as a fallback mechanism In-Band Bytestreams ("IBB"), which usually results in a successful (if slow) file transfer. A more robust and adaptable option is ICE-TCP (RFC 6544); at the time of writing &xep0176; is being updated to include the ability to negotiate ICE-TCP candidates.</p>
  267. </section1>
  268. <section1 topic='Terminology' anchor='terms'>
  269. <dl>
  270. <di>
  271. <dt>File Offer</dt>
  272. <dd>A Jingle File Transfer Content is said to be a File Offer if the content creator is the same as the content sender (see <link url='#content-senders'>Use of Jingle Content Senders</link>).</dd>
  273. </di>
  274. <di>
  275. <dt>File Request</dt>
  276. <dd>A Jingle File Transfer Content is said to be a File Request if the content creator is the opposite of the content sender (see <link url='#content-senders'>Use of Jingle Content Senders</link>).</dd>
  277. </di>
  278. <di>
  279. <dt>File Sender</dt>
  280. <dd>The File Sender is the side of the Jingle session responsible for sending the file data. The File Sender is not necessarily the same entity as the Jingle session initiator, and an entity could be both a File Sender and File Receiver in the context of a single Jingle session with multiple files.</dd>
  281. </di>
  282. <di>
  283. <dt>File Receiver</dt>
  284. <dd>The File Receiver is the side of the Jingle session responsible for receiving the file data. The File Receiver is not necessarily the same entity as the Jingle session responder, and an entity could be both a File Receiver and File Sender in the context of a single Jingle session with multiple files.</dd>
  285. </di>
  286. </dl>
  287. </section1>
  288. <section1 topic='Jingle Conformance'>
  289. <p>In accordance with Section 12 of <cite>XEP-0166</cite>, this document specifies the following information related to the Jingle File Transfer ("Jingle FT") application type:</p>
  290. <ol>
  291. <li><p>The application format negotiation process is defined in the <link url='#negotiation'>Negotiating a Jingle File Transfer Session</link> section of this document.</p></li>
  292. <li><p>The semantics of the &DESCRIPTION; element are defined in the <link url='#format'>Application Format</link> section of this document.</p></li>
  293. <li><p>A mapping of Jingle semantics to the Session Description Protocol is provided in the <link url='#sdp'>Mapping to Session Description Protocol</link> section of this document.</p></li>
  294. <li><p>A Jingle File Transfer session SHOULD use a streaming transport method, not a datagram transport method.</p></li>
  295. <li><p>Transport components are not used in Jingle File Transfer.</p></li>
  296. <li>
  297. <p>Content is to be sent and received as follows:</p>
  298. <p>For streaming transports, outbound content shall be encoded into packets (as defined by the transport mechanism) without any other framing mechanism and sent in succession over the transport. Incoming data received over the transport shall be processed as a stream of packets, where each packet's content payload is entirely composed of the next portion of file data to be processed.</p>
  299. </li>
  300. </ol>
  301. <section2 topic='Use of Jingle Content Senders' anchor='content-senders'>
  302. <p>Jingle File Transfer makes critical use of the 'senders' attribute of Jingle &CONTENT; elements in order to specify which party is responsible for sending the described file. As such, Jingle File Transfer content MUST include a 'senders' attribute, where the allowed values are "initiator" and "responder". The semantics of the values "both" and "none" are undefined in Jingle File Transfer and thus NOT RECOMMENDED for use with Jingle File Transfer content.</p>
  303. <p>In general, a Jingle File Transfer content is said to be a "File Offer" if the 'senders' attribute is the same as the role of the party adding the content to the session, and a "File Request" if the 'senders' value is the opposite role of the party adding the content.</p>
  304. <p>Note: The content 'creator' attribute does <em>not</em> specify who created or is sending the file, it only specifies which party to the session added the Jingle content to the session.</p>
  305. <table caption='Distinguishing File Offers and Requests'>
  306. <tr>
  307. <th>Jingle Session Role</th>
  308. <th>Content Senders</th>
  309. <th>File Transfer Type</th>
  310. </tr>
  311. <tr>
  312. <td>initiator</td>
  313. <td>initiator</td>
  314. <td>File Offer</td>
  315. </tr>
  316. <tr>
  317. <td>initiator</td>
  318. <td>responder</td>
  319. <td>File Request</td>
  320. </tr>
  321. <tr>
  322. <td>responder</td>
  323. <td>initiator</td>
  324. <td>File Request</td>
  325. </tr>
  326. <tr>
  327. <td>responder</td>
  328. <td>responder</td>
  329. <td>File Offer</td>
  330. </tr>
  331. </table>
  332. </section2>
  333. </section1>
  334. <section1 topic='Application Format'>
  335. <p>A Jingle File Transfer session is described by a content type that contains one application format and one transport method. Each &CONTENT; element defines the details of a single file transfer. A Jingle negotiation MAY result in the establishment of multiple file transfers by including multiple &CONTENT; elements.</p>
  336. <p>The application format consists of a file description contained within a &DESCRIPTION; element qualified by the "urn:xmpp:jingle:apps:file-transfer:5" namespace &VNOTE;. The file description is a &lt;file/&gt; element specifying metadata such as the name of the file, media type, etc., as illustrated in the following example.</p>
  337. <code><![CDATA[
  338. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  339. <file>
  340. <media-type>text/plain</media-type>
  341. <name>test.txt</name>
  342. <date>2015-07-26T21:46:00+01:00</date>
  343. <size>6144</size>
  344. <hash xmlns='urn:xmpp:hashes:2'
  345. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  346. </file>
  347. </description>]]></code>
  348. <p>The &DESCRIPTION; element is intended to be a child of a Jingle &CONTENT; element as specified in <cite>XEP-0166</cite>.</p>
  349. <p>The child elements of the &lt;file/&gt; element are as follows:</p>
  350. <table caption='File Description Elements'>
  351. <tr>
  352. <th>Element Name</th>
  353. <th>Description</th>
  354. <th>Inclusion</th>
  355. </tr>
  356. <tr>
  357. <td>date</td>
  358. <td>Timestamp specifying the last modified time of the file (which MUST conform to the DateTime profile of &xep0082;).</td>
  359. <td>OPTIONAL</td>
  360. </tr>
  361. <tr>
  362. <td>desc</td>
  363. <td>A human readable description of the file. Multiple &lt;desc/&gt; elements MAY be included if different xml:lang values are specified.</td>
  364. <td>OPTIONAL</td>
  365. </tr>
  366. <tr>
  367. <td>hash</td>
  368. <td>A hash of the file content, using the &lt;hash/&gt; element defined in &xep0300; and qualifed by the 'urn:xmpp:hashes:2' namespace. Multiple hashes MAY be included for hash agility.</td>
  369. <td>See &lt;hash-used/&gt;</td>
  370. </tr>
  371. <tr>
  372. <td>hash-used</td>
  373. <td>Alternatively to a &lt;hash/&gt; element, the initiator can also include a &lt;hash-used/&gt; element. This avoids the need to read the file twice to calculate the hash.</td>
  374. <td>Either a &lt;hash/&gt; or a &lt;hash-used/&gt; element MUST be included when offering a file.</td>
  375. </tr>
  376. <tr>
  377. <td>media-type</td>
  378. <td>The media type of the file content, which SHOULD be a valid MIME-TYPE as registered with &IANA; (specifically, as listed at &lt;<link url=''></link>&gt;). If not specified, the content is assumed to be "application/octet-stream".</td>
  379. <td>RECOMMENDED when offering a file, otherwise OPTIONAL</td>
  380. </tr>
  381. <tr>
  382. <td>name</td>
  383. <td>The name of the file. The name SHOULD NOT contain characters or character sequences that would be interpreted as a directory structure by the local file system (e.g. "/", "\", "../", etc.). If any such characters or character sequences are present (possibly because the local and remote file systems use different syntax for directory structure), they SHOULD be escaped (e.g., via percent-encoding) before using the name as part of any file system operation. See <link url='#security'>Security Considerations</link>.</td>
  384. <td>OPTIONAL</td>
  385. </tr>
  386. <tr>
  387. <td>size</td>
  388. <td>The length of the file's content, in bytes.</td>
  389. <td>OPTIONAL, but SHOULD be present when offering a file.</td>
  390. </tr>
  391. <tr>
  392. <td>range</td>
  393. <td>The presence of the &lt;range/&gt; element indicates support of ranged transfers, and can be used to control where a transfer starts.</td>
  394. <td>OPTIONAL</td>
  395. </tr>
  396. </table>
  397. <p>One or more &lt;hash/&gt; elements MUST be present when offering a file, but those elements MAY be empty if the hash has not yet been computed. If there is no computed hash value, the &lt;hash/&gt; element(s) MUST possess an 'algo' attribute specifying which hash algorithm will be used. Once a hash has been calculated by the File Sender, the File Sender SHOULD inform the File Receiver of the hash value as described in <link url='#hash'>Checksum</link>.</p>
  398. <p>Additional elements MAY be included as children of the &lt;file/&gt; element to provide additional metadata about the file, such as &xep0264;.</p>
  399. <p>The optional &lt;range/&gt; element MAY possess two attributes:</p>
  400. <table caption='Range Element Attributes'>
  401. <tr>
  402. <th>Attribute</th>
  403. <th>Description</th>
  404. <th>Inclusion</th>
  405. </tr>
  406. <tr>
  407. <td>offset</td>
  408. <td>Specifies the position, in bytes, from which to start transferring file data. This defaults to zero (0) if not specified.</td>
  409. <td>OPTIONAL</td>
  410. </tr>
  411. <tr>
  412. <td>length</td>
  413. <td>Specifies the number of bytes to retrieve starting at offset. This defaults to the length of the file from offset to the end.</td>
  414. <td>OPTIONAL</td>
  415. </tr>
  416. </table>
  417. <p>Inclusion of a &lt;range/&gt; element in a File Offer indicates support of ranged transfers for future File Requests if the transfer is interrupted and needs to be restarted.</p>
  418. <p>A &lt;range/&gt; element MAY include an 'offset' attribute set to begin the transfer at a point other than the start of the file, and MAY include a 'length' attribute to request a portion of the file smaller than the remaining length of the file. If no 'offset' or 'length' attributes are present then it is the same as if no &lt;range/&gt; element was present, because the default values of the attributes would indicate a requested range of the entire file. In general, the first byte of data to be transferred is at the (zero-indexed) position specified by the 'offset' value, with a total of 'length' bytes sent.</p>
  419. </section1>
  420. <section1 topic='Negotiating a Jingle File Transfer Session'>
  421. <p>In general, the process for negotiating a Jingle File Transfer session is as follows:</p>
  422. <code><![CDATA[
  423. Initiator Responder
  424. | |
  425. | session-initiate |
  426. |---------------------------->|
  427. | ack |
  428. |<----------------------------|
  429. | session-accept |
  430. |<----------------------------|
  431. | ack |
  432. |---------------------------->|
  433. | [optional further |
  434. | negotiation] |
  435. |<--------------------------->|
  436. | File Transfer |
  437. |============================>|
  438. | |]]></code>
  439. <section2 topic='Offering a File' anchor='offering'>
  440. <p>To start a File Offer, the initiator sends a Jingle session-initiation request to a potential responder. The request specifies three things:</p>
  441. <ol>
  442. <li>A content 'senders' attribute with the value of 'initiator' to indicate this is a File Offer.</li>
  443. <li>An application type of "urn:xmpp:jingle:apps:file-transfer:5". In particular, the &lt;description/&gt; element contains a &lt;file/&gt; elements describing the file to be sent.</li>
  444. <li>An appropriate transport method.</li>
  445. </ol>
  446. <p>In this example, the initiator is &lt;romeo@montague.example&gt;, the responder is &lt;juliet@capulet.example&gt;, the application type is a File Offer, and the transport method is jingle-s5b (XEP-0260).</p>
  447. <p>The flow is as follows.</p>
  448. <p>First the initiator sends a Jingle session-initiate.</p>
  449. <example caption="Initiator sends session-initiate"><![CDATA[
  450. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  451. id='nzu25s8'
  452. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  453. type='set'>
  454. <jingle xmlns='urn:xmpp:jingle:1'
  455. action='session-initiate'
  456. initiator='romeo@montague.example/dr4hcr0st3lup4c'
  457. sid='851ba2'>
  458. <content creator='initiator' name='a-file-offer' senders='initiator'>
  459. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  460. <file>
  461. <date>1969-07-21T02:56:15Z</date>
  462. <desc>This is a test. If this were a real file...</desc>
  463. <media-type>text/plain</media-type>
  464. <name>test.txt</name>
  465. <range/>
  466. <size>6144</size>
  467. <hash xmlns='urn:xmpp:hashes:2'
  468. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  469. </file>
  470. </description>
  471. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  472. mode='tcp'
  473. sid='vj3hs98y'>
  474. <candidate cid='hft54dqy'
  475. host=''
  476. jid='romeo@montague.example/dr4hcr0st3lup4c'
  477. port='5086'
  478. priority='8257636'
  479. type='direct'/>
  480. <candidate cid='hutr46fe'
  481. host=''
  482. jid='romeo@montague.example/dr4hcr0st3lup4c'
  483. port='5087'
  484. priority='8258636'
  485. type='direct'/>
  486. </transport>
  487. </content>
  488. </jingle>
  489. </iq>]]></example>
  490. <p>Note: Inclusion of the &lt;range/&gt; child of the &lt;file/&gt; element indicates that the initiator supports ranged transfers as described below under <link url='#range'>Ranged Transfers</link>.</p>
  491. <p>Note: Computing the hash of the file before sending it can slow down the process of file transfer, because the sending application needs to process the file twice. The File Sender might prefer to send the hash after the file transfer has begun, using a session-info message as described under <link url='#hash'>Checksum</link>.</p>
  492. <p>The responder immediately acknowledges receipt of the Jingle session-initiate.</p>
  493. <example caption="Responder acknowledges session-initiate"><![CDATA[
  494. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  495. id='nzu25s8'
  496. to='romeo@montague.example/dr4hcr0st3lup4c'
  497. type='result'/>]]></example>
  498. <p>The initiator then attempts to initiate a SOCKS5 Bytestream with the responder as described in <cite>XEP-0260</cite> and <cite>XEP-0065</cite>. In the meantime, the responder returns a Jingle session-accept. In the session-accept message, the &lt;file/&gt; element MAY contain a &lt;range/&gt; element to indicate that the receiver also supports ranged transfers as described below under <link url='#range'>Ranged Transfers</link>. If the responder includes a &lt;range /&gt; element with a limit or offset, the File Sender SHOULD respect the provided range settings.</p>
  499. <example caption="Responder sends session-accept"><![CDATA[
  500. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  501. id='jn2vs71g'
  502. to='romeo@montague.example/dr4hcr0st3lup4c'
  503. type='set'>
  504. <jingle xmlns='urn:xmpp:jingle:1'
  505. action='session-accept'
  506. responder='juliet@capulet.example/yn0cl4bnw0yr3vym'
  507. sid='851ba2'>
  508. <content creator='initiator' name='a-file-offer' senders='initiator'>
  509. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  510. <file>
  511. <date>1969-07-21T02:56:15Z</date>
  512. <desc>This is a test. If this were a real file...</desc>
  513. <media-type>text/plain</media-type>
  514. <name>test.txt</name>
  515. <range/>
  516. <size>6144</size>
  517. <hash xmlns='urn:xmpp:hashes:2'
  518. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  519. </file>
  520. </description>
  521. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  522. mode='tcp'
  523. sid='vj3hs98y'>
  524. <candidate cid='ht567dq'
  525. host=''
  526. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  527. port='6539'
  528. priority='8257636'
  529. type='direct'/>
  530. <candidate cid='hr65dqyd'
  531. host=''
  532. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  533. port='16453'
  534. priority='7929856'
  535. type='assisted'/>
  536. <candidate cid='grt654q2'
  537. host='2001:638:708:30c9:219:d1ff:fea4:a17d'
  538. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  539. port='6539'
  540. priority='8257606'
  541. type='direct'/>
  542. </transport>
  543. </content>
  544. </jingle>
  545. </iq>]]></example>
  546. <p>The initiator acknowledges the Jingle session-accept.</p>
  547. <example caption="Initiator acknowledges session-accept"><![CDATA[
  548. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  549. id='jn2vs71g'
  550. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  551. type='result'/>]]></example>
  552. </section2>
  553. <section2 topic='Requesting a File' anchor='requesting'>
  554. <p>If the File Sender has advertised the existence of a file that it hosts, such as by &xep0358;, or if a previous file transfer attempt has failed and the File Receiver would like to initiate another attempt, the File Receiver can "pull" the file from the File Sender. This is done by sending a Jingle session-initiate to the File Sender which includes a &lt;content/&gt; with the 'senders' attribute set to the opposite Jingle session role of the party requesting the file (see <link url='#content-senders'>Use of Jingle Content Senders</link>) and a &lt;description/&gt; element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace and which includes a &lt;file/&gt; element with enough information included to form a "file selector" (see Section 5 of &rfc5547;) to identify the requested file.</p>
  555. <example caption="File Receiver requests hosted file"><![CDATA[
  556. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  557. id='wsn361c3'
  558. to='romeo@montague.example/dr4hcr0st3lup4c'
  559. type='set'>
  560. <jingle xmlns='urn:xmpp:jingle:1'
  561. action='session-initiate'
  562. initiator='juliet@capulet.example/yn0cl4bnw0yr3vym'
  563. sid='uj3b2'>
  564. <content creator='initiator' name='a-file-request' senders='responder'>
  565. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  566. <file>
  567. <hash xmlns='urn:xmpp:hashes:2'
  568. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  569. </file>
  570. </description>
  571. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  572. mode='tcp'
  573. sid='xig361fj'>
  574. <candidate cid='ht567dq'
  575. host=''
  576. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  577. port='6539'
  578. priority='8257636'
  579. type='direct'/>
  580. <candidate cid='hr65dqyd'
  581. host=''
  582. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  583. port='16453'
  584. priority='7929856'
  585. type='assisted'/>
  586. <candidate cid='grt654q2'
  587. host='2001:638:708:30c9:219:d1ff:fea4:a17d'
  588. jid='juliet@capulet.example/yn0cl4bnw0yr3vym'
  589. port='6539'
  590. priority='8257606'
  591. type='direct'/>
  592. </transport>
  593. </content>
  594. </jingle>
  595. </iq>]]></example>
  596. <p>See <link url='#file-not-available'>File not Available</link> for how to respond if the requester does not have permission to request the file, or if the file cannot be found.</p>
  597. </section2>
  598. <section2 topic='Offering or Requesting Additional Files'>
  599. <p>While the Jingle File Transfer session is active, either party MAY choose to add additional files (both offers and requests) to the transfer session. To do so, a Jingle content-add action is used, as shown in the following examples.</p>
  600. <example caption="File Sender offers additional file"><![CDATA[
  601. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  602. id='wsn361c9'
  603. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  604. type='set'>
  605. <jingle xmlns='urn:xmpp:jingle:1'
  606. action='content-add'
  607. sid='uj3b2'>
  608. <content creator='initiator' name='additional' senders='initiator'>
  609. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  610. <file>
  611. <name>second-file.txt</name>
  612. <media-type>text/plain</media-type>
  613. <size>6144</size>
  614. <hash xmlns='urn:xmpp:hashes:2'
  615. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  616. </file>
  617. </description>
  618. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  619. mode='tcp'
  620. sid='vj3hs98y'>
  621. <candidate cid='hft54dqy'
  622. host=''
  623. jid='romeo@montague.example/dr4hcr0st3lup4c'
  624. port='5086'
  625. priority='8257636'
  626. type='direct'/>
  627. <candidate cid='hutr46fe'
  628. host=''
  629. jid='romeo@montague.example/dr4hcr0st3lup4c'
  630. port='5087'
  631. priority='8258636'
  632. type='direct'/>
  633. </transport>
  634. </content>
  635. </jingle>
  636. </iq>]]></example>
  637. <p>The other party then acks the content-add request.</p>
  638. <example caption="File Receiver acks content-add request"><![CDATA[
  639. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  640. to='romeo@montague.example/dr4hcr0st3lup4c'
  641. id='wsn361c9'
  642. type='result' />]]></example>
  643. <p>At this point, the content-add request needs to be either accepted or rejected using Jingle content-accept or content-reject actions.</p>
  644. </section2>
  645. <section2 topic='Ranged Transfers' anchor='range'>
  646. <p>As in <cite>XEP-0096</cite>, a transfer can include only part of a file (e.g., to restart delivery of a truncated transfer session at a point other than the start of the file). This is done using the &lt;range/&gt; element. The usage is illustrated in the following examples.</p>
  647. <p>Let us imagine that the parties negotiate a file transfer session using, say, In-Band Bytestreams. During the transfer, the recipient goes offline unexpectedly and IBB stanzas from the File Sender to the File Receiver begin to bounce. When the recipient comes back online, the File Sender could initiate a new Jingle session and specify that it wants to send all chunks after byte 270336 (which might be the 66th chunk of size 4096).</p>
  648. <example caption="File Sender requests session to send file, with range"><![CDATA[
  649. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  650. id='wsn361c3'
  651. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  652. type='set'>
  653. <jingle xmlns='urn:xmpp:jingle:1'
  654. action='session-initiate'
  655. initiator='romeo@montague.example/dr4hcr0st3lup4c'
  656. sid='uj3b2'>
  657. <content creator='initiator' name='restart' senders='initiator'>
  658. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  659. <file>
  660. <range offset='270336'/>
  661. <hash xmlns='urn:xmpp:hashes:2'
  662. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  663. </file>
  664. </description>
  665. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  666. mode='tcp'
  667. sid='vj3hs98y'>
  668. <candidate cid='hft54dqy'
  669. host=''
  670. jid='romeo@montague.example/dr4hcr0st3lup4c'
  671. port='5086'
  672. priority='8257636'
  673. type='direct'/>
  674. <candidate cid='hutr46fe'
  675. host=''
  676. jid='romeo@montague.example/dr4hcr0st3lup4c'
  677. port='5087'
  678. priority='8258636'
  679. type='direct'/>
  680. </transport>
  681. </content>
  682. </jingle>
  683. </iq>]]></example>
  684. </section2>
  685. <section2 topic='Aborting a Transfer'>
  686. <p>At any point, either party MAY choose to abort the transfer of a single file, or end the session entirely to abort all active transfers.</p>
  687. <p>When there is only a single Jingle content or if a party wishes to abort the transfer of all files in the session, a session-terminate including a Jingle reason of &lt;cancel /&gt; is sent.</p>
  688. <example caption='File Receiver aborts all active file transfers'><![CDATA[
  689. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  690. id='jp2ba614'
  691. to='romeo@montague.example/dr4hcr0st3lup4c'
  692. type='set'>
  693. <jingle xmlns='urn:xmpp:jingle:1'
  694. action='session-terminate'
  695. sid='a73sjjvkla37jfea'>
  696. <reason>
  697. <cancel />
  698. </reason>
  699. </jingle>
  700. </iq>]]></example>
  701. <p>If a party chooses to abort the transfer of a single file out of several active transfers, a Jingle content-remove action is used, which MAY include a Jingle reason of &lt;cancel/&gt;, as shown in the following example.</p>
  702. <example caption='File Receiver aborts the transfer'><![CDATA[
  703. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  704. id='jp2ba614'
  705. to='romeo@montague.example/dr4hcr0st3lup4c'
  706. type='set'>
  707. <jingle xmlns='urn:xmpp:jingle:1'
  708. action='content-remove'
  709. sid='a73sjjvkla37jfea'>
  710. <content creator='initiator' name='a-file-offer' />
  711. <reason>
  712. <cancel />
  713. </reason>
  714. </jingle>
  715. </iq>]]></example>
  716. <p>The other party then acks the content-remove request.</p>
  717. <example caption='File Sender acks abort request'><![CDATA[
  718. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  719. id='jp2ba614'
  720. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  721. type='result' />]]></example>
  722. <p>If after removing the content there are no other Jingle contents the session MUST be terminated as described in the next section.</p>
  723. </section2>
  724. <section2 topic='Ending the Session'>
  725. <p>Once all file content in the session has been transfered, either party MAY acknowledge receipt of the received files (see <link url='#received'>Received</link>) or, if there are no other active file transfers, terminate the Jingle session with a Jingle session of &lt;success/&gt;. Preferably, sending the session-terminate is done by the last entity to finish receiving a file to ensure that all offered or requested files by either party have been completely received (up to the advertised sizes).</p>
  726. <example caption='File Receiver ends the session after successfully receiving all files'><![CDATA[
  727. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  728. id='jp2ba614'
  729. to='romeo@montague.example/dr4hcr0st3lup4c'
  730. type='set'>
  731. <jingle xmlns='urn:xmpp:jingle:1'
  732. action='session-terminate'
  733. sid='a73sjjvkla37jfea'>
  734. <reason>
  735. <success />
  736. </reason>
  737. </jingle>
  738. </iq>]]></example>
  739. </section2>
  740. </section1>
  741. <section1 topic='Mapping to Session Description Protocol' anchor='sdp'>
  742. <p>&rfc5547; defines the general process for including file transfer information in SDP.</p>
  743. <p>The SDP media type for Jingle File Transfer can be "message" (e.g. when used with &rfc4975;) or "application"; however, this media value is not reflected in the Jingle File Transfer application format.</p>
  744. <p>Any combination of &lt;name/&gt;, &lt;size/&gt;, &lt;media-type/&gt;and &lt;hash/&gt; values MAY be used to form a "file selector" (see Section 5 of &rfc5547;), which would be mapped to SDP as follows:</p>
  745. <code><![CDATA[
  746. a=file-selector [name:"<name>"] [size:<size>] [type:<media-type>] [hash:<hash algo>:<hash value>]]]></code>
  747. <p>(The hash value MUST be encoded as hexadecimal with each byte separated by a colon.)</p>
  748. <p>The &lt;date/&gt; value is the last modified time of the file, and thus is mapped as follows:</p>
  749. <code><![CDATA[
  750. a=file-date:modification:"<date>"]]></code>
  751. <p>Note: the format used here for &lt;date&gt; is the date-time format defined in &rfc5322;.</p>
  752. <p>If a range is specified, the SDP mapping requires both a start and stop offset. If no length was specified for the range, the stop offset is "*". If a length was specified, the stop offset is the &lt;range/&gt; offset value plus the length.</p>
  753. <code><![CDATA[
  754. a=file-range:<offset>-<(offset + length) | *>]]></code>
  755. <p>As a full example, given the following Jingle File Transfer content description:</p>
  756. <code><![CDATA[
  757. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  758. <file>
  759. <media-type>text/plain</media-type>
  760. <name>test.txt</name>
  761. <date>2015-07-26T21:46:00+01:00</date>
  762. <size>6144</size>
  763. <hash xmlns='urn:xmpp:hashes:2'
  764. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  765. <range offset='1024' />
  766. </file>
  767. </description>]]></code>
  768. <p>The equivalent SDP would be:</p>
  769. <code><![CDATA[
  770. a=file-selector: name:"test.txt" size:6144 type:text/plain hash:sha-1:55:2D:A7:49:93:08:52:C6:9A:E5:D2:14:1D:37:66:B1
  771. a=file-date:modification:"26 Jul 2015 21:46:00"
  772. a=file-range:1024-*]]></code>
  773. </section1>
  774. <section1 topic='Informational Messages'>
  775. <section2 topic='Received' anchor='received'>
  776. <p>Once a file has been successfully received, the recipient MAY send a Jingle session-info message indicating receipt of the complete file, which consists of a &lt;received/&gt; element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace. The &lt;received/&gt; element SHOULD contain 'creator' and 'name' attributes sufficient to identify the content that was received.</p>
  777. <example caption='File Receiver sends ack in session-info'><![CDATA[
  778. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  779. id='jp2ba614'
  780. to='romeo@montague.example/dr4hcr0st3lup4c'
  781. type='set'>
  782. <jingle xmlns='urn:xmpp:jingle:1'
  783. action='session-info'
  784. sid='a73sjjvkla37jfea'>
  785. <received xmlns='urn:xmpp:jingle:apps:file-transfer:5'
  786. creator='initiator'
  787. name='a-file-offer' />
  788. </jingle>
  789. </iq>]]></example>
  790. </section2>
  791. <section2 topic='Checksum' anchor='hash'>
  792. <p>At any time during the lifetime of the file transfer session, the File Sender can communicate the checksum of the file to the File Receiver.</p>
  793. <p>This can be done in the session-initiate message if the File Sender already knows the checksum, as shown above in Example 3.</p>
  794. <p>After the session-initiate message, this can also be done by sending a session-info message containing a &lt;checksum/&gt; element qualified by the 'urn:xmpp:jingle:apps:file-transfer:5' namespace. In such a case however, the session-initiate message MUST contain a &lt;hash-used/&gt; element. The &lt;checksum/&gt; element SHOULD contain 'creator' and 'name' attributes sufficient to identitfy the content the checksum belongs to. Additionally, the &lt;checksum/&gt; element MUST contain a &lt;file/&gt; element which MUST contain at least one &lt;hash/&gt; or &lt;hash-used/&gt; element qualified by the 'urn:xmpp:hashes:2' namespace. Each &lt;hash/&gt; element contains a checksum of the file data produced in accordance with the hashing function specified by the 'algo' attribute, which MUST be one of the functions listed in the &ianahashes;.</p>
  795. <example caption="Initiator sends checksum in session-info"><![CDATA[
  796. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  797. id='kqh401b5'
  798. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  799. type='set'>
  800. <jingle xmlns='urn:xmpp:jingle:1'
  801. action='session-info'
  802. sid='a73sjjvkla37jfea'>
  803. <checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5'
  804. creator='initiator'
  805. name='a-file-offer'>
  806. <file>
  807. <hash xmlns='urn:xmpp:hashes:2'
  808. algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
  809. </file>
  810. </checksum>
  811. </jingle>
  812. </iq>]]></example>
  813. <p>If a ranged transfer was requested, the &lt;file/&gt; element inside the &lt;checksum/&gt; element MAY include a &lt;range/&gt; element specifying the offset and length of the requested range, which in turn includes &lt;hash/&gt; element(s) with hashes of the data that was transferred for that range.</p>
  814. <example caption="Initiator sends checksum in session-info for a specific range"><![CDATA[
  815. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  816. id='kqh401b5'
  817. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  818. type='set'>
  819. <jingle xmlns='urn:xmpp:jingle:1'
  820. action='session-info'
  821. sid='a73sjjvkla37jfea'>
  822. <checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5'
  823. creator='initiator'
  824. name='a-file-offer'>
  825. <file>
  826. <range offset='2048' length='1024'>
  827. <hash xmlns='urn:xmpp:hashes:2'
  828. algo='sha-1'>kHp5RSzW/h7Gm1etSf90Mr5PC/k=</hash>
  829. </range>
  830. </file>
  831. </checksum>
  832. </jingle>
  833. </iq>]]></example>
  834. <p>If the initiator wishes to communicate only the hashing algorithm at the beginning of the session (e.g., because it has not yet calculated the checksum), it can send an empty &lt;hash/&gt; element (without a checksum in the XML character data as shown in the previous examples) in the session-initiate message; this enables the recipient to check the file during the transfer session (which can be helpful in the case of transfers that are truncated or fail mid-stream).</p>
  835. <example caption="Initiator communicates hashing algorithm in session-initiate"><![CDATA[
  836. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  837. id='nzu25s8'
  838. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  839. type='set'>
  840. <jingle xmlns='urn:xmpp:jingle:1'
  841. action='session-initiate'
  842. initiator='romeo@montague.example/dr4hcr0st3lup4c'
  843. sid='851ba2'>
  844. <content creator='initiator' name='a-file-offer' senders='initiator'>
  845. <description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>
  846. <file>
  847. <date>1969-07-21T02:56:15Z</date>
  848. <desc>This is a test. If this were a real file...</desc>
  849. <media-type>text/plain</media-type>
  850. <name>test.txt</name>
  851. <range/>
  852. <size>6144</size>
  853. <hash xmlns='urn:xmpp:hashes:2' algo='sha-1'/>
  854. </file>
  855. </description>
  856. <transport xmlns='urn:xmpp:jingle:transports:s5b:1'
  857. mode='tcp'
  858. sid='vj3hs98y'>
  859. <candidate cid='hft54dqy'
  860. host=''
  861. jid='romeo@montague.example/dr4hcr0st3lup4c'
  862. port='5086'
  863. priority='8257636'
  864. type='direct'/>
  865. <candidate cid='hutr46fe'
  866. host=''
  867. jid='romeo@montague.example/dr4hcr0st3lup4c'
  868. port='5087'
  869. priority='8258636'
  870. type='direct'/>
  871. </transport>
  872. </content>
  873. </jingle>
  874. </iq>]]></example>
  875. </section2>
  876. </section1>
  877. <section1 topic='Errors' anchor='errors'>
  878. <section2 topic='File not Available' anchor='file-not-available'>
  879. <p>If a requested file cannot be found (or the requester does not have permission to request or know about the existence of the file in question), then the File Sender SHOULD send either a session-terminate or content-reject action in response to the session-initiate or content-add request, and SHOULD include a Jingle reason of &lt;failed-application/&gt; and MAY include an application specific reason of a &lt;file-not-available/&gt; element qualified by the 'urn:xmpp:jingle:apps:file-transfer:errors:0' namespace.</p>
  880. <example caption="File Sender rejects file request because the file could not be found"><![CDATA[
  881. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  882. id='wsn361c9'
  883. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  884. type='set'>
  885. <jingle xmlns='urn:xmpp:jingle:1'
  886. action='content-reject'
  887. sid='uj3b2'>
  888. <content creator='initiator' name='requesting-file' senders='initiator'/>
  889. <reason>
  890. <failed-application />
  891. <file-not-available xmlns='urn:xmpp:jingle:apps:file-transfer:errors:0' />
  892. </reason>
  893. </jingle>
  894. </iq>]]></example>
  895. </section2>
  896. <section2 topic='File too Large' anchor='file-too-large'>
  897. <p>There are several situations where a File Receiver might wish to abort a transfer due to an excess of file data, for example:</p>
  898. <ul>
  899. <li>The File Receiver has reached a file system storage quota or other hard limit that prevents continuing to receive file data.</li>
  900. <li>The File Sender has continued sending data past the initially specified size of the file.</li>
  901. </ul>
  902. <p>In such cases, the File Receiver MAY abort the transfer by sending a Jingle session-terminate (or content-remove as appropriate) which includes a Jingle reason of &lt;media-error/&gt; and MAY include an application specific reason of a &lt;file-too-large/&gt; element qualified by the 'urn:xmpp:jingle:apps:file-transfer:errors:0' namespace.</p>
  903. <example caption="File Receiver rejects file offer because the file is too large"><![CDATA[
  904. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  905. id='wsn361c9'
  906. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  907. type='set'>
  908. <jingle xmlns='urn:xmpp:jingle:1'
  909. action='content-remove'
  910. sid='uj3b2'>
  911. <content creator='initiator' name='big-file' senders='initiator'/>
  912. <reason>
  913. <media-error />
  914. <file-too-large xmlns='urn:xmpp:jingle:apps:file-transfer:errors:0' />
  915. </reason>
  916. </jingle>
  917. </iq>]]></example>
  918. <p>To prevent denial of service and other attacks, the File Receiver is fully within its rights to drop received data or not send a session-terminate message.</p>
  919. </section2>
  920. </section1>
  921. <section1 topic='Implementation Notes' anchor='impl'>
  922. <section2 topic='Mandatory to Implement Technologies' anchor='impl-mti'>
  923. <p>All implementations MUST support the Jingle In-Band Bytestreams Transport Method (<cite>XEP-0261</cite>) as a reliable method of last resort. An implementation SHOULD support other transport methods as well, especially ICE-TCP (RFC 6544) and the Jingle SOCKS5 Bytestreams Transport Method (<cite>XEP-0260</cite>).</p>
  924. </section2>
  925. <section2 topic='Preference Order of Transport Methods' anchor='impl-pref'>
  926. <p>An application MAY present transport methods in any order, except that the Jingle In-Band Bytestreams Transport Method MUST be the lowest preference.</p>
  927. </section2>
  928. <section2 topic='Migration from XEP-0096' anchor='impl-migration'>
  929. <p>Support for Jingle file transfer can be determined through discovery of the 'urn:xmpp:jingle:apps:file-transfer:5' namespace &VNOTE;, via either service discovery (<cite>XEP-0030</cite>) or entity capabilities (<cite>XEP-0115</cite>). If the initiator knows that the responder supports Jingle file transfer, it SHOULD first attempt negotiation using Jingle rather than Stream Initiation.</p>
  930. </section2>
  931. </section1>
  932. <section1 topic='Determining Support' anchor='support'>
  933. <p>To advertise its support for the Jingle File Transfer, when replying to service discovery information ("disco#info") requests an entity MUST return URNs for any version of this protocol that the entity supports -- e.g., "urn:xmpp:jingle:apps:file-transfer:5" for this version &VNOTE;.</p>
  934. <example caption="Service discovery information request"><![CDATA[
  935. <iq from='romeo@montague.example/dr4hcr0st3lup4c'
  936. id='uw72g176'
  937. to='juliet@capulet.example/yn0cl4bnw0yr3vym'
  938. type='get'>
  939. <query xmlns=''/>
  940. </iq>]]></example>
  941. <example caption="Service discovery information response"><![CDATA[
  942. <iq from='juliet@capulet.example/yn0cl4bnw0yr3vym'
  943. id='uw72g176'
  944. to='romeo@montague.example/dr4hcr0st3lup4c'
  945. type='result'>
  946. <query xmlns=''>
  947. <feature var='urn:xmpp:jingle:1'/>
  948. <feature var='urn:xmpp:jingle:apps:file-transfer:5'/>
  949. <feature var='urn:xmpp:jingle:transports:s5b:1'/>
  950. <feature var='urn:xmpp:jingle:transports:ibb:1'/>
  951. </query>
  952. </iq>]]></example>
  953. <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
  954. </section1>
  955. <section1 topic='Security Considerations' anchor='security'>
  956. <p>Caution needs to be exercised when using the &lt;name/&gt; of a file offer or request to control any interaction with a file system. For example, a malicious user could request a file with &lt;name&gt;/etc/passwd&lt;/name&gt; or include file system specific control patterns such as &lt;name&gt;../../private.txt&lt;/name&gt; to try and access a sensitive file outside of the set of files intended to be shared. Or a malicious user could offer a file named "/etc/passwd" to try and trick the receiver into overwriting that or other sensitive files. Therefore, implementations SHOULD escape any file system path separators in the &lt;name/&gt; before using that value in any file system calls.</p>
  957. <p>It is RECOMMENDED for implementations to use the strongest hashing algorithm available to both parties. See <cite>XEP-0300</cite> for further discussion.</p>
  958. <p>In order to secure the data stream, implementations SHOULD use encryption methods appropriate to the transport method being used. For example, end-to-end encryption can be negotiated over either SOCKS5 Bytestreams or In-Band Bytestreams as described in <cite>XEP-0260</cite> and <cite>XEP-0261</cite>.</p>
  959. <p>Refer to <cite>XEP-0047</cite>, <cite>XEP-0065</cite>, <cite>XEP-0096</cite>, <cite>XEP-0176</cite>, <cite>XEP-0260</cite>, <cite>XEP-0261</cite>, and <cite>RFC 6544</cite> for related security considerations.</p>
  960. </section1>
  961. <section1 topic='IANA Considerations' anchor='iana'>
  962. <p>No interaction with &IANA; is required as a result of this document.</p>
  963. <p>The XML character data of the &lt;media-type/&gt; element SHOULD be a value registered with the IANA in the &ianamedia;.</p>
  964. </section1>
  965. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  966. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  967. <p>This specification defines the following XML namespace:</p>
  968. <ul>
  969. <li>urn:xmpp:jingle:apps:file-transfer:5</li>
  970. </ul>
  971. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  972. </section2>
  973. <section2 topic='Namespace Versioning' anchor='registrar-versioning'>
  974. &NSVER;
  975. </section2>
  976. <section2 topic='Jingle Application Formats' anchor='registrar-content'>
  977. <p>The XMPP Registrar shall include "file-transfer" in its registry of Jingle application formats. The registry submission is as follows:</p>
  978. <code><![CDATA[
  979. <application>
  980. <name>file-transfer</name>
  981. <desc>Jingle sessions for the transfer of a file</desc>
  982. <transport>streaming</transport>
  983. <doc>XEP-0234</doc>
  984. </application>]]></code>
  985. </section2>
  986. </section1>
  987. <section1 topic='XML Schema' anchor='schema'>
  988. <section2 topic='urn:xmpp:jingle:apps:file-transfer:5' anchor='schemas-file-transfer'>
  989. <code><![CDATA[
  990. <?xml version='1.0' encoding='UTF-8'?>
  991. <xs:schema
  992. xmlns:xs=''
  993. targetNamespace='urn:xmpp:jingle:apps:file-transfer:5'
  994. xmlns='urn:xmpp:jingle:apps:file-transfer:5'
  995. elementFormDefault='qualified'>
  996. <xs:import namespace='urn:xmpp:hashes:2'/>
  997. <xs:element name='description'>
  998. <xs:complexType>
  999. <xs:all>
  1000. <xs:element name='file' type='fileTransferElementType'/>
  1001. </xs:all>
  1002. </xs:complexType>
  1003. </xs:element>
  1004. <xs:element name='checksum'>
  1005. <xs:complexType>
  1006. <xs:all>
  1007. <xs:element name='file' type='fileTransferElementType'/>
  1008. </xs:all>
  1009. <xs:attribute name='creator' use='required'>
  1010. <xs:simpleType>
  1011. <xs:restriction base='xs:NCName'>
  1012. <xs:enumeration value='initiator'/>
  1013. <xs:enumeration value='responder'/>
  1014. </xs:restriction>
  1015. </xs:simpleType>
  1016. </xs:attribute>
  1017. <xs:attribute name='name' type='xs:string' use='required'/>
  1018. </xs:complexType>
  1019. </xs:element>
  1020. <xs:element name='received'>
  1021. <xs:complexType>
  1022. <xs:attribute name='creator' use='required'>
  1023. <xs:simpleType>
  1024. <xs:restriction base='xs:NCName'>
  1025. <xs:enumeration value='initiator'/>
  1026. <xs:enumeration value='responder'/>
  1027. </xs:restriction>
  1028. </xs:simpleType>
  1029. </xs:attribute>
  1030. <xs:attribute name='name' type='xs:string' use='required'/>
  1031. </xs:complexType>
  1032. </xs:element>
  1033. <xs:complexType name='fileTransferElementType'>
  1034. <xs:all xmlns:h='urn:xmpp:hashes:2' minOccurs='0'>
  1035. <xs:element name='date' type='xs:date'/>
  1036. <xs:element name='media-type' type='xs:string'/>
  1037. <xs:element name='name' type='xs:string'/>
  1038. <xs:element name='desc' type='xs:string'/>
  1039. <xs:element name='size' type='xs:positiveInteger'/>
  1040. <xs:element name='range' type='fileTransferRangeType'/>
  1041. <xs:element ref='h:hash' minOccurs='0' maxOccurs='unbounded'/>
  1042. </xs:sequence>
  1043. </xs:complexType>
  1044. <xs:complexType name='fileTransferRangeType'>
  1045. <xs:attribute name='offset' type='xs:nonNegativeInteger' use='optional' default='0' />
  1046. <xs:attribute name='length' type='xs:nonNegativeInteger' use='optional' />
  1047. <xs:all xmlns:h='urn:xmpp:hashes:2' minOccurs='0'>
  1048. <xs:element ref='h:hash' minOccurs='0' maxOccurs='unbounded' />
  1049. </xs:all>
  1050. </xs:complexType>
  1051. </xs:schema>]]></code>
  1052. </section2>
  1053. <section2 topic='urn:xmpp:jingle:apps:file-transfer:errors:0' anchor='schema-file-transfer-errors'>
  1054. <code><![CDATA[
  1055. <?xml version='1.0' encoding='UTF-8'?>
  1056. <xs:schema
  1057. xmlns:xs=''
  1058. targetNamespace='urn:xmpp:jingle:apps:file-transfer:5'
  1059. xmlns='urn:xmpp:jingle:apps:file-transfer:errors:0'
  1060. elementFormDefault='qualified'>
  1061. <xs:element name='file-not-available' type='empty' />
  1062. <xs:element name='file-too-large' type='empty' />
  1063. </xs:schema>]]></code>
  1064. </section2>
  1065. </section1>
  1066. <section1 topic='Acknowledgements' anchor='ack'>
  1067. <p>Thanks to Diana Cionoiu, Olivier Crête, Viktor Fast, Philipp Hancke, Waqas Hussain, Justin Karneges, Steffen Larsen, Yann Leboulanger, Marcus Lundblad, Robert McQueen, Joe Maissel, Glenn Maynard, Ali Sabil, Sjoerd Simons, Will Thompson, Matthew Wild, Paul Schaub and Jiří Zárevúcky for their feedback.</p>
  1068. </section1>
  1069. </xep>