summaryrefslogtreecommitdiff
path: root/doc/rfc/rfc1228.txt
blob: a8e7932fc90da858337b378273fc91e1a0a1682f (plain) (blame)
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
Network Working Group                                       G. Carpenter
Request for Comments: 1228                                     B. Wijnen
                                  T.J. Watson Research Center, IBM Corp.
                                                                May 1991


                                SNMP-DPI
                   Simple Network Management Protocol
                     Distributed Program Interface

Status of this Memo

   This RFC describes a protocol that International Business Machines
   Corporation (IBM) has been implementing in most of its SNMP agents to
   allow dynamic extension of supported MIBs.  This is an Experimental
   Protocol for the Internet community.  Discussion and suggestions for
   improvement are requested.  Please refer to the current edition of
   the "IAB Official Protocol Standards" for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

ABSTRACT

   The Simple Network Management Protocol (SNMP) [1] Distributed Program
   Interface (DPI) is an extension to SNMP agents that permits end-users
   to dynamically add, delete or replace management variables in the
   local Management Information Base without requiring recompilation of
   the SNMP agent.  This is achieved by writing a so-called sub-agent
   that communicates with the agent via the SNMP-DPI.

   For the author of a sub-agent, the SNMP-DPI eliminates the need to
   know the details of ASN.1 [2] or SNMP PDU (Protocol Data Unit)
   encoding/decoding [1, 3].

   This protocol has been in use within IBM since 1989 and is included
   in the SNMP agents for VM, MVS and OS/2.

   Potentially useful sample sub-agent code and implementation examples
   are available for anonymous FTP from the University of Toronto.

MOTIVATION

   The Simple Network Management Protocol [1] defines a protocol that
   permits operations on a collection of variables.  This set of
   variables is called the Management Information Base (MIB) and a core
   set of variables has previously been defined [4, 5]; however, the
   design of the MIB makes provision for extension of this core set.
   Thus, an enterprise or individual can define variables of their own
   which represent information of use to them.  An example of a



Carpenter & Wijnen                                              [Page 1]
^L
RFC 1228                        SNMP-DPI                        May 1991


   potentially interesting variable which is not in the core MIB would
   be CPU utilization (percent busy).  Unfortunately, conventional SNMP
   agent implementations provide no means for an end-user to make
   available new variables.

   The SNMP DPI addresses this issue by providing a light-weight
   mechanism by which a process can register the existence of a MIB
   variable with the SNMP agent.  When requests for the variable are
   received by the SNMP agent, it will pass the query on to the process
   acting as a sub-agent.  This sub-agent then returns an appropriate
   answer to the SNMP agent.  The SNMP agent eventually packages an SNMP
   response packet and sends the answer back to the remote network
   management station that initiated the request.

   None of the remote network management stations have any knowledge
   that the SNMP agent calls on other processes to obtain an answer.  As
   far as they can tell, there is only one network management
   application running on the host.

THEORY OF OPERATION

CONNECTION ESTABLISHMENT

   Communication between the SNMP Agent and its clients (sub-agents)
   takes place over a stream connection.  This is typically a TCP
   connection, but other stream-oriented transport mechanisms can be
   used.  As an example, the VM SNMP agent allows DPI connections over
   IUCV (Inter-User Communications Vehicle) [6, 7].  Other than the
   connection establishment procedure, the protocol used is identical in
   these environments.

REGISTRATION

   Regardless of the connection-oriented transport mechanism used, after
   establishing a connection to the SNMP agent, the sub-agent registers
   the set of variables it supports.  Finally, when all the variable
   classes have been registered, the sub-agent then waits for requests
   from the SNMP agent or generates traps as required.

DPI ARCHITECTURE

   There are three requests that can be initiated by the SNMP agent:
   GET, GET-NEXT and SET.  These correspond directly to the three SNMP
   requests that a network management station can make.  The sub-agent
   responds to a request with a RESPONSE packet.

   There are currently two requests that can be initiated by a sub-
   agent: REGISTER and TRAP.



Carpenter & Wijnen                                              [Page 2]
^L
RFC 1228                        SNMP-DPI                        May 1991


------------------------------------------------------------------------

*---------------------------------*
|  SNMP Network                   |
|  Management Station             |
|                                 |
|---------------------------------|
|  SNMP Protocol                  |
*---------------------------------*
      A      | Get         A
      |      | GetNext     |  GetResponse
 Trap |      | Set         |
      |      V             |
*---------------------------------*            *----------------------*
|     SNMP Protocol               |            |   DPI Interface      |
|---------------------------------|  Reply     |    *-----------------|
|                        |        |<-----------|    |                 |
|     SNMP Agent         |        |            |    |   Client        |
|     A      *-----------+->      | MIB query  |    |                 |
|     |      | Get/Set   |        |----------->|    |     or          |
| Trap|      | info      |  SNMP  |            |    |                 |
|-----+------+-------*   |        |  trap      |    |   SNMP          |
|     |      V       |   |  DPI   |<-----------|    |   Sub-Agent     |
| TCP/IP layers,     |   |        |            |    |                 |
| Kernel             |   |        |<-----------|    |                 |
*---------------------------------*  Register  *----------------------*

------------------------------------------------------------------------
Figure 1. SNMP DPI overview

Remarks for Figure 1:

   o   The SNMP agent communicates with the SNMP manager via the
       standard SNMP protocol.
   o   The SNMP agent communicates with the TCP/IP layers and kernel
       (operating system) in an implementation-dependent manner.  It
       potentially implements the standard MIB view in this way.
   o   An SNMP sub-agent, running as a separate process (potentially
       even on another machine), can register objects with the SNMP
       agent.
   o   The SNMP agent will decode SNMP Packets.  If such a packet
       contains a Get/GetNext or Set request for an object registered
       by a sub-agent, it will send the request to the sub-agent via
       the corresponding query packet.
   o   The SNMP sub-agent sends responses back via a RESPONSE packet.
   o   The SNMP agent then encodes the reply into an SNMP packet and
       sends it back to the requesting SNMP manager.
   o   If the sub-agent wants to report an important state change, it



Carpenter & Wijnen                                              [Page 3]
^L
RFC 1228                        SNMP-DPI                        May 1991


       sends a TRAP packet to the SNMP agent, which will encode it
       into an SNMP trap packet and send it to the manager(s).

SNMP DPI PROTOCOL

   This section describes the actual protocol used between the SNMP
   agent and sub-agents.  This information has not previously been
   published.

CONNECTION ESTABLISHMENT

   In a TCP/IP environment, the SNMP agent listens on an arbitrary TCP
   port for a connection request from a sub-agent.  It is important to
   realize that a well-known port is not used:  every invocation of the
   SNMP agent will potentially result in a different TCP port being
   used.

   A sub-agent needs to determine this port number to establish a
   connection.  The sub-agent learns the port number from the agent by
   sending it one conventional SNMP get-request PDU.   The port number
   is maintained by the SNMP agent as the object whose identifier is
   1.3.6.1.4.1.2.2.1.1.0; this variable is registered under the IBM
   enterprise-specific tree.  The SNMP agent replies with a conventional
   SNMP response PDU that contains the port number to be used.  This
   response is examined by the sub-agent and the port number is
   extracted.  The sub-agent then establishes the connection to the
   specified port.

   On the surface, this procedure appears to mean that the sub-agent
   must be able to create and parse SNMP packets, but this is not the
   case.  The DPI Application Program Interface (API) has a library
   routine, query_DPI_port(), which can be used to generate and parse
   the required SNMP packets.  This routine is very small (under 100
   lines of C), so it does not greatly increase the size of any sub-
   agent).

   For completeness, byte-by-byte descriptions of the packets generated
   by the SNMP DPI API routine query_DPI_port() are provided below.
   This is probably of little interest to most readers and reading the
   source to query_DPI_port() provides much of the same information.

SNMP PDU TO GET THE AGENT'S DPI PORT

   As noted, before a TCP connection to the SNMP agent can be made, the
   sub-agent must learn which TCP port that the agent is listening on.
   To do so, it can issue an SNMP GET for an IBM enterprise-specific
   variable 1.3.6.1.4.1.2.2.1.1.0.




Carpenter & Wijnen                                              [Page 4]
^L
RFC 1228                        SNMP-DPI                        May 1991


   NOTE:  the object instance of ".0" is included for clarity in this
   document.

   The SNMP PDU can be constructed as shown below.  This PDU must be
   sent to UDP port 161 on the host where the agent runs (probably the
   same host where the sub-agent runs).













































Carpenter & Wijnen                                              [Page 5]
^L
RFC 1228                        SNMP-DPI                        May 1991


