This file is indexed.

/usr/include/capiutils.h is in libcapi20-dev 1:3.27-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
#ifndef __CAPIUTILS_H__
#define __CAPIUTILS_H__

/*
 * This program is free software and may be modified and
 * distributed under the terms of the GNU Public License.
 */

#include <sys/types.h>
#include <sys/time.h>
#include <time.h>

#include "capicmd.h"

#ifdef __cplusplus
extern "C" {
#endif

/*----- errornumbers -----*/

#define CapiToManyAppls				0x1001
#define CapiLogBlkSizeToSmall			0x1002
#define CapiBuffExeceeds64k			0x1003
#define CapiMsgBufSizeToSmall			0x1004
#define CapiAnzLogConnNotSupported		0x1005
#define CapiRegReserved				0x1006
#define CapiRegBusy				0x1007
#define CapiRegOSResourceErr			0x1008
#define CapiRegNotInstalled			0x1009
#define CapiRegCtrlerNotSupportExtEquip		0x100a
#define CapiRegCtrlerOnlySupportExtEquip	0x100b


#define CapiNoError				0x0000
#define CapiIllAppNr				0x1101
#define CapiIllCmdOrSubcmdOrMsgToSmall		0x1102
#define CapiSendQueueFull			0x1103
#define CapiReceiveQueueEmpty			0x1104
#define CapiReceiveOverflow			0x1105
#define CapiUnknownNotPar			0x1106
#define CapiMsgBusy				0x1107
#define CapiMsgOSResourceErr			0x1108
#define CapiMsgNotInstalled			0x1109
#define CapiMsgCtrlerNotSupportExtEquip		0x110a
#define CapiMsgCtrlerOnlySupportExtEquip	0x110b

/* standard CAPI2.0 function aliases */

#define CAPI20_REGISTER          capi20_register
#define CAPI20_RELEASE           capi20_release
#define CAPI20_PUT_MESSAGE       capi20_put_message
#define CAPI20_GET_MESSAGE       capi20_get_message
#define CAPI20_WaitforMessage	 capi20_waitformessage
#define CAPI20_GET_MANUFACTURER  capi20_get_manufacturer
#define CAPI20_GET_VERSION       capi20_get_version
#define CAPI20_GET_SERIAL_NUMBER capi20_get_serial_number
#define CAPI20_GET_PROFILE       capi20_get_profile
#define CAPI20_ISINSTALLED       capi20_isinstalled


#define CAPI_REGISTER_ERROR	unsigned
#define MESSAGE_EXCHANGE_ERROR	unsigned

typedef unsigned char *CAPI_MESSAGE;

#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2
#define HAS_UINT8_T
#include <stdint.h>
#endif
#endif

#ifdef HAS_UINT8_T
typedef uint8_t   _cbyte;
typedef uint16_t  _cword;
typedef uint32_t  _cdword;
typedef uint64_t  _cqword;
#else
typedef unsigned char      _cbyte;
typedef unsigned short     _cword;
typedef unsigned long      _cdword;
typedef unsigned long long _cqword;
#endif

typedef CAPI_MESSAGE   _cstruct;
typedef enum { CAPI_COMPOSE = 0, CAPI_DEFAULT = 1 } _cmstruct;

/*----- CAPI commands -----*/

#define CAPI_ALERT		    0x01
#define CAPI_CONNECT		    0x02
#define CAPI_CONNECT_ACTIVE	    0x03
#define CAPI_CONNECT_B3_ACTIVE	    0x83
#define CAPI_CONNECT_B3 	    0x82
#define CAPI_CONNECT_B3_T90_ACTIVE  0x88
#define CAPI_DATA_B3		    0x86
#define CAPI_DISCONNECT_B3	    0x84
#define CAPI_DISCONNECT 	    0x04
#define CAPI_FACILITY		    0x80
#define CAPI_INFO		    0x08
#define CAPI_LISTEN		    0x05
#define CAPI_MANUFACTURER	    0xff
#define CAPI_RESET_B3		    0x87
#define CAPI_SELECT_B_PROTOCOL	    0x41

/*----- CAPI subcommands -----*/

#define CAPI_REQ    0x80
#define CAPI_CONF   0x81
#define CAPI_IND    0x82
#define CAPI_RESP   0x83

/*-----------------------------------------------------------------------*/

static inline _cword _capimsg_getu16(void *m, int off)
{
	_cword r = 0;
	_cbyte	*p;

	p = (_cbyte *)m;
	p += off;
	r = p[1];
	r <<= 8;
	r |= *p;
	return r;
}

static inline _cdword _capimsg_getu32(void *m, int off)
{
	_cdword r = 0;
	_cbyte	*p, i;

	p = (_cbyte *)m;
	p += off + 3;
	for (i = 0; i < 3; i++) {
		r |= *p--;
		r <<= 8;
	}
	r |= *p;
	return r;
}

static inline _cqword _capimsg_getu64(void *m, int off)
{
	_cqword r = 0;
	_cbyte	*p, i;

	p = (_cbyte *)m;
	p += off + 7;
	for (i = 0; i < 7; i++) {
		r |= *p--;
		r <<= 8;
	}
	r |= *p;
	return r;
}

#define CAPIMSG_BASELEN		8
#define CAPIMSG_U8(m, off)	(*((_cbyte *)(m + off)))
#define CAPIMSG_U16(m, off)	_capimsg_getu16(m, off)
#define CAPIMSG_U32(m, off)	_capimsg_getu32(m, off)
#define CAPIMSG_U64(m, off)	_capimsg_getu64(m, off)
#define	CAPIMSG_LEN(m)		CAPIMSG_U16(m,0)
#define	CAPIMSG_APPID(m)	CAPIMSG_U16(m,2)
#define	CAPIMSG_COMMAND(m)	CAPIMSG_U8(m,4)
#define	CAPIMSG_SUBCOMMAND(m)	CAPIMSG_U8(m,5)
#define CAPIMSG_CMD(m)		(((m[4])<<8)|(m[5]))
#define	CAPIMSG_MSGID(m)	CAPIMSG_U16(m,6)
#define CAPIMSG_CONTROLLER(m)	(m[8] & 0x7f)
#define CAPIMSG_CONTROL(m)	CAPIMSG_U32(m, 8)
#define CAPIMSG_NCCI(m)		CAPIMSG_CONTROL(m)
#define CAPIMSG_DATALEN(m)	CAPIMSG_U16(m,16) /* DATA_B3_REQ */

static inline void capimsg_setu8(void *m, int off, _cbyte val)
{
	((_cbyte *)m)[off] = val;
}

static inline void capimsg_setu16(void *m, int off, _cword val)
{
	((_cbyte *)m)[off] = val & 0xff;
	((_cbyte *)m)[off+1] = (val >> 8) & 0xff;
}

static inline void capimsg_setu32(void *m, int off, _cdword val)
{
	((_cbyte *)m)[off] = val & 0xff;
	((_cbyte *)m)[off+1] = (val >> 8) & 0xff;
	((_cbyte *)m)[off+2] = (val >> 16) & 0xff;
	((_cbyte *)m)[off+3] = (val >> 24) & 0xff;
}

static inline void capimsg_setu64(void *m, int off, _cqword val)
{
	((_cbyte *)m)[off] = val & 0xff;
	((_cbyte *)m)[off+1] = (val >> 8) & 0xff;
	((_cbyte *)m)[off+2] = (val >> 16) & 0xff;
	((_cbyte *)m)[off+3] = (val >> 24) & 0xff;
	((_cbyte *)m)[off+4] = (val >> 32) & 0xff;
	((_cbyte *)m)[off+5] = (val >> 40) & 0xff;
	((_cbyte *)m)[off+6] = (val >> 48) & 0xff;
	((_cbyte *)m)[off+7] = (val >> 56) & 0xff;
}

#define	CAPIMSG_SETLEN(m, len)		capimsg_setu16(m, 0, len)
#define	CAPIMSG_SETAPPID(m, applid)	capimsg_setu16(m, 2, applid)
#define	CAPIMSG_SETCOMMAND(m,cmd)	capimsg_setu8(m, 4, cmd)
#define	CAPIMSG_SETSUBCOMMAND(m, cmd)	capimsg_setu8(m, 5, cmd)
#define	CAPIMSG_SETMSGID(m, msgid)	capimsg_setu16(m, 6, msgid)
#define	CAPIMSG_SETCONTROL(m, contr)	capimsg_setu32(m, 8, contr)
#define	CAPIMSG_SETDATALEN(m, len)	capimsg_setu16(m, 16, len)


/*
 * The _cmsg structure contains all possible CAPI 2.0 parameter.
 * All parameters are stored here first. The function capi_cmsg2message()
 * assembles the parameter and builds CAPI2.0 conform messages.
 * capi_message2cmsg disassembles CAPI 2.0 messages and stores the
 * parameter in the _cmsg structure
 */

typedef struct {
	/* Header */
	_cword ApplId;
	_cbyte Command;
	_cbyte Subcommand;
	_cword Messagenumber;

	/* Parameter */
	union {
		_cdword adrController;
		_cdword adrPLCI;
		_cdword adrNCCI;
	} adr;

	_cmstruct AdditionalInfo;
	_cstruct B1configuration;
	_cword B1protocol;
	_cstruct B2configuration;
	_cword B2protocol;
	_cstruct B3configuration;
	_cword B3protocol;
	_cstruct BC;
	_cstruct BChannelinformation;
	_cmstruct BProtocol;
	_cstruct CalledPartyNumber;
	_cstruct CalledPartySubaddress;
	_cstruct CallingPartyNumber;
	_cstruct CallingPartySubaddress;
	_cdword CIPmask;
	_cdword CIPmask2;
	_cword CIPValue;
	_cdword Class;
	_cstruct ConnectedNumber;
	_cstruct ConnectedSubaddress;
	_cdword Data32;
	_cqword Data64;
	_cword DataHandle;
	_cword DataLength;
	_cstruct FacilityConfirmationParameter;
	_cstruct Facilitydataarray;
	_cstruct FacilityIndicationParameter;
	_cstruct FacilityRequestParameter;
	_cstruct FacilityResponseParameters;
	_cword FacilitySelector;
	_cword Flags;
	_cdword Function;
#ifndef CAPI_LIBRARY_V2
	_cstruct Globalconfiguration;
#endif
	_cstruct HLC;
	_cword Info;
	_cstruct InfoElement;
	_cdword InfoMask;
	_cword InfoNumber;
	_cstruct Keypadfacility;
	_cstruct LLC;
	_cstruct ManuData;
	_cdword ManuID;
	_cstruct NCPI;
	_cword Reason;
	_cword Reason_B3;
	_cword Reject;
	_cstruct Useruserdata;
#ifndef CAPI_LIBRARY_V2
	_cstruct SendingComplete;
#endif
	unsigned char *Data;

	/* intern */
	_cword l;
	unsigned p;
	unsigned char *par;
	_cbyte *m;

	/* buffer to construct message */
	_cbyte buf[180];

} _cmsg;


/*
 * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0
 * conform message
 */
#define capi20_cmsg2message	capi_cmsg2message
unsigned capi_cmsg2message(_cmsg *cmsg, unsigned char *msg);

/*
 *  capi20_message2cmsg disassembles a CAPI message an writes the parameter
 *  into _cmsg for easy access
 */
#define capi20_message2cmsg	capi_message2cmsg
unsigned capi_message2cmsg (_cmsg *cmsg, unsigned char *msg);

/*
 * capi20_cmsg_header() fills the _cmsg structure with default values,
 * so only parameter with non default values must be changed before
 * sending the message.
 */

#define CAPI_CMSG_HEADER	capi_cmsg_header
#define capi20_cmsg_header	capi_cmsg_header
unsigned capi_cmsg_header (_cmsg *cmsg, unsigned _ApplId, _cbyte _Command, _cbyte _Subcommand, _cword _Messagenumber, _cdword _Controller);

/*
 * capi_cmsg_answer() is used to answer indications. It changes the header
 * of an indication to a response, and leaves all other parameters the same
 */

#define capi20_cmsg_answer	capi_cmsg_answer

static inline void capi_cmsg_answer(_cmsg * cmsg)
{
	cmsg->Subcommand |= 0x01;
}

/*
 * capi_get_cmsg() works like capi20_get_message() and converts the
 * CAPI message * to a _cmsg with capi_message2cmsg().
 * Possible errors from capi20_get_message() will be returned.
 */

#define CAPI_GET_CMSG	capi_get_cmsg
#define capi20_get_cmsg	capi_get_cmsg
unsigned capi_get_cmsg(_cmsg *cmsg, unsigned applid);

/*
 * capi_put_cmsg() works like capi20_put_message() but it converts the
 * _cmsg * first with capi_cmsg2message(). Possible errors from
 * capi_put_message() will be returned.
 */

#define CAPI_PUT_CMSG	capi_put_cmsg
#define capi20_put_cmsg	capi_put_cmsg
unsigned capi_put_cmsg(_cmsg *cmsg);

/*-----------------------------------------------------------------------*/

/*
 * Debugging / Tracing functions
 */

/*
 * capi_info2str generated a readable string for Capi2.0 reasons.
 */
#define capi20_info2str	capi_info2str
char *capi_info2str(_cword reason);

#define capi20_cmd2str	capi_cmd2str
char *capi_cmd2str(_cbyte cmd, _cbyte subcmd);

/*
 * WARNING: The following two functions use a single static buffer and
 * are not thread-safe.
 */
#define capi20_cmsg2str	capi_cmsg2str
char *capi_cmsg2str(_cmsg * cmsg);

#define capi20_message2str capi_message2str
char *capi_message2str(_cbyte * msg);

/*-----------------------------------------------------------------------*/

#define ALERT_REQ_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define ALERT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional info elements */
#define ALERT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define ALERT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define ALERT_REQ_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define ALERT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define ALERT_CONF_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define ALERT_CONF_INFO(x) ((x)->Info)
		 /* 0: alert initiated */
		 /* 0x0003: alert already sent by another application */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal PLCI */
		 /* 0x2007: illegal message parameter coding */
#define CONNECT_REQ_CONTROLLER(x) ((x)->adr.adrController)
#define CONNECT_REQ_CIPVALUE(x) ((x)->CIPValue)
		 /* Compatibility Information Profile */
#define CONNECT_REQ_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber)
		 /* Called party number */
#define CONNECT_REQ_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber)
		 /* Calling party number */
#define CONNECT_REQ_CALLEDPARTYSUBADDRESS(x) ((x)->CalledPartySubaddress)
		 /* Called party subaddress */
#define CONNECT_REQ_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress)
		 /* Calling party subaddress */
#define CONNECT_REQ_BPROTOCOL(x) ((x)->BProtocol)
		 /* B protocol to be used */
#define CONNECT_REQ_B1PROTOCOL(x) ((x)->B1protocol)
		 /* Physical layer and framing */
#define CONNECT_REQ_B2PROTOCOL(x) ((x)->B2protocol)
		 /* Data link layer */
#define CONNECT_REQ_B3PROTOCOL(x) ((x)->B3protocol)
		 /* Network layer */
#define CONNECT_REQ_B1CONFIGURATION(x) ((x)->B1configuration)
		 /* Physical layer and framing parameter */
#define CONNECT_REQ_B2CONFIGURATION(x) ((x)->B2configuration)
		 /* Data link layer parameter */
#define CONNECT_REQ_B3CONFIGURATION(x) ((x)->B3configuration)
		 /* Network layer parameter */
#ifndef CAPI_LIBRARY_V2
#define CONNECT_REQ_GLOBALCONFIGURATION(x) ((x)->Globalconfiguration)
		 /* all layer parameter */
#endif
#define CONNECT_REQ_BC(x) ((x)->BC)
		 /* Bearer Capability */
#define CONNECT_REQ_LLC(x) ((x)->LLC)
		 /* Low Layer Compatibility */
#define CONNECT_REQ_HLC(x) ((x)->HLC)
		 /* High Layer Compatibility */
#define CONNECT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional information elements */
#define CONNECT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define CONNECT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_REQ_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define CONNECT_CONF_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_CONF_INFO(x) ((x)->Info)
		 /* 0: connect initiated */
		 /* 0x2002: illegal controller */
		 /* 0x2003: out of PLCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x3001: B1 protocol not supported */
		 /* 0x3002: B2 protocol not supported */
		 /* 0x3003: B3 protocol not supported */
		 /* 0x3004: B1 protocol parameter not supported */
		 /* 0x3005: B2 protocol parameter not supported */
		 /* 0x3006: B3 protocol parameter not supported */
		 /* 0x3007: B protocol combination not supported */
		 /* 0x300A: CIP Value unknown */
#define CONNECT_IND_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_IND_CIPVALUE(x) ((x)->CIPValue)
		 /* Compatibility Information Profile */
#define CONNECT_IND_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber)
		 /* Called party number */
#define CONNECT_IND_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber)
		 /* Calling party number */
#define CONNECT_IND_CALLEDPARTYSUBADDRESS(x) ((x)->CalledPartySubaddress)
		 /* Called party subaddress */
#define CONNECT_IND_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress)
		 /* Calling party subaddress */
#define CONNECT_IND_BC(x) ((x)->BC)
		 /* Bearer compatibility */
#define CONNECT_IND_LLC(x) ((x)->LLC)
		 /* Low Layer Compatibility */
#define CONNECT_IND_HLC(x) ((x)->HLC)
		 /* High Layer Compatibility */
#define CONNECT_IND_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional information elements */
#define CONNECT_IND_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define CONNECT_IND_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_IND_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_IND_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define CONNECT_RESP_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_RESP_REJECT(x) ((x)->Reject)
		 /* 0: accept call */
		 /* 1: ignore call */
		 /* 2: reject call, normal call clearing */
		 /* 3: reject call, user busy */
		 /* 4: reject call, requestet circuit/channel not available */
		 /* 5: reject call, facility rejected */
		 /* 6: reject call, channel unacceptable */
		 /* 7: reject call, incompatible destination */
		 /* 8: reject call, destination out of order */
#define CONNECT_RESP_BPROTOCOL(x) ((x)->BProtocol)
		 /* B protocol to be used */
#define CONNECT_RESP_B1PROTOCOL(x) ((x)->B1protocol)
		 /* Physical layer and framing */
#define CONNECT_RESP_B2PROTOCOL(x) ((x)->B2protocol)
		 /* Data link layer */
#define CONNECT_RESP_B3PROTOCOL(x) ((x)->B3protocol)
		 /* Network layer */
#define CONNECT_RESP_B1CONFIGURATION(x) ((x)->B1configuration)
		 /* Physical layer and framing parameter */
#define CONNECT_RESP_B2CONFIGURATION(x) ((x)->B2configuration)
		 /* Data link layer parameter */
#define CONNECT_RESP_B3CONFIGURATION(x) ((x)->B3configuration)
		 /* Network layer parameter */
#ifndef CAPI_LIBRARY_V2
#define CONNECT_RESP_GLOBALCONFIGURATION(x) ((x)->Globalconfiguration)
		 /* all layer parameter */
#endif
#define CONNECT_RESP_CONNECTEDNUMBER(x) ((x)->ConnectedNumber)
		 /* Connected number */
#define CONNECT_RESP_CONNECTEDSUBADDRESS(x) ((x)->ConnectedSubaddress)
		 /* Connected subaddress */
#define CONNECT_RESP_LLC(x) ((x)->LLC)
		 /* Low Layer Compatibility */
#define CONNECT_RESP_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional information elements */
#define CONNECT_RESP_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define CONNECT_RESP_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_RESP_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define CONNECT_RESP_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define CONNECT_ACTIVE_IND_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_ACTIVE_IND_CONNECTEDNUMBER(x) ((x)->ConnectedNumber)
		 /* Connected number */
#define CONNECT_ACTIVE_IND_CONNECTEDSUBADDRESS(x) ((x)->ConnectedSubaddress)
		 /* Connected subaddress */
#define CONNECT_ACTIVE_IND_LLC(x) ((x)->LLC)
		 /* Low Layer Compatibility */
#define CONNECT_ACTIVE_RESP_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_B3_ACTIVE_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_ACTIVE_IND_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define CONNECT_B3_ACTIVE_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_REQ_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define CONNECT_B3_REQ_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define CONNECT_B3_CONF_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_CONF_INFO(x) ((x)->Info)
		 /* 0: connect initiated */
		 /* 0x0001: NCPI not supported by current protocol, NCPI ignored */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal PLCI */
		 /* 0x2004: out of NCCI */
		 /* 0x3008: NCPI not supported */
#define CONNECT_B3_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_IND_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define CONNECT_B3_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_RESP_REJECT(x) ((x)->Reject)
		 /* 0: accept call */
		 /* 2: reject call, normal call clearing */
#define CONNECT_B3_RESP_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define CONNECT_B3_T90_ACTIVE_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define CONNECT_B3_T90_ACTIVE_IND_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define CONNECT_B3_T90_ACTIVE_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DATA_B3_REQ_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DATA_B3_REQ_DATA(x) ((x)->Data)
		 /* Pointer to the data to be sent */
#define DATA_B3_REQ_DATALENGTH(x) ((x)->DataLength)
		 /* Size of data area to be sent */
#define DATA_B3_REQ_DATAHANDLE(x) ((x)->DataHandle)
		 /* Referenced in DATA_B3_CONF */
#define DATA_B3_REQ_FLAGS(x) ((x)->Flags)
		 /* [0]: qualifier bit */
		 /* [1]: more data bit */
		 /* [2]: delivery confirmation bit */
		 /* [3]: expedited data */
		 /* [4] to [15]: reserved */
#define DATA_B3_CONF_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DATA_B3_CONF_DATAHANDLE(x) ((x)->DataHandle)
		 /* Identifies the data area of corresponding DATA_B3_REQ */
#define DATA_B3_CONF_INFO(x) ((x)->Info)
		 /* 0: data transmission initiated */
		 /* 0x0002: flags not supported by current protocol, flags ignored */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal NCCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x300A: flags not supported (reserved bits) */
		 /* 0x300C: data length not supported by current protocol */
#define DATA_B3_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DATA_B3_IND_DATA(x) ((x)->Data)
		 /* Pointer to data received */
#define DATA_B3_IND_DATALENGTH(x) ((x)->DataLength)
		 /* Size of data area received */
#define DATA_B3_IND_DATAHANDLE(x) ((x)->DataHandle)
		 /* handle to data area, referenced in DATA_B3_RESP */
#define DATA_B3_IND_FLAGS(x) ((x)->Flags)
		 /* 0: qualifier bit */
		 /* 1: more-data bit */
		 /* 2: delivery confirmation bit */
		 /* 3: expedited data */
		 /* 4 to 14: reserved */
		 /* [15]: framing error bit, data may be invalid (only with corresponding B2 protocol) */
#define DATA_B3_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DATA_B3_RESP_DATAHANDLE(x) ((x)->DataHandle)
		 /* Data area reference in corresponding DATA_B3_IND */
#define DISCONNECT_B3_REQ_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DISCONNECT_B3_REQ_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define DISCONNECT_B3_CONF_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DISCONNECT_B3_CONF_INFO(x) ((x)->Info)
		 /* 0: disconnect initiated */
		 /* 0x0001: NCPI not supported by current protocol, NCPI ignored */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal NCCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x3008: NCPI not supported */
#define DISCONNECT_B3_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DISCONNECT_B3_IND_REASON_B3(x) ((x)->Reason_B3)
		 /* 0: clearing according to protocol */
		 /* 0x3301: protocol error layer 1 */
		 /* 0x3302: protocol error layer 2 */
		 /* 0x3303: protocol error layer 3 */
		 /* protocol dependent values are described in chapter 6 */
#define DISCONNECT_B3_IND_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define DISCONNECT_B3_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define DISCONNECT_REQ_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define DISCONNECT_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional information elements */
#define DISCONNECT_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define DISCONNECT_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define DISCONNECT_REQ_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define DISCONNECT_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define DISCONNECT_CONF_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define DISCONNECT_CONF_INFO(x) ((x)->Info)
		 /* 0: disconnect initiated */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal PLCI */
		 /* 0x2007: illegal message parameter coding */
#define DISCONNECT_IND_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define DISCONNECT_IND_REASON(x) ((x)->Reason)
		 /* 0: no cause available */
		 /* 0x3301: protocol error layer 1 */
		 /* 0x3302: protocol error layer 2 */
		 /* 0x3303: protocol error layer 3 */
		 /* 0x3304: another application got that call */
		 /* 0x34xx: disconnect cause from the network according to Q.931/ETS 300 102-1. In the field 'xx' the cause value received within a cause information element (octet 4) from the network is indicated. */
#define DISCONNECT_RESP_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define FACILITY_REQ_CONTROLLER(x) ((x)->adr.adrController)
#define FACILITY_REQ_PLCI(x) ((x)->adr.adrPLCI)
#define FACILITY_REQ_NCCI(x) ((x)->adr.adrNCCI)
		 /* Depending on the facility selector */
#define FACILITY_REQ_FACILITYSELECTOR(x) ((x)->FacilitySelector)
		 /* 0: Handset Support */
		 /* 1: DTMF */
		 /* 2 to n: reserved */
#define FACILITY_REQ_FACILITYREQUESTPARAMETER(x) ((x)->FacilityRequestParameter)
		 /* Facility depending parameters */
#define FACILITY_CONF_CONTROLLER(x) ((x)->adr.adrController)
#define FACILITY_CONF_PLCI(x) ((x)->adr.adrPLCI)
#define FACILITY_CONF_NCCI(x) ((x)->adr.adrNCCI)
		 /* Depending on the facility selector */
#define FACILITY_CONF_INFO(x) ((x)->Info)
		 /* 0: request accepted */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: incorrect Controller/PLCI/NCCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x300B: facility not supported */
#define FACILITY_CONF_FACILITYSELECTOR(x) ((x)->FacilitySelector)
		 /* 0: Handset Support */
		 /* 1: DTMF */
		 /* 2 to n: reserved */
#define FACILITY_CONF_FACILITYCONFIRMATIONPARAMETER(x) ((x)->FacilityConfirmationParameter)
		 /* Facility-depending parameters */
#define FACILITY_IND_CONTROLLER(x) ((x)->adr.adrController)
#define FACILITY_IND_PLCI(x) ((x)->adr.adrPLCI)
#define FACILITY_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Depending on the facility selector */
#define FACILITY_IND_FACILITYSELECTOR(x) ((x)->FacilitySelector)
		 /* 0: Handset Support */
		 /* 1: DTMF */
		 /* 2 to n: reserved */
#define FACILITY_IND_FACILITYINDICATIONPARAMETER(x) ((x)->FacilityIndicationParameter)
		 /* Facility-depending parameters */
#define FACILITY_RESP_CONTROLLER(x) ((x)->adr.adrController)
#define FACILITY_RESP_PLCI(x) ((x)->adr.adrPLCI)
#define FACILITY_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Depending on the facility selector */
#define FACILITY_RESP_FACILITYSELECTOR(x) ((x)->FacilitySelector)
		 /* 0: Handset Support */
		 /* 1: DTMF */
		 /* 2 to n: reserved */
		 /* Facility response parameters */
		 /* struct */
		 /* Facility-depending parameters */
#define INFO_REQ_CONTROLLER(x) ((x)->adr.adrController)
#define INFO_REQ_PLCI(x) ((x)->adr.adrPLCI)
		 /* See note */
#define INFO_REQ_CALLEDPARTYNUMBER(x) ((x)->CalledPartyNumber)
		 /* Called party number */
#define INFO_REQ_ADDITIONALINFO(x) ((x)->AdditionalInfo)
		 /* Additional information elements */
#define INFO_REQ_BCHANNELINFORMATION(x) ((x)->BChannelinformation)
#define INFO_REQ_KEYPADFACILITY(x) ((x)->Keypadfacility)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define INFO_REQ_USERUSERDATA(x) ((x)->Useruserdata)
		 /* coded according to ETS 300 102-1 / Q.931 */
#define INFO_REQ_FACILITYDATAARRAY(x) ((x)->Facilitydataarray)
		 /* which is used to transfer additional parameters coded */
		 /* according to ETS 300 102-1 / Q.931 starting from octet 1.  */
		 /* This field is used to transport one or more complete facility  */
		 /* data information elements. */
#define INFO_CONF_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define INFO_CONF_INFO(x) ((x)->Info)
		 /* 0: transmission of information initiated */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal Controller/PLCI */
		 /* 0x2003: out of PLCI */
		 /* 0x2007: illegal message parameter coding */
#define INFO_IND_CONTROLLER(x) ((x)->adr.adrController)
#define INFO_IND_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define INFO_IND_INFONUMBER(x) ((x)->InfoNumber)
		 /* Information element identifier */
#define INFO_IND_INFOELEMENT(x) ((x)->InfoElement)
		 /* Information element dependent structure */
#define INFO_RESP_CONTROLLER(x) ((x)->adr.adrController)
#define INFO_RESP_PLCI(x) ((x)->adr.adrPLCI)
		 /* As in INFO_IND */
#define LISTEN_REQ_CONTROLLER(x) ((x)->adr.adrController)
#define LISTEN_REQ_INFOMASK(x) ((x)->InfoMask)
		 /* Bit field, coding as follows: */
		 /* 0: cause */
		 /* 1: date/Time */
		 /* 2: display */
		 /* 3: user-user information */
		 /* 4: call progression */
		 /* 5: facility */
		 /* 6: charging */
		 /* 7 to 31: reserved */
#define LISTEN_REQ_CIPMASK(x) ((x)->CIPmask)
		 /* Bit field, coding as follows: */
		 /* 0: any match */
		 /* 1: speech */
		 /* 2: unrestricted digital information */
		 /* 3: restricted digital information */
		 /* 4: 3.1 kHz audio */
		 /* 5: 7.0 kHz audio */
		 /* 6: video */
		 /* 7: packet mode */
		 /* 8: 56 kBit/s rate adaptation */
		 /* 9: unrestricted digital information with tones/announcements */
		 /* 10..15: reserved */
		 /* 16: telephony */
		 /* 17: fax group 2/3 */
		 /* 18: fax group 4 class 1 */
		 /* 19: Teletex service (basic and mixed), fax group 4 class 2 */
		 /* 20: Teletex service (basic and processable) */
		 /* 21: Teletex service (basic) */
		 /* 22: Videotex */
		 /* 23: Telex */
		 /* reserved for additional services */
		 /* 25: OSI applications according X.200 */
		 /* 26: 7 kHz Telephony */
		 /* 27: Video Telephony F.721, first connection */
		 /* 28: Video Telephony F.721, second connection */
		 /* 29 to 31: reserved */
#define LISTEN_REQ_CIPMASK2(x) ((x)->CIPmask2)
		 /* reserved for additional services */
#define LISTEN_REQ_CALLINGPARTYNUMBER(x) ((x)->CallingPartyNumber)
		 /* Calling party number */
#define LISTEN_REQ_CALLINGPARTYSUBADDRESS(x) ((x)->CallingPartySubaddress)
		 /* Calling party subaddress */
#define LISTEN_CONF_CONTROLLER(x) ((x)->adr.adrController)
#define LISTEN_CONF_INFO(x) ((x)->Info)
		 /* 0: listen is active */
		 /* 0x2002: illegal controller */
		 /* 0x2005: out of LISTEN-Resources */
		 /* 0x2007: illegal message parameter coding */
#define MANUFACTURER_REQ_CONTROLLER(x) ((x)->adr.adrController)
#define MANUFACTURER_REQ_MANUID(x) ((x)->ManuID)
		 /* Manufacturer specific ID (should be unique) */
		 /* Manufacturer specific */
#define MANUFACTURER_REQ_CLASS(x) ((x)->Class)
#define MANUFACTURER_REQ_FUNCTION(x) ((x)->Function)
#define MANUFACTURER_REQ_MANUDATA(x) ((x)->ManuData)
		 /* Manufacturer specific data */
#define MANUFACTURER_CONF_CONTROLLER(x) ((x)->adr.adrController)
#define MANUFACTURER_CONF_MANUID(x) ((x)->ManuID)
		 /* Manufacturer specific ID (should be unique) */
		 /* Manufacturer specific */
#define MANUFACTURER_CONF_CLASS(x) ((x)->Class)
#define MANUFACTURER_CONF_FUNCTION(x) ((x)->Function)
#define MANUFACTURER_CONF_MANUDATA(x) ((x)->ManuData)
		 /* Manufacturer specific data */
#define MANUFACTURER_IND_CONTROLLER(x) ((x)->adr.adrController)
#define MANUFACTURER_IND_MANUID(x) ((x)->ManuID)
		 /* Manufacturer specific ID (should be unique) */
		 /* Manufacturer specific */
#define MANUFACTURER_IND_CLASS(x) ((x)->Class)
#define MANUFACTURER_IND_FUNCTION(x) ((x)->Function)
#define MANUFACTURER_IND_MANUDATA(x) ((x)->ManuData)
		 /* Manufacturer specific data */
#define MANUFACTURER_RESP_CONTROLLER(x) ((x)->adr.adrController)
#define MANUFACTURER_RESP_MANUID(x) ((x)->ManuID)
		 /* Manufacturer specific ID (should be unique) */
		 /* Manufacturer specific */
#define MANUFACTURER_RESP_CLASS(x) ((x)->Class)
#define MANUFACTURER_RESP_FUNCTION(x) ((x)->Function)
#define MANUFACTURER_RESP_MANUDATA(x) ((x)->ManuData)
		 /* Manufacturer specific data */
#define RESET_B3_REQ_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define RESET_B3_REQ_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define RESET_B3_CONF_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define RESET_B3_CONF_INFO(x) ((x)->Info)
		 /* 0: reset initiated */
		 /* 0x0001: NCPI not supported by current protocol, NCPI ignored */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal NCCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x3008: NCPI not supported */
		 /* 0x300D: reset procedure not supported by current protocol */
#define RESET_B3_IND_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define RESET_B3_IND_NCPI(x) ((x)->NCPI)
		 /* Network Control Protocol Information */
#define RESET_B3_RESP_NCCI(x) ((x)->adr.adrNCCI)
		 /* Network Control Connection Identifier */
#define SELECT_B_PROTOCOL_REQ_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define SELECT_B_PROTOCOL_REQ_BPROTOCOL(x) ((x)->BProtocol)
		 /* Protocol definition */
#define SELECT_B_PROTOCOL_REQ_B1PROTOCOL(x) ((x)->B1protocol)
		 /* Physical layer and framing */
#define SELECT_B_PROTOCOL_REQ_B2PROTOCOL(x) ((x)->B2protocol)
		 /* Data link layer */
#define SELECT_B_PROTOCOL_REQ_B3PROTOCOL(x) ((x)->B3protocol)
		 /* Network layer */
#define SELECT_B_PROTOCOL_REQ_B1CONFIGURATION(x) ((x)->B1configuration)
		 /* Physical layer and framing parameter */
#define SELECT_B_PROTOCOL_REQ_B2CONFIGURATION(x) ((x)->B2configuration)
		 /* Data link layer parameter */
#define SELECT_B_PROTOCOL_REQ_B3CONFIGURATION(x) ((x)->B3configuration)
		 /* Network layer parameter */
#ifndef CAPI_LIBRARY_V2
#define SELECT_B_PROTOCOL_REQ_GLOBALCONFIGURATION(x) ((x)->Globalconfiguration)
		 /* all layer parameter */
#endif
#define SELECT_B_PROTOCOL_CONF_PLCI(x) ((x)->adr.adrPLCI)
		 /* Physical Link Connection Identifier */
#define SELECT_B_PROTOCOL_CONF_INFO(x) ((x)->Info)
		 /* 0: protocol switch successful */
		 /* 0x2001: message not supported in current state */
		 /* 0x2002: illegal PLCI */
		 /* 0x2007: illegal message parameter coding */
		 /* 0x3001: B1 protocol not supported */
		 /* 0x3002: B2 protocol not supported */
		 /* 0x3003: B3 protocol not supported */
		 /* 0x3004: B1 protocol parameter not supported */
		 /* 0x3005: B2 protocol parameter not supported */
		 /* 0x3006: B3 protocol parameter not supported */
		 /* 0x3007: B protocol combination not supported */

/*----- tests for specific commands -----*/

#define IS_CONNECT_IND(m) ((m)->Command==0x02 && (m)->Subcommand==0x82)
#define IS_CONNECT_ACTIVE_IND(m) ((m)->Command==0x03 && (m)->Subcommand==0x82)
#define IS_CONNECT_B3_ACTIVE_IND(m) ((m)->Command==0x83 && (m)->Subcommand==0x82)
#define IS_CONNECT_B3_IND(m) ((m)->Command==0x82 && (m)->Subcommand==0x82)
#define IS_CONNECT_B3_T90_ACTIVE_IND(m) ((m)->Command==0x88 && (m)->Subcommand==0x82)
#define IS_DATA_B3_IND(m) ((m)->Command==0x86 && (m)->Subcommand==0x82)
#define IS_DISCONNECT_B3_IND(m) ((m)->Command==0x84 && (m)->Subcommand==0x82)
#define IS_DISCONNECT_IND(m) ((m)->Command==0x04 && (m)->Subcommand==0x82)
#define IS_FACILITY_IND(m) ((m)->Command==0x80 && (m)->Subcommand==0x82)
#define IS_INFO_IND(m) ((m)->Command==0x08 && (m)->Subcommand==0x82)
#define IS_MANUFACTURER_IND(m) ((m)->Command==0xff && (m)->Subcommand==0x82)
#define IS_RESET_B3_IND(m) ((m)->Command==0x87 && (m)->Subcommand==0x82)
#define IS_ALERT_CONF(m) ((m)->Command==0x01 && (m)->Subcommand==0x81)
#define IS_CONNECT_CONF(m) ((m)->Command==0x02 && (m)->Subcommand==0x81)
#define IS_CONNECT_B3_CONF(m) ((m)->Command==0x82 && (m)->Subcommand==0x81)
#define IS_DATA_B3_CONF(m) ((m)->Command==0x86 && (m)->Subcommand==0x81)
#define IS_DISCONNECT_B3_CONF(m) ((m)->Command==0x84 && (m)->Subcommand==0x81)
#define IS_DISCONNECT_CONF(m) ((m)->Command==0x04 && (m)->Subcommand==0x81)
#define IS_FACILITY_CONF(m) ((m)->Command==0x80 && (m)->Subcommand==0x81)
#define IS_INFO_CONF(m) ((m)->Command==0x08 && (m)->Subcommand==0x81)
#define IS_LISTEN_CONF(m) ((m)->Command==0x05 && (m)->Subcommand==0x81)
#define IS_MANUFACTURER_CONF(m) ((m)->Command==0xff && (m)->Subcommand==0x81)
#define IS_RESET_B3_CONF(m) ((m)->Command==0x87 && (m)->Subcommand==0x81)
#define IS_SELECT_B_PROTOCOL_CONF(m) ((m)->Command==0x41 && (m)->Subcommand==0x81)

/*----- header functions that fill the _cmsg structure with default -----*/
/*----- values. Only nonstandard parameter need to be changed -----*/

#define ALERT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x01,0x80,Messagenumber,adr)
#define CONNECT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x02,0x80,Messagenumber,adr)
#define CONNECT_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x82,0x80,Messagenumber,adr)
#define DATA_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x86,0x80,Messagenumber,adr)
#define DISCONNECT_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x84,0x80,Messagenumber,adr)
#define DISCONNECT_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x04,0x80,Messagenumber,adr)
#define FACILITY_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x80,0x80,Messagenumber,adr)
#define INFO_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x08,0x80,Messagenumber,adr)
#define LISTEN_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x05,0x80,Messagenumber,adr)
#define MANUFACTURER_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0xff,0x80,Messagenumber,adr)
#define RESET_B3_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x87,0x80,Messagenumber,adr)
#define SELECT_B_PROTOCOL_REQ_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x41,0x80,Messagenumber,adr)
#define CONNECT_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x02,0x83,Messagenumber,adr)
#define CONNECT_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x03,0x83,Messagenumber,adr)
#define CONNECT_B3_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x83,0x83,Messagenumber,adr)
#define CONNECT_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x82,0x83,Messagenumber,adr)
#define CONNECT_B3_T90_ACTIVE_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x88,0x83,Messagenumber,adr)
#define DATA_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x86,0x83,Messagenumber,adr)
#define DISCONNECT_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x84,0x83,Messagenumber,adr)
#define DISCONNECT_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x04,0x83,Messagenumber,adr)
#define FACILITY_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x80,0x83,Messagenumber,adr)
#define INFO_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x08,0x83,Messagenumber,adr)
#define MANUFACTURER_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0xff,0x83,Messagenumber,adr)
#define RESET_B3_RESP_HEADER(cmsg,ApplId,Messagenumber,adr) \
		      CAPI_CMSG_HEADER(cmsg,ApplId,0x87,0x83,Messagenumber,adr)

/*
 * CAPI-functions that correspond to the CAPI messages specified in the
 * CAPI 2.0 specification. All possible parameter have to be specified.
 * The CAPI message is sent immediately when calling these functions,
 * return values are the same as in capi_put_message()
 */

unsigned ALERT_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct BChannelinformation
		,_cstruct Keypadfacility
		,_cstruct Useruserdata
		,_cstruct Facilitydataarra
#ifndef CAPI_LIBRARY_V2
		,_cstruct SendingComplete
#endif
		);
