1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252
|
/*
* OpenIPMI.i
*
* A SWIG interface file for OpenIPMI
*
* Author: MontaVista Software, Inc.
* Corey Minyard <minyard@mvista.com>
* source@mvista.com
*
* Copyright 2004 MontaVista Software Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
%module OpenIPMI
%{
#include <config.h>
#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_GETADDRINFO
#include <netdb.h>
#endif
#include <OpenIPMI/ipmiif.h>
#include <OpenIPMI/ipmi_auth.h>
#include <OpenIPMI/ipmi_mc.h>
#include <OpenIPMI/ipmi_fru.h>
#include <OpenIPMI/ipmi_msgbits.h>
#include <OpenIPMI/ipmi_conn.h>
#include <OpenIPMI/ipmi_posix.h>
#include <OpenIPMI/ipmi_debug.h>
#include <OpenIPMI/ipmi_user.h>
#include <OpenIPMI/ipmi_lanparm.h>
#include <OpenIPMI/ipmi_pef.h>
#include <OpenIPMI/ipmi_pet.h>
#include <OpenIPMI/ipmi_sol.h>
#include <OpenIPMI/ipmi_solparm.h>
#include <OpenIPMI/ipmi_err.h>
#include <OpenIPMI/ipmi_cmdlang.h>
#include <signal.h>
/* For ipmi_debug_malloc_cleanup() */
#include <OpenIPMI/internal/ipmi_malloc.h>
#include "OpenIPMI.h"
typedef struct intarray
{
int *val;
int len;
} intarray;
typedef struct charbuf
{
char *val;
int len;
} charbuf;
os_handler_t *swig_os_hnd;
static int
next_parm(char *s, int *start, int *next)
{
while (s[*start] && isspace(s[*start]))
(*start)++;
if (!s[*start])
return EINVAL;
*next = *start;
while (s[*next] && !isspace(s[*next]))
(*next)++;
return 0;
}
static int
next_colon_parm(char *s, int *start, int *next)
{
while (s[*start] && (s[*start] == ':'))
(*start)++;
if (!s[*start])
return EINVAL;
*next = *start;
while (s[*next] && (s[*next] != ':'))
(*next)++;
return 0;
}
static int
num_parm(char *s, int len, int *rval)
{
char numstr[10];
char *end;
int val;
if (len > 9)
return EINVAL;
memcpy(numstr, s, len);
numstr[len] = '\0';
val = strtoul(numstr, &end, 0);
if (*end != '\0')
return EINVAL;
*rval = val;
return 0;
}
static int
parse_ipmi_addr(char *addr, int lun, ipmi_addr_t *i, unsigned int *addr_len)
{
int start, next;
int rv;
int num;
int len;
start = 0;
rv = next_parm(addr, &start, &next);
if (rv)
return rv;
len = next - start;
if (strncmp(addr+start, "smi", len) == 0) {
ipmi_system_interface_addr_t *si = (void *) i;
si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
si->lun = lun;
start = next;
rv = next_parm(addr, &start, &next);
if (rv)
return rv;
len = next - start;
rv = num_parm(addr+start, len, &num);
if (rv)
return rv;
si->channel = num;
*addr_len = sizeof(*si);
} else if (strncmp(addr+start, "ipmb", len) == 0) {
ipmi_ipmb_addr_t *ipmb = (void *) i;
ipmb->addr_type = IPMI_IPMB_ADDR_TYPE;
ipmb->lun = lun;
start = next;
rv = next_parm(addr, &start, &next);
if (rv)
return rv;
len = next - start;
rv = num_parm(addr+start, len, &num);
if (rv)
return rv;
ipmb->channel = num;
start = next;
rv = next_parm(addr, &start, &next);
if (rv)
return rv;
len = next - start;
rv = num_parm(addr+start, len, &num);
if (rv)
return rv;
ipmb->slave_addr = num;
*addr_len = sizeof(*ipmb);
} else {
return EINVAL;
}
return 0;
}
static void
make_ipmi_addr(char *out, int max_len, ipmi_addr_t *addr, int addr_len,
int *lun)
{
if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
ipmi_system_interface_addr_t *si = (void *) addr;
snprintf(out, max_len, "smi %d", si->channel);
*lun = si->lun;
} else if (addr->addr_type == IPMI_IPMB_ADDR_TYPE) {
ipmi_ipmb_addr_t *ipmb = (void *) addr;
snprintf(out, max_len, "ipmb %d %d", ipmb->channel, ipmb->slave_addr);
*lun = ipmb->lun;
} else {
strncpy(out, "unknown", max_len);
*lun = 0;
}
}
static int
parse_ipmi_data(intarray data, unsigned char *odata,
unsigned int max_len,
unsigned int *rlen)
{
int i;
if (data.len > max_len)
return E2BIG;
for (i=0; i<data.len; i++)
odata[i] = data.val[i];
*rlen = data.len;
return 0;
}
static unsigned char *
parse_raw_str_data(char *str, unsigned int *length)
{
char *s = str;
int inspace = 1;
int count = 0;
int i;
unsigned char *rv;
char *endstr;
while (*s) {
if (inspace && !isspace(*s)) {
inspace = 0;
count++;
} else if (!inspace && isspace(*s)) {
inspace = 1;
}
s++;
}
if (count == 0) {
*length = 0;
return malloc(1);
}
rv = malloc(count);
if (!rv)
return NULL;
s = str;
i = 0;
while ((*s) && (i < count)) {
rv[i] = strtoul(s, &endstr, 0);
if (*endstr && (!isspace(*endstr)))
goto out_err;
i++;
s = endstr;
}
*length = count;
return rv;
out_err:
free(rv);
return NULL;
}
static int
parse_ip_addr(char *str, struct in_addr *addr)
{
#ifdef HAVE_GETADDRINFO
struct addrinfo hints, *res0, *s;
struct sockaddr_in *paddr;
int rv;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
rv = getaddrinfo(str, "100", &hints, &res0);
if (rv) {
return EINVAL;
}
/* Only get the first ipv4 */
s = res0;
while (s) {
if (s->ai_family == PF_INET)
break;
s = s->ai_next;
}
if (!s) {
freeaddrinfo(res0);
return EINVAL;
}
paddr = (struct sockaddr_in *) s->ai_addr;
*addr = paddr->sin_addr;
freeaddrinfo(res0);
return 0;
#else
/* System does not support getaddrinfo, just for IPv4*/
struct hostent *ent;
ent = gethostbyname(str);
if (!ent)
return EINVAL;
memcpy(&addr->s_addr, ent->h_addr_list[0], 4);
return 0;
#endif
}
static int
parse_mac_addr(char *str, unsigned char *addr)
{
char *s;
int i;
char *endstr;
s = str;
while (isspace(*s))
s++;
if (! isxdigit(*s))
return EINVAL;
for (i=0; i<5; i++) {
addr[i] = strtoul(s, &endstr, 16);
if (*endstr != ':')
return EINVAL;
s = endstr+1;
}
addr[i] = strtoul(s, &endstr, 16);
if (*endstr != '\0')
return EINVAL;
return 0;
}
%}
%{
/* For output returning an array of constant strings */
typedef struct strconstarray
{
const char **val;
int len;
} strconstarray;
/* For input only */
typedef struct argarray
{
char **val;
int len;
} argarray;
/* For input only */
typedef struct iargarray
{
ipmi_args_t **val;
int len;
} iargarray;
%}
typedef struct strconstarray
{
const char **val;
int len;
} strconstarray;
typedef struct argarray
{
char **val;
int len;
} argarray;
typedef struct iargarray
{
ipmi_args_t **val;
int len;
} iargarray;
%include "OpenIPMI_lang.i"
%nodefault;
%{
swig_cb_val *swig_log_handler;
void
openipmi_swig_vlog(os_handler_t *os_handler, const char *format,
enum ipmi_log_type_e log_type, va_list ap)
{
char *pfx = "";
static char log[1024];
static int curr = 0;
swig_cb_val *handler = swig_log_handler;
if (! handler)
return;
switch(log_type)
{
case IPMI_LOG_INFO:
pfx = "INFO";
break;
case IPMI_LOG_WARNING:
pfx = "WARN";
break;
case IPMI_LOG_SEVERE:
pfx = "SEVR";
break;
case IPMI_LOG_FATAL:
pfx = "FATL";
break;
case IPMI_LOG_ERR_INFO:
pfx = "EINF";
break;
case IPMI_LOG_DEBUG:
pfx = "DEBG";
break;
case IPMI_LOG_DEBUG_START:
case IPMI_LOG_DEBUG_CONT:
if (curr < sizeof(log))
curr += vsnprintf(log+curr, sizeof(log)-curr, format, ap);
return;
case IPMI_LOG_DEBUG_END:
if (curr < sizeof(log))
vsnprintf(log+curr, sizeof(log)-curr, format, ap);
pfx = "DEBG";
curr = 0;
goto plog;
}
vsnprintf(log, sizeof(log), format, ap);
plog:
swig_call_cb(handler, "log", "%s%s", pfx, log);
}
static void
handle_domain_cb(ipmi_domain_t *domain, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_cb", "%p", &domain_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
}
static void
domain_connect_change_handler(ipmi_domain_t *domain,
int err,
unsigned int conn_num,
unsigned int port_num,
int still_connected,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "conn_change_cb", "%p%d%d%d%d",
&domain_ref, err, conn_num, port_num, still_connected);
swig_free_ref_check(domain_ref, ipmi_domain_t);
}
static void
domain_connect_change_handler_cl(ipmi_domain_con_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != domain_connect_change_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
domain_iterate_connections_handler(ipmi_domain_t *domain, int conn,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_iter_connection_cb", "%p%d", &domain_ref, conn);
swig_free_ref_check(domain_ref, ipmi_domain_t);
}
static void
domain_event_handler(ipmi_domain_t *domain, ipmi_event_t *event, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref event_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb(cb, "event_cb", "%p%p", &domain_ref, &event_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref(event_ref);
}
static void
domain_event_handler_cl(ipmi_event_handler_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != domain_event_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
domain_mc_updated_handler(enum ipmi_update_e op, ipmi_domain_t *domain,
ipmi_mc_t *mc, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref mc_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_update_cb", "%s%p%p",
ipmi_update_e_string(op), &domain_ref, &mc_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref_check(mc_ref, ipmi_mc_t);
}
static void
domain_mc_updated_handler_cl(ipmi_domain_mc_upd_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != domain_mc_updated_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
domain_entity_update_handler(enum ipmi_update_e op, ipmi_domain_t *domain,
ipmi_entity_t *entity, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref entity_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_update_cb", "%s%p%p",
ipmi_update_e_string(op), &domain_ref, &entity_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref_check(entity_ref, ipmi_entity_t);
}
static void
domain_entity_update_handler_cl(ipmi_domain_entity_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != domain_entity_update_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
domain_fully_up(ipmi_domain_t *domain, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_up_cb", "%p", &domain_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
parse_args_iter_help_hnd(const char *name, const char *help, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_call_cb(cb, "parse_args_iter_help_cb", "%s%s", name, help);
}
static void
domain_close_done(void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_call_cb(cb, "domain_close_done_cb", " ");
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
domain_iterate_entities_handler(ipmi_entity_t *entity, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref entity_ref;
domain_ref = swig_make_ref(ipmi_entity_get_domain(entity), ipmi_domain_t);
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "domain_iter_entity_cb", "%p%p",
&domain_ref, &entity_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref_check(entity_ref, ipmi_entity_t);
}
static void
ipmb_mc_scan_handler(ipmi_domain_t *domain, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_ipmb_mc_scan_cb", "%p%d", &domain_ref, err);
swig_free_ref_check(domain_ref, ipmi_domain_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
domain_reread_sels_handler(ipmi_domain_t *domain, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_reread_sels_cb", "%p%d", &domain_ref, err);
swig_free_ref_check(domain_ref, ipmi_domain_t);
}
static int
domain_msg_cb(ipmi_domain_t *domain, ipmi_msgi_t *rspi)
{
swig_cb_val *cb = rspi->data1;
swig_ref domain_ref;
ipmi_msg_t *msg = &rspi->msg;
ipmi_addr_t *addr = &rspi->addr;
int addr_len = rspi->addr_len;
char addr_str[50];
int lun;
make_ipmi_addr(addr_str, sizeof(addr_str), addr, addr_len, &lun);
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_addr_cmd_cb", "%p%s%d%d%d%*s", &domain_ref,
addr_str, lun, msg->netfn, msg->cmd,
msg->data_len, msg->data);
swig_free_ref_check(domain_ref, ipmi_domain_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
return IPMI_MSG_ITEM_NOT_USED;
}
static void
domain_iterate_mcs_handler(ipmi_domain_t *domain, ipmi_mc_t *mc, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref mc_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "domain_iter_mc_cb", "%p%p", &domain_ref, &mc_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref_check(mc_ref, ipmi_mc_t);
}
static void
fru_written_done(ipmi_domain_t *domain, ipmi_fru_t *fru,
int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref fru_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
fru_ref = swig_make_ref_destruct(fru, ipmi_fru_t);
/* The FRU is already referenced because of the callback, no need
to mess with refcounts. */
swig_call_cb(cb, "fru_written", "%p%p%d", &domain_ref, &fru_ref, err);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref(fru_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
fru_fetched(ipmi_domain_t *domain, ipmi_fru_t *fru, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
swig_ref fru_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
fru_ref = swig_make_ref_destruct(fru, ipmi_fru_t);
/* The FRU is already referenced because of the callback, no need
to mess with refcounts. */
swig_call_cb(cb, "fru_fetched", "%p%p%d", &domain_ref, &fru_ref, err);
swig_free_ref_check(domain_ref, ipmi_domain_t);
swig_free_ref(fru_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
handle_entity_cb(ipmi_entity_t *entity, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_cb", "%p", &entity_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
}
static void
entity_iterate_entities_handler(ipmi_entity_t *ent1,
ipmi_entity_t *ent2,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref ent1_ref;
swig_ref ent2_ref;
ent1_ref = swig_make_ref(ent1, ipmi_entity_t);
ent2_ref = swig_make_ref(ent2, ipmi_entity_t);
swig_call_cb(cb, "entity_iter_entities_cb", "%p%p", &ent1_ref, &ent2_ref);
swig_free_ref_check(ent2_ref, ipmi_entity_t);
swig_free_ref_check(ent1_ref, ipmi_entity_t);
}
static void
entity_iterate_sensors_handler(ipmi_entity_t *entity,
ipmi_sensor_t *sensor,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref sensor_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "entity_iter_sensors_cb", "%p%p",
&entity_ref, &sensor_ref);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
swig_free_ref_check(entity_ref, ipmi_entity_t);
}
static void
entity_iterate_controls_handler(ipmi_entity_t *entity,
ipmi_control_t *control,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref control_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
control_ref = swig_make_ref(control, ipmi_control_t);
swig_call_cb(cb, "entity_iter_controls_cb", "%p%p",
&entity_ref, &control_ref);
swig_free_ref_check(control_ref, ipmi_control_t);
swig_free_ref_check(entity_ref, ipmi_entity_t);
}
static int
entity_presence_handler(ipmi_entity_t *entity,
int present,
void *cb_data,
ipmi_event_t *event)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref event_ref;
int rv = IPMI_EVENT_NOT_HANDLED;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb_rv('I', &rv, cb, "entity_presence_cb", "%p%d%p",
&entity_ref, present, &event_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref(event_ref);
return rv;
}
static void
entity_presence_handler_cl(ipmi_entity_presence_change_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_presence_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
entity_sensor_update_handler(enum ipmi_update_e op,
ipmi_entity_t *entity,
ipmi_sensor_t *sensor,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref sensor_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "entity_sensor_update_cb", "%s%p%p",
ipmi_update_e_string(op), &entity_ref, &sensor_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
}
static void
entity_sensor_update_handler_cl(ipmi_entity_sensor_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_sensor_update_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
entity_control_update_handler(enum ipmi_update_e op,
ipmi_entity_t *entity,
ipmi_control_t *control,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref control_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
control_ref = swig_make_ref(control, ipmi_control_t);
swig_call_cb(cb, "entity_control_update_cb", "%s%p%p",
ipmi_update_e_string(op), &entity_ref, &control_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref_check(control_ref, ipmi_control_t);
}
static void
entity_control_update_handler_cl(ipmi_entity_control_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_control_update_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
entity_fru_update_handler(enum ipmi_update_e op,
ipmi_entity_t *entity,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref fru_ref;
ipmi_fru_t *fru;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
fru = ipmi_entity_get_fru(entity);
if (fru)
ipmi_fru_ref(fru);
fru_ref = swig_make_ref_destruct(fru, ipmi_fru_t);
swig_call_cb(cb, "entity_fru_update_cb", "%s%p%p",
ipmi_update_e_string(op), &entity_ref, &fru_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref(fru_ref);
}
static void
entity_fru_update_werr_handler(enum ipmi_update_werr_e op,
int err,
ipmi_entity_t *entity,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref fru_ref;
ipmi_fru_t *fru;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
fru = ipmi_entity_get_fru(entity);
if (fru)
ipmi_fru_ref(fru);
fru_ref = swig_make_ref_destruct(fru, ipmi_fru_t);
swig_call_cb(cb, "entity_fru_update_werr_cb", "%s%d%p%p",
ipmi_update_werr_e_string(op), err, &entity_ref, &fru_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref(fru_ref);
}
static void
entity_fru_update_handler_cl(ipmi_entity_fru_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_fru_update_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
entity_fru_update_werr_handler_cl(ipmi_entity_fru_werr_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_fru_update_werr_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static int
entity_hot_swap_handler(ipmi_entity_t *entity,
enum ipmi_hot_swap_states last_state,
enum ipmi_hot_swap_states curr_state,
void *cb_data,
ipmi_event_t *event)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
swig_ref event_ref;
int rv = IPMI_EVENT_NOT_HANDLED;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb_rv('I', &rv,
cb, "entity_hot_swap_update_cb", "%p%s%s%p", &entity_ref,
ipmi_hot_swap_state_name(last_state),
ipmi_hot_swap_state_name(curr_state),
&event_ref);
swig_free_ref_check(entity_ref, ipmi_entity_t);
swig_free_ref(event_ref);
return rv;
}
static void
entity_hot_swap_handler_cl(ipmi_entity_hot_swap_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != entity_hot_swap_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
entity_get_hot_swap_handler(ipmi_entity_t *entity,
int err,
enum ipmi_hot_swap_states state,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_hot_swap_cb", "%p%d%s", &entity_ref,
err, ipmi_hot_swap_state_name(state));
swig_free_ref_check(entity_ref, ipmi_entity_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
entity_get_hot_swap_time_handler(ipmi_entity_t *entity,
int err,
ipmi_timeout_t time,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_hot_swap_get_time_cb", "%p%d%f", &entity_ref,
err, ((double) time) / 1000000000.0);
swig_free_ref_check(entity_ref, ipmi_entity_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
entity_set_hot_swap_time_handler(ipmi_entity_t *entity,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_hot_swap_set_time_cb", "%p%d", &entity_ref, err);
swig_free_ref_check(entity_ref, ipmi_entity_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
entity_activate_handler(ipmi_entity_t *entity,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref entity_ref;
entity_ref = swig_make_ref(entity, ipmi_entity_t);
swig_call_cb(cb, "entity_activate_cb", "%p%d", &entity_ref, err);
swig_free_ref_check(entity_ref, ipmi_entity_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
handle_mc_cb(ipmi_mc_t *mc, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_cb", "%p", &mc_ref);
swig_free_ref_check(mc_ref, ipmi_mc_t);
}
static void
mc_active_handler(ipmi_mc_t *mc,
int active,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_active_cb", "%p%d", &mc_ref, active);
swig_free_ref_check(mc_ref, ipmi_mc_t);
}
static void
mc_active_handler_cl(ipmi_mc_active_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != mc_active_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
mc_fully_up_handler(ipmi_mc_t *mc, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_fully_up_cb", "%p", &mc_ref);
swig_free_ref_check(mc_ref, ipmi_mc_t);
}
static void
mc_fully_up_handler_cl(ipmi_mc_ptr_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != mc_fully_up_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
mc_msg_cb(ipmi_mc_t *mc,
ipmi_msg_t *msg,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_cmd_cb", "%p%d%d%*s", &mc_ref,
msg->netfn, msg->cmd, msg->data_len, msg->data);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_reset_handler(ipmi_mc_t *mc, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_reset_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_events_enable_handler(ipmi_mc_t *mc, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_events_enable_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_get_event_log_enable_handler(ipmi_mc_t *mc, int err, int val, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_get_event_log_enable_cb", "%p%d%d",
&mc_ref, err, val);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_set_event_log_enable_handler(ipmi_mc_t *mc, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_set_event_log_enable_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_reread_sensors_handler(ipmi_mc_t *mc, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_reread_sensors_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_reread_sel_handler(ipmi_mc_t *mc, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_reread_sel_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_sel_get_time_cb(ipmi_mc_t *mc,
int err,
unsigned long time,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_get_sel_time_cb", "%p%d%ld", &mc_ref, err, time);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_channel_get_info(ipmi_mc_t *mc,
int err,
ipmi_channel_info_t *info,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
swig_ref info_ref;
info = ipmi_channel_info_copy(info);
mc_ref = swig_make_ref(mc, ipmi_mc_t);
info_ref = swig_make_ref_destruct(info, ipmi_channel_info_t);
swig_call_cb(cb, "mc_channel_got_info_cb", "%p%d%p", &mc_ref, err,
&info_ref);
swig_free_ref_check(mc_ref, ipmi_mc_t);
swig_free_ref(info_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_channel_get_access(ipmi_mc_t *mc,
int err,
ipmi_channel_access_t *info,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
swig_ref info_ref;
info = ipmi_channel_access_copy(info);
mc_ref = swig_make_ref(mc, ipmi_mc_t);
info_ref = swig_make_ref_destruct(info, ipmi_channel_access_t);
swig_call_cb(cb, "mc_channel_got_access_cb", "%p%d%p", &mc_ref, err,
&info_ref);
swig_free_ref_check(mc_ref, ipmi_mc_t);
swig_free_ref(info_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_channel_set_access(ipmi_mc_t *mc,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_channel_set_access_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_channel_got_users(ipmi_mc_t *mc,
int err,
ipmi_user_list_t *info,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
swig_ref *info_ref;
int free_info_ref = 0;
int count;
swig_ref dummy;
int i;
unsigned int max, enabled, fixed;
if (info) {
count = ipmi_user_list_get_user_count(info);
info_ref = malloc(count * sizeof(swig_ref));
if (!info_ref) {
count = 0;
info_ref = &dummy;
} else {
free_info_ref = 1;
}
} else {
count = 0;
info_ref = &dummy;
}
mc_ref = swig_make_ref(mc, ipmi_mc_t);
for (i=0; i<count; i++) {
ipmi_user_t *user = ipmi_user_list_get_user(info, i);
info_ref[i] = swig_make_ref_destruct(user, ipmi_user_t);
}
ipmi_user_list_get_max_user(info, &max);
ipmi_user_list_get_enabled_users(info, &enabled);
ipmi_user_list_get_fixed_users(info, &fixed);
swig_call_cb(cb, "mc_channel_got_users_cb", "%p%d%d%d%d%*o", &mc_ref, err,
max, enabled, fixed, count, info_ref);
swig_free_ref_check(mc_ref, ipmi_mc_t);
for (i=0; i<count; i++)
swig_free_ref(info_ref[i]);
if (free_info_ref)
free(info_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
mc_channel_set_user(ipmi_mc_t *mc,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref mc_ref;
mc_ref = swig_make_ref(mc, ipmi_mc_t);
swig_call_cb(cb, "mc_channel_set_user_cb", "%p%d", &mc_ref, err);
swig_free_ref_check(mc_ref, ipmi_mc_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
handle_sensor_cb(ipmi_sensor_t *sensor, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_cb", "%p", &sensor_ref);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
}
static char *
threshold_str(char *s, enum ipmi_thresh_e thresh)
{
if (thresh == IPMI_UPPER_NON_CRITICAL) {
*s = 'u'; s++; *s = 'n'; s++;
} else if (thresh == IPMI_UPPER_CRITICAL) {
*s = 'u'; s++; *s = 'c'; s++;
} else if (thresh == IPMI_UPPER_NON_RECOVERABLE) {
*s = 'u'; s++; *s = 'r'; s++;
} else if (thresh == IPMI_LOWER_NON_CRITICAL) {
*s = 'l'; s++; *s = 'n'; s++;
} else if (thresh == IPMI_LOWER_CRITICAL) {
*s = 'l'; s++; *s = 'c'; s++;
} else if (thresh == IPMI_LOWER_NON_RECOVERABLE) {
*s = 'l'; s++; *s = 'r'; s++;
}
return s;
}
static char *
threshold_from_str(char *s, int len, enum ipmi_thresh_e *thresh)
{
if (len != 2)
return NULL;
if (strncasecmp(s, "un", 2) == 0)
*thresh = IPMI_UPPER_NON_CRITICAL;
else if (strncasecmp(s, "uc", 2) == 0)
*thresh = IPMI_UPPER_CRITICAL;
else if (strncasecmp(s, "ur", 2) == 0)
*thresh = IPMI_UPPER_NON_RECOVERABLE;
else if (strncasecmp(s, "ln", 2) == 0)
*thresh = IPMI_LOWER_NON_CRITICAL;
else if (strncasecmp(s, "lc", 2) == 0)
*thresh = IPMI_LOWER_CRITICAL;
else if (strncasecmp(s, "lr", 2) == 0)
*thresh = IPMI_LOWER_NON_RECOVERABLE;
else
return NULL;
return s+2;
}
static char *
threshold_event_str(char *s,
enum ipmi_thresh_e thresh,
enum ipmi_event_value_dir_e value_dir,
enum ipmi_event_dir_e dir)
{
s = threshold_str(s, thresh);
if (value_dir == IPMI_GOING_HIGH) {
*s = 'h'; s++;
} else {
*s = 'l'; s++;
}
if (dir == IPMI_ASSERTION) {
*s = 'a'; s++;
} else {
*s = 'd'; s++;
}
*s = '\0';
return s;
}
static char *
threshold_event_from_str(char *s,
int len,
enum ipmi_thresh_e *thresh,
enum ipmi_event_value_dir_e *value_dir,
enum ipmi_event_dir_e *dir)
{
if (len != 4)
return NULL;
s = threshold_from_str(s, 2, thresh);
if (*s == 'l')
*value_dir = IPMI_GOING_LOW;
else if (*s == 'h')
*value_dir = IPMI_GOING_HIGH;
else
return NULL;
s++;
if (*s == 'a')
*dir = IPMI_ASSERTION;
else if (*s == 'd')
*dir = IPMI_DEASSERTION;
else
return NULL;
s++;
return s;
}
static char *
discrete_event_from_str(char *s,
int len,
int *offset,
enum ipmi_event_dir_e *dir)
{
if ((len < 2) || (len > 3))
return NULL;
*offset = strtoul(s, &s, 0);
if (*offset >= 15)
return NULL;
if (*s == 'a')
*dir = IPMI_ASSERTION;
else if (*s == 'd')
*dir = IPMI_DEASSERTION;
else
return NULL;
s++;
return s;
}
static char *
discrete_event_str(char *s,
int offset,
enum ipmi_event_dir_e dir)
{
if (offset >= 100)
offset = 99;
if (offset < 0)
offset = 0;
s += sprintf(s, "%d", offset);
if (dir == IPMI_ASSERTION) {
*s = 'a'; s++;
} else {
*s = 'd'; s++;
}
*s = '\0';
return s;
}
static char *
threshold_event_state_to_str(ipmi_event_state_t *events)
{
int len = 0;
char *str;
enum ipmi_thresh_e thresh;
enum ipmi_event_value_dir_e value_dir;
enum ipmi_event_dir_e dir;
char *s;
if (ipmi_event_state_get_events_enabled(events))
len += strlen("events ");
if (ipmi_event_state_get_scanning_enabled(events))
len += strlen("scanning ");
if (ipmi_event_state_get_busy(events))
len += strlen("busy ");
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
for (value_dir = IPMI_GOING_LOW;
value_dir <= IPMI_GOING_HIGH;
value_dir++)
{
for (dir = IPMI_ASSERTION;
dir <= IPMI_DEASSERTION;
dir++)
{
if (ipmi_is_threshold_event_set(events,thresh, value_dir, dir))
len += 5;
}
}
}
str = malloc(len+1);
str[0] = '\0';
if (ipmi_event_state_get_events_enabled(events))
strcat(str, "events ");
if (ipmi_event_state_get_scanning_enabled(events))
strcat(str, "scanning ");
if (ipmi_event_state_get_busy(events))
strcat(str, "busy ");
s = str + strlen(str);
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
for (value_dir = IPMI_GOING_LOW;
value_dir <= IPMI_GOING_HIGH;
value_dir++)
{
for (dir = IPMI_ASSERTION;
dir <= IPMI_DEASSERTION;
dir++)
{
if (!ipmi_is_threshold_event_set(events,thresh,value_dir,dir))
continue;
s = threshold_event_str(s, thresh, value_dir, dir);
*s = ' ';
s++;
}
}
}
*s = '\0';
len = s - str;
if (len > 0)
str[len-1] = '\0'; /* Remove the final space */
return str;
}
static int
str_to_threshold_event_state(char *str,
ipmi_event_state_t **events)
{
enum ipmi_thresh_e thresh;
enum ipmi_event_value_dir_e value_dir;
enum ipmi_event_dir_e dir;
ipmi_event_state_t *e;
int start, next;
int rv;
e = malloc(ipmi_event_state_size());
ipmi_event_state_init(e);
start = 0;
rv = next_parm(str, &start, &next);
while (!rv) {
char *s = str+start;
int len = next - start;
if (strncasecmp(s, "events", len) == 0)
ipmi_event_state_set_events_enabled(e, 1);
else if (strncasecmp(s, "scanning", len) == 0)
ipmi_event_state_set_scanning_enabled(e, 1);
else if (strncasecmp(s, "busy", len) == 0)
ipmi_event_state_set_busy(e, 1);
else {
s = threshold_event_from_str(s, len, &thresh, &value_dir, &dir);
if (!s)
goto out_err;
ipmi_threshold_event_set(e, thresh, value_dir, dir);
}
start = next;
rv = next_parm(str, &start, &next);
}
*events = e;
return 0;
out_err:
free(e);
return EINVAL;
}
static char *
discrete_event_state_to_str(ipmi_event_state_t *events)
{
int len = 0;
char *str;
int offset;
enum ipmi_event_dir_e dir;
char *s;
if (ipmi_event_state_get_events_enabled(events))
len += strlen("events ");
if (ipmi_event_state_get_scanning_enabled(events))
len += strlen("scanning ");
if (ipmi_event_state_get_busy(events))
len += strlen("busy ");
for (offset=0; offset<15; offset++) {
for (dir = IPMI_ASSERTION;
dir <= IPMI_DEASSERTION;
dir++)
{
if (ipmi_is_discrete_event_set(events, offset, dir))
len += 4;
}
}
str = malloc(len+1);
str[0] = '\0';
if (ipmi_event_state_get_events_enabled(events))
strcat(str, "events ");
if (ipmi_event_state_get_scanning_enabled(events))
strcat(str, "scanning ");
if (ipmi_event_state_get_busy(events))
strcat(str, "busy ");
s = str + strlen(str);
for (offset=0; offset<15; offset++) {
for (dir = IPMI_ASSERTION;
dir <= IPMI_DEASSERTION;
dir++)
{
if (! ipmi_is_discrete_event_set(events, offset, dir))
continue;
s = discrete_event_str(s, offset, dir);
*s = ' ';
s++;
}
}
*s = '\0';
len = s - str;
if (len > 0)
str[len-1] = '\0'; /* Remove the final space */
return str;
}
static int
str_to_discrete_event_state(char *str,
ipmi_event_state_t **events)
{
int offset;
enum ipmi_event_dir_e dir;
ipmi_event_state_t *e;
int start, next;
int rv;
e = malloc(ipmi_event_state_size());
ipmi_event_state_init(e);
start = 0;
rv = next_parm(str, &start, &next);
while (!rv) {
char *s = str+start;
int len = next - start;
if (strncasecmp(s, "events", len) == 0)
ipmi_event_state_set_events_enabled(e, 1);
else if (strncasecmp(s, "scanning", len) == 0)
ipmi_event_state_set_scanning_enabled(e, 1);
else if (strncasecmp(s, "busy", len) == 0)
ipmi_event_state_set_busy(e, 1);
else {
s = discrete_event_from_str(s, len, &offset, &dir);
if (!s)
goto out_err;
ipmi_discrete_event_set(e, offset, dir);
}
start = next;
rv = next_parm(str, &start, &next);
}
*events = e;
return 0;
out_err:
free(e);
return EINVAL;
}
static char *
threshold_states_to_str(ipmi_states_t *states)
{
int len = 0;
char *str;
enum ipmi_thresh_e thresh;
char *s;
if (ipmi_is_event_messages_enabled(states))
len += strlen("events ");
if (ipmi_is_sensor_scanning_enabled(states))
len += strlen("scanning ");
if (ipmi_is_initial_update_in_progress(states))
len += strlen("busy ");
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
if (ipmi_is_threshold_out_of_range(states, thresh))
len += 3;
}
str = malloc(len+1);
str[0] = '\0';
if (ipmi_is_event_messages_enabled(states))
strcat(str, "events ");
if (ipmi_is_sensor_scanning_enabled(states))
strcat(str, "scanning ");
if (ipmi_is_initial_update_in_progress(states))
strcat(str, "busy ");
s = str + strlen(str);
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
if (!ipmi_is_threshold_out_of_range(states, thresh))
continue;
s = threshold_str(s, thresh);
*s = ' ';
s++;
}
*s = '\0';
len = s - str;
if (len > 0)
str[len-1] = '\0'; /* Remove the final space */
return str;
}
static char *
discrete_states_to_str(ipmi_states_t *states)
{
int len = 0;
char *str;
int offset;
char *s;
if (ipmi_is_event_messages_enabled(states))
len += strlen("events ");
if (ipmi_is_sensor_scanning_enabled(states))
len += strlen("scanning ");
if (ipmi_is_initial_update_in_progress(states))
len += strlen("busy ");
for (offset=0; offset<15; offset++) {
if (ipmi_is_state_set(states, offset))
len += 3;
}
str = malloc(len+1);
str[0] = '\0';
if (ipmi_is_event_messages_enabled(states))
strcat(str, "events ");
if (ipmi_is_sensor_scanning_enabled(states))
strcat(str, "scanning ");
if (ipmi_is_initial_update_in_progress(states))
strcat(str, "busy ");
s = str + strlen(str);
for (offset=0; offset<15; offset++) {
if (! ipmi_is_state_set(states, offset))
continue;
s += sprintf(s, "%d", offset);
*s = ' ';
s++;
}
*s = '\0';
len = s - str;
if (len > 0)
str[len-1] = '\0'; /* Remove the final space */
return str;
}
static char *
thresholds_to_str(ipmi_thresholds_t *t)
{
int len = 0;
char *str;
enum ipmi_thresh_e thresh;
char dummy[3];
char *s;
double val;
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
if (ipmi_threshold_get(t, thresh, &val) == 0)
len += snprintf(dummy, 1, "aa %f:", val) + 1;
}
str = malloc(len+1);
s = str;
for (thresh = IPMI_LOWER_NON_CRITICAL;
thresh <= IPMI_UPPER_NON_RECOVERABLE;
thresh++)
{
if (ipmi_threshold_get(t, thresh, &val) != 0)
continue;
threshold_str(dummy, thresh);
dummy[2] = '\0';
s += sprintf(s, "%s %f:", dummy, val);
*s = ' ';
s++;
}
*s = '\0';
len = s - str;
if (len > 0)
str[len-2] = '\0'; /* Remove the final ': ' */
return str;
}
static int
str_to_thresholds(char *str,
ipmi_sensor_t *sensor,
ipmi_thresholds_t **thresholds)
{
enum ipmi_thresh_e thresh;
ipmi_thresholds_t *t;
int start, next;
int rv;
double val;
int err = EINVAL;
t = malloc(ipmi_thresholds_size());
ipmi_thresholds_init(t);
start = 0;
rv = next_colon_parm(str, &start, &next);
while (!rv) {
char *s = str+start;
char *endstr;
int len = next - start;
if (len < 4)
goto out_err;
if (strncasecmp(s, "un ", 3) == 0)
thresh = IPMI_UPPER_NON_CRITICAL;
else if (strncasecmp(s, "uc ", 3) == 0)
thresh = IPMI_UPPER_CRITICAL;
else if (strncasecmp(s, "ur ", 3) == 0)
thresh = IPMI_UPPER_NON_RECOVERABLE;
else if (strncasecmp(s, "ln ", 3) == 0)
thresh = IPMI_LOWER_NON_CRITICAL;
else if (strncasecmp(s, "lc ", 3) == 0)
thresh = IPMI_LOWER_CRITICAL;
else if (strncasecmp(s, "lr ", 3) == 0)
thresh = IPMI_LOWER_NON_RECOVERABLE;
else
goto out_err;
val = strtod(s+3, &endstr);
if ((*endstr != ':') && (*endstr != '\0'))
goto out_err;
rv = ipmi_threshold_set(t, sensor, thresh, val);
if (rv) {
err = rv;
goto out_err;
}
start = next;
rv = next_colon_parm(str, &start, &next);
}
*thresholds = t;
return 0;
out_err:
free(t);
return err;
}
static int
sensor_threshold_event_handler(ipmi_sensor_t *sensor,
enum ipmi_event_dir_e dir,
enum ipmi_thresh_e threshold,
enum ipmi_event_value_dir_e high_low,
enum ipmi_value_present_e value_present,
unsigned int raw_value,
double value,
void *cb_data,
ipmi_event_t *event)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
char eventstr[5];
int raw_set = 0;
int value_set = 0;
swig_ref event_ref;
int rv = IPMI_EVENT_NOT_HANDLED;
if (value_present == IPMI_RAW_VALUE_PRESENT)
raw_set = 1;
if (value_present == IPMI_BOTH_VALUES_PRESENT) {
raw_set = 1;
value_set = 1;
}
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
threshold_event_str(eventstr, threshold, high_low, dir);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb_rv('I', &rv,
cb, "threshold_event_cb", "%p%s%d%d%d%f%p", &sensor_ref,
eventstr, raw_set, raw_value, value_set, value,
&event_ref);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
swig_free_ref(event_ref);
return rv;
}
static void
sensor_threshold_event_handler_cl(ipmi_sensor_threshold_event_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != sensor_threshold_event_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static int
sensor_discrete_event_handler(ipmi_sensor_t *sensor,
enum ipmi_event_dir_e dir,
int offset,
int severity,
int prev_severity,
void *cb_data,
ipmi_event_t *event)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
char eventstr[5];
swig_ref event_ref;
int rv = IPMI_EVENT_NOT_HANDLED;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
discrete_event_str(eventstr, offset, dir);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb_rv('I', &rv,
cb, "discrete_event_cb", "%p%s%d%d%p", &sensor_ref,
eventstr, severity, prev_severity, &event_ref);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
swig_free_ref(event_ref);
return rv;
}
static void
sensor_discrete_event_handler_cl(ipmi_sensor_discrete_event_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != sensor_discrete_event_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
/*
* For the event method call_handler to use.
*/
typedef struct event_call_handler_data_s
{
ipmi_event_t *event;
swig_cb_val *handlers_val;
ipmi_event_handlers_t *handlers;
int rv;
} event_call_handler_data_t;
static void event_call_handler_mc_cb(ipmi_mc_t *mc, void *cb_data)
{
event_call_handler_data_t *info = cb_data;
ipmi_domain_t *domain = ipmi_mc_get_domain(mc);
info->rv = ipmi_event_call_handler(domain, info->handlers,
info->event, info->handlers_val);
}
/* A generic callback for a lot of things. */
static void
sensor_event_enable_handler(ipmi_sensor_t *sensor,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_event_enable_cb", "%p%d", &sensor_ref, err);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_get_event_enables_handler(ipmi_sensor_t *sensor,
int err,
ipmi_event_state_t *states,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
char *st;
if (ipmi_sensor_get_event_reading_type(sensor)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
st = threshold_event_state_to_str(states);
} else {
st = discrete_event_state_to_str(states);
}
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_get_event_enable_cb", "%p%d%s",
&sensor_ref, err, st);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
free(st);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_rearm_handler(ipmi_sensor_t *sensor,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_rearm_cb", "%p%d", &sensor_ref, err);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_get_hysteresis_handler(ipmi_sensor_t *sensor,
int err,
unsigned int positive_hysteresis,
unsigned int negative_hysteresis,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_get_hysteresis_cb", "%p%d%d%d", &sensor_ref, err,
positive_hysteresis, negative_hysteresis);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_set_hysteresis_handler(ipmi_sensor_t *sensor,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_set_hysteresis_cb", "%p%d", &sensor_ref, err);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_set_thresholds_handler(ipmi_sensor_t *sensor,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_set_thresholds_cb", "%p%d", &sensor_ref, err);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void sensor_get_thresholds_handler(ipmi_sensor_t *sensor,
int err,
ipmi_thresholds_t *th,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
char *thstr = thresholds_to_str(th);
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
swig_call_cb(cb, "sensor_get_thresholds_cb", "%p%d%s", &sensor_ref, err,
thstr);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
free(thstr);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_get_reading_handler(ipmi_sensor_t *sensor,
int err,
enum ipmi_value_present_e value_present,
unsigned int raw_value,
double value,
ipmi_states_t *states,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
int raw_set = 0;
int value_set = 0;
char *statestr;
if (value_present == IPMI_RAW_VALUE_PRESENT)
raw_set = 1;
if (value_present == IPMI_BOTH_VALUES_PRESENT) {
raw_set = 1;
value_set = 1;
}
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
statestr = threshold_states_to_str(states);
swig_call_cb(cb, "threshold_reading_cb", "%p%d%d%d%d%f%s", &sensor_ref,
err, raw_set, raw_value, value_set, value, statestr);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
free(statestr);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sensor_get_states_handler(ipmi_sensor_t *sensor,
int err,
ipmi_states_t *states,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref sensor_ref;
char *statestr;
sensor_ref = swig_make_ref(sensor, ipmi_sensor_t);
statestr = discrete_states_to_str(states);
swig_call_cb(cb, "discrete_states_cb", "%p%d%s", &sensor_ref,
err, statestr);
swig_free_ref_check(sensor_ref, ipmi_sensor_t);
free(statestr);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static int
str_to_color(char *s, int len, int *color)
{
int i;
for (i=IPMI_CONTROL_COLOR_BLACK; i<=IPMI_CONTROL_COLOR_ORANGE; i++) {
if (strncasecmp(s, ipmi_get_color_string(i), len) == 0) {
*color = i;
return 0;
}
}
return EINVAL;
}
static int
str_to_light_setting(char *s, ipmi_light_setting_t **setting)
{
int rv;
ipmi_light_setting_t *e;
int start, next;
int count;
count = 0;
start = 0;
rv = next_colon_parm(s, &start, &next);
while (!rv) {
start = next;
count++;
rv = next_colon_parm(s, &start, &next);
}
if (count == 0)
return EINVAL;
e = ipmi_alloc_light_settings(count);
count = 0;
start = 0;
rv = next_colon_parm(s, &start, &next);
while (!rv) {
int color, on_time, off_time;
char *ms;
int mstart, mnext;
char *endstr;
char buf[100];
int len = next - start;
if (len >= 100)
goto out_err;
memcpy(buf, s+start, len);
buf[len] = '\0';
ms = buf;
mstart = 0;
rv = next_parm(ms, &mstart, &mnext);
if (rv)
goto out_err;
len = mnext - mstart;
if ((len == 2) && (strncasecmp(ms+mstart, "lc", 2) == 0)) {
rv = ipmi_light_setting_set_local_control(e, count, 1);
if (rv)
goto out_err;
mstart = mnext;
rv = next_parm(ms, &mstart, &mnext);
if (rv)
goto out_err;
}
rv = str_to_color(ms+mstart, mnext-mstart, &color);
if (rv)
goto out_err;
mstart = mnext;
rv = next_parm(ms, &mstart, &mnext);
if (rv)
goto out_err;
on_time = strtoul(ms+mstart, &endstr, 0);
if (endstr != (ms+mnext))
goto out_err;
mstart = mnext;
rv = next_parm(ms, &mstart, &mnext);
if (rv)
goto out_err;
off_time = strtoul(ms+mstart, &endstr, 0);
if (endstr != (ms+mnext))
goto out_err;
rv = ipmi_light_setting_set_color(e, count, color);
rv |= ipmi_light_setting_set_on_time(e, count, on_time);
rv |= ipmi_light_setting_set_off_time(e, count, off_time);
if (rv)
goto out_err;
count++;
start = next;
rv = next_colon_parm(s, &start, &next);
}
*setting = e;
return 0;
out_err:
ipmi_free_light_settings(e);
return EINVAL;
}
static char *
light_setting_to_str(ipmi_light_setting_t *e)
{
char *s, *str;
int i;
int count = ipmi_light_setting_get_count(e);
char dummy[1];
int size = 0;
for (i = 0; i < count; i++) {
int val;
size += 1; /* For the colon */
val = 0;
ipmi_light_setting_in_local_control(e, i, &val);
if (val)
size += 3;
val = 0;
ipmi_light_setting_get_color(e, i, &val);
size += strlen(ipmi_get_color_string(val)) + 1;
val = 0;
ipmi_light_setting_get_on_time(e, i, &val);
size += snprintf(dummy, 1, "%d ", val);
val = 0;
ipmi_light_setting_get_off_time(e, i, &val);
size += snprintf(dummy, 1, "%d ", val);
}
str = malloc(size + 1);
if (!str)
return NULL;
s = str;
for (i = 0; i < count; i++) {
int val;
const char *ov;
val = 0;
ipmi_light_setting_in_local_control(e, i, &val);
if (val) {
strcpy(s, "lc ");
s += 3;
}
val = 0;
ipmi_light_setting_get_color(e, i, &val);
ov = ipmi_get_color_string(val);
strcpy(s, ov);
s += strlen(ov);
*s = ' ';
s++;
val = 0;
ipmi_light_setting_get_on_time(e, i, &val);
s += sprintf(s, "%d ", val);
val = 0;
ipmi_light_setting_get_off_time(e, i, &val);
s += sprintf(s, "%d", val);
*s = ':';
s++;
}
if (s != str) {
/* Remove the final colon. */
s--;
*s = '\0';
} else {
*s = '\0';
}
return str;
}
static void
handle_control_cb(ipmi_control_t *control, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
control_ref = swig_make_ref(control, ipmi_control_t);
swig_call_cb(cb, "control_cb", "%p", &control_ref);
swig_free_ref_check(control_ref, ipmi_control_t);
}
static void
control_val_set_handler(ipmi_control_t *control, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
control_ref = swig_make_ref(control, ipmi_control_t);
swig_call_cb(cb, "control_set_val_cb", "%p%d", &control_ref, err);
swig_free_ref_check(control_ref, ipmi_control_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
control_val_get_handler(ipmi_control_t *control, int err, int *val,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
control_ref = swig_make_ref(control, ipmi_control_t);
if (err) {
/* On err, value may be NULL */
int dummy;
swig_call_cb(cb, "control_get_val_cb", "%p%d%*p", &control_ref, err,
1, &dummy);
} else {
swig_call_cb(cb, "control_get_val_cb", "%p%d%*p", &control_ref, err,
ipmi_control_get_num_vals(control), val);
}
swig_free_ref_check(control_ref, ipmi_control_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
control_val_get_light_handler(ipmi_control_t *control, int err,
ipmi_light_setting_t *val,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
char *str;
int free_str = 1;
control_ref = swig_make_ref(control, ipmi_control_t);
str = light_setting_to_str(val);
if (!str) {
str = "err";
free_str = 0;
}
swig_call_cb(cb, "control_get_light_cb", "%p%d%s", &control_ref, err, str);
swig_free_ref_check(control_ref, ipmi_control_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
if (free_str)
free(str);
}
static void
control_val_get_id_handler(ipmi_control_t *control, int err,
unsigned char *val, int length,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
control_ref = swig_make_ref(control, ipmi_control_t);
swig_call_cb(cb, "control_get_id_cb", "%p%d%*s", &control_ref, err,
length, val);
swig_free_ref_check(control_ref, ipmi_control_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static int
control_val_event_handler(ipmi_control_t *control, int *valid_vals, int *val,
void *cb_data, ipmi_event_t *event)
{
swig_cb_val *cb = cb_data;
swig_ref control_ref;
swig_ref event_ref;
int rv = IPMI_EVENT_NOT_HANDLED;
control_ref = swig_make_ref(control, ipmi_control_t);
event_ref = swig_make_ref_destruct(ipmi_event_dup(event), ipmi_event_t);
swig_call_cb_rv('I', &rv,
cb, "control_event_val_cb", "%p%p%*p%*p", &control_ref,
&event_ref,
ipmi_control_get_num_vals(control), valid_vals,
ipmi_control_get_num_vals(control), val);
swig_free_ref_check(control_ref, ipmi_control_t);
swig_free_ref(event_ref);
return rv;
}
static void
control_val_event_handler_cl(ipmi_control_val_event_cb handler,
void *handler_data,
void *cb_data)
{
if (handler != control_val_event_handler)
return;
swig_cb_val *handler_val = handler_data;
deref_swig_cb_val(handler_val);
}
static void
lanparm_get_parm(ipmi_lanparm_t *lanparm,
int err,
unsigned char *data,
unsigned int data_len,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref lanparm_ref;
lanparm_ref = swig_make_ref_destruct(lanparm, ipmi_lanparm_t);
swig_call_cb(cb, "lanparm_got_parm_cb", "%p%d%*s", &lanparm_ref, err,
data_len, (char *) data);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(lanparm_ref);
}
static void
lanparm_set_parm(ipmi_lanparm_t *lanparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref lanparm_ref;
if (cb) {
lanparm_ref = swig_make_ref_destruct(lanparm, ipmi_lanparm_t);
swig_call_cb(cb, "lanparm_set_parm_cb", "%p%d", &lanparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(lanparm_ref);
}
}
static void
lanparm_get_config(ipmi_lanparm_t *lanparm,
int err,
ipmi_lan_config_t *config,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref lanparm_ref;
swig_ref config_ref;
lanparm_ref = swig_make_ref_destruct(lanparm, ipmi_lanparm_t);
config_ref = swig_make_ref_destruct(config, ipmi_lan_config_t);
swig_call_cb(cb, "lanparm_got_config_cb", "%p%d%p", &lanparm_ref, err,
&config_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(lanparm_ref);
swig_free_ref(config_ref);
}
static void
lanparm_set_config(ipmi_lanparm_t *lanparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref lanparm_ref;
if (cb) {
lanparm_ref = swig_make_ref_destruct(lanparm, ipmi_lanparm_t);
swig_call_cb(cb, "lanparm_set_config_cb", "%p%d", &lanparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(lanparm_ref);
}
}
static void
lanparm_clear_lock(ipmi_lanparm_t *lanparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref lanparm_ref;
if (cb) {
lanparm_ref = swig_make_ref_destruct(lanparm, ipmi_lanparm_t);
swig_call_cb(cb, "lanparm_clear_lock_cb", "%p%d", &lanparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(lanparm_ref);
}
}
static void
get_pef(ipmi_pef_t *pef, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
ipmi_pef_ref(pef);
swig_call_cb(cb, "got_pef_cb", "%p%d", &pef_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
}
static void
pef_get_parm(ipmi_pef_t *pef,
int err,
unsigned char *data,
unsigned int data_len,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
swig_call_cb(cb, "pef_got_parm_cb", "%p%d%*s", &pef_ref, err,
data_len, (char *) data);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
}
static void
pef_set_parm(ipmi_pef_t *pef,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
if (cb) {
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
swig_call_cb(cb, "pef_set_parm_cb", "%p%d", &pef_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
}
}
static void
pef_get_config(ipmi_pef_t *pef,
int err,
ipmi_pef_config_t *config,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
swig_ref config_ref;
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
config_ref = swig_make_ref_destruct(config, ipmi_pef_config_t);
swig_call_cb(cb, "pef_got_config_cb", "%p%d%p", &pef_ref, err,
&config_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
swig_free_ref(config_ref);
}
static void
pef_set_config(ipmi_pef_t *pef,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
if (cb) {
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
swig_call_cb(cb, "pef_set_config_cb", "%p%d", &pef_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
}
}
static void
pef_clear_lock(ipmi_pef_t *pef,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pef_ref;
if (cb) {
pef_ref = swig_make_ref_destruct(pef, ipmi_pef_t);
swig_call_cb(cb, "pef_clear_lock_cb", "%p%d", &pef_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pef_ref);
}
}
static void
get_pet(ipmi_pet_t *pet, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref pet_ref;
pet_ref = swig_make_ref_destruct(pet, ipmi_pet_t);
ipmi_pet_ref(pet);
swig_call_cb(cb, "got_pet_cb", "%p%d", &pet_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(pet_ref);
}
static void
event_deleted_handler(ipmi_domain_t *domain, int err, void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "event_delete_cb", "%p%d", &domain_ref, err);
swig_free_ref_check(domain_ref, ipmi_domain_t);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
}
static void
sol_connection_state_change_cb(ipmi_sol_conn_t *conn,
ipmi_sol_state state,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_connection_state_change", "%p%d%d",
&conn_ref, state, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
}
static int
sol_data_received_cb(ipmi_sol_conn_t *conn,
const void *buf,
size_t count,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
int rv = 0;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb_rv('i', &rv, cb, "sol_data_received", "%p%*s",
&conn_ref, (int) count, (char *) buf);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
return rv;
}
static void
sol_break_detected_cb(ipmi_sol_conn_t *conn,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_break_detected", "%p", &conn_ref);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
}
static void
sol_bmc_transmit_overrun_cb(ipmi_sol_conn_t *conn,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_bmc_transmit_overrun", "%p", &conn_ref);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
}
static void
sol_write_complete_cb(ipmi_sol_conn_t *conn,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_write_complete", "%p%d", &conn_ref, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
sol_send_break_cb(ipmi_sol_conn_t *conn,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_send_break", "%p%d", &conn_ref, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
sol_set_CTS_assertable_cb(ipmi_sol_conn_t *conn,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_set_CTS_assertable", "%p%d", &conn_ref, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
sol_set_DCD_DSR_asserted_cb(ipmi_sol_conn_t *conn,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_set_DCD_DSR_asserted", "%p%d", &conn_ref, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
sol_set_RI_asserted_cb(ipmi_sol_conn_t *conn,
int error,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_set_RI_asserted", "%p%d", &conn_ref, error);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
sol_flush_complete_cb(ipmi_sol_conn_t *conn,
int error,
int queue_selectors_flushed,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref conn_ref;
conn_ref = swig_make_ref(conn, ipmi_sol_conn_t);
swig_call_cb(cb, "sol_flush_complete", "%p%d%d", &conn_ref, error,
queue_selectors_flushed);
swig_free_ref_check(conn_ref, ipmi_sol_conn_t);
/* One-time callback */
deref_swig_cb_val(cb);
}
static void
solparm_get_parm(ipmi_solparm_t *solparm,
int err,
unsigned char *data,
unsigned int data_len,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref solparm_ref;
solparm_ref = swig_make_ref_destruct(solparm, ipmi_solparm_t);
swig_call_cb(cb, "solparm_got_parm_cb", "%p%d%*s", &solparm_ref, err,
data_len, (char *) data);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(solparm_ref);
}
static void
solparm_set_parm(ipmi_solparm_t *solparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref solparm_ref;
if (cb) {
solparm_ref = swig_make_ref_destruct(solparm, ipmi_solparm_t);
swig_call_cb(cb, "solparm_set_parm_cb", "%p%d", &solparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(solparm_ref);
}
}
static void
solparm_get_config(ipmi_solparm_t *solparm,
int err,
ipmi_sol_config_t *config,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref solparm_ref;
swig_ref config_ref;
solparm_ref = swig_make_ref_destruct(solparm, ipmi_solparm_t);
config_ref = swig_make_ref_destruct(config, ipmi_sol_config_t);
swig_call_cb(cb, "solparm_got_config_cb", "%p%d%p", &solparm_ref, err,
&config_ref);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(solparm_ref);
swig_free_ref(config_ref);
}
static void
solparm_set_config(ipmi_solparm_t *solparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref solparm_ref;
if (cb) {
solparm_ref = swig_make_ref_destruct(solparm, ipmi_solparm_t);
swig_call_cb(cb, "solparm_set_config_cb", "%p%d", &solparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(solparm_ref);
}
}
static void
solparm_clear_lock(ipmi_solparm_t *solparm,
int err,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref solparm_ref;
if (cb) {
solparm_ref = swig_make_ref_destruct(solparm, ipmi_solparm_t);
swig_call_cb(cb, "solparm_clear_lock_cb", "%p%d", &solparm_ref, err);
/* One-time call, get rid of the CB. */
deref_swig_cb_val(cb);
swig_free_ref(solparm_ref);
}
}
#if defined(HAVE_GLIB) || defined(HAVE_GLIB12)
#include <OpenIPMI/ipmi_glib.h>
static void
glib_handle_log(const char *domain,
const char *pfx,
const char *message)
{
swig_cb_val *handler = swig_log_handler;
if (! handler)
return;
swig_call_cb(handler, "log", "%s%s", pfx, message);
}
#if defined(HAVE_GLIB) && defined(HAVE_GLIB12)
#include <dlfcn.h>
#endif
/*
* Initialize the OS handler with the glib version.
*/
os_handler_t *
init_glib_shim(char *ver)
{
os_handler_t *swig_os_hnd;
#if defined(HAVE_GLIB) && defined(HAVE_GLIB12)
/* Two versions of glib. Go through special machinations to make this
work right. We can't directly link with glib, we have to dlopen it
to get the right version. */
static char *olibst = "libOpenIPMIglib%s.so";
char dummy[1];
char *name;
void *hndl;
os_handler_t *(*get)(int);
void (*setlog)(void (*hndlr)(const char *domain,
const char *pfx,
const char *msg));
int len;
len = snprintf(dummy, 1, olibst, ver);
name = malloc(len+1);
if (!name) {
fprintf(stderr, "Unable to allocation memory for glib\n");
abort();
}
snprintf(name, len+1, olibst, ver);
hndl = dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
if (!hndl) {
fprintf(stderr, "Unable to open the glib library: %s: %s\n",
name, dlerror());
free(name);
abort();
}
free(name);
get = dlsym(hndl, "ipmi_glib_get_os_handler");
if (!get) {
fprintf(stderr,
"Could not find glib function: ipmi_glib_get_os_handler: %s\n",
dlerror());
abort();
}
setlog = dlsym(hndl, "ipmi_glib_set_log_handler");
if (!setlog) {
fprintf(stderr,
"Could not find glib function: ipmi_glib_set_log_handler: %s\n",
dlerror());
abort();
}
swig_os_hnd = get(0);
swig_os_hnd->set_log_handler(swig_os_hnd, openipmi_swig_vlog);
ipmi_init(swig_os_hnd);
ipmi_cmdlang_init(swig_os_hnd);
setlog(glib_handle_log);
#else
swig_os_hnd = ipmi_glib_get_os_handler(0);
swig_os_hnd->set_log_handler(swig_os_hnd, openipmi_swig_vlog);
ipmi_init(swig_os_hnd);
ipmi_cmdlang_init(swig_os_hnd);
ipmi_glib_set_log_handler(glib_handle_log);
#endif
return swig_os_hnd;
}
#endif
%}
typedef struct {
} ipmi_domain_t;
typedef struct {
} ipmi_domain_id_t;
typedef struct {
} ipmi_args_t;
typedef struct {
} ipmi_entity_t;
typedef struct {
} ipmi_entity_id_t;
typedef struct {
} ipmi_fru_t;
typedef struct {
} ipmi_fru_node_t;
typedef struct {
} ipmi_mc_t;
typedef struct {
} ipmi_mcid_t;
typedef struct {
} ipmi_event_t;
typedef struct {
} ipmi_sensor_t;
typedef struct {
} ipmi_sensor_id_t;
typedef struct {
} ipmi_control_t;
typedef struct {
} ipmi_control_id_t;
typedef struct {
} ipmi_channel_info_t;
typedef struct {
} ipmi_channel_access_t;
typedef struct {
} ipmi_user_t;
typedef struct {
} ipmi_lanparm_t;
typedef struct {
} ipmi_lan_config_t;
typedef struct {
} ipmi_pef_t;
typedef struct {
} ipmi_pef_config_t;
typedef struct {
} ipmi_pet_t;
typedef struct {
} ipmi_cmdlang_t;
typedef struct {
} ipmi_cmdlang_event_t;
typedef struct {
} ipmi_sol_conn_t;
typedef struct {
} ipmi_sol_config_t;
typedef struct {
} ipmi_solparm_t;
%inline %{
void enable_debug_malloc()
{
if (!swig_os_hnd) {
DEBUG_MALLOC_ENABLE();
}
}
void enable_debug_msg()
{
DEBUG_MSG_ENABLE();
}
void disable_debug_msg()
{
DEBUG_MSG_DISABLE();
}
void enable_debug_rawmsg()
{
DEBUG_RAWMSG_ENABLE();
}
void disable_debug_rawmsg()
{
DEBUG_RAWMSG_DISABLE();
}
int
init_glib(void)
{
#ifdef HAVE_GLIB
if (swig_os_hnd)
return 0;
#ifdef OpenIPMI_HAVE_INIT_LANG
init_lang();
#endif
swig_os_hnd = init_glib_shim("");
return 0;
#else
return ENOSYS;
#endif
}
int
init_glib12(void)
{
#ifdef HAVE_GLIB12
if (swig_os_hnd)
return 0;
#ifdef OpenIPMI_HAVE_INIT_LANG
init_lang();
#endif
swig_os_hnd = init_glib_shim("12");
return 0;
#else
return ENOSYS;
#endif
}
#if defined(HAVE_TCL)
#include <OpenIPMI/ipmi_tcl.h>
#endif
int
init_tcl(void)
{
#ifdef HAVE_TCL
if (swig_os_hnd)
return 0;
#ifdef OpenIPMI_HAVE_INIT_LANG
init_lang();
#endif
swig_os_hnd = ipmi_tcl_get_os_handler(0);
swig_os_hnd->set_log_handler(swig_os_hnd, openipmi_swig_vlog);
ipmi_init(swig_os_hnd);
ipmi_cmdlang_init(swig_os_hnd);
return 0;
#else
return ENOSYS;
#endif
}
/*
* Initialize the OS handler and use the POSIX version.
*/
int
init_posix(void)
{
if (swig_os_hnd)
return 0;
#ifdef OpenIPMI_HAVE_INIT_LANG
init_lang();
#endif
#ifdef USE_POSIX_THREADS
swig_os_hnd = ipmi_posix_thread_setup_os_handler(SIGUSR1);
#else
swig_os_hnd = ipmi_posix_setup_os_handler();
#endif
swig_os_hnd->set_log_handler(swig_os_hnd, openipmi_swig_vlog);
ipmi_init(swig_os_hnd);
ipmi_cmdlang_init(swig_os_hnd);
return 0;
}
/*
* Initialize the OS handler with the default version. This is glib
* if it is present, POSIX if it is not.
*/
int
init(void)
{
int rv;
if (rv = init_glib())
rv = init_posix();
return rv;
}
/*
* Free up all the memory used by OpenIPMI.
*/
void
shutdown_everything()
{
IPMI_SWIG_C_CB_ENTRY
ipmi_cmdlang_cleanup();
ipmi_shutdown();
swig_os_hnd->free_os_handler(swig_os_hnd);
swig_os_hnd = NULL;
#ifdef OpenIPMI_HAVE_CLEANUP_LANG
void cleanup_lang();
#endif
IPMI_SWIG_C_CB_EXIT
}
/*
* Perform one operation. The first parameter is a timeout in
* milliseconds.
*/
void
wait_io(int timeout)
{
struct timeval tv = { (timeout / 1000), ((timeout + 999) % 1000) };
IPMI_SWIG_C_BLOCK_ENTRY
swig_os_hnd->perform_one_op(swig_os_hnd, &tv);
IPMI_SWIG_C_BLOCK_EXIT
}
%}
/*
* Error return constants returned by OpenIPMI.
*/
%constant int ebadf = EBADF;
%constant int einval = EINVAL;
%constant int e2big = E2BIG;
%constant int enomem = ENOMEM;
%constant int enoent = ENOENT;
%constant int ecanceled = ECANCELED;
%constant int enosys = ENOSYS;
%constant int eexist = EEXIST;
%constant int eagain = EAGAIN;
%constant int eperm = EPERM;
/*
* Return values for event handlers
*/
%constant int EVENT_NOT_HANDLED = IPMI_EVENT_NOT_HANDLED;
%constant int EVENT_HANDLED = IPMI_EVENT_HANDLED;
%constant int EVENT_HANDLED_PASS = IPMI_EVENT_HANDLED_PASS;
/* These two defines simplify the functions that do addition/removal
of callbacks. The type is the object type (domain, entity, etc)
and the name is the stuff in the middle of the name, ie
(ipmi_<type>_add_<name>_handler. The function that will be called
with the info is <type>_<name>_handler. */
#define cb_add(type, name, func) \
int rv; \
swig_cb_val *handler_val; \
IPMI_SWIG_C_CB_ENTRY \
if (! valid_swig_cb(handler, func)) \
rv = EINVAL; \
else { \
handler_val = ref_swig_cb(handler, func); \
rv = ipmi_ ## type ## _add_ ## name ## _handler \
(self, type ## _ ## name ## _handler, handler_val); \
if (rv) \
deref_swig_cb_val(handler_val); \
} \
IPMI_SWIG_C_CB_EXIT \
return rv;
#define cb_rm(type, name, func) \
int rv; \
swig_cb_val *handler_val; \
IPMI_SWIG_C_CB_ENTRY \
if (! valid_swig_cb(handler, func)) \
rv = EINVAL; \
else { \
handler_val = get_swig_cb(handler, func); \
rv = ipmi_ ## type ## _remove_ ## name ##_handler \
(self, type ## _ ## name ## _handler, handler_val); \
if (!rv) \
deref_swig_cb_val(handler_val); \
} \
IPMI_SWIG_C_CB_EXIT \
return rv;
/*
* A bug in swig (default parameters not used in inline) causes this
* to have to not be in an inline and done the hard way.
*/
%{
static void
domain_cleanup_add(ipmi_domain_t *domain, void *cb_data)
{
ipmi_domain_add_connect_change_handler_cl
(domain, domain_connect_change_handler_cl, NULL);
}
static ipmi_domain_id_t *
open_domain(char *name, argarray *args, swig_cb *done, swig_cb *up)
{
int i, j;
int num_options = 0;
ipmi_open_option_t options[10];
int set = 0;
ipmi_args_t *con_parms[2];
ipmi_con_t *con[2];
ipmi_domain_id_t *nd;
int rv;
swig_cb_val *done_val = NULL;
swig_cb_val *up_val = NULL;
ipmi_domain_con_cb con_change = NULL;
ipmi_domain_ptr_cb domain_up = NULL;
IPMI_SWIG_C_CB_ENTRY
nd = malloc(sizeof(*nd));
for (i=0; i<args->len; i++) {
if (num_options >= 10) {
free(nd);
nd = NULL;
goto out_err;
}
if (! ipmi_parse_options(options+num_options, args->val[i]))
num_options++;
else
break;
}
rv = ipmi_parse_args(&i, args->len, args->val, &con_parms[set]);
if (rv) {
free(nd);
nd = NULL;
goto out_err;
}
set++;
if (i < args->len) {
rv = ipmi_parse_args(&i, args->len, args->val, &con_parms[set]);
if (rv) {
ipmi_free_args(con_parms[0]);
free(nd);
nd = NULL;
goto out_err;
}
set++;
}
for (i=0; i<set; i++) {
rv = ipmi_args_setup_con(con_parms[i],
swig_os_hnd,
NULL,
&con[i]);
if (rv) {
for (j=0; j<i; j++)
con[j]->close_connection(con[j]);
free(nd);
nd = NULL;
goto out;
}
}
if (!nil_swig_cb(up)) {
if (valid_swig_cb(up, domain_up_cb)) {
up_val = ref_swig_cb(up, domain_up_cb);
domain_up = domain_fully_up;
} else {
free(nd);
nd = NULL;
goto out;
}
}
if (!nil_swig_cb(done)){
if (valid_swig_cb(done, conn_change_cb)) {
done_val = ref_swig_cb(done, conn_change_cb);
con_change = domain_connect_change_handler;
} else {
if (domain_up)
deref_swig_cb(up);
free(nd);
nd = NULL;
goto out;
}
}
rv = ipmi_open_domain(name, con, set, con_change, done_val,
domain_up, up_val,
options, num_options, nd);
if (rv) {
if (domain_up)
deref_swig_cb(up);
if (con_change)
deref_swig_cb(done);
for (i=0; i<set; i++)
con[i]->close_connection(con[i]);
free(nd);
nd = NULL;
goto out;
}
ipmi_domain_pointer_cb(*nd, domain_cleanup_add, NULL);
out:
for (i=0; i<set; i++)
ipmi_free_args(con_parms[i]);
out_err:
IPMI_SWIG_C_CB_EXIT
return nd;
}
static ipmi_domain_id_t *
open_domain2(char *name, argarray *args, swig_cb *done, swig_cb *up)
{
int i, j;
int num_options = 0;
ipmi_open_option_t options[10];
int set = 0;
ipmi_args_t *con_parms[2];
ipmi_con_t *con[2];
ipmi_domain_id_t *nd;
int rv;
swig_cb_val *done_val = NULL;
swig_cb_val *up_val = NULL;
ipmi_domain_con_cb con_change = NULL;
ipmi_domain_ptr_cb domain_up = NULL;
IPMI_SWIG_C_CB_ENTRY
nd = malloc(sizeof(*nd));
for (i=0; i<args->len; i++) {
if (num_options >= 10) {
free(nd);
nd = NULL;
goto out_err;
}
if (! ipmi_parse_options(options+num_options, args->val[i]))
num_options++;
else
break;
}
rv = ipmi_parse_args2(&i, args->len, args->val, &con_parms[set]);
if (rv) {
free(nd);
nd = NULL;
goto out_err;
}
set++;
if (i < args->len) {
rv = ipmi_parse_args2(&i, args->len, args->val, &con_parms[set]);
if (rv) {
ipmi_free_args(con_parms[0]);
free(nd);
nd = NULL;
goto out_err;
}
set++;
}
for (i=0; i<set; i++) {
rv = ipmi_args_setup_con(con_parms[i],
swig_os_hnd,
NULL,
&con[i]);
if (rv) {
for (j=0; j<i; j++)
con[j]->close_connection(con[j]);
free(nd);
nd = NULL;
goto out;
}
}
if (!nil_swig_cb(up)) {
if (valid_swig_cb(up, domain_up_cb)) {
up_val = ref_swig_cb(up, domain_up_cb);
domain_up = domain_fully_up;
} else {
free(nd);
nd = NULL;
goto out;
}
}
if (!nil_swig_cb(done)){
if (valid_swig_cb(done, conn_change_cb)) {
done_val = ref_swig_cb(done, conn_change_cb);
con_change = domain_connect_change_handler;
} else {
if (domain_up)
deref_swig_cb(up);
free(nd);
nd = NULL;
goto out;
}
}
rv = ipmi_open_domain(name, con, set, con_change, done_val,
domain_up, up_val,
options, num_options, nd);
if (rv) {
if (domain_up)
deref_swig_cb(up);
if (con_change)
deref_swig_cb(done);
for (i=0; i<set; i++)
con[i]->close_connection(con[i]);
free(nd);
nd = NULL;
goto out;
}
ipmi_domain_pointer_cb(*nd, domain_cleanup_add, NULL);
out:
for (i=0; i<set; i++)
ipmi_free_args(con_parms[i]);
out_err:
IPMI_SWIG_C_CB_EXIT
return nd;
}
static ipmi_domain_id_t *
open_domain3(char *name, argarray *ioptions, iargarray *args,
swig_cb *done, swig_cb *up)
{
int i, j;
int num_options = 0;
ipmi_open_option_t options[10];
int set = 0;
ipmi_con_t *con[2];
ipmi_domain_id_t *nd;
int rv;
swig_cb_val *done_val = NULL;
swig_cb_val *up_val = NULL;
ipmi_domain_con_cb con_change = NULL;
ipmi_domain_ptr_cb domain_up = NULL;
IPMI_SWIG_C_CB_ENTRY
nd = malloc(sizeof(*nd));
for (i=0; i<ioptions->len; i++) {
if (num_options >= 10) {
free(nd);
nd = NULL;
goto out_err;
}
if (! ipmi_parse_options(options+num_options, ioptions->val[i]))
num_options++;
else
break;
}
for (i=0; i<args->len; i++) {
rv = ipmi_args_setup_con(args->val[i],
swig_os_hnd,
NULL,
&con[i]);
if (rv) {
for (j=0; j<i; j++)
con[j]->close_connection(con[j]);
free(nd);
nd = NULL;
goto out;
}
set++;
}
if (!nil_swig_cb(up)) {
if (valid_swig_cb(up, domain_up_cb)) {
up_val = ref_swig_cb(up, domain_up_cb);
domain_up = domain_fully_up;
} else {
free(nd);
nd = NULL;
goto out;
}
}
if (!nil_swig_cb(done)){
if (valid_swig_cb(done, conn_change_cb)) {
done_val = ref_swig_cb(done, conn_change_cb);
con_change = domain_connect_change_handler;
} else {
if (domain_up)
deref_swig_cb(up);
free(nd);
nd = NULL;
goto out;
}
}
rv = ipmi_open_domain(name, con, set, con_change, done_val,
domain_up, up_val,
options, num_options, nd);
if (rv) {
if (domain_up)
deref_swig_cb(up);
if (con_change)
deref_swig_cb(done);
for (i=0; i<set; i++)
con[i]->close_connection(con[i]);
free(nd);
nd = NULL;
goto out;
}
ipmi_domain_pointer_cb(*nd, domain_cleanup_add, NULL);
out:
out_err:
IPMI_SWIG_C_CB_EXIT
return nd;
}
static void
set_log_handler(swig_cb *handler)
{
swig_cb_val *old_handler = swig_log_handler;
IPMI_SWIG_C_CB_ENTRY
if (valid_swig_cb(handler, log))
swig_log_handler = ref_swig_cb(handler, log);
else
swig_log_handler = NULL;
if (old_handler)
deref_swig_cb_val(old_handler);
IPMI_SWIG_C_CB_EXIT
}
static const char *
color_string(int color)
{
return ipmi_get_color_string(color);
}
static const char *
lanparm_parm_to_str(int parm)
{
return ipmi_lanconfig_parm_to_str(parm);
}
static int
lanconfig_enum_val(int parm, int val, int *nval, const char **sval)
{
return ipmi_lanconfig_enum_val(parm, val, nval, sval);
}
static int
lanconfig_enum_idx(int parm, int idx, const char **sval)
{
return ipmi_lanconfig_enum_idx(parm, idx, sval);
}
static int
lanparm_str_to_parm(char *str)
{
return ipmi_lanconfig_str_to_parm(str);
}
static const char *
pef_parm_to_str(int parm)
{
return ipmi_pefconfig_parm_to_str(parm);
}
static int
pef_str_to_parm(char *str)
{
return ipmi_pefconfig_str_to_parm(str);
}
static int
pefconfig_enum_val(int parm, int val, int *nval, const char **sval)
{
return ipmi_lanconfig_enum_val(parm, val, nval, sval);
}
static int
pefconfig_enum_idx(int parm, int idx, const char **sval)
{
return ipmi_pefconfig_enum_idx(parm, idx, sval);
}
static const char *
get_threshold_access_support_string(int val)
{
return ipmi_get_threshold_access_support_string(val);
}
static const char *
get_hysteresis_support_string(int val)
{
return ipmi_get_hysteresis_support_string(val);
}
static const char *
get_event_support_string(int val)
{
return ipmi_get_event_support_string(val);
}
static const char *
channel_medium_string(int val)
{
return ipmi_channel_medium_string(val);
}
static const char *
channel_protocol_string(int val)
{
return ipmi_channel_protocol_string(val);
}
static const char *
channel_session_support_string(int val)
{
return ipmi_channel_session_support_string(val);
}
static const char *
channel_access_mode_string(int val)
{
return ipmi_channel_access_mode_string(val);
}
static const char *
privilege_string(int val)
{
return ipmi_privilege_string(val);
}
static const char *
authtype_string(int val)
{
return ipmi_authtype_string(val);
}
static const char *
solparm_parm_to_str(int parm)
{
return ipmi_solconfig_parm_to_str(parm);
}
static int
solparm_str_to_parm(char *str)
{
return ipmi_solconfig_str_to_parm(str);
}
static int
solconfig_enum_val(int parm, int val, int *nval, const char **sval)
{
return ipmi_solconfig_enum_val(parm, val, nval, sval);
}
static int
solconfig_enum_idx(int parm, int idx, const char **sval)
{
return ipmi_solconfig_enum_idx(parm, idx, sval);
}
static char *
get_error_string(unsigned int err)
{
int len;
char *buf;
len = ipmi_get_error_string_len(err);
buf = malloc(len);
if (!buf)
return NULL;
ipmi_get_error_string(err, buf, len);
return buf;
}
static void
domain_change_handler(ipmi_domain_t *domain,
enum ipmi_update_e op,
void *cb_data)
{
swig_cb_val *cb = cb_data;
swig_ref domain_ref;
domain_ref = swig_make_ref(domain, ipmi_domain_t);
swig_call_cb(cb, "domain_change_cb", "%s%p",
ipmi_update_e_string(op), &domain_ref);
swig_free_ref_check(domain_ref, ipmi_domain_t);
}
int
add_domain_change_handler(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_change_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, domain_change_cb);
rv = ipmi_domain_add_domain_change_handler(domain_change_handler,
handler_val);
if (rv)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
int
remove_domain_change_handler(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_change_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = get_swig_cb(handler, domain_change_cb);
rv = ipmi_domain_remove_domain_change_handler(domain_change_handler,
handler_val);
if (!rv)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%}
%newobject open_domain;
%newobject open_domain2;
%newobject open_domain3;
/*
* Create a new domain. The domain will be named with the first parm,
* the startup arguments are in a reference to a list in the second
* parm (\@args), the third parm is a callback object whose
* conn_change_cb method will be called when the domain has connected
* (but it may not be fully up yet). The fourth parameter's
* domain_up_cb method will be called when the domain is completely up
* Note that the done method will be kept around and will continue to
* be called on connection changes. If you don't want it any more,
* it must be deregistered with remove_connect_change_handler.
* Passing in a reference to an undefined value will cause the handlers
* to not be called.
* The domain_up_cb methods is called with the following parmeters:
* <self> <domain>
* The parameters of the connection change handler are defined in
* the domain->add_connect_change_handler method.
* The third and fourth parameters are optional, if not provided
* or undefined the handler will be ignored.
*
* The format of the arguments is the same as described in the
* ipmi_cmdlang.7 man page for domain open, except the -wait_til_up
* option is not supported. See that for more details. These options
* allow you to turn on and off various automatic operations that
* OpenIPMI does, such as scanning SDRs, fetching the SEL, etc.
*/
ipmi_domain_id_t *open_domain(char *name, argarray *args,
swig_cb *done = NULL, swig_cb *up = NULL);
/*
* Like open_domain, but takes the new parameter types and is more
* flexible. This is required for RMCP+.
*/
ipmi_domain_id_t *open_domain2(char *name, argarray *args,
swig_cb *done = NULL, swig_cb *up = NULL);
/*
* Like open_domain2, but takes ipmi_args_t. Works with RMCP+.
*/
ipmi_domain_id_t *open_domain3(char *name, argarray *options,
iargarray *args,
swig_cb *done = NULL, swig_cb *up = NULL);
/*
* Iterate through the help for the various connection types used with
* open_domain2() and open_domain3() and argument parsing and
* allocating. This will call the parse_args_iter_help_cb method on
* the supplied object for each registered connection type. The
* parameters are <self> <name> <help>. This can also be used to find
* the names of all registered connections.
*/
void parse_args_iter_help(swig_cb *help_cb);
%{
static void parse_args_iter_help(swig_cb *help_cb)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(help_cb, parse_args_iter_help_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(help_cb, parse_args_iter_help_cb);
ipmi_parse_args_iter_help(parse_args_iter_help_hnd, handler_val);
}
IPMI_SWIG_C_CB_EXIT
}
%}
const char *parse_option_help();
%{
static const char *parse_option_help(void)
{
return ipmi_parse_options_help();
}
%}
/*
* Add a handler whose domain_change_cb method will be called whenever
* a domain is added or removed. The handler will be called with the
* following parameters: <self> added|deleted|changed <domain>
*/
int add_domain_change_handler(swig_cb *handler);
/*
* Remove a previously registered domain handler.
*/
int
remove_domain_change_handler(swig_cb *handler);
/*
* Set the handler for OpenIPMI logs. This is a global value and
* there is only one, setting it replaces the old one. The logs will
* be sent to the "log" method of the first parameter. The log method
* will receive the following parameters: <self>, <log_level (a
* string)>, and <log (a string)>. If the log method is undefined or
* not provided, the current log handler will be removed.
*/
void set_log_handler(swig_cb *handler = NULL);
/*
* Convert the given color to a string.
*/
char *color_string(int color);
/* Convert between lanparm string names and parm numbers. */
char *lanparm_parm_to_str(int parm);
int lanparm_str_to_parm(char *str);
/* Used to discover enum values for lanparms. */
int lanconfig_enum_val(int parm, int val, int *nval, const char **sval);
int lanconfig_enum_idx(int parm, int idx, const char **sval);
/* Convert between pef string names and parm numbers. */
char *pef_parm_to_str(int parm);
int pef_str_to_parm(char *str);
/* Used to discover enum values for lanparms. */
int pefconfig_enum_val(int parm, int val, int *nval, const char **sval);
int pefconfig_enum_idx(int parm, int idx, const char **sval);
/* Convert between SoL string names and parm numbers. */
char *solparm_parm_to_str(int parm);
int solparm_str_to_parm(char *str);
/* Used to discover enum values for solparms. */
int solconfig_enum_val(int parm, int val, int *nval, const char **sval);
int solconfig_enum_idx(int parm, int idx, const char **sval);
/* Convert various sensor values to strings. */
char *get_threshold_access_support_string(int val);
char *get_hysteresis_support_string(int val);
char *get_event_support_string(int val);
/* Convert various channel/mc values to strings. */
char *channel_medium_string(int val);
char *channel_protocol_string(int val);
char *channel_session_support_string(int val);
char *channel_access_mode_string(int val);
char *privilege_string(int val);
char *authtype_string(int val);
%newobject get_error_string;
char *get_error_string(unsigned int val);
%constant long long TIMEOUT_FOREVER = IPMI_TIMEOUT_FOREVER;
/*
* A domain id object. This object is guaranteed to be valid and
* can be converted into a domain pointer later.
*/
%extend ipmi_domain_id_t {
~ipmi_domain_id_t()
{
free(self);
}
/* Compare self with other, return -1 if self<other, 0 if
self==other, or 1 if self>other. */
int cmp(ipmi_domain_id_t *other)
{
return ipmi_cmp_domain_id(*self, *other);
}
/*
* Convert a domain id to a domain pointer. The "domain_cb" method
* will be called on the first parameter with the following parameters:
* <self> <domain>
*/
int to_domain(swig_cb *handler)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_cb))
rv = EINVAL;
else
rv = ipmi_domain_pointer_cb(*self, handle_domain_cb,
get_swig_cb(handler, domain_cb));
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
/*
* A domain object.
*/
%extend ipmi_domain_t {
%newobject get_name;
/*
* Get the name of the domain.
*/
char *get_name()
{
char name[IPMI_DOMAIN_NAME_LEN];
ipmi_domain_get_name(self, name, sizeof(name));
return strdup(name);
}
%newobject get_id;
/*
* Get the ID of the domain so you can hold on to the reference.
*/
ipmi_domain_id_t *get_id()
{
ipmi_domain_id_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_domain_convert_to_id(self);
return rv;
}
%newobject get_guid;
/*
* Get the system GUID for the domain. Returns NULL if it is not
* supported.
*/
char *get_guid()
{
char *str = NULL;
unsigned char guid[16];
if (ipmi_domain_get_guid(self, guid) == 0) {
str = malloc(16 * 3);
if (str) {
char *s = str;
int i;
s += sprintf(s, "%2.2x", guid[0]);
for (i=1; i<16; i++)
s += sprintf(s, " %2.2x", guid[i]);
}
}
return str;
}
/*
* Shut down the connections to the domain and free it up. The
* domain_close_done_cb method for the handler object will be
* called with the following parameters: <self>
*/
int close(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_close_done_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, domain_close_done_cb);
rv = ipmi_domain_close(self, domain_close_done, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Add a handler to be called when the connection changes status.
* The conn_change_cb method on the first parameter will be
* called when the connection changes status with the following
* parameters: <self>, <domain>, <errorval>, <connection_number>,
* <port_number>, <anything_still_connected>.
*/
int add_connect_change_handler(swig_cb *handler)
{
/* cleanup handler is added when the domain is added. */
cb_add(domain, connect_change, conn_change_cb);
}
/*
* Remove the connection change handler.
*/
int remove_connect_change_handler(swig_cb *handler)
{
cb_rm(domain, connect_change, conn_change_cb);
}
/*
* Iterate through all the connections in the object. The
* domain_iter_connection_cb method will be called on the first
* parameter for each connection in the domain. The parameters it
* receives will be: <self>, <domain>, <connection (integer)>.
*/
int iterate_connections(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_iter_connection_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, domain_iter_connection_cb);
ipmi_domain_iterate_connections(self,
domain_iterate_connections_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Attempt to activate the given connection.
*/
int activate_connection(int connection)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
rv = ipmi_domain_activate_connection(self, connection);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Parm 1 is a connection number. Sets the second parameter to
* true if the connection is active, false if not. Returns an
* error value.
*/
int is_connection_active(int connection, unsigned int *active)
{
return ipmi_domain_is_connection_active(self, connection, active);
}
/*
* Parm 1 is a connection number. Sets the second parameter to true
* if the connection is up, false if not. Returns an error value.
*/
int is_connection_up(int connection, unsigned int *up)
{
return ipmi_domain_is_connection_up(self, connection, up);
}
/*
* Parm 1 is a connection number. Sets the second parameter to
* the number of ports in the connection. A connection may have
* multiple ports (ie, multiple IP addresses to the same BMC,
* whereas a separate connection is a connection to a different
* BMC); these functions let you check their status. Returns an
* error value.
*/
int num_connection_ports(int connection, unsigned int *ports)
{
return ipmi_domain_num_connection_ports(self, connection, ports);
}
/*
* Parm 1 is a connection number, parm 2 is a port number. Sets
* parm 3 to true if the given port is up, false if not. Returns
* an error value.
*/
int is_connection_port_up(int connection,
int port,
unsigned int *up)
{
return ipmi_domain_is_connection_port_up(self, connection, port, up);
}
%newobject get_port_info;
char *get_port_info(int connection, int port)
{
int rv;
char buf[256];
int len = sizeof(buf);
rv = ipmi_domain_get_port_info(self, connection, port, buf, &len);
if (rv)
return NULL;
return strdup(buf);
}
%newobject get_connection_args;
ipmi_args_t *get_connection_args(int connection)
{
return ipmi_domain_get_connection_args(self, connection);
}
char *get_connection_type(int connection)
{
return ipmi_domain_get_connection_type(self, connection);
}
/*
* Add a handler to be called when an entity is added, updated, or
* removed. When the entity is updated the entity_update_cb
* method on the first parameter will be called with the following
* parameters: <self>, added|deleted|changed <domain>, <entity>.
*/
int add_entity_update_handler(swig_cb *handler)
{
ipmi_domain_add_entity_update_handler_cl
(self, domain_entity_update_handler_cl, NULL);
cb_add(domain, entity_update, entity_update_cb);
}
/*
* Remove the entity change handler.
*/
int remove_entity_update_handler(swig_cb *handler)
{
cb_rm(domain, entity_update, entity_update_cb);
}
/*
* Iterate through all the entities in the object. The
* domain_iter_entities_cb method will be called on the first
* parameter for each entity in the domain. The parameters it
* receives will be: <self> <domain> <entity>.
*/
int iterate_entities(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_iter_entities_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, domain_iter_entities_cb);
ipmi_domain_iterate_entities(self, domain_iterate_entities_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Add a handler to be called when an MC is added, updated, or
* removed. When the mc is updated the mc_update_cb method on the
* first parameter will be called with the following parameters:
* <self>, added|deleted|changed <domain>, <mc>.
*/
int add_mc_update_handler(swig_cb *handler)
{
ipmi_domain_add_mc_updated_handler_cl
(self, domain_mc_updated_handler_cl, NULL);
cb_add(domain, mc_updated, mc_update_cb);
}
/*
* Remove the mc change handler.
*/
int remove_mc_update_handler(swig_cb *handler)
{
cb_rm(domain, mc_updated, mc_update_cb);
}
/*
* Iterate through all the MCs in the object. The
* domain_iter_mc_cb method will be called on the first parameter for
* each mc in the domain. The parameters it receives will be:
* <self> <domain> <mc>.
*/
int iterate_mcs(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, domain_iter_mc_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, domain_iter_mc_cb);
ipmi_domain_iterate_mcs(self, domain_iterate_mcs_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Return the type of the domain, either unknown, mxp, or atca.
* Others may be added later.
*/
const char *get_type()
{
return ipmi_domain_get_type_string(ipmi_domain_get_type(self));
}
/*
* Scan all the addresses on the given channel (parm 1) between
* (and including) start_addr (parm 2) and end_addr (parm 3) and
* call the "domain_ipmb_mc_scan_cb" method on the handler (parm4)
* with the following parms (if the parm is provided and defined):
* <self>, <domain>, <error val>
*/
int start_ipmb_mc_scan(int channel, int start_addr, int end_addr,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_domain_cb domain_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, domain_ipmb_mc_scan_cb)) {
rv = EINVAL;
goto out_err;
}
domain_cb = ipmb_mc_scan_handler;
handler_val = ref_swig_cb(handler, domain_ipmb_mc_scan_cb);
}
rv = ipmi_start_ipmb_mc_scan(self, channel, start_addr, end_addr,
domain_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/* Scan all IPMB busses for new/lost MCs. */
void start_full_ipmb_scan()
{
ipmi_domain_start_full_ipmb_scan(self);
}
/*
* Send a command to a given address (parm 1) with the given lun
* (parm 2), netfn (parm 3), command (parm 4). Parm 5 is the
* message data in an array reference. Parm 6 is the handler, it
* will be called with the response. The addr_cmd_cb method will
* be called on the handler handler if it is provided and defined;
* its parameters are: <domain> <addr> <lun> <netfn> <cmd>
* <response data>
*/
int send_command_addr(char *addr, int lun, int netfn, int cmd,
intarray msg_data, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_addr_response_handler_t msg_cb = NULL;
ipmi_addr_t iaddr;
unsigned int addr_len;
ipmi_msg_t msg;
unsigned char data[MAX_IPMI_DATA_SIZE];
unsigned int data_len;
IPMI_SWIG_C_CB_ENTRY
rv = parse_ipmi_addr(addr, lun, &iaddr, &addr_len);
if (rv)
goto out_err;
msg.netfn = netfn;
msg.cmd = cmd;
msg.data = data;
rv = parse_ipmi_data(msg_data, data, sizeof(data), &data_len);
msg.data_len = data_len;
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, addr_cmd_cb)) {
rv = EINVAL;
goto out_err;
}
msg_cb = domain_msg_cb;
handler_val = ref_swig_cb(handler, addr_cmd_cb);
}
rv = ipmi_send_command_addr(self, &iaddr, addr_len, &msg,
msg_cb, handler_val, NULL);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Cause the domain to start detecting presence changes. If parm
* 1 is supplied, it tells whether to force all entities to have
* their presence checked (if true) or just detect entity presence
* for ones that might have changed.
*/
int detect_presence_changes(int force = 0)
{
return ipmi_detect_domain_presence_changes(self, force);
}
/*
* Set the time (in seconds) between SEL rescans for all
* SELs in the domain
*/
void set_sel_rescan_time(int seconds)
{
return ipmi_domain_set_sel_rescan_time(self, seconds);
}
/*
* Get the default SEL rescan time for the domain.
*/
int get_sel_rescan_time()
{
return ipmi_domain_get_sel_rescan_time(self);
}
/*
* Set the time (in seconds) between IPMB bus rescans for the
* domain.
*/
void set_ipmb_rescan_time(int seconds)
{
return ipmi_domain_set_ipmb_rescan_time(self, seconds);
}
/*
* Get the default IPMB rescan time for the domain.
*/
int get_ipmb_rescan_time()
{
return ipmi_domain_get_ipmb_rescan_time(self);
}
/*
* Add a handler to be called when a new unhandled event comes
* into the domain. When the event comes in, the event_cb method
* on the first parameter will be called with the following
* parameters: <self>, <domain>, <event>
*/
int add_event_handler(swig_cb *handler)
{
ipmi_domain_add_event_handler_cl
(self, domain_event_handler_cl, NULL);
cb_add(domain, event, event_cb);
}
/*
* Remove the event handler.
*/
int remove_event_handler(swig_cb *handler)
{
cb_rm(domain, event, event_cb);
}
%newobject first_event;
/*
* Retrieve the first event from the domain. Return NULL (undef)
* if the event does not exist.
*/
ipmi_event_t *first_event()
{
return ipmi_domain_first_event(self);
}
%newobject last_event;
/*
* Retrieve the last event from the domain.
*/
ipmi_event_t *last_event()
{
return ipmi_domain_last_event(self);
}
%newobject next_event;
/*
* Retrieve the event after the given event from the domain.
*/
ipmi_event_t *next_event(ipmi_event_t *event)
{
return ipmi_domain_next_event(self, event);
}
%newobject prev_event;
/*
* Retrieve the event before the given event from the domain.
*/
ipmi_event_t *prev_event(ipmi_event_t *event)
{
return ipmi_domain_prev_event(self, event);
}
/*
* Number of live entries in the local SEL copy.
*/
int sel_count()
{
int rv;
unsigned int count;
rv = ipmi_domain_sel_count(self, &count);
if (rv)
return 0;
else
return count;
}
/*
* Number of entries in the the remote SEL. If an entry has been
* deleted in the local copy of the SEL but has not yet finished
* being deleted in the remote copy, it will be counted here.
*/
int sel_entries_used()
{
int rv;
unsigned int count;
rv = ipmi_domain_sel_entries_used(self, &count);
if (rv)
return 0;
else
return count;
}
/*
* Reread all SELs in the domain. The domain_reread_sels_cb
* method on the first parameter (if supplied) will be called with
* the following values: <domain> <error value>
*/
int reread_sels(swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_domain_cb domain_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, domain_reread_sels_cb)) {
rv = EINVAL;
goto out_err;
}
domain_cb = domain_reread_sels_handler;
handler_val = ref_swig_cb(handler, domain_reread_sels_cb);
}
rv = ipmi_domain_reread_sels(self, domain_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Fetch a FRU with the given parameters. The first parameter (the object)
* is the domain, successive parameters are:
* is_logical - do a logical or physical FRU fetch.
* device_address - The IPMB address of the FRU device.
* device_id - The particular FRU device id to fetch.
* LUN - The LUN to talk to for the device.
* private_bus - for physical FRUs, the bus it is on.
* channel - The channel where the device is located.
* If the handler is supplied, then the fru_fetched method on that
* will be called upon completion with the handler object as the first
* parameter, the domain as the second, the FRU as the third, and an
* error value as the fourth.
* This returns the FRU, or undefined if a failure occurred.
*/
%newobject fru_alloc;
ipmi_fru_t *fru_alloc(int is_logical, int device_address, int device_id,
int lun, int private_bus, int channel,
swig_cb *handler = NULL)
{
ipmi_fru_t *fru = NULL;
int rv;
swig_cb_val *handler_val = NULL;
ipmi_fru_cb cb_handler = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, fru_fetched))
goto out_err;
cb_handler = fru_fetched;
handler_val = ref_swig_cb(handler, fru_fetched);
}
rv = ipmi_domain_fru_alloc(self, is_logical, device_address, device_id,
lun, private_bus, channel, cb_handler,
handler_val, &fru);
if (rv) {
if (handler_val)
deref_swig_cb_val(handler_val);
fru = NULL;
} else {
/* We have one ref for the callback already, add a ref for
the returned value. */
if (handler_val)
ipmi_fru_ref(fru);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return fru;
}
/*
* Allocate a pet object for the domain over the given connection.
* The pet is returned. The ninth parameter is an optional
* callback object, the got_pet_cb method will be called on it
* when the PET fetch is complete. It will have the following
* parameters: <self> <pet> <err>. The parameters are:
* int connection: the connection to the domain to set up the PET for
* int channel: the channel number to set the PET for
* char ip_addr: the address to send the traps to
* char mac_addr: the mac address to send the traps to
* The rest are the selectors in the various tables, you have to
* read the spec and know your system to know how to set them.
* int eft_sel:
* int policy_num:
* int apt_sel:
* int lan_dest_sel:
*
* Note that you must keep a reference to the pet around, or it will
* be automatically destroyed by the garbage collector.
*/
%newobject get_pet;
ipmi_pet_t *get_pet(int connection,
int channel,
char *ip_addr,
char *mac_addr,
int eft_sel,
int policy_num,
int apt_sel,
int lan_dest_sel,
swig_cb *handler = NULL)
{
int rv;
ipmi_pet_t *pet = NULL;
swig_cb_val *handler_val = NULL;
struct in_addr ip;
unsigned char mac[6];
ipmi_pet_done_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
rv = parse_ip_addr(ip_addr, &ip);
if (rv)
goto out_err;
rv = parse_mac_addr(mac_addr, mac);
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, got_pet_cb))
goto out_err;
handler_val = ref_swig_cb(handler, got_pet_cb);
done = get_pet;
}
rv = ipmi_pet_create(self, connection, channel, ip, mac, eft_sel,
policy_num, apt_sel, lan_dest_sel, get_pet,
handler_val, &pet);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return pet;
}
/*
* Allocate a SoL object using the given domain's connection.
* Note that this does not cause a connection, it just creates an
* object for doing an SoL connection.
*
* The handler val will handle all events from the SOL session.
* this means it must implement the following callbacks:
*
* sol_connection_state_change <self> <conn> <state> <error>
* sol_data_received <self> <conn> <string>
* sol_break_detected <self> <conn>
* sol_bmc_transmit_overrun <self> <conn>
*/
%newobject create_sol;
ipmi_sol_conn_t *create_sol(int connection, swig_cb *handler)
{
ipmi_con_t *con;
ipmi_sol_conn_t *scon;
int rv;
swig_cb_val *handler_val;
if (nil_swig_cb(handler))
return NULL;
if (!valid_swig_cb(handler, sol_connection_state_change))
return NULL;
if (!valid_swig_cb(handler, sol_data_received))
return NULL;
if (!valid_swig_cb(handler, sol_break_detected))
return NULL;
if (!valid_swig_cb(handler, sol_bmc_transmit_overrun))
return NULL;
con = ipmi_domain_get_connection(self, connection);
if (!con)
return NULL;
rv = ipmi_sol_create(con, &scon);
if (rv) {
con->close_connection(con);
return NULL;
}
handler_val = ref_swig_gencb(handler);
rv = ipmi_sol_register_connection_state_callback
(scon,
sol_connection_state_change_cb,
handler_val);
if (rv)
goto out_err;
rv = ipmi_sol_register_data_received_callback
(scon,
sol_data_received_cb,
handler_val);
if (rv)
goto out_err;
rv = ipmi_sol_register_break_detected_callback
(scon,
sol_break_detected_cb,
handler_val);
if (rv)
goto out_err;
rv = ipmi_sol_register_bmc_transmit_overrun_callback
(scon,
sol_bmc_transmit_overrun_cb,
handler_val);
if (rv)
goto out_err;
return scon;
out_err:
deref_swig_cb_val(handler_val);
ipmi_sol_free(scon);
return NULL;
}
}
/*
* Allocate an args structure of the given connection type, generally
* "smi" or Lan".
*/
%newobject alloc_empty_args;
ipmi_args_t *alloc_empty_args(char *con_type);
%{
static ipmi_args_t *
alloc_empty_args(char *con_type)
{
int rv;
ipmi_args_t *argv;
rv = ipmi_args_alloc(con_type, &argv);
if (rv)
return NULL;
return argv;
}
%}
/*
* Parse the array of arguments. The arguments is a list/array of
* strings and parsed using the standard algorithms.
*/
%newobject alloc_parse_args;
ipmi_args_t *alloc_parse_args(argarray *args);
%{
static ipmi_args_t *
alloc_parse_args(argarray *args)
{
int rv;
ipmi_args_t *argv;
int i = 0;
rv = ipmi_parse_args(&i, args->len, args->val, &argv);
if (rv)
return NULL;
return argv;
}
%}
%extend ipmi_args_t {
~ipmi_args_t()
{
ipmi_free_args(self);
}
/*
* Return the type of connection, generally "lan" or "smi".
*/
const char *get_type()
{
return ipmi_args_get_type(self);
}
/*
* An args is a set of fields indexed by argnum. Fetching an
* argument returns the name, type, help string, and value. E2BIG
* is returned if argnum is larger than the number of fields.
* Type will be either "str" for a string or integer or IP address
* or other field like that, "bool" for a boolean, and "enum" for
* an enumeration type. The "str" type, obviously, may have
* semantics behind it. The "bool" value will be either "true" or
* "false". For enums, an array of strings is returned as "range"
* and the value will be one of these strings.
*/
int get_val(int argnum,
const char **name,
const char **type,
const char **help,
char **value,
strconstarray *range)
{
int rv;
const char **irange = NULL;
char *ivalue = NULL;
rv = ipmi_args_get_val(self, argnum, name, type, help,
&ivalue, &irange);
if (rv)
return rv;
if (ivalue) {
/* Convert it to a normal malloc() so char ** will work. */
char *ivalue2 = strdup(ivalue);
ipmi_args_free_str(self, ivalue);
ivalue = ivalue2;
}
*value = ivalue;
if (irange) {
int len;
for (len=0; irange[len]; len++)
;
range->len = len;
range->val = irange;
}
return 0;
}
/*
* Set the given field. If name is not NULL, then find the field
* by name. If name is NULL, then argnum is used for the field.
* If the value does not match the semantics of the field, an
* error is returned.
*/
int set_val(int argnum, const char *name, const char *value)
{
return ipmi_args_set_val(self, argnum, name, value);
}
}
/*
* A entity id object. This object is guaranteed to be valid and
* can be converted into a entity pointer later.
*/
%extend ipmi_entity_id_t {
~ipmi_entity_id_t()
{
free(self);
}
/* Compare self with other, return -1 if self<other, 0 if
self==other, or 1 if self>other. */
int cmp(ipmi_entity_id_t *other)
{
return ipmi_cmp_entity_id(*self, *other);
}
/*
* Convert a entity id to a entity pointer. The "entity_cb" method
* will be called on the first parameter with the following parameters:
* <self> <entity>
*/
int to_entity(swig_cb *handler)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_cb))
rv = EINVAL;
else
rv = ipmi_entity_pointer_cb(*self, handle_entity_cb,
get_swig_cb(handler, entity_cb));
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
%constant int ENTITY_ID_UNSPECIFIED = IPMI_ENTITY_ID_UNSPECIFIED;
%constant int ENTITY_ID_OTHER = IPMI_ENTITY_ID_OTHER;
%constant int ENTITY_ID_UNKOWN = IPMI_ENTITY_ID_UNKOWN;
%constant int ENTITY_ID_PROCESSOR = IPMI_ENTITY_ID_PROCESSOR;
%constant int ENTITY_ID_DISK = IPMI_ENTITY_ID_DISK;
%constant int ENTITY_ID_PERIPHERAL = IPMI_ENTITY_ID_PERIPHERAL;
%constant int ENTITY_ID_SYSTEM_MANAGEMENT_MODULE = IPMI_ENTITY_ID_SYSTEM_MANAGEMENT_MODULE;
%constant int ENTITY_ID_SYSTEM_BOARD = IPMI_ENTITY_ID_SYSTEM_BOARD;
%constant int ENTITY_ID_MEMORY_MODULE = IPMI_ENTITY_ID_MEMORY_MODULE;
%constant int ENTITY_ID_PROCESSOR_MODULE = IPMI_ENTITY_ID_PROCESSOR_MODULE;
%constant int ENTITY_ID_POWER_SUPPLY = IPMI_ENTITY_ID_POWER_SUPPLY;
%constant int ENTITY_ID_ADD_IN_CARD = IPMI_ENTITY_ID_ADD_IN_CARD;
%constant int ENTITY_ID_FRONT_PANEL_BOARD = IPMI_ENTITY_ID_FRONT_PANEL_BOARD;
%constant int ENTITY_ID_BACK_PANEL_BOARD = IPMI_ENTITY_ID_BACK_PANEL_BOARD;
%constant int ENTITY_ID_POWER_SYSTEM_BOARD = IPMI_ENTITY_ID_POWER_SYSTEM_BOARD;
%constant int ENTITY_ID_DRIVE_BACKPLANE = IPMI_ENTITY_ID_DRIVE_BACKPLANE;
%constant int ENTITY_ID_SYSTEM_INTERNAL_EXPANSION_BOARD = IPMI_ENTITY_ID_SYSTEM_INTERNAL_EXPANSION_BOARD;
%constant int ENTITY_ID_OTHER_SYSTEM_BOARD = IPMI_ENTITY_ID_OTHER_SYSTEM_BOARD;
%constant int ENTITY_ID_PROCESSOR_BOARD = IPMI_ENTITY_ID_PROCESSOR_BOARD;
%constant int ENTITY_ID_POWER_UNIT = IPMI_ENTITY_ID_POWER_UNIT;
%constant int ENTITY_ID_POWER_MODULE = IPMI_ENTITY_ID_POWER_MODULE;
%constant int ENTITY_ID_POWER_MANAGEMENT_BOARD = IPMI_ENTITY_ID_POWER_MANAGEMENT_BOARD;
%constant int ENTITY_ID_CHASSIS_BACK_PANEL_BOARD = IPMI_ENTITY_ID_CHASSIS_BACK_PANEL_BOARD;
%constant int ENTITY_ID_SYSTEM_CHASSIS = IPMI_ENTITY_ID_SYSTEM_CHASSIS;
%constant int ENTITY_ID_SUB_CHASSIS = IPMI_ENTITY_ID_SUB_CHASSIS;
%constant int ENTITY_ID_OTHER_CHASSIS_BOARD = IPMI_ENTITY_ID_OTHER_CHASSIS_BOARD;
%constant int ENTITY_ID_DISK_DRIVE_BAY = IPMI_ENTITY_ID_DISK_DRIVE_BAY;
%constant int ENTITY_ID_PERIPHERAL_BAY = IPMI_ENTITY_ID_PERIPHERAL_BAY;
%constant int ENTITY_ID_DEVICE_BAY = IPMI_ENTITY_ID_DEVICE_BAY;
%constant int ENTITY_ID_FAN_COOLING = IPMI_ENTITY_ID_FAN_COOLING;
%constant int ENTITY_ID_COOLING_UNIT = IPMI_ENTITY_ID_COOLING_UNIT;
%constant int ENTITY_ID_CABLE_INTERCONNECT = IPMI_ENTITY_ID_CABLE_INTERCONNECT;
%constant int ENTITY_ID_MEMORY_DEVICE = IPMI_ENTITY_ID_MEMORY_DEVICE;
%constant int ENTITY_ID_SYSTEM_MANAGEMENT_SOFTWARE = IPMI_ENTITY_ID_SYSTEM_MANAGEMENT_SOFTWARE;
%constant int ENTITY_ID_BIOS = IPMI_ENTITY_ID_BIOS;
%constant int ENTITY_ID_OPERATING_SYSTEM = IPMI_ENTITY_ID_OPERATING_SYSTEM;
%constant int ENTITY_ID_SYSTEM_BUS = IPMI_ENTITY_ID_SYSTEM_BUS;
%constant int ENTITY_ID_GROUP = IPMI_ENTITY_ID_GROUP;
%constant int ENTITY_ID_REMOTE_MGMT_COMM_DEVICE = IPMI_ENTITY_ID_REMOTE_MGMT_COMM_DEVICE;
%constant int ENTITY_ID_EXTERNAL_ENVIRONMENT = IPMI_ENTITY_ID_EXTERNAL_ENVIRONMENT;
%constant int ENTITY_ID_BATTERY = IPMI_ENTITY_ID_BATTERY;
%constant int ENTITY_ID_PROCESSING_BLADE = IPMI_ENTITY_ID_PROCESSING_BLADE;
%constant int ENTITY_ID_CONNECTIVITY_SWITCH = IPMI_ENTITY_ID_CONNECTIVITY_SWITCH;
%constant int ENTITY_ID_PROCESSOR_MEMORY_MODULE = IPMI_ENTITY_ID_PROCESSOR_MEMORY_MODULE;
%constant int ENTITY_ID_IO_MODULE = IPMI_ENTITY_ID_IO_MODULE;
%constant int ENTITY_ID_PROCESSOR_IO_MODULE = IPMI_ENTITY_ID_PROCESSOR_IO_MODULE;
%constant int ENTITY_ID_MGMT_CONTROLLER_FIRMWARE = IPMI_ENTITY_ID_MGMT_CONTROLLER_FIRMWARE;
%constant int ENTITY_ID_IPMI_CHANNEL = IPMI_ENTITY_ID_IPMI_CHANNEL;
%constant int ENTITY_ID_PCI_BUS = IPMI_ENTITY_ID_PCI_BUS;
%constant int ENTITY_ID_PCI_EXPRESS_BUS = IPMI_ENTITY_ID_PCI_EXPRESS_BUS;
%constant int ENTITY_ID_SCSI_BUS = IPMI_ENTITY_ID_SCSI_BUS;
%constant int ENTITY_ID_SATA_SAS_BUS = IPMI_ENTITY_ID_SATA_SAS_BUS;
%constant int ENTITY_ID_PROCESSOR_FRONT_SIDE_BUS = IPMI_ENTITY_ID_PROCESSOR_FRONT_SIDE_BUS;
/*
* An entity object.
*/
%extend ipmi_entity_t {
/*
* Get the domain the entity belongs to.
*/
ipmi_domain_t *get_domain()
{
return ipmi_entity_get_domain(self);
}
%newobject get_name;
/*
* Get the name of an entity.
*/
char *get_name()
{
char name[IPMI_ENTITY_NAME_LEN];
ipmi_entity_get_name(self, name, sizeof(name));
return strdup(name);
}
%newobject get_id;
/*
* Get the id for the entity.
*/
ipmi_entity_id_t *get_id()
{
ipmi_entity_id_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_entity_convert_to_id(self);
return rv;
}
/*
* Iterate through all the entity's children. The
* entity_iter_entities_cb method will be called on the first
* parameter for each child entity of the parent. The parameters
* it receives will be: <self> <parent> <child>.
*/
int iterate_children(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_iter_entities_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, entity_iter_entities_cb);
ipmi_entity_iterate_children(self, entity_iterate_entities_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Iterate through all the entity's parents. The
* entity_iter_entities_cb method will be called on the first
* parameter for each parent entity of the child. The parameters
* it receives will be: <self> <child> <parent>.
*/
int iterate_parents(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_iter_entities_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, entity_iter_entities_cb);
ipmi_entity_iterate_parents(self, entity_iterate_entities_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Iterate through all the entity's sensors. The
* entity_iter_sensors_cb method will be called on the first
* parameter for each sensor of the entity. The parameters
* it receives will be: <self> <entity> <sensor>.
*/
int iterate_sensors(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_iter_sensors_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, entity_iter_sensors_cb);
ipmi_entity_iterate_sensors(self, entity_iterate_sensors_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Iterate through all the entity's controls. The
* entity_iter_controls_cb method will be called on the first
* parameter for each control of the entity. The parameters
* it receives will be: <self> <entity> <control>.
*/
int iterate_controls(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv = 0;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_iter_controls_cb))
rv = EINVAL;
else {
handler_val = get_swig_cb(handler, entity_iter_controls_cb);
ipmi_entity_iterate_controls(self, entity_iterate_controls_handler,
handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Add a handler to be called when an entity's presence
* changes. When the presence changes the entity_presence_cb
* method on the first parameter will be called with the following
* parameters: <self> <entity> <present (boolean integer)> <event>.
* The event is optional and may not be present.
*/
int add_presence_handler(swig_cb *handler)
{
ipmi_entity_add_presence_handler_cl
(self, entity_presence_handler_cl, NULL);
cb_add(entity, presence, entity_presence_cb);
}
/*
* Remove the presence handler.
*/
int remove_presence_handler(swig_cb *handler)
{
cb_rm(entity, presence, entity_presence_cb);
}
/*
* Add a handler to be called when a sensor in the entity is
* added, deleted, or updated. When the sensor changes the
* entity_sensor_update_cb method on the first parameter will be
* called with the following parameters: <self>
* added|deleted|changed <entity> <sensor>.
*/
int add_sensor_update_handler(swig_cb *handler)
{
ipmi_entity_add_sensor_update_handler_cl
(self, entity_sensor_update_handler_cl, NULL);
cb_add(entity, sensor_update, entity_sensor_update_cb);
}
/*
* Remove the sensor update handler.
*/
int remove_sensor_update_handler(swig_cb *handler)
{
cb_rm(entity, sensor_update, entity_sensor_update_cb);
}
/*
* Add a handler to be called when a control in the entity is
* added, deleted, or updated. When the control changes the
* entity_control_update_cb method on the first parameter will be
* called with the following parameters: <self>
* added|deleted|changed <entity> <control>.
*/
int add_control_update_handler(swig_cb *handler)
{
ipmi_entity_add_control_update_handler_cl
(self, entity_control_update_handler_cl, NULL);
cb_add(entity, control_update, entity_control_update_cb);
}
/*
* Remove the control update handler.
*/
int remove_control_update_handler(swig_cb *handler)
{
cb_rm(entity, control_update, entity_control_update_cb);
}
/*
* Add a handler to be called when the FRU data in the entity is
* added, deleted, or updated. When the FRU data changes the
* entity_fru_update_cb method on the first parameter will be
* called with the following parameters: <self>
* added|deleted|changed <entity> <fru>.
*
* Deprecated, use the werr version below so you can get errors
* reported.
*/
int add_fru_update_handler(swig_cb *handler)
{
ipmi_entity_add_fru_update_handler_cl
(self, entity_fru_update_handler_cl, NULL);
cb_add(entity, fru_update, entity_fru_update_cb);
}
/*
* Remove the FRU data update handler.
*/
int remove_fru_update_handler(swig_cb *handler)
{
cb_rm(entity, fru_update, entity_fru_update_cb);
}
/*
* Add a handler to be called when the FRU data in the entity is
* added, deleted, or updated. When the FRU data changes the
* entity_fru_update_werr_cb method on the first parameter will be
* called with the following parameters: <self>
* added|deleted|changed|error <errnum> <entity> <fru>.
*/
int add_fru_update_werr_handler(swig_cb *handler)
{
ipmi_entity_add_fru_update_werr_handler_cl
(self, entity_fru_update_werr_handler_cl, NULL);
cb_add(entity, fru_update_werr, entity_fru_update_werr_cb);
}
/*
* Remove the FRU data update handler.
*/
int remove_fru_update_werr_handler(swig_cb *handler)
{
cb_rm(entity, fru_update_werr, entity_fru_update_werr_cb);
}
/*
* Get the entities type, return "mc", "fru", "generic", or "unknown".
*/
char *get_type()
{
switch (ipmi_entity_get_type(self)) {
case IPMI_ENTITY_MC: return "mc";
case IPMI_ENTITY_FRU: return "fru";
case IPMI_ENTITY_GENERIC: return "generic";
default: return "unknown";
}
}
/*
* Returns if the entity has FRU data or not.
*/
int is_fru()
{
return ipmi_entity_get_is_fru(self);
}
%newobject get_id_string;
/*
* Get the ID string from the SDR
*/
char *get_id_string()
{
int length = ipmi_entity_get_id_length(self);
char *str;
if (length < 2)
return NULL;
str = malloc(length);
if (!str)
return NULL;
ipmi_entity_get_id(self, str, length);
return str;
}
/*
* Get the entity id for the entity
*/
int get_entity_id()
{
return ipmi_entity_get_entity_id(self);
}
/*
* Get the string representation of the entity id
*/
const char *get_entity_id_string()
{
return ipmi_entity_get_entity_id_string(self);
}
/*
* Get the entity instance for the entity
*/
int get_entity_instance()
{
return ipmi_entity_get_entity_instance(self);
}
/*
* Get the channel for the entity. Only valid if the entity
* instance is 0x60 or larger.
*/
int get_entity_device_channel()
{
return ipmi_entity_get_device_channel(self);
}
/*
* Get the address for the entity. Only valid if the entity
* instance is 0x60 or larger.
*/
int get_entity_device_address()
{
return ipmi_entity_get_device_address(self);
}
/*
* Get the FRU data for the entity. Note that you cannot hold the
* FRU data pointer outside the context of where the entity pointer
* is valid.
*/
%newobject get_fru;
ipmi_fru_t *get_fru()
{
ipmi_fru_t *fru = ipmi_entity_get_fru(self);
if (fru)
ipmi_fru_ref(fru);
return fru;
}
/*
* If this returns true, then the presence sensor is always there
* for this entity.
*/
int get_presence_sensor_always_there()
{
return ipmi_entity_get_presence_sensor_always_there(self);
}
/*
* Returns if the entity has a parent.
*/
int is_child()
{
return ipmi_entity_get_is_child(self);
}
/*
* Returns if the entity has a child.
*/
int is_parent()
{
return ipmi_entity_get_is_parent(self);
}
/*
* Return the channel from the device locator record. Valid for
* all entities except unknown.
*/
int get_channel()
{
return ipmi_entity_get_channel(self);
}
/*
* Return the LUN from the device locator record. Valid for
* all entities except unknown.
*/
int get_lun()
{
return ipmi_entity_get_lun(self);
}
/*
* Return the OEM byte from the device locator record. Valid for
* all entities except unknown.
*/
int get_oem()
{
return ipmi_entity_get_oem(self);
}
/*
* Return the access address from the device locator record. Valid for
* FRU and generic entities.
*/
int get_access_address()
{
return ipmi_entity_get_access_address(self);
}
/*
* Return the private bus id from the device locator record. Valid for
* FRU and generic entities.
*/
int get_private_bus_id()
{
return ipmi_entity_get_private_bus_id(self);
}
/*
* Return the device type from the device locator record. Valid for
* FRU and generic entities.
*/
int get_device_type()
{
return ipmi_entity_get_device_type(self);
}
/*
* Return the device modifier from the device locator record.
* Valid for FRU and generic entities.
*/
int get_device_modifier()
{
return ipmi_entity_get_device_modifier(self);
}
/*
* Return the slave address from the device locator record. Valid for
* MC and generic entities.
*/
int get_slave_address()
{
return ipmi_entity_get_slave_address(self);
}
%newobject get_mc_id;
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *mc_id = malloc(sizeof(*mc_id));
int rv;
rv = ipmi_entity_get_mc_id(self, mc_id);
if (rv) {
free(mc_id);
mc_id = NULL;
}
return mc_id;
}
/*
* Return if the FRU is logical (from the device locator record).
* Valid for FRU entities.
*/
int get_is_logical_fru()
{
return ipmi_entity_get_is_logical_fru(self);
}
/*
* Return the device id from the device locator record. Valid for
* FRU entities.
*/
int get_fru_device_id()
{
return ipmi_entity_get_fru_device_id(self);
}
/*
* Return the ACPI system power notify required bit from the
* device locator record. Valid for MC entities.
*/
int get_ACPI_system_power_notify_required()
{
return ipmi_entity_get_ACPI_system_power_notify_required(self);
}
/*
* Return the ACPI device power notify required bit from the
* device locator record. Valid for MC entities.
*/
int get_ACPI_device_power_notify_required()
{
return ipmi_entity_get_ACPI_device_power_notify_required(self);
}
/*
* Return the controller logs init agent errors bit from the
* device locator record. Valid for MC entities.
*/
int get_controller_logs_init_agent_errors()
{
return ipmi_entity_get_controller_logs_init_agent_errors(self);
}
/*
* Return the log init agent errors accessing bit from the
* device locator record. Valid for MC entities.
*/
int get_log_init_agent_errors_accessing()
{
return ipmi_entity_get_log_init_agent_errors_accessing(self);
}
/*
* Return the global init bit from the
* device locator record. Valid for MC entities.
*/
int get_global_init()
{
return ipmi_entity_get_global_init(self);
}
/*
* Return the chassis device bit from the
* device locator record. Valid for MC entities.
*/
int get_chassis_device()
{
return ipmi_entity_get_chassis_device(self);
}
/*
* Return the !bridge bit from the
* device locator record. Valid for MC entities.
*/
int get_bridge()
{
return ipmi_entity_get_bridge(self);
}
/*
* Return the IPMB event generator bit from the
* device locator record. Valid for MC entities.
*/
int get_IPMB_event_generator()
{
return ipmi_entity_get_IPMB_event_generator(self);
}
/*
* Return the IPMB event receiver bit from the
* device locator record. Valid for MC entities.
*/
int get_IPMB_event_receiver()
{
return ipmi_entity_get_IPMB_event_receiver(self);
}
/*
* Return the FRU inventory device bit from the
* device locator record. Valid for MC entities.
*/
int get_FRU_inventory_device()
{
return ipmi_entity_get_FRU_inventory_device(self);
}
/*
* Return the SEL device bit from the
* device locator record. Valid for MC entities.
*/
int get_SEL_device()
{
return ipmi_entity_get_SEL_device(self);
}
/*
* Return the SDR repository device bit from the
* device locator record. Valid for MC entities.
*/
int get_SDR_repository_device()
{
return ipmi_entity_get_SDR_repository_device(self);
}
/*
* Return the sensor device bit from the
* device locator record. Valid for MC entities.
*/
int get_sensor_device()
{
return ipmi_entity_get_sensor_device(self);
}
/*
* Return the address span from the device locator record. Valid
* for generic entities.
*/
int get_address_span()
{
return ipmi_entity_get_address_span(self);
}
%newobject get_dlr_id;
/*
* Return the id string from the DLR.
*/
char *get_dlr_id()
{
/* FIXME - no unicode handling. */
int len = ipmi_entity_get_id_length(self) + 1;
char *id = malloc(len);
ipmi_entity_get_id(self, id, len);
return id;
}
/*
* Returns true if the entity is present, false if not.
*/
int is_present()
{
return ipmi_entity_is_present(self);
}
/*
* Returns the physical slot number, or -1 if there is not
* a slot number.
*/
int get_physical_slot_num()
{
unsigned int num;
if (ipmi_entity_get_physical_slot_num(self, &num) == 0)
return num;
else
return -1;
}
/*
* Returns true if the entity is hot-swappable, false if not.
*/
int is_hot_swappable()
{
return ipmi_entity_hot_swappable(self);
}
int supports_managed_hot_swap()
{
return ipmi_entity_supports_managed_hot_swap(self);
}
/*
* Add a handler to be called when the hot-swap state for the
* entity changes. When the hot-swap state changes the
* entity_hot_swap_update_cb method on the first parameter will be
* called with the following parameters: <self> <entity> <old
* state> <new state> <event>. The event is optional and may not
* be present.
*/
int add_hot_swap_handler(swig_cb *handler)
{
ipmi_entity_add_hot_swap_handler_cl
(self, entity_hot_swap_handler_cl, NULL);
cb_add(entity, hot_swap, entity_hot_swap_update_cb);
}
/*
* Remove the hot-swap update handler.
*/
int remove_hot_swap_handler(swig_cb *handler)
{
cb_rm(entity, hot_swap, entity_hot_swap_update_cb);
}
/*
* Get the current hot-swap state for the entity. The
* entity_hot_swap_cb handler will be called with the following
* parameters: <self> <entity> <err> <state>
*/
int get_hot_swap_state(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_hot_swap_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, entity_hot_swap_cb);
rv = ipmi_entity_get_hot_swap_state(self,
entity_get_hot_swap_handler,
handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/* Returns if the entity supports auto-activate. */
int supports_auto_activate_time()
{
return ipmi_entity_supports_auto_activate_time(self);
}
/*
* Get the current hot-swap activation time for the entity. The
* entity_hot_swap_get_time_cb handler will be called with the
* following parameters: <self> <entity> <err> <time>
*/
int get_auto_activate_time(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_hot_swap_get_time_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, entity_hot_swap_get_time_cb);
rv = ipmi_entity_get_auto_activate_time
(self,
entity_get_hot_swap_time_handler,
handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the current hot-swap activation time for the entity. The
* entity_hot_swap_set_time_cb handler will be called with the
* following parameters (if it is supplied): <self> <entity> <err>
*/
int set_auto_activate_time(ipmi_timeout_t auto_act,
swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_entity_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, entity_hot_swap_set_time_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, entity_hot_swap_set_time_cb);
done = entity_set_hot_swap_time_handler;
}
rv = ipmi_entity_set_auto_activate_time
(self, auto_act, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/* Returns if the entity supports auto-deactivate. */
int supports_auto_deactivate_time()
{
return ipmi_entity_supports_auto_deactivate_time(self);
}
/*
* Get the current hot-swap deactivation time for the entity. The
* entity_hot_swap_get_time_cb handler will be called with the
* following parameters: <self> <entity> <err> <time>
*/
int get_auto_deactivate_time(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, entity_hot_swap_get_time_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, entity_hot_swap_get_time_cb);
rv = ipmi_entity_get_auto_deactivate_time
(self,
entity_get_hot_swap_time_handler,
handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the current hot-swap deactivation time for the entity. The
* entity_hot_swap_set_time_cb handler will be called with the
* following parameters (if it is supplied): <self> <entity> <err>
*/
int set_auto_deactivate_time(ipmi_timeout_t auto_act,
swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_entity_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, entity_hot_swap_set_time_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, entity_hot_swap_set_time_cb);
done = entity_set_hot_swap_time_handler;
}
rv = ipmi_entity_set_auto_deactivate_time
(self, auto_act, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Cause the entity to move from INACTIVE to ACTIVATION_REQUESTED
* state, if possible. If the entity does not support this
* operation, this will return ENOSYS and you can move straight
* from INACTIVE to ACTIVE state by calling ipmi_entity_activate.
* After this is done, the entity_activate_cb handler will be
* called with the following parameters (if it is supplied):
* <self> <entity> <err>
*/
int set_activation_requested(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_entity_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, entity_activate_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, entity_activate_cb);
done = entity_activate_handler;
}
rv = ipmi_entity_set_activation_requested(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Attempt to activate an entity. Activate will cause a
* transition from INACTIVE to ACTIVE (but only if
* ipmi_entity_set_activation_requested() returns ENOSYS), or from
* ACTIVATION_REQUESTED to ACTIVE. After this is done, the
* entity_activate_cb handler will be called with the following
* parameters (if it is supplied): <self> <entity> <err>
*/
int activate(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_entity_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, entity_activate_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, entity_activate_cb);
done = entity_activate_handler;
}
rv = ipmi_entity_activate(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Attempt to deactivate an entity. Deactivate will cause a
* transition from DEACTIVATION_REQUESTED or ACTIVE to INACTIVE.
* After this is done, the entity_activate_cb handler will be
* called with the following parameters (if it is supplied):
* <self> <entity> <err>
*/
int deactivate(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_entity_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, entity_activate_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, entity_activate_cb);
done = entity_activate_handler;
}
rv = ipmi_entity_deactivate(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Check the state of hot-swap for the entity. This causes the
* local state to be audited against the actual state.
*/
int check_hot_swap_state()
{
return ipmi_entity_check_hot_swap_state(self);
}
}
/*
* A mc id object. This object is guaranteed to be valid and
* can be converted into a mc pointer later.
*/
%extend ipmi_mcid_t {
~ipmi_mcid_t()
{
free(self);
}
/* Compare self with other, return -1 if self<other, 0 if
self==other, or 1 if self>other. */
int cmp(ipmi_mcid_t *other)
{
return ipmi_cmp_mc_id(*self, *other);
}
/*
* Convert a mc id to a mc pointer. The "mc_cb" method
* will be called on the first parameter with the following parameters:
* <self> <mc>
*/
int to_mc(swig_cb *handler)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, mc_cb))
rv = EINVAL;
else
rv = ipmi_mc_pointer_cb(*self, handle_mc_cb,
get_swig_cb(handler, mc_cb));
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
/*
* An MC object
*/
%extend ipmi_mc_t {
/*
* Get the domain the mc belongs to.
*/
ipmi_domain_t *get_domain()
{
return ipmi_mc_get_domain(self);
}
%newobject get_name;
/*
* Get the name of an mc.
*/
char *get_name()
{
char name[IPMI_MC_NAME_LEN];
ipmi_mc_get_name(self, name, sizeof(name));
return strdup(name);
}
%newobject get_id;
/*
* Get the id for the mc.
*/
ipmi_mcid_t *get_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_mc_convert_to_id(self);
return rv;
}
%newobject get_guid;
/*
* Get the GUID for the MC. Returns NULL if it is not supported.
*/
char *get_guid()
{
char *str = NULL;
unsigned char guid[16];
if (ipmi_mc_get_guid(self, guid) == 0) {
str = malloc(16 * 3);
if (str) {
char *s = str;
int i;
s += sprintf(s, "%2.2x", guid[0]);
for (i=1; i<16; i++)
s += sprintf(s, " %2.2x", guid[i]);
}
}
return str;
}
/*
* Get the provides_device_sdrs from the get device id response
* from the MC.
*/
int provides_device_sdrs()
{
return ipmi_mc_provides_device_sdrs(self);
}
/*
* Get the device_available bit from the get device id response
* from the MC.
*/
int device_available()
{
return ipmi_mc_device_available(self);
}
/*
* Get the chassis_support bit from the get device id response
* from the MC.
*/
int chassis_support()
{
return ipmi_mc_chassis_support(self);
}
/*
* Get the bridge_support bit from the get device id response
* from the MC.
*/
int bridge_support()
{
return ipmi_mc_bridge_support(self);
}
/*
* Get the ipmb_event_generator_support bit from the get device id response
* from the MC.
*/
int ipmb_event_generator_support()
{
return ipmi_mc_ipmb_event_generator_support(self);
}
/*
* Get the ipmb_event_receiver_support bit from the get device id response
* from the MC.
*/
int ipmb_event_receiver_support()
{
return ipmi_mc_ipmb_event_receiver_support(self);
}
/*
* Get the fru_inventory_support bit from the get device id response
* from the MC.
*/
int fru_inventory_support()
{
return ipmi_mc_fru_inventory_support(self);
}
/*
* Get the sel_device_support bit from the get device id response
* from the MC.
*/
int sel_device_support()
{
return ipmi_mc_sel_device_support(self);
}
/*
* Get the sdr_repository_support bit from the get device id response
* from the MC.
*/
int sdr_repository_support()
{
return ipmi_mc_sdr_repository_support(self);
}
/*
* Get the sensor_device_support bit from the get device id response
* from the MC.
*/
int sensor_device_support()
{
return ipmi_mc_sensor_device_support(self);
}
/*
* Get the device_id from the get device id response
* from the MC.
*/
int device_id()
{
return ipmi_mc_device_id(self);
}
/*
* Get the device_revision from the get device id response
* from the MC.
*/
int device_revision()
{
return ipmi_mc_device_revision(self);
}
/*
* Get the major_fw_revision from the get device id response
* from the MC.
*/
int major_fw_revision()
{
return ipmi_mc_major_fw_revision(self);
}
/*
* Get the minor_fw_revision from the get device id response
* from the MC.
*/
int minor_fw_revision()
{
return ipmi_mc_minor_fw_revision(self);
}
/*
* Get the major_version from the get device id response
* from the MC.
*/
int major_version()
{
return ipmi_mc_major_version(self);
}
/*
* Get the minor_version from the get device id response
* from the MC.
*/
int minor_version()
{
return ipmi_mc_minor_version(self);
}
/*
* Get the manufacturer_id from the get device id response
* from the MC.
*/
int manufacturer_id()
{
return ipmi_mc_manufacturer_id(self);
}
/*
* Get the product_id from the get device id response
* from the MC.
*/
int product_id()
{
return ipmi_mc_product_id(self);
}
/*
* Get the auxiliary firmware revision. This returns a string
* with four bytes set.
*/
%newobject aux_fw_revision;
char *aux_fw_revision()
{
char *str;
unsigned char data[4];
str = malloc(28);
ipmi_mc_aux_fw_revision(self, data);
snprintf(str, 28,
"0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x",
data[0], data[1], data[2], data[3]);
return str;
}
/*
* Check to see if the MC is operational in the system. If this
* is return sfalse, then the MC was referred to by an SDR, but it
* doesn't really exist (at least not yet).
*/
int is_active()
{
return ipmi_mc_is_active(self);
}
/*
* Add a handler to be called when an mc's active state
* changes. When the active state changes the mc_active_cb
* method on the first parameter will be called with the following
* parameters: <self> <mc> <active (boolean integer)>.
*/
int add_active_handler(swig_cb *handler)
{
ipmi_mc_add_active_handler_cl
(self, mc_active_handler_cl, NULL);
cb_add(mc, active, mc_active_cb);
}
/*
* Remove the presence handler.
*/
int remove_active_handler(swig_cb *handler)
{
cb_rm(mc, active, mc_active_cb);
}
/*
* Add a handler to be called when an mc has reached fully up
* status. When this happens the mc_fully_up_cb
* method on the first parameter will be called with the following
* parameters: <self> <mc>.
*/
int add_fully_up_handler(swig_cb *handler)
{
ipmi_mc_add_fully_up_handler_cl
(self, mc_fully_up_handler_cl, NULL);
cb_add(mc, fully_up, mc_fully_up_cb);
}
/*
* Remove the presence handler.
*/
int remove_fully_up_handler(swig_cb *handler)
{
cb_rm(mc, fully_up, mc_fully_up_cb);
}
/*
* Send a command to a given MC with the given lun (parm 1), netfn
* (parm 2), command (parm 3). Parm 4 is the message data in an
* array reference. Parm 5 is the handler, it will be called with
* the response. The mc_cmd_cb method will be called on the
* handler (if it is supplied); its parameters are: <mc> <netfn> <cmd>
* <response data>
*/
int send_command(int lun,
int netfn,
int cmd,
intarray msg_data,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_mc_response_handler_t msg_cb = NULL;
ipmi_msg_t msg;
unsigned char data[MAX_IPMI_DATA_SIZE];
unsigned int data_len;
IPMI_SWIG_C_CB_ENTRY
msg.netfn = netfn;
msg.cmd = cmd;
msg.data = data;
rv = parse_ipmi_data(msg_data, data, sizeof(data), &data_len);
msg.data_len = data_len;
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_cmd_cb)) {
rv = EINVAL;
goto out_err;
}
msg_cb = mc_msg_cb;
handler_val = ref_swig_cb(handler, mc_cmd_cb);
}
rv = ipmi_mc_send_command(self, lun, &msg, msg_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%constant int MC_RESET_COLD = IPMI_MC_RESET_COLD;
%constant int MC_RESET_WARM = IPMI_MC_RESET_WARM;
/*
* Reset the MC, either a cold or warm reset depending on the
* first parm. Note that the effects of a reset are not defined
* by IPMI, so this might do wierd things. Some systems do not
* support resetting the MC. This is not a standard control
* because there is no entity to hang if from and you don't want
* people messing with it unless they really know what they are
* doing. When the reset is complete the mc_reset_cb will be
* called on the second parameter of this call (if it is
* supplied) with the following parameters: <self> <mc> <err>
*/
int reset(int reset_type,
swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_reset_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_reset_cb);
done = mc_reset_handler;
}
rv = ipmi_mc_reset(self, reset_type, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/* Get the setting to enable events for the entire MC. The value
returned by the get function is a boolean telling whether
events are enabled. */
int get_events_enable()
{
return ipmi_mc_get_events_enable(self);
}
/*
* Set the setting to enable events for the entire MC. The "val"
* passed in as the first parameter is a boolean telling whether
* to turn events on (true) or off (false). When the operation
* completes the mc_events_enable_cb will be called on the handler
* (if it is supplied) with the following parameters: <self> <mc>
* <err>.
*/
int set_events_enable(int val,
swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_events_enable_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_events_enable_cb);
done = mc_events_enable_handler;
}
rv = ipmi_mc_set_events_enable(self, val, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Find out of the event log is enabled. The
* mc_get_event_log_enable_cb will be called on the supplied
* handler with the following parms: <self> <mc> <err> <val>
*/
int get_event_log_enable(swig_cb *handler)
{
swig_cb_val *handler_val;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, mc_get_event_log_enable_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, mc_get_event_log_enable_cb);
rv = ipmi_mc_get_event_log_enable(self,
mc_get_event_log_enable_handler,
handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the MC's event log enable. The mc_set_event_log_enable_cb
* will be called on the supplied handler with the following
* parms: <self> <mc> <err>
*/
int set_event_log_enable(int val, swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_set_event_log_enable_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_set_event_log_enable_cb);
done = mc_set_event_log_enable_handler;
}
rv = ipmi_mc_set_event_log_enable(self, val, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Reread all the sensors for a given mc. This will request the
* device SDRs for that mc (And only for that MC) and change the
* sensors as necessary. When the operation completes, the
* mc_reread_sensors_cb on the first parameter (if supplied) will
* be called with the following parms: <self> <mc> <err>.
*/
int reread_sensors(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_reread_sensors_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_reread_sensors_cb);
done = mc_reread_sensors_handler;
}
rv = ipmi_mc_reread_sensors(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the time between SEL rescans for the MC (and only that MC).
* Parm 1 is the time in seconds.
*/
void set_sel_rescan_time(unsigned int seconds)
{
ipmi_mc_set_sel_rescan_time(self, seconds);
}
/*
* Return the current SEL rescan time for the MC.
*/
int get_sel_rescan_time()
{
return ipmi_mc_get_sel_rescan_time(self);
}
/*
* Reread the sel for the MC. When the handler is called, all the
* events in the SEL have been fetched into the local copy of the
* SEL (with the obvious caveat that this is a distributed system
* and other things may have come in after the read has finised).
* When this completes, the mc_reread_sel_cb method will be called
* on the handler (parm 1, if it is supplied) with the parameters:
* <self> <mc> <err>.
*/
int reread_sel(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_reread_sel_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_reread_sel_cb);
done = mc_reread_sel_handler;
}
rv = ipmi_mc_reread_sel(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Fetch the current time from the SEL. When the operation
* completes, the mc_get_sel_time_cb method will be called on the
* first parameter (if it is supplied) with the following
* values: <self> <mc> <err> <time>
*/
int get_current_sel_time(swig_cb *handler)
{
swig_cb_val *handler_val = NULL;
sel_get_time_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_get_sel_time_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_get_sel_time_cb);
done = mc_sel_get_time_cb;
}
rv = ipmi_mc_get_current_sel_time(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%newobject first_event;
/*
* Retrieve the first event from the MC. Return NULL (undef)
* if the event does not exist.
*/
ipmi_event_t *first_event()
{
return ipmi_mc_first_event(self);
}
%newobject last_event;
/*
* Retrieve the last event from the MC.
*/
ipmi_event_t *last_event()
{
return ipmi_mc_last_event(self);
}
%newobject next_event;
/*
* Retrieve the next event from the MC.
*/
ipmi_event_t *next_event(ipmi_event_t *event)
{
return ipmi_mc_next_event(self, event);
}
%newobject prev_event;
/*
* Retrieve the previous event from the MC.
*/
ipmi_event_t *prev_event(ipmi_event_t *event)
{
return ipmi_mc_prev_event(self, event);
}
%newobject event_by_recid;
/*
* Retrieve the event with the given record id from the MC.
*/
ipmi_event_t *event_by_recid(int record_id)
{
return ipmi_mc_event_by_recid(self, record_id);
}
/*
* The number of live items in the local copy of the MC's SEL.
*/
int sel_count()
{
return ipmi_mc_sel_count(self);
}
/*
* Number of entries in the the remote SEL. If an entry has been
* deleted in the local copy of the SEL but has not yet finished
* being deleted in the remote copy, it will be counted here.
*/
int sel_entries_used()
{
return ipmi_mc_sel_entries_used(self);
}
/*
* The major version of the MC's SEL.
*/
int sel_get_major_version()
{
return ipmi_mc_sel_get_major_version(self);
}
/*
* The minor version of the MC's SEL.
*/
int sel_get_minor_version()
{
return ipmi_mc_sel_get_minor_version(self);
}
/*
* The number of entries available in the MC's SEL.
*/
int sel_get_num_entries()
{
return ipmi_mc_sel_get_num_entries(self);
}
/*
* The number of free bytes available in the MC's SEL.
*/
int sel_get_free_bytes()
{
return ipmi_mc_sel_get_free_bytes(self);
}
/*
* Has an overflow occurred since the last SEL operation?
*/
int sel_get_overflow()
{
return ipmi_mc_sel_get_overflow(self);
}
/*
* Does the SEL support individual deletes of entries?
*/
int sel_get_supports_delete_sel()
{
return ipmi_mc_sel_get_supports_delete_sel(self);
}
/*
* Does the SEL support partial adds of entries?
*/
int sel_get_supports_partial_add_sel()
{
return ipmi_mc_sel_get_supports_partial_add_sel(self);
}
/*
* Does the SEL support the reserve protocol?
*/
int sel_get_supports_reserve_sel()
{
return ipmi_mc_sel_get_supports_reserve_sel(self);
}
/*
* Does the SEL support getting the SEL allocastion?
*/
int sel_get_supports_get_sel_allocation()
{
return ipmi_mc_sel_get_supports_get_sel_allocation(self);
}
/*
* The timestamp of the last time something was added to the SEL.
*/
int sel_get_last_addition_timestamp()
{
return ipmi_mc_sel_get_last_addition_timestamp(self);
}
%constant int MAX_USED_CHANNELS = MAX_IPMI_USED_CHANNELS;
/*
* Get the info for a channel on the MC. The first parm is the
* integer channel number. The second is the handler object,
* the mc_channel_got_info_cb method will be called on it with the
* following parameters: <self> <mc> <err> <chan_info>
* where chan_info is ipmi_channel_info_t.
*/
int channel_get_info(int channel, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, mc_channel_got_info_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, mc_channel_got_info_cb);
rv = ipmi_mc_channel_get_info(self, channel,
mc_channel_get_info, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the access info for a channel on the MC. The first parm is
* the integer channel number. The second parm is the type to
* set, either "volatile" or "nonvolatile". The third is the
* handler object, the mc_channel_got_access_cb method will be
* called on it with the following parameters: <self> <mc> <err>
* <access_info> where access_info is ipmi_channel_access_t.
*/
int channel_get_access(int channel, char *type, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
enum ipmi_set_dest_e dest;
IPMI_SWIG_C_CB_ENTRY
if (strcmp(type, "nonvolatile") == 0)
dest = IPMI_SET_DEST_NON_VOLATILE;
else if (strcmp(type, "volatile") == 0)
dest = IPMI_SET_DEST_VOLATILE;
else {
rv = EINVAL;
goto out_err;
}
if (!valid_swig_cb(handler, mc_channel_got_access_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_channel_got_access_cb);
rv = ipmi_mc_channel_get_access(self, channel, dest,
mc_channel_get_access, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the access info for a channel on the MC, generally from one
* that you have previously fetched. The first parameter is the
* access object you with to set the channel to. The second parm
* is the integer channel number. The third parm is the type to
* set, either "volatile" or "nonvolatile". The forth is the
* handler object, the mc_channel_set_access_cb method will be
* called on it with the following parameters: <self> <mc> <err>.
*/
int channel_set_access(ipmi_channel_access_t *access,
int channel,
char *type,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
enum ipmi_set_dest_e dest;
IPMI_SWIG_C_CB_ENTRY
if (strcmp(type, "nonvolatile") == 0)
dest = IPMI_SET_DEST_NON_VOLATILE;
else if (strcmp(type, "volatile") == 0)
dest = IPMI_SET_DEST_VOLATILE;
else {
rv = EINVAL;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, mc_channel_set_access_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_channel_set_access_cb);
done = mc_channel_set_access;
}
rv = ipmi_mc_channel_set_access(self, channel, dest, access,
done, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the user info for a channel on the MC. The first parameter
* is the channel. The second is the user number; if a valid user
* number is passed in, then that user is the only one fetched.
* If 0 is passed for the user number, then all users are
* fetched. The third is the handler object, the
* mc_channel_got_users_cb method will be called on it with the
* following parameters: <self> <mc> <err> <max users>
* <enabled users> <fixed users> <user1> [<user2> ...]
* where the users are ipmi_user_t objects.
*/
int get_users(int channel, int user, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, mc_channel_got_users_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, mc_channel_got_users_cb);
rv = ipmi_mc_get_users(self, channel, user,
mc_channel_got_users, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the user info for a channel on the MC. The first parameter
* is the ipmi_user_t object. The second parameter is the
* channel. The third is the user number; if a valid user number
* is passed in, then that user is the only one fetched. The
* fourth is the handler object, the mc_channel_set_user_cb
* method will be called on it with the following parameters:
* <self> <mc> <err>. Note that some info is channel-specific.
* Just the name and password and enable are global to the MC.
*/
int set_user(ipmi_user_t *userinfo,
int channel,
int usernum,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_mc_done_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, mc_channel_set_user_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, mc_channel_set_user_cb);
done = mc_channel_set_user;
}
rv = ipmi_mc_set_user(self, channel, usernum, userinfo,
done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Allocate a lanparm object for the MC. The channel is the first
* parameter, the lanparm is returned.
*/
%newobject get_lanparm;
ipmi_lanparm_t *get_lanparm(int channel)
{
int rv;
ipmi_lanparm_t *lp;
rv = ipmi_lanparm_alloc(self, channel, &lp);
if (rv)
return NULL;
return lp;
}
/*
* Allocate a pef object for the MC. The pef object is returned.
* The first parameter is an optional callback object, the
* got_pef_cb method will be called on it when the PEF fetch is
* complete. It will have the following parameters: <self> <pef>
* <err>. Note that you cannot use the PEF until the fetch is
* complete.
*/
%newobject get_pef;
ipmi_pef_t *get_pef(swig_cb *handler = NULL)
{
int rv;
ipmi_pef_t *pef = NULL;
swig_cb_val *handler_val = NULL;
ipmi_pef_done_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, got_pef_cb))
goto out_err;
handler_val = ref_swig_cb(handler, got_pef_cb);
done = get_pef;
}
rv = ipmi_pef_alloc(self, done, handler_val, &pef);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return pef;
}
/*
* Allocate a pet object for the MC. The pet is returned. The
* eighth parameter is an optional callback object, the got_pet_cb
* method will be called on it when the PET fetch is complete. It
* will have the following parameters: <self> <pet> <err>.
* The parameters are:
* int channel: the channel number to set the PET for
* char ip_addr: the address to send the traps to
* char mac_addr: the mac address to send the traps to
* The rest are the selectors in the various tables, you have to
* read the spec and know your system to know how to set them.
* int eft_sel:
* int policy_num:
* int apt_sel:
* int lan_dest_sel:
*
* Note that you must keep a reference to the pet around, or it will
* be automatically destroyed by the garbage collector.
*/
%newobject get_pet;
ipmi_pet_t *get_pet(int channel,
char *ip_addr,
char *mac_addr,
int eft_sel,
int policy_num,
int apt_sel,
int lan_dest_sel,
swig_cb *handler = NULL)
{
int rv;
ipmi_pet_t *pet = NULL;
swig_cb_val *handler_val = NULL;
struct in_addr ip;
unsigned char mac[6];
ipmi_pet_done_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
rv = parse_ip_addr(ip_addr, &ip);
if (rv)
goto out_err;
rv = parse_mac_addr(mac_addr, mac);
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (!valid_swig_cb(handler, got_pet_cb))
goto out_err;
handler_val = ref_swig_cb(handler, got_pet_cb);
done = get_pet;
}
rv = ipmi_pet_create_mc(self, channel, ip, mac, eft_sel, policy_num,
apt_sel, lan_dest_sel, done, handler_val,
&pet);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return pet;
}
/*
* Allocate a solparm object for the MC. The channel is the first
* parameter, the solparm is returned.
*/
%newobject get_solparm;
ipmi_solparm_t *get_solparm(int channel)
{
int rv;
ipmi_solparm_t *lp;
rv = ipmi_solparm_alloc(self, channel, &lp);
if (rv)
return NULL;
return lp;
}
}
%extend ipmi_channel_info_t {
~ipmi_channel_info_t()
{
ipmi_channel_info_free(self);
}
%newobject copy;
ipmi_channel_info_t *copy()
{
return ipmi_channel_info_copy(self);
}
int get_channel(int *channel)
{
unsigned int val;
int rv = ipmi_channel_info_get_channel(self, &val);
*channel = val;
return rv;
}
%constant int CHANNEL_MEDIUM_IPMB = IPMI_CHANNEL_MEDIUM_IPMB;
%constant int CHANNEL_MEDIUM_ICMB_V10 = IPMI_CHANNEL_MEDIUM_ICMB_V10;
%constant int CHANNEL_MEDIUM_ICMB_V09 = IPMI_CHANNEL_MEDIUM_ICMB_V09;
%constant int CHANNEL_MEDIUM_8023_LAN = IPMI_CHANNEL_MEDIUM_8023_LAN;
%constant int CHANNEL_MEDIUM_RS232 = IPMI_CHANNEL_MEDIUM_RS232;
%constant int CHANNEL_MEDIUM_OTHER_LAN = IPMI_CHANNEL_MEDIUM_OTHER_LAN;
%constant int CHANNEL_MEDIUM_PCI_SMBUS = IPMI_CHANNEL_MEDIUM_PCI_SMBUS;
%constant int CHANNEL_MEDIUM_SMBUS_v1 = IPMI_CHANNEL_MEDIUM_SMBUS_v1;
%constant int CHANNEL_MEDIUM_SMBUS_v2 = IPMI_CHANNEL_MEDIUM_SMBUS_v2;
%constant int CHANNEL_MEDIUM_USB_v1 = IPMI_CHANNEL_MEDIUM_USB_v1;
%constant int CHANNEL_MEDIUM_USB_v2 = IPMI_CHANNEL_MEDIUM_USB_v2;
%constant int CHANNEL_MEDIUM_SYS_INTF = IPMI_CHANNEL_MEDIUM_SYS_INTF;
int get_medium(int *medium)
{
unsigned int val;
int rv = ipmi_channel_info_get_medium(self, &val);
*medium = val;
return rv;
}
%constant int CHANNEL_PROTOCOL_IPMB = IPMI_CHANNEL_PROTOCOL_IPMB;
%constant int CHANNEL_PROTOCOL_ICMB = IPMI_CHANNEL_PROTOCOL_ICMB;
%constant int CHANNEL_PROTOCOL_SMBus = IPMI_CHANNEL_PROTOCOL_SMBus;
%constant int CHANNEL_PROTOCOL_KCS = IPMI_CHANNEL_PROTOCOL_KCS;
%constant int CHANNEL_PROTOCOL_SMIC = IPMI_CHANNEL_PROTOCOL_SMIC;
%constant int CHANNEL_PROTOCOL_BT_v10 = IPMI_CHANNEL_PROTOCOL_BT_v10;
%constant int CHANNEL_PROTOCOL_BT_v15 = IPMI_CHANNEL_PROTOCOL_BT_v15;
%constant int CHANNEL_PROTOCOL_TMODE = IPMI_CHANNEL_PROTOCOL_TMODE;
int get_protocol_type(int *prot_type)
{
unsigned int val;
int rv = ipmi_channel_info_get_protocol_type(self, &val);
*prot_type = val;
return rv;
}
%constant int CHANNEL_SESSION_LESS = IPMI_CHANNEL_SESSION_LESS;
%constant int CHANNEL_SINGLE_SESSION = IPMI_CHANNEL_SINGLE_SESSION;
%constant int CHANNEL_MULTI_SESSION = IPMI_CHANNEL_MULTI_SESSION;
%constant int CHANNEL_SESSION_BASED = IPMI_CHANNEL_SESSION_BASED;
int get_session_support(int *sup)
{
unsigned int val;
int rv = ipmi_channel_info_get_session_support(self, &val);
*sup = val;
return rv;
}
/* Data is 3 bytes long */
%newobject get_vendor_id;
char *get_vendor_id()
{
unsigned char data[3];
int rv;
char *rdata = malloc(15);
if (!rdata)
return NULL;
rv = ipmi_channel_info_get_vendor_id(self, data);
if (rv)
return NULL;
sprintf(rdata, "0x%2.2x 0x%2.2x 0x%2.2x", data[0], data[1], data[2]);
return rdata;
}
/* Data is 2 bytes long */
%newobject get_aux_info;
char *get_aux_info()
{
unsigned char data[2];
int rv;
char *rdata = malloc(10);
if (!rdata)
return NULL;
rv = ipmi_channel_info_get_aux_info(self, data);
if (rv)
return NULL;
sprintf(rdata, "0x%2.2x 0x%2.2x", data[0], data[1]);
return rdata;
}
}
%extend ipmi_channel_access_t {
~ipmi_channel_access_t()
{
ipmi_channel_access_free(self);
}
%newobject copy;
ipmi_channel_access_t *copy()
{
return ipmi_channel_access_copy(self);
}
int get_channel(int *channel)
{
unsigned int val;
int rv = ipmi_channel_access_get_channel(self, &val);
*channel = val;
return rv;
}
int get_alerting_enabled(int *enab)
{
unsigned int val;
int rv = ipmi_channel_access_get_alerting_enabled(self, &val);
*enab = val;
return rv;
}
int set_alerting_enabled(int enab)
{
return ipmi_channel_access_set_alerting_enabled(self, enab);
}
int get_per_msg_auth(int *msg_auth)
{
unsigned int val;
int rv = ipmi_channel_access_get_per_msg_auth(self, &val);
*msg_auth = val;
return rv;
}
int set_per_msg_auth(int msg_auth)
{
return ipmi_channel_access_set_per_msg_auth(self, msg_auth);
}
int get_user_auth(int *user_auth)
{
unsigned int val;
int rv = ipmi_channel_access_get_user_auth(self, &val);
*user_auth = val;
return rv;
}
int set_user_auth(int user_auth)
{
return ipmi_channel_access_set_user_auth(self, user_auth);
}
%constant int CHANNEL_ACCESS_MODE_DISABLED = IPMI_CHANNEL_ACCESS_MODE_DISABLED;
%constant int CHANNEL_ACCESS_MODE_PRE_BOOT = IPMI_CHANNEL_ACCESS_MODE_PRE_BOOT;
%constant int CHANNEL_ACCESS_MODE_ALWAYS = IPMI_CHANNEL_ACCESS_MODE_ALWAYS;
%constant int CHANNEL_ACCESS_MODE_SHARED = IPMI_CHANNEL_ACCESS_MODE_SHARED;
int get_access_mode(int *access_mode)
{
unsigned int val;
int rv = ipmi_channel_access_get_access_mode(self, &val);
*access_mode = val;
return rv;
}
int set_access_mode(int access_mode)
{
return ipmi_channel_access_set_access_mode(self, access_mode);
}
%constant int PRIVILEGE_CALLBACK = IPMI_PRIVILEGE_CALLBACK;
%constant int PRIVILEGE_USER = IPMI_PRIVILEGE_USER;
%constant int PRIVILEGE_OPERATOR = IPMI_PRIVILEGE_OPERATOR;
%constant int PRIVILEGE_ADMIN = IPMI_PRIVILEGE_ADMIN;
%constant int PRIVILEGE_OEM = IPMI_PRIVILEGE_OEM;
int get_privilege_limit(int *priv_limit)
{
unsigned int val;
int rv = ipmi_channel_access_get_priv_limit(self, &val);
*priv_limit = val;
return rv;
}
int set_privilege_limit(int priv_limit)
{
return ipmi_channel_access_set_priv_limit(self, priv_limit);
}
/* Normally setting will only set the values you have changed. This
forces all the values to be set. */
int setall() {
return ipmi_channel_access_setall(self);
}
}
%extend ipmi_user_t {
~ipmi_user_t()
{
ipmi_user_free(self);
}
%newobject copy;
ipmi_user_t *copy()
{
return ipmi_user_copy(self);
}
int get_channel(int *channel)
{
unsigned int val;
int rv = ipmi_user_get_channel(self, &val);
*channel = val;
return rv;
}
int get_num(int *num)
{
unsigned int val;
int rv = ipmi_user_get_num(self, &val);
*num = val;
return rv;
}
int set_num(int num)
{
return ipmi_user_set_num(self, num);
}
char *get_name()
{
unsigned int len;
int rv;
char *name;
rv = ipmi_user_get_name_len(self, &len);
if (rv)
return NULL;
name = malloc(len+1);
if (!name)
return NULL;
rv = ipmi_user_get_name(self, name, &len);
if (rv) {
free(name);
return NULL;
}
return name;
}
int set_name(char *name)
{
return ipmi_user_set_name(self, name, strlen(name));
}
int set_password(char *pw)
{
return ipmi_user_set_password(self, pw, strlen(pw));
}
int set_password2(char *pw)
{
return ipmi_user_set_password2(self, pw, strlen(pw));
}
/* Set the password, using either set_password or set_password2,
depending on the length of the password. */
int set_password_auto(char *pw)
{
if (strlen(pw) > 16)
return ipmi_user_set_password2(self, pw, strlen(pw));
else
return ipmi_user_set_password(self, pw, strlen(pw));
}
int get_enable(int *enable)
{
unsigned int val;
int rv = ipmi_user_get_enable(self, &val);
*enable = val;
return rv;
}
int set_enable(int val)
{
return ipmi_user_set_enable(self, val);
}
int get_link_auth_enabled(int *enable)
{
unsigned int val;
int rv = ipmi_user_get_link_auth_enabled(self, &val);
*enable = val;
return rv;
}
int set_link_auth_enabled(int val)
{
return ipmi_user_set_link_auth_enabled(self, val);
}
int get_msg_auth_enabled(int *enable)
{
unsigned int val;
int rv = ipmi_user_get_msg_auth_enabled(self, &val);
*enable = val;
return rv;
}
int set_msg_auth_enabled(int val)
{
return ipmi_user_set_msg_auth_enabled(self, val);
}
int get_access_cb_only(int *cb)
{
unsigned int val;
int rv = ipmi_user_get_access_cb_only(self, &val);
*cb = val;
return rv;
}
int set_access_cb_only(int val)
{
return ipmi_user_set_access_cb_only(self, val);
}
int get_privilege_limit(int *limit)
{
unsigned int val;
int rv = ipmi_user_get_privilege_limit(self, &val);
*limit = val;
return rv;
}
int set_privilege_limit(int val)
{
return ipmi_user_set_privilege_limit(self, val);
}
int get_session_limit(int *limit)
{
unsigned int val;
int rv = ipmi_user_get_session_limit(self, &val);
*limit = val;
return rv;
}
int set_session_limit(int val)
{
return ipmi_user_set_session_limit(self, val);
}
int set_all()
{
return ipmi_user_set_all(self);
}
}
/*
* A sensor id object. This object is guaranteed to be valid and
* can be converted into a mc pointer later.
*/
%extend ipmi_sensor_id_t {
~ipmi_sensor_id_t()
{
free(self);
}
/* Compare self with other, return -1 if self<other, 0 if
self==other, or 1 if self>other. */
int cmp(ipmi_sensor_id_t *other)
{
return ipmi_cmp_sensor_id(*self, *other);
}
/*
* Convert a sensor id to a sensor pointer. The "sensor_cb" method
* will be called on the first parameter with the following parameters:
* <self> <sensor>
*/
int to_sensor(swig_cb *handler)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, sensor_cb))
rv = EINVAL;
else
rv = ipmi_sensor_pointer_cb(*self, handle_sensor_cb,
get_swig_cb(handler, sensor_cb));
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
/*
* An sensor object. Sensor operations take several different types
* of objects. These are mostly strings that are a list of values.
*
* Event states are represented as a string with value separated by
* spaces. These value are settings and the events. The strings
* "events", "scanning", and "busy" are settings for the full sensor
* event states. For threshold sensor, the other values in the string
* are 4 characters with: 1st character: u for upper or l for lower.
* 2nd character: n for non-critical, c for critical, and r for
* non-recoverable. 3rd character: h for going high and l for going
* low. 4th character: a for assertion and d for deassertion. For
* discrete sensors, the other values are a 1 or 2-digit number
* representing the offset and then a for assertion and d for
* deassertion.
*
* A states structure is similar to event status, but does not have
* the last two characters (direction and assertion) for thresholds
* and last chararacter (assertion) for discrete values.
*/
%extend ipmi_sensor_t {
%newobject get_name;
/*
* Get the name of an sensor.
*/
char *get_name()
{
char name[IPMI_SENSOR_NAME_LEN];
ipmi_sensor_get_name(self, name, sizeof(name));
return strdup(name);
}
%newobject get_id;
/*
* Get the id for the sensor.
*/
ipmi_sensor_id_t *get_id()
{
ipmi_sensor_id_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_sensor_convert_to_id(self);
return rv;
}
/*
* Register a handler to be called when an event comes from the
* sensor. If the sensor is a threshold sensor, the
* threshold_event_cb method will be called on the sensor.
* Otherwise, the sensor is discrete and the discrete_event_cb
* will be called. The threshold_event_cb method takes the
* following parameters:
* <self> <sensor> <event spec> <raw_set> <raw> <value_set> <value> <event>
* The discrete_event_cb method takes the following parameters:
* <self> <sensor> <event spec> <severity> <old_severity> <event>
*/
int add_event_handler(swig_cb *handler)
{
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
ipmi_sensor_add_threshold_event_handler_cl
(self, sensor_threshold_event_handler_cl, NULL);
cb_add(sensor, threshold_event, threshold_event_cb);
} else {
ipmi_sensor_add_discrete_event_handler_cl
(self, sensor_discrete_event_handler_cl, NULL);
cb_add(sensor, discrete_event, discrete_event_cb);
}
}
/*
* Remove the event handler from the sensor
*/
int remove_event_handler(swig_cb *handler)
{
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
cb_rm(sensor, threshold_event, threshold_event_cb);
} else {
cb_rm(sensor, discrete_event, discrete_event_cb);
}
}
/* Set the event enables for the given sensor to exactly the event
* states given in the first parameter. This will first enable
* the events/thresholds that are set, then disable the
* events/thresholds that are not set. When the operation is
* done, the sensor_event_enable_cb method on the second parm (if
* it is supplied) will be called with the following parameters:
* <self> <sensor> <err>
*/
int set_event_enables(char *states, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
ipmi_event_state_t *st = NULL;
IPMI_SWIG_C_CB_ENTRY
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
rv = str_to_threshold_event_state(states, &st);
} else {
rv = str_to_discrete_event_state(states, &st);
}
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_event_enable_cb)) {
rv = EINVAL;
goto out_err;
}
sensor_cb = sensor_event_enable_handler;
handler_val = ref_swig_cb(handler, sensor_event_enable_cb);
}
rv = ipmi_sensor_set_event_enables(self, st, sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
if (st)
free(st);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Enable the event states that are set in the first parameter.
* This will *only* enable those states, it will not disable any
* states. It will, however, set the "events" flag and the
* "scanning" flag for the sensor to the value in the states
* parameter. When the operation is done, the
* sensor_event_enable_cb method on the second parm (if it is
* supplied) will be called with the following parameters: <self>
* <sensor> <err>
*/
int enable_events(char *states, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
ipmi_event_state_t *st = NULL;
IPMI_SWIG_C_CB_ENTRY
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
rv = str_to_threshold_event_state(states, &st);
} else {
rv = str_to_discrete_event_state(states, &st);
}
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_event_enable_cb)) {
rv = EINVAL;
goto out_err;
}
sensor_cb = sensor_event_enable_handler;
handler_val = ref_swig_cb(handler, sensor_event_enable_cb);
}
rv = ipmi_sensor_enable_events(self, st, sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
if (st)
free(st);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Disable the event states that are set in the first parameter.
* This will *only* disable those states, it will not enable any
* states. It will, however, set the "events" flag and the
* "scanning" flag for the sensor to the value in the states
* parameter. When the operation is done, the
* sensor_event_enable_cb method on the second parm (if it is
* supplied) will be called with the following parameters: <self>
* <sensor> <err>
*/
int disable_events(char *states, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
ipmi_event_state_t *st = NULL;
IPMI_SWIG_C_CB_ENTRY
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
rv = str_to_threshold_event_state(states, &st);
} else {
rv = str_to_discrete_event_state(states, &st);
}
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_event_enable_cb)) {
rv = EINVAL;
goto out_err;
}
sensor_cb = sensor_event_enable_handler;
handler_val = ref_swig_cb(handler, sensor_event_enable_cb);
}
rv = ipmi_sensor_disable_events(self, st, sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
if (st)
free(st);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the event enables for the given sensor. When done, the
* sensor_get_event_enable_cb method on the first parameter will
* be called with the following parameters: <self> <sensor> <err>
* <event states>
*/
int get_event_enables(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_event_enables_cb sensor_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, sensor_get_event_enable_cb))
rv = EINVAL;
else {
sensor_cb = sensor_get_event_enables_handler;
handler_val = ref_swig_cb(handler, sensor_get_event_enable_cb);
rv = ipmi_sensor_get_event_enables(self, sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Rearm the current sensor. This will cause the sensor to resend
* it's current event state if it is out of range. If
* get_supports_auto_rearm() returns false and you receive an
* event, you have to rearm a sensor manually to get another event
* from it. If global_enable (parm 1) is set, all events are
* enabled and the state is ignored (and may be NULL). Otherwise,
* the events set in the event state (parm 2) are enabled. When
* the operation is complete, the sensor_rearm_cb method of the
* third parameter (if it is supplied) will be called with the
* following parameters: <self> <sensor> <err>
*/
int rearm(int global_enable,
char *states,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
ipmi_event_state_t *st = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!global_enable) {
if (!states) {
rv = EINVAL;
goto out_err;
}
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
rv = str_to_threshold_event_state(states, &st);
} else {
rv = str_to_discrete_event_state(states, &st);
}
if (rv)
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_rearm_cb)) {
rv = EINVAL;
goto out_err;
}
sensor_cb = sensor_rearm_handler;
handler_val = ref_swig_cb(handler, sensor_rearm_cb);
}
rv = ipmi_sensor_rearm(self, global_enable, st,
sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
if (st)
free(st);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the hysteresis values for the given sensor. These are the
* raw values, there doesn't seem to be an easy way to calculate
* the cooked values. The sensor_get_hysteresis_cb method on the
* first parameter will be called with the values. It's
* parameters are: <self> <sensor> <err> <positive hysteresis>
* <negative hysteresis>
*/
int get_hysteresis(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_hysteresis_cb sensor_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, sensor_get_hysteresis_cb))
rv = EINVAL;
else {
sensor_cb = sensor_get_hysteresis_handler;
handler_val = ref_swig_cb(handler, sensor_get_hysteresis_cb);
rv = ipmi_sensor_get_hysteresis(self, sensor_cb, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the hysteresis values for the given sensor. These are the
* raw values, there doesn't seem to be an easy way to calculate
* the cooked values. The positive hysteresis is the first
* parameter, the negative hystersis is the second. When the
* operation completes, the sensor_set_hysteresis_cb will be
* called on the third parameter (if it is supplied) with the
* following parms: <self> <sensor> <err>
*/
int set_hysteresis(unsigned int positive_hysteresis,
unsigned int negative_hysteresis,
swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_set_hysteresis_cb)) {
rv = EINVAL;
goto out_err;
}
sensor_cb = sensor_set_hysteresis_handler;
handler_val = ref_swig_cb(handler, sensor_set_hysteresis_cb);
}
rv = ipmi_sensor_set_hysteresis(self, positive_hysteresis,
negative_hysteresis,
sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%newobject get_default_thresholds;
/*
* Return the default threshold settings for a sensor.
*/
char *get_default_thresholds()
{
ipmi_thresholds_t *th = malloc(ipmi_thresholds_size());
char *str = NULL;
int rv;
rv = ipmi_get_default_sensor_thresholds(self, th);
if (!rv) {
str = thresholds_to_str(th);
}
free(th);
return str;
}
/*
* Set the thresholds for the given sensor to the threshold values
* specified in the first parameter. When the thresholds are set,
* the sensor_set_thresholds_cb method on the second parm (if it
* is supplied) will be called with the following parameters:
* <self> <sensor> <err>
*/
int set_thresholds(char *thresholds,
swig_cb *handler = NULL)
{
ipmi_thresholds_t *th = NULL;
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_done_cb sensor_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
rv = str_to_thresholds(thresholds, self, &th);
if (rv)
goto out_err;
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sensor_set_thresholds_cb)) {
rv = EINVAL;
goto out_err_free;
}
sensor_cb = sensor_set_thresholds_handler;
handler_val = ref_swig_cb(handler, sensor_set_thresholds_cb);
}
rv = ipmi_sensor_set_thresholds(self, th, sensor_cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err_free:
free(th);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Fetch the thresholds for the given sensor. When the thresholds
* are received, the sensor_get_thresholds_cb method on the second
* parm will be called with the following parameters: <self>
* <sensor> <err> <thresholds>
*/
int get_thresholds(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_sensor_thresholds_cb sensor_cb = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, sensor_get_thresholds_cb))
rv = EINVAL;
else {
sensor_cb = sensor_get_thresholds_handler;
handler_val = ref_swig_cb(handler, sensor_get_thresholds_cb);
rv = ipmi_sensor_get_thresholds(self, sensor_cb, handler_val);
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/* Read the current value of the given sensor. If this is a
discrete sensor, the discrete_states_cb method of the first
parameter will be called with the following parameters: <self>
<sensor> <err> <states>. If this is a threshold sensor, the
threshold_reading_cb method of the first parameter will be
called with the following parameters: <self> <sensor> <err>
<raw_set> <raw> <value_set> <value> <states>. */
int get_value(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, threshold_reading_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, threshold_reading_cb);
if (ipmi_sensor_get_event_reading_type(self)
== IPMI_EVENT_READING_TYPE_THRESHOLD)
{
ipmi_sensor_reading_cb sensor_cb;
sensor_cb = sensor_get_reading_handler;
rv = ipmi_sensor_get_reading(self, sensor_cb, handler_val);
} else {
ipmi_sensor_states_cb sensor_cb;
sensor_cb = sensor_get_states_handler;
rv = ipmi_sensor_get_states(self, sensor_cb, handler_val);
}
if (rv)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Return the LUN for the sensor (with respect to the MC).
*/
int get_lun()
{
int lun = 0;
ipmi_sensor_get_num(self, &lun, NULL);
return lun;
}
/*
* Return the number for the sensor (The number in the MC/LUN).
*/
int get_num()
{
int num = 0;
ipmi_sensor_get_num(self, NULL, &num);
return num;
}
/*
* The sensor type. This return sa string representing the sensor
* type.
*/
const char *get_sensor_type_string()
{
return ipmi_sensor_get_sensor_type_string(self);
}
%constant int SENSOR_TYPE_TEMPERATURE = IPMI_SENSOR_TYPE_TEMPERATURE;
%constant int SENSOR_TYPE_VOLTAGE = IPMI_SENSOR_TYPE_VOLTAGE;
%constant int SENSOR_TYPE_CURRENT = IPMI_SENSOR_TYPE_CURRENT;
%constant int SENSOR_TYPE_FAN = IPMI_SENSOR_TYPE_FAN;
%constant int SENSOR_TYPE_PHYSICAL_SECURITY = IPMI_SENSOR_TYPE_PHYSICAL_SECURITY;
%constant int SENSOR_TYPE_PLATFORM_SECURITY = IPMI_SENSOR_TYPE_PLATFORM_SECURITY;
%constant int SENSOR_TYPE_PROCESSOR = IPMI_SENSOR_TYPE_PROCESSOR;
%constant int SENSOR_TYPE_POWER_SUPPLY = IPMI_SENSOR_TYPE_POWER_SUPPLY;
%constant int SENSOR_TYPE_POWER_UNIT = IPMI_SENSOR_TYPE_POWER_UNIT;
%constant int SENSOR_TYPE_COOLING_DEVICE = IPMI_SENSOR_TYPE_COOLING_DEVICE;
%constant int SENSOR_TYPE_OTHER_UNITS_BASED_SENSOR = IPMI_SENSOR_TYPE_OTHER_UNITS_BASED_SENSOR;
%constant int SENSOR_TYPE_MEMORY = IPMI_SENSOR_TYPE_MEMORY;
%constant int SENSOR_TYPE_DRIVE_SLOT = IPMI_SENSOR_TYPE_DRIVE_SLOT;
%constant int SENSOR_TYPE_POWER_MEMORY_RESIZE = IPMI_SENSOR_TYPE_POWER_MEMORY_RESIZE;
%constant int SENSOR_TYPE_SYSTEM_FIRMWARE_PROGRESS = IPMI_SENSOR_TYPE_SYSTEM_FIRMWARE_PROGRESS;
%constant int SENSOR_TYPE_EVENT_LOGGING_DISABLED = IPMI_SENSOR_TYPE_EVENT_LOGGING_DISABLED;
%constant int SENSOR_TYPE_WATCHDOG_1 = IPMI_SENSOR_TYPE_WATCHDOG_1;
%constant int SENSOR_TYPE_SYSTEM_EVENT = IPMI_SENSOR_TYPE_SYSTEM_EVENT;
%constant int SENSOR_TYPE_CRITICAL_INTERRUPT = IPMI_SENSOR_TYPE_CRITICAL_INTERRUPT;
%constant int SENSOR_TYPE_BUTTON = IPMI_SENSOR_TYPE_BUTTON;
%constant int SENSOR_TYPE_MODULE_BOARD = IPMI_SENSOR_TYPE_MODULE_BOARD;
%constant int SENSOR_TYPE_MICROCONTROLLER_COPROCESSOR = IPMI_SENSOR_TYPE_MICROCONTROLLER_COPROCESSOR;
%constant int SENSOR_TYPE_ADD_IN_CARD = IPMI_SENSOR_TYPE_ADD_IN_CARD;
%constant int SENSOR_TYPE_CHASSIS = IPMI_SENSOR_TYPE_CHASSIS;
%constant int SENSOR_TYPE_CHIP_SET = IPMI_SENSOR_TYPE_CHIP_SET;
%constant int SENSOR_TYPE_OTHER_FRU = IPMI_SENSOR_TYPE_OTHER_FRU;
%constant int SENSOR_TYPE_CABLE_INTERCONNECT = IPMI_SENSOR_TYPE_CABLE_INTERCONNECT;
%constant int SENSOR_TYPE_TERMINATOR = IPMI_SENSOR_TYPE_TERMINATOR;
%constant int SENSOR_TYPE_SYSTEM_BOOT_INITIATED = IPMI_SENSOR_TYPE_SYSTEM_BOOT_INITIATED;
%constant int SENSOR_TYPE_BOOT_ERROR = IPMI_SENSOR_TYPE_BOOT_ERROR;
%constant int SENSOR_TYPE_OS_BOOT = IPMI_SENSOR_TYPE_OS_BOOT;
%constant int SENSOR_TYPE_OS_CRITICAL_STOP = IPMI_SENSOR_TYPE_OS_CRITICAL_STOP;
%constant int SENSOR_TYPE_SLOT_CONNECTOR = IPMI_SENSOR_TYPE_SLOT_CONNECTOR;
%constant int SENSOR_TYPE_SYSTEM_ACPI_POWER_STATE = IPMI_SENSOR_TYPE_SYSTEM_ACPI_POWER_STATE;
%constant int SENSOR_TYPE_WATCHDOG_2 = IPMI_SENSOR_TYPE_WATCHDOG_2;
%constant int SENSOR_TYPE_PLATFORM_ALERT = IPMI_SENSOR_TYPE_PLATFORM_ALERT;
%constant int SENSOR_TYPE_ENTITY_PRESENCE = IPMI_SENSOR_TYPE_ENTITY_PRESENCE;
%constant int SENSOR_TYPE_MONITOR_ASIC_IC = IPMI_SENSOR_TYPE_MONITOR_ASIC_IC;
%constant int SENSOR_TYPE_LAN = IPMI_SENSOR_TYPE_LAN;
%constant int SENSOR_TYPE_MANAGEMENT_SUBSYSTEM_HEALTH = IPMI_SENSOR_TYPE_MANAGEMENT_SUBSYSTEM_HEALTH;
%constant int SENSOR_TYPE_BATTERY = IPMI_SENSOR_TYPE_BATTERY;
/*
* Return the numeric sensor type.
*/
int get_sensor_type()
{
return ipmi_sensor_get_sensor_type(self);
}
/*
* Return the event reading type string. If this returns
* "threshold", then this is a threshold sensor. Otherwise it is
* a discrete sensor.
*/
const char *get_event_reading_type_string()
{
return ipmi_sensor_get_event_reading_type_string(self);
}
%constant int EVENT_READING_TYPE_THRESHOLD = IPMI_EVENT_READING_TYPE_THRESHOLD;
%constant int EVENT_READING_TYPE_DISCRETE_USAGE = IPMI_EVENT_READING_TYPE_DISCRETE_USAGE;
%constant int EVENT_READING_TYPE_DISCRETE_STATE = IPMI_EVENT_READING_TYPE_DISCRETE_STATE;
%constant int EVENT_READING_TYPE_DISCRETE_PREDICTIVE_FAILURE = IPMI_EVENT_READING_TYPE_DISCRETE_PREDICTIVE_FAILURE;
%constant int EVENT_READING_TYPE_DISCRETE_LIMIT_EXCEEDED = IPMI_EVENT_READING_TYPE_DISCRETE_LIMIT_EXCEEDED;
%constant int EVENT_READING_TYPE_DISCRETE_PERFORMANCE_MET = IPMI_EVENT_READING_TYPE_DISCRETE_PERFORMANCE_MET;
%constant int EVENT_READING_TYPE_DISCRETE_SEVERITY = IPMI_EVENT_READING_TYPE_DISCRETE_SEVERITY;
%constant int EVENT_READING_TYPE_DISCRETE_DEVICE_PRESENCE = IPMI_EVENT_READING_TYPE_DISCRETE_DEVICE_PRESENCE;
%constant int EVENT_READING_TYPE_DISCRETE_DEVICE_ENABLE = IPMI_EVENT_READING_TYPE_DISCRETE_DEVICE_ENABLE;
%constant int EVENT_READING_TYPE_DISCRETE_AVAILABILITY = IPMI_EVENT_READING_TYPE_DISCRETE_AVAILABILITY;
%constant int EVENT_READING_TYPE_DISCRETE_REDUNDANCY = IPMI_EVENT_READING_TYPE_DISCRETE_REDUNDANCY;
%constant int EVENT_READING_TYPE_DISCRETE_ACPI_POWER = IPMI_EVENT_READING_TYPE_DISCRETE_ACPI_POWER;
%constant int EVENT_READING_TYPE_SENSOR_SPECIFIC = IPMI_EVENT_READING_TYPE_SENSOR_SPECIFIC;
/*
* Return the numeric event reading type. This will return
* EVENT_READING_TYPE_THRESHOLD for threshold sensors; everthing
* else is a discrete sensor.
*/
int get_event_reading_type()
{
return ipmi_sensor_get_event_reading_type(self);
}
/*
* Get the string for the sensor's rate unit. This will be blank
* if there is not a rate unit for this sensor.
*/
const char *get_rate_unit_string()
{
return ipmi_sensor_get_rate_unit_string(self);
}
%constant int RATE_UNIT_NONE = IPMI_RATE_UNIT_NONE;
%constant int RATE_UNIT_PER_US = IPMI_RATE_UNIT_PER_US;
%constant int RATE_UNIT_PER_MS = IPMI_RATE_UNIT_PER_MS;
%constant int RATE_UNIT_PER_SEC = IPMI_RATE_UNIT_PER_SEC;
%constant int RATE_UNIT_MIN = IPMI_RATE_UNIT_MIN;
%constant int RATE_UNIT_HOUR = IPMI_RATE_UNIT_HOUR;
%constant int RATE_UNIT_DAY = IPMI_RATE_UNIT_DAY;
/*
* Get the rate unit for this sensor.
*/
int get_rate_unit()
{
return ipmi_sensor_get_rate_unit(self);
}
/*
* Get the string for the sensor's base unit.
*/
const char *get_base_unit_string()
{
return ipmi_sensor_get_base_unit_string(self);
}
%constant int UNIT_TYPE_UNSPECIFIED = IPMI_UNIT_TYPE_UNSPECIFIED;
%constant int UNIT_TYPE_DEGREES_C = IPMI_UNIT_TYPE_DEGREES_C;
%constant int UNIT_TYPE_DEGREES_F = IPMI_UNIT_TYPE_DEGREES_F;
%constant int UNIT_TYPE_DEGREES_K = IPMI_UNIT_TYPE_DEGREES_K;
%constant int UNIT_TYPE_VOLTS = IPMI_UNIT_TYPE_VOLTS;
%constant int UNIT_TYPE_AMPS = IPMI_UNIT_TYPE_AMPS;
%constant int UNIT_TYPE_WATTS = IPMI_UNIT_TYPE_WATTS;
%constant int UNIT_TYPE_JOULES = IPMI_UNIT_TYPE_JOULES;
%constant int UNIT_TYPE_COULOMBS = IPMI_UNIT_TYPE_COULOMBS;
%constant int UNIT_TYPE_VA = IPMI_UNIT_TYPE_VA;
%constant int UNIT_TYPE_NITS = IPMI_UNIT_TYPE_NITS;
%constant int UNIT_TYPE_LUMENS = IPMI_UNIT_TYPE_LUMENS;
%constant int UNIT_TYPE_LUX = IPMI_UNIT_TYPE_LUX;
%constant int UNIT_TYPE_CANDELA = IPMI_UNIT_TYPE_CANDELA;
%constant int UNIT_TYPE_KPA = IPMI_UNIT_TYPE_KPA;
%constant int UNIT_TYPE_PSI = IPMI_UNIT_TYPE_PSI;
%constant int UNIT_TYPE_NEWTONS = IPMI_UNIT_TYPE_NEWTONS;
%constant int UNIT_TYPE_CFM = IPMI_UNIT_TYPE_CFM;
%constant int UNIT_TYPE_RPM = IPMI_UNIT_TYPE_RPM;
%constant int UNIT_TYPE_HZ = IPMI_UNIT_TYPE_HZ;
%constant int UNIT_TYPE_USECONDS = IPMI_UNIT_TYPE_USECONDS;
%constant int UNIT_TYPE_MSECONDS = IPMI_UNIT_TYPE_MSECONDS;
%constant int UNIT_TYPE_SECONDS = IPMI_UNIT_TYPE_SECONDS;
%constant int UNIT_TYPE_MINUTE = IPMI_UNIT_TYPE_MINUTE;
%constant int UNIT_TYPE_HOUR = IPMI_UNIT_TYPE_HOUR;
%constant int UNIT_TYPE_DAY = IPMI_UNIT_TYPE_DAY;
%constant int UNIT_TYPE_WEEK = IPMI_UNIT_TYPE_WEEK;
%constant int UNIT_TYPE_MIL = IPMI_UNIT_TYPE_MIL;
%constant int UNIT_TYPE_INCHES = IPMI_UNIT_TYPE_INCHES;
%constant int UNIT_TYPE_FEET = IPMI_UNIT_TYPE_FEET;
%constant int UNIT_TYPE_CUBIC_INCHS = IPMI_UNIT_TYPE_CUBIC_INCHS;
%constant int UNIT_TYPE_CUBIC_FEET = IPMI_UNIT_TYPE_CUBIC_FEET;
%constant int UNIT_TYPE_MILLIMETERS = IPMI_UNIT_TYPE_MILLIMETERS;
%constant int UNIT_TYPE_CENTIMETERS = IPMI_UNIT_TYPE_CENTIMETERS;
%constant int UNIT_TYPE_METERS = IPMI_UNIT_TYPE_METERS;
%constant int UNIT_TYPE_CUBIC_CENTIMETERS = IPMI_UNIT_TYPE_CUBIC_CENTIMETERS;
%constant int UNIT_TYPE_CUBIC_METERS = IPMI_UNIT_TYPE_CUBIC_METERS;
%constant int UNIT_TYPE_LITERS = IPMI_UNIT_TYPE_LITERS;
%constant int UNIT_TYPE_FL_OZ = IPMI_UNIT_TYPE_FL_OZ;
%constant int UNIT_TYPE_RADIANS = IPMI_UNIT_TYPE_RADIANS;
%constant int UNIT_TYPE_SERADIANS = IPMI_UNIT_TYPE_SERADIANS;
%constant int UNIT_TYPE_REVOLUTIONS = IPMI_UNIT_TYPE_REVOLUTIONS;
%constant int UNIT_TYPE_CYCLES = IPMI_UNIT_TYPE_CYCLES;
%constant int UNIT_TYPE_GRAVITIES = IPMI_UNIT_TYPE_GRAVITIES;
%constant int UNIT_TYPE_OUNCES = IPMI_UNIT_TYPE_OUNCES;
%constant int UNIT_TYPE_POUNDS = IPMI_UNIT_TYPE_POUNDS;
%constant int UNIT_TYPE_FOOT_POUNDS = IPMI_UNIT_TYPE_FOOT_POUNDS;
%constant int UNIT_TYPE_OUNCE_INCHES = IPMI_UNIT_TYPE_OUNCE_INCHES;
%constant int UNIT_TYPE_GAUSS = IPMI_UNIT_TYPE_GAUSS;
%constant int UNIT_TYPE_GILBERTS = IPMI_UNIT_TYPE_GILBERTS;
%constant int UNIT_TYPE_HENRIES = IPMI_UNIT_TYPE_HENRIES;
%constant int UNIT_TYPE_MHENRIES = IPMI_UNIT_TYPE_MHENRIES;
%constant int UNIT_TYPE_FARADS = IPMI_UNIT_TYPE_FARADS;
%constant int UNIT_TYPE_UFARADS = IPMI_UNIT_TYPE_UFARADS;
%constant int UNIT_TYPE_OHMS = IPMI_UNIT_TYPE_OHMS;
%constant int UNIT_TYPE_SIEMENS = IPMI_UNIT_TYPE_SIEMENS;
%constant int UNIT_TYPE_MOLES = IPMI_UNIT_TYPE_MOLES;
%constant int UNIT_TYPE_BECQUERELS = IPMI_UNIT_TYPE_BECQUERELS;
%constant int UNIT_TYPE_PPM = IPMI_UNIT_TYPE_PPM;
%constant int UNIT_TYPE_reserved1 = IPMI_UNIT_TYPE_reserved1;
%constant int UNIT_TYPE_DECIBELS = IPMI_UNIT_TYPE_DECIBELS;
%constant int UNIT_TYPE_DbA = IPMI_UNIT_TYPE_DbA;
%constant int UNIT_TYPE_DbC = IPMI_UNIT_TYPE_DbC;
%constant int UNIT_TYPE_GRAYS = IPMI_UNIT_TYPE_GRAYS;
%constant int UNIT_TYPE_SIEVERTS = IPMI_UNIT_TYPE_SIEVERTS;
%constant int UNIT_TYPE_COLOR_TEMP_DEG_K = IPMI_UNIT_TYPE_COLOR_TEMP_DEG_K;
%constant int UNIT_TYPE_BITS = IPMI_UNIT_TYPE_BITS;
%constant int UNIT_TYPE_KBITS = IPMI_UNIT_TYPE_KBITS;
%constant int UNIT_TYPE_MBITS = IPMI_UNIT_TYPE_MBITS;
%constant int UNIT_TYPE_GBITS = IPMI_UNIT_TYPE_GBITS;
%constant int UNIT_TYPE_BYTES = IPMI_UNIT_TYPE_BYTES;
%constant int UNIT_TYPE_KBYTES = IPMI_UNIT_TYPE_KBYTES;
%constant int UNIT_TYPE_MBYTES = IPMI_UNIT_TYPE_MBYTES;
%constant int UNIT_TYPE_GBYTES = IPMI_UNIT_TYPE_GBYTES;
%constant int UNIT_TYPE_WORDS = IPMI_UNIT_TYPE_WORDS;
%constant int UNIT_TYPE_DWORDS = IPMI_UNIT_TYPE_DWORDS;
%constant int UNIT_TYPE_QWORDS = IPMI_UNIT_TYPE_QWORDS;
%constant int UNIT_TYPE_LINES = IPMI_UNIT_TYPE_LINES;
%constant int UNIT_TYPE_HITS = IPMI_UNIT_TYPE_HITS;
%constant int UNIT_TYPE_MISSES = IPMI_UNIT_TYPE_MISSES;
%constant int UNIT_TYPE_RETRIES = IPMI_UNIT_TYPE_RETRIES;
%constant int UNIT_TYPE_RESETS = IPMI_UNIT_TYPE_RESETS;
%constant int UNIT_TYPE_OVERRUNS = IPMI_UNIT_TYPE_OVERRUNS;
%constant int UNIT_TYPE_UNDERRUNS = IPMI_UNIT_TYPE_UNDERRUNS;
%constant int UNIT_TYPE_COLLISIONS = IPMI_UNIT_TYPE_COLLISIONS;
%constant int UNIT_TYPE_PACKETS = IPMI_UNIT_TYPE_PACKETS;
%constant int UNIT_TYPE_MESSAGES = IPMI_UNIT_TYPE_MESSAGES;
%constant int UNIT_TYPE_CHARACTERS = IPMI_UNIT_TYPE_CHARACTERS;
%constant int UNIT_TYPE_ERRORS = IPMI_UNIT_TYPE_ERRORS;
%constant int UNIT_TYPE_CORRECTABLE_ERRORS = IPMI_UNIT_TYPE_CORRECTABLE_ERRORS;
%constant int UNIT_TYPE_UNCORRECTABLE_ERRORS = IPMI_UNIT_TYPE_UNCORRECTABLE_ERRORS;
%constant int UNIT_TYPE_FATAL_ERRORS = IPMI_UNIT_TYPE_FATAL_ERRORS;
%constant int UNIT_TYPE_GRAMS = IPMI_UNIT_TYPE_GRAMS;
/*
* Get the sensor's base unit.
*/
int get_base_unit()
{
return ipmi_sensor_get_base_unit(self);
}
/*
* Get the modifier unit string for the sensor, this will be an empty
* string if there is none.
*/
const char *get_modifier_unit_string()
{
return ipmi_sensor_get_modifier_unit_string(self);
}
/*
* Get the sensor's modifier unit.
*/
int get_modifier_unit()
{
return ipmi_sensor_get_modifier_unit(self);
}
%constant int MODIFIER_UNIT_NONE = IPMI_MODIFIER_UNIT_NONE;
%constant int MODIFIER_UNIT_BASE_DIV_MOD = IPMI_MODIFIER_UNIT_BASE_DIV_MOD;
%constant int MODIFIER_UNIT_BASE_MULT_MOD = IPMI_MODIFIER_UNIT_BASE_MULT_MOD;
/*
* Return the how the modifier unit should be used. If this
* returns MODIFIER_UNIT_NONE, then the modifier unit is not
* used. If it returns MODIFIER_UNIT_BASE_DIV_MOD, the modifier
* unit is dividied by the base unit (eg per hour, per second,
* etc.). If it returns MODIFIER_UNIT_BASE_MULT_MOD, the modifier
* unit is multiplied by the base unit.
*/
int get_modifier_unit_use()
{
return ipmi_sensor_get_modifier_unit_use(self);
}
/*
* Returns if the value is a percentage.
*/
int get_percentage()
{
return ipmi_sensor_get_percentage(self);
}
/*
* This call is a little different from the other string calls.
* For a discrete sensor, you can pass the offset into this call
* and it will return the string associated with the reading.
* This way, OEM sensors can supply their own strings as necessary
* for the various offsets. This is only for discrete sensors.
*/
const char *reading_name_string(int offset)
{
return ipmi_sensor_reading_name_string(self, offset);
}
/*
* Get the entity id of the entity the sensor is hooked to.
*/
int get_entity_id()
{
return ipmi_sensor_get_entity_id(self);
}
/*
* Get the entity instance of the entity the sensor is hooked to.
*/
int get_entity_instance()
{
return ipmi_sensor_get_entity_instance(self);
}
/*
* Get the entity the sensor is hooked to.
*/
ipmi_entity_t *get_entity()
{
return ipmi_sensor_get_entity(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_scanning()
{
return ipmi_sensor_get_sensor_init_scanning(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_events()
{
return ipmi_sensor_get_sensor_init_events(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_thresholds()
{
return ipmi_sensor_get_sensor_init_thresholds(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_hysteresis()
{
return ipmi_sensor_get_sensor_init_hysteresis(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_type()
{
return ipmi_sensor_get_sensor_init_type(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_pu_events()
{
return ipmi_sensor_get_sensor_init_pu_events(self);
}
/*
* Initialization information about a sensor from it's SDR.
*/
int get_sensor_init_pu_scanning()
{
return ipmi_sensor_get_sensor_init_pu_scanning(self);
}
/*
* Ignore the sensor if the entity it is attached to is not
* present.
*/
int get_ignore_if_no_entity()
{
return ipmi_sensor_get_ignore_if_no_entity(self);
}
/*
* If this is false, the user must manually re-arm the sensor to get
* any more events from it.
*/
int get_supports_auto_rearm()
{
return ipmi_sensor_get_supports_auto_rearm(self);
}
%constant int THRESHOLD_ACCESS_SUPPORT_NONE = IPMI_THRESHOLD_ACCESS_SUPPORT_NONE;
%constant int THRESHOLD_ACCESS_SUPPORT_READABLE = IPMI_THRESHOLD_ACCESS_SUPPORT_READABLE;
%constant int THRESHOLD_ACCESS_SUPPORT_SETTABLE = IPMI_THRESHOLD_ACCESS_SUPPORT_SETTABLE;
%constant int THRESHOLD_ACCESS_SUPPORT_FIXED = IPMI_THRESHOLD_ACCESS_SUPPORT_FIXED;
/*
* Get how the thresholds of the sensor may be accessed.
*/
int get_threshold_access()
{
return ipmi_sensor_get_threshold_access(self);
}
%constant int HYSTERESIS_SUPPORT_NONE = IPMI_HYSTERESIS_SUPPORT_NONE;
%constant int HYSTERESIS_SUPPORT_READABLE = IPMI_HYSTERESIS_SUPPORT_READABLE;
%constant int HYSTERESIS_SUPPORT_SETTABLE = IPMI_HYSTERESIS_SUPPORT_SETTABLE;
%constant int HYSTERESIS_SUPPORT_FIXED = IPMI_HYSTERESIS_SUPPORT_FIXED;
/*
* Get how the hysteresis of the sensor may be accessed.
*/
int get_hysteresis_support()
{
return ipmi_sensor_get_hysteresis_support(self);
}
%constant int EVENT_SUPPORT_PER_STATE = IPMI_EVENT_SUPPORT_PER_STATE;
%constant int EVENT_SUPPORT_ENTIRE_SENSOR = IPMI_EVENT_SUPPORT_ENTIRE_SENSOR;
%constant int EVENT_SUPPORT_GLOBAL_ENABLE = IPMI_EVENT_SUPPORT_GLOBAL_ENABLE;
%constant int EVENT_SUPPORT_GLOBAL_DISABLE = IPMI_EVENT_SUPPORT_GLOBAL_DISABLE;
%constant int EVENT_SUPPORT_NONE = IPMI_EVENT_SUPPORT_NONE;
/*
* Get how the events in the sensor may be enabled and disabled.
*/
int get_event_support()
{
return ipmi_sensor_get_event_support(self);
}
%constant int SENSOR_DIRECTION_UNSPECIFIED = IPMI_SENSOR_DIRECTION_UNSPECIFIED;
%constant int SENSOR_DIRECTION_INPUT = IPMI_SENSOR_DIRECTION_INPUT;
%constant int SENSOR_DIRECTION_OUTPUT = IPMI_SENSOR_DIRECTION_OUTPUT;
/*
* Get whether the sensor is monitoring an input or an output.
* For instance, the +5V sensor on the output of a power supply
* would be the output, the +5V sensor measuring the voltage
* coming into a card would be an input.
*/
int get_sensor_direction()
{
return ipmi_sensor_get_sensor_direction(self);
}
/*
* Get whether the sensor's value can be read or not (with
* get_value()). Sensors with system software owners and
* event-only sensors cannot be read.
*/
int is_readable()
{
return ipmi_sensor_get_is_readable(self);
}
/*
* Sets the second parameter to if an event is supported for this
* particular threshold event on the sensor. The first parameter
* is the event specifier string. This will return 0 on success
* or EINVAL on an invalid event.
*/
int threshold_event_supported(char *event, int *val)
{
enum ipmi_thresh_e thresh;
enum ipmi_event_value_dir_e value_dir;
enum ipmi_event_dir_e dir;
char *s;
s = threshold_event_from_str(event, strlen(event), &thresh,
&value_dir, &dir);
if (!s)
return EINVAL;
return ipmi_sensor_threshold_event_supported(self,
thresh,
value_dir,
dir,
val);
}
/*
* Sets the second parameter to if a specific threshold can be
* set. The first parameter is the threshold. Returns EINVAL
* if the threshold is invalid, otherwise returns zero.
*/
int threshold_settable(char *threshold, int *val)
{
enum ipmi_thresh_e thresh;
char *s;
s = threshold_from_str(threshold, strlen(threshold), &thresh);
if (!s)
return EINVAL;
return ipmi_sensor_threshold_settable(self, thresh, val);
}
/*
* Sets the second parameter to if a specific threshold can be
* read. The first parameter is the threshold. Returns EINVAL
* if the threshold is invalid, otherwise returns zero.
*/
int threshold_readable(char *threshold, int *val)
{
enum ipmi_thresh_e thresh;
char *s;
s = threshold_from_str(threshold, strlen(threshold), &thresh);
if (!s)
return EINVAL;
return ipmi_sensor_threshold_readable(self, thresh, val);
}
/*
* Sets the second parameter to if a specific threshold has its
* reading returned when reading the value of the sensor. The
* first parameter is the threshold. Returns EINVAL if the
* threshold is invalid, otherwise returns zero.
*/
int threshold_reading_supported(char *threshold, int *val)
{
enum ipmi_thresh_e thresh;
char *s;
s = threshold_from_str(threshold, strlen(threshold), &thresh);
if (!s)
return EINVAL;
return ipmi_sensor_threshold_reading_supported(self, thresh, val);
}
/*
* Sets the second parameter to if an offset will generate an
* event for the given event specifier for this particular
* sensor. The first parameter is the event specifier string.
* This will return 0 on success or EINVAL on an invalid event.
*/
int discrete_event_supported(char *event, int *val)
{
int offset;
enum ipmi_event_dir_e dir;
char *s;
s = discrete_event_from_str(event, strlen(event), &offset, &dir);
if (!s)
return EINVAL;
return ipmi_sensor_discrete_event_supported(self, offset, dir, val);
}
/*
* Sets the second parameter to if a specific offset is set by the
* sensor. The first parameter is the offset. Returns EINVAL if
* the threshold is invalid, otherwise returns zero.
*/
int discrete_event_readable(int offset, int *val)
{
return ipmi_sensor_discrete_event_readable(self, offset, val);
}
/*
* Returns the tolerance for the sensor at the given raw value
* (first parameter). The tolerance is returned as a double in
* the second parameter. Returns an error value.
*/
int get_tolerance(int val, double *tolerance)
{
return ipmi_sensor_get_tolerance(self, val, tolerance);
}
/*
* Returns the accuracy for the sensor at the given raw value
* (first parameter). The accuracy is returned as a double in the
* second parameter. Returns an error value.
*/
int get_accuracy(int val, double *accuracy)
{
return ipmi_sensor_get_accuracy(self, val, accuracy);
}
/*
* Is the normal minimum for the sensor specified?
*/
int get_normal_min_specified()
{
return ipmi_sensor_get_normal_min_specified(self);
}
/*
* Get the normal minimum for the sensor into the first parameter.
* Returns an error value.
*/
int get_normal_min(double *normal_min)
{
return ipmi_sensor_get_normal_min(self, normal_min);
}
/*
* Is the normal maximum for the sensor specified?
*/
int get_normal_max_specified()
{
return ipmi_sensor_get_normal_max_specified(self);
}
/*
* Get the normal maximum for the sensor into the first parameter.
* Returns an error value.
*/
int get_normal_max(double *normal_max)
{
return ipmi_sensor_get_normal_max(self, normal_max);
}
/*
* Returns if the nominal reading for the sensor is specified.
*/
int get_nominal_reading_specified()
{
return ipmi_sensor_get_nominal_reading_specified(self);
}
/*
* Get the nominal value for the sensor into the first parameter.
* Returns an error value.
*/
int get_nominal_reading(double *nominal_reading)
{
return ipmi_sensor_get_nominal_reading(self, nominal_reading);
}
/*
* Get the sensor maximum for the sensor into the first parameter.
* Returns an error value.
*/
int get_sensor_max(double *sensor_max)
{
return ipmi_sensor_get_sensor_max(self, sensor_max);
}
/*
* Get the sensor minimum for the sensor into the first parameter.
* Returns an error value.
*/
int get_sensor_min(double *sensor_min)
{
return ipmi_sensor_get_sensor_min(self, sensor_min);
}
/*
* Get the OEM value from the sensor's SDR.
*/
int get_oem1()
{
return ipmi_sensor_get_oem1(self);
}
%newobject get_sensor_id;
/*
* Get the ID string from the sensor's SDR.
*/
char *get_sensor_id()
{
/* FIXME - no unicode handling. */
int len = ipmi_sensor_get_id_length(self) + 1;
char *id = malloc(len);
ipmi_sensor_get_id(self, id, len);
return id;
}
/*
* Return the MC that owns the sensor.
*/
ipmi_mc_t *get_mc()
{
return ipmi_sensor_get_mc(self);
}
}
/*
* A control id object. This object is guaranteed to be valid and
* can be converted into a mc pointer later.
*/
%extend ipmi_control_id_t {
~ipmi_control_id_t()
{
free(self);
}
/* Compare self with other, return -1 if self<other, 0 if
self==other, or 1 if self>other. */
int cmp(ipmi_control_id_t *other)
{
return ipmi_cmp_control_id(*self, *other);
}
/*
* Convert a control id to a control pointer. The "control_cb" method
* will be called on the first parameter with the following parameters:
* <self> <control>
*/
int to_control(swig_cb *handler)
{
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, control_cb))
rv = EINVAL;
else
rv = ipmi_control_pointer_cb(*self, handle_control_cb,
get_swig_cb(handler, control_cb));
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
/*
* An control object
*/
%extend ipmi_control_t {
%newobject get_name;
/*
* Get the name of an control.
*/
char *get_name()
{
char name[IPMI_CONTROL_NAME_LEN];
ipmi_control_get_name(self, name, sizeof(name));
return strdup(name);
}
%newobject get_id;
/*
* Get the id for the control.
*/
ipmi_control_id_t *get_id()
{
ipmi_control_id_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_control_convert_to_id(self);
return rv;
}
/*
* Get the string type of control.
*/
const char *get_type_string()
{
return ipmi_control_get_type_string(self);
}
%constant int CONTROL_LIGHT = IPMI_CONTROL_LIGHT;
%constant int CONTROL_RELAY = IPMI_CONTROL_RELAY;
%constant int CONTROL_DISPLAY = IPMI_CONTROL_DISPLAY;
%constant int CONTROL_ALARM = IPMI_CONTROL_ALARM;
%constant int CONTROL_RESET = IPMI_CONTROL_RESET;
%constant int CONTROL_POWER = IPMI_CONTROL_POWER;
%constant int CONTROL_FAN_SPEED = IPMI_CONTROL_FAN_SPEED;
%constant int CONTROL_IDENTIFIER = IPMI_CONTROL_IDENTIFIER;
%constant int CONTROL_ONE_SHOT_RESET = IPMI_CONTROL_ONE_SHOT_RESET;
%constant int CONTROL_OUTPUT = IPMI_CONTROL_OUTPUT;
%constant int CONTROL_ONE_SHOT_OUTPUT = IPMI_CONTROL_ONE_SHOT_OUTPUT;
/*
* Get the numeric type of control.
*/
int get_type()
{
return ipmi_control_get_type(self);
}
/*
* Get the entity id for the control's entity.
*/
int get_entity_id()
{
return ipmi_control_get_entity_id(self);
}
/*
* Get the entity instance for the control's entity.
*/
int get_entity_instance()
{
return ipmi_control_get_entity_instance(self);
}
/*
* Get the entity for the control.
*/
ipmi_entity_t *get_entity()
{
return ipmi_control_get_entity(self);
}
/*
* Can the control's value be set?
*/
int is_settable()
{
return ipmi_control_is_settable(self);
}
/*
* Can the control's value be read?
*/
int is_readable()
{
return ipmi_control_is_readable(self);
}
/*
* Should the control be ignored if its entity is not present?
*/
int get_ignore_if_no_entity()
{
return ipmi_control_get_ignore_if_no_entity(self);
}
%newobject get_control_id;
/*
* Get the ID string from the control's SDR.
*/
char *get_control_id()
{
/* FIXME - no unicode handling. */
int len = ipmi_control_get_id_length(self) + 1;
char *id = malloc(len);
ipmi_control_get_id(self, id, len);
return id;
}
/*
* Returns true if the control can generate events upon change,
* and false if not.
*/
int has_events()
{
return ipmi_control_has_events(self);
}
/*
* Get the number of values the control supports.
*/
int get_num_vals()
{
return ipmi_control_get_num_vals(self);
}
/*
* Set the value of a control. Note that an control may support
* more than one element, the array reference passed in as the
* first parameter must match the number of elements the control
* supports. All the elements will be set simultaneously. The
* control_set_val_cb method on the second parameter (if it is
* supplied) will be called after the operation completes with.
* It will be called with the following parameters: <self>
* <control> <err>
*/
int set_val(intarray val, swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_control_op_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (val.len != ipmi_control_get_num_vals(self)) {
rv = EINVAL;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, control_set_val_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, control_set_val_cb);
done = control_val_set_handler;
}
rv = ipmi_control_set_val(self, val.val, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the setting of an control. The control_get_val_cb method
* on the first parameter will be called with the following
* parameters: <self> <control> <err> <val1> [<val2> ...]. The
* number of values passed to the handler will be the number of
* values the control supports.
*/
int get_val(swig_cb *handler)
{
swig_cb_val *handler_val = NULL;
ipmi_control_val_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, control_get_val_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, control_get_val_cb);
done = control_val_get_handler;
rv = ipmi_control_get_val(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Register a handler that will be called when the control changes
* value. Note that if the control does not support this
* operation, it will return ENOSYS. When a control event comes
* in, the control_event_val_cb method on the first parameter will
* be called with the following parameters: <self> <control>
* <valid1> [<valid2> ...] val1 [<val2> ...]. The valid fields
* tell if a particular value is corrected, the number of these
* is the same as what get_num_vals() returns for this control.
* the val fields are the actual values, the value is valid only
* if the valid field corresponding to it is true.
*/
int add_event_handler(swig_cb *handler)
{
ipmi_control_add_val_event_handler_cl
(self, control_val_event_handler_cl, NULL);
cb_add(control, val_event, control_event_val_cb);
}
/*
* Remove a control event handler.
*/
int remove_event_handler(swig_cb *handler)
{
cb_rm(control, val_event, control_event_val_cb);
}
%constant int CONTROL_COLOR_BLACK = IPMI_CONTROL_COLOR_BLACK;
%constant int CONTROL_COLOR_WHITE = IPMI_CONTROL_COLOR_WHITE;
%constant int CONTROL_COLOR_RED = IPMI_CONTROL_COLOR_RED;
%constant int CONTROL_COLOR_GREEN = IPMI_CONTROL_COLOR_GREEN;
%constant int CONTROL_COLOR_BLUE = IPMI_CONTROL_COLOR_BLUE;
%constant int CONTROL_COLOR_YELLOW = IPMI_CONTROL_COLOR_YELLOW;
%constant int CONTROL_COLOR_ORANGE = IPMI_CONTROL_COLOR_ORANGE;
%constant int CONTROL_NUM_COLORS = IPMI_CONTROL_COLOR_ORANGE+1;
/*
* This describes a setting for a light. There are two types of
* lights. One type has a general ability to be set to a color, on
* time, and off time. The other has a pre-defined set of
* transitions. For transition-based lights, each light is defined to
* go through a number of transitions. Each transition is described
* by a color, a time (in milliseconds) that the color is present.
* For non-blinking lights, there will only be one transition. For
* blinking lights, there will be one or more transitions.
*/
/*
* If this returns true, then you set the light with the
* set_light() function and get the values with the get_light()
* function. Otherwise you get/set it with the normal
* get_val/set_valfunctions and use the transitions functions to
* get what the LED can do.
*/
int light_set_with_setting()
{
return ipmi_control_light_set_with_setting(self);
}
/*
* Allows detecting if a setting light supports a specific
* color.
*/
int light_is_color_supported(int light_num, int color)
{
return ipmi_control_light_is_color_sup(self, light_num, color);
}
/*
* Returns true if the light has a local control mode, false if
* not.
*/
int light_has_local_control(int light_num)
{
return ipmi_control_light_has_loc_ctrl(self, light_num);
}
/*
* Set a setting style light's settings. The first parm is a
* string in the form:
* "[lc] <color> <on_time> <off time>[:[lc] <color>...]". The
* second parm turns on or off local control of the light. When
* the operation is complete the control_set_val_cb method on the
* second parameter (if it is supplied) will be called with the
* following parameters: <self> <control> <err>.
*/
int set_light(char *settings, swig_cb *handler = NULL)
{
ipmi_light_setting_t *s;
int rv;
swig_cb_val *handler_val = NULL;
ipmi_control_op_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
rv = str_to_light_setting(settings, &s);
if (rv)
goto out_err;
if (ipmi_light_setting_get_count(s)
!= ipmi_control_get_num_vals(self))
{
free(s);
rv = EINVAL;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, control_set_val_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, control_set_val_cb);
done = control_val_set_handler;
}
rv = ipmi_control_set_light(self, s, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
ipmi_free_light_settings(s);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the current values of the light. The control_get_light_cb
* method on the first parm will be called with the following
* parameters: <self> <control> <err> <light settings>
* The light settings is a string with each light separated by
* colons with the (optional) local control (lc), color, on, and
* off time like this:
* "[lc] <color> <on_time> <off time>[:[lc] <color>...]"
*/
int get_light(swig_cb *handler)
{
swig_cb_val *handler_val = NULL;
ipmi_light_settings_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, control_get_light_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, control_get_light_cb);
done = control_val_get_light_handler;
rv = ipmi_control_get_light(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* For lights that are transition based, this returns the number
* of values for a specific light. So if you put a 2 in the first
* parm, this will return the number of possible settings for the
* 3rd light.
*/
int get_num_light_values(int light)
{
return ipmi_control_get_num_light_values(self, light);
}
/*
* For lights that are transition based, return the number of
* transitions for the given light and value setting. So if you
* put a 1 and a 3, this returns the number of transitions that
* the second light will go through if you set it's value to 3.
* Each transition will have a color and duration time and can be
* fetched with other values. Returns -1 if the inputs are
* invalid.
*/
int get_num_light_transitions(int light, int value)
{
return ipmi_control_get_num_light_transitions(self, light, value);
}
/*
* For lights that are transition based, return the color of the
* given transition. Returns -1 if the inputs are invalid.
*/
int get_light_color(int light, int value, int transition)
{
return ipmi_control_get_light_color(self, light, value, transition);
}
/*
* For lights that are transition based, return the duration of
* the given transition. Returns -1 if the inputs are invalid.
*/
int get_light_color_time(int light, int value, int transition)
{
return ipmi_control_get_light_color_time(self, light, value,
transition);
}
/*
* Set the value of the identifier. The first parameter is a
* reference to an array of byte values to se the identifier to.
* When the setting is complete, the control_set_val_cb method on
* the second parameter (if it is supplied) will be called with
* the following parameters: <self> <control> <err>.
*/
int identifier_set_val(intarray val, swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_control_op_cb done = NULL;
int rv;
unsigned char *data;
int i;
IPMI_SWIG_C_CB_ENTRY
data = malloc(val.len);
if (!data) {
rv = ENOMEM;
goto out_err;
}
for (i=0; i<val.len; i++)
data[i] = val.val[i];
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, control_set_val_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, control_set_val_cb);
done = control_val_set_handler;
}
rv = ipmi_control_identifier_set_val(self, data, val.len,
done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
free(data);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the value of the identifier control. The control_get_id_cb
* method on the first parameter will be called when the operation
* completes. The values passed to that method will be:
* <self> <control> <err> byte1 [<byte2> ...].
* The id value is all the bytes after the error value.
*/
int identifier_get_val(swig_cb *handler)
{
swig_cb_val *handler_val = NULL;
ipmi_control_identifier_val_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (! valid_swig_cb(handler, control_get_id_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, control_get_id_cb);
done = control_val_get_id_handler;
rv = ipmi_control_identifier_get_val(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Return the maximum possible length of the identifier control's
* value.
*/
int identifier_get_max_length()
{
return ipmi_control_identifier_get_max_length(self);
}
}
/*
* Convert the FRU index to a string. Returns undefined if the
* index is out of range.
*/
%rename(fru_index_to_str) ipmi_fru_index_to_str;
extern char *ipmi_fru_index_to_str(int idx);
/*
* Convert a name to an index. Returns -1 if the name is not valid.
*/
%rename(fru_str_to_index) ipmi_fru_str_to_index;
extern int ipmi_fru_str_to_index(char *name);
/*
* A FRU object
*/
%extend ipmi_fru_t {
~ipmi_fru_t()
{
ipmi_fru_deref(self);
}
/* Area numbers */
%constant int FRU_INTERNAL_USE_AREA = IPMI_FRU_FTR_INTERNAL_USE_AREA;
%constant int FRU_CHASSIS_INFO_AREA = IPMI_FRU_FTR_CHASSIS_INFO_AREA;
%constant int FRU_BOARD_INFO_AREA = IPMI_FRU_FTR_BOARD_INFO_AREA;
%constant int FRU_PRODUCT_INFO_AREA = IPMI_FRU_FTR_PRODUCT_INFO_AREA;
%constant int FRU_MULTI_RECORD_AREA = IPMI_FRU_FTR_MULTI_RECORD_AREA;
%newobject get_domain_id;
/*
* Get the domain the FRU belongs to.
*/
ipmi_domain_id_t *get_domain_id()
{
ipmi_domain_id_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_fru_get_domain_id(self);
return rv;
}
/*
* Convert the string to a FRU index. Use this if you have a specfiic
* fru data object you are after. Returns -1 if the name is not valid.
*/
int str_to_index(char *name)
{
return ipmi_fru_str_to_index(name);
}
/*
* Get a FRU data item. The first parameter is an index to get,
* the second is an integer reference to an item number. This
* returns a string of the particular object with the following:
* "<name> <type> <data>". If the index or number are invalid,
* then an undefined value will be returned (NULL, undef, etc).
* If the FRU item is not supported for this FRU, only the name
* will be filled out and there will be no type or value.
*
* If the type is integer, a single integer number will follow.
* If the type is ascii, an ascii string will follow starting one
* space after the type. If the type is unicode or binary, then
* a set of ascii-encoded binary bytes will follow "0x01 0x03 ..."
*
* The second parameter (the number) is zero based and should be
* set to zero when fetching an index for the first time. It will
* be unchanged if the data item does not support multiple items.
* If it does support multiple items, then the number will be
* changed to the next supported value, or to -1 if this is the
* last item.
*/
%newobject get;
char *get(int index, int *num)
{
const char *name;
enum ipmi_fru_data_type_e dtype;
int intval;
time_t time;
char *data;
unsigned int data_len;
int rv;
char dummy[1];
char *str = NULL, *s;
int len;
int i;
data = NULL;
rv = ipmi_fru_get(self, index, &name, num, &dtype, &intval,
&time, &data, &data_len);
if ((rv == ENOSYS) || (rv == E2BIG))
return strdup(name);
else if (rv)
return NULL;
switch(dtype) {
case IPMI_FRU_DATA_INT:
len = snprintf(dummy, 1, "%s integer %d", name, intval);
str = malloc(len + 1);
sprintf(str, "%s integer %d", name, intval);
break;
case IPMI_FRU_DATA_TIME:
len = snprintf(dummy, 1, "%s time %ld", name, (long) time);
str = malloc(len + 1);
sprintf(str, "%s time %ld", name, (long) time);
break;
case IPMI_FRU_DATA_BINARY:
len = snprintf(dummy, 1, "%s binary", name);
len += data_len * 5;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s binary", name);
for (i=0; i<data_len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) data[i]);
break;
case IPMI_FRU_DATA_UNICODE:
len = snprintf(dummy, 1, "%s unicode", name);
len += data_len * 5;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s unicode", name);
for (i=0; i<data_len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) data[i]);
break;
case IPMI_FRU_DATA_ASCII:
len = snprintf(dummy, 1, "%s ascii %s", name, data);
str = malloc(len + 1);
sprintf(str, "%s ascii %s", name, data);
break;
default:
str = NULL;
}
if (data)
ipmi_fru_data_free(data);
return str;
}
/*
* Return the number of multi-records the FRU has.
*/
int get_num_multi_records()
{
return ipmi_fru_get_num_multi_records(self);
}
/*
* Fetch a multi record from the FRU. The data comes out in a
* string with the format:
* "<type num> <version num> [data1 [data2 ...]]"
* It returns an undefined value if the num is invalid. The data
* items will not be present if the length is zero.
*/
%newobject get_multirecord;
char *get_multirecord(int num)
{
unsigned char type;
unsigned char version;
unsigned int length;
unsigned char *data;
int rv;
char dummy[1];
char *str, *s;
int str_len;
int i;
rv = ipmi_fru_get_multi_record_type(self, num, &type);
if (rv)
return NULL;
rv = ipmi_fru_get_multi_record_format_version(self, num, &version);
if (rv)
return NULL;
rv = ipmi_fru_get_multi_record_data_len(self, num, &length);
if (rv)
return NULL;
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data)
return NULL;
rv = ipmi_fru_get_multi_record_data(self, num, data, &length);
if (rv) {
free(data);
return NULL;
}
str_len = snprintf(dummy, 1, "%d %d", type, version);
str_len += length * 5;
str = malloc(str_len + 1);
if (!str) {
free(data);
return NULL;
}
s = str;
s += sprintf(s, "%d %d", type, version);
for (i=0; i<length; i++)
s += sprintf(s, " 0x%2.2x", data[i]);
free(data);
return str;
}
/*
* Set a specific data item by index (see the get function for more
* info on what index and num mean). Note that the "num "field is
* not updated by this call, unlike the get function.
*
* The type passed in tells the kind of data being passed in. It is
* either:
* "integer" - An integer value passed in.
* "time" - An integer value passed in.
* "binary" - A string of 8-bit values is passed in, like
* "0x10 0x20 0x99".
* "unicode" - A string of 8-bit values is passed in, like
* "0x10 0x20 0x99".
* "ascii" - The string passed in is used.
* Passing an undefined value for binary, unicode, and ascii
* will result in the field being cleared or (for custom fields)
* deleted. NULL values are not allowed for integer or time.
*/
int set(int index, int num, char *type, char *value = NULL)
{
if (!type)
return EINVAL;
if (strcmp(type, "integer") == 0) {
unsigned int val;
char *endstr;
if (!value)
return EINVAL;
if (*value == '\0')
return EINVAL;
val = strtol(value, &endstr, 0);
if (*endstr != '\0')
return EINVAL;
return ipmi_fru_set_int_val(self, index, num, val);
} else if (strcmp(type, "time") == 0) {
unsigned int val;
char *endstr;
if (!value)
return EINVAL;
if (*value == '\0')
return EINVAL;
val = strtol(value, &endstr, 0);
if (*endstr != '\0')
return EINVAL;
return ipmi_fru_set_time_val(self, index, num, val);
} else if (strcmp(type, "binary") == 0) {
unsigned int length = 0;
unsigned char *data;
int rv;
if (!value) {
data = NULL;
} else {
data = parse_raw_str_data(value, &length);
if (!data)
return ENOMEM;
}
rv = ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_BINARY,
(char *) data, length);
if (data)
free(data);
return rv;
} else if (strcmp(type, "unicode") == 0) {
unsigned int length = 0;
unsigned char *data;
int rv;
if (!value) {
data = NULL;
} else {
data = parse_raw_str_data(value, &length);
if (!data)
return ENOMEM;
}
rv = ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_UNICODE,
(char *) data, length);
if (data)
free(data);
return rv;
} else if (strcmp(type, "ascii") == 0) {
int length = 0;
if (value)
length = strlen(value);
return ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_ASCII,
value, length);
} else {
return EINVAL;
}
}
/*
* Set a specific data item by index (see the get function for more
* info on what index and num mean). Note that the "num" field is
* not updated by this call, unlike the get function.
*
* The type passed in tells the kind of data being passed in. It is
* either:
* "integer" - The first element of the integer array is used.
* "time" - The first element of the integer array is used.
* "binary" - An array of 8-bit values is taken, like
* [ 0x10, 0x20, 0x99 ].
* "unicode" - An array of 8-bit values is passed in, like
* [ 0x10, 0x20, 0x99 ].
* "ascii" - An array of 8-bit values is passed in, like
* [ 0x10, 0x20, 0x99 ].
* Undefined values are not allowed here, but that shouldn't
* matter because the above function should be used for those.
*/
int set_array(int index, int num, char *type, intarray value)
{
if (value.len < 0)
return EINVAL;
if (!type)
return EINVAL;
if (strcmp(type, "integer") == 0) {
/* Only take the first value. */
if (value.len <= 0)
return EINVAL;
return ipmi_fru_set_int_val(self, index, num, value.val[0]);
} else if (strcmp(type, "time") == 0) {
/* Only take the first value. */
if (value.len <= 0)
return EINVAL;
return ipmi_fru_set_time_val(self, index, num, value.val[0]);
} else if (strcmp(type, "binary") == 0) {
unsigned int length = value.len;
unsigned char *data;
int rv;
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data)
return ENOMEM;
parse_ipmi_data(value, data, length, &length);
rv = ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_BINARY,
(char *) data, length);
free(data);
return rv;
} else if (strcmp(type, "unicode") == 0) {
unsigned int length = value.len;
unsigned char *data = malloc(length);
int rv;
if (!data)
return EINVAL;
parse_ipmi_data(value, data, length, &length);
rv = ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_UNICODE,
(char *) data, length);
free(data);
return rv;
} else if (strcmp(type, "ascii") == 0) {
unsigned int length = value.len;
unsigned char *data;
int rv;
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data)
return ENOMEM;
parse_ipmi_data(value, data, length, &length);
rv = ipmi_fru_set_data_val(self, index, num, IPMI_FRU_DATA_ASCII,
(char *) data, length);
free(data);
return rv;
} else {
return EINVAL;
}
}
/*
* Set multi-record fields from a string of the form:
* "0x10 0x20 0x99"
*
* It take a number (which multi-record), type, version, and a
* string value. Passing in an undefined value will delete the
* specific multi-record. Note that if the number is less than
* the number of fields in the record, then the record will be
* replaced. If it is larger than or equal to the number of
* fields, a new record will be appended in the next location, not
* in the number supplied.
*/
int set_multirecord(unsigned int num,
unsigned int type,
unsigned int version,
char *value = NULL)
{
unsigned int length = 0;
unsigned char *data;
int rv;
if (!value) {
data = NULL;
} else {
data = parse_raw_str_data(value, &length);
if (!data)
return ENOMEM;
}
rv = ipmi_fru_set_multi_record(self, num, type, version,
data, length);
if (data)
free(data);
return rv;
}
/*
* Set multi-record fields from a string of the form:
* "0x10 0x20 0x99"
*
* It take a number (which multi-record), type, version, and an
* integer array. Undefined values are not allowed here, use
* the previous call to delete records. Note that if the number
* is less than the number of fields in the record, then the
* record will be replaced. If it is larger than or equal to the
* number of fields, a new record will be appended in the next
* location, not in the number supplied.
*/
int set_multirecord_array(unsigned int num,
unsigned int type,
unsigned int version,
intarray value)
{
unsigned int length = value.len;
unsigned char *data;
int rv;
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data)
return ENOMEM;
parse_ipmi_data(value, data, length, &length);
rv = ipmi_fru_set_multi_record(self, num, type, version,
data, length);
free(data);
return rv;
}
/*
* Add a new area to the FRU. You must pass in the area number, the
* start offset and length of the area. The offset must be a multiple
* of 8 and the length will be truncated to a multiple of 8.
*/
int add_area(unsigned int area,
unsigned int offset,
unsigned int length)
{
return ipmi_fru_add_area(self, area, offset, length);
}
/*
* Delete the given area from the FRU.
*/
int delete_area(int area)
{
return ipmi_fru_delete_area(self, area);
}
/*
* Get the offset of the given area into the offset pointer.
*/
int area_get_offset(unsigned int area,
unsigned int *offset)
{
return ipmi_fru_area_get_offset(self, area, offset);
}
/*
* Get the length of the given area into the length pointer.
*/
int area_get_length(unsigned int area,
unsigned int *length)
{
return ipmi_fru_area_get_length(self, area, length);
}
/*
* Set the offset of the given area.
*/
int area_set_offset(unsigned int area,
unsigned int offset)
{
return ipmi_fru_area_set_offset(self, area, offset);
}
/*
* Set the length of the given area.
*/
int area_set_length(unsigned int area,
unsigned int length)
{
return ipmi_fru_area_set_length(self, area, length);
}
/*
* Get the number of bytes currently used in the given area into
* the used_length pointer.
*/
int area_get_used_length(unsigned int area,
unsigned int *used_length)
{
return ipmi_fru_area_get_used_length(self, area, used_length);
}
/*
* Write the contents of the fru back into the FRU device. If the
* handler (first parm) is non-null, the "fru_written" method on
* that object will be called with the domain as the first
* parameter, the FRU as the second parameter and the error value
* for the write as the third parameter.
*/
int write(swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_fru_cb cb_handler = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, fru_written)) {
rv = EINVAL;
goto out_err;
}
cb_handler = fru_written_done;
handler_val = ref_swig_cb(handler, fru_written);
ipmi_fru_ref(self);
}
rv = ipmi_fru_write(self, cb_handler, handler_val);
if (rv) {
if (handler_val)
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
int multi_record_get_root_node(unsigned int record_num,
const char **name,
ipmi_fru_node_t **sub_node)
{
int rv;
rv = ipmi_fru_multi_record_get_root_node(self, record_num,
name, sub_node);
return rv;
}
int get_root_node(const char **type, ipmi_fru_node_t **sub_node)
{
return ipmi_fru_get_root_node(self, type, sub_node);
}
}
/*
* A FRU node object
*/
%extend ipmi_fru_node_t {
~ipmi_fru_node_t()
{
ipmi_fru_put_node(self);
}
int get_field(unsigned int index,
const char **name,
const char **type,
char **value,
ipmi_fru_node_t **sub_node)
{
int rv;
enum ipmi_fru_data_type_e dtype;
int intval;
double floatval;
time_t time;
char *data = NULL;
unsigned int data_len;
int len;
char dummy[1];
char *str, *s;
int i;
rv = ipmi_fru_node_get_field(self,
index,
name,
&dtype,
&intval,
&time,
&floatval,
&data,
&data_len,
sub_node);
if (rv)
return rv;
switch(dtype) {
case IPMI_FRU_DATA_INT:
len = snprintf(dummy, 1, "%d", intval);
str = malloc(len + 1);
sprintf(str, "%d", intval);
*type = "integer";
break;
case IPMI_FRU_DATA_BOOLEAN:
len = snprintf(dummy, 1, "%d", intval);
str = malloc(len + 1);
sprintf(str, "%d", intval);
*type = "boolean";
break;
case IPMI_FRU_DATA_TIME:
len = snprintf(dummy, 1, "%ld", (long) time);
str = malloc(len + 1);
sprintf(str, "%ld", (long) time);
*type = "time";
break;
case IPMI_FRU_DATA_FLOAT:
len = snprintf(dummy, 1, "%lf", floatval);
str = malloc(len + 1);
sprintf(str, "%lf", floatval);
*type = "float";
break;
case IPMI_FRU_DATA_BINARY:
len = data_len * 5;
str = malloc(len + 1);
s = str;
if (data_len > 0)
s += sprintf(s, "0x%2.2x", (unsigned char) data[0]);
else
*s = '\0';
for (i=1; i<data_len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) data[i]);
*type = "binary";
break;
case IPMI_FRU_DATA_UNICODE:
len = data_len * 5;
str = malloc(len + 1);
s = str;
if (data_len > 0)
s += sprintf(s, "0x%2.2x", (unsigned char) data[0]);
else
*s = '\0';
for (i=1; i<data_len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) data[i]);
*type = "unicode";
break;
case IPMI_FRU_DATA_ASCII:
str = strdup(data);
*type = "ascii";
break;
case IPMI_FRU_DATA_SUB_NODE:
str = NULL;
*type = "subnode";
/* Put the array length (or the -1) in the value */
len = snprintf(dummy, 1, "%d", intval);
str = malloc(len + 1);
sprintf(str, "%d", intval);
break;
default:
str = NULL;
}
if (data)
ipmi_fru_data_free(data);
*value = str;
return 0;
}
int get_enum_val(unsigned int index,
int *pos,
int *nextpos,
const char **data)
{
return ipmi_fru_node_get_enum_val(self, index, pos, nextpos, data);
}
int set_field(unsigned int index,
const char *type,
char *value)
{
int rv;
enum ipmi_fru_data_type_e dtype;
int intval = 0;
double floatval = 0.0;
time_t time = 0;
char *data = NULL;
unsigned int data_len = 0;
char *s;
if (!type)
return EINVAL;
if (strcmp(type, "subnode") == 0) {
dtype = IPMI_FRU_DATA_SUB_NODE;
if (value) {
data = (char *) parse_raw_str_data(value, &data_len);
if (!data)
return ENOMEM;
}
goto ready_to_set;
} else if (strcmp(type, "binary") == 0) {
dtype = IPMI_FRU_DATA_BINARY;
if (value) {
data = (char *) parse_raw_str_data(value, &data_len);
if (!data)
return ENOMEM;
}
goto ready_to_set;
} else if (strcmp(type, "unicode") == 0) {
dtype = IPMI_FRU_DATA_UNICODE;
if (value) {
data = (char *) parse_raw_str_data(value, &data_len);
if (!data)
return ENOMEM;
}
goto ready_to_set;
} else if (strcmp(type, "ascii") == 0) {
dtype = IPMI_FRU_DATA_ASCII;
if (value) {
data = strdup(value);
if (!data)
return ENOMEM;
data_len = strlen(value);
}
goto ready_to_set;
}
if (!value || !(*value))
return EINVAL;
if (strcmp(type, "integer") == 0) {
dtype = IPMI_FRU_DATA_INT;
intval = strtol(value, &s, 0);
if (*s != '\0')
return EINVAL;
} else if (strcmp(type, "boolean") == 0) {
dtype = IPMI_FRU_DATA_BOOLEAN;
intval = strtol(value, &s, 0);
if (*s == '\0')
intval = !!intval;
else if (strcasecmp(value, "true") == 0)
intval = 1;
else if (strcasecmp(value, "false") == 0)
intval = 0;
else
return EINVAL;
} else if (strcmp(type, "time") == 0) {
dtype = IPMI_FRU_DATA_TIME;
time = strtol(value, &s, 0);
if (*s != '\0')
return EINVAL;
} else if (strcmp(type, "float") == 0) {
dtype = IPMI_FRU_DATA_FLOAT;
floatval = strtod(value, &s);
if (*s != '\0')
return EINVAL;
} else
return EINVAL;
ready_to_set:
rv = ipmi_fru_node_set_field(self, index, dtype, intval, time,
floatval, data, data_len);
if (data)
free(data);
return rv;
}
int settable(unsigned int index)
{
return ipmi_fru_node_settable(self, index);
}
char *get_subtype()
{
enum ipmi_fru_data_type_e dtype;
char *type;
int rv;
rv = ipmi_fru_node_get_subtype(self, &dtype);
if (rv)
return NULL;
switch (dtype) {
case IPMI_FRU_DATA_INT:
type = "integer";
break;
case IPMI_FRU_DATA_BOOLEAN:
type = "boolean";
break;
case IPMI_FRU_DATA_TIME:
type = "time";
break;
case IPMI_FRU_DATA_FLOAT:
type = "float";
break;
case IPMI_FRU_DATA_BINARY:
type = "binary";
break;
case IPMI_FRU_DATA_UNICODE:
type = "unicode";
break;
case IPMI_FRU_DATA_ASCII:
type = "ascii";
break;
case IPMI_FRU_DATA_SUB_NODE:
type = "subnode";
break;
default:
return NULL;
}
return type;
}
}
/*
* An event object
*/
%extend ipmi_event_t {
~ipmi_event_t()
{
ipmi_event_free(self);
}
/* When you are done with an event, you should delete it. This
removes the event from the local event queue and removes it
from the external system event log. */
int delete(swig_cb *handler = NULL)
{
swig_cb_val *handler_val = NULL;
ipmi_domain_cb done = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, event_delete_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, event_delete_cb);
done = event_deleted_handler;
}
rv = ipmi_event_delete(self, done, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%newobject get_mc_id;
/*
* Get the MC id the event came from. Note that the MC may not exist
* any more.
*/
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_event_get_mcid(self);
return rv;
}
/*
* Get the event's record id
*/
int get_record_id()
{
return ipmi_event_get_record_id(self);
}
/*
* Get the event's type.
*/
int get_type()
{
return ipmi_event_get_type(self);
}
/*
* Get the event's timestamp. This is in seconds.
*/
double get_timestamp()
{
return ((double) ipmi_event_get_timestamp(self)) / 1000000000.0;
}
/*
* Get the data from the event. This returns a reference to an
* array, so you have to reference it like @$val.
*/
intarray get_data()
{
intarray rv;
int i;
unsigned char *data;
int data_len;
data_len = ipmi_event_get_data_len(self);
data = malloc(data_len);
data_len = ipmi_event_get_data(self, data, 0, data_len);
rv.val = malloc(sizeof(int) * data_len);
for (i=0; i<data_len; i++)
rv.val[i] = data[i];
free(data);
rv.len = data_len;
return rv;
}
/* Call the sensor callback for the event. If the sensor is a
* threshold sensor, the threshold_event_cb method will be called
* on the sensor. Otherwise, the sensor is discrete and the
* discrete_event_cb will be called. The threshold_event_cb
* method takes the following parameters:
* <self> <sensor> <event spec> <raw_set> <raw> <value_set> <value> <event>
* The discrete_event_cb method takes the following parameters:
* <self> <sensor> <event spec> <severity> <old_severity> <event>
*
* Note: In the future, this may take control callbacks, too.
*/
int call_handler(swig_cb *handler)
{
event_call_handler_data_t info;
int rv;
if (! valid_swig_2cb(handler, threshold_event_cb, discrete_event_cb))
return EINVAL;
info.handlers = ipmi_event_handlers_alloc();
if (! info.handlers)
return ENOMEM;
ipmi_event_handlers_set_threshold(info.handlers,
sensor_threshold_event_handler);
ipmi_event_handlers_set_discrete(info.handlers,
sensor_discrete_event_handler);
info.handlers_val = ref_swig_2cb(handler, threshold_event_cb,
discrete_event_cb);
info.event = self;
info.rv = 0;
rv = ipmi_mc_pointer_cb(ipmi_event_get_mcid(self),
event_call_handler_mc_cb,
&info);
if (rv == 0)
rv = info.rv;
ipmi_event_handlers_free(info.handlers);
deref_swig_cb_val(handler);
return rv;
}
}
%extend ipmi_lanparm_t {
~ipmi_lanparm_t()
{
ipmi_lanparm_deref(self);
}
%newobject get_mc_id;
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_lanparm_get_mc_id(self);
return rv;
}
int get_channel()
{
return ipmi_lanparm_get_channel(self);
}
%constant int LANPARM_SET_IN_PROGRESS = IPMI_LANPARM_SET_IN_PROGRESS;
%constant int LANPARM_AUTH_TYPE_SUPPORT = IPMI_LANPARM_AUTH_TYPE_SUPPORT;
%constant int LANPARM_AUTH_TYPE_ENABLES = IPMI_LANPARM_AUTH_TYPE_ENABLES;
%constant int LANPARM_IP_ADDRESS = IPMI_LANPARM_IP_ADDRESS;
%constant int LANPARM_IP_ADDRESS_SRC = IPMI_LANPARM_IP_ADDRESS_SRC;
%constant int LANPARM_MAC_ADDRESS = IPMI_LANPARM_MAC_ADDRESS;
%constant int LANPARM_SUBNET_MASK = IPMI_LANPARM_SUBNET_MASK;
%constant int LANPARM_IPV4_HDR_PARMS = IPMI_LANPARM_IPV4_HDR_PARMS;
%constant int LANPARM_PRIMARY_RMCP_PORT = IPMI_LANPARM_PRIMARY_RMCP_PORT;
%constant int LANPARM_SECONDARY_RMCP_PORT = IPMI_LANPARM_SECONDARY_RMCP_PORT;
%constant int LANPARM_BMC_GENERATED_ARP_CNTL = IPMI_LANPARM_BMC_GENERATED_ARP_CNTL;
%constant int LANPARM_GRATUIDOUS_ARP_INTERVAL = IPMI_LANPARM_GRATUIDOUS_ARP_INTERVAL;
%constant int LANPARM_DEFAULT_GATEWAY_ADDR = IPMI_LANPARM_DEFAULT_GATEWAY_ADDR;
%constant int LANPARM_DEFAULT_GATEWAY_MAC_ADDR = IPMI_LANPARM_DEFAULT_GATEWAY_MAC_ADDR;
%constant int LANPARM_BACKUP_GATEWAY_ADDR = IPMI_LANPARM_BACKUP_GATEWAY_ADDR;
%constant int LANPARM_BACKUP_GATEWAY_MAC_ADDR = IPMI_LANPARM_BACKUP_GATEWAY_MAC_ADDR;
%constant int LANPARM_COMMUNITY_STRING = IPMI_LANPARM_COMMUNITY_STRING;
%constant int LANPARM_NUM_DESTINATIONS = IPMI_LANPARM_NUM_DESTINATIONS;
%constant int LANPARM_DEST_TYPE = IPMI_LANPARM_DEST_TYPE;
%constant int LANPARM_DEST_ADDR = IPMI_LANPARM_DEST_ADDR;
%constant int LANPARM_VLAN_ID = IPMI_LANPARM_VLAN_ID;
%constant int LANPARM_VLAN_PRIORITY = IPMI_LANPARM_VLAN_PRIORITY;
%constant int LANPARM_NUM_CIPHER_SUITE_ENTRIES = IPMI_LANPARM_NUM_CIPHER_SUITE_ENTRIES;
%constant int LANPARM_CIPHER_SUITE_ENTRY_SUPPORT = IPMI_LANPARM_CIPHER_SUITE_ENTRY_SUPPORT;
%constant int LANPARM_CIPHER_SUITE_ENTRY_PRIV = IPMI_LANPARM_CIPHER_SUITE_ENTRY_PRIV;
%constant int LANPARM_DEST_VLAN_TAG = IPMI_LANPARM_DEST_VLAN_TAG;
/*
* Fetch an individual parm from the MC. The parameter (parm1) ,
* and set (parm2) and block (parm3) are specified, along with a
* handler (parm4). The lanparm_got_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <lanparm> <err> <parm_rev> <data1> [<data2> ...]
*/
int get_parm(int parm, int set, int block, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, lanparm_got_parm_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, lanparm_got_parm_cb);
ipmi_lanparm_ref(self);
rv = ipmi_lanparm_get_parm(self, parm, set, block,
lanparm_get_parm, handler_val);
if (rv) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1),
* and string value (parm2) is specified, along with an optional
* handler (parm3). The lanparm_set_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <lanparm> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm(int parm, char *value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length;
IPMI_SWIG_C_CB_ENTRY
data = parse_raw_str_data(value, &length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, lanparm_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, lanparm_set_parm_cb);
}
if (handler_val)
ipmi_lanparm_ref(self);
rv = ipmi_lanparm_set_parm(self, parm, data, length,
lanparm_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1), and
* an array of integers (parm2) is specified, along with an
* optional handler (parm3). The lanparm_set_parm_cb method on
* the handler will be called when the the operation completes
* with the following parms: <self> <lanparm> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm_array(int parm, intarray value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length = value.len;
IPMI_SWIG_C_CB_ENTRY
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
parse_ipmi_data(value, data, length, &length);
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, lanparm_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, lanparm_set_parm_cb);
}
if (handler_val)
ipmi_lanparm_ref(self);
rv = ipmi_lanparm_set_parm(self, parm, data, length,
lanparm_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the full standard configuration for the lanparms. When
* done, the lanparm_got_config_cb method will be called on the
* handler (first parm) with the following parms: <self> <lanparm>
* <err> <lanconfig>. The lanconfig will be an object of type
* ipmi_lan_config_t.
*/
int get_config(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, lanparm_got_config_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, lanparm_got_config_cb);
ipmi_lanparm_ref(self);
rv = ipmi_lan_get_config(self, lanparm_get_config, handler_val);
if (rv) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the full standard configuration for the lanparms. The
* config to set is the first parm of type ipmi_lan_config_t. When
* done, the lanparm_set_config_cb method will be called on the
* handler (second parm) with the following parms: <self>
* <lanparm> <err>.
*/
int set_config(ipmi_lan_config_t *config, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, lanparm_set_config_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, lanparm_set_config_cb);
}
if (handler_val)
ipmi_lanparm_ref(self);
rv = ipmi_lan_set_config(self, config,
lanparm_set_config, handler_val);
if (rv && handler_val) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Unlock the lock for the lanparm. The config to set is the
* first parm of type ipmi_lan_config_t and may be undefined
* (meaning that the MC of the lanparm will be unlocked). If the
* config is supplied, it will be marked as unlocked. When done,
* the lanparm_clear_lock_cb method will be called on the handler
* (second parm) with the following parms: <self> <lanparm> <err>.
*/
int clear_lock(ipmi_lan_config_t *config = NULL, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, lanparm_clear_lock_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, lanparm_clear_lock_cb);
}
if (handler_val)
ipmi_lanparm_ref(self);
rv = ipmi_lan_clear_lock(self, config,
lanparm_clear_lock, handler_val);
if (rv && handler_val) {
ipmi_lanparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
%extend ipmi_lan_config_t {
~ipmi_lan_config_t()
{
ipmi_lan_free_config(self);
}
/*
* Get a value from the lanconfig. The first parameter is the
* parm number, the second is the parm index (which is a pointer
* to an integer). The returned value will be undefined if
* an error occurred, it will be of the format:
* "<name> <type> <data>"
* The type and data will not be present if the data value is not
* supported or the index is out of range, but the name will still
* be present.
*
* The supports types are: integer, bool, data, ip, and mac. The
* data for an integer is a number. The data for a bool is true
* or false. The data for ip is an IP address in the form
* "n.n.n.n". Data for mac is a mac address in the form
* "nn:nn:nn:nn:nn:nn"
*
* The second parameter (the index) is zero based and should be
* set to zero when fetching an index for the first time. It will
* be unchanged if the data item does not support multiple items.
* If it does support multiple items, then the number will be
* changed to the next supported value, or to -1 if this is the
* last item.
*
* Be careful with the index, it must be a number, not something
* that can be interpreted to a number. If necessary, in perl,
* you must do $idx = int($idx) in some cases.
*/
%newobject get_val;
char *get_val(int parm, int *index)
{
enum ipmi_lanconf_val_type_e valtype;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
const char *name;
char dummy[1];
char *str = NULL, *s;
int rv;
int i;
unsigned int len;
rv = ipmi_lanconfig_get_val(self, parm, &name, index, &valtype,
&ival, &dval, &dval_len);
if ((rv == ENOSYS) || (rv == E2BIG))
return strdup(name);
else if (rv)
return NULL;
switch (valtype) {
case IPMI_LANCONFIG_INT:
len = snprintf(dummy, 1, "%s integer %d", name, ival);
str = malloc(len + 1);
sprintf(str, "%s integer %d", name, ival);
break;
case IPMI_LANCONFIG_BOOL:
len = snprintf(dummy, 1, "%s bool %s", name,
ival ? "true" : "false");
str = malloc(len + 1);
sprintf(str, "%s bool %s", name,
ival ? "true" : "false");
break;
case IPMI_LANCONFIG_DATA:
len = snprintf(dummy, 1, "%s data", name);
len += dval_len * 5;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s data", name);
for (i=0; i<dval_len; i++)
s += sprintf(s, " 0x%2.2x", dval[i]);
break;
case IPMI_LANCONFIG_IP:
len = snprintf(dummy, 1, "%s ip", name);
len += 4 * 4; /* worst case */
str = malloc(len + 1);
sprintf(str, "%s ip %d.%d.%d.%d", name,
dval[0], dval[1], dval[2], dval[3]);
break;
case IPMI_LANCONFIG_MAC:
len = snprintf(dummy, 1, "%s mac", name);
len += 6 * 3;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s mac ", name);
for (i=0; i<5; i++)
s += sprintf(s, "%2.2x:", dval[i]);
sprintf(s, "%2.2x", dval[i]);
break;
}
if (dval)
ipmi_lanconfig_data_free(dval);
return str;
}
/*
* Set a value in the lanconfig. The first parameter is the parm
* number, the second is the parm index. The type is a string
* in the third parm. The data is the fourth parm.
*
* The supports types are: integer, bool, data, ip, and mac. The
* data for an integer is a number. The data for a bool is true
* or false. The data for ip is an IP address in the form
* "n.n.n.n". Data for mac is a mac address in the form
* "nn.nn.nn.nn.nn.nn"
*
* The index is ignored for types that do not use it.
*/
int set_val(int parm, int idx, char *type, char *value) {
enum ipmi_lanconf_val_type_e valtype;
int rv;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
rv = ipmi_lanconfig_parm_to_type(parm, &valtype);
if (rv)
return rv;
switch (valtype) {
case IPMI_LANCONFIG_INT:
{
char *endstr;
if (strcmp(type, "integer") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (*value == '\0')
return EINVAL;
ival = strtol(value, &endstr, 0);
if (*endstr != '\0')
return EINVAL;
break;
}
case IPMI_LANCONFIG_BOOL:
if (strcmp(type, "bool") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (strcasecmp(value, "true") == 0)
ival = 1;
else if (strcasecmp(value, "false") == 0)
ival = 0;
else if (strcasecmp(value, "on") == 0)
ival = 1;
else if (strcasecmp(value, "off") == 0)
ival = 0;
else
return EINVAL;
break;
case IPMI_LANCONFIG_DATA:
if (strcmp(type, "data") != 0)
return EINVAL;
if (!value)
return EINVAL;
dval = parse_raw_str_data(value, &dval_len);
if (!dval)
return ENOMEM;
break;
case IPMI_LANCONFIG_IP:
{
struct in_addr addr;
if (strcmp(type, "ip") != 0)
return EINVAL;
rv = parse_ip_addr(value, &addr);
if (rv)
return rv;
dval = malloc(4);
memcpy(dval, &addr.s_addr, 4);
dval_len = 4;
}
break;
case IPMI_LANCONFIG_MAC:
if (strcmp(type, "mac") != 0)
return EINVAL;
dval = malloc(6);
rv = parse_mac_addr(value, dval);
if (rv) {
free(dval);
return rv;
}
dval_len = 6;
break;
}
rv = ipmi_lanconfig_set_val(self, parm, idx, ival, dval, dval_len);
if (dval)
free(dval);
return rv;
}
}
%extend ipmi_pef_t {
~ipmi_pef_t()
{
ipmi_pef_deref(self);
}
%newobject get_mc_id;
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_pef_get_mc(self);
return rv;
}
%constant int PEFPARM_SET_IN_PROGRESS = IPMI_PEFPARM_SET_IN_PROGRESS;
%constant int PEFPARM_CONTROL = IPMI_PEFPARM_CONTROL;
%constant int PEFPARM_ACTION_GLOBAL_CONTROL = IPMI_PEFPARM_ACTION_GLOBAL_CONTROL;
%constant int PEFPARM_STARTUP_DELAY = IPMI_PEFPARM_STARTUP_DELAY;
%constant int PEFPARM_ALERT_STARTUP_DELAY = IPMI_PEFPARM_ALERT_STARTUP_DELAY;
%constant int PEFPARM_NUM_EVENT_FILTERS = IPMI_PEFPARM_NUM_EVENT_FILTERS;
%constant int PEFPARM_EVENT_FILTER_TABLE = IPMI_PEFPARM_EVENT_FILTER_TABLE;
%constant int PEFPARM_EVENT_FILTER_TABLE_DATA1 = IPMI_PEFPARM_EVENT_FILTER_TABLE_DATA1;
%constant int PEFPARM_NUM_ALERT_POLICIES = IPMI_PEFPARM_NUM_ALERT_POLICIES;
%constant int PEFPARM_ALERT_POLICY_TABLE = IPMI_PEFPARM_ALERT_POLICY_TABLE;
%constant int PEFPARM_SYSTEM_GUID = IPMI_PEFPARM_SYSTEM_GUID;
%constant int PEFPARM_NUM_ALERT_STRINGS = IPMI_PEFPARM_NUM_ALERT_STRINGS;
%constant int PEFPARM_ALERT_STRING_KEY = IPMI_PEFPARM_ALERT_STRING_KEY;
%constant int PEFPARM_ALERT_STRING = IPMI_PEFPARM_ALERT_STRING;
/*
* Fetch an individual parm from the MC. The parameter (parm1) ,
* and set (parm2) and block (parm3) are specified, along with a
* handler (parm4). The pef_got_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <pef> <err> <parm_rev> <data1> [<data2> ...]
*/
int get_parm(int parm, int set, int block, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, pef_got_parm_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, pef_got_parm_cb);
ipmi_pef_ref(self);
rv = ipmi_pef_get_parm(self, parm, set, block, pef_get_parm,
handler_val);
if (rv) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1),
* and string value (parm2) is specified, along with an optional
* handler (parm3). The pef_set_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <pef> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm(int parm, char *value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length;
IPMI_SWIG_C_CB_ENTRY
data = parse_raw_str_data(value, &length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, pef_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, pef_set_parm_cb);
}
if (handler_val)
ipmi_pef_ref(self);
rv = ipmi_pef_set_parm(self, parm, data, length,
pef_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1), and
* an array of integers (parm2) is specified, along with an
* optional handler (parm3). The pef_set_parm_cb method on
* the handler will be called when the the operation completes
* with the following parms: <self> <pef> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm_array(int parm, intarray value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length = value.len;
IPMI_SWIG_C_CB_ENTRY
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
parse_ipmi_data(value, data, length, &length);
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, pef_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, pef_set_parm_cb);
}
if (handler_val)
ipmi_pef_ref(self);
rv = ipmi_pef_set_parm(self, parm, data, length,
pef_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the full standard configuration for the pefs. When
* done, the pef_got_config_cb method will be called on the
* handler (first parm) with the following parms: <self> <pef>
* <err> <pefconfig>. The pefconfig will be an object of type
* ipmi_pef_config_t.
*/
int get_config(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, pef_got_config_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, pef_got_config_cb);
ipmi_pef_ref(self);
rv = ipmi_pef_get_config(self, pef_get_config, handler_val);
if (rv) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the full standard configuration for the pefs. The
* config to set is the first parm of type ipmi_pef_config_t. When
* done, the pef_set_config_cb method will be called on the
* handler (second parm) with the following parms: <self>
* <pef> <err>.
*/
int set_config(ipmi_pef_config_t *config, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
ipmi_pef_done_cb done = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, pef_set_config_cb)) {
rv = EINVAL;
goto out_err;
}
done = pef_set_config;
handler_val = ref_swig_cb(handler, pef_set_config_cb);
}
if (handler_val)
ipmi_pef_ref(self);
rv = ipmi_pef_set_config(self, config, done, handler_val);
if (rv && handler_val) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Unlock the lock for the pef. The config to set is the
* first parm of type ipmi_pef_config_t and may be undefined
* (meaning that the MC of the pef will be unlocked). If the
* config is supplied, it will be marked as unlocked. When done,
* the pef_clear_lock_cb method will be called on the handler
* (second parm) with the following parms: <self> <pef> <err>.
*/
int clear_lock(ipmi_pef_config_t *config = NULL, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, pef_clear_lock_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, pef_clear_lock_cb);
}
if (handler_val)
ipmi_pef_ref(self);
rv = ipmi_pef_clear_lock(self, config, pef_clear_lock, handler_val);
if (rv && handler_val) {
ipmi_pef_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
%extend ipmi_pef_config_t {
~ipmi_pef_config_t()
{
ipmi_pef_free_config(self);
}
/*
* Get a value from the pefconfig. The first parameter is the
* parm number, the second is the parm index (which is a pointer
* to an integer). The returned value will be undefined if
* an error occurred, it will be of the format:
* "<name> <type> <data>"
* The type and data will not be present if the data value is not
* supported or the index is out of range, but the name will still
* be present.
*
* The supports types are: integer, bool, data, and string. The
* data for an integer is a number. The data for a bool is true
* or false. The data for string is a string, starting one space
* after the string and going to the end of the returned valid
*
* The second parameter (the index) is zero based and should be
* set to zero when fetching an index for the first time. It will
* be unchanged if the data item does not support multiple items.
* If it does support multiple items, then the number will be
* changed to the next supported value, or to -1 if this is the
* last item.
*
* Be careful with the index, it must be a number, not something
* that can be interpreted to a number. If necessary, in perl,
* you must do $idx = int($idx) in some cases.
*/
%newobject get_val;
char *get_val(int parm, int *index)
{
enum ipmi_pefconf_val_type_e valtype;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
const char *name;
char dummy[1];
char *str = NULL, *s;
int rv;
int i;
unsigned int len;
rv = ipmi_pefconfig_get_val(self, parm, &name, index, &valtype,
&ival, &dval, &dval_len);
if ((rv == ENOSYS) || (rv == E2BIG))
return strdup(name);
else if (rv)
return NULL;
switch (valtype) {
case IPMI_PEFCONFIG_INT:
len = snprintf(dummy, 1, "%s integer %d", name, ival);
str = malloc(len + 1);
sprintf(str, "%s integer %d", name, ival);
break;
case IPMI_PEFCONFIG_BOOL:
len = snprintf(dummy, 1, "%s bool %s", name,
ival ? "true" : "false");
str = malloc(len + 1);
sprintf(str, "%s bool %s", name,
ival ? "true" : "false");
break;
case IPMI_PEFCONFIG_DATA:
len = snprintf(dummy, 1, "%s data", name);
len += dval_len * 5;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s data", name);
for (i=0; i<dval_len; i++)
s += sprintf(s, " 0x%2.2x", dval[i]);
break;
case IPMI_PEFCONFIG_STR:
len = snprintf(dummy, 1, "%s string %s", name, (char *) dval);
str = malloc(len + 1);
sprintf(str, "%s string %s", name, (char *) dval);
break;
}
if (dval)
ipmi_pefconfig_data_free(dval);
return str;
}
/*
* Set a value in the pefconfig. The first parameter is the parm
* number, the second is the parm index. The type is a string
* in the third parm. The data is the fourth parm.
*
* The supports types are: integer, bool, data, and string. The
* data for an integer is a number. The data for a bool is true
* or false. The data for string is just a string.
*
* The index is ignored for types that do not use it.
*/
int set_val(int parm, int idx, char *type, char *value) {
enum ipmi_pefconf_val_type_e valtype;
int rv;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
rv = ipmi_pefconfig_parm_to_type(parm, &valtype);
if (rv)
return rv;
switch (valtype) {
case IPMI_PEFCONFIG_INT:
{
char *endstr;
if (strcmp(type, "integer") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (*value == '\0')
return EINVAL;
ival = strtol(value, &endstr, 0);
if (*endstr != '\0')
return EINVAL;
break;
}
case IPMI_PEFCONFIG_BOOL:
if (strcmp(type, "bool") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (strcasecmp(value, "true") == 0)
ival = 1;
else if (strcasecmp(value, "false") == 0)
ival = 0;
else if (strcasecmp(value, "on") == 0)
ival = 1;
else if (strcasecmp(value, "off") == 0)
ival = 0;
else
return EINVAL;
break;
case IPMI_PEFCONFIG_DATA:
if (strcmp(type, "data") != 0)
return EINVAL;
if (!value)
return EINVAL;
dval = parse_raw_str_data(value, &dval_len);
if (!dval)
return ENOMEM;
break;
case IPMI_PEFCONFIG_STR:
if (strcmp(type, "string") != 0)
return EINVAL;
if (!value)
return EINVAL;
dval = (unsigned char *) strdup((char *) value);
if (!dval)
return ENOMEM;
break;
}
rv = ipmi_pefconfig_set_val(self, parm, idx, ival, dval, dval_len);
if (dval)
free(dval);
return rv;
}
}
%extend ipmi_pet_t {
~ipmi_pet_t()
{
ipmi_pet_deref(self);
}
%newobject get_mc_id;
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_pet_get_mc_id(self);
return rv;
}
int get_channel()
{
return ipmi_pet_get_channel(self);
}
%newobject get_ip_addr;
char *get_ip_addr()
{
struct in_addr ip;
char *dval = malloc(16);
unsigned char d[4];
if (!dval)
return NULL;
ipmi_pet_get_ip_addr(self, &ip);
d[0] = (ip.s_addr >> 24) & 0xff;
d[1] = (ip.s_addr >> 16) & 0xff;
d[2] = (ip.s_addr >> 8) & 0xff;
d[3] = (ip.s_addr >> 0) & 0xff;
sprintf(dval, "%d.%d.%d.%d", d[0], d[1], d[2], d[3]);
return dval;
}
%newobject get_mac_addr;
char *get_mac_addr()
{
char *dval = malloc(18);
unsigned char d[6];
if (!dval)
return NULL;
ipmi_pet_get_mac_addr(self, d);
sprintf(dval, "%d:%d:%d:%d:%d:%d", d[0], d[1], d[2], d[3], d[4], d[5]);
return dval;
}
int get_eft_sel()
{
return ipmi_pet_get_eft_sel(self);
}
int get_policy_num()
{
return ipmi_pet_get_policy_num(self);
}
int get_apt_sel()
{
return ipmi_pet_get_apt_sel(self);
}
int get_lan_dest_sel()
{
return ipmi_pet_get_lan_dest_sel(self);
}
}
%newobject alloc_cmdlang;
/*
* Allocate a command language handler for use by the interpreted
* language. This allows commands to be entered and the responses
* received by the handler object passed in. The handler object must
* implement a large number of methods:
*
* cmdlang_out - Normal output of a name/value pair. Has the following
* parameters: <self> <cmdlang> <name> <value>
*
* cmdlang_out_binary - Output binary information. Has the following
* parameters: <self> <cmdlang> <name> <val1> [<val2> ...] where the
* values are either a list of parameters or an array of integer
* values (depending on the language).
*
* cmdlang_out_unicode - Output a unicode string. Has the following
* parameters: <self> <cmdlang> <name> <val1> [<val2> ...] where the
* values are either a list of parameters or an array of integer
* values (depending on the language).
*
* cmdlang_down - increase the nesting level of the output. Takes
* the following parameters: <self> <cmdlang>.
* cmdlang_up - decrease the nesting level of the output. Takes
* the following parameters: <self> <cmdlang>.
*
* cmdlang_done - Execution of a command is complete. This will be
* called after every handled command so the upper layer will know
* when a new command can be entered.. Takes the following
* parameters: <self> <cmdlang>.
*/
ipmi_cmdlang_t *alloc_cmdlang(swig_cb *handler);
/*
* Enable or disable full information for events registers with
* set_cmdlang_event_handler. Normally (with this set to false) only
* minimal event information is printed. With this set to true, all
* information about the object the event occurs for is printed.
*/
void cmdlang_set_evinfo(int evinfo);
/*
* Get the event info flag value.
*/
int cmdlang_get_evinfo(void);
/*
* Set an error handler for handling "global" errors from the OpenIPMI
* command language. Basically, these are errors that are note
* related to any specific command handler. The handler has the
* global_cmdlang_err method called on it with the following parms:
* <self>
* <objstr> - The name of the object associated with the error. May
* be empty.
* <location> - The location (in the source code) where the error was
* generated. May be empty.
* <errstr> - The error string generated.
* <errval> - an integer value for the error.
*/
void set_cmdlang_global_err_handler(swig_cb *handler);
/*
* Handle event from the cmdlang interface. These are basically
* events that occur asyncronously and are thus not associated with
* any specific cmdlang handler. The handler's cmdlang_event method
* will be called with the following parameters: <self> <event>. The
* event is of the type ipmi_cmdlang_event_t.
*/
void set_cmdlang_event_handler(swig_cb *handler);
%{
static void cmdlang_set_evinfo(int evinfo)
{
ipmi_cmdlang_set_evinfo(evinfo);
}
static int cmdlang_get_evinfo(void)
{
return ipmi_cmdlang_get_evinfo();
}
static void cmdlang_down(ipmi_cmdlang_t *info)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
swig_call_cb(cb, "cmdlang_down", "%p", &ref);
swig_free_ref(ref);
}
static void cmdlang_up(ipmi_cmdlang_t *info)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
swig_call_cb(cb, "cmdlang_up", "%p", &ref);
swig_free_ref(ref);
}
static void cmdlang_done(ipmi_cmdlang_t *info)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
swig_call_cb(cb, "cmdlang_done", "%p", &ref);
swig_free_ref(ref);
/* Clean up the cmdlang information */
if (info->errstr_dynalloc)
ipmi_mem_free(info->errstr);
info->errstr_dynalloc = 0;
info->errstr = NULL;
info->objstr[0] = '\0';
info->err = 0;
}
static void cmdlang_out(ipmi_cmdlang_t *info,
const char *name,
const char *value)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
if (!value)
value = "";
swig_call_cb(cb, "cmdlang_out", "%p%s%s", &ref, name, value);
swig_free_ref(ref);
}
static void cmdlang_out_binary(ipmi_cmdlang_t *info,
const char *name,
const char *value,
unsigned int len)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
swig_call_cb(cb, "cmdlang_out_binary", "%p%s%*s", &ref, name,
len, value);
swig_free_ref(ref);
}
static void cmdlang_out_unicode(ipmi_cmdlang_t *info,
const char *name,
const char *value,
unsigned int len)
{
swig_cb_val *cb = info->user_data;
swig_ref ref = swig_make_ref(info, ipmi_cmdlang_t);
swig_call_cb(cb, "cmdlang_out_unicode", "%p%s%*s", &ref, name,
len, value);
swig_free_ref(ref);
}
static ipmi_cmdlang_t *
alloc_cmdlang(swig_cb *handler)
{
ipmi_cmdlang_t *cmdlang = NULL;
IPMI_SWIG_C_CB_ENTRY
if (nil_swig_cb(handler))
goto out;
if (!valid_swig_cb(handler, cmdlang_out))
goto out;
if (!valid_swig_cb(handler, cmdlang_out_binary))
goto out;
if (!valid_swig_cb(handler, cmdlang_out_unicode))
goto out;
if (!valid_swig_cb(handler, cmdlang_down))
goto out;
if (!valid_swig_cb(handler, cmdlang_up))
goto out;
if (!valid_swig_cb(handler, cmdlang_done))
goto out;
cmdlang = malloc(sizeof(*cmdlang));
if (!cmdlang)
goto out;
memset(cmdlang, 0, sizeof(*cmdlang));
cmdlang->out = cmdlang_out;
cmdlang->down = cmdlang_down;
cmdlang->up = cmdlang_up;
cmdlang->done = cmdlang_done;
cmdlang->out_binary = cmdlang_out_binary;
cmdlang->out_unicode = cmdlang_out_unicode;
cmdlang->os_hnd = swig_os_hnd;
cmdlang->objstr = malloc(IPMI_MAX_NAME_LEN);
if (!cmdlang->objstr) {
free(cmdlang);
cmdlang = NULL;
goto out;
}
cmdlang->objstr[0] = '\0';
cmdlang->objstr_len = IPMI_MAX_NAME_LEN;
cmdlang->user_data = ref_swig_gencb(handler);
out:
IPMI_SWIG_C_CB_EXIT
return cmdlang;
}
swig_cb_val *cmdlang_global_err_handler = NULL;
static void cmdlang_global_err(char *objstr,
char *location,
char *errstr,
int errval)
{
swig_cb_val *handler = cmdlang_global_err_handler;
if (!objstr)
objstr = "";
if (!location)
location = "";
if (! handler) {
fprintf(stderr, "Global IPMI cmdlang error: %s(%s): %s (%d)\n",
objstr, location, errstr, errval);
} else {
swig_call_cb(handler,
"global_cmdlang_err",
"%s%s%s%d", objstr, location, errstr, errval);
}
}
swig_cb_val *cmdlang_event_handler = NULL;
static void cmdlang_report_event(ipmi_cmdlang_event_t *event)
{
swig_ref event_ref;
swig_cb_val *handler = cmdlang_event_handler;
if (! handler)
return;
event_ref = swig_make_ref(event, ipmi_cmdlang_event_t);
swig_call_cb(handler, "cmdlang_event", "%p", &event_ref);
/* User shouldn't keep these around. */
swig_free_ref_check(event_ref, ipmi_cmdlang_event_t);
}
void set_cmdlang_global_err_handler(swig_cb *handler)
{
swig_cb_val *old_handler = cmdlang_global_err_handler;
IPMI_SWIG_C_CB_ENTRY
ipmi_cmdlang_err_rpt = cmdlang_global_err;
if (valid_swig_cb(handler, global_cmdlang_err))
cmdlang_global_err_handler = ref_swig_cb(handler,
global_cmdlang_err);
else
cmdlang_global_err_handler = NULL;
if (old_handler)
deref_swig_cb_val(old_handler);
IPMI_SWIG_C_CB_EXIT
}
void set_cmdlang_event_handler(swig_cb *handler)
{
swig_cb_val *old_handler = cmdlang_event_handler;
IPMI_SWIG_C_CB_ENTRY
ipmi_cmdlang_event_rpt = cmdlang_report_event;
if (valid_swig_cb(handler, cmdlang_event))
cmdlang_event_handler = ref_swig_cb(handler, cmdlang_event);
else
cmdlang_event_handler = NULL;
if (old_handler)
deref_swig_cb_val(old_handler);
IPMI_SWIG_C_CB_EXIT
}
%}
%extend ipmi_cmdlang_t {
~ipmi_cmdlang_t()
{
swig_cb_val *handler_val = self->user_data;
IPMI_SWIG_C_CB_ENTRY
if (handler_val)
deref_swig_cb_val(handler_val);
if (self->objstr)
free(self->objstr);
free(self);
IPMI_SWIG_C_CB_EXIT
}
/*
* Process a command for the command language.
*/
void handle(const char *icmd)
{
char *cmd = strdup(icmd);
IPMI_SWIG_C_CB_ENTRY
ipmi_cmdlang_handle(self, cmd);
IPMI_SWIG_C_CB_EXIT
}
/*
* When outputting, tells if this is help output.
*/
int is_help()
{
return self->help;
}
/*
* When outputting, gets the error value, or 0 if there was no
* error.
*/
int get_err()
{
return self->err;
}
%newobject get_errstr;
/*
* If there was an error, get the error string.
*/
char *get_errstr()
{
return strdup(self->errstr);
}
/*
* If there was an error, get the object name associated with the error.
*/
%newobject get_objstr;
char *get_objstr()
{
return strdup(self->objstr);
}
/*
* If there was an error, get the location in the source code
* where the error was generated.
*/
%newobject get_location;
char *get_location()
{
return strdup(self->location);
}
}
/*
* A cmdlang event is a series of name/value fields that may be
* fetched in sequence.
*/
%extend ipmi_cmdlang_event_t {
~ipmi_cmdlang_event_t()
{
/* Nothing to do. */
}
/*
* Restart with the first field.
*/
void restart()
{
ipmi_cmdlang_event_restart(self);
}
/*
* Get the values of the next field. The level is the nesting
* level, the type is either "string", "binary", or "unicode", the
* name is the name of the field, and value is its value. binary
* and unicode are returned as a string of hex values (0xnn 0xnn ...).
*/
int next_field(unsigned int *level,
const char **type,
char **name,
char **value)
{
int rv;
unsigned int len;
char *n, *v;
char *np, *vp;
enum ipmi_cmdlang_out_types t;
char *tp;
int i;
char *s;
rv = ipmi_cmdlang_event_next_field(self, level, &t, &n, &len, &v);
if (!rv) {
*type = "";
*name = NULL;
*value = NULL;
return rv;
}
if (!v)
v = "";
np = strdup(n);
if (!np)
return ENOMEM;
switch (t) {
case IPMI_CMDLANG_STRING:
tp = "string";
vp = strdup(v);
break;
case IPMI_CMDLANG_BINARY:
tp = "binary";
vp = malloc(len * 5);
if (!vp)
break;
s = vp;
if (len > 0)
s += sprintf(s, "0x%2.2x", (unsigned char) v[0]);
for (i=1; i<len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) v[i]);
break;
case IPMI_CMDLANG_UNICODE:
tp = "unicode";
vp = malloc(len * 5);
if (!vp)
break;
s = vp;
if (len > 0)
s += sprintf(s, "0x%2.2x", (unsigned char) v[0]);
for (i=1; i<len; i++)
s += sprintf(s, " 0x%2.2x", (unsigned char) v[i]);
break;
default:
free(np);
return EINVAL;
}
if (!vp) {
free(np);
return ENOMEM;
}
*name = np;
*value = vp;
*type = tp;
return 1;
}
}
%{
static char *sol_state_string(int val)
{
switch (val) {
case ipmi_sol_state_closed:
return "closed";
case ipmi_sol_state_connecting:
return "connecting";
case ipmi_sol_state_connected:
return "connected";
case ipmi_sol_state_connected_ctu:
return "connected no char xfer";
case ipmi_sol_state_closing:
return "closing";
default:
return "unknown";
}
}
%}
char *sol_state_string(int val);
%extend ipmi_sol_conn_t
{
~ipmi_sol_conn_t()
{
ipmi_sol_free(self);
}
%constant int sol_state_closed = ipmi_sol_state_closed;
%constant int sol_state_connecting = ipmi_sol_state_connecting;
%constant int sol_state_connected = ipmi_sol_state_connected;
%constant int sol_state_connected_ctu = ipmi_sol_state_connected_ctu;
%constant int sol_state_closing = ipmi_sol_state_closing;
void set_ACK_timeout(int timeout_usec)
{
ipmi_sol_set_ACK_timeout(self, timeout_usec);
}
int get_ACK_timeout()
{
return ipmi_sol_get_ACK_timeout(self);
}
void set_ACK_retries(int retries)
{
ipmi_sol_set_ACK_retries(self, retries);
}
int get_ACK_retries()
{
return ipmi_sol_get_ACK_retries(self);
}
int set_use_authentication(int use_authentication)
{
return ipmi_sol_set_use_authentication(self, use_authentication);
}
int get_use_authentication()
{
return ipmi_sol_get_use_authentication(self);
}
int set_use_encryption(int use_encryption)
{
return ipmi_sol_set_use_encryption(self, use_encryption);
}
int get_use_encryption()
{
return ipmi_sol_get_use_encryption(self);
}
%constant int sol_serial_alerts_fail = ipmi_sol_serial_alerts_fail;
%constant int sol_serial_alerts_deferred = ipmi_sol_serial_alerts_deferred;
%constant int sol_serial_alerts_succeed = ipmi_sol_serial_alerts_succeed;
int set_shared_serial_alert_behavior(int behavior)
{
return ipmi_sol_set_shared_serial_alert_behavior(self, behavior);
}
int get_shared_serial_alert_behavior()
{
return ipmi_sol_get_shared_serial_alert_behavior(self);
}
int set_deassert_CTS_DCD_DSR_on_connect(int assert)
{
return ipmi_sol_set_deassert_CTS_DCD_DSR_on_connect(self, assert);
}
int get_deassert_CTS_DCD_DSR_on_connect()
{
return ipmi_sol_get_deassert_CTS_DCD_DSR_on_connect(self);
}
%constant int SOL_BIT_RATE_DEFAULT = IPMI_SOL_BIT_RATE_DEFAULT;
%constant int SOL_BIT_RATE_9600 = IPMI_SOL_BIT_RATE_9600;
%constant int SOL_BIT_RATE_19200 = IPMI_SOL_BIT_RATE_19200;
%constant int SOL_BIT_RATE_38400 = IPMI_SOL_BIT_RATE_38400;
%constant int SOL_BIT_RATE_57600 = IPMI_SOL_BIT_RATE_57600;
%constant int SOL_BIT_RATE_115200 = IPMI_SOL_BIT_RATE_115200;
int set_bit_rate(unsigned int rate)
{
return ipmi_sol_set_bit_rate(self, rate);
}
unsigned int get_bit_rate()
{
return ipmi_sol_get_bit_rate(self);
}
int open()
{
int rv;
IPMI_SWIG_C_CB_ENTRY
rv = ipmi_sol_open(self);
IPMI_SWIG_C_CB_EXIT
return rv;
}
int close()
{
int rv;
IPMI_SWIG_C_CB_ENTRY
rv = ipmi_sol_close(self);
IPMI_SWIG_C_CB_EXIT
return rv;
}
int force_close()
{
int rv;
IPMI_SWIG_C_CB_ENTRY
rv = ipmi_sol_force_close(self);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Write the given buffer to the serial port. When complete, the
* sol_write_complete method of the handler will be called with
* the following parameters: <self> <conn> <error>
*/
int write(charbuf buf, swig_cb *handler = NULL)
{
ipmi_sol_transmit_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_write_complete)) {
rv = EINVAL;
goto out_err;
}
cb = sol_write_complete_cb;
handler_val = ref_swig_cb(handler, sol_write_complete);
}
rv = ipmi_sol_write(self, buf.val, buf.len, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* For every NACK returned from the receive routine, this function
* must be called to release the NACK.
*/
int release_nack()
{
int rv;
IPMI_SWIG_C_CB_ENTRY
rv = ipmi_sol_release_nack(self);
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Send a break to the serial port. When complete, the
* sol_send_break method of the handler will be called with
* the following parameters: <self> <conn> <error>
*/
int send_break(swig_cb *handler = NULL)
{
ipmi_sol_transmit_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_send_break)) {
rv = EINVAL;
goto out_err;
}
cb = sol_send_break_cb;
handler_val = ref_swig_cb(handler, sol_send_break);
}
rv = ipmi_sol_send_break(self, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Send CTS assertable (or not) on the serial port. When
* complete, the sol_set_CTS_assertable method of the handler will
* be called with the following parameters: <self> <conn> <error>
*/
int set_CTS_assertable(int asserted, swig_cb *handler = NULL)
{
ipmi_sol_transmit_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_set_CTS_assertable)) {
rv = EINVAL;
goto out_err;
}
cb = sol_set_CTS_assertable_cb;
handler_val = ref_swig_cb(handler, sol_set_CTS_assertable);
}
rv = ipmi_sol_set_CTS_assertable(self, asserted, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Assert or deassert DCD and DSR on the serial port. When
* complete, the sol_set_DCD_DSR_asserted method of the handler
* will be called with the following parameters: <self> <conn>
* <error>
*/
int set_DCD_DSR_asserted(int asserted, swig_cb *handler = NULL)
{
ipmi_sol_transmit_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_set_DCD_DSR_asserted)) {
rv = EINVAL;
goto out_err;
}
cb = sol_set_DCD_DSR_asserted_cb;
handler_val = ref_swig_cb(handler, sol_set_DCD_DSR_asserted);
}
rv = ipmi_sol_set_DCD_DSR_asserted(self, asserted, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Assert or deassert RI on the serial port. When complete, the
* sol_set_RI_asserted method of the handler will be called with
* the following parameters: <self> <conn> <error>
*/
int set_RI_asserted(int asserted, swig_cb *handler = NULL)
{
ipmi_sol_transmit_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_set_RI_asserted)) {
rv = EINVAL;
goto out_err;
}
cb = sol_set_RI_asserted_cb;
handler_val = ref_swig_cb(handler, sol_set_RI_asserted);
}
rv = ipmi_sol_set_RI_asserted(self, asserted, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
%constant int SOL_BMC_TRANSMIT_QUEUE = IPMI_SOL_BMC_TRANSMIT_QUEUE;
%constant int SOL_BMC_RECEIVE_QUEUE = IPMI_SOL_BMC_RECEIVE_QUEUE;
%constant int SOL_MANAGEMENT_CONSOLE_TRANSMIT_QUEUE = IPMI_SOL_MANAGEMENT_CONSOLE_TRANSMIT_QUEUE;
%constant int SOL_MANAGEMENT_CONSOLE_RECEIVE_QUEUE = IPMI_SOL_MANAGEMENT_CONSOLE_RECEIVE_QUEUE;
%constant int SOL_BMC_QUEUES = IPMI_SOL_BMC_QUEUES;
%constant int SOL_MANAGEMENT_CONSOLE_QUEUES = IPMI_SOL_MANAGEMENT_CONSOLE_QUEUES;
%constant int SOL_ALL_QUEUES = IPMI_SOL_ALL_QUEUES;
/*
* Flush the given queues, as specified by the queue selectors
* above. When complete, the sol_flush_complete method of the
* handler will be called with the following parameters: <self>
* <conn> <queue selectors> <error>
*/
int flush(int queue_selectors, swig_cb *handler = NULL)
{
ipmi_sol_flush_complete_cb cb = NULL;
swig_cb_val *handler_val = NULL;
int rv;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, sol_flush_complete)) {
rv = EINVAL;
goto out_err;
}
cb = sol_flush_complete_cb;
handler_val = ref_swig_cb(handler, sol_flush_complete);
}
rv = ipmi_sol_flush(self, queue_selectors, cb, handler_val);
if (rv && handler_val)
deref_swig_cb_val(handler_val);
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
%extend ipmi_solparm_t {
~ipmi_solparm_t()
{
ipmi_solparm_deref(self);
}
%newobject get_mc_id;
ipmi_mcid_t *get_mc_id()
{
ipmi_mcid_t *rv = malloc(sizeof(*rv));
if (rv)
*rv = ipmi_solparm_get_mc_id(self);
return rv;
}
int get_channel()
{
return ipmi_solparm_get_channel(self);
}
%constant int SOLPARM_SET_IN_PROGRESS = IPMI_SOLPARM_SET_IN_PROGRESS;
%constant int SOLPARM_ENABLE = IPMI_SOLPARM_ENABLE;
%constant int SOLPARM_AUTHENTICATION = IPMI_SOLPARM_AUTHENTICATION;
%constant int SOLPARM_CHAR_SETTINGS = IPMI_SOLPARM_CHAR_SETTINGS;
%constant int SOLPARM_RETRY = IPMI_SOLPARM_RETRY;
%constant int SOLPARM_NONVOLATILE_BITRATE = IPMI_SOLPARM_NONVOLATILE_BITRATE;
%constant int SOLPARM_VOLATILE_BITRATE = IPMI_SOLPARM_VOLATILE_BITRATE;
%constant int SOLPARM_PAYLOAD_CHANNEL = IPMI_SOLPARM_PAYLOAD_CHANNEL;
%constant int SOLPARM_PAYLOAD_PORT_NUMBER = IPMI_SOLPARM_PAYLOAD_PORT_NUMBER;
/*
* Fetch an individual parm from the MC. The parameter (parm1) ,
* and set (parm2) and block (parm3) are specified, along with a
* handler (parm4). The solparm_got_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <solparm> <err> <parm_rev> <data1> [<data2> ...]
*/
int get_parm(int parm, int set, int block, swig_cb *handler)
{
int rv;
swig_cb_val *handler_val;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, solparm_got_parm_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, solparm_got_parm_cb);
ipmi_solparm_ref(self);
rv = ipmi_solparm_get_parm(self, parm, set, block,
solparm_get_parm, handler_val);
if (rv) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1),
* and string value (parm2) is specified, along with an optional
* handler (parm3). The solparm_set_parm_cb method on the handler
* will be called when the the operation completes with the
* following parms: <self> <solparm> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm(int parm, char *value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length;
IPMI_SWIG_C_CB_ENTRY
data = parse_raw_str_data(value, &length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, solparm_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, solparm_set_parm_cb);
}
if (handler_val)
ipmi_solparm_ref(self);
rv = ipmi_solparm_set_parm(self, parm, data, length,
solparm_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set an individual parm on the MC. The parameter (parm1), and
* an array of integers (parm2) is specified, along with an
* optional handler (parm3). The solparm_set_parm_cb method on
* the handler will be called when the the operation completes
* with the following parms: <self> <solparm> <err>.
*
* The string value is in the form "0xNN 0xNN ...", basically
* a string of integer values.
*/
int set_parm_array(int parm, intarray value, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
unsigned char *data;
unsigned int length = value.len;
IPMI_SWIG_C_CB_ENTRY
if (length == 0)
data = malloc(1);
else
data = malloc(length);
if (!data) {
rv = ENOMEM;
goto out_err;
}
parse_ipmi_data(value, data, length, &length);
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, solparm_set_parm_cb)) {
free(data);
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, solparm_set_parm_cb);
}
if (handler_val)
ipmi_solparm_ref(self);
rv = ipmi_solparm_set_parm(self, parm, data, length,
solparm_set_parm, handler_val);
free(data);
if (rv && handler_val) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Get the full standard configuration for the solparms. When
* done, the solparm_got_config_cb method will be called on the
* handler (first parm) with the following parms: <self> <solparm>
* <err> <solconfig>. The solconfig will be an object of type
* ipmi_sol_config_t.
*/
int get_config(swig_cb *handler)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!valid_swig_cb(handler, solparm_got_config_cb))
rv = EINVAL;
else {
handler_val = ref_swig_cb(handler, solparm_got_config_cb);
ipmi_solparm_ref(self);
rv = ipmi_sol_get_config(self, solparm_get_config, handler_val);
if (rv) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
}
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Set the full standard configuration for the solparms. The
* config to set is the first parm of type ipmi_sol_config_t. When
* done, the solparm_set_config_cb method will be called on the
* handler (second parm) with the following parms: <self>
* <solparm> <err>.
*/
int set_config(ipmi_sol_config_t *config, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, solparm_set_config_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, solparm_set_config_cb);
}
if (handler_val)
ipmi_solparm_ref(self);
rv = ipmi_sol_set_config(self, config,
solparm_set_config, handler_val);
if (rv && handler_val) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
/*
* Unlock the lock for the solparm. The config to set is the
* first parm of type ipmi_sol_config_t and may be undefined
* (meaning that the MC of the solparm will be unlocked). If the
* config is supplied, it will be marked as unlocked. When done,
* the solparm_clear_lock_cb method will be called on the handler
* (second parm) with the following parms: <self> <solparm> <err>.
*/
int clear_lock(ipmi_sol_config_t *config = NULL, swig_cb *handler = NULL)
{
int rv;
swig_cb_val *handler_val = NULL;
IPMI_SWIG_C_CB_ENTRY
if (!nil_swig_cb(handler)) {
if (! valid_swig_cb(handler, solparm_clear_lock_cb)) {
rv = EINVAL;
goto out_err;
}
handler_val = ref_swig_cb(handler, solparm_clear_lock_cb);
}
if (handler_val)
ipmi_solparm_ref(self);
rv = ipmi_sol_clear_lock(self, config,
solparm_clear_lock, handler_val);
if (rv && handler_val) {
ipmi_solparm_deref(self);
deref_swig_cb_val(handler_val);
}
out_err:
IPMI_SWIG_C_CB_EXIT
return rv;
}
}
%extend ipmi_sol_config_t {
~ipmi_sol_config_t()
{
ipmi_sol_free_config(self);
}
/*
* Get a value from the solconfig. The first parameter is the
* parm number, the second is the parm index (which is a pointer
* to an integer). The returned value will be undefined if
* an error occurred, it will be of the format:
* "<name> <type> <data>"
* The type and data will not be present if the data value is not
* supported or the index is out of range, but the name will still
* be present.
*
* The supports types are: integer, bool, data, ip, and mac. The
* data for an integer is a number. The data for a bool is true
* or false. The data for ip is an IP address in the form
* "n.n.n.n". Data for mac is a mac address in the form
* "nn:nn:nn:nn:nn:nn"
*
* The second parameter (the index) is zero based and should be
* set to zero when fetching an index for the first time. It will
* be unchanged if the data item does not support multiple items.
* If it does support multiple items, then the number will be
* changed to the next supported value, or to -1 if this is the
* last item.
*
* Be careful with the index, it must be a number, not something
* that can be interpreted to a number. If necessary, in perl,
* you must do $idx = int($idx) in some cases.
*/
%newobject get_val;
char *get_val(int parm, int *index)
{
enum ipmi_solconf_val_type_e valtype;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
const char *name;
char dummy[1];
char *str = NULL, *s;
int rv;
int i;
unsigned int len;
rv = ipmi_solconfig_get_val(self, parm, &name, index, &valtype,
&ival, &dval, &dval_len);
if ((rv == ENOSYS) || (rv == E2BIG))
return strdup(name);
else if (rv)
return NULL;
switch (valtype) {
case IPMI_SOLCONFIG_INT:
len = snprintf(dummy, 1, "%s integer %d", name, ival);
str = malloc(len + 1);
sprintf(str, "%s integer %d", name, ival);
break;
case IPMI_SOLCONFIG_BOOL:
len = snprintf(dummy, 1, "%s bool %s", name,
ival ? "true" : "false");
str = malloc(len + 1);
sprintf(str, "%s bool %s", name,
ival ? "true" : "false");
break;
case IPMI_SOLCONFIG_DATA:
len = snprintf(dummy, 1, "%s data", name);
len += dval_len * 5;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s data", name);
for (i=0; i<dval_len; i++)
s += sprintf(s, " 0x%2.2x", dval[i]);
break;
case IPMI_SOLCONFIG_IP:
len = snprintf(dummy, 1, "%s ip", name);
len += 4 * 4; /* worst case */
str = malloc(len + 1);
sprintf(str, "%s ip %d.%d.%d.%d", name,
dval[0], dval[1], dval[2], dval[3]);
break;
case IPMI_SOLCONFIG_MAC:
len = snprintf(dummy, 1, "%s mac", name);
len += 6 * 3;
str = malloc(len + 1);
s = str;
s += sprintf(s, "%s mac ", name);
for (i=0; i<5; i++)
s += sprintf(s, "%2.2x:", dval[i]);
sprintf(s, "%2.2x", dval[i]);
break;
}
if (dval)
ipmi_solconfig_data_free(dval);
return str;
}
/*
* Set a value in the solconfig. The first parameter is the parm
* number, the second is the parm index. The type is a string
* in the third parm. The data is the fourth parm.
*
* The supports types are: integer, bool, data, ip, and mac. The
* data for an integer is a number. The data for a bool is true
* or false. The data for ip is an IP address in the form
* "n.n.n.n". Data for mac is a mac address in the form
* "nn.nn.nn.nn.nn.nn"
*
* The index is ignored for types that do not use it.
*/
int set_val(int parm, int idx, char *type, char *value) {
enum ipmi_solconf_val_type_e valtype;
int rv;
unsigned int ival = 0;
unsigned char *dval = NULL;
unsigned int dval_len = 0;
rv = ipmi_solconfig_parm_to_type(parm, &valtype);
if (rv)
return rv;
switch (valtype) {
case IPMI_SOLCONFIG_INT:
{
char *endstr;
if (strcmp(type, "integer") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (*value == '\0')
return EINVAL;
ival = strtol(value, &endstr, 0);
if (*endstr != '\0')
return EINVAL;
break;
}
case IPMI_SOLCONFIG_BOOL:
if (strcmp(type, "bool") != 0)
return EINVAL;
if (!value)
return EINVAL;
if (strcasecmp(value, "true") == 0)
ival = 1;
else if (strcasecmp(value, "false") == 0)
ival = 0;
else if (strcasecmp(value, "on") == 0)
ival = 1;
else if (strcasecmp(value, "off") == 0)
ival = 0;
else
return EINVAL;
break;
case IPMI_SOLCONFIG_DATA:
if (strcmp(type, "data") != 0)
return EINVAL;
if (!value)
return EINVAL;
dval = parse_raw_str_data(value, &dval_len);
if (!dval)
return ENOMEM;
break;
case IPMI_SOLCONFIG_IP:
{
struct in_addr addr;
if (strcmp(type, "ip") != 0)
return EINVAL;
rv = parse_ip_addr(value, &addr);
if (rv)
return rv;
dval = malloc(4);
memcpy(dval, &addr.s_addr, 4);
dval_len = 4;
}
break;
case IPMI_SOLCONFIG_MAC:
if (strcmp(type, "mac") != 0)
return EINVAL;
dval = malloc(6);
rv = parse_mac_addr(value, dval);
if (rv) {
free(dval);
return rv;
}
dval_len = 6;
break;
}
rv = ipmi_solconfig_set_val(self, parm, idx, ival, dval, dval_len);
if (dval)
free(dval);
return rv;
}
}
|