** **
\*****************************************************************************/
-
#include "main.h"
-#include <poll.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifdef SOCKET_MISDN
-#include <netinet/udp.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <pthread.h>
-#include <linux/mISDNif.h>
-#include <q931.h>
-#include <mlayer3.h>
-#else
+#ifndef SOCKET_MISDN
extern "C" {
#include <mISDNuser/net_l2.h>
}
+
+#ifndef CMX_TXDATA_ON
+#define OLD_MISDN
+#endif
+#ifndef CMX_TXDATA_OFF
+#define OLD_MISDN
+#endif
+#ifndef CMX_DELAY
+#define OLD_MISDN
+#endif
+#ifndef PIPELINE_CFG
+#define OLD_MISDN
+#endif
+#ifndef CMX_TX_DATA
+#define OLD_MISDN
+#endif
+
+#ifdef OLD_MISDN
+#warning
+#warning *********************************************************
+#warning *
+#warning * It seems that you use an older version of mISDN.
+#warning * Features like voice recording or echo will not work.
+#warning * Also it causes problems with loading modules and may
+#warning * not work at all.
+#warning *
+#warning * Please upgrade to newer version. A working version can
+#warning * be found at www.linux-call-router.de.
+#warning *
+#warning * Do not use the mISDN_1_1 branch, it does not have all
+#warning * the features that are required. Use the master branch
+#warning * instead.
+#warning *
+#warning *********************************************************
+#warning
+#error
#endif
#ifndef ISDN_PID_L4_B_USER
#define ISDN_PID_L4_B_USER 0x440000ff
#endif
+#endif
+
+// timeouts if activating/deactivating response from mISDN got lost
+#define B_TIMER_ACTIVATING 1 // seconds
+#define B_TIMER_DEACTIVATING 1 // seconds
/* list of mISDN ports */
struct mISDNport *mISDNport_first;
unsigned char mISDN_rand[256];
int mISDN_rand_count = 0;
-#ifdef MISDN_SOCKET
+#ifdef SOCKET_MISDN
int mISDNsocket = -1;
int mISDN_initialize(void)
return(-1);
}
- /* initialize stuff of the NT lib */
+ /* open debug, if enabled and not only stack debugging */
+ if (options.deb && (options.deb != DEBUG_STACK))
+ {
+ SPRINT(debug_log, "%s/debug.log", INSTALL_DATA);
+ debug_fp = fopen(debug_log, "a");
+ }
+
if (options.deb & DEBUG_STACK)
{
- global_debug = 0xffffffff & ~DBGM_MSG;
-// global_debug = DBGM_L3DATA;
+ SPRINT(debug_stack, "%s/debug_mISDN.log", INSTALL_DATA);
+ mISDN_debug_init(DBGM_ALL, debug_stack, debug_stack, debug_stack);
} else
- global_debug = DBGM_MAN;
- SPRINT(debug_log, "%s/debug.log", INSTALL_DATA);
- if (options.deb & DEBUG_LOG)
- mISDN_debug_init(global_debug, debug_log, debug_log, debug_log);
- else
- mISDN_debug_init(global_debug, NULL, NULL, NULL);
+ mISDN_debug_init(0, NULL, NULL, NULL);
/* init mlayer3 */
init_layer3(4); // buffer of 4
mISDN_debug_close();
+ if (debug_fp)
+ fclose(debug_fp);
+ debug_fp = NULL;
+
if (mISDNsocket > -1)
close(mISDNsocket);
}
unsigned char buff[1025];
debug_close();
+ global_debug = 0;
if (mISDNdevice >= 0)
{
p_m_b_reserve = 0;
p_m_delete = 0;
p_m_hold = 0;
- p_m_txvol = p_m_rxvol = 0;
+ p_m_tx_gain = mISDNport->ifport->interface->tx_gain;
+ p_m_rx_gain = mISDNport->ifport->interface->rx_gain;
p_m_conf = 0;
p_m_txdata = 0;
p_m_delay = 0;
p_m_timer = 0;
p_m_remote_ref = 0; /* channel shall be exported to given remote */
p_m_remote_id = 0; /* channel shall be exported to given remote */
-
+ SCPY(p_m_pipeline, mISDNport->ifport->interface->pipeline);
+
/* audio */
p_m_load = 0;
p_m_last_tv_sec = 0;
p_m_crypt_msg_len = 0;
p_m_crypt_msg[0] = '\0';
p_m_crypt_msg_current = 0;
- p_m_crypt_key[0] = '\0';
p_m_crypt_key_len = 0;
p_m_crypt_listen = 0;
p_m_crypt_listen_state = 0;
p_m_crypt_listen_len = 0;
p_m_crypt_listen_msg[0] = '\0';
p_m_crypt_listen_crc = 0;
+ if (mISDNport->ifport->interface->bf_len >= 4 && mISDNport->ifport->interface->bf_len <= 56)
+ {
+ memcpy(p_m_crypt_key, mISDNport->ifport->interface->bf_key, p_m_crypt_key_len);
+ p_m_crypt_key_len = mISDNport->ifport->interface->bf_len;
+ p_m_crypt = 1;
+ }
/* if any channel requested by constructor */
if (channel == CHANNEL_ANY)
char *name;
unsigned long value;
} isdn_message[] = {
- {"TIMEOUT", CC_TIMEOUT},
- {"SETUP", CC_SETUP},
- {"SETUP_ACK", CC_SETUP_ACKNOWLEDGE},
- {"PROCEEDING", CC_PROCEEDING},
- {"ALERTING", CC_ALERTING},
- {"CONNECT", CC_CONNECT},
- {"CONNECT RES", CC_CONNECT},
- {"CONNECT_ACK", CC_CONNECT_ACKNOWLEDGE},
- {"DISCONNECT", CC_DISCONNECT},
- {"RELEASE", CC_RELEASE},
- {"RELEASE_COMP", CC_RELEASE_COMPLETE},
- {"INFORMATION", CC_INFORMATION},
- {"PROGRESS", CC_PROGRESS},
- {"NOTIFY", CC_NOTIFY},
- {"SUSPEND", CC_SUSPEND},
- {"SUSPEND_ACK", CC_SUSPEND_ACKNOWLEDGE},
- {"SUSPEND_REJ", CC_SUSPEND_REJECT},
- {"RESUME", CC_RESUME},
- {"RESUME_ACK", CC_RESUME_ACKNOWLEDGE},
- {"RESUME_REJ", CC_RESUME_REJECT},
- {"HOLD", CC_HOLD},
- {"HOLD_ACK", CC_HOLD_ACKNOWLEDGE},
- {"HOLD_REJ", CC_HOLD_REJECT},
- {"RETRIEVE", CC_RETRIEVE},
- {"RETRIEVE_ACK", CC_RETRIEVE_ACKNOWLEDGE},
- {"RETRIEVE_REJ", CC_RETRIEVE_REJECT},
- {"FACILITY", CC_FACILITY},
- {"STATUS", CC_STATUS},
- {"RESTART", CC_RESTART},
- {"RELEASE_CR", CC_RELEASE_CR},
- {"NEW_CR", CC_NEW_CR},
- {"DL_ESTABLISH", DL_ESTABLISH},
- {"DL_RELEASE", DL_RELEASE},
- {"PH_ACTIVATE", PH_ACTIVATE},
- {"PH_DEACTIVATE", PH_DEACTIVATE},
+ {"PH_ACTIVATE", L1_ACTIVATE_REQ},
+ {"PH_DEACTIVATE", L1_DEACTIVATE_REQ},
+ {"DL_ESTABLISH", L2_ESTABLISH_REQ},
+ {"DL_RELEASE", L2_RELEASE_REQ},
+ {"UNKNOWN", L3_UNKNOWN},
+ {"MT_TIMEOUT", L3_TIMEOUT_REQ},
+ {"MT_SETUP", L3_SETUP_REQ},
+ {"MT_SETUP_ACK", L3_SETUP_ACKNOWLEDGE_REQ},
+ {"MT_PROCEEDING", L3_PROCEEDING_REQ},
+ {"MT_ALERTING", L3_ALERTING_REQ},
+ {"MT_CONNECT", L3_CONNECT_REQ},
+ {"MT_CONNECT_ACK", L3_CONNECT_ACKNOWLEDGE_REQ},
+ {"MT_DISCONNECT", L3_DISCONNECT_REQ},
+ {"MT_RELEASE", L3_RELEASE_REQ},
+ {"MT_RELEASE_COMP", L3_RELEASE_COMPLETE_REQ},
+ {"MT_INFORMATION", L3_INFORMATION_REQ},
+ {"MT_PROGRESS", L3_PROGRESS_REQ},
+ {"MT_NOTIFY", L3_NOTIFY_REQ},
+ {"MT_SUSPEND", L3_SUSPEND_REQ},
+ {"MT_SUSPEND_ACK", L3_SUSPEND_ACKNOWLEDGE_REQ},
+ {"MT_SUSPEND_REJ", L3_SUSPEND_REJECT_REQ},
+ {"MT_RESUME", L3_RESUME_REQ},
+ {"MT_RESUME_ACK", L3_RESUME_ACKNOWLEDGE_REQ},
+ {"MT_RESUME_REJ", L3_RESUME_REJECT_REQ},
+ {"MT_HOLD", L3_HOLD_REQ},
+ {"MT_HOLD_ACK", L3_HOLD_ACKNOWLEDGE_REQ},
+ {"MT_HOLD_REJ", L3_HOLD_REJECT_REQ},
+ {"MT_RETRIEVE", L3_RETRIEVE_REQ},
+ {"MT_RETRIEVE_ACK", L3_RETRIEVE_ACKNOWLEDGE_REQ},
+ {"MT_RETRIEVE_REJ", L3_RETRIEVE_REJECT_REQ},
+ {"MT_FACILITY", L3_FACILITY_REQ},
+ {"MT_STATUS", L3_STATUS_REQ},
+ {"MT_RESTART", L3_RESTART_REQ},
+#ifdef SOCKET_MISDN
+ {"MT_ASSIGN", L3_ASSIGN_REQ},
+ {"MT_FREE", L3_FREE_REQ},
+#else
+ {"MT_NEW_CR", L3_NEW_CR_REQ},
+ {"MT_RELEASE_CR", L3_RELEASE_CR_REQ},
+#endif
{NULL, 0},
};
" INDICATION",
" RESPONSE",
};
-void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned long prim, int direction)
+void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsigned long msg, int direction)
{
int i;
char msgtext[64] = "<<UNKNOWN MESSAGE>>";
i = 0;
while(isdn_message[i].name)
{
- if (isdn_message[i].value == (prim&0xffffff00))
+ if (isdn_message[i].value == (msg&0xffffff00))
{
SCPY(msgtext, isdn_message[i].name);
break;
}
i++;
}
- SCAT(msgtext, isdn_prim[prim&0x00000003]);
+ SCAT(msgtext, isdn_prim[msg&0x00000003]);
/* add direction */
- if (direction && (prim&0xffffff00)!=CC_NEW_CR && (prim&0xffffff00)!=CC_RELEASE_CR)
+ if (direction && (msg&0xffffff00)!=L3_NEW_CR_REQ && (msg&0xffffff00)!=L3_RELEASE_CR_REQ)
{
if (mISDNport)
{
/* open socket */
mISDNport->b_socket[i] = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_L2DSP);
- if (mISDNport->b_socket[i])
+ if (mISDNport->b_socket[i] < 0)
{
PERROR("Error: Failed to open bchannel-socket for index %d with mISDN-DSP layer. Did you load mISDNdsp.ko?\n", i);
return(0);
/* trace */
chan_trace_header(mISDNport, mISDNport->b_port[i], activate?(char*)"BCHANNEL activate":(char*)"BCHANNEL deactivate", DIRECTION_OUT);
add_trace("channel", NULL, "%d", i+1+(i>=15));
+ if (mISDNport->b_timer[i])
+ add_trace("event", NULL, "timeout recovery");
end_trace();
}
}
/* set dsp features */
+#ifndef OLD_MISDN
if (port->p_m_txdata)
ph_control(mISDNport, port, handle, (port->p_m_txdata)?CMX_TXDATA_ON:CMX_TXDATA_OFF, 0, "DSP-TXDATA", port->p_m_txdata);
if (port->p_m_delay)
ph_control(mISDNport, port, handle, CMX_DELAY, port->p_m_delay, "DSP-DELAY", port->p_m_delay);
- if (port->p_m_txvol)
- ph_control(mISDNport, port, handle, VOL_CHANGE_TX, port->p_m_txvol, "DSP-TXVOL", port->p_m_txvol);
- if (port->p_m_rxvol)
- ph_control(mISDNport, port, handle, VOL_CHANGE_RX, port->p_m_rxvol, "DSP-RXVOL", port->p_m_rxvol);
+#endif
+ if (port->p_m_tx_gain)
+ ph_control(mISDNport, port, handle, VOL_CHANGE_TX, port->p_m_tx_gain, "DSP-TX_GAIN", port->p_m_tx_gain);
+ if (port->p_m_rx_gain)
+ ph_control(mISDNport, port, handle, VOL_CHANGE_RX, port->p_m_rx_gain, "DSP-RX_GAIN", port->p_m_rx_gain);
+#ifndef OLD_MISDN
+ if (port->p_m_pipeline[0])
+ ph_control_block(mISDNport, port, handle, PIPELINE_CFG, port->p_m_pipeline, strlen(port->p_m_pipeline)+1, "DSP-PIPELINE", 0);
+#endif
if (port->p_m_conf)
ph_control(mISDNport, port, handle, CMX_CONF_JOIN, port->p_m_conf, "DSP-CONF", port->p_m_conf);
if (port->p_m_echo)
{
class PmISDN *b_port = mISDNport->b_port[i];
int state = mISDNport->b_state[i];
+ double timer = mISDNport->b_timer[i];
unsigned long p_m_remote_ref = 0;
unsigned long p_m_remote_id = 0;
+ int p_m_tx_gain = 0;
+ int p_m_rx_gain = 0;
+ char *p_m_pipeline = NULL;
+ unsigned char *p_m_crypt_key = NULL;
+ int p_m_crypt_key_len = 0;
+ int p_m_crypt_key_type = 0;
#ifdef SOCKET_MISDN
unsigned long portid = (mISDNport->portnum<<8) + i+1+(i>=15);
#else
- unsigned long portid = mISDNport->b_addr[i];
+ unsigned long portid = mISDNport->b_stid[i];
#endif
if (b_port)
{
p_m_remote_id = b_port->p_m_remote_id;
p_m_remote_ref = b_port->p_m_remote_ref;
+ p_m_tx_gain = b_port->p_m_tx_gain;
+ p_m_rx_gain = b_port->p_m_rx_gain;
+ p_m_pipeline = b_port->p_m_pipeline;
+ p_m_crypt_key = b_port->p_m_crypt_key;
+ p_m_crypt_key_len = b_port->p_m_crypt_key_len;
+ p_m_crypt_key_type = /*b_port->p_m_crypt_key_type*/1;
}
switch(event)
if (p_m_remote_ref)
{
/* export bchannel */
- message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid);
+ message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "assign");
#ifdef SOCKET_MISDN
{
_bchannel_activate(mISDNport, i, 1);
state = B_STATE_ACTIVATING;
+ timer = now_d + B_TIMER_ACTIVATING;
}
}
break;
/* in case, the bchannel is exported right after seize_bchannel */
/* export bchannel */
/* p_m_remote_id is set, when this event happens. */
- message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid);
+ message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "assign");
#ifdef SOCKET_MISDN
/* bchannel is active, so we deactivate */
_bchannel_activate(mISDNport, i, 0);
state = B_STATE_DEACTIVATING;
+ timer = now_d + B_TIMER_DEACTIVATING;
break;
default:
break;
case B_EVENT_ACTIVATED:
+ timer = 0;
switch(state)
{
case B_STATE_ACTIVATING:
/* bchannel is active, but exported OR not used anymore (or has wrong stack config), so we deactivate */
_bchannel_activate(mISDNport, i, 0);
state = B_STATE_DEACTIVATING;
+ timer = now_d + B_TIMER_DEACTIVATING;
}
break;
* OR bchannel is not used anymore
* OR bchannel has been exported to an obsolete ref,
* so reimport, to later export to new remote */
- message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid);
+ message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "remove");
#ifdef SOCKET_MISDN
/* bchannel is active, so we deactivate */
_bchannel_activate(mISDNport, i, 0);
state = B_STATE_DEACTIVATING;
+ timer = now_d + B_TIMER_DEACTIVATING;
break;
case B_STATE_REMOTE:
/* bchannel is exported, so we re-import */
- message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid);
+ message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "remove");
#ifdef SOCKET_MISDN
break;
case B_EVENT_DEACTIVATED:
+ timer = 0;
switch(state)
{
case B_STATE_IDLE:
/* bchannel is now deactivate, but is requied by Port class, so we reactivate / export */
if (p_m_remote_ref)
{
- message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid);
+ message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "assign");
#ifdef SOCKET_MISDN
{
_bchannel_activate(mISDNport, i, 1);
state = B_STATE_ACTIVATING;
+ timer = now_d + B_TIMER_ACTIVATING;
}
}
}
/* bchannel is now imported, but is requied by Port class, so we reactivate / export */
if (p_m_remote_ref)
{
- message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid);
+ message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
add_trace("type", NULL, "assign");
#ifdef SOCKET_MISDN
{
_bchannel_activate(mISDNport, i, 1);
state = B_STATE_ACTIVATING;
+ timer = now_d + B_TIMER_ACTIVATING;
}
}
}
}
break;
+ case B_EVENT_TIMEOUT:
+ timer = 0;
+ switch(state)
+ {
+ case B_STATE_IDLE:
+ /* ignore due to deactivation confirm after unloading */
+ break;
+
+ case B_STATE_ACTIVATING:
+ _bchannel_activate(mISDNport, i, 1);
+ timer = now_d + B_TIMER_ACTIVATING;
+ break;
+
+ case B_STATE_DEACTIVATING:
+ _bchannel_activate(mISDNport, i, 0);
+ timer = now_d + B_TIMER_DEACTIVATING;
+ break;
+
+ default:
+ PERROR("Illegal event %d at state %d, please correct.\n", event, state);
+ }
+ break;
+
default:
PERROR("Illegal event %d, please correct.\n", event);
}
mISDNport->b_state[i] = state;
+ mISDNport->b_timer[i] = timer;
}
p_m_load = 0;
/* to send data, tone must be active OR crypt messages must be on */
- if ((p_tone_name[0] || p_m_crypt_msg_loops) && p_m_load < ISDN_LOAD)
+ if ((p_tone_name[0] || p_m_crypt_msg_loops)
+ && (p_m_load < ISDN_LOAD)
+ && (p_state==PORT_STATE_CONNECT || p_m_mISDNport->tones))
{
int tosend = ISDN_LOAD - p_m_load, length;
#ifdef SOCKET_MISDN
/* next loop */
p_m_crypt_msg_current = 0;
p_m_crypt_msg_loops--;
+// puts("eine loop weniger");
}
/* new length */
{
switch(frm->dinfo)
{
+#ifndef OLD_MISDN
case CMX_TX_DATA:
if (!p_m_txdata)
{
if (p_record)
record(data, len, 1); // from up
break;
+#endif
default:
chan_trace_header(p_m_mISDNport, this, "BCHANNEL signal", DIRECTION_IN);
switch(param->mISDNsignal.message)
{
case mISDNSIGNAL_VOLUME:
- if (p_m_txvol != param->mISDNsignal.txvol)
+ if (p_m_tx_gain != param->mISDNsignal.tx_gain)
{
- p_m_txvol = param->mISDNsignal.txvol;
- PDEBUG(DEBUG_BCHANNEL, "we change tx-volume to shift=%d.\n", p_m_txvol);
+ p_m_tx_gain = param->mISDNsignal.tx_gain;
+ PDEBUG(DEBUG_BCHANNEL, "we change tx-volume to shift=%d.\n", p_m_tx_gain);
if (p_m_b_index >= 0)
if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
#ifdef SOCKET_MISDN
- ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], VOL_CHANGE_TX, p_m_txvol, "DSP-TXVOL", p_m_txvol);
+ ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], VOL_CHANGE_TX, p_m_tx_gain, "DSP-TX_GAIN", p_m_tx_gain);
#else
- ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_TX, p_m_txvol, "DSP-TXVOL", p_m_txvol);
+ ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_TX, p_m_tx_gain, "DSP-TX_GAIN", p_m_tx_gain);
#endif
} else
- PDEBUG(DEBUG_BCHANNEL, "we already have tx-volume shift=%d.\n", p_m_rxvol);
- if (p_m_rxvol != param->mISDNsignal.rxvol)
+ PDEBUG(DEBUG_BCHANNEL, "we already have tx-volume shift=%d.\n", p_m_rx_gain);
+ if (p_m_rx_gain != param->mISDNsignal.rx_gain)
{
- p_m_rxvol = param->mISDNsignal.rxvol;
- PDEBUG(DEBUG_BCHANNEL, "we change rx-volume to shift=%d.\n", p_m_rxvol);
+ p_m_rx_gain = param->mISDNsignal.rx_gain;
+ PDEBUG(DEBUG_BCHANNEL, "we change rx-volume to shift=%d.\n", p_m_rx_gain);
if (p_m_b_index >= 0)
if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
#ifdef SOCKET_MISDN
- ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], VOL_CHANGE_RX, p_m_rxvol, "DSP-RXVOL", p_m_rxvol);
+ ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], VOL_CHANGE_RX, p_m_rx_gain, "DSP-RX_GAIN", p_m_rx_gain);
#else
- ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_RX, p_m_rxvol, "DSP-RXVOL", p_m_rxvol);
+ ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_RX, p_m_rx_gain, "DSP-RX_GAIN", p_m_rx_gain);
#endif
} else
- PDEBUG(DEBUG_BCHANNEL, "we already have rx-volume shift=%d.\n", p_m_rxvol);
+ PDEBUG(DEBUG_BCHANNEL, "we already have rx-volume shift=%d.\n", p_m_rx_gain);
break;
case mISDNSIGNAL_CONF:
{
p_m_delay = param->mISDNsignal.delay;
PDEBUG(DEBUG_BCHANNEL, "we change delay mode to delay=%d.\n", p_m_delay);
+#ifndef OLD_MISDN
if (p_m_b_index >= 0)
if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
#ifdef SOCKET_MISDN
#else
ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_delay?CMX_DELAY:CMX_JITTER, p_m_delay, "DSP-DELAY", p_m_delay);
#endif
+#endif
} else
PDEBUG(DEBUG_BCHANNEL, "we already have delay=%d.\n", p_m_delay);
break;
break;
}
p_m_crypt_msg_current = 0; /* reset */
- p_m_crypt_msg_loops = 3; /* enable */
+ p_m_crypt_msg_loops = 6; /* enable */
#if 0
/* disable txmix, or we get corrupt data due to audio process */
if (p_m_txmix && p_m_b_index>=0)
#ifdef SOCKET_MISDN
int mISDN_handler(void)
{
- int ret;
+ int ret, work = 0;
struct mISDNport *mISDNport;
class PmISDN *isdnport;
int i;
i = 0;
while(i < mISDNport->b_num)
{
+ /* process timer events for bchannel handling */
+ if (mISDNport->b_timer[i])
+ {
+ if (mISDNport->b_timer[i] <= now_d)
+ bchannel_event(mISDNport, i, B_EVENT_TIMEOUT);
+ }
/* handle port of bchannel */
isdnport=mISDNport->b_port[i];
if (isdnport)
ret = recv(mISDNport->b_stack[i], buffer, sizeof(buffer), 0);
if (ret >= MISDN_HEADER_LEN)
{
+ work = 1;
switch(hh->prim)
{
/* we don't care about confirms, we use rx data to sync tx */
/* we receive audio data, we respond to it AND we send tones */
case PH_DATA_IND:
case DL_DATA_IND:
+ case PH_SIGNAL_IND:
case PH_CONTROL_IND:
if (mISDNport->b_port[i])
mISDNport->b_port[i]->bchannel_receive(hh, buffer+MISDN_HEADER_LEN, ret-MISDN_HEADER_LEN);
PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
mISDNport->ml3->to_layer2(mISDNport->ml3, DL_ESTABLISH_REQ);
- l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH_REQ, DIRECTION_OUT);
+ l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
end_trace();
return(1);
}
mISDNport = mISDNport->next;
}
+ /* if we received at least one b-frame, we will return 1 */
+ return(work);
}
#else
int mISDN_handler(void)
i = 0;
while(i < mISDNport->b_num)
{
+ /* process timer events for bchannel handling */
+ if (mISDNport->b_timer[i])
+ {
+ if (mISDNport->b_timer[i] <= now_d)
+ bchannel_event(mISDNport, i, B_EVENT_TIMEOUT);
+ }
isdnport=mISDNport->b_port[i];
if (isdnport)
{
/* turn on RX */
isdnport->p_m_txdata = 1;
PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is required, so we turn them on\n");
+#ifndef OLD_MISDN
if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_ON, 0, "DSP-TXDATA", 1);
+#endif
return(1);
}
} else
/* turn off RX */
isdnport->p_m_txdata = 0;
PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is not required, so we turn them off\n");
+#ifndef OLD_MISDN
if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_OFF, 0, "DSP-TXDATA", 0);
+#endif
return(1);
}
}
act.len = 0;
mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
}
- l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH | REQUEST, DIRECTION_OUT);
+ l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
end_trace();
return(1);
}
if (!mISDNport)
{
PERROR("message belongs to no mISDNport: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, msg->len);
+ // show a list of all mISDNports and their address
+#if 0
+ mISDNport = mISDNport_first;
+ while(mISDNport)
+ {
+ PERROR(" port %s %x -> %x\n", mISDNport->name, (frm->addr&MASTER_ID_MASK), (unsigned int)(mISDNport->upper_id&MASTER_ID_MASK));
+ mISDNport = mISDNport->next;
+ }
+#endif
goto out;
}
case MGR_SHORTSTATUS | CONFIRM:
switch(frm->dinfo) {
case SSTATUS_L1_ACTIVATED:
- l1l2l3_trace_header(mISDNport, NULL, PH_ACTIVATE | (frm->prim & 0x3), DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
goto ss_act;
case SSTATUS_L1_DEACTIVATED:
- l1l2l3_trace_header(mISDNport, NULL, PH_DEACTIVATE | (frm->prim & 0x3), DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
goto ss_deact;
case SSTATUS_L2_ESTABLISHED:
- l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH | (frm->prim & 0x3), DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
goto ss_estab;
case SSTATUS_L2_RELEASED:
- l1l2l3_trace_header(mISDNport, NULL, DL_RELEASE | (frm->prim & 0x3), DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
goto ss_rel;
}
case PH_ACTIVATE | CONFIRM:
case PH_ACTIVATE | INDICATION:
- l1l2l3_trace_header(mISDNport, NULL, frm->prim, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
if (mISDNport->ntmode)
{
case PH_DEACTIVATE | CONFIRM:
case PH_DEACTIVATE | INDICATION:
- l1l2l3_trace_header(mISDNport, NULL, frm->prim, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
if (mISDNport->ntmode)
{
case DL_ESTABLISH | INDICATION:
case DL_ESTABLISH | CONFIRM:
- l1l2l3_trace_header(mISDNport, NULL, frm->prim, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */
ss_estab:
case DL_RELEASE | INDICATION:
case DL_RELEASE | CONFIRM:
- l1l2l3_trace_header(mISDNport, NULL, frm->prim, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, DL_RELEASE_REQ | (frm->prim & 0x3), DIRECTION_IN);
end_trace();
if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */
ss_rel:
if (cmd == MT_ASSIGN)
{
+ if (angeforderte, dann schreiben, weil wir )
ueberdenken!!!
}
/* lock LCR */
+ pthread_mutex_lock(&mutex_lcr);
achtung MT_ASSIGN kommt hier an
- lock it baby
/* d-message */
switch(cmd)
{
+#warning shortstatus
+#if 0
case MGR_SHORTSTATUS_IND:
case MGR_SHORTSTATUS_CONF:
switch(frm->dinfo) {
case SSTATUS_L1_ACTIVATED:
- l1l2l3_trace_header(mISDNport, NULL, PH_ACTIVATE_IND, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN);
end_trace();
goto ss_act;
case SSTATUS_L1_DEACTIVATED:
- l1l2l3_trace_header(mISDNport, NULL, PH_DEACTIVATE_IND, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN);
end_trace();
goto ss_deact;
case SSTATUS_L2_ESTABLISHED:
- l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH_IND, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN);
end_trace();
goto ss_estab;
case SSTATUS_L2_RELEASED:
- l1l2l3_trace_header(mISDNport, NULL, DL_RELEASE_IND, DIRECTION_IN);
+ l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
end_trace();
goto ss_rel;
}
break;
+#endif
- case PH_ACTIVATE_CONF:
- case PH_ACTIVATE_IND:
- l1l2l3_trace_header(mISDNport, NULL, cmd, DIRECTION_IN);
+ case MT_L1ACTIVATE:
+ l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN);
end_trace();
- ss_act:
+// ss_act:
mISDNport->l1link = 1;
#if 0
if (mISDNport->ntmode)
#endif
break;
- case PH_DEACTIVATE | CONFIRM:
- case PH_DEACTIVATE | INDICATION:
- l1l2l3_trace_header(mISDNport, NULL, cmd, DIRECTION_IN);
+ case MT_L1DEACTIVATE:
+ l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN);
end_trace();
- ss_deact:
+// ss_deact:
mISDNport->l1link = 0;
raus mit der setup-queue, da dies im stack geschieht
#if 0
#endif
break;
- case PH_CONTROL_CONFIRM:
- case PH_CONTROL_INDICATION:
+ case MT_L1CONTROL:
PDEBUG(DEBUG_ISDN, "Received PH_CONTROL for port %d (%s).\n", mISDNport->portnum, mISDNport->ifport->interface->name);
+ // special config commands for interface (ip-address/LOS/AIS/RDI/SLIP)
break;
- case DL_ESTABLISH_IND:
- case DL_ESTABLISH_CONF:
- l1l2l3_trace_header(mISDNport, NULL, cmd, DIRECTION_IN);
+ case MT_L2ESTABLISH:
+ l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN);
end_trace();
- if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */
- ss_estab:
+// ss_estab:
if (mISDNport->l2establish)
{
mISDNport->l2establish = 0;
mISDNport->l2link = 1;
break;
- case DL_RELEASE_IND:
- case DL_RELEASE_CONF:
- l1l2l3_trace_header(mISDNport, NULL, cmd, DIRECTION_IN);
+ case MT_L2RELEASE:
+ l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
end_trace();
- ss_rel:
+// ss_rel:
mISDNport->l2link = 0;
if (mISDNport->ptp)
{
default:
/* l3-data is sent to LCR */
- message_from_mlayer3(mISDNport, cmd, pid, l3m);
+ stack2manager(mISDNport, cmd, pid, l3m);
}
- /* unlock LCR */
- unlock it baby
-
/* free message */
if (l3m)
free_l3_msg(l3m);
+
+ /* unlock LCR */
+ pthread_mutex_unlock(&mutex_lcr);
+
return(0);
}