extern "C" {
}
#include <mISDN/q931.h>
+#include <mISDN/suppserv.h>
#ifdef OLD_MT_ASSIGN
extern unsigned int mt_assign_pid;
#endif
/*
* constructor
*/
-Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode) : PmISDN(type, mISDNport, portname, settings, channel, exclusive, mode)
+Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, struct interface *interface, int channel, int exclusive, int mode) : PmISDN(type, mISDNport, portname, settings, interface, channel, exclusive, mode)
{
p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
p_m_d_ntmode = mISDNport->ntmode;
l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
end_trace();
- if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold) {
+ if (!ACTIVE_EPOINT(p_epointlist) || p_hold) {
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
- enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
+ enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_hold?101:31); /* normal unspecified / incompatible state */
add_trace("reason", NULL, "no endpoint");
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
drop_bchannel();
/* set hold state */
- p_m_hold = 1;
+ p_hold = 1;
#if 0
epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
if (epoint && p_m_d_ntmode) {
dec_ie_channel_id(l3m, &exclusive, &channel);
end_trace();
- if (!p_m_hold) {
+ if (!p_hold) {
cause = 101; /* incompatible state */
reject:
bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
/* set hold state */
- p_m_hold = 0;
+ p_hold = 0;
unsched_timer(&p_m_timeout);
/* acknowledge retrieve */
/* CC_FACILITY INDICATION */
void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
- unsigned char facil[256];
- int facil_len;
+ unsigned char fac_ie[256];
+ struct asn1_parm fac;
+ int fac_len;
struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
- dec_ie_facility(l3m, facil, &facil_len);
+ dec_ie_facility(l3m, fac_ie + 1, &fac_len);
+ fac_ie[0] = fac_len;
end_trace();
/* facility */
- if (facil_len<=0)
+ if (fac_len<=0)
return;
+ decodeFac(fac_ie, &fac);
+ switch (fac.comp) {
+ case CompInvoke:
+ switch(fac.u.inv.operationValue) {
+ case Fac_Begin3PTY:
+ message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_3PTY);
+ message->param.threepty.begin = 1;
+ message->param.threepty.invoke = 1;
+ message->param.threepty.invoke_id = fac.u.inv.invokeId;
+ message_put(message);
+ return;
+
+ case Fac_End3PTY:
+ message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_3PTY);
+ message->param.threepty.end = 1;
+ message->param.threepty.invoke = 1;
+ message->param.threepty.invoke_id = fac.u.inv.invokeId;
+ message_put(message);
+ return;
+
+ case Fac_EctExecute:
+ message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_TRANSFER);
+ message->param.transfer.invoke = 1;
+ message->param.transfer.invoke_id = fac.u.inv.invokeId;
+ message_put(message);
+ return;
+ default:
+ ;
+ }
+ break;
+ default:
+ ;
+ }
+
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_FACILITY);
- message->param.facilityinfo.len = facil_len;
- memcpy(message->param.facilityinfo.data, facil, facil_len);
+ message->param.facilityinfo.len = fac_len;
+ memcpy(message->param.facilityinfo.data, fac_ie + 1, fac_len);
message_put(message);
}
/* screen outgoing caller id */
do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface->name);
do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface->name);
+ do_screen(1, p_redirinfo.id, sizeof(p_redirinfo.id), &p_redirinfo.ntype, &p_redirinfo.present, p_m_mISDNport->ifport->interface->name);
/* only display at connect state: this case happens if endpoint is in connected mode */
if (p_state==PORT_STATE_CONNECT) {
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
}
+/* MESSAGE_3PTY */
+void Pdss1::message_3pty(unsigned int epoint_id, int message_id, union parameter *param)
+{
+ l3_msg *l3m;
+ unsigned char fac_ie[256];
+ struct asn1_parm fac;
+
+ /* encode 3PTY facility */
+ memset(&fac, 0, sizeof(fac));
+ fac.Valid = 1;
+ if (param->threepty.result) {
+ fac.comp = CompReturnResult;
+ fac.u.retResult.invokeId = param->threepty.invoke_id;
+ fac.u.retResult.operationValuePresent = 1;
+ if (param->threepty.begin)
+ fac.u.retResult.operationValue = Fac_Begin3PTY;
+ if (param->threepty.end)
+ fac.u.retResult.operationValue = Fac_End3PTY;
+ }
+ if (param->threepty.error) {
+ fac.comp = CompReturnError;
+ fac.u.retError.invokeId = param->threepty.invoke_id;
+ fac.u.retError.errorValue = FacError_Gen_InvalidCallState;
+ }
+ encodeFac(fac_ie, &fac);
+
+ /* sending facility */
+ l3m = create_l3msg();
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
+ enc_ie_facility(l3m, fac_ie + 2, fac_ie[1]);
+ end_trace();
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
+}
+
+void Pdss1::enc_ie_facility_ect(l3_msg *l3m, struct param_transfer *transfer)
+{
+ unsigned char fac_ie[256];
+ struct asn1_parm fac;
+
+ /* encode ECT facility */
+ memset(&fac, 0, sizeof(fac));
+ fac.Valid = 1;
+ if (transfer->result) {
+ fac.comp = CompReturnResult;
+ fac.u.retResult.invokeId = transfer->invoke_id;
+ fac.u.retResult.operationValuePresent = 1;
+ fac.u.retResult.operationValue = Fac_EctExecute;
+ }
+ if (transfer->error) {
+ fac.comp = CompReturnError;
+ fac.u.retError.invokeId = transfer->invoke_id;
+ fac.u.retError.errorValue = FacError_Gen_InvalidCallState;
+ }
+ encodeFac(fac_ie, &fac);
+
+ enc_ie_facility(l3m, fac_ie + 2, fac_ie[1]);
+}
+
+/* MESSAGE_TRANSFER */
+void Pdss1::message_transfer(unsigned int epoint_id, int message_id, union parameter *param)
+{
+ l3_msg *l3m;
+
+ /* sending facility */
+ l3m = create_l3msg();
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
+ enc_ie_facility_ect(l3m, ¶m->transfer);
+ end_trace();
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
+}
+
/* MESSAGE_NOTIFY */
void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
{
{
l3_msg *l3m;
int type, plan, present, screen;
- class Endpoint *epoint;
time_t current_time;
/* NT-MODE in setup state we must send PROCEEDING first */
/* screen outgoing caller id */
do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface->name);
- /* only display at connect state */
- if (p_state == PORT_STATE_CONNECT)
- if (p_connectinfo.display[0]) {
- /* sending information */
- l3m = create_l3msg();
- l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
- if (p_m_d_ntmode || p_m_d_tespecial)
- enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
- end_trace();
- p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
- return;
- }
+ set_display(p_connectinfo.display);
if (p_state!=PORT_STATE_IN_SETUP && p_state!=PORT_STATE_IN_OVERLAP && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING) {
/* connect command only possible in setup, proceeding or alerting state */
// enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
/* date & time */
if (p_m_d_ntmode || p_m_d_tespecial) {
- epoint = find_epoint_id(epoint_id);
time(¤t_time);
enc_ie_date(l3m, current_time, p_settings.no_seconds);
}
enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
/* send cause */
enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
+ /* send facility */
+ if (param->disconnectinfo.transfer.result) {
+ enc_ie_facility_ect(l3m, ¶m->disconnectinfo.transfer);
+ }
/* send display */
if (param->disconnectinfo.display[0])
p = param->disconnectinfo.display;
void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
- class Endpoint *epoint;
char *p = NULL;
/*
/* send cause */
enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
/* send display */
- epoint = find_epoint_id(epoint_id);
if (param->disconnectinfo.display[0])
p = param->disconnectinfo.display;
if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
message_facility(epoint_id, message_id, param);
break;
+ case MESSAGE_3PTY: /* begin result message */
+ message_3pty(epoint_id, message_id, param);
+ break;
+
+ case MESSAGE_TRANSFER: /* begin result message */
+ message_transfer(epoint_id, message_id, param);
+ break;
+
case MESSAGE_OVERLAP: /* more information is needed */
if (p_state!=PORT_STATE_IN_SETUP) {
break;
case MT_SETUP:
/* creating port object, transparent until setup with hdlc */
SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
- if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
+ if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, mISDNport->ifport->interface, 0, 0, B_MODE_TRANSPARENT)))
FATAL("Cannot create Port instance.\n");
pdss1->message_isdn(cmd, pid, l3m);
case MT_RESUME:
/* creating port object, transparent until setup with hdlc */
SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
- if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
+ if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, mISDNport->ifport->interface, 0, 0, B_MODE_TRANSPARENT)))
FATAL("Cannot create Port instance.\n");
pdss1->message_isdn(cmd, pid, l3m);
break;
return(0);
}
+void Pdss1::set_display(const char *text)
+{
+ l3_msg *l3m;
+
+ /* only display at connect state */
+ if (p_state == PORT_STATE_CONNECT)
+ if (text[0]) {
+ /* sending information */
+ l3m = create_l3msg();
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
+ if (p_m_d_ntmode || p_m_d_tespecial)
+ enc_ie_display(l3m, (unsigned char *)text);
+ end_trace();
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
+ return;
+ }
+}