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


/*
 * Copyright 1997 Purdue Research Foundation, West Lafayette, Indiana
 * 47907.  All rights reserved.
 *
 * Written by Victor A. Abell
 *
 * This software is not subject to any license of the American Telephone
 * and Telegraph Company or the Regents of the University of California.
 *
 * Permission is granted to anyone to use this software for any purpose on
 * any computer system, and to alter it and redistribute it freely, subject
 * to the following restrictions:
 *
 * 1. Neither the authors nor Purdue University are responsible for any
 *    consequences of the use of this software.
 *
 * 2. The origin of this software must not be misrepresented, either by
 *    explicit claim or by omission.  Credit to the authors and Purdue
 *    University must appear in documentation and sources.
 *
 * 3. Altered versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 *
 * 4. This notice may not be removed or altered.
 */

#ifndef lint
static char copyright[] =
"@(#) Copyright 1997 Purdue Research Foundation.\nAll rights reserved.\n";
static char *rcsid = "$Id: dsock.c,v 1.41 2015/07/07 19:46:33 abe Exp $";
#endif


#include "lsof.h"
#include <sys/xattr.h>


#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
/*
 * UNIX endpoint definitions
 */

#include <sys/socket.h>			/* for AF_NETLINK */
#include <linux/rtnetlink.h>		/* for NETLINK_INET_DIAG */
#include <linux/sock_diag.h>		/* for SOCK_DIAG_BY_FAMILY */
#include <linux/unix_diag.h>		/* for unix_diag_req */
#include <string.h>			/* memset */
#include <stdint.h>			/* for unt8_t */
#include <unistd.h>			/* for getpagesize */
#define SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */


/*
 * Local definitions
 */

#define	INOBUCKS	128		/* inode hash bucket count -- must be
					 * a power of two */
#define INOHASH(ino)	((int)((ino * 31415) >> 3) & (INOBUCKS - 1))
#define TCPUDPHASH(ino)	((int)((ino * 31415) >> 3) & (TcpUdp_bucks - 1))
#define TCPUDP6HASH(ino) ((int)((ino * 31415) >> 3) & (TcpUdp6_bucks - 1))


/*
 * Local structures
 */

struct ax25sin {			/* AX25 socket information */
	char *da;			/* destination address */
	char *dev_ch;			/* device characters */
	char *sa;			/* source address */
	INODETYPE inode;
	unsigned long sq, rq;		/* send and receive queue values */
	unsigned char sqs, rqs;		/* send and receive queue states */
	int state;
	struct ax25sin *next;
};

struct icmpin {
	INODETYPE inode;		/* node number */
	char *la;			/* local address */
	char *ra;			/* remote address */
	MALLOC_S lal;			/* strlen(la) */
	MALLOC_S ral;			/* strlen(ra) */
	struct icmpin *next;
};

struct ipxsin {				/* IPX socket information */
	INODETYPE inode;
	char *la;			/* local address */
	char *ra;			/* remote address */
	int state;
	unsigned long txq, rxq;		/* transmit and receive queue values */
	struct ipxsin *next;
};

struct nlksin {				/* Netlink socket information */
	INODETYPE inode;		/* node number */
	unsigned int pr;		/* protocol */
	struct nlksin *next;
};

struct packin {				/* packet information */
	INODETYPE inode;
	int ty;				/* socket type */
	int pr;				/* protocol */
	struct packin *next;
};

struct rawsin {				/* raw socket information */
	INODETYPE inode;
	char *la;			/* local address */
	char *ra;			/* remote address */
	char *sp;			/* state characters */
	MALLOC_S lal;			/* strlen(la) */
	MALLOC_S ral;			/* strlen(ra) */
	MALLOC_S spl;			/* strlen(sp) */
	struct rawsin *next;
};

struct sctpsin {			/* SCTP socket information */
	INODETYPE inode;
	int type;			/* type: 0 = assoc
					 *	 1 = eps
					 *	 2  assoc and eps */
	char *addr;			/* association or endpoint address */
	char *assocID;			/* association ID */
	char *lport;			/* local port */
	char *rport;			/* remote port */
	char *laddrs;			/* local address */
	char *raddrs;			/* remote address */
	struct sctpsin *next;
};

struct tcp_udp {			/* IPv4 TCP and UDP socket
					 * information */
	INODETYPE inode;
	unsigned long faddr, laddr;	/* foreign & local IPv6 addresses */
	int fport, lport;		/* foreign & local ports */
	unsigned long txq, rxq;		/* transmit & receive queue values */
	int proto;			/* 0 = TCP, 1 = UDP, 2 = UDPLITE */
	int state;			/* protocol state */
	struct tcp_udp *next;
};

#if	defined(HASIPv6)
struct tcp_udp6 {			/* IPv6 TCP and UDP socket
					 * information */
	INODETYPE inode;
	struct in6_addr faddr, laddr;	/* foreign and local IPv6 addresses */
	int fport, lport;		/* foreign & local ports */
	unsigned long txq, rxq;		/* transmit & receive queue values */
	int proto;			/* 0 = TCP, 1 = UDP, 2 = UDPLITE */
	int state;			/* protocol state */
	struct tcp_udp6 *next;
};
#endif	/* defined(HASIPv6) */


/*
 * Local static values
 */

static char *AX25path = (char *)NULL;	/* path to AX25 /proc information */
static struct ax25sin **AX25sin = (struct ax25sin **)NULL;
					/* AX25 socket info, hashed by inode */
static char *ax25st[] = {
	"LISTENING",			/* 0 */
	"SABM SENT",			/* 1 */
	"DISC SENT",			/* 2 */
	"ESTABLISHED",			/* 3 */
	"RECOVERY"			/* 4 */
};
#define NAX25ST	(sizeof(ax25st) / sizeof(char *))
static char *ICMPpath = (char *)NULL;	/* path to ICMP /proc information */
static struct icmpin **Icmpin = (struct icmpin **)NULL;
					/* ICMP socket info, hashed by inode */
static char *Ipxpath = (char *)NULL;	/* path to IPX /proc information */
static struct ipxsin **Ipxsin = (struct ipxsin **)NULL;
					/* IPX socket info, hashed by inode */
static char *Nlkpath = (char *)NULL;	/* path to Netlink /proc information */
static struct nlksin **Nlksin = (struct nlksin **)NULL;
					/* Netlink socket info, hashed by
					 * inode */
static struct packin **Packin = (struct packin **)NULL;
					/* packet info, hashed by inode */
static char *Packpath = (char *)NULL;	/* path to packet /proc information */
static char *Rawpath = (char *)NULL;	/* path to raw socket /proc
					 * information */
static struct rawsin **Rawsin = (struct rawsin **)NULL;
					/* raw socket info, hashed by inode */
static char *SCTPPath[] = {		/* paths to /proc/net STCP info */
	(char *)NULL,			/* 0 = /proc/net/sctp/assocs */
	(char *)NULL			/* 1 = /proc/net/sctp/eps */
};
#define	NSCTPPATHS sizeof(SCTPPath)/sizeof(char *)
static char *SCTPSfx[] = {		/* /proc/net suffixes */
	"sctp/assocs",			/* 0 = /proc/net/sctp/assocs */
	"sctp/eps"			/* 1 = /proc/net/sctp/eps */
};
static struct sctpsin **SCTPsin = (struct sctpsin **)NULL;
					/* SCTP info, hashed by inode */
static char *SockStatPath = (char *)NULL;
					/* path to /proc/net socket status */
static char *TCPpath = (char *)NULL;	/* path to TCP /proc information */
static struct tcp_udp **TcpUdp = (struct tcp_udp **)NULL;
					/* IPv4 TCP & UDP info, hashed by
					 * inode */
static int TcpUdp_bucks = 0;		/* dynamically sized hash bucket
					 * count for TCP and UDP -- will
					 * be a power of two */

#if	defined(HASIPv6)
static char *Raw6path = (char *)NULL;	/* path to raw IPv6 /proc information */
static struct rawsin **Rawsin6 = (struct rawsin **)NULL;
					/* IPv6 raw socket info, hashed by
					 * inode */
static char *SockStatPath6 = (char *)NULL;
					/* path to /proc/net IPv6 socket
					 * status */
static char *TCP6path = (char *)NULL;	/* path to IPv6 TCP /proc information */
static struct tcp_udp6 **TcpUdp6 = (struct tcp_udp6 **)NULL;
					/* IPv6 TCP & UDP info, hashed by
					 * inode */
static int TcpUdp6_bucks = 0;		/* dynamically sized hash bucket
					 * count for IPv6 TCP and UDP -- will
					 * be a power of two */
static char *UDP6path = (char *)NULL;	/* path to IPv6 UDP /proc information */
static char *UDPLITE6path = (char *)NULL;
					/* path to IPv6 UDPLITE /proc
					 * information */
#endif	/* defined(HASIPv6) */

static char *UDPpath = (char *)NULL;	/* path to UDP /proc information */
static char *UDPLITEpath = (char *)NULL;
					/* path to UDPLITE /proc information */
static char *UNIXpath = (char *)NULL;	/* path to UNIX /proc information */
static uxsin_t **Uxsin = (uxsin_t **)NULL;
					/* UNIX socket info, hashed by inode */


/*
 * Local function prototypes
 */

_PROTOTYPE(static struct ax25sin *check_ax25,(INODETYPE i));

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
_PROTOTYPE(static void enter_uxsinfo,(uxsin_t *up));
_PROTOTYPE(static void fill_uxicino,(INODETYPE si, INODETYPE sc));
_PROTOTYPE(static void fill_uxpino,(INODETYPE si, INODETYPE pi));
_PROTOTYPE(static int get_diagmsg,(int sockfd));
_PROTOTYPE(static void get_uxpeeri,(void));
_PROTOTYPE(static void parse_diag,(struct unix_diag_msg *dm, int len));
_PROTOTYPE(static void prt_uxs,(uxsin_t *p, int mk));
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

_PROTOTYPE(static struct icmpin *check_icmp,(INODETYPE i));
_PROTOTYPE(static struct ipxsin *check_ipx,(INODETYPE i));
_PROTOTYPE(static struct nlksin *check_netlink,(INODETYPE i));
_PROTOTYPE(static struct packin *check_pack,(INODETYPE i));
_PROTOTYPE(static struct rawsin *check_raw,(INODETYPE i));
_PROTOTYPE(static struct sctpsin *check_sctp,(INODETYPE i));
_PROTOTYPE(static struct tcp_udp *check_tcpudp,(INODETYPE i, char **p));
_PROTOTYPE(static uxsin_t *check_unix,(INODETYPE i));
_PROTOTYPE(static void get_ax25,(char *p));
_PROTOTYPE(static void get_icmp,(char *p));
_PROTOTYPE(static void get_ipx,(char *p));
_PROTOTYPE(static void get_netlink,(char *p));
_PROTOTYPE(static void get_pack,(char *p));
_PROTOTYPE(static void get_raw,(char *p));
_PROTOTYPE(static void get_sctp,(void));
_PROTOTYPE(static char *get_sctpaddrs,(char **fp, int i, int nf, int *x));
_PROTOTYPE(static void get_tcpudp,(char *p, int pr, int clr));
_PROTOTYPE(static void get_unix,(char *p));
_PROTOTYPE(static int isainb,(char *a, char *b));
_PROTOTYPE(static void print_ax25info,(struct ax25sin *ap));
_PROTOTYPE(static void print_ipxinfo,(struct ipxsin *ip));
_PROTOTYPE(static char *sockty2str,(uint32_t ty, int *rf));

#if	defined(HASIPv6)
_PROTOTYPE(static struct rawsin *check_raw6,(INODETYPE i));
_PROTOTYPE(static struct tcp_udp6 *check_tcpudp6,(INODETYPE i, char **p));
_PROTOTYPE(static void get_raw6,(char *p));
_PROTOTYPE(static void get_tcpudp6,(char *p, int pr, int clr));
_PROTOTYPE(static int net6a2in6,(char *as, struct in6_addr *ad));
#endif	/* defined(HASIPv6) */


/*
 * build_IPstates() -- build the TCP and UDP state tables
 */

void
build_IPstates()
{
	if (!TcpSt) {
	    (void) enter_IPstate("TCP", "ESTABLISHED", TCP_ESTABLISHED);
	    (void) enter_IPstate("TCP", "SYN_SENT", TCP_SYN_SENT);
	    (void) enter_IPstate("TCP", "SYN_RECV", TCP_SYN_RECV);
	    (void) enter_IPstate("TCP", "FIN_WAIT1", TCP_FIN_WAIT1);
	    (void) enter_IPstate("TCP", "FIN_WAIT2", TCP_FIN_WAIT2);
	    (void) enter_IPstate("TCP", "TIME_WAIT", TCP_TIME_WAIT);
	    (void) enter_IPstate("TCP", "CLOSE", TCP_CLOSE);
	    (void) enter_IPstate("TCP", "CLOSE_WAIT", TCP_CLOSE_WAIT);
	    (void) enter_IPstate("TCP", "LAST_ACK", TCP_LAST_ACK);
	    (void) enter_IPstate("TCP", "LISTEN", TCP_LISTEN);
	    (void) enter_IPstate("TCP", "CLOSING", TCP_CLOSING);
	    (void) enter_IPstate("TCP", "CLOSED", 0);
	    (void) enter_IPstate("TCP", (char *)NULL, 0);
	}
}


/*
 * check_ax25() - check for AX25 socket file
 */

static struct ax25sin *
check_ax25(i)
	INODETYPE i;			/* socket file's inode number */
{
	struct ax25sin *ap;
	int h;

	h = INOHASH(i);
	for (ap = AX25sin[h]; ap; ap = ap->next) {
	    if (i == ap->inode)
		return(ap);
	}
	return((struct ax25sin *)NULL);
}



/*
 * check_icmp() - check for ICMP socket
 */

static struct icmpin *
check_icmp(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct icmpin *icmpp;

	h = INOHASH(i);
	for (icmpp = Icmpin[h]; icmpp; icmpp = icmpp->next) {
	    if (i == icmpp->inode)
		return(icmpp);
	}
	return((struct icmpin *)NULL);
}


/*
 * check_ipx() - check for IPX socket file
 */

static struct ipxsin *
check_ipx(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct ipxsin *ip;

	h = INOHASH(i);
	for (ip = Ipxsin[h]; ip; ip = ip->next) {
	    if (i == ip->inode)
		return(ip);
	}
	return((struct ipxsin *)NULL);
}


/*
 * check_netlink() - check for Netlink socket file
 */

static struct nlksin *
check_netlink(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct nlksin *lp;

	h = INOHASH(i);
	for (lp = Nlksin[h]; lp; lp = lp->next) {
	    if (i == lp->inode)
		return(lp);
	}
	return((struct nlksin *)NULL);
}


/*
 * check_pack() - check for packet file
 */

static struct packin *
check_pack(i)
	INODETYPE i;			/* packet file's inode number */
{
	int h;
	struct packin *pp;

	h = INOHASH(i);
	for (pp = Packin[h]; pp; pp = pp->next) {
	    if (i == pp->inode)
		return(pp);
	}
	return((struct packin *)NULL);
}


/*
 * check_raw() - check for raw socket file
 */

static struct rawsin *
check_raw(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct rawsin *rp;

	h = INOHASH(i);
	for (rp = Rawsin[h]; rp; rp = rp->next) {
	    if (i == rp->inode)
		return(rp);
	}
	return((struct rawsin *)NULL);
}


/*
 * check_sctp() - check for SCTP socket file
 */

static struct sctpsin *
check_sctp(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct sctpsin *sp;

	h = INOHASH(i);
	for (sp = SCTPsin[h]; sp; sp = sp->next) {
	    if (i == sp->inode)
		return(sp);
	}
	return((struct sctpsin *)NULL);
}


/*
 * check_tcpudp() - check for IPv4 TCP or UDP socket file
 */

static struct tcp_udp *
check_tcpudp(i, p)
	INODETYPE i;			/* socket file's inode number */
	char **p;			/* protocol return */
{
	int h;
	struct tcp_udp *tp;

	h = TCPUDPHASH(i);
	for (tp = TcpUdp[h]; tp; tp = tp->next) {
	    if (i == tp->inode) {
		switch (tp->proto) {
		case 0:
		    *p = "TCP";
		    break;
		case 1:
		    *p = "UDP";
		    break;
		case 2:
		    *p = "UDPLITE";
		    break;
		default:
		   *p = "unknown";
		}
		return(tp);
	    }
	}
	return((struct tcp_udp *)NULL);
}