+----------------------------------------------------------------------+
| Table 1. SNMP PDU for GET DPI_port.  This is the layout of an SNMP   |
|          PDU for GET DPI_port                                        |
+-----------------+-----------------+----------------------------------+
| OFFSET          | VALUE           | FIELD                            |
+-----------------+-----------------+----------------------------------+
| 0               | 0x30            | ASN.1 header                     |
+-----------------+-----------------+----------------------------------+
| 1               | 34 + len        | pdu_length, see formula below    |
+-----------------+-----------------+----------------------------------+
| 2               | 0x02 0x01 0x00  | version (integer, length=1,      |
|                 | 0x04            | value=0), community name         |
|                 |                 | (string)                         |
+-----------------+-----------------+----------------------------------+
| 6               | len             | length of community name         |
+-----------------+-----------------+----------------------------------+
| 7               | community name  |                                  |
+-----------------+-----------------+----------------------------------+
| 7 + len         | 0xa0 0x1b       | SNMP GET request:                |
|                 |                 | request_type=0xa0, length=0x1b   |
+-----------------+-----------------+----------------------------------+
| 7 + len + 2     | 0x02 0x01 0x01  | SNMP request ID: integer,        |
|                 |                 | length=1, ID=1                   |
+-----------------+-----------------+----------------------------------+
| 7 + len + 5     | 0x02 0x01 0x00  | SNMP error status: integer,      |
|                 |                 | length=1, error=0                |
+-----------------+-----------------+----------------------------------+
| 7 + len + 8     | 0x02 0x01 0x00  | SNMP index: integer, length=1,   |
|                 |                 | index=0                          |
+-----------------+-----------------+----------------------------------+
| 7 + len + 11    | 0x30 0x10       | Varbind list, length=0x10        |
+-----------------+-----------------+----------------------------------+
| 7 + len + 13    | 0x30 0x0e       | Varbind, length=0x0e             |
+-----------------+-----------------+----------------------------------+
| 7 + len + 15    | 0x06 0x0a       | Object ID, length=0x0a           |
+-----------------+-----------------+----------------------------------+
| 7 + len + 17    | 0x2b 0x06 0x01  | Object instance:                 |
|                 | 0x04 0x01 0x02  | 1.3.6.1.4.1.2.2.1.1.0            |
|                 | 0x02 0x01 0x01  |                                  |
|                 | 0x00            |                                  |
+-----------------+-----------------+----------------------------------+
| 7 + len + 27    | 0x05 0x00       | null value, length=0             |
+-----------------+-----------------+----------------------------------+
+----------------------------------------------------------------------+

The formula to calculate the length field "pdu_length" is as follows:

  pdu_length =   length of version field and string tag (4 bytes)



Carpenter & Wijnen                                              [Page 6]
^L
RFC 1228                        SNMP-DPI                        May 1991


             +   length of community length field (1 byte)
             +   length of community name (depends...)
             +   length of SNMP GET request (29 bytes)

             =   34 + length of community name














































Carpenter & Wijnen                                              [Page 7]
^L
RFC 1228                        SNMP-DPI                        May 1991


SNMP PDU CONTAINING THE RESPONSE TO THE GET

Assuming that no errors occured, then the port is returned in the last 2
octets of the received packet.  The format of the packet is shown below:

+----------------------------------------------------------------------+
| Table 2. SNMP RESPONSE PDU for GET of Agent's DPI port.  This is the |
|          layout of an SNMP RESPONSE PDU for GET DPI_port             |
+-----------------+-----------------+----------------------------------+
| OFFSET          | VALUE           | FIELD                            |
+-----------------+-----------------+----------------------------------+
| 0               | 0x30            | ASN.1 header                     |
+-----------------+-----------------+----------------------------------+
| 1               | 36 + len        | length, see formula below        |
+-----------------+-----------------+----------------------------------+
| 2               | 0x02 0x01 0x00  | version (integer, length=1,      |
|                 | 0x04            | value=0), community name         |
|                 |                 | (string)                         |
+-----------------+-----------------+----------------------------------+
| 6               | len             | length of community name         |
+-----------------+-----------------+----------------------------------+
| 7               | community name  |                                  |
+-----------------+-----------------+----------------------------------+
| 7 + len         | 0xa2 0x1d       | SNMP RESPONSE:                   |
|                 |                 | request_type=0xa2, length=0x1d   |
+-----------------+-----------------+----------------------------------+
| 7 + len + 2     | 0x02 0x01 0x01  | SNMP request ID: integer,        |
|                 |                 | length=1, ID=1                   |
+-----------------+-----------------+----------------------------------+
| 7 + len + 5     | 0x02 0x01 0x00  | SNMP error status: integer,      |
|                 |                 | length=1, error=0                |
+-----------------+-----------------+----------------------------------+
| 7 + len + 8     | 0x02 0x01 0x00  | SNMP index: integer, length=1,   |
|                 |                 | index=0                          |
+-----------------+-----------------+----------------------------------+
| 7 + len + 11    | 0x30 0x12       | Varbind list, length=0x12        |
+-----------------+-----------------+----------------------------------+
| 7 + len + 13    | 0x30 0x10       | Varbind, length=0x10             |
+-----------------+-----------------+----------------------------------+
| 7 + len + 15    | 0x06 0x0a       | Object ID, length=0x0a           |
+-----------------+-----------------+----------------------------------+
+----------------------------------------------------------------------+









Carpenter & Wijnen                                              [Page 8]
^L
RFC 1228                        SNMP-DPI                        May 1991


+----------------------------------------------------------------------+
| Table 2. SNMP RESPONSE PDU for GET of Agent's DPI port.  This is the |
|          layout of an SNMP RESPONSE PDU for GET DPI_port             |
+-----------------+-----------------+----------------------------------+
| OFFSET          | VALUE           | FIELD                            |
+-----------------+-----------------+----------------------------------+
| 7 + len + 17    | 0x2b 0x06 0x01  | Object instance:                 |
|                 | 0x04 0x01 0x02  | 1.3.6.1.4.1.2.2.1.1.0            |
|                 | 0x02 0x01 0x01  |                                  |
|                 | 0x00            |                                  |
+-----------------+-----------------+----------------------------------+
| 7 + len + 27    | 0x02 0x02       | integer, length=2                |
+-----------------+-----------------+----------------------------------+
| 7 + len + 29    | msb lsb         | port number (msb, lsb)           |
+-----------------+-----------------+----------------------------------+
+----------------------------------------------------------------------+

The formula to calculate the length field "pdu_length" is as follows:

  pdu_length =   length of version field and string tag (4 bytes)
             +   length of community length field (1 byte)
             +   length of community name (depends...)
             +   length of SNMP RESPONSE (31 bytes)

             =   36 + length of community name

SNMP DPI PACKET FORMATS

   Each request to or response from the agent is constructed as a
   "packet" and is written to the stream.

   Each packet is prefaced with the length of the data remaining in the
   packet.  The length is stored in network byte order (most significant
   byte first, least significant last).  The receiving side will read
   the packet by doing something similar to:

      unsigned char len_bfr[2];
      char *bfr;
      int len;

      read(fd,len_bfr,2);
      len = len_bfr[0] * 256 + len_bfr[1];
      bfr = malloc(len);
      read(fd,bfr,len);

   NOTE:  the above example makes no provisions for error handling or a
   read returning less than the requested amount of data.  This is not a
   suggested coding style.



Carpenter & Wijnen                                              [Page 9]
^L
RFC 1228                        SNMP-DPI                        May 1991


   The first part of every packet identifies the application protocol
   being used, as well as some version information.  The protocol major
   version is intended to indicate in broad terms what version of the
   protocol is used.  The protocol minor version is intended to identify
   major incompatible versions of the protocol.  The protocol release is
   intended to indicate incremental modifications to the protocol.  The
   constants that are valid for these fields are defined in Table 10 on
   page 18.

   The next (common) field in all packets is the packet type.  This
   field indicates what kind of packet we're dealing with (SNMP DPI GET,
   GET-NEXT, SET, TRAP, RESPONSE or REGISTER).  The permitted values for
   this field are defined in Table 11 on page 18.

+----------------------------------------------------------------------+
| Table 3. SNMP DPI packet header.  This header is present in all      |
|          packets.                                                    |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type                                            |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+

>From this point onwards, the contents of the packet are defined by the
protocol being used.  The remainder of this section describes:

   o   the structure of packets for the SNMP DPI protocol, version 1.0.

   o   The constants as defined with this version of the protocol.











Carpenter & Wijnen                                             [Page 10]
^L
RFC 1228                        SNMP-DPI                        May 1991


REGISTER

   In order to register a branch in the MIB tree, an SNMP sub-agent
   sends an SNMP DPI REGISTER packet to the agent.

   Such a packet contains the standard SNMP DPI header plus REGISTER-
   specific data, which basically is a null terminated string
   representing the object ID in dotted ASN.1 notation (with a trailing
   dot!).

+----------------------------------------------------------------------+
| Table 4. SNMP DPI REGISTER packet.  This is the layout of an SNMP    |
|          DPI REGISTER packet                                         |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type = SNMP_DPI_REGISTER                        |
+-------------+--------------------------------------------------------+
| 6           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+




















Carpenter & Wijnen                                             [Page 11]
^L
RFC 1228                        SNMP-DPI                        May 1991


GET

   When the SNMP agent receives a PDU containing an SNMP GET request for
   a variable that a sub-agent registered with the agent, it passes an
   SNMP DPI GET packet to the sub-agent.

   Such a packet contains the standard SNMP DPI header plus GET-specific
   data, which is basically a null terminated string representing the
   object ID in dotted ASN.1 notation.

+----------------------------------------------------------------------+
| Table 5. SNMP DPI GET packet.  This is the layout of an SNMP DPI GET |
|          packet                                                      |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type = SNMP_DPI_GET                             |
+-------------+--------------------------------------------------------+
| 6           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+




















Carpenter & Wijnen                                             [Page 12]
^L
RFC 1228                        SNMP-DPI                        May 1991


GET-NEXT

   When the SNMP agent receives a PDU containing an SNMP GET-NEXT
   request for a variable for which a sub-agent may be authoritative, it
   passes an SNMP DPI GET-NEXT packet to the sub-agent.

   Such a packet contains the standard SNMP DPI header plus GET-NEXT-
   specific data.  These data take the form of two null terminated
   strings.  The first string represents the object ID in dotted ASN.1
   notation; the second string represents the group ID in dotted ASN.1
   notation.

