extern "C" {
}
#include <q931.h>
-extern unsigned long mt_assign_pid;
+extern unsigned int mt_assign_pid;
#include "ie.cpp"
/*
* constructor
*/
-Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive) : PmISDN(type, mISDNport, portname, settings, channel, exclusive)
+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)
{
p_callerinfo.itype = (mISDNport->ifport->interface->extension)?INFO_ITYPE_ISDN_EXTENSION:INFO_ITYPE_ISDN;
p_m_d_ntmode = mISDNport->ntmode;
+ p_m_d_tespecial = mISDNport->tespecial;
p_m_d_l3id = 0;
p_m_d_ces = -1;
- p_m_d_queue = NULL;
+ p_m_d_queue[0] = '\0';
p_m_d_notify_pending = NULL;
p_m_d_collect_cause = 0;
p_m_d_collect_location = 0;
- PDEBUG(DEBUG_ISDN, "Created new mISDNPort(%s). Currently %d objects use, %s port #%d\n", portname, mISDNport->use, (mISDNport->ntmode)?"NT":"TE", p_m_portnum);
+ PDEBUG(DEBUG_ISDN, "Created new mISDNPort(%s). Currently %d objects use, %s%s port #%d\n", portname, mISDNport->use, (mISDNport->ntmode)?"NT":"TE", (mISDNport->tespecial)?" (special)":"", p_m_portnum);
}
Pdss1::~Pdss1()
{
/* remove queued message */
- if (p_m_d_queue)
- message_free(p_m_d_queue);
-
if (p_m_d_notify_pending)
message_free(p_m_d_notify_pending);
}
* return: <0: error, call is released, -cause is given
* 0: ok, nothing to do
*/
-int Pdss1::received_first_reply_to_setup(unsigned long cmd, int channel, int exclusive)
+int Pdss1::received_first_reply_to_setup(unsigned int cmd, int channel, int exclusive)
{
int ret;
l3_msg *l3m;
/* exclusive channel requests must be in the list */
if (exclusive)
{
+ /* no exclusive channel */
if (!channel)
{
add_trace("conclusion", NULL, "exclusively requested channel not in list");
end_trace();
return(-6); // channel unacceptable
}
- i = selchannel->channel-1-(selchannel->channel>=17);
+ /* get index for channel */
+ i = channel-1-(channel>=17);
+ if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
+ {
+ add_trace("conclusion", NULL, "exclusively requested channel outside interface range");
+ end_trace();
+ return(-6); // channel unacceptable
+ }
+ /* check if busy */
if (p_m_mISDNport->b_port[i] == NULL)
goto use_channel;
add_trace("conclusion", NULL, "exclusively requested channel is busy");
/* requested channels in list will be used */
if (channel)
{
- i = selchannel->channel-1-(selchannel->channel>=17);
+ /* get index for channel */
+ i = channel-1-(channel>=17);
+ if (i < 0 || i >= p_m_mISDNport->b_num || channel == 16)
+ {
+ add_trace("info", NULL, "requested channel %d outside interface range", channel);
+ } else /* if inside range (else) check if available */
if (p_m_mISDNport->b_port[i] == NULL)
goto use_channel;
}
void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
int calling_type, calling_plan, calling_present, calling_screen;
+ int calling_type2, calling_plan2, calling_present2, calling_screen2;
int called_type, called_plan;
int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc;
end_trace();
l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
- dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
+ dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id), &calling_type2, &calling_plan2, &calling_present2, &calling_screen2, (unsigned char *)p_callerinfo.id2, sizeof(p_callerinfo.id2));
dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
/* te-mode: CNIP (calling name identification presentation) */
- if (!p_m_d_ntmode)
- dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
+ dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
dec_ie_channel_id(l3m, &exclusive, &channel);
dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
+ dec_ie_display(l3m, (unsigned char *)p_dialinginfo.display, sizeof(p_dialinginfo.display));
end_trace();
/* if blocked, release call with MT_RELEASE_COMPLETE */
switch (calling_type)
{
case -1:
+ p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT;
+ break;
+ case 0x0:
p_callerinfo.ntype = INFO_NTYPE_UNKNOWN;
- p_callerinfo.present = INFO_PRESENT_NOTAVAIL;
- p_callerinfo.screen = INFO_SCREEN_NETWORK;
break;
case 0x1:
p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
p_callerinfo.isdn_port = p_m_portnum;
SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name);
+ /* caller info2 */
+ switch (calling_present2)
+ {
+ case 1:
+ p_callerinfo.present2 = INFO_PRESENT_RESTRICTED;
+ break;
+ case 2:
+ p_callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
+ break;
+ default:
+ p_callerinfo.present2 = INFO_PRESENT_ALLOWED;
+ break;
+ }
+ switch (calling_screen2)
+ {
+ case 0:
+ p_callerinfo.screen2 = INFO_SCREEN_USER;
+ break;
+ default:
+ p_callerinfo.screen2 = INFO_SCREEN_NETWORK;
+ break;
+ }
+ switch (calling_type2)
+ {
+ case -1:
+ p_callerinfo.ntype2 = INFO_NTYPE_NOTPRESENT;
+ break;
+ case 0x0:
+ p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
+ break;
+ case 0x1:
+ p_callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL;
+ break;
+ case 0x2:
+ p_callerinfo.ntype2 = INFO_NTYPE_NATIONAL;
+ break;
+ case 0x4:
+ p_callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER;
+ break;
+ default:
+ p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
+ break;
+ }
+
/* dialing information */
SCAT(p_dialinginfo.id, (char *)keypad);
switch (called_type)
switch (redir_type)
{
case -1:
+ p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT;
+ break;
+ case 0x0:
p_redirinfo.ntype = INFO_NTYPE_UNKNOWN;
- p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */
- p_redirinfo.reason = INFO_REDIR_UNKNOWN;
break;
case 0x1:
p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
break;
}
+ /* set bchannel mode */
+ if (p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED
+ || p_capainfo.bearer_capa==INFO_BC_DATARESTRICTED
+ || p_capainfo.bearer_capa==INFO_BC_VIDEO)
+ p_capainfo.source_mode = B_MODE_HDLC;
+ else
+ p_capainfo.source_mode = B_MODE_TRANSPARENT;
+ p_m_b_mode = p_capainfo.source_mode;
+
/* hunt channel */
ret = channel = hunt_bchannel(channel, exclusive);
if (ret < 0)
void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
int type, plan;
- unsigned char keypad[32] = "";
+ unsigned char keypad[32] = "", display[128] = "";
struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
+ dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
end_trace();
p_dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
break;
}
+ SCAT(p_dialinginfo.display, (char *)display);
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_INFORMATION);
memcpy(&message->param.information, &p_dialinginfo, sizeof(struct dialing_info));
message_put(message);
int coding, location, progress;
int ret;
struct lcr_msg *message;
+ int max = p_m_mISDNport->ifport->dialmax;
+ char *number;
+ l3_msg *nl3m;
l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
dec_ie_channel_id(l3m, &exclusive, &channel);
message_put(message);
new_state(PORT_STATE_OUT_OVERLAP);
+
+ number = p_m_d_queue;
+ while (number[0]) /* as long we have something to dial */
+ {
+ if (max > strlen(number) || max == 0)
+ max = strlen(number);
+
+ nl3m = create_l3msg();
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
+ enc_ie_called_pn(nl3m, 0, 1, (unsigned char *)number, max);
+ end_trace();
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, nl3m);
+ number += max;
+ }
+ p_m_d_queue[0] = '\0';
}
/* CC_PROCEEDING INDICATION */
switch (type)
{
case -1:
- message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
- message->param.notifyinfo.present = INFO_PRESENT_NULL;
+ message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
break;
case 1:
message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
switch (type)
{
case -1:
- message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
- message->param.notifyinfo.present = INFO_PRESENT_NULL;
+ message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
break;
case 1:
message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
dec_ie_channel_id(l3m, &exclusive, &channel);
dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
+ dec_ie_display(l3m, (unsigned char *)p_connectinfo.display, sizeof(p_connectinfo.display));
/* te-mode: CONP (connected name identification presentation) */
- if (!p_m_d_ntmode)
- dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
+ dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
end_trace();
/* select channel */
}
switch (type)
{
- case 0x0:
- p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */
- p_connectinfo.ntype = INFO_NTYPE_UNKNOWN;
+ case -1:
+ p_connectinfo.ntype = INFO_NTYPE_NOTPRESENT;
break;
case 0x1:
p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL;
int location, cause;
int coding, proglocation, progress;
struct lcr_msg *message;
+ unsigned char display[128] = "";
l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
dec_ie_progress(l3m, &coding, &proglocation, &progress);
dec_ie_cause(l3m, &location, &cause);
+ dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
end_trace();
if (cause < 0)
message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
message->param.disconnectinfo.cause = cause;
message->param.disconnectinfo.location = location;
+ SCAT(message->param.disconnectinfo.display, (char *)display);
message_put(message);
/* remove epoint */
free_epointlist(p_epointlist);
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DISCONNECT);
message->param.disconnectinfo.location = location;
message->param.disconnectinfo.cause = cause;
+ SCAT(message->param.disconnectinfo.display, (char *)display);
message_put(message);
}
while(INACTIVE_EPOINT(p_epointlist))
message = message_create(p_serial, INACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
message->param.disconnectinfo.location = location;
message->param.disconnectinfo.cause = cause;
+ SCAT(message->param.disconnectinfo.display, (char *)display);
message_put(message);
/* remove epoint */
free_epointid(INACTIVE_EPOINT(p_epointlist));
{
int location, cause;
struct lcr_msg *message;
+ unsigned char display[128] = "";
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
dec_ie_cause(l3m, &location, &cause);
+ dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
end_trace();
if (cause < 0)
message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
message->param.disconnectinfo.cause = cause;
message->param.disconnectinfo.location = location;
+ SCAT(message->param.disconnectinfo.display, (char *)display);
message_put(message);
/* remove epoint */
free_epointlist(p_epointlist);
p_m_delete = 1;
}
+/* CC_RESTART INDICATION */
+void Pdss1::restart_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
+{
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_RESTART_IND, DIRECTION_IN);
+ end_trace();
+
+ // L3 process is not toucht. (not even by network stack)
+}
+
/* CC_RELEASE_COMPLETE INDICATION (a reject) */
void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
/* in case layer 2 is down during setup, we send cause 27 loc 5 */
- if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
+ if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
{
cause = 27;
location = 5;
} else
{
dec_ie_cause(l3m, &location, &cause);
- add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
+ if (p_m_mISDNport->l1link < 0)
+ add_trace("layer 1", NULL, "unknown");
+ else
+ add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
}
end_trace();
if (location == LOCATION_PRIVATE_LOCAL)
struct lcr_msg *message;
int notify, type, plan, present;
unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
+ unsigned char display[128] = "";
l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
dec_ie_notify(l3m, ¬ify);
dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
+ dec_ie_display(l3m, (unsigned char *)display, sizeof(display));
end_trace();
if (!ACTIVE_EPOINT(p_epointlist))
switch (type)
{
case -1:
- message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
- message->param.notifyinfo.present = INFO_PRESENT_NULL;
+ message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT;
break;
case 1:
message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL;
message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN;
break;
}
+ SCAT(message->param.notifyinfo.display, (char *)display);
message->param.notifyinfo.isdn_port = p_m_portnum;
message_put(message);
}
if (ret < 0)
goto no_channel;
+// mode (if hdlc parked) to be done. never mind, this is almost never requested
/* open channel */
ret = seize_bchannel(channel, 1);
if (ret < 0)
}
+/* CC_PROGRESS INDICATION */
+void Pdss1::progress_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
+{
+ unsigned char facil[256];
+ int facil_len;
+ struct lcr_msg *message;
+ int coding, location, progress;
+
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_PROGRESS_IND, DIRECTION_IN);
+ dec_ie_progress(l3m, &coding, &location, &progress);
+ end_trace();
+}
+
+
/*
* handler for isdn connections
* incoming information are parsed and sent via message to the endpoint
release_complete_ind(cmd, pid, l3m);
break;
+ case MT_RESTART:
+ restart_ind(cmd, pid, l3m);
+ break;
+
case MT_NOTIFY:
notify_ind(cmd, pid, l3m);
break;
facility_ind(cmd, pid, l3m);
break;
+ case MT_PROGRESS:
+ progress_ind(cmd, pid, l3m);
+ break;
+
case MT_FREE:
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_L3ID_IND, DIRECTION_IN);
add_trace("callref", NULL, "0x%x", p_m_d_l3id);
break;
default:
- l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN_IND, DIRECTION_IN);
add_trace("unhandled", "cmd", "0x%x", cmd);
end_trace();
}
* handles all messages from endpoint
*/
/* MESSAGE_INFORMATION */
-void Pdss1::message_information(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
+ char *display = param->information.display;
+ char *number = param->information.id;
+ int max = p_m_mISDNport->ifport->dialmax;
- if (param->information.id[0]) /* only if we have something to dial */
+ while (number[0]) /* as long we have something to dial */
{
+ if (max > strlen(number) || max == 0)
+ max = strlen(number);
+
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
- enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
+ enc_ie_called_pn(l3m, 0, 1, (unsigned char *)number, max);
+ if ((p_m_d_ntmode || p_m_d_tespecial) && display[0]) {
+ enc_ie_display(l3m, (unsigned char *)display);
+ display = "";
+ }
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
+ number += max;
}
new_state(p_state);
}
int newteid = 0;
/* MESSAGE_SETUP */
-void Pdss1::message_setup(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_setup(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
int ret;
int plan, type, screen, present, reason;
+ int plan2, type2, screen2, present2;
int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
int channel, exclusive;
struct epoint_list *epointlist;
+ int max = p_m_mISDNport->ifport->dialmax;
/* release if port is blocked */
if (p_m_mISDNport->ifport->block)
// SCPY(&p_m_tones_dir, param->setup.ext.tones_dir);
/* 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);
/* only display at connect state: this case happens if endpoint is in connected mode */
if (p_state==PORT_STATE_CONNECT)
/* sending information */
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
- if (p_m_d_ntmode)
+ if (p_m_d_ntmode || p_m_d_tespecial)
enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
plan = 1;
switch (p_callerinfo.ntype)
{
+ case INFO_NTYPE_UNKNOWN:
+ type = 0x0;
+ break;
case INFO_NTYPE_INTERNATIONAL:
type = 0x1;
break;
case INFO_NTYPE_SUBSCRIBER:
type = 0x4;
break;
- default: /* INFO_NTYPE_UNKNOWN */
- type = 0x0;
+ default: /* INFO_NTYPE_NOTPRESENT */
+ type = -1;
break;
}
switch (p_callerinfo.screen)
}
switch (p_callerinfo.present)
{
+ case INFO_PRESENT_ALLOWED:
+ present = 0;
+ break;
case INFO_PRESENT_RESTRICTED:
present = 1;
break;
- case INFO_PRESENT_NOTAVAIL:
+ default: /* INFO_PRESENT_NOTAVAIL */
present = 2;
break;
- default: /* INFO_PRESENT_ALLOWED */
- present = 0;
+ }
+ /* caller information 2 */
+ plan2 = 1;
+ switch (p_callerinfo.ntype2)
+ {
+ case INFO_NTYPE_UNKNOWN:
+ type2 = 0x0;
+ break;
+ case INFO_NTYPE_INTERNATIONAL:
+ type2 = 0x1;
+ break;
+ case INFO_NTYPE_NATIONAL:
+ type2 = 0x2;
+ break;
+ case INFO_NTYPE_SUBSCRIBER:
+ type2 = 0x4;
+ break;
+ default: /* INFO_NTYPE_NOTPRESENT */
+ type2 = -1;
+ break;
+ }
+ switch (p_callerinfo.screen2)
+ {
+ case INFO_SCREEN_USER:
+ screen2 = 0;
+ break;
+ default: /* INFO_SCREEN_NETWORK */
+ screen2 = 3;
+ break;
+ }
+ switch (p_callerinfo.present2)
+ {
+ case INFO_PRESENT_ALLOWED:
+ present2 = 0;
+ break;
+ case INFO_PRESENT_RESTRICTED:
+ present2 = 1;
+ break;
+ default: /* INFO_PRESENT_NOTAVAIL */
+ present2 = 2;
break;
}
if (type >= 0)
- enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
+ enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id, type2, plan2, present2, screen2, (unsigned char *)p_callerinfo.id2);
/* dialing information */
if (p_dialinginfo.id[0]) /* only if we have something to dial */
{
- enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
+ if (max > strlen(p_dialinginfo.id) || max == 0)
+ max = strlen(p_dialinginfo.id);
+ enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id, max);
+ SCPY(p_m_d_queue, p_dialinginfo.id + max);
}
/* sending complete */
if (p_dialinginfo.sending_complete)
plan = 1;
switch (p_redirinfo.ntype)
{
+ case INFO_NTYPE_UNKNOWN:
+ type = 0x0;
+ break;
case INFO_NTYPE_INTERNATIONAL:
type = 0x1;
break;
case INFO_NTYPE_SUBSCRIBER:
type = 0x4;
break;
- default: /* INFO_NTYPE_UNKNOWN */
- type = 0x0;
+ default: /* INFO_NTYPE_NOTPRESENT */
+ type = -1;
break;
}
switch (p_redirinfo.screen)
}
switch (p_redirinfo.present)
{
- case INFO_PRESENT_NULL: /* no redir at all */
- present = -1;
- screen = -1;
- reason = -1;
- plan = -1;
- type = -1;
+ case INFO_PRESENT_ALLOWED:
+ present = 0;
break;
case INFO_PRESENT_RESTRICTED:
present = 1;
break;
- case INFO_PRESENT_NOTAVAIL:
+ default: /* INFO_PRESENT_NOTAVAIL */
present = 2;
break;
- default: /* INFO_PRESENT_ALLOWED */
- present = 0;
- break;
}
/* sending redirecting number only in ntmode */
- if (type >= 0 && p_m_d_ntmode)
+ if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
/* bearer capability */
//printf("hlc=%d\n",p_capainfo.hlc);
}
/* display */
- if (p_callerinfo.display[0] && p_m_d_ntmode)
+ if (p_callerinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
/* nt-mode: CNIP (calling name identification presentation) */
-// if (p_callerinfo.name[0] && p_m_d_ntmode)
+// if (p_callerinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
// enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
end_trace();
}
/* MESSAGE_FACILITY */
-void Pdss1::message_facility(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_facility(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
/* facility will not be sent to external lines */
- if (!p_m_d_ntmode)
+ if (!p_m_d_ntmode && !p_m_d_tespecial)
return;
/* sending facility */
}
/* MESSAGE_NOTIFY */
-void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_notify(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
int notify;
- int plan, type = -1, present;
+ int plan = 0, type = -1, present = 0;
+ printf("if = %d\n", param->notifyinfo.notify);
if (param->notifyinfo.notify>INFO_NOTIFY_NONE)
notify = param->notifyinfo.notify & 0x7f;
else
notify = -1;
- if (p_state != PORT_STATE_CONNECT)
- {
- /* notify only allowed in active state */
- notify = -1;
- }
if (notify >= 0)
{
plan = 1;
switch (param->notifyinfo.ntype)
{
+ case INFO_NTYPE_UNKNOWN:
+ type = 0;
+ break;
case INFO_NTYPE_INTERNATIONAL:
type = 1;
break;
type = 4;
break;
default: /* INFO_NTYPE_UNKNOWN */
- type = 0;
+ type = -1;
break;
}
switch (param->notifyinfo.present)
{
- case INFO_PRESENT_NULL: /* no redir at all */
- present = -1;
- plan = -1;
- type = -1;
+ case INFO_PRESENT_ALLOWED:
+ present = 0;
break;
case INFO_PRESENT_RESTRICTED:
present = 1;
break;
- case INFO_PRESENT_NOTAVAIL:
+ default: /* INFO_PRESENT_NOTAVAIL */
present = 2;
break;
- default: /* INFO_PRESENT_ALLOWED */
- present = 0;
- break;
}
}
if (notify >= 0)
{
- if (p_state!=PORT_STATE_CONNECT)
+ if (p_state!=PORT_STATE_CONNECT && p_state!=PORT_STATE_IN_PROCEEDING && p_state!=PORT_STATE_IN_ALERTING)
{
/* queue notification */
if (p_m_d_notify_pending)
l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
enc_ie_notify(l3m, notify);
/* sending redirection number only in ntmode */
- if (type >= 0 && p_m_d_ntmode)
+ if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
- if (param->notifyinfo.display[0] && p_m_d_ntmode)
+ if (param->notifyinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
}
- } else if (p_m_d_ntmode)
+ } else if (p_m_d_ntmode || p_m_d_tespecial)
{
/* sending information */
l3m = create_l3msg();
}
/* MESSAGE_OVERLAP */
-void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_overlap(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
+ /* in case of sending complete, we proceed */
+ if (p_dialinginfo.sending_complete)
+ {
+ PDEBUG(DEBUG_ISDN, "sending proceeding instead of setup_acknowledge, because address is complete.\n");
+ message_proceeding(epoint_id, message_id, param);
+ return;
+ }
+
/* sending setup_acknowledge */
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
if (p_m_mISDNport->tones)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
}
/* MESSAGE_PROCEEDING */
-void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_proceeding(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
if (p_m_mISDNport->tones)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
}
/* MESSAGE_ALERTING */
-void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_alerting(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ if (p_m_mISDNport->tones)
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
new_state(PORT_STATE_IN_PROCEEDING);
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
if (p_m_mISDNport->tones)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
}
/* MESSAGE_CONNECT */
-void Pdss1::message_connect(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
int type, plan, present, screen;
l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
/* channel information */
enc_ie_channel_id(l3m, 1, p_m_b_channel);
-// /* progress information */
-// if (p_capainfo.bearer_capa==INFO_BC_SPEECH
-// || p_capainfo.bearer_capa==INFO_BC_AUDIO
-// || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
-// enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
new_state(PORT_STATE_IN_PROCEEDING);
/* sending information */
l3m = create_l3msg();
l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
- if (p_m_d_ntmode)
+ 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);
plan = 1;
switch (p_connectinfo.ntype)
{
+ case INFO_NTYPE_UNKNOWN:
+ type = 0x0;
+ break;
case INFO_NTYPE_INTERNATIONAL:
type = 0x1;
break;
case INFO_NTYPE_SUBSCRIBER:
type = 0x4;
break;
- default: /* INFO_NTYPE_UNKNOWN */
- type = 0x0;
+ default: /* INFO_NTYPE_NOTPRESENT */
+ type = -1;
break;
}
switch (param->connectinfo.screen)
}
switch (p_connectinfo.present)
{
- case INFO_PRESENT_NULL: /* no colp at all */
- present = -1;
- screen = -1;
- plan = -1;
- type = -1;
+ case INFO_PRESENT_ALLOWED:
+ present = 0;
break;
case INFO_PRESENT_RESTRICTED:
present = 1;
break;
- case INFO_PRESENT_NOTAVAIL:
+ default: /* INFO_PRESENT_NOTAVAIL */
present = 2;
break;
- default: /* INFO_PRESENT_ALLOWED */
- present = 0;
- break;
}
if (type >= 0)
enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
/* display */
- if (p_connectinfo.display[0] && p_m_d_ntmode)
+ if (p_connectinfo.display[0] && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
/* nt-mode: CONP (connected name identification presentation) */
-// if (p_connectinfo.name[0] && p_m_d_ntmode)
+// if (p_connectinfo.name[0] && (p_m_d_ntmode || p_m_d_tespecial))
// enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
/* date & time */
- if (p_m_d_ntmode)
+ if (p_m_d_ntmode || p_m_d_tespecial)
{
epoint = find_epoint_id(epoint_id);
enc_ie_date(l3m, now, p_settings.no_seconds);
}
/* MESSAGE_DISCONNECT */
-void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_disconnect(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
struct lcr_msg *message;
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ if (p_m_mISDNport->tones)
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
new_state(PORT_STATE_IN_PROCEEDING);
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
if (p_m_mISDNport->tones)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ 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 display */
if (param->disconnectinfo.display[0])
p = param->disconnectinfo.display;
- if (p) if (*p && p_m_d_ntmode)
+ if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_display(l3m, (unsigned char *)p);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
}
/* MESSAGE_RELEASE */
-void Pdss1::message_release(unsigned long epoint_id, int message_id, union parameter *param)
+void Pdss1::message_release(unsigned int epoint_id, int message_id, union parameter *param)
{
l3_msg *l3m;
class Endpoint *epoint;
*/
if (p_state==PORT_STATE_IN_SETUP
|| p_state==PORT_STATE_OUT_SETUP)
-// // NOTE: a bug in mISDNuser (see disconnect_req_out !!!)
-// || p_state==PORT_STATE_OUT_DISCO)
{
//#warning remove me
//PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
if (p_capainfo.bearer_capa==INFO_BC_SPEECH
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ if (p_m_mISDNport->tones)
+ enc_ie_progress(l3m, 0, (p_m_d_ntmode)?1:5, 8);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
}
|| p_capainfo.bearer_capa==INFO_BC_AUDIO
|| p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
if (p_m_mISDNport->tones)
- enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
+ 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_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)
+ if (p) if (*p && (p_m_d_ntmode || p_m_d_tespecial))
enc_ie_display(l3m, (unsigned char *)p);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
/*
* endpoint sends messages to the port
*/
-int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union parameter *param)
+int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
{
- struct lcr_msg *message;
-
if (PmISDN::message_epoint(epoint_id, message_id, param))
return(1);
break;
}
message_proceeding(epoint_id, message_id, param);
+ if (p_m_d_notify_pending)
+ {
+ /* send pending notify message during connect */
+ message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
+ message_free(p_m_d_notify_pending);
+ p_m_d_notify_pending = NULL;
+ }
break;
case MESSAGE_ALERTING: /* call of endpoint is ringing */
break;
}
message_alerting(epoint_id, message_id, param);
+ if (p_m_d_notify_pending)
+ {
+ /* send pending notify message during connect */
+ message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
+ message_free(p_m_d_notify_pending);
+ p_m_d_notify_pending = NULL;
+ }
break;
case MESSAGE_CONNECT: /* call of endpoint is connected */
break;
}
message_connect(epoint_id, message_id, param);
+ if (p_m_d_notify_pending)
+ {
+ /* send pending notify message during connect */
+ message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
+ message_free(p_m_d_notify_pending);
+ p_m_d_notify_pending = NULL;
+ }
break;
case MESSAGE_DISCONNECT: /* call has been disconnected */
break;
default:
- PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message);
+ PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id);
}
return(1);
switch(cmd)
{
case MT_SETUP:
- /* creating port object */
+ /* 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)))
+ if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
FATAL("Cannot create Port instance.\n");
pdss1->message_isdn(cmd, pid, l3m);
break;
case MT_RESUME:
- /* creating port object */
+ /* 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)))
+ if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0, B_MODE_TRANSPARENT)))
FATAL("Cannot create Port instance.\n");
pdss1->message_isdn(cmd, pid, l3m);
break;
}
-#if 0
-/*
- * sending message that were queued during L1 activation
- * or releasing port if link is down
- */
-void setup_queue(struct mISDNport *mISDNport, int link)
-{
- class Port *port;
- class Pdss1 *pdss1;
- struct lcr_msg *message;
-
- if (!mISDNport->ntmode)
- return;
-
- /* check all port objects for pending message */
- port = port_first;
- while(port)
- {
- if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
- {
- pdss1 = (class Pdss1 *)port;
- if (pdss1->p_m_mISDNport == mISDNport)
- {
- if (pdss1->p_m_d_queue)
- {
- if (link)
- {
- PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
- /* LAYER 1 is up, so we send */
- pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param);
- message_free(pdss1->p_m_d_queue);
- pdss1->p_m_d_queue = NULL;
- } else
- {
- PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name);
- message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE);
- message->param.disconnectinfo.cause = 27;
- message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
- message_put(message);
- pdss1->new_state(PORT_STATE_RELEASE);
- pdss1->p_m_delete = 1;
- }
- }
- }
- }
- port = port->next;
- }
-}
-
-#endif