unsigned char mISDN_rand[256];
int mISDN_rand_count = 0;
+#ifdef OLD_MT_ASSIGN
unsigned int mt_assign_pid = ~0;
+#endif
int mISDNsocket = -1;
static int upqueue_pipe[2];
p_m_echo = 0;
p_m_tone = 0;
p_m_rxoff = 0;
- p_m_joindata = 0;
p_m_inband_send_on = 0;
p_m_inband_receive_on = 0;
p_m_dtmf = !mISDNport->ifport->nodtmf;
}
if (p_tone_name[0] || p_m_crypt_msg_loops || p_m_inband_send_on || p_m_load) {
- schedule_timer(&p_m_loadtimer, 0, ISDN_TRANSMIT*125);
+ schedule_timer(&p_m_loadtimer, 0, PORT_TRANSMIT * 125);
}
}
void PmISDN::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len)
{
unsigned int cont = *((unsigned int *)data);
- unsigned char *data_temp;
- unsigned int length_temp;
struct lcr_msg *message;
unsigned char *p;
int l;
if (p_m_inband_receive_on)
inband_receive(data, len);
+ /* send to remote, if bridged */
+ bridge_tx(data, len);
+
/* calls will not process any audio data unless
* the call is connected OR tones feature is enabled.
*/
cryptman_listen_bch(data, len);
}
-
- p = data;
-
- /* send data to epoint */
- if (p_m_joindata && ACTIVE_EPOINT(p_epointlist)) { /* only if we have an epoint object */
- length_temp = len;
- data_temp = p;
- while(length_temp) {
- message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DATA);
- message->param.data.len = (length_temp>sizeof(message->param.data.data))?sizeof(message->param.data.data):length_temp;
- memcpy(message->param.data.data, data_temp, message->param.data.len);
- message_put(message);
- if (length_temp <= sizeof(message->param.data.data))
- break;
- data_temp += sizeof(message->param.data.data);
- length_temp -= sizeof(message->param.data.data);
- }
- }
}
set_conf(oldconf, newconf);
break;
- case mISDNSIGNAL_JOINDATA:
- if (p_m_joindata != param->mISDNsignal.joindata) {
- p_m_joindata = param->mISDNsignal.joindata;
- PDEBUG(DEBUG_BCHANNEL, "we change to joindata=%d.\n", p_m_joindata);
- update_rxoff();
- } else
- PDEBUG(DEBUG_BCHANNEL, "we already have joindata=%d.\n", p_m_joindata);
- break;
-
case mISDNSIGNAL_DELAY:
if (p_m_delay != param->mISDNsignal.delay) {
p_m_delay = param->mISDNsignal.delay;
*/
int PmISDN::message_epoint(unsigned int epoint_id, int message_id, union parameter *param)
{
- if (Port::message_epoint(epoint_id, message_id, param))
- return(1);
+ if (Port::message_epoint(epoint_id, message_id, param)) {
+ if (message_id == MESSAGE_BRIDGE)
+ update_rxoff();
+ return 1;
+ }
switch(message_id) {
- case MESSAGE_DATA: /* tx-data from upper layer */
- txfromup(param->data.data, param->data.len);
- return(1);
-
case MESSAGE_mISDNSIGNAL: /* user command */
PDEBUG(DEBUG_ISDN, "PmISDN(%s) received special ISDN SIGNAL %d.\n", p_name, param->mISDNsignal.message);
message_mISDNsignal(epoint_id, message_id, param);
- return(1);
+ return 1;
case MESSAGE_CRYPT: /* crypt control command */
PDEBUG(DEBUG_ISDN, "PmISDN(%s) received encryption command '%d'.\n", p_name, param->crypt.type);
message_crypt(epoint_id, message_id, param);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
void PmISDN::update_rxoff(void)
{
/* call bridges in user space OR crypto OR recording */
- if (p_m_joindata || p_m_crypt_msg_loops || p_m_crypt_listen || p_record || p_m_inband_receive_on) {
+ if (p_bridge || p_m_crypt_msg_loops || p_m_crypt_listen || p_record || p_m_inband_receive_on) {
/* rx IS required */
if (p_m_rxoff) {
/* turn on RX */
struct mISDNport *mISDNport = (struct mISDNport *)instance;
if (!mISDNport->isloopback && mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) {
-// PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
+ PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
schedule_timer(&mISDNport->l2establish, 5, 0); /* 5 seconds */
}
static int b_timer_timeout(struct lcr_timer *timer, void *instance, int i)
{
struct mISDNport *mISDNport = (struct mISDNport *)instance;
-puts("fires");
bchannel_event(mISDNport, i, B_EVENT_TIMEOUT);
struct mISDNport *mISDNport = (struct mISDNport *)ml3->priv;
struct mbuffer *mb;
+#ifdef OLD_MT_ASSIGN
/* special MT_ASSIGN handling:
*
* if we request a PID from mlayer, we always do it while lcr is locked.
mt_assign_pid = pid;
return(0);
}
+#endif
/* queue message, create, if required */
if (!l3m) {
l3m = alloc_l3_msg();
struct mISDN_devinfo devinfo;
unsigned int protocol, prop;
-#if defined WITH_GSM_BS && defined WITH_GSM_MS
- loop = ifport->gsm_ms | ifport->gsm_bs;
-#else
-#ifdef WITH_GSM_BS
- loop = ifport->gsm_bs;
-#endif
-#ifdef WITH_GSM_MS
- loop = ifport->gsm_ms;
-#endif
-#endif
+ loop = 0;
//printf("%s == %s\n", ifport->portname, options.loopback_int);
if (!strcmp(ifport->portname, options.loopback_lcr))
loop = 1;
mISDNport->l1link = -1;
mISDNport->l2link = -1;
}
-#ifdef WITH_GSM_BS
- mISDNport->gsm_bs = ifport->gsm_bs;
-#endif
-#ifdef WITH_GSM_MS
- mISDNport->gsm_ms = ifport->gsm_ms;
-#endif
mISDNport->isloopback = loop;
pmemuse++;
*mISDNportp = mISDNport;
if (ss5) {
/* try to keep interface enabled */
l1hold = 1;
- l2hold = 1;
+ l2hold = 0;
}
/* set l2hold */
switch (l2hold) {
/*
* enque data from upper buffer
*/
-void PmISDN::txfromup(unsigned char *data, int length)
+int PmISDN::bridge_rx(unsigned char *data, int length)
{
unsigned char buf[MISDN_HEADER_LEN+((length>ISDN_LOAD)?length:ISDN_LOAD)];
struct mISDNhead *hh = (struct mISDNhead *)buf;
int ret;
if (p_m_b_index < 0)
- return;
+ return -EIO;
if (p_m_mISDNport->b_state[p_m_b_index] != B_STATE_ACTIVE)
- return;
+ return -EINVAL;
/* check if high priority tones exist
* ignore data in this case
*/
if (p_tone_name[0] || p_m_crypt_msg_loops || p_m_inband_send_on)
- return;
+ return -EBUSY;
/* preload procedure
* if transmit buffer in DSP module is empty,
if (ret <= 0)
PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_sock[p_m_b_index].fd);
p_m_load += ISDN_LOAD;
- schedule_timer(&p_m_loadtimer, 0, ISDN_TRANSMIT*125);
+ schedule_timer(&p_m_loadtimer, 0, PORT_TRANSMIT * 125);
}
/* drop if load would exceed ISDN_MAXLOAD
* this keeps the delay not too high
*/
if (p_m_load+length > ISDN_MAXLOAD)
- return;
+ return -EINVAL;
/* make and send frame */
hh->prim = PH_DATA_REQ;
if (ret <= 0)
PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_sock[p_m_b_index].fd);
p_m_load += length;
+
+ return 0;
}
int PmISDN::inband_send(unsigned char *buffer, int len)