+----------------------------------------------------------------------+
| Table 6. SNMP DPI GET NEXT packet.  This is the layout of an SNMP    |
|          DPI GET NEXT packet                                         |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type = SNMP_DPI_GET_NEXT                        |
+-------------+--------------------------------------------------------+
| 6           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
| 6 + len     | null terminated group ID                               |
+-------------+--------------------------------------------------------+
| NOTE:  len=strlen(object ID)+1                                       |
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+














Carpenter & Wijnen                                             [Page 13]
^L
RFC 1228                        SNMP-DPI                        May 1991


SET

   When the SNMP agent receives a PDU containing an SNMP SET request for
   a variable that a sub-agent registered with the agent, it passes an
   SNMP DPI SET packet to the sub-agent.

   Such a packet contains the standard SNMP DPI header plus SET specific
   data, which is basically a null terminated string representing the
   object ID in ASN.1 notation, with the type, value length and value to
   be set.  The permitted types for the type field are defined in Table
   12 on page 19.  Integer values are sent as 4-byte elements in network
   byte order (most significant byte first, least significant byte
   last).

+----------------------------------------------------------------------+
| Table 7. SNMP DPI SET packet.  This is the layout of an SNMP DPI SET |
|          packet                                                      |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type = SNMP_DPI_SET                             |
+-------------+--------------------------------------------------------+
| 6           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
| 6 + len     | SNMP Variable Type Value                               |
+-------------+--------------------------------------------------------+
| 6 + len + 1 | Length of value (MSB)                                  |
+-------------+--------------------------------------------------------+
| 6 + len + 2 | Length of value (LSB)                                  |
+-------------+--------------------------------------------------------+
| 6 + len + 3 | Value                                                  |
+-------------+--------------------------------------------------------+
| NOTE:  len=strlen(object ID)+1                                       |
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+






Carpenter & Wijnen                                             [Page 14]
^L
RFC 1228                        SNMP-DPI                        May 1991


RESPONSE

   An SNMP sub-agent must respond to a GET, GET_NEXT or SET request that
   it has received from the agent (unless it fails or has a bug).  To do
   so, it sends an SNMP DPI RESPONSE packet to the agent.

   Such a packet contains the standard SNMP DPI header plus RESPONSE
   specific data, which basically is an error_code plus (if there was no
   error), the name/type/value tuple representing the returned object.
   This is described as by a string representing the object ID in ASN.1
   notation, plus the type, value length and value of the object that
   was manipulated.  The permitted types for the type field are defined
   in Table 12 on page 19.  Integer values are sent as 4-byte elements
   in network byte order (most significant byte first, least significant
   byte last).




































Carpenter & Wijnen                                             [Page 15]
^L
RFC 1228                        SNMP-DPI                        May 1991


+----------------------------------------------------------------------+
| Table 8. SNMP DPI RESPONSE packet.  This is the layout of an SNMP    |
|          DPI RESPONSE packet                                         |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type = SNMP_DPI_RESPONSE                        |
+-------------+--------------------------------------------------------+
| 6           | SNMP error code                                        |
+-------------+--------------------------------------------------------+
| 7           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
| 7 + len     | SNMP Variable Type Value                               |
+-------------+--------------------------------------------------------+
| 7 + len + 1 | Length of value (MSB)                                  |
+-------------+--------------------------------------------------------+
| 7 + len + 2 | Length of value (LSB)                                  |
+-------------+--------------------------------------------------------+
| 7 + len + 3 | Value                                                  |
+-------------+--------------------------------------------------------+
| NOTE:  len=strlen(object ID)+1                                       |
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+

TRAP

   An SNMP sub-agent can request the agent to generate a TRAP by sending
   an SNMP DPI TRAP packet to the agent.

   Such a packet contains the standard SNMP DPI header plus TRAP
   specific data, which is basically the generic and specific trap code,
   plus a name/type/value tuple.  The tuple is described by a string
   representing the object ID in ASN.1 notation, plus the type, value
   length and value of the object that is being sent in the trap.  The
   permitted types for the type field are defined in Table 12 on page
   19.  Integer values are sent as 4-byte elements in network byte order
   (most significant byte first, least significant byte last).




Carpenter & Wijnen                                             [Page 16]
^L
RFC 1228                        SNMP-DPI                        May 1991


+----------------------------------------------------------------------+
| Table 9. SNMP DPI TRAP packet.  This is the layout of an SNMP DPI    |
|          TRAP packet                                                 |
+-------------+--------------------------------------------------------+
| OFFSET      | FIELD                                                  |
+-------------+--------------------------------------------------------+
| 0           | packet length to follow (MSB)                          |
+-------------+--------------------------------------------------------+
| 1           | packet length to follow (LSB)                          |
+-------------+--------------------------------------------------------+
| 2           | protocol major version                                 |
+-------------+--------------------------------------------------------+
| 3           | protocol minor version                                 |
+-------------+--------------------------------------------------------+
| 4           | protocol release                                       |
+-------------+--------------------------------------------------------+
| 5           | packet type - SNMP_DPI_TRAP                            |
+-------------+--------------------------------------------------------+
| 6           | SNMP generic trap code                                 |
+-------------+--------------------------------------------------------+
| 7           | SNMP specific trap code                                |
+-------------+--------------------------------------------------------+
| 8           | null terminated object ID                              |
+-------------+--------------------------------------------------------+
| 8 + len     | SNMP Variable Type Value                               |
+-------------+--------------------------------------------------------+
| 8 + len + 1 | Length of value (MSB)                                  |
+-------------+--------------------------------------------------------+
| 8 + len + 2 | Length of value (LSB)                                  |
+-------------+--------------------------------------------------------+
| 8 + len + 3 | Value                                                  |
+-------------+--------------------------------------------------------+
| NOTE:  len=strlen(object ID)+1                                       |
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+
















Carpenter & Wijnen                                             [Page 17]
^L
RFC 1228                        SNMP-DPI                        May 1991


CONSTANTS AND VALUES

   This section describes the constants that have been defined for this
   version of the SNMP DPI Protocol.

PROTOCOL VERSION AND RELEASE VALUES

+----------------------------------------------------------------------+
| Table 10. Protocol version and release values                        |
+-----------------------------------+----------------------------------+
| FIELD                             | VALUE                            |
+-----------------------------------+----------------------------------+
| protocol major version            | 2 (SNMP DPI protocol)            |
+-----------------------------------+----------------------------------+
| protocol minor version            | 1 (version 1)                    |
+-----------------------------------+----------------------------------+
| protocol release                  | 0 (release 0)                    |
+-----------------------------------+----------------------------------+
+----------------------------------------------------------------------+

Any other values are currently undefined.

PACKET TYPE VALUES

   The packet type field can have the following values:

+----------------------------------------------------------------------+
| Table 11. Valid values for the packet type field                     |
+-------+--------------------------------------------------------------+
| VALUE | PACKET TYPE                                                  |
+-------+--------------------------------------------------------------+
| 1     | SNMP_DPI_GET                                                 |
+-------+--------------------------------------------------------------+
| 2     | SNMP_DPI_GET_NEXT                                            |
+-------+--------------------------------------------------------------+
| 3     | SNMP_DPI_SET                                                 |
+-------+--------------------------------------------------------------+
| 4     | SNMP_DPI_TRAP                                                |
+-------+--------------------------------------------------------------+
| 5     | SNMP_DPI_RESPONSE                                            |
+-------+--------------------------------------------------------------+
| 6     | SNMP_DPI_REGISTER                                            |
+-------+--------------------------------------------------------------+
+----------------------------------------------------------------------+







Carpenter & Wijnen                                             [Page 18]
^L
RFC 1228                        SNMP-DPI                        May 1991


VARIABLE TYPE VALUES

   The variable type field can have the following values:

+----------------------------------------------------------------------+
| Table 12. Valid values for the Value Type field                      |
+-------+--------------------------------------------------------------+
| VALUE | VALUE TYPE                                                   |
+-------+--------------------------------------------------------------+
| 0     | text representation                                          |
+-------+--------------------------------------------------------------+
| 129   | number (integer)                                             |
+-------+--------------------------------------------------------------+
| 2     | octet string                                                 |
+-------+--------------------------------------------------------------+
| 3     | object identifier                                            |
+-------+--------------------------------------------------------------+
| 4     | empty (no value)                                             |
+-------+--------------------------------------------------------------+
| 133   | internet address                                             |
+-------+--------------------------------------------------------------+
| 134   | counter (unsigned)                                           |
+-------+--------------------------------------------------------------+
| 135   | gauge (unsigned)                                             |
+-------+--------------------------------------------------------------+
| 136   | time ticks (1/100ths seconds)                                |
+-------+--------------------------------------------------------------+
| 9     | display string                                               |
+-------+--------------------------------------------------------------+
+----------------------------------------------------------------------+

   NOTE:  Fields which represent values that are stored as a 4-byte
   integer are indicated by ORing their base type value with 128.

Error Code Values for SNMP Agent Detected Errors

   The error code can have one of the following values:














Carpenter & Wijnen                                             [Page 19]
^L
RFC 1228                        SNMP-DPI                        May 1991