#if	defined(HASIPv6)
/*
 * check_raw6() - check for raw IPv6 socket file
 */

static struct rawsin *
check_raw6(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	struct rawsin *rp;

	h = INOHASH(i);
	for (rp = Rawsin6[h]; rp; rp = rp->next) {
	    if (i == rp->inode)
		return(rp);
	}
	return((struct rawsin *)NULL);
}


/*
 * check_tcpudp6() - check for IPv6 TCP or UDP socket file
 */

static struct tcp_udp6 *
check_tcpudp6(i, p)
	INODETYPE i;			/* socket file's inode number */
	char **p;			/* protocol return */
{
	int h;
	struct tcp_udp6 *tp6;

	h = TCPUDP6HASH(i);
	for (tp6 = TcpUdp6[h]; tp6; tp6 = tp6->next) {
	    if (i == tp6->inode) {
		switch (tp6->proto) {
		case 0:
		    *p = "TCP";
		    break;
		case 1:
		    *p = "UDP";
		    break;
		case 2:
		    *p = "UDPLITE";
		    break;
		default:
		   *p = "unknown";
		}
		return(tp6);
	    }
	}
	return((struct tcp_udp6 *)NULL);
}
#endif	/* defined(HASIPv6) */


/*
 * check_unix() - check for UNIX domain socket
 */

static uxsin_t *
check_unix(i)
	INODETYPE i;			/* socket file's inode number */
{
	int h;
	uxsin_t *up;

	h = INOHASH(i);
	for (up = Uxsin[h]; up; up = up->next) {
	    if (i == up->inode)
		return(up);
	}
	return((uxsin_t *)NULL);
}


/*
 * get_ax25() - get /proc/net/ax25 info
 */