unsigned CONNECT_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword CIPValue
		,_cstruct CalledPartyNumber
		,_cstruct CallingPartyNumber
		,_cstruct CalledPartySubaddress
		,_cstruct CallingPartySubaddress
		,_cword B1protocol
		,_cword B2protocol
		,_cword B3protocol
		,_cstruct B1configuration
		,_cstruct B2configuration
		,_cstruct B3configuration
#ifndef CAPI_LIBRARY_V2
		,_cstruct Globalconfiguration
#endif
		,_cstruct BC
		,_cstruct LLC
		,_cstruct HLC
		,_cstruct BChannelinformation
		,_cstruct Keypadfacility
		,_cstruct Useruserdata
		,_cstruct Facilitydataarray
#ifndef CAPI_LIBRARY_V2
		,_cstruct SendingComplete
#endif
		);
unsigned CONNECT_B3_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct NCPI);
unsigned DATA_B3_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,void * Data
		,_cword DataLength
		,_cword DataHandle
		,_cword Flags);
unsigned DISCONNECT_B3_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct NCPI);
unsigned DISCONNECT_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct BChannelinformation
		,_cstruct Keypadfacility
		,_cstruct Useruserdata
		,_cstruct Facilitydataarray);
unsigned FACILITY_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword FacilitySelector
		,_cstruct FacilityRequestParameter);
