#include "ie.cpp"
+static int delete_event(struct lcr_work *work, void *instance, int index);
+
/*
* constructor
*/
p_m_d_ntmode = mISDNport->ntmode;
p_m_d_tespecial = mISDNport->tespecial;
p_m_d_l3id = 0;
+ memset(&p_m_d_delete, 0, sizeof(p_m_d_delete));
+ add_work(&p_m_d_delete, delete_event, this, 0);
p_m_d_ces = -1;
p_m_d_queue[0] = '\0';
p_m_d_notify_pending = NULL;
*/
Pdss1::~Pdss1()
{
+ del_work(&p_m_d_delete);
+
/* remove queued message */
if (p_m_d_notify_pending)
message_free(p_m_d_notify_pending);
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return(-34); /* to epoint: no channel available */
}
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
p_m_d_l3id = pid;
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_PROCEEDING);
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_ALERTING);
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
free_epointlist(p_epointlist);
}
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
}
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
}
/* CC_RESTART INDICATION */
}
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
}
/* T312 timeout */
#if 0
epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
if (epoint && p_m_d_ntmode) {
- p_m_timeout = p_settings.tout_hold;
- time(&p_m_timer);
+ if (p_settings.tout_hold)
+ schedule_timer(&p_m_timeout, p_settings.tout_hold, 0);
}
#endif
/* set hold state */
p_m_hold = 0;
- p_m_timeout = 0;
+ unsched_timer(&p_m_timeout);
/* acknowledge retrieve */
l3m = create_l3msg();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
}
/* CC_RESUME INDICATION */
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, pid, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
p_m_d_l3id = pid;
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
bchannel_event(p_m_mISDNport, p_m_b_index, B_EVENT_USE);
add_trace("callref", NULL, "0x%x", p_m_d_l3id);
end_trace();
p_m_d_l3id = 0;
+ trigger_work(&p_m_d_delete);
p_m_d_ces = -1;
- p_m_delete = 1;
/* 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)
*/
/* set timeout */
if (state == PORT_STATE_IN_OVERLAP) {
- p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
- time(&p_m_timer);
+ if (p_m_mISDNport->ifport->tout_dialing)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_dialing, 0);
}
if (state != p_state) {
+ unsched_timer(&p_m_timeout);
if (state == PORT_STATE_IN_SETUP
|| state == PORT_STATE_OUT_SETUP
|| state == PORT_STATE_IN_OVERLAP
|| state == PORT_STATE_OUT_OVERLAP) {
- p_m_timeout = p_m_mISDNport->ifport->tout_setup;
- time(&p_m_timer);
+ if (p_m_mISDNport->ifport->tout_setup)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_setup, 0);
}
if (state == PORT_STATE_IN_PROCEEDING
|| state == PORT_STATE_OUT_PROCEEDING) {
- p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
- time(&p_m_timer);
+ if (p_m_mISDNport->ifport->tout_proceeding)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_proceeding, 0);
}
if (state == PORT_STATE_IN_ALERTING
|| state == PORT_STATE_OUT_ALERTING) {
- p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
- time(&p_m_timer);
+ if (p_m_mISDNport->ifport->tout_alerting)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_alerting, 0);
}
+#if 0
if (state == PORT_STATE_CONNECT
|| state == PORT_STATE_CONNECT_WAITING) {
- p_m_timeout = 0;
+ if (p_m_mISDNport->ifport->tout_connect)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_connect, 0);
}
+#endif
if (state == PORT_STATE_IN_DISCONNECT
|| state == PORT_STATE_OUT_DISCONNECT) {
- p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
- time(&p_m_timer);
+ if (p_m_mISDNport->ifport->tout_disconnect)
+ schedule_timer(&p_m_timeout, p_m_mISDNport->ifport->tout_disconnect, 0);
}
}
}
-/*
- * handler
- */
-int Pdss1::handler(void)
+/* deletes only if l3id is release, otherwhise it will be triggered then */
+static int delete_event(struct lcr_work *work, void *instance, int index)
{
- int ret;
+ class Pdss1 *isdnport = (class Pdss1 *)instance;
- if ((ret = PmISDN::handler()))
- return(ret);
+ if (!isdnport->p_m_d_l3id)
+ delete isdnport;
- /* handle destruction */
- if (p_m_delete && p_m_d_l3id==0) {
- delete this;
- return(-1);
- }
-
- return(0);
+ return 0;
}
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
message_put(message);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}
p_m_d_l3id = mt_assign_pid;
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 */
if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP) {
/* date & time */
if (p_m_d_ntmode || p_m_d_tespecial) {
epoint = find_epoint_id(epoint_id);
- enc_ie_date(l3m, now, p_settings.no_seconds);
+ time(¤t_time);
+ enc_ie_date(l3m, current_time, p_settings.no_seconds);
}
end_trace();
/* finally send message */
end_trace();
p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
new_state(PORT_STATE_RELEASE);
- p_m_delete = 1;
+ trigger_work(&p_m_d_delete);
return;
}