/*---------------------------------------------------------------------------* * close trace device *---------------------------------------------------------------------------*/ PDEVSTATIC int isdntrcclose(dev_t dev, int flag, int fmt, struct lwp *l) { int isdnif = minor(dev); int x; if (analyzemode && (isdnif == outunit)) { l2_softc_t * rx_l2sc, * tx_l2sc; analyzemode = 0; outunit = -1; rx_l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(rxunit); tx_l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(txunit); if (rx_l2sc != NULL) rx_l2sc->driver->mph_command_req(rx_l2sc->l1_token, CMR_SETTRACE, TRACE_OFF); if (tx_l2sc != NULL) tx_l2sc->driver->mph_command_req(tx_l2sc->l1_token, CMR_SETTRACE, TRACE_OFF); x = splnet(); device_state[rxunit] = ST_IDLE; device_state[txunit] = ST_IDLE; splx(x); rxunit = -1; txunit = -1; } else { l2_softc_t * l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(isdnif); if (l2sc != NULL) { l2sc->driver->mph_command_req(l2sc->l1_token, CMR_SETTRACE, TRACE_OFF); x = splnet(); device_state[isdnif] = ST_IDLE; splx(x); } } return(0); }
/*---------------------------------------------------------------------------* * i4bctlioctl - device driver ioctl routine *---------------------------------------------------------------------------*/ PDEVSTATIC int isdnctlioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { #if DO_I4B_DEBUG ctl_debug_t *cdbg; int error = 0; #endif #if !DO_I4B_DEBUG return(ENODEV); #else if(minor(dev)) return(ENODEV); switch(cmd) { case I4B_CTL_GET_DEBUG: cdbg = (ctl_debug_t *)data; cdbg->l1 = i4b_l1_debug; cdbg->l2 = i4b_l2_debug; cdbg->l3 = i4b_l3_debug; cdbg->l4 = i4b_l4_debug; break; case I4B_CTL_SET_DEBUG: cdbg = (ctl_debug_t *)data; i4b_l1_debug = cdbg->l1; i4b_l2_debug = cdbg->l2; i4b_l3_debug = cdbg->l3; i4b_l4_debug = cdbg->l4; break; case I4B_CTL_GET_CHIPSTAT: { struct chipstat *cst; l2_softc_t * scl2; cst = (struct chipstat *)data; scl2 = (l2_softc_t*)isdn_find_softc_by_isdnif(cst->driver_unit); scl2->driver->mph_command_req(scl2->l1_token, CMR_GCST, cst); break; } case I4B_CTL_CLR_CHIPSTAT: { struct chipstat *cst; l2_softc_t * scl2; cst = (struct chipstat *)data; scl2 = (l2_softc_t*)isdn_find_softc_by_isdnif(cst->driver_unit); scl2->driver->mph_command_req(scl2->l1_token, CMR_CCST, cst); break; } case I4B_CTL_GET_LAPDSTAT: { l2stat_t *l2s; l2_softc_t *sc; l2s = (l2stat_t *)data; sc = (l2_softc_t*)isdn_find_softc_by_isdnif(l2s->unit); if (sc == NULL) { error = EINVAL; break; } memcpy(&l2s->lapdstat, &sc->stat, sizeof(lapdstat_t)); break; } case I4B_CTL_CLR_LAPDSTAT: { int *up; l2_softc_t *sc; up = (int *)data; sc = (l2_softc_t*)isdn_find_softc_by_isdnif(*up); if (sc == NULL) { error = EINVAL; break; } memset(&sc->stat, 0, sizeof(lapdstat_t)); break; } default: error = ENOTTY; break; } return(error); #endif /* DO_I4B_DEBUG */ }
/*---------------------------------------------------------------------------* * device driver ioctl routine *---------------------------------------------------------------------------*/ PDEVSTATIC int isdntrcioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { int error = 0; int isdnif = minor(dev); i4b_trace_setupa_t *tsa; l2_softc_t * l2sc = (l2_softc_t*)isdn_find_softc_by_isdnif(isdnif); switch(cmd) { case I4B_TRC_SET: if (l2sc == NULL) return ENOTTY; l2sc->driver->mph_command_req(l2sc->l1_token, CMR_SETTRACE, (void *)*(unsigned long *)data); break; case I4B_TRC_SETA: tsa = (i4b_trace_setupa_t *)data; if(tsa->rxunit >= 0 && tsa->rxunit < NISDNTRC) rxunit = tsa->rxunit; else error = EINVAL; if(tsa->txunit >= 0 && tsa->txunit < NISDNTRC) txunit = tsa->txunit; else error = EINVAL; if(error) { outunit = -1; rxunit = -1; txunit = -1; } else { l2_softc_t * rx_l2sc, * tx_l2sc; 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); if (l2sc == NULL || rx_l2sc == NULL || tx_l2sc == NULL) return ENOTTY; outunit = isdnif; analyzemode = 1; 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))); } break; case I4B_TRC_RESETA: analyzemode = 0; outunit = -1; rxunit = -1; txunit = -1; break; default: error = ENOTTY; break; } return(error); }