unsigned INFO_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct CalledPartyNumber
		,_cstruct BChannelinformation
		,_cstruct Keypadfacility
		,_cstruct Useruserdata
		,_cstruct Facilitydataarray
#ifndef CAPI_LIBRARY_V2
		,_cstruct SendingComplete
#endif
		);
unsigned LISTEN_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cdword InfoMask
		,_cdword CIPmask
		,_cdword CIPmask2
		,_cstruct CallingPartyNumber
		,_cstruct CallingPartySubaddress);
unsigned MANUFACTURER_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cdword ManuID
		,_cdword Class
		,_cdword Function
		,_cstruct ManuData);
unsigned RESET_B3_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cstruct NCPI);
unsigned SELECT_B_PROTOCOL_REQ (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword B1protocol
		,_cword B2protocol
		,_cword B3protocol
		,_cstruct B1configuration
		,_cstruct B2configuration
		,_cstruct B3configuration
#ifndef CAPI_LIBRARY_V2
		,_cstruct Globalconfiguration
#endif
		);
unsigned CONNECT_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword Reject
		,_cword B1protocol
		,_cword B2protocol
		,_cword B3protocol
		,_cstruct B1configuration
		,_cstruct B2configuration
		,_cstruct B3configuration
#ifndef CAPI_LIBRARY_V2
		,_cstruct Globalconfiguration