+----------------------------------------------------------------------+
| Table 13. Valid values for the SNMP Agent Minor Error Code field     |
+-------+--------------------------------------------------------------+
| VALUE | SNMP AGENT ERROR CODE                                        |
+-------+--------------------------------------------------------------+
| 0     | no error                                                     |
+-------+--------------------------------------------------------------+
| 1     | too big                                                      |
+-------+--------------------------------------------------------------+
| 2     | no such name                                                 |
+-------+--------------------------------------------------------------+
| 3     | bad value                                                    |
+-------+--------------------------------------------------------------+
| 4     | read only                                                    |
+-------+--------------------------------------------------------------+
| 5     | general error                                                |
+-------+--------------------------------------------------------------+
+----------------------------------------------------------------------+

SNMP DPI APPLICATION PROGRAM INTERFACE

   This section documents an API that implements the SNMP DPI.  This
   information has been previously published [6, 8], but the information
   provided below is more current as of May 14, 1991.

OVERVIEW OF REQUEST PROCESSING

GET PROCESSING

   A GET request is the easiest to process.  When the DPI packet is
   parsed, the parse tree holds the object ID of the variable being
   requested.

   If the specified object is not supported by the sub-agent, it would
   return an error indication of "no such name".  No name/type/value
   information would be returned.

        unsigned char *cp;

        cp = mkDPIresponse(SNMP_NO_SUCH_NAME,0);

   If the object is recognized, then the sub-agent creates a parse tree
   representing the name/type/value of the object in question (using the
   DPI API routine mkDPIset()), and returns no error indication.  This
   is demonstrated below (a string is being returned).






Carpenter & Wijnen                                             [Page 20]
^L
RFC 1228                        SNMP-DPI                        May 1991


        char *obj_id;

        unsigned char *cp;
        struct dpi_set_packet *ret_value;
        char *data;

        /* obj_id = object ID of variable, like 1.3.6.1.2.1.1.1 */
        /* should be identical to object ID sent in get request */
        data = "a string to be returned";
        ret_value = mkDPIset(obj_id,SNMP_TYPE_STRING,
                        strlen(data)+1,data);
        cp = mkDPIresponse(0,ret_value);

SET PROCESSING

   Processing a SET request is only slightly more difficult than a GET
   request.  In this case, additional information is made available in
   the parse tree, namely the type, length and value to be set.

   The sub-agent may return an error indication of "no such name" if the
   variable is unrecognized, just as in a GET request.  If the variable
   is recognized, but cannot be set, an error indication of "no such
   name" should be also be returned, although it is tempting to return a
   "read only" error.

GET NEXT PROCESSING

   GET-NEXT requests are the most complicated requests to process.
   After parsing a GET-NEXT request, the parse tree will contain two
   parameters.  One is the object ID on which the GET-NEXT operation is
   being performed.  The semantics of the operation are that the sub-
   agent is to return the name/type/value of the next variable it
   supports whose name lexicographically follows the passed object ID.

   It is important to realize that a given sub-agent may support several
   discontiguous sections of the MIB tree.  In such a situation it would
   be incorrect to jump from one section to another.  This problem is
   correctly handled by examining the second parameter which is passed.
   This parameter represents the "reason" why the sub-agent is being
   called.  It holds the prefix of the tree that the sub-agent had
   indicated it supported.

   If the next variable supported by the sub-agent does not begin with
   that prefix, the sub-agent must return an error indication of "no
   such name".  If required, the SNMP agent will call upon the sub-agent
   again, but pass it a different group prefix.  This is illustrated in
   the discussion below:




Carpenter & Wijnen                                             [Page 21]
^L
RFC 1228                        SNMP-DPI                        May 1991


   Assume there are two sub-agents.  The first sub-agent registers two
   distinct sections of the tree, A and C.  In reality, the sub-agent
   supports variables A.1 and A.2, but it correctly registers the
   minimal prefix required to uniquely identify the variable class it
   supports.

   The second sub-agent registers a different section, B, which appears
   between the two sections registered by the first agent.

   If a remote management station begins dumping the MIB, starting from
   A, the following sequence of queries would be performed:

     Sub-agent 1 gets called:
            get-next(A,A) == A.1
            get-next(A.1,A) = A.2
            get-next(A.2,A) = error(no such name)

     Sub-agent 2 is then called:
            get-next(A.2,B) = B.1
            get-next(B.1,B) = error(no such name)

     Sub-agent 1 gets called again:
            get-next(B.1,C) = C.1

REGISTER REQUESTS

   A sub-agent must register the variables it supports with the SNMP
   agent.  The appropriate packets may be created using the DPI API
   library routine mkDPIregister().

         unsigned char *cp;

         cp = mkDPIregister("1.3.6.1.2.1.1.2.");

NOTE:  object IDs are registered with a trailing dot (".").

TRAP REQUESTS

   A sub-agent can request that the SNMP agent generate a trap for it.
   The sub-agent must provide the desired values for the generic and
   specific parameters of the trap.  It may optionally provide a
   name/type/value parameter that will be included in the trap packet.
   The DPI API library routine mkDPItrap() can be used to generate the
   required packet.







Carpenter & Wijnen                                             [Page 22]
^L
RFC 1228                        SNMP-DPI                        May 1991


DPI API LIBRARY ROUTINES

   This section documents Application Program Interfaces to the DPI.

   QUERY_DPI_PORT()

     int port;
     char *hostname, *community_name;

     port = query_DPI_port(hostname, community_name);

   The query_DPI_port() function is used by a DPI client to determine
   what TCP port number is associated with the DPI.  This port number is
   needed to connect() to the SNMP agent.  If the port cannot be
   determined, -1 is returned.

   The function is passed two arguments:  a string representing the
   host's name or IP address and the community name to be used when
   making the request.

   This function enables a DPI client to "bootstrap" itself.  The port
   number is obtained via an SNMP GET request, but the DPI client does
   not have to be able to create and parse SNMP packets--this is all
   done by the query_DPI_port() function.

   NOTE:  the query_DPI_port() function assumes that the community name
   does not contain any null characters.  If this is not the case, use
   the _query_DPI_port() function which takes a third parameter, the
   length of the community name.

MKDPIREGISTER

     #include "snmp_dpi.h"

     unsigned char *packet;
     int len;

     /* register sysDescr variable */
     packet = mkDPIregister("1.3.6.1.2.1.1.1.");

     len = *packet * 256 + *(packet + 1);
     len += 2;  /* include length bytes */

   The mkDPIregister() function creates the necessary register-request
   packet and returns a pointer to a static buffer holding the packet
   contents.  The null pointer (0) is returned if there is an error
   detected during the creation of the packet.




Carpenter & Wijnen                                             [Page 23]
^L
RFC 1228                        SNMP-DPI                        May 1991


   The length of the remainder packet is stored in the first two bytes
   of the packet, as demonstrated in the example above.

   NOTE:  object identifiers are registered with a trailing dot (".").

MKDPISET

     #include "snmp_dpi.h"

     struct dpi_set_packet *set_value;

     char *obj_id;
     int type, length;
     char *value;

     set_value = mkDPIset(obj_id, type, length, value);

   The mkDPIset() function can be used to create the portion of a parse
   tree that represents a name/value pair (as would be normally be
   returned in a response packet).  It returns a pointer to a
   dynamically allocated parse tree representing the name/type/value
   information.  If there is an error detected while creating the parse
   tree, the null pointer (0) is returned.

   The value of type can be one of the following (which are defined in
   the include file "snmp_dpi.h"):

      o   SNMP_TYPE_NUMBER
      o   SNMP_TYPE_STRING
      o   SNMP_TYPE_OBJECT
      o   SNMP_TYPE_INTERNET
      o   SNMP_TYPE_COUNTER
      o   SNMP_TYPE_GAUGE
      o   SNMP_TYPE_TICKS

   The value parameter is always a pointer to the first byte of the
   object's value.

   NOTE:  the parse tree is dynamically allocated and copies are made of
   the passed parameters.  After a successful call to mkDPIset(), they
   can be disposed of in any manner the application chooses without
   affecting the parse tree contents.

MKDPIRESPONSE

     #include "snmp_dpi.h"

     unsigned char *packet;



Carpenter & Wijnen                                             [Page 24]
^L
RFC 1228                        SNMP-DPI                        May 1991


     int error_code;
     struct dpi_set_packet *ret_value;

     packet = mkDPIresponse(error_code, ret_value);

     len = *packet * 256 + *(packet + 1);
     len += 2;  /* include length bytes */

   The mkDPIresponse() function creates an appropriate response packet.
   It takes two parameters.  The first is the error code to be returned.
   It may be 0 (indicating no error) or one of the following (which are
   defined in the include file "snmp_dpi.h"):

      o   SNMP_NO_ERROR
      o   SNMP_TOO_BIG
      o   SNMP_NO_SUCH_NAME
      o   SNMP_BAD_VALUE
      o   SNMP_READ_ONLY
      o   SNMP_GEN_ERR

   If the error code indicates no error, then the second parameter is a
   pointer to a parse tree (created by mkDPIset()) which represents the
   name/type/value information being returned.  If an error is
   indicated, the second parameter is passed as a null pointer (0).

   If the packet can be created, a pointer to a static buffer containing
   the packet contents is returned.  This is the same buffer used by
   mkDPIregister().  If an error is encountered while creating the
   packet, the null pointer (0) is returned.

   The length of the remainder packet is stored in the first two bytes
   of the packet, as demonstrated in the example above.

   NOTE:  mkDPIresponse() always frees the passed parse tree.

MKDPITRAP

     #include "snmp_dpi.h"

     unsigned char *packet;

     int generic, specific;
     struct dpi_set_packet *ret_value;

     packet = mkDPItrap(generic, specific, ret_value);

     len = *packet * 256 + *(packet + 1);
     len += 2;  /* include length bytes */



