Codebase list ibutils / 46a747a7-e6d2-4b80-95d6-358455c124af/main ibis / src / ibsac.i
46a747a7-e6d2-4b80-95d6-358455c124af/main

Tree @46a747a7-e6d2-4b80-95d6-358455c124af/main (Download .tar.gz)

ibsac.i @46a747a7-e6d2-4b80-95d6-358455c124af/mainraw · history · blame

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
/*
 * Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

%{
#include "stdio.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <iba/ib_types.h>
#include <complib/cl_types.h>
#include <complib/cl_qmap.h>
#include <complib/cl_map.h>
#include <complib/cl_debug.h>
#include "ibis_api.h"
#ifdef OSM_BUILD_OPENIB
#include <vendor/osm_vendor_sa_api.h>
#else
#include <opensm/osm_vendor_sa_api.h>
#endif
#include "ibsac.h"

  /*
     TODO:  Add the following queries
     ClassPortInfo
     InformInfo
     SLtoVLMappingTableRecord
     VLArbitrationTableRecord
     ServiceRecord
     P_KeyTableRecord

     Not supported by OpenSM:
     Notice
     MulticastForwardingTableRecord
     InformInfoRecord

     Later:
     MultiPathRecord
  */

  /* we probably want to use our own naming for classes */
  typedef ib_node_record_t         sacNodeRec;
  typedef ib_node_info_t           sacNodeInfo;
  typedef ib_portinfo_record_t     sacPortRec;
  typedef ib_port_info_t           sacPortInfo;
  typedef ib_sminfo_record_t       sacSmRec;
  typedef ib_sm_info_t             sacSmInfo;
  typedef ib_switch_info_record_t  sacSwRec;
  typedef ib_switch_info_t         sacSwInfo;
  typedef ib_link_record_t         sacLinkRec;
  typedef ib_path_rec_t            sacPathRec;
  typedef ib_lft_record_t          sacLFTRec;
  typedef ib_member_rec_t          sacMCMRec;
  typedef ib_class_port_info_t     sacClassPortInfo;
  typedef ib_inform_info_t         sacInformInfo;
  typedef ib_service_record_t      sacServiceRec;
  typedef ib_slvl_table_t          sacSlVlTbl;
  typedef ib_slvl_table_record_t   sacSlVlRec;
  typedef ib_vl_arb_table_record_t sacVlArbRec;
  typedef ib_pkey_table_t          sacPKeyTbl;
  typedef ib_pkey_table_record_t   sacPKeyRec;
  typedef ib_guid_info_t           sacGuidInfo;
  typedef ib_guidinfo_record_t     sacGuidRec;
  typedef uint8_t                  ib_lft_t;
%}

