X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=mISDN.cpp;h=aff2f341d8246eb7d4193da564445bbe008f39f9;hp=8ae58556e4142b956771aa7ffdfe4169945eae34;hb=refs%2Fheads%2Fjolly%2Fhandover;hpb=e9b162540529e627c12573ffb4eff47c3273d756 diff --git a/mISDN.cpp b/mISDN.cpp index 8ae5855..aff2f34 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -63,7 +63,6 @@ static struct mi_ext_fn_s myfn; int mISDN_initialize(void) { char filename[256]; - int ver; /* try to open raw socket to check kernel */ mISDNsocket = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE); @@ -76,7 +75,7 @@ int mISDN_initialize(void) // set debug printout function myfn.prt_debug = my_mISDNlib_debug; - ver = init_layer3(4, &myfn); // buffer of 4 + init_layer3(4, &myfn); // buffer of 4 /* open debug, if enabled and not only stack debugging */ if (options.deb) { @@ -131,7 +130,6 @@ PmISDN::PmISDN(int type, mISDNport *mISDNport, char *portname, struct port_setti p_m_b_exclusive = 0; p_m_b_reserve = 0; p_m_b_mode = mode; - p_m_hold = 0; p_m_tx_gain = mISDNport->ifport->interface->tx_gain; p_m_rx_gain = mISDNport->ifport->interface->rx_gain; p_m_conf = 0; @@ -147,6 +145,7 @@ PmISDN::PmISDN(int type, mISDNport *mISDNport, char *portname, struct port_setti p_m_inband_send_on = 0; p_m_inband_receive_on = 0; p_m_dtmf = !mISDNport->ifport->nodtmf; + p_m_dtmf_threshold = mISDNport->ifport->dtmf_threshold; memset(&p_m_timeout, 0, sizeof(p_m_timeout)); add_timer(&p_m_timeout, mISDN_timeout, this, 0); SCPY(p_m_pipeline, mISDNport->ifport->interface->pipeline); @@ -348,15 +347,20 @@ void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, int sock, u struct mISDNhead *ctrl = (struct mISDNhead *)buffer; unsigned int *d = (unsigned int *)(buffer+MISDN_HEADER_LEN); int ret; + int len = 8; if (sock < 0) return; + if (c1 == DTMF_TONE_START && c2 == 0) { + len = 4; + } + ctrl->prim = PH_CONTROL_REQ; ctrl->id = 0; *d++ = c1; *d++ = c2; - ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0); + ret = sendto(sock, buffer, MISDN_HEADER_LEN+len, 0, NULL, 0); if (ret <= 0) PERROR("Failed to send to socket %d\n", sock); chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT); @@ -507,7 +511,7 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i) // if (port->p_m_txmix && mode == B_MODE_TRANSPARENT) // ph_control(mISDNport, port, handle, DSP_MIX_ON, 0, "DSP-MIX", 1); if (port->p_m_dtmf && mode == B_MODE_TRANSPARENT) - ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1); + ph_control(mISDNport, port, handle, DTMF_TONE_START, port->p_m_dtmf_threshold, "DSP-DTMF", 1); if (port->p_m_crypt && mode == B_MODE_TRANSPARENT) ph_control_block(mISDNport, port, handle, DSP_BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len); } @@ -598,6 +602,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event) class PmISDN *b_port = mISDNport->b_port[i]; int state = mISDNport->b_state[i]; int timer = -1; // no change +#if 0 int p_m_tx_gain = 0; int p_m_rx_gain = 0; char *p_m_pipeline = NULL; @@ -613,6 +618,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event) 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; } +#endif switch(event) { case B_EVENT_USE: @@ -958,7 +964,7 @@ void PmISDN::load_tx(void) p_m_load = 0; /* to send data, tone must be on */ - if ((p_tone_name[0] || p_m_crypt_msg_loops || p_m_inband_send_on) /* what tones? */ + if ((p_tone_name[0] || p_dov_tx || p_m_crypt_msg_loops || p_m_inband_send_on) /* what tones? */ && (p_m_load < p_m_preload) /* not too much load? */ && (p_state==PORT_STATE_CONNECT || p_m_mISDNport->tones || p_m_inband_send_on)) { /* connected or inband-tones? */ int tosend = p_m_preload - p_m_load, length; @@ -998,6 +1004,11 @@ void PmISDN::load_tx(void) tosend -= length; } + /* copy dov */ + if (p_dov_tx) { + tosend -= dov_tx(p, tosend); + } + /* copy tones */ if (p_tone_name[0] && tosend) { tosend -= read_audio(p, tosend); @@ -1135,6 +1146,10 @@ void PmISDN::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len return; } + /* dov is processed */ + if (p_dov_rx) + dov_rx(data, len); + /* inband is processed */ if (p_m_inband_receive_on) inband_receive(data, len); @@ -1428,17 +1443,44 @@ void PmISDN::message_crypt(unsigned int epoint_id, int message_id, union paramet } +/* MESSAGE_VOOTP */ +void PmISDN::message_vootp(unsigned int epoint_id, int message_id, union parameter *param) +{ + struct lcr_msg *message; + + message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_UPDATEBRIDGE); + message_put(message); + +#if 0 +does not make sense, since remote port may dejitter + if (param->vootp.enable) { + PDEBUG(DEBUG_ISDN, "PmISDN(%s) received vootp enable order, so we disable de-jitter.\n", p_name); + p_m_disable_dejitter = 1; + } +#endif + update_rxoff(); +} + /* * endpoint sends messages to the port */ int PmISDN::message_epoint(unsigned int epoint_id, int message_id, union parameter *param) { + /* messages also handled by base class */ + switch(message_id) { + case MESSAGE_VOOTP: /* crypt control command */ + PDEBUG(DEBUG_ISDN, "PmISDN(%s) received VoOTP encryption\n", p_name); + message_vootp(epoint_id, message_id, param); + break; + } + if (Port::message_epoint(epoint_id, message_id, param)) { if (message_id == MESSAGE_BRIDGE) update_rxoff(); return 1; } + /* messages not handled by base class */ switch(message_id) { case MESSAGE_mISDNSIGNAL: /* user command */ PDEBUG(DEBUG_ISDN, "PmISDN(%s) received special ISDN SIGNAL %d.\n", p_name, param->mISDNsignal.message); @@ -1466,7 +1508,7 @@ void PmISDN::update_rxoff(void) int tx_dejitter = 0; /* call bridges in user space OR crypto OR recording */ - if (p_bridge || p_m_crypt_msg_loops || p_m_crypt_listen || p_record || p_tap || p_m_inband_receive_on) { + if (p_bridge || p_m_crypt_msg_loops || p_m_crypt_listen || p_record || p_tap || p_m_inband_receive_on || p_dov_rx) { /* rx IS required */ if (p_m_rxoff) { /* turn on RX */ @@ -1527,7 +1569,7 @@ static int mISDN_upqueue(struct lcr_fd *fd, unsigned int what, void *instance, i struct mbuffer *mb; struct l3_msg *l3m; char byte; - int ret; + int __attribute__((__unused__)) ret; /* unset global semaphore */ upqueue_avail = 0; @@ -1763,7 +1805,7 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3 // this is no problem. upqueue_avail = 1; char byte = 0; - int ret; + int __attribute__((__unused__)) ret; ret = write(upqueue_pipe[1], &byte, 1); } return 0; @@ -1790,6 +1832,7 @@ int mISDN_getportbyname(int sock, int cnt, char *portname) return (port); } +#ifdef ISDN_P_FXS_POTS /* handle frames from pots */ static int pots_sock_callback(struct lcr_fd *fd, unsigned int what, void *instance, int i) { @@ -1826,6 +1869,7 @@ static int pots_sock_callback(struct lcr_fd *fd, unsigned int what, void *instan return 0; } +#endif /* * global function to add a new card (port) @@ -2266,6 +2310,9 @@ int PmISDN::bridge_rx(unsigned char *data, int length) struct mISDNhead *hh = (struct mISDNhead *)buf; int ret; + if ((ret = Port::bridge_rx(data, length))) + return ret; + if (p_m_b_index < 0) return -EIO; if (p_m_mISDNport->b_state[p_m_b_index] != B_STATE_ACTIVE) @@ -2274,7 +2321,7 @@ int PmISDN::bridge_rx(unsigned char *data, int length) /* 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) + if (p_tone_name[0] || p_dov_tx || p_m_crypt_msg_loops || p_m_inband_send_on) return -EBUSY; /* preload procedure