#endif
		,_cstruct ConnectedNumber
		,_cstruct ConnectedSubaddress
		,_cstruct LLC
		,_cstruct BChannelinformation
		,_cstruct Keypadfacility
		,_cstruct Useruserdata
		,_cstruct Facilitydataarray);
unsigned CONNECT_ACTIVE_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned CONNECT_B3_ACTIVE_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned CONNECT_B3_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword Reject
		,_cstruct NCPI);
unsigned CONNECT_B3_T90_ACTIVE_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned DATA_B3_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword DataHandle);
unsigned DISCONNECT_B3_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned DISCONNECT_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned FACILITY_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cword FacilitySelector
		,_cstruct FacilityResponseParameters);
unsigned INFO_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);
unsigned MANUFACTURER_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr
		,_cdword ManuID
		,_cdword Class
		,_cdword Function
		,_cstruct ManuData);
unsigned RESET_B3_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber
		,_cdword adr);

/*-----------------------------------------------------------------------*/

static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					    _cdword adr,
					    _cstruct NCPI)
{
	capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr);
	cmsg->NCPI = NCPI;
}

static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					  _cdword adr,
					  _cword FacilitySelector,
				       _cstruct FacilityRequestParameter)
{
	capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr);
	cmsg->FacilitySelector = FacilitySelector;
	cmsg->FacilityRequestParameter = FacilityRequestParameter;
}