Carpenter & Wijnen                                             [Page 25]
^L
RFC 1228                        SNMP-DPI                        May 1991


   The mkDPItrap() function creates an appropriate trap request packet.
   The first two parameters correspond to to value of the generic and
   specific fields in the SNMP trap packet.  The third field can be used
   to pass a name/value pair to be provided in the SNMP trap packet.
   This information is passed as the set-packet portion of the parse
   tree.  As an example, a linkDown trap for interface 3 might be
   generated by the following:

     struct dpi_set_packet *if_index_value;
     unsigned long data;
     unsigned char *packet;
     int len;

     data = 3;  /* interface number = 3 */
     if_index_value = mkDPIset("1.3.6.1.2.1.2.2.1.1", SNMP_TYPE_NUMBER,
             sizeof(unsigned long), &data);
     packet = mkDPItrap(2, 0, if_index_value);
     len = *packet * 256 + *(packet + 1);
     len += 2;  /* include length bytes */
     write(fd,packet,len);

   If the packet can be created, a pointer to a static buffer containing
   the packet contents is returned.  This is the same buffer used by
   mkDPIregister().  If an error is encountered while creating the
   packet, the null pointer (0) is returned.

   The length of the remainder packet is stored in the first two bytes
   of the packet, as demonstrated in the example above.

   NOTE:  mkDPItrap() always frees the passed parse tree.

PDPIPACKET

     #include "snmp_dpi.h"

     unsigned char *packet;

     struct snmp_dpi_hdr *hdr;

     hdr = pDPIpacket(packet)

   The pDPIpacket() function parses a DPI packet and returns a parse
   tree representing its contents.  The parse tree is dynamically
   allocated and contains copies of the information within the DPI
   packet.  After a successful call to pDPIpacket(), the packet may be
   disposed of in any manner the application chooses without affecting
   the contents of the parse tree.  If an error is encountered during
   the parse, the null pointer (0) is returned.



Carpenter & Wijnen                                             [Page 26]
^L
RFC 1228                        SNMP-DPI                        May 1991


   NOTE:  the relevant parse tree structures are defined in the include
   file "snmp_dpi.h", and that file remains the definitive reference.

   The root of the parse tree is represented by a snmp_dpi_hdr
   structure:

     struct snmp_dpi_hdr {
         unsigned char  proto_major;
         unsigned char  proto_minor;
         unsigned char  proto_release;

         unsigned char  packet_type;
         union {
              struct dpi_get_packet    *dpi_get;
              struct dpi_next_packet   *dpi_next;
              struct dpi_set_packet    *dpi_set;
              struct dpi_resp_packet   *dpi_response;
              struct dpi_trap_packet   *dpi_trap;
         } packet_body;
     };

   The field of immediate interest is packet_type.  This field can have
   one of the following values (which are defined in the include file
   "snmp_dpi.h"):

      o   SNMP_DPI_GET
      o   SNMP_DPI_GET_NEXT
      o   SNMP_DPI_SET

   The packet_type field indicates what request is being made of the DPI
   client.  For each of these requests, the remainder of the packet_body
   will be different.

   If a get request is indicated, the object ID of the desired variable
   is passed in a dpi_get_packet structure:

     struct dpi_get_packet {
         char *object_id;
     };

   A get-next request is similar, but the dpi_next_packet structure also
   contains the object ID prefix of the group that is currently being
   traversed:

     struct dpi_next_packet {
         char *object_id;
         char *group_id;
     };



Carpenter & Wijnen                                             [Page 27]
^L
RFC 1228                        SNMP-DPI                        May 1991


   If the next object whose object ID lexicographically follows the
   object ID indicated by object_id does not begin with the suffix
   indicated by group_id, the DPI client must return an error indication
   of SNMP_NO_SUCH_NAME.

   A set request has the most amount of data associated with it and this
   is contained in a dpi_set_packet structure:

     struct dpi_set_packet {
         char      *object_id;
         unsigned char  type;
         unsigned short value_len;
         char      *value;
     };

   The object ID of the variable to be modified is indicated by
   object_id The type of the variable is provided in type and may have
   one of the following values:

      o   SNMP_TYPE_NUMBER
      o   SNMP_TYPE_STRING
      o   SNMP_TYPE_OBJECT
      o   SNMP_TYPE_EMPTY
      o   SNMP_TYPE_INTERNET
      o   SNMP_TYPE_COUNTER
      o   SNMP_TYPE_GAUGE
      o   SNMP_TYPE_TICKS

   The length of the value to be set is stored in value_len and value
   contains a pointer to the value.

   NOTE:  the storage pointed to by value will be reclaimed when the
   parse tree is freed.  The DPI client must make provision for copying
   the value contents.

FDPIPARSE

     #include "snmp_dpi.h"

     struct snmp_dpi_hdr *hdr;

     fDPIparse(hdr);

   The routine fDPIparse() frees a parse tree previously created by a
   call to pDPIpacket This routine is declared as void--it has no return
   value.

   NOTE:  after calling fDPIparse(), no further references to the parse



Carpenter & Wijnen                                             [Page 28]
^L
RFC 1228                        SNMP-DPI                        May 1991


   tree can be made.

AGENT IMPLEMENTATION ISSUES

   Although the SNMP DPI protocol is completely documented in this
   paper, the document itself is somewhat biased towards clearly
   defining the interface provided to sub-agents (i.e., it provides a
   specification of a C language API).  This detailed coverage is
   possible because the client side of the interface is completely
   self-contained.

   The agent side of the interface has to be integrated into individual
   vendor implementations, many of which may have a unique
   organizational structure in an attempt to address various performance
   and storage constraints.  This makes it infeasible to provide much
   more than suggestions for SNMP agent implementers.  Unfortunately,
   this leaves room for a large amount of interpretation which can lead
   to implementations that don't necessarily work they way they should-
   -too much ambiguity can be a bad thing.

   The following characteristics of an agent implementation are to be
   considered mandatory:

DUPLICATE REGISTRATIONS

   With this release of the protocol, order of registration is
   significant.  The last sub-agent to register a variable is the one
   that is deemed to be authoritative.  Variables implemented by the
   base SNMP agent are considered to have been registered prior to any
   sub-agent registrations.  Thus sub-agents may re-implement support
   for variables that were incorrectly implemented by a vendor.

AUTOMATIC DEREGISTRATION ON CLOSE

   All SNMP DPI connections are carried over a stream connection.  When
   the connection is closed by the client (no matter what the cause),
   the agent must automatically unregister all of the variables that
   were registered by the sub-agent.

TIMELY RESPONSE CONSTRAINTS

   A sub-agent must respond to a request in a timely fashion.  In this
   version of the protocol, we specify that a sub-agent must respond to
   a request by the SNMP agent within 5 seconds.  If the sub-agent does
   not respond in time, the SNMP agent should terminate the connection
   and unregister all of the variables that were previously registered
   by the sub-agent in question.




Carpenter & Wijnen                                             [Page 29]
^L
RFC 1228                        SNMP-DPI                        May 1991


   NOTE:  agent implementations that do not have access to a timer may
   not be able to implement this.  In that case, they leave themselves
   open to being placed in a state where they are blocked forever if the
   sub-agent malfunctions.

SUPPORT FOR MULTIPLE MIB VIEWS

   Some agents allow different MIB views to be selected based on the
   community name used.  It is not the intention of this document to
   pass judgement on the various approaches that have been proposed or
   implemented, but instead merely to recognize the existence of
   implementations that support this feature.

   The point of this discussion is to specify clearly that objects
   supported by an SNMP DPI sub-agent are to be registered under the MIB
   view that was selected by the community name used in the SNMP GET
   request that obtained the DPI_port value.

   The SNMP DPI does not specify a reserved port, but instead sub-agents
   bootstrap themselves by making an SNMP GET request for the DPI_port
   variable.  This variable represents the TCP port to which the sub-
   agent should connect.  It should be understood that there is no
   reason why the SNMP agent cannot have several listens (passive opens)
   active, each corresponding to a distinct MIB view.  The port number
   returned then would be different based on the community name used in
   the SNMP GET request for the DPI_port variable.

CONSIDERATIONS FOR THE NEXT RELEASE

   The SNMP DPI protocol makes provision for extension and parallel use
   of potentially incompatible releases.  The discussion above documents
   the protocol as it is currently in use and has not discussed features
   of interest that should be considered for a future revision.

UNREGISTER

   For closure, an UNREGISTER request could be of use.

SUPPORT FOR ATOMIC SETS

   The SNMP protocol [1] specifies that:

      Each variable assignment specified by the SetRequest-PDU should be
      effected as if simultaneously set with respect to all other
      assignments specified in the same message.

   The SNMP DPI has no provision for backing out a successfully
   processed SET request if one of the subsequent variable assignments



Carpenter & Wijnen                                             [Page 30]
^L
RFC 1228                        SNMP-DPI                        May 1991


   fails.  This omission is a reflection of several biases:

   o   the SNMP DPI was intended to be light-weight.

   o   a belief that the SNMP RFC prescribes semantics which are infeasible
       to implement unless the range of applications is restricted.

   It has been suggested that a new request, TEST_SET, be added to the
   DPI protocol.  Processing of a SET request would then be performed as
   follows:

   o   all variables would be processed using TEST_SET unless any error
       occurred.  The subagents would verify that they could process the
       request.

   o   if no error occurred, each of the variables would be reprocessed,
       this time with a SET request.

   A problem with such an approach is that it relies on the TEST_SET
   operation to make an assertion that the request can be successfully
   performed.  If this is not possible, then it cannot be asserted that
   the prescribed semantics will be provided.  Such situations do exist,
   for example, a SET request that causes the far-end channel service
   unit to be looped up--one does not know if the operation will be
   successful until it is performed.

