/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "socket.h" #ifndef sun #include #endif #include #include /* * log ioctl requests in a human readable form. Requests appear as * they are defined in sys/ioctl.h, i.e. as the following example * shows: * * _IOR('T', 1, 18) * * is output for the call defined in sys/termio.h: * * #define TCGETA _IOR('T', 1, struct termio) */ #ifdef hpux # define IOC_DIRMASK (~(IOCSIZE_MASK|IOCCMD_MASK)) # define IOC_INOUT (IOC_IN|IOC_OUT) # define IOCGROUP(x) (((x)&IOCCMD_MASK)>>8) # define IOCPARM_LEN(x) (((x)&IOCSIZE_MASK)>>16) #define IOCCMD(x) ((x)&0xff) #define BUF_SIZE 1024 void logioctl(int pri, const char* msg, u_long cmd) { char iocmdbuf[BUF_SIZE] = ""; switch( cmd & IOC_DIRMASK ) { case IOC_INOUT: strcat(iocmdbuf,"_IOWR"); break; case IOC_IN: strcat(iocmdbuf,"_IOW"); break; case IOC_OUT: strcat(iocmdbuf,"_IOR"); break; case IOC_VOID: strcat(iocmdbuf,"_IO"); break; } sprintf(iocmdbuf + strlen(iocmdbuf), "('%c', %ld", (char)IOCGROUP(cmd), IOCCMD(cmd)); switch( cmd & IOC_DIRMASK ) { case IOC_INOUT: case IOC_IN: case IOC_OUT: sprintf(iocmdbuf + strlen(iocmdbuf), ", %ld", IOCPARM_LEN(cmd)); break; } strcat(iocmdbuf,")"); syslog(pri, "%s: ioctl request: %s", msg, iocmdbuf); } bool istermios(u_long cmd) { return IOCGROUP(cmd) == 'T'; } void logtermios(int pri, const char *msg, struct termios *tio) { syslog(pri, "%s: termios: " "i(0x%04hx) o(0x%04hx) c(0x%04hx) l(0x%04hx) ln(0x%04hx)", msg, tio->c_iflag, tio->c_oflag, tio->c_cflag, tio->c_lflag, tio->c_reserved); } #endif