static inline void capi_fill_INFO_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
				      _cdword adr,
				      _cstruct CalledPartyNumber,
				      _cstruct BChannelinformation,
				      _cstruct Keypadfacility,
				      _cstruct Useruserdata,
				      _cstruct Facilitydataarray
#ifndef CAPI_LIBRARY_V2
				     ,_cstruct SendingComplete
#endif
				      )
{
	capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr);
	cmsg->CalledPartyNumber = CalledPartyNumber;
	cmsg->BChannelinformation = BChannelinformation;
	cmsg->Keypadfacility = Keypadfacility;
	cmsg->Useruserdata = Useruserdata;
	cmsg->Facilitydataarray = Facilitydataarray;
#ifndef CAPI_LIBRARY_V2
	cmsg->SendingComplete = SendingComplete;
#endif
}

static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					_cdword adr,
					_cdword InfoMask,
					_cdword CIPmask,
					_cdword CIPmask2,
					_cstruct CallingPartyNumber,
					_cstruct CallingPartySubaddress)
{
	capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr);
	cmsg->InfoMask = InfoMask;
	cmsg->CIPmask = CIPmask;
	cmsg->CIPmask2 = CIPmask2;
	cmsg->CallingPartyNumber = CallingPartyNumber;
	cmsg->CallingPartySubaddress = CallingPartySubaddress;
}