SAMPLE SNMP DPI API IMPLEMENTATION

   The following C language sources show an example implementation of
   the SNMP DPI Application Programming Interface as it would be exposed
   to the sub-agents.

SAMPLE SNMP DPI INCLUDE FILE

  /* SNMP distributed program interface */

  #define SNMP_DPI_GET            1
  #define SNMP_DPI_GET_NEXT       2
  #define SNMP_DPI_SET            3
  #define SNMP_DPI_TRAP           4
  #define SNMP_DPI_RESPONSE       5
  #define SNMP_DPI_REGISTER       6

  #define SNMP_DPI_PROTOCOL       2
  #define SNMP_DPI_VERSION        1
  #define SNMP_DPI_RELEASE        0

  /* SNMP error codes from RFC 1098 (1067) */



Carpenter & Wijnen                                             [Page 31]
^L
RFC 1228                        SNMP-DPI                        May 1991


  #define SNMP_NO_ERROR           0
  #define SNMP_TOO_BIG            1
  #define SNMP_NO_SUCH_NAME       2
  #define SNMP_BAD_VALUE          3
  #define SNMP_READ_ONLY          4
  #define SNMP_GEN_ERR            5

  /* variable types */
  #define SNMP_TYPE_TEXT          0       /* textual representation */
  #define SNMP_TYPE_NUMBER        (128|1) /* number */
  #define SNMP_TYPE_STRING        2       /* text string */
  #define SNMP_TYPE_OBJECT        3       /* object identifier */
  #define SNMP_TYPE_EMPTY         4       /* no value */
  #define SNMP_TYPE_INTERNET      (128|5) /* internet address */
  #define SNMP_TYPE_COUNTER       (128|6) /* counter */
  #define SNMP_TYPE_GAUGE         (128|7) /* gauge */
  #define SNMP_TYPE_TICKS         (128|8) /* time ticks (1/100th sec) */
  #define SNMP_TYPE_MASK          0x7f    /* mask for type */


  struct dpi_get_packet {
          char    *object_id;
  };

  struct dpi_next_packet {
          char    *object_id;
          char    *group_id;
  };

  struct dpi_set_packet {
          char            *object_id;
          unsigned char   type;
          unsigned short  value_len;
          char            *value;
  };

  struct dpi_resp_packet {
          unsigned char   ret_code;
          struct dpi_set_packet   *ret_data;
  };

  struct dpi_trap_packet {
          unsigned char   generic;
          unsigned char   specific;
          struct dpi_set_packet   *info;
  };

  struct snmp_dpi_hdr {



Carpenter & Wijnen                                             [Page 32]
^L
RFC 1228                        SNMP-DPI                        May 1991


          unsigned char   proto_major;
          unsigned char   proto_minor;
          unsigned char   proto_release;

          unsigned char   packet_type;
          union {
                  struct dpi_get_packet   *dpi_get;
                  struct dpi_next_packet  *dpi_next;
                  struct dpi_set_packet   *dpi_set;
                  struct dpi_resp_packet  *dpi_response;
                  struct dpi_trap_packet  *dpi_trap;
          } packet_body;
  };

  extern struct snmp_dpi_hdr *pDPIpacket();
  extern void fDPIparse();
  extern unsigned char *mkMIBquery();
  extern unsigned char *mkDPIregister();
  extern unsigned char *mkDPIresponse();
  extern unsigned char *mkDPItrap();
  extern struct dpi_set_packet *mkDPIset();

SAMPLE QUERY_DPI_PORT() FUNCTION


  #ifdef VM

  #include <manifest.h>
  #include <snmp_vm.h>
  #include <bsdtime.h>
  #include <bsdtypes.h>
  #include <socket.h>
  #include <in.h>
  #include <netdb.h>
  #include <inet.h>

  #else

  #include <sys/time.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <netdb.h>
  #include <arpa/inet.h>

  #endif

  static unsigned char asn1_hdr[] = {0x30};



Carpenter & Wijnen                                             [Page 33]
^L
RFC 1228                        SNMP-DPI                        May 1991


  /* insert length of remaining packet, not including this */
  static unsigned char version[] = {0x02, 0x01, 0x00, 0x04};

  /* integer, len=1, value=0, string */
  /* insert community name length and community name */
  static unsigned char request[] = {
      0xa0, 0x1b,         /* get request, len=0x1b */
      0x02, 0x01, 0x01,   /* integer, len=1,request_id = 1 */
      0x02, 0x01, 0x00,   /* integer, len=1, error_status = 0 */
      0x02, 0x01, 0x00,   /* integer, len=1, error_index = 0 */
      0x30, 0x10,         /* varbind list, len=0x10 */
      0x30, 0x0e,         /* varbind , len=0x0e */
      0x06, 0x0a,         /* object ID, len=0x0a */
      0x2b, 0x06, 0x01, 0x04, 0x01, 0x02, 0x02, 0x01, 0x01, 0x00,
      0x05, 0x00          /* value, len = 0 */
  };

  static          extract_DPI_port();

  query_DPI_port(hostname, community_name)
  char           *hostname;
  char           *community_name;
  {
      int             community_len;
      int             rc;

      community_len = strlen(community_name);

      rc = _query_DPI_port(hostname, community_name, community_len);
      return (rc);
  }

  /* use if community_name has embedded nulls */

  _query_DPI_port(hostname, community_name, community_len)
  char           *hostname;
  char           *community_name;
  int             community_len;
  {
      unsigned char   packet[1024];
      int             packet_len;
      int             remaining_len;
      int             fd, rc, sock_len;
      struct sockaddr_in sock, dest_sock;
      struct timeval  timeout;
      unsigned long   host_addr, read_mask;
      int             tries;




Carpenter & Wijnen                                             [Page 34]
^L
RFC 1228                        SNMP-DPI                        May 1991


      host_addr = lookup_host(hostname);
      packet_len = 0;
      bcopy(asn1_hdr, packet, sizeof(asn1_hdr));
      packet_len += sizeof(asn1_hdr);

      remaining_len = sizeof(version) + 1 +
        community_len + sizeof(request);

      packet[packet_len++] = remaining_len & 0xff;
      bcopy(version, packet + packet_len, sizeof(version));
      packet_len += sizeof(version);
      packet[packet_len++] = community_len & 0xff;
      bcopy(community_name, packet + packet_len, community_len);
      packet_len += community_len;
      bcopy(request, packet + packet_len, sizeof(request));
      packet_len += sizeof(request);

      fd = socket(AF_INET, SOCK_DGRAM, 0);
      if (fd < 0) {
      return (-1);
      }
      bzero(&sock, sizeof(sock));
      sock.sin_family = AF_INET;
      sock.sin_port = 0;
      sock.sin_addr.s_addr = 0;
      rc = bind(fd, &sock, sizeof(sock));
      if (rc < 0)
      return (-1);
      timeout.tv_sec = 3;
      timeout.tv_usec = 0;
      bzero(&dest_sock, sizeof(dest_sock));
      dest_sock.sin_family = AF_INET;
      dest_sock.sin_port = htons(161);
      dest_sock.sin_addr.s_addr = host_addr;

      tries = 0;
      while (++tries < 4) {
      rc = sendto(fd, packet, packet_len, 0, &dest_sock,
               sizeof(dest_sock));
      read_mask = 1 << fd;
      rc = select(read_mask + 1, &read_mask, 0, 0, &timeout);
      if (rc <= 0)
          continue;
      sock_len = sizeof(dest_sock);
      packet_len = recvfrom(fd, packet, sizeof(packet), 0,
                      &dest_sock, &sock_len);
      if (packet_len <= 0) {
          return (-1);



Carpenter & Wijnen                                             [Page 35]
^L
RFC 1228                        SNMP-DPI                        May 1991


      }
      rc = extract_DPI_port(packet, packet_len);
      return (rc);
      }
      return (-1);
  }

  static          extract_DPI_port(packet, len)
  unsigned char   packet[];
  int             len;

  {
      int             offset;
      int             port;

      /* should do error checking (like for noSuchName) */
      offset = len - 2;
      port = (packet[offset] << 8) + packet[offset + 1];
      return (port);
  }

SAMPLE DPI FUNCTIONS

  /* DPI parser */

  #ifdef VM
  #include "manifest.h"
  #endif

  #include "snmp_dpi.h"

  static struct dpi_get_packet *pDPIget();
  static struct dpi_next_packet *pDPInext();
  static struct dpi_set_packet *pDPIset();
  static struct dpi_trap_packet *pDPItrap();
  static struct dpi_resp_packet *pDPIresponse();

  static void     fDPIget();
  static void     fDPInext();
  static void     fDPIset();
  static void     fDPItrap();
  static void     fDPIresponse();

  static int      cDPIget();
  static int      cDPInext();
  static int      cDPIset();
  static int      cDPItrap();
  static int      cDPIresponse();