static void
get_ax25(p)
	char *p;			/* /proc/net/ipx path */
{
	struct ax25sin *ap, *np;
	FILE *as;
	char buf[MAXPATHLEN], *da, *dev_ch, *ep, **fp, *sa;
	int h, nf;
	INODETYPE inode;
	unsigned long rq, sq, state;
	MALLOC_S len;
	unsigned char rqs, sqs;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
/*
 * Do second time cleanup or first time setup.
 */
	if (AX25sin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (ap = AX25sin[h]; ap; ap = np) {
		    np = ap->next;
		    if (ap->da)
			(void) free((FREE_P *)ap->da);
		    if (ap->dev_ch)
			(void) free((FREE_P *)ap->dev_ch);
		    if (ap->sa)
			(void) free((FREE_P *)ap->sa);
		    (void) free((FREE_P *)ap);
		}
		AX25sin[h] = (struct ax25sin *)NULL;
	    }
	} else {
	    AX25sin = (struct ax25sin **)calloc(INOBUCKS,
					      sizeof(struct ax25sin *));
	    if (!AX25sin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d AX25 hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct ax25sin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/ax25 file, assign a page size buffer to the stream,
 * and read it.  Store AX25 socket info in the AX25sin[] hash buckets.
 */
	if (!(as = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, as)) {
	    if ((nf = get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0)) < 24)
		continue;
	/*
	 * /proc/net/ax25 has no title line, a very poor deficiency in its
	 * implementation.
	 *
	 * The ax25_get_info() function in kern module .../net/ax25/af_ax25.c
	 * says the format of the lines in the file is:
	 *
	 *     magic dev src_addr dest_addr,digi1,digi2,.. st vs vr va t1 t1 \
	 *     t2  t2 t3 t3 idle idle n2 n2 rtt window paclen Snd-Q Rcv-Q \
	 *     inode
	 *
	 * The code in this function is forced to assume that format is in
	 * effect..
	 */

	/*
	 * Assemble the inode number and see if it has already been recorded.
	 * If it has, skip this line.
	 */
	    ep = (char *)NULL;
	    if (!fp[23] || !*fp[23]
	    ||  (inode = strtoull(fp[23], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH((INODETYPE)inode);
	    for (ap = AX25sin[h]; ap; ap = ap->next) {
		if (inode == ap->inode)
		    break;
	    }
	    if (ap)
		continue;
	/*
	 * Assemble the send and receive queue values and the state.
	 */
	    rq = sq = (unsigned long)0;
	    rqs = sqs = (unsigned char)0;
	    ep = (char *)NULL;
	    if (!fp[21] || !*fp[21]
	    ||  (sq = strtoul(fp[21], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	    sqs = (unsigned char)1;
	    ep = (char *)NULL;
	    if (!fp[22] || !*fp[22]
	    ||  (rq = strtoul(fp[22], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	    rqs = (unsigned char)1;
	    ep = (char *)NULL;
	    if (!fp[4] || !*fp[4]
	    ||  (state = strtoul(fp[4], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Allocate space for the destination address.
	 */
	    if (!fp[3] || !*fp[3])
		da = (char *)NULL;
	    else if ((len = strlen(fp[3]))) {
		if (!(da = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
		      "%s: can't allocate %d destination AX25 addr bytes: %s\n",
		      Pn, (int)(len + 1), fp[3]);
		    Exit(1);
		}
		(void) snpf(da, len + 1, "%s", fp[3]);
	    } else
		da = (char *)NULL;
	/*
	 * Allocate space for the source address.
	 */
	    if (!fp[2] || !*fp[2])
		sa = (char *)NULL;
	    else if ((len = strlen(fp[2]))) {
		if (!(sa = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d source AX25 address bytes: %s\n",
			Pn, (int)(len + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(sa, len + 1, "%s", fp[2]);
	    } else
		sa = (char *)NULL;
	/*
	 * Allocate space for the device characters.
	 */
	    if (!fp[1] || !*fp[1])
		dev_ch = (char *)NULL;
	    else if ((len = strlen(fp[1]))) {
		if (!(dev_ch = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
		      "%s: can't allocate %d destination AX25 dev bytes: %s\n",
		      Pn, (int)(len + 1), fp[1]);
		    Exit(1);
		}
		(void) snpf(dev_ch, len + 1, "%s", fp[1]);
	    } else
		dev_ch = (char *)NULL;
	/*
	 * Allocate space for an ax25sin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(ap = (struct ax25sin *)malloc(sizeof(struct ax25sin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte ax25sin structure\n",
		    Pn, (int)sizeof(struct ax25sin));
		Exit(1);
	    }
	    ap->da = da;
	    ap->dev_ch = dev_ch;
	    ap->inode = inode;
	    ap->rq = rq;
	    ap->rqs = rqs;
	    ap->sa = sa;
	    ap->sq = sq;
	    ap->sqs = sqs;
	    ap->state = (int)state;
	    ap->next = AX25sin[h];
	    AX25sin[h] = ap;
	}
	(void) fclose(as);
}


#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
/*
 * enter_uxsinfo() -- enter unix socket info
 * 	entry	Lf = local file structure pointer
 * 		Lp = local process structure pointer
 */

static void
enter_uxsinfo (up)
	uxsin_t *up;
{
	pxinfo_t *pi;			/* pxinfo_t structure pointer */
	struct lfile *lf;		/* local file structure pointer */
	struct lproc *lp;		/* local proc structure pointer */
	pxinfo_t *np;			/* new pxinfo_t structure pointer */

	for (pi = up->pxinfo; pi; pi = pi->next) {
	    lf = pi->lf;
	    lp = &Lproc[pi->lpx];
	    if (pi->ino == Lf->inode) {
		if ((lp->pid == Lp->pid) && !strcmp(lf->fd, Lf->fd))
		    return;
	    }
	}
	if (!(np = (pxinfo_t *)malloc(sizeof(pxinfo_t)))) {
	    (void) fprintf(stderr,
		"%s: no space for pipeinfo in uxsinfo, PID %d\n",
		Pn, Lp->pid);
	    Exit(1);
	}
	np->ino = Lf->inode;
	np->lf = Lf;
	np->lpx = Lp - Lproc;
	np->next = up->pxinfo;
	up->pxinfo = np;
}


/*
 * fill_uxicino() -- fill incoming connection inode number
 */

static void
fill_uxicino (si, ic)
	INODETYPE si;			/* UNIX socket inode number */
	INODETYPE ic;			/* incomining UNIX socket connection 
					 * inode number */
{
	uxsin_t *psi;			/* pointer to socket's information */
	uxsin_t *pic;			/* pointer to incoming connection's
					 * information */

	if ((psi = check_unix(si))) {
	    if (psi->icstat || psi->icons)
		return;
	    if ((pic = check_unix(ic))) {
		psi->icstat = 1;
		psi->icons = pic;
	    }
	}
}


/*
 * fill_uxpino() -- fill in UNIX socket's peer inode number
 */

static void
fill_uxpino(si, pi)
	INODETYPE si;		/* UNIX socket inode number */
	INODETYPE pi;		/* UNIX socket peer's inode number */
{
	uxsin_t *pp, *up;

	if ((up = check_unix(si))) {
	    if (!up->peer) {
		if (pp = check_unix(pi))
		    up->peer = pp;
	    }
	}
}


/*
 * find_uxepti(lf) -- find UNIX socket endpoint info
 */

uxsin_t *
find_uxepti(lf)
	struct lfile *lf;		/* pipe's lfile */
{
	uxsin_t *up;

	up = check_unix(lf->inode);
	return(up ? up->peer: (uxsin_t *)NULL);
}


/*
 * get_diagmsg() -- get UNIX socket's diag message
 */

static int
get_diagmsg(sockfd)
	int sockfd;			/* socket's file descriptor */
{
	struct msghdr msg;		/* message header */
	struct nlmsghdr nlh;		/* header length */
	struct unix_diag_req creq;	/* connection request */
	struct sockaddr_nl sa;		/* netlink socket address */
	struct iovec iov[2];		/* I/O vector */
/*
 * Build and send message to socket's file descriptor, asking for its
 * diagnostic message.
 */
	zeromem((char *)&msg, sizeof(msg));
	zeromem((char *)&sa, sizeof(sa));
	zeromem((char *)&nlh, sizeof(nlh));
	zeromem((char *)&creq, sizeof(creq));
	sa.nl_family = AF_NETLINK;
	creq.sdiag_family = AF_UNIX;
	creq.sdiag_protocol = 0;
	memset((void *)&creq.udiag_states, -1, sizeof(creq.udiag_states));
	creq.udiag_ino = (INODETYPE)0;
	creq.udiag_show = UDIAG_SHOW_PEER|UDIAG_SHOW_ICONS;
	nlh.nlmsg_len = NLMSG_LENGTH(sizeof(creq));
	nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
	nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY;
	iov[0].iov_base = (void *)&nlh;
	iov[0].iov_len = sizeof(nlh);
	iov[1].iov_base = (void *) &creq;
	iov[1].iov_len = sizeof(creq);
	msg.msg_name = (void *) &sa;
	msg.msg_namelen = sizeof(sa);
	msg.msg_iov = iov;
	msg.msg_iovlen = 2;
	return(sendmsg(sockfd, &msg, 0));
}


/*
 * get_uxpeeri() - get UNIX socket peer inode information 
 */

static void
get_uxpeeri()
{
	struct unix_diag_msg *dm;	/* pointer to diag message */
	struct nlmsghdr *hp;		/* netlink structure header pointer */
	int nb = 0;			/* number of bytes */
	int ns = 0;			/* netlink socket */
	uint8_t rb[SOCKET_BUFFER_SIZE];	/* receive buffer */
	int rl = 0;			/* route info length */
/*
 * Get a netlink socket.
 */
	if ((ns = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_SOCK_DIAG)) == -1) {
	    (void) fprintf(stderr, "%s: netlink socket error: %s\n",
		Pn, strerror(errno));
	    Exit(1);
	}
/*
 * Request peer information.
 */
	if (get_diagmsg(ns) < 0) {
	    (void) fprintf(stderr, "%s: netlink peer request error: %s\n",
		Pn, strerror(errno));
	    goto get_uxpeeri_exit;
	}
/*
 * Receive peer information.
 */
	while (1) {
	    if ((nb = recv(ns, rb, sizeof(rb), 0)) <= 0)
		goto get_uxpeeri_exit;
	    hp = (struct nlmsghdr *)rb;
	    while (NLMSG_OK(hp, nb)) {
		if(hp->nlmsg_type == NLMSG_DONE)
		    goto get_uxpeeri_exit;
		if(hp->nlmsg_type == NLMSG_ERROR) {
		    (void) fprintf(stderr,
			"%s: netlink UNIX socket msg peer info error\n", Pn);
		    goto get_uxpeeri_exit;
		}
		dm = (struct unix_diag_msg *)NLMSG_DATA(hp);
		rl = hp->nlmsg_len - NLMSG_LENGTH(sizeof(*dm));
		parse_diag(dm, rl);
		hp = NLMSG_NEXT(hp, nb);
	    }
	}

get_uxpeeri_exit:

	    (void) close(ns);
}


/*
 * parse_diag() -- parse UNIX diag message
 */

static void
parse_diag(dm, len)
	struct unix_diag_msg *dm;	/* pointer to diag message */
	int len;			/* message length */
{
	struct rtattr *rp;		/* route info pointer */
	int i;				/* tmporary index */
	int icct;			/* incoming connection count */
	uint32_t *icp;			/* incoming connection pointer */
	uint32_t inoc, inop;		/* inode numbers */

	if (!dm || (dm->udiag_family != AF_UNIX) || !(inop = dm->udiag_ino)
	||  (len <= 0)
	) {
	    return;
	}
	rp = (struct rtattr *)(dm + 1);
/*
 * Process route information.
 */
	while (RTA_OK(rp, len)) {
	    switch (rp->rta_type) {
	    case UNIX_DIAG_PEER:
		if (len < 4) {
		    (void) fprintf(stderr,
			"%s: unix_diag: msg length (%d) < 4)\n", Pn, len);
		    return;
		}
		if ((inoc = *(uint32_t *)RTA_DATA(rp))) {
		    fill_uxpino((INODETYPE)inop, (INODETYPE)inoc);
		    fill_uxpino((INODETYPE)inoc, (INODETYPE)inop);
		}
		break;
	    case UNIX_DIAG_ICONS:
		icct = RTA_PAYLOAD(rp), 
		icp = (uint32_t *)RTA_DATA(rp);

		for (i = 0; i < icct; i += sizeof(uint32_t), icp++) {
		    fill_uxicino((INODETYPE)inop, (INODETYPE)*icp);
		}
	    }
	    rp = RTA_NEXT(rp, len);
	}
}


/*
 * prt_uxs() -- print UNIX socket information
 */

static void
prt_uxs(p, mk)
	uxsin_t *p;			/* peer info */
	int mk;				/* 1 == mark for later processing */
{
	struct lproc *ep;		/* socket endpoint process */
	struct lfile *ef;		/* socket endpoint file */
	int i;				/* temporary index */
	int len;			/* string length */
	char nma[1024];			/* character buffer */
	pxinfo_t *pp;			/* previous pipe info of socket */

	(void) strcpy(nma, "->INO=");
	len = (int)strlen(nma);
	(void) snpf(&nma[len], sizeof(nma) - len - 1, InodeFmt_d, p->inode);
	(void) add_nma(nma, strlen(nma));
	for (pp = p->pxinfo; pp; pp = pp->next) {

	/*
	 * Add a linked socket's PID, command name and FD to the name column
	 * addition.
	 */
	    ep = &Lproc[pp->lpx];
	    ef = pp->lf;
	    for (i = 0; i < (FDLEN - 1); i++) {
		if (ef->fd[i] != ' ')
		    break;
	    }
	    (void) snpf(nma, sizeof(nma) - 1, "%d,%.*s,%s%c",
			ep->pid, CmdLim, ep->cmd, &ef->fd[i], ef->access);
	    (void) add_nma(nma, strlen(nma));
	    if (mk && FeptE == 2) {

	    /*
	     * Endpoint files have been selected, so mark this
	     * one for selection later.
	     */
		ef->chend = CHEND_UXS;
		ep->ept |= EPT_UXS_END;
	    }
	}
}


/*
 * process_uxsinfo() -- process UNIX socket information, adding it to selected
 *			UNIX socket files and selecting UNIX socket end point
 *			files (if requested)
 */

void
process_uxsinfo(f)
	int f;				/* function:
					 *     0 == process selected socket
					 *     1 == process socket end point
					 */
{
	uxsin_t *p;			/* peer UNIX socket info pointer */
	uxsin_t *tp;			/* temporary UNIX socket info pointer */

	if (!FeptE)
	    return;
	for (Lf = Lp->file; Lf; Lf = Lf->next) {
	    if (strcmp(Lf->type, "unix"))
		continue;
	    switch (f) {
	    case 0:

	    /*
	     * Process already selected socket.
	     */
		if (is_file_sel(Lp, Lf)) {

		/*
		 * This file has been selected by some criterion other than its
		 * being a socket.  Look up the socket's endpoints.
		 */
		    p = find_uxepti(Lf);
		    if (p && p->inode)
			prt_uxs(p, 1);
		    if ((tp = check_unix(Lf->inode))) {
			if (tp->icons) {
			    if (tp->icstat) {
				p = tp->icons;
				while (p != tp) {
				    if (p && p->inode)
					prt_uxs(p, 1);
				    p = p->icons;
				}
			    } else {
				for (p = tp->icons; !p->icstat; p = p->icons)
				    ; /* DO NOTHING */
				if (p->icstat && p->inode)
				    prt_uxs (p, 1);
			    }
			}
		    }
		}
		break;
	    case 1:
		if (!is_file_sel(Lp, Lf) && (Lf->chend & CHEND_UXS)) {

		/*
		 * This is an unselected end point UNIX socket file.  Select it
		 * and add its end point information to peer's name column
		 * addition.
		 */
		    Lf->sf = Selflags;
		    Lp->pss |= PS_SEC;
		    p = find_uxepti(Lf);
		    if (p && p->inode)
			prt_uxs(p, 0);
		    else if ((tp = check_unix(Lf->inode))) {
			if (tp->icons) {
			    if (tp->icstat) {
				p = tp->icons;
				while (p != tp) {
				    if (p  && p->inode)
					prt_uxs(p, 0);
				    p = p->icons;
				}
			    } else {
				for (p = tp->icons; !p->icstat; p = p->icons)
				    ; /* DO NOTHING */
				if (p->icstat && p->inode)
				    prt_uxs(p, 0);
			    }
			}
		    }
		}
		break;
	    }
	}
}
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */
 
 
/*
 * get_icmp() - get ICMP net info
 */

static void
get_icmp(p)
	char *p;			/* /proc/net/icmp path */
{
	char buf[MAXPATHLEN], *ep, **fp, *la, *ra;
	int fl = 1;
	int h;
	INODETYPE inode;
	struct icmpin *np, *icmpp;
	MALLOC_S lal, ral;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Icmpin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (icmpp = Icmpin[h]; icmpp; icmpp = np) {
		    np = icmpp->next;
		    (void) free((FREE_P *)icmpp);
		}
		Icmpin[h] = (struct icmpin *)NULL;
	    }
	} else {
	    Icmpin = (struct icmpin **)calloc(INOBUCKS,
					      sizeof(struct icmpin *));
	    if (!Icmpin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d icmp hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct icmpin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/icmp file, assign a page size buffer to its stream,
 * and read the file.  Store icmp info in the Icmpin[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < 11)
		continue;
	    if (fl) {

	    /*
	     * Check the column labels in the first line.
	     *
	     * NOTE:
	     *       In column header, "inode" is at the 11th column.
	     *       However, in data rows, inode appears at the 9th column.
	     *
	     *       In column header, "tx_queue" and "rx_queue" are separated
	     *       by a space.  It is the same for "tr" and "tm->when"; in
	     *       data rows they are connected with ":".
	     */
		if (!fp[1]  || strcmp(fp[1], "local_address")
		||  !fp[2]  || strcmp(fp[2], "rem_address")
		||  !fp[11] || strcmp(fp[11], "inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		fl = 0;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[9] || !*fp[9]
	    ||  (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (icmpp = Icmpin[h]; icmpp; icmpp = icmpp->next) {
		if (inode == icmpp->inode)
		    break;
	    }
	    if (icmpp)
		continue;
	/*
	 * Save the local address, and remote address.
	 */
	    if (!fp[1] || !*fp[1] || (lal = strlen(fp[1])) < 1) {
		la = (char *)NULL;
		lal = (MALLOC_S)0;
	    } else {
		if (!(la = (char *)malloc(lal + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d local icmp address bytes: %s\n",
			Pn, (int)(lal + 1), fp[1]);
		    Exit(1);
		}
		(void) snpf(la, lal + 1, "%s", fp[1]);
	    }
	    if (!fp[2] || !*fp[2] || (ral = strlen(fp[2])) < 1) {
		ra = (char *)NULL;
		ral = (MALLOC_S)0;
	    } else {
		if (!(ra = (char *)malloc(ral + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote icmp address bytes: %s\n",
			Pn, (int)(ral + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(ra, ral + 1, "%s", fp[2]);
	    }
	/*
	 * Allocate space for a icmpin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(icmpp = (struct icmpin *)malloc(sizeof(struct icmpin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte icmp structure\n",
		    Pn, (int)sizeof(struct icmpin));
		Exit(1);
	    }
	    icmpp->inode = inode;
	    icmpp->la = la;
	    icmpp->lal = lal;
	    icmpp->ra = ra;
	    icmpp->ral = ral;
	    icmpp->next = Icmpin[h];
	    Icmpin[h] = icmpp;
	}
	(void) fclose(xs);
}



/*
 * get_ipx() - get /proc/net/ipx info
 */

static void
get_ipx(p)
	char *p;			/* /proc/net/ipx path */
{
	char buf[MAXPATHLEN], *ep, **fp, *la, *ra;
	int fl = 1;
	int h;
	INODETYPE inode;
	unsigned long rxq, state, txq;
	struct ipxsin *ip, *np;
	MALLOC_S len;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Ipxsin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (ip = Ipxsin[h]; ip; ip = np) {
		    np = ip->next;
		    if (ip->la)
			(void) free((FREE_P *)ip->la);
		    if (ip->ra)
			(void) free((FREE_P *)ip->ra);
		    (void) free((FREE_P *)ip);
		}
		Ipxsin[h] = (struct ipxsin *)NULL;
	    }
	} else {
	    Ipxsin = (struct ipxsin **)calloc(INOBUCKS,
					      sizeof(struct ipxsin *));
	    if (!Ipxsin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d IPX hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct ipxsin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/ipx file, assign a page size buffer to the stream,
 * and read it.  Store IPX socket info in the Ipxsin[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < 7)
		continue;
	    if (fl) {

	    /*
	     * Check the column labels in the first line.
	     */
		if (!fp[0] || strcmp(fp[0], "Local_Address")
		||  !fp[1] || strcmp(fp[1], "Remote_Address")
		||  !fp[2] || strcmp(fp[2], "Tx_Queue")
		||  !fp[3] || strcmp(fp[3], "Rx_Queue")
		||  !fp[4] || strcmp(fp[4], "State")
		||  !fp[5] || strcmp(fp[5], "Uid")
		||  !fp[6] || strcmp(fp[6], "Inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		fl = 0;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[6] || !*fp[6]
	    ||  (inode = strtoull(fp[6], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (ip = Ipxsin[h]; ip; ip = ip->next) {
		if (inode == ip->inode)
		    break;
	    }
	    if (ip)
		continue;
	/*
	 * Assemble the transmit and receive queue values and the state.
	 */
	    ep = (char *)NULL;
	    if (!fp[2] || !*fp[2]
	    ||  (txq = strtoul(fp[2], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[3] || !*fp[3]
	    ||  (rxq = strtoul(fp[3], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[4] || !*fp[4]
	    ||  (state = strtoul(fp[4], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Allocate space for the local address, unless it is "Not_Connected".
	 */
	    if (!fp[0] || !*fp[0] || strcmp(fp[0], "Not_Connected") == 0)
		la = (char *)NULL;
	    else if ((len = strlen(fp[0]))) {
		if (!(la = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d local IPX address bytes: %s\n",
			Pn, (int)(len + 1), fp[0]);
		    Exit(1);
		}
		(void) snpf(la, len + 1, "%s", fp[0]);
	    } else
		la = (char *)NULL;
	/*
	 * Allocate space for the remote address, unless it is "Not_Connected".
	 */
	    if (!fp[1] || !*fp[1] || strcmp(fp[1], "Not_Connected") == 0)
		ra = (char *)NULL;
	    else if ((len = strlen(fp[1]))) {
		if (!(ra = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote IPX address bytes: %s\n",
			Pn, (int)(len + 1), fp[1]);
		    Exit(1);
		}
		(void) snpf(ra, len + 1, "%s", fp[1]);
	    } else
		ra = (char *)NULL;
	/*
	 * Allocate space for an ipxsin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(ip = (struct ipxsin *)malloc(sizeof(struct ipxsin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte ipxsin structure\n",
		    Pn, (int)sizeof(struct ipxsin));
		Exit(1);
	    }
	    ip->inode = inode;
	    ip->la = la;
	    ip->ra = ra;
	    ip->txq = txq;
	    ip->rxq = rxq;
	    ip->state = (int)state;
	    ip->next = Ipxsin[h];
	    Ipxsin[h] = ip;
	}
	(void) fclose(xs);
}

 
/*
 * get_netlink() - get /proc/net/netlink info
 */

static void
get_netlink(p)
	char *p;			/* /proc/net/netlink path */
{
	char buf[MAXPATHLEN], *ep, **fp;
	int fr = 1;
	int h, pr;
	INODETYPE inode;
	struct nlksin *np, *lp;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;	
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Nlksin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (lp = Nlksin[h]; lp; lp = np) {
		    np = lp->next;
		    (void) free((FREE_P *)lp);
		}
		Nlksin[h] = (struct nlksin *)NULL;
	    }
	} else {
	    Nlksin = (struct nlksin **)calloc(INOBUCKS,sizeof(struct nlksin *));
	    if (!Nlksin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d netlink hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct nlksin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/netlink file, assign a page size buffer to its stream,
 * and read the file.  Store Netlink info in the Nlksin[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < 10)
		continue;
	    if (fr) {

	    /*
	     * Check the column labels in the first line.
	     */
		if (!fp[1] || strcmp(fp[1], "Eth")
		||  !fp[9] || strcmp(fp[9], "Inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		fr = 0;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[9] || !*fp[9]
	    ||  (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (lp = Nlksin[h]; lp; lp = lp->next) {
		if (inode == lp->inode)
		    break;
	    }
	    if (lp)
		continue;
	/*
	 * Save the protocol from the Eth column.
	 */
	    if (!fp[1] || !*fp[1] || (strlen(fp[1])) < 1)
		continue;
	    pr = atoi(fp[1]);
	/*
	 * Allocate space for a nlksin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(lp = (struct nlksin *)malloc(sizeof(struct nlksin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte Netlink structure\n",
		    Pn, (int)sizeof(struct nlksin));
		Exit(1);
	    }
	    lp->inode = inode;
	    lp->pr = pr;
	    lp->next = Nlksin[h];
	    Nlksin[h] = lp;
	}
	(void) fclose(xs);
}


/*
 * get_pack() - get /proc/net/packet info
 */

static void
get_pack(p)
	char *p;			/* /proc/net/raw path */
{
	char buf[MAXPATHLEN], *ep, **fp;
	int fl = 1;
	int h, ty;
	INODETYPE inode;
	struct packin *np, *pp;
	unsigned long pr;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Packin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (pp = Packin[h]; pp; pp = np) {
		    np = pp->next;
		    (void) free((FREE_P *)pp);
		}
		Packin[h] = (struct packin *)NULL;
	    }
	} else {
	    Packin = (struct packin **)calloc(INOBUCKS,
					      sizeof(struct packin *));
	    if (!Packin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d packet hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct packin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/packet file, assign a page size buffer to its stream,
 * and read the file.  Store packet info in the Packin[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < 9)
		continue;
	    if (fl) {

	    /*
	     * Check the column labels in the first line.
	     */
		if (!fp[2]  || strcmp(fp[2], "Type")
		||  !fp[3]  || strcmp(fp[3], "Proto")
		||  !fp[8] || strcmp(fp[8], "Inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		fl = 0;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[8] || !*fp[8]
	    ||  (inode = strtoull(fp[8], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (pp = Packin[h]; pp; pp = pp->next) {
		if (inode == pp->inode)
		    break;
	    }
	    if (pp)
		continue;
	/*
	 * Save the socket type and protocol.
	 */
	    if (!fp[2] || !*fp[2] || (strlen(fp[2])) < 1)
		continue;
	    ty = atoi(fp[2]);
	    ep = (char *)NULL;
	    if (!fp[3] || !*fp[3] || (strlen(fp[3]) < 1)
	    ||  ((pr = strtoul(fp[3], &ep, 16)) == ULONG_MAX) || !ep || *ep)
		continue;
	/*
	 * Allocate space for a packin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(pp = (struct packin *)malloc(sizeof(struct packin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte packet structure\n",
		    Pn, (int)sizeof(struct packin));
		Exit(1);
	    }
	    pp->inode = inode;
	    pp->pr = (int)pr;
	    pp->ty = ty;
	    pp->next = Packin[h];
	    Packin[h] = pp;
	}
	(void) fclose(xs);
}


/*
 * get_raw() - get /proc/net/raw info
 */

static void
get_raw(p)
	char *p;			/* /proc/net/raw path */
{
	char buf[MAXPATHLEN], *ep, **fp, *la, *ra, *sp;
	int h;
	INODETYPE inode;
	int nf = 12;
	struct rawsin *np, *rp;
	MALLOC_S lal, ral, spl;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Rawsin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (rp = Rawsin[h]; rp; rp = np) {
		    np = rp->next;
		    if (rp->la)
			(void) free((FREE_P *)rp->la);
		    if (rp->ra)
			(void) free((FREE_P *)rp->ra);
		    (void) free((FREE_P *)rp);
		}
		Rawsin[h] = (struct rawsin *)NULL;
	    }
	} else {
	    Rawsin = (struct rawsin **)calloc(INOBUCKS,
					      sizeof(struct rawsin *));
	    if (!Rawsin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d raw hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct rawsin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/raw file, assign a page size buffer to its stream,
 * and read the file.  Store raw socket info in the Rawsin[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < nf)
		continue;
	    if (nf == 12) {

	    /*
	     * Check the column labels in the first line.
	     */
		if (!fp[1]  || strcmp(fp[1],  "local_address")
		||  !fp[2]  || strcmp(fp[2],  "rem_address")
		||  !fp[3]  || strcmp(fp[3],  "st")
		||  !fp[11] || strcmp(fp[11], "inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		nf = 10;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[9] || !*fp[9]
	    ||  (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (rp = Rawsin[h]; rp; rp = rp->next) {
		if (inode == rp->inode)
		    break;
	    }
	    if (rp)
		continue;
	/*
	 * Save the local address, remote address, and state.
	 */
	    if (!fp[1] || !*fp[1] || (lal = strlen(fp[1])) < 1) {
		la = (char *)NULL;
		lal = (MALLOC_S)0;
	    } else {
		if (!(la = (char *)malloc(lal + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d local raw address bytes: %s\n",
			Pn, (int)(lal + 1), fp[1]);
		    Exit(1);
		}
		(void) snpf(la, lal + 1, "%s", fp[1]);
	    }
	    if (!fp[2] || !*fp[2] || (ral = strlen(fp[2])) < 1) {
		ra = (char *)NULL;
		ral = (MALLOC_S)0;
	    } else {
		if (!(ra = (char *)malloc(ral + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote raw address bytes: %s\n",
			Pn, (int)(ral + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(ra, ral + 1, "%s", fp[2]);
	    }
	    if (!fp[3] || !*fp[3] || (spl = strlen(fp[3])) < 1) {
		sp = (char *)NULL;
		spl = (MALLOC_S)0;
	    } else {
		if (!(sp = (char *)malloc(spl + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote raw state bytes: %s\n",
			Pn, (int)(spl + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(sp, spl + 1, "%s", fp[3]);
	    }
	/*
	 * Allocate space for an rawsin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(rp = (struct rawsin *)malloc(sizeof(struct rawsin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte rawsin structure\n",
		    Pn, (int)sizeof(struct rawsin));
		Exit(1);
	    }
	    rp->inode = inode;
	    rp->la = la;
	    rp->lal = lal;
	    rp->ra = ra;
	    rp->ral = ral;
	    rp->sp = sp;
	    rp->spl = spl;
	    rp->next = Rawsin[h];
	    Rawsin[h] = rp;
	}
	(void) fclose(xs);
}


/*
 * get_sctp() - get /proc/net/sctp/assocs info
 */

static void
get_sctp()
{
	char buf[MAXPATHLEN], *a, *ep, **fp, *id, *la, *lp, *ra, *rp, *ta;
	int d, err, fl, h, i, j, nf, ty, x;
	INODETYPE inode;
	MALLOC_S len, plen;
	struct sctpsin *sp, *np;
	FILE *ss;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
/*
 * Do second time cleanup or first time setup.
 */
	if (SCTPsin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (sp = SCTPsin[h]; sp; sp = np) {
		    np = sp->next;
		    if (sp->addr)
			(void) free((FREE_P *)sp->addr);
		    if (sp->assocID)
			(void) free((FREE_P *)sp->assocID);
		    if (sp->lport)
			(void) free((FREE_P *)sp->lport);
		    if (sp->rport)
			(void) free((FREE_P *)sp->rport);
		    if (sp->laddrs)
			(void) free((FREE_P *)sp->laddrs);
		    if (sp->raddrs)
			(void) free((FREE_P *)sp->raddrs);
		    (void) free((FREE_P *)sp);
		}
		SCTPsin[h] = (struct sctpsin *)NULL;
	    }
	} else {
	    SCTPsin = (struct sctpsin **)calloc(INOBUCKS,
					      sizeof(struct sctpsin *));
	    if (!SCTPsin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d SCTP hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct sctpsin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/sctp files, assign a page size buffer to the streams,
 * and read them.  Store SCTP socket info in the SCTPsin[] hash buckets.
 */
	for (i = 0; i < NSCTPPATHS; i++ ) {
	    if (!(ss = open_proc_stream(SCTPPath[i], "r", &vbuf, &vsz, 0)))
		continue;
	    fl = 1;
	    while (fgets(buf, sizeof(buf) - 1, ss)) {
		if ((nf = get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0))
		<   (i ? 9 : 16)
		) {
		    continue;
		}
		if (fl) {

		/*
		 * Check the column labels in the first line.
		 */
		    err = 0;
		    switch (i) {
		    case 0:
			if (!fp[0]  || strcmp(fp[0],  "ASSOC")
			||  !fp[6]  || strcmp(fp[6],  "ASSOC-ID")
			||  !fp[10] || strcmp(fp[10], "INODE")
			||  !fp[11] || strcmp(fp[11], "LPORT")
			||  !fp[12] || strcmp(fp[12], "RPORT")
			||  !fp[13] || strcmp(fp[13], "LADDRS")
			||  !fp[14] || strcmp(fp[14], "<->")
			||  !fp[15] || strcmp(fp[15], "RADDRS")
			) {
			    err = 1;
			}
			break;
		    case 1:
			if (!fp[0]  || strcmp(fp[0],  "ENDPT")
			||  !fp[5]  || strcmp(fp[5],  "LPORT")
			||  !fp[7]  || strcmp(fp[7],  "INODE")
			||  !fp[8]  || strcmp(fp[8],  "LADDRS")
			) {
			    err = 1;
			}
		    }
		    if (err) {
			if (!Fwarn)
			    (void) fprintf(stderr,
				"%s: WARNING: unsupported format: %s\n",
				Pn, SCTPPath[i]);
			break;
		    }
		    fl = 0;
		    continue;
		}
	    /*
	     * Assemble the inode number and see if it has already been
	     * recorded.
	     */
		ep = (char *)NULL;
		j = i ? 7 : 10;
		if (!fp[j] || !*fp[j]
		||  (inode = strtoull(fp[j], &ep, 0)) == ULONG_MAX
		||  !ep || *ep)
		    continue;
		h = INOHASH((INODETYPE)inode);
		for (sp = SCTPsin[h]; sp; sp = sp->next) {
		    if (inode == sp->inode)
			break;
		}
	    /*
	     * Set the entry type.
	     */
		if (sp)
		    ty = (sp->type == i) ? i : 3;
		else
		    ty = i;
	    /*
	     * Allocate space for this line's sctpsin members.
	     *
	     * The association or endpoint address is in the first field.
	     */
		a = sp ? sp->addr : (char *)NULL;
		if (fp[0] && *fp[0] && (len = strlen(fp[0]))) {
		    if (a) {
			if (isainb(fp[0], a)) {
			    plen = strlen(a);
			    a = (char *)realloc((MALLOC_P *)a, plen + len + 2);
			    d = 0;
			} else
			    d = 1;
		    } else {
			plen = (MALLOC_S)0;
			a = (char *)malloc(len + 1);
			d = 0;
		    }
		    if (!a) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP ASSOC bytes: %s\n",
			  Pn, (int)(len + 1), fp[0]);
			Exit(1);
		    }
		    if (!d) {
			if (plen)
			    (void) snpf((a + plen), len + 2, ",%s", fp[0]);
			else
			    (void) snpf(a, len + 1, "%s", fp[0]);
		    }
		}
	    /*
	     * The association ID is in the seventh field.
	     */
		id = sp ? sp->assocID : (char *)NULL;
		if (!i && fp[6] && *fp[6] && (len = strlen(fp[6]))) {
		    if (id) {
			if (isainb(fp[6], id)) {
			    plen = strlen(id);
			    id = (char *)realloc((MALLOC_P *)id,plen+len+2);
			    d = 0;
			} else
			    d = 1;
		    } else {
			plen = (MALLOC_S)0;
			id = (char *)malloc(len + 1);
			d = 0;
		    }
		    if (!id) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP ASSOC-ID bytes: %s\n",
			  Pn, (int)(len + 1), fp[6]);
			Exit(1);
		    }
		    if (!d) {
			if (plen)
			    (void) snpf((id + plen), len + 2, ",%s", fp[6]);
			else
			    (void) snpf(id, len + 1, "%s", fp[6]);
		    }
		}
	    /*
	     * The field number for the local port depends on the entry type.
	     */
		j = i ? 5 : 11;
		lp = sp ? sp->lport : (char *)NULL;
		if (fp[j] && *fp[j] && (len = strlen(fp[j]))) {
		    if (lp) {
			if (isainb(fp[j], lp)) {
			    plen = strlen(lp);
			    lp = (char *)realloc((MALLOC_P *)lp,plen+len+2);
			    d = 0;
			} else
			    d = 1;
		    } else {
			plen = (MALLOC_S)0;
			lp = (char *)malloc(len + 1);
			d = 0;
		    }
		    if (!lp) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP LPORT bytes: %s\n",
			  Pn, (int)(len + 1), fp[j]);
			Exit(1);
		    }
		    if (!d) {
			if (plen)
			    (void) snpf((lp + plen), len + 2, ",%s", fp[j]);
			else
			    (void) snpf(lp, len + 1, "%s", fp[j]);
		    }
		}
	    /*
	     * The field number for the remote port depends on the entry type.
	     */
		rp = sp ? sp->rport : (char *)NULL;
		if (!i && fp[12] && *fp[12] && (len = strlen(fp[12]))) {
		    if (rp) {
			if (isainb(fp[12], rp)) {
			    plen = strlen(rp);
			    rp = (char *)realloc((MALLOC_P *)rp,plen+len+2);
			    d = 0;
			} else
			    d = 1;
		    } else {
			plen = (MALLOC_S)0;
			rp = (char *)malloc(len + 1);
			d = 0;
		    }
		    if (!rp) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP RPORT bytes: %s\n",
			  Pn, (int)(len + 1), fp[12]);
			Exit(1);
		    }
		    if (!d) {
			if (plen)
			    (void) snpf((rp + plen), len + 2, ",%s", fp[12]);
			else
			    (void) snpf(rp, len + 1, "%s", fp[12]);
		    }
		}
	    /*
	     * The local addresses begin in a field whose number depends on
	     * the entry type.
	     */
		j = i ? 8 : 13;
		la = sp ? sp->laddrs : (char *)NULL;
		if (fp[j] && *fp[j] && (len = strlen(fp[j]))) {
		    if (!(ta = get_sctpaddrs(fp, j, nf, &x))) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP LADDRS bytes\n",
			  Pn, (int)len);
			Exit(1);
		    }
		    if (la) {
			if (isainb(ta, la)) {
			    len = strlen(ta);
			    plen = strlen(la);
			    if (!(la=(char *)realloc((MALLOC_P *)la,plen+len+2))
			    ) {
				(void) fprintf(stderr,
				  "%s: can't reallocate %d SCTP LADDRS bytes\n",
				  Pn, (int)len);
				Exit(1);
			    }
			    (void) snpf(la + plen, len + 2, ",%s", ta);
			    (void) free((FREE_P *)ta);
			}
		    } else
			la = ta;
		}
	    /*
	     * The remote addresses begin after the local addresses, but only
	     * for the ASSOC type.
	     */
		ra = sp ? sp->raddrs : (char *)NULL;
		if (!i && x && fp[x+1] && *fp[x+1] && (len = strlen(fp[x+1]))) {
		    if (!(ta = get_sctpaddrs(fp, x + 1, nf, &x))) {
			(void) fprintf(stderr,
			  "%s: can't allocate %d SCTP RADDRS bytes\n",
			  Pn, (int)len);
			Exit(1);
		    }
		    if (ra) {
			if (isainb(ta, ra)) {
			    len = strlen(ta);
			    plen = strlen(ra);
			    if (!(ra=(char *)realloc((MALLOC_P *)ra,plen+len+2))
			    ) {
				(void) fprintf(stderr,
				  "%s: can't reallocate %d SCTP RADDRS bytes\n",
				  Pn, (int)len);
				Exit(1);
			    }
			    (void) snpf(ra + plen, len + 2, ",%s", ta);
			    (void) free((FREE_P *)ta);
			}
		    } else
			ra = ta;
		}
	    /*
	     * If no matching sctpsin entry was found for this inode, allocate
	     * space for a new sctpsin entry, fill it, and link it to its hash
	     * bucket.  Update a matching entry.
	     */
		if (!sp) {
		    if (!(sp = (struct sctpsin *)malloc(sizeof(struct sctpsin)))		    ) {
			(void) fprintf(stderr,
			    "%s: can't allocate %d byte sctpsin structure\n",
			    Pn, (int)sizeof(struct sctpsin));
			Exit(1);
		    }
		    sp->inode = inode;
		    sp->next = SCTPsin[h];
		    SCTPsin[h] = sp;
		}
		sp->addr = a;
		sp->assocID = id;
		sp->lport = lp;
		sp->rport = rp;
		sp->laddrs = la;
		sp->raddrs = ra;
		sp->type = ty;
	    }
	    (void) fclose(ss);
	}
}


static char *
get_sctpaddrs(fp, i, nf, x)
	char **fp;			/* field pointers */
	int i;				/* first address field index in fp */
	int nf;				/* number of fields */
	int *x;				/* index of first "<->" field entry */
{
	MALLOC_S al = (MALLOC_S)0;
	char *cp = (char *)NULL;
	MALLOC_S tl;

	*x = 0;
	do {
	    if ((i >= nf) || !fp[i] || !*fp[i] || !(tl = strlen(fp[i])))
		break;
	    if (!strcmp(fp[i], "<->")) {
		*x = i;
		break;
	    }
	    if (!strchr(fp[i], (int)'.') && !strchr(fp[i], (int)':'))
		break;
	    if (cp)
		cp = (char *)realloc((MALLOC_P *)cp, al + tl + 1);
	    else 
		cp = (char *)malloc(al + tl + 1);
	    if (!cp)
		break;
	    if (al)
		*(cp + al - 1) = ',';
	    (void) strncpy(al ? (cp + al) : cp, fp[i], tl);
	    al += (tl + 1);
	    *(cp + al - 1) = '\0';
	} while (++i < nf);
	return(cp);
}


/*
 * get_tcpudp() - get IPv4 TCP, UDP or UDPLITE net info
 */

static void
get_tcpudp(p, pr, clr)
	char *p;			/* /proc/net/{tcp,udp} path */
	int pr;				/* protocol: 0 = TCP, 1 = UDP,
					 *           2 = UDPLITE */
	int clr;			/* 1 == clear the table */
{
	char buf[MAXPATHLEN], *ep, **fp;
	unsigned long faddr, fport, laddr, lport, rxq, state, txq;
	FILE *fs;
	int h, nf;
	INODETYPE inode;
	struct tcp_udp *np, *tp;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
/*
 * Delete previous table contents.
 */
	if (TcpUdp) {
	    if (clr) {
		for (h = 0; h < TcpUdp_bucks; h++) {
		    for (tp = TcpUdp[h]; tp; tp = np) {
			np = tp->next;
			(void) free((FREE_P *)tp);
		    }
		    TcpUdp[h] = (struct tcp_udp *)NULL;
		}
	    }
/*
 * If no hash buckets have been allocated, do so now.
 */
	} else {
	
	/*
	 * Open the /proc/net/sockstat file and establish the hash bucket
	 * count from its "sockets: used" line.
	 */
	    TcpUdp_bucks = INOBUCKS;
	    if ((fs = fopen(SockStatPath, "r"))) {
		while (fgets(buf, sizeof(buf) - 1, fs)) {
		    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) != 3)
			continue;
		    if (!fp[0] || strcmp(fp[0], "sockets:")
		    ||  !fp[1] || strcmp(fp[1], "used")
		    ||  !fp[2] || !*fp[2])
			continue;
    		    if ((h = atoi(fp[2])) < 1)
			h = INOBUCKS;
		    while (TcpUdp_bucks < h)
			TcpUdp_bucks *= 2;
		    break;
		}
		(void) fclose(fs);
	    }
	    if (!(TcpUdp = (struct tcp_udp **)calloc(TcpUdp_bucks,
						     sizeof(struct tcp_udp *))))
	    {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for TCP&UDP hash buckets\n",
		    Pn, (int)(TcpUdp_bucks * sizeof(struct tcp_udp *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net file, assign a page size buffer to the stream, and
 * read it.
 */ 
	if (!(fs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	nf = 12;
	while (fgets(buf, sizeof(buf) - 1, fs)) {
	    if (get_fields(buf,
			   (nf == 12) ? (char *)NULL : ":",
			   &fp, (int *)NULL, 0)
	    < nf)
		continue;
	    if (nf == 12) {
		if (!fp[1]  || strcmp(fp[1],  "local_address")
		||  !fp[2]  || strcmp(fp[2],  "rem_address")
		||  !fp[3]  || strcmp(fp[3],  "st")
		||  !fp[4]  || strcmp(fp[4],  "tx_queue")
		||  !fp[5]  || strcmp(fp[5],  "rx_queue")
		||  !fp[11] || strcmp(fp[11], "inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		nf = 14;
		continue;
	    }
	/*
	 * Get the local and remote addresses.
	 */
	    ep = (char *)NULL;
	    if (!fp[1] || !*fp[1]
	    ||  (laddr = strtoul(fp[1], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[2] || !*fp[2]
	    ||  (lport = strtoul(fp[2], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[3] || !*fp[3]
	    ||  (faddr = strtoul(fp[3], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[4] || !*fp[4]
	    ||  (fport = strtoul(fp[4], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Get the state and queue sizes.
	 */
	    ep = (char *)NULL;
	    if (!fp[5] || !*fp[5]
	    ||  (state = strtoul(fp[5], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[6] || !*fp[6]
	    ||  (txq = strtoul(fp[6], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[7] || !*fp[7]
	    ||  (rxq = strtoul(fp[7], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Get the inode and use it for hashing and searching.
	 */
	    ep = (char *)NULL;
	    if (!fp[13] || !*fp[13]
	    ||  (inode = strtoull(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	    h = TCPUDPHASH(inode);
	    for (tp = TcpUdp[h]; tp; tp = tp->next) {
		if (tp->inode == inode)
		    break;
	    }
	    if (tp)
		continue;
	/*
	 * Create a new entry and link it to its hash bucket.
	 */
	    if (!(tp = (struct tcp_udp *)malloc(sizeof(struct tcp_udp)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for tcp_udp struct\n",
		    Pn, (int)sizeof(struct tcp_udp));
		Exit(1);
	    }
	    tp->inode = inode;
	    tp->faddr = faddr;
	    tp->fport = (int)(fport & 0xffff);
	    tp->laddr = laddr;
	    tp->lport = (int)(lport & 0xffff);
	    tp->txq = txq;
	    tp->rxq = rxq;
	    tp->proto = pr;
	    tp->state = (int)state;
	    tp->next = TcpUdp[h];
	    TcpUdp[h] = tp;
	}
	(void) fclose(fs);
}


#if	defined(HASIPv6)
/*
 * get_raw6() - get /proc/net/raw6 info
 */

static void
get_raw6(p)
	char *p;			/* /proc/net/raw path */
{
	char buf[MAXPATHLEN], *ep, **fp, *la, *ra, *sp;
	int h;
	INODETYPE inode;
	int nf = 12;
	struct rawsin *np, *rp;
	MALLOC_S lal, ral, spl;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
	FILE *xs;
/*
 * Do second time cleanup or first time setup.
 */
	if (Rawsin6) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (rp = Rawsin6[h]; rp; rp = np) {
		    np = rp->next;
		    if (rp->la)
			(void) free((FREE_P *)rp->la);
		    if (rp->ra)
			(void) free((FREE_P *)rp->ra);
		    (void) free((FREE_P *)rp);
		}
		Rawsin6[h] = (struct rawsin *)NULL;
	    }
	} else {
	    Rawsin6 = (struct rawsin **)calloc(INOBUCKS,
					       sizeof(struct rawsin *));
	    if (!Rawsin6) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d raw6 hash pointer bytes\n",
		    Pn, (int)(INOBUCKS * sizeof(struct rawsin *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net/raw6 file, assign a page size buffer to the stream,
 * and read it.  Store raw6 socket info in the Rawsin6[] hash buckets.
 */
	if (!(xs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, xs)) {
	    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) < nf)
		continue;
	    if (nf == 12) {

	    /*
	     * Check the column labels in the first line.
	     */
		if (!fp[1]  || strcmp(fp[1],  "local_address")
		||  !fp[2]  || strcmp(fp[2],  "remote_address")
		||  !fp[3]  || strcmp(fp[3],  "st")
		||  !fp[11] || strcmp(fp[11], "inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		nf = 10;
		continue;
	    }
	/*
	 * Assemble the inode number and see if the inode is already
	 * recorded.
	 */
	    ep = (char *)NULL;
	    if (!fp[9] || !*fp[9]
	    ||  (inode = strtoull(fp[9], &ep, 0)) == ULONG_MAX
	    ||  !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (rp = Rawsin6[h]; rp; rp = rp->next) {
		if (inode == rp->inode)
		    break;
	    }
	    if (rp)
		continue;
	/*
	 * Save the local address, remote address, and state.
	 */
	    if (!fp[1] || !*fp[1] || (lal = strlen(fp[1])) < 1) {
		la = (char *)NULL;
		lal = (MALLOC_S)0;
	    } else {
		if (!(la = (char *)malloc(lal + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d local raw6 address bytes: %s\n",
			Pn, (int)(lal + 1), fp[1]);
		    Exit(1);
		}
		(void) snpf(la, lal + 1, "%s", fp[1]);
	    }
	    if (!fp[2] || !*fp[2] || (ral = strlen(fp[2])) < 1) {
		ra = (char *)NULL;
		ral = (MALLOC_S)0;
	    } else {
		if (!(ra = (char *)malloc(ral + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote raw6 address bytes: %s\n",
			Pn, (int)(ral + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(ra, ral + 1, "%s", fp[2]);
	    }
	    if (!fp[3] || !*fp[3] || (spl = strlen(fp[3])) < 1) {
		sp = (char *)NULL;
		spl = (MALLOC_S)0;
	    } else {
		if (!(sp = (char *)malloc(spl + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d remote raw6 state bytes: %s\n",
			Pn, (int)(spl + 1), fp[2]);
		    Exit(1);
		}
		(void) snpf(sp, spl + 1, "%s", fp[3]);
	    }
	/*
	 * Allocate space for an rawsin entry, fill it, and link it to its
	 * hash bucket.
	 */
	    if (!(rp = (struct rawsin *)malloc(sizeof(struct rawsin)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d byte rawsin structure for IPv6\n",
		    Pn, (int)sizeof(struct rawsin));
		Exit(1);
	    }
	    rp->inode = inode;
	    rp->la = la;
	    rp->lal = lal;
	    rp->ra = ra;
	    rp->ral = ral;
	    rp->sp = sp;
	    rp->spl = spl;
	    rp->next = Rawsin6[h];
	    Rawsin6[h] = rp;
	}
	(void) fclose(xs);
}


/*
 * get_tcpudp6() - get IPv6 TCP, UDP or UDPLITE net info
 */

static void
get_tcpudp6(p, pr, clr)
	char *p;			/* /proc/net/{tcp,udp} path */
	int pr;				/* protocol: 0 = TCP, 1 = UDP */
	int clr;			/* 1 == clear the table */
{
	char buf[MAXPATHLEN], *ep, **fp;
	struct in6_addr faddr, laddr;
	unsigned long fport, lport, rxq, state, txq;
	FILE *fs;
	int h, i, nf;
	INODETYPE inode;
	struct tcp_udp6 *np6, *tp6;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;
/*
 * Delete previous table contents.  Allocate a table for the first time.
 */
	if (TcpUdp6) {
	    if (clr) {
		for (h = 0; h < TcpUdp6_bucks; h++) {
		    for (tp6 = TcpUdp6[h]; tp6; tp6 = np6) {
			np6 = tp6->next;
			(void) free((FREE_P *)tp6);
		    }
		    TcpUdp6[h] = (struct tcp_udp6 *)NULL;
		}
	    }
	} else {
	
	/*
	 * Open the /proc/net/sockstat6 file and establish the hash bucket
	 * count from its "TCP6: inuse" and "UDP6: inuse" lines.
	 */
	    TcpUdp6_bucks = INOBUCKS;
	    h = i = nf = 0;
	    if ((fs = fopen(SockStatPath6, "r"))) {
		while (fgets(buf, sizeof(buf) - 1, fs)) {
		    if (get_fields(buf, (char *)NULL, &fp, (int *)NULL, 0) != 3)
			continue;
		    if (!fp[0]
		    ||  !fp[1] || strcmp(fp[1], "inuse")
		    ||  !fp[2] || !*fp[2])
			continue;
		    if (!strcmp(fp[0], "TCP6:")) {
			nf |= 1;
    			if ((h = atoi(fp[2])) < 1)
			    h = INOBUCKS;
			i += h;
		    } else if (!strcmp(fp[0], "UDP6:")) {
			nf |= 2;
    			if ((h = atoi(fp[2])) < 1)
			    h = INOBUCKS;
			i += h;
		    } else
			continue;
		    if (nf == 3) {
			while (TcpUdp6_bucks < i)
			    TcpUdp6_bucks *= 2;
			break;
		    }
		}
		(void) fclose(fs);
	    }
	    if (!(TcpUdp6 = (struct tcp_udp6 **)calloc(TcpUdp6_bucks,
						sizeof(struct tcp_udp6 *))))
	    {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for TCP6&UDP6 hash buckets\n",
		    Pn, (int)(TcpUdp6_bucks * sizeof(struct tcp_udp6 *)));
		Exit(1);
	    }
	}
/*
 * Open the /proc/net file, assign a page size buffer to the stream,
 * and read it.
 */
	if (!(fs = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	nf = 12;
	while (fgets(buf, sizeof(buf) - 1, fs)) {
	    if (get_fields(buf,
			   (nf == 12) ? (char *)NULL : ":",
			   &fp, (int *)NULL, 0)
	    < nf)
		continue;
	    if (nf == 12) {
		if (!fp[1]  || strcmp(fp[1],  "local_address")
		||  !fp[2]  || strcmp(fp[2],  "remote_address")
		||  !fp[3]  || strcmp(fp[3],  "st")
		||  !fp[4]  || strcmp(fp[4],  "tx_queue")
		||  !fp[5]  || strcmp(fp[5],  "rx_queue")
		||  !fp[11] || strcmp(fp[11], "inode"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		nf = 14;
		continue;
	    }
	/*
	 * Get the local and remote addresses.
	 */
	    if (!fp[1] || !*fp[1] || net6a2in6(fp[1], &laddr))
		continue;
	    ep = (char *)NULL;
	    if (!fp[2] || !*fp[2]
	    ||  (lport = strtoul(fp[2], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    if (!fp[3] || !*fp[3] || net6a2in6(fp[3], &faddr))
		continue;
	    ep = (char *)NULL;
	    if (!fp[4] || !*fp[4]
	    ||  (fport = strtoul(fp[4], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Get the state and queue sizes.
	 */
	    ep = (char *)NULL;
	    if (!fp[5] || !*fp[5]
	    ||  (state = strtoul(fp[5], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[6] || !*fp[6]
	    ||  (txq = strtoul(fp[6], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	    ep = (char *)NULL;
	    if (!fp[7] || !*fp[7]
	    ||  (rxq = strtoul(fp[7], &ep, 16)) == ULONG_MAX || !ep || *ep)
		continue;
	/*
	 * Get the inode and use it for hashing and searching.
	 */
	    ep = (char *)NULL;
	    if (!fp[13] || !*fp[13]
	    ||  (inode = strtoull(fp[13], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	    h = TCPUDP6HASH(inode);
	    for (tp6 = TcpUdp6[h]; tp6; tp6 = tp6->next) {
		if (tp6->inode == inode)
		    break;
	    }
	    if (tp6)
		continue;
	/*
	 * Create a new entry and link it to its hash bucket.
	 */
	    if (!(tp6 = (struct tcp_udp6 *)malloc(sizeof(struct tcp_udp6)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for tcp_udp6 struct\n",
		    Pn, (int)sizeof(struct tcp_udp6));
		Exit(1);
	    }
	    tp6->inode = inode;
	    tp6->faddr = faddr;
	    tp6->fport = (int)(fport & 0xffff);
	    tp6->laddr = laddr;
	    tp6->lport = (int)(lport & 0xffff);
	    tp6->txq = txq;
	    tp6->rxq = rxq;
	    tp6->proto = pr;
	    tp6->state = (int)state;
	    tp6->next = TcpUdp6[h];
	    TcpUdp6[h] = tp6;
	}
	(void) fclose(fs);
}
#endif	/* defined(HASIPv6) */


/*
 * get_unix() - get UNIX net info
 */

static void
get_unix(p)
	char *p;			/* /proc/net/unix path */
{
	char buf[MAXPATHLEN], *ep, **fp, *path, *pcb;
	int fl = 1;
	int h, nf;
	INODETYPE inode;
	MALLOC_S len;
	uxsin_t *np, *up;
	FILE *us;
	uint32_t ty;
	static char *vbuf = (char *)NULL;
	static size_t vsz = (size_t)0;

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
	pxinfo_t *pp, *pnp;
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

/*
 * Do second time cleanup or first time setup.
 */
	if (Uxsin) {
	    for (h = 0; h < INOBUCKS; h++) {
		for (up = Uxsin[h]; up; up = np) {
		    np = up->next;

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
		    for (pp = up->pxinfo; pp; pp = pnp) {
		        pnp = pp->next;
		        (void) free((FREE_P *)pp);
		    }
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

		    if (up->path)
			(void) free((FREE_P *)up->path);
		    if (up->pcb)
			(void) free((FREE_P *)up->pcb);
		    (void) free((FREE_P *)up);
		}
		Uxsin[h] = (uxsin_t *)NULL;
	    }
	} else {
	    Uxsin = (uxsin_t **)calloc(INOBUCKS, sizeof(uxsin_t *));
	    if (!Uxsin) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for Unix socket info\n",
		    Pn, (int)(INOBUCKS * sizeof(uxsin_t *)));
	    }
	}
/*
 * Open the /proc/net/unix file, assign a page size buffer to the stream,
 * read the file's contents, and add them to the Uxsin hash buckets.
 */
	if (!(us = open_proc_stream(p, "r", &vbuf, &vsz, 0)))
	    return;
	while (fgets(buf, sizeof(buf) - 1, us)) {
	    if ((nf = get_fields(buf, ":", &fp, (int *)NULL, 0)) < 7)
		continue;
	    if (fl) {

	    /*
	     * Check the first line for header words.
	     */
		if (!fp[0] || strcmp(fp[0], "Num")
		||  !fp[1] || strcmp(fp[1], "RefCount")
		||  !fp[2] || strcmp(fp[2], "Protocol")
		||  !fp[3] || strcmp(fp[3], "Flags")
		||  !fp[4] || strcmp(fp[4], "Type")
		||  !fp[5] || strcmp(fp[5], "St")
		||  !fp[6] || strcmp(fp[6], "Inode")
		||  nf < 8
		||  !fp[7] || strcmp(fp[7], "Path"))
		{
		    if (!Fwarn) {
			(void) fprintf(stderr,
			    "%s: WARNING: unsupported format: %s\n",
			    Pn, p);
		    }
		    break;
		}
		fl = 0;
		continue;
	    }
	/*
	 * Assemble PCB address, inode number, and path name.  If this
	 * inode is already represented in Uxsin, skip it.
	 */
	    ep = (char *)NULL;
	    if (!fp[6] || !*fp[6]
	    ||  (inode = strtoull(fp[6], &ep, 0)) == ULONG_MAX || !ep || *ep)
		continue;
	    h = INOHASH(inode);
	    for (up = Uxsin[h]; up; up = up->next) {
		if (inode == up->inode)
		    break;
	    }
	    if (up)
		continue;
	    if (!fp[0] || !*fp[0])
		pcb = (char *)NULL;
	    else {
		len = strlen(fp[0]) + 2;
		if (!(pcb = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d bytes for UNIX PCB: %s\n",
			Pn, (int)(len + 1), fp[0]);
		    Exit(1);
		}
		(void) snpf(pcb, len + 1, "0x%s", fp[0]);
	    }
	    if (nf >= 8 && fp[7] && *fp[7] && (len = strlen(fp[7]))) {
		if (!(path = (char *)malloc(len + 1))) {
		    (void) fprintf(stderr,
			"%s: can't allocate %d bytes for UNIX path \"%s\"\n",
			Pn, (int)(len + 1), fp[7]);
		    Exit(1);
		}
		(void) snpf(path, len + 1, "%s", fp[7]);
	    } else
		path = (char *)NULL;
	/*
	 * Assemble socket type.
	 */
	    ep = (char *)NULL;
	    if (!fp[4] || !*fp[4]
	    ||  (ty = (uint32_t)strtoul(fp[4], &ep, 16)) == (uint32_t)UINT32_MAX
	    ||  !ep || *ep)
	    {
		ty = (uint32_t)UINT_MAX;
	    }
	/*
	 * Allocate and fill a Unix socket info structure; link it to its
	 * hash bucket.
	 */
	    if (!(up = (uxsin_t *)malloc(sizeof(uxsin_t)))) {
		(void) fprintf(stderr,
		    "%s: can't allocate %d bytes for uxsin struct\n",
		    Pn, (int)sizeof(uxsin_t));
		Exit(1);
	    }
	    up->inode = inode;
	    up->next = (uxsin_t *)NULL;
	    up->pcb = pcb;
	    up->sb_def = 0;
	    up->ty = ty;
	    if ((up->path = path) && (*path == '/')) {

	    /*
	     * If an absolute path (i.e., one that begins with a '/') exists
	     * for the line, attempt to stat(2) it and save the device and
	     * node numbers reported in the stat buffer.
	     */
		struct stat sb;
		int sr;

		if (HasNFS)
		    sr = statsafely(path, &sb);
		else
		    sr = stat(path, &sb);
		if (sr && ((sb.st_mode & S_IFMT) == S_IFSOCK)) {
		    up->sb_def = 1;
		    up->sb_dev = sb.st_dev;
		    up->sb_ino = (INODETYPE)sb.st_ino;
		    up->sb_rdev = sb.st_rdev;
		}
	    }

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
	/*
	 * Clean UNIX socket endpoint values.
	 */
	    up->icstat = 0;
	    up->pxinfo = (pxinfo_t *)NULL;
	    up->peer = up->icons = (uxsin_t *)NULL;
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

	    up->next = Uxsin[h];
	    Uxsin[h] = up;
	}

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
/*
 * If endpoint info has been requested, get UNIX socket peer info.
 */
	if (FeptE)
	    get_uxpeeri();
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

	(void) fclose(us);
}


#if	defined(HASIPv6)
/*
 * net6a2in6() - convert ASCII IPv6 address in /proc/net/{tcp,udp} form to
 *		 an in6_addr
 */

static int
net6a2in6(as, ad)
	char *as;			/* address source */
	struct in6_addr *ad;		/* address destination */
{
	char buf[9], *ep;
	int i;
	size_t len;
/*
 * Assemble four uint32_t's from 4 X 8 hex digits into s6_addr32[].
 */
	for (i = 0, len = strlen(as);
	     (i < 4) && (len >= 8);
	     as += 8, i++, len -= 8)
	{
	    (void) strncpy(buf, as, 8);
	    buf[8] = '\0';
	    ep = (char *)NULL;
	    if ((ad->s6_addr32[i] = (uint32_t)strtoul(buf, &ep, 16))
	    ==  (uint32_t)UINT32_MAX || !ep || *ep)
		break;
	}
	return((*as || (i != 4) || len) ? 1 : 0);
}
#endif	/* defined(HASIPv6) */


/*
 * isainb(a,b) is string a in string b
 */

static int
isainb(a, b)
	char *a;			/*string a */
	char *b;			/* string b */
{
	char *cp, *pp;
	MALLOC_S la, lb, lt;

	if (!a || !b)
	    return(1);
	if (!(la = strlen(a)) || !(lb = strlen(b)))
	    return(1);
	if (!(cp = strchr(b, (int)','))) {
	    if (la != lb)
		return(1);
	    return(strcmp(a, b));
	}
	for (pp = b; pp && *pp; ) {
	    lt = (MALLOC_S)(cp - pp);
	    if ((la == lt) && !strncmp(a, pp, lt))
		return(0);
	    if (*cp) {
		pp = cp + 1;
		if (!(cp = strchr(pp, (int)',')))
		    cp = b + lb;
	    } else
		pp = cp;
	}
	return(1);
}


/*
 * print_ax25info() - print AX25 socket info
 */

static void
print_ax25info(ap)
	struct ax25sin *ap;		/* AX25 socket info */
{
	char *cp, pbuf[1024];
	int ds;
	MALLOC_S pl = (MALLOC_S)0;

	if (Lf->nma)
	    return;
	if (ap->sa) {
	    ds = (ap->da && strcmp(ap->da, "*")) ? 1 : 0;
	    (void) snpf(&pbuf[pl], sizeof(pbuf) - pl, "%s%s%s ", ap->sa,
		ds ? "->" : "",
		ds ? ap->da : "");
	    pl = strlen(pbuf);
	}
	if (ap->sqs) {
	    (void) snpf(&pbuf[pl], sizeof(pbuf) - pl, "(Sq=%lu ", ap->sq);
	    pl = strlen(pbuf);
	    cp = "";
	} else 
	    cp = "(";
	if (ap->rqs) {
	    (void) snpf(&pbuf[pl], sizeof(pbuf) - pl, "%sRq=%lu ", cp, ap->rq);
	    pl = strlen(pbuf);
	    cp = "";
	}
	(void) snpf(&pbuf[pl], sizeof(pbuf) - pl, "%sState=%d", cp, ap->state);
	pl = strlen(pbuf);
	if ((ap->state >= 0) && (ap->state < NAX25ST))
	    cp = ax25st[ap->state];
	else
	    cp = NULL;
	(void) snpf(&pbuf[pl], sizeof(pbuf) - pl, "%s%s)",
	    cp ? ", " : "",
	    cp ? cp : "");
	pl = strlen(pbuf);
	if (!(cp = (char *)malloc(pl + 1))) {
	    (void) fprintf(stderr,
		"%s: can't allocate %d bytes for AX25 sock state, PID: %d\n",
		Pn, (int)(pl + 1), Lp->pid);
	    Exit(1);
	}
	(void) snpf(cp, pl + 1, "%s", pbuf);
	Lf->nma = cp;
}


/*
 * print_ipxinfo() - print IPX socket info
 */

static void
print_ipxinfo(ip)
	struct ipxsin *ip;		/* IPX socket info */
{
	char *cp, pbuf[256];
	MALLOC_S pl;

	if (Lf->nma)
	    return;
	(void) snpf(pbuf, sizeof(pbuf), "(Tx=%lx Rx=%lx State=%02x)",
	    ip->txq, ip->rxq, ip->state);
	pl = strlen(pbuf);
	if (!(cp = (char *)malloc(pl + 1))) {
	    (void) fprintf(stderr,
		"%s: can't allocate %d bytes for IPX sock state, PID: %d\n",
		Pn, (int)(pl + 1), Lp->pid);
	    Exit(1);
	}
	(void) snpf(cp, pl + 1, "%s", pbuf);
	Lf->nma = cp;
}


/*
 * print_tcptpi() - print TCP/TPI state
 */

void
print_tcptpi(nl)
	int nl;				/* 1 == '\n' required */
{
	char buf[128];
	char *cp = (char *)NULL;
	int ps = 0;
	int s;

	if ((Ftcptpi & TCPTPI_STATE) && Lf->lts.type == 0) {
	    if (!TcpSt)
		(void) build_IPstates();
	    if ((s = Lf->lts.state.i + TcpStOff) < 0 || s >= TcpNstates) {
		(void) snpf(buf, sizeof(buf), "UNKNOWN_TCP_STATE_%d",
		    Lf->lts.state.i);
		cp = buf;
    	    } else
		cp = TcpSt[s];
	    if (cp) {
		if (Ffield)
		    (void) printf("%cST=%s%c", LSOF_FID_TCPTPI, cp, Terminator);
		else {
		    putchar('(');
		    (void) fputs(cp, stdout);
		}
		ps++;
	    }
	}

# if	defined(HASTCPTPIQ)
	if (Ftcptpi & TCPTPI_QUEUES) {
	    if (Lf->lts.rqs) {
		if (Ffield)
		    putchar(LSOF_FID_TCPTPI);
		else {
		    if (ps)
			putchar(' ');
		    else
			putchar('(');
		}
		(void) printf("QR=%lu", Lf->lts.rq);
		if (Ffield)
		    putchar(Terminator);
		ps++;
	    }
	    if (Lf->lts.sqs) {
		if (Ffield)
		    putchar(LSOF_FID_TCPTPI);
		else {
		    if (ps)
			putchar(' ');
		    else
			putchar('(');
		}
		(void) printf("QS=%lu", Lf->lts.sq);
		if (Ffield)
		    putchar(Terminator);
		ps++;
	    }
	}
# endif	/* defined(HASTCPTPIQ) */

# if	defined(HASTCPTPIW)
	if (Ftcptpi & TCPTPI_WINDOWS) {
	    if (Lf->lts.rws) {
		if (Ffield)
		    putchar(LSOF_FID_TCPTPI);
		else {
		    if (ps)
			putchar(' ');
		    else
			putchar('(');
		}
		(void) printf("WR=%lu", Lf->lts.rw);
		if (Ffield)
		    putchar(Terminator);
		ps++;
	    }
	    if (Lf->lts.wws) {
		if (Ffield)
		    putchar(LSOF_FID_TCPTPI);
		else {
		    if (ps)
			putchar(' ');
		    else
			putchar('(');
		}
		(void) printf("WW=%lu", Lf->lts.ww);
		if (Ffield)
		    putchar(Terminator);
		ps++;
	    }
	}
# endif	/* defined(HASTCPTPIW) */

	if (!Ffield && ps)
	    putchar(')');
	if (nl)
	    putchar('\n');
}


/*
 * process_proc_sock() - process /proc-based socket
 */

void
process_proc_sock(p, pbr, s, ss, l, lss)
	char *p;			/* node's readlink() path */
	char *pbr;			/* node's path before readlink() */
	struct stat *s;			/* stat() result for path */
	int ss;				/* *s status -- i.e, SB_* values */
	struct stat *l;			/* lstat() result for FD (NULL for
					 * others) */
	int lss;			/* *l status -- i.e, SB_* values */
{
	struct ax25sin *ap;
	char *cp, *path = (char *)NULL, tbuf[64];
	unsigned char *fa, *la;
	struct in_addr fs, ls;
	struct icmpin *icmpp;
	struct ipxsin *ip;
	int i, len, nl, rf;
	struct nlksin *np;
	struct packin *pp;
	char *pr;
	static char *prp = (char *)NULL;
	struct rawsin *rp;
	struct sctpsin *sp;
	static ssize_t sz;
	struct tcp_udp *tp;
	uxsin_t *up;

#if	defined(HASIPv6)
	int af;
	struct tcp_udp6 *tp6;
#endif	/* defined(HASIPv6) */

/*
 * Enter offset, if possible.
 */
	if (Foffset || !Fsize) {
	    if (l && (lss & SB_SIZE) && OffType) {
		Lf->off = (SZOFFTYPE)l->st_size;
		Lf->off_def = 1;
	    }
	}
/*
 * Check for socket's inode presence in the protocol info caches.
 */
	if (AX25path) {
	    (void) get_ax25(AX25path);
	    (void) free((FREE_P *)AX25path);
	    AX25path = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (ap = check_ax25((INODETYPE)s->st_ino))
	) {
	
	/*
	 * The inode is connected to an AX25 /proc record.
	 *
	 * Set the type to "ax25"; save the device name; save the inode number;
	 * save the destination and source addresses; save the send and receive
	 * queue sizes; and save the connection state.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "ax25");
	    if (ap->dev_ch)
		(void) enter_dev_ch(ap->dev_ch);
	    Lf->inode = ap->inode;
	    Lf->inp_ty = 1;
	    print_ax25info(ap);
	    return;
	}
	if (Ipxpath) {
	    (void) get_ipx(Ipxpath);
	    (void) free((FREE_P *)Ipxpath);
	    Ipxpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (ip = check_ipx((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to an IPX /proc record.
	 *
	 * Set the type to "ipx"; enter the inode and device numbers; store
	 * the addresses, queue sizes, and state in the NAME column.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "ipx");
	    if (ss & SB_INO) {
		Lf->inode = (INODETYPE)s->st_ino;
		Lf->inp_ty = 1;
	    }
	    if (ss & SB_DEV) {
		Lf->dev = s->st_dev;
		Lf->dev_def = 1;
	    }
	    cp = Namech;
	    nl = Namechl;
	    *cp = '\0';
	    if (ip->la && nl) {

	    /*
	     * Store the local IPX address.
	     */
		len = strlen(ip->la);
		if (len > nl)
		    len = nl;
		(void) strncpy(cp, ip->la, len);
		cp += len;
		*cp = '\0';
		nl -= len;
	    }
	    if (ip->ra && nl) {

	    /*
	     * Store the remote IPX address, prefixed with "->".
	     */
		if (nl > 2) {
		    (void) snpf(cp, nl, "->");
		    cp += 2;
		    nl -= 2;
		}
		if (nl) {
		    (void) snpf(cp, nl, "%s", ip->ra);
		    cp += len;
		    nl -= len;
		}
	    }
	    (void) print_ipxinfo(ip);
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (Rawpath) {
	    (void) get_raw(Rawpath);
	    (void) free((FREE_P *)Rawpath);
	    Rawpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (rp = check_raw((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to a raw /proc record.
	 *
	 * Set the type to "raw"; enter the inode number; store the local
	 * address, remote address, and state in the NAME column.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "raw");
	    if (ss & SB_INO) {
		Lf->inode = (INODETYPE)s->st_ino;
		Lf->inp_ty = 1;
	    }
	    cp = Namech;
	    nl = Namechl - 2;
	    *cp = '\0';
	    if (rp->la && rp->lal) {

	    /*
	     * Store the local raw address.
	     */
		if (nl > rp->lal) {
		    (void) snpf(cp, nl, "%s", rp->la);
		    cp += rp->lal;
		    *cp = '\0';
		    nl -= rp->lal;
		}
	    }
	    if (rp->ra && rp->ral) {

	    /*
	     * Store the remote raw address, prefixed with "->".
	     */
		if (nl > (rp->ral + 2)) {
		    (void) snpf(cp, nl, "->%s", rp->ra);
		    cp += (rp->ral + 2);
		    *cp = '\0';
		    nl -= (rp->ral + 2);
		}
	    }
	    if (rp->sp && rp->spl) {

	    /*
	     * Store the state, optionally prefixed by a space, in the
	     * form "st=x...x".
	     */
	    
		if (nl > (len = ((cp == Namech) ? 0 : 1) + 3 + rp->spl)) {
		    (void) snpf(cp, nl, "%sst=%s",
			(cp == Namech) ? "" : " ", rp->sp);
		    cp += len;
		    *cp = '\0';
		    nl -= len;
		}
	    }
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (Nlkpath) {
	    (void) get_netlink(Nlkpath);
	    (void) free((FREE_P *) Nlkpath);
	    Nlkpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	    &&  (np = check_netlink((INODETYPE)s->st_ino))
	) {
	    /*
	     * The inode is connected to a Netlink /proc record.
	     *
	     * Set the type to "netlink" and store the protocol in the NAME
	     * column.  Save the inode number.
	     */

	    (void) snpf(Lf->type, sizeof(Lf->type), "netlink");
	    switch (np->pr) {

#if	defined(NETLINK_ROUTE)
	    case NETLINK_ROUTE:
		cp = "ROUTE";
		break;
#endif	/* defined(NETLINK_ROUTE) */

#if	defined(NETLINK_UNUSED)
	    case NETLINK_UNUSED:
		cp = "UNUSED";
		break;
#endif	/* defined(NETLINK_UNUSED) */

#if	defined(NETLINK_USERSOCK)
	    case NETLINK_USERSOCK:
		cp = "USERSOCK";
		break;
#endif	/* defined(NETLINK_USERSOCK) */

#if	defined(NETLINK_FIREWALL)
	    case NETLINK_FIREWALL:
		cp = "FIREWALL";
		break;
#endif	/* defined(NETLINK_FIREWALL) */

#if	defined(NETLINK_INET_DIAG)
	    case NETLINK_INET_DIAG:
		cp = "INET_DIAG";
		break;
#endif	/* defined(NETLINK_INET_DIAG) */

#if	defined(NETLINK_NFLOG)
	    case NETLINK_NFLOG:
		cp = "NFLOG";
		break;
#endif	/* defined(NETLINK_NFLOG) */

#if	defined(NETLINK_XFRM)
	    case NETLINK_XFRM:
		cp = "XFRM";
		break;
#endif	/* defined(NETLINK_XFRM) */

#if	defined(NETLINK_SELINUX)
	    case NETLINK_SELINUX:
		cp = "SELINUX";
		break;
#endif	/* defined(NETLINK_SELINUX) */

#if	defined(NETLINK_ISCSI)
	    case NETLINK_ISCSI:
		cp = "ISCSI";
		break;
#endif	/* defined(NETLINK_ISCSI) */

#if	defined(NETLINK_AUDIT)
	    case NETLINK_AUDIT:
		cp = "AUDIT";
		break;
#endif	/* defined(NETLINK_AUDIT) */

#if	defined(NETLINK_FIB_LOOKUP)
	    case NETLINK_FIB_LOOKUP:
		cp = "FIB_LOOKUP";
		break;
#endif	/* defined(NETLINK_FIB_LOOKUP) */

#if	defined(NETLINK_CONNECTOR)
	    case NETLINK_CONNECTOR:
		cp = "CONNECTOR";
		break;
#endif	/* defined(NETLINK_CONNECTOR) */

#if	defined(NETLINK_NETFILTER)
	    case NETLINK_NETFILTER:
		cp = "NETFILTER";
		break;
#endif	/* defined(NETLINK_NETFILTER) */

#if	defined(NETLINK_IP6_FW)
	    case NETLINK_IP6_FW:
		cp = "IP6_FW";
		break;
#endif	/* defined(NETLINK_IP6_FW) */

#if	defined(NETLINK_DNRTMSG)
	    case NETLINK_DNRTMSG:
		cp = "DNRTMSG";
		break;
#endif	/* defined(NETLINK_DNRTMSG) */

#if	defined(NETLINK_KOBJECT_UEVENT)
	    case NETLINK_KOBJECT_UEVENT:
		cp = "KOBJECT_UEVENT";
		break;
#endif	/* defined(NETLINK_KOBJECT_UEVENT) */

#if	defined(NETLINK_GENERIC)
	    case NETLINK_GENERIC:
		cp = "GENERIC";
		break;
#endif	/* defined(NETLINK_GENERIC) */

#if	defined(NETLINK_SCSITRANSPORT)
	    case NETLINK_SCSITRANSPORT:
		cp = "SCSITRANSPORT";
		break;
#endif	/* defined(NETLINK_SCSITRANSPORT) */

#if	defined(NETLINK_ECRYPTFS)
	    case NETLINK_ECRYPTFS:
		cp = "ECRYPTFS";
		break;
#endif	/* defined(NETLINK_ECRYPTFS) */

	    default:
		(void) snpf(Namech, Namechl, "unknown protocol: %d", np->pr);
		cp = (char *)NULL;
	    }
	    if (cp)
		(void) snpf(Namech, Namechl, "%s", cp);
	    Lf->inode = (INODETYPE)s->st_ino;
	    Lf->inp_ty = 1;
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (Packpath) {
	    (void) get_pack(Packpath);
	    (void) free((FREE_P *)Packpath);
	    Packpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (pp = check_pack((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to a packet /proc record.
	 *
	 * Set the type to "pack" and store the socket type in the NAME
	 * column.  Put the protocol name in the NODE column and the inode
	 * number in the DEVICE column.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "pack");
	    cp = sockty2str(pp->ty, &rf);
	    (void) snpf(Namech, Namechl, "type=%s%s", rf ? "" : "SOCK_", cp);
	    switch (pp->pr) {

#if	defined(ETH_P_LOOP)
	    case ETH_P_LOOP:
		cp = "LOOP";
		break;
#endif	/* defined(ETH_P_LOOP) */

#if	defined(ETH_P_PUP)
	    case ETH_P_PUP:
		cp = "PUP";
		break;
#endif	/* defined(ETH_P_PUP) */

#if	defined(ETH_P_PUPAT)
	    case ETH_P_PUPAT:
		cp = "PUPAT";
		break;
#endif	/* defined(ETH_P_PUPAT) */

#if	defined(ETH_P_IP)
	    case ETH_P_IP:
		cp = "IP";
		break;
#endif	/* defined(ETH_P_IP) */

#if	defined(ETH_P_X25)
	    case ETH_P_X25:
		cp = "X25";
		break;
#endif	/* defined(ETH_P_X25) */

#if	defined(ETH_P_ARP)
	    case ETH_P_ARP:
		cp = "ARP";
		break;
#endif	/* defined(ETH_P_ARP) */

#if	defined(ETH_P_BPQ)
	    case ETH_P_BPQ:
		cp = "BPQ";
		break;
#endif	/* defined(ETH_P_BPQ) */

#if	defined(ETH_P_IEEEPUP)
	    case ETH_P_IEEEPUP:
		cp = "I3EPUP";
		break;
#endif	/* defined(ETH_P_IEEEPUP) */

#if	defined(ETH_P_IEEEPUPAT)
	    case ETH_P_IEEEPUPAT:
		cp = "I3EPUPA";
		break;
#endif	/* defined(ETH_P_IEEEPUPAT) */

#if	defined(ETH_P_DEC)
	    case ETH_P_DEC:
		cp = "DEC";
		break;
#endif	/* defined(ETH_P_DEC) */

#if	defined(ETH_P_DNA_DL)
	    case ETH_P_DNA_DL:
		cp = "DNA_DL";
		break;
#endif	/* defined(ETH_P_DNA_DL) */

#if	defined(ETH_P_DNA_RC)
	    case ETH_P_DNA_RC:
		cp = "DNA_RC";
		break;
#endif	/* defined(ETH_P_DNA_RC) */

#if	defined(ETH_P_DNA_RT)
	    case ETH_P_DNA_RT:
		cp = "DNA_RT";
		break;
#endif	/* defined(ETH_P_DNA_RT) */

#if	defined(ETH_P_LAT)
	    case ETH_P_LAT:
		cp = "LAT";
		break;
#endif	/* defined(ETH_P_LAT) */

#if	defined(ETH_P_DIAG)
	    case ETH_P_DIAG:
		cp = "DIAG";
		break;
#endif	/* defined(ETH_P_DIAG) */

#if	defined(ETH_P_CUST)
	    case ETH_P_CUST:
		cp = "CUST";
		break;
#endif	/* defined(ETH_P_CUST) */

#if	defined(ETH_P_SCA)
	    case ETH_P_SCA:
		cp = "SCA";
		break;
#endif	/* defined(ETH_P_SCA) */

#if	defined(ETH_P_RARP)
	    case ETH_P_RARP:
		cp = "RARP";
		break;
#endif	/* defined(ETH_P_RARP) */

#if	defined(ETH_P_ATALK)
	    case ETH_P_ATALK:
		cp = "ATALK";
		break;
#endif	/* defined(ETH_P_ATALK) */

#if	defined(ETH_P_AARP)
	    case ETH_P_AARP:
		cp = "AARP";
		break;
#endif	/* defined(ETH_P_AARP) */

#if	defined(ETH_P_8021Q)
	    case ETH_P_8021Q:
		cp = "8021Q";
		break;
#endif	/* defined(ETH_P_8021Q) */

#if	defined(ETH_P_IPX)
	    case ETH_P_IPX:
		cp = "IPX";
		break;
#endif	/* defined(ETH_P_IPX) */

#if	defined(ETH_P_IPV6)
	    case ETH_P_IPV6:
		cp = "IPV6";
		break;
#endif	/* defined(ETH_P_IPV6) */

#if	defined(ETH_P_SLOW)
	    case ETH_P_SLOW:
		cp = "SLOW";
		break;
#endif	/* defined(ETH_P_SLOW) */
	
#if	defined(ETH_P_WCCP)
	    case ETH_P_WCCP:
		cp = "WCCP";
		break;
#endif	/* defined(ETH_P_WCCP) */

#if	defined(ETH_P_PPP_DISC)
	    case ETH_P_PPP_DISC:
		cp = "PPP_DIS";
		break;
#endif	/* defined(ETH_P_PPP_DISC) */

#if	defined(ETH_P_PPP_SES)
	    case ETH_P_PPP_SES:
		cp = "PPP_SES";
		break;
#endif	/* defined(ETH_P_PPP_SES) */

#if	defined(ETH_P_MPLS_UC)
	    case ETH_P_MPLS_UC:
		cp = "MPLS_UC";
		break;
#endif	/* defined(ETH_P_MPLS_UC) */

#if	defined(ETH_P_ATMMPOA)
	    case ETH_P_ATMMPOA:
		cp = "ATMMPOA";
		break;
#endif	/* defined(ETH_P_ATMMPOA) */

#if	defined(ETH_P_MPLS_MC)
	    case ETH_P_MPLS_MC:
		cp = "MPLS_MC";
		break;
#endif	/* defined(ETH_P_MPLS_MC) */

#if	defined(ETH_P_ATMFATE)
	    case ETH_P_ATMFATE:
		cp = "ATMFATE";
		break;
#endif	/* defined(ETH_P_ATMFATE) */

#if	defined(ETH_P_AOE)
	    case ETH_P_AOE:
		cp = "AOE";
		break;
#endif	/* defined(ETH_P_AOE) */

#if	defined(ETH_P_TIPC)
	    case ETH_P_TIPC:
		cp = "TIPC";
		break;
#endif	/* defined(ETH_P_TIPC) */

#if	defined(ETH_P_802_3)
	    case ETH_P_802_3:
		cp = "802.3";
		break;
#endif	/* defined(ETH_P_802_3) */

#if	defined(ETH_P_AX25)
	    case ETH_P_AX25:
		cp = "AX25";
		break;
#endif	/* defined(ETH_P_AX25) */

#if	defined(ETH_P_ALL)
	    case ETH_P_ALL:
		cp = "ALL";
		break;
#endif	/* defined(ETH_P_ALL) */

#if	defined(ETH_P_802_2)
	    case ETH_P_802_2:
		cp = "802.2";
		break;
#endif	/* defined(ETH_P_802_2) */

#if	defined(ETH_P_SNAP)
	    case ETH_P_SNAP:
		cp = "SNAP";
		break;
#endif	/* defined(ETH_P_SNAP) */

#if	defined(ETH_P_DDCMP)
	    case ETH_P_DDCMP:
		cp = "DDCMP";
		break;
#endif	/* defined(ETH_P_DDCMP) */

#if	defined(ETH_P_WAN_PPP)
	    case ETH_P_WAN_PPP:
		cp = "WAN_PPP";
		break;
#endif	/* defined(ETH_P_WAN_PPP) */

#if	defined(ETH_P_PPP_MP)
	    case ETH_P_PPP_MP:
		cp = "PPP MP";
		break;
#endif	/* defined(ETH_P_PPP_MP) */

#if	defined(ETH_P_LOCALTALK)
	    case ETH_P_LOCALTALK:
		cp = "LCLTALK";
		break;
#endif	/* defined(ETH_P_LOCALTALK) */

#if	defined(ETH_P_PPPTALK)
	    case ETH_P_PPPTALK:
		cp = "PPPTALK";
		break;
#endif	/* defined(ETH_P_PPPTALK) */

#if	defined(ETH_P_TR_802_2)
	    case ETH_P_TR_802_2:
		cp = "802.2";
		break;
#endif	/* defined(ETH_P_TR_802_2) */

#if	defined(ETH_P_MOBITEX)
	    case ETH_P_MOBITEX:
		cp = "MOBITEX";
		break;
#endif	/* defined(ETH_P_MOBITEX) */

#if	defined(ETH_P_CONTROL)
	    case ETH_P_CONTROL:
		cp = "CONTROL";
		break;
#endif	/* defined(ETH_P_CONTROL) */

#if	defined(ETH_P_IRDA)
	    case ETH_P_IRDA:
		cp = "IRDA";
		break;
#endif	/* defined(ETH_P_IRDA) */

#if	defined(ETH_P_ECONET)
	    case ETH_P_ECONET:
		cp = "ECONET";
		break;
#endif	/* defined(ETH_P_ECONET) */

#if	defined(ETH_P_HDLC)
	    case ETH_P_HDLC:
		cp = "HDLC";
		break;
#endif	/* defined(ETH_P_HDLC) */

#if	defined(ETH_P_ARCNET)
	    case ETH_P_ARCNET:
		cp = "ARCNET";
		break;
#endif	/* defined(ETH_P_ARCNET) */

	    default:
		(void) snpf(tbuf, sizeof(tbuf) - 1, "%d", pp->pr);
		tbuf[sizeof(tbuf) - 1] = '\0';
		cp = tbuf;
	    }
	    (void) snpf(Lf->iproto, sizeof(Lf->iproto), "%.*s", IPROTOL-1, cp);
	    Lf->inp_ty = 2;
	    if (ss & SB_INO) {
		(void) snpf(tbuf, sizeof(tbuf), InodeFmt_d,
		    (INODETYPE)s->st_ino);
		tbuf[sizeof(tbuf) - 1] = '\0';
		enter_dev_ch(tbuf);
	    }
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (UNIXpath) {
	    (void) get_unix(UNIXpath);
	    (void) free((FREE_P *)UNIXpath);
	    UNIXpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (up = check_unix((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to a UNIX /proc record.
	 *
	 * Set the type to "unix"; enter the PCB address in the DEVICE column;
	 * enter the inode number; and save the optional path.
	 */
	    if (Funix)
		Lf->sf |= SELUNX;
	    (void) snpf(Lf->type, sizeof(Lf->type), "unix");
	    if (up->pcb)
		enter_dev_ch(up->pcb);
	    if (ss & SB_INO) {
		Lf->inode = (INODETYPE)s->st_ino;
		Lf->inp_ty = 1;
	    }

#if	defined(HASEPTOPTS) && defined(HASUXSOCKEPT)
	    if (FeptE) {
		(void) enter_uxsinfo(up);
		Lf->sf |= SELUXSINFO;
	    }
#endif	/* defined(HASEPTOPTS) && defined(HASUXSOCKEPT) */

	    cp = sockty2str(up->ty, &rf);
	    (void) snpf(Namech, Namechl - 1, "%s%stype=%s",
		up->path ? up->path : "",
		up->path ? " " : "",
		cp);
	    Namech[Namechl - 1] = '\0';
	    (void) enter_nm(Namech);
	    if (Sfile) {
	    
	    /*
	     * See if this UNIX domain socket was specified as a search
	     * argument.
	     *
	     * Search first by device and node numbers, if that is possible;
	     * then search by name.
	     */
		unsigned char f = 0;		/* file-found flag */

		if (up->sb_def) {

		/*
		 * If the UNIX socket information includes stat(2) results, do
		 * a device and node number search.
		 *
		 * Note: that requires the saving, temporary modification and
		 *	 restoration of some *Lf values.
		 */
		    unsigned char sv_dev_def;	/* saved dev_def */
		    unsigned char sv_inp_ty;	/* saved inp_ty */
		    unsigned char sv_rdev_def;	/* saved rdev_def */
		    dev_t sv_dev;		/* saved dev */
		    INODETYPE sv_inode;		/* saved inode */
		    dev_t sv_rdev;		/* saved rdev */

		    sv_dev_def = Lf->dev_def;
		    sv_dev = Lf->dev;
		    sv_inode = Lf->inode;
		    sv_inp_ty = Lf->inp_ty;
		    sv_rdev_def = Lf->rdev_def;
		    sv_rdev = Lf->rdev;
		    Lf->dev_def = Lf->inp_ty = Lf->rdev_def = 1;
		    Lf->dev = up->sb_dev;
		    Lf->inode = up->sb_ino;
		    Lf->rdev = up->sb_rdev;
		    if (is_file_named(0, path, (struct mounts *)NULL, 0)) {
			f = 1;
			Lf->sf |= SELNM;
		    }
		    Lf->dev_def = sv_dev_def;
		    Lf->dev = sv_dev;
		    Lf->inode = sv_inode;
		    Lf->inp_ty = sv_inp_ty;
		    Lf->rdev_def = sv_rdev_def;
		    Lf->rdev = sv_rdev;
		}
		if (!f && (ss & SB_MODE)) {

		/*
		 * If the file has not yet been found and the stat buffer has
		 * st_mode, search for the file by full path.
		 */
		    if (is_file_named(2, up->path ? up->path : p,
			(struct mounts *)NULL,
			((s->st_mode & S_IFMT) == S_IFCHR)) ? 1 : 0)
		    {
			Lf->sf |= SELNM;
		    }
		}
	    }
	    return;
	}

#if	defined(HASIPv6)
	if (Raw6path) {
	    if (!Fxopt)
		(void) get_raw6(Raw6path);
	    (void) free((FREE_P *)Raw6path);
	    Raw6path = (char *)NULL;
	}
	if (!Fxopt && (ss & SB_INO)
	&&  (rp = check_raw6((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to a raw IPv6 /proc record.
	 *
	 * Set the type to "raw6"; enter the inode number; store the local
	 * address, remote address, and state in the NAME column.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "raw6");
	    if (ss & SB_INO) {
		Lf->inode = (INODETYPE)s->st_ino;
		Lf->inp_ty = 1;
	    }
	    cp = Namech;
	    nl = MAXPATHLEN - 2;
	    if (rp->la && rp->lal) {

	    /*
	     * Store the local raw IPv6 address.
	     */
		if (nl > rp->lal) {
		    (void) snpf(cp, nl, "%s", rp->la);
		    cp += rp->lal;
		    *cp = '\0';
		    nl -= rp->lal;
		}
	    }
	    if (rp->ra && rp->ral) {

	    /*
	     * Store the remote raw address, prefixed with "->".
	     */
		if (nl > (rp->ral + 2)) {
		    (void) snpf(cp, nl, "->%s", rp->ra);
		    cp += (rp->ral + 2);
		    nl -= (rp->ral + 2);
		}
	    }
	    if (rp->sp && rp->spl) {

	    /*
	     * Store the state, optionally prefixed by a space, in the
	     * form "st=x...x".
	     */
	    
		if (nl > (len = ((cp == Namech) ? 0 : 1) + 3 + rp->spl)) {
		    (void) snpf(cp, nl, "%sst=%s",
			(cp == Namech) ? "" : " ", rp->sp);
		    cp += len;
		    *cp = '\0';
		    nl -= len;
		}
	    }
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (TCP6path) {
	    if (!Fxopt)
		(void) get_tcpudp6(TCP6path, 0, 1);
	    (void) free((FREE_P *)TCP6path);
	    TCP6path = (char *)NULL;
	}
	if (UDP6path) {
	    if (!Fxopt)
		(void) get_tcpudp6(UDP6path, 1, 0);
	    (void) free((FREE_P *)UDP6path);
	    UDP6path = (char *)NULL;
	}
	if (UDPLITE6path) {
	    if (!Fxopt)
		(void) get_tcpudp6(UDPLITE6path, 2, 0);
	    (void) free((FREE_P *)UDPLITE6path);
	    UDPLITE6path = (char *)NULL;
	}
	if (!Fxopt && (ss & SB_INO)
	&&  (tp6 = check_tcpudp6((INODETYPE)s->st_ino, &pr))
	) {

	/*
	 * The inode is connected to an IPv6 TCP or UDP /proc record.
	 *
	 * Set the type to "IPv6"; enter the protocol; put the inode number
	 * in the DEVICE column in lieu of the PCB address; save the local
	 * and foreign IPv6 addresses; save the type and protocol; and
	 * (optionally) save the queue sizes.
	 */
	    i = tp6->state + TcpStOff;
	    if (TcpStXn) {

	    /*
	     * Check for state exclusion.
	     */
		if (i >= 0 && i < TcpNstates) {
		    if (TcpStX[i]) {
			Lf->sf |= SELEXCLF;
			return;
		    }
		}
	    }
	    if (TcpStIn) {

	    /*
	     * Check for state inclusion.
	     */
		if (i >= 0 && i < TcpNstates) {
		    if (TcpStI[i])
			TcpStI[i] = 2;
		    else {
			Lf->sf |= SELEXCLF;
			return;
		   }
		}
	    }
	    if (Fnet && (FnetTy != 4))
		Lf->sf |= SELNET;
	    (void) snpf(Lf->type, sizeof(Lf->type), "IPv6");
	    (void) snpf(Lf->iproto, sizeof(Lf->iproto), "%.*s", IPROTOL-1, pr);
	    Lf->inp_ty = 2;
	    if (ss & SB_INO) {
		(void) snpf(tbuf, sizeof(tbuf), InodeFmt_d,
		    (INODETYPE)s->st_ino);
		tbuf[sizeof(tbuf) - 1] = '\0';
		enter_dev_ch(tbuf);
	    }
	    af = AF_INET6;
	    if (!IN6_IS_ADDR_UNSPECIFIED(&tp6->faddr) || tp6->fport)
		fa = (unsigned char *)&tp6->faddr;
	    else
		fa = (unsigned char *)NULL;
	    if (!IN6_IS_ADDR_UNSPECIFIED(&tp6->laddr) || tp6->lport)
		la = (unsigned char *)&tp6->laddr;
	    else
		la = (unsigned char *)NULL;
	    if ((fa && IN6_IS_ADDR_V4MAPPED(&tp6->faddr))
	    ||  (la && IN6_IS_ADDR_V4MAPPED(&tp6->laddr))) {
		af = AF_INET;
		if (fa)
		    fa += 12;
		if (la)
		    la += 12;
	    }
	    ent_inaddr(la, tp6->lport, fa, tp6->fport, af);
	    Lf->lts.type = tp6->proto;
	    Lf->lts.state.i = tp6->state;

#if     defined(HASTCPTPIQ)
	    Lf->lts.rq = tp6->rxq;
	    Lf->lts.sq = tp6->txq;
	    Lf->lts.rqs = Lf->lts.sqs = 1;
#endif  /* defined(HASTCPTPIQ) */

	    return;
	}
#endif	/* defined(HASIPv6) */

	if (TCPpath) {
	    if (!Fxopt)
		(void) get_tcpudp(TCPpath, 0, 1);
	    (void) free((FREE_P *)TCPpath);
	    TCPpath = (char *)NULL;
	}
	if (UDPpath) {
	    if (!Fxopt)
		(void) get_tcpudp(UDPpath, 1, 0);
	    (void) free((FREE_P *)UDPpath);
	    UDPpath = (char *)NULL;
	}
	if (UDPLITEpath) {
	    if (!Fxopt)
		(void) get_tcpudp(UDPLITEpath, 2, 0);
	    (void) free((FREE_P *)UDPLITEpath);
	    UDPLITEpath = (char *)NULL;
	}
	if (!Fxopt && (ss & SB_INO)
	&&  (tp = check_tcpudp((INODETYPE)s->st_ino, &pr))
	) {

	/*
	 * The inode is connected to an IPv4 TCP or UDP /proc record.
	 *
	 * Set the type to "inet" or "IPv4"; enter the protocol; put the
	 * inode number in the DEVICE column in lieu of the PCB address;
	 * save the local and foreign IPv4 addresses; save the type and
	 * protocol; and (optionally) save the queue sizes.
	 */
	    i = tp->state + TcpStOff;
	    if (TcpStXn) {

	    /*
	     * Check for state exclusion.
	     */
		if (i >= 0 && i < TcpNstates) {
		    if (TcpStX[i]) {
			Lf->sf |= SELEXCLF;
			return;
		    }
		}
	    }
	    if (TcpStIn) {

	    /*
	     * Check for state inclusion.
	     */
		if (i >= 0 && i < TcpNstates) {
		    if (TcpStI[i])
			TcpStI[i] = 2;
		    else {
			Lf->sf |= SELEXCLF;
			return;
		    }
		}
	    }
	    if (Fnet && (FnetTy != 6))
		Lf->sf |= SELNET;

#if	defined(HASIPv6)
	    (void) snpf(Lf->type, sizeof(Lf->type), "IPv4");
#else	/* !defined(HASIPv6) */
	    (void) snpf(Lf->type, sizeof(Lf->type), "inet");
#endif	/* defined(HASIPv6) */

	    (void) snpf(Lf->iproto, sizeof(Lf->iproto), "%.*s", IPROTOL-1, pr);
	    Lf->inp_ty = 2;
	    if (ss & SB_INO) {
		(void) snpf(tbuf, sizeof(tbuf), InodeFmt_d,
		    (INODETYPE)s->st_ino);
		tbuf[sizeof(tbuf) - 1] = '\0';
		enter_dev_ch(tbuf);
	    }
	    if (tp->faddr || tp->fport) {
		fs.s_addr = tp->faddr;
		fa = (unsigned char *)&fs;
	    } else
		fa = (unsigned char *)NULL;
	    if (tp->laddr || tp->lport) {
		ls.s_addr = tp->laddr;
		la = (unsigned char *)&ls;
	    } else
		la = (unsigned char *)NULL;
	    ent_inaddr(la, tp->lport, fa, tp->fport, AF_INET);
	    Lf->lts.type = tp->proto;
	    Lf->lts.state.i = tp->state;

#if     defined(HASTCPTPIQ)
	    Lf->lts.rq = tp->rxq;
	    Lf->lts.sq = tp->txq;
	    Lf->lts.rqs = Lf->lts.sqs = 1;
#endif  /* defined(HASTCPTPIQ) */

	    return;
	}
	if (SCTPPath[0]) {
	    (void) get_sctp();
	    for (i = 0; i < NSCTPPATHS; i++) {
		(void) free((FREE_P *)SCTPPath[i]);
		SCTPPath[i] = (char *)NULL;
	    }
	}
	if ((ss & SB_INO) && (sp = check_sctp((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to an SCTP /proc record.
	 *
	 * Set the type to "sock"; enter the inode number in the DEVICE
	 * column; set the protocol to SCTP; and fill in the NAME column
	 * with ASSOC, ASSOC-ID, ENDPT, LADDRS, LPORT, RADDRS and RPORT.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "sock");
	    (void) snpf(Lf->iproto, sizeof(Lf->iproto), "%.*s", IPROTOL-1,
		"SCTP");
	    Lf->inp_ty = 2;
	    (void) snpf(tbuf, sizeof(tbuf), InodeFmt_d, (INODETYPE)s->st_ino);
	    tbuf[sizeof(tbuf) - 1] = '\0';
	    enter_dev_ch(tbuf);
	    Namech[0] = '\0';
	    if  (sp->type == 1) {

	    /*
	     * This is an ENDPT SCTP file.
	     */
		(void) snpf(Namech, Namechl,
		    "ENDPT: %s%s%s%s%s%s",
		    sp->addr ? sp->addr : "",
		    (sp->laddrs || sp->lport) ? " " : "",
		    sp->laddrs ? sp->laddrs : "",
		    sp->lport ? "[" : "", 
		    sp->lport ? sp->lport : "", 
		    sp->lport ? "]" : ""
		 ); 
	    } else {

	    /*
	     * This is an ASSOC, or ASSOC and ENDPT socket file.
	     */
		(void) snpf(Namech, Namechl,
		    "%s: %s%s%s %s%s%s%s%s%s%s%s%s",
		    sp->type ? "ASSOC+ENDPT" : "ASSOC",
		    sp->addr ? sp->addr : "",
		    (sp->addr && sp->assocID) ? "," : "",
		    sp->assocID ? sp->assocID : "",
		    sp->laddrs ? sp->laddrs : "",
		    sp->lport ? "[" : "", 
		    sp->lport ? sp->lport : "", 
		    sp->lport ? "]" : "", 
		    ((sp->laddrs || sp->lport) && (sp->raddrs || sp->rport))
			? "<->" : "",
		    sp->raddrs ? sp->raddrs : "",
		    sp->rport ? "[" : "", 
		    sp->rport ? sp->rport : "", 
		    sp->rport ? "]" : ""
		 ); 
	    }
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
	if (ICMPpath) {
	    (void) get_icmp(ICMPpath);
	    (void) free((FREE_P *)ICMPpath);
	    ICMPpath = (char *)NULL;
	}
	if ((ss & SB_INO)
	&&  (icmpp = check_icmp((INODETYPE)s->st_ino))
	) {

	/*
	 * The inode is connected to an ICMP /proc record.
	 *
	 * Set the type to "icmp" and store the type in the NAME
	 * column.  Save the inode number.
	 */
	    (void) snpf(Lf->type, sizeof(Lf->type), "icmp");
	    Lf->inode = (INODETYPE)s->st_ino;
	    Lf->inp_ty = 1;
	    cp = Namech;
	    nl = Namechl- 2;
	    *cp = '\0';
	    if (icmpp->la && icmpp->lal) {

	    /*
	     * Store the local raw address.
	     */
		if (nl > icmpp->lal) {
		    (void) snpf(cp, nl, "%s", icmpp->la);
		    cp += icmpp->lal;
		    *cp = '\0';
		    nl -= icmpp->lal;
		}
	    }
	    if (icmpp->ra && icmpp->ral) {

	    /*
	     * Store the remote raw address, prefixed with "->".
	     */
		if (nl > (icmpp->ral + 2)) {
		    (void) snpf(cp, nl, "->%s", icmpp->ra);
		    cp += (icmpp->ral + 2);
		    *cp = '\0';
		    nl -= (icmpp->ral + 2);
		}
	    }
	    if (Namech[0])
		enter_nm(Namech);
	    return;
	}
/*
 * The socket's protocol can't be identified.
 */
	(void) snpf(Lf->type, sizeof(Lf->type), "sock");
	if (ss & SB_INO) {
	    Lf->inode = (INODETYPE)s->st_ino;
	    Lf->inp_ty = 1;
	}
	if (ss & SB_DEV) {
	    Lf->dev = s->st_dev;
	    Lf->dev_def = 1;
	}
	if (Fxopt)
	    enter_nm("can't identify protocol (-X specified)");
	else {
	    (void) snpf(Namech, Namechl, "protocol: ");
	    if (!prp) {
		i = (int)strlen(Namech);
		prp = &Namech[i];
		sz = (ssize_t)(Namechl - i - 1);
	    }
	    if ((getxattr(pbr, "system.sockprotoname", prp, sz)) < 0) 
		enter_nm("can't identify protocol");
	    else
		enter_nm(Namech);
	}
}


/*
 * set_net_paths() - set /proc/net paths
 */

void
set_net_paths(p, pl)
	char *p;			/* path to /proc/net/ */
	int pl;				/* strlen(p) */
{
	int i;
	int pathl;

	pathl = 0;
	(void) make_proc_path(p, pl, &AX25path, &pathl, "ax25");
	pathl = 0;
	(void) make_proc_path(p, pl, &ICMPpath, &pathl, "icmp");
	pathl = 0;
	(void) make_proc_path(p, pl, &Ipxpath, &pathl, "ipx");
	pathl = 0;
	(void) make_proc_path(p, pl, &Nlkpath, &pathl, "netlink");
	pathl = 0;
	(void) make_proc_path(p, pl, &Packpath, &pathl, "packet");
	pathl = 0;
	(void) make_proc_path(p, pl, &Rawpath, &pathl, "raw");
	for (i = 0; i < NSCTPPATHS; i++) {
	    pathl = 0;
	    (void) make_proc_path(p, pl, &SCTPPath[i], &pathl, SCTPSfx[i]);
	}
	pathl = 0;
	(void) make_proc_path(p, pl, &SockStatPath, &pathl, "sockstat");
	pathl = 0;
	(void) make_proc_path(p, pl, &TCPpath, &pathl, "tcp");
	pathl = 0;
	(void) make_proc_path(p, pl, &UDPpath, &pathl, "udp");
	pathl = 0;
	(void) make_proc_path(p, pl, &UDPLITEpath, &pathl, "udplite");

#if	defined(HASIPv6)
	pathl = 0;
	(void) make_proc_path(p, pl, &Raw6path, &pathl, "raw6");
	pathl = 0;
	(void) make_proc_path(p, pl, &SockStatPath6, &pathl, "sockstat6");
	pathl = 0;
	(void) make_proc_path(p, pl, &TCP6path, &pathl, "tcp6");
	pathl = 0;
	(void) make_proc_path(p, pl, &UDP6path, &pathl, "udp6");
	pathl = 0;
	(void) make_proc_path(p, pl, &UDPLITE6path, &pathl, "udplite6");
#endif	/* defined(HASIPv6) */

	pathl = 0;
	(void) make_proc_path(p, pl, &UNIXpath, &pathl, "unix");
}


/*
 * Sockty2str() -- convert socket type number to a string
 */

static char *
sockty2str(ty, rf)
	uint32_t ty;			/* socket type number */
	int *rf;			/* result flag: 0 == known
					 *		1 = unknown */
{
	int f = 0;			/* result flag */
	char *sr;			/*string result */

	switch (ty) {

#if	defined(SOCK_STREAM)
	case SOCK_STREAM:
	    sr = "STREAM";
	    break;
#endif	/* defined(SOCK_STREAM) */

#if	defined(SOCK_DGRAM)
	case SOCK_DGRAM:
	    sr = "DGRAM";
	    break;
#endif	/* defined(SOCK_DGRAM) */

#if	defined(SOCK_RAW)
	case SOCK_RAW:
	    sr = "RAW";
	    break;
#endif	/* defined(SOCK_RAW) */

#if	defined(SOCK_RDM)
	case SOCK_RDM:
	    sr = "RDM";
	    break;
#endif	/* defined(SOCK_RDM) */

#if	defined(SOCK_SEQPACKET)
	case SOCK_SEQPACKET:
	    sr = "SEQPACKET";
	    break;
#endif	/* defined(SOCK_SEQPACKET) */

#if	defined(SOCK_PACKET)
	case SOCK_PACKET:
	    sr = "PACKET";
	    break;
#endif	/* defined(SOCK_PACKET) */

	default:
	    f = 1;
	    sr = "unknown";
	}
	*rf = f;
	return(sr);
}