summaryrefslogtreecommitdiff
path: root/doc/rfc6121.html
blob: bd00706c2fc2e029d31f465ebf33ac6385869d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>Extensible Messaging and Presence Protocol
    (XMPP): Instant&nbsp;Messaging&nbsp;and&nbsp;Presence</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Extensible Messaging and Presence Protocol
    (XMPP): Instant&nbsp;Messaging&nbsp;and&nbsp;Presence">
<meta name="keywords" content="XMPP, Extensible Messaging and Presence Protocol, Jabber, IM, Instant Messaging, Presence, XML, Extensible Markup Language">
<meta name="generator" content="xml2rfc v1.36 (http://xml.resource.org/)">
<style type='text/css'><!--
        body {
                font-family: verdana, charcoal, helvetica, arial, sans-serif;
                font-size: small; color: #000; background-color: #FFF;
                margin: 2em;
        }
        h1, h2, h3, h4, h5, h6 {
                font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
                font-weight: bold; font-style: normal;
        }
        h1 { color: #900; background-color: transparent; text-align: right; }
        h3 { color: #333; background-color: transparent; }

        td.RFCbug {
                font-size: x-small; text-decoration: none;
                width: 30px; height: 30px; padding-top: 2px;
                text-align: justify; vertical-align: middle;
                background-color: #000;
        }
        td.RFCbug span.RFC {
                font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
                font-weight: bold; color: #666;
        }
        td.RFCbug span.hotText {
                font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
                font-weight: normal; text-align: center; color: #FFF;
        }

        table.TOCbug { width: 30px; height: 15px; }
        td.TOCbug {
                text-align: center; width: 30px; height: 15px;
                color: #FFF; background-color: #900;
        }
        td.TOCbug a {
                font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
                font-weight: bold; font-size: x-small; text-decoration: none;
                color: #FFF; background-color: transparent;
        }

        td.header {
                font-family: arial, helvetica, sans-serif; font-size: x-small;
                vertical-align: top; width: 33%;
                color: #FFF; background-color: #666;
        }
        td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
        td.author-text { font-size: x-small; }

        /* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
        a.info {
                /* This is the key. */
                position: relative;
                z-index: 24;
                text-decoration: none;
        }
        a.info:hover {
                z-index: 25;
                color: #FFF; background-color: #900;
        }
        a.info span { display: none; }
        a.info:hover span.info {
                /* The span will display just on :hover state. */
                display: block;
                position: absolute;
                font-size: smaller;
                top: 2em; left: -5em; width: 15em;
                padding: 2px; border: 1px solid #333;
                color: #900; background-color: #EEE;
                text-align: left;
        }

        a { font-weight: bold; }
        a:link    { color: #900; background-color: transparent; }
        a:visited { color: #633; background-color: transparent; }
        a:active  { color: #633; background-color: transparent; }

        p { margin-left: 2em; margin-right: 2em; }
        p.copyright { font-size: x-small; }
        p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
        table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
        td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }

        ol.text { margin-left: 2em; margin-right: 2em; }
        ul.text { margin-left: 2em; margin-right: 2em; }
        li      { margin-left: 3em; }

        /* RFC-2629 <spanx>s and <artwork>s. */
        em     { font-style: italic; }
        strong { font-weight: bold; }
        dfn    { font-weight: bold; font-style: normal; }
        cite   { font-weight: normal; font-style: normal; }
        tt     { color: #036; }
        tt, pre, pre dfn, pre em, pre cite, pre span {
                font-family: "Courier New", Courier, monospace; font-size: small;
        }
        pre {
                text-align: left; padding: 4px;
                color: #000; background-color: #CCC;
        }
        pre dfn  { color: #900; }
        pre em   { color: #66F; background-color: #FFC; font-weight: normal; }
        pre .key { color: #33C; font-weight: bold; }
        pre .id  { color: #900; }
        pre .str { color: #000; background-color: #CFF; }
        pre .val { color: #066; }
        pre .rep { color: #909; }
        pre .oth { color: #000; background-color: #FCF; }
        pre .err { background-color: #FCC; }

        /* RFC-2629 <texttable>s. */
        table.all, table.full, table.headers, table.none {
                font-size: small; text-align: center; border-width: 2px;
                vertical-align: top; border-collapse: collapse;
        }
        table.all, table.full { border-style: solid; border-color: black; }
        table.headers, table.none { border-style: none; }
        th {
                font-weight: bold; border-color: black;
                border-width: 2px 2px 3px 2px;
        }
        table.all th, table.full th { border-style: solid; }
        table.headers th { border-style: none none solid none; }
        table.none th { border-style: none; }
        table.all td {
                border-style: solid; border-color: #333;
                border-width: 1px 2px;
        }
        table.full td, table.headers td, table.none td { border-style: none; }

        hr { height: 1px; }
        hr.insert {
                width: 80%; border-style: none; border-width: 0;
                color: #CCC; background-color: #CCC;
        }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="2" width="30" align="right">
    <tr>
        <td class="RFCbug">
                <span class="RFC">&nbsp;RFC&nbsp;</span><br /><span class="hotText">&nbsp;6121&nbsp;</span>
        </td>
    </tr>
    <tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a><br /></td></tr>
</table>
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
<tr><td class="header">Internet Engineering Task Force (IETF)</td><td class="header">P. Saint-Andre</td></tr>
<tr><td class="header">Request for Comments: 6121</td><td class="header">Cisco</td></tr>
<tr><td class="header">Obsoletes: <a href='http://tools.ietf.org/html/rfc3921'>3921</a></td><td class="header">March 2011</td></tr>
<tr><td class="header">Category: Standards Track</td><td class="header">&nbsp;</td></tr>
<tr><td class="header">ISSN: 2070-1721</td><td class="header">&nbsp;</td></tr>
</table></td></tr></table>
<h1><br />Extensible Messaging and Presence Protocol
    (XMPP): Instant&nbsp;Messaging&nbsp;and&nbsp;Presence</h1>

<h3>Abstract</h3>

<p>This document defines extensions to core features of the Extensible Messaging and Presence Protocol (XMPP) that provide basic instant messaging (IM) and presence functionality in conformance with the requirements in RFC 2779.  This document obsoletes RFC 3921.
</p>
<h3>Status of This Memo</h3>
<p>
This is an Internet Standards Track document.</p>
<p>
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.</p>
<p>
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc6121.</p>

<h3>Copyright Notice</h3>
<p>
Copyright (c) 2011 IETF Trust and the persons identified as the
document authors.  All rights reserved.</p>
<p>
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document.  Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.</p>
<a name="toc"></a><hr />

<table border="0" cellpadding="0" cellspacing="2" width="30" align="right">
    <tr>
        <td class="RFCbug">
                <span class="RFC">&nbsp;RFC&nbsp;</span><br /><span class="hotText">&nbsp;6121&nbsp;</span>
        </td>
    </tr>
    <tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a><br /></td></tr>
</table>
<h3>Table of Contents</h3>
<p class="toc">
<a href="#intro">1.</a>&nbsp;
Introduction<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-overview">1.1.</a>&nbsp;
Overview<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-history">1.2.</a>&nbsp;
History<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-requirements">1.3.</a>&nbsp;
Requirements<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-summary">1.4.</a>&nbsp;
Functional Summary<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-terms">1.5.</a>&nbsp;
Terminology<br />
<a href="#roster">2.</a>&nbsp;
Managing the Roster<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax">2.1.</a>&nbsp;
Syntax and Semantics<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-ver">2.1.1.</a>&nbsp;
Ver Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items">2.1.2.</a>&nbsp;
Roster Items<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-approved">2.1.2.1.</a>&nbsp;
Approved Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-ask">2.1.2.2.</a>&nbsp;
Ask Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-jid">2.1.2.3.</a>&nbsp;
JID Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-name">2.1.2.4.</a>&nbsp;
Name Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-subscription">2.1.2.5.</a>&nbsp;
Subscription Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-items-group">2.1.2.6.</a>&nbsp;
Group Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-actions-get">2.1.3.</a>&nbsp;
Roster Get<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-actions-result">2.1.4.</a>&nbsp;
Roster Result<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-actions-set">2.1.5.</a>&nbsp;
Roster Set<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-syntax-actions-push">2.1.6.</a>&nbsp;
Roster Push<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-login">2.2.</a>&nbsp;
Retrieving the Roster on Login<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-add">2.3.</a>&nbsp;
Adding a Roster Item<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-add-request">2.3.1.</a>&nbsp;
Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-add-success">2.3.2.</a>&nbsp;
Success Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-add-errors">2.3.3.</a>&nbsp;
Error Cases<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-update">2.4.</a>&nbsp;
Updating a Roster Item<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-update-request">2.4.1.</a>&nbsp;
Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-update-success">2.4.2.</a>&nbsp;
Success Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-update-error">2.4.3.</a>&nbsp;
Error Cases<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-delete">2.5.</a>&nbsp;
Deleting a Roster Item<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-delete-request">2.5.1.</a>&nbsp;
Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-delete-success">2.5.2.</a>&nbsp;
Success Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-delete-error">2.5.3.</a>&nbsp;
Error Cases<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-versioning">2.6.</a>&nbsp;
Roster Versioning<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-versioning-feature">2.6.1.</a>&nbsp;
Stream Feature<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-versioning-request">2.6.2.</a>&nbsp;
Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#roster-versioning-success">2.6.3.</a>&nbsp;
Success Case<br />
<a href="#sub">3.</a>&nbsp;
Managing Presence Subscriptions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request">3.1.</a>&nbsp;
Requesting a Subscription<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-gen">3.1.1.</a>&nbsp;
Client Generation of Outbound Subscription Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-outbound">3.1.2.</a>&nbsp;
Server Processing of Outbound Subscription Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-inbound">3.1.3.</a>&nbsp;
Server Processing of Inbound Subscription Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-handle">3.1.4.</a>&nbsp;
Client Processing of Inbound Subscription Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-approvalout">3.1.5.</a>&nbsp;
Server Processing of Outbound Subscription Approval<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-request-approvalin">3.1.6.</a>&nbsp;
Server Processing of Inbound Subscription Approval<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-cancel">3.2.</a>&nbsp;
Canceling a Subscription<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-cancel-gen">3.2.1.</a>&nbsp;
Client Generation of Subscription Cancellation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-cancel-outbound">3.2.2.</a>&nbsp;
Server Processing of Outbound Subscription Cancellation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-cancel-inbound">3.2.3.</a>&nbsp;
Server Processing of Inbound Subscription Cancellation<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-unsub">3.3.</a>&nbsp;
Unsubscribing<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-unsub-gen">3.3.1.</a>&nbsp;
Client Generation of Unsubscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-unsub-outbound">3.3.2.</a>&nbsp;
Server Processing of Outbound Unsubscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-unsub-inbound">3.3.3.</a>&nbsp;
Server Processing of Inbound Unsubscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-preapproval">3.4.</a>&nbsp;
Pre-Approving a Subscription Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-preapproval-gen">3.4.1.</a>&nbsp;
Client Generation of Subscription Pre-Approval<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sub-preapproval-proc">3.4.2.</a>&nbsp;
Server Processing of Subscription Pre-Approval<br />
<a href="#presence">4.</a>&nbsp;
Exchanging Presence Information<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-fundamentals">4.1.</a>&nbsp;
Presence Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-initial">4.2.</a>&nbsp;
Initial Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-initial-gen">4.2.1.</a>&nbsp;
Client Generation of Initial Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-initial-outbound">4.2.2.</a>&nbsp;
Server Processing of Outbound Initial Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-initial-inbound">4.2.3.</a>&nbsp;
Server Processing of Inbound Initial Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-initial-client">4.2.4.</a>&nbsp;
Client Processing of Initial Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-probe">4.3.</a>&nbsp;
Presence Probes<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-probe-outbound">4.3.1.</a>&nbsp;
Server Generation of Outbound Presence Probe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-probe-inbound">4.3.2.</a>&nbsp;
Server Processing of Inbound Presence Probe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-probe-inbound-id">4.3.2.1.</a>&nbsp;
Handling of the 'id' Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-broadcast">4.4.</a>&nbsp;
Subsequent Presence Broadcast<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-broadcast-gen">4.4.1.</a>&nbsp;
Client Generation of Subsequent Presence Broadcast<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-broadcast-outbound">4.4.2.</a>&nbsp;
Server Processing of Subsequent Outbound Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-broadcast-inbound">4.4.3.</a>&nbsp;
Server Processing of Subsequent Inbound Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-broadcast-client">4.4.4.</a>&nbsp;
Client Processing of Subsequent Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-unavailable">4.5.</a>&nbsp;
Unavailable Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-unavailable-gen">4.5.1.</a>&nbsp;
Client Generation of Unavailable Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-unavailable-outbound">4.5.2.</a>&nbsp;
Server Processing of Outbound Unavailable Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-unavailable-inbound">4.5.3.</a>&nbsp;
Server Processing of Inbound Unavailable Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-unavailable-client">4.5.4.</a>&nbsp;
Client Processing of Unavailable Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed">4.6.</a>&nbsp;
Directed Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-considerations">4.6.1.</a>&nbsp;
General Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-gen">4.6.2.</a>&nbsp;
Client Generation of Directed Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-outbound">4.6.3.</a>&nbsp;
Server Processing of Outbound Directed Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-inbound">4.6.4.</a>&nbsp;
Server Processing of Inbound Directed Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-client">4.6.5.</a>&nbsp;
Client Processing of Inbound Directed Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-directed-probe">4.6.6.</a>&nbsp;
Server Processing of Presence Probes<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax">4.7.</a>&nbsp;
Presence Syntax<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax-type">4.7.1.</a>&nbsp;
Type Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax-children">4.7.2.</a>&nbsp;
Child Elements<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax-children-show">4.7.2.1.</a>&nbsp;
Show Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax-children-status">4.7.2.2.</a>&nbsp;
Status Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-syntax-children-priority">4.7.2.3.</a>&nbsp;
Priority Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#presence-extended">4.7.3.</a>&nbsp;
Extended Content<br />
<a href="#message">5.</a>&nbsp;
Exchanging Messages<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-chat">5.1.</a>&nbsp;
One-to-One Chat Sessions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax">5.2.</a>&nbsp;
Message Syntax<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-to">5.2.1.</a>&nbsp;
To Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-type">5.2.2.</a>&nbsp;
Type Attribute<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-body">5.2.3.</a>&nbsp;
Body Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-subject">5.2.4.</a>&nbsp;
Subject Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-thread">5.2.5.</a>&nbsp;
Thread Element<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#message-syntax-extended">5.3.</a>&nbsp;
Extended Content<br />
<a href="#iq">6.</a>&nbsp;
Exchanging IQ Stanzas<br />
<a href="#session">7.</a>&nbsp;
A Sample Session<br />
<a href="#rules">8.</a>&nbsp;
Server Rules for Processing XML Stanzas<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-general">8.1.</a>&nbsp;
General Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-noto">8.2.</a>&nbsp;
No 'to' Address<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-remote">8.3.</a>&nbsp;
Remote Domain<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local">8.4.</a>&nbsp;
Local Domain<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart">8.5.</a>&nbsp;
Local User<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-nosuchuser">8.5.1.</a>&nbsp;
No Such User<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-barejid">8.5.2.</a>&nbsp;
localpart@domainpart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-barejid-resource">8.5.2.1.</a>&nbsp;
Available or Connected Resources<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-barejid-noresource">8.5.2.2.</a>&nbsp;
No Available or Connected Resources<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-fulljid">8.5.3.</a>&nbsp;
localpart@domainpart/resourcepart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-fulljid-match">8.5.3.1.</a>&nbsp;
Resource Matches<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-localpart-fulljid-nomatch">8.5.3.2.</a>&nbsp;
No Resource Matches<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-message">8.5.4.</a>&nbsp;
Summary of Message Delivery Rules<br />
<a href="#uri">9.</a>&nbsp;
Handling of URIs<br />
<a href="#i18n">10.</a>&nbsp;
Internationalization Considerations<br />
<a href="#security">11.</a>&nbsp;
Security Considerations<br />
<a href="#conformance">12.</a>&nbsp;
Conformance Requirements<br />
<a href="#rfc.references1">13.</a>&nbsp;
References<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references1">13.1.</a>&nbsp;
Normative References<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references2">13.2.</a>&nbsp;
Informative References<br />
<a href="#substates">Appendix&nbsp;A.</a>&nbsp;
Subscription States<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-defined">A.1.</a>&nbsp;
Defined States<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-out">A.2.</a>&nbsp;
Server Processing of Outbound Presence Subscription Stanzas<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-out-subscribe">A.2.1.</a>&nbsp;
Subscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-out-unsubscribe">A.2.2.</a>&nbsp;
Unsubscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-out-subscribed">A.2.3.</a>&nbsp;
Subscribed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-out-unsubscribed">A.2.4.</a>&nbsp;
Unsubscribed<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-in">A.3.</a>&nbsp;
Server Processing of Inbound Presence Subscription Stanzas<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-in-subscribe">A.3.1.</a>&nbsp;
Subscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-in-unsubscribe">A.3.2.</a>&nbsp;
Unsubscribe<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-in-subscribed">A.3.3.</a>&nbsp;
Subscribed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#substates-in-unsubscribed">A.3.4.</a>&nbsp;
Unsubscribed<br />
<a href="#blocking">Appendix&nbsp;B.</a>&nbsp;
Blocking Communication<br />
<a href="#vcard">Appendix&nbsp;C.</a>&nbsp;
vCards<br />
<a href="#schema">Appendix&nbsp;D.</a>&nbsp;
XML Schema for jabber:iq:roster<br />
<a href="#diffs">Appendix&nbsp;E.</a>&nbsp;
Differences From RFC 3921<br />
<a href="#acks">Appendix&nbsp;F.</a>&nbsp;
Acknowledgements<br />
</p>
<br clear="all" />

<a name="intro"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1"></a><h3>1.&nbsp;
Introduction</h3>

<a name="intro-overview"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.1"></a><h3>1.1.&nbsp;
Overview</h3>

<p>The Extensible Messaging and Presence Protocol (XMPP) is an application profile of the Extensible Markup Language <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a> that enables the near-real-time exchange of structured yet extensible data between any two or more network entities.  The core features of XMPP defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> provide the building blocks for many types of near-real-time applications, which can be layered on top of the core by sending application-specific data qualified by particular XML namespaces (refer to <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Bray, T., Hollander, D., and A. Layman, &ldquo;Namespaces in XML,&rdquo; January&nbsp;1999.</span><span>)</span></a>).  This document defines XMPP extensions that provide the basic functionality expected of an instant messaging (IM) and presence application as described in <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a>.
</p>
<a name="intro-history"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.2"></a><h3>1.2.&nbsp;
History</h3>

<p>The basic syntax and semantics of XMPP were developed originally within the Jabber open-source community, mainly in 1999.  In late 2002, the XMPP Working Group was chartered with developing an adaptation of the core Jabber protocol that would be suitable as an IETF IM and presence technology in accordance with <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a>.  In October 2004, <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> and <a class='info' href='#RFC3921'>[RFC3921]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; October&nbsp;2004.</span><span>)</span></a> were published, representing the most complete definition of XMPP at that time.
</p>
<p>Since 2004 the Internet community has gained extensive implementation and deployment experience with XMPP, including formal interoperability testing carried out under the auspices of the XMPP Standards Foundation (XSF).  This document incorporates comprehensive feedback from software developers and service providers, including a number of backward-compatible modifications summarized under <a class='info' href='#diffs'>Appendix&nbsp;E<span> (</span><span class='info'>Differences From RFC 3921</span><span>)</span></a>.  As a result, this document reflects the rough consensus of the Internet community regarding the IM and presence features of XMPP 1.0, thus obsoleting RFC 3921.
</p>
<a name="intro-requirements"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.3"></a><h3>1.3.&nbsp;
Requirements</h3>

<p>Traditionally, IM applications have combined the following factors:
</p>
<p>
        </p>
<ol class="text">
<li>The central point of focus is a list of one's contacts or "buddies" (in XMPP this list is called a "roster").
</li>
<li>The purpose of using such an application is to exchange relatively brief text messages with particular contacts in close to real time -- often relatively large numbers of such messages in rapid succession, in the form of a one-to-one "chat session" as described under <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a>.
</li>
<li>The catalyst for exchanging messages is "presence" -- i.e., information about the network availability of particular contacts (thus knowing who is online and available for a one-to-one chat session).
</li>
<li>Presence information is provided only to contacts that one has authorized by means of an explicit agreement called a "presence subscription".
</li>
</ol><p>
      
</p>
<p>Thus at a high level this document assumes that a user needs to be able to complete the following use cases:
</p>
<p>
        </p>
<ul class="text">
<li>Manage items in one's contact list
</li>
<li>Exchange messages with one's contacts
</li>
<li>Exchange presence information with one's contacts
</li>
<li>Manage presence subscriptions to and from one's contacts
</li>
</ul><p>
      
</p>
<p>Detailed definitions of these functionality areas are contained in RFC 2779 <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a>, and the interested reader is referred to that document regarding in-depth requirements.  Although the XMPP IM and presence extensions specified herein meet the requirements of RFC 2779, they were not designed explicitly with that specification in mind, since the base protocol evolved through an open development process within the Jabber open-source community before RFC 2779 was written.  Although XMPP protocol extensions addressing many other functionality areas have been defined in the XMPP Standards Foundation's XEP series (e.g., multi-user text chat as specified in <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2008.</span><span>)</span></a>), such extensions are not specified in this document because they are not mandated by RFC 2779.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: RFC 2779 stipulates that presence services must be separable from IM services and vice-versa; i.e., it must be possible to use the protocol to provide a presence service, a messaging service, or both.  Although the text of this document assumes that implementations and deployments will want to offer a unified IM and presence service, it is not mandatory for an XMPP service to offer both a presence service and a messaging service, and the protocol makes it possible to offer separate and distinct services for presence and for messaging.  (For example, a presence-only service could return a &lt;service-unavailable/&gt; stanza error if a client attempts to send a &lt;message/&gt; stanza.)
</p>
</blockquote>

<a name="intro-summary"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.4"></a><h3>1.4.&nbsp;
Functional Summary</h3>

<p>This non-normative section provides a developer-friendly, functional summary of XMPP-based IM and presence features; consult the sections that follow for a normative definition of these features.
</p>
<p><a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> specifies how an XMPP client connects to an XMPP server.  In particular, it specifies the preconditions that need to be fulfilled before a client is allowed to send XML stanzas (the basic unit of meaning in XMPP) to other entities on an XMPP network.  These preconditions comprise negotiation of the XML stream and include exchange of XML stream headers, optional channel encryption via Transport Layer Security <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>, mandatory authentication via Simple Authentication and Security Layer <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>, and binding of a resource to the stream for client addressing.  The reader is referred to <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> for details regarding these preconditions, and knowledge of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> is assumed herein.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: <a class='info' href='#RFC3921'>[RFC3921]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; October&nbsp;2004.</span><span>)</span></a> specified one additional precondition: formal establishment of an instant messaging and presence session.  Implementation and deployment experience has shown that this additional step is unnecessary.  However, for backward compatibility an implementation MAY still offer that feature.  This enables older software to connect while letting newer software save a round trip.
</p>
</blockquote>

<p>Upon fulfillment of the preconditions specified in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, an XMPP client has a long-lived XML stream with an XMPP server, which enables the user controlling that client to send and receive a potentially unlimited number of XML stanzas over the stream.  Such a stream can be used to exchange messages, share presence information, and engage in structured request-response interactions in close to real time.  After negotiation of the XML stream, the typical flow for an instant messaging and presence session is as follows:
</p>
<p>
        </p>
<ol class="text">
<li>Retrieve one's roster.  (See <a class='info' href='#roster-login'>Section&nbsp;2.2<span> (</span><span class='info'>Retrieving the Roster on Login</span><span>)</span></a>.)
</li>
<li>Send initial presence to the server for broadcast to all subscribed contacts, thus "going online" from the perspective of XMPP communication.  (See <a class='info' href='#presence-initial'>Section&nbsp;4.2<span> (</span><span class='info'>Initial Presence</span><span>)</span></a>.)
</li>
<li>Exchange messages, manage presence subscriptions, perform roster
updates, and in general process and generate other XML stanzas with particular
semantics throughout the life of the session.  (See Sections <a class='info' href='#message'>5<span> (</span><span class='info'>Exchanging Messages</span><span>)</span></a>, <a class='info' href='#sub'>3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>,
<a class='info' href='#roster'>2<span> (</span><span class='info'>Managing the Roster</span><span>)</span></a>, and <a class='info' href='#iq'>6<span> (</span><span class='info'>Exchanging IQ Stanzas</span><span>)</span></a>.)
</li>
<li>Terminate the session when desired by sending unavailable presence and closing the underlying XML stream. (See <a class='info' href='#presence-unavailable'>Section&nbsp;4.5<span> (</span><span class='info'>Unavailable Presence</span><span>)</span></a>.)
</li>
</ol><p>
      
</p>
<a name="intro-terms"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.5"></a><h3>1.5.&nbsp;
Terminology</h3>

<p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 <a class='info' href='#KEYWORDS'>[KEYWORDS]<span> (</span><span class='info'>Bradner, S., &ldquo;Key words for use in RFCs to Indicate Requirement Levels,&rdquo; March&nbsp;1997.</span><span>)</span></a>.
</p>
<p>This document inherits the terminology defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>The terms "automated client" and "interactive client" are to be understood in the sense defined in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>For convenience, this document employs the term "user" to refer to the owner of an XMPP account; however, account owners need not be humans and can be bots, devices, or other automated applications.
</p>
<p>Several other terms, such as "interested resource", are defined within the body of this document.
</p>
<p>Following the "XML Notation" used in <a class='info' href='#IRI'>[IRI]<span> (</span><span class='info'>Duerst, M. and M. Suignard, &ldquo;Internationalized Resource Identifiers (IRIs),&rdquo; January&nbsp;2005.</span><span>)</span></a> to represent characters that cannot be rendered in ASCII-only documents, some examples in this document use the form "&amp;#x...." as a notational device to represent <a class='info' href='#UNICODE'>[UNICODE]<span> (</span><span class='info'>The Unicode Consortium, &ldquo;The Unicode Standard, Version 6.0,&rdquo; 2010.</span><span>)</span></a> characters (e.g., the string "&amp;#x0159;" stands for the Unicode character LATIN SMALL LETTER R WITH CARON); this form is definitely not to be sent over the wire in XMPP systems.
</p>
<p>In examples, lines have been wrapped for improved readability, "[...]" means elision, and the following prepended strings are used (these prepended strings are not to be sent over the wire):
</p>
<p>
        </p>
<ul class="text">
<li>C: = client
</li>
<li>CC: = contact's client
</li>
<li>CS: = contact's server
</li>
<li>S: = server
</li>
<li>UC: = user's client
</li>
<li>US: = user's server
</li>
</ul><p>
      
</p>
<p>Readers need to be aware that the examples are not exhaustive
      and that, in examples for some protocol flows, the alternate
      steps shown would not necessarily be triggered by the exact data
      sent in the previous step; in all cases, the protocol definitions specified in this document or in normatively referenced documents rule over any examples provided here.  All examples are fictional and the information exchanged (e.g., usernames and passwords) does not represent any existing users or servers.
</p>
<a name="roster"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2"></a><h3>2.&nbsp;
Managing the Roster</h3>

<p>In XMPP, a user's roster contains any number of specific contacts.  A user's roster is stored by the user's server on the user's behalf so that the user can access roster information from any device.  When the user adds items to the roster or modifies existing items, if an error does not occur then the server SHOULD store that data unmodified if at all possible and MUST return the data it has stored when an authorized client requests the roster.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Because the user's roster can contain confidential data, the server MUST restrict access to this data so that only authorized entities (typically limited to the account owner) are able to retrieve, modify, or delete it.
</p>
</blockquote>

<p>RFC 3921 assumed that the only place where a user stores their roster is the server where the user's account is registered and at which the user authenticates for access to the XMPP network.  This specification removes that strict coupling of roster storage to account registration and network authentication, with the result that a user could store their roster at another location, or could have multiple rosters that are stored in multiple locations.  However, in the absence of implementation and deployment experience with a more flexible roster storage model, this specification retains the terminology of RFC 3921 by using the terms "client" and "server" (and "the roster" instead of "a roster"), rather than coining a new term for "a place where a user stores a roster".  Future documents might provide normative rules for non-server roster storage or for the management of multiple rosters, but such rules are out of scope for this document.
</p>
<a name="roster-syntax"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1"></a><h3>2.1.&nbsp;
Syntax and Semantics</h3>

<p>Rosters are managed using &lt;iq/&gt; stanzas (see Section 8.2.3 of
<a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>), specifically by means of a &lt;query/&gt; child element qualified by the 'jabber:iq:roster' namespace.  The detailed syntax and semantics are defined in the following sections.
</p>
<a name="roster-syntax-ver"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.1"></a><h3>2.1.1.&nbsp;
Ver Attribute</h3>

<p>The 'ver' attribute is a string that identifies a particular version of the roster information.  The value MUST be generated only by the server and MUST be treated by the client as opaque.  The server can use any appropriate method for generating the version ID, such as a hash of the roster data or a strictly increasing sequence number.
</p>
<p>Inclusion of the 'ver' attribute is RECOMMENDED.
</p>
<p>Use of the 'ver' attribute is described more fully under <a class='info' href='#roster-versioning'>Section&nbsp;2.6<span> (</span><span class='info'>Roster Versioning</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: The 'ver' attribute of the &lt;query/&gt; element was not defined in RFC 3921 and is newly defined in this specification.
</p>
</blockquote>

<a name="roster-syntax-items"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2"></a><h3>2.1.2.&nbsp;
Roster Items</h3>

<p>The &lt;query/&gt; element inside a <a class='info' href='#roster-syntax-actions-set'>roster set<span> (</span><span class='info'>Roster Set</span><span>)</span></a> contains one &lt;item/&gt; child, and a <a class='info' href='#roster-syntax-actions-result'>roster result<span> (</span><span class='info'>Roster Result</span><span>)</span></a> typically contains multiple &lt;item/&gt; children.  Each &lt;item/&gt; element describes a unique "roster item" (sometimes also called a "contact").
</p>
<p>The syntax of the &lt;item/&gt; element is described in the following sections.
</p>
<a name="roster-syntax-items-approved"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.1"></a><h3>2.1.2.1.&nbsp;
Approved Attribute</h3>

<p>The boolean 'approved' attribute with a value of "true" is used to signal subscription pre-approval as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a> (the default is "false", in accordance with <a class='info' href='#XML-DATATYPES'>[XML&#8209;DATATYPES]<span> (</span><span class='info'>Biron, P. and A. Malhotra, &ldquo;XML Schema Part 2: Datatypes Second Edition,&rdquo; October&nbsp;2004.</span><span>)</span></a>).
</p>
<p>A server SHOULD include the 'approved' attribute to inform the client of subscription pre-approvals.  A client MUST NOT include the 'approved' attribute in the roster sets it sends to the server, but instead MUST use presence stanzas of type "subscribed" and "unsubscribed" to manage pre-approvals as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: The 'approved' attribute of the &lt;item/&gt; element was not defined in RFC 3921 and is newly defined in this specification.
</p>
</blockquote>

<a name="roster-syntax-items-ask"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.2"></a><h3>2.1.2.2.&nbsp;
Ask Attribute</h3>

<p>The 'ask' attribute of the &lt;item/&gt; element with a value of "subscribe" is used to signal various subscription sub-states that include a "Pending Out" aspect as described under <a class='info' href='#sub-request-outbound'>Section&nbsp;3.1.2<span> (</span><span class='info'>Server Processing of Outbound Subscription Request</span><span>)</span></a>.
</p>
<p>A server SHOULD include the 'ask' attribute to inform the client of "Pending Out" sub-states.  A client MUST NOT include the 'ask' attribute in the roster sets it sends to the server, but instead MUST use presence stanzas of type "subscribe" and "unsubscribe" to manage such sub-states as described under <a class='info' href='#sub-request-outbound'>Section&nbsp;3.1.2<span> (</span><span class='info'>Server Processing of Outbound Subscription Request</span><span>)</span></a>.
</p>
<a name="roster-syntax-items-jid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.3"></a><h3>2.1.2.3.&nbsp;
JID Attribute</h3>

<p>The 'jid' attribute of the &lt;item/&gt; element specifies the Jabber Identifier (JID) that uniquely identifies the roster item.
</p>
<p>The 'jid' attribute is REQUIRED whenever a client or server adds, updates, deletes, or returns a roster item.
</p>
<a name="roster-syntax-items-name"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.4"></a><h3>2.1.2.4.&nbsp;
Name Attribute</h3>

<p>The 'name' attribute of the &lt;item/&gt; element specifies the "handle" to be associated with the JID, as determined by the user (not the contact).  Although the value of the 'name' attribute MAY have meaning to a human user, it is opaque to the server.  However, the 'name' attribute MAY be used by the server for matching purposes within the context of various XMPP extensions (one possible comparison method is that described for XMPP resourceparts in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p>
<p>It is OPTIONAL for a client to include the 'name' attribute when adding or updating a roster item.
</p>
<a name="roster-syntax-items-subscription"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.5"></a><h3>2.1.2.5.&nbsp;
Subscription Attribute</h3>

<p>The state of the presence subscription is captured in the 'subscription' attribute of the &lt;item/&gt; element.  The defined subscription-related values are:
</p>
<p>
            </p>
<blockquote class="text"><dl>
<dt>none:</dt>
<dd>the user does not have a subscription to the contact's presence, and the contact does not have a subscription to the user's presence; this is the default value, so if the subscription attribute is not included then the state is to be understood as "none"
</dd>
<dt>to:</dt>
<dd>the user has a subscription to the contact's presence, but the contact does not have a subscription to the user's presence
</dd>
<dt>from:</dt>
<dd>the contact has a subscription to the user's presence, but the user does not have a subscription to the contact's presence
</dd>
<dt>both:</dt>
<dd>the user and the contact have subscriptions to each other's presence (also called a "mutual subscription")
</dd>
</dl></blockquote><p>
          
</p>
<p>In a <a class='info' href='#roster-syntax-actions-result'>roster result<span> (</span><span class='info'>Roster Result</span><span>)</span></a>, the client MUST ignore values of the 'subscription' attribute other than "none", "to", "from", or "both".
</p>
<p>In a <a class='info' href='#roster-syntax-actions-push'>roster push<span> (</span><span class='info'>Roster Push</span><span>)</span></a>, the client MUST ignore values of the 'subscription' attribute other than "none", "to", "from", "both", or "remove".
</p>
<p>In a <a class='info' href='#roster-syntax-actions-set'>roster set<span> (</span><span class='info'>Roster Set</span><span>)</span></a>, the 'subscription' attribute MAY be included with a value of "remove", which indicates that the item is to be removed from the roster; in a roster set the server MUST ignore all values of the 'subscription' attribute other than "remove".
</p>
<p>Inclusion of the 'subscription' attribute is OPTIONAL.
</p>
<a name="roster-syntax-items-group"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.2.6"></a><h3>2.1.2.6.&nbsp;
Group Element</h3>

<p>The &lt;group/&gt; child element specifies a category or "bucket" into which the roster item is to be grouped by a client.  An &lt;item/&gt; element MAY contain more than one &lt;group/&gt; element, which means that roster groups are not exclusive.  Although the XML character data of the &lt;group/&gt; element MAY have meaning to a human user, it is opaque to the server.  However, the &lt;group/&gt; element MAY be used by the server for matching purposes within the context of various XMPP extensions (one possible comparison method is that described for XMPP resourceparts in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p>
<p>It is OPTIONAL for a client to include the &lt;group/&gt; element when adding or updating a roster item.  If a <a class='info' href='#roster-syntax-actions-set'>roster set<span> (</span><span class='info'>Roster Set</span><span>)</span></a> includes no &lt;group/&gt; element, then the item is to be interpreted as being affiliated with no group.
</p>
<a name="roster-syntax-actions-get"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.3"></a><h3>2.1.3.&nbsp;
Roster Get</h3>

<p>A "roster get" is a client's request for the server to return the roster; syntactically it is an IQ stanza of type "get" sent from client to server and containing a &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace, where the &lt;query/&gt; element MUST NOT contain any &lt;item/&gt; child elements.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='bv1bs71f'
       type='get'&gt;
    &lt;query xmlns='jabber:iq:roster'/&gt;
  &lt;/iq&gt;
</pre></div>
<p>The expected outcome of sending a roster get is for the server to return a roster result.
</p>
<a name="roster-syntax-actions-result"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.4"></a><h3>2.1.4.&nbsp;
Roster Result</h3>

<p>A "roster result" is the server's response to a roster get; syntactically it is an IQ stanza of type "result" sent from server to client and containing a &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace.
</p>
<p>The &lt;query/&gt; element in a roster result contains one &lt;item/&gt; element for each contact and therefore can contain more than one &lt;item/&gt; element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='bv1bs71f'
       to='juliet@example.com/chamber'
       type='result'&gt;
    &lt;query xmlns='jabber:iq:roster' ver='ver7'&gt;
      &lt;item jid='nurse@example.com'/&gt;
      &lt;item jid='romeo@example.net'/&gt;
    &lt;/query&gt;
  &lt;/iq&gt;
</pre></div>
<p>If the roster exists but there are no contacts in the roster, then the server MUST return an IQ-result containing a child &lt;query/&gt; element that in turn contains no &lt;item/&gt; children (i.e., the server MUST NOT return an empty &lt;iq/&gt; stanza of type "error").
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='bv1bs71f'
       to='juliet@example.com/chamber'
       type='result'&gt;
    &lt;query xmlns='jabber:iq:roster' ver='ver9'/&gt;
  &lt;/iq&gt;
</pre></div>
<p>If the roster does not exist, then the server MUST return a stanza error with a condition of &lt;item-not-found/&gt;.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='bv1bs71f'
       to='juliet@example.com/chamber'
       type='error'&gt;
    &lt;error type='cancel'&gt;
      &lt;item-not-found
          xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;/error&gt;
  &lt;/iq&gt;
</pre></div>
<a name="roster-syntax-actions-set"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.5"></a><h3>2.1.5.&nbsp;
Roster Set</h3>

<p>A "roster set" is a client's request for the server to modify (i.e., create, update, or delete) a roster item; syntactically it is an IQ stanza of type "set" sent from client to server and containing a &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace.
</p>
<p>The following rules apply to roster sets:
</p>
<p>
          </p>
<ol class="text">
<li>The &lt;query/&gt; element MUST contain one and only one &lt;item/&gt; element.
</li>
<li>The server MUST ignore any value of the 'subscription' attribute other than "remove" (see <a class='info' href='#roster-syntax-items-subscription'>Section&nbsp;2.1.2.5<span> (</span><span class='info'>Subscription Attribute</span><span>)</span></a>).
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Traditionally, the IQ stanza of the roster set included no 'to' address, with the result that all roster sets were sent from an authenticated resource (full JID) of the account whose roster was being updated.  Furthermore, RFC 3921 required a server to perform special-case checking of roster sets to ignore the 'to' address; however, this specification has removed that special-casing, which means that a roster set might include a 'to' address other than that of the sender.  Therefore, the entity that processes a roster set MUST verify that the sender of the roster set is authorized to update the roster, and if not return a &lt;forbidden/&gt; error.
</p>
</blockquote>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='rs1'
       type='set'&gt;
    &lt;query xmlns='jabber:iq:roster'&gt;
      &lt;item jid='nurse@example.com'/&gt;
    &lt;/query&gt;
  &lt;/iq&gt;
</pre></div>
<a name="roster-syntax-actions-push"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1.6"></a><h3>2.1.6.&nbsp;
Roster Push</h3>

<p>A "roster push" is a newly created, updated, or deleted roster item that is sent from the server to the client; syntactically it is an IQ stanza of type "set" sent from server to client and containing a &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace.
</p>
<p>The following rules apply to roster pushes:
</p>
<p>
          </p>
<ol class="text">
<li>The &lt;query/&gt; element in a roster push MUST contain one and only one &lt;item/&gt; element.
</li>
<li>A receiving client MUST ignore the stanza unless it has no 'from' attribute (i.e., implicitly from the bare JID of the user's account) or it has a 'from' attribute whose value matches the user's bare JID &lt;user@domainpart&gt;.
</li>
</ol><p>
        
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='a78b4q6ha463'
       to='juliet@example.com/chamber'
       type='set'&gt;
    &lt;query xmlns='jabber:iq:roster'&gt;
      &lt;item jid='nurse@example.com'/&gt;
    &lt;/query&gt;
  &lt;/iq&gt;
</pre></div>
<p>As mandated by the semantics of the IQ stanza as defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, each resource that receives a roster push from the server is supposed to reply with an IQ stanza of type "result" or "error" (however, it is known that many existing clients do not reply to roster pushes).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='a78b4q6ha463'
       type='result'/&gt;

C: &lt;iq from='juliet@example.com/chamber'
       id='a78b4q6ha463'
       type='result'/&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: Traditionally, a roster push included no 'from' address, with the result that all roster pushes were sent implicitly from the bare JID of the account itself.  However, this specification allows entities other than the user's server to maintain roster information, which means that a roster push might include a 'from' address other than the bare JID of the user's account.  Therefore, the client MUST check the 'from' address to verify that the sender of the roster push is authorized to update the roster.  If the client receives a roster push from an unauthorized entity, it MUST NOT process the pushed data; in addition, the client can either return a stanza error of &lt;service-unavailable/&gt; error or refuse to return a stanza error at all (the latter behavior overrides a MUST-level requirement from <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> for the purpose of preventing a presence leak).
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: There is no error case for client processing of roster pushes; if the server receives an IQ of type "error" in response to a roster push then it SHOULD ignore the error.
</p>
</blockquote>

<a name="roster-login"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.2"></a><h3>2.2.&nbsp;
Retrieving the Roster on Login</h3>

<p>Upon authenticating with a server and binding a resource (thus becoming a connected resource as defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>), a client SHOULD request the roster before sending initial presence (however, because receiving the roster is not necessarily desirable for all resources, e.g., a connection with limited bandwidth, the client's request for the roster is not mandatory).  After a connected resource sends initial presence (see <a class='info' href='#presence-initial'>Section&nbsp;4.2<span> (</span><span class='info'>Initial Presence</span><span>)</span></a>), it is referred to as an "available resource".  If a connected resource or available resource requests the roster, it is referred to as an "interested resource".  The server MUST send roster pushes to all interested resources.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Presence subscription requests are sent to available resources, whereas the roster pushes associated with subscription state changes are sent to interested resources.  Therefore, if a resource wishes to receive both subscription requests and roster pushes, it MUST both send initial presence and request the roster.
</p>
</blockquote>

<p>A client requests the roster by sending a roster get over its stream with the server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='hu2bac18'
       type='get'&gt;
     &lt;query xmlns='jabber:iq:roster'/&gt;
   &lt;/iq&gt;
</pre></div><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='hu2bac18'
       to='juliet@example.com/balcony'
       type='result'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver11'&gt;
       &lt;item jid='romeo@example.net'
             name='Romeo'
             subscription='both'&gt;
         &lt;group&gt;Friends&lt;/group&gt;
       &lt;/item&gt;
       &lt;item jid='mercutio@example.com'
             name='Mercutio'
             subscription='from'/&gt;
       &lt;item jid='benvolio@example.net'
             name='Benvolio'
             subscription='both'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>If the server cannot process the roster get, it MUST return an appropriate stanza error as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> (such as &lt;service-unavailable/&gt; if the roster namespace is not supported or &lt;internal-server-error/&gt; if the server experiences trouble processing or returning the roster).
</p>
<a name="roster-add"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.3"></a><h3>2.3.&nbsp;
Adding a Roster Item</h3>

<a name="roster-add-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.3.1"></a><h3>2.3.1.&nbsp;
Request</h3>

<p>At any time, a client can add an item to the roster.  This is done by sending a roster set containing a new item.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='ph1xaz53'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<a name="roster-add-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.3.2"></a><h3>2.3.2.&nbsp;
Success Case</h3>

<p>If the server can successfully process the roster set for the new item (i.e., if no error occurs), it MUST create the item in the user's roster and proceed as follows.
</p>
<p>The server MUST return an IQ stanza of type "result" to the connected resource that sent the roster set.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='ph1xaz53'
       to='juliet@example.com/balcony'
       type='result'/&gt;
</pre></div>
<p>The server MUST also send a roster push containing the new roster item to all of the user's interested resources, including the resource that generated the roster set.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq to='juliet@example.com/balcony'
       id='a78b4q6ha463'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver13'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'
             subscription='none'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq to='juliet@example.com/chamber'
       id='x81g3bdy4n19'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver13'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'
             subscription='none'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>As mandated by the semantics of the IQ stanza as defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, each resource that receives a roster push from the server is supposed to reply with an IQ stanza of type "result" or "error" (however, it is known that many existing clients do not reply to roster pushes).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='a78b4q6ha463'
       type='result'/&gt;

C: &lt;iq from='juliet@example.com/chamber'
       id='x81g3bdy4n19'
       type='result'/&gt;
</pre></div>
<a name="roster-add-errors"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.3.3"></a><h3>2.3.3.&nbsp;
Error Cases</h3>

<p>If the server cannot successfully process the roster set, it MUST return a stanza error.  The following error cases are defined.  Naturally, other stanza errors can occur, such as &lt;internal-server-error/&gt; if the server experiences an internal problem with processing the roster get, or even &lt;not-allowed/&gt; if the server only allows roster modifications by means of a non-XMPP method such as a web interface.
</p>
<p>The server MUST return a &lt;forbidden/&gt; stanza error to the client if the sender of the roster set is not authorized to update the roster (where typically only an authenticated resource of the account itself is authorized).
</p>
<p>The server MUST return a &lt;bad-request/&gt; stanza error to the client if the roster set contains any of the following violations:
</p>
<p>
          </p>
<ol class="text">
<li>The &lt;query/&gt; element contains more than one &lt;item/&gt; child element.
</li>
<li>The &lt;item/&gt; element contains more than one &lt;group/&gt; element, but there are duplicate groups (one possible comparison method for determining duplicates is that described for XMPP resourceparts in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
</ol><p>
        
</p>
<p>The server MUST return a &lt;not-acceptable/&gt; stanza error to the client if the roster set contains any of the following violations:
</p>
<p>
          </p>
<ol class="text">
<li>The length of the 'name' attribute is greater than a server-configured limit.
</li>
<li>The XML character data of the &lt;group/&gt; element is of zero length (to remove an item from all groups, the client instead needs to exclude any &lt;group/&gt; element from the roster set).
</li>
<li>The XML character data of the &lt;group/&gt; element is larger than a server-configured limit.
</li>
</ol><p>
        
</p>
<p>Error: Roster set initiated by unauthorized entity
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='ix7s53v2'
       to='romeo@example.net'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='ix7s53v2'
       to='juliet@example.com/balcony'
       type='error'&gt;
    &lt;error type='auth'&gt;
      &lt;forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;/error&gt;
  &lt;/iq&gt;
</pre></div>
<p>Error: Roster set contains more than one item
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='nw83vcj4'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
       &lt;item jid='mother@example.com'
             name='Mom'&gt;
         &lt;group&gt;Family&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='nw83vcj4'
       to='juliet@example.com/balcony'
       type='error'&gt;
    &lt;error type='modify'&gt;
      &lt;bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;/error&gt;
  &lt;/iq&gt;
</pre></div>
<p>Error: Roster set contains item with oversized handle
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='yl491b3d'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='[ ... some-very-long-handle ... ]'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='yl491b3d'
       to='juliet@example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<p>Error: Roster set contains duplicate groups
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='tk3va749'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='tk3va749'
       to='juliet@example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<p>Error: Roster set contains empty group
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='fl3b486u'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'&gt;
         &lt;group&gt;&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='fl3b486u'
       to='juliet@example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<p>Error: Roster set contains oversized group name
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='qh3b4v19'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             name='Nurse'&gt;
         &lt;group&gt;[ ... some-very-long-group-name ... ]&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='qh3b4v19'
       to='juliet@example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Interoperability Note: Some servers return a &lt;not-allowed/&gt; stanza error to the client if the value of the &lt;item/&gt; element's 'jid' attribute matches the bare JID &lt;localpart@domainpart&gt; of the user's account.
</p>
</blockquote>

<a name="roster-update"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.4"></a><h3>2.4.&nbsp;
Updating a Roster Item</h3>

<a name="roster-update-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.4.1"></a><h3>2.4.1.&nbsp;
Request</h3>

<p>Updating an existing roster item is done in the same way as adding a new roster item, i.e., by sending a roster set to the server.  Because a roster item is atomic, the item MUST be updated exactly as provided in the roster set.
</p>
<p>There are several reasons why a client might update a roster item:
</p>
<p>
          </p>
<ol class="text">
<li>Adding a group
</li>
<li>Deleting a group
</li>
<li>Changing the handle
</li>
<li>Deleting the handle
</li>
</ol><p>
        
</p>
<p>Consider a roster item that is defined as follows:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
    &lt;item jid='romeo@example.net'
          name='Romeo'&gt;
      &lt;group&gt;Friends&lt;/group&gt;
    &lt;/item&gt;
</pre></div>
<p>The user who has this item in her roster might want to add the item to another group.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='di43b2x9'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='romeo@example.net'
             name='Romeo'&gt;
         &lt;group&gt;Friends&lt;/group&gt;
         &lt;group&gt;Lovers&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>Sometime later, the user might want to remove the item from the original group.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='lf72v157'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='romeo@example.net'
             name='Romeo'&gt;
         &lt;group&gt;Lovers&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>The user might want to remove the item from all groups.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='ju4b62a5'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='romeo@example.net'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>The user might also want to change the handle for the item.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='gb3sv487'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='romeo@example.net'
             name='MyRomeo'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>The user might then want to remove the handle altogether.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='o3bx66s5'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='romeo@example.net'
             name=''/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Implementation Note: Including an empty 'name' attribute is equivalent to including no 'name' attribute; both actions set the name to the empty string.
</p>
</blockquote>

<a name="roster-update-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.4.2"></a><h3>2.4.2.&nbsp;
Success Case</h3>

<p>As with adding a roster item, if the roster item can be successfully processed then the server MUST update the item in the user's roster, send a roster push to all of the user's interested resources, and send an IQ result to the initiating resource; details are provided under <a class='info' href='#roster-add'>Section&nbsp;2.3<span> (</span><span class='info'>Adding a Roster Item</span><span>)</span></a>.
</p>
<a name="roster-update-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.4.3"></a><h3>2.4.3.&nbsp;
Error Cases</h3>

<p>The error cases described under <a class='info' href='#roster-add-errors'>Section&nbsp;2.3.3<span> (</span><span class='info'>Error Cases</span><span>)</span></a> also apply to updating a roster item.
</p>
<a name="roster-delete"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.5"></a><h3>2.5.&nbsp;
Deleting a Roster Item</h3>

<a name="roster-delete-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.5.1"></a><h3>2.5.1.&nbsp;
Request</h3>

<p>At any time, a client can delete an item from his or her roster by sending a roster set and specifying a value of "remove" for the 'subscription' attribute.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='hm4hs97y'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='nurse@example.com'
             subscription='remove'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<a name="roster-delete-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.5.2"></a><h3>2.5.2.&nbsp;
Success Case</h3>

<p>As with adding a roster item, if the server can successfully process the roster set then it MUST update the item in the user's roster, send a roster push to all of the user's interested resources (with the 'subscription' attribute set to a value of "remove"), and send an IQ result to the initiating resource; details are provided under <a class='info' href='#roster-add'>Section&nbsp;2.3<span> (</span><span class='info'>Adding a Roster Item</span><span>)</span></a>.
</p>
<p>In addition, the user's server might need to generate one or more subscription-related presence stanzas, as follows:
</p>
<p>
          </p>
<ol class="text">
<li>If the user has a presence subscription to the contact, then the user's server MUST send a presence stanza of type "unsubscribe" to the contact (in order to unsubscribe from the contact's presence).
</li>
<li>If the contact has a presence subscription to the user, then the user's server MUST send a presence stanza of type "unsubscribed" to the contact (in order to cancel the contact's subscription to the user).
</li>
<li>If the presence subscription is mutual, then the user's server MUST send both a presence stanza of type "unsubscribe" and a presence stanza of type "unsubscribed" to the contact.
</li>
</ol><p>
        
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;presence from='juliet@example.com'
             id='lm3ba81g'
             to='nurse@example.com'
             type='unsubscribe'/&gt;

S: &lt;presence from='juliet@example.com'
             id='xb2c1v4k'
             to='nurse@example.com'
             type='unsubscribed'/&gt;
</pre></div>
<a name="roster-delete-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.5.3"></a><h3>2.5.3.&nbsp;
Error Cases</h3>

<p>If the value of the 'jid' attribute specifies an item that is not in the roster, then the server MUST return an &lt;item-not-found/&gt; stanza error.
</p>
<p>Error: Roster item not found
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@example.com/balcony'
       id='uj4b1ca8'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster'&gt;
       &lt;item jid='[ ... non-existent-jid ... ]'
             subscription='remove'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq id='uj4b1ca8'
       to='juliet@example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;item-not-found
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="roster-versioning"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.6"></a><h3>2.6.&nbsp;
Roster Versioning</h3>

<a name="roster-versioning-feature"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.6.1"></a><h3>2.6.1.&nbsp;
Stream Feature</h3>

<p>If a server supports roster versioning, then it MUST advertise the following stream feature during stream negotiation.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;ver xmlns='urn:xmpp:features:rosterver'/&gt;
</pre></div>
<p>  The roster versioning stream feature is merely informative and
  therefore is never mandatory-to-negotiate.
</p>
<a name="roster-versioning-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.6.2"></a><h3>2.6.2.&nbsp;
Request</h3>

<p>If a client supports roster versioning and the server to which it has connected advertises support for roster versioning as described in the foregoing section, then the client SHOULD include the 'ver' element in its request for the roster. If the server does not advertise support for roster versioning, the client MUST NOT include the 'ver' attribute. If the client includes the 'ver' attribute in its roster get, it sets the attribute's value to the version ID associated with its last cache of the roster.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='romeo@example.net/home'
       id='r1h3vzp7'
       to='romeo@example.net'
       type='get'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver14'/&gt;
   &lt;/iq&gt;
</pre></div>
<p>If the client has not yet cached the roster or the cache is lost or corrupted, but the client wishes to bootstrap the use of roster versioning, it MUST set the 'ver' attribute to the empty string (i.e., ver="").
</p>
<p>Naturally, if the client does not support roster versioning or does not wish to bootstrap the use of roster versioning, it will not include the 'ver' attribute.
</p>
<a name="roster-versioning-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.6.3"></a><h3>2.6.3.&nbsp;
Success Case</h3>

<p>Whether or not the roster has been modified since the version ID enumerated by the client, the server MUST either return the complete roster as described under <a class='info' href='#roster-syntax-actions-result'>Section&nbsp;2.1.4<span> (</span><span class='info'>Roster Result</span><span>)</span></a> (including a 'ver' attribute that signals the latest version) or return an empty IQ-result (thus indicating that any roster modifications will be sent via roster pushes, as described below). In general, unless returning the complete roster would (1) use less bandwidth than sending individual roster pushes to the client (e.g., if the roster contains only a few items) or (2) the server cannot associate the version ID with any previous version it has on file, the server SHOULD send an empty IQ-result and then send the modifications (if any) via roster pushes.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq from='romeo@example.net'
       id='r1h3vzp7'
       to='romeo@example.net/home'
       type='result'/&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Implementation Note: This empty IQ-result is different from an empty &lt;query/&gt; element, thus disambiguating this usage from an empty roster.
</p>
</blockquote>

<p>If roster versioning is enabled and the roster has not been modified since the version ID enumerated by the client, the server will simply not send any roster pushes to the client (until and unless some relevant event triggers a roster push during the lifetime of the client's session).
</p>
<p>If the roster has been modified since the version ID enumerated by the client, the server MUST then send one roster push to the client for each roster item that has been modified since the version ID enumerated by the client. (We call a roster push that is sent for purposes of roster version synchronization an "interim roster push".)
</p>
<p></p>
<blockquote class="text">
<p>Definition: A "roster modification" is any change to the roster data that would result in a roster push to a connected client. Therefore, internal states related to roster processing within the server that would not result in a roster push to a connected client do not necessitate a change to the version.
</p>
</blockquote>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq from='romeo@example.net'
       id='ah382g67'
       to='romeo@example.net/home'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver34'&gt;
       &lt;item jid='tybalt@example.org' subscription='remove'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq from='romeo@example.net'
       id='b2gs90j5'
       to='romeo@example.net/home'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver42'&gt;
       &lt;item jid='bill@example.org' subscription='both'/&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq from='romeo@example.net'
       id='c73gs419'
       to='romeo@example.net/home'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver72'&gt;
       &lt;item jid='nurse@example.org'
             name='Nurse'
             subscription='to'&gt;
         &lt;group&gt;Servants&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;

S: &lt;iq from='romeo@example.net'
       id='dh361f35'
       to='romeo@example.net/home'
       type='set'&gt;
     &lt;query xmlns='jabber:iq:roster' ver='ver96'&gt;
       &lt;item jid='juliet@example.org'
             name='Juliet'
             subscription='both'&gt;
         &lt;group&gt;VIPs&lt;/group&gt;
       &lt;/item&gt;
     &lt;/query&gt;
   &lt;/iq&gt;
</pre></div>
<p>These "interim roster pushes" can be understood as follows:
</p>
<p>
          </p>
<ol class="text">
<li>Imagine that the client had an active presence session for the entire time between its cached roster version (say, "ver14") and the new roster version (say, "ver96").
</li>
<li>During that time, the client might have received roster pushes related to various roster versions (which might have been, say, "ver51" and "ver79"). However, some of those roster pushes might have contained intermediate updates to the same roster item (e.g., modifications to the subscription state for bill@example.org from "none" to "to" and from "to" to "both").
</li>
<li>The interim roster pushes would not include all of the intermediate steps, only the final result of all modifications applied to each item while the client was in fact offline (which might have been, say, "ver34", "ver42", "ver72", and "ver96").
</li>
</ol><p>
        
</p>
<p>The client MUST handle an "interim roster push" in the same way it handles any roster push (indeed, from the client's perspective it cannot tell the difference between an "interim" roster push and a "live" roster push and therefore it has no way of knowing when it has received all of the interim roster pushes).  When requesting the roster after reconnection, the client SHOULD request the version associated with the last roster push it received during its previous session, not the version associated with the roster result it received at the start of its previous session.
</p>
<p>When roster versioning is enabled, the server MUST include the updated roster version with each roster push. Roster pushes MUST occur in order of modification and the version contained in a roster push MUST be unique.  Even if the client has not included the 'ver' attribute in its roster gets or sets, the server SHOULD include the 'ver' attribute on all roster pushes and results that it sends to the client.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Guidelines and more detailed examples for roster versioning are provided in <a class='info' href='#XEP-0237'>[XEP&#8209;0237]<span> (</span><span class='info'>Saint-Andre, P. and D. Cridland, &ldquo;Roster Versioning,&rdquo; March&nbsp;2010.</span><span>)</span></a>.
</p>
</blockquote>

<a name="sub"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3"></a><h3>3.&nbsp;
Managing Presence Subscriptions</h3>

<p>In order to protect the privacy of XMPP users, presence information is disclosed only to other entities that a user has approved.  When a user has agreed that another entity is allowed to view its presence, the entity is said to have a "subscription" to the user's presence.  An entity that has a subscription to a user's presence or to which a user has a presence subscription is called a "contact" (in this document the term "contact" is also used in a less strict sense to refer to a potential contact or any item in a user's roster).
</p>
<p>In XMPP, a subscription lasts across presence sessions; indeed, it lasts until the contact unsubscribes or the user cancels the previously granted subscription.  (This model is different from that used for presence subscriptions in the Session Initiation Protocol (SIP), as defined in <a class='info' href='#SIP-PRES'>[SIP&#8209;PRES]<span> (</span><span class='info'>Rosenberg, J., &ldquo;A Presence Event Package for the Session Initiation Protocol (SIP),&rdquo; August&nbsp;2004.</span><span>)</span></a>.)
</p>
<p>Subscriptions are managed within XMPP by sending presence stanzas containing specially defined attributes ("subscribe", "unsubscribe", "subscribed", and "unsubscribed").
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: When a server processes or generates an outbound presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST stamp the outgoing presence stanza with the bare JID &lt;localpart@domainpart&gt; of the sending entity, not the full JID &lt;localpart@domainpart/resourcepart&gt;.  Enforcement of this rule simplifies the presence subscription model and helps to prevent presence leaks; for information about presence leaks, refer to the security considerations of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
</blockquote>

<p>Subscription states are reflected in the rosters of both the user and the contact.  This section does not cover every possible case related to presence subscriptions, and mainly narrates the protocol flows for bootstrapping a mutual subscription between a user and a contact.  Complete details regarding subscription states can be found under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>.
</p>
<a name="sub-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1"></a><h3>3.1.&nbsp;
Requesting a Subscription</h3>

<p>A "subscription request" is a request from a user for authorization to permanently subscribe to a contact's presence information; syntactically it is a presence stanza whose 'type' attribute has a value of "subscribe".  A subscription request is generated by a user's client, processed by the (potential) contact's server, and acted on by the contact via the contact's client.  The workflow is described in the following sections.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Presence subscription requests are sent to available resources, whereas the roster pushes associated with subscription state changes are sent to interested resources.  Therefore, if a resource wishes to receive both subscription requests and roster pushes, it MUST both send initial presence and request the roster.
</p>
</blockquote>

<a name="sub-request-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.1"></a><h3>3.1.1.&nbsp;
Client Generation of Outbound Subscription Request</h3>

<p>A user's client generates a subscription request by sending a presence stanza of type "subscribe" and specifying a 'to' address of the potential contact's bare JID &lt;contact@domainpart&gt;.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence id='xk3h1v69'
              to='juliet@example.com'
              type='subscribe'/&gt;
</pre></div>
<p>When a user sends a presence subscription request to a potential instant messaging and presence contact, the value of the 'to' attribute MUST be a bare JID &lt;contact@domainpart&gt; rather than a full JID &lt;contact@domainpart/resourcepart&gt;, since the desired result is for the user to receive presence from all of the contact's resources, not merely the particular resource specified in the 'to' attribute.  Use of bare JIDs also simplifies subscription processing, presence probes, and presence notifications by the user's server and the contact's server.
</p>
<p>For tracking purposes, a client SHOULD include an 'id' attribute in a presence subscription request.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Many XMPP clients prompt the user for information about the potential contact (e.g., "handle" and desired roster group) when generating an outbound presence subscription request and therefore send a roster set before sending the outbound presence subscription request.  This behavior is OPTIONAL, because a client MAY instead wait until receiving the initial roster push from the server before uploading user-provided information about the contact.  A server MUST process a roster set and outbound presence subscription request in either order (i.e., in whatever order generated by the client).
</p>
</blockquote>

<a name="sub-request-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.2"></a><h3>3.1.2.&nbsp;
Server Processing of Outbound Subscription Request</h3>

<p>Upon receiving the outbound presence subscription request, the user's server MUST proceed as follows.
</p>
<p>
          </p>
<ol class="text">
<li>Before processing the request, the user's server MUST check the syntax of the JID contained in the 'to' attribute (however, it is known that some existing implementations do not perform this check).  If the JID is of the form &lt;contact@domainpart/resourcepart&gt; instead of &lt;contact@domainpart&gt;, the user's server SHOULD treat it as if the request had been directed to the contact's bare JID and modify the 'to' address accordingly.  The server MAY also verify that the JID adheres to the format defined in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a> and possibly return a &lt;jid-malformed/&gt; stanza error.
</li>
<li>If the potential contact is hosted on the same server as the
user, then the server MUST adhere to the rules specified under <a class='info' href='#sub-request-inbound'>Section&nbsp;3.1.3<span> (</span><span class='info'>Server Processing of Inbound Subscription Request</span><span>)</span></a> when processing the subscription request and delivering it to the (local) contact.
</li>
<li>If the potential contact is hosted on a remote server, subject to local service policies the user's server MUST then route the stanza to that remote domain in accordance with core XMPP stanza processing rules.  (This can result in returning an appropriate stanza error to the user, such as &lt;remote-server-timeout/&gt;.)
</li>
</ol><p>
        
</p>
<p>As mentioned, before locally delivering or remotely routing the presence subscription request, the user's server MUST stamp the outbound subscription request with the bare JID &lt;user@domainpart&gt; of the user.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='romeo@example.net'
              id='xk3h1v69'
              to='juliet@example.com'
              type='subscribe'/&gt;
</pre></div>
<p>If the presence subscription request cannot be locally delivered or remotely routed (e.g., because the request is malformed, the local contact does not exist, the remote server does not exist, an attempt to contact the remote server times out, or any other error is determined or experienced by the user's server), then the user's server MUST return an appropriate error stanza to the user.  An example follows.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com'
              id='xk3h1v69'
              to='romeo@example.net'
              type='error'&gt;
      &lt;error type='modify'&gt;
        &lt;remote-server-not-found
            xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
      &lt;/error&gt;
    &lt;/presence&gt;
</pre></div>
<p>After locally delivering or remotely routing the presence subscription request, the user's server MUST then send a roster push to all of the user's interested resources, containing the potential contact with a subscription state of "none" and with notation that the subscription is pending (via an 'ask' attribute whose value is "subscribe").
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='b89c5r7ib574'
        to='romeo@example.net/foo'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item ask='subscribe'
              jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

US: &lt;iq id='b89c5r7ib575'
        to='romeo@example.net/bar'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item ask='subscribe'
              jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<p>If a remote contact does not approve or deny the subscription request within some configurable amount of time, the user's server SHOULD resend the subscription request to the contact based on an implementation-specific algorithm (e.g., whenever a new resource becomes available for the user, or after a certain amount of time has elapsed); this helps to recover from transient, silent errors that might have occurred when the original subscription request was routed to the remote domain.  When doing so, it is RECOMMENDED for the server to include an 'id' attribute so that it can track responses to the resent subscription request.
</p>
<a name="sub-request-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.3"></a><h3>3.1.3.&nbsp;
Server Processing of Inbound Subscription Request</h3>

<p>Before processing the inbound presence subscription request, the contact's server SHOULD check the syntax of the JID contained in the 'to' attribute.  If the JID is of the form &lt;contact@domainpart/resourcepart&gt; instead of &lt;contact@domainpart&gt;, the contact's server SHOULD treat it as if the request had been directed to the contact's bare JID and modify the 'to' address accordingly.  The server MAY also verify that the JID adheres to the format defined in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a> and possibly return a &lt;jid-malformed/&gt; stanza error.
</p>
<p>When processing the inbound presence subscription request, the contact's server MUST adhere to the following rules:
</p>
<p>
          </p>
<ol class="text">
<li>Above all, the contact's server MUST NOT automatically approve subscription requests on the contact's behalf -- unless the contact has (a) pre-approved subscription requests from the user as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>, (b) configured its account to automatically approve subscription requests, or (c) accepted an agreement with its service provider that allows automatic approval (for instance, via an employment agreement within an enterprise deployment).  Instead, if a subscription request requires approval then the contact's server MUST deliver that request to the contact's available resource(s) for approval or denial by the contact.
</li>
<li>If the contact exists and the user already has a subscription to the contact's presence, then the contact's server MUST auto-reply on behalf of the contact by sending a presence stanza of type "subscribed" from the contact's bare JID to the user's bare JID.  Likewise, if the contact previously sent a presence stanza of type "subscribed" and the contact's server treated that as indicating "pre-approval" for the user's presence subscription (see <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>), then the contact's server SHOULD also auto-reply on behalf of the contact.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com'
              id='xk3h1v69'
              to='romeo@example.net'
              type='subscribed'/&gt;
</pre></div>
            
</li>
<li>Otherwise, if there is at least one available resource associated with the contact when the subscription request is received by the contact's server, then the contact's server MUST send that subscription request to all available resources in accordance with <a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>.
            
            As a way of acknowledging receipt of the presence subscription request, the contact's server MAY send a presence stanza of type "unavailable" from the bare JID of the contact to the bare JID of the user (the user's client MUST NOT assume that this acknowledgement provides presence information about the contact, since it comes from the contact's bare JID and is received before the subscription request has been approved).
</li>
<li>Otherwise, if the contact has no available resources when the subscription request is received by the contact's server, then the contact's server MUST keep a record of the complete presence stanza comprising the subscription request, including any extended content contained therein (see Section 8.4 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>), and then deliver the request when the contact next has an available resource.  The contact's server MUST continue to deliver the subscription request whenever the contact creates an available resource, until the contact either approves or denies the request.  (The contact's server MUST NOT deliver more than one subscription request from any given user when the contact next has an available resource; e.g., if the user sends multiple subscription requests to the contact while the contact is offline, the contact's server SHOULD store only one of those requests, such as the first request or last request, and MUST deliver only one of the requests when the contact next has an available resource; this helps to prevent "subscription request spam".)
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Until and unless the contact approves the subscription request as described under <a class='info' href='#sub-request-handle'>Section&nbsp;3.1.4<span> (</span><span class='info'>Client Processing of Inbound Subscription Request</span><span>)</span></a>, the contact's server MUST NOT add an item for the user to the contact's roster.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Security Warning: The mandate for the contact's server to store the complete stanza of the presence subscription request introduces the possibility of an application resource exhaustion attack (see Section 2.1.2 of <a class='info' href='#DOS'>[DOS]<span> (</span><span class='info'>Handley, M., Rescorla, E., and IAB, &ldquo;Internet Denial-of-Service Considerations,&rdquo; December&nbsp;2006.</span><span>)</span></a>), for example, by a rogue server or a coordinated group of users (e.g., a botnet) against the contact's server or particular contact.  Server implementers are advised to consider the possibility of such attacks and provide tools for counteracting it, such as enabling service administrators to set limits on the number or size of inbound presence subscription requests that the server will store in aggregate or for any given contact.
</p>
</blockquote>

<a name="sub-request-handle"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.4"></a><h3>3.1.4.&nbsp;
Client Processing of Inbound Subscription Request</h3>

<p>When an interactive client receives a subscription request, it MUST present the request to the natural person controlling the client (i.e., the "contact") for approval, unless the contact has explicitly configured the client to automatically approve or deny some or all subscription requests as described above.  An automated client that is not controlled by a natural person will have its own application-specific rules for approving or denying subscription requests.
</p>
<p>A client approves a subscription request by sending a presence stanza of type "subscribed", which is processed as described under <a class='info' href='#sub-request-approvalout'>Section&nbsp;3.1.5<span> (</span><span class='info'>Server Processing of Outbound Subscription Approval</span><span>)</span></a> for the contact's server and <a class='info' href='#sub-request-approvalin'>Section&nbsp;3.1.6<span> (</span><span class='info'>Server Processing of Inbound Subscription Approval</span><span>)</span></a> for the user's server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence id='h4v1c4kj'
              to='romeo@example.net'
              type='subscribed'/&gt;
</pre></div>
<p>A client denies a subscription request by sending a presence stanza of type "unsubscribed", which is processed as described under <a class='info' href='#sub-cancel'>Section&nbsp;3.2<span> (</span><span class='info'>Canceling a Subscription</span><span>)</span></a> for both the contact's server and the user's server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence id='tb2m1b59'
              to='romeo@example.net'
              type='unsubscribed'/&gt;
</pre></div>
<p>For tracking purposes, a client SHOULD include an 'id' attribute in a subscription approval or subscription denial; this 'id' attribute MUST NOT mirror the 'id' attribute of the subscription request.
</p>
<a name="sub-request-approvalout"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.5"></a><h3>3.1.5.&nbsp;
Server Processing of Outbound Subscription Approval</h3>

<p>When the contact's client sends the subscription approval, the contact's server MUST stamp the outbound stanza with the bare JID &lt;contact@domainpart&gt; of the contact and locally deliver or remotely route the stanza to the user.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com'
              id='h4v1c4kj'
              to='romeo@example.net'
              type='subscribed'/&gt;
</pre></div>
<p>The contact's server then MUST send an updated roster push to all of the contact's interested resources, with the 'subscription' attribute set to a value of "from". (Here we assume that the contact does not already have a subscription to the user; if that were the case, the 'subscription' attribute would be set to a value of "both", as explained under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;iq id='a78b4q6ha463'
        to='juliet@example.com/balcony'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='from'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

CS: &lt;iq id='x81g3bdy4n19'
        to='juliet@example.com/chamber'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='from'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<p>From the perspective of the contact, there now exists a subscription from the user, which is why the 'subscription' attribute is set to a value of "from".  (Here we assume that the contact does not already have a subscription to the user; if that were the case, the 'subscription' attribute would be set to a value of "both", as explained under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>.)
</p>
<p>The contact's server MUST then also send current presence to the user from each of the contact's available resources.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com/balcony'
              id='pw72bc5j'
              to='romeo@example.net'/&gt;

CS: &lt;presence from='juliet@example.com/chamber'
              id='ux31da4q'
              to='romeo@example.net'/&gt;
</pre></div>
<p>In order to subscribe to the user's presence, the contact would then need to send a subscription request to the user.  (XMPP clients will often automatically send the subscription request instead of requiring the contact to initiate the subscription request, since it is assumed that the desired end state is a mutual subscription.)  Naturally, when the contact sends a subscription request to the user, the subscription states will be different from those shown in the foregoing examples (see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>) and the roles will be reversed.
</p>
<a name="sub-request-approvalin"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1.6"></a><h3>3.1.6.&nbsp;
Server Processing of Inbound Subscription Approval</h3>

<p>When the user's server receives a subscription approval, it MUST first check if the contact is in the user's roster with subscription='none' or subscription='from' and the 'ask' flag set to "subscribe" (i.e., a subscription state of "None + Pending Out", "None + Pending Out+In", or "From + Pending Out"; see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>).  If this check is successful, then the user's server MUST:
</p>
<p>
          </p>
<ol class="text">
<li>Deliver the inbound subscription approval to all of the user's interested resources (this helps to give the user's client(s) proper context regarding the subscription approval so that they can differentiate between a roster push originated by another of the user's resources and a subscription approval received from the contact).  This MUST occur before sending the roster push described in the next step.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com'
              id='h4v1c4kj'
              to='romeo@example.net'
              type='subscribed'/&gt;
</pre></div>
            
</li>
<li>Initiate a roster push to all of the user's interested resources, containing an updated roster item for the contact with the 'subscription' attribute set to a value of "to" (if the subscription state was "None + Pending Out" or "None + Pending Out+In") or "both" (if the subscription state was "From + Pending Out").
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='b89c5r7ib576'
        to='romeo@example.net/foo'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='to'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

US: &lt;iq id='b89c5r7ib577'
        to='romeo@example.net/bar'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='to'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>

            
</li>
<li>The user's server MUST also deliver the available presence stanza received from each of the contact's available resources to each of the user's available resources.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
[ ... to resource1 ... ]

US: &lt;presence from='juliet@example.com/balcony'
              id='pw72bc5j'
              to='romeo@example.net'/&gt;

[ ... to resource2 ... ]

US: &lt;presence from='juliet@example.com/balcony'
              id='pw72bc5j'
              to='romeo@example.net'/&gt;

[ ... to resource1 ... ]

US: &lt;presence from='juliet@example.com/chamber'
              id='ux31da4q'
              to='romeo@example.net'/&gt;

[ ... to resource2 ... ]

US: &lt;presence from='juliet@example.com/chamber'
              id='ux31da4q'
              to='romeo@example.net'/&gt;
</pre></div>
            
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: If the user's account has no available resources when the inbound subscription approval notification is received, the user's server MAY keep a record of the notification (ideally the complete presence stanza) and then deliver the notification when the account next has an available resource.  This behavior provides more complete signaling to the user regarding the reasons for the roster change that occurred while the user was offline.
</p>
</blockquote>

<p>Otherwise -- that is, if the user does not exist, if the contact is not in the user's roster, or if the contact is in the user's roster with a subscription state other than those described in the foregoing check -- then the user's server MUST silently ignore the subscription approval notification by not delivering it to the user, not modifying the user's roster, and not generating a roster push to the user's interested resources.
</p>
<p>From the perspective of the user, there now exists a subscription to the contact's presence (which is why the 'subscription' attribute is set to a value of "to").
</p>
<a name="sub-cancel"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2"></a><h3>3.2.&nbsp;
Canceling a Subscription</h3>

<a name="sub-cancel-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.1"></a><h3>3.2.1.&nbsp;
Client Generation of Subscription Cancellation</h3>

<p>If a contact would like to cancel a subscription that it has previously granted to a user, to cancel a subscription pre-approval (<a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>), or to deny a subscription request, it sends a presence stanza of type "unsubscribed".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence id='ij5b1v7g'
              to='romeo@example.net'
              type='unsubscribed'/&gt;
</pre></div>
<a name="sub-cancel-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.2"></a><h3>3.2.2.&nbsp;
Server Processing of Outbound Subscription Cancellation</h3>

<p>Upon receiving the outbound subscription cancellation, the contact's server MUST proceed as follows.
</p>
<p>
          </p>
<ol class="text">
<li>If the user's bare JID is not yet in the contact's roster or is in the contact's roster with a state of "None", "None + Pending Out", or "To", the contact's server SHOULD NOT route or deliver the presence stanza of type "unsubscribed" to the user and MUST NOT send presence notifications of type "unavailable" to the user as described below.
</li>
<li>If the user's bare JID is in the contact's roster with a state of "None", "None + Pending Out", or "To" and the 'approved' flag is set to "true" (thus signaling a subscription pre-approval as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>), the contact's server MUST remove the pre-approval and MUST NOT route or deliver the presence stanza of type "unsubscribed" to the user.
</li>
<li>Otherwise, as shown in the following examples, the contact's server MUST route or deliver both presence notifications of type "unavailable" and presence stanzas of type "unsubscribed" to the user and MUST send a roster push to the contact.
</li>
</ol><p>
        
</p>
<p>While the user is still subscribed to the contact's presence (i.e., before the contact's server routes or delivers the presence stanza of type "unsubscribed" to the user), the contact's server MUST send a presence stanza of type "unavailable" from all of the contact's online resources to the user.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com/balcony'
              id='i8bsg3h3'
              type='unavailable'/&gt;

CS: &lt;presence from='juliet@example.com/chamber'
              id='bvx2c9mk'
              type='unavailable'/&gt;
</pre></div>
<p>Then the contact's server MUST route or deliver the presence stanza of type "unsubscribed" to the user, making sure to stamp the outbound subscription cancellation with the bare JID &lt;contact@domainpart&gt; of the contact.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com'
              id='ij5b1v7g'
              to='romeo@example.net'
              type='unsubscribed'/&gt;
</pre></div>
<p>The contact's server then MUST send a roster push with the updated roster item to all of the contact's interested resources, where the subscription state is now either "none" or "to" (see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;iq id='pw3f2v175b34'
        to='juliet@example.com/balcony'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

CS: &lt;iq id='zu2y3f571v35'
        to='juliet@example.com/chamber'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<a name="sub-cancel-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.3"></a><h3>3.2.3.&nbsp;
Server Processing of Inbound Subscription Cancellation</h3>

<p>When the user's server receives the inbound subscription cancellation, it MUST first check if the contact is in the user's roster with subscription='to' or subscription='both' (see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>).  If this check is successful, then the user's server MUST:
</p>
<p>
          </p>
<ol class="text">
<li>Deliver the inbound subscription cancellation to all of the user's interested resources (this helps to give the user's client(s) proper context regarding the subscription cancellation so that they can differentiate between a roster push originated by another of the user's resources and a subscription cancellation received from the contact).  This MUST occur before sending the roster push described in the next step.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com'
              id='ij5b1v7g'
              to='romeo@example.net'
              type='unsubscribed'/&gt;
</pre></div>
            
</li>
<li>Initiate a roster push to all of the user's interested resources, containing an updated roster item for the contact with the 'subscription' attribute set to a value of "none" (if the subscription state was "To" or "To + Pending In") or "from" (if the subscription state was "Both").
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='h37h3u1bv400'
        to='romeo@example.net/foo'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

US: &lt;iq id='h37h3u1bv401'
        to='romeo@example.net/bar'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>

            
</li>
</ol><p>
        
</p>
<p>The user's server MUST also deliver the inbound presence stanzas of type "unavailable".
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: If the user's account has no available resources when the inbound unsubscribed notification is received, the user's server MAY keep a record of the notification (ideally the complete presence stanza) and then deliver the notification when the account next has an available resource.  This behavior provides more complete signaling to the user regarding the reasons for the roster change that occurred while the user was offline.
</p>
</blockquote>

<p>Otherwise -- that is, if the user does not exist, if the contact is not in the user's roster, or if the contact is in the user's roster with a subscription state other than those described in the foregoing check -- then the user's server MUST silently ignore the unsubscribed notification by not delivering it to the user, not modifying the user's roster, and not generating a roster push to the user's interested resources.
</p>
<a name="sub-unsub"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.3"></a><h3>3.3.&nbsp;
Unsubscribing</h3>

<a name="sub-unsub-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.3.1"></a><h3>3.3.1.&nbsp;
Client Generation of Unsubscribe</h3>

<p>If a user would like to unsubscribe from a contact's presence, it sends a presence stanza of type "unsubscribe".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence id='ul4bs71n'
              to='juliet@example.com'
              type='unsubscribe'/&gt;
</pre></div>
<a name="sub-unsub-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.3.2"></a><h3>3.3.2.&nbsp;
Server Processing of Outbound Unsubscribe</h3>

<p>Upon receiving the outbound unsubscribe, the user's server MUST proceed as follows.
</p>
<p>
          </p>
<ol class="text">
<li>If the contact is hosted on the same server as the user, then
the server MUST adhere to the rules specified under <a class='info' href='#sub-unsub-inbound'>Section&nbsp;3.3.3<span> (</span><span class='info'>Server Processing of Inbound Unsubscribe</span><span>)</span></a> when processing the subscription request.
</li>
<li>If the contact is hosted on a remote server, subject to local service policies the user's server MUST then route the stanza to that remote domain in accordance with core XMPP stanza processing rules.  (This can result in returning an appropriate stanza error to the user, such as &lt;remote-server-timeout/&gt;.)
</li>
</ol><p>
        
</p>
<p>As mentioned, before locally delivering or remotely routing the unsubscribe, the user's server MUST stamp the stanza with the bare JID &lt;user@domainpart&gt; of the user.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='romeo@example.net'
              id='ul4bs71n'
              to='juliet@example.com'
              type='unsubscribe'/&gt;
</pre></div>
<p>The user's server then MUST send a roster push with the updated roster item to all of the user's interested resources, where the subscription state is now either "none" or "from" (see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='h37h3u1bv402'
        to='romeo@example.net/foo'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

US: &lt;iq to='romeo@example.net/bar'
        type='set'
        id='h37h3u1bv403'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<a name="sub-unsub-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.3.3"></a><h3>3.3.3.&nbsp;
Server Processing of Inbound Unsubscribe</h3>

<p>When the contact's server receives the unsubscribe notification, it MUST first check if the user's bare JID is in the contact's roster with subscription='from' or subscription='both' (i.e., a subscription state of "From", "From + Pending Out", or "Both"; see <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>).  If this check is successful, then the contact's server MUST:
</p>
<p>
          </p>
<ol class="text">
<li>Deliver the inbound unsubscribe to all of the contact's interested resources (this helps to give the contact's client(s) proper context regarding the unsubscribe so that they can differentiate between a roster push originated by another of the contact's resources and an unsubscribe received from the user).  This MUST occur before sending the roster push described in the next step.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='romeo@example.net'
              id='ul4bs71n'
              to='juliet@example.com'
              type='unsubscribe'/&gt;
</pre></div>
            
</li>
<li>Initiate a roster push to all of the contact's interested resources, containing an updated roster item for the user with the 'subscription' attribute set to a value of "none" (if the subscription state was "From" or "From + Pending Out") or "to" (if the subscription state was "Both").
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;iq id='tn2b5893g1s4'
        to='juliet@example.com/balcony'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;

CS: &lt;iq id='sp3b56n27hrp'
        to='juliet@example.com/chamber'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='romeo@example.net'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
            
</li>
<li>Generate an outbound presence stanza of type "unavailable" from each of the contact's available resources to the user.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com/balcony'
              id='o5v91w49'
              to='romeo@example.net'
              type='unavailable'/&gt;

CS: &lt;presence from='juliet@example.com/chamber'
              id='n6b1c37k'
              to='romeo@example.net'
              type='unavailable'/&gt;
</pre></div>
            
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: If the contact's account has no available resources when the inbound unsubscribe notification is received, the contact's server MAY keep a record of the notification (ideally the complete presence stanza) and then deliver the notification when the account next has an available resource.  This behavior provides more complete signaling to the user regarding the reasons for the roster change that occurred while the user was offline.
</p>
</blockquote>

<p>Otherwise -- that is, if the contact does not exist, if the user is not in the contact's roster, or if the user's bare JID is in the contact's roster with a subscription state other than those described in the foregoing check -- then the contact's server MUST silently ignore the unsubscribe stanza by not delivering it to the contact, not modifying the contact's roster, and not generating a roster push to the contact's interested resources.  However, if the contact's server is keeping track of an inbound presence subscription request from the user to the contact but the user is not yet in the contact's roster (functionally equivalent to a subscription state of "None + Pending In" where the contact never added the user to the contact's roster), then the contact's server MUST simply remove any record of the inbound presence subscription request (it cannot remove the user from the contact's roster because the user was never added to the contact's roster).
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: The user's client MUST NOT depend on receiving the unavailable presence notification from the contact, since it MUST consider its presence subscription to the contact, and its presence information about the contact, to be null and void when it sends the presence stanza of type "unsubscribe" or when it receives the roster push triggered by the unsubscribe request.
</p>
</blockquote>

<a name="sub-preapproval"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.4"></a><h3>3.4.&nbsp;
Pre-Approving a Subscription Request</h3>

<p>If a user has not received a subscription request from a contact, the user can "pre-approve" such a request so that it will be automatically approved by the user's server.
</p>
<p>Support for subscription pre-approvals is OPTIONAL on the part of clients and servers.  If a server supports subscription pre-approvals, then it MUST advertise the following stream feature during stream negotiation.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;sub xmlns='urn:xmpp:features:pre-approval'/&gt;
</pre></div>
<p>The subscription pre-approval stream feature is merely informative and therefore is never mandatory-to-negotiate.
</p>
<a name="sub-preapproval-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.4.1"></a><h3>3.4.1.&nbsp;
Client Generation of Subscription Pre-Approval</h3>

<p>If the server to which a client connects has advertised support for subscription pre-approvals, the client MAY generate a subscription pre-approval by sending a presence stanza of type "subscribed" to the contact.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence id='pg81vx64'
              to='juliet@example.com'
              type='subscribed'/&gt;
</pre></div>
<p>If the server does not advertise support for subscription pre-approvals, the client MUST NOT attempt to pre-approve subscription requests from potential or actual contacts.
</p>
<a name="sub-preapproval-proc"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.4.2"></a><h3>3.4.2.&nbsp;
Server Processing of Subscription Pre-Approval</h3>

<p>Upon receiving the presence stanza of type "subscribed", the user's server MUST proceed as follows if it supports subscription pre-approvals.
</p>
<p>
          </p>
<ol class="text">
<li>If the contact is in the user's roster with a state of "Both", "From", or "From + Pending Out", the user's server MUST silently ignore the stanza.
</li>
<li>If the contact is in the user's roster with a state of "To + Pending In", "None + Pending In", or "None + Pending Out+In", the user's server MUST handle the stanza as a normal subscription approval (see under <a class='info' href='#sub-request-approvalout'>Section&nbsp;3.1.5<span> (</span><span class='info'>Server Processing of Outbound Subscription Approval</span><span>)</span></a>) by updating the existing roster item to a state of "Both", "From", or "From + Pending Out" (respectively), pushing the modified roster item to all of the user's interested resources, and routing the presence stanza of type "subscribed" to the contact.
</li>
<li>If the contact is in the user's roster with a state of "To", "None", or "None + Pending Out", the user's server MUST note the subscription pre-approval by setting the 'approved' flag to a value of "true", then push the modified roster item to all of the user's interested resources.  However, the user's server MUST NOT route the presence stanza of type "subscribed" to the contact.
</li>
<li>If the contact is not yet in the user's roster, the user's server MUST create a roster item for the contact with a state of "None" and set the 'approved' flag to a value of "true", then push the roster item to all of the user's interested resources.  However, the user's server MUST NOT route the presence stanza of type "subscribed" to the contact.
</li>
</ol><p>
        
</p>
<p>An example of the roster push follows.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='h3bs81vs763f'
        to='romeo@example.net/bar'
        type='set'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item approved='true'
              jid='juliet@example.com'
              subscription='none'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<p>When the 'approved' flag is set to "true", the user's server MUST NOT deliver a presence stanza of type "subscribe" from the contact to the user, but instead MUST automatically respond to such a stanza on behalf of the user by returning a presence stanza of type "subscribed" from the bare JID of the user to the bare JID of the contact.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: It is a matter of implementation or local service policy whether the server maintains a record of the subscription approval after it has received a presence subscription request from the contact.  If the server does not maintain such a record, upon receiving the subscription request it will not include the 'approved' attribute in the roster item for the contact (i.e., in subsequent roster pushes and roster results).  If the server maintains such a record, it will always include the 'approved' attribute (set to "true") in the roster item for the contact, until and unless the user sends a presence stanza of type "unsubscribed" to the contact (or removes the contact from the roster entirely).
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: A client can cancel a pre-approval by sending a presence stanza of type "unsubscribed", as described more fully under <a class='info' href='#sub-cancel'>Section&nbsp;3.2<span> (</span><span class='info'>Canceling a Subscription</span><span>)</span></a>.  In this case, the user's server would send a roster push to all of the user's interested resources with the 'approved' attribute removed.  (Alternatively, the client can simply remove the roster item entirely.)
</p>
</blockquote>

<a name="presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4"></a><h3>4.&nbsp;
Exchanging Presence Information</h3>

<a name="presence-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.1"></a><h3>4.1.&nbsp;
Presence Fundamentals</h3>

<p>The concept of presence refers to an entity's availability for communication over a network.  At the most basic level, presence is a boolean "on/off" variable that signals whether an entity is available or unavailable for communication (the terms "online" and "offline" are also used).  In XMPP, an entity's availability is signaled when its client generates a &lt;presence/&gt; stanza with no 'type' attribute, and an entity's lack of availability is signaled when its client generates a &lt;presence/&gt; stanza whose 'type' attribute has a value of "unavailable".
</p>
<p>XMPP presence typically follows a "publish-subscribe" or "observer" pattern, wherein an entity sends presence to its server, and its server then broadcasts that information to all of the entity's contacts who have a subscription to the entity's presence (in the terminology of <a class='info' href='#IMP-MODEL'>[IMP&#8209;MODEL]<span> (</span><span class='info'>Day, M., Rosenberg, J., and H. Sugano, &ldquo;A Model for Presence and Instant Messaging,&rdquo; February&nbsp;2000.</span><span>)</span></a>, an entity that generates presence is a "presentity" and the entities that receive presence are "subscribers").  A client generates presence for broadcast to all subscribed entities by sending a presence stanza to its server with no 'to' address, where the presence stanza has either no 'type' attribute or a 'type' attribute whose value is "unavailable".  This kind of presence is called "broadcast presence".  (A client can also send "directed presence", i.e., a presence stanza with a 'to' address; this is less common but is sometimes used to send presence to entities that are not subscribed to the user's presence; see <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a>.)
</p>
<p>After a client completes the preconditions specified in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, it can establish a "presence session" at its server by sending <a class='info' href='#presence-initial'>initial presence<span> (</span><span class='info'>Initial Presence</span><span>)</span></a>, where the presence session is terminated by sending <a class='info' href='#presence-unavailable'>unavailable presence<span> (</span><span class='info'>Unavailable Presence</span><span>)</span></a>.  For the duration of its presence session, a connected resource (in the terminology of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>) is said to be an "available resource".
</p>
<p>In XMPP, applications that combine messaging and presence functionality, the default type of communication for which presence signals availability is messaging; however, it is not necessary for XMPP applications to combine messaging and presence functionality, and they can provide standalone presence features without messaging (in addition, XMPP servers do not require information about network availability in order to successfully route message and IQ stanzas).
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: In the examples that follow, the user is &lt;juliet@example.com&gt;, she has two available resources ("balcony" and "chamber"), and she has three contacts in her roster with a subscription state of "from" or "both": &lt;romeo@example.net&gt;, &lt;mercutio@example.com&gt;, and &lt;benvolio@example.net&gt;.
</p>
</blockquote>

<a name="presence-initial"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2"></a><h3>4.2.&nbsp;
Initial Presence</h3>

<a name="presence-initial-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2.1"></a><h3>4.2.1.&nbsp;
Client Generation of Initial Presence</h3>

<p>After completing the preconditions described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> (REQUIRED) and requesting the roster (RECOMMENDED), a client signals its availability for communication by sending "initial presence" to its server, i.e., a presence stanza with no 'to' address (indicating that it is meant to be broadcast by the server on behalf of the client) and no 'type' attribute (indicating the user's availability).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence/&gt;
</pre></div>
<p>The initial presence stanza MAY contain the &lt;priority/&gt; element, the &lt;show/&gt; element, and one or more instances of the &lt;status/&gt; element, as well as extended content; details are provided under <a class='info' href='#presence-syntax'>Section&nbsp;4.7<span> (</span><span class='info'>Presence Syntax</span><span>)</span></a>.
</p>
<a name="presence-initial-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2.2"></a><h3>4.2.2.&nbsp;
Server Processing of Outbound Initial Presence</h3>

<p>Upon receiving initial presence from a client, the user's server MUST send the initial presence stanza from the full JID &lt;user@domainpart/resourcepart&gt; of the user to all contacts that are subscribed to the user's presence; such contacts are those for which a JID is present in the user's roster with the 'subscription' attribute set to a value of "from" or "both".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'/&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='mercutio@example.com'/&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='benvolio@example.net'/&gt;
</pre></div>
<p>The user's server MUST also broadcast initial presence from the user's newly available resource to all of the user's available resources, including the resource that generated the presence notification in the first place (i.e., an entity is implicitly subscribed to its own presence).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
[... to the "balcony" resource ...]

US: &lt;presence from='juliet@example.com/balcony'
              to='juliet@example.com'/&gt;

[... to the "chamber" resource ...]

US: &lt;presence from='juliet@example.com/balcony'
              to='juliet@example.com'/&gt;
</pre></div>
<p>In the absence of presence information about the user's contacts, the user's server MUST also send presence probes to the user's contacts on behalf of the user as specified under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.
</p>
<a name="presence-initial-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2.3"></a><h3>4.2.3.&nbsp;
Server Processing of Inbound Initial Presence</h3>

<p>Upon receiving presence from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
[ ... to resource1 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'/&gt;

[ ... to resource2 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'/&gt;
</pre></div>
<a name="presence-initial-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2.4"></a><h3>4.2.4.&nbsp;
Client Processing of Initial Presence</h3>

<p>When the contact's client receives presence from the user, the following behavior is suggested for interactive clients:
</p>
<p>
          </p>
<ol class="text">
<li>If the user's bare JID is in the contact's roster, display the presence information in an appropriate roster interface.
</li>
<li>If the user is not in the contact's roster but the contact and the user are actively exchanging message or IQ stanzas, display the presence information in the user interface for that communication session (see also <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a> and <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a>).
</li>
<li>Otherwise, ignore the presence information and do not display it to the contact.
</li>
</ol><p>
        
</p>
<a name="presence-probe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3"></a><h3>4.3.&nbsp;
Presence Probes</h3>

<p>A "presence probe" is a request for a contact's current presence information, sent on behalf of a user by the user's server; syntactically it is a presence stanza whose 'type' attribute has a value of "probe".  In the context of presence subscriptions, the value of the 'from' address MUST be the bare JID of the subscribed user and the value of the 'to' address MUST be the bare JID of the contact to which the user is subscribed, since presence subscriptions are based on the bare JID.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com'
              id='ign291v5'
              to='romeo@example.net'
              type='probe'/&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Interoperability Note: RFC 3921 specified that probes are sent from the full JID, not the bare JID (a rule that was changed because subscriptions are based on the bare JID).  Some existing implementations send from the full JID instead of the bare JID.
</p>
</blockquote>

<p>Probes can also be sent by an entity that has received presence outside the context of a presence subscription, typically when the contact has sent directed presence as described under <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a>; in this case the value of the 'from' or 'to' address can be a full JID instead of a bare JID.  See <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a> for a complete discussion.
</p>
<p>Presence probes SHOULD NOT be sent by a client, because in general a client will not need to send them since the task of gathering presence from a user's contacts is managed by the user's server.  However, if a user's client generates an outbound presence probe then the user's server SHOULD route the probe (if the contact is at another server) or process the probe (if the contact is at the same server) and MUST NOT use its receipt of the presence probe from a connected client as the sole cause for returning a stanza or stream error to the client.
</p>
<a name="presence-probe-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.1"></a><h3>4.3.1.&nbsp;
Server Generation of Outbound Presence Probe</h3>

<p>When a server needs to discover the availability of a user's contact, it sends a presence probe from the bare JID &lt;user@domainpart&gt; of the user to the bare JID &lt;contact@domainpart&gt; of the contact.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Although presence probes are intended for sending to contacts (i.e., entities to which a user is subscribed), a server MAY send a presence probe to the full JID of an entity from which the user has received presence information during the current session.
</p>
</blockquote>

<p>The user's server SHOULD send a presence probe whenever the user starts a new presence session by sending initial presence; however, the server MAY choose not to send the probe at that point if it has what it deems to be reliable and up-to-date presence information about the user's contacts (e.g., because the user has another available resource or because the user briefly logged off and on before the new presence session began).  In addition, a server MAY periodically send a presence probe to a contact if it has not received presence information or other traffic from the contact in some configurable amount of time; this can help to prevent "ghost" contacts who appear to be online but in fact are not.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com'
              id='ign291v5'
              to='romeo@example.net'
              type='probe'/&gt;

US: &lt;presence from='juliet@example.com'
              id='xv291f38'
              to='mercutio@example.com'
              type='probe'/&gt;
</pre></div>
<p>Naturally, the user's server does not need to send a presence probe to a contact if the contact's account resides on the same server as the user, since the server possesses the contact's information locally.
</p>
<a name="presence-probe-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.2"></a><h3>4.3.2.&nbsp;
Server Processing of Inbound Presence Probe</h3>

<p>Upon receiving a presence probe to the contact's bare JID from the user's server on behalf of the user, the contact's server MUST reply as follows:
</p>
<p>
          </p>
<ol class="text">
<li>If the contact account does not exist or the user's bare JID is in the contact's roster with a subscription state other than "From", "From + Pending Out", or "Both" (as explained under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>), then the contact's server SHOULD return a presence stanza of type "unsubscribed" in response to the presence probe (this will trigger a protocol flow for canceling the user's subscription to the contact as described under <a class='info' href='#sub-cancel'>Section&nbsp;3.2<span> (</span><span class='info'>Canceling a Subscription</span><span>)</span></a>; however, this MUST NOT result in cancellation of a subscription pre-approval as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>).  Here the 'from' address MUST be the bare JID of the contact, since specifying a full JID would constitute a presence leak as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='mercutio@example.com'
              id='xv291f38'
              to='juliet@example.com'
              type='unsubscribed'/&gt;
</pre></div>
             However, if a server receives a presence probe from a configured domain of the server itself or another such trusted service, it MAY provide presence information about the user to that entity.
            
</li>
<li>Else, if the contact has moved temporarily or permanently to another address, then the server SHOULD return a presence stanza of type "error" with a stanza error condition of &lt;redirect/&gt; (temporary) or &lt;gone/&gt; (permanent) that includes the new address of the contact.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='mercutio@example.com'
              id='xv291f38'
              to='juliet@example.com'
              type='error'&gt;
      &lt;error type='modify'&gt;
        &lt;gone xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
          xmpp:la-mer@example.com
        &lt;/gone&gt;
      &lt;/error&gt;
    &lt;/presence&gt;
</pre></div>
            
</li>
<li>Else, if the contact has no available resources, then the server SHOULD reply to the presence probe by sending to the user a presence stanza of type "unavailable" (although sending unavailable presence here is preferable because it results in a deterministic answer to the probe, it is not mandatory because it can greatly increase the number of presence notifications generated by the contact's server).  Here the 'from' address is the bare JID because there is no available resource associated with the contact.
            
            If appropriate in accordance with local security policies this presence notification MAY include the full XML of the last unavailable presence stanza that the server received from the contact (including the 'id' of the original stanza), but if not then the presence notification SHOULD simply indicate that the contact is unavailable without any of the details originally provided.  In any case, the presence notification returned to the probing entity SHOULD include information about the time when the last unavailable presence stanza was generated (formatted using the XMPP delayed delivery extension <a class='info' href='#DELAY'>[DELAY]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Delayed Delivery,&rdquo; September&nbsp;2009.</span><span>)</span></a>).
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='mercutio@example.com'
              id='xv291f38'
              to='juliet@example.com'
              type='unavailable'&gt;
      &lt;delay xmlns='urn:xmpp:delay'
             stamp='2002-09-10T23:41:07Z'/&gt;
    &lt;/presence&gt;
</pre></div>
            
</li>
<li>Else, if the contact has at least one available resource, then the server MUST reply to the presence probe by sending to the user the full XML of the last presence stanza with no 'to' attribute received by the server from each of the contact's available resources.  Here the 'from' addresses are the full JIDs of each available resource.
              <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='romeo@example.net/foo'
              id='hzf1v27k'
              to='juliet@example.com'/&gt;

CS: &lt;presence from='romeo@example.net/bar'
              id='ps6t1fu3'
              to='juliet@example.com'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;
</pre></div>
            
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: By "full XML" is meant the complete stanza from the opening &lt;presence&gt; tag to the closing &lt;/presence&gt; tag, including all elements and attributes whether qualified by the content namespace or extended namespaces; however, in accordance with <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, the contact's server will need to transform the content namespace from 'jabber:client' to 'jabber:server' if it sends the complete stanza over a server-to-server stream.
</p>
</blockquote>

<p>If the contact's server receives a presence probe addressed to a full JID of the contact, the server MUST NOT return presence information about any resource except the resource specified by the 'to' address of the probe.  Rules #1 and #2 for a bare JID probe apply equally to the case of a full JID probe.  If there is a resource matching the full JID and the probing entity has authorization via a presence subscription to see the contact's presence, then the server MUST return an available presence notification, which SHOULD communicate only the fact that the resource is available (not detailed information such as the &lt;show/&gt;, &lt;status/&gt;, &lt;priority/&gt;, or presence extensions).
</p>
<p>
          </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='romeo@example.net/bar'
              to='lobby@chat.example.com'/&gt;
</pre></div><p>

        
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: See <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a> regarding rules that supplement the foregoing for handling of directed presence.
</p>
</blockquote>

<a name="presence-probe-inbound-id"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.2.1"></a><h3>4.3.2.1.&nbsp;
Handling of the 'id' Attribute</h3>

<p>The handling of the 'id' attribute in relation to
          presence probes was unspecified in RFC 3921. Although the
          pattern of "send a probe and receive a reply" might seem
          like a request-response protocol similar to the XMPP
          &lt;iq/&gt; stanza, in fact it is not because the response
          to a probe might consist of multiple presence stanzas (one
          for each available resource currently active for the
          contact).  For this reason, if the contact currently has
          available resources then the contact's server SHOULD
          preserve the 'id' attribute of the contact's original
          presence stanza (if any) when sending those presence
          notifications to the probing entity. By contrast, if the contact currently has no available resources, the probing entity is not authorized (via presence subscription) to see the contact's presence, or an error occurs in relation to the probe, then the contact's server SHOULD mirror the 'id' of the user's presence probe when replying to the probing entity.
</p>
<p>The following examples illustrate the difference.
</p>
<p>In the first scenario, Juliet sends presence from her "chamber" resource.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence from='juliet@example.com/chamber' id='pres1'&gt;
      &lt;show&gt;dnd&lt;/show&gt;
      &lt;status&gt;busy!&lt;/status&gt;
    &lt;/presence&gt;
</pre></div><p>

          
</p>
<p>She also sends presence from her "balcony" resource.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence from='juliet@example.com/balcony' id='pres2'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;stepped away&lt;/status&gt;
    &lt;/presence&gt;
</pre></div><p>

          
</p>
<p>Romeo's server then sends a probe to Juliet.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='romeo@example.net' id='probe1' type='probe'/&gt;
</pre></div><p>

          
</p>
<p>Juliet's server then sends both of her presence notifications to Romeo, preserving the 'id' attributes included in the stanzas that her client has sent.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com/chamber' id='pres1'&gt;
      &lt;show&gt;dnd&lt;/show&gt;
      &lt;status&gt;busy!&lt;/status&gt;
    &lt;/presence&gt;

CS: &lt;presence from='juliet@example.com/balcony' id='pres2'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;stepped away&lt;/status&gt;
    &lt;/presence&gt;
</pre></div><p>

          
</p>
<p>In the second scenario, Juliet is offline when Romeo's server sends a probe.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='romeo@example.net'
              id='probe2'
              type='probe'/&gt;
</pre></div><p>

          
</p>
<p>Juliet's server replies with an unavailable notification, mirroring the 'id' of Rome's presence probe because there is no 'id' to preserve from an available notification that her client has sent.
            </p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence from='juliet@example.com'
              id='probe2'
              type='unavailable'/&gt;
</pre></div><p>

          
</p>
<a name="presence-broadcast"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4"></a><h3>4.4.&nbsp;
Subsequent Presence Broadcast</h3>

<a name="presence-broadcast-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4.1"></a><h3>4.4.1.&nbsp;
Client Generation of Subsequent Presence Broadcast</h3>

<p>After sending initial presence, at any time during its session the user's client can update its availability for broadcast by sending a presence stanza with no 'to' address and no 'type' attribute.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;
</pre></div>
<p>The presence broadcast MAY contain the &lt;priority/&gt; element, the &lt;show/&gt; element, and one or more instances of the &lt;status/&gt; element, as well as extended content; details are provided under <a class='info' href='#presence-syntax'>Section&nbsp;4.7<span> (</span><span class='info'>Presence Syntax</span><span>)</span></a>.
</p>
<p>However, a user SHOULD send a presence update only to broadcast information that is relevant to the user's availability for communication or the communication capabilities of the resource.  Information that is not relevant in this way might be of interest to the user's contacts but SHOULD be sent via other means, such as the "publish-subscribe" method described in <a class='info' href='#XEP-0163'>[XEP&#8209;0163]<span> (</span><span class='info'>Saint-Andre, P. and K. Smith, &ldquo;Personal Eventing Protocol,&rdquo; July&nbsp;2010.</span><span>)</span></a>.
</p>
<a name="presence-broadcast-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4.2"></a><h3>4.4.2.&nbsp;
Server Processing of Subsequent Outbound Presence</h3>

<p>Upon receiving a presence stanza expressing updated availability, the user's server MUST broadcast the full XML of that presence stanza to the contacts who are in the user's roster with a subscription type of "from" or "both".
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: RFC 3921 specified that the user's server would check to make sure that it had not received a presence error from the contact before sending subsequent presence notifications. That rule has been removed because this specification uses presence stanzas of type "unsubscribe" (not "error") to solve subscription synchronization problems, in part because such stanzas change the contact's subscription state in the user's roster to either "none" or "to" (see <a class='info' href='#sub-unsub'>Section&nbsp;3.3<span> (</span><span class='info'>Unsubscribing</span><span>)</span></a> and <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>), thus obviating the need for the error check.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Interoperability Note: If the subscription type is "both", some existing server implementations send subsequent presence notifications to a contact only if the contact is online according to the user's server (that is, if the user's server never received a positive indication that the contact is online in response to the presence probe it sent to the contact, the user's server does not send subsequent presence notifications from the user to the contact).  This behavior is perceived to save bandwidth, since most presence subscriptions are bidirectional and many contacts will not be online at any given time.
</p>
</blockquote>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='benvolio@example.net'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='mercutio@example.com'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Implementation Note: See <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a> regarding rules that supplement the foregoing for handling of directed presence.
</p>
</blockquote>

<p>The user's server MUST also send the presence stanza to all of the user's available resources (including the resource that generated the presence notification in the first place).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com/balcony'
              to='juliet@example.com/chamber'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='juliet@example.com/balcony'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;
</pre></div>
<a name="presence-broadcast-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4.3"></a><h3>4.4.3.&nbsp;
Server Processing of Subsequent Inbound Presence</h3>

<p>Upon receiving presence from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
[ ... to resource1 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;

[ ... to resource2 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'&gt;
      &lt;show&gt;away&lt;/show&gt;
    &lt;/presence&gt;
</pre></div>
<a name="presence-broadcast-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4.4"></a><h3>4.4.4.&nbsp;
Client Processing of Subsequent Presence</h3>

<p>From the perspective of the contact's client, there is no significant difference between initial presence broadcast and subsequent presence, so the contact's client follows the rules for processing of inbound presence defined under <a class='info' href='#presence-broadcast-inbound'>Section&nbsp;4.4.3<span> (</span><span class='info'>Server Processing of Subsequent Inbound Presence</span><span>)</span></a>.
</p>
<a name="presence-unavailable"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5"></a><h3>4.5.&nbsp;
Unavailable Presence</h3>

<a name="presence-unavailable-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5.1"></a><h3>4.5.1.&nbsp;
Client Generation of Unavailable Presence</h3>

<p>Before ending its presence session with a server, the user's client SHOULD gracefully become unavailable by sending "unavailable presence", i.e., a presence stanza that possesses no 'to' attribute and that possesses a 'type' attribute whose value is "unavailable".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence type='unavailable'/&gt;
</pre></div>
<p>Optionally, the unavailable presence stanza MAY contain one or more &lt;status/&gt; elements specifying the reason why the user is no longer available.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>However, the unavailable presence stanza MUST NOT contain the &lt;priority/&gt; element or the &lt;show/&gt; element, since these elements apply only to available resources.
</p>
<a name="presence-unavailable-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5.2"></a><h3>4.5.2.&nbsp;
Server Processing of Outbound Unavailable Presence</h3>

<p>The user's server MUST NOT depend on receiving unavailable presence from an available resource, since the resource might become unavailable ungracefully (e.g., the resource's XML stream might be closed with or without a stream error for any of the reasons described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p>
<p>If an available resource becomes unavailable for any reason (either gracefully or ungracefully), the user's server MUST broadcast unavailable presence to all contacts that are in the user's roster with a subscription type of "from" or "both".
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: RFC 3921 specified that the user's server would check to make sure that it had not received a presence error from the contact before sending unavailable presence notifications. That rule has been removed because this specification uses presence stanzas of type "unsubscribe" (not "error") to solve subscription synchronization problems, in part because such stanzas change the contact's subscription state in the user's roster to either "none" or "to" (see <a class='info' href='#sub-unsub'>Section&nbsp;3.3<span> (</span><span class='info'>Unsubscribing</span><span>)</span></a> and <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>), thus obviating the need for the error check.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: Even if the user's server does not broadcast the user's subsequent presence notifications to contacts who are offline (as described under <a class='info' href='#presence-broadcast-outbound'>Section&nbsp;4.4.2<span> (</span><span class='info'>Server Processing of Subsequent Outbound Presence</span><span>)</span></a>), it MUST broadcast the user's unavailable presence notification; if it did not do so, the last presence received by the contact's server would be the user's initial presence for the presence session, with the result that the contact would consider the user to be online.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: See <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a> regarding rules that supplement the foregoing for handling of directed presence.
</p>
</blockquote>

<p>If the unavailable notification was gracefully received from the client, then the server MUST broadcast the full XML of the presence stanza.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='benvolio@example.net'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;

US: &lt;presence from='juliet@example.com/balcony'
              to='mercutio@example.com'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>The user's server MUST also send the unavailable notification to all of the user's available resources (as well as to the resource that generated the unavailable presence in the first place).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence from='juliet@example.com/balcony'
              to='juliet@example.com/chamber'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>If the server detects that the user has gone offline ungracefully, then the server MUST generate the unavailable presence broadcast on the user's behalf.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Any presence stanza with no 'type' attribute and no 'to' attribute that the client sends after the server broadcasts or generates an unavailable presence notification MUST be routed or delivered by the user's server to all subscribers (i.e., MUST be treated as equivalent to initial presence for a new presence session).
</p>
</blockquote>

<a name="presence-unavailable-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5.3"></a><h3>4.5.3.&nbsp;
Server Processing of Inbound Unavailable Presence</h3>

<p>Upon receiving an unavailable notification from the user, the contact's server MUST deliver the user's presence stanza to all of the contact's available resources.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
[ ... to resource1 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;

[ ... to resource2 ... ]

CS: &lt;presence from='juliet@example.com/balcony'
              to='romeo@example.net'
              type='unavailable'&gt;
      &lt;status&gt;going on vacation&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Implementation Note: If the contact's server does not broadcast subsequent presence notifications to users who are offline (as described under <a class='info' href='#presence-broadcast-outbound'>Section&nbsp;4.4.2<span> (</span><span class='info'>Server Processing of Subsequent Outbound Presence</span><span>)</span></a>), it MUST also update its internal representation of which entities are online by noting that the user is unavailable.
</p>
</blockquote>

<a name="presence-unavailable-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5.4"></a><h3>4.5.4.&nbsp;
Client Processing of Unavailable Presence</h3>

<p>From the perspective of the contact's client, there is no significant difference between available presence broadcast and unavailable presence broadcast, so in general the contact's client follows the rules for processing of inbound presence defined under <a class='info' href='#presence-broadcast-inbound'>Section&nbsp;4.4.3<span> (</span><span class='info'>Server Processing of Subsequent Inbound Presence</span><span>)</span></a>.
</p>
<p>However, if the contact receives an unavailable notification from the bare JID of the user (rather than the full JID of a particular available resource), the contact's client SHOULD treat the unavailable notification as applying to all resources.
</p>
<a name="presence-directed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6"></a><h3>4.6.&nbsp;
Directed Presence</h3>

<p>This section supplements the rules for client and server processing of presence notifications and presence probes, but only for the special case of directed presence.
</p>
<a name="presence-directed-considerations"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.1"></a><h3>4.6.1.&nbsp;
General Considerations</h3>

<p>In general, a client sends directed presence when it wishes to share availability information with an entity that is not subscribed to its presence, typically on a temporary basis.  Common uses of directed presence include casual one-to-one chat sessions as described under <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a> and multi-user chat rooms as described in <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2008.</span><span>)</span></a>.
</p>
<p>The temporary relationship established by sharing directed presence with another entity is secondary to the permanent relationship established through a presence subscription.  Therefore, the acts of creating, modifying, or canceling a presence subscription MUST take precedence over the rules specified in the following subsections.  For example, if a user shares directed presence with a contact but then adds the contact to the user's roster by completing the presence subscription "handshake", the user's server MUST treat the contact just as it would any normal subscriber as described under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>, for example, by sending subsequent presence broadcasts to the contact.  As another example, if the user then cancels the contact's subscription to the user's presence, the user's server MUST handle the cancellation just as it normally would as described under <a class='info' href='#sub-cancel'>Section&nbsp;3.2<span> (</span><span class='info'>Canceling a Subscription</span><span>)</span></a>, which includes sending unavailable presence to the contact even if the user has sent directed presence to the contact.
</p>
<p>XMPP servers typically implement directed presence by keeping a list of the entities (bare JIDs or full JIDs) to which a user has sent directed presence during the user's current session for a given resource (full JID), then clearing the list when the user goes offline (e.g., by sending a broadcast presence stanza of type "unavailable").  The server MUST remove from the directed presence list (or its functional equivalent) any entity to which the user sends directed unavailable presence and SHOULD remove any entity that sends unavailable presence to the user.
</p>
<a name="presence-directed-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.2"></a><h3>4.6.2.&nbsp;
Client Generation of Directed Presence</h3>

<p>As noted, directed presence is a client-generated presence stanza with a 'to' attribute whose value is the bare JID or full JID of the other entity and with either no 'type' attribute (indicating availability) or a 'type' attribute whose value is "unavailable".
</p>
<a name="presence-directed-outbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.3"></a><h3>4.6.3.&nbsp;
Server Processing of Outbound Directed Presence</h3>

<p>When the user's server receives a directed presence stanza, it SHOULD process it according to the following rules.
</p>
<p>
          </p>
<ol class="text">
<li>If the user sends directed available or unavailable presence to a contact that is in the user's roster with a subscription type of "from" or "both" after having sent initial presence and before sending unavailable presence broadcast (i.e., during the user's presence session), the user's server MUST locally deliver or remotely route the full XML of that presence stanza but SHOULD NOT otherwise modify the contact's status regarding presence broadcast (i.e., it SHOULD include the contact's JID in any subsequent presence broadcasts initiated by the user).
</li>
<li>If the user sends directed presence to an entity that is not in the user's roster with a subscription type of "from" or "both" after having sent initial presence and before sending unavailable presence broadcast (i.e., during the user's presence session), the user's server MUST locally deliver or remotely route the full XML of that presence stanza to the entity but MUST NOT modify the contact's status regarding available presence broadcast (i.e., it MUST NOT include the entity's JID in any subsequent broadcasts of available presence initiated by the user); however, if the available resource from which the user sent the directed presence becomes unavailable, the user's server MUST route that unavailable presence to the entity (if the user has not yet sent directed unavailable presence to that entity).
</li>
<li>If the user sends directed presence without first sending initial presence or after having sent unavailable presence broadcast (i.e., the resource is connected but not available), the user's server MUST treat the entity to which the user sends directed presence as in case #2 above.
</li>
</ol><p>
        
</p>
<a name="presence-directed-inbound"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.4"></a><h3>4.6.4.&nbsp;
Server Processing of Inbound Directed Presence</h3>

<p>From the perspective of the contact's server, there is no
significant difference between presence broadcast and directed presence, so the
contact's server follows the rules for processing of inbound presence defined
under Sections <a class='info' href='#presence-probe-inbound'>4.3.2<span> (</span><span class='info'>Server Processing of Inbound Presence Probe</span><span>)</span></a>, <a class='info' href='#presence-broadcast-inbound'>4.4.3<span> (</span><span class='info'>Server Processing of Subsequent Inbound Presence</span><span>)</span></a>, and <a class='info' href='#presence-unavailable-inbound'>4.5.3<span> (</span><span class='info'>Server Processing of Inbound Unavailable Presence</span><span>)</span></a>.
</p>
<a name="presence-directed-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.5"></a><h3>4.6.5.&nbsp;
Client Processing of Inbound Directed Presence</h3>

<p>From the perspective of the contact's client, there is no significant difference between presence broadcast and directed presence, so the contact's client follows the rules for processing of inbound presence defined under <a class='info' href='#presence-broadcast-inbound'>Section&nbsp;4.4.3<span> (</span><span class='info'>Server Processing of Subsequent Inbound Presence</span><span>)</span></a>.
</p>
<a name="presence-directed-probe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.6"></a><h3>4.6.6.&nbsp;
Server Processing of Presence Probes</h3>

<p>If a user's client has sent directed presence to another entity (e.g., a one-to-one chat partner or a multi-user chat room), after some time the entity or its server might want to know if the client is still online.  This scenario is especially common in the case of multi-user chat rooms, in which the user might be a participant for a long period of time.  If the user's client goes offline without the chat room being informed (either by the client or the client's server), the user's representation in the room might become a "ghost" that appears to be participating but that in fact is no longer present in the room.  To detect such "ghosts", some multi-user chat room implementations send presence probes to users that have joined the room.
</p>
<p>In the case of directed presence, the probing entity SHOULD send the probe from the JID that received directed presence (whether a full JID or a bare JID).  The probe SHOULD be sent to the user's full JID, not the user's bare JID without a resourcepart, because the temporary "authorization" involved with directed presence is based on the full JID from which the user sent directed presence to the probing entity.  When the user's server receives a probe, it MUST first apply any logic associated with presence subscriptions as described under <a class='info' href='#presence-probe-inbound'>Section&nbsp;4.3.2<span> (</span><span class='info'>Server Processing of Inbound Presence Probe</span><span>)</span></a>.  If the probing entity does not have a subscription to the user's presence, then the server MUST check if the user has sent directed presence to the entity during its current session; if so, the server SHOULD answer the probe with only mere presence of type "available" or "unavailable" (i.e., not including child elements) and only for that full JID (i.e., not for any other resources that might be currently associated with the user's bare JID).
</p>
<a name="presence-syntax"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7"></a><h3>4.7.&nbsp;
Presence Syntax</h3>

<a name="presence-syntax-type"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.1"></a><h3>4.7.1.&nbsp;
Type Attribute</h3>

<p>The absence of a 'type' attribute signals that the relevant entity is available for communication (see <a class='info' href='#presence-initial'>Section&nbsp;4.2<span> (</span><span class='info'>Initial Presence</span><span>)</span></a> and <a class='info' href='#presence-broadcast'>Section&nbsp;4.4<span> (</span><span class='info'>Subsequent Presence Broadcast</span><span>)</span></a>).
</p>
<p>A 'type' attribute with a value of "unavailable" signals that the relevant entity is not available for communication (see <a class='info' href='#presence-unavailable'>Section&nbsp;4.5<span> (</span><span class='info'>Unavailable Presence</span><span>)</span></a>).
</p>
<p>The XMPP presence stanza is also used to negotiate and manage subscriptions to the presence of other entities.  These tasks are completed via presence stanzas of type "subscribe", "unsubscribe", "subscribed", and "unsubscribed" as described under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>.
</p>
<p>If a user and contact are associated with different XMPP servers, those servers also use a special presence stanza of type "probe" in order to determine the availability of the entity on the peer server; details are provided under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.  Clients SHOULD NOT send presence stanzas of type "probe".
</p>
<p>The values of the 'type' attribute can be summarized as follows:
</p>
<p>
          </p>
<ul class="text">
<li>error -- An error has occurred regarding processing of a previously sent presence stanza; if the presence stanza is of type "error", it MUST include an &lt;error/&gt; child element (refer to <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
<li>probe -- A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
</li>
<li>subscribe -- The sender wishes to subscribe to the recipient's presence.
</li>
<li>subscribed -- The sender has allowed the recipient to receive their presence.
</li>
<li>unavailable -- The sender is no longer available for communication.
</li>
<li>unsubscribe -- The sender is unsubscribing from the receiver's presence.
</li>
<li>unsubscribed -- The subscription request has been denied or a previously granted subscription has been canceled.
</li>
</ul><p>
        
</p>
<p>If the value of the 'type' attribute is not one of the foregoing values, the recipient or an intermediate router SHOULD return a stanza error of &lt;bad-request/&gt;.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: There is no default value for the 'type' attribute of the &lt;presence/&gt; element.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: There is no value of "available" for the 'type' attribute of the &lt;presence/&gt; element.
</p>
</blockquote>

<a name="presence-syntax-children"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.2"></a><h3>4.7.2.&nbsp;
Child Elements</h3>

<p>In accordance with the default namespace declaration, a presence stanza is qualified by the 'jabber:client' or 'jabber:server' namespace, which defines certain child elements of presence stanzas, in particular the &lt;show/&gt;, &lt;status/&gt;, and &lt;priority/&gt; elements.  These child elements are used to provide more detailed information about an entity's availability.  Typically these child elements are included only if the presence stanza possesses no 'type' attribute, although exceptions are noted in the text that follows.
</p>
<a name="presence-syntax-children-show"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.2.1"></a><h3>4.7.2.1.&nbsp;
Show Element</h3>

<p>The OPTIONAL &lt;show/&gt; element specifies the particular availability sub-state of an entity or a specific resource thereof.  A presence stanza MUST NOT contain more than one &lt;show/&gt; element.  There are no attributes defined for the &lt;show/&gt; element.  The &lt;show/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).  The XML character data of the &lt;show/&gt; element is not meant for presentation to a human user.  The XML character data MUST be one of the following (additional availability states could be defined through extended content elements):
</p>
<p>
            </p>
<ul class="text">
<li>away -- The entity or resource is temporarily away.
</li>
<li>chat -- The entity or resource is actively interested in chatting.
</li>
<li>dnd -- The entity or resource is busy (dnd = "Do Not Disturb").
</li>
<li>xa -- The entity or resource is away for an extended period (xa = "eXtended Away").
</li>
</ul><p>
          
</p>
<p>If no &lt;show/&gt; element is provided, the entity is assumed to be online and available.
</p>
<p>Any specialized processing of availability states by recipients and intermediate routers is up to the implementation (e.g., incorporation of availability states into stanza routing and delivery logic).
</p>
<a name="presence-syntax-children-status"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.2.2"></a><h3>4.7.2.2.&nbsp;
Status Element</h3>

<p>The OPTIONAL &lt;status/&gt; element contains human-readable XML character data specifying a natural-language description of an entity's availability.  It is normally used in conjunction with the show element to provide a detailed description of an availability state (e.g., "In a meeting") when the presence stanza has no 'type' attribute.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net/orchard'
          xml:lang='en'&gt;
  &lt;show&gt;dnd&lt;/show&gt;
  &lt;status&gt;Wooing Juliet&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<p>There are no attributes defined for the &lt;status/&gt; element, with the exception of the 'xml:lang' attribute inherited from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>.  The &lt;status/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).  Multiple instances of the &lt;status/&gt; element MAY be included, but only if each instance possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, which from the sender's perspective can include the XML stream header as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net/orchard'
          id='jx62vs97'
          xml:lang='en'&gt;
  &lt;show&gt;dnd&lt;/show&gt;
  &lt;status&gt;Wooing Juliet&lt;/status&gt;
  &lt;status xml:lang='cs'&gt;Dvo&amp;#x0159;&amp;#x00ED;m se Julii&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<p>A presence stanza of type "unavailable" MAY also include a &lt;status/&gt; element to provide detailed information about why the entity is going offline.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net/orchard'
          id='oy6sb241'
          type='unavailable'
          xml:lang='en'&gt;
  &lt;status&gt;Busy IRL&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<p>The &lt;status/&gt; child MAY also be sent in a subscription-related presence stanza (i.e., type "subscribe", "subscribed", "unsubscribe", or "unsubscribed") to provide a description of the action.  An interactive client MAY present this &lt;status/&gt; information to a human user (see <a class='info' href='#security'>Section&nbsp;11<span> (</span><span class='info'>Security Considerations</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net'
          id='uc51xs63'
          to='nurse@example.com'
          type='subscribe'&gt;
  &lt;status&gt;Hi, Juliet told me to add you to my buddy list.&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<a name="presence-syntax-children-priority"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.2.3"></a><h3>4.7.2.3.&nbsp;
Priority Element</h3>

<p>The OPTIONAL &lt;priority/&gt; element contains non-human-readable XML character data that specifies the priority level of the resource.  The value MUST be an integer between -128 and +127.  A presence stanza MUST NOT contain more than one &lt;priority/&gt; element.  There are no attributes defined for the &lt;priority/&gt; element.  The &lt;priority/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence xml:lang='en'&gt;
  &lt;show&gt;dnd&lt;/show&gt;
  &lt;status&gt;Wooing Juliet&lt;/status&gt;
  &lt;status xml:lang='cs'&gt;Dvo&amp;#x0159;&amp;#x00ED;m se Julii&lt;/status&gt;
  &lt;priority&gt;1&lt;/priority&gt;
&lt;/presence&gt;
</pre></div>
<p>If no priority is provided, the processing server or client MUST consider the priority to be zero ("0").
</p>
<p>The client's server MAY override the priority value
          provided by the client (e.g., in order to impose a message
          handling rule of delivering a message intended for the
          account's bare JID to all of the account's available
          resources). If the server does so, it MUST communicate the modified priority value when it echoes the client's presence back to itself and sends the presence notification to the user's contacts (because this modified priority value is typically the default value of zero, communicating the modified priority value can be done by not including the &lt;priority/&gt; child element).
</p>
<p>For information regarding the semantics of priority values in stanza processing within instant messaging and presence applications, refer to <a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>.
</p>
<a name="presence-extended"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.3"></a><h3>4.7.3.&nbsp;
Extended Content</h3>

<p>As described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, an XML stanza MAY contain any child element that is qualified by a namespace other than the default namespace; this applies to the presence stanza as well.
</p>
<p>(In the following example, the presence stanza includes entity capabilities information as defined in <a class='info' href='#XEP-0115'>[XEP&#8209;0115]<span> (</span><span class='info'>Hildebrand, J., Saint-Andre, P., and R. Tron&#xE7;on, &ldquo;Entity Capabilities,&rdquo; February&nbsp;2008.</span><span>)</span></a>.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net'&gt;
  &lt;c xmlns='http://jabber.org/protocol/caps'
     hash='sha-1'
     node='http://psi-im.org'
     ver='q07IKJEyjvHSyhy//CH0CxmKi8w='/&gt;
&lt;/presence&gt;
</pre></div>
<p>Any extended content included in a presence stanza SHOULD represent aspects of an entity's availability for communication or provide information about communication-related capabilities.
</p>
<a name="message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5"></a><h3>5.&nbsp;
Exchanging Messages</h3>

<p>Once a client has authenticated with a server and bound a resource to an XML stream as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, an XMPP server will route XML stanzas to and from that client.  One kind of stanza that can be exchanged is &lt;message/&gt; (if, that is, messaging functionality is enabled on the server).  Exchanging messages is a basic use of XMPP and occurs when a user generates a message stanza that is addressed to another entity.  As defined under <a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>, the sender's server is responsible for delivering the message to the intended recipient (if the recipient is on the same local server) or for routing the message to the recipient's server (if the recipient is on a remote server).  Thus a message stanza is used to "push" information to another entity.
</p>
<a name="message-chat"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.1"></a><h3>5.1.&nbsp;
One-to-One Chat Sessions</h3>

<p>In practice, instant messaging activity between human users tends to occur in the form of a conversational burst that we call a "chat session": the exchange of multiple messages between two parties in relatively rapid succession within a relatively brief period of time.
</p>
<p>When a human user intends to engage in such a chat session with a contact (rather than sending a single message to which no reply is expected), the message type generated by the user's client SHOULD be "chat" and the contact's client SHOULD preserve that message type in subsequent replies.   The user's client also SHOULD include a &lt;thread/&gt; element with its initial message, which the contact's client SHOULD also preserve during the life of the chat session (see <a class='info' href='#message-syntax-thread'>Section&nbsp;5.2.5<span> (</span><span class='info'>Thread Element</span><span>)</span></a>).
</p>
<p>The user's client SHOULD address the initial message in a chat session to the bare JID &lt;contact@domainpart&gt; of the contact (rather than attempting to guess an appropriate full JID &lt;contact@domainpart/resourcepart&gt; based on the &lt;show/&gt;, &lt;status/&gt;, or &lt;priority/&gt; value of any presence notifications it might have received from the contact).  Until and unless the user's client receives a reply from the contact, it SHOULD send any further messages to the contact's bare JID.  The contact's client SHOULD address its replies to the user's full JID &lt;user@domainpart/resourcepart&gt; as provided in the 'from' address of the initial message.  Once the user's client receives a reply from the contact's full JID, it SHOULD address its subsequent messages to the contact's full JID as provided in the 'from' address of the contact's replies, thus "locking in" on that full JID.  A client SHOULD "unlock" after having received a &lt;message/&gt; or &lt;presence/&gt; stanza from any other resource controlled by the peer (or a presence stanza from the locked resource); as a result, it SHOULD address its next message(s) in the chat session to the bare JID of the peer (thus "unlocking" the previous "lock") until it receives a message from one of the peer's full JIDs.
</p>
<p>When two parties engage in a chat session but do not share presence with each other based on a presence subscription, they SHOULD send directed presence to each other so that either party can easily discover if the peer goes offline during the course of the chat session.  However, a client MUST provide a way for a user to disable such presence sharing globally or to enable it only with particular entities.  Furthermore, a party SHOULD send directed unavailable presence to the peer when it has reason to believe that the chat session is over (e.g., if, after some reasonable amount of time, no subsequent messages have been exchanged between the parties).
</p>
<p>An example of a chat session is provided under <a class='info' href='#session'>Section&nbsp;7<span> (</span><span class='info'>A Sample Session</span><span>)</span></a>.
</p>
<a name="message-syntax"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2"></a><h3>5.2.&nbsp;
Message Syntax</h3>

<p>The following sections describe the syntax of the &lt;message/&gt; stanza.
</p>
<a name="message-syntax-to"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2.1"></a><h3>5.2.1.&nbsp;
To Attribute</h3>

<p>An instant messaging client specifies an intended recipient for a message by providing the JID of the intended recipient in the 'to' attribute of the &lt;message/&gt; stanza.
</p>
<p>If the message is being sent outside the context of any existing chat session or received message, the value of the 'to' address SHOULD be of the form &lt;localpart@domainpart&gt; rather than of the form &lt;localpart@domainpart/resourcepart&gt; (see <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    id='ktx72v49'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>If the message is being sent in reply to a message previously received from an address of the form &lt;localpart@domainpart/resourcepart&gt; (e.g., within the context of a one-to-one chat session as described under <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a>), the value of the 'to' address SHOULD be of the form &lt;localpart@domainpart/resourcepart&gt; rather than of the form &lt;localpart@domainpart&gt; unless the sender has knowledge (e.g., via presence) that the intended recipient's resource is no longer available.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='romeo@example.net/orchard'
    id='sl3nx51f'
    to='juliet@example.com/balcony'
    type='chat'
    xml:lang='en'&gt;
  &lt;body&gt;Neither, fair saint, if either thee dislike.&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<a name="message-syntax-type"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2.2"></a><h3>5.2.2.&nbsp;
Type Attribute</h3>

<p>Common uses of the message stanza in instant messaging applications include: single messages; messages sent in the context of a one-to-one chat session; messages sent in the context of a multi-user chat room; alerts, notifications, or other information to which no reply is expected; and errors.  These uses are differentiated via the 'type' attribute.  Inclusion of the 'type' attribute is RECOMMENDED.  If included, the 'type' attribute MUST have one of the following values:
</p>
<p>
        </p>
<ul class="text">
<li>chat -- The message is sent in the context of a one-to-one chat session.  Typically an interactive client will present a message of type "chat" in an interface that enables one-to-one chat between the two parties, including an appropriate conversation history.  Detailed recommendations regarding one-to-one chat sessions are provided under <a class='info' href='#message-chat'>Section&nbsp;5.1<span> (</span><span class='info'>One-to-One Chat Sessions</span><span>)</span></a>.
</li>
<li>error -- The message is generated by an entity that experiences an error when processing a message received from another entity (for details regarding stanza error syntax, refer to <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).  A client that receives a message of type "error" SHOULD present an appropriate interface informing the original sender regarding the nature of the error.
</li>
<li>groupchat -- The message is sent in the context of a multi-user chat environment (similar to that of <a class='info' href='#IRC'>[IRC]<span> (</span><span class='info'>Kalt, C., &ldquo;Internet Relay Chat: Architecture,&rdquo; April&nbsp;2000.</span><span>)</span></a>).  Typically a receiving client will present a message of type "groupchat" in an interface that enables many-to-many chat between the parties, including a roster of parties in the chatroom and an appropriate conversation history.  For detailed information about XMPP-based groupchat, refer to <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2008.</span><span>)</span></a>.
</li>
<li>headline -- The message provides an alert, a notification, or other transient information to which no reply is expected (e.g., news headlines, sports updates, near-real-time market data, or syndicated content).  Because no reply to the message is expected, typically a receiving client will present a message of type "headline" in an interface that appropriately differentiates the message from standalone messages, chat messages, and groupchat messages (e.g., by not providing the recipient with the ability to reply).  If the 'to' address is the bare JID, the receiving server SHOULD deliver the message to all of the recipient's available resources with non-negative presence priority and MUST deliver the message to at least one of those resources; if the 'to' address is a full JID and there is a matching resource, the server MUST deliver the message to that resource; otherwise the server MUST either silently ignore the message or return an error (see <a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>).
</li>
<li>normal -- The message is a standalone message that is sent outside the context of a one-to-one conversation or groupchat, and to which it is expected that the recipient will reply.  Typically a receiving client will present a message of type "normal" in an interface that enables the recipient to reply, but without a conversation history.  The default value of the 'type' attribute is "normal".
</li>
</ul><p>
      
</p>
<p>An IM application SHOULD support all of the foregoing message types.  If an application receives a message with no 'type' attribute or the application does not understand the value of the 'type' attribute provided, it MUST consider the message to be of type "normal" (i.e., "normal" is the default).
</p>
<p>Guidelines for server handling of different message types is provided under <a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>.
</p>
<p>Although the 'type' attribute is OPTIONAL, it is considered polite to mirror the type in any replies to a message; furthermore, some specialized applications (e.g., a multi-user chat service) MAY at their discretion enforce the use of a particular message type (e.g., type='groupchat').
</p>
<a name="message-syntax-body"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2.3"></a><h3>5.2.3.&nbsp;
Body Element</h3>

<p>The &lt;body/&gt; element contains human-readable XML character data that specifies the textual contents of the message; this child element is normally included but is OPTIONAL.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    id='b4vs9km4'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>There are no attributes defined for the &lt;body/&gt; element, with the exception of the 'xml:lang' attribute.  Multiple instances of the &lt;body/&gt; element MAY be included in a message stanza for the purpose of providing alternate versions of the same body, but only if each instance possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, which from the sender's perspective can include the XML stream header as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    id='z94nb37h'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
  &lt;body xml:lang='cs'&gt;
     Pro&amp;#x010D;e&amp;#x017D; jsi ty, Romeo?
   &lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>The &lt;body/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).
</p>
<a name="message-syntax-subject"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2.4"></a><h3>5.2.4.&nbsp;
Subject Element</h3>

<p>The &lt;subject/&gt; element contains human-readable XML character data that specifies the topic of the message.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    id='c8xg3nf8'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;subject&gt;I implore you!&lt;/subject&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>There are no attributes defined for the &lt;subject/&gt; element, with the exception of the 'xml:lang' attribute inherited from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>.  Multiple instances of the &lt;subject/&gt; element MAY be included for the purpose of providing alternate versions of the same subject, but only if each instance possesses an 'xml:lang' attribute with a distinct language value (either explicitly or by inheritance from the 'xml:lang' value of an element farther up in the XML hierarchy, which from the sender's perspective can include the XML stream header as described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    id='jk3v47gw'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;subject&gt;I implore you!&lt;/subject&gt;
  &lt;subject xml:lang='cs'&gt;
    &amp;#x00DA;p&amp;#x011B;nliv&amp;#x011B; pros&amp;#x00ED;m!
  &lt;/subject&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
  &lt;body xml:lang='cs'&gt;
     Pro&amp;#x010D;e&amp;#x017E; jsi ty, Romeo?
   &lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>The &lt;subject/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).
</p>
<a name="message-syntax-thread"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2.5"></a><h3>5.2.5.&nbsp;
Thread Element</h3>

<p>The primary use of the XMPP &lt;thread/&gt; element is to uniquely identify a conversation thread or "chat session" between two entities instantiated by &lt;message/&gt; stanzas of type 'chat'.  However, the XMPP &lt;thread/&gt; element MAY also be used to uniquely identify an analogous thread between two entities instantiated by &lt;message/&gt; stanzas of type 'headline' or 'normal', or among multiple entities in the context of a multi-user chat room instantiated by &lt;message/&gt; stanzas of type 'groupchat'. It MAY also be used for &lt;message/&gt; stanzas not related to a human conversation, such as a game session or an interaction between plugins.  The &lt;thread/&gt; element is not used to identify individual messages, only conversations or messaging sessions.
</p>
<p>The inclusion of the &lt;thread/&gt; element is OPTIONAL.  Because the &lt;thread/&gt; element identifies the particular conversation thread to which a message belongs, a message stanza MUST NOT contain more than one &lt;thread/&gt; element.
</p>
<p>The &lt;thread/&gt; element MAY possess a 'parent' attribute that identifies another thread of which the current thread is an offshoot or child.  The 'parent' attribute MUST conform to the syntax of the &lt;thread/&gt; element itself and its value MUST be different from the XML character data of the &lt;thread/&gt; element on which the 'parent' attribute is included.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: The ability to specify both a parent thread and a child thread introduces the possibility of conflicts between thread identifiers for overlapping threads.  For example, one &lt;thread/&gt; element might contain XML character data of "foo" and a 'parent' attribute whose value is "bar", a second &lt;thread/&gt; element might contain XML character data of "bar" and a 'parent' attribute whose value is "baz", and a third &lt;thread/&gt; element might contain XML character data of "baz" and a 'parent' attribute whose value is once again "foo".  It is up to the implementation how it will treat conflicts between such overlapping thread identifiers (e.g., whether it will "chain together" thread identifiers by showing "foo" as both a parent and grandchild of "baz" in a multi-level user interface, or whether it will show only one level of dependency at a time).
</p>
</blockquote>

<p>The value of the &lt;thread/&gt; element is not human-readable and MUST be treated as opaque by entities; no semantic meaning can be derived from it, and only exact comparisons can be made against it.  The value of the &lt;thread/&gt; element MUST uniquely identify the conversation thread either between the conversation partners or more generally (one way to ensure uniqueness is by generating a universally unique identifier (UUID) as described in <a class='info' href='#UUID'>[UUID]<span> (</span><span class='info'>Leach, P., Mealling, M., and R. Salz, &ldquo;A Universally Unique IDentifier (UUID) URN Namespace,&rdquo; July&nbsp;2005.</span><span>)</span></a>).
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: An application that generates a ThreadID MUST ensure that it does not reveal identifying information about the entity (e.g., the MAC address of the device on which the XMPP application is running).
</p>
</blockquote>

<p>The &lt;thread/&gt; element MUST NOT contain mixed content (as defined in Section 3.2.2 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;subject&gt;I implore you!&lt;/subject&gt;
  &lt;subject xml:lang='cs'&gt;
    &amp;#x00DA;p&amp;#x011B;nliv&amp;#x011B; pros&amp;#x00ED;m!
  &lt;/subject&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
  &lt;body xml:lang='cs'&gt;
     Pro&amp;#x010D;e&amp;#x017E; jsi ty, Romeo?
  &lt;/body&gt;
  &lt;thread parent='e0ffe42b28561960c6b12b944a092794b9683a38'&gt;
    0e3141cd80894871a68e6fe6b1ec56fa
  &lt;/thread&gt;
&lt;/message&gt;
</pre></div>
<p>For detailed recommendations regarding use of the &lt;thread/&gt; element, refer to <a class='info' href='#XEP-0201'>[XEP&#8209;0201]<span> (</span><span class='info'>Saint-Andre, P., Paterson, I., and K. Smith, &ldquo;Best Practices for Message Threads,&rdquo; November&nbsp;2010.</span><span>)</span></a>.
</p>
<a name="message-syntax-extended"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3"></a><h3>5.3.&nbsp;
Extended Content</h3>

<p>As described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, an XML stanza MAY contain any child element that is qualified by a namespace other than the default namespace; this applies to the message stanza as well.  Guidelines for handling extended content on the part of both routing servers and end recipients are provided in Section 8.4 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>(In the following example, the message stanza includes an XHTML-formatted version of the message as defined in <a class='info' href='#XEP-0071'>[XEP&#8209;0071]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XHTML-IM,&rdquo; September&nbsp;2008.</span><span>)</span></a>).)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message
    from='juliet@example.com/balcony'
    to='romeo@example.net'
    type='chat'
    xml:lang='en'&gt;
  &lt;body&gt;Wherefore art thou, Romeo?&lt;/body&gt;
  &lt;html xmlns='http://jabber.org/protocol/xhtml-im'&gt;
    &lt;body xmlns='http://www.w3.org/1999/xhtml'&gt;
      &lt;p&gt;Wherefore &lt;span style='font-style: italic'&gt;art&lt;/span&gt;
      thou, &lt;span style='color:red'&gt;Romeo&lt;/span&gt;?&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
&lt;/message&gt;
</pre></div>
<a name="iq"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6"></a><h3>6.&nbsp;
Exchanging IQ Stanzas</h3>

<p>As described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, IQ stanzas provide a structured request-response mechanism.  The basic semantics of that mechanism (e.g., that the 'id' attribute is mandatory) are defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, whereas the specific semantics needed to complete particular use cases are defined in all instances by the extended namespace that qualifies the direct child element of an IQ stanza of type "get" or "set".  The 'jabber:client' and 'jabber:server' namespaces do not define any children of IQ stanzas other than the &lt;error/&gt; element common to all stanza types.  This document defines one such extended namespace, for <a class='info' href='#roster'>Managing the Roster<span> (</span><span class='info'>Managing the Roster</span><span>)</span></a>.  However, an IQ stanza MAY contain structured information qualified by any extended namespace.
</p>
<a name="session"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7"></a><h3>7.&nbsp;
A Sample Session</h3>

<p>The examples in this section illustrate a possible instant messaging and presence session.  The user is &lt;romeo@example.net&gt;, he has an available resource whose resourcepart is "orchard", and he has the following individuals in his roster:
</p>
<p>
      </p>
<ul class="text">
<li>&lt;juliet@example.com&gt; (subscription="both" and she has two available resources, "chamber" and "balcony")
</li>
<li>&lt;benvolio@example.net&gt; (subscription="to")
</li>
<li>&lt;mercutio@example.org&gt; (subscription="from")
</li>
</ul><p>
    
</p>
<p>First, the user completes the preconditions (stream establishment, TLS and SASL negotiation, and resource binding) described in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>; those protocol flows are not reproduced here.
</p>
<p>Next, the user requests his roster.
</p>
<p>Example 1: User requests current roster from server
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;iq from='romeo@example.net/orchard'
        id='hf61v3n7'
        type='get'&gt;
      &lt;query xmlns='jabber:iq:roster'/&gt;
    &lt;/iq&gt;
</pre></div>
<p>Example 2: User receives roster from server
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;iq id='hf61v3n7'
        to='romeo@example.net/orchard'
        type='result'&gt;
      &lt;query xmlns='jabber:iq:roster'&gt;
        &lt;item jid='juliet@example.com'
              name='Juliet'
              subscription='both'&gt;
          &lt;group&gt;Friends&lt;/group&gt;
        &lt;/item&gt;
        &lt;item jid='benvolio@example.org'
              name='Benvolio'
              subscription='to'/&gt;
        &lt;item jid='mercutio@example.org'
              name='Mercutio'
              subscription='from'/&gt;
      &lt;/query&gt;
    &lt;/iq&gt;
</pre></div>
<p>Now the user begins a presence session.
</p>
<p>Example 3: User sends initial presence
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence/&gt;
</pre></div>
<p>Example 4: User's server sends presence probes to contacts with subscription="to" and subscription="both" on behalf of the user
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence
        from='romeo@example.net'
        to='juliet@example.com'
        type='probe'/&gt;

US: &lt;presence
        from='romeo@example.net'
        to='benvolio@example.org'
        type='probe'/&gt;
</pre></div>
<p>Example 5: User's server sends initial presence to contacts with subscription="from" and subscription="both" on behalf of the user's available resource, as well as to user
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'/&gt;

US: &lt;presence
        from='romeo@example.net/orchard'
        to='mercutio@example.org'/&gt;

US: &lt;presence
        from='romeo@example.net/orchard'
        to='romeo@example.net'/&gt;
</pre></div>
<p>Example 6: Contacts' servers reply to presence probe on behalf of all available resources
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence
        from='juliet@example.com/balcony'
        to='romeo@example.net'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;be right back&lt;/status&gt;
      &lt;priority&gt;0&lt;/priority&gt;
    &lt;/presence&gt;

CS: &lt;presence
        from='juliet@example.com/chamber'
        to='romeo@example.net'&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;

CS: &lt;presence
        from='benvolio@example.org/pda'
        to='romeo@example.net'
        xml:lang='en'&gt;
      &lt;show&gt;dnd&lt;/show&gt;
      &lt;status&gt;gallivanting&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>Example 7: Contacts' servers deliver user's initial presence to all available resources
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'/&gt;

CS: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'/&gt;

CS: &lt;presence
        from='romeo@example.net/orchard'
        to='mercutio@example.org'/&gt;
</pre></div>
<p>Example 8: User sends directed presence to another user not in his roster
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence
        from='romeo@example.net/orchard'
        to='nurse@example.com'
        xml:lang='en'&gt;
      &lt;show&gt;dnd&lt;/show&gt;
      &lt;status&gt;courting Juliet&lt;/status&gt;
      &lt;priority&gt;0&lt;/priority&gt;
    &lt;/presence&gt;
</pre></div>
<p>Now the user engages in a chat session with one of his contacts.
</p>
<p>Example 9: A threaded conversation
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;message
        from='juliet@example.com/balcony'
        to='romeo@example.net'
        type='chat'
        xml:lang='en'&gt;
      &lt;body&gt;My ears have not yet drunk a hundred words&lt;/body&gt;
      &lt;thread&gt;e0ffe42b28561960c6b12b944a092794b9683a38&lt;/thread&gt;
    &lt;/message&gt;

CC: &lt;message
        from='juliet@example.com/balcony'
        to='romeo@example.net'
        type='chat'
        xml:lang='en'&gt;
      &lt;body&gt;Of that tongue's utterance, yet I know the sound:&lt;/body&gt;
      &lt;thread&gt;e0ffe42b28561960c6b12b944a092794b9683a38&lt;/thread&gt;
    &lt;/message&gt;

CC: &lt;message
        from='juliet@example.com/balcony'
        to='romeo@example.net'
        type='chat'
        xml:lang='en'&gt;
      &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
      &lt;thread&gt;e0ffe42b28561960c6b12b944a092794b9683a38&lt;/thread&gt;
    &lt;/message&gt;

UC: &lt;message
        from='romeo@example.net/orchard'
        to='juliet@example.com/balcony'
        type='chat'
        xml:lang='en'&gt;
      &lt;body&gt;Neither, fair saint, if either thee dislike.&lt;/body&gt;
      &lt;thread&gt;e0ffe42b28561960c6b12b944a092794b9683a38&lt;/thread&gt;
    &lt;/message&gt;

CC: &lt;message
        from='juliet@example.com/balcony'
        to='romeo@example.net/orchard'
        type='chat'
        xml:lang='en'&gt;
      &lt;body&gt;How cam'st thou hither, tell me, and wherefore?&lt;/body&gt;
      &lt;thread&gt;e0ffe42b28561960c6b12b944a092794b9683a38&lt;/thread&gt;
    &lt;/message&gt;
</pre></div>
<p>And so on.
</p>
<p>The user can also send subsequent presence broadcast.
</p>
<p>Example 10: User sends updated available presence for broadcast
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;
</pre></div>
<p>Example 11: User's server broadcasts updated presence to the contacts who have a subscription of type "both" or "from" (but not to the entity to which the user sent directed presence)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;

US: &lt;presence
        from='romeo@example.net/orchard'
        to='mercutio@example.org'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;
</pre></div>
<p>Example 12: Contacts' servers deliver updated presence
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;

CS: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;

CS: &lt;presence
        from='romeo@example.net/orchard'
        to='mercutio@example.org'
        xml:lang='en'&gt;
      &lt;show&gt;away&lt;/show&gt;
      &lt;status&gt;I shall return!&lt;/status&gt;
      &lt;priority&gt;1&lt;/priority&gt;
    &lt;/presence&gt;
</pre></div>
<p>Example 13: One of the contact's resources broadcasts unavailable notification
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CC: &lt;presence from='juliet@example.com/chamber' type='unavailable'/&gt;
</pre></div>
<p>Example 14: Contact's server sends unavailable notification to user
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
CS: &lt;presence
        from='juliet@example.com/chamber'
        to='romeo@example.net'
        type='unavailable'/&gt;
</pre></div>
<p>Now the user ends his presence session.
</p>
<p>Example 15: User sends unavailable notification
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;presence type='unavailable' xml:lang='en'&gt;
      &lt;status&gt;gone home&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>Example 16: User's server broadcasts unavailable notification to contacts as well as to the entity to whom the user sent directed presence
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;presence
        from='romeo@example.net/orchard'
        to='juliet@example.com'
        type='unavailable'
        xml:lang='en'&gt;
      &lt;status&gt;gone home&lt;/status&gt;
    &lt;/presence&gt;

US: &lt;presence
        from='romeo@example.net/orchard'
        to='mercutio@example.org'
        type='unavailable'
        xml:lang='en'&gt;
      &lt;status&gt;gone home&lt;/status&gt;
    &lt;/presence&gt;

US: &lt;presence
        from='romeo@example.net/orchard'
        to='nurse@example.com'
        type='unavailable'
        xml:lang='en'&gt;
      &lt;status&gt;gone home&lt;/status&gt;
    &lt;/presence&gt;
</pre></div>
<p>Finally the user closes his stream and the server responds in kind.
</p>
<p>Example 17: User closes stream
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
UC: &lt;/stream:stream&gt;
</pre></div>
<p>Example 18: User's server closes stream
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
US: &lt;/stream:stream&gt;
</pre></div>
<p>THE END
</p>
<a name="rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8"></a><h3>8.&nbsp;
Server Rules for Processing XML Stanzas</h3>

<p>Basic server rules for processing XML stanzas are defined in
    <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, and the reader is referred to that specification for underlying rules and security implications.  This section defines supplementary rules for XMPP instant messaging and presence servers.
</p>
<p>Some delivery rules defined in this section specify the use of "offline storage", i.e., the server's act of storing a message stanza on behalf of the user and then delivering it when the user next becomes available.  For recommendations regarding offline message storage, refer to <a class='info' href='#XEP-0160'>[XEP&#8209;0160]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices for Handling Offline Messages,&rdquo; January&nbsp;2006.</span><span>)</span></a>.
</p>
<a name="rules-general"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1"></a><h3>8.1.&nbsp;
General Considerations</h3>

<p><a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> discusses general considerations for stanza delivery, in particular the tradeoffs between (i) providing an acceptable level of service regarding stanza delivery and (ii) preventing directory harvesting attacks and presence leaks.  However, the concept of a directory harvesting attack does not apply if a contact is known to and trusted by a user (because the contact is in the user's roster as described under <a class='info' href='#roster'>Section&nbsp;2<span> (</span><span class='info'>Managing the Roster</span><span>)</span></a>).  Similarly, the concept of a presence leak does not apply if a contact is authorized to know a user's presence (by means of a presence subscription as described under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>) or if the user has voluntarily sent presence to an entity (by means of directed presence as described under <a class='info' href='#presence-directed'>Section&nbsp;4.6<span> (</span><span class='info'>Directed Presence</span><span>)</span></a>).  Therefore, in cases where the following sections guard against directory harvesting attacks and presence leaks by providing an alternative of (a) silently ignoring a stanza or (b) returning an error, a server SHOULD return an error if the originating entity is in the user's roster (when the error would reveal whether the user's account exists) or is authorized to receive presence from the user or has received directed presence from the user (when the error would reveal the presence of a user's resource).
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: All of the stanza processing rules described below are defined with the understanding that they will be applied subject to enforcement of relevant privacy and security policies, such as those deployed by means of <a class='info' href='#XEP-0016'>[XEP&#8209;0016]<span> (</span><span class='info'>Millard, P. and P. Saint-Andre, &ldquo;Privacy Lists,&rdquo; February&nbsp;2007.</span><span>)</span></a> or <a class='info' href='#XEP-0191'>[XEP&#8209;0191]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Simple Communications Blocking,&rdquo; February&nbsp;2007.</span><span>)</span></a>.  The conformance language (MUST, SHOULD, etc.) in the following sections is not meant to override any such local service policies.
</p>
</blockquote>

<a name="rules-noto"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.2"></a><h3>8.2.&nbsp;
No 'to' Address</h3>

<p>If the stanza possesses no 'to' attribute, the rules defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> apply.
</p>
<a name="rules-remote"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3"></a><h3>8.3.&nbsp;
Remote Domain</h3>

<p>If the domainpart of the address contained in the 'to' attribute of an outbound stanza does not match a configured domain of the server itself, then the rules provided in Section 10.4 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> apply.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: RFC 3921 specified how to use the _im._xmpp and _pres._xmpp SRV records <a class='info' href='#IMP-SRV'>[IMP&#8209;SRV]<span> (</span><span class='info'>Peterson, J., &ldquo;Address Resolution for Instant Messaging and Presence,&rdquo; August&nbsp;2004.</span><span>)</span></a> as a fallback method for discovering whether a remote instant messaging and presence service communicates via XMPP.  Because those SRV records have not been widely deployed, this document no longer specifies their use, and new implementations are not encouraged.
</p>
</blockquote>

<a name="rules-local"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.4"></a><h3>8.4.&nbsp;
Local Domain</h3>

<p>If the domainpart of the JID contained in the 'to' attribute matches one of the configured domains of the server, the domain is serviced by the server itself (not by a specialized local service), and the JID is of the form &lt;domainpart&gt; or &lt;domainpart/resourcepart&gt;, the rules defined in <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> apply.
</p>
<a name="rules-localpart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5"></a><h3>8.5.&nbsp;
Local User</h3>

<p>If the 'to' address specifies a bare JID &lt;localpart@domainpart&gt; or full JID &lt;localpart@domainpart/resourcepart&gt; where the domainpart of the JID matches a configured domain that is serviced by the server itself, the server MUST proceed as follows.
</p>
<a name="rules-localpart-nosuchuser"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.1"></a><h3>8.5.1.&nbsp;
No Such User</h3>

<p>If the user account identified by the 'to' attribute does not exist, how the stanza is processed depends on the stanza type.
</p>
<p>
          </p>
<ul class="text">
<li>For an IQ stanza, the server MUST return a &lt;service-unavailable/&gt; stanza error to the sender.
</li>
<li>For a message stanza, the server MUST either (a) silently ignore the message or (b) return a &lt;service-unavailable/&gt; stanza error to the sender.
</li>
<li>For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the server MUST silently ignore the stanza.
</li>
<li>For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST silently ignore the stanza.
</li>
<li>For a presence stanza of type "probe", the server MUST either (a) silently ignore the stanza or (b) return a presence stanza of type "unsubscribed".
</li>
</ul><p>
        
</p>
<a name="rules-localpart-barejid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2"></a><h3>8.5.2.&nbsp;
localpart@domainpart</h3>

<p>If the JID contained in the 'to' attribute is of the form &lt;localpart@domainpart&gt;, then the server MUST adhere to the following rules.
</p>
<a name="rules-localpart-barejid-resource"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.1"></a><h3>8.5.2.1.&nbsp;
Available or Connected Resources</h3>

<p>If there is at least one available resource or connected resource, how the stanza is processed depends on the stanza type.
</p>
<a name="rules-localpart-barejid-resource-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.1.1"></a><h3>8.5.2.1.1.&nbsp;
Message</h3>

<p>For a message stanza of type "normal":
</p>
<p>
              </p>
<ul class="text">
<li>If all of the available resources have a negative presence priority then the server SHOULD either (a) store the message offline for later delivery or (b) return a stanza error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</li>
<li>If there is one available resource with a non-negative presence priority then the server MUST deliver the message to that resource.
</li>
<li>If there is more than one resource with a non-negative presence priority then the server MUST either (a) deliver the message to the "most available" resource or resources (according to the server's implementation-specific algorithm, e.g., treating the resource or resources with the highest presence priority as "most available") or (b) deliver the message to all of the non-negative resources.
</li>
</ul><p>
            
</p>
<p>For a message stanza of type "chat":
</p>
<p>
              </p>
<ul class="text">
<li>If the only available resource has a negative presence priority then the server SHOULD either (a) store the message offline for later delivery or (b) return a stanza error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</li>
<li>If the only available resource has a non-negative presence priority then the server MUST deliver the message to that resource.
</li>
<li>If there is more than one resource with a non-negative presence priority then the server MUST either (a) deliver the message to the "most available" resource or resources (according to the server's implementation-specific algorithm, e.g., treating the resource or resources with the highest presence priority as "most available") or (b) deliver the message to all of the non-negative resources that have opted in to receive chat messages.
</li>
</ul><p>
            
</p>
<p>For a message stanza of type "groupchat", the server MUST NOT deliver the stanza to any of the available resources but instead MUST return a stanza error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</p>
<p>For a message stanza of type "headline":
</p>
<p>
              </p>
<ul class="text">
<li>If the only available resource has a negative presence priority then the server MUST silently ignore the stanza.
</li>
<li>If the only available resource has a non-negative presence priority then the server MUST deliver the message to that resource.
</li>
<li>If there is more than one resource with a non-negative presence priority then the server MUST deliver the message to all of the non-negative resources.
</li>
</ul><p>
            
</p>
<p>For a message stanza of type "error", the server MUST silently ignore the message.
</p>
<p>However, for any message type the server MUST NOT deliver the stanza to any available resource with a negative priority; if the only available resource has a negative priority, the server SHOULD handle the message as if there were no available resources or connected resources as described under <a class='info' href='#rules-localpart-barejid-noresource'>Section&nbsp;8.5.2.2<span> (</span><span class='info'>No Available or Connected Resources</span><span>)</span></a>.
</p>
<p>In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., it MUST leave it as &lt;localpart@domainpart&gt; rather than change it to &lt;localpart@domainpart/resourcepart&gt;).
</p>
<a name="rules-localpart-barejid-resource-pres"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.1.2"></a><h3>8.5.2.1.2.&nbsp;
Presence</h3>

<p>For a presence stanza with no type or of type "unavailable", the server MUST deliver it to all available resources.
</p>
<p>For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST adhere to the rules defined under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a> and summarized under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>.
</p>
<p>For a presence stanza of type "probe", the server MUST handle it directly as described under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.
</p>
<p>In all cases, the server MUST NOT rewrite the 'to' attribute (i.e., it MUST leave it as &lt;localpart@domainpart&gt; rather than change it to &lt;localpart@domainpart/resourcepart&gt;).
</p>
<a name="rules-localpart-barejid-resource-iq"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.1.3"></a><h3>8.5.2.1.3.&nbsp;
IQ</h3>

<p>For an IQ stanza, the server itself MUST reply on behalf of the user with either an IQ result or an IQ error, and MUST NOT deliver the IQ stanza to any of the user's available resources.  Specifically, if the semantics of the qualifying namespace define a reply that the server can provide on behalf of the user, then the server MUST reply to the stanza on behalf of the user by returning either an IQ stanza of type "result" or an IQ stanza of type "error" that is appropriate to the original payload; if not, then the server MUST reply with a &lt;service-unavailable/&gt; stanza error.
</p>
<a name="rules-localpart-barejid-noresource"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.2"></a><h3>8.5.2.2.&nbsp;
No Available or Connected Resources</h3>

<p>If there are no available resources or connected resources associated with the user, how the stanza is processed depends on the stanza type.
</p>
<a name="rules-localpart-barejid-noresource-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.2.1"></a><h3>8.5.2.2.1.&nbsp;
Message</h3>

<p>For a message stanza of type "normal" or "chat", the server SHOULD either (a) add the message to offline storage or (b) return a stanza error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</p>
<p>For a message stanza of type "groupchat", the server MUST return an error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</p>
<p>For a message stanza of type "headline" or "error", the server MUST silently ignore the message.
</p>
<a name="rules-localpart-barejid-noresource-pres"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.2.2"></a><h3>8.5.2.2.2.&nbsp;
Presence</h3>

<p>For a presence stanza with no type or of type "unavailable", the server SHOULD silently ignore the stanza by not storing it for later delivery and not replying to it on behalf of the user.
</p>
<p>For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST adhere to the rules defined under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a> and summarized under <a class='info' href='#substates'>Appendix&nbsp;A<span> (</span><span class='info'>Subscription States</span><span>)</span></a>.
</p>
<p>For a presence stanza of type "probe", the server MUST handle it directly as described under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.
</p>
<a name="rules-localpart-barejid-noresource-iq"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.2.2.3"></a><h3>8.5.2.2.3.&nbsp;
IQ</h3>

<p>For an IQ stanza, the server itself MUST reply on behalf of the user with either an IQ result or an IQ error.  Specifically, if the semantics of the qualifying namespace define a reply that the server can provide on behalf of the user, then the server MUST reply to the stanza on behalf of the user by returning either an IQ stanza of type "result" or an IQ stanza of type "error" that is appropriate to the original payload; if not, then the server MUST reply with a &lt;service-unavailable/&gt; stanza error.
</p>
<a name="rules-localpart-fulljid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3"></a><h3>8.5.3.&nbsp;
localpart@domainpart/resourcepart</h3>

<p>If the domainpart of the JID contained in the 'to' attribute of an inbound stanza matches one of the configured domains of the server itself and the JID contained in the 'to' attribute is of the form &lt;localpart@domainpart/resourcepart&gt;, then the server MUST adhere to the following rules.
</p>
<a name="rules-localpart-fulljid-match"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3.1"></a><h3>8.5.3.1.&nbsp;
Resource Matches</h3>

<p>If an available resource or connected resource exactly matches the full JID, how the stanza is processed depends on the stanza type.
</p>
<p>
            </p>
<ul class="text">
<li>For an IQ stanza of type "get" or "set", if the intended recipient does not share presence with the requesting entity either by means of a presence subscription of type "both" or "from" or by means of directed presence, then the server SHOULD NOT deliver the IQ stanza but instead SHOULD return a &lt;service-unavailable/&gt; stanza error to the requesting entity.  This policy helps to prevent presence leaks (see <a class='info' href='#security'>Section&nbsp;11<span> (</span><span class='info'>Security Considerations</span><span>)</span></a>).
</li>
<li>For an IQ stanza of type "result" or "error", the server MUST deliver the stanza to the resource.
</li>
<li>For a message stanza, the server MUST deliver the stanza to the resource.
</li>
<li>For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the server MUST deliver the stanza to the resource.
</li>
<li>For a presence stanza of type "subscribe", "subscribed", "unsubscribe", or "unsubscribed", the server MUST follow the guidelines provided under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>.
</li>
<li>For a presence stanza of type "probe", the server MUST follow the guidelines provided under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.
</li>
</ul><p>
          
</p>
<a name="rules-localpart-fulljid-nomatch"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3.2"></a><h3>8.5.3.2.&nbsp;
No Resource Matches</h3>

<p>If no available resource or connected resource exactly matches the full JID, how the stanza is processed depends on the stanza type.
</p>
<a name="rules-local-fulljid-nomatch-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3.2.1"></a><h3>8.5.3.2.1.&nbsp;
Message</h3>

<p>For a message stanza of type "normal", "groupchat", or "headline", the server MUST either (a) silently ignore the stanza or (b) return an error stanza to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</p>
<p>For a message stanza of type "chat":
</p>
<p>
              </p>
<ul class="text">
<li>If there is no available or connected resource, the server MUST either (a) store the message offline for later delivery or (b) return an error stanza to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</li>
<li>If all of the available resources have a negative presence priority then the server SHOULD (a) store the message offline for later delivery or (b) return a stanza error to the sender, which SHOULD be &lt;service-unavailable/&gt;.
</li>
<li>If there is one available resource with a non-negative presence priority then the server MUST deliver the message to that resource.
</li>
<li>If there is more than one resource with a non-negative presence priority then the server MUST either (a) deliver the message to the "most available" resource or resources (according to the server's implementation-specific algorithm, e.g., treating the resource or resources with the highest presence priority as "most available") or (b) deliver the message to all of the non-negative resources that have opted in to receive chat messages.
</li>
</ul><p>
            
</p>
<p>For a message stanza of type "error", the server MUST silently ignore the stanza.
</p>
<a name="rules-localpart-fulljid-nomatch-presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3.2.2"></a><h3>8.5.3.2.2.&nbsp;
Presence</h3>

<p>For a presence stanza with no 'type' attribute or a 'type' attribute of "unavailable", the server MUST silently ignore the stanza.
</p>
<p>For a presence stanza of type "subscribe", the server MUST follow the guidelines provided under <a class='info' href='#sub-request-inbound'>Section&nbsp;3.1.3<span> (</span><span class='info'>Server Processing of Inbound Subscription Request</span><span>)</span></a>.
</p>
<p>For a presence stanza of type "subscribed", "unsubscribe", or "unsubscribed", the server MUST ignore the stanza.
</p>
<p>For a presence stanza of type "probe", the server MUST follow the guidelines provided under <a class='info' href='#presence-probe'>Section&nbsp;4.3<span> (</span><span class='info'>Presence Probes</span><span>)</span></a>.
</p>
<a name="rules-localpart-fulljid-nomatch-iq"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.3.2.3"></a><h3>8.5.3.2.3.&nbsp;
IQ</h3>

<p>For an IQ stanza, the server MUST return a &lt;service-unavailable/&gt; stanza error to the sender.
</p>
<a name="rules-local-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.5.4"></a><h3>8.5.4.&nbsp;
Summary of Message Delivery Rules</h3>

<p>The following table summarizes the message (not stanza) delivery rules described earlier in this section.  The left column shows various combinations of conditions (non-existent account, no active resources, only one resource and it has a negative presence priority, only one resource and it has a non-negative presence priority, or more than one resource and each one has a non-negative presence priority) and 'to' addresses (bare JID, full JID matching an available resource, or full JID matching no available resource).  The subsequent columns list the four primary message types (normal, chat, groupchat, or headline) along with six possible delivery options: storing the message offline (O), bouncing the message with a stanza error (E), silently ignoring the message (S), delivering the message to the resource specified in the 'to' address (D), delivering the message to the "most available" resource or resources according to the server's implementation-specific algorithm, e.g., treating the resource or resources with the highest presence priority as "most available" (M), or delivering the message to all resources with non-negative presence priority (A -- where for chat messages "all resources" can mean the set of resources that have explicitly opted in to receiving every chat message).  The '/' character stands for "exclusive or".  The server SHOULD observe the rules given in section 8.1 when choosing which action to take for a particular message.
</p>
<p>Table 1: Message Delivery Rules
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+----------------------------------------------------------+
| Condition        | Normal | Chat  | Groupchat | Headline |
+----------------------------------------------------------+
| ACCOUNT DOES NOT EXIST                                   |
|  bare            |  S/E   |  S/E  |     E     |    S     |
|  full            |  S/E   |  S/E  |    S/E    |   S/E    |
+----------------------------------------------------------+
| ACCOUNT EXISTS, BUT NO ACTIVE RESOURCES                  |
|  bare            |  O/E   |  O/E  |     E     |    S     |
|  full (no match) |  S/E   |  O/E  |    S/E    |   S/E    |
+----------------------------------------------------------+
| 1+ NEGATIVE RESOURCES BUT ZERO NON-NEGATIVE RESOURCES    |
|  bare            |  O/E   |  O/E  |     E     |    S     |
|  full match      |   D    |   D   |     D     |    D     |
|  full no match   |  S/E   |  O/E  |    S/E    |   S/E    |
+----------------------------------------------------------+
| 1 NON-NEGATIVE RESOURCE                                  |
|  bare            |   D    |   D   |     E     |    D     |
|  full match      |   D    |   D   |     D     |    D     |
|  full no match   |  S/E   |   D   |    S/E    |   S/E    |
+----------------------------------------------------------+
| 1+ NON-NEGATIVE RESOURCES                                |
|  bare            |  M/A   |  M/A* |     E     |    A     |
|  full match      |   D    |  D/A* |     D     |    D     |
|  full no match   |  S/E   |  M/A* |    S/E    |   S/E    |
+----------------------------------------------------------+
</pre></div>
<p></p>
<blockquote class="text">
<p>* For messages of type "chat", a server SHOULD NOT act in accordance with option (A) unless clients can explicitly opt in to receiving all chat messages; however, methods for opting in are outside the scope of this specification.
</p>
</blockquote>

<a name="uri"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9"></a><h3>9.&nbsp;
Handling of URIs</h3>

<p>The addresses of XMPP entities as used in communication over an XMPP network (e.g., in the 'from' and 'to' addresses of an XML stanza) MUST NOT be prepended with a Uniform Resource Identifier <a class='info' href='#URI'>[URI]<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a> scheme.
</p>
<p>However, an application that is external to XMPP itself (e.g., a page on the World Wide Web) might need to identify an XMPP entity either as a URI or as an Internationalized Resource Identifier <a class='info' href='#IRI'>[IRI]<span> (</span><span class='info'>Duerst, M. and M. Suignard, &ldquo;Internationalized Resource Identifiers (IRIs),&rdquo; January&nbsp;2005.</span><span>)</span></a>, and an XMPP client might need to interact with such an external application (for example, an XMPP client might be invoked by clicking a link provided on a web page).  In the context of such interactions, XMPP clients are encouraged to handle addresses that are encoded as "xmpp:" URIs and IRIs as specified in <a class='info' href='#XMPP-URI'>[XMPP&#8209;URI]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP),&rdquo; February&nbsp;2008.</span><span>)</span></a> and further described in <a class='info' href='#XEP-0147'>[XEP&#8209;0147]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XMPP URI Scheme Query Components,&rdquo; September&nbsp;2006.</span><span>)</span></a>.  Although XMPP clients are also encouraged to handle addresses that are encoded as "im:" URIs as specified in <a class='info' href='#CPIM'>[CPIM]<span> (</span><span class='info'>Peterson, J., &ldquo;Common Profile for Instant Messaging (CPIM),&rdquo; August&nbsp;2004.</span><span>)</span></a> and "pres:" URIs as specified in <a class='info' href='#CPP'>[CPP]<span> (</span><span class='info'>Peterson, J., &ldquo;Common Profile for Presence (CPP),&rdquo; August&nbsp;2004.</span><span>)</span></a>, they can do so by removing the "im:" or "pres:" scheme and entrusting address resolution to the server as specified under <a class='info' href='#rules-remote'>Section&nbsp;8.3<span> (</span><span class='info'>Remote Domain</span><span>)</span></a>.
</p>
<a name="i18n"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10"></a><h3>10.&nbsp;
Internationalization Considerations</h3>

<p>For internationalization considerations, refer to the relevant section of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="security"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11"></a><h3>11.&nbsp;
Security Considerations</h3>

<p>Core security considerations for XMPP are provided in Section 13 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, including discussion of channel encryption, authentication, information leaks, denial-of-service attacks, and interdomain federation.
</p>
<p>Section 13.1 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a> outlines the architectural roles of clients and servers in typical deployments of XMPP, and discusses the security properties associated with those roles.  These roles have an impact on the security of instant messages, presence subscriptions, and presence notifications as described in this document.  In essence, an XMPP user registers (or has provisioned) an account on an XMPP server and therefore places some level of trust in the server to complete various tasks on the user's behalf, enforce security policies, etc.  Thus it is the server's responsibility to:
</p>
<p>
      </p>
<ol class="text">
<li>Preferably mandate the use of channel encryption for communication with local clients and remote servers.
</li>
<li>Authenticate any client that wishes to access the user's account.
</li>
<li>Process XML stanzas to and from clients that have authenticated as the user (specifically with regard to instant messaging and presence functionality, store the user's roster, process inbound and outbound subscription requests and responses, generate and handle presence probes, broadcast outbound presence notifications, route outbound messages, and deliver inbound messages and presence notifications).
</li>
</ol><p>
    
</p>
<p>As discussed in Sections 13.1 and 13.4 of <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>, even if the server fulfills the foregoing responsibilities, the client does not have any assurance that stanzas it might exchange with other clients (whether on the same server or a remote server) are protected for all hops along the XMPP communication path, or within the server itself.  It is the responsibility of the client to use an appropriate technology for encryption and signing of XML stanzas if it wishes to ensure end-to-end confidentiality and integrity of its communications.
</p>
<p>Additional considerations that apply only to instant messaging and presence applications of XMPP are defined in several places within this document; specifically:
</p>
<p>
      </p>
<ul class="text">
<li>When a server processes an inbound presence stanza of type "probe" whose intended recipient is a user associated with one of the server's configured domains, the server MUST NOT reveal the user's presence if the sender is an entity that is not authorized to receive that information as determined by presence subscriptions (see <a class='info' href='#presence'>Section&nbsp;4<span> (</span><span class='info'>Exchanging Presence Information</span><span>)</span></a>).
</li>
<li>A user's server MUST NOT leak the user's network availability to entities who are not authorized to know the user's presence.  In XMPP itself, authorization takes the form of an explicit subscription from a contact to the user (as described under <a class='info' href='#sub'>Section&nbsp;3<span> (</span><span class='info'>Managing Presence Subscriptions</span><span>)</span></a>).  However, some XMPP deployments might consider an entity to be authorized if there is an existing trust relationship between the entity and the user who is generating presence information (as an example, a corporate deployment of XMPP might automatically add the user's presence information to a private directory of employees if the organization mandates the sharing of presence information as part of an employment agreement).
</li>
<li>When a server processes an outbound presence stanza with no type or of type "unavailable", it MUST follow the rules defined under <a class='info' href='#presence'>Section&nbsp;4<span> (</span><span class='info'>Exchanging Presence Information</span><span>)</span></a> in order to ensure that such presence information is not sent to entities that are not authorized to know such information.
</li>
<li>A client MAY ignore the &lt;status/&gt; element when contained in a presence stanza of type "subscribe", "unsubscribe", "subscribed", or "unsubscribed"; this can help prevent "presence subscription spam".
</li>
</ul><p>
    
</p>
<a name="conformance"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.12"></a><h3>12.&nbsp;
Conformance Requirements</h3>

<p>This section describes a protocol feature set that summarizes the conformance requirements of this specification.  This feature set is appropriate for use in software certification, interoperability testing, and implementation reports.  For each feature, this section provides the following information:
</p>
<p>
      </p>
<ul class="text">
<li>A human-readable name
</li>
<li>An informational description
</li>
<li>A reference to the particular section of this document that normatively defines the feature
</li>
<li>Whether the feature applies to the Client role, the Server role, or both (where "N/A" signifies that the feature is not applicable to the specified role)
</li>
<li>Whether the feature MUST or SHOULD be implemented, where the capitalized terms are to be understood as described in <a class='info' href='#KEYWORDS'>[KEYWORDS]<span> (</span><span class='info'>Bradner, S., &ldquo;Key words for use in RFCs to Indicate Requirement Levels,&rdquo; March&nbsp;1997.</span><span>)</span></a>
</li>
</ul><p>
    
</p>
<p>The feature set specified here attempts to adhere to the concepts and formats proposed by Larry Masinter within the IETF's NEWTRK Working Group in 2005, as captured in <a class='info' href='#INTEROP'>[INTEROP]<span> (</span><span class='info'>Masinter, L., &ldquo;Formalizing IETF Interoperability Reporting,&rdquo; October&nbsp;2005.</span><span>)</span></a>.  Although this feature set is more detailed than called for by <a class='info' href='#REPORTS'>[REPORTS]<span> (</span><span class='info'>Dusseault, L. and R. Sparks, &ldquo;Guidance on Interoperation and Implementation Reports for Advancement to Draft Standard,&rdquo; September&nbsp;2009.</span><span>)</span></a>, it provides a suitable basis for the generation of implementation reports to be submitted in support of advancing this specification from Proposed Standard to Draft Standard in accordance with <a class='info' href='#PROCESS'>[PROCESS]<span> (</span><span class='info'>Bradner, S., &ldquo;The Internet Standards Process -- Revision 3,&rdquo; October&nbsp;1996.</span><span>)</span></a>.
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>message-body
</dd>
<dt>Description:</dt>
<dd>Support the &lt;body/&gt; child element of the &lt;message/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#message-syntax-body'>Section&nbsp;5.2.3<span> (</span><span class='info'>Body Element</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server N/A.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>message-subject
</dd>
<dt>Description:</dt>
<dd>Support the &lt;subject/&gt; child element of the &lt;message/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#message-syntax-subject'>Section&nbsp;5.2.4<span> (</span><span class='info'>Subject Element</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server N/A.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>message-thread
</dd>
<dt>Description:</dt>
<dd>Support the &lt;thread/&gt; child element of the &lt;message/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#message-syntax-thread'>Section&nbsp;5.2.5<span> (</span><span class='info'>Thread Element</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server N/A.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>message-type-support
</dd>
<dt>Description:</dt>
<dd>Support reception of messages of type "normal", "chat", "groupchat", "headline", and "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#message-syntax-type'>Section&nbsp;5.2.2<span> (</span><span class='info'>Type Attribute</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server N/A.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>message-type-deliver
</dd>
<dt>Description:</dt>
<dd>Appropriately deliver messages of type "normal", "chat", "groupchat", "headline", and "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#rules'>Section&nbsp;8<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-notype
</dd>
<dt>Description:</dt>
<dd>Treat a presence stanza with no 'type' attribute as indicating availability.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#presence-syntax-type'>Section&nbsp;4.7.1<span> (</span><span class='info'>Type Attribute</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-probe
</dd>
<dt>Description:</dt>
<dd>Send and receive presence stanzas with a 'type' attribute of "probe" for the discovery of presence information.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#presence-syntax-type'>Section&nbsp;4.7.1<span> (</span><span class='info'>Type Attribute</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-sub-approval
</dd>
<dt>Description:</dt>
<dd>Treat an outbound presence stanza of type "subscribed" as the act of approving a presence subscription request previously received from another entity, and treat an inbound presence stanza of type "subscribed" as a subscription approval from another entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sub-request'>Section&nbsp;3.1<span> (</span><span class='info'>Requesting a Subscription</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-sub-cancel
</dd>
<dt>Description:</dt>
<dd>Treat an outbound presence stanza of type "unsubscribed" as the act of denying a subscription request received from another entity or canceling a subscription approval previously granted to another entity, and treat an inbound presence stanza of type "unsubscribed" as an subscription denial or cancellation from another entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sub-cancel'>Section&nbsp;3.2<span> (</span><span class='info'>Canceling a Subscription</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-sub-preapproval
</dd>
<dt>Description:</dt>
<dd>Treat an outbound presence stanza of type "subscribed" in certain circumstances as the act of pre-approving a subscription request received from another entity; this includes support for the 'approved' attribute of the &lt;item/&gt; element within the 'jabber:iq:roster' namespace.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MAY, Server MAY.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-sub-request
</dd>
<dt>Description:</dt>
<dd>Treat an outbound presence stanza of type "subscribe" as the act of requesting a subscription to the presence information of another entity, and treat an inbound presence stanza of type "subscribe" as a presence subscription request from another entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sub-request'>Section&nbsp;3.1<span> (</span><span class='info'>Requesting a Subscription</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-sub-unsubscribe
</dd>
<dt>Description:</dt>
<dd>Treat an outbound presence stanza of type "unsubscribe" as the act of unsubscribing from another entity, and treat an inbound presence stanza of type "unsubscribe" as an unsubscribe notification from another entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sub-unsub'>Section&nbsp;3.3<span> (</span><span class='info'>Unsubscribing</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>presence-unavailable
</dd>
<dt>Description:</dt>
<dd>Treat a presence stanza with a 'type' attribute of "unavailable" as indicating lack of availability.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#presence-syntax-type'>Section&nbsp;4.7.1<span> (</span><span class='info'>Type Attribute</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>roster-get
</dd>
<dt>Description:</dt>
<dd>Treat an IQ stanza of type "get" containing an empty &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace as a request to retrieve the roster information associated with an account on a server.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#roster-syntax-actions-get'>Section&nbsp;2.1.3<span> (</span><span class='info'>Roster Get</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>roster-set
</dd>
<dt>Description:</dt>
<dd>Treat an IQ stanza of type "set" containing a &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace as a request to add or update the item contained in the &lt;query/&gt; element.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#roster-syntax-actions-set'>Section&nbsp;2.1.5<span> (</span><span class='info'>Roster Set</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>roster-push
</dd>
<dt>Description:</dt>
<dd>Send a roster push to each interested resource whenever the server-side representation of the roster information materially changes, or handle such a push when received from the server.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#roster-syntax-actions-push'>Section&nbsp;2.1.6<span> (</span><span class='info'>Roster Push</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>roster-version
</dd>
<dt>Description:</dt>
<dd>Treat the 'ver' attribute of the &lt;query/&gt; element qualified by the 'jabber:iq:roster' namespace as an identifier of the particular version of roster information being sent or received.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#roster-syntax-ver'>Section&nbsp;2.1.1<span> (</span><span class='info'>Ver Attribute</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<a name="rfc.references"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13"></a><h3>13.&nbsp;
References</h3>

<a name="rfc.references1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>13.1.&nbsp;Normative References</h3>
<table width="99%" border="0">
<tr><td class="author-text" valign="top"><a name="DELAY">[DELAY]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0203.html">Delayed Delivery</a>,&rdquo; XSF XEP&nbsp;0203, September&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="KEYWORDS">[KEYWORDS]</a></td>
<td class="author-text"><a href="mailto:sob@harvard.edu">Bradner, S.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>,&rdquo; BCP&nbsp;14, RFC&nbsp;2119, March&nbsp;1997 (<a href="http://www.rfc-editor.org/rfc/rfc2119.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc2119.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2119.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML">[XML]</a></td>
<td class="author-text">Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;<a href="http://www.w3.org/TR/2008/REC-xml-20081126">Extensible Markup Language (XML) 1.0 (Fifth Edition)</a>,&rdquo; World Wide Web Consortium Recommendation&nbsp;REC&#8209;xml&#8209;20081126, November&nbsp;2008 (<a href="http://www.w3.org/TR/2008/REC-xml-20081126">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-NAMES">[XML-NAMES]</a></td>
<td class="author-text"><a href="mailto:tbray@textuality.com">Bray, T.</a>, <a href="mailto:dmh@corp.hp.com">Hollander, D.</a>, and <a href="mailto:andrewl@microsoft.com">A. Layman</a>, &ldquo;<a href="http://www.w3.org/TR/REC-xml-names">Namespaces in XML</a>,&rdquo; W3C&nbsp;REC-xml-names, January&nbsp;1999.</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-CORE">[XMPP-CORE]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc6120">Extensible Messaging and Presence Protocol (XMPP): Core</a>,&rdquo; RFC&nbsp;6120, March&nbsp;2011.</td></tr>
</table>

<a name="rfc.references2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>13.2.&nbsp;Informative References</h3>
<table width="99%" border="0">
<tr><td class="author-text" valign="top"><a name="CPIM">[CPIM]</a></td>
<td class="author-text">Peterson, J., &ldquo;<a href="http://tools.ietf.org/html/rfc3860">Common Profile for Instant Messaging (CPIM)</a>,&rdquo; RFC&nbsp;3860, August&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3860.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="CPP">[CPP]</a></td>
<td class="author-text">Peterson, J., &ldquo;<a href="http://tools.ietf.org/html/rfc3859">Common Profile for Presence (CPP)</a>,&rdquo; RFC&nbsp;3859, August&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3859.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DOS">[DOS]</a></td>
<td class="author-text">Handley, M., Rescorla, E., and IAB, &ldquo;<a href="http://tools.ietf.org/html/rfc4732">Internet Denial-of-Service Considerations</a>,&rdquo; RFC&nbsp;4732, December&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4732.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IMP-MODEL">[IMP-MODEL]</a></td>
<td class="author-text"><a href="mailto:mday@alum.mit.edu">Day, M.</a>, <a href="mailto:jdrosen@dynamicsoft.com">Rosenberg, J.</a>, and <a href="mailto:suga@flab.fujitsu.co.jp">H. Sugano</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2778">A Model for Presence and Instant Messaging</a>,&rdquo; RFC&nbsp;2778, February&nbsp;2000.</td></tr>
<tr><td class="author-text" valign="top"><a name="IMP-REQS">[IMP-REQS]</a></td>
<td class="author-text"><a href="mailto:mday@alum.mit.edu">Day, M.</a>, <a href="mailto:sonuag@microsoft.com">Aggarwal, S.</a>, and <a href="mailto:jesse@intonet.com">J. Vincent</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2779">Instant Messaging / Presence Protocol Requirements</a>,&rdquo; RFC&nbsp;2779, February&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2779.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IMP-SRV">[IMP-SRV]</a></td>
<td class="author-text">Peterson, J., &ldquo;<a href="http://tools.ietf.org/html/rfc3861">Address Resolution for Instant Messaging and Presence</a>,&rdquo; RFC&nbsp;3861, August&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3861.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="INTEROP">[INTEROP]</a></td>
<td class="author-text">Masinter, L., &ldquo;Formalizing IETF Interoperability Reporting,&rdquo; Work in&nbsp;Progress, October&nbsp;2005.</td></tr>
<tr><td class="author-text" valign="top"><a name="IRC">[IRC]</a></td>
<td class="author-text">Kalt, C., &ldquo;<a href="http://tools.ietf.org/html/rfc2810">Internet Relay Chat: Architecture</a>,&rdquo; RFC&nbsp;2810, April&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2810.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IRI">[IRI]</a></td>
<td class="author-text">Duerst, M. and M. Suignard, &ldquo;<a href="http://tools.ietf.org/html/rfc3987">Internationalized Resource Identifiers (IRIs)</a>,&rdquo; RFC&nbsp;3987, January&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc3987.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PROCESS">[PROCESS]</a></td>
<td class="author-text"><a href="mailto:sob@harvard.edu">Bradner, S.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2026">The Internet Standards Process -- Revision 3</a>,&rdquo; BCP&nbsp;9, RFC&nbsp;2026, October&nbsp;1996 (<a href="http://www.rfc-editor.org/rfc/rfc2026.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="REPORTS">[REPORTS]</a></td>
<td class="author-text">Dusseault, L. and R. Sparks, &ldquo;<a href="http://tools.ietf.org/html/rfc5657">Guidance on Interoperation and Implementation Reports for Advancement to Draft Standard</a>,&rdquo; BCP&nbsp;9, RFC&nbsp;5657, September&nbsp;2009 (<a href="http://www.rfc-editor.org/rfc/rfc5657.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="RFC3920">[RFC3920]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P., Ed.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3920">Extensible Messaging and Presence Protocol (XMPP): Core</a>,&rdquo; RFC&nbsp;3920, October&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3920.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3920.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3920.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="RFC3921">[RFC3921]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P., Ed.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3921">Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence</a>,&rdquo; RFC&nbsp;3921, October&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3921.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3921.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3921.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SASL">[SASL]</a></td>
<td class="author-text">Melnikov, A. and K. Zeilenga, &ldquo;<a href="http://tools.ietf.org/html/rfc4422">Simple Authentication and Security Layer (SASL)</a>,&rdquo; RFC&nbsp;4422, June&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4422.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SIP-PRES">[SIP-PRES]</a></td>
<td class="author-text">Rosenberg, J., &ldquo;<a href="http://tools.ietf.org/html/rfc3856">A Presence Event Package for the Session Initiation Protocol (SIP)</a>,&rdquo; RFC&nbsp;3856, August&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3856.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS">[TLS]</a></td>
<td class="author-text">Dierks, T. and E. Rescorla, &ldquo;<a href="http://tools.ietf.org/html/rfc5246">The Transport Layer Security (TLS) Protocol Version 1.2</a>,&rdquo; RFC&nbsp;5246, August&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5246.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-CERTS">[TLS-CERTS]</a></td>
<td class="author-text">Saint-Andre, P. and J. Hodges, &ldquo;<a href="http://tools.ietf.org/html/rfc6125">Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS)</a>,&rdquo; RFC&nbsp;6125, March&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="UNICODE">[UNICODE]</a></td>
<td class="author-text">The Unicode Consortium, &ldquo;<a href="http://www.unicode.org/versions/Unicode6.0.0/">The Unicode Standard, Version 6.0</a>,&rdquo; 2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="URI">[URI]</a></td>
<td class="author-text">Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;<a href="http://tools.ietf.org/html/rfc3986">Uniform Resource Identifier (URI): Generic Syntax</a>,&rdquo; STD&nbsp;66, RFC&nbsp;3986, January&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc3986.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="UUID">[UUID]</a></td>
<td class="author-text"><a href="mailto:paulle@microsoft.com">Leach, P.</a>, <a href="mailto:michael@refactored-networks.com">Mealling, M.</a>, and <a href="mailto:rsalz@datapower.com">R. Salz</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc4122">A Universally Unique IDentifier (UUID) URN Namespace</a>,&rdquo; RFC&nbsp;4122, July&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4122.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc4122.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc4122.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0016">[XEP-0016]</a></td>
<td class="author-text">Millard, P. and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0016.html">Privacy Lists</a>,&rdquo; XSF XEP&nbsp;0016, February&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0045">[XEP-0045]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0045.html">Multi-User Chat</a>,&rdquo; XSF XEP&nbsp;0045, July&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0054">[XEP-0054]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0054.html">vcard-temp</a>,&rdquo; XSF XEP&nbsp;0054, July&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0071">[XEP-0071]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0071.html">XHTML-IM</a>,&rdquo; XSF XEP&nbsp;0071, September&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0115">[XEP-0115]</a></td>
<td class="author-text"><a href="mailto:jhildebrand@jabber.com">Hildebrand, J.</a>, <a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, and <a href="mailto:public@el-tramo.be">R. Tron&#xE7;on</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0115.html">Entity Capabilities</a>,&rdquo; XSF XEP&nbsp;0115, February&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0147">[XEP-0147]</a></td>
<td class="author-text"><a href="mailto:">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0147.html">XMPP URI Scheme Query Components</a>,&rdquo; XSF XEP&nbsp;0147, September&nbsp;2006.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0160">[XEP-0160]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0160.html">Best Practices for Handling Offline Messages</a>,&rdquo; XSF XEP&nbsp;0160, January&nbsp;2006.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0163">[XEP-0163]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a> and <a href="mailto:kevin@kismith.co.uk">K. Smith</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0163.html">Personal Eventing Protocol</a>,&rdquo; XSF XEP&nbsp;0163, July&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0191">[XEP-0191]</a></td>
<td class="author-text"><a href="mailto:">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0191.html">Simple Communications Blocking</a>,&rdquo; XSF XEP&nbsp;0191, February&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0201">[XEP-0201]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, <a href="mailto:ian.paterson@clientside.co.uk">Paterson, I.</a>, and <a href="mailto:kevin@kismith.co.uk">K. Smith</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0201.html">Best Practices for Message Threads</a>,&rdquo; XSF XEP&nbsp;0201, November&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0237">[XEP-0237]</a></td>
<td class="author-text"><a href="mailto:">Saint-Andre, P.</a> and <a href="mailto:dave.cridland@isode.com">D. Cridland</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0237.html">Roster Versioning</a>,&rdquo; XSF XEP&nbsp;0237, March&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-DATATYPES">[XML-DATATYPES]</a></td>
<td class="author-text">Biron, P. and A. Malhotra, &ldquo;<a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">XML Schema Part 2: Datatypes Second Edition</a>,&rdquo; W3C&nbsp;REC-xmlschema-2, October&nbsp;2004 (<a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-SCHEMA">[XML-SCHEMA]</a></td>
<td class="author-text">Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, &ldquo;<a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028">XML Schema Part 1: Structures Second Edition</a>,&rdquo; World Wide Web Consortium Recommendation&nbsp;REC-xmlschema-1-20041028, October&nbsp;2004 (<a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-ADDR">[XMPP-ADDR]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc6122">Extensible Messaging and Presence Protocol (XMPP): Address Format</a>,&rdquo; RFC&nbsp;6122, March&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-URI">[XMPP-URI]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc5122">Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP)</a>,&rdquo; RFC&nbsp;5122, February&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5122.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="VCARD">[VCARD]</a></td>
<td class="author-text"><a href="mailto:frank_dawson@lotus.com">Dawson, F.</a> and <a href="mailto:howes@netscape.com">T. Howes</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2426">vCard MIME Directory Profile</a>,&rdquo; RFC&nbsp;2426, September&nbsp;1998 (<a href="http://xml.resource.org/public/rfc/html/rfc2426.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2426.xml">XML</a>).</td></tr>
</table>

<a name="substates"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A"></a><h3>Appendix A.&nbsp;
Subscription States</h3>

<p>This section provides detailed information about subscription states and server processing of subscription-related presence stanzas (i.e., presence stanzas of type "subscribe", "subscribed", "unsubscribe", and "unsubscribed").
</p>
<a name="substates-defined"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.1"></a><h3>A.1.&nbsp;
Defined States</h3>

<p>There are four primary subscription states (these states are described from the perspective of the user, not the contact):
</p>
<p>
        </p>
<blockquote class="text"><dl>
<dt>None:</dt>
<dd>The user does not have a subscription to the contact's presence, and the contact does not have a subscription to the user's presence.
</dd>
<dt>To:</dt>
<dd>The user has a subscription to the contact's presence, but the contact does not have a subscription to the user's presence.
</dd>
<dt>From:</dt>
<dd>The contact has a subscription to the user's presence, but the user does not have a subscription to the contact's presence.
</dd>
<dt>Both:</dt>
<dd>Both the user and the contact have subscriptions to each other's presence (i.e., the union of 'from' and 'to').
</dd>
</dl></blockquote><p>
      
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: For the purpose of processing subscription-related presence stanzas as described in the following sections, a subscription state of "None" includes the case of the contact not being in the user's roster at all, i.e., an unknown entity from the perspective of the user's roster.
</p>
</blockquote>

<p>The foregoing states are supplemented by various sub-states related to pending inbound and outbound subscriptions, thus yielding nine possible subscription states:
</p>
<p>
        </p>
<ol class="text">
<li>"None" = Contact and user are not subscribed to each other, and neither has requested a subscription from the other; this is reflected in the user's roster by subscription='none'.
</li>
<li>"None + Pending Out" = Contact and user are not subscribed to each other, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.
</li>
<li>"None + Pending In" = Contact and user are not subscribed to each other, and contact has sent user a subscription request but user has not replied yet. This state might or might not be reflected in the user's roster, as follows: if the user has created a roster item for the contact then the server MUST maintain that roster item and also note the existence of the inbound presence subscription request, whereas if the user has not created a roster item for the contact then the user's server MUST note the existence of the inbound presence subscription request but MUST NOT create a roster item for the contact (instead, the server MUST wait until the user has approved the subscription request before adding the contact to the user's roster).
</li>
<li>"None + Pending Out+In" = Contact and user are not subscribed to each other, contact has sent user a subscription request but user has not replied yet, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.
</li>
<li>"To" = User is subscribed to contact (one-way); this is reflected in the user's roster by subscription='to'.
</li>
<li>"To + Pending In" = User is subscribed to contact, and contact has sent user a subscription request but user has not replied yet; this is reflected in the user's roster by subscription='to'.
</li>
<li>"From" = Contact is subscribed to user (one-way); this is reflected in the user's roster by subscription='from'.
</li>
<li>"From + Pending Out" = Contact is subscribed to user, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='from' and ask='subscribe'.
</li>
<li>"Both" = User and contact are subscribed to each other
          (two-way); this is reflected in the user's roster by
          subscription='both'.
</li>
</ol><p>
      
</p>
<a name="substates-out"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2"></a><h3>A.2.&nbsp;
Server Processing of Outbound Presence Subscription Stanzas</h3>

<p>Outbound presence subscription stanzas enable the user to manage his or her subscription to the contact's presence (via the "subscribe" and "unsubscribe" types), and to manage the contact's access to the user's presence (via the "subscribed" and "unsubscribed" types).
</p>
<p>The following rules apply to outbound routing of the stanza as well as changes to the user's roster.  (These rules are described from the perspective of the user, not the contact.  In addition, "S.N." stands for SHOULD NOT and "M.N." stands for MUST NOT.)
</p>
<a name="substates-out-subscribe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2.1"></a><h3>A.2.1.&nbsp;
Subscribe</h3>

<p>Table 2: Processing of outbound "subscribe" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+------------------------------------------------------------------+
|  EXISTING STATE          |  ROUTE?   |  NEW STATE                |
+------------------------------------------------------------------+
|  "None"                  |  MUST [1] |  "None + Pending Out"     |
|  "None + Pending Out"    |  MUST     |  no state change          |
|  "None + Pending In"     |  MUST [1] |  "None + Pending Out+In"  |
|  "None + Pending Out+In" |  MUST     |  no state change          |
|  "To"                    |  MUST     |  no state change          |
|  "To + Pending In"       |  MUST     |  no state change          |
|  "From"                  |  MUST [1] |  "From + Pending Out"     |
|  "From + Pending Out"    |  MUST     |  no state change          |
|  "Both"                  |  MUST     |  no state change          |
+------------------------------------------------------------------+
</pre></div>
<p></p>
<blockquote class="text">
<p>[1] A state change to "pending out" includes setting the 'ask' flag to a value of "subscribe" in the user's roster.
</p>
</blockquote>

<a name="substates-out-unsubscribe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2.2"></a><h3>A.2.2.&nbsp;
Unsubscribe</h3>

<p>Table 3: Processing of outbound "unsubscribe" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+-----------------------------------------------------------------+
|  EXISTING STATE          |  ROUTE?  |  NEW STATE                |
+-----------------------------------------------------------------+
|  "None"                  |  MUST    |  no state change          |
|  "None + Pending Out"    |  MUST    |  "None"                   |
|  "None + Pending In"     |  MUST    |  no state change          |
|  "None + Pending Out+In" |  MUST    |  "None + Pending In"      |
|  "To"                    |  MUST    |  "None"                   |
|  "To + Pending In"       |  MUST    |  "None + Pending In"      |
|  "From"                  |  MUST    |  no state change          |
|  "From + Pending Out"    |  MUST    |  "From"                   |
|  "Both"                  |  MUST    |  "From"                   |
+-----------------------------------------------------------------+
</pre></div>
<a name="substates-out-subscribed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2.3"></a><h3>A.2.3.&nbsp;
Subscribed</h3>

<p>Table 4: Processing of outbound "subscribed" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+-----------------------------------------------------------------+
|  EXISTING STATE          |  ROUTE?  |  NEW STATE                |
+-----------------------------------------------------------------+
|  "None"                  |  M.N.    |  pre-approval [1]         |
|  "None + Pending Out"    |  M.N.    |  pre-approval [1]         |
|  "None + Pending In"     |  MUST    |  "From"                   |
|  "None + Pending Out+In" |  MUST    |  "From + Pending Out"     |
|  "To"                    |  M.N.    |  pre-approval [1]         |
|  "To + Pending In"       |  MUST    |  "Both"                   |
|  "From"                  |  M.N.    |  no state change          |
|  "From + Pending Out"    |  M.N.    |  no state change          |
|  "Both"                  |  M.N.    |  no state change          |
+-----------------------------------------------------------------+
</pre></div>
<p></p>
<blockquote class="text">
<p>[1] Detailed information regarding subscription pre-approval is provided under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>.
</p>
</blockquote>

<a name="substates-out-unsubscribed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2.4"></a><h3>A.2.4.&nbsp;
Unsubscribed</h3>

<p>Table 5: Processing of outbound "unsubscribed" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+-----------------------------------------------------------------+
|  EXISTING STATE          |  ROUTE?  |  NEW STATE                |
+-----------------------------------------------------------------+
|  "None"                  |  S.N.    |  no state change [1]      |
|  "None + Pending Out"    |  S.N.    |  no state change [1]      |
|  "None + Pending In"     |  MUST    |  "None"                   |
|  "None + Pending Out+In" |  MUST    |  "None + Pending Out"     |
|  "To"                    |  S.N.    |  no state change [1]      |
|  "To + Pending In"       |  MUST    |  "To"                     |
|  "From"                  |  MUST    |  "None"                   |
|  "From + Pending Out"    |  MUST    |  "None + Pending Out"     |
|  "Both"                  |  MUST    |  "To"                     |
+-----------------------------------------------------------------+
</pre></div>
<p></p>
<blockquote class="text">
<p>[1] This event can result in cancellation of a subscription pre-approval, as described under <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>.
</p>
</blockquote>

<a name="substates-in"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3"></a><h3>A.3.&nbsp;
Server Processing of Inbound Presence Subscription Stanzas</h3>

<p>Inbound presence subscription stanzas request a subscription-related action from the user (via the "subscribe" type), inform the user of subscription-related actions taken by the contact (via the "unsubscribe" type), or enable the user to manage the contact's access to the user's presence information (via the "subscribed" and "unsubscribed" types).
</p>
<p>The following rules apply to delivery of the inbound stanza as well as changes to the user's roster.  (These rules for server processing of inbound presence subscription stanzas are described from the perspective of the user, not the contact.  In addition, "S.N." stands for SHOULD NOT.)
</p>
<a name="substates-in-subscribe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3.1"></a><h3>A.3.1.&nbsp;
Subscribe</h3>

<p>Table 6: Processing of inbound "subscribe" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+------------------------------------------------------------------+
|  EXISTING STATE          |  DELIVER?  |  NEW STATE               |
+------------------------------------------------------------------+
|  "None"                  |  MUST [1]  |  "None + Pending In"     |
|  "None + Pending Out"    |  MUST      |  "None + Pending Out+In" |
|  "None + Pending In"     |  S.N.      |  no state change         |
|  "None + Pending Out+In" |  S.N.      |  no state change         |
|  "To"                    |  MUST      |  "To + Pending In"       |
|  "To + Pending In"       |  S.N.      |  no state change         |
|  "From"                  |  S.N. [2]  |  no state change         |
|  "From + Pending Out"    |  S.N. [2]  |  no state change         |
|  "Both"                  |  S.N. [2]  |  no state change         |
+------------------------------------------------------------------+
</pre></div>
<p></p>
<blockquote class="text">
<p>[1] If the user previously sent presence of type "subscribed" as described under <a class='info' href='#substates-out-subscribed'>Appendix&nbsp;A.2.3<span> (</span><span class='info'>Subscribed</span><span>)</span></a> and <a class='info' href='#sub-preapproval'>Section&nbsp;3.4<span> (</span><span class='info'>Pre-Approving a Subscription Request</span><span>)</span></a>, then the server MAY auto-reply with "subscribed" and change the state to "From" rather than "None + Pending In".
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>[2] Server SHOULD auto-reply with "subscribed".
</p>
</blockquote>

<a name="substates-in-unsubscribe"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3.2"></a><h3>A.3.2.&nbsp;
Unsubscribe</h3>

<p>When the user's server receives a presence stanza of type "unsubscribe" for the user from the contact, if the stanza results in a subscription state change from the user's perspective then the user's server MUST change the state, MUST deliver the presence stanza from the contact to the user, and SHOULD auto-reply by sending a presence stanza of type "unsubscribed" to the contact on behalf of the user.  Otherwise the user's server MUST NOT change the state and (because there is no state change) SHOULD NOT deliver the stanza.  These rules are summarized in the following table.
</p>
<p>Table 7: Processing of inbound "unsubscribe" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+------------------------------------------------------------------+
|  EXISTING STATE          |  DELIVER?  |  NEW STATE               |
+------------------------------------------------------------------+
|  "None"                  |  S.N.      |  no state change         |
|  "None + Pending Out"    |  S.N.      |  no state change         |
|  "None + Pending In"     |  MUST [1]  |  "None"                  |
|  "None + Pending Out+In" |  MUST [1]  |  "None + Pending Out"    |
|  "To"                    |  S.N.      |  no state change         |
|  "To + Pending In"       |  MUST [1]  |  "To"                    |
|  "From"                  |  MUST [1]  |  "None"                  |
|  "From + Pending Out"    |  MUST [1]  |  "None + Pending Out"    |
|  "Both"                  |  MUST [1]  |  "To"                    |
+------------------------------------------------------------------+
</pre></div>
<p>[1] Server SHOULD auto-reply with "unsubscribed".
</p>
<a name="substates-in-subscribed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3.3"></a><h3>A.3.3.&nbsp;
Subscribed</h3>

<p>When the user's server receives a presence stanza of type "subscribed" for the user from the contact, if there is no pending outbound request for access to the contact's presence information, then it MUST NOT change the subscription state and (because there is no state change) SHOULD NOT deliver the stanza to the user.  If there is a pending outbound request for access to the contact's presence information and the inbound presence stanza of type "subscribed" results in a subscription state change, then the user's server MUST change the subscription state and MUST deliver the stanza to the user.  If the user already is subscribed to the contact's presence information, the inbound presence stanza of type "subscribed" does not result in a subscription state change; therefore the user's server MUST NOT change the subscription state and (because there is no state change) SHOULD NOT deliver the stanza to the user.  These rules are summarized in the following table.
</p>
<p>Table 8: Processing of inbound "subscribed" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+------------------------------------------------------------------+
|  EXISTING STATE          |  DELIVER?  |  NEW STATE               |
+------------------------------------------------------------------+
|  "None"                  |  S.N.      |  no state change         |
|  "None + Pending Out"    |  MUST      |  "To"                    |
|  "None + Pending In"     |  S.N.      |  no state change         |
|  "None + Pending Out+In" |  MUST      |  "To + Pending In"       |
|  "To"                    |  S.N.      |  no state change         |
|  "To + Pending In"       |  S.N.      |  no state change         |
|  "From"                  |  S.N.      |  no state change         |
|  "From + Pending Out"    |  MUST      |  "Both"                  |
|  "Both"                  |  S.N.      |  no state change         |
+------------------------------------------------------------------+
</pre></div>
<a name="substates-in-unsubscribed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3.4"></a><h3>A.3.4.&nbsp;
Unsubscribed</h3>

<p>When the user's server receives a presence stanza of type "unsubscribed" for the user from the contact, if there is a pending outbound request for access to the contact's presence information or if the user currently is subscribed to the contact's presence information, then the user's server MUST change the subscription state and MUST deliver the stanza to the user.  Otherwise, the user's server MUST NOT change the subscription state and (because there is no state change) SHOULD NOT deliver the stanza.  These rules are summarized in the following table.
</p>
<p>Table 9: Processing of inbound "unsubscribed" stanzas
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+------------------------------------------------------------------+
|  EXISTING STATE          |  DELIVER?  |  NEW STATE               |
+------------------------------------------------------------------+
|  "None"                  |  S.N.      |  no state change         |
|  "None + Pending Out"    |  MUST      |  "None"                  |
|  "None + Pending In"     |  S.N.      |  no state change         |
|  "None + Pending Out+In" |  MUST      |  "None + Pending In"     |
|  "To"                    |  MUST      |  "None"                  |
|  "To + Pending In"       |  MUST      |  "None + Pending In"     |
|  "From"                  |  S.N.      |  no state change         |
|  "From + Pending Out"    |  MUST      |  "From"                  |
|  "Both"                  |  MUST      |  "From"                  |
+------------------------------------------------------------------+
</pre></div>
<a name="blocking"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.B"></a><h3>Appendix B.&nbsp;
Blocking Communication</h3>

<p>Sections 2.3.5 and 5.4.10 of <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a> require that a compliant instant messaging and presence technology needs to enable a user to block communications from selected users.  Protocols for doing so are specified in <a class='info' href='#XEP-0016'>[XEP&#8209;0016]<span> (</span><span class='info'>Millard, P. and P. Saint-Andre, &ldquo;Privacy Lists,&rdquo; February&nbsp;2007.</span><span>)</span></a> and <a class='info' href='#XEP-0191'>[XEP&#8209;0191]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Simple Communications Blocking,&rdquo; February&nbsp;2007.</span><span>)</span></a>.
</p>
<a name="vcard"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.C"></a><h3>Appendix C.&nbsp;
vCards</h3>

<p>Sections 3.1.3 and 4.1.4 of <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a> require that it be possible to retrieve out-of-band contact information for other users (e.g., telephone number or email address).  An XML representation of the vCard specification defined in <a class='info' href='#VCARD'>RFC 2426<span> (</span><span class='info'>Dawson, F. and T. Howes, &ldquo;vCard MIME Directory Profile,&rdquo; September&nbsp;1998.</span><span>)</span></a> [VCARD] is in common use within the XMPP community to provide such information but is out of scope for this specification (documentation of this protocol is contained in <a class='info' href='#XEP-0054'>[XEP&#8209;0054]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;vcard-temp,&rdquo; July&nbsp;2008.</span><span>)</span></a>).
</p>
<a name="schema"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.D"></a><h3>Appendix D.&nbsp;
XML Schema for jabber:iq:roster</h3>

<p>The following schema formally defines the 'jabber:iq:roster' namespace used in this document, in conformance with <a class='info' href='#XML-SCHEMA'>[XML&#8209;SCHEMA]<span> (</span><span class='info'>Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, &ldquo;XML Schema Part 1: Structures Second Edition,&rdquo; October&nbsp;2004.</span><span>)</span></a>.  Because validation of XML streams and stanzas is optional, this schema is not normative and is provided for descriptive purposes only.  For schemas defining core XMPP namespaces, refer to <a class='info' href='#XMPP-CORE'>[XMPP&#8209;CORE]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:iq:roster'
    xmlns='jabber:iq:roster'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='query'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element ref='item'
                    minOccurs='0'
                    maxOccurs='unbounded'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='ver'
                    type='xs:string'
                    use='optional'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='item'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element ref='group'
                    minOccurs='0'
                    maxOccurs='unbounded'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='approved'
                    type='xs:boolean'
                    use='optional'/&gt;
      &lt;xs:attribute name='ask'
                    use='optional'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='subscribe'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
      &lt;xs:attribute name='jid'
                    type='xs:string'
                    use='required'/&gt;
      &lt;xs:attribute name='name'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='subscription'
                    use='optional'
                    default='none'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='both'/&gt;
            &lt;xs:enumeration value='from'/&gt;
            &lt;xs:enumeration value='none'/&gt;
            &lt;xs:enumeration value='remove'/&gt;
            &lt;xs:enumeration value='to'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='group' type='xs:string'/&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="diffs"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.E"></a><h3>Appendix E.&nbsp;
Differences From RFC 3921</h3>

<p>Based on consensus derived from implementation and deployment experience as well as formal interoperability testing, the following substantive modifications were made from <a class='info' href='#RFC3921'>[RFC3921]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; October&nbsp;2004.</span><span>)</span></a> (in addition to numerous changes of an editorial nature).
</p>
<p>
        </p>
<ul class="text">
<li>The protocol for session establishment was determined to be unnecessary and therefore the content previously defined in Section 3 of RFC 3921 was removed.  However, for the sake of backward-compatibility server implementations are encouraged to advertise support for the feature, even though session establishment is a "no-op".
</li>
<li>In order to more seamlessly repair lack of synchronization in subscription states between rosters located at different servers, clarified and modified error handling related to presence subscription requests, presence probes and presence notifications.
</li>
<li>Changed the 'from' address for presence probes so that it is the bare JID, not the full JID.
</li>
<li>Adjusted and clarified stanza delivery rules based on implementation and deployment experience.
</li>
<li>Explicitly specified that a server is allowed to deliver a message stanza of type "normal" or "chat" to all resources if it has a method for allowing resources to opt in to such behavior.
</li>
<li>Allowed a server to use its own algorithm for determining the "most available" resource for the purpose of message delivery, but mentioned the recommended algorithm from RFC 3921 (based on presence priority) as one possible algorithm.
</li>
<li>Added optional versioning of roster information to save bandwidth in cases where the roster has not changed (or has changed very little) between sessions; the relevant protocol interactions were originally described in <a class='info' href='#XEP-0237'>[XEP&#8209;0237]<span> (</span><span class='info'>Saint-Andre, P. and D. Cridland, &ldquo;Roster Versioning,&rdquo; March&nbsp;2010.</span><span>)</span></a>.
</li>
<li>Added optional server support for pre-approved presence subscriptions via presence stanzas of type "subscribed", including a new 'approved' attribute that can be set to "true" (for a pre-approved subscription) or "false" (the default).
</li>
<li>Added optional 'parent' attribute to &lt;thread/&gt; element.
</li>
<li>Moved the protocol for communications blocking (specified in Section 10 of RFC 3921) back to <a class='info' href='#XEP-0016'>[XEP&#8209;0016]<span> (</span><span class='info'>Millard, P. and P. Saint-Andre, &ldquo;Privacy Lists,&rdquo; February&nbsp;2007.</span><span>)</span></a>, from which it was originally taken.
</li>
<li>Recommended returning presence unavailable in response to probes.
</li>
<li>Clarified handling of presence probes sent to full JIDs.
</li>
<li>Explicitly specified that the default value for the presence &lt;priority/&gt; element is zero.
</li>
<li>Removed recommendation to support the "_im" and "_pres" SRV records.
</li>
</ul><p>
      
</p>
<a name="acks"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.F"></a><h3>Appendix F.&nbsp;
Acknowledgements</h3>

<p>This document is an update to, and derived from, RFC 3921.  This document would have been impossible without the work of the contributors and commenters acknowledged there.
</p>
<p>Hundreds of people have provided implementation feedback, bug reports, requests for clarification, and suggestions for improvement since publication of RFC 3921.  Although the document editor has endeavored to address all such feedback, he is solely responsible for any remaining errors and ambiguities.
</p>
<p>Some of the text about roster versioning was borrowed from <a class='info' href='#XEP-0237'>[XEP&#8209;0237]<span> (</span><span class='info'>Saint-Andre, P. and D. Cridland, &ldquo;Roster Versioning,&rdquo; March&nbsp;2010.</span><span>)</span></a>, and some of the text about message threads was borrowed from <a class='info' href='#XEP-0201'>[XEP&#8209;0201]<span> (</span><span class='info'>Saint-Andre, P., Paterson, I., and K. Smith, &ldquo;Best Practices for Message Threads,&rdquo; November&nbsp;2010.</span><span>)</span></a>.
</p>
<p>Special thanks are due to Kevin Smith, Matthew Wild, Dave Cridland, Waqas Hussain, Philipp Hancke, Florian Zeitz, Jonas Lindberg, Jehan Pages, Tory Patnoe, and others for their comments during Working Group Last Call.
</p>
<p>Thanks also to Richard Barnes for his review on behalf of the Security Directorate.
</p>
<p>The Working Group chairs were Ben Campbell and Joe Hildebrand.  The responsible Area Director was Gonzalo Camarillo.
</p>
<a name="rfc.authors"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>Author's Address</h3>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Peter Saint-Andre</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Cisco</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">1899 Wyknoop Street, Suite 600</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Denver, CO  80202</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">USA</td></tr>
<tr><td class="author" align="right">Phone:&nbsp;</td>
<td class="author-text">+1-303-308-3282</td></tr>
<tr><td class="author" align="right">EMail:&nbsp;</td>
<td class="author-text"><a href="mailto:psaintan@cisco.com">psaintan@cisco.com</a></td></tr>
</table>
</body></html>