From 894f4b987acc41e225b6d5f0d73543771c88146b Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Thu, 26 Oct 1995 14:48:54 +0100 Subject: [PATCH] isdn-16 --- DOKU | 2 +- Make.config | 8 +- Makefile | 6 +- cards/capi/bintec.c | 5 + config/config.data | 207 +++++++++++++++++++++++++++++ include/isdn_23.h | 2 +- include/isdn_3.h | 2 +- isdn_3/capi.c | 181 +++++++++++++++++-------- isdn_3/isdn_3.c | 2 + isdn_3/prot_1TR6_1.c | 4 - isdn_3/prot_ETS.c | 2 +- isdn_4/master.h | 2 + isdn_4/work.c | 31 ++++- streams/stream.h | 6 + streams/streams_io.c | 14 +- streams/streams_sys.c | 301 +++++++++++++++++++++++++++--------------- 16 files changed, 592 insertions(+), 183 deletions(-) create mode 100644 config/config.data diff --git a/DOKU b/DOKU index 1b367cf..48bb8ab 100644 --- a/DOKU +++ b/DOKU @@ -603,7 +603,7 @@ Parameter: Spezifisch für 1TR6 und CAPI: :sv Dienstkennung; zwei Bytes in Hex. Telefon ist 0101 und 0102; DFÜ ist 07xx (xx ist üblicherweise 00). -:pv Semipermanente Verbindung bei abgehenden Rufen. (Noch nicht bei CAPI.) +:pv Semipermanente Verbindung bei abgehenden Rufen. Ankommend werden SPVs automatisch unterstützt. Spezifisch für Euro-ISDN: diff --git a/Make.config b/Make.config index 1c4c61f..f18eeac 100644 --- a/Make.config +++ b/Make.config @@ -4,14 +4,14 @@ SHELL = /bin/sh ## =()@>()= -CARDS = ncp16 ncp teles bintec +CARDS = teles ## =()@>()= -PROTOCOLS = phone capi tei fixed +PROTOCOLS = phone tei ## =()@>()= SUBPROTOCOLS = euro german ## =()@>()= -KERNELSRC := /usr/src/kernel/linux-test +KERNELSRC := /usr/src/linux ifdef KERNEL ## =()@>()= @@ -37,7 +37,7 @@ LD = ld ## =()@>()= LDFLAGS = ## =()@>()= -RANLIB = ranlib +RANLIB = echo ## =()@>()= STR_IF = str_linux ## =()@>()= diff --git a/Makefile b/Makefile index bc7a0bf..eda3b43 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ # config and include are first, then libraries, tools, modules+programs -SUBDIRS = config include tools compat streams support isdn_3 isdn_4 \ +SUBDIRS = config include tools compat streams support isdn_3 isdn_4 \ ksupport isdn_2 str_if cards x75 alaw tools van_j strslip \ v110 pr_on strslip fakeh t70 rate timer reconnect ip_mon .PHONY: depend all:: .diddepend +depend:: + $(MAKE) -C compat depend + $(MAKE) -C streams depend + dep: depend TOPDIR=. diff --git a/cards/capi/bintec.c b/cards/capi/bintec.c index 4603aab..1e1c11c 100644 --- a/cards/capi/bintec.c +++ b/cards/capi/bintec.c @@ -776,6 +776,11 @@ bintec_mode (struct _isdn1_card * card, short channel, char mode, char listen) if(channel > 0 && channel <= bp->card.nr_chans) { DEBUG(info) printf("%sBINTEC: Chan%d %s<%d>%s\n",KERN_INFO ,channel,mode?"up":"down",mode,listen?" listen":""); bp->chan[channel].mode = mode; + if(mode == M_OFF) { + bp->chan[channel].appID = 0; + bp->chan[channel].PLCI = 0; + bp->chan[channel].NCCI = 0; + } splx(ms); return 0; } else { diff --git a/config/config.data b/config/config.data new file mode 100644 index 0000000..7a9a058 --- /dev/null +++ b/config/config.data @@ -0,0 +1,207 @@ +## +## ISDN master configuration file for Linux. +## Note that if you leave a field blank, you must have the trailing tab! + +## +## +## System type. +## +#### =()@>()= +SYS linux +## +## +## Where to install everything. The programs are in bin-KERNELVERSION. +## +#### =()@>()= +DESTDIR /usr/local/isdn +## +## +## What to name the lockfiles. Someting with %s (device name). +## Make sure "cu" and other UUCP utilities use the same convention! +## +#### =()@>()= +LOCKNAME /var/lock/LCK..%s +## +## +#### Path names +## +#### =()@>()= +ROUTE_PATH /sbin/route +## +## +## +## Card drivers to install. teles. +## +#### =()@>()= +CARDS teles +## +## +## Protocols to make. fixed phone tei. +## +#### =()@>()= +PROTOCOLS phone tei +## +## +## Subprotocols for "phone". euro german. +## +#### =()@>()= +SUBPROTOCOLS euro german +## +## +## Debugging? DO or DONT +## +#### =()@>()= +DEBUGGING DO +## +## +## +## Stuff to define +## +## Where's the Linux source? +## +#### =()@>()= +KERNELSRC /usr/src/linux +## +## +## C compiler for the kernel +## +#### =()@>()= +CC gcc +## +## +## C compiler for the utilities +## +#### =()@>()= +HOSTCC gcc +## +## +## C flags for kernel modules. Needs -DMODULE -DKERNEL -D__KERNEL__. +## +#### =()@>()= +CFLAGS -g -O2 -Wall -fomit-frame-pointer -DKERNEL -D__KERNEL__ -DMODULE +## +## +## C flags for programs +## +#### =()@>()= +HOSTCFLAGS -g -O2 -Wall +#CFLAGS -x c++ -g -O2 -W -Wreturn-type -Wshadow -Wcomment +#CFLAGS -g -W -Wreturn-type -Wshadow -Wcomment -D_BSD_SOURCE -D_SYSV_SOURCE +## +## +## Calling ld directly? +## +#### =()@>()= +LD ld +#LD /usr/i486-linuxaout/bin/ld -m i386linux +## +## +## Flags for the "cc -o" command line +## +#### =()@>()= +LDFLAGS +## +## +## If you need to link in other libraries, add them here +## +#### =()@>()= +LIBS -lbsd +## +## +## +## System dependent stuff below: don't change. +## +## +## Byte order. Motorola 4321, Intel 1234. +#### =()@>()= +BYTEORDER 1234 +## +## Ranlib needed ? "ranlib" or "echo" +#### =()@>()= +RANLIB echo +## +## Need strsave(3)? DO or DONT. +#### =()@>()= +NEED_STRDUP DONT +## +## Do you have setsid()? +#### =()@>()= +HAVE_SETSID DO +## +## How many arguments does your setpgrp() take? 0 or 2. +#### =()@>()= +HAVE_SETPGRP 0 + +## Does Streeams use signed or unsigned characters in its buffer? +#### =()@>()= +STREAMCHAR unsigned char +## +## Define only if building a kernel complains that there's no spl(). +#### =()@>()= +NEED_SPL DONT +## +## signal functions' return type? Usually void or int. +#### =()@>()= +SIGRET void +## +## Need writev(3)? DO or DONT. +#### =()@>()= +NEED_WRITEV DONT +## +## Signal blocking? SYSV or BSD or NONE. +#### =()@>()= +SIGTYPE SYSV +## +## Define only if building a kernel complains that there's no memcpy. +#### =()@>()= +NEED_MEMCPY DONT +## +## Name of sys/termio.h (or sys/termios.h) +#### =()@>()= +TERMIO termios +## +## Name of /usr/include/strings.h +#### =()@>()= +STRINGS string +## +## What a minor number is called. +#### =()@>()= +SUBDEV uchar_t +## +## Streams <-> INet interface? "in" or "in2" or "str" or "linux" or "none" +## "in" is old BSD, "in2" is BSD 4.4, "str" is Streams-based +#### =()@>()= +STR_IF linux +## +## kernel timeout() funtion. OLD: untimeout takes first two args of timeout(). +## NEW: untimeout takes return value of timeout(). +#### =()@>()= +TIMEOUT NEW +## +## Streams XXXopen() -- does it get an additional "pointer to int" argument +## which points to the appropriate errno value? +#### =()@>()= +ADDERROR DONT +## + + +### ISDN configuration options + +## One TEI per B channel? Seems to be required for US National-1. +## DO or DONT. +#### =()@>()= +MULTI_TEI DONT +## +## +## What to call protocol stuff. M_EXPROTO or (M_PROTO+0x40) +#### =()@>()= +MSG_PROTO M_EXPROTO +## +## What to call hopefully-expedited data stuff. M_EXDATA or (M_DATA+0x40). +#### =()@>()= +MSG_EXDATA M_EXDATA +## +## What to call normal data stuff. M_DATA +#### =()@>()= +MSG_DATA M_DATA + diff --git a/include/isdn_23.h b/include/isdn_23.h index d920361..e224f41 100644 --- a/include/isdn_23.h +++ b/include/isdn_23.h @@ -173,7 +173,7 @@ typedef struct _isdn23_hdr { } sel; } -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)) +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) __attribute__((packed)) #endif *isdn23_hdr; diff --git a/include/isdn_3.h b/include/isdn_3.h index 0f9351b..eb331f0 100644 --- a/include/isdn_3.h +++ b/include/isdn_3.h @@ -153,7 +153,7 @@ typedef struct _isdn3_talk { /* one per card's D channel connection */ ** One struct isdn3_conn represents one ISDN call. **/ #define STACK_LEN 10 -#define NICONN 16 +#define NICONN 18 #define NSCONN 3 typedef struct _isdn3_conn { diff --git a/isdn_3/capi.c b/isdn_3/capi.c index dfcb4be..deedad2 100644 --- a/isdn_3/capi.c +++ b/isdn_3/capi.c @@ -22,14 +22,14 @@ #define ST_pbx 2 /* Bits! */ -#if NITALK <=NBOARD+3 -#error "Need NITALK > NBOARD+3" +#if NITALK <=NBOARD+5 +#error "Need NITALK > NBOARD+5" #endif #define tappl talki #define regnum talki[NBOARD+0] /* current interface I'm talking about */ #define message_id talki[NBOARD+1] /* Expected msgid for current interface */ #define tstate talki[NBOARD+2] /* State of the current interface */ -#define lasteaz talki[NBOARD+3] /* last EAZ we used up */ +#define chanmask talki[NBOARD+3] /* channels we have used up */ #if NICONN <= 15 #error "Need NICONN > 15" @@ -152,6 +152,25 @@ printf ("Conn CAPI:%d %05lx: State %d --> %d\n", deb_line, conn->call_ref, conn- timer(CAPI_TFOO,conn); break; } + if(state == 0 || state >= 20) { + if(conn->bchan != 0) { + conn->bchan = 0; + conn->talk->chanmask &=~ (1<bchan); + conn->minorstate &=~ MS_BCHAN; + /* XXX send a clearing msg down? */ + } + } else if(conn->bchan == 0) { + int ch; unsigned long chm; + for(ch=1,chm = 1;chm; chm <<= 1, ch++) + if(!(conn->talk->chanmask & chm)) + break; + if(chm) { + conn->bchan = ch; + conn->minorstate |= MS_BCHAN; + conn->talk->chanmask |= chm; + isdn3_setup_conn (conn, EST_NO_CHANGE); + } + } } static ushort_t newmsgid(isdn3_talk talk) @@ -267,11 +286,11 @@ send_setup(isdn3_conn conn) bzero(dl,sizeof(*dl)); bzero(c3,sizeof(*c3)); - c2->plci = conn->call_ref & 0xFFFF; + c2->plci = conn->call_ref; c2->B2_proto = 0x02; /* transparent HDLC */ c2->dlpdlen = sizeof(*dl); dl->data_length = 4096; - c3->plci = conn->call_ref & 0xFFFF; + c3->plci = conn->call_ref; c3->B3_proto = 0x04; /* transparent */ err = capi_send(conn->talk,conn->call_ref >> 16, CAPI_SELECTB2_REQ, m2, conn->conni[WF_SELECTB2_CONF] = newmsgid(conn->talk)); if(err < 0) { @@ -378,6 +397,7 @@ chstate (isdn3_talk talk, uchar_t ind, short add) case DL_ESTABLISH_IND: case DL_ESTABLISH_CONF: talk->regnum = 0; + talk->state |= IS_UP; { isdn3_conn conn, nconn; for(conn = talk->conn; conn != NULL; conn = nconn) { @@ -399,6 +419,7 @@ chstate (isdn3_talk talk, uchar_t ind, short add) case PH_DISCONNECT_IND: talk->regnum = 0; talk->tstate = STATE_BOOTING; + talk->state &=~ IS_UP; { isdn3_conn conn, nconn; for(conn = talk->conn; conn != NULL; conn = nconn) { @@ -545,8 +566,10 @@ send_disconnect(isdn3_conn conn, char do_L3, ushort_t cause) return 0; if(conn->state == 0) return 0; + if((conn->state >= 20) && (cause == N1_LocalProcErr)) + cause = 0; conn->waitflags = 0; - report_terminate(conn,0,0); + report_terminate(conn,0,cause); switch(conn->state) { case 6: case 7: @@ -623,21 +646,71 @@ send_dialout(isdn3_conn conn) struct CAPI_connect_req *c2; struct capi_info *info = conn->p_data; mblk_t *m2; + int llen = strlen(info->lnr); if(info == NULL) return -ENXIO; - m2 = allocb(sizeof(*c2)+strlen(info->nr)+((info->flags & INF_SPV) != 0),BPRI_MED); + m2 = allocb(sizeof(*c2)+strlen(info->nr)+(llen ? llen+1 : 0)+((info->flags & INF_SPV) != 0),BPRI_MED); if(m2 == NULL) return -ENOMEM; - c2 = ((typeof(c2))m2->b_wptr++); + c2 = ((typeof(c2))m2->b_wptr)++; bzero(c2,sizeof(*c2)); - c2->infomask = ~0; + c2->infomask = 0xC00000FF; + { /* Find correct info mask */ + int err; char skip = 0; + mblk_t *inf = conn->talk->card->info; + if(inf != NULL) { + streamchar *sta = inf->b_rptr; + ushort_t idx; + + while(m_getid(inf,&idx) == 0) { + long sap; + switch(idx) { + case ARG_PROTOCOL: + if (m_geti(inf,&sap) == 0) { + skip = (sap != SAPI_CAPI); + } + break; + case ARG_SUBPROT: + if (m_geti(inf,&sap) == 0 && !skip) { + switch(sap) { + case SAPI_CAPI_BINTEC: + skip=0; + break; + default: + /* Wrong card. TODO: Do something! */ + inf->b_rptr = sta; + return -ENXIO; + } + } + break; + case ARG_SUBCARD: + if (m_geti(inf,&sap) == 0 && !skip) + skip = (sap != info->subcard); + break; + case ARG_LISTEN: + { + long x; + if(skip) + break; + if((err = m_getx(inf,&x)) >= 0) { + if((err = m_getx(inf,&x)) >= 0) { + if((err = m_getx(inf,&x)) >= 0) { + c2->infomask = x; + } + } + } + } + break; + } + } + inf->b_rptr = sta; + } + } c2->channel = (info->bchan ? info->bchan : CAPI_ANYBCHANNEL); c2->DST_service = info->service >> 8; c2->DST_addinfo = info->service; - if(info->lnr[0] != '\0') - c2->SRC_eaz = info->lnr[strlen(info->lnr)-1]; c2->telnolen = strlen(info->nr); strncpy(m2->b_wptr,info->nr,c2->telnolen); m2->b_wptr += strlen(info->nr); @@ -645,6 +718,18 @@ send_dialout(isdn3_conn conn) c2->telnolen++; *m2->b_wptr++ = 'S'; } + if(llen > 0) && (conn->talk->state & (1<<(info->subcard+ST_pbx)))) { + c2->SRC_eaz = 0; + if(info->lnr[0] >= '0' && info->lnr[0] <= '9') { + memcpy(m2->b_wptr+1,info->lnr,llen); + } else { + llen--; + memcpy(m2->b_wptr+1,info->lnr+1,llen); + } + *m2->b_wptr = llen; + m2->b_wptr += llen+1; + } else if(llen > 0) + c2->SRC_eaz = info->lnr[llen-1]; conn->call_ref = conn->talk->tappl[info->subcard]<<16; if((err = capi_send(conn->talk,conn->talk->tappl[info->subcard],CAPI_CONNECT_REQ,m2,conn->conni[WF_CONNECT_CONF]=newmsgid(conn->talk))) < 0) freemsg(m2); @@ -868,11 +953,9 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) report_terminate(conn,0,0); setstate(conn,0); } - } else { - if((c2->info != 0) || (conn->state >= 21)) + } else if((c2->info != 0) || ((conn->state >= 21) && (conn->state < 99))) { printf("CAPI error: DISCONNECT_IND in wrong state %d, info %04x\n",conn->state,c2->info); isdn3_setup_conn (conn, EST_DISCONNECT); - send_disconnect(conn,0,0); report_terminate(conn,c2->info,0); } { @@ -930,6 +1013,7 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) c2 = ((typeof(c2))data->b_rptr)++; if((c2->info == 0) && ((conn = capi_findconn(talk,capi->appl,c2->plci)) != NULL)) { printf("CAPI error: CONNECT_CONF has known cref %x%04x\n",capi->appl,c2->plci); + report_terminate(conn,c2->info,0); setstate(conn,0); err = -ENXIO; break; @@ -1170,7 +1254,6 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) struct capi_info *info = conn->p_data; bzero(info,sizeof(*info)); - info->subcard = ~0; { int i; for(i=0;i < talk->card->dchans; i++) { @@ -1251,7 +1334,6 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) break; } bzero(conn->p_data,sizeof(struct capi_info)); - ((struct capi_info *)conn->p_data)->subcard = 0; } info = conn->p_data; @@ -1277,21 +1359,27 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) } break; case AI_DAD: - { - int nrlen = c2->infolen; - switch(*data->b_rptr) { - case 0x81: + switch(*data->b_rptr) { + case 0x81: + { + int nrlen = c2->infolen; + int haslen = strlen(info->lnr); + if(haslen == 0) { + haslen = 1; + info->lnr[0] = '/'; + } data->b_rptr++; nrlen--; - if(nrlen >= MAXNR) - nrlen = MAXNR-1; - bcopy(data->b_rptr,info->lnr,nrlen); + if(nrlen >= MAXNR-haslen) + nrlen = MAXNR-haslen-1; + bcopy(data->b_rptr,info->lnr+haslen,nrlen); + info->lnr[nrlen+1]='\0'; setstate(conn,7); report_incoming(conn); - break; - default: - err = -EINVAL; - break; } + break; + default: + err = -EINVAL; + break; } break; case AI_UUINFO: @@ -1418,7 +1506,7 @@ recv (isdn3_talk talk, char isUI, mblk_t * data) c2->info_mask = 0xC00000FF; c2->eaz_mask = 0x03FF; c2->service_mask = 0xE7BF; - { /* Find correct driver name */ + { /* Find correct masks */ int err; char skip = 0; mblk_t *info = talk->card->info; if(info != NULL) { @@ -1745,6 +1833,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) } else send_disconnect(conn,0,N1_OutOfOrder); } + break; case CMD_DIAL: { if (data == NULL) { @@ -1757,32 +1846,7 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) conn->lockit--; return -EINVAL; } - if((info->lnr[0] != '\0') && (conn->talk->state & (1<<(info->subcard+ST_pbx)))) { - char eaz; - struct eazmapping *ce; - mblk_t *mp; - int len = strlen(info->lnr+1); - - eaz = ++conn->talk->lasteaz; - if(eaz > 8) eaz = 1; - eaz += '0'; - mp = allocb(sizeof(*ce)+len, BPRI_MED); - if(mp == NULL) - break; - ce = ((struct eazmapping *)mp->b_wptr)++; - bzero(ce,sizeof(*ce)); - ce->eaz = eaz; - ce->telnolen = len; - strncpy(mp->b_wptr,info->lnr+1,len); - mp->b_wptr += len; - if((err = capi_sendctl(conn->talk,conn->talk->tappl[conn->talk->regnum],CONTROL_EAZMAPPING,mp,conn->conni[WF_CONTROL_EAZ] = newmsgid(conn->talk))) < 0) - freemsg(mp); - else { - conn->waitflags = 1<state == 0) { + conn->lockit--; + return; } send_disconnect(conn, !force, 0); - if (conn->p_data != NULL) { - free (conn->p_data); - conn->p_data = NULL; - } conn->lockit--; checkterm(conn); } diff --git a/isdn_3/isdn_3.c b/isdn_3/isdn_3.c index 6480871..2bc51ae 100644 --- a/isdn_3/isdn_3.c +++ b/isdn_3/isdn_3.c @@ -390,6 +390,8 @@ isdn3_killconn (isdn3_conn conn, char force) if(conn->conns[i] != NULL) free(conn->conns[i]); } + if(conn->p_data != NULL) + free(conn->p_data); free(conn); } } diff --git a/isdn_3/prot_1TR6_1.c b/isdn_3/prot_1TR6_1.c index 06e304e..7c7ed40 100644 --- a/isdn_3/prot_1TR6_1.c +++ b/isdn_3/prot_1TR6_1.c @@ -2461,10 +2461,6 @@ sendcmd (isdn3_conn conn, ushort_t id, mblk_t * data) static void killconn (isdn3_conn conn, char force) { - if (conn->p_data != NULL) { - free (conn->p_data); - conn->p_data = NULL; - } if (force) { untimer (N1_T308, conn); untimer (N1_T313, conn); diff --git a/isdn_3/prot_ETS.c b/isdn_3/prot_ETS.c index 99e6d05..f8b7451 100644 --- a/isdn_3/prot_ETS.c +++ b/isdn_3/prot_ETS.c @@ -437,7 +437,7 @@ printf("FacL 8 is %d %d\n",ilen,nlen); ilen--; } -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)) +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) #define UNUSED __attribute__((unused)) #else #define UNUSED diff --git a/isdn_4/master.h b/isdn_4/master.h index 6ce0b2f..be95f7c 100644 --- a/isdn_4/master.h +++ b/isdn_4/master.h @@ -222,6 +222,7 @@ typedef struct proginfo { char *protocol; char *cclass; char *card; + long id; ulong_t mask; char *type; pid_t pid; @@ -279,6 +280,7 @@ typedef struct conninfo { long ccharge; /* cumulative charge, informational msg */ int chargecount; /* Debug! */ pid_t pid; + long id; uchar_t minor; uchar_t fminor; CState state; diff --git a/isdn_4/work.c b/isdn_4/work.c index 46f3ac4..6f62cf4 100644 --- a/isdn_4/work.c +++ b/isdn_4/work.c @@ -588,7 +588,19 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) syslog(LOG_CRIT,"Pipe: %m"); return "NO PIPE"; } - + { + struct conninfo *xconn; + int id = 0; char *ids = strchr(cfr->type,'/'); + if(ids != NULL) + id = atoi(ids); + if(id != 0) { + for(xconn = isdn4_conn; xconn != NULL; xconn = xconn->next) { + if(xconn->id == id) { + return "Already Running"; + } + } + } + } { char *err; @@ -619,6 +631,17 @@ runprog (cf cfr, struct conninfo **rconn, conngrab *foo) ReportConn(conn); } } else { + if(conn != NULL) { + int id = 0; char *ids = strchr(cfr->type,'/'); + if(ids != NULL) + id = atoi(ids); + if(id != 0) { + for(prog = conn->run; prog != NULL; prog = prog->next) { + if(prog->id == id) + return "Already Running"; + } + } + } prog = (struct proginfo *) malloc (sizeof (struct proginfo)); if (prog == NULL) @@ -1101,6 +1124,8 @@ run_rp(struct conninfo *conn, char what) for(cfr = cf_RP; cfr != NULL; cfr = cfr->next) { char *sit,*pro,*car,*cla; ulong_t sub; + int id = 0; + char *ids; if(strchr(cfr->type,what) == NULL) continue; if((sit = wildmatch(conn->cg->site,cfr->site)) == NULL) continue; @@ -1108,9 +1133,13 @@ run_rp(struct conninfo *conn, char what) if((car = wildmatch(conn->cg->card,cfr->card)) == NULL) continue; if((sub = maskmatch(conn->cg->mask,cfr->mask)) == 0) continue; if((cla = classmatch(conn->cg->cclass,cfr->cclass)) == NULL) continue; + if((ids = strchr(cfr->type,'/')) != NULL) + id = atoi(ids); for(pr = conn->run; pr != NULL; pr = pr->next) { struct conninfo *xconn; + if(id != 0 && pr->id == id) + break; if(strchr(pr->type,what) == NULL) continue; if(wildmatch(pr->site,sit) == NULL) continue; if(wildmatch(pr->protocol,pro) == NULL) continue; diff --git a/streams/stream.h b/streams/stream.h index 9e7cf43..8819576 100644 --- a/streams/stream.h +++ b/streams/stream.h @@ -576,6 +576,11 @@ extern int strmsgsz; /* maximum stream message size */ extern int nstrpush; /* maximum # of pushed modules */ extern volatile queue_t *sched_first, *sched_last; +#ifdef CONFIG_DEBUG_STREAMS +extern void putnext(queue_t *p_queue, mblk_t *p_msg); +extern void linkb(mblk_t *p_msg1, mblk_t *p_msg2); +extern mblk_t *unlinkb(mblk_t *p_msg); +#else static inline void putnext(queue_t *p_queue, mblk_t *p_msg) { (*p_queue->q_next->q_qinfo->qi_putp)(p_queue->q_next, p_msg); @@ -603,5 +608,6 @@ static inline mblk_t *unlinkb(mblk_t *p_msg) p_msg->b_cont = NULL; return p_nextmsg; } +#endif /* DEBUG */ #endif /* __sys_stream_h */ diff --git a/streams/streams_io.c b/streams/streams_io.c index dd673c1..420ffdb 100644 --- a/streams/streams_io.c +++ b/streams/streams_io.c @@ -184,7 +184,9 @@ xstreams_open (struct inode *inode, struct file *file, struct stream_header **pp p_stream->flag &= ~SF_WAITOPEN; wake_up (&p_stream->waiting); if (p_stream->error < 0) { +#ifdef CONFIG_DEBUG_STREAMS printk("XOpen RetErr %d\n",p_stream->error); +#endif return p_stream->error; } return 0; @@ -255,8 +257,16 @@ xstreams_open (struct inode *inode, struct file *file, struct stream_header **pp freeq (p_queue); kfree_s (p_stream, sizeof (*p_stream)); +#ifdef CONFIG_DEBUG_STREAMS printk("XOpen RetErrR %d\n",err); - return err; +#endif + if(p_stream->next != NULL) + p_stream->next->prev = p_stream->prev; + if(p_stream->prev != NULL) + p_stream->prev->next = p_stream->next; + else + first_stream = p_stream->next; + return err; } /* @@ -318,7 +328,7 @@ streams_close (struct inode *inode, struct file *file) wake_up (&p_stream->ioctling); p_queue = p_stream->write_queue; -#if 0 /* def CONFIG_DEBUG_STREAMS */ +#ifdef CONFIG_DEBUG_STREAMS_1 printf("Closing %p q %p\n",p_stream,RD(p_queue)); #endif /* diff --git a/streams/streams_sys.c b/streams/streams_sys.c index 3465d71..071a3b2 100644 --- a/streams/streams_sys.c +++ b/streams/streams_sys.c @@ -77,7 +77,6 @@ int q_timeout = 0; #undef freeb #undef dupb #undef copyb -#undef unlinkb #undef qenable #ifdef CONFIG_MALLOC_NAMES #undef kmalloc @@ -89,7 +88,6 @@ int q_timeout = 0; #define freeb(a) deb_freeb(deb_file,deb_line,a) #define dupb(a) deb_dupb(deb_file,deb_line,a) #define copyb(a) deb_copyb(deb_file,deb_line,a) -#define unlinkb(a) deb_unlinkb(deb_file,deb_line,a) #define qenable(a) deb_qenable(deb_file,deb_line,a) void traceback(char str) { @@ -132,7 +130,8 @@ __res;}) * Data message type? */ -static inline const int datamsg(uchar_t type) +static inline const int +datamsg(uchar_t type) { return (type == M_DATA || type==M_EXDATA); } @@ -150,10 +149,11 @@ static inline const int datamsg(uchar_t type) * reasonable values. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t * deb_allocb(const char *deb_file, unsigned int deb_line, ushort size, ushort pri) +deb_allocb(const char *deb_file, unsigned int deb_line, ushort size, ushort pri) #else -mblk_t * allocb(ushort size, ushort pri) +allocb(ushort size, ushort pri) #endif { mblk_t *p_msg; @@ -226,10 +226,11 @@ mblk_t * allocb(ushort size, ushort pri) * Free a message header, decrement data block refcount, free data block if zero. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_freeb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_freeb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -void freeb(mblk_t *p_msg) +freeb(mblk_t *p_msg) #endif { #ifdef SK_STREAM @@ -325,10 +326,11 @@ void freeb(mblk_t *p_msg) * * This is rather inefficient and unsafe, but testb() is not widely used anyway. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_testb(const char *deb_file, unsigned int deb_line, ushort size, ushort pri) +deb_testb(const char *deb_file, unsigned int deb_line, ushort size, ushort pri) #else -int testb(ushort size, ushort pri) +testb(ushort size, ushort pri) #endif { mblk_t *p_msg; @@ -349,7 +351,8 @@ int testb(ushort size, ushort pri) * Class of the buffer? * We're using kmalloc instead of fixed tables, so this gets skipped. */ -int getclass(ushort size) +int +getclass(ushort size) { return 1; } @@ -361,10 +364,11 @@ int getclass(ushort size) * The read side gets a QREADR flag so OTHERQ knows what to do. */ +queue_t * #ifdef CONFIG_DEBUG_STREAMS -queue_t *deb_allocq(const char *deb_file, unsigned int deb_line) +deb_allocq(const char *deb_file, unsigned int deb_line) #else -queue_t *allocq(void) +allocq(void) #endif { queue_t *p_queue; @@ -391,10 +395,11 @@ queue_t *allocq(void) * * Frees a queue pair. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_freeq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +deb_freeq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -void freeq(queue_t *p_queue) +freeq(queue_t *p_queue) #endif { if(p_queue == NULL) { @@ -423,10 +428,11 @@ void freeq(queue_t *p_queue) * this is the place to add the appropriate dispose code. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_freemsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_freemsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -void freemsg(mblk_t *p_msg) +freemsg(mblk_t *p_msg) #endif { mblk_t *p_temp; @@ -452,10 +458,11 @@ void freemsg(mblk_t *p_msg) * the existing data; also increment the refcount. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_dupb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_dupb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *dupb(mblk_t *p_msg) +dupb(mblk_t *p_msg) #endif { mblk_t *p_newmsg; @@ -492,10 +499,11 @@ mblk_t *dupb(mblk_t *p_msg) * Duplicate a message. Walk through it with dupb(). */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_dupmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_dupmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *dupmsg(mblk_t *p_msg) +dupmsg(mblk_t *p_msg) #endif { mblk_t *p_head, *p_newmsg; @@ -529,10 +537,11 @@ mblk_t *dupmsg(mblk_t *p_msg) * of the block is _not_ preserved. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_copyb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_copyb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *copyb(mblk_t *p_msg) +copyb(mblk_t *p_msg) #endif { mblk_t *p_newmsg; @@ -565,10 +574,11 @@ mblk_t *copyb(mblk_t *p_msg) * Copy a message. Walk through it with dupb(). */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_copymsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_copymsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *copymsg(mblk_t *p_msg) +copymsg(mblk_t *p_msg) #endif { mblk_t *p_head, *p_newmsg; @@ -600,10 +610,11 @@ mblk_t *copymsg(mblk_t *p_msg) * Free space is preserved. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_copybufb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_copybufb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *copybufb(mblk_t *p_msg) +copybufb(mblk_t *p_msg) #endif { mblk_t *p_newmsg; @@ -637,10 +648,11 @@ mblk_t *copybufb(mblk_t *p_msg) * Copy a message with block alignment. Walk through it with copybufb(). */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_copybufmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_copybufmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -mblk_t *copybufmsg(mblk_t *p_msg) +copybufmsg(mblk_t *p_msg) #endif { mblk_t *p_head, *p_newmsg; @@ -666,25 +678,6 @@ mblk_t *copybufmsg(mblk_t *p_msg) } -/** - * linkb - * - * Link two messages. - * This procedure is misnamed and should be called linkmsg(). - * - * Inlined and moved to the header file. - */ - -/** - * unlinkb - * - * Unlink a message block from the head of a message. - * - * This code is rather useless because there's no advantage to grabbing the - * b_cont field and then either freeb()ing the head or clearing b_cont... - * unless it's inlined, that is. - */ - /** * rmvb * @@ -696,10 +689,11 @@ mblk_t *copybufmsg(mblk_t *p_msg) * block is in the message, you deserve to lose. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_rmvb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, mblk_t *p_block) +deb_rmvb(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, mblk_t *p_block) #else -mblk_t *rmvb(mblk_t *p_msg, mblk_t *p_block) +rmvb(mblk_t *p_msg, mblk_t *p_block) #endif { mblk_t *p_ret = p_msg; @@ -743,10 +737,11 @@ mblk_t *rmvb(mblk_t *p_msg, mblk_t *p_block) * This code is rather stupid. See pullupm() for how to do it better * (but not compatible). */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_pullupmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, short length) +deb_pullupmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, short length) #else -int pullupmsg(mblk_t *p_msg, short length) +pullupmsg(mblk_t *p_msg, short length) #endif { mblk_t *p_temp, *p_newmsg; @@ -828,10 +823,11 @@ int pullupmsg(mblk_t *p_msg, short length) * Actually, this is the same stupidity pullupmsg() engaged in, * but I didn't redo adjmsg() because I don't need it... */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_adjmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, short length) +deb_adjmsg(const char *deb_file, unsigned int deb_line, mblk_t *p_msg, short length) #else -int adjmsg(mblk_t *p_msg, short length) +adjmsg(mblk_t *p_msg, short length) #endif { mblk_t *p_temp = NULL; /* shut up GCC */ @@ -888,10 +884,11 @@ int adjmsg(mblk_t *p_msg, short length) * */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_xmsgsize(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_xmsgsize(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -int xmsgsize(mblk_t *p_msg) +xmsgsize(mblk_t *p_msg) #endif { unsigned char type; @@ -941,10 +938,11 @@ int xmsgsize(mblk_t *p_msg) * * Count size of data blocks. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_msgdsize(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) +deb_msgdsize(const char *deb_file, unsigned int deb_line, mblk_t *p_msg) #else -int msgdsize(mblk_t *p_msg) +msgdsize(mblk_t *p_msg) #endif { int bytes = 0; @@ -1013,9 +1011,11 @@ int msgdsize(mblk_t *p_msg) #ifdef CONFIG_DEBUG_STREAMS #define rmv_post(a,b) deb_rmv_post(deb_file,deb_line,a,b) -static inline void deb_rmv_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +static void +deb_rmv_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -static inline void rmv_post(queue_t *p_queue, mblk_t *p_msg) +static inline void +rmv_post(queue_t *p_queue, mblk_t *p_msg) #endif { mblk_t *p_tmp = p_msg; @@ -1084,9 +1084,11 @@ static inline void rmv_post(queue_t *p_queue, mblk_t *p_msg) #ifdef CONFIG_DEBUG_STREAMS #define put_post(a,b) deb_put_post(deb_file,deb_line,a,b) -static inline void deb_put_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +static void +deb_put_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -static inline void put_post(queue_t *p_queue, mblk_t *p_msg) +static inline void +put_post(queue_t *p_queue, mblk_t *p_msg) #endif { mblk_t *p_tmp = p_msg; @@ -1150,9 +1152,11 @@ static inline void put_post(queue_t *p_queue, mblk_t *p_msg) * - Enable back queue if QWANTW is set, i.e. if a back queue is full. */ #ifdef CONFIG_DEBUG_STREAMS -inline void deb_get_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +void +deb_get_post(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -inline void get_post(queue_t *p_queue) +inline void +get_post(queue_t *p_queue) #endif { if (p_queue->q_count<=p_queue->q_lowat && p_queue->q_flag&QWANTW) { @@ -1180,10 +1184,11 @@ inline void get_post(queue_t *p_queue) * - Adjust flow control. */ +mblk_t * #ifdef CONFIG_DEBUG_STREAMS -mblk_t *deb_getq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +deb_getq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -mblk_t *getq(queue_t *p_queue) +getq(queue_t *p_queue) #endif { mblk_t *p_msg; @@ -1256,10 +1261,11 @@ if(0)printf("%sG %s:%d ",KERN_ERR ,deb_file,deb_line); * The message must be on the queue. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_rmvq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +deb_rmvq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -void rmvq(queue_t *p_queue, mblk_t *p_msg) +rmvq(queue_t *p_queue, mblk_t *p_msg) #endif { unsigned long s; @@ -1328,10 +1334,11 @@ void rmvq(queue_t *p_queue, mblk_t *p_msg) * Restore flow control. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_flushq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, int flag) +deb_flushq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, int flag) #else -void flushq(queue_t *p_queue, int flag) +flushq(queue_t *p_queue, int flag) #endif { mblk_t *p_msg, *p_next; @@ -1391,10 +1398,11 @@ void flushq(queue_t *p_queue, int flag) * Reports if the queue is full and kicks the next available writer if it is. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_canput(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +deb_canput(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -int canput(queue_t *p_queue) +canput(queue_t *p_queue) #endif { if (p_queue == NULL) { @@ -1425,10 +1433,11 @@ if(0)printf("%sP %s:%d ",KERN_ERR ,deb_file,deb_line); * */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_putq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +deb_putq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -void putq(queue_t *p_queue, mblk_t *p_msg) +putq(queue_t *p_queue, mblk_t *p_msg) #endif { unsigned long s; @@ -1510,10 +1519,11 @@ if(0)printf("%sP %s:%d ",KERN_ERR ,deb_file,deb_line); * Put a message back onto its queue. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_putbq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +deb_putbq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -void putbq(queue_t *p_queue, mblk_t *p_msg) +putbq(queue_t *p_queue, mblk_t *p_msg) #endif { unsigned long s; @@ -1592,10 +1602,11 @@ void putbq(queue_t *p_queue, mblk_t *p_msg) * If NULL, insert at the end. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_insq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) +deb_insq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) #else -void insq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) +insq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) #endif { unsigned long s; @@ -1659,10 +1670,11 @@ void insq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) * if NULL, insert at the beginning. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_appq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) +deb_appq(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) #else -void appq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) +appq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) #endif { unsigned long s; @@ -1735,10 +1747,11 @@ void appq(queue_t *p_queue, mblk_t *p_oldmsg, mblk_t *p_msg) * * Create a zero-byte control message and put it onto a queue. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_putctl(const char *deb_file, unsigned int deb_line, queue_t *p_queue, uchar_t type) +deb_putctl(const char *deb_file, unsigned int deb_line, queue_t *p_queue, uchar_t type) #else -int putctl(queue_t *p_queue, uchar_t type) +putctl(queue_t *p_queue, uchar_t type) #endif { mblk_t *p_msg; @@ -1757,10 +1770,11 @@ int putctl(queue_t *p_queue, uchar_t type) * * Create a one-byte control message and put it onto a queue. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_putctl1(const char *deb_file, unsigned int deb_line, queue_t *p_queue, uchar_t type, streamchar param) +deb_putctl1(const char *deb_file, unsigned int deb_line, queue_t *p_queue, uchar_t type, streamchar param) #else -int putctl1(queue_t *p_queue, uchar_t type, streamchar param) +putctl1(queue_t *p_queue, uchar_t type, streamchar param) #endif { mblk_t *p_msg; @@ -1781,10 +1795,11 @@ int putctl1(queue_t *p_queue, uchar_t type, streamchar param) * Return the queue which feeds this one. */ +queue_t #ifdef CONFIG_DEBUG_STREAMS -queue_t *deb_backq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +*deb_backq(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -queue_t *backq(queue_t *p_queue) +*backq(queue_t *p_queue) #endif { if(p_queue == NULL) { @@ -1808,10 +1823,11 @@ queue_t *backq(queue_t *p_queue) * Send something in the "other" direction. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_qreply(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) +deb_qreply(const char *deb_file, unsigned int deb_line, queue_t *p_queue, mblk_t *p_msg) #else -void qreply(queue_t *p_queue, mblk_t *p_msg) +qreply(queue_t *p_queue, mblk_t *p_msg) #endif { if(p_msg == NULL) { @@ -1860,10 +1876,11 @@ void qreply(queue_t *p_queue, mblk_t *p_msg) * * return number of messages on queue */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_qsize(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +deb_qsize(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -int qsize(queue_t *p_queue) +qsize(queue_t *p_queue) #endif { int msgs = 0; @@ -1887,10 +1904,11 @@ int qsize(queue_t *p_queue) * * Set queue variables */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_setq (const char *deb_file, unsigned int deb_line, queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) +deb_setq (const char *deb_file, unsigned int deb_line, queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) #else -void setq (queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) +setq (queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) #endif { if(p_queue == NULL) { @@ -1927,10 +1945,11 @@ void setq (queue_t * p_queue, struct qinit *read_init, struct qinit *write_init) * Afterwards, unschedule the service procedures if necessary. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_qdetach (const char *deb_file, unsigned int deb_line, queue_t * p_queue, int do_close, int flag) +deb_qdetach (const char *deb_file, unsigned int deb_line, queue_t * p_queue, int do_close, int flag) #else -void qdetach (queue_t * p_queue, int do_close, int flag) +qdetach (queue_t * p_queue, int do_close, int flag) #endif { unsigned long s; @@ -2007,10 +2026,11 @@ void qdetach (queue_t * p_queue, int do_close, int flag) * driver/module. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_qattach (const char *deb_file, unsigned int deb_line, struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) +deb_qattach (const char *deb_file, unsigned int deb_line, struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) #else -int qattach (struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) +qattach (struct streamtab *qinfo, queue_t * p_queue, dev_t dev, int flag) #endif { queue_t *p_newqueue; @@ -2069,10 +2089,11 @@ printf("%sDriver %s opened\n",KERN_DEBUG ,p_newqueue->q_qinfo->qi_minfo->mi_idna * Schedule a queue. */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_qenable(const char *deb_file, unsigned int deb_line, queue_t *p_queue) +deb_qenable(const char *deb_file, unsigned int deb_line, queue_t *p_queue) #else -void qenable(queue_t *p_queue) +qenable(queue_t *p_queue) #endif { unsigned long s; @@ -2178,10 +2199,11 @@ qretry(queue_t *p_queue) * */ +void #ifdef CONFIG_DEBUG_STREAMS -void deb_runqueues(const char *deb_file, unsigned int deb_line) +deb_runqueues(const char *deb_file, unsigned int deb_line) #else -void runqueues(void) +runqueues(void) #endif { if(sched_first != NULL) { @@ -2194,10 +2216,12 @@ void runqueues(void) static void do_runqueues(void*); static int isrunning = 0; - if(isrunning) { + if(isrunning++) { + --isrunning; return; } do_runqueues(NULL); + --isrunning; #endif } } @@ -2210,7 +2234,8 @@ void runqueues(void) * Must not be reentered. (Guaranteed by Linux and by the above code.) */ -static void do_runqueues(void *dummy) +static void +do_runqueues(void *dummy) { queue_t *p_queue; unsigned long s; @@ -2272,7 +2297,8 @@ static void do_runqueues(void *dummy) const char *str__file; unsigned long str__line; -int deb_splstr(const char * deb_file, unsigned int deb_line) +int +deb_splstr(const char * deb_file, unsigned int deb_line) { if(bh_mask & (1<q_next->q_qinfo->qi_putp)(p_queue->q_next, p_msg); +} + +/** + * linkb + * + * Link two messages. + * This procedure is misnamed and should be called linkmsg(). + */ + +void +linkb(mblk_t *p_msg1, mblk_t *p_msg2) +{ + if(p_msg1 == NULL || p_msg2 == NULL) + return; + + while(p_msg1->b_cont != NULL) + p_msg1 = p_msg1->b_cont; + + p_msg1->b_cont = p_msg2; +} + +/** + * unlinkb + * + * Unlink a message block from the head of a message. + * + * Some people think this code is actually useful... + */ + +mblk_t * +unlinkb(mblk_t *p_msg) +{ + mblk_t *p_nextmsg; + + if(p_msg == NULL) + return NULL; + + p_nextmsg = p_msg->b_cont; + p_msg->b_cont = NULL; + return p_nextmsg; +} + +#endif /* CONFIG_DEBUG_STREAMS */ + /** * findmod * * Find a Streams module by name. */ +int #ifdef CONFIG_DEBUG_STREAMS -int deb_findmod(const char *deb_file, unsigned int deb_line, const char *name) +deb_findmod(const char *deb_file, unsigned int deb_line, const char *name) #else -int findmod(const char *name) +findmod(const char *name) #endif { int i, j; @@ -2358,7 +2437,9 @@ int findmod(const char *name) */ #ifdef __KERNEL__ struct streamtab *fstr_sw[MAX_STRDEV] = {NULL,}; -int register_strdev(unsigned int major, struct streamtab *strtab, int nminor) + +int +register_strdev(unsigned int major, struct streamtab *strtab, int nminor) { int err; int register_term_strdev(unsigned int major, const char *name, int nminor); @@ -2414,7 +2495,8 @@ int unregister_strdev (unsigned int major, struct streamtab *strtab, int nminor) struct fmodsw fmod_sw[MAX_STRMOD] = {{{0}}}; int fmodcnt = MAX_STRMOD; -int register_strmod(struct streamtab *strtab) +int +register_strmod(struct streamtab *strtab) { int fm; struct fmodsw *f; @@ -2438,7 +2520,8 @@ int register_strmod(struct streamtab *strtab) return -EBUSY; } -int unregister_strmod(struct streamtab *strtab) +int +unregister_strmod(struct streamtab *strtab) { int fm; struct fmodsw *f;