static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
				       _cdword adr,
				       _cstruct BChannelinformation,
				       _cstruct Keypadfacility,
				       _cstruct Useruserdata,
				       _cstruct Facilitydataarray
#ifndef CAPI_LIBRARY_V2
				       ,_cstruct SendingComplete
#endif
				       )
{
	capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr);
	cmsg->BChannelinformation = BChannelinformation;
	cmsg->Keypadfacility = Keypadfacility;
	cmsg->Useruserdata = Useruserdata;
	cmsg->Facilitydataarray = Facilitydataarray;
#ifndef CAPI_LIBRARY_V2
	cmsg->SendingComplete = SendingComplete;
#endif
}

static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					 _cdword adr,
					 _cword CIPValue,
					 _cstruct CalledPartyNumber,
					 _cstruct CallingPartyNumber,
					 _cstruct CalledPartySubaddress,
					 _cstruct CallingPartySubaddress,
					 _cword B1protocol,
					 _cword B2protocol,
					 _cword B3protocol,
					 _cstruct B1configuration,
					 _cstruct B2configuration,
					 _cstruct B3configuration,
#ifndef CAPI_LIBRARY_V2
					 _cstruct Globalconfiguration,
#endif
					 _cstruct BC,
					 _cstruct LLC,
					 _cstruct HLC,
					 _cstruct BChannelinformation,
					 _cstruct Keypadfacility,
					 _cstruct Useruserdata,
					 _cstruct Facilitydataarray
