1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-13 21:05:09 -05:00
xeps/xep-0079.xml
2013-07-11 09:42:10 -06:00

1304 lines
67 KiB
XML

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Advanced Message Processing</title>
<abstract>This specification defines an XMPP protocol extension that enables entities to request, and servers to perform, advanced processing of XMPP message stanzas, including reliable data transport, time-sensitive delivery, and expiration of transient messages.</abstract>
&LEGALNOTICE;
<number>0079</number>
<status>Draft</status>
<type>Standards Track</type>
<sig>Standards</sig>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-0030</spec>
<spec>XEP-0082</spec>
</dependencies>
<supersedes>
<spec>XEP-0023</spec>
</supersedes>
<supersededby>None</supersededby>
<shortname>amp</shortname>
<schemaloc>
<ns>amp</ns>
<url>http://www.xmpp.org/schemas/amp.xsd</url>
</schemaloc>
<schemaloc>
<ns>amp#errors</ns>
<url>http://www.xmpp.org/schemas/amp-errors.xsd</url>
</schemaloc>
<schemaloc>
<ns>feature</ns>
<url>http://www.xmpp.org/schemas/amp-feature.xsd</url>
</schemaloc>
<registry/>
&linuxwolf;
&stpeter;
<revision>
<version>1.2</version>
<date>2005-11-30</date>
<initials>psa</initials>
<remark>Consolidated and generalized security considerations.</remark>
</revision>
<revision>
<version>1.1</version>
<date>2005-10-19</date>
<initials>psa</initials>
<remark>Reversed the meaning of conditions other than expire-at (per list discussion); correctly specified stream feature.</remark>
</revision>
<revision>
<version>1.0</version>
<date>2004-10-11</date>
<initials>psa</initials>
<remark>Per a vote of the Jabber Council, advanced to a status of Draft.</remark>
</revision>
<revision>
<version>0.12</version>
<date>2004-09-09</date>
<initials>lw</initials>
<remark>Relaxed server-to-server requirements; clarified discovery rules; removed expire-in condition.</remark>
</revision>
<revision>
<version>0.11</version>
<date>2004-08-25</date>
<initials>lw/psa</initials>
<remark>Specified that the timestamp for an expire-at condition must be a UTC DateTime per XEP-0082; provided further explanation regarding expire-at and expire-in conditions.</remark>
</revision>
<revision>
<version>0.10</version>
<date>2004-07-14</date>
<initials>lw/psa</initials>
<remark>Changes to address Council feedback: clarified error handling and provided error examples; specified that server should validate all rule semantics before returning an error; specified that service discovery information can be cached (not necessary to send disco query before dispatching each message); added "forward" and "gateway" to values of "deliver" condition to handle redirection of messages to alternate XMPP addresses and non-XMPP systems respectively; more clearly specified processing rules for "expire-in" condition; changed milliseconds to seconds for "expire-in"; made explicit that partial JID-matching is not included for "match-resource" condition; added clarifying note to security consideration regarding "deliver" condition; corrected values of per-hop from [yes|no] to [true|false]; changed "standard" conditions to "defined" conditions and mandated that they should be supported; changed "http://jabber.org/protocol/amp#std-actions" namespace to "http://jabber.org/protocol/amp#errors".</remark>
</revision>
<revision>
<version>0.9</version>
<date>2004-04-25</date>
<initials>psa</initials>
<remark>Editorial review: clarified some matters in the text; fully defined the XMPP Registrar Considerations.</remark>
</revision>
<revision>
<version>0.8</version>
<date>2004-01-20</date>
<initials>lw</initials>
<remark>Reorganized for Editorial preferences; revised error conditions to properly align with XMPP-Core</remark>
</revision>
<revision>
<version>0.7</version>
<date>2003-12-10</date>
<initials>lw</initials>
<remark>Incorported changes requested from Standards list discussions: Changed entity-to-server discovery behavior; s2s discovery behavior; Expanded application-specific error conditions; Reorganized for better presentation; Changed "per-hop" to apply to the entire ruleset; Fixed minor typos and missteps</remark>
</revision>
<revision>
<version>0.6</version>
<date>2003-10-15</date>
<initials>lw</initials>
<remark>Changed disco behavior; Changed schema to reflect customizations</remark>
</revision>
<revision>
<version>0.5.1</version>
<date>2003-09-20</date>
<initials>lw</initials>
<remark>Fixed many typos</remark>
</revision>
<revision>
<version>0.5</version>
<date>2003-08-28</date>
<initials>lw</initials>
<remark>Renamed to "amp" (thanks stpeter!); Added information about the original addressing; Added requirement for id attribute in &MESSAGE;; Restricted behavior within the "Security Considerations";</remark>
</revision>
<revision>
<version>0.4</version>
<date>2003-06-23</date>
<initials>lw</initials>
<remark>Completely rewritten to better account for various suggested usage details and requirements; Completely reorganized to better codify the protocol(s) and their possible uses; Added more conditions; Added more actions; Added common usage scenarios</remark>
</revision>
<revision>
<version>0.3</version>
<date>2003-04-21</date>
<initials>lw</initials>
<remark>Clarified client-side processing; Removed semantics scope; Clarified "fail" action; Moved existing "use-cases" into "Usage" section in "Overview"; Added more relevant use cases; Added XMPP-style error conditions</remark>
</revision>
<revision>
<version>0.2</version>
<date>2003-04-15</date>
<initials>psa</initials>
<remark>Added XML Schema (with author's assistance).</remark>
</revision>
<revision>
<version>0.1</version>
<date>2003-04-15</date>
<initials>lw</initials>
<remark>Initial version.</remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>This document defines a protocol that enables an end-point entity to specify additional delivery semantics for an XMPP &lt;message/&gt; stanza. This protocol is typically used by clients to inform the receiving server how to deliver a particular stanza, such as providing an expiration time or a resource-matching strategy.</p>
<section2 topic='Motivation' anchor='intro-motivation'>
<p>The built-in delivery semantics for &lt;message/&gt; stanzas (defined in &xmppcore; and, for instant messaging applications, also in &xmppim;) are adequate for most current applications. However, there are various cases where more stringent delivery semantics are necessary. The most common cases discussed in this document are:</p>
<ul>
<li>Reliable data transport -- the sender requires notification (positive and/or negative) of message delivery.</li>
<li>Time-sensitive messages -- the message is valid only until a certain date and time.</li>
<li>Transient messages -- the message should not be stored offline for later delivery.</li>
</ul>
</section2>
<section2 topic='Concepts' anchor='intro-concepts'>
<p>This protocol is mostly handled by the server or servers processing the &lt;message/&gt;. The protocol consists of a list of rules, with conditions and actions for each rule. Upon receipt of an appropriately marked message, the server interprets the rules in the order they are received, looking for met conditions. When a condition is met, the action for that rule is executed, and message processing stops.</p>
<p>Each rule is flagged for the scope it applies to, whether it be the overall route, or for each hop in the route. Additionally, while this document defines a default set of conditions and actions, the protocol is extensible enough to allow for more to be defined in the future.</p>
<p>The namespace for the protocol is "http://jabber.org/protocol/amp".</p>
</section2>
<section2 topic='Prerequisites' anchor='intro-prereq'>
<p>In order for this protocol to function properly, the containing &MESSAGE; stanza MUST possess an 'id' attribute, and the value of the 'id' attribute MUST NOT be an empty string. The server MUST include this 'id' attribute value with any response back to the sender; this enables servers and clients to properly relate the initial request with any subsequent alert, error, or notification.</p>
</section2>
</section1>
<section1 topic='Process Flows' anchor='process'>
<section2 topic='Sender-to-Server' anchor='process-s2s'>
<p>The following use case flow describes the interaction between the sender and a server. As illustrated below, this interaction is actually rather simple:</p>
<ol>
<li>Sender determines support (E1)</li>
<li>Sender specifies appropriate rules and sends message to server (E1,E2)</li>
<li>Sender awaits any protocol-specific responses (UCE)</li>
</ol>
<ul>
<li><cite>E1:</cite> The server does not support this protocol (UCE unsuccessfully)</li>
<li><cite>E2:</cite> The server does not support one or more specified rule conditions/actions (UCE unsuccessfully)</li>
</ul>
<section3 topic='Discovery' anchor='process-s2s-disco'>
<p>Sending entities that wish to use AMP SHOULD discover support for this protocol (using &xep0030;) along the intended path. Typically, this would involve sending disco#info queries to the sending entity's own server and the server of the intended recipient. The results of these queries MAY be cached for up to 24 hours, unless otherwise expired.</p>
<p>If a server supports Advanced Message Processing, it MUST report that by including a service discovery feature of "http://jabber.org/protocol/amp" in the service discovery information result that it returns to the requesting entity.</p>
<example caption="Initial Service Discovery information request"><![CDATA[
<iq from='northumberland@shakespeare.lit/westminster'
to='shakespeare.lit'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
<example caption="Service Discovery information response"><![CDATA[
<iq from='shakespeare.lit'
to='northumberland@shakespeare.lit/westminster'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity name='Shakespeare IM' category='im' type='server'/>
...
<feature var='http://jabber.org/protocol/amp'/>
...
</query>
</iq>
]]></example>
<p>A server SHOULD also maintain a service discovery node named "http://jabber.org/protocol/amp", at which it advertises the individual actions and conditions it supports. If an entity needs to determine whether the server supports individual actions and conditions, it SHOULD send a service discovery information request to that node; the server then MUST either return the list of supported actions and conditions or return an error such as &feature;. (Note: If the server does not provide information for this disco node, the requesting entity MUST assume that all actions and conditons are supported for each reported action set or condition set.)</p>
<p>Each supported action shall be reported as a feature using the following format:</p>
<code>http://jabber.org/protocol/amp?action={action}</code>
<p>Each supported condition shall be reported as a feature using the following format:</p>
<code>http://jabber.org/protocol/amp?condition={condition}</code>
<p>The following examples show the request-response flow for information about individual actions and conditions (note the inclusion of the 'node' attribute).</p>
<example caption="Request for information about individual actions and conditions"><![CDATA[
<iq from='northumberland@shakespeare.lit/westminster'
to='shakespeare.lit'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://jabber.org/protocol/amp'/>
</iq>
]]></example>
<example caption="Response for individual actions and conditions"><![CDATA[
<iq from='shakespeare.lit'
to='northumberland@shakespeare.lit/westminster'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://jabber.org/protocol/amp'>
<identity name='Shakespeare IM AMP Support' category='im' type='server'/>
...
<feature var='http://jabber.org/protocol/amp'/>
<feature var='http://jabber.org/protocol/amp?action=drop'/>
<feature var='http://jabber.org/protocol/amp?action=error'/>
<feature var='http://jabber.org/protocol/amp?action=notify'/>
<feature var='http://jabber.org/protocol/amp?condition=deliver'/>
<feature var='http://jabber.org/protocol/amp?condition=expire-at'/>
<feature var='http://jabber.org/protocol/amp?condition=match-resource'/>
...
</query>
</iq>
]]></example>
</section3>
<section3 topic='Specifying Semantics' anchor='process-s2s-semantics'>
<p>Once support is determined, the sender can attach the desired delivery semantics to the message:</p>
<example caption='A message with AMP semantics'><![CDATA[
<message
from='northumberland@shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule condition='expire-at'
action='drop'
value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<p>The semantics are defined as a set of &lt;rule/&gt; elements within the &lt;amp/&gt; root element. Each &lt;rule/&gt; declares the condition to trigger on and the action to execute if triggered.</p>
<p>By default, the ruleset applies only to the "edge servers": those servers to which the sending and receiving entities are connected. (Note: For the purposes of Advanced Message Processing, "server" is defined as in <cite>XMPP Core</cite> and does not include any internal components, such as connection managers, that may provide functionality within a server implementation or installation.)</p>
<p>The ruleset MAY be applied to all server-to-server "hops" along the route from the sending and receiving entities by adding the "per-hop' attribute to the &lt;amp/&gt; element. The value of this attribute is either "true" (apply rules to all hops) or "false" (follow default behavior, i.e., apply rules at the edge servers only).</p>
<example caption='Another message with AMP semantics'><![CDATA[
<message
from='northumberland@shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'
per-hop='true'>
<rule condition='expire-at'
action='drop'
value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<p>For examples of validation failure, refer to the <link url="#errors">Error Handling</link> section of this document.</p>
<p>Note: Even if "per-hop" processing is requested, each server in the route MUST ignore rules that cannot apply to it; the <link url="#conditions-def">Defined Conditions</link> outline if they can be applied per-hop.</p>
</section3>
</section2>
<section2 topic='Server Processing' anchor='process-server'>
<p>Server operation is where the bulk of the work is performed. Upon receiving a message with an AMP extension, the server performs the following flow:</p>
<ol>
<li>Validate the semantics (E1, E2).</li>
<li>Determine the default behavior.</li>
<li>Process rules until condition is met.
<ul>
<li>If a condition is met, execute that rule's action</li>
<li>If no conditions are met, perform "default" behavior for message</li>
</ul>
</li>
<li>Execute determined action (UCE) (E3).</li>
</ol>
<ul>
<li><cite>E1:</cite> The provided semantics (condition and/or action) are not supported or valid (UCE unsuccessfully)</li>
<li><cite>E2:</cite> The requested semantics are not acceptable (UCE unsuccessfully)</li>
<li><cite>E3:</cite> The next server does not support this protocol (UCE unsuccessfully)</li>
</ul>
<section3 topic='Validating Semantics' anchor='process-server-semantics'>
<p>Validation can take many forms, but at the very least the server MUST verify that it understands each of the rule conditions and actions, and that the condition contents are appropriate. The server MAY also refuse to accept certain combinations of conditions and actions, for example if they present a risk of violating security policies. If the semantics are not valid, supported, or acceptable, the server MUST reply with an error specifying the rule(s) that are at issue. The server SHOULD validate all the semantics before returning an error. For syntax and examples of error handling related to validation failure, refer to the <link url="#errors">Error Handling</link> section of this document.</p>
</section3>
<section3 topic='Determine Default Action' anchor='process-server-default'>
<p>This step is essentially what a server normally does, except that it does not actually perform the action. This determines what would happen to the message if there were no semantics attached (such as dispatch to another server or store offline). At this point, the server SHOULD also calculate any timing or calendar requirements (if applicable).</p>
</section3>
<section3 topic='Process Rules' anchor='process-server-rules'>
<p>At this step, the server processes the attached semantics. The server MUST process the rules serially, and in the order they are presented within the &lt;amp/&gt; element. As soon as a rule's condition is met, processing ends with that action overriding the default action determined earlier (unless the action permits continued processing).</p>
</section3>
<section3 topic='Execute Determined Action' anchor='process-server-execute'>
<p>Once all rules have been processed or otherwise accounted for, the server executes the action determined at this point.</p>
<p>A server SHOULD NOT dispatch a &MESSAGE; stanza with AMP semantics to another server unless it knows that the next server supports AMP (this SHOULD be discovered via <cite>Service Discovery</cite> and MAY be cached to avoid delivery delays). If the next server does not support AMP, the current server replies to the original sender with a &e503; error condition. Otherwise this flow starts again for the server to which the message has been dispatched.</p>
</section3>
<section3 topic='Return Event' anchor='process-server-event'>
<p>If the determined action involves returning an event (alert, error, or notification) to the sender, a server MUST send a &MESSAGE; stanza to the sender containing the rule that was met. This &MESSAGE; stanza MUST include the original value of the 'id' attribute and SHOULD NOT contain the non-AMP contents (e.g., &BODY; child) originally included by the sender.</p>
</section3>
</section2>
</section1>
<section1 topic='Conditions and Actions' anchor='conditionsactions'>
<p>The preceding sections of this document define the general behavior regarding AMP. This section outlines how &lt;rule/&gt; action and condition sets are specified. It also provides defined action and condition sets; these action and condition sets SHOULD be supported by any implementation of Advanced Message Processing, but support for any given action or condition set it not required. (Note: The action and condition sets defined herein may be supplemented in the future via registration of additional action and condition sets with the XMPP Registrar.)</p>
<section2 topic='Rule Condition Guidelines' anchor='conditions-guide'>
<p>The definition of a &lt;rule/&gt; condition MUST provide the following information:</p>
<ul>
<li>Define a namespace governing the condition set</li>
<li>Define the condition:
<ul>
<li>Define the 'condition' attribute value</li>
<li>Specify if the "per-hop" flag applies</li>
<li>Define the syntax/format of the 'value' attribute value</li>
<li>Define how the "value" is interpreted to meet a condition</li>
</ul>
</li>
</ul>
</section2>
<section2 topic='Rule Action Guidelines' anchor='actions-guide'>
<p>The definition of a &lt;rule/&gt; action MUST provide the following information:</p>
<ul>
<li>Define a namespace governing the action set</li>
<li>Define the action:
<ul>
<li>Define each 'action' attribute value</li>
<li>Define the expected behavior if the &lt;rule/&gt; is triggered</li>
</ul>
</li>
</ul>
</section2>
<section2 topic='Defined Conditions' anchor='conditions-def'>
<p>The condition defines how or when a particular rule is triggered. The value of the condition attribute determines what the contents of the &lt;rule/&gt; mean.</p>
<p>The following conditions are defined by this document and SHOULD be supported by any implementation.</p>
<p>In the following sections, the terms "content" and "contents" refers to the XML character data contained by the &lt;rule/&gt; element.</p>
<section3 topic='deliver' anchor='conditions-def-deliver'>
<p>The "deliver" condition is used to ensure delivery (or non-delivery) in one of five ways:</p>
<ol>
<li>Directly to the specified address or account over XMPP</li>
<li>Delayed to offline storage (for later delivery via XMPP)</li>
<li>Forwarded to an alternate address or account over XMPP</li>
<li>Indirectly to an alternate address or account through a gateway to a non-XMPP system</li>
</ol>
<p>This condition is met based on what the processor would do with the message at the moment of receipt, as follows:</p>
<table caption='"deliver" values'>
<tr>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>direct</td>
<td>The message would be immediately delivered to the intended recipient or routed to the next hop.</td>
</tr>
<tr>
<td>forward</td>
<td>The message would be forwarded to another XMPP address or account.</td>
</tr>
<tr>
<td>gateway</td>
<td>The message would be sent through a gateway to an address or account on a non-XMPP system.</td>
</tr>
<tr>
<td>none</td>
<td>The message would not be delivered at all (e.g., because the intended recipient is offline and message storage is not enabled).</td>
</tr>
<tr>
<td>stored</td>
<td>The message would be stored offline for later delivery to the intended recipient.</td>
</tr>
</table>
<p>This condition MAY be applied to each "hop" in the server route.</p>
</section3>
<section3 topic='expire-at' anchor='conditions-def-expireat'>
<p>The "expire-at" condition is used to ensure delivery before an absolute point in time. Naturally, this does not <em>guarantee</em> <note>Guarantee is a strong word. This document defines methods for making message delivery more reliable within certain bounds, but does not pretend that such methods provide any form of guaranteed delivery.</note> that the message will not be delivered after that time from the sender's perspective, since this document does not assume that all machine clocks (e.g., for all servers along the delivery route) are synchronized. However, in order to help ensure that this condition is met correctly, servers that implement this document (or the machines that host such servers) SHOULD use the Network Time Protocol (&rfc1305;) to keep in sync with established time authorities. Note also that expire-at functionality becomes less reliable the closer the expire-at time is to the present (e.g., the sender will receive less reliable delivery of a message speciifying an expire-at time two seconds in the future than of a message specifying an expire-at time two hours or two days in the future).</p>
<p>The content of the 'value' attribute specifies some point after the exact moment the message is sent; the content MUST be a DateTime as specified in &xep0082;, and the timezone MUST be UTC.</p>
<p>The condition is met if the message would be delivered to the recipient after the specified datetime. To determine the datetime to compare to, the processor first determines if and when a message can be dispatched (e.g. not stored offline). The processor then records this datetime, and compares it with the specified datetime. If the current datetime is on or after that specified, the condition is met.</p>
<p>This condition MAY be applied to each "hop" in the server route.</p>
</section3>
<section3 topic='match-resource' anchor='conditions-def-match'>
<p>The "match-resource" condition is used to restrict delivery based on the resource identifier of the recipient JID.</p>
<p>The defined values for this condition are:</p>
<table caption='"match-resource" values'>
<tr>
<th>Value</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>any</td>
<td>Destination resource matches any value, effectively ignoring the intended resource.</td>
<td>"home/laptop" matches "home", "home/desktop" or "work/desktop"</td>
</tr>
<tr>
<td>exact</td>
<td>Destination resource exactly matches the intended resource.</td>
<td>"home/laptop" only matches "home/laptop" and not "home/desktop" or "work/desktop"</td>
</tr>
<tr>
<td>other</td>
<td>Destination resource matches any value except for the intended resource.</td>
<td>"home/laptop" matches "work/desktop", "home" or "home/desktop", but not "home/laptop"</td>
</tr>
</table>
<p>The condition is met if the resource for the actual destination JID matches the intended JID using the above rules. For instance, if a message is intended for "romeo@montague.net/work" with the "match-resource" condition of "exact", the condition is met if the message can be immediately delivered only to "romeo@montague.net/work".</p>
<p>For purposes of this condition, an intended JID with no resource has the following behavior:</p>
<ul>
<li>If the value is "exact", the condition is met only if the server would deliver to a destination JID without a resource identifier (e.g., a &xep0045; room or offline storage).</li>
<li>If the value is "other", the condition is met only if the server would not deliver to a destination JID without a resource identifier.</li>
</ul>
<p>This condition MUST NOT be applied to each "hop" in the server route, only at the edge servers. If an &lt;amp/&gt; element includes this condition and also indicates that it should be processed per hop, this &lt;rule/&gt; shall be ignored.</p>
<p>Note: By design, this protocol does not include support for partial resource matching (which would stipulate, for example, that the resource identifiers "home/laptop" and "homeboy" both match "home").</p>
</section3>
</section2>
<section2 topic='Defined Actions' anchor='actions-def'>
<p>The action defines what occurs when a particular rule is triggered. The value of the action attribute determines the behavior if the rule's condition is met.</p>
<p>The following actions are defined by this document.</p>
<section3 topic='alert' anchor='actions-def-alert'>
<p>The "alert" action triggers a reply &MESSAGE; stanza to the sending entity. This &MESSAGE; stanza MUST contain the element &lt;amp status='alert'/&gt;, which itself contains the &lt;rule/&gt; that triggered this action. In all other respects, this action behaves as "drop".</p>
<example caption='Alert Response'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
id='chatty2'>
<amp xmlns='http://jabber.org/protocol/amp'
status='alert'
from='bernardo@hamlet.lit/elsinore'
to='francisco@hamlet.lit'>
<rule action='alert' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
</section3>
<section3 topic='drop' anchor='actions-def-drop'>
<p>The "drop" action silently discards the message from any further delivery attempts and ensures that it is not placed into offline storage. The drop MUST NOT result in other responses.</p>
</section3>
<section3 topic='error' anchor='actions-def-error'>
<p>The "error" action triggers a reply &MESSAGE; stanza of type "error" to the sending entity. The &MESSAGE; stanza's &lt;error/&gt; child MUST contain a &lt;failed-rules xmlns='http://jabber.org/protocol/amp#errors'/&gt; error condition, which itself contains the rules that triggered this action.</p>
<example caption='Error Response'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
type='error'
id='chatty2'>
<amp xmlns='http://jabber.org/protocol/amp'
status='error'
to='bernardo@hamlet.lit/elsinore'
from='francisco@hamlet.lit'>
<rule action='error' condition='deliver' value='stored'/>
</amp>
<error type='modify' code='500'>
<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<failed-rules xmlns='http://jabber.org/protocol/amp#errors'>
<rule action='error' condition='deliver' value='stored'/>
</failed-rules>
</error>
</message>
]]></example>
<p>Note that the error SHOULD be of type "modify", and the general error condition SHOULD be &lt;undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;.</p>
</section3>
<section3 topic='notify' anchor='actions-def-notify'>
<p>The "notify" action triggers a reply &MESSAGE; stanza to the sending entity. This &MESSAGE; stanza MUST contain the element &lt;amp status='notify'/&gt;, which itself contains the &lt;rule/&gt; that triggered this action. Unlike the other actions, this action does not override the default behavior for a server. Instead, the server then executes its default behavior after sending the notify.</p>
<example caption='Notify Response'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
id='chatty2'>
<amp xmlns='http://jabber.org/protocol/amp'
status='notify'
to='bernardo@hamlet.lit/elsinore'
from='francisco@hamlet.lit'>
<rule action='notify' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
</section3>
</section2>
<section2 topic='Description of Condition/Action Combinations' anchor='description'>
<p>In general, a rule can be read as "do {action} if {condition} is true for {value}"; however, to facilitate understanding, this section describes the various condition/action combinations in plain English.</p>
<section3 topic='Deliver Rules' anchor='description-deliver'>
<p>When the condition is "deliver", the rules can be described as follows:</p>
<table caption='Deliver Rules'>
<tr>
<th>Action</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>alert</td>
<td>direct</td>
<td>Return an alert if the message would be delivered directly.</td>
</tr>
<tr>
<td>alert</td>
<td>forward</td>
<td>Return an alert if the message would be forwarded to another XMPP address.</td>
</tr>
<tr>
<td>alert</td>
<td>gateway</td>
<td>Return an alert if the message would be delivered to a non-XMPP address through a gateway.</td>
</tr>
<tr>
<td>alert</td>
<td>none</td>
<td>Return an alert if no delivery is possible.</td>
</tr>
<tr>
<td>alert</td>
<td>stored</td>
<td>Return an alert if the message would be stored offline for later delivery via XMPP.</td>
</tr>
<tr>
<td>drop</td>
<td>direct</td>
<td>Drop the message if it would be delivered directly.</td>
</tr>
<tr>
<td>drop</td>
<td>forward</td>
<td>Drop the message if it would be forwarded to another XMPP address.</td>
</tr>
<tr>
<td>drop</td>
<td>gateway</td>
<td>Drop the message if it would be delivered to a non-XMPP address through a gateway.</td>
</tr>
<tr>
<td>drop</td>
<td>none</td>
<td>Drop the message if no delivery is possible.</td>
</tr>
<tr>
<td>drop</td>
<td>stored</td>
<td>Drop the message if it would be stored offline for later delivery via XMPP.</td>
</tr>
<tr>
<td>error</td>
<td>direct</td>
<td>Return an error if the message would be delivered directly.</td>
</tr>
<tr>
<td>error</td>
<td>forward</td>
<td>Return an error if the message would be forwarded to another XMPP address.</td>
</tr>
<tr>
<td>error</td>
<td>gateway</td>
<td>Return an error if the message would be delivered to a non-XMPP address through a gateway.</td>
</tr>
<tr>
<td>error</td>
<td>none</td>
<td>Return an error if no delivery is possible.</td>
</tr>
<tr>
<td>error</td>
<td>stored</td>
<td>Return an error if the message would be stored offline for later delivery via XMPP.</td>
</tr>
<tr>
<td>notify</td>
<td>direct</td>
<td>Return a notification if the message would be delivered directly.</td>
</tr>
<tr>
<td>notify</td>
<td>forward</td>
<td>Return a notification if the message would be forwarded to another XMPP address.</td>
</tr>
<tr>
<td>notify</td>
<td>gateway</td>
<td>Return a notification if the message would be delivered to a non-XMPP address through a gateway.</td>
</tr>
<tr>
<td>notify</td>
<td>none</td>
<td>Return a notification if no delivery is possible.</td>
</tr>
<tr>
<td>notify</td>
<td>stored</td>
<td>Return a notification if the message would be stored offline for later delivery via XMPP.</td>
</tr>
</table>
</section3>
<section3 topic='Expire-at Rules' anchor='description-expire-at'>
<p>When the condition is "expire-at", the rules can be described as follows:</p>
<table caption='Expiration Rules'>
<tr>
<th>Action</th>
<th>Description</th>
</tr>
<tr>
<td>alert</td>
<td>Return an alert if the message would be delivered after the specified timestamp.</td>
</tr>
<tr>
<td>drop</td>
<td>Drop the message if it would be delivered after the specified timestamp.</td>
</tr>
<tr>
<td>error</td>
<td>Return an error if the message would be delivered after the specified timestamp.</td>
</tr>
<tr>
<td>notify</td>
<td>Return a notification if the message would be delivered after the specified timestamp.</td>
</tr>
</table>
</section3>
<section3 topic='Match-resource Rules' anchor='description-match-resource'>
<p>When the condition is "match-resource", the rules can be described as follows:</p>
<table caption='Resource Matching Rules'>
<tr>
<th>Action</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>alert</td>
<td>any</td>
<td>Return an alert if the message would be delivered to any resource.</td>
</tr>
<tr>
<td>alert</td>
<td>exact</td>
<td>Return an alert if the message would be delivered to the exact resource.</td>
</tr>
<tr>
<td>alert</td>
<td>other</td>
<td>Return an alert if the message would be delivered to a resource other than that specified.</td>
</tr>
<tr>
<td>drop</td>
<td>any</td>
<td>Drop the message if it would be delivered to any resource.</td>
</tr>
<tr>
<td>drop</td>
<td>exact</td>
<td>Drop the message if it would be delivered to the exact resource.</td>
</tr>
<tr>
<td>drop</td>
<td>other</td>
<td>Drop the message if it would be delivered to a resource other than that specified.</td>
</tr>
<tr>
<td>error</td>
<td>any</td>
<td>Return an error if the message would be delivered to any resource.</td>
</tr>
<tr>
<td>error</td>
<td>exact</td>
<td>Return an error if the message would be delivered to the exact resource.</td>
</tr>
<tr>
<td>error</td>
<td>other</td>
<td>Return an error if the message would be delivered to a resource other than that specified.</td>
</tr>
<tr>
<td>notify</td>
<td>any</td>
<td>Return a notification if the message would be delivered to any resource.</td>
</tr>
<tr>
<td>notify</td>
<td>exact</td>
<td>Return a notification if the message would be delivered to the exact resource.</td>
</tr>
<tr>
<td>notify</td>
<td>other</td>
<td>Return a notification if the message would be delivered to a resource other than that specified.</td>
</tr>
</table>
</section3>
</section2>
</section1>
<section1 topic='Formal Description' anchor='formal'>
<section2 topic='&lt;amp/&gt; Root Element' anchor='formal-root'>
<p>All delivery semantics are encapsulated in the &lt;amp/&gt; element. This element contains one or more &lt;rule/&gt; elements specifying the specific rules to process. It can optionally possess attributes about the current status, the original sender and recipient, and route applicability.</p>
<p>The 'status' attribute specifies the reason for this &lt;amp/&gt; element. When specifying semantics to be applied (client to server), this attribute MUST NOT be present. When replying to a sending entity regarding a met condition, this attribute MUST be present and SHOULD be the value of the 'action' attribute for the triggered rule. (Note: Individual action definitions MAY provide their own requirements.)</p>
<p>The 'from' attribute specifies the original sender of the containing &MESSAGE; stanza. This attribute MUST be specified for any &MESSAGE; stanza sent from a supporting server, regardless of the recipient. It SHOULD NOT be specified otherwise. The value of the 'from' attribute MUST be the full JID (node@domain/resource) of the sender for the original &MESSAGE; stanza.</p>
<p>The 'to' attribute specifies the original (intended) recipient of the containing &MESSAGE; stanza. This attribute MUST be specified for any &MESSAGE; stanza sent from a supporting server, regardless of the recipient. It SHOULD NOT be specified otherwise. The value of the 'to' attribute MUST be the full JID (node@domain/resource) of the intended recipient for the original &MESSAGE; stanza.</p>
<p>The 'per-hop' attribute flags the contained ruleset for processing at each server in the route between the original sender and original intended recipient. This attribute MAY be present, and MUST be either "true" or "false". If not present, the default is "false".</p>
</section2>
<section2 topic='&lt;rule/&gt; Element' anchor='formal-rule'>
<p>Each semantic rule is specified with a &lt;rule/&gt; element. This element possesses attributes for the condition, value, and action.</p>
<p>The 'action' attribute defines the result for this rule. This attribute MUST be present, and MUST be either a value defined in the <link url="#actions-def">Defined Actions</link> section, or one registered with the XMPP Registrar.</p>
<p>The 'condition' attribute defines the overall condition this rule applies to. This attribute MUST be present, and MUST be either a value defined in the <link url="#conditions-def">Defined Conditions</link> section, or one registered with the XMPP Registrar.</p>
<p>The 'value' attribute defines how the condition is matched. This attribute MUST be present, and MUST NOT be an empty string (""). The interpretation of this attribute's value is determined by the 'condition' attribute.</p>
</section2>
</section1>
<section1 topic='Example Scenarios' anchor='examples'>
<section2 topic='Reliable Data Transport' anchor='examples-reliabledata'>
<p>The &MESSAGE; stanza is nearly ideal for data transport, but to ensure reliability it is often desirable that such messages not be delivered to any resource but that specified. To facilitate this, the sending entity includes a &lt;rule action='drop' condition='match-resource' value='other'/&gt; (if failure notification is unnecessary) or &lt;rule action='error' condition='match-resource' value='other'/&gt; (if failure notification is required). The following example illustrates this using &xep0047;:</p>
<example caption='Sending a message for reliable data transport'><![CDATA[
<message to='francisco@hamlet.lit/pda'
from='bernardo@hamlet.lit/elsinore'
id='ibb1'>
<data xmlns='http://jabber.org/protocol/ibb' sid='mySID' seq='0'>
qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
</data>
<amp xmlns='http://jabber.org/protocol/amp' per-hop='true'>
<rule action='error' condition='expire-at' value='2004-09-10T08:33:14Z'/>
<rule action='error' condition='match-resource' value='other'/>
</amp>
</message>
]]></example>
<p>In the above case, the sender would receive an error reply if the message could not be delivered specifically to "francisco@hamlet.lit/pda" by the specified time. For example, if the intended resource went offline before the message could be delivered, the processing server would return the following error:</p>
<example caption='Failed reliable data transport message'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
id='ibb1'>
<amp xmlns='http://jabber.org/protocol/amp'
from='bernardo@hamlet.lit/elsinore'
to='francisco@hamlet.lit/pda'>
<rule action='error' condition='match-resource' value='other'/>
</amp>
<error type='modify' code='500'>
<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<failed-rules xmlns='http://jabber.org/protocol/amp#errors'>
<rule action='error' condition='match-resource' value='other'/>
</failed-rules>
</error>
</message>
]]></example>
</section2>
<section2 topic='Time-Sensitive Messages' anchor='examples-time'>
<p>Time-sensitive messages are a frequent occurrence in some environments (e.g., front-office personnel routinely notify others of "events" such as guests, unexpected refreshments, and ad-hoc gatherings). To send a time-sensitive message, the sending entity includes a &lt;rule action='drop' condition='expire-at'/&gt; with the time when the event is to occur:</p>
<example caption='Sending a time-sensitive message'><![CDATA[
<message to='linuxwolf@outer-planes.net'
from='receptionist@outer-planes.net'
id='alert849'>
<subject>Guest Alert!</subject>
<body>
There will be clients in the conference room today around 1 PM!
As always, be courteous and quiet nearby...
</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2003-06-23T23:00:00Z'/>
</amp>
</message>
]]></example>
<p>In the above case, the server for "linuxwolf@outer-planes.net" would not deliver the message once 23:00 UTC (3:00 PM Pacific Daylight Time) has passed.</p>
</section2>
<section2 topic='Transient Messages' anchor='examples-transient'>
<p>Transient messages are messages that should never be stored offline. To send a transient message, the sending entity includes a &lt;rule action='drop' condition='deliver' value='stored'/&gt;:</p>
<example caption='Sending a transient message'><![CDATA[
<message to='francisco@hamlet.lit'
from='bernardo@hamlet.lit/elsinore'
type='chat'
id='chatty1'>
<body>Who&apos;s there?</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
<p>Alternatively, the sending entity includes a &lt;rule action='alert' condition='deliver' value='stored'/&gt; to be alerted instead of having the message silently dropped:</p>
<example caption='Sending a transient message (requesting alert)'><![CDATA[
<message to='francisco@hamlet.lit'
from='bernardo@hamlet.lit/elsinore'
type='chat'
id='chatty2'>
<body>Who&apos;s there?</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='alert' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
<example caption='Sender alerted regarding transient message'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
id='chatty2'>
<amp xmlns='http://jabber.org/protocol/amp'
status='alert'
from='bernardo@hamlet.lit/elsinore'
to='francisco@hamlet.lit'>
<rule action='alert' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
</section2>
</section1>
<section1 topic='Error Handling' anchor='errors'>
<section2 topic='Conditions' anchor='errors-conditions'>
<p>To simplify the discussion of error conditions, this document uses the following mappings between namespace URIs and namespace prefixes (note: this mapping is provided only for the purpose of simplifying the discussion and is not intended for use within the protocol itself).</p>
<table caption='Namespace Mappings'>
<tr>
<th>Prefix</th>
<th>URI</th>
</tr>
<tr>
<td>xmpp</td>
<td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
</tr>
<tr>
<td>msg</td>
<td>http://jabber.org/protocol/amp</td>
</tr>
<tr>
<td>err</td>
<td>http://jabber.org/protocol/amp#errors</td>
</tr>
</table>
<p>The following table shows the possible error conditions in relation to general AMP rules and conditions as well as the <link url="#actions-def">Defined Actions</link>.</p>
<table caption='Error conditions'>
<tr>
<th>General Condition</th>
<th>Error Type</th>
<th>Specific Condition</th>
<th>Description</th>
</tr>
<tr>
<td>&lt;xmpp:bad-request/&gt;</td>
<td>modify</td>
<td>&lt;msg:unsupported-actions/&gt;</td>
<td>One or more rule's specified actions are not supported. The element &lt;msg:unsupported-actions/&gt; contains the &lt;rule/&gt; elements that specify the unsupported actions.</td>
</tr>
<tr>
<td>&lt;xmpp:bad-request/&gt;</td>
<td>modify</td>
<td>&lt;msg:unsupported-conditions/&gt;</td>
<td>One or more rule's specified conditions are not supported. The element &lt;msg:unsupported-conditions/&gt; contains the &lt;rule/&gt; elements that specify the unsupported conditions.</td>
</tr>
<tr>
<td>&lt;xmpp:not-acceptable/&gt;</td>
<td>modify</td>
<td>&lt;msg:invalid-rules/&gt;</td>
<td>One or more rules are not acceptable by this server, usually because the condition/action combination is restricted. The element &lt;msg:invalid-rules/&gt; contains the &lt;rule/&gt; elements that are not acceptable.</td>
</tr>
<tr>
<td>&lt;xmpp:service-unavailable/&gt;</td>
<td>cancel</td>
<td>NONE</td>
<td>This protocol is not supported. This error is returned to the sending entity if a server along the route to the recipient does not implement this protocol.</td>
</tr>
<tr>
<td>&lt;xmpp:undefined-condition/&gt;</td>
<td>modify</td>
<td>&lt;err:failed-rules/&gt;</td>
<td>One or more &lt;rule/&gt; elements triggered the "error" action. This condition contains the triggered &lt;rule/&gt; elements.</td>
</tr>
</table>
</section2>
<section2 topic='Examples' anchor='errors-examples'>
<p>This section shows examples of the error conditions described in the previous section (for information regarding mapping of XMPP error conditions to Jabber error codes, refer to &xep0086;).</p>
<section3 topic='Unsupported Action' anchor='errors-action'>
<example caption='A message with AMP semantics'><![CDATA[
<message
from='northumberland@shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<example caption='Server does not support action'><![CDATA[
<message
from='shakespeare.lit'
id='richard2-4.1.247'
to='northumberland@shakespeare.lit'
type='error'>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
<error type='modify' code='400'>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<unsupported-actions xmlns='http://jabber.org/protocol/amp'>
<rule condition='expire-at'
action='drop'
value='2004-01-01T00:00:00Z'/>
</unsupported-actions>
</error>
</message>
]]></example>
</section3>
<section3 topic='Unsupported Condition' anchor='errors-condition'>
<example caption='A message with AMP semantics'><![CDATA[
<message
from='shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<example caption='Server does not support condition'><![CDATA[
<message
from='shakespeare.lit'
id='richard2-4.1.247'
to='northumberland@shakespeare.lit'
type='error'>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
<error type='modify' code='400'>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<unsupported-conditions xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</unsupported-conditions>
</error>
</message>
]]></example>
</section3>
<section3 topic='Not Acceptable' anchor='errors-notacceptable'>
<example caption='A message with AMP semantics'><![CDATA[
<message
from='northumberland@shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<example caption='The rule is not acceptable to the server'><![CDATA[
<message
from='shakespeare.lit'
id='richard2-4.1.247'
to='northumberland@shakespeare.lit'
type='error'>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
<error type='modify' code='405'>
<not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<invalid-rules xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</invalid-rules>
</error>
</message>
]]></example>
</section3>
<section3 topic='Service Unavailable' anchor='errors-unavail'>
<example caption='A message with AMP semantics'><![CDATA[
<message
from='northumberland@shakespeare.lit'
id='richard2-4.1.247'
to='kingrichard@royalty.england.lit'>
<body>My lord, dispatch; read o'er these articles.</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
</message>
]]></example>
<example caption='AMP service is unavailable'><![CDATA[
<message
from='royalty.england.lit'
id='richard2-4.1.247'
to='northumberland@shakespeare.lit'
type='error'>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='expire-at' value='2004-01-01T00:00:00Z'/>
</amp>
<error type='cancel' code='503'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</message>
]]></example>
</section3>
<section3 topic='Undefined Condition' anchor='errors-undefined'>
<example caption='A message with AMP semantics'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
id='chatty2'>
<body>Who&apos;s there?</body>
<amp xmlns='http://jabber.org/protocol/amp'
status='error'
from='francisco@hamlet.lit'
to='bernardo@hamlet.lit/elsinore'>
<rule action='error' condition='deliver' value='stored'/>
</amp>
</message>
]]></example>
<example caption='Failed rules'><![CDATA[
<message from='hamlet.lit'
to='bernardo@hamlet.lit/elsinore'
type='error'
id='chatty2'>
<amp xmlns='http://jabber.org/protocol/amp'
status='error'
from='francisco@hamlet.lit'
to='bernardo@hamlet.lit/elsinore'>
<rule action='error' condition='deliver' value='stored'/>
</amp>
<error type='modify' code='500'>
<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<failed-rules xmlns='http://jabber.org/protocol/amp#errors'>
<rule action='error' condition='deliver' value='stored'/>
</failed-rules>
</error>
</message>
]]></example>
</section3>
</section2>
</section1>
<section1 topic='Implementation Notes' anchor='impl'>
<p>If the recipient's server implements "offline storage", it will need to keep track of which offline messages are subject to expiration and not deliver those which have expired. Exactly how to do so is a matter of implementation. One possible implementation is for the server to maintain a separate database of expirable messages and periodically scan it; upon discovering an expired message, it could flag the message as eligible for discarding and inform the sender, but not discard the message until the intended recipient next becomes available.</p>
</section1>
<section1 topic='Stream Feature' anchor='streamfeature'>
<p>&xmppcore; defines methods for advertising feature support during stream negotiation. For the sake of efficiency, it may be desirable for a server to advertise support for Advanced Message Processing as a stream feature. The namespace for reporting support within &lt;stream:features/&gt; is "http://jabber.org/features/amp". Upon receiving a stream header from the initiating entity, the receiving entity (usually a server) returns a stream header to initiating entity and MAY announce support for Advanced Message Processing registration by including the relevant stream feature:</p>
<example caption='Advertising Advanced Message Processing as a stream feature'><![CDATA[
<stream:features>
<amp xmlns='http://jabber.org/features/amp'/>
</stream:features>
]]></example>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<p>Most AMP conditions could be used by unauthorized individuals to gain access to presence information about users of IM servers and other presence-based messaging systems. For example, consider the following scenario: the user &lt;romeo@montague.net&gt; is not an authorized subscriber to the presence of the user &lt;nurse@capulet.com&gt;, but sends a &MESSAGE; stanza with a "deliver" rule of "stored" and an action of "alert" to that address; if the Nurse is not online, Romeo would receive an AMP alert that the message has been stored offline, in the process discovering that the Nurse is offline. Similar scenarios are possible with the "match-resource" rule (send to the user's usual resource) and the "expire-at" rule (send messages every minute to poll for presence). If a server implements presence subscriptions as specified in &rfc3921;, it SHOULD NOT return alerts, errors, or other AMP notifications to senders who are not authorized to view the recipient's presence information (via a subscription of "both" or "from") if the notification would reveal the recipient's status as online or offline. <note>An exception might be fully-trusted or closed networks.</note>
).</p>
<p>There are several directions server implementors can follow in this regard:</p>
<ul>
<li><p>Do not implement the relevant condition, as a result of which the server MUST reply with a &feature; error condition if the condition is specified; however, this is unduly restricts the supported conditions and effectively cripples the AMP functionality, so is NOT RECOMMENDED.</p></li>
<li><p>Accept the relevant condition only if the action is "drop", as a result of which the server MUST reply with a &notacceptable; error condition if the action is "alert", "error", or "notify"; this is slightly less restrictive but still unnecessarily restricts the functionality of the system, so is NOT RECOMMENDED.</p></li>
<li><p>Accept the relevant condition only if the sender is authorized to receive the receiver's presence, as a result of which the server MUST reply with a &notacceptable; error condition if the sender is not so authorized; this is the RECOMMENDED behavior.</p></li>
</ul>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>No interaction with &IANA; is necessary as a result of this document.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Protocol Namespaces' anchor='registrar-ns'>
<p>The &REGISTRAR; includes 'http://jabber.org/protocol/amp' and 'http://jabber.org/protocol/amp#errors' in its registry of protocol namespaces.</p>
</section2>
<section2 topic='Stream Features' anchor='registrar-stream'>
<p>The XMPP Registrar includes the 'http://jabber.org/features/amp' namespace in its registry of stream feature namespaces.</p>
</section2>
<section2 topic='Well-Known Service Discovery Nodes' anchor='registrar-nodes'>
<p>The XMPP Registrar includes 'http://jabber.org/protocol/amp' in its registry of well-known Service Discovery nodes.</p>
</section2>
<section2 topic='Registries' anchor='registrar-reg'>
<section3 topic='Rule Conditions Registry' anchor='registrar-reg-conditions'>
<p>The XMPP Registrar maintains a registry of AMP &lt;rule/&gt; conditions at &AMPCONDITIONS;.</p>
<section4 topic='Process' anchor='registrar-reg-conditions-process'>
&REGPROCESS;
<code><![CDATA[
<condition>
<name>the value of the 'condition' attribute</name>
<ns>the namespace to be used as a service discovery feature</ns>
<per-hop>does the "per-hop" flag apply? [true|false]</per-hop>
<value>
The syntax (e.g., datatype or allowable values) of the
'value' attribute.
</value>
<processing>values that result in message processing</processing>
<doc>the document (e.g., XEP) in which this condition is specified</doc>
</condition>
]]></code>
<p>The registrant may register more than one condition at a time, each contained in a separate &lt;condition/&gt; element.</p>
<p>Note: The namespace for the condition set shall be included in the Service Discovery features registry.</p>
</section4>
<section4 topic='Initial Submission' anchor='registrar-reg-conditions-initial'>
<code><![CDATA[
<condition>
<name>deliver</name>
<ns>http://jabber.org/protocol/amp?condition=deliver</ns>
<per-hop>true</per-hop>
<value>[direct|forward|gateway|none|stored]</value>
<processing>
The condition is met if (1) the value is "direct" and the message
can be immediately delivered or further dispatched, (2) the value
is "forward" and the message can be forwarded to another XMPP
address, (3) the value is "gateway" and the message can be sent
to a non-XMPP address via a gateway, (4) the value is "none" and
the message cannot be delivered at all, or (5) the value is
"stored" and the message can be stored for later delivery.
</processing>
<doc>XEP-0079</doc>
</condition>
<condition>
<name>expire-at</name>
<ns>http://jabber.org/protocol/amp?condition=expire-at</ns>
<per-hop>true</per-hop>
<value>DateTime per XEP-0082</value>
<processing>
The condition is met if the message would be delivered after
the specified DateTime.
</processing>
<doc>XEP-0079</doc>
</condition>
<condition>
<name>match-resource</name>
<ns>http://jabber.org/protocol/amp?condition=match-resource</ns>
<per-hop>false</per-hop>
<value>[any|exact|other]</value>
<processing>
The condition is met if (1) the value is "any" and the intended
recipient has at least one available resource (as defined in the
XMPP IM specification); (2) the value "exact" and the intended
recipient has an available resource that exactly matches the JID
specified in the 'to' address; (3) the value is "other" and the
intended recipient has an available resource whose full JID is
other than that specified in the 'to' address.
</processing>
<doc>XEP-0079</doc>
</condition>
]]></code>
</section4>
</section3>
<section3 topic='Rule Actions Registry' anchor='registrar-reg-actions'>
<p>The XMPP Registrar maintains a registry of AMP &lt;rule/&gt; actions at &AMPACTIONS;.</p>
<section4 topic='Process' anchor='registrar-reg-actions-process'>
&REGPROCESS;
<code><![CDATA[
<action>
<name>the value of the 'action' attribute</name>
<ns>the namespace to be used as a service discovery feature</ns>
<behavior>the expected behavior if the rule is triggered</behavior>
<doc>the document (e.g., XEP) in which this action is specified</doc>
</action>
]]></code>
<p>The registrant may register more than one action at a time, each contained in a separate &lt;action/&gt; element.</p>
<p>Note: The namespace for the action set shall be included in the Service Discovery features registry.</p>
</section4>
<section4 topic='Initial Submission' anchor='registrar-reg-actions-initial'>
<code><![CDATA[
<action>
<name>alert</name>
<ns>http://jabber.org/protocol/amp?action=drop</ns>
<behavior>
The message is silently discarded but an alert is returned to the
sender.
</behavior>
<doc>XEP-0079</doc>
</action>
<action>
<name>drop</name>
<ns>http://jabber.org/protocol/amp?action=drop</ns>
<behavior>
The message is silently discarded.
</behavior>
<doc>XEP-0079</doc>
</action>
<action>
<name>error</name>
<ns>http://jabber.org/protocol/amp?action=error</ns>
<behavior>
The message is not processed and an error is returned to the sender,
specifying which rule resulted in failed processing.
</behavior>
<doc>XEP-0079</doc>
</action>
<action>
<name>notify</name>
<ns>http://jabber.org/protocol/amp?action=notify</ns>
<behavior>
The message is processed and a notification message is returned to
the sender, specifying which rule was processed.
</behavior>
<doc>XEP-0079</doc>
</action>
]]></code>
</section4>
</section3>
</section2>
</section1>
<section1 topic='XML Schemas' anchor='schemas'>
<section2 topic='AMP' anchor='schemas-amp'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='http://jabber.org/protocol/amp'
xmlns='http://jabber.org/protocol/amp'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0079: http://www.xmpp.org/extensions/xep-0079.html
</xs:documentation>
</xs:annotation>
<xs:element name='amp'>
<xs:complexType>
<xs:sequence>
<xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
<xs:attribute name='from' use='optional' type='xs:string'/>
<xs:attribute name='per-hop' use='optional' type='xs:boolean' default='false'/>
<xs:attribute name='status' use='optional' type='xs:NCName'/>
<xs:attribute name='to' use='optional' type='xs:string'/>
</xs:complexType>
</xs:element>
<xs:element name='invalid-rules'>
<xs:complexType>
<xs:sequence>
<xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='unsupported-actions'>
<xs:complexType>
<xs:sequence>
<xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='unsupported-conditions'>
<xs:complexType>
<xs:sequence>
<xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='rule'>
<xs:complexType>
<xs:attribute name='action' use='required' type='xs:NCName'/>
<xs:attribute name='condition' use='required' type='xs:NCName'/>
<xs:attribute name='value' use='required' type='xs:string'/>
</xs:complexType>
</xs:element>
</xs:schema>
]]></code>
</section2>
<section2 topic='Errors' anchor='schemas-err'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='http://jabber.org/protocol/amp#errors'
xmlns='http://jabber.org/protocol/amp#errors'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0079: http://www.xmpp.org/extensions/xep-0079.html
</xs:documentation>
</xs:annotation>
<xs:element name='failed-rules'>
<xs:complexType>
<xs:sequence>
<xs:element ref='rule' minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='rule'>
<xs:complexType>
<xs:attribute name='action' use='required' type='xs:NCName'/>
<xs:attribute name='condition' use='required' type='xs:NCName'/>
<xs:attribute name='value' use='required' type='xs:string'/>
</xs:complexType>
</xs:element>
</xs:schema>
]]></code>
</section2>
<section2 topic='Stream Feature' anchor='schemas-streams'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='http://jabber.org/features/amp'
xmlns='http://jabber.org/features/amp'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0079: http://www.xmpp.org/extensions/xep-0079.html
</xs:documentation>
</xs:annotation>
<xs:element name='amp' type='empty'/>
<xs:simpleType name='empty'>
<xs:restriction base='xs:string'>
<xs:enumeration value=''/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
]]></code>
</section2>
</section1>
<section1 topic='Acknowledgements' anchor='acks'>
<p>Thanks to Marshall Rose and Craig Kaes for their comments.</p>
</section1>
</xep>