#include <sys/stat.h>
#include <fcntl.h>
extern "C" {
-#include <net_l2.h>
+#include <mISDNuser/net_l2.h>
}
-//#define CENTREX
-
#include "q931.h"
#include "ie.cpp"
/*
- * hunt bchannel for incomming setup or retrieve or resume
+ * hunt bchannel for incoming setup or retrieve or resume
*/
int Pdss1::hunt_bchannel(int channel, int exclusive)
{
}
if (channel <= 0) /* not given, no channel, whatever.. */
channel = CHANNEL_ANY; /* any channel */
+ add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) // of out chan..
{
- add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved);
add_trace("conclusion", NULL, "all channels are reserved");
end_trace();
return(-34); // no channel
dec_ie_calling_pn(setup->CALLING_PN, (Q931_info_t *)((unsigned long)data+headerlen), &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
-#ifdef CENTREX
/* te-mode: CNIP (calling name identification presentation) */
if (!p_m_d_ntmode)
dec_facility_centrex(setup->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
-#endif
dec_ie_useruser(setup->USER_USER, (Q931_info_t *)((unsigned long)data+headerlen), &useruser_protocol, useruser, &useruser_len);
dec_ie_complete(setup->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete);
dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)((unsigned long)data+headerlen), &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
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)))
+ if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incoming
FATAL("No memory for Endpoint Application instance\n");
epointlist_new(epoint->ep_serial);
l1l2l3_trace_header(p_m_mISDNport, this, prim, DIRECTION_IN);
dec_ie_channel_id(connect->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
dec_ie_connected_pn(connect->CONNECT_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
-#ifdef CENTREX
/* te-mode: CONP (connected name identification presentation) */
if (!p_m_d_ntmode)
dec_facility_centrex(connect->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
-#endif
end_trace();
/* select channel */
add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
}
dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
- end_trace();
if (location == LOCATION_PRIVATE_LOCAL)
location = LOCATION_PRIVATE_REMOTE;
collect_cause(&p_m_d_collect_cause, &p_m_d_collect_location, cause, location);
add_trace("new-cause", "location", "%d", p_m_d_collect_location);
add_trace("new-cause", "value", "%d", p_m_d_collect_cause);
+ end_trace();
}
}
p_m_d_l3id = 0;
p_m_delete = 1;
-#warning remove me
-PDEBUG(DEBUG_LOG, "JOLLY release cr %d\n", p_serial);
+//#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)
*/
class Endpoint *epoint;
/* set timeout */
- epoint = find_epoint_id(ACTIVE_EPOINT(p_epointlist));
- if (epoint && p_m_d_ntmode)
+ if (state == PORT_STATE_IN_OVERLAP)
{
- if (state == PORT_STATE_IN_OVERLAP)
+ p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
+ time(&p_m_timer);
+ }
+ if (state != p_state)
+ {
+ 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_settings.tout_dialing;
+ p_m_timeout = p_m_mISDNport->ifport->tout_setup;
time(&p_m_timer);
}
- if (state != p_state)
+ if (state == PORT_STATE_IN_PROCEEDING
+ || state == PORT_STATE_OUT_PROCEEDING)
{
- if (state == PORT_STATE_IN_SETUP
- || state == PORT_STATE_IN_OVERLAP)
- {
- p_m_timeout = p_settings.tout_setup;
- time(&p_m_timer);
- }
- if (state == PORT_STATE_IN_PROCEEDING
- || state == PORT_STATE_OUT_PROCEEDING)
- {
- p_m_timeout = p_settings.tout_proceeding;
- time(&p_m_timer);
- }
- if (state == PORT_STATE_IN_ALERTING
- || state == PORT_STATE_OUT_ALERTING)
- {
- p_m_timeout = p_settings.tout_alerting;
- time(&p_m_timer);
- }
- if (state == PORT_STATE_CONNECT
- || state == PORT_STATE_CONNECT_WAITING)
- {
- p_m_timeout = 0;
- }
- if (state == PORT_STATE_IN_DISCONNECT
- || state == PORT_STATE_OUT_DISCONNECT)
- {
- p_m_timeout = p_settings.tout_disconnect;
- time(&p_m_timer);
- }
+ p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
+ time(&p_m_timer);
+ }
+ 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 (state == PORT_STATE_CONNECT
+ || state == PORT_STATE_CONNECT_WAITING)
+ {
+ p_m_timeout = 0;
+ }
+ if (state == PORT_STATE_IN_DISCONNECT
+ || state == PORT_STATE_OUT_DISCONNECT)
+ {
+ p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
+ time(&p_m_timer);
}
}
{
int ret;
-if (p_m_delete && p_m_d_l3id==0)
- printf("ping! %d", p_serial);
+//if (p_m_delete && p_m_d_l3id==0)
+// printf("ping! %d", p_serial);
if ((ret = PmISDN::handler()))
return(ret);
/* handle destruction */
if (p_m_delete && p_m_d_l3id==0)
{
-#warning remove
-PDEBUG(DEBUG_LOG, "JOLLY destroy object %d\n", p_serial);
+//#warning remove
+//PDEBUG(DEBUG_LOG, "JOLLY destroy object %d\n", p_serial);
delete this;
return(-1);
memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo));
memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo));
// 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);
/* only display at connect state: this case happens if endpoint is in connected mode */
if (p_state==PORT_STATE_CONNECT)
/* display */
if (p_callerinfo.display[0] && p_m_d_ntmode)
enc_ie_display(&setup->DISPLAY, dmsg, (unsigned char *)p_callerinfo.display);
-#ifdef CENTREX
/* nt-mode: CNIP (calling name identification presentation) */
- if (p_callerinfo.name[0] && p_m_d_ntmode)
- enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
-#endif
+// if (p_callerinfo.name[0] && p_m_d_ntmode)
+// enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
end_trace();
/* send setup message now */
/* 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);
/* only display at connect state */
if (p_state == PORT_STATE_CONNECT)
/* display */
if (p_connectinfo.display[0] && p_m_d_ntmode)
enc_ie_display(&connect->DISPLAY, dmsg, (unsigned char *)p_connectinfo.display);
-#ifdef CENTREX
/* nt-mode: CONP (connected name identification presentation) */
- if (p_connectinfo.name[0] && p_m_d_ntmode)
- enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
-#endif
+// if (p_connectinfo.name[0] && p_m_d_ntmode)
+// enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
/* date & time */
if (p_m_d_ntmode)
{
char *p = NULL;
/*
- * we may only release during incomming disconnect state.
+ * we may only release during incoming disconnect state.
* this means that the endpoint doesnt require audio anymore
*/
- if (p_state == PORT_STATE_IN_DISCONNECT)
+ if (p_state == PORT_STATE_IN_DISCONNECT
+ || p_state == PORT_STATE_OUT_DISCONNECT)
{
/* sending release */
dmsg = create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, p_m_d_l3id, sizeof(RELEASE_t), p_m_d_ntmode);
// // 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);
+//#warning remove me
+//PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
/* sending release complete */
dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
/* remove epoint */
free_epointid(epoint_id);
// wait for release and callref to be released
-#warning remove me
-PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
+//#warning remove me
+//PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
}
/* check out correct stack */
if (pdss1->p_m_mISDNport == mISDNport)
/* check out correct id */
- if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
+ if ((pdss1->p_m_d_l3id&0x0000ff00) != 0x000ff00)
{
- /* found port, the message belongs to */
- break;
+ /* a single process */
+ if (hh->dinfo == pdss1->p_m_d_l3id)
+ {
+ /* found port, the message belongs to */
+ break;
+ }
+ } else
+ {
+ /* a broadcast process */
+ if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
+ {
+ /* found port, the message belongs to */
+ break;
+ }
}
}
port = port->next;
}
if (port)
{
+//printf("%x %x\n", hh->dinfo, pdss1->p_m_d_l3id);
/* if process id is master process, but a child disconnects */
- if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00 && hh->prim==(CC_DISCONNECT|INDICATION))
+ if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00)
{
- /* send special indication for child disconnect */
- pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
+ if (hh->prim == (CC_DISCONNECT|INDICATION))
+ {
+ /* send special indication for child disconnect */
+ pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
+ free_msg(msg);
+ return(0);
+ }
+ // ignoring other messages from child processes
free_msg(msg);
return(0);
}
time(&mISDNport->l2establish);
PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
}
-#warning debugging usleep crash
- printf("JOLLY release port %d\n", mISDNport->portnum);
+//#warning debugging usleep crash
+// printf("JOLLY release port %d\n", mISDNport->portnum);
usleep(1);
break;
PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", hh->dinfo);
break;
- case CC_DISCONNECT | INDICATION:
+ case CC_RELEASE_COMPLETE | INDICATION:
+ break;
+
+ case CC_FACILITY | INDICATION:
+ break;
- // fall throug
default:
PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
+ port = port_first;
+ while(port)
+ {
+ if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
+ {
+ pdss1 = (class Pdss1 *)port;
+ //PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
+ /* check out correct stack */
+ if (pdss1->p_m_mISDNport == mISDNport)
+ /* check out correct id */
+ PERROR("unhandled message: dinfo=%x is not associated with port-dinfo=%x\n",hh->dinfo,pdss1->p_m_d_l3id);
+ }
+ port = port->next;
+ }
return(-EINVAL);
}
free_msg(msg);
if (frm->prim == (CC_RELEASE_CR | INDICATION))
{
- PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", frm->dinfo);
+ PDEBUG(DEBUG_ISDN, "unhandled message from stack: call ref released (l3id=0x%x)\n", frm->dinfo);
free_msg(msg);
return(0);
}