#ifndef CAPI_LIBRARY_V2
					 ,_cstruct SendingComplete
#endif
					 )
{

	capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr);
	cmsg->CIPValue = CIPValue;
	cmsg->CalledPartyNumber = CalledPartyNumber;
	cmsg->CallingPartyNumber = CallingPartyNumber;
	cmsg->CalledPartySubaddress = CalledPartySubaddress;
	cmsg->CallingPartySubaddress = CallingPartySubaddress;
	cmsg->B1protocol = B1protocol;
	cmsg->B2protocol = B2protocol;
	cmsg->B3protocol = B3protocol;
	cmsg->B1configuration = B1configuration;
	cmsg->B2configuration = B2configuration;
	cmsg->B3configuration = B3configuration;
#ifndef CAPI_LIBRARY_V2
	cmsg->Globalconfiguration = Globalconfiguration;
#endif
	cmsg->BC = BC;
	cmsg->LLC = LLC;
	cmsg->HLC = HLC;
	cmsg->BChannelinformation = BChannelinformation;
	cmsg->Keypadfacility = Keypadfacility;
	cmsg->Useruserdata = Useruserdata;
	cmsg->Facilitydataarray = Facilitydataarray;
#ifndef CAPI_LIBRARY_V2
	cmsg->SendingComplete = SendingComplete;
