40 #define FILE_ "MESSAGE.C"
57 static dword diva_xdi_extended_features = 0;
59 #define DIVA_CAPI_USE_CMA 0x00000001
60 #define DIVA_CAPI_XDI_PROVIDES_SDRAM_BAR 0x00000002
61 #define DIVA_CAPI_XDI_PROVIDES_NO_CANCEL 0x00000004
62 #define DIVA_CAPI_XDI_PROVIDES_RX_DMA 0x00000008
68 #define DIVA_CAPI_SUPPORTS_NO_CANCEL(__a__) (((__a__)->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) && ((__a__)->manufacturer_features & MANUFACTURER_FEATURE_OK_FC_LABEL) && (diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_NO_CANCEL))
75 static void set_group_ind_mask(
PLCI *
plci);
89 static void plci_remove(
PLCI *);
98 static void sig_ind(
PLCI *);
105 static void nl_ind(
PLCI *);
144 static void send_req(
PLCI *);
145 static void send_data(
PLCI *);
146 static word plci_remove_check(
PLCI *);
158 static void channel_flow_control_remove(
PLCI *
plci);
162 static void channel_xmit_xon(
PLCI *
plci);
164 static void channel_xmit_extended_xon(
PLCI *
plci);
170 static void VoiceChannelOff(
PLCI *
plci);
171 static void adv_voice_write_coefs(
PLCI *
plci,
word write_command);
172 static void adv_voice_clear_config(
PLCI *
plci);
176 static void adjust_b1_facilities(
PLCI *
plci,
byte new_b1_resource,
word new_b1_facilities);
189 static void init_b1_config(
PLCI *
plci);
190 static void clear_b1_config(
PLCI *
plci);
196 static void dtmf_parameter_write(
PLCI *
plci);
199 static void mixer_set_bchannel_id_esc(
PLCI *
plci,
byte bchannel_id);
200 static void mixer_set_bchannel_id(
PLCI *
plci,
byte *chi);
201 static void mixer_clear_config(
PLCI *
plci);
202 static void mixer_notify_update(
PLCI *
plci,
byte others);
205 static void mixer_indication_coefs_set(
dword Id,
PLCI *
plci);
208 static void mixer_remove(
PLCI *
plci);
220 static int diva_get_dma_descriptor(
PLCI *
plci,
dword *dma_magic);
221 static void diva_free_dma_descriptor(
PLCI *
plci,
int nr);
229 #define MapId(Id)(((Id) & 0xffffff00L) | MapController((byte)(Id)))
230 #define UnMapId(Id)(((Id) & 0xffffff00L) | UnMapController((byte)(Id)))
255 static byte remove_started =
false;
256 static PLCI dummy_plci;
259 static struct _ftable {
292 static byte *cip_bc[29][2] = {
294 {
"\x03\x80\x90\xa3",
"\x03\x80\x90\xa2" },
295 {
"\x02\x88\x90",
"\x02\x88\x90" },
296 {
"\x02\x89\x90",
"\x02\x89\x90" },
297 {
"\x03\x90\x90\xa3",
"\x03\x90\x90\xa2" },
298 {
"\x03\x91\x90\xa5",
"\x03\x91\x90\xa5" },
299 {
"\x02\x98\x90",
"\x02\x98\x90" },
300 {
"\x04\x88\xc0\xc6\xe6",
"\x04\x88\xc0\xc6\xe6" },
301 {
"\x04\x88\x90\x21\x8f",
"\x04\x88\x90\x21\x8f" },
302 {
"\x03\x91\x90\xa5",
"\x03\x91\x90\xa5" },
310 {
"\x03\x80\x90\xa3",
"\x03\x80\x90\xa2" },
311 {
"\x03\x90\x90\xa3",
"\x03\x90\x90\xa2" },
312 {
"\x02\x88\x90",
"\x02\x88\x90" },
313 {
"\x02\x88\x90",
"\x02\x88\x90" },
314 {
"\x02\x88\x90",
"\x02\x88\x90" },
315 {
"\x02\x88\x90",
"\x02\x88\x90" },
316 {
"\x02\x88\x90",
"\x02\x88\x90" },
317 {
"\x02\x88\x90",
"\x02\x88\x90" },
318 {
"\x02\x88\x90",
"\x02\x88\x90" },
319 {
"\x02\x88\x90",
"\x02\x88\x90" },
320 {
"\x03\x91\x90\xa5",
"\x03\x91\x90\xa5" },
321 {
"\x03\x91\x90\xa5",
"\x03\x91\x90\xa5" },
322 {
"\x02\x88\x90",
"\x02\x88\x90" }
325 static byte *cip_hlc[29] = {
360 #define V120_HEADER_LENGTH 1
361 #define V120_HEADER_EXTEND_BIT 0x80
362 #define V120_HEADER_BREAK_BIT 0x40
363 #define V120_HEADER_C1_BIT 0x04
364 #define V120_HEADER_C2_BIT 0x08
365 #define V120_HEADER_FLUSH_COND (V120_HEADER_BREAK_BIT | V120_HEADER_C1_BIT | V120_HEADER_C2_BIT)
367 static byte v120_default_header[] =
374 static byte v120_break_header[] =
405 controller = (
byte)((msg->
header.controller & 0x7f) - 1);
420 ncci = GET_WORD(&msg->
header.ncci);
452 dbug(0,
dprintf(
"Q-FULL1(msg) - len=%d write=%d read=%d wrap=%d free=%d",
467 if (msg->
header.length < 20)
494 dbug(0,
dprintf(
"Q-FULL2(data) - pending=%d/%d ack_pending=%d/%d",
523 dbug(1,
dprintf(
"enqueue msg(0x%04x,0x%x,0x%x) - len=%d write=%d read=%d wrap=%d free=%d",
530 for (i = 0; i < msg->
header.length; i++)
539 j = (j + 3) & 0xfffc;
559 if (!api_parse(msg->
info.
b, (
word)(msg->
header.length - 12), ftable[i].format, msg_parms)) {
563 for (j = 0; j < MAX_MSG_PARMS + 1; j++) msg_parms[j].
length = 0;
573 c = ftable[
i].function(GET_DWORD(&msg->
header.controller),
580 channel_xmit_extended_xon(plci);
582 if (c == 1) send_req(plci);
598 for (i = 0, p = 0; format[
i]; i++) {
614 if (msg[p] == 0xff) {
616 parms[
i].
length = msg[p + 1] + (msg[p + 2] << 8);
626 if (p > length)
return true;
638 for (i = 0; format[
i] !=
'\0'; i++)
657 for (j = 0; j <
n; j++)
686 if (!remove_started) {
687 remove_started =
true;
690 for (j = 0; j < adapter[
i].
max_plci; j++) {
691 if (adapter[i].
plci[j].Sig.Id) plci_remove(&adapter[i].
plci[j]);
700 for (j = 0; j < adapter[
i].
max_plci; j++) {
701 if (adapter[i].
plci[j].Sig.Id)
return 1;
715 static void init_internal_command_queue(
PLCI *
plci)
719 dbug(1,
dprintf(
"%s,%d: init_internal_command_queue",
720 (
char *)(
FILE_), __LINE__));
732 dbug(1,
dprintf(
"[%06lx] %s,%d: start_internal_command",
738 (*command_function)(Id,
plci,
OK);
750 static void next_internal_command(
dword Id,
PLCI *plci)
754 dbug(1,
dprintf(
"[%06lx] %s,%d: next_internal_command",
765 if (plci->internal_command != 0)
767 plci->internal_command_queue[0] =
NULL;
776 static dword ncci_mapping_bug = 0;
787 dbug(1,
dprintf(
"NCCI mapping exists %ld %02x %02x %02x-%02x",
824 dbug(1,
dprintf(
"NCCI mapping overflow %ld %02x %02x %02x-%02x-%02x",
825 ncci_mapping_bug, ch, force_ncci, i, k, j));
829 dbug(1,
dprintf(
"NCCI mapping overflow %ld %02x %02x",
830 ncci_mapping_bug, ch, force_ncci));
845 dbug(1,
dprintf(
"NCCI mapping established %ld %02x %02x %02x-%02x",
846 ncci_mapping_bug, ch, force_ncci, ch, ncci));
852 static void ncci_free_receive_buffers(
PLCI *plci,
word ncci)
860 Id = (((
dword) ncci) << 16) | (((
word)(plci->
Id)) << 8) | a->
Id;
868 dbug(1,
dprintf(
"NCCI mapping appl expected %ld %08lx",
869 ncci_mapping_bug, Id));
874 ncci_code = ncci | (((
word) a->
Id) << 8);
877 if ((appl->
DataNCCI[i] == ncci_code)
888 for (ncci = 1; ncci <
MAX_NCCI + 1; ncci++)
896 ncci_mapping_bug, Id));
901 ncci_code = ncci | (((
word) a->
Id) << 8);
904 if ((appl->
DataNCCI[i] == ncci_code)
917 static void cleanup_ncci_data(
PLCI *plci,
word ncci)
944 static void ncci_remove(
PLCI *plci,
word ncci,
byte preserve_ncci)
951 Id = (((
dword) ncci) << 16) | (((
word)(plci->
Id)) << 8) | a->
Id;
953 ncci_free_receive_buffers(plci, ncci);
959 dbug(1,
dprintf(
"NCCI mapping doesn't exist %ld %08lx %02x",
960 ncci_mapping_bug, Id, preserve_ncci));
964 cleanup_ncci_data(plci, ncci);
965 dbug(1,
dprintf(
"NCCI mapping released %ld %08lx %02x %02x-%02x",
966 ncci_mapping_bug, Id, preserve_ncci, a->
ncci_ch[ncci], ncci));
976 if ((i != 0) && (a->
ncci_next[i] == ncci))
990 for (ncci = 1; ncci < MAX_NCCI + 1; ncci++)
994 cleanup_ncci_data(plci, ncci);
995 dbug(1,
dprintf(
"NCCI mapping released %ld %08lx %02x %02x-%02x",
996 ncci_mapping_bug, Id, preserve_ncci, a->
ncci_ch[ncci], ncci));
1017 static void plci_free_msg_in_queue(
PLCI *plci)
1047 static void plci_remove(
PLCI *plci)
1054 init_internal_command_queue(plci);
1056 if (plci_remove_check(plci))
1060 if (plci->
Sig.
Id == 0xff)
1065 nl_req_ncci(plci,
REMOVE, 0);
1076 sig_req(plci,
HANGUP, 0);
1080 ncci_remove(plci, 0,
false);
1081 plci_free_msg_in_queue(plci);
1093 static void set_group_ind_mask(
PLCI *plci)
1101 static void clear_group_ind_mask_bit(
PLCI *plci,
word b)
1115 static void clear_c_ind_mask(
PLCI *plci)
1123 static byte c_ind_mask_empty(
PLCI *plci)
1133 static void set_c_ind_mask_bit(
PLCI *plci,
word b)
1138 static void clear_c_ind_mask_bit(
PLCI *plci,
word b)
1148 static void dump_c_ind_mask(
PLCI *plci)
1150 static char hex_digit_table[0x10] =
1151 {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
1161 for (j = 0; j < 4; j++)
1163 if (i + j < C_IND_MASK_DWORDS)
1166 for (k = 0; k < 8; k++)
1168 *(--
p) = hex_digit_table[d & 0xf];
1174 for (k = 0; k < 8; k++)
1187 #define dump_plcis(a)
1208 static byte esc_chi[35] = {0x02, 0x18, 0x01};
1209 static byte lli[2] = {0x01, 0x00};
1214 for (i = 0; i < 5; i++) ai_parms[i].length = 0;
1223 Id = ((
word)1 << 8) | a->
Id;
1229 if ((i = get_plci(a)))
1232 plci = &a->
plci[i - 1];
1238 if (AdvCodecSupport(a, plci, appl, 0))
1253 if (!api_parse(&ai->
info[1], (
word)ai->
length,
"ssss", ai_parms))
1256 if (ai_parms[0].length)
1258 ch = GET_WORD(ai_parms[0].
info + 1);
1263 if ((ai_parms[0].
info)[3] >= 1)
1265 if ((ai_parms[0].info)[4] ==
CHI)
1267 p_chi = &((ai_parms[0].
info)[5]);
1271 p_chi = &((ai_parms[0].
info)[3]);
1281 if (ch == 3 && ai_parms[0].length >= 7 && ai_parms[0].length <= 36)
1283 dir = GET_WORD(ai_parms[0].
info + 3);
1286 for (i = 0; i + 5 <= ai_parms[0].
length; i++)
1288 if (ai_parms[0].
info[i + 5] != 0)
1290 if ((ai_parms[0].
info[i + 5] | m) != 0xff)
1305 if ((ai_parms[0].length == 36) || (ch_mask != ((
dword)(1
L << channel))))
1307 esc_chi[0] = (
byte)(ai_parms[0].length - 2);
1308 for (i = 0; i + 5 <= ai_parms[0].
length; i++)
1309 esc_chi[i + 3] = ai_parms[0].
info[i + 5];
1313 esc_chi[2] = (
byte)channel;
1315 add_p(plci,
LLI, lli);
1316 add_p(plci,
ESC, esc_chi);
1326 dbug(1,
dprintf(
"ch=%x,dir=%x,p_ch=%d", ch, dir, channel));
1330 if (ch == 1 && LinkLayer != 3 && LinkLayer != 12) noCh =
true;
1331 if ((ch == 0 || ch == 2 || noCh || ch == 3 || ch == 4) && !Info)
1335 if (noCh) Info = add_b1(plci, &parms[5], 2, 0);
1336 else Info = add_b1(plci, &parms[5], ch, 0);
1337 add_s(plci,
OAD, &parms[2]);
1338 add_s(plci,
OSA, &parms[4]);
1339 add_s(plci,
BC, &parms[6]);
1340 add_s(plci,
LLC, &parms[7]);
1341 add_s(plci,
HLC, &parms[8]);
1345 add_p(plci,
LLI,
"\x01\x01");
1347 if (GET_WORD(parms[0].
info) < 29) {
1348 add_p(plci,
BC, cip_bc[GET_WORD(parms[0].info)][a->
u_law]);
1349 add_p(plci,
HLC, cip_hlc[GET_WORD(parms[0].info)]);
1351 add_p(plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
1357 plci->
Sig.
Id = 0xff;
1361 if (!Info && ch != 2 && !noCh) {
1362 Info = add_b23(plci, &parms[5]);
1370 if (ch == 0 || ch == 2 || ch == 3 || noCh || ch == 4)
1374 api_save_msg(parms,
"wsssssssss", &plci->
saved_msg);
1382 if (ch == 4)add_p(plci,
CHI, p_chi);
1383 add_s(plci,
CPN, &parms[1]);
1384 add_s(plci,
DSA, &parms[3]);
1385 if (noCh) add_p(plci,
ESC,
"\x02\x18\xfd");
1386 add_ai(plci, &parms[9]);
1387 if (!dir)sig_req(plci,
CALL_REQ, 0);
1416 static byte cau_t[] = {0, 0, 0x90, 0x91, 0xac, 0x9d, 0x86, 0xd8, 0x9b};
1417 static byte esc_t[] = {0x03, 0x08, 0x00, 0x00};
1428 for (i = 0; i < 5; i++) ai_parms[i].length = 0;
1434 if (!api_parse(&ai->
info[1], (
word)ai->
length,
"ssss", ai_parms))
1436 dbug(1,
dprintf(
"ai_parms[0].length=%d/0x%x", ai_parms[0].length, GET_WORD(ai_parms[0].
info + 1)));
1438 if (ai_parms[0].length)
1440 ch = GET_WORD(ai_parms[0].
info + 1);
1452 add_p(plci,
LLI,
"\x01\x01");
1454 add_s(plci,
CONN_NR, &parms[2]);
1455 add_s(plci,
LLC, &parms[4]);
1456 add_ai(plci, &parms[5]);
1462 clear_c_ind_mask_bit(plci, (
word)(appl->
Id - 1));
1463 dump_c_ind_mask(plci);
1464 Reject = GET_WORD(parms[0].
info);
1468 if (c_ind_mask_empty(plci))
1470 if ((Reject & 0xff00) == 0x3400)
1472 esc_t[2] = ((
byte)(Reject & 0x00ff)) | 0x80;
1473 add_p(plci,
ESC, esc_t);
1474 add_ai(plci, &parms[5]);
1475 sig_req(plci,
REJECT, 0);
1477 else if (Reject == 1 || Reject > 9)
1479 add_ai(plci, &parms[5]);
1480 sig_req(plci,
HANGUP, 0);
1484 esc_t[2] = cau_t[(Reject&0x000f)];
1485 add_p(plci,
ESC, esc_t);
1486 add_ai(plci, &parms[5]);
1487 sig_req(plci,
REJECT, 0);
1499 if (AdvCodecSupport(a, plci, appl, 0)) {
1500 dbug(1,
dprintf(
"connect_res(error from AdvCodecSupport)"));
1501 sig_req(plci,
HANGUP, 0);
1506 Info = add_b23(plci, &parms[1]);
1509 dbug(1,
dprintf(
"connect_res(error from add_b23)"));
1510 sig_req(plci,
HANGUP, 0);
1515 nl_req_ncci(plci,
ASSIGN, 0);
1524 Info = add_b23(plci, &parms[1]);
1527 dbug(1,
dprintf(
"connect_res(error from add_b23 2)"));
1528 sig_req(plci,
HANGUP, 0);
1532 nl_req_ncci(plci,
ASSIGN, 0);
1537 api_save_msg(parms,
"wsssss", &plci->
saved_msg);
1549 add_p(plci,
LLI,
"\x01\x01");
1551 add_s(plci,
CONN_NR, &parms[2]);
1552 add_s(plci,
LLC, &parms[4]);
1553 add_ai(plci, &parms[5]);
1559 if (test_c_ind_mask_bit(plci, i)) {
1589 clear_c_ind_mask_bit(plci, (
word)(appl->
Id - 1));
1593 if (test_c_ind_mask_bit(plci, i))
1601 if (plci->
Sig.
Id != 0xff)
1605 add_ai(plci, &msg[0]);
1606 sig_req(plci,
HANGUP, 0);
1616 nl_req_ncci(plci,
REMOVE, 0);
1626 if (!appl)
return false;
1639 clear_c_ind_mask_bit(plci, (
word)(appl->
Id - 1));
1640 ncci_free_receive_buffers(plci, 0);
1641 if (plci_remove_check(plci))
1647 if (c_ind_mask_empty(plci)) {
1678 if (Id&EXT_CONTROLLER && GET_DWORD(parms[1].
info)) {
1683 for (i = 1; parms[3].
length >= i && i < 22; i++) {
1688 for (i = 1; parms[4].
length >= i && i < 22; i++) {
1705 if (a) listen_check(a);
1719 for (i = 0; i < 5; i++) ai_parms[i].length = 0;
1736 if (!ai_parms[3].length && plci->
State && (msg[0].
length || ai_parms[1].
length))
1740 add_s(plci,
CPN, &msg[0]);
1741 add_s(plci,
KEY, &ai_parms[1]);
1751 add_s(plci,
UUI, &ai_parms[2]);
1758 add_s(plci,
CPN, &msg[0]);
1759 add_ai(plci, &msg[1]);
1767 else if ((ai_parms[1].length || ai_parms[2].length || ai_parms[3].length) && !Info)
1771 if ((i = get_plci(a)))
1773 rc_plci = &a->
plci[i - 1];
1776 rc_plci->
appl = appl;
1777 add_p(rc_plci,
CAI,
"\x01\x80");
1778 add_p(rc_plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
1789 add_s(rc_plci,
CPN, &msg[0]);
1790 add_ai(rc_plci, &msg[1]);
1843 add_ai(plci, &msg[0]);
1865 long relatedPLCIvalue;
1868 byte RCparms[] =
"\x05\x00\x00\x02\x00\x00";
1869 byte SSstruct[] =
"\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00";
1878 for (i = 0; i < 9; i++) ss_parms[i].length = 0;
1888 selector = GET_WORD(msg[0].info);
1904 SSreq = GET_WORD(&(msg[1].info[1]));
1905 PUT_WORD(&RCparms[1], SSreq);
1910 if ((i = get_plci(a)))
1912 rplci = &a->
plci[i - 1];
1914 add_p(rplci,
CAI,
"\x01\x80");
1915 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
1922 SSparms = (
byte *)SSstruct;
1936 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbd", ss_parms))
1951 if ((i = get_plci(a)))
1953 rplci = &a->
plci[i - 1];
1955 add_p(rplci,
CAI,
"\x01\x80");
1956 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
1977 add_s(plci,
CAI, &ss_parms[1]);
1987 if (Id & EXT_CONTROLLER)
1989 if (AdvCodecSupport(a, plci, appl, 0))
2019 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbs", ss_parms))
2026 if (plci && plci->
State)
2028 add_s(plci,
CAI, &ss_parms[2]);
2038 if (!(i = get_plci(a)))
2043 rplci = &a->
plci[i - 1];
2049 if (Id & EXT_CONTROLLER)
2051 if (AdvCodecSupport(a, rplci, appl, 0))
2060 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbs", ss_parms))
2069 dummy.
info =
"\x00";
2070 add_b1(rplci, &dummy, 0, 0);
2074 add_p(rplci,
LLI,
"\x01\x01");
2076 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
2079 add_s(rplci,
CAI, &ss_parms[2]);
2081 sig_req(rplci,
RESUME, 0);
2090 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbd", ss_parms))
2098 d = GET_DWORD(ss_parms[2].info);
2128 add_p(plci,
CAI, cai);
2142 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbd", ss_parms))
2149 else if (parms->
length == 8)
2151 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbdb", ss_parms))
2173 relatedPLCIvalue = GET_DWORD(ss_parms[2].info);
2174 relatedPLCIvalue &= 0x0000FFFF;
2175 dbug(1,
dprintf(
"PTY/ECT/addCONF,relPLCI=%lx", relatedPLCIvalue));
2177 if (((relatedPLCIvalue & 0x7f) == 0)
2183 dbug(1,
dprintf(
"wrong Controller use 2nd PLCI=PLCI"));
2195 relatedPLCIvalue >>= 8;
2197 for (i = 0, rplci =
NULL; i < relatedadapter->
max_plci; i++)
2199 if (relatedadapter->
plci[i].
Id == (
byte)relatedPLCIvalue)
2201 rplci = &relatedadapter->
plci[
i];
2204 if (!rplci || !relatedPLCIvalue)
2256 cai[1] = (
byte)(SSreq - 3);
2262 cai[2] = plci->
Sig.
Id;
2270 add_p(rplci,
CAI, cai);
2284 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbwss", ss_parms))
2296 ss_parms[3].
info[3] = (
byte)GET_WORD(&(ss_parms[2].info[0]));
2302 add_p(plci,
CAI, cai);
2303 add_p(plci,
CPN, ss_parms[3].info);
2310 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbdwwsss", ss_parms))
2317 if ((i = get_plci(a)))
2319 rplci = &a->
plci[i - 1];
2321 add_p(rplci,
CAI,
"\x01\x80");
2322 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
2336 appl->
S_Handle = GET_DWORD(&(ss_parms[2].info[0]));
2338 cai[1] = 0x70 | (
byte)GET_WORD(&(ss_parms[3].info[0]));
2339 cai[2] = (
byte)GET_WORD(&(ss_parms[4].info[0]));
2340 add_p(rplci,
CAI, cai);
2341 add_p(rplci,
OAD, ss_parms[5].info);
2342 add_p(rplci,
CPN, ss_parms[6].info);
2357 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbd", ss_parms))
2365 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbdw", ss_parms))
2372 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbdws", ss_parms))
2379 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbdwws", ss_parms))
2389 if ((i = get_plci(a)))
2391 rplci = &a->
plci[i - 1];
2395 cai[1] = 0x60 | (
byte)GET_WORD(&(ss_parms[3].info[0]));
2404 cai[1] = 0x80 | (
byte)GET_WORD(&(ss_parms[3].info[0]));
2424 add_p(rplci,
CAI,
"\x01\x80");
2425 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
2435 appl->
S_Handle = GET_DWORD(&(ss_parms[2].info[0]));
2440 add_p(rplci,
CAI, cai);
2445 PUT_WORD(&cai[2], GET_WORD(&(ss_parms[3].info[0])));
2446 add_p(rplci,
CAI, cai);
2450 PUT_WORD(&cai[2], GET_WORD(&(ss_parms[3].info[0])));
2451 add_p(rplci,
CAI, cai);
2452 add_p(rplci,
OAD, ss_parms[4].info);
2456 cai[2] = (
byte)GET_WORD(&(ss_parms[4].info[0]));
2457 add_p(rplci,
CAI, cai);
2458 add_p(rplci,
OAD, ss_parms[5].info);
2468 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbwdwwwssss", ss_parms))
2476 if ((i = get_plci(a)))
2478 rplci = &a->
plci[i - 1];
2481 add_p(rplci,
CAI,
"\x01\x80");
2482 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
2505 PUT_WORD(&cai[2], GET_WORD(&(ss_parms[2].info[0])));
2506 PUT_DWORD(&cai[4], GET_DWORD(&(ss_parms[3].info[0])));
2507 PUT_WORD(&cai[8], GET_WORD(&(ss_parms[4].info[0])));
2508 PUT_WORD(&cai[10], GET_WORD(&(ss_parms[5].info[0])));
2509 PUT_WORD(&cai[12], GET_WORD(&(ss_parms[6].info[0])));
2510 add_p(rplci,
CAI, cai);
2511 add_p(rplci,
CPN, ss_parms[7].info);
2512 add_p(rplci,
OAD, ss_parms[8].info);
2513 add_p(rplci,
OSA, ss_parms[9].info);
2514 add_p(rplci,
UID, ss_parms[10].info);
2520 if (api_parse(&parms->
info[1], (
word)parms->
length,
"wbwwss", ss_parms))
2528 if ((i = get_plci(a)))
2530 rplci = &a->
plci[i - 1];
2533 add_p(rplci,
CAI,
"\x01\x80");
2534 add_p(rplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
2557 PUT_WORD(&cai[2], GET_WORD(&(ss_parms[2].info[0])));
2558 PUT_WORD(&cai[4], GET_WORD(&(ss_parms[3].info[0])));
2559 add_p(rplci,
CAI, cai);
2560 add_p(rplci,
CPN, ss_parms[4].info);
2561 add_p(rplci,
OAD, ss_parms[5].info);
2574 return (dtmf_request(Id, Number, a, plci, appl, msg));
2579 return (mixer_request(Id, Number, a, plci, appl, msg));
2585 return (ec_request(Id, Number, a, plci, appl, msg));
2589 return (ec_request(Id, Number, a, plci, appl, msg));
2604 "wws", Info, selector, SSparms);
2622 word fax_control_bits, fax_feature_bits, fax_info_change;
2651 dbug(1,
dprintf(
"B3 already connected=%d or no NL.Id=0x%x, dir=%d sstate=0x%x",
2670 if (ncpi->
info[2] || ncpi->
info[3])
2672 pvc[0] = ncpi->
info[3];
2673 pvc[1] = ncpi->
info[2];
2674 add_d(plci, 2, pvc);
2694 fax_info_change =
false;
2697 w = GET_WORD(&ncpi->
info[3]);
2703 fax_info_change =
true;
2715 w = GET_WORD(&ncpi->
info[5]);
2719 fax_info_change =
true;
2723 && (GET_WORD(&ncpi->
info[5]) & 0x8000))
2728 && (GET_WORD(&ncpi->
info[5]) & 0x4000))
2737 if (api_parse(&ncpi->
info[1], ncpi->
length,
"wwwwsss", fax_parms))
2752 for (i = 0; i <
w; i++)
2760 for (i = 0; i <
w; i++)
2766 for (i = 0; i <
w; i++)
2771 if (api_parse(&ncpi->
info[1], ncpi->
length,
"wwwwssss", fax_parms))
2773 dbug(1,
dprintf(
"non-standard facilities info missing or wrong format"));
2778 if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
2781 for (i = 0; i < fax_parms[7].
length; i++)
2791 fax_info_change =
true;
2797 fax_info_change =
true;
2803 if (fax_info_change)
2805 if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)
2807 start_internal_command(Id, plci, fax_connect_info_command);
2812 start_internal_command(Id, plci, fax_adjust_b23_command);
2827 for (w = 0; w < ncpi->
length; w++)
2829 start_internal_command(Id, plci, rtp_connect_b3_req_command);
2835 nl_req_ncci(plci, req, 0);
2867 ncci = (
word)(Id >> 16);
2870 if (GET_WORD(&parms[0].info[0]) != 0)
2873 channel_request_xon(plci, a->
ncci_ch[ncci]);
2874 channel_xmit_xon(plci);
2875 cleanup_ncci_data(plci, ncci);
2899 if (api_parse(&ncpi->
info[1], ncpi->
length,
"wwwwssss", fax_parms))
2901 dbug(1,
dprintf(
"non-standard facilities info missing or wrong format"));
2911 if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
2914 for (i = 0; i < fax_parms[7].
length; i++)
2919 start_internal_command(Id, plci, fax_connect_ack_command);
2924 nl_req_ncci(plci, req, (
byte)ncci);
2940 for (w = 0; w < ncpi->
length; w++)
2942 start_internal_command(Id, plci, rtp_connect_b3_res_command);
2952 nl_req_ncci(plci, req, (
byte)ncci);
2957 start_internal_command(Id, plci, adjust_b_restore);
2971 ncci = (
word)(Id >> 16);
2972 dbug(1,
dprintf(
"connect_b3_a_res(ncci=0x%x)", ncci));
2980 channel_request_xon(plci, a->
ncci_ch[ncci]);
2981 channel_xmit_xon(plci);
2997 ncci = (
word)(Id >> 16);
3007 channel_request_xon(plci, a->
ncci_ch[ncci]);
3008 channel_xmit_xon(plci);
3021 cleanup_ncci_data(plci, ncci);
3050 ncci = (
word)(Id >> 16);
3051 dbug(1,
dprintf(
"disconnect_b3_res(ncci=0x%x", ncci));
3067 ncci_free_receive_buffers(plci, ncci);
3075 "ws", (
word)3,
"\x03\x04\x00\x00");
3088 ncci_free_receive_buffers(plci, ncci);
3093 start_internal_command(Id, plci, fax_disconnect_command);
3113 ncci = (
word)(Id >> 16);
3114 dbug(1,
dprintf(
"ncci=0x%x, plci=0x%x", ncci, plci));
3133 data->
P = (
byte *)(
long)(*((
dword *)(parms[0].info)));
3138 data->
Length = GET_WORD(parms[1].info);
3139 data->
Handle = GET_WORD(parms[2].info);
3140 data->
Flags = GET_WORD(parms[3].info);
3144 if (data->
Flags & 0x0004)
3174 "ww", GET_WORD(parms[2].info), Info);
3188 ncci = (
word)(Id >> 16);
3190 n = GET_WORD(parms[0].info);
3192 NCCIcode = ncci | (((
word) a->
Id) << 8);
3193 if (n < appl->MaxBuffer &&
3199 if (channel_can_xon(plci, a->
ncci_ch[ncci])) {
3200 channel_request_xon(plci, a->
ncci_ch[ncci]);
3202 channel_xmit_xon(plci);
3222 ncci = (
word)(Id >> 16);
3240 start_internal_command(Id, plci, reset_b3_command);
3262 ncci = (
word)(Id >> 16);
3289 ncci = (
word)(Id >> 16);
3300 if (parms[0].info) {
3307 nl_req_ncci(plci, req, (
byte)ncci);
3329 dbug(1,
dprintf(
"select_b_req[%d],PLCI=0x%x,Tel=0x%x,NL=0x%x,appl=0x%x,sstate=0x%x",
3332 for (i = 0; i < 7; i++) bp_parms[i].length = 0;
3349 if (Id & EXT_CONTROLLER)
3356 clear_c_ind_mask_bit(plci, (
word)(appl->
Id - 1));
3357 dump_c_ind_mask(plci);
3360 if (test_c_ind_mask_bit(plci, i))
3365 api_save_msg(msg,
"s", &plci->
saved_msg);
3367 if (Id & EXT_CONTROLLER)
3387 if (AdvCodecSupport(a, plci, appl, 0))
3409 CodecIdCheck(a, plci);
3426 start_internal_command(Id, plci, select_b_command);
3447 static byte chi[2] = {0x01, 0x00};
3448 static byte lli[2] = {0x01, 0x00};
3449 static byte codec_cai[2] = {0x01, 0x01};
3450 static byte null_msg = {0};
3451 static API_PARSE null_parms = { 0, &null_msg };
3456 for (i = 0; i < 5; i++) m_parms[i].length = 0;
3461 command = GET_WORD(parms[1].info);
3471 codec = GET_WORD(m_parms[0].info);
3472 ch = m_parms[1].
info[0];
3473 dir = m_parms[2].
info[0];
3474 if ((i = get_plci(a))) {
3475 plci = &a->
plci[i - 1];
3484 if ((ch == 1 || ch == 2) && (dir <= 2)) {
3485 chi[1] = (
byte)(0x80 | ch);
3491 Info = add_b1(plci, &m_parms[3], 0, 0);
3494 add_p(plci,
CAI, codec_cai);
3499 if (AdvCodecSupport(a, plci, appl, 0)) {
3517 add_p(plci,
LLI, lli);
3518 add_p(plci,
CHI, chi);
3519 add_p(plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
3524 Info = add_b23(plci, &m_parms[3]);
3527 nl_req_ncci(plci,
ASSIGN, 0);
3536 api_save_msg(m_parms,
"wbbs", &plci->
saved_msg);
3576 req = m_parms[0].
info[0];
3582 plci->
b_channel = getChannel(&m_parms[1]);
3583 mixer_set_bchannel_id_esc(plci, plci->
b_channel);
3596 add_ss(plci,
FTY, &m_parms[1]);
3597 sig_req(plci, req, 0);
3605 for (ncci = 1; ncci < MAX_NCCI + 1; ncci++)
3610 cleanup_ncci_data(plci, ncci);
3616 nl_req_ncci(plci,
REMOVE, 0);
3632 add_ss(plci,
FTY, m);
3649 add_ss(plci,
FTY, m);
3675 && (m->
info[1] == 0x1c)
3676 && (m->
info[2] >= 1))
3712 dtmf_parameter_write(plci);
3726 add_ss(v_plci,
FTY, m);
3778 if ((msg[0].length == 0)
3779 || (msg[1].length == 0)
3784 indication = GET_WORD(msg[1].info);
3794 dbug(1,
dprintf(
"wrong state for NEGOTIATE_B3 parameters"));
3797 if (api_parse(&msg[2].info[1], msg[2].length,
"ws", m_parms))
3799 dbug(1,
dprintf(
"wrong format in NEGOTIATE_B3 parameters"));
3809 if (api_parse(&ncpi->
info[1], ncpi->
length,
"wwwwssss", fax_parms))
3811 dbug(1,
dprintf(
"non-standard facilities info missing or wrong format"));
3821 if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2))
3824 for (i = 0; i < fax_parms[7].
length; i++)
3829 start_internal_command(Id, plci, fax_edata_ack_command);
3865 if (((e->
complete == 0xff) && no_cancel_rc) ||
3866 (e->
Rc && !no_cancel_rc)) {
3872 if (e->
user[0] & 0x8000)
3886 channel_flow_control_remove(plci);
3887 for (i = 0; i < 256; i++)
3915 dbug(3,
dprintf(
"XDI CAPI: RC cancelled Id:0x02, Ch:%02x", e->
Id, ch));
3930 control_rc(plci, 0, rc, ch, 0,
true);
3935 channel_x_on(plci, ch);
3937 control_rc(plci, req, rc, ch, 0,
true);
3952 channel_xmit_xon(plci);
3953 control_rc(plci, 0, rc, ch, global_req,
true);
3957 channel_xmit_xon(plci);
3962 control_rc(plci, req, rc, ch, 0,
true);
3966 channel_xmit_xon(plci);
3967 control_rc(plci, req, rc, ch, 0,
true);
3995 channel_xmit_xon(plci);
3996 control_rc(plci, 0, rc, ch, global_req,
false);
4000 channel_xmit_xon(plci);
4001 control_rc(plci, req, rc, ch, 0,
false);
4010 channel_xmit_xon(plci);
4011 goto capi_callback_suffix;
4015 channel_xmit_xon(plci);
4018 if (e->
user[0] & 0x8000) {
4024 dbug(3,
dprintf(
"XDI CAPI: I: pending N-XON Ch:%02x", Ch));
4029 if ((e->
RNR != 1) &&
4033 dbug(3,
dprintf(
"XDI CAPI: I: remove faked N-XON Ch:%02x", Ch));
4041 capi_callback_suffix:
4053 dbug(1,
dprintf(
"dequeue msg(0x%04x) - write=%d read=%d wrap=%d",
4088 mixer_notify_update(plci,
false);
4109 byte SSparms[] =
"\x05\x00\x00\x02\x00\x00";
4110 byte SSstruct[] =
"\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00";
4113 dbug(0,
dprintf(
"A: control_rc, no plci %02x:%02x:%02x:%02x:%02x", req, rc, ch, global_req, nl_rc));
4134 Id = (((
dword)(ncci ? ncci : ch)) << 16) | ((
word)plci->
Id << 8) | a->
Id;
4137 dbug(1,
dprintf(
"Contr_RC-Id=%08lx,plci=%x,tel=%x, entity=0x%x, command=0x%x, int_command=0x%x", Id, plci->
Id, plci->
tel, plci->
Sig.
Id, plci->
command, plci->
internal_command));
4139 if (plci_remove_check(plci))
4143 sig_req(plci,
HANGUP, 0);
4144 sig_req(plci,
REMOVE, 0);
4180 dbug(1,
dprintf(
"Connect_R=0x%x/0x%x/0x%x/0x%x", req, rc, global_req, nl_rc));
4183 if (plci->
Sig.
Id != 0xff)
4186 || (!nl_rc && (req ==
CALL_REQ) && (rc !=
OK)))
4201 dbug(1,
dprintf(
"No more IDs/X.25 Call_Req failed"));
4221 if (plci->
Sig.
Id != 0xff)
4240 ncci = get_ncci(plci, ch, 0);
4241 Id = (Id & 0xffff) | (((
dword) ncci) << 16);
4343 if (global_req ==
ASSIGN)
4345 dbug(1,
dprintf(
"AssignDiversion_RC=0x%x/0x%x", req, rc));
4348 if (!plci->
appl)
break;
4358 plci->
number,
"wws", Info, (
word)3, SSparms);
4359 if (Info) plci_remove(plci);
4379 "wws", Info, (
word)3, SSparms);
4400 "wws", Info, (
word)3, SSparms);
4404 dbug(1,
dprintf(
"_Manufacturer_R=0x%x/0x%x", req, rc));
4414 dbug(1,
dprintf(
"_Connect_R=0x%x/0x%x", req, rc));
4427 dbug(1,
dprintf(
"***Codec Connect_Pending A, Rc = 0x%x", rc));
4432 dbug(1,
dprintf(
"***Codec Assign A, Rc = 0x%x", rc));
4442 if (global_req ==
ASSIGN)
4476 cleanup_ncci_data(plci, ncci);
4512 PUT_WORD(&SSparms[4], 0x300E);
4527 "wws", Info, (
word)3, SSparms);
4528 if (rc !=
OK) plci_remove(plci);
4536 "wws", Info, (
word)3, SSparms);
4584 "wws", Info, (
word)3, SSparms);
4618 plci->
number,
"wws", Info, (
word)3, SSparms);
4624 ncci = get_ncci(plci, ch, 0);
4625 Id = (Id & 0xffff) | (((
dword) ncci) << 16);
4634 if (plci->internal_command)
4639 next_internal_command(Id, plci);
4654 if (global_req ==
ASSIGN)
4662 sig_req(plci,
REMOVE, 0);
4676 if (application[i].CDEnable)
4678 if (!application[i].Id) application[
i].
CDEnable = 0;
4682 plci->
number,
"wws", Info, (
word)3, SSparms);
4695 dbug(1,
dprintf(
"***Codec Connect_Pending, Rc = 0x%x", rc));
4699 dbug(1,
dprintf(
"***Codec Assign, Rc = 0x%x", rc));
4712 add_p(plci,
ESC,
"\x02\x18\x00");
4718 dbug(1,
dprintf(
"ListenCheck failed (assignRc=0x%x)", rc));
4726 if (global_req ==
ASSIGN)
4754 sig_req(plci,
REMOVE, 0);
4760 plci_remove_check(plci);
4764 static void data_rc(
PLCI *plci,
byte ch)
4800 static void data_ack(
PLCI *plci,
byte ch)
4826 static void sig_ind(
PLCI *plci)
4837 #define MAXPARMSIDS 31
4852 byte *esc_profile =
"";
4856 byte chi[] =
"\x02\x18\x01";
4857 byte voice_cai[] =
"\x06\x14\x00\x00\x00\x00\x08";
4858 byte resume_cau[] =
"\x05\x05\x00\x02\x00\x00";
4864 {
MAXPARMSIDS,
CPN, 0xff,
DSA,
OSA,
BC,
LLC,
HLC,
ESC_CAUSE,
DSP,
DT,
CHA,
4871 word multi_fac_id[] = {1,
FTY};
4872 word multi_pi_id[] = {1,
PI};
4873 word multi_CiPN_id[] = {1,
OAD};
4880 byte SS_Ind[] =
"\x05\x02\x00\x02\x00\x00";
4881 byte CF_Ind[] =
"\x09\x02\x00\x06\x00\x00\x00\x00\x00\x00";
4882 byte Interr_Err_Ind[] =
"\x0a\x02\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
4883 byte CONF_Ind[] =
"\x09\x16\x00\x06\x00\x00\0x00\0x00\0x00\0x00";
4884 byte force_mt_info =
false;
4890 Id = ((
word)plci->
Id << 8) | a->
Id;
4891 PUT_WORD(&SS_Ind[4], 0x0000);
4896 dbug(1,
dprintf(
"SIG discard while remove pending"));
4900 dbug(1,
dprintf(
"SigInd-Id=%08lx,plci=%x,tel=%x,state=0x%x,channels=%d,Discflowcl=%d",
4917 for (ncci = 1; ncci < MAX_NCCI + 1; ncci++)
4921 cleanup_ncci_data(plci, ncci);
4938 IndParse(plci, multi_fac_id, multi_fac_parms,
MAX_MULTI_IE);
4939 IndParse(plci, multi_pi_id, multi_pi_parms,
MAX_MULTI_IE);
4940 IndParse(plci, multi_ssext_id, multi_ssext_parms,
MAX_MULTI_IE);
4942 IndParse(plci, multi_vswitch_id, multi_vswitch_parms,
MAX_MULTI_IE);
4944 IndParse(plci, parms_id, parms, 0);
4945 IndParse(plci, multi_CiPN_id, multi_CiPN_parms,
MAX_MULTI_IE);
4946 esc_chi = parms[14];
4947 esc_law = parms[18];
4948 pty_cai = parms[24];
4950 esc_profile = parms[27];
4951 if (esc_cr[0] && plci)
4970 2 + 1 + 1 + esc_cr[0] + 1 + 1 + esc_law[0], plci->
Sig.
Ind, 1 + 1 + esc_cr[0] + 1 + 1 + esc_law[0],
ESC, esc_cr,
ESC, esc_law);
4974 add_i[1] = parms[15];
4975 add_i[2] = parms[11];
4976 ai_len = AddInfo(add_i, multi_fac_parms, esc_chi, facility);
4995 sig_req(plci,
REMOVE, 0);
5002 dbug(1,
dprintf(
"[%06x] CardProfile: %lx %lx %lx %lx %lx",
5004 GET_DWORD(&esc_profile[10]), GET_DWORD(&esc_profile[14]),
5005 GET_DWORD(&esc_profile[18]), GET_DWORD(&esc_profile[46])));
5079 dbug(1,
dprintf(
"[%06x] Profile: %lx %lx %lx %lx %lx",
5087 force_mt_info = SendMultiIE(plci, Id, multi_fac_parms,
FTY, 0x20, 0);
5088 force_mt_info |= SendMultiIE(plci, Id, multi_pi_parms,
PI, 0x210, 0);
5089 SendSSExtInd(
NULL, plci, Id, multi_ssext_parms);
5090 SendInfo(plci, Id, parms, force_mt_info);
5092 VSwitchReqInd(plci, Id, multi_vswitch_parms);
5097 if (esc_chi[0] && plci && !plci->
SuppState) {
5098 plci->
b_channel = esc_chi[esc_chi[0]]&0x1f;
5099 mixer_set_bchannel_id_esc(plci, plci->
b_channel);
5112 if (!plci->
appl)
break;
5113 if (pty_cai[0] == 4)
5115 PUT_DWORD(&CF_Ind[6], GET_DWORD(&pty_cai[1]));
5121 PUT_WORD(&CF_Ind[1], 0);
5122 PUT_WORD(&CF_Ind[4], 0);
5130 if (!pty_cai[0])
break;
5142 PUT_WORD(&SS_Ind[1],
S_ECT);
5150 PUT_WORD(&SS_Ind[1], pty_cai[5] + 3);
5152 if (pty_cai[2] != 0xff)
5154 PUT_WORD(&SS_Ind[4], 0x3600 | (
word)pty_cai[2]);
5158 PUT_WORD(&SS_Ind[4], 0x300E);
5166 if (pty_cai[2] != 0xff)
5168 PUT_WORD(&SS_Ind[4], 0x3600 | (
word)pty_cai[2]);
5172 PUT_WORD(&SS_Ind[4], 0x300E);
5174 PUT_WORD(&SS_Ind[1], pty_cai[5]);
5177 if (application[i].CDEnable)
5179 if (application[i].Id)
sendf(&application[i],
_FACILITY_I, Id, 0,
"ws", 3, SS_Ind);
5194 if (!plci->
appl)
break;
5195 if (pty_cai[2] != 0xff)
5197 PUT_WORD(&Interr_Err_Ind[4], 0x3600 | (
word)pty_cai[2]);
5201 PUT_WORD(&Interr_Err_Ind[4], 0x300E);
5207 Interr_Err_Ind[0] = 0x9;
5208 Interr_Err_Ind[3] = 0x6;
5213 Interr_Err_Ind[0] = 0x9;
5214 Interr_Err_Ind[3] = 0x6;
5221 Interr_Err_Ind[0] = 0xa;
5222 Interr_Err_Ind[3] = 0x7;
5227 Interr_Err_Ind[0] = 0xa;
5228 Interr_Err_Ind[3] = 0x7;
5233 Interr_Err_Ind[0] = 0xd;
5234 Interr_Err_Ind[3] = 0xa;
5239 Interr_Err_Ind[0] = 0x9;
5240 Interr_Err_Ind[3] = 0x6;
5245 Interr_Err_Ind[0] = 0xb;
5246 Interr_Err_Ind[3] = 0x8;
5262 if (pty_cai[2] != 0xff)
5264 PUT_WORD(&SS_Ind[4], 0x3600 | (
word)pty_cai[2]);
5268 PUT_WORD(&SS_Ind[4], 0x300E);
5321 if (pty_cai[2] != 0xff)
5323 PUT_WORD(&CONF_Ind[4], 0x3600 | (
word)pty_cai[2]);
5327 PUT_WORD(&CONF_Ind[4], 0x3303);
5331 PUT_DWORD(&CONF_Ind[6], 0x0);
5340 PUT_WORD(&CF_Ind[4], 0);
5352 PUT_WORD(&SS_Ind[1],
S_ECT);
5385 PUT_WORD(&SS_Ind[1], pty_cai[5] + 3);
5391 PUT_WORD(&SS_Ind[1], pty_cai[5]);
5394 if (application[i].CDEnable)
5396 if (application[i].Id)
sendf(&application[i],
_FACILITY_I, Id, 0,
"ws", 3, SS_Ind);
5404 if (!plci->
appl)
break;
5405 PUT_WORD(&CF_Ind[1], pty_cai[5] + 2);
5418 if (!plci->
appl)
break;
5426 pty_cai[3] = pty_cai[0] - 3;
5431 pty_cai[3] = pty_cai[0] - 3;
5436 pty_cai[3] = pty_cai[0] - 3;
5441 pty_cai[3] = pty_cai[0] - 3;
5446 pty_cai[3] = pty_cai[0] - 3;
5449 PUT_WORD(&pty_cai[4], 0);
5473 if (pty_cai[0] >= 0x12)
5476 pty_cai[2] = pty_cai[0] - 2;
5477 pty_cai[5] = pty_cai[0] - 5;
5505 else facility[2] = 0xff;
5514 add_p(plci,
CAI, facility);
5515 add_p(plci,
ESC, multi_ssext_parms[0]);
5519 next_internal_command(Id, plci);
5533 if (pty_cai[0] == 6)
5536 PUT_DWORD(&CONF_Ind[6], d);
5540 PUT_DWORD(&CONF_Ind[6], 0x0);
5561 PUT_DWORD(&CONF_Ind[6], d);
5570 PUT_DWORD(&CONF_Ind[4], d);
5598 PUT_WORD(&CONF_Ind[4], w);
5618 if (cau[2] == 0) i = 0x3603;
5624 PUT_WORD(&SS_Ind[1],
S_HOLD);
5625 PUT_WORD(&SS_Ind[4], i);
5637 CodecIdCheck(a, plci);
5638 start_internal_command(Id, plci, hold_save_command);
5647 if (cau[2] == 0) i = 0x3603;
5654 PUT_WORD(&SS_Ind[4], i);
5658 CodecIdCheck(a, plci);
5669 plci->
b_channel = esc_chi[esc_chi[0]]&0x1f;
5672 mixer_set_bchannel_id_esc(plci, plci->
b_channel);
5678 start_internal_command(Id, plci, retrieve_restore_command);
5684 start_internal_command(Id, plci, retrieve_restore_command);
5690 sig_req(plci,
HANGUP, 0);
5694 cip = find_cip(a, parms[4], parms[6]);
5695 cip_mask = 1
L << cip;
5696 dbug(1,
dprintf(
"cip=%d,cip_mask=%lx", cip, cip_mask));
5697 clear_c_ind_mask(plci);
5700 set_c_ind_mask_bit(plci,
MAX_APPL);
5701 group_optimization(a, plci);
5703 if (application[i].Id
5705 && CPN_filter_ok(parms[0], a, i)
5706 && test_group_ind_mask_bit(plci, i)) {
5708 set_c_ind_mask_bit(plci, i);
5709 dump_c_ind_mask(plci);
5714 plci->
b_channel = esc_chi[esc_chi[0]] & 0x1f;
5715 mixer_set_bchannel_id_esc(plci, plci->
b_channel);
5729 "wSSSSSSSbSSSSS", cip,
5731 multi_CiPN_parms[0],
5744 SendSSExtInd(&application[i],
5748 SendSetupInfo(&application[i],
5752 SendMultiIE(plci, Id, multi_pi_parms,
PI, 0x210,
true));
5755 clear_c_ind_mask_bit(plci,
MAX_APPL);
5756 dump_c_ind_mask(plci);
5758 if (c_ind_mask_empty(plci)) {
5759 sig_req(plci,
HANGUP, 0);
5795 api_load_msg(&tplci->
saved_msg, saved_parms);
5800 add_p(tplci,
LLI,
"\x01\x01");
5802 add_s(tplci,
CONN_NR, &saved_parms[2]);
5803 add_s(tplci,
LLC, &saved_parms[4]);
5804 add_ai(tplci, &saved_parms[5]);
5812 start_internal_command(x_Id, tplci, select_b_command);
5824 api_load_msg(&tplci->
saved_msg, saved_parms);
5825 dir = saved_parms[2].
info[0];
5850 api_load_msg(&tplci->
saved_msg, saved_parms);
5851 add_s(tplci,
CPN, &saved_parms[1]);
5852 add_s(tplci,
DSA, &saved_parms[3]);
5853 add_ai(tplci, &saved_parms[9]);
5866 next_internal_command(x_Id, tplci);
5869 next_internal_command(Id, plci);
5874 add_p(plci,
FTY,
"\x01\x09");
5882 mixer_set_bchannel_id_esc(plci, plci->
b_channel);
5894 ie = multi_fac_parms[0];
5896 switch (ie[1] & 0x91) {
5903 next_internal_command(Id, plci);
5924 tplci->
appl = &application[
i];
5930 if ((i = get_plci(a))) {
5937 add_p(tplci,
LLI,
"\x01\x01");
5939 add_p(tplci,
CAI, voice_cai);
5943 add_p(tplci,
SIN,
"\x02\x01\x00");
5944 add_p(tplci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
5956 Id = ((
word)tplci->
Id << 8) | a->
Id;
5962 "ws", (
word)0,
"\x01+");
5971 next_internal_command(Id, plci);
5976 if (((plci->
hook_state) & 0xf0) == 0x90)
break;
5987 "ws", (
word)0,
"\x01-");
5999 clear_c_ind_mask_bit(plci, (
word)(plci->
appl->
Id - 1));
6000 PUT_WORD(&resume_cau[4],
GOOD);
6005 clear_c_ind_mask(plci);
6009 nl_req_ncci(plci,
REMOVE, 0);
6013 sig_req(plci,
REMOVE, 0);
6031 if (cau[2] == 0) i = 0;
6033 else if (cau[2] == 9 || cau[2] == 10) i =
_L2_ERROR;
6044 if (test_c_ind_mask_bit(plci, i))
6050 clear_c_ind_mask(plci);
6060 if (c_ind_mask_empty(plci))
6066 nl_req_ncci(plci,
REMOVE, 0);
6071 sig_req(plci,
REMOVE, 0);
6085 PUT_WORD(&resume_cau[4], i);
6095 SendSSExtInd(
NULL, plci, Id, multi_ssext_parms);
6099 VSwitchReqInd(plci, Id, multi_vswitch_parms);
6105 parms[MAXPARMSIDS - 1][0])
6111 else VSwitchReqInd(plci, Id, multi_vswitch_parms);
6136 Info_Number = 0x0070;
6138 Info_Sent_Flag =
true;
6142 Info_Number = 0x0028;
6144 Info_Sent_Flag =
true;
6148 Info_Number = 0x0018;
6150 Info_Sent_Flag =
true;
6151 mixer_set_bchannel_id(plci, Info_Element);
6155 Info_Number = 0x0074;
6157 Info_Sent_Flag =
true;
6161 Info_Number = 0x0073;
6163 Info_Sent_Flag =
true;
6167 Info_Number = 0x0076;
6169 Info_Sent_Flag =
true;
6177 if (i == MAXPARMSIDS - 2) {
6178 Info_Number = 0x8000 | 5;
6183 if (Info_Sent_Flag && Info_Number) {
6185 sendf(appl,
_INFO_I, Id, 0,
"wS", Info_Number, Info_Element);
6201 static byte charges[5] = {4, 0, 0, 0, 0};
6202 static byte cause[] = {0x02, 0x80, 0x00};
6217 for (i = 0; i < MAXPARMSIDS; i++) {
6225 Info_Number = 0x0070;
6230 Info_Number = 0x0008;
6233 Info_Element =
NULL;
6237 Info_Number = 0x0028;
6242 Info_Number = 0x0029;
6246 for (j = 0; j < 4; j++) charges[1 + j] = 0;
6247 for (j = 0; j < ie[0] && !(ie[1 +
j] & 0x80); j++);
6248 for (k = 1, j++; j < ie[0] && k <= 4; j++, k++) charges[k] = ie[1 + j];
6249 Info_Number = 0x4000;
6251 Info_Element = charges;
6255 Info_Number = 0x007E;
6260 Info_Number = 0x00B0;
6266 Info_Number = 0x00BF;
6272 Info_Number = 0x002C;
6277 Info_Number = 0x0018;
6279 mixer_set_bchannel_id(plci, Info_Element);
6283 if (!cause[2] || cause[2] < 0x80)
break;
6284 Info_Number = 0x0008;
6286 if (cause[2] != ie[2]) Info_Element =
cause;
6290 Info_Number = 0x0074;
6295 Info_Number = 0x0076;
6308 case MAXPARMSIDS - 2:
6310 Info_Number = 0x8000 | ie[3];
6311 if (iesent) Info_Mask = 0xffff;
6312 else Info_Mask = 0x10;
6327 appl = &application[
j];
6334 sendf(&application[j],
_INFO_I, Id & 0x0f, 0,
"wS", Info_Number, Info_Element);
6338 else if (!plci->
appl)
6340 if (Info_Number ==
CPN
6341 || Info_Number ==
KEY
6342 || Info_Number ==
NI
6343 || Info_Number ==
DSP
6344 || Info_Number ==
UUI)
6348 if (test_c_ind_mask_bit(plci, j))
6352 sendf(&application[j],
_INFO_I, Id, 0,
"wS", Info_Number, Info_Element);
6357 else if (Info_Number
6400 Info_Number = (
word)ie_type;
6401 Info_Mask = (
word)info_mask;
6408 appl = &application[
j];
6415 sendf(&application[j],
_INFO_I, Id & 0x0f, 0,
"wS", Info_Number, Info_Element);
6419 else if (!plci->
appl && Info_Number)
6423 if (test_c_ind_mask_bit(plci, j))
6427 sendf(&application[j] ,
_INFO_I, Id, 0,
"wS", Info_Number, Info_Element);
6431 else if (Info_Number
6460 if (parms[i][0] < 6)
continue;
6474 else if (plci->
appl)
6488 static void nl_ind(
PLCI *plci)
6499 byte len, ncci_state;
6502 word fax_feature_bits;
6503 byte fax_send_edata_ack;
6504 static byte v120_header_buffer[2 + 3];
6505 static word fax_info[] = {
6558 static word rtp_info[] = {
6563 static dword udata_forwarding_table[0x100 /
sizeof(
dword)] =
6565 0x0020301e, 0x00000000, 0x00000000, 0x00000000,
6566 0x00000000, 0x00000000, 0x00000000, 0x00000000
6572 Id = (((
dword)(ncci ? ncci : ch)) << 16) | (((
word) plci->
Id) << 8) | a->
Id;
6574 APPLptr = plci->
appl;
6575 dbug(1,
dprintf(
"NL_IND-Id(NL:0x%x)=0x%08lx,plci=%x,tel=%x,state=0x%x,ch=0x%x,chs=%d,Ind=%x",
6583 dbug(1,
dprintf(
"NL discard while remove pending"));
6627 word conn_opt, ncpi_opt = 0x00;
6640 conn_opt = GET_WORD(data);
6643 PUT_WORD(&(plci->
ncpi_buffer[1]), (
word)(GET_DWORD(data) & 0x0000FFFF));
6680 & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN)))
6693 && !(udata_forwarding_table[plci->
RData[0].
P[0] >> 5] & (1L << (plci->
RData[0].
P[0] & 0x1f))))
6695 switch (plci->
RData[0].
P[0])
6710 dtmf_confirmation(Id, plci);
6720 dtmf_indication(Id, plci, dtmf_code_buffer, (
word)(i + 1));
6726 mixer_indication_coefs_set(Id, plci);
6777 fax_feature_bits = 0;
6815 if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)
6820 dbug(1,
dprintf(
"FAX Options %04x %04x", fax_feature_bits, i));
6844 while (i < plci->NL.RBuffer->length)
6889 switch (plci->
NL.
Ind & 0x0f) {
6909 fax_send_edata_ack =
false;
6950 fax_send_edata_ack =
false;
6973 if (fax_send_edata_ack)
6977 start_internal_command(Id, plci, fax_edata_ack_command);
6988 ncci = get_ncci(plci, ch, 0);
6989 Id = (Id & 0xffff) | (((
dword) ncci) << 16);
6991 dbug(1,
dprintf(
"N_CONNECT: ch=%d state=%d plci=%lx plci_Id=%lx plci_State=%d",
7014 if (!plci->internal_command)
7015 next_internal_command(Id, plci);
7019 if (plci->B3_prot == 1)
7024 sendf(plci->appl, msg, Id, 0,
"S", plci->ncpi_buffer);
7026 else if ((plci->B3_prot == 4) || (plci->B3_prot == 5) || (plci->B3_prot == 7))
7033 if (plci->B3_prot == 4)
7034 sendf(plci->appl, msg, Id, 0,
"s",
"");
7036 sendf(plci->appl, msg, Id, 0,
"S", plci->ncpi_buffer);
7043 sendf(plci->appl, msg, Id, 0,
"S", plci->ncpi_buffer);
7045 if (plci->adjust_b_restore)
7047 plci->adjust_b_restore =
false;
7048 start_internal_command(Id, plci, adjust_b_restore);
7053 if (plci->internal_command_queue[0]
7058 (*(plci->internal_command_queue[0]))(Id,
plci, 0);
7059 if (!plci->internal_command)
7060 next_internal_command(Id, plci);
7063 ncci_remove(plci, ncci,
false);
7069 for (i = 0; plci->inc_dis_ncci_table[
i]; i++);
7070 plci->inc_dis_ncci_table[
i] = (
byte) ncci;
7074 && (plci->B1_resource == 16)
7078 i = ((
T30_INFO *)plci->fax_connect_info_buffer)->rate_div_2400 * 2400;
7079 PUT_WORD(&plci->ncpi_buffer[1], i);
7080 PUT_WORD(&plci->ncpi_buffer[3], 0);
7081 i = ((
T30_INFO *)plci->fax_connect_info_buffer)->data_format;
7082 PUT_WORD(&plci->ncpi_buffer[5], i);
7083 PUT_WORD(&plci->ncpi_buffer[7], 0);
7084 plci->ncpi_buffer[len] = 0;
7085 plci->ncpi_buffer[0] = len;
7086 if (plci->B3_prot == 4)
7094 plci->ncpi_buffer[++len] = 0;
7095 plci->ncpi_buffer[++len] = 0;
7096 plci->ncpi_buffer[++len] = 0;
7097 plci->ncpi_buffer[0] = len;
7103 plci->ncpi_state = 0;
7104 sig_req(plci,
HANGUP, 0);
7110 && ((plci->B3_prot == 4) || (plci->B3_prot == 5))
7113 if (ncci_state ==
IDLE)
7117 if ((plci->State ==
IDLE || plci->State ==
SUSPENDING) && !plci->channels) {
7123 "ws", (
word)3,
"\x03\x04\x00\x00");
7131 else if (plci->channels)
7134 plci->ncpi_state = 0;
7138 sig_req(plci,
HANGUP, 0);
7154 if (!(udata_forwarding_table[plci->NL.RBuffer->P[0] >> 5] & (1L << (plci->NL.RBuffer->P[0] & 0x1f))))
7156 plci->RData[0].P = plci->internal_ind_buffer + (-((
int)(
long)(plci->internal_ind_buffer)) & 3);
7158 plci->NL.R = plci->RData;
7177 channel_x_off(plci, ch, 0);
7181 NCCIcode = ncci | (((
word)a->
Id) << 8);
7189 for (i = 0; i < APPLptr->
MaxBuffer; i++) {
7190 if (NCCIcode == APPLptr->
DataNCCI[i]) count++;
7191 if (!APPLptr->
DataNCCI[i] && Num == 0xffff) Num =
i;
7194 if (count >= APPLptr->
MaxNCCIData || Num == 0xffff)
7204 channel_x_off(plci, ch, 0);
7214 if (!plci->RData[0].P) {
7216 channel_x_off(plci, ch, 0);
7221 APPLptr->
DataFlags[Num] = (plci->Id << 8) | (plci->NL.Ind >> 4);
7225 plci->RFlags = plci->NL.Ind >> 4;
7227 plci->NL.R = plci->RData;
7228 if ((plci->NL.RLength != 0)
7233 plci->RData[1].P = plci->RData[0].P;
7234 plci->RData[1].PLength = plci->RData[0].PLength;
7235 plci->RData[0].P = v120_header_buffer + (-((
unsigned long)v120_header_buffer) & 3);
7237 plci->RData[0].PLength = 1;
7239 plci->RData[0].PLength = 2;
7241 plci->RFlags |= 0x0010;
7243 plci->RFlags |= 0x8000;
7248 if ((plci->NL.Ind & 0x0f) ==
N_UDATA)
7249 plci->RFlags |= 0x0010;
7251 else if ((plci->B3_prot ==
B3_RTP) && ((plci->NL.Ind & 0x0f) ==
N_BDATA))
7252 plci->RFlags |= 0x0001;
7282 plci->
Id = (
byte)(i + 1);
7301 init_internal_command_queue(plci);
7326 clear_c_ind_mask(plci);
7327 set_group_ind_mask(plci);
7339 init_b1_config(plci);
7353 if (p) p_length = p[0];
7354 add_ie(plci, code, p, p_length);
7390 if (p->
info[i] == 2) {
7407 if (!(code & 0x80) && !p_length)
return;
7419 for (i = 0; i < p_length; i++) plci->
RBuffer[plci->
req_in++] = p[1 + i];
7452 for (i = 0; i < 5; i++) ai_parms[i].length = 0;
7459 add_s(plci,
KEY, &ai_parms[1]);
7460 add_s(plci,
UUI, &ai_parms[2]);
7461 add_ss(plci,
FTY, &ai_parms[3]);
7475 byte resource[] = {5, 9, 13, 12, 16, 39, 9, 17, 17, 18};
7476 byte voice_cai[] =
"\x06\x14\x00\x00\x00\x00\x08";
7484 for (i = 0; i < 8; i++) bp_parms[i].length = 0;
7485 for (i = 0; i < 2; i++) global_config[i].length = 0;
7490 if (b_channel_info == 2) {
7492 adjust_b1_facilities(plci, plci->
B1_resource, b1_facilities);
7493 add_p(plci,
CAI,
"\x01\x00");
7501 adjust_b1_facilities(plci, plci->
B1_resource, b1_facilities);
7502 add_p(plci,
CAI,
"\x01\x01");
7511 add_p(plci,
CAI, voice_cai);
7512 dbug(1,
dprintf(
"Cai=1,0x%x (AdvVoice)", voice_cai[1]));
7523 adjust_b1_facilities(plci, plci->
B1_resource, b1_facilities);
7524 add_p(plci,
CAI,
"\x01\x05");
7530 if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwsssb", bp_parms))
7533 if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwsss", bp_parms))
7539 else if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwssss", bp_parms))
7545 if (bp_parms[6].length)
7547 if (api_parse(&bp_parms[6].info[1], (
word)bp_parms[6].length,
"w", global_config))
7551 switch (GET_WORD(global_config[0].info))
7564 if ((GET_WORD(bp_parms[0].info) ==
B1_RTP)
7574 for (i = 0; i < bp_parms[3].
length; i++)
7575 cai[7 + i] = bp_parms[3].info[1 + i];
7576 cai[0] = 6 + bp_parms[3].
length;
7577 add_p(plci,
CAI, cai);
7582 if ((GET_WORD(bp_parms[0].info) ==
B1_PIAFS)
7593 add_p(plci,
CAI, cai);
7598 if ((GET_WORD(bp_parms[0].info) >= 32)
7600 && ((GET_WORD(bp_parms[0].info) != 3)
7602 || ((bp_parms[3].
length != 0) && (GET_WORD(&bp_parms[3].info[1]) != 0) && (GET_WORD(&bp_parms[3].info[1]) != 56000)))))
7606 plci->
B1_resource = add_b1_facilities(plci, resource[GET_WORD(bp_parms[0].info)],
7611 for (i = 2; i <
sizeof(cai); i++) cai[i] = 0;
7617 for (i = 0; i < 7; i++) mdm_cfg[i].length = 0;
7619 if (bp_parms[3].length)
7621 if (api_parse(&bp_parms[3].info[1], (
word)bp_parms[3].
length,
"wwwwww", mdm_cfg))
7628 dbug(1,
dprintf(
"MDM Max Bit Rate:<%d>", GET_WORD(mdm_cfg[0].info)));
7630 PUT_WORD(&cai[13], 0);
7631 PUT_WORD(&cai[15], GET_WORD(mdm_cfg[0].info));
7632 PUT_WORD(&cai[17], 0);
7633 PUT_WORD(&cai[19], GET_WORD(mdm_cfg[0].info));
7636 switch (GET_WORD(mdm_cfg[2].info))
7653 switch (GET_WORD(mdm_cfg[3].info))
7665 switch (GET_WORD(mdm_cfg[1].info))
7738 && (GET_WORD(mdm_cfg[5].info) & 0x8000))
7742 if (GET_WORD(mdm_cfg[5].info) & 0x4000)
7746 & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN)))
7748 if (!api_parse(&bp_parms[3].info[1], (
word)bp_parms[3].length,
"wwwwwws", mdm_cfg))
7751 if (mdm_cfg[6].length >= 4)
7753 d = GET_DWORD(&mdm_cfg[6].info[1]);
7755 cai[9] |= (
byte)(d >> 8);
7756 cai[++
i] = (
byte)(d >> 16);
7757 cai[++
i] = (
byte)(d >> 24);
7758 if (mdm_cfg[6].length >= 8)
7760 d = GET_DWORD(&mdm_cfg[6].info[5]);
7761 cai[10] |= (
byte) d;
7762 cai[11] |= (
byte)(d >> 8);
7763 if (mdm_cfg[6].length >= 12)
7765 d = GET_DWORD(&mdm_cfg[6].info[9]);
7767 cai[++
i] = (
byte)(d >> 8);
7768 cai[++
i] = (
byte)(d >> 16);
7769 cai[++
i] = (
byte)(d >> 24);
7771 if (mdm_cfg[6].length >= 14)
7773 w = GET_WORD(&mdm_cfg[6].info[13]);
7775 PUT_WORD(&cai[13], w);
7776 if (mdm_cfg[6].length >= 16)
7778 w = GET_WORD(&mdm_cfg[6].info[15]);
7780 PUT_WORD(&cai[15], w);
7781 if (mdm_cfg[6].length >= 18)
7783 w = GET_WORD(&mdm_cfg[6].info[17]);
7785 PUT_WORD(&cai[17], w);
7786 if (mdm_cfg[6].length >= 20)
7788 w = GET_WORD(&mdm_cfg[6].info[19]);
7790 PUT_WORD(&cai[19], w);
7791 if (mdm_cfg[6].length >= 22)
7793 w = GET_WORD(&mdm_cfg[6].info[21]);
7794 cai[23] = (
byte)(-((
short) w));
7795 if (mdm_cfg[6].length >= 24)
7797 w = GET_WORD(&mdm_cfg[6].info[23]);
7798 cai[22] |= (
byte) w;
7799 cai[21] |= (
byte)(w >> 8);
7811 if (!api_parse(&bp_parms[3].info[1], (
word)bp_parms[3].
length,
"wwwwwwss", mdm_cfg))
7813 if (!api_parse(&mdm_cfg[7].info[1], (
word)mdm_cfg[7].
length,
"sss", mdm_cfg_v18))
7815 for (n = 0; n < 3; n++)
7817 cai[
i] = (
byte)(mdm_cfg_v18[n].length);
7818 for (j = 1; j < ((
word)(cai[i] + 1)); j++)
7819 cai[i + j] = mdm_cfg_v18[n].info[j];
7824 cai[0] = (
byte)(i - 1);
7830 if (GET_WORD(bp_parms[0].info) == 2 ||
7831 GET_WORD(bp_parms[0].info) == 3)
7833 if (bp_parms[3].length) {
7834 dbug(1,
dprintf(
"V.110,%d", GET_WORD(&bp_parms[3].info[1])));
7835 switch (GET_WORD(&bp_parms[3].info[1])) {
7838 if (GET_WORD(bp_parms[0].info) == 3) {
7844 else if (GET_WORD(bp_parms[0].info) == 2) {
7849 case 50: cai[2] = 1;
break;
7850 case 75: cai[2] = 1;
break;
7851 case 110: cai[2] = 1;
break;
7852 case 150: cai[2] = 1;
break;
7853 case 200: cai[2] = 1;
break;
7854 case 300: cai[2] = 1;
break;
7855 case 600: cai[2] = 1;
break;
7856 case 1200: cai[2] = 2;
break;
7857 case 2400: cai[2] = 3;
break;
7858 case 4800: cai[2] = 4;
break;
7859 case 7200: cai[2] = 10;
break;
7860 case 9600: cai[2] = 5;
break;
7861 case 12000: cai[2] = 13;
break;
7862 case 24000: cai[2] = 0;
break;
7863 case 14400: cai[2] = 11;
break;
7864 case 19200: cai[2] = 6;
break;
7865 case 28800: cai[2] = 12;
break;
7866 case 38400: cai[2] = 7;
break;
7867 case 48000: cai[2] = 8;
break;
7868 case 76: cai[2] = 15;
break;
7869 case 1201: cai[2] = 14;
break;
7870 case 56001: cai[2] = 9;
break;
7878 if (bp_parms[3].length >= 8)
7880 switch (GET_WORD(&bp_parms[3].info[3]))
7892 switch (GET_WORD(&bp_parms[3].info[5]))
7901 switch (GET_WORD(&bp_parms[3].info[7]))
7910 else if (cai[1] == 8 || GET_WORD(bp_parms[0].info) == 3) {
7922 dbug(1,
dprintf(
"CAI[%d]=%x,%x,%x,%x,%x,%x", cai[0], cai[1], cai[2], cai[3], cai[4], cai[5], cai[6]));
7925 add_p(plci,
CAI, cai);
7935 word i, fax_control_bits;
7946 static byte llc[3] = {2,0,0};
7947 static byte dlc[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
7948 static byte nlc[256];
7949 static byte lli[12] = {1,1};
7951 const byte llc2_out[] = {1,2,4,6,2,0,0,0,
X75_V42BIS,
V120_L2,
V120_V42BIS,
V120_L2,6};
7952 const byte llc2_in[] = {1,3,4,6,3,0,0,0,
X75_V42BIS,
V120_L2,
V120_V42BIS,
V120_L2,6};
7954 const byte llc3[] = {4,3,2,2,6,6,0};
7957 for (i = 0; i < 8; i++) bp_parms[i].length = 0;
7958 for (i = 0; i < 6; i++) b2_config_parms[i].length = 0;
7959 for (i = 0; i < 5; i++) b3_config_parms[i].length = 0;
7997 add_p(plci,
LLI, lli);
8002 add_p(plci,
LLC, llc);
8005 add_p(plci,
DLC, dlc);
8012 add_p(plci,
LLI, lli);
8017 add_p(plci,
LLC, llc);
8020 add_p(plci,
DLC, dlc);
8026 if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwsssb", bp_parms))
8029 if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwsss", bp_parms))
8035 else if (api_parse(&bp->
info[1], (
word)bp->
length,
"wwwssss", bp_parms))
8043 if (GET_WORD(bp_parms[1].info) != 1
8050 if ((GET_WORD(bp_parms[1].info) ==
B2_RTP)
8051 && (GET_WORD(bp_parms[2].info) ==
B3_RTP)
8054 add_p(plci,
LLI, lli);
8055 plci->
B2_prot = (
byte) GET_WORD(bp_parms[1].info);
8056 plci->
B3_prot = (
byte) GET_WORD(bp_parms[2].info);
8059 add_p(plci,
LLC, llc);
8068 for (i = 0; i < bp_parms[4].
length; i++)
8069 dlc[9 + i] = bp_parms[4].info[1 + i];
8070 dlc[0] = (
byte)(8 + bp_parms[4].length);
8071 add_p(plci,
DLC, dlc);
8072 for (i = 0; i < bp_parms[5].
length; i++)
8073 nlc[1 + i] = bp_parms[5].info[1 + i];
8074 nlc[0] = (
byte)(bp_parms[5].length);
8075 add_p(plci,
NLC, nlc);
8081 if ((GET_WORD(bp_parms[1].info) >= 32)
8083 && ((GET_WORD(bp_parms[1].info) !=
B2_PIAFS)
8089 if ((GET_WORD(bp_parms[2].info) >= 32)
8094 if ((GET_WORD(bp_parms[1].info) !=
B2_SDLC)
8099 return (add_modem_b23(plci, bp_parms));
8102 add_p(plci,
LLI, lli);
8106 if (plci->
B2_prot == 12) SAPI = 0;
8108 if (bp_parms[6].length)
8110 if (api_parse(&bp_parms[6].info[1], (
word)bp_parms[6].
length,
"w", global_config))
8114 switch (GET_WORD(global_config[0].info))
8133 llc2_out[GET_WORD(bp_parms[1].info)] : llc2_in[GET_WORD(bp_parms[1].info)];
8135 llc[2] = llc3[GET_WORD(bp_parms[2].info)];
8137 add_p(plci,
LLC, llc);
8141 header[GET_WORD(bp_parms[2].info)]);
8143 b1_config = &bp_parms[3];
8148 for (i = 0; i <
sizeof(
T30_INFO); i++) nlc[i] = 0;
8152 ((
T30_INFO *)&nlc[1])->rate_div_2400 = 0xff;
8153 if (b1_config->
length >= 2)
8155 ((
T30_INFO *)&nlc[1])->rate_div_2400 = (
byte)(GET_WORD(&b1_config->
info[1]) / 2400);
8158 b2_config = &bp_parms[4];
8167 if (b2_config->
length && api_parse(&b2_config->
info[1], (
word)b2_config->
length,
"bwww", b2_config_parms)) {
8175 if (b2_config->
length >= 7) {
8178 dlc[9] = b2_config_parms[0].
info[0];
8179 dlc[10] = b2_config_parms[1].
info[0];
8180 dlc[11] = b2_config_parms[1].
info[1];
8181 dlc[12] = b2_config_parms[2].
info[0];
8182 dlc[13] = b2_config_parms[2].
info[1];
8183 dlc[14] = b2_config_parms[3].
info[0];
8184 dlc[15] = b2_config_parms[3].
info[1];
8186 if (b2_config->
length >= 8) {
8190 dlc[18] = b2_config_parms[4].
info[0];
8207 add_p(plci,
DLC, dlc);
8217 PUT_WORD(&dlc[1], GET_WORD(&dlc[1]) + 2);
8222 if (b2_config->
length != 0)
8227 dlc[3] = (
byte)((b2_config->
info[2] << 3) | ((b2_config->
info[1] >> 5) & 0x04));
8228 dlc[4] = (
byte)((b2_config->
info[1] << 1) | 0x01);
8229 if (b2_config->
info[3] != 128)
8231 dbug(1,
dprintf(
"1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4]));
8234 dlc[5] = (
byte)(b2_config->
info[3] - 1);
8235 dlc[6] = b2_config->
info[4];
8237 if (b2_config->
length >= 10) {
8240 dlc[9] = b2_config_parms[4].
info[0];
8241 dlc[10] = b2_config_parms[4].
info[1];
8242 dlc[11] = b2_config_parms[5].
info[0];
8243 dlc[12] = b2_config_parms[5].
info[1];
8244 dlc[13] = b2_config_parms[6].
info[0];
8245 dlc[14] = b2_config_parms[6].
info[1];
8247 dbug(1,
dprintf(
"b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1]));
8248 dbug(1,
dprintf(
"b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1]));
8249 dbug(1,
dprintf(
"b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1]));
8263 if (api_parse(&b2_config->
info[1], (
word)b2_config->
length,
"bbbbwww", b2_config_parms))
8269 if (api_parse(&b2_config->
info[1], (
word)b2_config->
length,
"bbbbs", b2_config_parms))
8278 if (b2_config->
length >= 1) dlc[2] = b2_config->
info[1];
8282 SAPI = b2_config->
info[2];
8285 if ((b2_config->
length >= 3) && (b2_config->
info[3] == 128))
8294 if (b2_config->
length >= 4) dlc[4] = b2_config->
info[4];
8296 dbug(1,
dprintf(
"D-dlc[%d]=%x,%x,%x,%x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4]));
8301 dlc[0] = (
byte)(b2_config_parms[4].length + 6);
8302 dlc[3] = b2_config->
info[1];
8303 dlc[4] = b2_config->
info[2];
8304 if (b2_config->
info[3] != 8 && b2_config->
info[3] != 128) {
8305 dbug(1,
dprintf(
"1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4]));
8309 dlc[5] = (
byte)(b2_config->
info[3] - 1);
8310 dlc[6] = b2_config->
info[4];
8311 if (dlc[6] > dlc[5]) {
8312 dbug(1,
dprintf(
"2D-dlc= %x %x %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4], dlc[5], dlc[6]));
8317 if (b2_config->
length >= 10) {
8320 dlc[9] = b2_config_parms[4].
info[0];
8321 dlc[10] = b2_config_parms[4].
info[1];
8322 dlc[11] = b2_config_parms[5].
info[0];
8323 dlc[12] = b2_config_parms[5].
info[1];
8324 dlc[13] = b2_config_parms[6].
info[0];
8325 dlc[14] = b2_config_parms[6].
info[1];
8327 dbug(1,
dprintf(
"b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1]));
8328 dbug(1,
dprintf(
"b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1]));
8329 dbug(1,
dprintf(
"b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1]));
8337 PUT_WORD(&dlc[7], (
word)b2_config_parms[4].length);
8338 for (i = 0; i < b2_config_parms[4].
length; i++)
8339 dlc[11 + i] = b2_config_parms[4].info[1 + i];
8344 add_p(plci,
DLC, dlc);
8346 b3_config = &bp_parms[5];
8352 if (api_parse(&b3_config->
info[1], (
word)b3_config->
length,
"wwss", b3_config_parms))
8356 i = GET_WORD((
byte *)(b3_config_parms[0].info));
8357 ((
T30_INFO *)&nlc[1])->resolution = (
byte)(((i & 0x0001) ||
8361 if ((((
T30_INFO *)&nlc[1])->rate_div_2400 != 0) && (((
T30_INFO *)&nlc[1])->rate_div_2400 <= 6))
8374 ((
T30_INFO *)&nlc[1])->recording_properties =
8401 if (i < b3_config_parms[2].length)
8403 ((
T30_INFO *)&nlc[1])->station_id[
i] = ((
byte *)b3_config_parms[2].info)[1 +
i];
8407 ((
T30_INFO *)&nlc[1])->station_id[
i] =
' ';
8412 if (b3_config_parms[3].length)
8422 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] =
' ';
8423 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] =
' ';
8424 len = (
byte)b3_config_parms[2].length;
8429 for (i = 0; i < len; i++)
8430 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((
byte *)b3_config_parms[2].info)[1 +
i];
8431 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] =
' ';
8432 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] =
' ';
8437 len = (
byte)b3_config_parms[3].length;
8440 ((
T30_INFO *)&nlc[1])->head_line_len = (
byte)(pos + len);
8441 nlc[0] += (
byte)(pos + len);
8442 for (i = 0; i < len; i++)
8443 nlc[1 +
offsetof(
T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((
byte *)b3_config_parms[3].info)[1 +
i];
8445 ((
T30_INFO *)&nlc[1])->head_line_len = 0;
8451 && (GET_WORD((
byte *)b3_config_parms[1].
info) & 0x8000))
8456 && (GET_WORD((
byte *)b3_config_parms[1].
info) & 0x4000))
8472 if (pos < plci->fax_connect_info_length)
8479 if (pos < plci->fax_connect_info_length)
8498 if (api_parse(&b3_config->
info[1], (
word)b3_config->
length,
"wwsss", b3_config_parms))
8500 dbug(1,
dprintf(
"non-standard facilities info missing or wrong format"));
8505 if ((b3_config_parms[4].length >= 3) && (b3_config_parms[4].info[1] >= 2))
8507 nlc[++len] = (
byte)(b3_config_parms[4].length);
8508 for (i = 0; i < b3_config_parms[4].
length; i++)
8509 nlc[++len] = b3_config_parms[4].info[1 + i];
8522 PUT_WORD(&(((
T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits);
8524 for (i = 0; i < len; i++)
8527 i += ((
T30_INFO *)&nlc[1])->head_line_len;
8535 if (b3_config->
length != 16)
8537 for (i = 0; i < 12; i++) nlc[1 + i] = b3_config->
info[1 + i];
8538 if (GET_WORD(&b3_config->
info[13]) != 8 && GET_WORD(&b3_config->
info[13]) != 128)
8540 nlc[13] = b3_config->
info[13];
8541 if (GET_WORD(&b3_config->
info[15]) >= nlc[13])
8543 nlc[14] = b3_config->
info[15];
8551 add_p(plci,
NLC, nlc);
8572 static byte lli[12] = {1,1};
8573 static byte llc[3] = {2,0,0};
8574 static byte dlc[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
8579 for (i = 0; i < 2; i++) mdm_config[i].length = 0;
8580 for (i = 0; i <
sizeof(dlc); i++) dlc[i] = 0;
8589 if ((GET_WORD(bp_parms[2].info) !=
B3_MODEM)
8595 plci->
B2_prot = (
byte) GET_WORD(bp_parms[1].info);
8596 plci->
B3_prot = (
byte) GET_WORD(bp_parms[2].info);
8600 if (api_parse(&bp_parms[4].info[1],
8606 b2_config = GET_WORD(mdm_config[0].info);
8618 if ((lli[1] & 0x02) && (diva_xdi_extended_features & DIVA_CAPI_USE_CMA)) {
8643 add_p(plci,
LLI, lli);
8644 add_p(plci,
LLC, llc);
8650 if (bp_parms[4].length)
8652 dbug(1,
dprintf(
"MDM b2_config=%02x", b2_config));
8696 dlc[0] = (
byte)(i - 1);
8698 add_p(plci,
DLC, dlc);
8729 static void nl_req_ncci(
PLCI *plci,
byte req,
byte ncci)
8733 dbug(1,
dprintf(
"nl_req %02x %02x %02x", plci->
Id, req, ncci));
8737 ncci_remove(plci, 0, (
byte)(ncci != 0));
8751 static void send_req(
PLCI *plci)
8759 channel_xmit_xon(plci);
8777 if (!(e->
Id & 0x1f))
8797 if (!(e->
Id & 0x1f))
8807 static void send_data(
PLCI *plci)
8838 if (data->
Flags & 0x10)
8839 plci->
NData[0].
P = v120_break_header;
8841 plci->
NData[0].
P = v120_default_header;
8850 if (data->
Flags & 0x10)
8867 cleanup_ncci_data(plci, ncci);
8890 byte activnotifiedcalls = 0;
8897 plci = &(a->
plci[
i]);
8900 dbug(1,
dprintf(
"listen_check(%d)", activnotifiedcalls));
8903 if ((j = get_plci(a))) {
8905 plci = &a->
plci[j - 1];
8908 add_p(plci,
OAD,
"\x01\xfd");
8910 add_p(plci,
KEY,
"\x04\x43\x41\x32\x30");
8912 add_p(plci,
CAI,
"\x01\xc0");
8913 add_p(plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
8914 add_p(plci,
LLI,
"\x01\xc4");
8916 add_p(plci,
SIN,
"\x02\x00\x00");
8929 static void IndParse(
PLCI *plci,
word *parms_id,
byte **parms,
byte multiIEsize)
8944 for (i = 0; i < parms_id[0]; i++)
8946 parms[
i] = (
byte *)
"";
8948 for (i = 0; i < multiIEsize; i++)
8950 parms[
i] = (
byte *)
"";
8953 while (ploc < plci->Sig.RBuffer->length - 1) {
8964 wlen = (
byte)(in[ploc + 1] + 1);
8967 if ((ploc + wlen) > 270)
return;
8968 if (lock & 0x80) lock &= 0x7f;
8969 else codeset = lock;
8971 if ((w & 0xf0) ==
SHIFT) {
8973 if (!(codeset & 0x08)) lock = (
byte)(codeset & 7);
8978 if (w ==
ESC && wlen >= 3) code = in[ploc + 2] | 0x800;
8980 code |= (codeset << 8);
8982 for (i = 1; i < parms_id[0] + 1 && parms_id[
i] !=
code; i++);
8984 if (i < parms_id[0] + 1) {
8989 parms[mIEindex] = &in[ploc + 1];
8990 dbug(1,
dprintf(
"mIE[%d]=0x%x", *parms[mIEindex], in[ploc]));
8991 if (parms_id[i] ==
OAD
8993 || parms_id[i] ==
CAD) {
8994 if (in[ploc + 2] & 0x80) {
8995 in[ploc + 0] = (
byte)(in[ploc + 1] + 1);
8996 in[ploc + 1] = (
byte)(in[ploc + 2] & 0x7f);
8997 in[ploc + 2] = 0x80;
8998 parms[mIEindex] = &in[ploc];
9017 if (!ie1 || !ie2)
return false;
9018 if (!ie1[0])
return false;
9019 for (i = 0; i < (
word)(ie1[0] + 1); i++)
if (ie1[i] != ie2[i])
return false;
9028 for (i = 9; i && !ie_compare(bc, cip_bc[i][a->
u_law]); i--);
9030 for (j = 16; j < 29 &&
9031 (!ie_compare(bc, cip_bc[j][a->
u_law]) || !ie_compare(hlc, cip_hlc[j])); j++);
9032 if (j == 29)
return i;
9050 if (esc_chi[0] && !(esc_chi[esc_chi[0]] & 0x7f))
9052 add_i[0] = (
byte *)
"\x02\x02\x00";
9057 add_i[0] = (
byte *)
"";
9061 add_i[3] = (
byte *)
"";
9065 for (i = 0, j = 1; i < MAX_MULTI_IE && fty_i[
i][0]; i++)
9071 facility[j++] = 0x1c;
9072 for (k = 0; k <= flen; k++, j++)
9074 facility[
j] = fty_i[
i][
k];
9079 add_i[3] = facility;
9082 len = add_i[0][0] + add_i[1][0] + add_i[2][0] + add_i[3][0];
9093 byte voice_chi[] =
"\x02\x18\x01";
9096 channel = chi[chi[0]] & 0x3;
9098 voice_chi[2] = (
channel) ? channel : 1;
9099 add_p(plci,
FTY,
"\x02\x01\x07");
9100 add_p(plci,
ESC, voice_chi);
9109 static void VoiceChannelOff(
PLCI *plci)
9112 add_p(plci,
FTY,
"\x02\x01\x08");
9150 if ((j = get_plci(a)))
9152 splci = &a->
plci[j - 1];
9176 add_p(splci,
CAI,
"\x01\x15");
9177 add_p(splci,
LLI,
"\x01\x00");
9178 add_p(splci,
ESC,
"\x02\x18\x00");
9179 add_p(splci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
9192 if (hook_listen)
return 0x300B;
9200 if ((j = get_plci(a))) {
9201 splci = &a->
plci[j - 1];
9202 add_p(splci,
CAI,
"\x01\x80");
9203 add_p(splci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
9204 sig_req(splci,
ASSIGN, 0xC0);
9271 if (!diva_xdi_extended_features) {
9273 diva_xdi_extended_features |= 0x80000000;
9299 dbug(3,
dprintf(
"XDI provides NO_CANCEL_RC feature"));
9305 diva_ask_for_xdi_sdram_bar(a, preq);
9321 if ((j = get_plci(a))) {
9322 diva_get_extended_adapter_features(a);
9323 splci = &a->
plci[j - 1];
9326 add_p(splci,
CAI,
"\x01\x80");
9327 add_p(splci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
9350 this = &application[Id - 1];
9352 for (i = 0, appls_found = 0; i <
max_appl; i++)
9354 if (application[i].Id)
9378 if (test_c_ind_mask_bit(plci, (
word)(Id - 1)))
9380 clear_c_ind_mask_bit(plci, (
word)(Id - 1));
9381 if (c_ind_mask_empty(plci))
9383 sig_req(plci,
HANGUP, 0);
9389 if (test_c_ind_mask_bit(plci, (
word)(Id - 1)))
9391 clear_c_ind_mask_bit(plci, (
word)(Id - 1));
9392 if (c_ind_mask_empty(plci))
9401 if (plci->
appl ==
this)
9413 if (appls_found == 1)
9415 if ((j = get_plci(a)))
9417 plci = &a->
plci[j - 1];
9419 add_p(plci,
OAD,
"\x01\xfd");
9420 add_p(plci,
CAI,
"\x01\x80");
9421 add_p(plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
9423 add_p(plci,
SIN,
"\x02\x00\x00");
9426 add_p(plci,
FTY,
"\x02\xff\x06");
9434 this->NullCREnable =
false;
9454 static word plci_remove_check(
PLCI *plci)
9456 if (!plci)
return true;
9457 if (!plci->
NL.
Id && c_ind_mask_empty(plci))
9459 if (plci->
Sig.
Id == 0xff)
9467 CodecIdCheck(plci->
adapter, plci);
9468 clear_b1_config(plci);
9469 ncci_remove(plci, 0,
false);
9470 plci_free_msg_in_queue(plci);
9471 channel_flow_control_remove(plci);
9488 static byte plci_nl_busy(
PLCI *plci)
9509 } dtmf_digit_map[] =
9587 #define DTMF_DIGIT_MAP_ENTRIES ARRAY_SIZE(dtmf_digit_map)
9590 static void dtmf_enable_receiver(
PLCI *plci,
byte enable_mask)
9592 word min_digit_duration, min_gap_duration;
9594 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_enable_receiver %02x",
9596 (
char *)(
FILE_), __LINE__, enable_mask));
9598 if (enable_mask != 0)
9628 static void dtmf_send_digits(
PLCI *plci,
byte *digit_buffer,
word digit_count)
9632 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_send_digits %d",
9634 (
char *)(
FILE_), __LINE__, digit_count));
9641 for (i = 0; i < digit_count; i++)
9645 && (digit_buffer[
i] != dtmf_digit_map[
w].character))
9661 static void dtmf_rec_clear_config(
PLCI *plci)
9664 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_rec_clear_config",
9666 (
char *)(
FILE_), __LINE__));
9677 static void dtmf_send_clear_config(
PLCI *plci)
9680 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_send_clear_config",
9682 (
char *)(
FILE_), __LINE__));
9690 static void dtmf_prepare_switch(
dword Id,
PLCI *plci)
9693 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_prepare_switch",
9697 dtmf_confirmation(Id, plci);
9704 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_save_config %02x %d",
9715 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_restore_config %02x %d",
9725 if (plci_nl_busy(plci))
9734 if ((Rc !=
OK) && (Rc !=
OK_FC))
9736 dbug(1,
dprintf(
"[%06lx] %s,%d: Reenable DTMF receiver failed %02x",
9750 word internal_command, Info;
9754 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_command %02x %04x %04x %d %d %d %d",
9774 switch (internal_command)
9780 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
9782 dbug(1,
dprintf(
"[%06lx] %s,%d: Load DTMF failed",
9790 if (plci_nl_busy(plci))
9799 if ((Rc !=
OK) && (Rc !=
OK_FC))
9801 dbug(1,
dprintf(
"[%06lx] %s,%d: Enable DTMF receiver failed %02x",
9821 switch (internal_command)
9854 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
9856 dbug(1,
dprintf(
"[%06lx] %s,%d: Unload DTMF failed",
9874 switch (internal_command)
9881 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
9883 dbug(1,
dprintf(
"[%06lx] %s,%d: Load DTMF failed",
9891 if (plci_nl_busy(plci))
9901 if ((Rc !=
OK) && (Rc !=
OK_FC))
9903 dbug(1,
dprintf(
"[%06lx] %s,%d: Send DTMF digits failed %02x",
9935 dbug(1,
dprintf(
"[%06lx] %s,%d: Facility not supported",
9939 else if (api_parse(&msg[1].info[1], msg[1].length,
"w", dtmf_parms))
9941 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
9950 & (1L << PRIVATE_DTMF_TONE)))
9952 dbug(1,
dprintf(
"[%06lx] %s,%d: DTMF unknown request %04x",
9953 UnMapId(Id), (
char *)(
FILE_), __LINE__, GET_WORD(dtmf_parms[0].info)));
9958 for (i = 0; i < 32; i++)
9965 result[4 + (dtmf_digit_map[
i].character >> 3)] |= (1 << (dtmf_digit_map[i].
character & 0x7));
9973 result[4 + (dtmf_digit_map[
i].character >> 3)] |= (1 << (dtmf_digit_map[i].
character & 0x7));
9981 else if (plci ==
NULL)
9999 plci->
dtmf_cmd = GET_WORD(dtmf_parms[0].info);
10011 & (1L << PRIVATE_DTMF_TONE)))
10013 dbug(1,
dprintf(
"[%06lx] %s,%d: DTMF unknown request %04x",
10014 UnMapId(Id), (
char *)(
FILE_), __LINE__, GET_WORD(dtmf_parms[0].info)));
10024 dbug(1,
dprintf(
"[%06lx] %s,%d: Facility not supported",
10031 if (api_parse(&msg[1].info[1], msg[1].length,
"wwws", dtmf_parms))
10042 start_internal_command(Id, plci, dtmf_command);
10051 & (1L << PRIVATE_DTMF_TONE)))
10053 dbug(1,
dprintf(
"[%06lx] %s,%d: DTMF unknown request %04x",
10054 UnMapId(Id), (
char *)(
FILE_), __LINE__, GET_WORD(dtmf_parms[0].info)));
10060 if (api_parse(&msg[1].info[1], msg[1].length,
"wwws", dtmf_parms))
10062 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
10067 if (mask & DTMF_LISTEN_ACTIVE_FLAG)
10074 while ((i < dtmf_parms[3].length) && (j < DTMF_DIGIT_MAP_ENTRIES))
10077 while ((j < DTMF_DIGIT_MAP_ENTRIES)
10078 && ((dtmf_parms[3].info[i + 1] != dtmf_digit_map[j].
character)
10079 || ((dtmf_digit_map[j].
send_mask & mask) == 0)))
10085 if (j == DTMF_DIGIT_MAP_ENTRIES)
10087 dbug(1,
dprintf(
"[%06lx] %s,%d: Incorrect DTMF digit %02x",
10088 UnMapId(Id), (
char *)(
FILE_), __LINE__, dtmf_parms[3].info[i]));
10094 dbug(1,
dprintf(
"[%06lx] %s,%d: DTMF request overrun",
10099 api_save_msg(dtmf_parms,
"wwws", &plci->
saved_msg);
10100 start_internal_command(Id, plci, dtmf_command);
10104 dbug(1,
dprintf(
"[%06lx] %s,%d: DTMF unknown request %04x",
10116 static void dtmf_confirmation(
dword Id,
PLCI *plci)
10121 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_confirmation",
10141 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_indication",
10145 for (i = 1; i <
length; i++)
10148 while ((j < DTMF_DIGIT_MAP_ENTRIES)
10149 && ((msg[i] != dtmf_digit_map[j].code)
10154 if (j < DTMF_DIGIT_MAP_ENTRIES)
10163 for (i = length; i > n + 1; i--)
10164 msg[i] = msg[i - 1];
10172 msg[++
n] = dtmf_digit_map[
j].character;
10187 static void dtmf_parameter_write(
PLCI *plci)
10192 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_parameter_write",
10194 (
char *)(
FILE_), __LINE__));
10200 add_p(plci,
FTY, parameter_buffer);
10206 static void dtmf_parameter_clear_config(
PLCI *plci)
10209 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_parameter_clear_config",
10211 (
char *)(
FILE_), __LINE__));
10217 static void dtmf_parameter_prepare_switch(
dword Id,
PLCI *plci)
10220 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_parameter_prepare_switch",
10229 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_parameter_save_config %02x %d",
10240 dbug(1,
dprintf(
"[%06lx] %s,%d: dtmf_parameter_restore_config %02x %d",
10256 dtmf_parameter_write(plci);
10260 if ((Rc !=
OK) && (Rc !=
OK_FC))
10262 dbug(1,
dprintf(
"[%06lx] %s,%d: Restore DTMF parameters failed %02x",
10302 if (pchannelmap) *pchannelmap = 0;
10303 if (!chi[0])
return 0xff;
10306 if (chi[1] & 0x20) {
10307 if (chi[0] == 1 && chi[1] == 0xac)
return 0xfd;
10308 for (i = 1; i < chi[0] && !(chi[
i] & 0x80); i++);
10309 if (i == chi[0] || !(chi[i] & 0x80))
return 0xfe;
10310 if ((chi[1] | 0xc8) != 0xe9)
return 0xfe;
10311 if (chi[1] & 0x08) excl = 0x40;
10314 if (chi[1] & 0x40) {
10316 for (i = p; i < chi[0] && !(chi[
i] & 0x80); i++);
10317 if (i == chi[0] || !(chi[i] & 0x80))
return 0xfe;
10322 for (i = p; i < chi[0] && !(chi[
i] & 0x80); i++);
10323 if (i == chi[0] || !(chi[i] & 0x80))
return 0xfe;
10324 if ((chi[p] | 0xd0) != 0xd3)
return 0xfe;
10327 if (chi[p] & 0x10) {
10330 if ((chi[0] - p) == 4) ofs = 0;
10331 else if ((chi[0] - p) == 3) ofs = 1;
10335 for (i = 0; i < 4 && p < chi[0]; i++) {
10340 for (ch = 0; !(chi[
p] & (1 << ch)); ch++);
10351 ch = chi[
p] & 0x3f;
10353 if ((
byte)(chi[0] -
p) > 30)
return 0xfe;
10355 for (i = p; i <= chi[0]; i++) {
10356 if ((chi[i] & 0x7f) > 31)
return 0xfe;
10357 map |= (1
L << (chi[
i] & 0x7f));
10361 if (p != chi[0])
return 0xfe;
10362 if (ch > 31)
return 0xfe;
10365 if (chi[p] & 0x40)
return 0xfe;
10367 if (pchannelmap) *pchannelmap =
map;
10368 else if (map != ((
dword)(1
L << ch)))
return 0xfe;
10369 return (
byte)(excl | ch);
10372 for (i = 1; i < chi[0] && !(chi[
i] & 0x80); i++);
10373 if (i != chi[0] || !(chi[i] & 0x80))
return 0xfe;
10374 if (chi[1] & 0x08) excl = 0x40;
10376 switch (chi[1] | 0x98) {
10377 case 0x98:
return 0;
10379 if (pchannelmap) *pchannelmap = 2;
10382 if (pchannelmap) *pchannelmap = 4;
10384 case 0x9b:
return 0xff;
10385 case 0x9c:
return 0xfd;
10386 default:
return 0xfe;
10392 static void mixer_set_bchannel_id_esc(
PLCI *plci,
byte bchannel_id)
10402 if ((old_id != 0) && (li_config_table[a->
li_base + (old_id - 1)].
plci == plci))
10403 li_config_table[a->
li_base + (old_id - 1)].plci =
NULL;
10410 if (((bchannel_id & 0x03) == 1) || ((bchannel_id & 0x03) == 2))
10412 if ((old_id != 0) && (li_config_table[a->
li_base + (old_id - 1)].plci == plci))
10427 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_set_bchannel_id_esc %d",
10439 mixer_clear_config(plci);
10441 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_set_bchannel_id_esc %d %d",
10447 static void mixer_set_bchannel_id(
PLCI *plci,
byte *chi)
10455 ch = chi_to_channel(chi,
NULL);
10460 if ((old_id != 0) && (li_config_table[a->
li_base + (old_id - 1)].
plci == plci))
10461 li_config_table[a->
li_base + (old_id - 1)].plci =
NULL;
10468 if (((ch & 0x1f) == 1) || ((ch & 0x1f) == 2))
10470 if ((old_id != 0) && (li_config_table[a->
li_base + (old_id - 1)].plci == plci))
10485 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_set_bchannel_id %d",
10498 mixer_clear_config(plci);
10500 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_set_bchannel_id %02x %d",
10506 #define MIXER_MAX_DUMP_CHANNELS 34
10510 static char hex_digit_table[0x10] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
10515 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_calculate_coefs",
10521 if (li_config_table[i].chflags != 0)
10527 if (((li_config_table[i].flag_table[j]) != 0)
10528 || ((li_config_table[j].flag_table[i]) != 0))
10533 || ((li_config_table[j].flag_table[i] & LI_FLAG_CONFERENCE) != 0))
10555 if (li_config_table[i].channel & LI_CHANNEL_CONFERENCE)
10590 if (li_config_table[i].flag_table[j] &
LI_FLAG_MIX)
10623 if (li_config_table[n].flag_table[i] & LI_FLAG_INTERCONNECT)
10626 if (li_config_table[j].chflags & LI_CHFLAG_MIX)
10629 if (li_config_table[n].chflags & LI_CHFLAG_MONITOR)
10632 else if (li_config_table[n].chflags & LI_CHFLAG_MONITOR)
10653 if ((li_config_table[i].flag_table[j] &
10679 if (j < li_total_channels)
10694 for (j = 0; j <
n; j++)
10696 if ((j & 0x7) == 0)
10698 *(p++) = hex_digit_table[li_config_table[j].curchnl >> 4];
10699 *(p++) = hex_digit_table[li_config_table[j].curchnl & 0xf];
10705 for (j = 0; j <
n; j++)
10707 if ((j & 0x7) == 0)
10709 *(p++) = hex_digit_table[li_config_table[j].channel >> 4];
10710 *(p++) = hex_digit_table[li_config_table[j].channel & 0xf];
10716 for (j = 0; j <
n; j++)
10718 if ((j & 0x7) == 0)
10720 *(p++) = hex_digit_table[li_config_table[j].chflags >> 4];
10721 *(p++) = hex_digit_table[li_config_table[j].chflags & 0xf];
10726 for (i = 0; i <
n; i++)
10729 for (j = 0; j <
n; j++)
10731 if ((j & 0x7) == 0)
10733 *(p++) = hex_digit_table[li_config_table[i].flag_table[j] >> 4];
10734 *(p++) = hex_digit_table[li_config_table[i].flag_table[j] & 0xf];
10740 for (i = 0; i <
n; i++)
10743 for (j = 0; j <
n; j++)
10745 if ((j & 0x7) == 0)
10747 *(p++) = hex_digit_table[li_config_table[i].coef_table[j] >> 4];
10748 *(p++) = hex_digit_table[li_config_table[i].coef_table[j] & 0xf];
10761 } mixer_write_prog_pri[] =
10775 } mixer_write_prog_bri[] =
10815 static byte mixer_swapped_index_bri[] =
10860 } xconnect_write_prog[] =
10869 static void xconnect_query_addresses(
PLCI *plci)
10875 dbug(1,
dprintf(
"[%06lx] %s,%d: xconnect_query_addresses",
10877 (
char *)(
FILE_), __LINE__));
10883 dbug(1,
dprintf(
"[%06x] %s,%d: Channel id wiped out",
10885 (
char *)(
FILE_), __LINE__));
10893 *(p++) = (
byte)(w >> 8);
10896 *(p++) = (
byte)(w >> 8);
10906 static void xconnect_write_coefs(
PLCI *plci,
word internal_command)
10909 dbug(1,
dprintf(
"[%06lx] %s,%d: xconnect_write_coefs %04x",
10911 (
char *)(
FILE_), __LINE__, internal_command));
10927 dbug(1,
dprintf(
"[%06x] %s,%d: xconnect_write_coefs_process %02x %d",
10934 dbug(1,
dprintf(
"[%06x] %s,%d: Channel id wiped out",
10943 if ((Rc !=
OK) && (Rc !=
OK_FC))
10945 dbug(1,
dprintf(
"[%06lx] %s,%d: LI write coefs failed %02x",
10954 if (j < li_total_channels)
10958 s = ((li_config_table[
i].
send_b.card_address.low | li_config_table[
i].
send_b.card_address.high) ?
10960 ((li_config_table[
i].
send_pc.card_address.low | li_config_table[
i].
send_pc.card_address.high) ?
10963 r = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
10964 while ((j < li_total_channels)
10966 || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET))
10967 || (!li_config_table[j].adapter->
li_pri
10969 || (((li_config_table[j].send_b.card_address.low != li_config_table[i].
send_b.card_address.low)
10970 || (li_config_table[
j].
send_b.card_address.high != li_config_table[
i].
send_b.card_address.high))
10975 ((li_config_table[j].send_b.card_address.low | li_config_table[j].
send_b.card_address.high) ?
10977 ((li_config_table[j].send_pc.card_address.low | li_config_table[j].
send_pc.card_address.high) ?
10981 if (j < li_total_channels)
10982 r = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
10985 if (j < li_total_channels)
10988 if (plci_nl_busy(plci))
10997 ((li_config_table[
j].
send_b.card_address.low | li_config_table[
j].
send_b.card_address.high) ?
11005 if (r & xconnect_write_prog[n].mask)
11007 if (xconnect_write_prog[n].
from_pc)
11008 transfer_address = &(li_config_table[
j].
send_pc);
11010 transfer_address = &(li_config_table[
j].
send_b);
11013 *(p++) = (
byte)(d >> 8);
11014 *(p++) = (
byte)(d >> 16);
11015 *(p++) = (
byte)(d >> 24);
11018 *(p++) = (
byte)(d >> 8);
11019 *(p++) = (
byte)(d >> 16);
11020 *(p++) = (
byte)(d >> 24);
11021 d = transfer_address->
offset;
11023 *(p++) = (
byte)(d >> 8);
11024 *(p++) = (
byte)(d >> 16);
11025 *(p++) = (
byte)(d >> 24);
11028 *(p++) = (
byte)(w >> 8);
11029 w = ((li_config_table[
i].
coef_table[
j] & xconnect_write_prog[
n].mask) == 0) ? 0x01 :
11032 (li_config_table[j].adapter->
u_law ? 0x7a : 0x80));
11035 li_config_table[
i].
coef_table[
j] ^= xconnect_write_prog[
n].mask << 4;
11038 }
while ((n <
ARRAY_SIZE(xconnect_write_prog))
11045 if (j < li_total_channels)
11046 r = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
11047 }
while ((j < li_total_channels)
11049 || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET))
11050 || (!li_config_table[j].adapter->
li_pri
11052 || (((li_config_table[j].send_b.card_address.low != li_config_table[i].
send_b.card_address.low)
11053 || (li_config_table[
j].
send_b.card_address.high != li_config_table[
i].
send_b.card_address.high))
11058 ((li_config_table[j].send_b.card_address.low | li_config_table[j].
send_b.card_address.high) ?
11060 ((li_config_table[j].send_pc.card_address.low | li_config_table[j].
send_pc.card_address.high) ?
11063 }
while ((j < li_total_channels)
11066 else if (j == li_total_channels)
11069 if (plci_nl_busy(plci))
11080 *(p++) = (
byte)(w >> 8);
11091 if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
11093 if (li_config_table[i].channel & LI_CHANNEL_RX_DATA)
11096 *(p++) = (
byte)(w >> 8);
11097 for (j = 0; j <
sizeof(ch_map); j += 2)
11101 ch_map[
j] = (
byte)(j + 1);
11102 ch_map[j + 1] = (
byte) j;
11106 ch_map[
j] = (
byte) j;
11107 ch_map[j + 1] = (
byte)(j + 1);
11110 for (n = 0; n <
ARRAY_SIZE(mixer_write_prog_bri); n++)
11112 i = a->
li_base + ch_map[mixer_write_prog_bri[
n].to_ch];
11113 j = a->
li_base + ch_map[mixer_write_prog_bri[
n].from_ch];
11116 *p = (mixer_write_prog_bri[
n].xconnect_override != 0) ?
11118 ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01);
11121 w = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
11122 li_config_table[
i].
coef_table[
j] ^= (w & mixer_write_prog_bri[
n].mask) << 4;
11130 w = (plci == a->
AdvSignalPLCI) ? n : mixer_swapped_index_bri[n];
11138 j = li_total_channels + 1;
11143 if (j <= li_total_channels)
11146 if (plci_nl_busy(plci))
11148 if (j < a->li_base)
11154 if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
11156 if (li_config_table[i].channel & LI_CHANNEL_RX_DATA)
11159 *(p++) = (
byte)(w >> 8);
11160 for (n = 0; n <
ARRAY_SIZE(mixer_write_prog_pri); n++)
11165 w = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
11166 if (w & mixer_write_prog_pri[n].mask)
11168 *(p++) = (li_config_table[i].coef_table[j] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01;
11169 li_config_table[
i].
coef_table[
j] ^= mixer_write_prog_pri[
n].mask << 4;
11177 w = ((li_config_table[
j].
coef_table[
i] & 0xf) ^ (li_config_table[j].coef_table[i] >> 4));
11178 if (w & mixer_write_prog_pri[n].mask)
11180 *(p++) = (li_config_table[j].coef_table[i] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01;
11181 li_config_table[
j].
coef_table[
i] ^= mixer_write_prog_pri[
n].mask << 4;
11197 if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
11199 if (li_config_table[i].channel & LI_CHANNEL_RX_DATA)
11202 *(p++) = (
byte)(w >> 8);
11203 for (j = 0; j <
sizeof(ch_map); j += 2)
11207 ch_map[
j] = (
byte)(j + 1);
11208 ch_map[j + 1] = (
byte) j;
11212 ch_map[
j] = (
byte) j;
11213 ch_map[j + 1] = (
byte)(j + 1);
11216 for (n = 0; n <
ARRAY_SIZE(mixer_write_prog_bri); n++)
11218 i = a->
li_base + ch_map[mixer_write_prog_bri[
n].to_ch];
11219 j = a->
li_base + ch_map[mixer_write_prog_bri[
n].from_ch];
11220 if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED)
11222 *p = ((li_config_table[
i].
coef_table[
j] & mixer_write_prog_bri[
n].mask) ? 0x80 : 0x01);
11223 w = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
11224 li_config_table[
i].
coef_table[
j] ^= (w & mixer_write_prog_bri[
n].mask) << 4;
11231 w = (plci == a->
AdvSignalPLCI) ? n : mixer_swapped_index_bri[n];
11239 j = li_total_channels + 1;
11256 static void mixer_notify_update(
PLCI *plci,
byte others)
11263 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_notify_update %d",
11265 (
char *)(
FILE_), __LINE__, others));
11275 notify_plci =
NULL;
11278 while ((i < li_total_channels) && (li_config_table[i].plci ==
NULL))
11280 if (i < li_total_channels)
11281 notify_plci = li_config_table[i++].
plci;
11288 notify_plci =
plci;
11291 if ((notify_plci !=
NULL)
11294 && (notify_plci->
State)
11298 ((
CAPI_MSG *) msg)->header.length = 18;
11301 ((
CAPI_MSG *) msg)->header.number = 0;
11303 ((
CAPI_MSG *) msg)->header.plci = notify_plci->
Id;
11304 ((
CAPI_MSG *) msg)->header.ncci = 0;
11306 ((
CAPI_MSG *) msg)->info.facility_req.structs[0] = 3;
11308 ((
CAPI_MSG *) msg)->info.facility_req.structs[3] = 0;
11314 dbug(1,
dprintf(
"[%06lx] %s,%d: Interconnect notify failed %06x %d",
11316 (
char *)(
FILE_), __LINE__,
11322 }
while (others && (notify_plci !=
NULL));
11329 static void mixer_clear_config(
PLCI *plci)
11334 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_clear_config",
11336 (
char *)(
FILE_), __LINE__));
11393 static void mixer_prepare_switch(
dword Id,
PLCI *plci)
11396 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_prepare_switch",
11401 mixer_indication_coefs_set(Id, plci);
11411 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_save_config %02x %d",
11436 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_restore_config %02x %d",
11451 if (plci_nl_busy(plci))
11456 xconnect_query_addresses(plci);
11465 if ((Rc !=
OK) && (Rc !=
OK_FC) && (Rc != 0))
11467 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B query addresses failed %02x",
11496 if (!xconnect_write_coefs_process(Id, plci, Rc))
11498 dbug(1,
dprintf(
"[%06lx] %s,%d: Write mixer coefs failed",
11517 word i, internal_command;
11519 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_command %02x %04x %04x",
11531 switch (internal_command)
11542 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
11544 dbug(1,
dprintf(
"[%06lx] %s,%d: Load mixer failed",
11563 mixer_indication_coefs_set(Id, plci);
11572 if (!xconnect_write_coefs_process(Id, plci, Rc))
11574 dbug(1,
dprintf(
"[%06lx] %s,%d: Write mixer coefs failed",
11600 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
11602 dbug(1,
dprintf(
"[%06lx] %s,%d: Unload mixer failed",
11616 dbug(1,
dprintf(
"[%06x] %s,%d: Channel id wiped out %d",
11640 word i, ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s;
11645 plci_b = &(a_b->
plci[((plci_b_id >> 8) & 0xff) - 1]);
11661 && (plci_b == a_b->
AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER))
11683 if (ch_a_v == ch_b_v)
11695 li_config_table[ch_a_v].
flag_table[
i] &= ~LI_FLAG_CONFERENCE;
11698 if (li_config_table[ch_a_s].flag_table[ch_b_v] & LI_FLAG_CONFERENCE)
11703 li_config_table[ch_a_s].
flag_table[
i] &= ~LI_FLAG_CONFERENCE;
11706 if (li_config_table[ch_b_v].flag_table[ch_a_v] & LI_FLAG_CONFERENCE)
11711 li_config_table[
i].
flag_table[ch_a_v] &= ~LI_FLAG_CONFERENCE;
11714 if (li_config_table[ch_b_v].flag_table[ch_a_s] & LI_FLAG_CONFERENCE)
11719 li_config_table[
i].
flag_table[ch_a_s] &= ~LI_FLAG_CONFERENCE;
11767 if (ch_a_v != ch_a_s)
11772 if (ch_b_v != ch_b_s)
11783 word ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s;
11788 plci_b = &(a_b->
plci[((plci_b_id >> 8) & 0xff) - 1]);
11804 && (plci_b == a_b->
AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER))
11875 if (ch_a_v != ch_a_s)
11880 if (ch_b_v != ch_b_s)
11918 dbug(1,
dprintf(
"[%06lx] %s,%d: LI request overrun",
11924 if ((plci_b_id & 0x7f) != 0)
11931 || (((plci_b_id >> 8) & 0xff) == 0)
11932 || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci))
11934 dbug(1,
dprintf(
"[%06lx] %s,%d: LI invalid second PLCI %08lx",
11939 plci_b = &(adapter[ctlr_b - 1].
plci[((plci_b_id >> 8) & 0xff) - 1]);
11944 dbug(1,
dprintf(
"[%06lx] %s,%d: LI peer in wrong state %08lx",
11950 if (((
byte)(plci_b_id & ~EXT_CONTROLLER)) !=
11955 dbug(1,
dprintf(
"[%06lx] %s,%d: LI not on same ctrl %08lx",
11960 if (!(get_b1_facilities(plci_b, add_b1_facilities(plci_b, plci_b->
B1_resource,
11963 dbug(1,
dprintf(
"[%06lx] %s,%d: Interconnect peer cannot mix %d",
11981 dbug(1,
dprintf(
"[%06lx] %s,%d: LI request overrun",
11987 if ((plci_b_id & 0x7f) != 0)
11994 || (((plci_b_id >> 8) & 0xff) == 0)
11995 || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci))
11997 dbug(1,
dprintf(
"[%06lx] %s,%d: LI invalid second PLCI %08lx",
12002 plci_b = &(adapter[ctlr_b - 1].
plci[((plci_b_id >> 8) & 0xff) - 1]);
12008 dbug(1,
dprintf(
"[%06lx] %s,%d: LI peer in wrong state %08lx",
12013 if (((
byte)(plci_b_id & ~EXT_CONTROLLER)) !=
12018 dbug(1,
dprintf(
"[%06lx] %s,%d: LI not on same ctrl %08lx",
12023 if (!(get_b1_facilities(plci_b, add_b1_facilities(plci_b, plci_b->
B1_resource,
12026 dbug(1,
dprintf(
"[%06lx] %s,%d: Interconnect peer cannot mix %d",
12039 dword d, li_flags, plci_b_id;
12045 word participant_parms_pos;
12046 byte result_buffer[32];
12049 word plci_b_write_pos;
12055 result = result_buffer;
12056 result_buffer[0] = 0;
12059 dbug(1,
dprintf(
"[%06lx] %s,%d: Facility not supported",
12063 else if (api_parse(&msg[1].info[1], msg[1].length,
"ws", li_parms))
12065 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12071 result_buffer[0] = 3;
12072 PUT_WORD(&result_buffer[1], GET_WORD(li_parms[0].info));
12073 result_buffer[3] = 0;
12074 switch (GET_WORD(li_parms[0].info))
12079 result_buffer[0] = 17;
12080 result_buffer[3] = 14;
12081 PUT_WORD(&result_buffer[4],
GOOD);
12091 PUT_DWORD(&result_buffer[6], d);
12109 PUT_DWORD(&result_buffer[10], d / 2);
12110 PUT_DWORD(&result_buffer[14], d);
12114 result_buffer[0] = 25;
12115 result_buffer[3] = 22;
12116 PUT_WORD(&result_buffer[4],
GOOD);
12126 PUT_DWORD(&result_buffer[6], d);
12128 PUT_DWORD(&result_buffer[10], d / 2);
12129 PUT_DWORD(&result_buffer[14], d - 1);
12143 PUT_DWORD(&result_buffer[18], d / 2);
12144 PUT_DWORD(&result_buffer[22], d - 1);
12149 if (li_parms[1].length == 8)
12152 if (api_parse(&li_parms[1].info[1], li_parms[1].length,
"dd", li_req_parms))
12154 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12159 plci_b_id = GET_DWORD(li_req_parms[0].info) & 0xffff;
12160 li_flags = GET_DWORD(li_req_parms[1].info);
12161 Info = li_check_main_plci(Id, plci);
12162 result_buffer[0] = 9;
12163 result_buffer[3] = 6;
12164 PUT_DWORD(&result_buffer[4], plci_b_id);
12165 PUT_WORD(&result_buffer[8],
GOOD);
12169 for (i = 0; i <= result_buffer[0]; i++)
12170 result[i] = result_buffer[i];
12172 plci_b = li_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[8]);
12173 if (plci_b ==
NULL)
12175 li_update_connect(Id, a, plci, plci_b_id,
true, li_flags);
12183 if (api_parse(&li_parms[1].info[1], li_parms[1].length,
"ds", li_req_parms))
12185 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12191 Info = li_check_main_plci(Id, plci);
12192 result_buffer[0] = 7;
12193 result_buffer[3] = 4;
12194 PUT_WORD(&result_buffer[4], Info);
12195 result_buffer[6] = 0;
12199 for (i = 0; i <= result_buffer[0]; i++)
12200 result[i] = result_buffer[i];
12202 participant_parms_pos = 0;
12204 li2_update_connect(Id, a, plci,
UnMapId(Id),
true, li_flags);
12205 while (participant_parms_pos < li_req_parms[1].length)
12207 result[result_pos] = 6;
12209 PUT_DWORD(&result[result_pos - 6], 0);
12210 PUT_WORD(&result[result_pos - 2],
GOOD);
12211 if (api_parse(&li_req_parms[1].info[1 + participant_parms_pos],
12212 (
word)(li_parms[1].length - participant_parms_pos),
"s", li_participant_struct))
12214 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12219 if (api_parse(&li_participant_struct[0].info[1],
12220 li_participant_struct[0].length,
"dd", li_participant_parms))
12222 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12227 plci_b_id = GET_DWORD(li_participant_parms[0].info) & 0xffff;
12228 li_flags = GET_DWORD(li_participant_parms[1].info);
12229 PUT_DWORD(&result[result_pos - 6], plci_b_id);
12230 if (
sizeof(result) - result_pos < 7)
12232 dbug(1,
dprintf(
"[%06lx] %s,%d: LI result overrun",
12237 plci_b = li2_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]);
12238 if (plci_b !=
NULL)
12240 li2_update_connect(Id, a, plci, plci_b_id,
true, li_flags);
12242 ((li_flags & (LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A |
12246 participant_parms_pos = (
word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) -
12247 (&li_req_parms[1].
info[1]));
12249 result[0] = (
byte)(result_pos - 1);
12250 result[3] = (
byte)(result_pos - 4);
12251 result[6] = (
byte)(result_pos - 7);
12263 mixer_calculate_coefs(a);
12265 mixer_notify_update(plci,
true);
12269 plci->
li_cmd = GET_WORD(li_parms[0].info);
12270 start_internal_command(Id, plci, mixer_command);
12274 if (li_parms[1].length == 4)
12277 if (api_parse(&li_parms[1].info[1], li_parms[1].length,
"d", li_req_parms))
12279 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12284 plci_b_id = GET_DWORD(li_req_parms[0].info) & 0xffff;
12285 Info = li_check_main_plci(Id, plci);
12286 result_buffer[0] = 9;
12287 result_buffer[3] = 6;
12288 PUT_DWORD(&result_buffer[4], GET_DWORD(li_req_parms[0].info));
12289 PUT_WORD(&result_buffer[8],
GOOD);
12293 for (i = 0; i <= result_buffer[0]; i++)
12294 result[i] = result_buffer[i];
12296 plci_b = li_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[8]);
12297 if (plci_b ==
NULL)
12299 li_update_connect(Id, a, plci, plci_b_id,
false, 0);
12307 if (api_parse(&li_parms[1].info[1], li_parms[1].length,
"s", li_req_parms))
12309 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12314 Info = li_check_main_plci(Id, plci);
12315 result_buffer[0] = 7;
12316 result_buffer[3] = 4;
12317 PUT_WORD(&result_buffer[4], Info);
12318 result_buffer[6] = 0;
12322 for (i = 0; i <= result_buffer[0]; i++)
12323 result[i] = result_buffer[i];
12325 participant_parms_pos = 0;
12327 while (participant_parms_pos < li_req_parms[0].length)
12329 result[result_pos] = 6;
12331 PUT_DWORD(&result[result_pos - 6], 0);
12332 PUT_WORD(&result[result_pos - 2],
GOOD);
12333 if (api_parse(&li_req_parms[0].info[1 + participant_parms_pos],
12334 (
word)(li_parms[1].length - participant_parms_pos),
"s", li_participant_struct))
12336 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12341 if (api_parse(&li_participant_struct[0].info[1],
12342 li_participant_struct[0].length,
"d", li_participant_parms))
12344 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12349 plci_b_id = GET_DWORD(li_participant_parms[0].info) & 0xffff;
12350 PUT_DWORD(&result[result_pos - 6], plci_b_id);
12351 if (
sizeof(result) - result_pos < 7)
12353 dbug(1,
dprintf(
"[%06lx] %s,%d: LI result overrun",
12358 plci_b = li2_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]);
12359 if (plci_b !=
NULL)
12361 li2_update_connect(Id, a, plci, plci_b_id,
false, 0);
12365 participant_parms_pos = (
word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) -
12366 (&li_req_parms[0].
info[1]));
12368 result[0] = (
byte)(result_pos - 1);
12369 result[3] = (
byte)(result_pos - 4);
12370 result[6] = (
byte)(result_pos - 7);
12382 mixer_calculate_coefs(a);
12384 mixer_notify_update(plci,
true);
12388 plci->
li_cmd = GET_WORD(li_parms[0].info);
12389 start_internal_command(Id, plci, mixer_command);
12393 if (!plci || !plci->
State
12406 dbug(1,
dprintf(
"[%06lx] %s,%d: LI request overrun",
12422 plci->
li_cmd = GET_WORD(li_parms[0].info);
12423 start_internal_command(Id, plci, mixer_command);
12427 dbug(1,
dprintf(
"[%06lx] %s,%d: LI unknown request %04x",
12428 UnMapId(Id), (
char *)(
FILE_), __LINE__, GET_WORD(li_parms[0].info)));
12438 static void mixer_indication_coefs_set(
dword Id,
PLCI *plci)
12443 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_indication_coefs_set",
12498 static void mixer_indication_xconnect_from(
dword Id,
PLCI *plci,
byte *msg,
word length)
12504 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_indication_xconnect_from %d",
12505 UnMapId(Id), (
char *)(
FILE_), __LINE__, (
int)length));
12509 for (i = 1; i <
length; i += 16)
12511 s.card_address.low = msg[
i] | (msg[i + 1] << 8) | (((
dword)(msg[i + 2])) << 16) | (((
dword)(msg[i + 3])) << 24);
12512 s.card_address.high = msg[i + 4] | (msg[i + 5] << 8) | (((
dword)(msg[i + 6])) << 16) | (((
dword)(msg[i + 7])) << 24);
12513 s.offset = msg[i + 8] | (msg[i + 9] << 8) | (((
dword)(msg[i + 10])) << 16) | (((
dword)(msg[i + 11])) << 24);
12514 ch = msg[i + 12] | (msg[i + 13] << 8);
12520 p = &(li_config_table[
j].
send_pc);
12522 p = &(li_config_table[
j].
send_b);
12534 if (!plci->internal_command)
12535 next_internal_command(Id, plci);
12537 mixer_notify_update(plci,
true);
12541 static void mixer_indication_xconnect_to(
dword Id,
PLCI *plci,
byte *msg,
word length)
12544 dbug(1,
dprintf(
"[%06lx] %s,%d: mixer_indication_xconnect_to %d",
12545 UnMapId(Id), (
char *)(
FILE_), __LINE__, (
int) length));
12550 static byte mixer_notify_source_removed(
PLCI *plci,
dword plci_b_id)
12552 word plci_b_write_pos;
12558 dbug(1,
dprintf(
"[%06lx] %s,%d: LI request overrun",
12560 (
char *)(
FILE_), __LINE__));
12570 static void mixer_remove(
PLCI *plci)
12579 (
char *)(
FILE_), __LINE__));
12596 notify_plci = li_config_table[
j].
plci;
12597 if ((notify_plci !=
NULL)
12598 && (notify_plci !=
plci)
12601 && (notify_plci->
State)
12604 mixer_notify_source_removed(notify_plci, plci_b_id);
12608 mixer_clear_config(plci);
12609 mixer_calculate_coefs(a);
12610 mixer_notify_update(plci,
true);
12624 static void ec_write_parameters(
PLCI *plci)
12627 byte parameter_buffer[6];
12629 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_write_parameters",
12631 (
char *)(
FILE_), __LINE__));
12633 parameter_buffer[0] = 5;
12638 PUT_WORD(¶meter_buffer[4], w);
12639 add_p(plci,
FTY, parameter_buffer);
12645 static void ec_clear_config(
PLCI *plci)
12648 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_clear_config",
12650 (
char *)(
FILE_), __LINE__));
12658 static void ec_prepare_switch(
dword Id,
PLCI *plci)
12661 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_prepare_switch",
12670 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_save_config %02x %d",
12681 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_restore_config %02x %d",
12696 ec_write_parameters(plci);
12700 if ((Rc !=
OK) && (Rc !=
OK_FC))
12702 dbug(1,
dprintf(
"[%06lx] %s,%d: Restore EC failed %02x",
12716 word internal_command, Info;
12719 dbug(1,
dprintf(
"[%06lx] %s,%d: ec_command %02x %04x %04x %04x %d",
12732 PUT_WORD(&result[1], plci->
ec_cmd);
12734 PUT_WORD(&result[4],
GOOD);
12744 switch (internal_command)
12750 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
12766 ec_write_parameters(plci);
12769 if ((Rc !=
OK) && (Rc !=
OK_FC))
12771 dbug(1,
dprintf(
"[%06lx] %s,%d: Enable EC failed %02x",
12781 switch (internal_command)
12793 ec_write_parameters(plci);
12798 if ((Rc !=
OK) && (Rc !=
OK_FC))
12800 dbug(1,
dprintf(
"[%06lx] %s,%d: Disable EC failed %02x",
12808 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
12810 dbug(1,
dprintf(
"[%06lx] %s,%d: Unload EC failed",
12841 dbug(1,
dprintf(
"[%06lx] %s,%d: Facility not supported",
12849 if (api_parse(&msg[1].info[1], msg[1].length,
"w", ec_parms))
12851 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12872 plci->
ec_cmd = GET_WORD(ec_parms[0].info);
12876 if (msg[1].length >= 4)
12878 opt = GET_WORD(&ec_parms[0].info[2]);
12887 if (msg[1].length >= 6)
12896 start_internal_command(Id, plci,
ec_command);
12903 start_internal_command(Id, plci,
ec_command);
12908 start_internal_command(Id, plci,
ec_command);
12913 start_internal_command(Id, plci,
ec_command);
12918 start_internal_command(Id, plci,
ec_command);
12922 dbug(1,
dprintf(
"[%06lx] %s,%d: EC unknown request %04x",
12931 if (api_parse(&msg[1].info[1], msg[1].length,
"ws", ec_parms))
12933 dbug(1,
dprintf(
"[%06lx] %s,%d: Wrong message format",
12944 PUT_WORD(&result[4],
GOOD);
12945 PUT_WORD(&result[6], 0x0007);
12947 PUT_WORD(&result[10], 0);
12949 else if (plci ==
NULL)
12964 plci->
ec_cmd = GET_WORD(ec_parms[0].info);
12967 PUT_WORD(&result[1], plci->
ec_cmd);
12969 PUT_WORD(&result[4],
GOOD);
12973 if (ec_parms[1].length >= 2)
12975 opt = GET_WORD(&ec_parms[1].info[1]);
12978 if (opt & EC_DETECT_DISABLE_TONE)
12980 if (!(opt & EC_DO_NOT_REQUIRE_REVERSALS))
12982 if (ec_parms[1].length >= 4)
12991 start_internal_command(Id, plci,
ec_command);
12998 start_internal_command(Id, plci,
ec_command);
13002 dbug(1,
dprintf(
"[%06lx] %s,%d: EC unknown request %04x",
13029 PUT_WORD(&result[1], 0);
13048 PUT_WORD(&result[4], 0);
13073 static void adv_voice_write_coefs(
PLCI *plci,
word write_command)
13084 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_write_coefs %d",
13086 (
char *)(
FILE_), __LINE__, write_command));
13089 p = coef_buffer + 1;
13100 PUT_WORD(p, 0x8000);
13111 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_set_bchannel_id %d",
13119 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_set_bchannel_id %d",
13128 switch (write_command)
13145 mixer_calculate_coefs(a);
13173 mixer_calculate_coefs(a);
13181 if (li_config_table[i].channel & LI_CHANNEL_TX_DATA)
13183 if (li_config_table[i].channel & LI_CHANNEL_RX_DATA)
13186 *(p++) = (
byte)(w >> 8);
13187 for (j = 0; j <
sizeof(ch_map); j += 2)
13192 for (n = 0; n <
ARRAY_SIZE(mixer_write_prog_bri); n++)
13194 i = a->
li_base + ch_map[mixer_write_prog_bri[
n].to_ch];
13195 j = a->
li_base + ch_map[mixer_write_prog_bri[
n].from_ch];
13196 if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED)
13198 *(p++) = ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01);
13199 w = ((li_config_table[
i].
coef_table[
j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4));
13200 li_config_table[
i].
coef_table[
j] ^= (w & mixer_write_prog_bri[
n].mask) << 4;
13221 coef_buffer[0] = (p - coef_buffer) - 1;
13222 add_p(plci,
FTY, coef_buffer);
13228 static void adv_voice_clear_config(
PLCI *plci)
13235 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_clear_config",
13237 (
char *)(
FILE_), __LINE__));
13290 static void adv_voice_prepare_switch(
dword Id,
PLCI *plci)
13293 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_prepare_switch",
13302 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_save_config %02x %d",
13314 dbug(1,
dprintf(
"[%06lx] %s,%d: adv_voice_restore_config %02x %d",
13335 if ((Rc !=
OK) && (Rc !=
OK_FC))
13337 dbug(1,
dprintf(
"[%06lx] %s,%d: Restore voice config failed %02x",
13355 static byte b1_facilities_table[] =
13399 static word get_b1_facilities(
PLCI *plci,
byte b1_resource)
13401 word b1_facilities;
13403 b1_facilities = b1_facilities_table[b1_resource];
13404 if ((b1_resource == 9) || (b1_resource == 20) || (b1_resource == 25))
13417 if ((b1_resource == 17) || (b1_resource == 18))
13427 return (b1_facilities);
13431 static byte add_b1_facilities(
PLCI *plci,
byte b1_resource,
word b1_facilities)
13435 switch (b1_resource)
13479 if (b1_facilities & B1_FACILITY_LOCAL)
13490 && ((b1_facilities & B1_FACILITY_MIXER)
13493 && ((b1_facilities & B1_FACILITY_MIXER)
13496 if (b1_facilities & B1_FACILITY_LOCAL)
13505 if (b1_facilities & B1_FACILITY_LOCAL)
13517 if (b1_facilities & B1_FACILITY_LOCAL)
13528 dbug(1,
dprintf(
"[%06lx] %s,%d: add_b1_facilities %d %04x %d %04x",
13530 (
char *)(
FILE_), __LINE__,
13531 b1_resource, b1_facilities, b, get_b1_facilities(plci, b)));
13536 static void adjust_b1_facilities(
PLCI *plci,
byte new_b1_resource,
word new_b1_facilities)
13538 word removed_facilities;
13540 dbug(1,
dprintf(
"[%06lx] %s,%d: adjust_b1_facilities %d %04x %04x",
13542 (
char *)(
FILE_), __LINE__, new_b1_resource, new_b1_facilities,
13543 new_b1_facilities & get_b1_facilities(plci, new_b1_resource)));
13545 new_b1_facilities &= get_b1_facilities(plci, new_b1_resource);
13546 removed_facilities = plci->
B1_facilities & ~new_b1_facilities;
13548 if (removed_facilities & B1_FACILITY_EC)
13549 ec_clear_config(plci);
13552 if (removed_facilities & B1_FACILITY_DTMFR)
13554 dtmf_rec_clear_config(plci);
13555 dtmf_parameter_clear_config(plci);
13557 if (removed_facilities & B1_FACILITY_DTMFX)
13558 dtmf_send_clear_config(plci);
13561 if (removed_facilities & B1_FACILITY_MIXER)
13562 mixer_clear_config(plci);
13565 adv_voice_clear_config(plci);
13570 static void adjust_b_clear(
PLCI *plci)
13575 (
char *)(
FILE_), __LINE__));
13588 dbug(1,
dprintf(
"[%06lx] %s,%d: adjust_b_process %02x %d",
13609 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B nonsupported facilities %d %d %04x",
13619 mixer_prepare_switch(Id, plci);
13622 dtmf_prepare_switch(Id, plci);
13623 dtmf_parameter_prepare_switch(Id, plci);
13626 ec_prepare_switch(Id, plci);
13628 adv_voice_prepare_switch(Id, plci);
13636 Info = mixer_save_config(Id, plci, Rc);
13647 Info = dtmf_save_config(Id, plci, Rc);
13669 nl_req_ncci(plci,
REMOVE,
13678 if ((Rc !=
OK) && (Rc !=
OK_FC))
13680 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B remove failed %02x",
13687 if (plci_nl_busy(plci))
13699 Info = ec_save_config(Id, plci, Rc);
13710 Info = dtmf_parameter_save_config(Id, plci, Rc);
13720 Info = adv_voice_save_config(Id, plci, Rc);
13737 Info = add_b1(plci, bp,
13742 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B invalid L1 parameters %d %04x",
13756 if ((Rc !=
OK) && (Rc !=
OK_FC))
13758 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B switch failed %02x %d %04x",
13770 Info = adv_voice_restore_config(Id, plci, Rc);
13781 Info = dtmf_parameter_restore_config(Id, plci, Rc);
13793 Info = ec_restore_config(Id, plci, Rc);
13802 if (plci_nl_busy(plci))
13813 Info = add_b23(plci, bp);
13816 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B invalid L23 parameters %04x",
13821 nl_req_ncci(plci,
ASSIGN, 0);
13831 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B assign failed %02x",
13854 if (plci_nl_busy(plci))
13866 if ((Rc !=
OK) && (Rc !=
OK_FC) && (Rc != 0))
13868 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B connect failed %02x",
13903 Info = dtmf_restore_config(Id, plci, Rc);
13920 Info = mixer_restore_config(Id, plci, Rc);
13936 dbug(1,
dprintf(
"[%06lx] %s,%d: adjust_b1_resource %d %04x",
13949 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B1 resource %d %04x...",
13955 static void adjust_b_restore(
dword Id,
PLCI *plci,
byte Rc)
13957 word internal_command;
13959 dbug(1,
dprintf(
"[%06lx] %s,%d: adjust_b_restore %02x %04x",
13964 switch (internal_command)
13975 if ((Rc !=
OK) && (Rc !=
OK_FC))
13977 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B enqueued failed %02x",
13986 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B restore...",
13989 if (adjust_b_process(Id, plci, Rc) !=
GOOD)
13991 dbug(1,
dprintf(
"[%06lx] %s,%d: Adjust B restore failed",
14001 static void reset_b3_command(
dword Id,
PLCI *plci,
byte Rc)
14004 word internal_command;
14006 dbug(1,
dprintf(
"[%06lx] %s,%d: reset_b3_command %02x %04x",
14012 switch (internal_command)
14025 Info = adjust_b_process(Id, plci, Rc);
14041 static void select_b_command(
dword Id,
PLCI *plci,
byte Rc)
14044 word internal_command;
14047 dbug(1,
dprintf(
"[%06lx] %s,%d: select_b_command %02x %04x",
14053 switch (internal_command)
14075 dbug(1,
dprintf(
"[%06lx] %s,%d: Select B protocol...",
14078 Info = adjust_b_process(Id, plci, Rc);
14081 dbug(1,
dprintf(
"[%06lx] %s,%d: Select B protocol failed",
14100 static void fax_connect_ack_command(
dword Id,
PLCI *plci,
byte Rc)
14102 word internal_command;
14104 dbug(1,
dprintf(
"[%06lx] %s,%d: fax_connect_ack_command %02x %04x",
14109 switch (internal_command)
14114 if (plci_nl_busy(plci))
14128 if ((Rc !=
OK) && (Rc !=
OK_FC))
14130 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX issue CONNECT ACK failed %02x",
14147 static void fax_edata_ack_command(
dword Id,
PLCI *plci,
byte Rc)
14149 word internal_command;
14151 dbug(1,
dprintf(
"[%06lx] %s,%d: fax_edata_ack_command %02x %04x",
14156 switch (internal_command)
14161 if (plci_nl_busy(plci))
14175 if ((Rc !=
OK) && (Rc !=
OK_FC))
14177 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX issue EDATA ACK failed %02x",
14185 static void fax_connect_info_command(
dword Id,
PLCI *plci,
byte Rc)
14188 word internal_command;
14190 dbug(1,
dprintf(
"[%06lx] %s,%d: fax_connect_info_command %02x %04x",
14196 switch (internal_command)
14201 if (plci_nl_busy(plci))
14215 if ((Rc !=
OK) && (Rc !=
OK_FC))
14217 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX setting connect info failed %02x",
14222 if (plci_nl_busy(plci))
14236 static void fax_adjust_b23_command(
dword Id,
PLCI *plci,
byte Rc)
14239 word internal_command;
14241 dbug(1,
dprintf(
"[%06lx] %s,%d: fax_adjust_b23_command %02x %04x",
14247 switch (internal_command)
14257 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX adjust B23...",
14260 Info = adjust_b_process(Id, plci, Rc);
14263 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX adjust failed",
14270 if (plci_nl_busy(plci))
14284 static void fax_disconnect_command(
dword Id,
PLCI *plci,
byte Rc)
14286 word internal_command;
14288 dbug(1,
dprintf(
"[%06lx] %s,%d: fax_disconnect_command %02x %04x",
14293 switch (internal_command)
14302 if ((Rc !=
OK) && (Rc !=
OK_FC) && (Rc != 0))
14304 dbug(1,
dprintf(
"[%06lx] %s,%d: FAX disconnect EDATA failed %02x",
14327 static void rtp_connect_b3_req_command(
dword Id,
PLCI *plci,
byte Rc)
14330 word internal_command;
14332 dbug(1,
dprintf(
"[%06lx] %s,%d: rtp_connect_b3_req_command %02x %04x",
14338 switch (internal_command)
14343 if (plci_nl_busy(plci))
14353 if ((Rc !=
OK) && (Rc !=
OK_FC))
14355 dbug(1,
dprintf(
"[%06lx] %s,%d: RTP setting connect info failed %02x",
14360 if (plci_nl_busy(plci))
14380 static void rtp_connect_b3_res_command(
dword Id,
PLCI *plci,
byte Rc)
14382 word internal_command;
14384 dbug(1,
dprintf(
"[%06lx] %s,%d: rtp_connect_b3_res_command %02x %04x",
14389 switch (internal_command)
14394 if (plci_nl_busy(plci))
14404 if ((Rc !=
OK) && (Rc !=
OK_FC))
14406 dbug(1,
dprintf(
"[%06lx] %s,%d: RTP setting connect resp info failed %02x",
14410 if (plci_nl_busy(plci))
14431 static void hold_save_command(
dword Id,
PLCI *plci,
byte Rc)
14433 byte SS_Ind[] =
"\x05\x02\x00\x02\x00\x00";
14435 word internal_command;
14437 dbug(1,
dprintf(
"[%06lx] %s,%d: hold_save_command %02x %04x",
14443 switch (internal_command)
14458 Info = adjust_b_process(Id, plci, Rc);
14461 dbug(1,
dprintf(
"[%06lx] %s,%d: HOLD save failed",
14472 static void retrieve_restore_command(
dword Id,
PLCI *plci,
byte Rc)
14474 byte SS_Ind[] =
"\x05\x03\x00\x02\x00\x00";
14476 word internal_command;
14478 dbug(1,
dprintf(
"[%06lx] %s,%d: retrieve_restore_command %02x %04x",
14484 switch (internal_command)
14494 dbug(1,
dprintf(
"[%06lx] %s,%d: RETRIEVE restore...",
14497 Info = adjust_b_process(Id, plci, Rc);
14500 dbug(1,
dprintf(
"[%06lx] %s,%d: RETRIEVE restore failed",
14511 static void init_b1_config(
PLCI *plci)
14516 (
char *)(
FILE_), __LINE__));
14522 mixer_clear_config(plci);
14525 ec_clear_config(plci);
14528 dtmf_rec_clear_config(plci);
14529 dtmf_send_clear_config(plci);
14530 dtmf_parameter_clear_config(plci);
14532 adv_voice_clear_config(plci);
14533 adjust_b_clear(plci);
14537 static void clear_b1_config(
PLCI *plci)
14540 dbug(1,
dprintf(
"[%06lx] %s,%d: clear_b1_config",
14542 (
char *)(
FILE_), __LINE__));
14544 adv_voice_clear_config(plci);
14545 adjust_b_clear(plci);
14547 ec_clear_config(plci);
14550 dtmf_rec_clear_config(plci);
14551 dtmf_send_clear_config(plci);
14552 dtmf_parameter_clear_config(plci);
14558 mixer_clear_config(plci);
14571 static void channel_flow_control_remove(
PLCI *plci) {
14582 static void channel_x_on(
PLCI *plci,
byte ch) {
14598 static void channel_request_xon(
PLCI *plci,
byte ch) {
14608 static void channel_xmit_extended_xon(
PLCI *plci) {
14611 int i, one_requested = 0;
14613 if ((!plci) || (!plci->
Id) || ((a = plci->
adapter) ==
NULL)) {
14617 for (i = 0; i < max_ch; i++) {
14621 channel_request_xon(plci, (
byte)i);
14626 if (one_requested) {
14627 channel_xmit_xon(plci);
14664 static void channel_xmit_xon(
PLCI *plci) {
14671 if ((ch = (
byte)find_channel_with_pending_x_on(a, plci)) == 0) {
14687 static int channel_can_xon(
PLCI *plci,
byte ch) {
14695 APPLptr = plci->
appl;
14708 for (i = 0; i < APPLptr->
MaxBuffer; i++) {
14709 if (NCCIcode == APPLptr->
DataNCCI[i]) count++;
14710 if (!APPLptr->
DataNCCI[i] && Num == 0xffff) Num =
i;
14712 if ((count > 2) || (Num == 0xffff)) {
14744 set_group_ind_mask(plci);
14756 info_mask_group[
i] = 0;
14757 cip_mask_group[
i] = 0;
14761 appl_number_group_type[
i] = 0;
14767 dbug(1,
dprintf(
"Multi-Instance capable, no optimization required"));
14773 if (application[i].Id && a->
CIP_Mask[i])
14775 for (k = 0, busy =
false; k < a->
max_plci; k++)
14779 auxplci = &a->
plci[
k];
14780 if (auxplci->
appl == &application[i])
14785 else if (test_c_ind_mask_bit(auxplci, i))
14788 dbug(1,
dprintf(
"Appl 0x%x has inc. call pending", i + 1));
14793 for (j = 0, group_found = 0; j <= (
MAX_CIP_TYPES) && !busy && !group_found; j++)
14795 if (j == MAX_CIP_TYPES)
14798 group_found =
true;
14799 dbug(1,
dprintf(
"Field overflow appl 0x%x", i + 1));
14801 else if ((info_mask_group[j] == a->
CIP_Mask[i]) && (cip_mask_group[j] == a->
Info_Mask[i]))
14803 appl_number_group_type[
i] = j | 0x80;
14804 group_found =
true;
14805 dbug(1,
dprintf(
"Group 0x%x found with appl 0x%x, CIP=0x%lx", appl_number_group_type[i], i + 1, info_mask_group[j]));
14807 else if (!info_mask_group[j])
14809 appl_number_group_type[
i] = j | 0x80;
14812 group_found =
true;
14813 dbug(1,
dprintf(
"New Group 0x%x established with appl 0x%x, CIP=0x%lx", appl_number_group_type[i], i + 1, info_mask_group[j]));
14821 if (appl_number_group_type[i])
14823 if (appl_number_group_type[i] == MAX_CIP_TYPES)
14825 dbug(1,
dprintf(
"OverflowGroup 0x%x, valid appl = 0x%x, call enabled", appl_number_group_type[i], i + 1));
14829 dbug(1,
dprintf(
"Group 0x%x, valid appl = 0x%x", appl_number_group_type[i], i + 1));
14830 for (j = i + 1; j <
max_appl; j++)
14832 if (appl_number_group_type[i] == appl_number_group_type[j])
14834 dbug(1,
dprintf(
"Appl 0x%x is member of group 0x%x, no call", j + 1, appl_number_group_type[j]));
14835 clear_group_ind_mask_bit(plci, j);
14836 appl_number_group_type[
j] = 0;
14843 clear_group_ind_mask_bit(plci, i);
14859 for (i = 0, appls_found = 0; i <
max_appl; i++)
14861 if (application[i].Id && (application[i].Id !=
id))
14867 if (appls_found)
return true;
14877 if ((j = get_plci(a)))
14879 plci = &a->
plci[j - 1];
14881 add_p(plci,
OAD,
"\x01\xfd");
14882 add_p(plci,
CAI,
"\x01\x80");
14883 add_p(plci,
UID,
"\x06\x43\x61\x70\x69\x32\x30");
14885 add_p(plci,
SIN,
"\x02\x00\x00");
14888 add_p(plci,
FTY,
"\x02\xff\x07");
14903 static void VSwitchReqInd(
PLCI *plci,
dword Id,
byte **parms)
14924 if (!parms[i][0])
continue;
14925 if (parms[i][0] < 7)
14930 dbug(1,
dprintf(
"VSwitchReqInd(%d)", parms[i][4]));
14931 switch (parms[i][4])
14940 if (parms[i][0] != 11 || parms[i][8] != 3)
14944 if (parms[i][2] ==
VSWITCH_IND && parms[i][9] == 1)
14950 else if (parms[i][2] ==
VSWITCH_REQ && parms[i][9] == 3)
14991 static int diva_get_dma_descriptor(
PLCI *plci,
dword *dma_magic) {
15025 static void diva_free_dma_descriptor(
PLCI *plci,
int nr) {