X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=dss1.cpp;h=2df264504d2c620bf81d97f23008568ea8a35660;hp=c6e6549d1207789a1ac219943bbd4a105ad331bb;hb=012abb3e07c04507685491070cedd93e4b093374;hpb=258c2e57a441f1fd8ed779bb2d88992aba3c1e65 diff --git a/dss1.cpp b/dss1.cpp index c6e6549..2df2645 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -21,9 +21,7 @@ extern "C" { #include extern "C" { } -#include -#include -#include +#include extern unsigned long mt_assign_pid; #endif @@ -525,7 +523,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) 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 */ @@ -533,7 +531,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) add_trace("callref", "new", "0x%x", pid); if (p_m_d_l3id) { - /* release is case the ID is already in use */ + /* release in case the ID is already in use */ add_trace("error", NULL, "callref already in use"); end_trace(); l3m = create_l3msg(); @@ -547,8 +545,6 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) return; } p_m_d_l3id = pid; -#warning SOCKET TBD - // soll die ces wirklich von der pid abgeleitet werden oder kommt da noch ein "l3m->ces" ? p_m_d_ces = pid >> 16; end_trace(); #else @@ -883,7 +879,7 @@ void Pdss1::information_ind(unsigned long prim, unsigned long dinfo, void *data) #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 @@ -933,7 +929,7 @@ void Pdss1::setup_acknowledge_ind(unsigned long prim, unsigned long dinfo, void 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 @@ -981,7 +977,7 @@ void Pdss1::proceeding_ind(unsigned long prim, unsigned long dinfo, void *data) 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]; @@ -1080,7 +1076,7 @@ void Pdss1::alerting_ind(unsigned long prim, unsigned long dinfo, void *data) 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]; @@ -1181,14 +1177,11 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data) 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 -#warning SOCKET TBD -// p_m_d_ces = connect->ces; -#else p_m_d_ces = connect->ces; #endif @@ -1290,7 +1283,7 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data) #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 @@ -1315,7 +1308,7 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data) #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 @@ -1444,7 +1437,7 @@ void Pdss1::release_ind(unsigned long prim, unsigned long dinfo, void *data) 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 @@ -1514,14 +1507,23 @@ void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void * 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; @@ -1548,12 +1550,12 @@ void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void * #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 */ @@ -1577,6 +1579,7 @@ void Pdss1::t312_timeout_ind(unsigned long prim, unsigned long dinfo, void *data new_state(PORT_STATE_RELEASE); p_m_delete = 1; } +#endif /* CC_NOTIFY INDICATION */ #ifdef SOCKET_MISDN @@ -1588,7 +1591,7 @@ void Pdss1::notify_ind(unsigned long prim, unsigned long dinfo, void *data) 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)]; @@ -1649,7 +1652,7 @@ void Pdss1::notify_ind(unsigned long prim, unsigned long dinfo, void *data) /* 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) { @@ -1745,7 +1748,7 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data) RETRIEVE_REJECT_t *retrieve_reject; RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge; #endif - struct message *message; + struct lcr_msg *message; int channel, exclusive, cause; int ret; @@ -1843,7 +1846,7 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data) 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; @@ -1960,7 +1963,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) int len; int channel, exclusive; class Endpoint *epoint; - struct message *message; + struct lcr_msg *message; int ret; #ifdef SOCKET_MISDN @@ -2130,7 +2133,7 @@ void Pdss1::facility_ind(unsigned long prim, unsigned long dinfo, void *data) #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 @@ -2158,21 +2161,29 @@ void Pdss1::facility_ind(unsigned long prim, unsigned long dinfo, void *data) #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) { case MT_TIMEOUT: -#warning SOCKET TBD -// if (p_m_d_ntmode) -// timer_hex = *((int *)(((char *)data)/*+headerlen*/)); - if (timer_hex==0x312) + if (!l3m->cause) { - l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN); - add_trace("timer", NULL, "%x", timer_hex); - end_trace(); - t312_timeout_ind(cmd, pid, l3m); + PERROR("Pdss1(%s) timeout without cause.\n", p_name); + break; + } + if (l3m->cause[0] != 5) + { + PERROR("Pdss1(%s) expecting timeout with timer diagnostic. (got len=%d)\n", p_name, l3m->cause[0]); + break; } + 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: @@ -2188,7 +2199,7 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) 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); @@ -2198,7 +2209,7 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *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); @@ -2209,7 +2220,7 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *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); @@ -2221,7 +2232,7 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *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); @@ -2289,17 +2300,22 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *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); @@ -2482,7 +2498,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) */ 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; @@ -2652,7 +2668,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet /* 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. @@ -2735,7 +2751,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet 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(); @@ -2763,7 +2779,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet } if (i == 0x100) { - struct message *message; + struct lcr_msg *message; add_trace("callref", NULL, "no free id"); end_trace(); @@ -2791,11 +2807,9 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet 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 */ @@ -3552,7 +3566,7 @@ void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union pa 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 */ @@ -3852,7 +3866,7 @@ wirklich erst proceeding?: */ 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); @@ -4027,8 +4041,8 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi 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 */ @@ -4036,15 +4050,23 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi 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 == pid) + 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; @@ -4053,21 +4075,44 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi /* 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 */ -#warning SOCKET TBD -//hier das abfragen des child processes - if (0) + if (mISDNport->ntmode + && (pid & MISDN_PID_CRTYPE_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 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); } @@ -4093,7 +4138,7 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi 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: @@ -4375,7 +4420,7 @@ void setup_queue(struct mISDNport *mISDNport, int link) { class Port *port; class Pdss1 *pdss1; - struct message *message; + struct lcr_msg *message; if (!mISDNport->ntmode) return;