Carpenter & Wijnen                                             [Page 36]
^L
RFC 1228                        SNMP-DPI                        May 1991


  static struct snmp_dpi_hdr *mkDPIhdr();
  static struct dpi_get_packet *mkDPIget();
  static struct dpi_next_packet *mkDPInext();
  struct dpi_set_packet *mkDPIset();


  extern char    *malloc();

  static unsigned char new_packet[1024];
  static int      packet_len;

  struct snmp_dpi_hdr *pDPIpacket(packet)
  unsigned char  *packet;
  {
      struct snmp_dpi_hdr *hdr;
      int             len, offset;


      hdr = (struct snmp_dpi_hdr *) malloc(sizeof(struct snmp_dpi_hdr));
      if (hdr == 0)
          return (0);

      len = (packet[0] << 8) + packet[1];
      len += 2;
      offset = 2;
      hdr->proto_major = packet[offset++];
      hdr->proto_minor = packet[offset++];
      hdr->proto_release = packet[offset++];
      hdr->packet_type = packet[offset++];
      switch (hdr->packet_type) {
      case SNMP_DPI_GET:
      case SNMP_DPI_REGISTER:
          hdr->packet_body.dpi_get =
            pDPIget(packet + offset, len - offset);
          break;
      case SNMP_DPI_GET_NEXT:
          hdr->packet_body.dpi_next =
            pDPInext(packet + offset, len - offset);
          break;
      case SNMP_DPI_SET:
          hdr->packet_body.dpi_set =
            pDPIset(packet + offset, len - offset);
          break;
      case SNMP_DPI_TRAP:
          hdr->packet_body.dpi_trap =
            pDPItrap(packet + offset, len - offset);
          break;
      case SNMP_DPI_RESPONSE:



Carpenter & Wijnen                                             [Page 37]
^L
RFC 1228                        SNMP-DPI                        May 1991


          hdr->packet_body.dpi_response =
            pDPIresponse(packet + offset, len - offset);
          break;
      }
      return (hdr);
  }

  static struct dpi_get_packet *pDPIget(packet, len)
  unsigned char  *packet;
  int             len;
  {
      struct dpi_get_packet *get;
      int             l;

      get = (struct dpi_get_packet *)
        malloc(sizeof(struct dpi_get_packet));
      if (get == 0)
          return (0);
      l = strlen(packet) + 1;
      get->object_id = malloc(l);
      strcpy(get->object_id, packet);
      return (get);
  }

  static struct dpi_next_packet *pDPInext(packet, len)
  unsigned char  *packet;
  int             len;
  {
      struct dpi_next_packet *next;
      int             l;
      unsigned char  *cp;

      next = (struct dpi_next_packet *)
        malloc(sizeof(struct dpi_next_packet));
      if (next == 0)
          return (0);
      cp = packet;
      l = strlen(cp) + 1;
      next->object_id = malloc(l);
      strcpy(next->object_id, cp);
      cp += l;
      l = strlen(cp) + 1;
      next->group_id = malloc(l);
      strcpy(next->group_id, cp);
      return (next);
  }

  static struct dpi_set_packet *pDPIset(packet, len)



Carpenter & Wijnen                                             [Page 38]
^L
RFC 1228                        SNMP-DPI                        May 1991


  unsigned char  *packet;
  int             len;
  {
      struct dpi_set_packet *set;
      int             l;
      unsigned char  *cp;

      if (len == 0)
          return (0);     /* nothing to parse */
      set = (struct dpi_set_packet *)
        malloc(sizeof(struct dpi_set_packet));
      if (set == 0)
          return (0);

      cp = packet;
      l = strlen(cp) + 1;
      set->object_id = malloc(l);
      strcpy(set->object_id, cp);
      cp += l;
      set->type = *(cp++);
      l = (*(cp++) << 8);
      l += *(cp++);
      set->value_len = l;
      set->value = malloc(l);
      bcopy(cp, set->value, l);
      return (set);
  }

  static struct dpi_trap_packet *pDPItrap(packet, len)
  unsigned char  *packet;
  int             len;
  {
      struct dpi_trap_packet *trap;

      trap = (struct dpi_trap_packet *)
        malloc(sizeof(struct dpi_trap_packet));
      if (trap == 0)
          return (0);

      trap->generic = *packet;
      trap->specific = *(packet + 1);
      trap->info = pDPIset(packet + 2, len - 2);
      return (trap);
  }

  static struct dpi_resp_packet *pDPIresponse(packet, len)
  unsigned char  *packet;
  int             len;



Carpenter & Wijnen                                             [Page 39]
^L
RFC 1228                        SNMP-DPI                        May 1991


  {
      struct dpi_resp_packet *resp;

      resp = (struct dpi_resp_packet *)
        malloc(sizeof(struct dpi_resp_packet));
      if (resp == 0)
          return (0);

      resp->ret_code = *packet;
      resp->ret_data = pDPIset(packet + 1, len - 1);
      return (resp);
  }

  void            fDPIparse(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      if (hdr == 0)
          return;
      switch (hdr->packet_type) {
      case SNMP_DPI_GET:
      case SNMP_DPI_REGISTER:
          fDPIget(hdr);
          break;
      case SNMP_DPI_GET_NEXT:
          fDPInext(hdr);
          break;
      case SNMP_DPI_SET:
          fDPIset(hdr);
          break;
      case SNMP_DPI_TRAP:
          fDPItrap(hdr);
          break;
      case SNMP_DPI_RESPONSE:
          fDPIresponse(hdr);
          break;
      }
      free(hdr);
  }

  static void     fDPIget(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      struct dpi_get_packet *get;

      get = hdr->packet_body.dpi_get;
      if (get == 0)
          return;
      if (get->object_id)



Carpenter & Wijnen                                             [Page 40]
^L
RFC 1228                        SNMP-DPI                        May 1991


          free(get->object_id);
      free(get);
  }

  static void     fDPInext(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      struct dpi_next_packet *next;

      next = hdr->packet_body.dpi_next;
      if (next == 0)
          return;
      if (next->object_id)
          free(next->object_id);
      if (next->group_id)
          free(next->group_id);
      free(next);
  }

  static void     fDPIset(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      struct dpi_set_packet *set;

      set = hdr->packet_body.dpi_set;
      if (set == 0)
          return;
      if (set->object_id)
          free(set->object_id);
      if (set->value)
          free(set->value);
      free(set);
  }

  static void     fDPItrap(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      struct dpi_trap_packet *trap;
      struct dpi_set_packet *set;

      trap = hdr->packet_body.dpi_trap;
      if (trap == 0)
          return;

      set = trap->info;
      if (set != 0) {
          if (set->object_id)
              free(set->object_id);



Carpenter & Wijnen                                             [Page 41]
^L
RFC 1228                        SNMP-DPI                        May 1991


          if (set->value)
              free(set->value);
          free(set);
      }
      free(trap);
  }

  static void     fDPIresponse(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      struct dpi_resp_packet *resp;
      struct dpi_set_packet *set;

      resp = hdr->packet_body.dpi_response;
      if (resp == 0)
          return;

      set = resp->ret_data;
      if (set != 0) {
          if (set->object_id)
              free(set->object_id);
          if (set->value)
              free(set->value);
          free(set);
      }
      free(resp);
  }

  unsigned char  *cDPIpacket(hdr)
  struct snmp_dpi_hdr *hdr;
  {
      int             rc, len;
      if (hdr == 0) {
          return (0);
      }
      packet_len = 2;
      new_packet[packet_len++] = hdr->proto_major;
      new_packet[packet_len++] = hdr->proto_minor;
      new_packet[packet_len++] = hdr->proto_release;
      new_packet[packet_len++] = hdr->packet_type;
      switch (hdr->packet_type) {
      case SNMP_DPI_GET:
      case SNMP_DPI_REGISTER:
          rc = cDPIget(hdr->packet_body.dpi_get);
          break;
      case SNMP_DPI_GET_NEXT:
          rc = cDPInext(hdr->packet_body.dpi_next);
          break;



Carpenter & Wijnen                                             [Page 42]
^L
RFC 1228                        SNMP-DPI                        May 1991


      case SNMP_DPI_SET:
          rc = cDPIset(hdr->packet_body.dpi_set);
          break;
      case SNMP_DPI_TRAP:
          rc = cDPItrap(hdr->packet_body.dpi_trap);
          break;
      case SNMP_DPI_RESPONSE:
          rc = cDPIresponse(hdr->packet_body.dpi_response);
          break;
      }
      if (rc == -1)
          return (0);
      len = packet_len - 2;
      new_packet[1] = len & 0xff;
      len >>= 8;
      new_packet[0] = len & 0xff;
      return (new_packet);
  }

  static int      cDPIget(get)
  struct dpi_get_packet *get;
  {
      if (get->object_id == 0)
          return (-1);

      strcpy(&new_packet[packet_len], get->object_id);
      packet_len += strlen(get->object_id) + 1;
      return (0);
  }

  static int      cDPInext(next)
  struct dpi_next_packet *next;
  {
      if (next->object_id == 0)
          return (-1);
      if (next->group_id == 0)
          return (-1);

      strcpy(&new_packet[packet_len], next->object_id);
      packet_len += strlen(next->object_id) + 1;
      strcpy(&new_packet[packet_len], next->group_id);
      packet_len += strlen(next->group_id) + 1;
      return (0);
  }

  static int      cDPIset(set)
  struct dpi_set_packet *set;
  {



Carpenter & Wijnen                                             [Page 43]
^L
RFC 1228                        SNMP-DPI                        May 1991


      int             len;

      if (set->object_id == 0)
          return (-1);
      if ((set->value == 0) && (set->value_len != 0))
          return (-1);

      strcpy(&new_packet[packet_len], set->object_id);
      packet_len += strlen(set->object_id) + 1;
      new_packet[packet_len++] = set->type;
      len = set->value_len >> 8;
      new_packet[packet_len++] = len & 0xff;
      new_packet[packet_len++] = set->value_len & 0xff;
      bcopy(set->value, &new_packet[packet_len], set->value_len);
      packet_len += set->value_len;
      return (0);
  }

  static int      cDPIresponse(resp)
  struct dpi_resp_packet *resp;
  {
      int             rc;

      if (resp == 0)
          return (-1);

      new_packet[packet_len++] = resp->ret_code;
      if (resp->ret_data != 0) {
          rc = cDPIset(resp->ret_data);
      } else
          rc = 0;
      return (rc);
  }

  static int      cDPItrap(trap)
  struct dpi_trap_packet *trap;
  {
      int             rc;

      new_packet[packet_len++] = trap->generic;
      new_packet[packet_len++] = trap->specific;
      if (trap->info != 0)
          rc = cDPIset(trap->info);
      else
          rc = 0;
      return (rc);
  }




