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
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
|
Network Working Group J. Kempf
Request for Comments: 2614 E. Guttman
Category: Informational Sun Microsystems
June 1999
An API for Service Location
Status of This Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Abstract
The Service Location Protocol (SLP) provides a new way for clients to
dynamically discovery network services. With SLP, it is simple to
offer highly available services that require no user configuration or
assistance from network administrators prior to use. This document
describes standardized APIs for SLP in C and Java. The APIs are
modular and are designed to allow implementations to offer just the
feature set needed. In addition, standardized file formats for
configuration and serialized registrations are defined, allowing SLP
agents to set network and other parameters in a portable way. The
serialized file format allows legacy services to be registered with
SLP directory agents in cases where modifying the legacy service
program code is difficult or impossible, and to portably exchange a
registration database.
Table of Contents
1. Introduction 4
1.1. Goals . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2. Terminology . . . . . . . . . . . . . . . . . . . . . 4
2. File Formats 7
2.1. Configuration File Format . . . . . . . . . . . . . . 8
2.1.1. DA configuration . . . . . . . . . . . . . . 9
2.1.2. Static Scope Configuration . . . . . . . . . . 9
2.1.3. Tracing and Logging . . . . . . . . . . . . . 11
2.1.4. Serialized Proxy Registrations . . . . . . . . 11
2.1.5. Network Configuration Properties . . . . . . . 12
2.1.6. SA Configuration . . . . . . . . . . . . . . . 14
2.1.7. UA Configuration . . . . . . . . . . . . . . . 14
2.1.8. Security . . . . . . . . . . . . . . . . . . 15
2.2. Multihomed Machines. . . . . . . . . . . . . . . . . . 16
2.3. Serialized Registration File . . . . . . . . . . . . . 16
Kempf & Guttman Informational [Page 1]
^L
RFC 2614 Service Location API June 1999
2.4. Processing Serialized Registration and Configuration
Files . . . . . . . . . . . . . . . . . . . . . . . . 18
3. Binding Independent Implementation Considerations 18
3.1. Multithreading . . . . . . . . . . . . . . . . . . . . 18
3.2. Asynchronous and Incremental . . . . . . . . . . . . . 19
3.3. Type Checking for Service Types. . . . . . . . . . . . 19
3.4. Refreshing Registrations . . . . . . . . . . . . . . . 19
3.5. Configuration File Processing . . . . . . . . . . . . 19
3.6. Attribute Types . . . . . . . . . . . . . . . . . . . 20
3.7. Removal of Duplicates . . . . . . . . . . . . . . . . 20
3.8. Character Set Encoding . . . . . . . . . . . . . . . . 20
3.9. Error Semantics . . . . . . . . . . . . . . . . . . . 20
3.10. Modular Implementations . . . . . . . . . . . . . . . 24
3.11. Handling Special Service Types . . . . . . . . . . . . 24
3.12. Scope Discovery and Handling . . . . . . . . . . . . . 24
4. C Language Binding 25
4.1. Constant Types . . . . . . . . . . . . . . . . . . . . 26
4.1.1. URL Lifetimes. . . . . . . . . . . . . . . . . 26
4.1.2. Error Codes. . . . . . . . . . . . . . . . . . 26
4.1.3. SLPBoolean . . . . . . . . . . . . . . . . . . 27
4.2. Struct Types . . . . . . . . . . . . . . . . . . . . 28
4.2.1. SLPSrvURL . . . . . . . . . . . . . . . . . . 28
4.2.2. SLPHandle . . . . . . . . . . . . . . . . . . 29
4.3. Callbacks . . . . . . . . . . . . . . . . . . . . . . 29
4.3.1. SLPRegReport . . . . . . . . . . . . . . . . 30
4.3.2. SLPSrvTypeCallback . . . . . . . . . . . . . . 30
4.3.3. SLPSrvURLCallback . . . . . . . . . . . . . . 31
4.3.4. SLPAttrCallback . . . . . . . . . . . . . . . 33
4.4. Opening and Closing an SLPHandle . . . . . . . . . . . 34
4.4.1. SLPOpen. . . . . . . . . . . . . . . . . . . . 34
4.4.2. SLPClose . . . . . . . . . . . . . . . . . . . 35
4.5. Protocol API . . . . . . . . . . . . . . . . . . . . 36
4.5.1. SLPReg . . . . . . . . . . . . . . . . . . . . 36
4.5.2. SLPDereg . . . . . . . . . . . . . . . . . . . 37
4.5.3. SLPDelAttrs . . . . . . . . . . . . . . . . . 38
4.5.4. SLPFindSrvTypes. . . . . . . . . . . . . . . . 39
4.5.5. SLPFindSrvs . . . . . . . . . . . . . . . . . 41
4.5.6. SLPFindAttrs . . . . . . . . . . . . . . . . . 42
4.6. Miscellaneous Functions . . . . . . . . . . . . . . . 43
4.6.1. SLPGetRefreshInterval . . . . . . . . . . . . 44
4.6.2. SLPFindScopes . . . . . . . . . . . . . . . . 44
4.6.3. SLPParseSrvURL . . . . . . . . . . . . . . . . 45
4.6.4. SLPEscape . . . . . . . . . . . . . . . . . . 46
4.6.5. SLPUnescape . . . . . . . . . . . . . . . . . 47
4.6.6. SLPFree . . . . . . . . . . . . . . . . . . . 48
4.6.7. SLPGetProperty . . . . . . . . . . . . . . . . 48
4.6.8. SLPSetProperty . . . . . . . . . . . . . . . . 49
4.7. Implementation Notes . . . . . . . . . . . . . . . . 49
Kempf & Guttman Informational [Page 2]
^L
RFC 2614 Service Location API June 1999
4.7.1. Refreshing Registrations . . . . . . . . . . . 49
4.7.2. Syntax for String Parameters . . . . . . . . . 49
4.7.3. Client Side Syntax Checking . . . . . . . . . 50
4.7.4. System Properties . . . . . . . . . . . . . . 50
4.7.5. Memory Management . . . . . . . . . . . . . . 51
4.7.6. Asynchronous and Incremental Return Semantics. 51
4.8. Example. . . . . . . . . . . . . . . . . . . . . . . . 52
5. Java Language Binding 56
5.1. Introduction . . . . . . . . . . . . . . . . . . . . . 56
5.2. Exceptions and Errors . . . . . . . . . . . . . . . . 56
5.2.1. Class ServiceLocationException . . . . . . . . 57
5.3. Basic Data Structures . . . . . . . . . . . . . . . . 58
5.3.1. Interface ServiceLocationEnumeration . . . . . 58
5.3.2. Class ServiceLocationAttribute . . . . . . . 58
5.3.3. Class ServiceType . . . . . . . . . . . . . . 61
5.3.4. Class ServiceURL . . . . . . . . . . . . . . 63
5.4. SLP Access Interfaces . . . . . . . . . . . . . . . . 67
5.4.1. Interface Advertiser . . . . . . . . . . . . . 67
5.4.2. Interface Locator . . . . . . . . . . . . . . 69
5.5. The Service Location Manager . . . . . . . . . . . . . 72
5.5.1. Class ServiceLocationManager . . . . . . . . . 72
5.6. Service Template Introspection . . . . . . . . . . . . 74
5.6.1. Abstract Class TemplateRegistry . . . . . . . 74
5.6.2. Interface ServiceLocationAttributeVerifier . . 77
5.6.3. Interface ServiceLocationAttributeDescriptor . 79
5.7. Implementation Notes . . . . . . . . . . . . . . . . . 81
5.7.1. Refreshing Registrations . . . . . . . . . . . 81
5.7.2. Parsing Alternate Transports in ServiceURL . . 81
5.7.3. String Attribute Values . . . . . . . . . . . 82
5.7.4. Client Side Syntax Checking. . . . . . . . . . 82
5.7.5. Language Locale Handling . . . . . . . . . . . 82
5.7.6. Setting SLP System Properties. . . . . . . . . 83
5.7.7. Multithreading . . . . . . . . . . . . . . . . 83
5.7.8. Modular Implementations . . . . . . . . . . . 83
5.7.9. Asynchronous and Incremental Return Semantics. 84
5.8. Example. . . . . . . . . . . . . . . . . . . . . . . . 85
6. Internationalization Considerations 87
6.1. service URL. . . . . . . . . . . . . . . . . . . . . . 87
6.2. Character Set Encoding . . . . . . . . . . . . . . . . 87
6.3. Language Tagging . . . . . . . . . . . . . . . . . . 88
7. Security Considerations 88
8. Acknowledgements 88
9. References 89
10. Authors' Addresses 90
11. Full Copyright Statement 91
Kempf & Guttman Informational [Page 3]
^L
RFC 2614 Service Location API June 1999
1. Introduction
The Service Location API is designed for standardized access to the
Service Location Protocol (SLP). The APIs allow client and service
programs to be be written or modified in a very simple manner to
provide dynamic service discovery and selection. Bindings in the C
and Java languages are defined in this document. In addition,
standardized formats for configuration files and for serialized
registration files are presented. These files allow SLP agents to
configure network parameters, to register legacy services that have
not been SLP enabled, and to portably exchange registration
databases.
1.1. Goals
The overall goal of the API is to enable source portability of
applications that use the API between different implementations of
SLP. The result should facilitate the adoption of SLP, and conversion
of clients and service programs to SLP.
The goals of the C binding are to create a minimal but complete
access to the functionality of the SLP protocol, allowing for simple
memory management and limited code size.
The Java API provides for modular implementations (where unneeded
features can be omitted) and an object oriented interface to the
complete set of SLP data and functionality.
The standardized configuration file and serialized file formats
provide a simple syntax with complete functional coverage of the
protocol, but without system dependent properties and secure
information.
1.2. Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [1].
Service Location Protocol (SLP)
The underlying protocol allowing dynamic and scalable service
discovery. This protocol is specified in the Service Location
Protocol Version 2 [7].
Kempf & Guttman Informational [Page 4]
^L
RFC 2614 Service Location API June 1999
SLP framework
When a 'Service Location framework' is mentioned, it refers to
both the SLP implementation and interface implementation; i.e.
whatever provides the SLP functionality to user level programs.
This includes remote agents.
Directory Agent (DA)
A service that automatically gathers service advertisements
from SAs in order to provide them to UAs.
User Agent (UA)
This is the Service Location process or library that allows SLP
requests to be made on behalf of a client process. UAs
automatically direct requests to DAs when they exist. In their
absence, UAs make requests to SAs.
Service Agent (SA)
This is the Service Location process or library that allows
service software to register and deregister itself with the SLP
framework. SAs respond to UA service requests, detect DAs and
register service advertisements with them.
SA Server
Many operating system platforms only allow a single process to
listen on a particular port number. Since SAs are required to
listen on a multicast address for SLP service requests,
implementations of the SLP framework on such platforms that
want to support multiple SAs on one machine need to arrange for
a single process to do the listening while the advertising SAs
communicate with that process through another mechanism. The
single listening process is called an SA server. SA servers
share many characteristics with DAs, but they are not the same.
Service Advertisement
A URL possibly combined with service attributes. These are
made available to UAs by SAs, either directly or via a DA.
Locale
The language localization that applies to strings passed into
or returned from the SLP API. The Locale is expressed using a
Language Tag [6]. All attribute strings are associated with a
Kempf & Guttman Informational [Page 5]
^L
RFC 2614 Service Location API June 1999
particular locale. The locale is completely orthogonal to the
ANSI C locale. The SLP locale is mapped into the Java locale
in the Java API.
Service Template
A document that describes the syntax of the URL for a given
service type and a definition of all service attributes
including the meaning, defaults, and constraints on values the
attributes may take. See [8] for more information on service
templates.
The service: URL
A service of a particular type announces its availability with
a service: URL that includes its service access point (domain
name or IP address, and possibly its port number) and
optionally basic configuration parameters. The syntax of the
service: URL is defined in the service template. Other URL's
can be used in service advertisements if desired.
Service Attributes
The attributes associated with a given service. The values
that can be assigned to service attributes are defined by the
service template.
Scope
A string used to control the availability of service
advertisements. Every SLP Agent is configured with one or more
scope strings. Scopes are assigned by site administrators to
group services for many purposes, but chiefly as a means of
scalability. DAs store only services advertised having a scope
string matching the scopes with which they are configured.
Naming Authority (NA)
This is a 'suffix' to the service type string. It completely
changes the meaning of the service type. NAs are used for
private definitions of well known Service Types and
experimental Service Type extensions. The default NA is
"IANA", which must not be explicitly included. Service types
with the IANA naming authority are registered with the Internet
Assigned Numbers Authority (see [8] for more information on the
registration procedure).
Kempf & Guttman Informational [Page 6]
^L
RFC 2614 Service Location API June 1999
2. File Formats
This section describes the configuration and serialized registration
file formats. Both files are defined in the UTF-8 character set [3].
Attribute tags and values in the serialized registration file require
SLP reserved characters to be escaped. The SLP reserved characters
are `(', `)', `,', `\', `!', `<', `=', `>', `~' and control
characters (characters with UTF codes less than 0x0020 and the
character 0x007f, which is US-ASCII DEL). The escapes are formed
exactly as for the wire protocol, i.e. a backslash followed by two
hex digits representing the character. For example, the escape for '
,' is '\2c'. In addition, the characters `\n', `\r', `\t', and `_'
are prohibited from attribute tags by the SLP wire syntax grammar.
[7]
In serialized registration files, escaped strings beginning with
`\ff`, an encoding for a nonUTF-8 character, are treated as opaques.
Exactly as in the wire protocol, syntactically correct opaque
encodings consist of a string beginning with `\ff` and containing
*only* escaped characters that are transformed to bytes. Such
strings are only syntactically correct in the serialized registration
file as attribute values. In other cases, whenever an escape is
encountered and the character is not an SLP reserved character, an
error is signaled.
Escaped characters in URLs in serialized registration files use the
URL escape convention. [2].
Property names and values in the configuration file have a few
reserved characters that are involved in file's lexical definition.
The characters '.' and '=' are reserved in property names and must
be escape. The characters ',', '(', and ')' are reserved in property
values and must be escaped. In addition, scope names in the
net.slp.useScopes property use the SLP wire format escape convention
for SLP reserved characters. This simplifies implementation, since
the same code can be used to unescape scope names as is used in
processing the serialized registration file or for formatting wire
messages.
On platforms that only support US-ASCII and not UTF-8, the upper bit
of bytes incoming from the configuration and registration files
determines whether the character is US-ASCII or not US-ASCII.
According to the standard UTF-8 encoding, the upper bit is zero if
the character is US-ASCII and one if the character is multibyte and
thus not US-ASCII. Platforms without intrinsic UTF-8 support are
required to parse the multibyte character and store it in an
appropriate internal format. Support for UTF-8 is required to
Kempf & Guttman Informational [Page 7]
^L
RFC 2614 Service Location API June 1999
implement the SLP protocol (see [7]), and can therefore be used in
file processing as well.
The location and name of the configuration file is system-dependent,
but implementations of the API are encouraged to locate it together
with other configuration files and name it consistently.
2.1. Configuration File Format
The configuration file format consists of a newline delimited list of
zero or more property definitions. Each property definition
corresponds to a particular configurable SLP, network, or other
parameter in one or more of the three SLP agents. The file format
grammar in ABNF [5] syntax is:
config-file = line-list
line-list = line / line line-list
line = property-line / comment-line
comment-line = ( "#" / ";" ) 1*allchar newline
property-line = property newline
property = tag "=" value-list
tag = prop / prop "." tag
prop = 1*tagchar
value-list = value / value "," value-list
value = int / bool /
"(" value-list ")" / string
int = 1*DIGIT
bool = "true" / "false" / "TRUE" / "FALSE"
newline = CR / ( CRLF )
string = 1*stringchar
tagchar = DIGIT / ALPHA / tother / escape
tother = %x21-%x2d / %x2f /
%x3a / %x3c-%x40 /
%x5b-%x60 / %7b-%7e
; i.e., all characters except `.',
; and `='.
stringchar = DIGIT / ALPHA / sother / escape
sother = %x21-%x29 / %x2a-%x2b /
%x2d-%x2f / %x3a-%x40 /
%x5b-%x60 / %7b-%7e
; i.e., all characters except `,'
allchar = DIGIT / ALPHA / HTAB / SP
escape = "\" HEXDIG HEXDIG
; Used for reserved characters
With the exception of net.slp.useScopes, net.slp.DAAddresses, and
net.slp.isBroadcastOnly, all other properties can be changed through
property accessors in the C and Java APIs. The property accessors
Kempf & Guttman Informational [Page 8]
^L
RFC 2614 Service Location API June 1999
only change the property values in the running agent program and do
not affect the values in the configuration file. The
net.slp.useScopes and net.slp.DAAddresses properties are read-only
because they control the agent's view of the scopes and DAs and are
therefore critical to the function of the API scope discovery
algorithm. Attempts to modify them are unlikely to yield productive
results, and could harm the ability of the agent to find scopes and
use DAs. The net.slp.isBroadcastOnly property is read-only because
the API library needs to configure networking upon start up and
changing this property might invalidate the configuration. Whether
the local network uses broadcast or multicast is not likely to change
during the course of the program's execution.
The properties break down into the following subsections describes an
area and its properties.
2.1.1. DA configuration
Important configuration properties for DAs are included in this
section. These are:
net.slp.isDA
A boolean indicating if the SLP server is to act as a DA. If
false, not run as a DA. Default is false.
net.slp.DAHeartBeat
A 32 bit integer giving the number of seconds for the
DA heartbeat. Default is 3 hours (10800 seconds). This
property corresponds to the protocol specification parameter
CONFIG_DA_BEAT [7]. Ignored if isDA is false.
net.slp.DAAttributes
A comma-separated list of parenthesized attribute/value list
pairs that the DA must advertise in DAAdverts. The property
must be in the SLP attribute list wire format, including
escapes for reserved characters. [7]
2.1.2. Static Scope Configuration
These properties allow various aspects of scope handling to be
configured.
Kempf & Guttman Informational [Page 9]
^L
RFC 2614 Service Location API June 1999
net.slp.useScopes
A value-list of strings indicating the only scopes a UA or SA
is allowed to use when making requests or registering, or the
scopes a DA must support. If not present for the DA and SA,
then in the absence of scope information from DHCP, the default
scope "DEFAULT" is used. If not present for the UA, and there
is no scope information available from DHCP, then the user
scoping model is in force. Active and passive DA discovery
or SA discovery are used for scope discovery, and the scope
"DEFAULT" is used if no other information is available. If a
DA or SA gets another scope in a request, a SCOPE_NOT_SUPPORTED
error should be returned, unless the request was multicast, in
which case it should be dropped. If a DA gets another scope in
a registration, a SCOPE_NOT_SUPPORTED error must be returned.
Unlike other properties, this property is "read-only", so
attempts to change it after the configuration file has been
read are ignored. See Section 3.12 for the algorithm the API
uses in determining what scope information to present.
net.slp.DAAddresses
A value-list of IP addresses or DNS resolvable host names
giving the SLPv2 DAs to use for statically configured UAs and
SAs. Ignored by DAs (unless the DA is also an SA server).
Default is none. Unlike other properties, this property is
"read-only", so attempts to change it after the configuration
file has been read are ignored.
The following grammar describes the property:
addr-list = addr / addr "," addr-list
addr = fqdn / hostnumber
fqdn = ALPHA / ALPHA *[ anum / "-" ] anum
anum = ALPHA / DIGIT
hostnumber = 1*3DIGIT 3("." 1*3DIGIT)
An example is:
sawah,mandi,sambal
IP addresses can be used instead of host names in networks
where DNS is not deployed, but network administrators are
reminded that using IP addresses will complicate machine
Kempf & Guttman Informational [Page 10]
^L
RFC 2614 Service Location API June 1999
renumbering, since the SLP configuration property files
in statically configured networks will have to be changed.
Similarly, if host names are used, implementors must be careful
that a name service is available before SLP starts, in other
words, SLP cannot be used to find the name service.
2.1.3. Tracing and Logging
This section allows tracing and logging information to be printed by
the various agents.
net.slp.traceDATraffic
A boolean controlling printing of messages about traffic with
DAs. Default is false.
net.slp.traceMsg
A boolean controlling printing of details on SLP messages.
The fields in all incoming messages and outgoing replies are
printed. Default is false.
net.slp.traceDrop
A boolean controlling printing details when a SLP message is
dropped for any reason. Default is false.
net.slp.traceReg
A boolean controlling dumps of all registered services upon
registration and deregistration. If true, the contents
of the DA or SA server are dumped after a registration or
deregistration occurs. Default is false.
2.1.4. Serialized Proxy Registrations
These properties control the reading and writing of serialized
registrations.
net.slp.serializedRegURL
A string containing a URL pointing to a document containing
serialized registrations that should be processed when the DA
or SA server starts up. Default is none.
Kempf & Guttman Informational [Page 11]
^L
RFC 2614 Service Location API June 1999
2.1.5. Network Configuration Properties
The properties in this section allow various network configuration
properties to be set.
net.slp.isBroadcastOnly
A boolean indicating if broadcast should be used instead of
multicast. Like the net.slp.useScopes and net.slp.DAAddresses
properties, this property is "read-only", so attempts to change
it after the configuration file has been read are ignored.
Default is false.
net.slp.passiveDADetection
A boolean indicating whether passive DA detection should be
used. Default is true.
net.slp.multicastTTL
A positive integer less than or equal to 255, giving the
multicast TTL. Default is 255.
net.slp.DAActiveDiscoveryInterval
A 16 bit positive integer giving the number of seconds
between DA active discovery queries. Default is 900 seconds
(15 minutes). This property corresponds to the protocol
specification parameter CONFIG_DA_FIND [7]. If the property is
set to zero, active discovery is turned off. This is useful
when the DAs available are explicitly restricted to those
obtained from DHCP or the net.slp.DAAddresses property.
net.slp.multicastMaximumWait
A 32 bit integer giving the maximum amount of time to perform
multicast, in milliseconds. Default is 15000 ms (15 sec.).
This property corresponds to the CONFIG_MC_MAX parameter in the
protocol specification [7].
net.slp.multicastTimeouts
A value-list of 32 bit integers used as timeouts, in
milliseconds, to implement the multicast convergence
algorithm. Each value specifies the time to wait before
sending the next request, or until nothing new has
been learned from two successive requests. Default
is: 3000,3000,3000,3000,3000. In a fast network the
Kempf & Guttman Informational [Page 12]
^L
RFC 2614 Service Location API June 1999
aggressive values of 1000,1250,1500,2000,4000 allow better
performance. This property corresponds to the CONFIG_MC_RETRY
parameter in the protocol specification [7]. Note that the
net.slp.DADiscoveryTimeouts property must be used for active DA
discovery.
net.slp.DADiscoveryTimeouts
A value-list of 32 bit integers used as timeouts, in
milliseconds, to implement the multicast convergence algorithm
during active DA discovery. Each value specifies the time
to wait before sending the next request, or until nothing
new has been learned from two successive requests. This
property corresponds to the protocol specification parameter
CONFIG_RETRY [7]. Default is: 2000,2000,2000,2000,3000,4000.
net.slp.datagramTimeouts
A value-list of 32 bit integers used as timeouts, in
milliseconds, to implement unicast datagram transmission to
DAs. The nth value gives the time to block waiting for a reply
on the nth try to contact the DA. The sum of these values is
the protocol specification property CONFIG_RETRY_MAX [7].
net.slp.randomWaitBound
A 32 bit integer giving the maximum value for all random
wait parameters, in milliseconds. Default is 1000 (1
sec.). This value corresponds to the protocol specification
parameters CONFIG_START_WAIT, CONFIG_REG_PASSIVE, and
CONFIG_REG_ACTIVE [7].
net.slp.MTU
A 16 bit integer giving the network packet MTU, in bytes.
This is the maximum size of any datagram to send, but the
implementation might receive a larger datagram. The maximum
size includes IP, and UDP or TCP headers. Default is 1400.
net.slp.interfaces
Value-list of strings giving the IP addresses of network
interfaces on which the DA or SA should listen on port 427 for
multicast, unicast UDP, and TCP messages. Default is empty,
i.e. use the default network interface. The grammar for this
property is:
Kempf & Guttman Informational [Page 13]
^L
RFC 2614 Service Location API June 1999
addr-list = hostnumber / hostnumber "," addr-list
hostnumber = 1*3DIGIT 3("." 1*3DIGIT)
An example is:
195.42.42.42,195.42.142.1,195.42.120.1
The example machine has three interfaces on which the DA should
listen.
Note that since this property only takes IP addresses, it will
need to be changed if the network is renumbered.
2.1.6. SA Configuration
This section contains configuration properties for the SA. These
properties are typically set programmatically by the SA, since they
are specific to each SA.
net.slp.SAAttributes
A comma-separated list of parenthesized attribute/value list
pairs that the SA must advertise in SAAdverts. The property
must be in the SLP attribute list wire format, including
escapes for reserved characters. [7]
2.1.7. UA Configuration
This section contains configuration properties for the UA. These
properties can be set either programmatically by the UA or in the
configuration file.
net.slp.locale
A RFC 1766 Language Tag [6] for the language locale. Setting
this property causes the property value to become the default
locale for SLP messages. Default is "en". This property is
also used for SA and DA configuration.
net.slp.maxResults
A 32 bit integer giving the maximum number of results to
accumulate and return for a synchronous request before the
timeout, or the maximum number of results to return through a
callback if the request results are reported asynchronously.
Kempf & Guttman Informational [Page 14]
^L
RFC 2614 Service Location API June 1999
Positive integers and -1 are legal values. If -1, indicates
that all results should be returned. Default value is -1.
DAs and SAs always return all results that match the
request. This configuration value applies only to UAs, that
filter incoming results and only return as many values as
net.slp.maxResults indicates.
net.slp.typeHint
A value-list of service type names. In the absence of any
DAs, UAs perform SA discovery for finding scopes. These SA
discovery requests may contain a request for service types as
an attribute.
The API implementation will use the service type names supplied
by this property to discover only those SAs (and their scopes)
which support the desired service type or types. For example,
if net.slp.typeHint is set to "service:imap,service:pop3" then
SA discovery requests will include the search filter:
(|(service-type=service:imap)(service-type=service:pop3))
The API library can also use unicast to contact the discovered
SAs for subsequent requests for these service types, to
optimize network access.
2.1.8. Security
The property in this section allows security for all agents to be set
on or off. When the property is true, then the agent must include
security information on all SLP messages transacted by that agent.
Since security policy must be set network wide to be effective, a
single property controls security for all agents. Key management and
management of SLP SPI strings [7] are implementation and policy
dependent.
net.slp.securityEnabled
A boolean indicating whether the agent should enable
security for URLs, attribute lists, DAAdverts, and SAAdverts.
Each agent is responsible for interpreting the property
appropriately. Default is false.
Kempf & Guttman Informational [Page 15]
^L
RFC 2614 Service Location API June 1999
2.2. Multihomed Machines
On multihomed machines, the bandwidth and latency characteristics on
different network interfaces may differ considerably, to the point
where different configuration properties are necessary to achieve
optimal performance. The net.slp.interfaces property indicates which
network interfaces are SLP enabled. An API library implementation
may support configuration customization on a per network interface
basis by allowing the interface IP address to be appended to the
property name. In that case, the values of the property are only
used for that particular interface, the generic property (or defaults
if no generic property is set) applies to all others.
For example, if a configuration has the following properties:
net.slp.interfaces=125.196.42.41,125.196.42.42,125.196.42.43
net.slp.multicastTTL.125.196.42.42=1
then the network interface on subnet 42 is restricted to a TTL of 1,
while the interfaces on the other subnets have the default multicast
radius, 255.
The net.slp.interfaces property must only be set if there is no
routing between the interfaces. If the property is set, the DA (if
any) and SAs should advertise with the IP address or host name
appropriate to the interface on the interfaces in the list. If
packets are routed between the interfaces, then the DA and SAs should
only advertise on the default interface. The property should also be
set if broadcast is used rather than multicast on the subnets
connected to the interfaces. Note that even if unicast packets are
not routed between the interfaces, multicast may be routed through
another router. The danger in listening for multicast on multiple
interfaces when multicast packets are routed is that the DA or SA may
receive the same multicast request via more than one interface.
Since the IP address is different on each interface, the DA or SA
cannot identify the request as having already being answered via the
previous responder's list. The requesting agent will end up getting
URLs that refer to the same DA or service but have different
addresses or host names.
2.3. Serialized Registration File
The serialized registration file contains a group of registrations
that a DA or SA server (if one exists) registers when it starts up.
These registrations are primarily for older service programs that do
not internally support SLP and cannot be converted, and for portably
Kempf & Guttman Informational [Page 16]
^L
RFC 2614 Service Location API June 1999
exchanging registrations between SLP implementations. The character
encoding of the registrations is required to be UTF-8.
The syntax of the serialized registration file, in ABNF format [5],
is as follows:
ser-file = reg-list
reg-list = reg / reg reg-list
reg = creg / ser-reg
creg = comment-line ser-reg
comment-line = ( "#" / ";" ) 1*allchar newline
ser-reg = url-props [slist] [attr-list] newline
url-props = surl "," lang "," ltime [ "," type ] newline
surl = ;The registration's URL. See
; [8] for syntax.
lang = 1*8ALPHA [ "-" 1*8ALPHA ]
;RFC 1766 Language Tag see [6].
ltime = 1*5DIGIT
; A positive 16-bit integer
; giving the lifetime
; of the registration.
type = ; The service type name, see [7]
; and [8] for syntax.
slist = "scopes" "=" scope-list newline
scope-list = scope-name / scope-name "," scope-list
scope = ; See grammar of [7] for
; scope-name syntax.
attr-list = attr-def / attr-def attr-list
attr-def = ( attr / keyword ) newline
keyword = attr-id
attr = attr-id "=" attr-val-list
attr-id = ;Attribute id, see [7] for syntax.
attr-val-list = attr-val / attr-val "," attr-val-list
attr-val = ;Attribute value, see [7] for syntax.
allchar = char / WSP
char = DIGIT / ALPHA / other
other = %x21-%x2f / %x3a-%x40 /
%x5b-%x60 / %7b-%7e
; All printable, nonwhitespace US-ASCII
; characters.
newline = CR / ( CRLF )
The syntax for scope names, attribute tags, and attribute values
requires escapes for special characters as specified in [7]. DAs and
SA servers that process serialized registrations must handle them
exactly as if they were registered by an SA. In the url-props
Kempf & Guttman Informational [Page 17]
^L
RFC 2614 Service Location API June 1999
production, the type token is optional. If the type token is present
for a service: URL, a warning is signaled and the type name is
ignored. If the maximum lifetime is specified (65535 sec.), the
registration is taken to be permanent, and is continually refreshed
by the DA or SA server until it exits. Scopes can be included in a
registration by including an attribute definition with tag "scopes"
followed by a comma separated list of scope names immediately after
the url-props production. If the optional scope list is present, the
registrations are made in the indicated scopes; otherwise, they are
registered in the scopes with which the DA or SA server was
configured through the net.slp.useScopes property.
If the scope list contains scopes that are not in the
net.slp.useScopes property (provided that property is set) or are not
specified by DHCP, the API library should reject the registration and
issue a warning message.
2.4. Processing Serialized Registration and Configuration Files
Implementations are encouraged to make processing of configuration
and serialized files as transparent as possible to clients of the
API. At the latest, errors must be caught when the relevant
configuration item is used. At the earliest, errors may be caught
when the relevant file is loaded into the executing agent. Errors
should be reported by logging to the appropriate platform logging
file, error output, or log device, and the default value substituted.
Serialized registration file entries should be caught and reported
when the file is loaded.
Configuration file loading must be complete prior to the initiation
of the first networking connection. Serialized registration must be
complete before the DA accepts the first network request.
3. Binding Independent Implementation Considerations
This section discusses a number of implementation considerations
independent of language binding, with language specific notes where
applicable.
3.1. Multithreading
Implementations of both the C and Java APIs are required to make API
calls thread-safe. Access to data structures shared between threads
must be co-ordinated to avoid corruption or invalid access. One way
to achieve this goal is to allow only one thread at a time in the
implementing library. Performance in such an implementation suffers,
however. Therefore, where possible, implementations are encouraged
to allow multiple threads within the SLP API library.
Kempf & Guttman Informational [Page 18]
^L
RFC 2614 Service Location API June 1999
3.2. Asynchronous and Incremental
The APIs are designed to encourage implementations supporting
asynchronous and incremental client interaction. The goal is to
allow large numbers of returned service URLs, service types, and
attributes without requiring the allocation of huge chunks of memory.
The particular design features to support this goal differ in the two
language bindings.
3.3. Type Checking for Service Types
Service templates [8] allow SLP registrations to be type checked for
correctness. Implementations of the API are free to make use of
service type information for type checking, but are not required to
do so. If a type error occurs, the registration should terminate
with TYPE_ERROR.
3.4. Refreshing Registrations
SLP advertisements carry an explicit lifetime with them. After the
lifetime expires, the DA flushes the registration from its cache. In
some cases, an application may want to have the URL continue being
registered for the entire time during which the application is
executing. The API includes provision for clients to indicate
whether they want URLs to be automatically refreshed.
Implementations of the SA API must provide this automatic refreshing
capability. Note that a client which uses this facility should
explicitly deregister the service URL before exiting, since the API
implementation may not be able to assure that the URL is deregistered
when the application exits, although it will time out in the DA
eventually.
3.5. Configuration File Processing
DAs, SAs and UAs processing the configuration file, and DAs and SA
servers processing the serialized registration file are required to
log any errors using whatever underlying error mechanism is
appropriate for the platform. Examples include writing error
messages to the standard output, writing to a system logging device,
or displaying the errors to a logging window. After the error is
reported, the offending property must be set to the default and
program execution continued. An agent MUST NOT fail if a file format
error occurs.
Kempf & Guttman Informational [Page 19]
^L
RFC 2614 Service Location API June 1999
3.6. Attribute Types
String encoded attribute values do not include explicit type
information. All UA implementations and those SA and DA
implementations that choose to support type checking should use the
type rules described in [8] in order to convert from the string
representation on the wire to an object typed appropriately.
3.7. Removal of Duplicates
The UA implementation SHOULD always collate results to remove
duplicates during synchronous operations and for the Java API. During
asynchronous operation in C, the UA implementation SHOULD forgo
duplicate elimination to reduce memory requirements in the library.
This allows the API library to simply take the returned attribute
value list strings, URL strings, or service type list strings and
call the callback function with it, without any additional
processing. Naturally, the burden of duplicate elimination is thrown
onto the client in this case.
3.8. Character Set Encoding
Character string parameters in the Java API are all represented in
Unicode internally because that is the Java-supported character set.
Characters buffer parameters in the C API are represented in UTF-8 to
maintain maximum compatibility on platforms that only support US-
ASCII and not UTF-8. API functions are still required to handle the
full range of UTF-8 characters because the SLP protocol requires it,
but the API implementation can represent the characters internally in
any convenient way. On the wire, all characters are converted to
UTF-8. Inside URLs, characters that are not allowed by URL syntax
[2] must be escaped according to the URL escape character convention.
Strings that are included in SLP messages may include SLP reserved
characters and can be escaped by clients through convenience
functions provided by the API. The character encoding used in escapes
is UTF-8.
Due to constraints in SLP, no string parameter passed to the C or
Java API may exceed 64K bytes in length.
3.9. Error Semantics
All errors encountered processing SLP messages should be logged. For
synchronous calls, an error is only reported on a call if no
successful replies were received from any SLP framework entity. If
an error occurred among one of several successful replies, then the
error should be logged and the successful replies returned. For
asynchronous calls, an error occurring during correspondence with a
Kempf & Guttman Informational [Page 20]
^L
RFC 2614 Service Location API June 1999
particular remote SLP agent is reported through the first callback
(in the C API) or enumeration method invocation (in the Java API)
after the error occurs, which would normally report the results of
the correspondence. This allows the callback or client code to
determine whether the operation should be terminated or continue. In
some cases, the error returned from the SLP framework may be fatal
(SLP_PARSE_ERROR, etc.). In these cases, the API library terminates
the operation.
Both the Java and C APIs contain language specific error code
mechanisms for returning error information. The names of the error
codes are consistent between the two implementations, however.
The following error codes are returned from a remote agent (DA or SA
server):
LANGUAGE_NOT_SUPPORTED
No DA or SA has service advertisement or attribute information
in the language requested, but at least one DA or SA indicated,
via the LANGUAGE_NOT_SUPPORTED error code, that it might have
information for that service in another language.
PARSE_ERROR
The SLP message was rejected by a remote SLP agent. The API
returns this error only when no information was retrieved, and
at least one SA or DA indicated a protocol error. The data
supplied through the API may be malformed or a may have been
damaged in transit.
INVALID_REGISTRATION
The API may return this error if an attempt to register a
service was rejected by all DAs because of a malformed URL or
attributes. SLP does not return the error if at least one DA
accepted the registration.
AUTHENTICATION_ABSENT
If the SLP framework supports authentication, this error arises
when the UA or SA failed to send an authenticator for requests
or registrations in a protected scope.
Kempf & Guttman Informational [Page 21]
^L
RFC 2614 Service Location API June 1999
INVALID_UPDATE
An update for a non-existing registration was issued, or the
update includes a service type or scope different than that in
the initial registration, etc.
The following errors result from interactions with remote agents or
can occur locally:
AUTHENTICATION_FAILED
If the SLP framework supports authentication, this error arises
when a authentication on an SLP message failed.
SCOPE_NOT_SUPPORTED
The API returns this error if the SA has been configured with
net.slp.useScopes value-list of scopes and the SA request did
not specify one or more of these allowable scopes, and no
others. It may be returned by a DA or SA if the scope included
in a request is not supported by the DA or SA.
REFRESH_REJECTED
The SA attempted to refresh a registration more frequently
than the minimum refresh interval. The SA should call the
appropriate API function to obtain the minimum refresh interval
to use.
The following errors are generated through a program interacting with
the API implementation. They do not involve a remote SLP agent.
NOT_IMPLEMENTED
If an unimplemented feature is used, this error is returned.
NETWORK_INIT_FAILED
If the network cannot initialize properly, this error is
returned.
NETWORK_TIMED_OUT
When no reply can be obtained in the time specified by the
configured timeout interval for a unicast request, this error
is returned.
Kempf & Guttman Informational [Page 22]
^L
RFC 2614 Service Location API June 1999
NETWORK_ERROR
The failure of networking during normal operations causes this
error to be returned.
BUFFER_OVERFLOW
An outgoing request overflowed the maximum network MTU size.
The request should be reduced in size or broken into pieces and
tried again.
MEMORY_ALLOC_FAILED
If the API fails to allocate memory, the operation is aborted
and returns this.
PARAMETER_BAD
If a parameter passed into an interface is bad, this error is
returned.
INTERNAL_SYSTEM_ERROR
A basic failure of the API causes this error to be returned.
This occurs when a system call or library fails. The operation
could not recover.
HANDLE_IN_USE
In the C API, callback functions are not permitted to
recursively call into the API on the same SLPHandle, either
directly or indirectly. If an attempt is made to do so, this
error is returned from the called API function.
TYPE_ERROR
If the API supports type checking of registrations against
service type templates, this error can arise if the attributes
in a registration do not match the service type template for
the service.
Some error codes are handled differently in the Java API. These
differences are discussed in Section 5.
The SLP protocol errors OPTION_NOT_UNDERSTOOD, VERSION_NOT_SUPPORTED,
INTERNAL_ERROR, MSG_NOT_SUPPORTED, AUTHENTICATON_UNKNOWN, and
DA_BUSY_NOW should be handled internally and not surfaced to clients
through the API.
Kempf & Guttman Informational [Page 23]
^L
RFC 2614 Service Location API June 1999
3.10. Modular Implementations
Subset implementations that do not support the full range of
functionality are required to nevertheless support every interface in
order to maintain link compatibility between compliant API
implementations and applications. If a particular operation is not
supported, a NOT_IMPLEMENTED error should be returned. The Java API
has some additional conventions for handling subsets. Applications
that are expected to run on a wide variety of platforms should be
prepared for subset API implementations by checking returned error
codes.
3.11. Handling Special Service Types
The service types service:directory-agent and service:service-agent
are used internally in the SLP framework to discover DAs and SAs.
The mechanism of DA and SA discovery is not normally exposed to the
API client; however, the client may have interest in discovering DAs
and SAs independently of their role in discovering other services.
For example, a network management application may want to determine
which machines are running SLP DAs. To facilitate that, API
implementations must handle requests to find services and attributes
for these two service types so that API clients obtain the
information they expect.
In particular, if the UA is using a DA, SrvRqst and AttrRqst for
these service types must be multicast and not unicast to the DA, as
is the case for other service types. If the requests are not
multicast, the DA will respond with an empty reply to a request for
services of type service:service-agent and with its URL only to a
request for services of type service:directory-agent. The UA would
therefore not obtain a complete picture of the available DAs and SAs.
3.12. Scope Discovery and Handling
Both APIs contain an operation to obtain a list of currently known
scope names. This scope information comes from a variety of places:
DHCP, the net.slp.useScopes property, unicast to DAs configured via
DHCP or the net.slp.DAAddresses property, and active and passive
discovery.
The API is required to be implemented in a way that re-enforces the
administrative and user scoping models described in [7]. SA clients
only support the administrative scoping model. SAs must know a
priori what DAs they need to register with since there is typically
no human intervention in scope selection for SAs. UAs must support
both administrative and user scoping because an application may
require human intervention in scope selection.
Kempf & Guttman Informational [Page 24]
^L
RFC 2614 Service Location API June 1999
API implementations are required to support administrative scoping in
the following way. Scopes configured by DHCP and scopes of DAs
configured by DHCP have first priority (in that order) and must be
returned if they are available. The net.slp.useScopes property has
second priority, and scopes discovered through the net.slp.useScopes
property must be returned if this property is set and there are no
scopes available from DHCP. If scopes are not available from either
of these sources and the net.slp.DAAddresses property is set, then
the scopes available from the configured DAs must be returned. Note
that if both DAs and scopes are configured, the scopes of the
configured DAs must match the configured scope list; otherwise and
error is signaled and agent execution is terminated. If no
configured scope information is available, then an SA client has
default scope, "DEFAULT", and a UA client employs user scoping.
User scoping is supported in the following way. Scopes discovered
from active DA discovery, and from passive DA discovery all must be
returned. If no information is available from active and passive DA
discovery, then the API library may perform SA discovery, using the
service types in the net.slp.typeHint property to limit the search to
SAs supporting particular service types. If no net.slp.typeHint
property is set, the UA may perform SA discovery without any service
type query. In the absence of any of the above sources of
information, the API must return the default scope, "DEFAULT". Note
that the API must always return some scope information.
SLP requires that SAs must perform their operations in all scopes
currently known to them. [7]. The API enforces this constraint by
not requiring the API client to supply any scopes as parameters to
API operations. The API library must obtain all currently known
scopes and use them in SA operations. UA API clients should use a
scope obtained through one of the API operations for finding scopes.
Any other scope name may result in a SCOPE_NOT_SUPPORTED error from a
remote agent. The UA API library can optionally check the scope and
return the error without contacting a remote agent.
4. C Language Binding
The C language binding presents a minimal overhead implementation
that maps directly into the protocol. There is one C language
function per protocol request, with the exception of the SLPDereg()
and SLPDelAttrs() functions, which map into different uses of the SLP
deregister request. Parameters are for the most part character
buffers. Memory management is kept simple by having the client
allocate most memory and requiring that client callback functions
copy incoming parameters into memory allocated by the client code.
Any memory returned directly from the API functions is deallocated
using the SLPFree() function.
Kempf & Guttman Informational [Page 25]
^L
RFC 2614 Service Location API June 1999
To conform with standard C practice, all character strings passed to
and returned through the API are null terminated, even though the SLP
protocol does not use null terminated strings. Strings passed as
parameters are UTF-8 but they may still be passed as a C string (a
null terminated sequence of bytes.) Escaped characters must be
encoded by the API client as UTF-8. In the common case of US-ASCII,
the usual one byte per character C strings work. API functions
assist in escaping and unescaping strings.
Unless otherwise noted, parameters to API functions and callbacks are
non-NULL. Some parameters may have other restrictions. If any
parameter fails to satisfy the restrictions on its value, the
operation returns a PARAMETER_BAD error.
4.1. Constant Types
4.1.1. URL Lifetimes
4.1.1.1. Synopsis
typedef enum {
SLP_LIFETIME_DEFAULT = 10800,
SLP_LIFETIME_MAXIMUM = 65535
} SLPURLLifetime;
4.1.1.2. Description
The SLPURLLifetime enum type contains URL lifetime values, in
seconds, that are frequently used. SLP_LIFETIME_DEFAULT is 3 hours,
while SLP_LIFETIME_MAXIMUM is about 18 hours and corresponds to the
maximum size of the lifetime field in SLP messages.
4.1.2. Error Codes
4.1.2.1. Synopsis
typedef enum {
SLP_LAST_CALL = 1,
SLP_OK = 0,
SLP_LANGUAGE_NOT_SUPPORTED = -1,
SLP_PARSE_ERROR = -2,
SLP_INVALID_REGISTRATION = -3,
SLP_SCOPE_NOT_SUPPORTED = -4,
SLP_AUTHENTICATION_ABSENT = -6,
SLP_AUTHENTICATION_FAILED = -7,
Kempf & Guttman Informational [Page 26]
^L
RFC 2614 Service Location API June 1999
SLP_INVALID_UPDATE = -13,
SLP_REFRESH_REJECTED = -15,
SLP_NOT_IMPLEMENTED = -17,
SLP_BUFFER_OVERFLOW = -18,
SLP_NETWORK_TIMED_OUT = -19,
SLP_NETWORK_INIT_FAILED = -20,
SLP_MEMORY_ALLOC_FAILED = -21,
SLP_PARAMETER_BAD = -22,
SLP_NETWORK_ERROR = -23,
SLP_INTERNAL_SYSTEM_ERROR = -24,
SLP_HANDLE_IN_USE = -25,
SLP_TYPE_ERROR = -26
} SLPError ;
4.1.2.2. Description
The SLPError enum contains error codes that are returned from API
functions.
The SLP_OK code indicates that the no error occurred during the
operation.
The SLP_LAST_CALL code is passed to callback functions when the API
library has no more data for them and therefore no further calls will
be made to the callback on the currently outstanding operation. The
callback can use this to signal the main body of the client code that
no more data will be forthcoming on the operation, so that the main
body of the client code can break out of data collection loops. On
the last call of a callback during both a synchronous and
asynchronous call, the error code parameter has value SLP_LAST_CALL,
and the other parameters are all NULL. If no results are returned by
an API operation, then only one call is made, with the error
parameter set to SLP_LAST_CALL.
4.1.3. SLPBoolean
4.1.3.1. Synopsis
typedef enum {
SLP_FALSE = 0,
SLP_TRUE = 1
} SLPBoolean;
Kempf & Guttman Informational [Page 27]
^L
RFC 2614 Service Location API June 1999
4.1.3.2. Description
The SLPBoolean enum is used as a boolean flag.
4.2. Struct Types
4.2.1. SLPSrvURL
4.2.1.1. Synopsis
typedef struct srvurl {
char *s_pcSrvType;
char *s_pcHost;
int s_iPort;
char *s_pcNetFamily;
char *s_pcSrvPart;
} SLPSrvURL;
4.2.1.2. Description
The SLPSrvURL structure is filled in by the SLPParseSrvURL() function
with information parsed from a character buffer containing a service
URL. The fields correspond to different parts of the URL. Note that
the structure is in conformance with the standard Berkeley sockets
struct servent, with the exception that the pointer to an array of
characters for aliases (s_aliases field) is replaced by the pointer
to host name (s_pcHost field).
s_pcSrvType
A pointer to a character string containing the service
type name, including naming authority. The service type
name includes the "service:" if the URL is of the service:
scheme. [7]
s_pcHost
A pointer to a character string containing the host
identification information.
s_iPort
The port number, or zero if none. The port is only available
if the transport is IP.
Kempf & Guttman Informational [Page 28]
^L
RFC 2614 Service Location API June 1999
s_pcNetFamily
A pointer to a character string containing the network address
family identifier. Possible values are "ipx" for the IPX
family, "at" for the Appletalk family, and "" (i.e. the empty
string) for the IP address family.
s_pcSrvPart
The remainder of the URL, after the host identification.
The host and port should be sufficient to open a socket to the
machine hosting the service, and the remainder of the URL should
allow further differentiation of the service.
4.2.2. SLPHandle
4.2.2.1. Synopsis
typedef void* SLPHandle;
The SLPHandle type is returned by SLPOpen() and is a parameter to all
SLP functions. It serves as a handle for all resources allocated on
behalf of the process by the SLP library. The type is opaque, since
the exact nature differs depending on the implementation.
4.3. Callbacks
A function pointer to a callback function specific to a particular
API operation is included in the parameter list when the API function
is invoked. The callback function is called with the results of the
operation in both the synchronous and asynchronous cases. The memory
included in the callback parameters is owned by the API library, and
the client code in the callback must copy out the contents if it
wants to maintain the information longer than the duration of the
current callback call.
In addition to parameters for reporting the results of the operation,
each callback parameter list contains an error code parameter and a
cookie parameter. The error code parameter reports the error status
of the ongoing (for asynchronous) or completed (for synchronous)
operation. The cookie parameter allows the client code that starts
the operation by invoking the API function to pass information down
to the callback without using global variables. The callback returns
an SLPBoolean to indicate whether the API library should continue
processing the operation. If the value returned from the callback is
Kempf & Guttman Informational [Page 29]
^L
RFC 2614 Service Location API June 1999
SLP_TRUE, asynchronous operations are terminated, synchronous
operations ignore the return (since the operation is already
complete).
4.3.1. SLPRegReport
4.3.1.1. Synopsis
typedef void SLPRegReport(SLPHandle hSLP,
SLPError errCode,
void *pvCookie);
4.3.1.2. Description
The SLPRegReport callback type is the type of the callback function
to the SLPReg(), SLPDereg(), and SLPDelAttrs() functions.
4.3.1.3. Parameters
hSLP
The SLPHandle used to initiate the operation.
errCode
An error code indicating if an error occurred during the
operation.
pvCookie
Memory passed down from the client code that called the
original API function, starting the operation. May be NULL.
4.3.2. SLPSrvTypeCallback
4.3.2.1. Synopsis
typedef SLPBoolean SLPSrvTypeCallback(SLPHandle hSLP,
const char* pcSrvTypes,
SLPError errCode,
void *pvCookie);
Kempf & Guttman Informational [Page 30]
^L
RFC 2614 Service Location API June 1999
4.3.2.2. Description
The SLPSrvTypeCallback type is the type of the callback function
parameter to SLPFindSrvTypes() function. If the hSLP handle
parameter was opened asynchronously, the results returned through the
callback MAY be uncollated. If the hSLP handle parameter was opened
synchronously, then the returned results must be collated and
duplicates eliminated.
4.3.2.3. Parameters
hSLP
The SLPHandle used to initiate the operation.
pcSrvTypes
A character buffer containing a comma separated, null
terminated list of service types.
errCode
An error code indicating if an error occurred during the
operation. The callback should check this error code before
processing the parameters. If the error code is other than
SLP_OK, then the API library may choose to terminate the
outstanding operation.
pvCookie
Memory passed down from the client code that called the
original API function, starting the operation. May be NULL.
4.3.2.4. Returns
The client code should return SLP_TRUE if more data is desired,
otherwise SLP_FALSE.
4.3.3. SLPSrvURLCallback
4.3.3.1. Synopsis
typedef SLPBoolean SLPSrvURLCallback(SLPHandle hSLP,
const char* pcSrvURL,
unsigned short sLifetime,
SLPError errCode,
void *pvCookie);
Kempf & Guttman Informational [Page 31]
^L
RFC 2614 Service Location API June 1999
4.3.3.2. Description
The SLPSrvURLCallback type is the type of the callback function
parameter to SLPFindSrvs() function. If the hSLP handle parameter
was opened asynchronously, the results returned through the callback
MAY be uncollated. If the hSLP handle parameter was opened
synchronously, then the returned results must be collated and
duplicates eliminated.
4.3.3.3. Parameters
hSLP
The SLPHandle used to initiate the operation.
pcSrvURL
A character buffer containing the returned service URL.
sLifetime
An unsigned short giving the life time of the service
advertisement, in seconds. The value must be an unsigned
integer less than or equal to SLP_LIFETIME_MAXIMUM.
errCode
An error code indicating if an error occurred during the
operation. The callback should check this error code before
processing the parameters. If the error code is other than
SLP_OK, then the API library may choose to terminate the
outstanding operation.
pvCookie
Memory passed down from the client code that called the
original API function, starting the operation. May be NULL.
4.3.3.4. Returns
The client code should return SLP_TRUE if more data is desired,
otherwise SLP_FALSE.
Kempf & Guttman Informational [Page 32]
^L
RFC 2614 Service Location API June 1999
4.3.4. SLPAttrCallback
4.3.4.1. Synopsis
typedef SLPBoolean SLPAttrCallback(SLPHandle hSLP,
const char* pcAttrList,
SLPError errCode,
void *pvCookie);
4.3.4.2. Description
The SLPAttrCallback type is the type of the callback function
parameter to SLPFindAttrs() function.
The behavior of the callback differs depending on whether the
attribute request was by URL or by service type. If the
SLPFindAttrs() operation was originally called with a URL, the
callback is called once regardless of whether the handle was opened
asynchronously or synchronously. The pcAttrList parameter contains
the requested attributes as a comma separated list (or is empty if no
attributes matched the original tag list).
If the SLPFindAttrs() operation was originally called with a service
type, the value of pcAttrList and calling behavior depend on whether
the handle was opened asynchronously or synchronously. If the handle
was opened asynchronously, the callback is called every time the API
library has results from a remote agent. The pcAttrList parameter
MAY be uncollated between calls. It contains a comma separated list
with the results from the agent that immediately returned results.
If the handle was opened synchronously, the results must be collated
from all returning agents and the callback is called once, with the
pcAttrList parameter set to the collated result.
4.3.4.3. Parameters
hSLP
The SLPHandle used to initiate the operation.
pcAttrList
A character buffer containing a comma separated, null
terminated list of attribute id/value assignments, in SLP wire
format; i.e. "(attr-id=attr-value-list)" [7].
Kempf & Guttman Informational [Page 33]
^L
RFC 2614 Service Location API June 1999
errCode
An error code indicating if an error occurred during the
operation. The callback should check this error code before
processing the parameters. If the error code is other than
SLP_OK, then the API library may choose to terminate the
outstanding operation.
pvCookie
Memory passed down from the client code that called the
original API function, starting the operation. May be NULL.
4.3.4.4. Returns
The client code should return SLP_TRUE if more data is desired,
otherwise SLP_FALSE.
4.4. Opening and Closing an SLPHandle
4.4.1. SLPOpen
4.4.1.1. Synopsis
SLPError SLPOpen(const char *pcLang, SLPBoolean isAsync, SLPHandle
*phSLP);
4.4.1.2. Description
Returns a SLPHandle handle in the phSLP parameter for the language
locale passed in as the pcLang parameter. The client indicates if
operations on the handle are to be synchronous or asynchronous
through the isAsync parameter. The handle encapsulates the language
locale for SLP requests issued through the handle, and any other
resources required by the implementation. However, SLP properties
are not encapsulated by the handle; they are global. The return
value of the function is an SLPError code indicating the status of
the operation. Upon failure, the phSLP parameter is NULL.
An SLPHandle can only be used for one SLP API operation at a time.
If the original operation was started asynchronously, any attempt to
start an additional operation on the handle while the original
operation is pending results in the return of an SLP_HANDLE_IN_USE
error from the API function. The SLPClose() API function terminates
any outstanding calls on the handle. If an implementation is unable
to support a asynchronous( resp. synchronous) operation, due to
memory constraints or lack of threading support, the
SLP_NOT_IMPLEMENTED flag may be returned when the isAsync flag is
Kempf & Guttman Informational [Page 34]
^L
RFC 2614 Service Location API June 1999
SLP_TRUE (resp. SLP_FALSE).
4.4.1.3. Parameters
pcLang
A pointer to an array of characters containing the RFC 1766
Language Tag [6] for the natural language locale of requests
and registrations issued on the handle.
isAsync
An SLPBoolean indicating whether the SLPHandle should be opened
for asynchronous operation or not.
phSLP
A pointer to an SLPHandle, in which the open SLPHandle is
returned. If an error occurs, the value upon return is NULL.
4.4.2. SLPClose
4.4.2.1. Synopsis
void SLPClose(SLPHandle hSLP);
4.4.2.2. Description
Frees all resources associated with the handle. If the handle was
invalid, the function returns silently. Any outstanding synchronous
or asynchronous operations are cancelled so their callback functions
will not be called any further.
4.4.2.3. Parameters
SLPHandle
A SLPHandle handle returned from a call to SLPOpen().
Kempf & Guttman Informational [Page 35]
^L
RFC 2614 Service Location API June 1999
4.5. Protocol API
4.5.1. SLPReg
4.5.1.1. Synopsis
SLPError SLPReg(SLPHandle hSLP,
const char *pcSrvURL,
const unsigned short usLifetime,
const char *pcSrvType,
const char *pcAttrs
SLPBoolean fresh,
SLPRegReport callback,
void *pvCookie);
4.5.1.2. Description
Registers the URL in pcSrvURL having the lifetime usLifetime with the
attribute list in pcAttrs. The pcAttrs list is a comma separated
list of attribute assignments in the wire format (including escaping
of reserved characters). The usLifetime parameter must be nonzero
and less than or equal to SLP_LIFETIME_MAXIMUM. If the fresh flag is
SLP_TRUE, then the registration is new (the SLP protocol FRESH flag
is set) and the registration replaces any existing registrations.
The pcSrvType parameter is a service type name and can be included
for service URLs that are not in the service: scheme. If the URL is
in the service: scheme, the pcSrvType parameter is ignored. If the
fresh flag is SLP_FALSE, then an existing registration is updated.
Rules for new and updated registrations, and the format for pcAttrs
and pcScopeList can be found in [7]. Registrations and updates take
place in the language locale of the hSLP handle.
The API library is required to perform the operation in all scopes
obtained through configuration.
4.5.1.3. Parameters
hSLP
The language specific SLPHandle on which to register the
advertisement.
pcSrvURL
The URL to register. May not be the empty string.
Kempf & Guttman Informational [Page 36]
^L
RFC 2614 Service Location API June 1999
usLifetime
An unsigned short giving the life time of the service
advertisement, in seconds. The value must be an unsigned
integer less than or equal to SLP_LIFETIME_MAXIMUM and greater
than zero.
pcSrvType
The service type. If pURL is a service: URL, then this
parameter is ignored.
pcAttrs
A comma separated list of attribute assignment expressions for
the attributes of the advertisement. Use empty string, "" for
no attributes.
fresh
An SLPBoolean that is SLP_TRUE if the registration is new or
SLP_FALSE if a reregistration.
callback
A callback to report the operation completion status.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
4.5.1.4. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.5.2. SLPDereg
4.5.2.1. Synopsis
SLPError SLPDereg(SLPHandle hSLP,
const char *pcURL,
SLPRegReport callback,
void *pvCookie);
Kempf & Guttman Informational [Page 37]
^L
RFC 2614 Service Location API June 1999
4.5.2.2. Description
Deregisters the advertisement for URL pcURL in all scopes where the
service is registered and all language locales. The deregistration
is not just confined to the locale of the SLPHandle, it is in all
locales. The API library is required to perform the operation in all
scopes obtained through configuration.
4.5.2.3. Parameters
hSLP
The language specific SLPHandle to use for deregistering.
pcURL
The URL to deregister. May not be the empty string.
callback
A callback to report the operation completion status.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
4.5.2.4. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.5.3. SLPDelAttrs
4.5.3.1. Synopsis
SLPError SLPDelAttrs(SLPHandle hSLP,
const char *pcURL,
const char *pcAttrs,
SLPRegReport callback,
void *pvCookie);
Kempf & Guttman Informational [Page 38]
^L
RFC 2614 Service Location API June 1999
4.5.3.2. Description
Delete the selected attributes in the locale of the SLPHandle. The
API library is required to perform the operation in all scopes
obtained through configuration.
4.5.3.3. Parameters
hSLP
The language specific SLPHandle to use for deleting attributes.
pcURL
The URL of the advertisement from which the attributes should
be deleted. May not be the empty string.
pcAttrs
A comma separated list of attribute ids for the attributes to
deregister. See Section 9.8 in [7] for a description of the
list format. May not be the empty string.
callback
A callback to report the operation completion status.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
4.5.3.4. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.5.4. SLPFindSrvTypes
4.5.4.1. Synopsis
SLPError SLPFindSrvTypes(SLPHandle hSLP,
const char *pcNamingAuthority,
const char *pcScopeList,
SLPSrvTypeCallback callback,
void *pvCookie);
Kempf & Guttman Informational [Page 39]
^L
RFC 2614 Service Location API June 1999
The SLPFindSrvType() function issues an SLP service type request for
service types in the scopes indicated by the pcScopeList. The
results are returned through the callback parameter. The service
types are independent of language locale, but only for services
registered in one of scopes and for the indicated naming authority.
If the naming authority is "*", then results are returned for all
naming authorities. If the naming authority is the empty string,
i.e. "", then the default naming authority, "IANA", is used. "IANA"
is not a valid naming authority name, and it is a PARAMETER_BAD error
to include it explicitly.
The service type names are returned with the naming authority intact.
If the naming authority is the default (i.e. empty string) then it
is omitted, as is the separating ".". Service type names from URLs
of the service: scheme are returned with the "service:" prefix
intact. [7] See [8] for more information on the syntax of service
type names.
4.5.4.2. Parameters
hSLP
The SLPHandle on which to search for types.
pcNamingAuthority
The naming authority to search. Use "*" for all naming
authorities and the empty string, "", for the default naming
authority.
pcScopeList
A pointer to a char containing comma separated list of scope
names to search for service types. May not be the empty
string, "".
callback
A callback function through which the results of the operation
are reported.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
Kempf & Guttman Informational [Page 40]
^L
RFC 2614 Service Location API June 1999
4.5.4.3. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.5.5. SLPFindSrvs
4.5.5.1. Synopsis
SLPError SLPFindSrvs(SLPHandle hSLP,
const char *pcServiceType,
const char *pcScopeList,
const char *pcSearchFilter,
SLPSrvURLCallback callback,
void *pvCookie);
4.5.5.2. Description
Issue the query for services on the language specific SLPHandle and
return the results through the callback. The parameters determine
the results
4.5.5.3. Parameters
hSLP
The language specific SLPHandle on which to search for
services.
pcServiceType
The Service Type String, including authority string if any, for
the request, such as can be discovered using SLPSrvTypes().
This could be, for example "service:printer:lpr" or
"service:nfs". May not be the empty string.
pcScopeList
A pointer to a char containing comma separated list of scope
names. May not be the empty string, "".
pcSearchFilter
A query formulated of attribute pattern matching expressions in
the form of a LDAPv3 Search Filter, see [4]. If this filter
is empty, i.e. "", all services of the requested type in the
Kempf & Guttman Informational [Page 41]
^L
RFC 2614 Service Location API June 1999
specified scopes are returned.
callback
A callback function through which the results of the operation
are reported.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
4.5.5.4. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.5.6. SLPFindAttrs
4.5.6.1. Synopsis
SLPError SLPFindAttrs(SLPHandle hSLP,
const char *pcURLOrServiceType,
const char *pcScopeList,
const char *pcAttrIds,
SLPAttrCallback callback,
void *pvCookie);
4.5.6.2. Description
This function returns service attributes matching the attribute ids
for the indicated service URL or service type. If pcURLOrServiceType
is a service URL, the attribute information returned is for that
particular advertisement in the language locale of the SLPHandle.
If pcURLOrServiceType is a service type name (including naming
authority if any), then the attributes for all advertisements of that
service type are returned regardless of the language of registration.
Results are returned through the callback.
The result is filtered with an SLP attribute request filter string
parameter, the syntax of which is described in [7]. If the filter
string is the empty string, i.e. "", all attributes are returned.
Kempf & Guttman Informational [Page 42]
^L
RFC 2614 Service Location API June 1999
4.5.6.3. Parameters
hSLP
The language specific SLPHandle on which to search for
attributes.
pcURLOrServiceType
The service URL or service type. See [7] for URL and service
type syntax. May not be the empty string.
pcScopeList
A pointer to a char containing a comma separated list of scope
names. May not be the empty string, "".
pcAttrIds
The filter string indicating which attribute values to return.
Use empty string, "", to indicate all values. Wildcards
matching all attribute ids having a particular prefix or suffix
are also possible. See [7] for the exact format of the filter
string.
callback
A callback function through which the results of the operation
are reported.
pvCookie
Memory passed to the callback code from the client. May be
NULL.
4.5.6.4. Returns
If an error occurs in starting the operation, one of the SLPError
codes is returned.
4.6. Miscellaneous Functions
4.6.1. SLPGetRefreshInterval
4.6.1.1. Synopsis
unsigned short SLPGetRefreshInterval();
Kempf & Guttman Informational [Page 43]
^L
RFC 2614 Service Location API June 1999
4.6.1.2. Description
Returns the maximum across all DAs of the min-refresh-interval
attribute. This value satisfies the advertised refresh interval
bounds for all DAs, and, if used by the SA, assures that no refresh
registration will be rejected. If no DA advertises a min-refresh-
interval attribute, a value of 0 is returned.
4.6.1.3. Returns
If no error, the maximum refresh interval value allowed by all DAs (a
positive integer). If no DA advertises a min-refresh-interval
attribute, returns 0. If an error occurs, returns an SLP error code.
4.6.2. SLPFindScopes
4.6.2.1. Synopsis
SLPError SLPFindScopes(SLPHandle hSLP,
char** ppcScopeList);
4.6.2.2. Description
Sets ppcScopeList parameter to a pointer to a comma separated list
including all available scope values. The list of scopes comes from
a variety of sources: the configuration file's net.slp.useScopes
property, unicast to DAs on the net.slp.DAAddresses property, DHCP,
or through the DA discovery process. If there is any order to the
scopes, preferred scopes are listed before less desirable scopes.
There is always at least one name in the list, the default scope,
"DEFAULT".
4.6.2.3. Parameters
hSLP
The SLPHandle on which to search for scopes.
ppcScopeList
A pointer to char pointer into which the buffer pointer is
placed upon return. The buffer is null terminated. The memory
should be freed by calling SLPFree().
Kempf & Guttman Informational [Page 44]
^L
RFC 2614 Service Location API June 1999
4.6.2.4. Returns
If no error occurs, returns SLP_OK, otherwise, the appropriate error
code.
4.6.3. SLPParseSrvURL
4.6.3.1. Synopsis
SLPError SLPParseSrvURL(char *pcSrvURL
SLPSrvURL** ppSrvURL);
4.6.3.2. Description
Parses the URL passed in as the argument into a service URL structure
and returns it in the ppSrvURL pointer. If a parse error occurs,
returns SLP_PARSE_ERROR. The input buffer pcSrvURL is destructively
modified during the parse and used to fill in the fields of the
return structure. The structure returned in ppSrvURL should be freed
with SLPFreeURL(). If the URL has no service part, the s_pcSrvPart
string is the empty string, "", i.e. not NULL. If pcSrvURL is not a
service: URL, then the s_pcSrvType field in the returned data
structure is the URL's scheme, which might not be the same as the
service type under which the URL was registered. If the transport is
IP, the s_pcTransport field is the empty string. If the transport is
not IP or there is no port number, the s_iPort field is zero.
4.6.3.3. Parameters
pcSrvURL
A pointer to a character buffer containing the null terminated
URL string to parse. It is destructively modified to produce
the output structure.
ppSrvURL
A pointer to a pointer for the SLPSrvURL structure to receive
the parsed URL. The memory should be freed by a call to
SLPFree() when no longer needed.
4.6.3.4. Returns
If no error occurs, the return value is SLP_OK. Otherwise, the
appropriate error code is returned.
Kempf & Guttman Informational [Page 45]
^L
RFC 2614 Service Location API June 1999
4.6.4. SLPEscape
4.6.4.1. Synopsis
SLPError SLPEscape(const char* pcInbuf,
char** ppcOutBuf,
SLPBoolean isTag);
4.6.4.2. Description
Process the input string in pcInbuf and escape any SLP reserved
characters. If the isTag parameter is SLPTrue, then look for bad tag
characters and signal an error if any are found by returning the
SLP_PARSE_ERROR code. The results are put into a buffer allocated by
the API library and returned in the ppcOutBuf parameter. This buffer
should be deallocated using SLPFree() when the memory is no longer
needed.
4.6.4.3. Parameters
pcInbuf
Pointer to he input buffer to process for escape characters.
ppcOutBuf
Pointer to a pointer for the output buffer with the SLP
reserved characters escaped. Must be freed using SLPFree()
when the memory is no longer needed.
isTag
When true, the input buffer is checked for bad tag characters.
4.6.4.4. Returns
Return SLP_PARSE_ERROR if any characters are bad tag characters and
the isTag flag is true, otherwise SLP_OK, or the appropriate error
code if another error occurs.
Kempf & Guttman Informational [Page 46]
^L
RFC 2614 Service Location API June 1999
4.6.5. SLPUnescape
4.6.5.1. Synopsis
SLPError SLPUnescape(const char* pcInbuf,
char** ppcOutBuf,
SLPBoolean isTag);
4.6.5.2. Description
Process the input string in pcInbuf and unescape any SLP reserved
characters. If the isTag parameter is SLPTrue, then look for bad tag
characters and signal an error if any are found with the
SLP_PARSE_ERROR code. No transformation is performed if the input
string is an opaque. The results are put into a buffer allocated by
the API library and returned in the ppcOutBuf parameter. This buffer
should be deallocated using SLPFree() when the memory is no longer
needed.
4.6.5.3. Parameters
pcInbuf
Pointer to he input buffer to process for escape characters.
ppcOutBuf
Pointer to a pointer for the output buffer with the SLP
reserved characters escaped. Must be freed using SLPFree()
when the memory is no longer needed.
isTag
When true, the input buffer is checked for bad tag characters.
4.6.5.4. Returns
Return SLP_PARSE_ERROR if any characters are bad tag characters and
the isTag flag is true, otherwise SLP_OK, or the appropriate error
code if another error occurs.
Kempf & Guttman Informational [Page 47]
^L
RFC 2614 Service Location API June 1999
4.6.6. SLPFree
4.6.6.1. Synopsis
void SLPFree(void* pvMem);
4.6.6.2. Description
Frees memory returned from SLPParseSrvURL(), SLPFindScopes(),
SLPEscape(), and SLPUnescape().
4.6.6.3. Parameters
pvMem
A pointer to the storage allocated by the SLPParseSrvURL(),
SLPEscape(), SLPUnescape(), or SLPFindScopes() function.
Ignored if NULL.
4.6.7. SLPGetProperty
4.6.7.1. Synopsis
const char* SLPGetProperty(const char* pcName);
4.6.7.2. Description
Returns the value of the corresponding SLP property name. The
returned string is owned by the library and MUST NOT be freed.
4.6.7.3. Parameters
pcName
Null terminated string with the property name, from
Section 2.1.
4.6.7.4. Returns
If no error, returns a pointer to a character buffer containing the
property value. If the property was not set, returns the default
value. If an error occurs, returns NULL. The returned string MUST
NOT be freed.
Kempf & Guttman Informational [Page 48]
^L
RFC 2614 Service Location API June 1999
4.6.8. SLPSetProperty
4.6.8.1. Synopsis
void SLPSetProperty(const char *pcName,
const char *pcValue);
4.6.8.2. Description
Sets the value of the SLP property to the new value. The pcValue
parameter should be the property value as a string.
4.6.8.3. Parameters
pcName
Null terminated string with the property name, from
Section 2.1.
pcValue
Null terminated string with the property value, in UTF-8
character encoding.
4.7. Implementation Notes
4.7.1. Refreshing Registrations
Clients indicate that they want URLs to be automatically refreshed by
setting the usLifetime parameter in the SLPReg() function call to
SLP_LIFETIME_MAXIMUM. This will cause the API implementation to
refresh the URL before it times out. Although using
SLP_LIFETIME_MAXIMUM to designate automatic reregistration means that
a transient URL can't be registered for the maximum lifetime, little
hardship is likely to occur, since service URL lifetimes are measured
in seconds and the client can simply use a lifetime of
SLP_LIFETIME_MAXIMUM - 1 if a transient URL near the maximum lifetime
is desired. API implementations MUST provide this facility.
4.7.2. Syntax for String Parameters
Query strings, attribute registration lists, attribute deregistration
lists, scope lists, and attribute selection lists follow the syntax
described in [7] for the appropriate requests. The API directly
reflects the strings passed in from clients into protocol requests,
and directly reflects out strings returned from protocol replies to
Kempf & Guttman Informational [Page 49]
^L
RFC 2614 Service Location API June 1999
clients. As a consequence, clients are responsible for formatting
request strings, including escaping and converting opaque values to
escaped byte encoded strings. Similarly, on output, clients are
required to unescape strings and convert escaped string encoded
opaques to binary. The functions SLPEscape() and SLPUnescape() can
be used for escaping SLP reserved characters, but perform no opaque
processing.
Opaque values consist of a character buffer containing a UTF-8-
encoded string, the first characters of which are the nonUTF-8
encoding '\ff'. Subsequent characters are the escaped values for the
original bytes in the opaque. The escape convention is relatively
simple. An escape consists of a backslash followed by the two
hexadecimal digits encoding the byte. An example is '\2c' for the
byte 0x2c. Clients handle opaque processing themselves, since the
algorithm is relatively simple and uniform.
4.7.3. Client Side Syntax Checking
Client side API implementations may do syntax checking of scope
names, naming authority names, and service type names, but are not
required to do so. Since the C API is designed to be a thin layer
over the protocol, some low memory SA implementations may find
extensive syntax checking on the client side to be burdensome. If
syntax checking uncovers an error in a parameter, the
SLP_PARAMETER_BAD error must be returned. If any parameter is NULL
and is required to be nonNULL, SLP_PARAMETER_BAD is returned.
4.7.4. System Properties
The system properties established in the configuration file are
accessible through the SLPGetProperty() and SLPSetProperty()
functions. The SLPSetProperty() function only modifies properties in
the running process, not in the configuration file. Properties are
global to the process, affecting all threads and all handles created
with SLPOpen. Errors are checked when the property is used and, as
with parsing the configuration file, are logged. Program execution
continues without interruption by substituting the default for the
erroneous parameter. With the exception of net.slp.locale,
net.slp.typeHint, and net.slp.maxResults, clients of the API should
rarely be required to override these properties, since they reflect
properties of the SLP network that are not of concern to individual
agents. If changes are required, system administrators should modify
the configuration file.
Kempf & Guttman Informational [Page 50]
^L
RFC 2614 Service Location API June 1999
4.7.5. Memory Management
The only API functions returning memory specifically requiring
deallocation on the part of the client are SLPParseSrvURL(),
SLPFindScopes(), SLPEscape(), and SLPUnescape(). This memory should
be freed using SLPFree() when no longer needed. Character strings
returned via the SLPGetProperty() function should NOT be freed, they
are owned by the SLP library.
Memory passed to callbacks belongs to the library and MUST NOT be
retained by the client code. Otherwise, crashes are possible.
Clients are required to copy data out of the callback parameters. No
other use of the parameter memory in callback parameters is allowed.
4.7.6. Asynchronous and Incremental Return Semantics
If a handle parameter to an API function was opened asynchronously,
API function calls on the handle check the other parameters, open the
appropriate operation and return immediately. In an error occurs in
the process of starting the operation, an error code is returned. If
the handle parameter was opened synchronously, the API function call
blocks until all results are available, and returns only after the
results are reported through the callback function. The return code
indicates whether any errors occurred both starting and during the
operation.
The callback function is called whenever the API library has results
to report. The callback code is required to check the error code
parameter before looking at the other parameters. If the error code
is not SLP_OK, the other parameters may be invalid. The API library
has the option of terminating any outstanding operation on which an
error occurs. The callback code can similarly indicate that the
operation should be terminated by passing back SLP_FALSE. Callback
functions are not permitted to recursively call into the API on the
same SLPHandle. If an attempt is made to recursively call into the
API, the API function returns SLP_HANDLE_IN_USE. Prohibiting
recursive callbacks on the same handle simplifies implementation of
thread safe code, since locks held on the handle will not be in place
during a second outcall on the handle. On the other hand, it means
that handle creation should be fairly lightweight so a client program
can easily support multiple outstanding calls.
The total number of results received can be controlled by setting the
net.slp.maxResults parameter.
On the last call to a callback, whether asynchronous or synchronous,
the status code passed to the callback has value SLP_LAST_CALL. There
are four reasons why the call can terminate:
Kempf & Guttman Informational [Page 51]
^L
RFC 2614 Service Location API June 1999
DA reply received
A reply from a DA has been received and therefore nothing more
is expected.
Multicast terminated
The multicast convergence time has elapsed and the API library
multicast code is giving up.
Multicast null results
Nothing new has been received during multicast for a while and
the API library multicast code is giving up on that (as an
optimization).
Maximum results
The user has set the net.slp.maxResults property and that
number of replies has been collected and returned
4.8. Example
This example illustrates how to discover a mailbox.
A POP3 server registers itself with the SLP framework. The
attributes it registers are "USER", a list of all users whose mail is
available through the POP3 server.
The POP3 server code is the following:
SLPHandle slph;
SLPRegReport errCallback = POPRegErrCallback;
/* Create an English SLPHandle, asynchronous processing. */
SLPError err = SLPOpen("en", SLP_TRUE, &slph);
if( err != SLP_OK ) {
/* Deal with error. */
}
/* Create the service: URL and attribute parameters. */
const char* surl = "service:pop3://mail.netsurf.de"; /* the URL */
Kempf & Guttman Informational [Page 52]
^L
RFC 2614 Service Location API June 1999
const char *pcAttrs = "(user=zaphod,trillian,roger,marvin)"
/* Perform the registration. */
err = SLPReg(slph,
surl,
SLP_LIFETIME_DEFAULT,
ppcAttrs,
errCallback,
NULL);
if (err != SLP_OK ) {
/*Deal with error.*/
}
The errCallback reports any errors:
void
POPRegErrCallback(SLPHandle hSLP,
SLPError errCode,
unsigned short usLifetime,
void* pvCookie) {
if( errCode != SLP_OK ) {
/* Report error through a dialog, message, etc. */
}
/*Use lifetime interval to update periodically. */
}
The POP3 client locates the server for the user with the following
code:
/*
* The client calls SLPOpen(), exactly as above.
*/
const char *pcSrvType = "service:pop3"; /* the service type */
const char *pcScopeList = "default"; /* the scope */
const char *pcFilter = "(user=roger)"; /* the search filter */
SLPSrvURLCallback srvCallback = /* the callback */
POPSrvURLCallback;
Kempf & Guttman Informational [Page 53]
^L
RFC 2614 Service Location API June 1999
err = SLPFindSrvs(slph,
pcSrvType, pcScopeList, pcFilter,
srvCallback, NULL);
if( err != SLP_OK ) {
/* Deal with error. */
}
Within the callback, the client code can use the returned POP
service:
SLPBoolean
POPSrvURLCallback(SLPHandle hSLP,
const char* pcSrvURL,
unsigned short sLifetime,
SLPError errCode,
void* pvCookie) {
if( errCode != SLP_OK ) {
/* Deal with error. */
}
SLPSrvURL* pSrvURL;
errCode = SLPParseSrvURL(pcSrvURL, &pSrvURL);
if (err != SLP_OK ) {
/* Deal with error. */
} else {
/* get the server's address */
struct hostent *phe = gethostbyname(pSrvURL.s_pcHost);
/* use hostname in pSrvURL to connect to the POP3 server
* . . .
*/
SLPFreeSrvURL((void*)pSrvURL); /* Free the pSrvURL storage */
}
return SLP_FALSE; /* Done! */
Kempf & Guttman Informational [Page 54]
^L
RFC 2614 Service Location API June 1999
}
A client that wanted to discover all the users receiving mail at the
server uses with the following query:
/*
* The client calls SLPOpen(), exactly as above. We assume the
* service: URL was retrieved into surl.
*/
const char *pcScopeList = "default"; /* the scope */
const char *pcAttrFilter = "use"; /* the attribute filter */
SLPAttrCallback attrCallBack = /* the callback */
POPUsersCallback
err =
SLPFindAttrs(slph,
surl,
pcScopeList, pcAttrFilter,
attrCallBack, NULL);
if( err != SLP_OK ) {
/* Deal with error. */
}
The callback processes the attributes:
SLPBoolean
POPUsersCallback(const char* pcAttrList,
SLPError errCode,
void* pvCookie) {
if( errCode != SLP_OK ) {
/* Deal with error. */
} else {
/* Parse attributes. */
}
return SLP_FALSE; /* Done! */
}
Kempf & Guttman Informational [Page 55]
^L
RFC 2614 Service Location API June 1999
5. Java Language Binding
5.1. Introduction
The Java API is designed to model the various SLP entities in classes
and objects. APIs are provided for SA, UA, and service type template
access capabilities. The ServiceLocationManager class contains
methods that return instances of objects implementing SA and UA
capability. Each of these is modeled in an interface. The Locator
interface provides UA capability and the Advertiser interface
provides SA capability. The TemplateRegistry abstract class contains
methods that return objects for template introspection and attribute
type checking. The ServiceURL, ServiceType, and
ServiceLocationAttribute classes model the basic SLP concepts. A
concrete subclass instance of TemplateRegistry is returned by a class
method.
All SLP classes and interfaces are located within a single package.
The package name should begin with the name of the implementation and
conclude with the suffix "slp". Thus, the name for a hypothetical
implementation from the University of Michigan would look like:
edu.umich.slp
This follows the Java convention of prepending the top level DNS
domain name for the organization implementing the package onto the
organization's name and using that as the package prefix.
5.2. Exceptions and Errors
Most parameters to API methods are required to be non-null. The API
description indicates if a null parameter is acceptable, or if other
restrictions constrain a parameter. When parameters are checked for
validity (such as not being null) or their syntax is checked, an
error results in the RuntimeException subclass
IllegalArgumentException being thrown. Clients of the API are
reminded that IllegalArgumentException, derived from
RuntimeException, is unchecked by the compiler. Clients should thus
be careful to include try/catch blocks for it if the relevant
parameters could be erroneous.
Standard Java practice is to encode every exceptional condition as a
separate subclass of Exception. Because of the relatively high cost
in code size of Exception subclasses, the API contains only a single
Exception subclass with different conditions being determined by an
integer error code property. A subset, appropriate to Java, of the
error codes described in Section 3 are available as constants on the
ServiceLocationException class. The subset excludes error codes such
Kempf & Guttman Informational [Page 56]
^L
RFC 2614 Service Location API June 1999
as MEMORY_ALLOC_FAILED.
5.2.1. Class ServiceLocationException
5.2.1.1. Synopsis
public class ServiceLocationException
extends Exception
5.2.1.2. Description
The ServiceLocationException class is thrown by all methods when
exceptional conditions occur in the SLP framework. The error code
property determines the exact nature of the condition, and an
optional message may provide more information.
5.2.1.3. Fields
public static final short LANGUAGE_NOT_SUPPORTED = 1
public static final short PARSE_ERROR = 2
public static final short INVALID_REGISTRATION = 3
public static final short SCOPE_NOT_SUPPORTED = 4
public static final short AUTHENTICATION_ABSENT = 6
public static final short AUTHENTICATION_FAILED = 7
public static final short INVALID_UPDATE = 13
public static final short REFRESH_REJECTED = 15
public static final short NOT_IMPLEMENTED = 16
public static final short NETWORK_INIT_FAILED 17
public static final short NETWORK_TIMED_OUT = 18
public static final short NETWORK_ERROR = 19
public static final short INTERNAL_SYSTEM_ERROR = 20
public static final short TYPE_ERROR = 21
public static final short BUFFER_OVERFLOW = 22
5.2.1.4. Instance Methods
public short getErrorCode()
Return the error code. The error code takes on one of the static
field values.
Kempf & Guttman Informational [Page 57]
^L
RFC 2614 Service Location API June 1999
5.3. Basic Data Structures
5.3.1. Interface ServiceLocationEnumeration
public interface ServiceLocationEnumeration
extends Enumeration
5.3.1.1. Description
The ServiceLocationEnumeration class is the return type for all
Locator SLP operations. The Java API library may implement this
class to block until results are available from the SLP operation, so
that the client can achieve asynchronous operation by retrieving
results from the enumeration in a separate thread. Clients use the
superclass nextElement() method if they are unconcerned with SLP
exceptions.
5.3.1.2. Instance Methods
public abstract Object next() throws ServiceLocationException
Return the next value or block until it becomes available.
Throws:
ServiceLocationException
Thrown if the SLP operation encounters an error.
NoSuchElementException
If there are no more elements to return.
5.3.2. Class ServiceLocationAttribute
5.3.2.1. Synopsis
public class ServiceLocationAttribute
extends Object implements Serializable
Kempf & Guttman Informational [Page 58]
^L
RFC 2614 Service Location API June 1999
5.3.2.2. Description
The ServiceLocationAttribute class models SLP attributes. Instances
of this class are returned by Locator.findAttributes() and are
communicated along with register/deregister requests.
5.3.2.3. Constructors
public ServiceLocationAttribute(String id,Vector values)
Construct a service location attribute. Errors in the id or values
vector result in an IllegalArgumentException.
Parameters:
id
The attribute name. The String can consist of any Unicode
character.
values
A Vector of one or more attribute values. Vector contents
must be uniform in type and one of Integer, String, Boolean,
or byte[]. If the attribute is a keyword attribute, then the
parameter should be null. String values can consist of any
Unicode character.
5.3.2.4. Class Methods
public static String escapeId(String id)
Returns an escaped version of the id parameter, suitable for
inclusion in a query. Any reserved characters as specified in [7]
are escaped using UTF-8 encoding. If any characters in the tag are
illegal, throws IllegalArgumentException.
Parameters:
id
The attribute id to escape. ServiceLocationException is thrown
if any characters are illegal for an attribute tag.
Kempf & Guttman Informational [Page 59]
^L
RFC 2614 Service Location API June 1999
public static String escapeValue(Object value)
Returns a String containing the escaped value parameter as a string,
suitable for inclusion in a query. If the parameter is a string,
any reserved characters as specified in [7] are escaped using UTF-8
encoding. If the parameter is a byte array, then the escaped string
begins with the nonUTF-8 sequence `\ff` and the rest of the string
consists of the escaped bytes, which is the encoding for opaques.
If the value parameter is a Boolean or Integer, then the returned
string contains the object converted into a string. If the value
is any type other than String, Integer, Boolean or byte[], an
IllegalArgumentException is thrown.
Parameters:
value
The attribute value to be converted into a string and escaped.
5.3.2.5. Instance Methods
public Vector getValues()
Returns a cloned vector of attribute values, or null if the attribute
is a keyword attribute. If the attribute is single-valued, then the
vector contains only one object.
public String getId()
Returns the attribute's name.
public boolean equals(Object o)
Overrides Object.equals(). Two attributes are equal if their
identifiers are equal and their value vectors contain the same number
of equal values as determined by the Object equals() method. Values
having byte[] type are equal if the contents of all byte arrays in
both attribute vectors match. Note that the SLP string matching
algorithm [7] MUST NOT be used for comparing attribute identifiers or
string values.
Kempf & Guttman Informational [Page 60]
^L
RFC 2614 Service Location API June 1999
public String toString()
Overrides Object.toString(). The string returned contains a
formatted representation of the attribute, giving the attribute's
id, values, and the Java type of the values. The returned string is
suitable for debugging purposes, but is not in SLP wire format.
public int hashCode()
Overrides Object.hashCode(). Hashes on the attribute's identifier.
5.3.3. Class ServiceType
5.3.3.1. Synopsis
public class ServiceType extends Object implements Serializable
5.3.3.2. Description
The ServiceType object models the SLP service type. It parses a
string based service type specifier into its various components, and
contains property accessors to return the components. URL schemes,
protocol service types, and abstract service types are all handled.
5.3.3.3. Constructors
public ServiceType(String type)
Construct a service type object from the service type specifier.
Throws IllegalArgumentException if the type name is syntactically
incorrect.
Parameters:
type
The service type name as a String. If the service type is from
a service: URL, the "service:" prefix must be intact.
Kempf & Guttman Informational [Page 61]
^L
RFC 2614 Service Location API June 1999
5.3.3.4. Methods
public boolean isServiceURL()
Returns true if the type name contains the "service:" prefix.
public boolean isAbstractType()
Returns true if the type name is for an abstract type.
public boolean isNADefault()
Returns true if the naming authority is the default, i.e. is the
empty string.
public String getConcreteTypeName()
Returns the concrete type name in an abstract type, or the empty
string if the service type is not abstract. For example, if the type
name is "service:printing:ipp", the method returns "ipp". If the
type name is "service:ftp", the method returns "".
public String getPrincipleTypeName()
Returns the abstract type name for an abstract type, the protocol
name in a protocol type, or the URL scheme for a generic URL. For
example, in the abstract type name "service:printing:ipp", the method
returns "printing". In the protocol type name "service:ftp", the
method returns "ftp".
public String getAbstractTypeName()
If the type is an abstract type, returns the fully formatted abstract
type name including the "service:" and naming authority but without
the concrete type name or intervening colon. If not an abstract
type, returns the empty string. For example, in the abstract type
name "service:printing:ipp", the method returns "service:printing".
Kempf & Guttman Informational [Page 62]
^L
RFC 2614 Service Location API June 1999
public String getNamingAuthority()
Return the naming authority name, or the empty string if the naming
authority is the default.
public boolean equals(Object obj)
Overrides Object.equals(). The two objects are equal if they are
both ServiceType objects and the components of both are equal.
public String toString()
Returns the fully formatted type name, including the "service:" if
the type was originally from a service: URL.
public int hashCode()
Overrides Object.hashCode(). Hashes on the string value of the
"service" prefix, naming authority, if any, abstract and concrete
type names for abstract types, protocol type name for protocol types,
and URL scheme for generic URLs.
5.3.4. Class ServiceURL
5.3.4.1. Synopsis
public class ServiceURL extends Object implements Serializable
5.3.4.2. Description
The ServiceURL object models the advertised SLP service URL. It can
be either a service: URL or a regular URL. These objects are
returned from service lookup requests, and describe the registered
services. This class should be a subclass of java.net.URL but can't
since that class is final.
Kempf & Guttman Informational [Page 63]
^L
RFC 2614 Service Location API June 1999
5.3.4.3. Class Variables
public static final int NO_PORT = 0
Indicates that no port information is required or was returned for
this URL.
public static final int LIFETIME_NONE = 0
Indicates that the URL has a zero lifetime. This value is never
returned from the API, but can be used to create a ServiceURL object
to deregister, delete attributes, or find attributes.
public static final int LIFETIME_DEFAULT = 10800
The default URL lifetime (3 hours) in seconds.
public static final int LIFETIME_MAXIMUM = 65535
The maximum URL lifetime (about 18 hours) in seconds.
public static final int LIFETIME_PERMANENT = -1
Indicates that the API implementation should continuously re-register
the URL until the application exits.
5.3.4.4. Constructors
public ServiceURL(String URL,int lifetime)
Construct a service URL object having the specified lifetime.
Kempf & Guttman Informational [Page 64]
^L
RFC 2614 Service Location API June 1999
Parameters:
URL
The URL as a string. Must be either a service: URL or a valid
generic URL according to RFC 2396 [2].
lifetime
The service advertisement lifetime in seconds. This value may
be between LIFETIME_NONE and LIFETIME_MAXIMUM.
5.3.4.5. Methods
public ServiceType getServiceType()
Returns the service type object representing the service type name of
the URL.
public final void setServiceType(ServiceType type)
throws ServiceLocationException
Set the service type name to the object. Ignored if the URL is a
service: URL.
Parameters:
type
The service type object.
public String getTransport()
Get the network layer transport identifier. If the transport is IP,
an empty string, "", is returned.
public String getHost()
Kempf & Guttman Informational [Page 65]
^L
RFC 2614 Service Location API June 1999
Returns the host identifier. For IP, this will be the machine name
or IP address.
public int getPort()
Returns the port number, if any. For non-IP transports, always
returns NO_PORT.
public String getURLPath()
Returns the URL path description, if any.
public int getLifetime()
Returns the service advertisement lifetime. This will be a positive
int between LIFETIME_NONE and LIFETIME_MAXIMUM.
public boolean equals(Object obj)
Compares the object to the ServiceURL and returns true if the two are
the same. Two ServiceURL objects are equal if their current service
types match and they have the same host, port, transport, and URL
path.
public String toString()
Returns a formatted string with the URL. Overrides Object.toString().
The returned URL has the original service type or URL scheme, not the
current service type.
public int hashCode()
Overrides Object.hashCode(). Hashes on the current service type,
transport, host, port, and URL part.
Kempf & Guttman Informational [Page 66]
^L
RFC 2614 Service Location API June 1999
5.4. SLP Access Interfaces
5.4.1. Interface Advertiser
5.4.1.1. Synopsis
public interface Advertiser
5.4.1.2. Description
The Advertiser is the SA interface, allowing clients to register new
service instances with SLP, to change the attributes of existing
services, and to deregister service instances. New registrations and
modifications of attributes are made in the language locale with
which the Advertiser was created, deregistrations of service
instances are made for all locales.
5.4.1.3. Instance Methods
public abstract Locale getLocale()
Return the language locale with which this object was created.
public abstract void register(ServiceURL URL,
Vector attributes)
throws ServiceLocationException
Register a new service with SLP having the given attributes.
The API library is required to perform the operation in all
scopes obtained through configuration.
Parameters:
URL
The URL for the service.
attributes
A vector of ServiceLocationAttribute objects describing the
service.
Kempf & Guttman Informational [Page 67]
^L
RFC 2614 Service Location API June 1999
public abstract void deregister(ServiceURL URL)
throws ServiceLocationException
Deregister a service from the SLP framework. This has the effect
of deregistering the service from every language locale. The API
library is required to perform the operation in all scopes obtained
through configuration.
Parameters:
URL
The URL for the service.
public abstract void
addAttributes(ServiceURL URL,
Vector attributes)
throws ServiceLocationException
Update the registration by adding the given attributes. The API
library is required to perform the operation in all scopes obtained
through configuration.
Parameters:
URL
The URL for the service.
attributes
A Vector of ServiceLocationAttribute objects to add to the
existing registration. Use an empty vector to update the URL
alone. May not be null.
public abstract void
deleteAttributes(ServiceURL URL,
Vector attributeIds)
throws ServiceLocationException
Delete the attributes from a URL for the locale with which the
Advertiser was created. The API library is required to perform the
operation in all scopes obtained through configuration.
Kempf & Guttman Informational [Page 68]
^L
RFC 2614 Service Location API June 1999
Parameters:
URL
The URL for the service.
attributeIds
A vector of Strings indicating the ids of the attributes
to remove. The strings may be attribute ids or they
may be wildcard patterns to match ids. See [7] for the
syntax of wildcard patterns. The strings may include SLP
reserved characters, they will be escaped by the API before
transmission. May not be the empty vector or null.
5.4.2. Interface Locator
5.4.2.1. Synopsis
public interface Locator
5.4.2.2. Description
The Locator is the UA interface, allowing clients to query the SLP
framework about existing service types, services instances, and about
the attributes of an existing service instance or service type.
Queries for services and attributes are made in the locale with which
the Locator was created, queries for service types are independent of
locale.
5.4.2.3. Instance Methods
public abstract Locale getLocale()
Return the language locale with which this object was created.
public abstract ServiceLocationEnumeration
findServiceTypes(String namingAuthority,
Vector scopes)
throws ServiceLocationException
Kempf & Guttman Informational [Page 69]
^L
RFC 2614 Service Location API June 1999
Returns an enumeration of ServiceType objects giving known service
types for the given scopes and given naming authority. If no service
types are found, an empty enumeration is returned.
Parameters:
namingAuthority
The naming authority. Use "" for the default naming authority
and "*" for all naming authorities.
scopes
A Vector of scope names. The vector should be selected from
the results of a findScopes() API invocation. Use "DEFAULT"
for the default scope.
public abstract ServiceLocationEnumeration
findServices(ServiceType type,
Vector scopes,
String searchFilter)
throws ServiceLocationException
Returns a vector of ServiceURL objects for services matching the
query, and having a matching type in the given scopes. If no
services are found, an empty enumeration is returned.
Parameters:
type
The SLP service type of the service.
scopes
A Vector of scope names. The vector should be selected from
the results of a findScopes() API invocation. Use "DEFAULT"
for the default scope.
searchFilter
An LDAPv3 [4] string encoded query. If the filter is empty,
i.e. "", all services of the requested type in the specified
scopes are returned. SLP reserved characters must be escaped
in the query. Use ServiceLocationAttribute.escapeId() and
ServiceLocationAttribute.escapeValue() to construct the query.
Kempf & Guttman Informational [Page 70]
^L
RFC 2614 Service Location API June 1999
public abstract ServiceLocationEnumeration
findAttributes(ServiceURL URL,
Vector scopes,
Vector attributeIds)
throws ServiceLocationException
For the URL and scope, return a Vector of ServiceLocationAttribute
objects whose ids match the String patterns in the attributeIds
Vector. The request is made in the language locale of the Locator.
If no attributes match, an empty enumeration is returned.
Parameters:
URL
The URL for which the attributes are desired.
scopes
A Vector of scope names. The vector should be selected from
the results of a findScopes() API invocation. Use "DEFAULT"
for the default scope.
attributeIds
A Vector of String patterns identifying the desired attributes.
An empty vector means return all attributes. As described
in [7], the patterns may include wildcards to match substrings.
The strings may include SLP reserved characters, they will be
escaped by the API before transmission.
public abstract ServiceLocationEnumeration
findAttributes(ServiceType type,
Vector scopes,
Vector attributeIds)
throws ServiceLocationException
For the type and scope, return a Vector of all ServiceLocationAttribute
objects whose ids match the String patterns in the attributeIds
Vector regardless of the Locator's locale. The request is made
independent of language locale. If no attributes are found, an empty
vector is returned.
Kempf & Guttman Informational [Page 71]
^L
RFC 2614 Service Location API June 1999
Parameters:
serviceType
The service type.
scopes
A Vector of scope names. The vector should be selected from
the results of a findScopes() API invocation. Use "DEFAULT"
for the default scope.
attributeIds
A Vector of String patterns identifying the desired
attributes. An empty vector means return all attributes.
As described in [7], the patterns may include wildcards to
match all prefixes or suffixes. The patterns may include SLP
reserved characters, they will be escaped by the API before
transmission.
5.5. The Service Location Manager
5.5.1. Class ServiceLocationManager
5.5.1.1. Synopsis
public class ServiceLocationManager
extends Object
5.5.1.2. Description
The ServiceLocationManager manages access to the service location
framework. Clients obtain the Locator and Advertiser objects for UA
and SA, and a Vector of known scope names from the
ServiceLocationManager.
5.5.1.3. Class Methods
public static int getRefreshInterval()
throws ServiceLocationException
Kempf & Guttman Informational [Page 72]
^L
RFC 2614 Service Location API June 1999
Returns the maximum across all DAs of the min-refresh-interval
attribute. This value satisfies the advertised refresh interval
bounds for all DAs, and, if used by the SA, assures that no
refresh registration will be rejected. If no DA advertises a
min-refresh-interval attribute, a value of 0 is returned.
public static Vector findScopes()
throws ServiceLocationException
Returns an Vector of strings with all available scope names. The
list of scopes comes from a variety of sources, see Section 2.1 for
the scope discovery algorithm. There is always at least one string
in the Vector, the default scope, "DEFAULT".
public static Locator
getLocator(Locale locale)
throws ServiceLocationException
Return a Locator object for the given language Locale. If the
implementation does not support UA functionality, returns null.
Parameters:
locale
The language locale of the Locator. The default SLP locale is
used if null.
public static Advertiser
getAdvertiser(Locale locale)
throws ServiceLocationException
Return an Advertiser object for the given language locale. If the
implementation does not support SA functionality, returns null.
Parameters:
locale
The language locale of the Advertiser. The default SLP locale
is used if null.
Kempf & Guttman Informational [Page 73]
^L
RFC 2614 Service Location API June 1999
5.6. Service Template Introspection
5.6.1. Abstract Class TemplateRegistry
5.6.1.1. Synopsis
public abstract class TemplateRegistry
5.6.1.2. Description
Subclasses of the TemplateRegistry abstract class provide access to
service location templates [8]. Classes implementing
TemplateRegistry perform a variety of functions. They manage the
registration and access of service type template documents. They
create attribute verifiers from service templates, for verification
of attributes and introspection on template documents. Note that
clients of the Advertiser are not required to verify attributes
before registering (though they may get a TYPE_ERROR if the
implementation supports type checking and there is a mismatch with
the template).
5.6.1.3. Class Methods
public static TemplateRegistry getTemplateRegistry();
Returns the distinguished TemplateRegistry object for performing
operations on and with service templates. Returns null if the
implementation doesn't support TemplateRegistry functionality.
5.6.1.4. Instance Methods
public abstract void
registerServiceTemplate(ServiceType type,
String documentURL,
Locale locale,
String version)
throws ServiceLocationException
Register the service template with the template registry.
Kempf & Guttman Informational [Page 74]
^L
RFC 2614 Service Location API June 1999
Parameters:
type
The service type.
documentURL
A string containing the URL of the template document. May not
be the empty string.
locale
A Locale object containing the language locale of the template.
version
The version number identifier of template document.
public abstract void
deregisterServiceTemplate(ServiceType type,
Locale locale,
String version)
throws ServiceLocationException
Deregister the template for the service type.
Parameters:
type
The service type.
locale
A Locale object containing the language locale of the template.
version
A String containing the version number. Use null to indicate
the latest version.
Kempf & Guttman Informational [Page 75]
^L
RFC 2614 Service Location API June 1999
public abstract
String findTemplateURL(ServiceType type,
Locale locale,
String version)
throws ServiceLocationException
Returns the URL for the template document.
Parameters:
type
The service type.
locale
A Locale object containing the language locale of the template.
version
A String containing the version number. Use null to indicate
the latest version.
public abstract
ServiceLocationAttributeVerifier
attributeVerifier(String documentURL)
throws ServiceLocationException
Reads the template document URL and returns an attribute verifier
for the service type. The attribute verifier can be used for
verifying that registration attributes match the template, and for
introspection on the template definition.
Parameters:
documentURL
A String containing the template document's URL. May not be the
empty string.
Kempf & Guttman Informational [Page 76]
^L
RFC 2614 Service Location API June 1999
5.6.2. Interface ServiceLocationAttributeVerifier
5.6.2.1. Synopsis
public interface ServiceLocationAttributeVerifier
5.6.2.2. Description
The ServiceLocationAttributeVerifier provides access to service
templates. Classes implementing this interface parse SLP template
definitions, provide information on attribute definitions for service
types, and verify whether a ServiceLocationAttribute object matches a
template for a particular service type. Clients obtain
ServiceLocationAttributeVerifier objects for specific SLP service
types through the TemplateRegistry.
5.6.2.3. Instance Methods
public abstract ServiceType getServiceType()
Returns the SLP service type for which this is the verifier.
public abstract Locale getLocale()
Return the language locale of the template.
public abstract String getVersion()
Return the template version number identifier.
public abstract String getURLSyntax()
Return the URL syntax expression for the service: URL.
public abstract String getDescription()
Kempf & Guttman Informational [Page 77]
^L
RFC 2614 Service Location API June 1999
Return the descriptive help text for the template.
public abstract ServiceLocationAttributeDescriptor
getAttributeDescriptor(String attrId)
Return the ServiceLocationAttributeDescriptor for the attribute
having the named id. If no such attribute exists in this template,
return null. This method is primarily for GUI tools to display
attribute information. Programmatic verification of attributes
should use the verifyAttribute() method.
public abstract Enumeration
getAttributeDescriptors()
Returns an Enumeration allowing introspection on the attribute
definition in the service template. The Enumeration returns
ServiceLocationAttributeDescriptor objects for the attributes.
This method is primarily for GUI tools to display attribute
information. Programmatic verification of attributes should use the
verifyAttribute() method.
public abstract void
verifyAttribute(
ServiceLocationAttribute attribute)
throws ServiceLocationException
Verify that the attribute matches the template definition. If the
attribute doesn't match, ServiceLocationException is thrown with the
error code as ServiceLocationException.PARSE_ERROR.
Parameters:
attribute
The ServiceLocationAttribute object to be verified.
public abstract void
verifyRegistration(
Vector attributeVector)
throws ServiceLocationException
Kempf & Guttman Informational [Page 78]
^L
RFC 2614 Service Location API June 1999
Verify that the Vector of ServiceLocationAttribute objects matches
the template for this service type. The vector must contain all the
required attributes, and all attributes must match their template
definitions. If the attributes don't match, ServiceLocationException
is thrown with the error code as ServiceLocationException.PARSE_ERROR
Parameters:
attributeVector
A Vector of ServiceLocationAttribute objects for the
registration.
5.6.3. Interface ServiceLocationAttributeDescriptor
5.6.3.1. Synopsis
public interface
ServiceLocationAttributeDescriptor
5.6.3.2. Description
The ServiceLocationAttributeDescriptor interface provides
introspection on a template attribute definition. Classes
implementing the ServiceLocationAttributeDescriptor interface return
information on a particular service location attribute definition
from the service template. This information is primarily for GUI
tools. Programmatic attribute verification should be done through
the ServiceLocationAttributeVerifier.
5.6.3.3. Instance Methods
public abstract String getId()
Return a String containing the attribute's id.
public abstract String getValueType()
Return a String containing the fully package-qualified Java type of
the attribute. SLP types are translated into Java types as follows:
Kempf & Guttman Informational [Page 79]
^L
RFC 2614 Service Location API June 1999
STRING
"java.lang.String"
INTEGER
"java.lang.Integer"
BOOLEAN
"java.lang.Boolean"
OPAQUE
"[B" (i.e. array of byte, byte[])
KEYWORD
empty string, ""
public abstract String getDescription()
Return a String containing the attribute's help text.
public abstract Enumeration
getAllowedValues()
Return an Enumeration of allowed values for the attribute type.
For keyword attributes returns null. For no allowed values (i.e.
unrestricted) returns an empty Enumeration.
public abstract Enumeration
getDefaultValues()
Return an Enumeration of default values for the attribute type.
For keyword attributes returns null. For no allowed values (i.e.
unrestricted) returns an empty Enumeration.
public abstract boolean
getRequiresExplicitMatch()
Kempf & Guttman Informational [Page 80]
^L
RFC 2614 Service Location API June 1999
Returns true if the "X"" flag is set, indicating that the attribute
should be included in an any Locator.findServices() request search
filter.
public abstract boolean getIsMultivalued()
Returns true if the "M" flag is set.
public abstract boolean getIsOptional()
Returns true if the "O"" flag is set.
public abstract boolean getIsLiteral()
Returns true if the "L" flag is set.
public abstract boolean getIsKeyword()
Returns true if the attribute is a keyword attribute.
5.7. Implementation Notes
5.7.1. Refreshing Registrations
A special lifetime constant, ServiceURL.LIFETIME_PERMANENT, is used
by clients to indicate that the URL should be automatically refreshed
until the application exits. The API implementation should interpret
this flag as indicating that the URL lifetime is
ServiceURL.LIFETIME_MAXIMUM, and MUST arrange for automatic refresh
to occur.
5.7.2. Parsing Alternate Transports in ServiceURL
The ServiceURL class is designed to handle multiple transports. The
standard API performs no additional processing on transports other
than IP except to separate out the host identifier and the URL path.
However, implementations are free to subclass ServiceURL and support
additional methods that provide more detailed parsing of alternate
transport information. For IP transport, the port number, if any, is
Kempf & Guttman Informational [Page 81]
^L
RFC 2614 Service Location API June 1999
returned from the getPort() method. For non-IP transports, the
getPort() method returns NO_PORT.
5.7.3. String Attribute Values
In general, translation between Java types for attribute values and
the SLP on-the-wire string is straightforward. However, there are
two corner cases. If the Java attribute value type is String and the
value of the string has an on-the-wire representation that is
inferred by SLP as an integer, the registered attribute value may not
be what the API client intended. A similar problem could result if
the Java attribute value is the string "true" or "false", in which
case the on-the-wire representation is inferred to boolean. To
handle these corner cases, the Java API prepends a space onto the
string. So, for example, if the string attribute value is "123", the
Java API transforms the value to "123 ", which will have an on-the-
wire representation that is inferred by SLP to be string. Since
appended and prepended spaces have no effect on query handling, this
procedure should cause no problem with queries. API clients need to
be aware, however, that the transformation is occurring.
5.7.4. Client Side Syntax Checking
The syntax of scope names, service type names, naming authority
names, and URLs is described in [7] and [8]. The various methods and
classes taking String parameters for these entities SHOULD type check
the parameters for syntax errors on the client side, and throw an
IllegalArgumentException if an error occurs. In addition, character
escaping SHOULD be implemented before network transmission for
escapable characters in attribute ids and String values. This
reduces the number of error messages transmitted. The
ServiceLocationAttribute class provides methods for clients to obtain
escaped attribute id and value strings to facilitate query
construction.
5.7.5. Language Locale Handling
The Locator and Advertiser interfaces are created with a Locale
parameter. The language locale with which these objects are created
is used in all SLP requests issued through the object. If the Locale
parameter is null, the default SLP locale is used. The default SLP
locale is determined by, first, checking the net.slp.locale System
property. If that is unset, then the default SLP locale [7] is used,
namely "en". Note that the default SLP locale may not be the same as
the default Java locale.
Kempf & Guttman Informational [Page 82]
^L
RFC 2614 Service Location API June 1999
5.7.6. Setting SLP System Properties
SLP system properties that are originally set in the configuration
file can be overridden programmatically in API clients by simply
invoking the System.getProperties() operation to get a copy of the
system properties, modifying or adding the SLP property in question,
then using System.setProperties() to set the properties to the
modified Property object. Program execution continues without
interruption by substituting the default for the erroneous parameter.
Errors are checked when the property is used and are logged.
The SLP configuration file cannot be read with the
java.util.Properties file reader because there are some syntactic
differences. The SLP configuration file syntax defines a different
escape convention for non-ASCII characters than the Java syntax.
However, after the file has been read, the properties are stored and
retrieved from java.util.Properties objects.
Properties are global for a process, affecting all threads and all
Locator and Advertiser objects obtained through the
ServiceLocationManager. With the exception of the net.slp.locale,
net.slp.typeHint, and net.slp.maxResults properties, clients should
rarely be required to override these properties, since they reflect
properties of the SLP network that are not of concern to individual
agents. If changes are required, system administrators should modify
the configuration file.
5.7.7. Multithreading
Thread-safe operation is relatively easy to achieve in Java. By
simply making each method in the classes implementing the Locator and
Advertiser interfaces synchronized, and by synchronizing access to
any shared data structures within the class, the Locator and
Advertiser interfaces are made safe. Alternatively, finer grained
synchronization is also possible within the classes implementing
Advertiser and Locator.
5.7.8. Modular Implementations
While, at first glance, the API may look rather heavyweight, the
design has been carefully arranged so that modular implementations
that provide only SA, only UA, or only service template access
capability, or any combination of the three, are possible.
Because the objects returned from the
ServiceLocationManager.getLocator() and
ServiceLocationManager.getAdvertiser() operations are interfaces, and
because the objects returned through those interfaces are in the set
Kempf & Guttman Informational [Page 83]
^L
RFC 2614 Service Location API June 1999
of base data structures, an implementation is free to omit either UA
or SA capability by simply returning null from the instance creation
operation if the classes implementing the missing function cannot be
dynamically linked. API clients are encouraged to check for such a
contingency, and to signal an exception if it occurs. Similarly, the
TemplateRegistry concrete subclass can simply be omitted from an
implementation that only supports UA and/or SA clients, and the
TemplateRegistry.getRegistry() method can return null. In this way,
the API implementation can be tailored for the particular memory
requirements at hand.
In addition, if an implementation only supports the minimal subset of
SLP [7], the unsupported Locator and Advertiser interface operations
can throw an exception with ServiceLocationException.NOT_IMPLEMENTED
as the error code. This supports better source portability between
low and high memory platforms.
5.7.9. Asynchronous and Incremental Return Semantics
The Java API contains no specific support for asynchronous operation.
Incremental return is not needed for the Advertiser because service
registrations can be broken up into pieces when large. Asynchronous
return is also not needed because clients can always issue the
Advertiser operation in a separate thread if the calling thread can't
block.
The Locator can be implemented either synchronously or
asynchronously. Since the return type for Locator calls is
ServiceLocationEnumeration, a Java API implementation that supports
asynchronous semantics can implement ServiceLocationEnumeration to
dole results out as they come in, blocking when no results are
available. If the client code needs to support other processing
while the results are trickling in, the call into the enumeration to
retrieve the results can be done in a separate thread.
Unlike the C case, collation semantics for return of attributes when
an attribute request by service type is made require that the API
collate returned values so that only one attribute having a collation
of all returned values appear to the API client. In practice, this
may limit the amount of asynchronous processing possible with the
findAttributes() method. This requirement is imposed because memory
management is much easier in Java and so implementing collation as
part of the API should not be as difficult as in C, and it saves the
client from having to do the collation.
Kempf & Guttman Informational [Page 84]
^L
RFC 2614 Service Location API June 1999
5.8. Example
In this example, a printer server advertises its availability to
clients. Additionally, the server advertises a service template for
use by client software in validating service requests:
//Get the Advertiser and TemplateRegistry.
Advertiser adv = null;
TemplateRegistry tr = null
try {
adv = ServiceLocationManager.getAdvertiser("en");
tr = TemplateRegistry.getTemplateRegistry();
} catch( ServiceLocationException ex ) { } //Deal with error.
if( adv == null ) {
//Serious error as printer can't be registered
// if the implementation doesn't support SA
// functionality.
}
//Get the printer's attributes, from a file or
// otherwise. We assume that the attributes
// conform to the template, otherwise, we
// could register the template here and verify
// them.
Vector attributes = getPrinterAttributes();
//Create the service: URL for the printer.
ServiceURL printerURL =
new ServiceURL(
"service:printer:lpr://printshop/color2",
ServiceURL.LIFETIME_MAXIMUM);
try {
//Register the printer.
adv.register(printerURL, attributes);
Kempf & Guttman Informational [Page 85]
^L
RFC 2614 Service Location API June 1999
//If the template registry is available,
// register the printer's template.
if( tr != null ) {
tr.registerServiceTemplate(
new ServiceType("service:printer:lpr"),
"http://shop.arv/printer/printer-lpr.slp",
new Locale("en",""),
"1.0");
}
} catch( ServiceLocationException ex ) { } //Deal with error.
Suppose a client is looking for color printer. The following code is
used to issue a request for printer advertisements:
Locator loc = null;
TemplateRegistry tr = null;
try {
loc = ServiceLocationManager.getLocator("en");
} catch( ServiceLocationException ex ) { } //Deal with error.
if( loc == null ) {
//Serious error as client can't be located
// if the implementation doesn't support
// UA functionality.
}
//We want a color printer that does CMYK
// and prints at least 600 dpi.
String query = "(&(marker-type=CMYK)(resolution=600))";
//Get scopes.
Vector scopes = ServiceLocationManager.findScopes();
Enumeration services;
try {
Kempf & Guttman Informational [Page 86]
^L
RFC 2614 Service Location API June 1999
services =
loc.findServices(new ServiceType("service:printer"),scopes,query);
} catch { } //Deal with error.
if (services.hasMoreElements() ) {
//Printers can now be used.
ServiceURL surl = (ServiceURL) services.next();
Socket sock = new Socket(surl.getHost, surl.getPort());
// Use the Socket...
}
6. Internationalization Considerations
6.1. service URL
The service URL itself must be encoded using the rules set forth in
[2]. The character set encoding is limited to specific ranges within
the UTF-8 character set [3].
The attribute information associated with the service URL must be
expressed in UTF-8. See [8] for attribute internationalization
guidelines.
6.2. Character Set Encoding
Configuration and serialized registration files are encoded in the
UTF-8 character set [3]. This is fully compatible with US-ASCII
character values. C platforms that do not support UTF-8 are required
to check the top bit of input bytes to determine whether the incoming
character is multibyte. If it is, the character should be dealt with
accordingly. This should require no additional implementation
effort, since the SLP wire protocol requires that strings are encoded
as UTF-8. C platforms without UTF-8 support need to supply their own
support, if only in the form of multibyte string handling.
At the API level, the character encoding is specified to be Unicode
for Java and UTF-8 for C. Unicode is the default in Java. For C, the
standard US-ASCII 8 bits per character, null terminated C strings are
a subset of the UTF-8 character set, and so work in the API. Because
the C API is very simple, the API library needs to do a minimum of
processing on UTF-8 strings. The strings primarily just need to be
reflected into the outgoing SLP messages, and reflected out of the
Kempf & Guttman Informational [Page 87]
^L
RFC 2614 Service Location API June 1999
API from incoming SLP messages.
6.3. Language Tagging
All SLP requests and registrations are tagged to indicate in which
language the strings included are encoded. This allows multiple
languages to be supported. It also presents the possibility that
error conditions result when a request is made in a language that is
not supported. In this case, an error is only returned when there is
data available, but not obtainable in the language requested.
The dialect portion of the Language Tag is used on 'best effort'
basis for matching strings by SLP. Dialects that match are preferred
over those which don't. Dialects that do not match will not prevent
string matching or comparisons from occurring.
7. Security Considerations
Security is handled within the API library and is not exposed to API
clients except in the form of exceptions. The
net.slp.securityEnabled, property determines whether an SA client's
messages are signed, but a UA client should be prepared for an
authentication exception at any time, because it may contact a DA
with authenticated advertisements.
An adversary could delete valid service advertisements, provide false
service information and deny UAs knowledge of existing services
unless the mechanisms in SLP for authenticating SLP messages are
used. These mechanisms allow DAAdverts, SAAdverts, Service URLs and
Service Attributes to be verified using digital cryptography. For
this reason, all SLP agents should be configured to use SLP SPIs.
See [7] for a description of how this mechanism works.
8. Acknowledgements
The authors would like to thank Don Provan for his pioneering work
during the initial stages of API definition.
Kempf & Guttman Informational [Page 88]
^L
RFC 2614 Service Location API June 1999
9. References
[1] Bradner, S., "Key Words for Use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
[2] Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform
Resource Identifiers (URI): Generic Syntax", RFC 2396,
August 1998.
[3] Yergeau, F., "UTF-8, a transformation format of ISO 10646",
RFC 2279, January 1998.
[4] Howes, T., "The String Representation of LDAP Search Filters",
RFC 2254 December 1997.
[5] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", RFC 2234, November 1997.
[6] Alvestrand, H., "Tags for the Identification of Languages",
RFC 1766, March 1995.
[7] Guttman, E., Perkins, C., Veizades, J. and M. Day, "Service
Location Protocol, Version 2", RFC 2608, June 1999.
[8] Guttman, E., Perkins, C. and J. Kempf, "Service Templates and
Service: Schemes", RFC 2609, June 1999.
Kempf & Guttman Informational [Page 89]
^L
RFC 2614 Service Location API June 1999
10. Authors' Addresses
Questions about this memo can be directed to:
James Kempf
Sun Microsystems
901 San Antonio Rd.
Palo Alto, CA, 94303
USA
Phone: +1 650 786 5890
Fax: +1 650 786 6445
EMail: james.kempf@sun.com
Erik Guttman
Sun Microsystems
Bahnstr. 2
74915 Waibstadt
Germany
Phone: +49 7263 911 701
EMail: erik.guttman@sun.com
Kempf & Guttman Informational [Page 90]
^L
RFC 2614 Service Location API June 1999
11. Full Copyright Statement
Copyright (C) The Internet Society (1999). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."
Acknowledgement
Funding for the RFC Editor function is currently provided by the
Internet Society.
Kempf & Guttman Informational [Page 91]
^L
|