extern "C" {
}
#include <mISDN/q931.h>
+#include <mISDN/suppserv.h>
+#ifdef OLD_MT_ASSIGN
extern unsigned int mt_assign_pid;
+#endif
#include "ie.cpp"
FATAL("Incoming call but already got an endpoint.\n");
if (!(epoint = new Endpoint(p_serial, 0)))
FATAL("No memory for Endpoint instance\n");
- if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
- FATAL("No memory for Endpoint Application instance\n");
+ epoint->ep_app = new_endpointapp(epoint, 0, p_m_mISDNport->ifport->interface->app); //incoming
epointlist_new(epoint->ep_serial);
/* send setup message to endpoit */
/* 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;
+ 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, fac_len);
message_put(message);
}
void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
+#ifdef OLD_MT_ASSIGN
int ret;
+#endif
int plan, type, screen, present, reason;
int plan2, type2, screen2, present2;
int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
/* 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);
- do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface);
+ 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) {
/* creating l3id */
l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
+#ifdef OLD_MT_ASSIGN
/* see MT_ASSIGN notes at do_layer3() */
mt_assign_pid = 0;
ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
- if (mt_assign_pid == 0 || ret < 0) {
+ if (mt_assign_pid == 0 || ret < 0)
+ p_m_d_l3id = mt_assign_pid;
+ mt_assign_pid = ~0;
+#else
+ p_m_d_l3id = request_new_pid(p_m_mISDNport->ml3);
+ if (p_m_d_l3id == MISDN_PID_NONE)
+#endif
+ {
struct lcr_msg *message;
add_trace("callref", NULL, "no free id");
trigger_work(&p_m_d_delete);
return;
}
+#ifdef OLD_MT_ASSIGN
p_m_d_l3id = mt_assign_pid;
mt_assign_pid = ~0;
+#endif
add_trace("callref", "new", "0x%x", p_m_d_l3id);
end_trace();
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
/* channel information */
- if (channel >= 0) /* it should */
+ if (p_m_d_ntmode || channel != CHANNEL_ANY) /* only omit channel id in te-mode/any channel */
enc_ie_channel_id(l3m, exclusive, channel);
/* caller information */
plan = 1;
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;
+ }
+ if (param->threepty.error) {
+ fac.comp = CompReturnError;
+ fac.u.retError.invokeId = param->threepty.invoke_id;
+ fac.u.retError.errorValue = FacError_Gen_InvalidCallState;
+ }
+ 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;
+ 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);
+}
+
/* MESSAGE_NOTIFY */
void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
{
/* copy connected information */
memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo));
/* 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);
+ 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)
message_facility(epoint_id, message_id, param);
break;
+ case MESSAGE_3PTY: /* begin result message */
+ message_3pty(epoint_id, message_id, param);
+ break;
+
case MESSAGE_OVERLAP: /* more information is needed */
if (p_state!=PORT_STATE_IN_SETUP) {
break;
port = port_first;
while(port) {
/* are we ISDN ? */
- if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) {
+ if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_DSS1) {
pdss1 = (class Pdss1 *)port;
/* check out correct stack and id */
if (pdss1->p_m_mISDNport == mISDNport) {
// facility als broadcast
break;
+ case MT_L2IDLE:
+ // L2 became idle - we could sent a MT_L2RELEASE if we are the L2 master
+ PDEBUG(DEBUG_ISDN, "Got L2 idle\n");
+ break;
+
default:
PERROR("unhandled message: cmd(0x%x) pid(0x%x)\n", cmd, pid);
port = port_first;