%{

#include "swig_extended_obj.c"

  /* Pre allocated Query Objects */
  ib_node_record_t          ibsac_node_rec;             // ib_node_info_t
  ib_portinfo_record_t      ibsac_portinfo_rec;         // ib_port_info_t
  ib_sminfo_record_t        ibsac_sminfo_rec;           // ib_sm_info_t
  ib_switch_info_record_t   ibsac_swinfo_rec;           // ib_switch_info_t
  ib_link_record_t          ibsac_link_rec;             // no sub type
  ib_path_rec_t             ibsac_path_rec;             // no sub type
  ib_lft_record_t           ibsac_lft_rec;              // no sub type
  ib_member_rec_t           ibsac_mcm_rec;              // no sub type
  ib_class_port_info_t      ibsac_class_port_info;      // no sub type
  ib_inform_info_t          ibsac_inform_info;          // no sub type
  ib_service_record_t       ibsac_svc_rec;              // no sub type
  ib_slvl_table_record_t    ibsac_slvl_rec;             // ib_slvl_table_t
  ib_vl_arb_table_record_t  ibsac_vlarb_rec;            // ib_vl_arb_table_t
  ib_pkey_table_record_t    ibsac_pkey_rec;             // ib_pkey_table_t
  ib_guidinfo_record_t      ibsac_guidinfo_rec;         // ib_guid_info_t

  /* Query Functions for each record */
  /* These are TCL specific thus are here */

  char *ibsacNodeRecordQuery(
	 ib_node_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_node_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_NODE_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_node_record_t *)malloc(sizeof(ib_node_record_t));

		/* copy into it */
		*p_rec = *(osmv_get_query_node_rec( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("nr",p_rec);
		SWIG_AltMnglRegObj("ni",&(p_rec->node_info));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "nr", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacPortInfoRecordQuery(
	 ib_portinfo_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_portinfo_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_PORTINFO_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_portinfo_record_t *)malloc(sizeof(ib_portinfo_record_t));

		/* copy into it */
		*p_rec = *(osmv_get_query_portinfo_rec( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("pir",p_rec);
		SWIG_AltMnglRegObj("pi",&(p_rec->port_info));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "pir", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacSMInfoRecordQuery(
	 ib_sminfo_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_sminfo_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_SMINFO_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_sminfo_record_t *)malloc(sizeof(ib_sminfo_record_t));

		/* copy into it */
		*p_rec = *((ib_sminfo_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("smir",p_rec);
		SWIG_AltMnglRegObj("smi",&(p_rec->sm_info));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "smir", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacSwitchInfoRecordQuery(
	 ib_switch_info_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_switch_info_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, CL_NTOH16(0x0014), self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_switch_info_record_t *)malloc(sizeof(ib_switch_info_record_t));

		/* copy into it */
		*p_rec = *((ib_switch_info_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("swir",p_rec);
		SWIG_AltMnglRegObj("swi",&(p_rec->switch_info));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "swir", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacPathRecordQuery(
	 ib_path_rec_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_path_rec_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_PATH_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_path_rec_t *)malloc(sizeof(ib_path_rec_t));

		/* copy into it */
		*p_rec = *((ib_path_rec_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("path",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "path", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacLinkRecordQuery(
	 ib_link_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_link_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_LINK_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_link_record_t *)malloc(sizeof(ib_link_record_t));

		/* copy into it */
		*p_rec = *((ib_link_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("link",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "link", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacLFTRecordQuery(
	 ib_lft_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_lft_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_LFT_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_lft_record_t *)malloc(sizeof(ib_lft_record_t));

		/* copy into it */
		*p_rec = *((ib_lft_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("lft",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "lft", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacMCMemberRecordQuery(
	 ib_member_rec_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_member_rec_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_MCMEMBER_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_member_rec_t *)malloc(sizeof(ib_member_rec_t));

		/* copy into it */
		*p_rec = *((ib_member_rec_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("mcm",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "mcm", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacClassPortInfoQuery(
	 ib_class_port_info_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_class_port_info_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_CLASS_PORT_INFO, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_class_port_info_t *)malloc(sizeof(ib_class_port_info_t));

		/* copy into it */
		*p_rec = *((ib_class_port_info_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("cpi",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "cpi", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacInformInfoQuery(
	 ib_inform_info_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_inform_info_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj,  IB_MAD_ATTR_INFORM_INFO, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_inform_info_t *)malloc(sizeof(ib_inform_info_t));

		/* copy into it */
		*p_rec = *((ib_inform_info_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("info",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "info", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }


  char *ibsacServiceRecordQuery(
	 ib_service_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_service_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj,  IB_MAD_ATTR_SERVICE_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_service_record_t *)malloc(sizeof(ib_service_record_t));

		/* copy into it */
		*p_rec = *((ib_service_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("svc",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "svc", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacSl2VlRecordQuery(
	 ib_slvl_table_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_slvl_table_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_SLVL_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_slvl_table_record_t *)malloc(sizeof(ib_slvl_table_record_t));

		/* copy into it */
		*p_rec = *((ib_slvl_table_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("slvr",p_rec);
		SWIG_AltMnglRegObj("slvt",&(p_rec->slvl_tbl));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "slvr", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacVlArbRecordQuery(
	 ib_vl_arb_table_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_vl_arb_table_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_VLARB_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_vl_arb_table_record_t *)malloc(sizeof(ib_vl_arb_table_record_t));

		/* copy into it */
		*p_rec = *((ib_vl_arb_table_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("vlarb",p_rec);

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "vlarb", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

  char *ibsacPKeyRecordQuery(
	 ib_pkey_table_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_pkey_table_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_PKEY_TBL_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_pkey_table_record_t *)malloc(sizeof(ib_pkey_table_record_t));

		/* copy into it */
		*p_rec = *((ib_pkey_table_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("pkr",p_rec);
		SWIG_AltMnglRegObj("pkt",&(p_rec->pkey_tbl));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "pkr", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }

char *ibsacGuidRecordQuery(
	 ib_guidinfo_record_t *self,
	 uint64_t comp_mask,
	 uint8_t method) {
	 ib_guidinfo_record_t *p_rec;
	 uint32_t i;
	 ib_api_status_t status;
	 uint32_t num_recs = 0;
	 osm_madw_t *p_result_madw;
	 char *p_res_str = NULL, *tmp;
	 Tcl_Obj *p_tclObj;
	 int nameLength;

	 status = ibsac_query(
		&IbisObj, IB_MAD_ATTR_GUIDINFO_RECORD, self, comp_mask, method,
		&num_recs, &p_result_madw
		);

	 for( i = 0; i < num_recs; i++ )
	 {
		/* we need to create a new node info and copy */
		p_rec = (ib_guidinfo_record_t *)malloc(sizeof(ib_guidinfo_record_t));

		/* copy into it */
		*p_rec = *((ib_guidinfo_record_t*)osmv_get_query_result( p_result_madw, i ));

		/* register it as a new object */
		SWIG_AltMnglRegObj("gr",p_rec);
		SWIG_AltMnglRegObj("gi",&(p_rec->guid_info));

		p_tclObj = Tcl_NewObj();

		/* get the assigned name */
		if (SWIG_AltMnglGetObjNameByPtr(p_tclObj, "gr", p_rec)) {
		  printf("-E- Fail to get name of object %p\n", p_rec);
		} else {
		  tmp = Tcl_GetStringFromObj(p_tclObj, &nameLength);

		  /* enlarge the result string length */
		  if (p_res_str)
			 p_res_str = (char *)realloc(p_res_str, strlen(p_res_str) + nameLength + 2);
		  else {
			 p_res_str = (char *)malloc(nameLength + 2);
			 p_res_str[0] = '\0';
		  }

		  strcat(p_res_str, tmp);
		  strcat(p_res_str, " ");
		}
		Tcl_DecrRefCount(p_tclObj);
	 }

	 if( p_result_madw != NULL )
		osm_mad_pool_put( &IbisObj.mad_pool, p_result_madw );

	 return(p_res_str);
  }


%}

//
// STANDARD IB TYPE MAPS:
//

%typemap(tcl8,in) ib_gid_t*(ib_gid_t temp) {
  char buf[40];
  char *p_prefix, *p_guid;
  char *str_token = NULL;

  strcpy(buf, Tcl_GetStringFromObj($source,NULL));
  p_prefix = strtok_r(buf,":", &str_token);
  if (! p_prefix)
  {
    printf("Wrong format for gid prefix:%s\n", Tcl_GetStringFromObj($source,NULL));
    return TCL_ERROR;
  }
  p_guid = strtok_r(NULL, " ", &str_token);
  if (! p_guid)
  {
    printf("Wrong format for gid prefix:%s\n", Tcl_GetStringFromObj($source,NULL));
    return TCL_ERROR;
  }

  errno = 0;
  temp.unicast.prefix = cl_hton64(strtoull(p_prefix, NULL, 16));
  if (errno) {
    printf("Wrong format for gid prefix:%s\n", p_prefix);
    return TCL_ERROR;
  }

  temp.unicast.interface_id = cl_hton64(strtoull(p_guid, NULL, 16));
  if (errno) {
    printf("Wrong format for gid guid:%s\n", p_guid);
    return TCL_ERROR;
  }

  $target = &temp;
}

%typemap(tcl8,out) ib_node_desc_t * {
  /* we must make sure we do not overflow the node desc length */
  char buff[IB_NODE_DESCRIPTION_SIZE];
  strncpy(buff,(char *)$source,IB_NODE_DESCRIPTION_SIZE - 1);
  buff[IB_NODE_DESCRIPTION_SIZE - 1] = '\0';
  Tcl_SetStringObj($target, buff, strlen(buff));
}

%typemap(tcl8,out) ib_lft_t * {
  char buf[12];
  int i;
  for (i = 0; i < 64; i++) {
	 sprintf(buf, "{%u %u} ", i, $source[i]);
	 Tcl_AppendToObj($target, buf, -1);
  }
}

%typemap(tcl8,memberin) ib_lft_t[ANY] {
  int i;
  int m = $dim0;
  if (m > 64) m = 64;
  for (i=0; i <$dim0 ; i++) {
    $target[i] = *($source+i);
  }
}

%typemap(tcl8,in) ib_node_desc_t *(ib_node_desc_t temp) {
  strcpy((char *)temp.description, Tcl_GetStringFromObj($source,NULL));
  $target = &temp;
}


//
// INTERFACE DEFINITION (~copy of h file)
//

%section "IBSAC Constants"
/* These constants are provided by IBIS: */

%section "IBSAC Objects",pre
/* This section describes the various object types exposed by IBSAC. */
%text %{

  IBSAC exposes some of its internal subnet objects. The objects
  identifiers returned by the various function calls are formatted
  acording to the following rules:
  ni:<idx> = node info objects

  IBIS Objects are standard Swig-Tcl objects.
  As such they have two flavors for their usage: Variables, Objects.

  Variables:
     For each object attribute a "get" and "set" methods are provided.
	  The format of the methods is: <class>_<attribute>_<get|set>.
     The "set" method is only available for read/write attributes.

  Example:
  ib_node_info_t_port_guid_get ni:1

  Objects:
     Given an object identifier one can convert it to a Tcl "Object"
	  using the following command:
     <class> <obj_name> -this <obj identifier>

     Once declared the <obj-name> can be used in conjunction to
     with the standard "configure" and "cget" commands.

  Example: (following the previous one):
		 ib_node_info_t nodeRecNI -this ni:1

%}

#define IB_NR_COMPMASK_LID					0x1
#define IB_NR_COMPMASK_RESERVED1			0x2
#define IB_NR_COMPMASK_BASEVERSION		0x4
#define IB_NR_COMPMASK_CLASSVERSION		0x8
#define IB_NR_COMPMASK_NODETYPE			0x10
#define IB_NR_COMPMASK_NUMPORTS			0x20
#define IB_NR_COMPMASK_SYSIMAGEGUID		0x40
#define IB_NR_COMPMASK_NODEGUID			0x80
#define IB_NR_COMPMASK_PORTGUID			0x100
#define IB_NR_COMPMASK_PARTCAP			0x200
#define IB_NR_COMPMASK_DEVID				0x400
#define IB_NR_COMPMASK_REV					0x800
#define IB_NR_COMPMASK_PORTNUM			0x1000
#define IB_NR_COMPMASK_VENDID				0x2000
#define IB_NR_COMPMASK_NODEDESC			0x4000

typedef struct _ib_node_info
{
	uint8_t				base_version;
	uint8_t				class_version;
	uint8_t				node_type;
	uint8_t				num_ports;
	ib_net64_t			sys_guid;
	ib_net64_t			node_guid;
	ib_net64_t			port_guid;
	ib_net16_t			partition_cap;
	ib_net16_t			device_id;
	ib_net32_t			revision;
	ib_net32_t			port_num_vendor_id;

} sacNodeInfo;

%addmethods sacNodeInfo {
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

typedef struct _ib_node_record_t
{
	ib_net16_t		lid;
	sacNodeInfo 	node_info;
	ib_node_desc_t node_desc;
} sacNodeRec;

%addmethods sacNodeRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacNodeRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacNodeRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 /* we need to de-register both the node info and node record */
	 SWIG_AltMnglUnregObj(&(self->node_info));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	PORT INFO
	-----------------------------------------------------*/

#define IB_PIR_COMPMASK_LID				  "0x1"
#define IB_PIR_COMPMASK_PORTNUM			  "0x2"
#define IB_PIR_COMPMASK_RESV1				  "0x4"
#define IB_PIR_COMPMASK_MKEY				  "0x8"
#define IB_PIR_COMPMASK_GIDPRE			  0x10
#define IB_PIR_COMPMASK_BASELID			  0x20
#define IB_PIR_COMPMASK_SMLID				  0x40
#define IB_PIR_COMPMASK_CAPMASK			  0x80
#define IB_PIR_COMPMASK_DIAGCODE			  0x100
#define IB_PIR_COMPMASK_MKEYLEASEPRD	  0x200
#define IB_PIR_COMPMASK_LOCALPORTNUM	  0x400
#define IB_PIR_COMPMASK_LNKWIDTHSUPPORT  0x800
#define IB_PIR_COMPMASK_LNKWIDTHACTIVE	  0x1000
#define IB_PIR_COMPMASK_LINKWIDTHENABLED 0x2000
#define IB_PIR_COMPMASK_LNKSPEEDSUPPORT  0x4000
#define IB_PIR_COMPMASK_PORTSTATE		  0x10000
#define IB_PIR_COMPMASK_PORTPHYSTATE	  0x20000
#define IB_PIR_COMPMASK_LINKDWNDFLTSTATE 0x40000
#define IB_PIR_COMPMASK_MKEYPROTBITS	  0x80000
#define IB_PIR_COMPMASK_LMC				  0x100000
#define IB_PIR_COMPMASK_LINKSPEEDACTIVE  0x200000
#define IB_PIR_COMPMASK_LINKSPEEDENABLE  0x400000
#define IB_PIR_COMPMASK_NEIGHBORMTU		  0x800000
#define IB_PIR_COMPMASK_MASTERSMSL		  0x1000000
#define IB_PIR_COMPMASK_VLCAP				  0x2000000
#define IB_PIR_COMPMASK_INITTYPE			  0x4000000
#define IB_PIR_COMPMASK_VLHIGHLIMIT		  0x8000000
#define IB_PIR_COMPMASK_VLARBHIGHCAP	  0x10000000
#define IB_PIR_COMPMASK_VLARBLOWCAP		  0x20000000
#define IB_PIR_COMPMASK_INITTYPEREPLY	  0x40000000
#define IB_PIR_COMPMASK_MTUCAP			  0x80000000
#define IB_PIR_COMPMASK_VLSTALLCNT		  "0x100000000"
#define IB_PIR_COMPMASK_HOQLIFE			  "0x200000000"
#define IB_PIR_COMPMASK_OPVLS		    	  "0x400000000"
#define IB_PIR_COMPMASK_PARENFIN		     "0x800000000"
#define IB_PIR_COMPMASK_PARENFOUT		  "0x1000000000"
#define IB_PIR_COMPMASK_FILTERRAWIN		  "0x2000000000"
#define IB_PIR_COMPMASK_FILTERRAWOUT	  "0x4000000000"
#define IB_PIR_COMPMASK_MKEYVIO			  "0x8000000000"
#define IB_PIR_COMPMASK_PKEYVIO			  "0x10000000000"
#define IB_PIR_COMPMASK_QKEYVIO			  "0x20000000000"
#define IB_PIR_COMPMASK_GUIDCAP			  "0x40000000000"
#define IB_PIR_COMPMASK_RESV2			     "0x80000000000"
#define IB_PIR_COMPMASK_SUBNTO			  "0x100000000000"
#define IB_PIR_COMPMASK_RESV3			     "0x200000000000"
#define IB_PIR_COMPMASK_RESPTIME		     "0x400000000000"
#define IB_PIR_COMPMASK_LOCALPHYERR		  "0x800000000000"
#define IB_PIR_COMPMASK_OVERRUNERR		  "0x1000000000000"

typedef struct _ib_port_info
{
	ib_net64_t			m_key;
	ib_net64_t			subnet_prefix;
	ib_net16_t			base_lid;
	ib_net16_t			master_sm_base_lid;
	ib_net32_t			capability_mask;
	ib_net16_t			diag_code;
	ib_net16_t			m_key_lease_period;
	uint8_t				local_port_num;
	uint8_t				link_width_enabled;
	uint8_t				link_width_supported;
	uint8_t				link_width_active;
	uint8_t				state_info1;	// LinkSpeedSupported and PortState
	uint8_t				state_info2;	// PortPhysState and LinkDownDefaultState
	uint8_t				mkey_lmc;
	uint8_t				link_speed;		// LinkSpeedEnabled and LinkSpeedActive
	uint8_t				mtu_smsl;
   uint8_t				vl_cap;        // VlCap and InitType
	uint8_t				vl_high_limit;
	uint8_t				vl_arb_high_cap;
	uint8_t				vl_arb_low_cap;
	uint8_t				mtu_cap;
	uint8_t				vl_stall_life;
	uint8_t				vl_enforce;
	ib_net16_t			m_key_violations;
	ib_net16_t			p_key_violations;
	ib_net16_t			q_key_violations;
	uint8_t				guid_cap;
	uint8_t				subnet_timeout;
	uint8_t				resp_time_value;
	uint8_t				error_threshold;

} sacPortInfo;

%addmethods sacPortInfo {
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

typedef struct _ib_portinfo_record
{
	ib_net16_t		lid;
	uint8_t			port_num;
	sacPortInfo   	port_info;
} sacPortRec;

%addmethods sacPortRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacPortInfoRecordQuery(self, cl_hton64(comp_mask),
                                    IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacPortInfoRecordQuery(self, cl_hton64(comp_mask),
                                    IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 /* we need to de-register both the node info and node record */
	 SWIG_AltMnglUnregObj(&(self->port_info));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	SM INFO
	-----------------------------------------------------*/

#define IB_SMR_COMPMASK_LID				  "0x1"
#define IB_SMR_COMPMASK_GUID             "0x2"
#define IB_SMR_COMPMASK_SM_KEY           "0x4"
#define IB_SMR_COMPMASK_ACT_COUNT 	     "0x8"
#define IB_SMR_COMPMASK_STATE  		     0x10
#define IB_SMR_COMPMASK_PRI       	     0x20

typedef struct _ib_sm_info
{
  ib_net64_t			guid;
  ib_net64_t			sm_key;
  ib_net32_t			act_count;
  uint8_t				pri_state;
} sacSmInfo;

%addmethods sacSmInfo {
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

typedef struct _ib_sminfo_record
{
  ib_net16_t		lid;
  sacSmInfo	      sm_info;
} sacSmRec;

%addmethods sacSmRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacSMInfoRecordQuery(self, cl_hton64(comp_mask),
                                  IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacSMInfoRecordQuery(self, cl_hton64(comp_mask),
                                  IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 /* we need to de-register both the node info and node record */
	 SWIG_AltMnglUnregObj(&(self->sm_info));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	SWITCH INFO
	-----------------------------------------------------*/

#define IB_SWR_COMPMASK_LID			    "0x1"
#define IB_SWR_COMPMASK_LIN_CAP         "0x2"
#define IB_SWR_COMPMASK_RAND_CAP	       "0x4"
#define IB_SWR_COMPMASK_MCAST_CAP	    "0x8"
#define IB_SWR_COMPMASK_LIN_TOP		    "0x10"
#define IB_SWR_COMPMASK_DEF_PORT  	    "0x20"
#define IB_SWR_COMPMASK_DEF_MCAST_PRI   "0x40"
#define IB_SWR_COMPMASK_DEF_MCAST_NOT   "0x80"
#define IB_SWR_COMPMASK_STATE 		    "0x100"
#define IB_SWR_COMPMASK_LIFE    	       "0x200"
#define IB_SWR_COMPMASK_LMC 			    "0x400"
#define IB_SWR_COMPMASK_ENFORCE_CAP     "0x800"
#define IB_SWR_COMPMASK_FLAGS		       "0x1000"

typedef struct _ib_switch_info
{
	ib_net16_t			lin_cap;
	ib_net16_t			rand_cap;
	ib_net16_t			mcast_cap;
	ib_net16_t			lin_top;
	uint8_t				def_port;
	uint8_t				def_mcast_pri_port;
	uint8_t				def_mcast_not_port;
	uint8_t				life_state;
	ib_net16_t			lids_per_port;
	ib_net16_t			enforce_cap;
	uint8_t				flags;

} sacSwInfo;

%addmethods sacSwInfo {
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

typedef struct _ib_switch_info_record
{
  ib_net16_t			lid;
  sacSwInfo       	switch_info;
} sacSwRec;

%addmethods sacSwRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacSwitchInfoRecordQuery(self, cl_hton64(comp_mask),
                                      IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacSwitchInfoRecordQuery(self, cl_hton64(comp_mask),
                                      IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 /* we need to de-register both the node info and node record */
	 SWIG_AltMnglUnregObj(&(self->switch_info));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	LINK
	-----------------------------------------------------*/

#define IB_LR_COMPMASK_FROM_LID   0x1
#define IB_LR_COMPMASK_FROM_PORT  0x2
#define IB_LR_COMPMASK_TO_PORT    0x4
#define IB_LR_COMPMASK_TO_LID     0x8

typedef struct _ib_link_record
{
	ib_net16_t		from_lid;
	uint8_t			from_port_num;
	uint8_t			to_port_num;
	ib_net16_t		to_lid;
} sacLinkRec;

%addmethods sacLinkRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacLinkRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacLinkRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	PATH
	-----------------------------------------------------*/

#define  IB_PR_COMPMASK_DGID              0x4
#define  IB_PR_COMPMASK_SGID              0x8
#define  IB_PR_COMPMASK_DLID              0x10
#define  IB_PR_COMPMASK_SLID              0x20
#define  IB_PR_COMPMASK_RAWTRAFIC         0x40
#define  IB_PR_COMPMASK_RESV0             0x80
#define  IB_PR_COMPMASK_FLOWLABEL         0x100
#define  IB_PR_COMPMASK_HOPLIMIT          0x200
#define  IB_PR_COMPMASK_TCLASS            0x400
#define  IB_PR_COMPMASK_REVERSIBLE        0x800
#define  IB_PR_COMPMASK_NUMBPATH          0x1000
#define  IB_PR_COMPMASK_PKEY              0x2000
#define  IB_PR_COMPMASK_RESV1             0x4000
#define  IB_PR_COMPMASK_SL                0x8000
#define  IB_PR_COMPMASK_MTUSELEC          0x10000
#define  IB_PR_COMPMASK_MTU               0x20000
#define  IB_PR_COMPMASK_RATESELEC         0x40000
#define  IB_PR_COMPMASK_RATE              0x80000
#define  IB_PR_COMPMASK_PKTLIFETIMESELEC  0x100000
#define  IB_PR_COMPMASK_PFTLIFETIME       0x200000

typedef struct _ib_path_rec
{
        ib_net64_t service_id;
        ib_gid_t dgid;
        ib_gid_t sgid;
        ib_net16_t dlid;
        ib_net16_t slid;
        ib_net32_t hop_flow_raw;
        uint8_t tclass;
        uint8_t num_path;
        ib_net16_t pkey;
        ib_net16_t qos_class_sl;
        uint8_t mtu;
        uint8_t rate;
        uint8_t pkt_life;
        uint8_t preference;
} sacPathRec;

%addmethods sacPathRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacPathRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacPathRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
    free(self);
	 SWIG_AltMnglUnregObj(self);
  }
}

/* -----------------------------------------------------
	LFT
	-----------------------------------------------------*/

#define IB_LFT_COMPMASK_LID    "0x1"
#define IB_LFT_COMPMASK_BLOCK  "0x2"

typedef struct _ib_lft_record
{
	ib_net16_t		lid;
	ib_net16_t		block_num;
	ib_lft_t	      lft[64];
} sacLFTRec;

%addmethods sacLFTRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacLFTRecordQuery(self, cl_hton64(comp_mask),
                               IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacLFTRecordQuery(self, cl_hton64(comp_mask),
                               IB_MAD_METHOD_GETTABLE));
  };
  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	MCM
	-----------------------------------------------------*/

#define IB_MCR_COMPMASK_GID         "0x1"
#define IB_MCR_COMPMASK_MGID        "0x1"
#define IB_MCR_COMPMASK_PORT_GID    "0x2"
#define IB_MCR_COMPMASK_QKEY        "0x4"
#define IB_MCR_COMPMASK_MLID        "0x8"
#define IB_MCR_COMPMASK_MTU_SEL     "0x10"
#define IB_MCR_COMPMASK_MTU         "0x20"
#define IB_MCR_COMPMASK_TCLASS      "0x40"
#define IB_MCR_COMPMASK_PKEY        "0x80"
#define IB_MCR_COMPMASK_RATE_SEL    "0x100"
#define IB_MCR_COMPMASK_RATE        "0x200"
#define IB_MCR_COMPMASK_LIFE_SEL    "0x400"
#define IB_MCR_COMPMASK_LIFE        "0x800"
#define IB_MCR_COMPMASK_SL          "0x1000"
#define IB_MCR_COMPMASK_FLOW        "0x2000"
#define IB_MCR_COMPMASK_HOP         "0x4000"
#define IB_MCR_COMPMASK_SCOPE       "0x8000"
#define IB_MCR_COMPMASK_JOIN_STATE  "0x10000"
#define IB_MCR_COMPMASK_PROXY       "0x20000"

typedef struct _ib_member_rec
{
	ib_gid_t				mgid;
	ib_gid_t				port_gid;
	ib_net32_t			qkey;
	ib_net16_t			mlid;
	uint8_t				mtu;
	uint8_t				tclass;
	ib_net16_t			pkey;
	uint8_t				rate;
	uint8_t				pkt_life;
	ib_net32_t			sl_flow_hop;
	uint8_t				scope_state;
  // uint8_t				proxy_join:1; bit fields are not supported.
} sacMCMRec;

%addmethods sacMCMRec {
%new char *get(uint64_t comp_mask) {
	 return(ibsacMCMemberRecordQuery(self, cl_hton64(comp_mask),
                                    IB_MAD_METHOD_GET));
  };
%new char *getTable(uint64_t comp_mask) {
	 return(ibsacMCMemberRecordQuery(self, cl_hton64(comp_mask),
                                    IB_MAD_METHOD_GETTABLE));
  };
 %new char *set(uint64_t comp_mask) {
   return(ibsacMCMemberRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_SET));
 };
 %new char *del(uint64_t comp_mask) {
   return(ibsacMCMemberRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_DELETE));
 };

 int proxy_join_get() {
   return(self->proxy_join);
 }

  void proxy_join_set(uint8_t proxy_join) {
    self->proxy_join = proxy_join;
  }

  void obj_delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }

}

/* -----------------------------------------------------
	Class Port Info
	-----------------------------------------------------*/
typedef struct _ibsac_class_port_info
{
	uint8_t					base_ver;
	uint8_t					class_ver;
	ib_net16_t				cap_mask;
	ib_net32_t				cap_mask2_resp_time;
	ib_gid_t				redir_gid;
	ib_net32_t				redir_tc_sl_fl;
	ib_net16_t				redir_lid;
	ib_net16_t				redir_pkey;
	ib_net32_t				redir_qp;
	ib_net32_t				redir_qkey;
	ib_gid_t				trap_gid;
	ib_net32_t				trap_tc_sl_fl;
	ib_net16_t				trap_lid;
	ib_net16_t				trap_pkey;
	ib_net32_t				trap_hop_qp;
	ib_net32_t				trap_qkey;
} sacClassPortInfo;

%addmethods sacClassPortInfo {
  %new char *get() {
    return(ibsacClassPortInfoQuery(self, 0, IB_MAD_METHOD_GET));
  };

  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	Inform Info
	-----------------------------------------------------*/
typedef struct _ibsac_inform_info
{
  ib_gid_t				   gid;
  ib_net16_t				lid_range_begin;
  ib_net16_t				lid_range_end;
  ib_net16_t				reserved1;
  uint8_t					is_generic;
  uint8_t					subscribe;
  ib_net16_t				trap_type;
  union _sac_inform_g_or_v
  {
	 struct _sac_inform_generic
	 {
		ib_net16_t		trap_num;
		ib_net32_t		qpn_resp_time_val;
      uint8_t        reserved2;
		uint8_t			node_type_msb;
		ib_net16_t		node_type_lsb;
	 } generic;

	 struct _sac_inform_vend
	 {
		ib_net16_t		dev_id;
		ib_net32_t		qpn_resp_time_val;
      uint8_t        reserved2;
		uint8_t			vendor_id_msb;
		ib_net16_t		vendor_id_lsb;
	 } vend;

  } g_or_v;

} sacInformInfo;

%addmethods sacInformInfo {
  %new char *set() {
    return(ibsacInformInfoQuery(self, 0, IB_MAD_METHOD_SET));
  };

  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	Service Record
	-----------------------------------------------------*/

#define IB_SR_COMPMASK_SID           "0x1"
#define IB_SR_COMPMASK_SGID          "0x1"
#define IB_SR_COMPMASK_SPKEY         "0x2"
#define IB_SR_COMPMASK_RES1          "0x4"
#define IB_SR_COMPMASK_SLEASE        "0x8"
#define IB_SR_COMPMASK_SKEY          "0x10"
#define IB_SR_COMPMASK_SNAME         "0x20"
#define IB_SR_COMPMASK_SDATA8_0      "0x40"
#define IB_SR_COMPMASK_SDATA8_1      "0x80"
#define IB_SR_COMPMASK_SDATA8_2      "0x100"
#define IB_SR_COMPMASK_SDATA8_3      "0x200"
#define IB_SR_COMPMASK_SDATA8_4      "0x400"
#define IB_SR_COMPMASK_SDATA8_5      "0x800"
#define IB_SR_COMPMASK_SDATA8_6      "0x1000"
#define IB_SR_COMPMASK_SDATA8_7      "0x2000"
#define IB_SR_COMPMASK_SDATA8_8      "0x4000"
#define IB_SR_COMPMASK_SDATA8_9      "0x8000"
#define IB_SR_COMPMASK_SDATA8_10     "0x10000"
#define IB_SR_COMPMASK_SDATA8_11     "0x20000"
#define IB_SR_COMPMASK_SDATA8_12     "0x40000"
#define IB_SR_COMPMASK_SDATA8_13     "0x80000"
#define IB_SR_COMPMASK_SDATA8_14     "0x100000"
#define IB_SR_COMPMASK_SDATA8_15     "0x200000"
#define IB_SR_COMPMASK_SDATA16_0     "0x400000"
#define IB_SR_COMPMASK_SDATA16_1     "0x800000"
#define IB_SR_COMPMASK_SDATA16_2     "0x1000000"
#define IB_SR_COMPMASK_SDATA16_3     "0x2000000"
#define IB_SR_COMPMASK_SDATA16_4     "0x4000000"
#define IB_SR_COMPMASK_SDATA16_5     "0x8000000"
#define IB_SR_COMPMASK_SDATA16_6     "0x10000000"
#define IB_SR_COMPMASK_SDATA16_7     "0x20000000"
#define IB_SR_COMPMASK_SDATA32_0     "0x40000000"
#define IB_SR_COMPMASK_SDATA32_1     "0x80000000"
#define IB_SR_COMPMASK_SDATA32_2     "0x100000000"
#define IB_SR_COMPMASK_SDATA32_3     "0x200000000"
#define IB_SR_COMPMASK_SDATA64_0     "0x400000000"
#define IB_SR_COMPMASK_SDATA64_1     "0x800000000"

%typemap(tcl8,in) ib_svc_name_t*(ib_svc_name_t n) {
  char *p_name;
  int l;
  p_name = Tcl_GetStringFromObj($source, &l);
  if (l > 63) l = 63;
  memcpy(n, p_name, l);
  $target = &n;
}

%typemap(tcl8,memberin) ib_svc_name_t {
  memcpy(&($target), $source, sizeof(ib_svc_name_t));
}

%typemap(tcl8,out) ib_svc_name_t* {
  char buff[64];
  strncpy(buff, (char *)(*$source), 63);
  buff[63] = '\0';
  Tcl_SetStringObj($target,buff, strlen(buff));
}


typedef struct _ib_service_record
{
	ib_net64_t		service_id;
	ib_gid_t		   service_gid;
	ib_net16_t		service_pkey;
	ib_net16_t		resv;
	ib_net32_t		service_lease;
	uint8_array_t	service_key[16];
	ib_svc_name_t	service_name;
	uint8_array_t	service_data8[16];
	ib_net16_array_t service_data16[8];
	ib_net32_array_t service_data32[4];
	ib_net64_array_t service_data64[2];
} sacServiceRec;

%addmethods sacServiceRec {
  %new char *get(uint64_t comp_mask) {
    return(ibsacServiceRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_GET));
  };
  %new char *set(uint64_t comp_mask) {
    return(ibsacServiceRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_SET));
  };
  %new char *getTable(uint64_t comp_mask) {
    return(ibsacServiceRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_GETTABLE));
  };
  %new char *delete(uint64_t comp_mask) {
    return(ibsacServiceRecordQuery(self, cl_hton64(comp_mask),
                                   IB_MAD_METHOD_DELETE));
  };

  void obj_delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	SL to VL Table Record
	-----------------------------------------------------*/
#define IB_SLVL_COMPMASK_LID             "0x1"
#define IB_SLVL_COMPMASK_IN_PORT         "0x2"
#define IB_SLVL_COMPMASK_OUT_PORT        "0x4"
typedef struct _ib_slvl_table
{
	uint8_array_t raw_vl_by_sl[IB_MAX_NUM_VLS/2];
} sacSlVlTbl;

typedef struct _ib_slvl_table_record
{
	ib_net16_t		 lid; // for CA: lid of port, for switch lid of port 0
	uint8_t			 in_port_num;	// reserved for CA's
	uint8_t			 out_port_num;	// reserved for CA's
	uint32_t	  	    resv;
	sacSlVlTbl      slvl_tbl;
} sacSlVlRec;

%addmethods sacSlVlRec {
  %new char *get(uint64_t comp_mask) {
    return(ibsacSl2VlRecordQuery(self, cl_hton64(comp_mask),
                                 IB_MAD_METHOD_GET));
  };
  %new char *getTable(uint64_t comp_mask) {
    return(ibsacSl2VlRecordQuery(self, cl_hton64(comp_mask),
                                 IB_MAD_METHOD_GETTABLE));
  };

  void delete() {
	 SWIG_AltMnglUnregObj(&(self->slvl_tbl));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
   VL Arb Table Record
	-----------------------------------------------------*/
#define IB_VLA_COMPMASK_LID              "0x1"
#define IB_VLA_COMPMASK_OUT_PORT         "0x2"
#define IB_VLA_COMPMASK_BLOCK            "0x4"

%typemap(tcl8,in) sac_vl_arb_tbl_t* (ib_vl_arb_table_t n) {
  uint8_t idx;
  char *p_vl_str, *p_wt_str;
  unsigned long int vl, weight;
#if TCL_MINOR_VERSION > 3
  const char **sub_lists;
#else
  char **sub_lists;
#endif
  int num_sub_lists;
  memset( &n, 0, sizeof(ib_vl_arb_table_t) );

  /* we will use the TCL split list to split into elements */
  if (Tcl_SplitList(interp,
                    Tcl_GetStringFromObj($source,0),
                    &num_sub_lists, &sub_lists) != TCL_OK) {
    printf("-E- Bad formatted list :%s\n",
           Tcl_GetStringFromObj($source,0));
    return TCL_ERROR;
  }

  for (idx = 0;
       (idx < num_sub_lists) && (idx < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK);
       idx++)
  {
    /* we need to double copy since TCL 8.4 requires split res to be const */
    char buf[16];
    char *p_last;
    strcpy(buf, sub_lists[idx]);
    p_vl_str = strtok_r(buf," \t", &p_last);
    p_wt_str = strtok_r(NULL," \t", &p_last);
    if (! (p_vl_str && p_wt_str)) {
      printf("-E- Bad formatted number pair:%s\n", sub_lists[idx]);
      return TCL_ERROR;
    } else {
      errno = 0;
      vl = strtoul(p_vl_str, NULL, 0);
      if (errno || (vl > 15)) {
        printf("-E- Bad formatted VL:%s\n", p_vl_str);
        return TCL_ERROR;
      }

      weight = strtoul(p_wt_str, NULL, 0);
      if (errno || (weight > 255)) {
        printf("-E- Bad formatted Weight:%s\n", p_wt_str);
        return TCL_ERROR;
      }

      n.vl_entry[idx].vl = vl;
      n.vl_entry[idx].weight = weight;
    }
  }
  Tcl_Free((char *) sub_lists);

  $target = &n;
}

%typemap(tcl8,out) sac_vl_arb_tbl_t* {
  uint32_t i;
  ib_vl_arb_table_t *p_tbl;
  char buf[256];
  if ($source) {
    strcpy(buf, "");
    p_tbl = $source;
    /*  go over all elements */
    for (i = 0; i < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) {
      sprintf(buf, "{0x%X 0x%02X} ",
              p_tbl->vl_entry[i].vl, p_tbl->vl_entry[i].weight);
      Tcl_AppendResult(interp, buf, NULL);
    }
  } else {
	 Tcl_SetResult(interp, "", NULL);
  }
}


%{
#define sac_vl_arb_tbl_t ib_vl_arb_table_t
%}
typedef struct _ib_vl_arb_table_record
{
	ib_net16_t			lid; // for CA: lid of port, for switch lid of port 0
	uint8_t				port_num;
	uint8_t				block_num;
	uint32_t			   reserved;
	sac_vl_arb_tbl_t  vl_arb_tbl;
} sacVlArbRec;

%addmethods sacVlArbRec {
  %new char *get(uint64_t comp_mask) {
    return(ibsacVlArbRecordQuery(self, cl_hton64(comp_mask),
                                 IB_MAD_METHOD_GET));
  };
  %new char *getTable(uint64_t comp_mask) {
    return(ibsacVlArbRecordQuery(self, cl_hton64(comp_mask),
                                 IB_MAD_METHOD_GETTABLE));
  };

  void delete() {
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
   PKey Table Record
	-----------------------------------------------------*/
#define IB_PKEY_COMPMASK_LID        "0x1"
#define IB_PKEY_COMPMASK_BLOCK      "0x2"
#define IB_PKEY_COMPMASK_PORT       "0x4"

typedef struct _ib_pkey_table
{
  ib_net16_array_t pkey_entry[IB_NUM_PKEY_ELEMENTS_IN_BLOCK];
} sacPKeyTbl;

typedef struct _ib_pkey_table_record
{
	ib_net16_t			lid; // for CA: lid of port, for switch lid of port 0
	uint16_t				block_num;
   uint8_t				port_num; // for switch: port number, for CA: reserved
	uint8_t   			reserved1;
	uint16_t 			reserved2;
	sacPKeyTbl     	pkey_tbl;
} sacPKeyRec;

%addmethods sacPKeyRec {
  %new char *get(uint64_t comp_mask) {
    return(ibsacPKeyRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GET));
  };
  %new char *getTable(uint64_t comp_mask) {
    return(ibsacPKeyRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GETTABLE));
  };

  void delete() {
	 SWIG_AltMnglUnregObj(&(self->pkey_tbl));
	 SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

/* -----------------------------------------------------
	GuidInfo INFO
	-----------------------------------------------------*/
#define IB_GIR_COMPMASK_LID             "0x1"
#define IB_GIR_COMPMASK_BLOCKNUM        "0x2"
#define IB_GIR_COMPMASK_GID0            "0x10"
#define IB_GIR_COMPMASK_GID1            "0x20"
#define IB_GIR_COMPMASK_GID2            "0x40"
#define IB_GIR_COMPMASK_GID3            "0x80"
#define IB_GIR_COMPMASK_GID4            "0x100"
#define IB_GIR_COMPMASK_GID5            "0x200"
#define IB_GIR_COMPMASK_GID6            "0x400"
#define IB_GIR_COMPMASK_GID7            "0x800"

typedef struct _ib_guid_info {
        ib_net64_array_t guid[GUID_TABLE_MAX_ENTRIES];
} sacGuidInfo;

%addmethods sacGuidInfo {
  void delete() {
    SWIG_AltMnglUnregObj(self);
    free(self);
  }
}

typedef struct _ib_guidinfo_record {
        ib_net16_t lid;
        uint8_t block_num;
        uint8_t resv;
        uint32_t reserved;
        sacGuidInfo guid_info;
} sacGuidRec;

%addmethods sacGuidRec {
  %new char *get(uint64_t comp_mask) {
    return(ibsacGuidRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GET));
  };
  %new char *set(uint64_t comp_mask) {
    return(ibsacGuidRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_SET));
  };
  %new char *getTable(uint64_t comp_mask) {
    return(ibsacGuidRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_GETTABLE));
  };
  %new char *delete(uint64_t comp_mask) {
    return(ibsacGuidRecordQuery(self, cl_hton64(comp_mask),
                                IB_MAD_METHOD_DELETE));
  };

  void obj_delete() {
    /* we need to de-register both the guid info and guid record */
    SWIG_AltMnglUnregObj(&(self->guid_info));
    SWIG_AltMnglUnregObj(self);
    free(self);
  }
}