unsigned char useruser[128];
int useruser_len = 0, useruser_protocol;
class Endpoint *epoint;
- struct message *message;
+ struct lcr_msg *message;
#ifdef SOCKET_MISDN
/* process given callref */
l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
add_trace("callref", "new", "0x%x", pid);
- if (p_m_d_l3id != pid)
+ if (p_m_d_l3id)
{
/* release in case the ID is already in use */
add_trace("error", NULL, "callref already in use");
#endif
int type, plan;
unsigned char keypad[32] = "";
- struct message *message;
+ struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
#ifdef SOCKET_MISDN
int exclusive, channel;
int coding, location, progress;
int ret;
- struct message *message;
+ struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
#ifdef SOCKET_MISDN
int exclusive, channel;
int coding, location, progress;
int ret;
- struct message *message;
+ struct lcr_msg *message;
int notify = -1, type, plan, present;
char redir[32];
int exclusive, channel;
int coding, location, progress;
int ret;
- struct message *message;
+ struct lcr_msg *message;
int notify = -1, type, plan, present;
char redir[32];
int exclusive, channel;
int type, plan, present, screen;
int ret;
- struct message *message;
+ struct lcr_msg *message;
int bchannel_before;
+#ifndef SOCKET_MISDN
if (p_m_d_ntmode)
-#ifdef SOCKET_MISDN
- p_m_d_ces = pid >> 16;
-#else
p_m_d_ces = connect->ces;
#endif
#endif
end_trace();
#ifdef SOCKET_MISDN
- p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
#else
msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
#endif
#endif
int location, cause;
int coding, proglocation, progress;
- struct message *message;
+ struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
#ifdef SOCKET_MISDN
RELEASE_t *release = (RELEASE_t *)((unsigned long)data + headerlen);
#endif
int location, cause;
- struct message *message;
+ struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
#ifdef SOCKET_MISDN
RELEASE_COMPLETE_t *release_complete = (RELEASE_COMPLETE_t *)((unsigned long)data + headerlen);
#endif
int location, cause;
- struct message *message;
-
+ struct lcr_msg *message;
+
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)
+ {
+ cause = 27;
+ location = 5;
+ } else
+ {
#ifdef SOCKET_MISDN
- dec_ie_cause(l3m, &location, &cause);
+ dec_ie_cause(l3m, &location, &cause);
#else
- dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
+ dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
#endif
+ add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
+ }
end_trace();
if (location == LOCATION_PRIVATE_LOCAL)
location = LOCATION_PRIVATE_REMOTE;
#ifdef SOCKET_MISDN
void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
+ // not required, release is performed with MT_FREE
+}
#else
void Pdss1::t312_timeout_ind(unsigned long prim, unsigned long dinfo, void *data)
{
-#endif
- struct message *message;
-
+ struct lcr_msg *message;
// trace is done at message_isdn()
/* sending release to endpoint */
new_state(PORT_STATE_RELEASE);
p_m_delete = 1;
}
+#endif
/* CC_NOTIFY INDICATION */
#ifdef SOCKET_MISDN
int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
NOTIFY_t *notifying = (NOTIFY_t *)((unsigned long)data + headerlen);
#endif
- struct message *message;
+ struct lcr_msg *message;
int notify, type, plan, present;
unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
/* CC_HOLD INDICATION */
- struct message *message;
+ struct lcr_msg *message;
#ifdef SOCKET_MISDN
void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
RETRIEVE_REJECT_t *retrieve_reject;
RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge;
#endif
- struct message *message;
+ struct lcr_msg *message;
int channel, exclusive, cause;
int ret;
SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge;
SUSPEND_REJECT_t *suspend_reject;
#endif
- struct message *message;
+ struct lcr_msg *message;
class Endpoint *epoint;
unsigned char callid[8];
int len;
int len;
int channel, exclusive;
class Endpoint *epoint;
- struct message *message;
+ struct lcr_msg *message;
int ret;
#ifdef SOCKET_MISDN
/* process given callref */
l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
add_trace("callref", "new", "0x%x", pid);
- if (p_m_d_l3id != pid)
+ if (p_m_d_l3id)
{
/* release is case the ID is already in use */
add_trace("error", NULL, "callref already in use");
#endif
unsigned char facil[256];
int facil_len;
- struct message *message;
+ struct lcr_msg *message;
l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
#ifdef SOCKET_MISDN
#ifdef SOCKET_MISDN
void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
{
- int timer_hex=0;
+ int timer = 0;
switch (cmd)
{
PERROR("Pdss1(%s) timeout without cause.\n", p_name);
break;
}
- if (l3m->cause[1] != 5)
+ if (l3m->cause[0] != 5)
{
- PERROR("Pdss1(%s) expecting timeout with timer diagnostic.\n", p_name);
+ PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]);
break;
}
- if (l3m->cause[4]=='3' && l3m->cause[5]=='1' && l3m->cause[6]=='2')
- {
- l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
- add_trace("timer", NULL, "%x", timer_hex);
- end_trace();
+ timer = (l3m->cause[3]-'0')*100;
+ timer += (l3m->cause[4]-'0')*10;
+ timer += (l3m->cause[5]-'0');
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
+ add_trace("timer", NULL, "%d", timer);
+ end_trace();
+ if (timer == 312)
t312_timeout_ind(cmd, pid, l3m);
- }
break;
case MT_SETUP:
case MT_SETUP_ACKNOWLEDGE:
if (p_state != PORT_STATE_OUT_SETUP)
{
- PERROR("Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
+ PDEBUG(DEBUG_ISDN, "Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
break;
}
setup_acknowledge_ind(cmd, pid, l3m);
if (p_state != PORT_STATE_OUT_SETUP
&& p_state != PORT_STATE_OUT_OVERLAP)
{
- PERROR("Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
+ PDEBUG(DEBUG_ISDN, "Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
break;
}
proceeding_ind(cmd, pid, l3m);
&& p_state != PORT_STATE_OUT_OVERLAP
&& p_state != PORT_STATE_OUT_PROCEEDING)
{
- PERROR("Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
+ PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
break;
}
alerting_ind(cmd, pid, l3m);
&& p_state != PORT_STATE_OUT_PROCEEDING
&& p_state != PORT_STATE_OUT_ALERTING)
{
- PERROR("Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding OR ALERTING state, IGNORING.\n", p_name);
+ PDEBUG(DEBUG_ISDN, "Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding OR ALERTING state, IGNORING.\n", p_name);
break;
}
connect_ind(cmd, pid, l3m);
p_m_d_l3id = 0;
p_m_d_ces = -1;
p_m_delete = 1;
-//#warning remove me
-//PDEBUG(DEBUG_LOG, "JOLLY release cr %d\n", p_serial);
/* sending release to endpoint in case we still have an endpoint
* this is because we don't get any response if a release_complete is received (or a release in release state)
*/
- while(p_epointlist)
+ while(p_epointlist) // only if not already released
{
- struct message *message;
+ struct lcr_msg *message;
message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
- message->param.disconnectinfo.cause = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_cause:CAUSE_UNSPECIFIED;
- message->param.disconnectinfo.location = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_location:LOCATION_PRIVATE_LOCAL;
+ if (p_m_d_collect_cause)
+ {
+ message->param.disconnectinfo.cause = p_m_d_collect_cause;
+ message->param.disconnectinfo.location = p_m_d_collect_location;
+ } else
+ {
+ message->param.disconnectinfo.cause = CAUSE_NOUSER;
+ message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+ }
message_put(message);
/* remove epoint */
free_epointlist(p_epointlist);
*/
while(p_epointlist)
{
- struct message *message;
+ struct lcr_msg *message;
message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
message->param.disconnectinfo.cause = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_cause:CAUSE_UNSPECIFIED;
message->param.disconnectinfo.location = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_location:LOCATION_PRIVATE_LOCAL;
/* release if port is blocked */
if (p_m_mISDNport->ifport->block)
{
- struct message *message;
+ struct lcr_msg *message;
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
message->param.disconnectinfo.cause = 27; // temp. unavail.
ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL);
if (mt_assign_pid == 0 || ret < 0)
{
- struct message *message;
+ struct lcr_msg *message;
add_trace("callref", NULL, "no free id");
end_trace();
}
if (i == 0x100)
{
- struct message *message;
+ struct lcr_msg *message;
add_trace("callref", NULL, "no free id");
end_trace();
ncr.len = 0;
/* send message */
mISDN_write(mISDNdevice, &ncr, mISDN_HEADER_LEN+ncr.len, TIMEOUT_1SEC);
-// if (!dmsg)
-// goto nomem;
}
- add_trace("callref", "new", "0x%x", p_m_d_l3id);
#endif
+ add_trace("callref", "new", "0x%x", p_m_d_l3id);
end_trace();
/* preparing setup message */
DISCONNECT_t *disconnect;
RELEASE_COMPLETE_t *release_complete;
#endif
- struct message *message;
+ struct lcr_msg *message;
char *p = NULL;
/* we reject during incoming setup when we have no tones. also if we are in outgoing setup state */
*/
int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union parameter *param)
{
- struct message *message;
+ struct lcr_msg *message;
if (PmISDN::message_epoint(epoint_id, message_id, param))
return(1);
if (pid == 0)
{
- PERROR("PID is 0. change it.... quick...\n");
- return(-EINVAL);
+ PDEBUG(DEBUG_ISDN, "ignoring dummy process from phone.\n");
+ return(0);
}
/* find Port object of type ISDN */
while(port)
{
/* are we ISDN ? */
- if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
+ if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
{
pdss1 = (class Pdss1 *)port;
/* check out correct stack and id */
- if (pdss1->p_m_mISDNport == mISDNport
- && (pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
+ if (pdss1->p_m_mISDNport == mISDNport)
{
- /* found port, the message belongs to */
- break;
+ if (pdss1->p_m_d_l3id & MISDN_PID_CR_FLAG)
+ {
+ /* local callref, so match value only */
+ if ((pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK))
+ break; // found
+ } else
+ {
+ /* remote callref, ref + channel id */
+ if (pdss1->p_m_d_l3id == pid)
+ break; // found
+ }
}
}
port = port->next;
/* aktueller prozess */
if (port)
{
+ if (cmd == MT_ASSIGN)
+ {
+ /* stack gives us new layer 3 id (during connect) */
+ l1l2l3_trace_header(mISDNport, pdss1, L3_NEW_L3ID_IND, DIRECTION_IN);
+ add_trace("callref", "old", "0x%x", pdss1->p_m_d_l3id);
+ /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
+ if ((pdss1->p_m_d_l3id&MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER)
+ PERROR(" strange setup-procid 0x%x\n", pdss1->p_m_d_l3id);
+ pdss1->p_m_d_l3id = pid;
+ if (port->p_state == PORT_STATE_CONNECT)
+ pdss1->p_m_d_ces = pid >> 16;
+ add_trace("callref", "new", "0x%x", pdss1->p_m_d_l3id);
+ end_trace();
+ return(0);
+ }
/* if process id is master process, but a child disconnects */
if (mISDNport->ntmode
&& (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
- && (pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == MISDN_PID_MASTER)
+ && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) == MISDN_PID_MASTER)
{
- if (cmd == MT_DISCONNECT)
+ if (cmd == MT_DISCONNECT
+ || cmd == MT_RELEASE)
{
/* send special indication for child disconnect */
pdss1->disconnect_ind_i(cmd, pid, l3m);
return(0);
}
- // ignoring other messages from child processes
- return(0);
+ if (cmd == MT_RELEASE_COMPLETE)
+ return(0);
}
- /* if process id and layer 3 id matches */
- if (pid == pdss1->p_m_d_l3id)
- pdss1->message_isdn(cmd, pid, l3m);
+ /* if we have child pid and got different child pid message, ignore */
+ if (mISDNport->ntmode
+ && (pid & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
+ && (pdss1->p_m_d_l3id & MISDN_PID_CRTYPE_MASK) != MISDN_PID_MASTER
+ && pid != pdss1->p_m_d_l3id)
+ return(0);
+
+ /* process message */
+ pdss1->message_isdn(cmd, pid, l3m);
return(0);
}
break;
case MT_FREE:
- PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", pid);
+ PDEBUG(DEBUG_ISDN, "unused call ref released (l3id=0x%x)\n", pid);
break;
case MT_RELEASE_COMPLETE:
{
class Port *port;
class Pdss1 *pdss1;
- struct message *message;
+ struct lcr_msg *message;
if (!mISDNport->ntmode)
return;