[Asterisk-bsd] possible bug, only first E1 span seems to be initializing in wct4xxp.ko driver

Dinesh Nair dinesh at alphaque.com
Tue Oct 18 07:56:30 CDT 2005


asterisk folk,

as the self-appointed maintainer for the freebsd 4.x branch of the zaptel 
drivers, i was looking through the code to figure out a possible bug which 
was disturbing me the last few days in connecting to an ericsson md110. the 
offending code in question is,

	for (x=0;x<sc->numspans;x++) {
		if (sc->t1e1 & (1 << x)) { /* WHY BITSHIFT x ? */
			sc->tspans[x] = malloc(sizeof(struct t4_span) + sizeof(struct zt_chan) * 
31, M_TDM, M_NOWAIT);
			if (sc->tspans[x]) {
				memset(sc->tspans[x], 0, sizeof(struct t4_span) + sizeof(struct 
zt_chan) * 31);
				sc->tspans[x]->spantype = TYPE_E1;
			}
	
	    	} else {
			sc->tspans[x] = malloc(sizeof(struct t4_span) + sizeof(struct zt_chan) * 
24, M_TDM, M_NOWAIT);
			if (sc->tspans[x]) {
				memset(sc->tspans[x], 0, sizeof(struct t4_span) + sizeof(struct 
zt_chan) * 24);
				if (j1mode)
					sc->tspans[x]->spantype = TYPE_J1;
				else
					sc->tspans[x]->spantype = TYPE_T1;
			}

	    	}
		if (!sc->tspans[x])
			return ENOMEM;
		sc->tspans[x]->spanflags |= flags;
	}

which occurs both in t4_init_one() and t1e1_sysctl() in the freebsd driver 
version of wct4xxp.c

look at the comment /* WHY BITSHIFT x ? */, and you'd see that the if() 
block is only executed when x==0 if t1e1=1 (as it should be if E1 is 
selected). hence, for subsequent spans, the else block will be executed 
which would set the spans for T1 (or J1, depending on j1mode) behaviour. 
the behaviour seems to be correct if t1e1=0, i.e it sets all spans as 
either T1 or J1.

i havent yet tested the code with the (1<<x) removed on a live E1, but 
before i did, i wondered if there was a reason for the bitshift and if this 
is really broken behaviour ?

additionally, this also occurs in the freebsd 5.x drivers. could someone 
let me know if this occurs within the cvs zaptel linux sources from digium 
as well ?

-- 
Regards,                           /\_/\   "All dogs go to heaven."
dinesh at alphaque.com                (0 0)    http://www.alphaque.com/
+==========================----oOO--(_)--OOo----==========================+
| for a in past present future; do                                        |
|   for b in clients employers associates relatives neighbours pets; do   |
|   echo "The opinions here in no way reflect the opinions of my $a $b."  |
| done; done                                                              |
+=========================================================================+


More information about the Asterisk-BSD mailing list