Carpenter & Wijnen                                             [Page 44]
^L
RFC 1228                        SNMP-DPI                        May 1991


  unsigned char  *mkMIBquery(cmd, oid_name, group_oid, type, len, value)
  int             cmd;
  char           *oid_name, *group_oid;
  int             type, len;
  char           *value;
  {
      struct snmp_dpi_hdr *hdr;
      unsigned char  *cp;

      hdr = mkDPIhdr(cmd);
      if (hdr == 0)
          return (0);
      switch (hdr->packet_type) {
      case SNMP_DPI_GET:
      case SNMP_DPI_REGISTER:
          hdr->packet_body.dpi_get = mkDPIget(oid_name);
          break;
      case SNMP_DPI_GET_NEXT:
          hdr->packet_body.dpi_next = mkDPInext(oid_name, group_oid);
          break;
      case SNMP_DPI_SET:
          hdr->packet_body.dpi_set =
            mkDPIset(oid_name, type, len, value);
          break;
      }
      cp = cDPIpacket(hdr);
      fDPIparse(hdr);
      return (cp);
  }

  unsigned char  *mkDPIregister(oid_name)
  char           *oid_name;
  {
      return (mkMIBquery(SNMP_DPI_REGISTER, oid_name));
  }

  unsigned char  *mkDPIresponse(ret_code, value_list)
  int             ret_code;
  struct dpi_set_packet *value_list;
  {
      struct snmp_dpi_hdr *hdr;
      struct dpi_resp_packet *resp;
      unsigned char  *cp;

      hdr = mkDPIhdr(SNMP_DPI_RESPONSE);
      resp = (struct dpi_resp_packet *)
        malloc(sizeof(struct dpi_resp_packet));
      if (resp == 0) {



Carpenter & Wijnen                                             [Page 45]
^L
RFC 1228                        SNMP-DPI                        May 1991


          free(hdr);
          return (0);
      }
      hdr->packet_body.dpi_response = resp;
      resp->ret_code = ret_code;
      resp->ret_data = value_list;
      cp = cDPIpacket(hdr);
      fDPIparse(hdr);
      return (cp);
  }

  unsigned char  *mkDPItrap(generic, specific, value_list)
  int             generic, specific;
  struct dpi_set_packet *value_list;
  {
      struct snmp_dpi_hdr *hdr;
      struct dpi_trap_packet *trap;
      unsigned char  *cp;

      hdr = mkDPIhdr(SNMP_DPI_TRAP);
      trap = (struct dpi_trap_packet *)
        malloc(sizeof(struct dpi_trap_packet));
      if (trap == 0) {
          free(hdr);
          return (0);
      }
      hdr->packet_body.dpi_trap = trap;
      trap->generic = generic;
      trap->specific = specific;
      trap->info = value_list;
      cp = cDPIpacket(hdr);
      fDPIparse(hdr);
      return (cp);
  }

  static struct snmp_dpi_hdr *mkDPIhdr(type)
  int             type;
  {

      struct snmp_dpi_hdr *hdr;

      hdr = (struct snmp_dpi_hdr *) malloc(sizeof(struct snmp_dpi_hdr));
      if (hdr == 0)
          return (0);
      hdr->proto_major = SNMP_DPI_PROTOCOL;
      hdr->proto_minor = SNMP_DPI_VERSION;
      hdr->proto_release = SNMP_DPI_RELEASE;
      hdr->packet_type = type;



Carpenter & Wijnen                                             [Page 46]
^L
RFC 1228                        SNMP-DPI                        May 1991


      return (hdr);
  }

  static struct dpi_get_packet *mkDPIget(oid_name)
  char           *oid_name;
  {
      struct dpi_get_packet *get;
      int             l;

      get = (struct dpi_get_packet *)
        malloc(sizeof(struct dpi_get_packet));
      if (get == 0)
          return (0);

      l = strlen(oid_name) + 1;
      get->object_id = malloc(l);
      strcpy(get->object_id, oid_name);
      return (get);
  }

  static struct dpi_next_packet *mkDPInext(oid_name, group_oid)
  char           *oid_name;
  char           *group_oid;
  {
      struct dpi_next_packet *next;
      int             l;

      next = (struct dpi_next_packet *)
        malloc(sizeof(struct dpi_next_packet));
      if (next == 0)
          return (0);
      l = strlen(oid_name) + 1;
      next->object_id = malloc(l);
      strcpy(next->object_id, oid_name);
      l = strlen(group_oid) + 1;
      next->group_id = malloc(l);
      strcpy(next->group_id, group_oid);
      return (next);
  }

  struct dpi_set_packet *mkDPIset(oid_name, type, len, value)
  char           *oid_name;
  int             type;
  int             len;
  char           *value;
  {
      struct dpi_set_packet *set;
      int             l;



Carpenter & Wijnen                                             [Page 47]
^L
RFC 1228                        SNMP-DPI                        May 1991


      set = (struct dpi_set_packet *)
        malloc(sizeof(struct dpi_set_packet));
      if (set == 0)
          return (0);

      l = strlen(oid_name) + 1;
      set->object_id = malloc(l);
      strcpy(set->object_id, oid_name);
      set->type = type;
      set->value_len = len;
      set->value = malloc(len);
      bcopy(value, set->value, len);
      return (set);
  }


SAMPLE SOURCES FOR ANONYMOUS FTP

   The complete source to two SNMP DPI-related programs is available for
   anonymous ftp from the University of Toronto.  The host name to use
   is "vm.utcs.utoronto.ca" (128.100.100.2).  The files are in the
   "anonymou.204" minidisk, so one must issue a "cd anonymou.204" after
   having logged in.  Don't forget to use the binary transmission mode.

The Ping Engine

   This program is an SNMP DPI sub-agent which allows network management
   stations to perform remote PINGs.  The source to this applications is
   in the file "ping_eng.tarbin".  The source to the SNMP DPI API is
   also contained within the archive.

The DPI->SMUX daemon

   This program illustrates what is required to include the SNMP DPI in
   an SNMP agent.  This is actually a SMUX-based agent that works with
   the ISODE SNMP agent and provides an interface for SNMP DPI sub-
   agents.  The source to this program is in the file "dpid.tarbin".
   ISODE 6.7, or later, is a prerequisite.

References

   [1] Case, J., Fedor, M., Schoffstall, M., and J. Davin, "Simple
       Network Management Protocol", RFC 1157, SNMP Research,
       Performance Systems International, Performance Systems
       International, MIT Laboratory for Computer Science, May 1990.

   [2] Information processing systems - Open Systems Interconnection,
       "Specification of Abstract Syntax Notation One (ASN.1)",



Carpenter & Wijnen                                             [Page 48]
^L
RFC 1228                        SNMP-DPI                        May 1991


       International Organization for Standardization, International
       Standard 8824, December 1987.

   [3] Information processing systems - Open Systems Interconnection,
       "Specification of Basic Encoding Rules for Abstract Syntax
       Notation One (ASN.1)", International Organization for
       Standardization, International Standard 8825, December 1987.

   [4] McCloghrie K., and M. Rose, "Management Information Base for
       Network Management of TCP/IP-based internets", RFC 1156,
       Performance Systems International and Hughes LAN Systems, May
       1990.

   [5] Rose, M., and K. McCloghrie, "Structure and Identification of
       Management Information for TCP/IP-based internets", RFC 1155,
       Performance Systems International and Hughes LAN Systems, May
       1990.

   [6] International Business Machines, Inc., "TCP/IP for VM:
       Programmer's Reference", SC31-6084-0, 1990.

   [7] International Business Machines, Inc., "Virtual Machine System
       Facilities for Programming, Release 6", SC24-5288-01, 1988.

   [8] International Business Machines, Inc., "TCP/IP Version 1.1 for
       OS/2 EE:  Programmer's Reference", SC31-6077-1, 1990.

Security Considerations

   Security issues are not discussed in this memo.





















Carpenter & Wijnen                                             [Page 49]
^L
RFC 1228                        SNMP-DPI                        May 1991


Authors' Addresses

   Geoffrey C. Carpenter
   IBM T. J. Watson Research Center
   P. O. Box 218
   Yorktown Heights, NY  10598

   Phone:  (914) 945-1970

   Email:  gcc@watson.ibm.com


   Bert Wijnen
   IBM International Operations
   Watsonweg 2
   1423 ND Uithoorn
   The Netherlands

   Phone:  +31-2975-53316

   Email:  wijnen@uitvm2.iinus1.ibm.com






























Carpenter & Wijnen                                             [Page 50]
^L