2001-01-05 15:49:52 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* i4btrc - device driver for trace data read device
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*
|
2003-10-03 20:38:44 +04:00
|
|
|
* $Id: i4b_trace.c,v 1.13 2003/10/03 16:38:44 pooka Exp $
|
2001-01-05 15:49:52 +03:00
|
|
|
*
|
|
|
|
* last edit-date: [Fri Jan 5 11:33:47 2001]
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2001-11-13 03:56:55 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-10-03 20:38:44 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: i4b_trace.c,v 1.13 2003/10/03 16:38:44 pooka Exp $");
|
2001-11-13 03:56:55 +03:00
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
#include "isdntrc.h"
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
#if NISDNTRC > 0
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#else
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
|
|
|
|
#include <netisdn/i4b_trace.h>
|
|
|
|
#include <netisdn/i4b_ioctl.h>
|
|
|
|
|
|
|
|
#include <netisdn/i4b_mbuf.h>
|
|
|
|
#include <netisdn/i4b_global.h>
|
2001-03-24 15:40:29 +03:00
|
|
|
#include <netisdn/i4b_debug.h>
|
2001-01-05 15:49:52 +03:00
|
|
|
#include <netisdn/i4b_l3l4.h>
|
2001-03-24 15:40:29 +03:00
|
|
|
#include <netisdn/i4b_l2.h>
|
2002-03-24 23:35:43 +03:00
|
|
|
#include <netisdn/i4b_l1l2.h>
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
static struct ifqueue trace_queue[NISDNTRC];
|
|
|
|
static int device_state[NISDNTRC];
|
2001-01-05 15:49:52 +03:00
|
|
|
#define ST_IDLE 0x00
|
|
|
|
#define ST_ISOPEN 0x01
|
|
|
|
#define ST_WAITDATA 0x02
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
static int analyzemode = 0; /* we are in anlyzer mode */
|
|
|
|
static int rxunit = -1; /* l2 isdnif of receiving driver */
|
|
|
|
static int txunit = -1; /* l2 isdnif of transmitting driver */
|
|
|
|
static int outunit = -1; /* output device for trace data */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
#define PDEVSTATIC /* - not static - */
|
2002-03-16 19:55:51 +03:00
|
|
|
void isdntrcattach __P((void));
|
|
|
|
int isdntrcopen __P((dev_t dev, int flag, int fmt, struct proc *p));
|
|
|
|
int isdntrcclose __P((dev_t dev, int flag, int fmt, struct proc *p));
|
|
|
|
int isdntrcread __P((dev_t dev, struct uio * uio, int ioflag));
|
|
|
|
int isdntrcioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p));
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
#ifdef __NetBSD__
|
|
|
|
const struct cdevsw isdntrc_cdevsw = {
|
|
|
|
isdntrcopen, isdntrcclose, isdntrcread, nowrite, isdntrcioctl,
|
2002-10-23 13:10:23 +04:00
|
|
|
nostop, notty, nopoll, nommap, nokqfilter,
|
2002-09-06 17:18:43 +04:00
|
|
|
};
|
|
|
|
#endif /* __NetBSD__ */
|
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* interface attach routine
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC void
|
|
|
|
#ifdef __FreeBSD__
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcattach(void *dummy)
|
2001-01-05 15:49:52 +03:00
|
|
|
#else
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcattach()
|
2001-01-05 15:49:52 +03:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
for(i=0; i < NISDNTRC; i++)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
#if __FreeBSD__ < 4
|
|
|
|
|
|
|
|
#ifdef DEVFS
|
|
|
|
devfs_token[i]
|
|
|
|
= devfs_add_devswf(&i4btrc_cdevsw, i, DV_CHR,
|
|
|
|
UID_ROOT, GID_WHEEL, 0600,
|
2002-03-16 19:55:51 +03:00
|
|
|
"isdntrc%d", i);
|
2001-01-05 15:49:52 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
make_dev(&i4btrc_cdevsw, i,
|
2002-03-16 19:55:51 +03:00
|
|
|
UID_ROOT, GID_WHEEL, 0600, "isdntrc%d", i);
|
2001-01-05 15:49:52 +03:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
trace_queue[i].ifq_maxlen = IFQ_MAXLEN;
|
|
|
|
device_state[i] = ST_IDLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
2001-03-24 15:40:29 +03:00
|
|
|
* isdn_layer2_trace_ind
|
|
|
|
* ---------------------
|
2001-01-05 15:49:52 +03:00
|
|
|
* is called from layer 1, adds timestamp to trace data and puts
|
|
|
|
* it into a queue, from which it can be read from the i4btrc
|
|
|
|
* device. The unit number in the trace header selects the minor
|
|
|
|
* device's queue the data is put into.
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int
|
2002-05-21 14:31:10 +04:00
|
|
|
isdn_layer2_trace_ind(struct l2_softc *sc, struct isdn_l3_driver *drv, i4b_trace_hdr *hdr, size_t len, unsigned char *buf)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
struct mbuf *m;
|
2003-10-03 20:38:44 +04:00
|
|
|
int isdnif, x;
|
2001-01-05 15:49:52 +03:00
|
|
|
int trunc = 0;
|
2001-03-24 15:40:29 +03:00
|
|
|
int totlen = len + sizeof(i4b_trace_hdr);
|
|
|
|
|
|
|
|
MICROTIME(hdr->time);
|
2003-10-03 20:38:44 +04:00
|
|
|
hdr->isdnif = sc->drv->isdnif;
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* for telephony (or better non-HDLC HSCX mode) we get
|
|
|
|
* (MCLBYTE + sizeof(i4b_trace_hdr_t)) length packets
|
|
|
|
* to put into the queue to userland. because of this
|
|
|
|
* we detect this situation, strip the length to MCLBYTES
|
|
|
|
* max size, and infor the userland program of this fact
|
|
|
|
* by putting the no of truncated bytes into hdr->trunc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(totlen > MCLBYTES)
|
|
|
|
{
|
|
|
|
trunc = 1;
|
|
|
|
hdr->trunc = totlen - MCLBYTES;
|
|
|
|
totlen = MCLBYTES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hdr->trunc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set length of trace record */
|
|
|
|
|
|
|
|
hdr->length = totlen;
|
|
|
|
|
2001-03-24 15:40:29 +03:00
|
|
|
/* check valid interface */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
if((isdnif = hdr->isdnif) > NISDNTRC)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
2003-10-03 20:38:44 +04:00
|
|
|
printf("i4b_trace: get_trace_data_from_l1 - isdnif > NISDNTRC!\n");
|
2001-01-05 15:49:52 +03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get mbuf */
|
|
|
|
|
|
|
|
if(!(m = i4b_Bgetmbuf(totlen)))
|
|
|
|
{
|
|
|
|
printf("i4b_trace: get_trace_data_from_l1 - i4b_getmbuf() failed!\n");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we are in analyzemode */
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
if(analyzemode && (isdnif == rxunit || isdnif == txunit))
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
2003-10-03 20:38:44 +04:00
|
|
|
if(isdnif == rxunit)
|
2001-01-05 15:49:52 +03:00
|
|
|
hdr->dir = FROM_NT;
|
|
|
|
else
|
|
|
|
hdr->dir = FROM_TE;
|
2003-10-03 20:38:44 +04:00
|
|
|
isdnif = outunit;
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
if(IF_QFULL(&trace_queue[isdnif]))
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
struct mbuf *m1;
|
|
|
|
|
2001-01-19 15:44:44 +03:00
|
|
|
x = splnet();
|
2003-10-03 20:38:44 +04:00
|
|
|
IF_DEQUEUE(&trace_queue[isdnif], m1);
|
2001-01-05 15:49:52 +03:00
|
|
|
splx(x);
|
|
|
|
|
|
|
|
i4b_Bfreembuf(m1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy trace header */
|
2001-03-24 15:40:29 +03:00
|
|
|
memcpy(m->m_data, hdr, sizeof(i4b_trace_hdr));
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
/* copy trace data */
|
|
|
|
if(trunc)
|
2001-03-24 15:40:29 +03:00
|
|
|
memcpy(&m->m_data[sizeof(i4b_trace_hdr)], buf, totlen-sizeof(i4b_trace_hdr));
|
2001-01-05 15:49:52 +03:00
|
|
|
else
|
2001-03-24 15:40:29 +03:00
|
|
|
memcpy(&m->m_data[sizeof(i4b_trace_hdr)], buf, len);
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2001-01-19 15:44:44 +03:00
|
|
|
x = splnet();
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
IF_ENQUEUE(&trace_queue[isdnif], m);
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
if(device_state[isdnif] & ST_WAITDATA)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
2003-10-03 20:38:44 +04:00
|
|
|
device_state[isdnif] &= ~ST_WAITDATA;
|
|
|
|
wakeup((caddr_t) &trace_queue[isdnif]);
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
splx(x);
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* open trace device
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC int
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcopen(dev_t dev, int flag, int fmt, struct proc *p)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int unit = minor(dev);
|
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
if(unit >= NISDNTRC)
|
2001-01-05 15:49:52 +03:00
|
|
|
return(ENXIO);
|
|
|
|
|
|
|
|
if(device_state[unit] & ST_ISOPEN)
|
|
|
|
return(EBUSY);
|
|
|
|
|
|
|
|
if(analyzemode && (unit == outunit || unit == rxunit || unit == txunit))
|
|
|
|
return(EBUSY);
|
2001-03-24 15:40:29 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2001-01-19 15:44:44 +03:00
|
|
|
x = splnet();
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
device_state[unit] = ST_ISOPEN;
|
|
|
|
|
|
|
|
splx(x);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* close trace device
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC int
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcclose(dev_t dev, int flag, int fmt, struct proc *p)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
2003-10-03 20:38:44 +04:00
|
|
|
int isdnif = minor(dev);
|
2001-03-24 15:40:29 +03:00
|
|
|
int x;
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
if (analyzemode && (isdnif == outunit)) {
|
2001-03-24 15:40:29 +03:00
|
|
|
l2_softc_t * rx_l2sc, * tx_l2sc;
|
2001-01-05 15:49:52 +03:00
|
|
|
analyzemode = 0;
|
|
|
|
outunit = -1;
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
rx_l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(rxunit);
|
|
|
|
tx_l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(txunit);
|
2001-03-24 15:40:29 +03:00
|
|
|
|
|
|
|
if (rx_l2sc != NULL)
|
2002-03-19 23:10:45 +03:00
|
|
|
rx_l2sc->driver->mph_command_req(rx_l2sc->l1_token, CMR_SETTRACE, TRACE_OFF);
|
2001-03-24 15:40:29 +03:00
|
|
|
if (tx_l2sc != NULL)
|
2002-03-19 23:10:45 +03:00
|
|
|
tx_l2sc->driver->mph_command_req(tx_l2sc->l1_token, CMR_SETTRACE, TRACE_OFF);
|
2001-03-24 15:40:29 +03:00
|
|
|
|
|
|
|
x = splnet();
|
|
|
|
device_state[rxunit] = ST_IDLE;
|
|
|
|
device_state[txunit] = ST_IDLE;
|
|
|
|
splx(x);
|
2001-01-05 15:49:52 +03:00
|
|
|
rxunit = -1;
|
|
|
|
txunit = -1;
|
2001-03-24 15:40:29 +03:00
|
|
|
} else {
|
2003-10-03 20:38:44 +04:00
|
|
|
l2_softc_t * l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(isdnif);
|
2001-03-24 15:40:29 +03:00
|
|
|
if (l2sc != NULL) {
|
2002-03-19 23:10:45 +03:00
|
|
|
l2sc->driver->mph_command_req(l2sc->l1_token, CMR_SETTRACE, TRACE_OFF);
|
2001-03-24 15:40:29 +03:00
|
|
|
x = splnet();
|
2003-10-03 20:38:44 +04:00
|
|
|
device_state[isdnif] = ST_IDLE;
|
2001-03-24 15:40:29 +03:00
|
|
|
splx(x);
|
|
|
|
}
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* read from trace device
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC int
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcread(dev_t dev, struct uio * uio, int ioflag)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
int x;
|
|
|
|
int error = 0;
|
|
|
|
int unit = minor(dev);
|
|
|
|
|
|
|
|
if(!(device_state[unit] & ST_ISOPEN))
|
|
|
|
return(EIO);
|
|
|
|
|
2001-01-19 15:44:44 +03:00
|
|
|
x = splnet();
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
while(IF_QEMPTY(&trace_queue[unit]) && (device_state[unit] & ST_ISOPEN))
|
|
|
|
{
|
|
|
|
device_state[unit] |= ST_WAITDATA;
|
|
|
|
|
|
|
|
if((error = tsleep((caddr_t) &trace_queue[unit],
|
|
|
|
TTIPRI | PCATCH,
|
|
|
|
"bitrc", 0 )) != 0)
|
|
|
|
{
|
|
|
|
device_state[unit] &= ~ST_WAITDATA;
|
|
|
|
splx(x);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IF_DEQUEUE(&trace_queue[unit], m);
|
|
|
|
|
|
|
|
if(m && m->m_len)
|
|
|
|
error = uiomove(m->m_data, m->m_len, uio);
|
|
|
|
else
|
|
|
|
error = EIO;
|
|
|
|
|
|
|
|
if(m)
|
|
|
|
i4b_Bfreembuf(m);
|
|
|
|
|
|
|
|
splx(x);
|
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(__FreeBSD__) && defined(OS_USES_POLL)
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* poll device
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC int
|
|
|
|
i4btrcpoll(dev_t dev, int events, struct proc *p)
|
|
|
|
{
|
|
|
|
return(ENODEV);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* device driver ioctl routine
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
PDEVSTATIC int
|
2002-03-16 19:55:51 +03:00
|
|
|
isdntrcioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
int error = 0;
|
2003-10-03 20:38:44 +04:00
|
|
|
int isdnif = minor(dev);
|
2001-01-05 15:49:52 +03:00
|
|
|
i4b_trace_setupa_t *tsa;
|
2003-10-03 20:38:44 +04:00
|
|
|
l2_softc_t * l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(isdnif);
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
switch(cmd)
|
|
|
|
{
|
|
|
|
case I4B_TRC_SET:
|
2001-03-24 15:40:29 +03:00
|
|
|
if (l2sc == NULL)
|
2001-01-05 15:49:52 +03:00
|
|
|
return ENOTTY;
|
2002-03-19 23:10:45 +03:00
|
|
|
l2sc->driver->mph_command_req(l2sc->l1_token, CMR_SETTRACE, (void *)*(unsigned long *)data);
|
2001-01-05 15:49:52 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case I4B_TRC_SETA:
|
|
|
|
tsa = (i4b_trace_setupa_t *)data;
|
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
if(tsa->rxunit >= 0 && tsa->rxunit < NISDNTRC)
|
2001-01-05 15:49:52 +03:00
|
|
|
rxunit = tsa->rxunit;
|
|
|
|
else
|
|
|
|
error = EINVAL;
|
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
if(tsa->txunit >= 0 && tsa->txunit < NISDNTRC)
|
2001-01-05 15:49:52 +03:00
|
|
|
txunit = tsa->txunit;
|
|
|
|
else
|
|
|
|
error = EINVAL;
|
|
|
|
|
|
|
|
if(error)
|
|
|
|
{
|
|
|
|
outunit = -1;
|
|
|
|
rxunit = -1;
|
|
|
|
txunit = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-24 15:40:29 +03:00
|
|
|
l2_softc_t * rx_l2sc, * tx_l2sc;
|
2003-10-03 20:38:44 +04:00
|
|
|
rx_l2sc = (l2_softc_t*)(l2_softc_t*)isdn_find_softc_by_isdnif(rxunit);
|
|
|
|
tx_l2sc = (l2_softc_t*)(l2_softc_t*)isdn_find_softc_by_isdnif(txunit);
|
2001-03-24 15:40:29 +03:00
|
|
|
|
|
|
|
if (l2sc == NULL || rx_l2sc == NULL || tx_l2sc == NULL)
|
2001-01-05 15:49:52 +03:00
|
|
|
return ENOTTY;
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
outunit = isdnif;
|
2001-01-05 15:49:52 +03:00
|
|
|
analyzemode = 1;
|
2002-03-19 23:10:45 +03:00
|
|
|
rx_l2sc->driver->mph_command_req(rx_l2sc->l1_token, CMR_SETTRACE, (void *)(unsigned long)(tsa->rxflags & (TRACE_I | TRACE_D_RX | TRACE_B_RX)));
|
|
|
|
tx_l2sc->driver->mph_command_req(tx_l2sc->l1_token, CMR_SETTRACE, (void *)(unsigned long)(tsa->txflags & (TRACE_I | TRACE_D_RX | TRACE_B_RX)));
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case I4B_TRC_RESETA:
|
|
|
|
analyzemode = 0;
|
|
|
|
outunit = -1;
|
|
|
|
rxunit = -1;
|
|
|
|
txunit = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = ENOTTY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
2002-03-16 19:55:51 +03:00
|
|
|
#endif /* NISDNTRC > 0 */
|