#endif
}

static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					 _cdword adr,
					 unsigned char *Data,
					 _cword DataLength,
					 _cword DataHandle,
					 _cword Flags)
{

	capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr);
	cmsg->Data = Data;
	cmsg->DataLength = DataLength;
	cmsg->DataHandle = DataHandle;
	cmsg->Flags = Flags;
}

static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					    _cdword adr,
					    _cstruct BChannelinformation,
					    _cstruct Keypadfacility,
					    _cstruct Useruserdata,
					    _cstruct Facilitydataarray)
{

	capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr);
	cmsg->BChannelinformation = BChannelinformation;
	cmsg->Keypadfacility = Keypadfacility;
	cmsg->Useruserdata = Useruserdata;
	cmsg->Facilitydataarray = Facilitydataarray;
#ifndef CAPI_LIBRARY_V2
	cmsg->SendingComplete = NULL;
#endif
}

static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					       _cdword adr,
					       _cstruct NCPI)
{

	capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr);
	cmsg->NCPI = NCPI;
}

static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					      _cdword adr,
					      _cdword ManuID,
					      _cdword Class,
					      _cdword Function,
					      _cstruct ManuData)
{

	capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr);
	cmsg->ManuID = ManuID;
	cmsg->Class = Class;
	cmsg->Function = Function;
	cmsg->ManuData = ManuData;
}

static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					  _cdword adr,
					  _cstruct NCPI)
{

	capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr);
	cmsg->NCPI = NCPI;
}

static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
						   _cdword adr,
						   _cword B1protocol,
						   _cword B2protocol,
						   _cword B3protocol,
						_cstruct B1configuration,
						_cstruct B2configuration,
						_cstruct B3configuration
#ifndef CAPI_LIBRARY_V2
						,_cstruct Globalconfiguration
#endif
						)
{

	capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr);
	cmsg->B1protocol = B1protocol;
	cmsg->B2protocol = B2protocol;
	cmsg->B3protocol = B3protocol;
	cmsg->B1configuration = B1configuration;
	cmsg->B2configuration = B2configuration;
	cmsg->B3configuration = B3configuration;
#ifndef CAPI_LIBRARY_V2
	cmsg->Globalconfiguration = Globalconfiguration;
#endif
}

static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					  _cdword adr,
					  _cword Reject,
					  _cword B1protocol,
					  _cword B2protocol,
					  _cword B3protocol,
					  _cstruct B1configuration,
					  _cstruct B2configuration,
					  _cstruct B3configuration,
#ifndef CAPI_LIBRARY_V2
					  _cstruct Globalconfiguration,
#endif
					  _cstruct ConnectedNumber,
					  _cstruct ConnectedSubaddress,
					  _cstruct LLC,
					  _cstruct BChannelinformation,
					  _cstruct Keypadfacility,
					  _cstruct Useruserdata,
					  _cstruct Facilitydataarray)
{
	capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr);
	cmsg->Reject = Reject;
	cmsg->B1protocol = B1protocol;
	cmsg->B2protocol = B2protocol;
	cmsg->B3protocol = B3protocol;
	cmsg->B1configuration = B1configuration;
	cmsg->B2configuration = B2configuration;
	cmsg->B3configuration = B3configuration;
#ifndef CAPI_LIBRARY_V2
	cmsg->Globalconfiguration = Globalconfiguration;
#endif
	cmsg->ConnectedNumber = ConnectedNumber;
	cmsg->ConnectedSubaddress = ConnectedSubaddress;
	cmsg->LLC = LLC;
	cmsg->BChannelinformation = BChannelinformation;
	cmsg->Keypadfacility = Keypadfacility;
	cmsg->Useruserdata = Useruserdata;
	cmsg->Facilitydataarray = Facilitydataarray;
}

static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
						 _cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr);
}

static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
						    _cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr);
}

static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					     _cdword adr,
					     _cword Reject,
					     _cstruct NCPI)
{
	capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr);
	cmsg->Reject = Reject;
	cmsg->NCPI = NCPI;
}

static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
							_cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr);
}

static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					  _cdword adr,
					  _cword DataHandle)
{

	capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr);
	cmsg->DataHandle = DataHandle;
}

static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
						_cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr);
}

static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					     _cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr);
}

static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					   _cdword adr,
					   _cword FacilitySelector)
{

	capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr);
	cmsg->FacilitySelector = FacilitySelector;
}

static inline void capi_fill_INFO_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
				       _cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr);
}

static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					       _cdword adr,
					       _cdword ManuID,
					       _cdword Class,
					       _cdword Function,
					       _cstruct ManuData)
{

	capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr);
	cmsg->ManuID = ManuID;
	cmsg->Class = Class;
	cmsg->Function = Function;
	cmsg->ManuData = ManuData;
}

static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber,
					   _cdword adr)
{

	capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr);
}

#ifdef __cplusplus
}
#endif

#endif /* __CAPIUTILS_H__ */