A Session Description Protocol (SDP) Offer/Answer Mechanism to Enable File Transfer
Extracted elements (35)
Each file uses its own 'm=' line (and thus its own MSRP session) so the answerer can individually accept or reject each file by setting that line's port to zero; multiple MSRP sessions may still share a single TCP connection to avoid excessive resource use.
The 'file-range' attribute is intentionally distinct from the MSRP Byte-Range header: 'file-range' describes which portion of the file the application reads and passes to MSRP, while MSRP Byte-Range describes the portion of the resulting MSRP message carried in a single chunk. MSRP always counts from octet 1 of its message.
The 'file-transfer-id' attribute was introduced because SDP may be retransmitted unchanged for reasons unrelated to file transfer (e.g., SIP Session Timer re-INVITEs, addition of other media streams), and without it endpoints cannot determine whether a new file transfer is being requested or SDP is merely being repeated.
The hash value in the 'file-selector' attribute covers the whole file even when only a range is transferred, so that the hash can serve both as a file identifier for pull operations and as a post-transfer integrity check regardless of chunking.
A regular MSRP endpoint that does not implement the file transfer extensions can still act as SDP answerer and file receiver for a push: it answers the offer ignoring extension attributes. However, the user experience is degraded because the recipient has no protocol means to identify the transfer or accept/reject based on file metadata.
If a file receiver does not support multipart MIME bodies and rejects an SDP offer containing a 'file-icon' body part, it is RECOMMENDED that the file sender retry by removing the icon and sending a plain SDP body to improve backwards compatibility.
An offerer wishing to send or receive files MUST build an SDP description containing one 'm=' line per file, and all media line attributes required by MSRP (e.g., 'a=path', 'a=accept-types') MUST be included.
File senders MUST NOT exceed the 'max-size' limit for any message sent in the resulting MSRP session; file receivers MAY add a 'max-size' attribute specifying the maximum MSRP message size they will accept.
If an endpoint creates an SDP offer where the 'file-transfer-id' is unchanged but the file selector changes to select a new file, this is an error and the SDP answerer MUST abort the file transfer operation (e.g., by setting the port to zero).
If the SDP answer contains a supported hashing algorithm in the 'hash' selector, the file receiver SHOULD compute the hash of the received file and verify it against the SDP answer; a mismatch means the transfer SHOULD be considered failed and the user informed.
Implementations MUST add a 160-bit string resulting from SHA-1 computation if the 'hash' selector is present, and MUST be prepared to receive SDP containing more than a single 'hash' selector in the 'file-selector' attribute.
Implementations MUST implement the 'file-selector' attribute, and SDP offers and answers for file transfer MUST contain a 'file-selector' media attribute that selects the file to be transferred.
Implementations MUST include a 'file-transfer-id' attribute in SDP offers and answers. The offerer MUST select a new globally unique random identifier; the answerer MUST copy the value into the SDP answer.
In a pull operation, if the 'file-transfer-id' value has been previously used within the session, the file sender MUST NOT alert the user and MUST NOT start a new transfer of the file.
In a pull operation, the file receiver MUST include a 'file-selector' with at least one selector, a 'file-transfer-id' with a new globally unique value, and a 'recvonly' attribute in the SDP offer.
In a push operation, the file sender MUST add a 'file-selector' with at least one of 'type', 'size', or 'hash' selectors, a 'file-transfer-id' with a new globally unique value, and a 'sendonly' attribute to the SDP offer.
Senders MUST only use the dedicated MSRP session to send the file described in the SDP offer or answer and MUST NOT send additional files over the same MSRP session. Implementations MUST include a single file in a single MSRP message.
The file transfer identifier MUST be unique within the current session and is RECOMMENDED to be unique across different sessions; a relatively large random identifier (e.g., 32 characters) is RECOMMENDED to avoid duplications.
When indicating capability (Section 8.5), an endpoint SHOULD add an empty 'file-selector' media attribute to the 'm=message' line; the attribute MUST NOT contain any selector and no other file attributes MUST be added.
When the answerer accepts a push, it MUST copy 'name', 'type', and 'size' selectors from the offer into the answer, copy the 'file-transfer-id', add 'recvonly', and MUST NOT include 'file-icon', 'file-disposition', or 'file-date' attributes in the SDP answer.
When using the 'file-icon' attribute, the file sender MUST wrap the SDP body and icon bodies in a MIME multipart/related body, and implementations MUST implement the multipart/related MIME type. The SDP body MUST be the root body.
The 'file-date' attribute conveys creation, modification, and last-read timestamps of the file using RFC 5322 'date-time' format with numeric timezones; at most one of each date type ('creation', 'modification', 'read') is permitted.
The 'file-disposition' attribute suggests the intended rendering: 'render' (default, display automatically) or 'attachment' (do not display automatically, require user action). Absence of the attribute implies 'render'.
The 'file-icon' attribute contains a Content-ID URL (RFC 2392) pointing to a separate MIME body part carrying a small preview icon of the file, sent alongside the SDP in a multipart/related wrapper.
The 'file-range' attribute specifies start and stop byte offsets (1-based, inclusive) for partial file transfer, enabling interrupted transfers to be resumed. A '*' stop offset indicates unknown total size. Absence implies the whole file (1-*).
The 'file-selector' media attribute is a tuple of up to four selectors — 'name' (UTF-8 filename in double quotes), 'size' (octets), 'type' (MIME media type), and 'hash' (algorithm:value) — used to identify the file to be transferred.
The 'file-transfer-id' attribute contains a globally unique random token that distinguishes a new file transfer request from a repetition of the SDP, enabling endpoints to determine when an actual new transfer should begin.
Section 11.1 registers six new SDP media-level attributes in the IANA SDP Parameters registry: 'file-selector', 'file-transfer-id', 'file-disposition', 'file-date', 'file-icon', and 'file-range', all defined in RFC 5547.
The 'hash' selector (SHA-1) is suitable for file identification and post-transfer integrity verification, but should not be relied upon to protect file integrity against active attackers; endpoints requiring integrity protection should use a separate mechanism such as S/MIME.
The 'name' selector may contain characters meaningful to the remote operating system (e.g., '\', '/', ':') even if not significant locally. Implementations are responsible for sanitizing filenames received from remote endpoints before performing local file system operations, including percent-encoding OS-meaningful characters.
Aborting a file transfer: the aborting party includes '#' in the MSRP SEND end-line continuation field to abort the MSRP message, then sends a new SDP offer setting the 'm=' port to zero while preserving the same 'file-transfer-id'. The receiving party mirrors the abort in its SDP answer.
On receiving an SDP offer for a push, the answerer checks: (1) if port is zero, close and do nothing; (2) if port non-zero and 'file-transfer-id' already seen, keep existing session; (3) if port non-zero and 'file-transfer-id' is new, prompt user and initiate new file transfer.
Filenames in the 'name' selector are UTF-8 encoded and enclosed in double quotes; characters not allowed by the grammar (double quotes, NUL, CR, LF, percent) and directory-separator characters MUST be percent-encoded using %HEXDIG HEXDIG encoding.
The 'file-range' attribute is encoded as '<start-offset>-<stop-offset>' where both values are integers (RFC 4566 'integer') and the stop offset may be the literal '*'. The start offset of the first octet is 1.
The 'hash' selector is encoded as 'hash:<algorithm>:<value>' where the value is the SHA-1 hash expressed as two-hex-digit bytes separated by colons (e.g., '72:24:5F:...'). Only 'sha-1' is currently supported; the algorithm token references the IANA Hash Function Textual Names registry.