From 16488a01568e7c35d0e7adf46fdfee5e488df8d8 Mon Sep 17 00:00:00 2001 From: Super User Date: Fri, 2 May 2008 21:19:06 +0200 Subject: [PATCH] SOCKET BRANCH: los,ais,rdi,slip query works! opening socket almost works :) --- Makefile | 2 +- lcradmin.c | 21 ++++++++++++++ lcrsocket.h | 1 + mISDN.cpp | 80 ++++++++++++++++++++++++++++++++++++---------------- mISDN.h | 1 + main.c | 7 +++-- socket_server.c | 9 ++++++ todo.txt | 87 +++++++++++++++++---------------------------------------- 8 files changed, 119 insertions(+), 89 deletions(-) diff --git a/Makefile b/Makefile index d829903..254448c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ WITH-CRYPTO = 42 # comment this out, if no libcrypto should be used #WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver. -#WITH-SOCKET = 42 # compile for socket based mISDN (this options is far unfinished !!!) +WITH-SOCKET = 42 # compile for socket based mISDN (this options is far unfinished !!!) # note: check your location and the names of libraries. # select location to install diff --git a/lcradmin.c b/lcradmin.c index cf97f69..f771609 100644 --- a/lcradmin.c +++ b/lcradmin.c @@ -681,6 +681,27 @@ char *admin_state(int sock, char *argv[]) } color((m[i].u.i.l1link)?green:blue); addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive"); + if (m[i].u.i.los) + { + color(red); + addstr(" LOS"); + } + if (m[i].u.i.ais) + { + color(red); + addstr(" AIS"); + } + if (m[i].u.i.rdi) + { + color(red); + addstr(" RDI"); + } + if (m[i].u.i.slip_tx || m[i].u.i.slip_rx) + { + color(red); + SPRINT(buffer, " SLIP(tx:%d rx:%d)", m[i].u.i.slip_tx, m[i].u.i.slip_rx); + addstr(buffer); + } if (m[i].u.i.block) { color(red); diff --git a/lcrsocket.h b/lcrsocket.h index a34820d..19fa835 100644 --- a/lcrsocket.h +++ b/lcrsocket.h @@ -73,6 +73,7 @@ struct admin_response_interface { int use; /* number of ports that use this interface */ int l1link; /* down(0) or up(1) */ int l2link; /* down(0) or up(1) */ + int los, ais, rdi, slip_tx, slip_rx; int channels; char busy[256]; /* if port is idle(0) busy(1) */ unsigned long port[256]; /* current port */ diff --git a/mISDN.cpp b/mISDN.cpp index c9eb114..6e74a90 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -532,7 +532,10 @@ static int _bchannel_create(struct mISDNport *mISDNport, int i) } /* open socket */ - mISDNport->b_socket[i] = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_L2DSP); +#warning testing without bchannel +return(0); +#warning testing without DSP + mISDNport->b_socket[i] = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_RAW/*ISDN_P_B_L2DSP*/); 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); @@ -2296,25 +2299,48 @@ int mISDN_handler(void) l3m = &mb->l3; switch(l3m->type) { -#warning SOCKET TBD: Layer 1 indication -#if 0 - case MT_L1ACTIVATE: + case MPH_ACTIVATE_IND: l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN); end_trace(); mISDNport->l1link = 1; break; - case MT_L1DEACTIVATE: + case MPH_DEACTIVATE_IND: 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) + case MPH_INFORMATION_IND: + PDEBUG(DEBUG_ISDN, "Received MPH_INFORMATION_IND for port %d (%s).\n", mISDNport->portnum, mISDNport->ifport->interface->name); + switch (l3m->pid) + { + case L1_SIGNAL_LOS_ON: + mISDNport->los = 1; + break; + case L1_SIGNAL_LOS_OFF: + mISDNport->los = 0; + break; + case L1_SIGNAL_AIS_ON: + mISDNport->ais = 1; + break; + case L1_SIGNAL_AIS_OFF: + mISDNport->ais = 0; + break; + case L1_SIGNAL_RDI_ON: + mISDNport->rdi = 1; + break; + case L1_SIGNAL_RDI_OFF: + mISDNport->rdi = 0; + break; + case L1_SIGNAL_SLIP_TX: + mISDNport->slip_tx++; + break; + case L1_SIGNAL_SLIP_RX: + mISDNport->slip_rx++; + break; + } break; -#endif case MT_L2ESTABLISH: l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN); @@ -2944,7 +2970,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st #ifdef SOCKET_MISDN devinfo.id = port - 1; ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo); - if (ret <= 0) + if (ret < 0) { PERROR_RUNTIME("Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", i, ret); return(NULL); @@ -3537,7 +3563,7 @@ void mISDN_port_info(void) #ifdef SOCKET_MISDN devinfo.id = i - 1; ret = ioctl(sock, IMGETDEVINFO, &devinfo); - if (ret <= 0) + if (ret < 0) { fprintf(stderr, "Cannot get device information for port %d. (ioctl IMGETDEVINFO failed ret=%d)\n", i, ret); break; @@ -3582,18 +3608,24 @@ void mISDN_port_info(void) if ((te || nt) && (bri || pri || pots)) useable = 1; - if (te && bri) - printf("TE-mode BRI S/T interface line (for phone lines)"); - if (nt && bri) - printf("NT-mode BRI S/T interface port (for phones)"); - if (te && pri) - printf("TE-mode PRI E1 interface line (for phone lines)"); - if (nt && pri) - printf("NT-mode PRI E1 interface port (for E1 terminals)"); - if (te && pots) - printf("FXS POTS interface port (for analog lines)"); - if (nt && pots) - printf("FXO POTS interface port (for analog phones)"); + if (te && nt && bri) + printf("TE/NT-mode BRI S/T (for phone lines & phones)"); + if (te && !nt && bri) + printf("TE-mode BRI S/T (for phone lines)"); + if (nt && !te && bri) + printf("NT-mode BRI S/T (for phones)"); + if (te && nt && pri) + printf("TE/NT-mode PRI E1 (for phone lines & E1 devices)"); + if (te && !nt && pri) + printf("TE-mode PRI E1 (for phone lines)"); + if (nt && !te && pri) + printf("NT-mode PRI E1 (for E1 devices)"); + if (te && nt && pots) + printf("FXS/FXO POTS (for analog lines & phones)"); + if (te && !nt && pots) + printf("FXS POTS (for analog lines)"); + if (nt && !te && pots) + printf("FXO POTS (for analog phones)"); if (pots) { useable = 0; @@ -3641,7 +3673,7 @@ void mISDN_port_info(void) useable = 1; nt = 1; pri = 1; - printf("NT-mode PRI E1 interface port (for E1 terminals)"); + printf("NT-mode PRI E1 interface port (for E1 devices)"); break; default: useable = 0; diff --git a/mISDN.h b/mISDN.h index a4e6014..de33e16 100644 --- a/mISDN.h +++ b/mISDN.h @@ -59,6 +59,7 @@ struct mISDNport { unsigned long b_remote_id[128]; /* the socket currently exported */ unsigned long b_remote_ref[128]; /* the ref currently exported */ int locally; /* local causes are sent as local causes not remote */ + int los, ais, rdi, slip_rx, slip_tx; }; extern mISDNport *mISDNport_first; diff --git a/main.c b/main.c index 931ac2a..8732b79 100644 --- a/main.c +++ b/main.c @@ -207,7 +207,8 @@ int main(int argc, char *argv[]) struct sched_param schedp; char *debug_prefix = "alloc"; int created_mutexd = 0,/* created_mutext = 0,*/ created_mutexe = 0, - created_lock = 0, created_signal = 0, created_debug = 0; + created_lock = 0, created_signal = 0, created_debug = 0, + created_misdn = 0; int idletime = 0, idlecheck = 0; char tracetext[256]; @@ -307,6 +308,7 @@ int main(int argc, char *argv[]) /* init mISDN */ if (mISDN_initialize() < 0) goto free; + created_misdn = 1; created_debug = 1; /* read ruleset(s) */ @@ -751,7 +753,8 @@ free: fprintf(stderr, "cannot destroy 'PDEBUG' mutex\n"); /* deinitialize mISDN */ - mISDN_deinitialize(); + if (created_misdn) + mISDN_deinitialize(); /* display memory leak */ #define MEMCHECK(a, b) \ diff --git a/socket_server.c b/socket_server.c index b50b3e7..469f562 100644 --- a/socket_server.c +++ b/socket_server.c @@ -855,6 +855,15 @@ int admin_state(struct admin_queue **responsep) response->am[num].u.i.l1link = mISDNport->l1link; /* l2link */ response->am[num].u.i.l2link = mISDNport->l2link; + /* los */ + response->am[num].u.i.los = mISDNport->los; + /* ais */ + response->am[num].u.i.ais = mISDNport->ais; + /* rdi */ + response->am[num].u.i.rdi = mISDNport->rdi; + /* slip */ + response->am[num].u.i.slip_tx = mISDNport->slip_tx; + response->am[num].u.i.slip_rx = mISDNport->slip_rx; /* channels */ response->am[num].u.i.channels = mISDNport->b_num; /* channel info */ diff --git a/todo.txt b/todo.txt index 325392d..2ebe280 100644 --- a/todo.txt +++ b/todo.txt @@ -1,73 +1,36 @@ -chan_lcr: - -milestones: -- das cli -- auf- und abbau von calls und instanzen -- informationen in den jeweiligen messages umwandeln -- setup-queue -- einbau von b-channel-features -- durchcompilieren -- testen - - -CLI: -show calls -show lcr -block/unblock port -reload interfaces/routing -release call - -setup: -es werden setupdaten gespeichert, bis eine ref vom lcr erfolgt. -dabei werden zusätzliche wahlinformationen der rufummer hinzugefügt. -die gespeicherten daten sind die schnittmenge von den informationen des lcr und der asterisk. +socket-test: +- testswitches und karte einbauen +- call-aufbau ohne bchannel +- call-aufbau mit bchannel +- dsp +- hfc-multi +- call nach extern +- l1oip -bridge: jede instanz (chan_call) hat eine bridge_id -wenn keine bridge, dann ist sie 0. -mit new_bridge_id() wird eine neue id gesucht. diese wird in beide instanzen eingetragen -zudem wird fuer jede instanz (zwei) der bridge eine bchannel_join ausgeführt, wenn die bchannels verfügbar sind. -schon implementiert: falls der bchannel später kommt, wird der join beim exporieren des b-channels ausgeführt. - -info-bridge: -wir koennen informationen, wie notifys einfach parallel zur bridge weiterreichen. z.b. notify "es wird angeklopft", "das gespraech wird gehalten", "sie werden weitergeleitet". auch display informationen und facilities +chan_lcr: +- das cli +- bchannel handling +- config gile +- einbau von b-channel-features call transfer - -doku: remote, exten - -doku: action execute geht mit fork - -doku: rx_vol -> rx_gain - -context -doku: context - -fuer asterisk: dejitter tx_buffer in dsp.o - -doku: tout in interface.conf - -layer-2-hold interface feature - -neue params zum aufbau eines externen/internen calls -neue params zun aufbau eines externen/internen calls dokumentieren - -neuen partyline-param dokumentieren - -dokumentieren: aufzeichnung der ansage mit 0 ohne beep beenden -doku: gain, pipeline, crypt - -make asterisk call implementation - display message during nothing/play -maybe: -delay - per param setzen, lokal als mISDNsignal und remote mittels setup - - - +doku: + +- remote, exten +- action execute geht mit fork +- rx_vol -> rx_gain +- interface context +- tout in interface.conf +- layer-2-hold interface feature +- neue params zun aufbau eines externen/internen calls +- neuen partyline-param dokumentieren +- aufzeichnung der ansage mit 0 ohne beep beenden +- gain, pipeline, crypt -- 2.13.6