From 1bfbfbf903777d13df3107fbc89bdaeb2af9f2d6 Mon Sep 17 00:00:00 2001 From: Super User Date: Thu, 24 Apr 2008 09:24:04 +0200 Subject: [PATCH] socket mISDN work modified: Makefile modified: apppbx.cpp modified: default/interface.conf modified: dss1.cpp modified: interface.c modified: interface.h modified: mISDN.cpp modified: mISDN.h modified: main.h modified: options.c modified: options.h modified: route.c --- Makefile | 2 +- apppbx.cpp | 4 +- default/interface.conf | 12 +- dss1.cpp | 41 ++--- interface.c | 47 +++++- interface.h | 4 +- mISDN.cpp | 429 ++++++++++++++++++++++++++++--------------------- mISDN.h | 5 +- main.h | 4 +- options.c | 33 ---- options.h | 2 - route.c | 6 +- 12 files changed, 333 insertions(+), 256 deletions(-) diff --git a/Makefile b/Makefile index a93da32..1c9cca3 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ ifdef WITH-CRYPTO CFLAGS += -DCRYPTO endif ifdef WITH-SOCKET -CFLAGS += -DSOCKET_MISDN +CFLAGS += -DSOCKET_MISDN -I/usr/include/mISDNuser endif ifdef WITH-CRYPTO LIBDIR += -L/usr/local/ssl/lib diff --git a/apppbx.cpp b/apppbx.cpp index 9560103..3788c85 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -678,9 +678,9 @@ foundif: } /* see if link is up on PTP*/ - if (mISDNport->ptp && !mISDNport->l2link) + if (mISDNport->l2hold && !mISDNport->l2link) { - trace_header("CHANNEL SELECTION (port is ptp with layer 2 down, skipping)", DIRECTION_NONE); + trace_header("CHANNEL SELECTION (port holds layer 2, but layer 2 is down, skipping)", DIRECTION_NONE); add_trace("port", NULL, "%d", ifport->portnum); add_trace("position", NULL, "%d", index); end_trace(); diff --git a/default/interface.conf b/default/interface.conf index bd00e41..7259288 100644 --- a/default/interface.conf +++ b/default/interface.conf @@ -14,6 +14,14 @@ #port 3 #port 4 +# Example of an PTP ISDN interface on port 1 +# Layer-2-Hold is required to keep link alive. + +#[Ext] +#port 1 +#ptp +#layer2hold yes + # Example of an internal ISDN interface on port 2, which accepts all extensions #[Int] @@ -77,6 +85,7 @@ # (Siemens EWSD will select bot-way-channels when indicated that way.) #[Ext] #port 1 +#layer2hold #channel-in 1,2,3,4,5,6,7,8,9,10,22,23,24,25,26,27,28,29,30,31 #channel-out force,11,12,13,14,15,17,18,19,20,21,any @@ -86,8 +95,9 @@ # Additinally the timeout values for the different call states are adjusted to 60 seconds. # They are: setup, dialing, proceeding, alerting, disconnect #[PBX] -#nt #port 5 +#nt +#layer2hold #earlyb yes #tones yes #timeouts 60 60 60 60 60 diff --git a/dss1.cpp b/dss1.cpp index c6e6549..795ba4a 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 @@ -531,9 +529,9 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) /* process given callref */ l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN); add_trace("callref", "new", "0x%x", pid); - if (p_m_d_l3id) + if (p_m_d_l3id != pid) { - /* 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 @@ -1186,8 +1182,7 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data) if (p_m_d_ntmode) #ifdef SOCKET_MISDN -#warning SOCKET TBD -// p_m_d_ces = connect->ces; + p_m_d_ces = pid >> 16; #else p_m_d_ces = connect->ces; #endif @@ -1967,7 +1962,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) /* process given callref */ l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN); add_trace("callref", "new", "0x%x", pid); - if (p_m_d_l3id) + if (p_m_d_l3id != pid) { /* release is case the ID is already in use */ add_trace("error", NULL, "callref already in use"); @@ -2163,10 +2158,17 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) 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) + { + PERROR("Pdss1(%s) timeout without cause.\n", p_name); + break; + } + if (l3m->cause[1] != 5) + { + PERROR("Pdss1(%s) expecting timeout with timer diagnostic.\n", p_name); + break; + } + if (l3m->cause[4]=='3' && l3m->cause[5]=='1' && l3m->cause[6]=='2') { l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN); add_trace("timer", NULL, "%x", timer_hex); @@ -4041,7 +4043,7 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi pdss1 = (class Pdss1 *)port; /* check out correct stack and id */ if (pdss1->p_m_mISDNport == mISDNport - && pdss1->p_m_d_l3id == pid) + && (pdss1->p_m_d_l3id & MISDN_PID_CRVAL_MASK) == (pid & MISDN_PID_CRVAL_MASK)) { /* found port, the message belongs to */ break; @@ -4054,9 +4056,9 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi if (port) { /* 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_CRVAL_MASK) == MISDN_PID_MASTER) { if (cmd == MT_DISCONNECT) { @@ -4068,7 +4070,8 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi return(0); } /* if process id and layer 3 id matches */ - pdss1->message_isdn(cmd, pid, l3m); + if (pid == pdss1->p_m_d_l3id) + pdss1->message_isdn(cmd, pid, l3m); return(0); } diff --git a/interface.c b/interface.c index aa55f36..6ac2871 100644 --- a/interface.c +++ b/interface.c @@ -155,6 +155,7 @@ static int inter_ptp(struct interface *interface, char *filename, int line, char ifport->ptp = 1; return(0); } +#if 0 static int inter_ptmp(struct interface *interface, char *filename, int line, char *parameter, char *value) { struct interface_port *ifport; @@ -183,6 +184,7 @@ static int inter_ptmp(struct interface *interface, char *filename, int line, cha ifport->ptmp = 1; return(0); } +#endif static int inter_nt(struct interface *interface, char *filename, int line, char *parameter, char *value) { #ifdef SOCKET_MISDN @@ -297,6 +299,34 @@ static int inter_port(struct interface *interface, char *filename, int line, cha *ifportp = ifport; return(0); } +static int inter_l2hold(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + struct interface_port *ifport; + + /* port in chain ? */ + if (!interface->ifport) + { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter); + return(-1); + } + /* goto end of chain */ + ifport = interface->ifport; + while(ifport->next) + ifport = ifport->next; + if (!strcmp(value, "yes")) + { + ifport->l2hold = 1; + } else + if (!strcmp(value, "no")) + { + ifport->l2hold = -1; + } else + { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expecting parameter 'yes' or 'no'.\n", filename, line, parameter); + return(-1); + } + return(0); +} static int inter_channel_out(struct interface *interface, char *filename, int line, char *parameter, char *value) { struct interface_port *ifport; @@ -836,10 +866,13 @@ struct interface_param interface_param[] = { "This is required on NT-mode ports that are multipoint by default.\n" "This parameter must follow a 'port' parameter."}, +#if 0 {"ptmp", &inter_ptmp, "", "The given port above is opened as point-to-multipoint.\n" "This is required on PRI NT-mode ports that are point-to-point by default.\n" "This parameter must follow a 'port' parameter."}, +#endif + {"nt", &inter_nt, "", "The given port above is opened in NT-mode.\n" #ifdef SOCKET_MISDN @@ -849,6 +882,11 @@ struct interface_param interface_param[] = { #endif "This parameter must follow a 'port' parameter."}, + {"layer2hold", &inter_l2hold, "yes | no", + "The given port will continuously try to establish layer 2 link and hold it.\n" + "It is required for PTP links in most cases, therefore it is default.\n" + "This parameter must follow a 'port' parameter."}, + {"channel-out", &inter_channel_out, "[force,][][,...][,free][,any][,no]", "Channel selection list for all outgoing calls to the interface.\n" "A free channels is searched in order of appearance.\n" @@ -895,13 +933,6 @@ struct interface_param interface_param[] = { "Disables DTMF detection for this interface.\n" "This parameter must follow a 'port' parameter."}, -#if 0 - {"layer2keep", &inter_layer2keep, "yes | no", - "By default, layer 2 is establised and kept up on PTP interfaces.\n" - ".\n" - "This parameter must follow a 'port' parameter."}, -#endif - {"filter", &inter_filter, " ", "Adds/appends a filter. Filters are ordered in transmit direction.\n" "gain - Changes volume (-8 .. 8)\n" @@ -1256,7 +1287,7 @@ void load_port(struct interface_port *ifport) struct mISDNport *mISDNport; /* open new port */ - mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->ptmp, ifport->nt, ifport->interface); + mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->nt, ifport->l2hold, ifport->interface); if (mISDNport) { /* link port */ diff --git a/interface.h b/interface.h index dd986ca..d80d9b2 100644 --- a/interface.h +++ b/interface.h @@ -9,9 +9,6 @@ ** ** \*****************************************************************************/ -#define FLAG_PORT_USE 1 -#define FLAG_PORT_PTP (1<<1) - enum { /* interface type */ IF_TYPE_DIRECT, IF_TYPE_EXTENSION, @@ -51,6 +48,7 @@ struct interface_port { int ptp; /* force load stack in PTP mode */ int ptmp; /* force load stack in PTP mode */ int nt; /* load stack in NT-mode */ + int l2hold; /* hold layer 2 (1=force, -1=disable */ int channel_force; /* forces channel by protocol */ int nodtmf; /* disables DTMF */ struct select_channel *out_channel; /* list of channels to select */ diff --git a/mISDN.cpp b/mISDN.cpp index 6307840..e8e7692 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -60,12 +60,20 @@ extern "C" { #else // socket mISDN -#include extern "C" { } -#include -#include -#include +#include + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) #endif // timeouts if activating/deactivating response from mISDN got lost @@ -461,7 +469,11 @@ void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned lo mISDN_write(mISDNdevice, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); #endif chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT); +#ifdef SOCKET_MISDN + if (c1 == DSP_CONF_JOIN) +#else if (c1 == CMX_CONF_JOIN) +#endif add_trace(trace_name, NULL, "0x%08x", trace_value); else add_trace(trace_name, NULL, "%d", trace_value); @@ -679,11 +691,42 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i) int handle; handle = mISDNport->b_socket[i]; + port = mISDNport->b_port[i]; + if (!port) + { + PERROR("bchannel index i=%d not associated with a port object\n", i); + return; + } + + /* set dsp features */ + if (port->p_m_txdata) + ph_control(mISDNport, port, handle, (port->p_m_txdata)?DSP_TXDATA_ON:DSP_TXDATA_OFF, 0, "DSP-TXDATA", port->p_m_txdata); + if (port->p_m_delay) + ph_control(mISDNport, port, handle, DSP_DELAY, port->p_m_delay, "DSP-DELAY", port->p_m_delay); + if (port->p_m_tx_gain) + ph_control(mISDNport, port, handle, DSP_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, DSP_VOL_CHANGE_RX, port->p_m_rx_gain, "DSP-RX_GAIN", port->p_m_rx_gain); + if (port->p_m_pipeline[0]) + ph_control_block(mISDNport, port, handle, DSP_PIPELINE_CFG, port->p_m_pipeline, strlen(port->p_m_pipeline)+1, "DSP-PIPELINE", 0); + if (port->p_m_conf) + ph_control(mISDNport, port, handle, DSP_CONF_JOIN, port->p_m_conf, "DSP-CONF", port->p_m_conf); + if (port->p_m_echo) + ph_control(mISDNport, port, handle, DSP_ECHO_ON, 0, "DSP-ECHO", 1); + if (port->p_m_tone) + ph_control(mISDNport, port, handle, DSP_TONE_PATT_ON, port->p_m_tone, "DSP-TONE", port->p_m_tone); + if (port->p_m_rxoff) + ph_control(mISDNport, port, handle, DSP_RECEIVE_OFF, 0, "DSP-RXOFF", 1); +// if (port->p_m_txmix) +// ph_control(mISDNport, port, handle, DSP_MIX_ON, 0, "DSP-MIX", 1); + if (port->p_m_dtmf) + ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1); + if (port->p_m_crypt) + 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); #else unsigned long handle; handle = mISDNport->b_addr[i]; -#endif port = mISDNport->b_port[i]; if (!port) { @@ -720,6 +763,7 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i) ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1); if (port->p_m_crypt) ph_control_block(mISDNport, port, handle, BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len); +#endif } /* @@ -1631,7 +1675,11 @@ void PmISDN::bchannel_receive(iframe_t *frm) } switch(cont) { +#ifdef SOCKET_MISDN + case DSP_BF_REJECT: +#else case BF_REJECT: +#endif chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN); add_trace("DSP-CRYPT", NULL, "error"); end_trace(); @@ -1641,7 +1689,11 @@ void PmISDN::bchannel_receive(iframe_t *frm) message_put(message); break; +#ifdef SOCKET_MISDN + case DSP_BF_ACCEPT: +#else case BF_ACCEPT: +#endif chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN); add_trace("DSP-CRYPT", NULL, "ok"); end_trace(); @@ -1670,7 +1722,11 @@ void PmISDN::bchannel_receive(iframe_t *frm) #endif { #ifndef OLD_MISDN +#ifdef SOCKET_MISDN + case DSP_TX_DATA: +#else case CMX_TX_DATA: +#endif if (!p_m_txdata) { /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */ @@ -1776,7 +1832,7 @@ void PmISDN::set_echotest(int echo) if (p_m_b_channel) 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], p_m_echo?CMX_ECHO_ON:CMX_ECHO_OFF, 0, "DSP-ECHO", p_m_echo); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_echo?DSP_ECHO_ON:DSP_ECHO_OFF, 0, "DSP-ECHO", p_m_echo); #else ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_echo?CMX_ECHO_ON:CMX_ECHO_OFF, 0, "DSP-ECHO", p_m_echo); #endif @@ -1809,7 +1865,7 @@ void PmISDN::set_tone(char *dir, char *tone) { PDEBUG(DEBUG_ISDN, "we reset tone from id=%d to OFF.\n", p_m_tone); #ifdef SOCKET_MISDN - ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], TONE_PATT_OFF, 0, "DSP-TONE", 0); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_TONE_PATT_OFF, 0, "DSP-TONE", 0); #else ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], TONE_PATT_OFF, 0, "DSP-TONE", 0); #endif @@ -1895,7 +1951,7 @@ void PmISDN::set_tone(char *dir, char *tone) if (p_m_b_index > -1) 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], p_m_tone?TONE_PATT_ON:TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_tone?DSP_TONE_PATT_ON:DSP_TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone); #else ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_tone?TONE_PATT_ON:TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone); #endif @@ -1919,7 +1975,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union if (p_m_b_index > -1) 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_tx_gain, "DSP-TX_GAIN", p_m_tx_gain); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_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_tx_gain, "DSP-TX_GAIN", p_m_tx_gain); #endif @@ -1932,7 +1988,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union if (p_m_b_index > -1) 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_rx_gain, "DSP-RX_GAIN", p_m_rx_gain); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_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_rx_gain, "DSP-RX_GAIN", p_m_rx_gain); #endif @@ -1950,7 +2006,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union if (p_m_b_index > -1) 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], (p_m_conf)?CMX_CONF_JOIN:CMX_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], (p_m_conf)?DSP_CONF_JOIN:DSP_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf); #else ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], (p_m_conf)?CMX_CONF_JOIN:CMX_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf); #endif @@ -1979,7 +2035,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union if (p_m_b_index > -1) 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], p_m_delay?CMX_DELAY:CMX_JITTER, p_m_delay, "DSP-DELAY", p_m_delay); + ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_delay?DSP_DELAY:DSP_JITTER, p_m_delay, "DSP-DELAY", p_m_delay); #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 @@ -2017,7 +2073,7 @@ void PmISDN::message_crypt(unsigned long epoint_id, int message_id, union parame if (p_m_b_index > -1) if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE) #ifdef SOCKET_MISDN - ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_crypt?BF_ENABLE_KEY:BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len); + ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_crypt?DSP_BF_ENABLE_KEY:DSP_BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len); #else ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_crypt?BF_ENABLE_KEY:BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len); #endif @@ -2052,7 +2108,7 @@ void PmISDN::message_crypt(unsigned long epoint_id, int message_id, union parame { PDEBUG(DEBUG_BCHANNEL, "for sending CR_MESSAGE_REQ, we reset txmix from txmix=%d.\n", p_m_txmix); #ifdef SOCKET_MISDN - ph_control(p_m_mISDNport, this, p_mISDNport->b_socket[p_m_b_index], CMX_MIX_OFF, 0, "DSP-TXMIX", 0); + ph_control(p_m_mISDNport, this, p_mISDNport->b_socket[p_m_b_index], DSP_MIX_OFF, 0, "DSP-TXMIX", 0); #else ph_control(p_m_mISDNport, this, p_mISDNport->b_addr[p_m_b_index], CMX_MIX_OFF, 0, "DSP-TXMIX", 0); #endif @@ -2107,6 +2163,8 @@ int mISDN_handler(void) int i; unsigned char buffer[2048+MISDN_HEADER_LEN]; struct mISDNhead *hh = (struct mISDNhead *)buffer; + struct mbuffer *mb; + struct l3_msg *l3m; /* process all ports */ mISDNport = mISDNport_first; @@ -2136,7 +2194,7 @@ int mISDN_handler(void) isdnport->p_m_rxoff = 0; PDEBUG(DEBUG_BCHANNEL, "%s: receive data is required, so we turn them on\n"); if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) - ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], CMX_RECEIVE_ON, 0, "DSP-RXOFF", 0); + ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], DSP_RECEIVE_ON, 0, "DSP-RXOFF", 0); return(1); } } else @@ -2148,7 +2206,7 @@ int mISDN_handler(void) isdnport->p_m_rxoff = 1; PDEBUG(DEBUG_BCHANNEL, "%s: receive data is not required, so we turn them off\n"); if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) - ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], CMX_RECEIVE_OFF, 0, "DSP-RXOFF", 1); + ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], DSP_RECEIVE_OFF, 0, "DSP-RXOFF", 1); return(1); } } @@ -2162,7 +2220,7 @@ int mISDN_handler(void) isdnport->p_m_txdata = 1; PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is required, so we turn them on\n"); if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) - ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], CMX_TXDATA_ON, 0, "DSP-TXDATA", 1); + ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], DSP_TXDATA_ON, 0, "DSP-TXDATA", 1); return(1); } } else @@ -2174,7 +2232,7 @@ int mISDN_handler(void) isdnport->p_m_txdata = 0; PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is not required, so we turn them off\n"); if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) - ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], CMX_TXDATA_OFF, 0, "DSP-TXDATA", 0); + ph_control(mISDNport, isdnport, mISDNport->b_socket[isdnport->p_m_b_index], DSP_TXDATA_OFF, 0, "DSP-TXDATA", 0); return(1); } } @@ -2231,6 +2289,70 @@ int mISDN_handler(void) i++; } + + /* handle queued up-messages (d-channel) */ + while ((mb = mdequeue(&mISDNport->upqueue))) + { + l3m = &mb->l3; + switch(l3m->type) + { +#warning SOCKET TBD: Layer 1 indication +#if 0 + case MT_L1ACTIVATE: + l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN); + end_trace(); + mISDNport->l1link = 1; + break; + + case MT_L1DEACTIVATE: + l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN); + end_trace(); + mISDNport->l1link = 0; + break; + + 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; +#endif + + case MT_L2ESTABLISH: + l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN); + end_trace(); + if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) + { + if (mISDNport->l2establish) + { + mISDNport->l2establish = 0; + PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n"); + } + mISDNport->l2link = 1; + } + break; + + case MT_L2RELEASE: + l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN); + end_trace(); + if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) + { + mISDNport->l2link = 0; + if (mISDNport->l2hold) + { + time(&mISDNport->l2establish); + PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n"); + } + } + break; + + default: + /* l3-data is sent to LCR */ + stack2manager(mISDNport, l3m->type, l3m->pid, l3m); + } + } + + /* free message */ + free_l3_msg(l3m); + #if 0 if (mISDNport->l1timeout && now>mISDNport->l1timeout) { ---} @@ -2243,13 +2365,17 @@ int mISDN_handler(void) { if (now-mISDNport->l2establish > 5) { + mISDNport->l2establish = 0; + if (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); -#warning SOCKET TBD -// mISDNport->ml3->to_layer2(mISDNport->ml3, DL_ESTABLISH_REQ); -// l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); -// end_trace(); - return(1); + 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); + l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); + end_trace(); + time(&mISDNport->l2establish); + return(1); + } } } @@ -2361,29 +2487,34 @@ int mISDN_handler(void) { if (now-mISDNport->l2establish > 5) { - if (mISDNport->ntmode) + mISDNport->l2establish = 0; + if (mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) { - PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link NT portnum=%d.\n", mISDNport->portnum); - time(&mISDNport->l2establish); - /* establish */ - dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0); - if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg)) - free_msg(dmsg); - } else { - iframe_t act; - - PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link TE portnum=%d.\n", mISDNport->portnum); + if (mISDNport->ntmode) + { + PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link NT portnum=%d.\n", mISDNport->portnum); + time(&mISDNport->l2establish); + /* establish */ + dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0); + if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg)) + free_msg(dmsg); + } else { + iframe_t act; + + PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link TE portnum=%d.\n", mISDNport->portnum); + time(&mISDNport->l2establish); + /* establish */ + act.prim = DL_ESTABLISH | REQUEST; + act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN; + act.dinfo = 0; + act.len = 0; + mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); + } + l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); + end_trace(); time(&mISDNport->l2establish); - /* establish */ - act.prim = DL_ESTABLISH | REQUEST; - act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN; - act.dinfo = 0; - act.len = 0; - mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); + return(1); } - l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); - end_trace(); - return(1); } } if ((dmsg = msg_dequeue(&mISDNport->downqueue))) @@ -2577,12 +2708,15 @@ int mISDN_handler(void) end_trace(); if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */ ss_estab: - if (mISDNport->l2establish) + if (!mISDNport->ntmode || mISDNport->ptp) { - mISDNport->l2establish = 0; - PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n"); + if (mISDNport->l2establish) + { + mISDNport->l2establish = 0; + PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n"); + } + mISDNport->l2link = 1; } - mISDNport->l2link = 1; break; case DL_RELEASE | INDICATION: @@ -2591,11 +2725,14 @@ int mISDN_handler(void) end_trace(); if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */ ss_rel: - mISDNport->l2link = 0; - if (mISDNport->ptp) + if (!mISDNport->ntmode || mISDNport->ptp) { - time(&mISDNport->l2establish); - PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n"); + mISDNport->l2link = 0; + if (mISDNport->l2hold) + { + time(&mISDNport->l2establish); + PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n"); + } } break; @@ -2714,10 +2851,11 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3 { /* IMPORTAINT: * - * l3m must be freed, except for MT_ASSIGN + * l3m must be queued, except for MT_ASSIGN * */ struct mISDNport *mISDNport = (struct mISDNport *)ml3->priv; + struct mbuffer *mb; /* special MT_ASSIGN handling: * @@ -2740,105 +2878,27 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3 return(0); } - /* lock LCR */ - pthread_mutex_lock(&mutex_lcr); - - /* d-message */ - switch(cmd) - { -#warning SOCKET TBD -#if 0 - case MGR_SHORTSTATUS_IND: - case MGR_SHORTSTATUS_CNF: - switch(frm->dinfo) { - case SSTATUS_L1_ACTIVATED: - l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN); - end_trace(); - goto ss_act; - case SSTATUS_L1_DEACTIVATED: - l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN); - end_trace(); - goto ss_deact; - case SSTATUS_L2_ESTABLISHED: - l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN); - end_trace(); - goto ss_estab; - case SSTATUS_L2_RELEASED: - l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN); - end_trace(); - goto ss_rel; - } - break; -#endif - -#warning SOCKET TBD -#if 0 - case MT_L1ACTIVATE: - l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN); - end_trace(); -// ss_act: - mISDNport->l1link = 1; - break; - - case MT_L1DEACTIVATE: - l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN); - end_trace(); -// ss_deact: - mISDNport->l1link = 0; - break; - - 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; -#endif - - case MT_L2ESTABLISH: - l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN); - end_trace(); -// ss_estab: - if (mISDNport->l2establish) - { - mISDNport->l2establish = 0; - PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n"); - } - mISDNport->l2link = 1; - break; - - case MT_L2RELEASE: - l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN); - end_trace(); -// ss_rel: - mISDNport->l2link = 0; - if (mISDNport->ptp) - { - time(&mISDNport->l2establish); - PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n"); - } - break; - - default: - /* l3-data is sent to LCR */ - stack2manager(mISDNport, cmd, pid, l3m); - } - - /* free message */ - if (l3m) - free_l3_msg(l3m); - - /* unlock LCR */ - pthread_mutex_unlock(&mutex_lcr); - - return(0); - + /* queue message, create, if required */ + if (!l3m) + { + l3m = alloc_l3_msg(); + if (!l3m) + FATAL("No memory for layer 3 message\n"); + } + mb = container_of(l3m, struct mbuffer, l3); + l3m->type = cmd; + l3m->pid = pid; + mqueue_tail(&mISDNport->upqueue, mb); + return 0; } + #endif /* * global function to add a new card (port) */ -struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, struct interface *interface) +struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, struct interface *interface) { int ret; struct mISDNport *mISDNport, **mISDNportp; @@ -2900,20 +2960,16 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru bri = 1; nt = 1; } -#ifdef ISDN_P_TE_E1 if (devinfo.Dprotocols & (1 << ISDN_P_TE_E1)) { pri = 1; te = 1; } -#endif -#ifdef ISDN_P_NT_E1 if (devinfo.Dprotocols & (1 << ISDN_P_NT_E1)) { pri = 1; nt = 1; } -#endif #ifdef ISDN_P_FXS if (devinfo.Dprotocols & (1 << ISDN_P_FXS)) { @@ -2930,7 +2986,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru #endif if (force_nt && !nt) { - PERROR_RUNTIME("Port %d does not support NT-mode.\n", port); + PERROR_RUNTIME("Port %d does not support NT-mode\n", port); return(NULL); } if (bri && pri) @@ -2953,7 +3009,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru PERROR_RUNTIME("Port %d does not support NT-mode nor TE-mode!\n", port); return(NULL); } - /* force nt, by turning off TE */ + /* set NT by turning off TE */ if (force_nt && nt) te = 0; /* if TE an NT is supported (and not forced to NT), turn off NT */ @@ -3048,20 +3104,38 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru pmemuse++; *mISDNportp = mISDNport; + /* if pri, set PTP */ + if (pri) + ptp = 1; + + /* set l2hold */ + switch (l2hold) + { + case -1: // off + l2hold = 0; + break; + case 1: // on + l2hold = 0; + break; + default: + if (ptp) + l2hold = 1; + else + l2hold = 0; + break; + } + /* allocate ressources of port */ #ifdef SOCKET_MISDN /* open layer 3 */ protocol = (nt)?L3_PROTOCOL_DSS1_USER:L3_PROTOCOL_DSS1_NET; prop = 0; if (ptp) // ptp forced - prop |= MISDN_FLG_PTP; -#warning SOCKET TBD -#if 0 - if (ptmp && pri) // ptmp forced - prop |= FLG_FORCE_PTMP; -#endif + prop |= (1 << MISDN_FLG_PTP); if (nt) // supports hold/retrieve on nt-mode - prop |= MISDN_FLG_NET_HOLD; + prop |= (1 << MISDN_FLG_NET_HOLD); + if (l2hold) // supports layer 2 hold + prop |= (1 << MISDN_FLG_L2_HOLD); mISDNport->ml3 = open_layer3(port-1, protocol, prop , do_layer3, mISDNport); if (!mISDNport->ml3) { @@ -3091,16 +3165,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru msg_queue_init(&mISDNport->downqueue); mISDNport->d_stid = stinf->id; PDEBUG(DEBUG_ISDN, "d_stid = 0x%x.\n", mISDNport->d_stid); - if ((stinf->pid.protocol[2]&ISDN_PID_L2_DF_PTP) || (nt&&ptp) || pri) - { - PDEBUG(DEBUG_ISDN, "Port is point-to-point.\n"); - ptp = 1; - if (ptmp && nt) - { - PDEBUG(DEBUG_ISDN, "Port is forced to point-to-multipoint.\n"); - ptp = 0; - } - } /* create layer intance */ memset(&li, 0, sizeof(li)); @@ -3196,6 +3260,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru mISDNport->ntmode = nt; mISDNport->pri = pri; mISDNport->ptp = ptp; + mISDNport->l2hold = l2hold; PDEBUG(DEBUG_ISDN, "Port has %d b-channels.\n", mISDNport->b_num); i = 0; while(i < mISDNport->b_num) @@ -3212,12 +3277,11 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru #ifdef SOCKET_MISDN /* if ptp, pull up the link */ - if (mISDNport->ptp) + if (mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) { -#warning SOCKET TBD -// mISDNport->ml3->to_layer2(mISDNport->ml3, DL_ESTABLISH_REQ); -// l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); -// end_trace(); + mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL); + l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); + end_trace(); time(&mISDNport->l2establish); } #else @@ -3232,10 +3296,9 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru act.dinfo = SSTATUS_BROADCAST_BIT | SSTATUS_ALL; act.len = 0; mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); - time(&mISDNport->l2establish); } /* if ptp AND te-mode, pull up the link */ - if (mISDNport->ptp && !mISDNport->ntmode) + if (mISDNport->l2hold && !mISDNport->ntmode) { iframe_t act; /* L2 */ @@ -3244,13 +3307,13 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru act.dinfo = 0; act.len = 0; mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); - time(&mISDNport->l2establish); l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); end_trace(); + time(&mISDNport->l2establish); } /* if ptp AND nt-mode, pull up the link */ - if (mISDNport->ptp && mISDNport->ntmode) + if (mISDNport->l2hold && mISDNport->ntmode && mISDNport->ptp) { msg_t *dmsg; /* L2 */ @@ -3259,8 +3322,15 @@ struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, stru free_msg(dmsg); l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT); end_trace(); + time(&mISDNport->l2establish); } #endif + +#ifdef SOCKET_MISDN + /* init stack queue */ + mqueue_init(&mISDNport->upqueue); +#endif + /* initially, we assume that the link is down, exept for nt-ptmp */ mISDNport->l2link = (mISDNport->ntmode && !mISDNport->ptp)?1:0; @@ -3353,6 +3423,7 @@ void mISDNport_close(struct mISDNport *mISDNport) #ifdef SOCKET_MISDN close_layer3(mISDNport->ml3); + mqueue_purge(&mISDNport->upqueue); #else /* free ressources of port */ msg_queue_purge(&mISDNport->downqueue); @@ -3484,20 +3555,16 @@ void mISDN_port_info(void) bri = 1; nt = 1; } -#ifdef ISDN_P_TE_E1 if (devinfo.Dprotocols & (1 << ISDN_P_TE_E1)) { pri = 1; te = 1; } -#endif -#ifdef ISDN_P_NT_E1 if (devinfo.Dprotocols & (1 << ISDN_P_NT_E1)) { pri = 1; nt = 1; } -#endif #ifdef ISDN_P_FXS if (devinfo.Dprotocols & (1 << ISDN_P_FXS)) { diff --git a/mISDN.h b/mISDN.h index a7ef696..a4e6014 100644 --- a/mISDN.h +++ b/mISDN.h @@ -36,7 +36,7 @@ struct mISDNport { int ptp; /* if ptp is set, we keep track of l2link */ int l1link; /* if l1 is available (only works with nt-mode) */ int l2link; /* if l2 is available (at PTP we take this serious) */ -// time_t l1timeout; /* timout when establishing link */ + int l2hold; /* set, if layer 2 must be hold/checked */ time_t l2establish; /* time until establishing after link failure */ int use; /* counts the number of port that uses this port */ int ntmode; /* is TRUE if port is nt mode */ @@ -47,6 +47,7 @@ struct mISDNport { int b_reserved; /* number of bchannels reserved or in use */ class PmISDN *b_port[128]; /* bchannel assigned to port object */ #ifdef SOCKET_MISDN + struct mqueue upqueue; int b_socket[128]; #else int procids[256]; /* keep track of free ids */ @@ -80,7 +81,7 @@ calls with no bchannel (call waiting, call on hold). int mISDN_initialize(void); void mISDN_deinitialize(void); void mISDN_port_info(void); -struct mISDNport *mISDNport_open(int port, int ptp, int ptmp, int force_nt, struct interface *interface); +struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, struct interface *interface); void mISDNport_close_all(void); void mISDNport_close(struct mISDNport *mISDNport); void mISDN_port_reorder(void); diff --git a/main.h b/main.h index c0a479a..720a3c4 100644 --- a/main.h +++ b/main.h @@ -47,7 +47,7 @@ extern int classuse; extern int fduse; extern int fhuse; -extern pthread_mutex_t mutex_lcr; // lcr process mutex +//extern pthread_mutex_t mutex_lcr; // lcr process mutex #ifdef SOCKET_MISDN extern FILE *debug_fp; @@ -136,6 +136,8 @@ extern "C" { #ifndef SOCKET_MISDN #include #include +#else +#include #endif #ifdef __cplusplus } diff --git a/options.c b/options.c index db6c9fc..4c1fabb 100644 --- a/options.c +++ b/options.c @@ -13,14 +13,6 @@ struct options options = { "/usr/local/lcr/log", /* log file */ - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0x0000, /* debug mode */ 'a', /* a-law */ "0", /* national prefix */ @@ -139,31 +131,6 @@ int read_options(void) PDEBUG(DEBUG_CONFIG, "log file: %s\n", options.log); } else - if (!strcmp(option,"port")) - { - i = strtol(param, NULL, 0); - if (i < 1 || i > sizeof(options.ports)) - { - PERROR_RUNTIME("Error in %s (line %d): port number %s out of range.\n", filename, line, option); - goto error; - } - options.ports[i] |= FLAG_PORT_USE; - - PDEBUG(DEBUG_CONFIG, "adding interface: %d (param=%s)\n", i, param); - if (strstr(param, "ptp")) - { - options.ports[i] |= FLAG_PORT_PTP; - PDEBUG(DEBUG_CONFIG, " -> interface shall be ptp\n"); - } - } else -#if 0 - if (!strcmp(option,"ptp")) - { - options.ptp = 1; - - PDEBUG(DEBUG_CONFIG, "ptp layer-2 watch and keep established.\n"); - } else -#endif if (!strcmp(option,"alaw")) { options.law = 'a'; diff --git a/options.h b/options.h index 571ba8e..a0dbad4 100644 --- a/options.h +++ b/options.h @@ -11,8 +11,6 @@ struct options { char log[128]; /* location of log file */ - char ports[256]; /* use of ports */ -// int ptp; /* if layer 2 should be watched */ int deb; /* debugging */ char law; /* 'a' or 'u' law */ diff --git a/route.c b/route.c index e322774..1899b08 100644 --- a/route.c +++ b/route.c @@ -2141,7 +2141,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) if (mISDNport->ifport) if (strlen(mISDNport->ifport->interface->name) == comp_len) if (!strncasecmp(mISDNport->ifport->interface->name, cond->string_value, comp_len)) - if (!mISDNport->ptp || mISDNport->l2link) + if (!mISDNport->l2hold || mISDNport->l2link) { j = 0; jj = mISDNport->b_num; @@ -2173,7 +2173,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->ptp || mISDNport->l2link) /* break if one is up */ + if (!mISDNport->l2hold || mISDNport->l2link) break; mISDNport = mISDNport->next; } @@ -2187,7 +2187,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) { if (mISDNport->ifport) if (!strcasecmp(mISDNport->ifport->interface->name, cond->string_value)) - if (!mISDNport->ptp || mISDNport->l2link) /* break if one is up */ + if (!mISDNport->l2hold || mISDNport->l2link) break; mISDNport = mISDNport->next; -- 2.13.6