irda-utils-0.9.18/0000755000175000017500000000000010454641046013230 5ustar samuelsamuelirda-utils-0.9.18/Makefile0000644000175000017500000000305210454641046014670 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for Linux IrDA Manager ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Tue Jan 25 09:54:38 2000 ## Modified by: Dag Brattli ## ## $Id: Makefile 116 2006-02-28 22:33:43Z sambau $ ## ## Copyright (c) 1998-2000 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include output.mak TARGET = test DIRS = irattach irdaping etc man irnetd psion tekram findchip irdadump smcinit CFLAGS= -O2 -W -Wall all: @-(set -e ; for d in $(DIRS) ; do $(MAKE) $(MAKE_OUTPUT) -C $$d $@ ; done) install: @-(set -e ; for d in $(DIRS) ; do $(MAKE) $(MAKE_OUTPUT) -C $$d $@ ; done) clean: $(prn_clean) @-(set -e ; for d in $(DIRS) ; do $(MAKE) $(MAKE_OUTPUT) -C $$d $@ ; done) distclean: $(prn_distclean) @-(set -e ; for d in $(DIRS) ; do $(MAKE) $(MAKE_OUTPUT) -C $$d $@ ; done) irda-utils-0.9.18/README0000644000175000017500000000511710454641046014114 0ustar samuelsamuelIrDA Utilities Dag Brattli Abstract The IrDA Utils package is a collection of programs, that enables the use of the IrDA protocols. Some user-space configuration is required in order to make IrDA work for your machine, and some IrDA features like IrOBEX is actually implemented in user-space. 1 Introduction IrDA is an exciting way of communicating with remote devices. IrDA uses infrared wireless communication so no cables are required. Speeds range from 9600bps to 4Mbps. The types of devices that support IrDA are LAN adapters, PDA's, printers, laptops, mobile phones etc. Linux-IrDA is a GNU implementation of the IrDA protocols specifications written from scratch. Linux-IrDA supports most of the IrDA protocols like IrLAP, IrLMP, IrIAP, IrTTP, IrLPT, IrLAN, IrCOMM and IrOBEX. Most of the features are implemented in the kernel, so you must enable IrDA support in the kernel before you can use any of the tools and programs mentioned in this document. 2 Getting started First of all you need to install the tools in this package. Make and make install should do that for you. By default it will install the files in /etc/irda, and in /usr/sbin. If you don't like that, you should edit the makefile. 2.2 irattach irattach uses the irtty module which connects to the Linux TTY and serial driver. This works well for most machines, but limits the speed to 115200bps (IrDA SIR mode). If you want higher speeds, you must use a special device driver for the IrDA chipset used by your machine. Currently there are not that many device drivers implemented, mostly because it's very hard to get the documentation, and the drivers are in fact quite hard to implement even if you are lucky and get the documentation for the chipset. If you are one of the lucky people which have a chipset that is supported, then you don't need to use irattach anymore. Now you just have to insmod the driver like this: For more info, please read irattach/README 3 Other programs irdadump Is a program that displays all the frames sent, and received on the infrared link. irdaping Makes it possible to try and ping a remote device using IrDA test frames. Not all devices implements support for test frames. irkbd Implements support for the mouse and keyboard protocol as used by the Tekram IR-660 infrared docking station. findchip Tries to find out which IrDA chipset your machine is using. Try out "./findchip -v" to check it out. irsockets A collections of programs which uses IrDA sockets. psion File transfer program for exchanging files with your Psion PDA Have fun! irda-utils-0.9.18/etc/0000755000175000017500000000000010454641161014001 5ustar samuelsamuelirda-utils-0.9.18/etc/modules.conf.irda0000644000175000017500000000247010454641046017243 0ustar samuelsamuel# IrDA configuration # IrDA over a normal serial port, or a serial port compatible IrDA port alias tty-ldisc-11 irtty # IrCOMM/IrLPT support (virtual serial/parallel over IrDA) alias char-major-161 ircomm-tty # Official allocation of IrCOMM # IrLAN support (Ethernet over IrDA) alias irlan0 irlan # IrNET support (Synchronous PPP over IrDA) alias char-major-10-187 irnet # Official allocation of IrNET # Serial Dongles # These values are hard-coded in irattach (not instance order) alias irda-dongle-0 tekram # Tekram IrMate IR-210B alias irda-dongle-1 esi # ESI JetEye alias irda-dongle-2 actisys # Actisys IR-220L alias irda-dongle-3 actisys # Actisys IR-220L+ alias irda-dongle-4 girbil # Greenwich GIrBIL alias irda-dongle-5 litelink # Parallax LiteLink (+ modern ESI) alias irda-dongle-6 airport # Adaptec Airport 1000 and 2000 alias irda-dongle-7 old_belkin # Old Belkin (9600 baud only) alias irda-dongle-8 ep7211 # ??? alias irda-dongle-9 mcp2120 # Crystal compatible chipset # To use the NSC driver on a Thinkpad laptop #alias irda0 nsc-ircc #options nsc-ircc dongle_id=0x09 # To use the NSC driver on a HP OB6000 laptop #alias irda0 nsc-ircc #options nsc-ircc dongle_id=0x08 # SMC driver #alias irda0 smc-ircc irda-utils-0.9.18/etc/irda.sysconfig0000755000175000017500000000007210454641046016652 0ustar samuelsamuelIRDA=yes DEVICE=/dev/ttyS2 #DONGLE=actisys+ DISCOVERY=yes irda-utils-0.9.18/etc/install-etc0000755000175000017500000000044710454641046016155 0ustar samuelsamuel#!/bin/sh # Only install on SYSV for now if [ -d /etc/sysconfig/ ]; then install -D irda.sysconfig $ROOT/etc/sysconfig/irda install -D ifcfg-irlan0 $ROOT/etc/sysconfig/network-scripts/ifcfg-irlan0 fi if [ -d /etc/rc.d/init.d ]; then install -D irda.rc $ROOT/etc/rc.d/init.d/irda fi irda-utils-0.9.18/etc/ifcfg-irlan00000755000175000017500000000010710454641046016170 0ustar samuelsamuelDEVICE=irlan0 BOOTPROTO=dhcp IPADDR="" NETMASK=255.255.255.0 ONBOOT=no irda-utils-0.9.18/etc/irda.rc0000755000175000017500000000200210454641046015245 0ustar samuelsamuel#!/bin/sh # # irda This shell script takes care of starting and stopping # IrDA support # # chkconfig: 2345 45 96 # # description: IrDA stack for Linux # # Source function library. . /etc/rc.d/init.d/functions # Source IrDA networking configuration. . /etc/sysconfig/irda # Check that irda is up. [ ${IRDA} = "no" ] && exit 0 [ -f /usr/sbin/irattach ] || exit 0 ARGS= if [ $DONGLE ]; then ARGS="$ARGS -d $DONGLE" fi if [ "$DISCOVERY" = "yes" ];then ARGS="$ARGS -s" fi # See how we were called. case "$1" in start) # Attach irda device echo -n "Starting IrDA: " daemon /usr/sbin/irattach ${DEVICE} ${ARGS} touch /var/lock/subsys/irda echo ;; stop) # Stop service. echo -n "Shutting down IrDA: " killproc irattach rm -f /var/lock/subsys/irda echo ;; status) status irattach ;; restart|reload) $0 stop $0 start ;; *) echo "Usage: irda {start|stop|restart|reload|status}" exit 1 esac exit 0 irda-utils-0.9.18/etc/network.opts0000644000175000017500000000220110454641046016376 0ustar samuelsamuel# Network adapter configuration # # The address format is "scheme,socket,instance,hwaddr". # # Note: the "network address" here is NOT the same as the IP address. # See the Networking HOWTO. In short, the network address is the IP # address masked by the netmask. # case "$ADDRESS" in *,*,*,*) # Transceiver selection, for cards that need it -- see 'man ifport' IF_PORT="" # Use BOOTP [y/n] BOOTP="n" # IP address IPADDR="" # Netmask NETMASK="255.255.255.0" # Network address NETWORK="1.2.0.0" # Broadcast address BROADCAST="1.2.255.255" # Gateway address GATEWAY="1.2.0.1" # Domain name DOMAIN="stanford.edu" # Nameserver #1 DNS_1="" # Nameserver #2 DNS_2="" # Nameserver #3 DNS_3="" # NFS mounts, should be listed in /etc/fstab MOUNTS="" # For IPX interfaces, the frame type (i.e., 802.2) IPX_FRAME="" # For IPX interfaces, the network number IPX_NETNUM="" # Extra stuff to do after setting up the interface start_fn () { return; } # Extra stuff to do before shutting down the interface stop_fn () { return; } ;; esac irda-utils-0.9.18/etc/Makefile0000644000175000017500000000033610454641046015445 0ustar samuelsamuelinclude ../output.mak CC = gcc $(RPM_OPT_FLAGS) LD = ld RM = rm -f RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a all: etc: all clean: $(RM_CMD) distclean: $(RM_CMD) install: etc $(prn_install) @./install-etc $(ROOT) irda-utils-0.9.18/ethereal/0000755000175000017500000000000010454641161015017 5ustar samuelsamuelirda-utils-0.9.18/ethereal/README0000644000175000017500000000331010454641046015676 0ustar samuelsamuel Ethereal capture ---------------- You can now use Ethereal to display your IrDA traces, so you can do traffic analysis from a GUI. This is still experimental and is a work in progress. There is basically two possibilities : 1) Read from capture files 2) Read from live IrDA interface 1) Packages ----------- You will need those packages 1) ethereal-0.10.1 or later 2) irda-utils 0.9.17-pre2 or later 3) libpcap-0.8.2 or later Note : until those packages are released, just grab the latest CVS version... 2) Capture file method ---------------------- 1) Start generate a capture file using "irdadump -w file.dump" 2) Stop capture with CTRL-C 3) Start Ethereal 4) Open the capture file (File->Open) 3) Live IrDA interface method ----------------------------- 1) Start Ethereal 2) Open capture window (Capture->Start) 3) Select IrDA interface (for example 'irda0') 4) Check "Update list of packets in real time" box 5) Start capture on IrDA interface 4) Ethereal IrDA parsing ------------------------ The current IrDA parsing done by Ethereal is quite different from what is available in irdadump because not based on the same codebase. Decoding output looks very different and fields don't have the same name. Some higher layer protocols are not parsed by Ethereal, for example Obex and IrNET. On the other hand, Ethereal gives more details in some of the fields. 5) Extra -------- Thanks to Shaun Jackman and Jan Kiszka for the initial work, I did heavily modified their code to make it "clean". Thanks to Guy Harris for integrating our code in libpcap and Ethereal. I won't be maintaining the Ethereal code, so all questions and patches should be addressed to Jan Kiszka. Have fun... Jean II 16.1.04 irda-utils-0.9.18/findchip/0000755000175000017500000000000010454641161015012 5ustar samuelsamuelirda-utils-0.9.18/findchip/winbond.c0000644000175000017500000003205210454641046016622 0ustar samuelsamuel/********************************************************************* * * Filename: winbond.c * Version: 0.1 * Description: Hardware probe for Winbond infrared controllers * Status: Experimental. * Author: Takahide Higuchi * Created at: Tue Jan 18 00:23:00 2000 * Modified at: Tue Jan 18 00:35:04 2000 * Modified by: Takahide Higuchi * * Copyright (c) 2000 Takahide Higuchi, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include "findchip.h" #define MANUFACTURER "WINBOND" #define CR07 0x07 #define CR09 0x09 #define CR0B 0x0B #define CR0C 0x0C #define CR0D 0x0D #define CR16 0x16 #define CR20 0x20 #define CR21 0x21 #define CR25 0x25 #define CR26 0x26 #define CR28 0x28 #define CR2A 0x2A #define CR2C 0x2C #define CR60 0x60 #define CR61 0x61 #define CR70 0x70 #define CR74 0x74 #define CR75 0x75 #define CRF0 0xF0 #define W83977_DEVICE_ID 0x97 /* bitmasks */ #define W83877_HEFRAS_MASK 0x01 #define W83877_HEFERE_MASK 0x20 #define W83977_HEFRAS_MASK 0x40 #define CHIPID 0x0F #define IRTXDRQSEL 0xF0 #define IRRXDRQSEL 0x0F #define URBIQS 0x0F #define URBAD 0xFE #define TXW4C 0x40 #define RXW4C 0x20 #define RXW4C_977 0x08 #define TXW4C_977 0x04 #define ENBKIRSL 0x10 #define URIRSEL 0x08 #define HDUPLX 0x08 #define IRMODE 0x07 #define ENBNKSEL 0x08 #define ENBNKSEL_977 0x01 /* indexs */ #define W83877_HEFRAS_INDEX CR16 #define W83877_HEFERE_INDEX CR0C #define W83977_HEFRAS_INDEX CR26 #define NOT_EXIST -1 enum { FIR_SUPPORT, NO_FIR_SUPPORT, }; enum { W83977_PNP, /* not implemented yet : W83977 chip will be Comply-PNP mode if PIN #51 (~DTRB) is pulled up */ W83977, /* compatible-PNP mode */ W83877, }; struct winbond_chip { char *name; int chip_id; /* Device Rev (CR21) for 83977s, CHIP ID (CR09) for 83877s */ int fir_support; /* SUPPORT_FIR or 0 */ }; struct winbond_efer { int chip_type; /* W83877 , W83977 or W83977_PNP */ int efer_addr; /* address of Extended Function Enable Register */ int writes; /* write start_flag to EFER "writes" times */ int start_flag; int end_flag; /* finally write it to EFER */ int efir_addr; /* Extended Function Index Reg. */ int efdr_addr; /* Extended Function Data Reg. */ int hefras_index; /* Register index of HEFERE bit */ int hefras_mask; /* bitmask for HEFERE */ int hefras; /* HEFRAS bit should be (1 or 0) */ /* if hefere_index == -1, HEFERE will be ignored */ int hefere_index; /* Register index of HEFERE bit */ int hefere_mask; /* bitmask for HEFERE */ int hefere; /* HEFERE bit should be (1 or 0) */ }; typedef struct winbond_chip winbond_chip_t; typedef struct winbond_efer winbond_efer_t; static winbond_chip_t chips[] = { { "W83977TF", 0x73, NO_FIR_SUPPORT}, { "W83977ATF", 0x74, FIR_SUPPORT}, { "W83877AF", 0x0b, FIR_SUPPORT}, { "W83877TF", 0x0c, NO_FIR_SUPPORT}, { "W83877ATF", 0x0d, FIR_SUPPORT}, /* Entries below here are not well confirmed. if you have one of these chips, please mail me an output of "findchip -d -v WINBOND". */ /* { "W83977F/AF", 0x71, FIR_SUPPORT }, */ /* { "W83877F", 0x0a, NO_FIR_SUPPORT}, */ { NULL } }; static winbond_efer_t efers[] = { { W83977, 0x3F0, 2, 0x87 ,0xAA, 0x3F0, 0x3F1, W83977_HEFRAS_INDEX, W83977_HEFRAS_MASK, 0, NOT_EXIST, 0 ,0 }, { W83977, 0x370, 2, 0x87 ,0xAA, 0x370, 0x371, W83977_HEFRAS_INDEX, W83977_HEFRAS_MASK, 1, NOT_EXIST, 0 ,0 }, { W83877, 0x250, 1, 0x88 ,0x88, 0x251, 0x252, W83877_HEFRAS_INDEX, W83877_HEFRAS_MASK, 0, W83877_HEFERE_INDEX, W83877_HEFERE_MASK, 0 }, { W83877, 0x250, 1, 0x89 ,0x89, 0x251, 0x252, W83877_HEFRAS_INDEX, W83877_HEFRAS_MASK, 0, W83877_HEFERE_INDEX, W83877_HEFERE_MASK, 1 }, { W83877, 0x3F0, 2, 0x86 ,0xAA, 0x3F0, 0x3F1, W83877_HEFRAS_INDEX, W83877_HEFRAS_MASK, 1, W83877_HEFERE_INDEX, W83877_HEFERE_MASK, 0 }, { W83877, 0x3F0, 2, 0x87 ,0xAA, 0x3F0, 0x3F1, W83877_HEFRAS_INDEX, W83877_HEFRAS_MASK, 1, W83877_HEFERE_INDEX, W83877_HEFERE_MASK, 1 }, { 0 } }; /* * Function w83977_read_info() * * if Chip ID is valid, return non-zero * */ int w83977_read_info(winbond_efer_t *eferinfo) { struct chip_info info; winbond_chip_t *chipinfo; int rxdma, txdma, devid, revision, misc; devid = 0; outb( CR20, eferinfo->efir_addr); devid = (inb(eferinfo->efdr_addr)); outb( CR21, eferinfo->efir_addr); revision = (inb(eferinfo->efdr_addr)); DEBUG("chip id = 0x%02x, revision = 0x%02x\n", devid, revision); if(devid != W83977_DEVICE_ID) { DEBUG("Wrong device ID = 0x%02x\n", devid); return 0; } for(chipinfo = chips; chipinfo->name; chipinfo++){ if (revision == chipinfo->chip_id) break; } if(chipinfo->name == NULL){ DEBUG("Device Revision is 0x%02x :" "no known chip was detected.\n", revision); return 0; } info.chip_id = devid; info.revision = revision; DEBUG("Device Revision 0x%02x : %s is detected!\n", info.chip_id, chipinfo->name); if(chipinfo->fir_support != FIR_SUPPORT) DEBUG("this chip does not have FIR block.n"); /* select a logical device */ outb( CR07, eferinfo->efir_addr); outb( 0x06 ,eferinfo->efdr_addr); /* FIR block */ /* read DMA settings */ outb(CR74, eferinfo->efir_addr); rxdma = inb(eferinfo->efdr_addr); if(rxdma > 3){ DEBUG(" RX DMA is inactive\n"); rxdma = -1; } outb(CR75, eferinfo->efir_addr); txdma = inb(eferinfo->efdr_addr); if(txdma > 3){ DEBUG(" TX DMA is inactive, or single DMA mode\n"); txdma = -1; } info.dma = rxdma; /* read IRQ settings */ outb(CR70, eferinfo->efir_addr); info.irq = inb(eferinfo->efdr_addr) & 0x0f; /* read I/O base address */ outb(CR60, eferinfo->efir_addr); info.sir_base = (inb(eferinfo->efdr_addr) << 8); outb(CR61, eferinfo->efir_addr); info.sir_base |= (inb(eferinfo->efdr_addr) & 0xff); info.fir_base = info.sir_base ; info.manufacturer = MANUFACTURER; info.name = chipinfo->name; info.cfg_base = eferinfo->efer_addr; info.uart_comp = 1; /* we knows it :) */ /* read misc (no! very important) settings */ outb(CRF0, eferinfo->efir_addr); misc = inb(eferinfo->efdr_addr) ; if(misc & TXW4C_977) DEBUG(" RX->TX Turn around delay(4 char time) is enabled\n"); else DEBUG(" RX->TX Turn around delay(4 char time) is disabled\n"); if(misc & RXW4C_977) DEBUG(" TX->RX Turn around delay(4 char time) is enabled\n"); else DEBUG(" TX->RX Turn around delay(4 char time) is disabled\n"); if(misc & ENBNKSEL_977) { DEBUG(" Bank selection si enabled.\n"); info.enabled = 1; } else { DEBUG(" Bank selection is disabled(CRF0 = 0x%02x).\n", misc); info.enabled = 0; } info.suspended = 0; /* todo: handling of this */ print_info(&info); return 1; } /* * Function winbond_read_info() * * if Chip ID is valid, return non-zero * */ int w83877_read_info(winbond_efer_t *eferinfo) { struct chip_info info; winbond_chip_t *chipinfo; int rxdma, txdma, chipid, misc; int disabled = 0; /* find chip_ID */ outb( CR09, eferinfo->efir_addr); chipid = (inb(eferinfo->efdr_addr)) & CHIPID; for(chipinfo = chips; chipinfo->name; chipinfo++){ if (chipid == chipinfo->chip_id) break; } if(chipinfo->name == NULL){ DEBUG("chip ID is 0x%02x : no known chip was detected.\n", chipid); return 0; } info.chip_id = chipid; DEBUG("chip ID is 0x%02x : %s is detected!\n", info.chip_id, chipinfo->name); if(chipinfo->fir_support != FIR_SUPPORT) DEBUG("this chip does not have FIR block.n"); /* read DMA settings */ outb(CR2A, eferinfo->efir_addr); rxdma = inb(eferinfo->efdr_addr); txdma = (rxdma & IRTXDRQSEL) >> 4; rxdma &= IRRXDRQSEL; DEBUG(" RX DMA = %d, TX DMA = %d\n", rxdma, txdma); if( txdma == rxdma ) info.dma = txdma; else { if(txdma !=0) /* todo: redefinition of chip_info ? */ DEBUG(" -- Configured for Dual DMA mode\n"); } if(info.dma == 0) DEBUG(" -- DMA is disabled.\n"); /* read IRQ settings */ outb(CR28, eferinfo->efir_addr); info.irq = inb(eferinfo->efdr_addr) & URBIQS; outb(CR25, eferinfo->efir_addr); info.sir_base = (inb(eferinfo->efdr_addr) & URBAD) << 2; info.fir_base = info.sir_base ; info.manufacturer = MANUFACTURER; info.name = chipinfo->name; info.cfg_base = eferinfo->efer_addr; info.uart_comp = 1; /* we knows it :) */ /* read misc (no! very important) settings */ outb(CR0B, eferinfo->efir_addr); misc = inb(eferinfo->efdr_addr) ; if(misc & TXW4C) DEBUG(" RX->TX Turn around delay(4 char time) is enabled\n"); else DEBUG(" RX->TX Turn around delay(4 char time) is disabled\n"); if(misc & RXW4C) DEBUG(" TX->RX Turn around delay(4 char time) is enabled\n"); else DEBUG(" TX->RX Turn around delay(4 char time) is disabled\n"); outb(CR0C, eferinfo->efir_addr); misc = inb(eferinfo->efdr_addr) ; if(misc & ENBKIRSL) DEBUG(" Config Registers for IR functions are activated. good.\n"); else { DEBUG(" Config Registers for IR functions are " "inactivated(CR0C = 0x%02x).\n", misc); disabled = 1; } if(misc & URIRSEL) DEBUG(" UART B is IR mode. \n"); else { DEBUG(" UART B is not IR mode(CR0C = 0x%02x). \n",misc); disabled = 1; } outb(CR0D, eferinfo->efir_addr); misc = inb(eferinfo->efdr_addr) ; if(misc & HDUPLX) DEBUG(" Configured for Half-Duplex\n"); else DEBUG(" Configured for Full-Duplex\n"); switch(misc & IRMODE){ case 0: case 1: DEBUG(" IR support are disabled. bad.\n"); disabled = 1; break; case 2: DEBUG(" Configured for IrDA. (SIR pulse width = 1.6us)\n"); break; case 3: DEBUG(" Configured for IrDA. (SIR pulse width = 3/16)\n"); break; default: DEBUG(" Configured for ASK-IR(0x%02x). \n",misc & IRMODE); disabled = 1; break; } outb(CR2C, eferinfo->efir_addr); misc = inb(eferinfo->efdr_addr); if(misc & ENBNKSEL) DEBUG(" Bank selection is enabled. \n"); else { DEBUG(" Bank selection is disabled(CR2C = 0x%02x)\n",misc); disabled = 1; } if(disabled){ info.enabled = 0; } else info.enabled = 1; /* I think we should not read revision number because it resides in Advanced UART, which may be activated as a normal UART by the Linux kernel. once I've tried to read the number, but kernel got frozen :< note: Device ID and Device Rev do not exist in EFRs because W83877 is not ISA-PNP spec compliant */ info.revision = -1; info.suspended = 0; /* todo: handling of this */ print_info(&info); return 1; /* found */ } /* * Function probe_winbond () * * * */ int probe_winbond(void) { int found = 0; winbond_efer_t *eferinfo; int i, hefras, hefere; /* search for the address of EFIR. */ for (eferinfo = efers; eferinfo->efer_addr && found == 0; eferinfo++) { DEBUG("Probing for EFER at 0x%04x ...\n", eferinfo->efer_addr); /* knock EFER */ for (i = 0; i < eferinfo->writes; i++){ outb( eferinfo->start_flag, eferinfo->efer_addr); } if(eferinfo->hefras_index >= 0) { outb( eferinfo->hefras_index, eferinfo->efir_addr); hefras = (inb(eferinfo->efdr_addr)); DEBUG("hefras = 0x%02x \n", hefras); hefras = (hefras & eferinfo->hefras_mask) ? 1 : 0; if(hefras != eferinfo->hefras) goto skip; } if(eferinfo->hefere_index >= 0) { outb( eferinfo->hefere_index, eferinfo->efir_addr); hefere = (inb(eferinfo->efdr_addr)); DEBUG("hefere = 0x%02x \n", hefere); hefere = (hefere & eferinfo->hefere_mask) ? 1 : 0; if(hefere != eferinfo->hefere) goto skip; } DEBUG("EFER seems to be probed at 0x%04x\n", eferinfo->efer_addr); switch(eferinfo->chip_type){ case W83877: found = w83877_read_info(eferinfo); break; case W83977: found = w83977_read_info(eferinfo); break; default: DEBUG("BUG in the source code.. :("); break; } skip: outb( eferinfo->end_flag, eferinfo->efer_addr); if(found) return 0; } DEBUG("Couldn't find Winbond superI/O chip.\n"); return 0; } irda-utils-0.9.18/findchip/smc.c0000644000175000017500000001326010454641046015744 0ustar samuelsamuel/********************************************************************* * * Filename: smc.c * Version: 0.4 * Description: Hardware probe for SMC infrared controllers * Status: Experimental. * Author: Jonathan Hudson * Created at: Thu Jan 1 09:46:05 2000 * Modified at: Fri Jan 28 11:21:46 2000 * Modified by: Dag Brattli * * Copyright (c) 2000 Jonathan Hudson , * * 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include "findchip.h" #define IRCC_MASTER 0x07 #define IRCC_ID_HIGH 0x00 /* 0x10 */ #define IRCC_ID_LOW 0x01 /* 0xB8 */ #define IRCC_CHIP_ID 0x02 /* 0xF1 */ #define IRCC_VERSION 0x03 /* 0x01 */ #define IRCC_INTERFACE 0x04 /* low 4 = DMA, high 4 = IRQ */ #define SMC_DISCONF 0xAA /* Disable Config */ #define CR00 0x00 #define CR02 0x02 #define CR0C 0x0c #define CR0D 0x0d #define CR24 0x24 #define CR25 0x25 #define CR28 0x28 #define CR2B 0x2b #define CR2C 0x2c #define CR2D 0x2d typedef struct { char *name; int cfg[2]; unsigned char entr1; unsigned char entr2; unsigned char cid_index; unsigned char cid_value; int (*probe)(char *name, int confreg); } smc_chip_info_t; int probe_69(char *name, int confreg); int probe_58(char *name, int confreg); /* These are the currently known SMC chips */ static smc_chip_info_t chips[] = { { "FDC37C669", {0x3f0, 0x370}, 0x55, 0x55, 0x0d, 0x03, probe_69 }, { "FDC37C669FR", {0x3f0, 0x370}, 0x55, 0x55, 0x0d, 0x04, probe_69 }, { "FDC37N869", {0x3f0, 0x370}, 0x55, 0x00, 0x0d, 0x29, probe_69 }, { "FDC37C93xFR", {0x3f0, 0x370}, 0x55, 0x55, 0x20, 0x03, probe_58 }, { "FDC37N957FR", {0x3f0, 0x370}, 0x55, 0x55, 0x20, 0x07, probe_58 }, { "FDC37N958FR", {0x3f0, 0x370}, 0x55, 0x55, 0x20, 0x09, probe_58 }, { 0 } }; static inline void register_bank(int port, int bank) { outb(((inb(port + IRCC_MASTER) & 0xF0) | (bank & 0x07)), port + IRCC_MASTER); } static inline unsigned int serial_in(int port, int offset) { return inb(port + offset); } /* * Function probe_69 (name, confreg) * * Probes for the FDC37C669 and FDC37N869 * */ int probe_69(char *name, int confreg) { struct chip_info info; int fir, enb; memset(&info, 0, sizeof(struct chip_info)); outb(CR25, confreg); info.sir_base = inb(confreg + 1); info.sir_base <<= 2; outb(CR2C, confreg); info.dma = inb(confreg+1); outb(CR28, confreg); info.irq = inb(confreg+1) & 0x0F; outb(CR2B, confreg); fir = inb(confreg + 1); fir <<= 3; if (fir) { outb(CR2D, confreg); info.delay = inb(confreg + 1); register_bank(fir, 3); info.chip_id = inb(fir + IRCC_CHIP_ID) & 0x0f; info.revision = inb(fir + IRCC_VERSION); } outb(CR02, confreg); enb = inb(confreg + 1) & 0x80; info.manufacturer = "SMC"; info.name = name; info.cfg_base = confreg; info.fir_base = fir; info.enabled = enb; info.uart_comp = 1; /* We know it is */ print_info(&info); return fir; } /* * Function probe_58 (name, confreg) * * Probes for the SMC FDC37N958 * */ int probe_58(char *name, int confreg) { struct chip_info info; int fir, enb; memset(&info, 0, sizeof(struct chip_info)); /* Select logical device (UART2) */ outb(0x07, confreg); outb(0x05, confreg + 1); /* Read SIR base */ outb(0x60, confreg); info.sir_base = inb(confreg + 1) << 8; outb(0x61, confreg); info.sir_base |= inb(confreg + 1); /* Read DMA */ outb(0x74, confreg); info.dma = inb(confreg+1); /* Read IRQ */ outb(0x70, confreg); info.irq = inb(confreg+1) & 0x0F; /* Read FIR base */ outb(0x62, confreg); fir = inb(confreg + 1) << 8; outb(0x63, confreg); fir |= inb(confreg + 1); if (fir) { outb(0xf2, confreg); info.delay = inb(confreg + 1); register_bank(fir, 3); info.chip_id = inb(fir + IRCC_CHIP_ID) & 0x0f; info.revision = inb(fir + IRCC_VERSION); } /* Check if device is enabled */ outb(0x22, confreg); enb = inb(confreg + 1) & 0x20; info.manufacturer = "SMC"; info.name = name; info.cfg_base = confreg; info.fir_base = fir; info.enabled = enb; info.uart_comp = 1; /* We know it is */ print_info(&info); return fir; } int probe_smc(void) { int confreg = 0; int fir = 0; smc_chip_info_t *chp; int i; /* Probe all chips */ for (chp = chips; chp->name && fir == 0; chp++) { DEBUG("Probing for %s ...\n", chp->name); /* Try both config register */ for (i = 0; i < 2 && fir == 0; i++) { int devid; outb(chp->entr1, chp->cfg[i]); if (chp->entr2) { outb(chp->entr2, chp->cfg[i]); } outb(chp->cid_index, chp->cfg[i]); devid = inb(chp->cfg[i] + 1); if (devid == chp->cid_value) { confreg = chp->cfg[i]; fir = chp->probe(chp->name, confreg); } else { DEBUG("Wrong chip id=0x%02x\n", devid); } outb(SMC_DISCONF, chp->cfg[i]); } } return 0; } irda-utils-0.9.18/findchip/nsc.c0000644000175000017500000001603310454641046015746 0ustar samuelsamuel/********************************************************************* * * Filename: nsc.c * Version: 0.4 * Description: Hardware probe for NSC infrared controllers * Status: Experimental. * Author: Dag Brattli * Created at: Thu Jan 6 09:46:13 2000 * Modified at: Tue Jan 25 10:02:20 2000 * Modified by: Dag Brattli * * Copyright (c) 1999-2000 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include "findchip.h" #define MANUFACTURER "NSC" /* Config registers for the '108 */ #define CFG_BAIC 0x00 #define CFG_CSRT 0x01 #define CFG_MCTL 0x02 /* Config registers for the '338 */ #define CFG_FER 0x00 #define CFG_FAR 0x01 #define CFG_PTR 0x02 #define CFG_PNP0 0x1b #define CFG_PNP1 0x1c #define CFG_PNP3 0x4f struct nsc_chip { char *name; int cfg[3]; u_int8_t cid_index; u_int8_t cid_value; u_int8_t cid_mask; void (*probe)(struct nsc_chip *nsc_chip, int cfg_base, int chip_id, int revision); }; typedef struct nsc_chip nsc_chip_t; void nsc_probe_108(nsc_chip_t *chip, int cfg_base, int chip_id, int revision); void nsc_probe_338(nsc_chip_t *chip, int cfg_base, int chip_id, int revision); static nsc_chip_t chips[] = { { "PC87108", { 0x150, 0x398, 0xea }, 0x05, 0x10, 0xf0, nsc_probe_108 }, { "PC87338", { 0x398, 0x15c, 0x2e }, 0x08, 0xb0, 0xf0, nsc_probe_338 }, { NULL } }; /* * Function nsc_probe_108 (nsc_chip, cfg_base, chip_id, revision) * * * */ void nsc_probe_108(nsc_chip_t *chip, int cfg_base, int chip_id, int revision) { struct chip_info info; int reg; memset(&info, 0, sizeof(struct chip_info)); /* Read address and interrupt control register (BAIC) */ outb(CFG_BAIC, cfg_base); reg = inb(cfg_base+1); switch (reg & 0x03) { case 0: info.sir_base = 0x3e8; break; case 1: info.sir_base = 0x2e8; break; case 2: info.sir_base = 0x3f8; break; case 3: info.sir_base = 0x2f8; break; } info.fir_base = info.sir_base; /* Read control signals routing register (CSRT) */ outb(CFG_CSRT, cfg_base); reg = inb(cfg_base+1); switch (reg & 0x07) { case 0: info.irq = -1; break; case 1: info.irq = 3; break; case 2: info.irq = 4; break; case 3: info.irq = 5; break; case 4: info.irq = 7; break; case 5: info.irq = 9; break; case 6: info.irq = 11; break; case 7: info.irq = 15; break; } /* Currently we only read Rx DMA but it will also be used for Tx */ switch ((reg >> 3) & 0x03) { case 0: info.dma = -1; break; case 1: info.dma = 0; break; case 2: info.dma = 1; break; case 3: info.dma = 3; break; } /* Read mode control register (MCTL) */ outb(CFG_MCTL, cfg_base); reg = inb(cfg_base+1); info.enabled = reg & 0x01; info.suspended = !((reg >> 1) & 0x01); /* Other stuff we must include */ info.manufacturer = MANUFACTURER; info.name = chip->name; info.revision = revision; info.chip_id = chip_id; info.cfg_base = cfg_base; info.uart_comp = 1; /* We know it is */ print_info(&info); } /* * Function nsc_probe_338 (nsc_chip, cfg_base, chip_id, revision) * * * */ void nsc_probe_338(nsc_chip_t *chip, int cfg_base, int chip_id, int revision) { struct chip_info info; int com = 0; int reg; int pnp; memset(&info, 0, sizeof(struct chip_info)); /* Read funtion enable register (FER) */ outb(CFG_FER, cfg_base); reg = inb(cfg_base+1); info.enabled = (reg >> 2) & 0x01; /* Check if we are in Legacy or PnP mode */ outb(CFG_PNP0, cfg_base); reg = inb(cfg_base+1); pnp = (reg >> 4) & 0x01; if (pnp) { DEBUG("Chip is in PnP mode\n"); outb(0x46, cfg_base); reg = (inb(cfg_base+1) & 0xfe) << 2; outb(0x47, cfg_base); reg |= ((inb(cfg_base+1) & 0xfc) << 8); info.sir_base = reg; } else { DEBUG("Chip is in Legacy mode\n"); /* Read function address register (FAR) */ outb(CFG_FAR, cfg_base); reg = inb(cfg_base+1); printf("reg=0x%03x\n", reg); switch ((reg >> 4) & 0x03) { case 0: info.sir_base = 0x3f8; break; case 1: info.sir_base = 0x2f8; break; case 2: com = 3; break; case 3: com = 4; break; } if (com) { switch ((reg >> 6) & 0x03) { case 0: if (com == 3) info.sir_base = 0x3e8; else info.sir_base = 0x2e8; break; case 1: if (com == 3) info.sir_base = 0x338; else info.sir_base = 0x238; break; case 2: if (com == 3) info.sir_base = 0x2e8; else info.sir_base = 0x2e0; break; case 3: if (com == 3) info.sir_base = 0x220; else info.sir_base = 0x228; break; } } } info.fir_base = info.sir_base; /* Read PnP register 1 (PNP1) */ outb(CFG_PNP1, cfg_base); reg = inb(cfg_base+1); info.irq = reg >> 4; /* Read PnP register 3 (PNP3) */ outb(CFG_PNP3, cfg_base); reg = inb(cfg_base+1); info.dma = (reg & 0x07) - 1; /* Read power and test register (PTR) */ outb(CFG_PTR, cfg_base); reg = inb(cfg_base+1); info.suspended = reg & 0x01; info.manufacturer = MANUFACTURER; info.name = chip->name; info.revision = revision; info.chip_id = chip_id; info.uart_comp = 1; /* We know it is */ info.cfg_base = cfg_base; print_info(&info); } /* * Function probe_nsc () * * * */ int probe_nsc(void) { nsc_chip_t *chip; u_int8_t index, id; int cfg_base; int cfg; /* Search all chips */ for (chip = chips; chip->name; chip++) { DEBUG("Probing for %s ...\n", chip->name); /* Try all config registers for this chip */ for (cfg=0; cfg<3; cfg++) { cfg_base = chip->cfg[cfg]; if (!cfg_base) continue; /* Read index register */ index = inb(cfg_base); if (index == 0xff) { DEBUG("no chip at 0x%03x\n", cfg_base); continue; } /* Read chip identification register */ outb(chip->cid_index, cfg_base); id = inb(cfg_base+1); if ((id & chip->cid_mask) == chip->cid_value) { DEBUG("Found %s chip, revision=%d\n", chip->name, id & ~chip->cid_mask); /* Print chip information */ if (!chip->probe) continue; chip->probe(chip, cfg_base, (id & chip->cid_mask) >> 4, id & ~chip->cid_mask); } else { DEBUG("Wrong chip id=0x%02x\n", id); } } } return 0; } irda-utils-0.9.18/findchip/findchip.c0000644000175000017500000001014610454641046016746 0ustar samuelsamuel/********************************************************************* * * Filename: findchip.c * Version: 0.5 * Description: Hardware probe for infrared controllers * Status: Experimental. * Author: Jonathan Hudson * Created at: Thu Jan 1 09:45:49 2000 * Modified at: Wed Jan 19 10:36:57 2000 * Modified by: Dag Brattli * * Copyright (c) 2000 Jonathan Hudson , * Copyright (c) 2000 Dag Brattli , * 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include "findchip.h" #define AUTHORS "Jonathan Hudson and Dag Brattli" extern int probe_smc(void); extern int probe_nsc(void); extern int probe_winbond(void); static int verbose = 0; int debug = 0; typedef struct { char *chip; int (*probe_func) (void); } chipset_t; static chipset_t allchips[] = { { "SMC", probe_smc }, { "NSC", probe_nsc }, { "WINBOND", probe_winbond }, { NULL, NULL } }; void list_chips(void) { chipset_t *probe; for (probe = allchips; probe->chip; probe++) { printf("%s\n", probe->chip); } } void print_info(struct chip_info *info) { if (verbose) { printf("Found %s %s Controller at 0x%x, DevID=0x%02x, Rev. %d\n", info->manufacturer, info->name, info->cfg_base, info->chip_id, info->revision); printf(" SIR Base 0x%x, FIR Base 0x%x\n", info->sir_base, info->fir_base); printf(" IRQ = %d, DMA = %d\n", info->irq, info->dma); printf(" Enabled: %s, Suspended: %s\n", info->enabled ? "yes" : "no", info->suspended ? "yes" : "no"); printf(" UART compatible: %s\n", info->uart_comp ? "yes" : "no"); printf(" Half duplex delay = %d us\n", info->delay); } else { printf("%s,%s,%d.%d,0x%x,0x%x,0x%x,%d,%d,%d,%d,%d\n", info->manufacturer, info->name, info->chip_id, info->revision, info->cfg_base, info->sir_base, info->fir_base, info->irq, info->dma, info->enabled, info->suspended, info->uart_comp); } } int main(int argc, char **argv) { chipset_t *probe; int c; while ((c = getopt(argc, argv, "vdlh")) != -1) { switch (c) { case 'v': verbose = 1; break; case 'd': debug = 1; break; case 'h': fputs("Usage: findchip [-d] [-v] [-l] [chip1 ... chipN]\n", stderr); fputs("\n", stderr); fputs("-d Enable debug output\n", stderr); fputs("-v Be verbose\n", stderr); fputs("-l List supported chipsets\n", stderr); fputs("-h Print help (this message)\n", stderr); exit(0); case 'l': list_chips(); exit(0); break; } } if (ioperm(0x0, 0x3ff, 1)) { perror("Set i/o permission"); exit(0); } /* Probe the chips! */ do { for (probe = allchips; probe->chip; probe++) { if (argv[optind] == NULL || (0 == strcasecmp(argv[optind], probe->chip))) { probe->probe_func(); } } } while (++optind < argc); return 0; } irda-utils-0.9.18/findchip/findchip.h0000644000175000017500000000333710454641046016757 0ustar samuelsamuel/********************************************************************* * * Filename: findchip.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Jan 9 22:24:34 2000 * Modified at: Wed Jan 19 10:38:10 2000 * Modified by: Dag Brattli * * Copyright (c) 2000 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #ifndef FINDCHIP_H #define FINDCHIP_H struct chip_info { char *manufacturer; char *name; int chip_id; int revision; int cfg_base; int sir_base; int fir_base; int irq; int dma; int uart_comp; int enabled; /* Device enabled */ int suspended; /* Device suspended */ int delay; /* Half duplex delay */ }; extern void print_info(struct chip_info *info); extern int debug; #define DEBUG(args...) (debug ? printf(args):0) #endif irda-utils-0.9.18/findchip/IRProbe.pl0000644000175000017500000000526510454641046016663 0ustar samuelsamuel#!/usr/bin/perl -w use Gtk; use strict 'vars'; init Gtk; my ($main_window,$table); my @results; sub item_factory_cb { my ($widget, $action, @data) = @_; if($action == -1) { destroy $main_window; exit } } my @item_factory_entries = (); sub create_item_factory { my ($accel_group, $item_factory, $box1, $label, $box2); my ($separator, $button, $dummy); $main_window = new Gtk::Window('toplevel'); $accel_group = new Gtk::AccelGroup; $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', "
", $accel_group); # my @chips = `findchip -l`; # push @item_factory_entries, ["/_File", undef, 0, ""]; # foreach (@chips) # { # chomp; # my $item = "/_File/Probe ".$_; # push @item_factory_entries, [$item, undef, 1]; # } # push @item_factory_entries, ["/File/_All", "A", 0]; push @item_factory_entries, ["/File/_Quit", "Q", -1]; $accel_group->attach($main_window); foreach (@item_factory_entries) { $item_factory->create_item($_, \&item_factory_cb); } $main_window->set_title("Linux IrDA Chip Probe"); $main_window->set_border_width(0); $box1 = new Gtk::VBox(0, 0); $main_window->add($box1); $box1->pack_start($item_factory->get_widget('
'), 0, 0, 0); $table = new Gtk::Table(3,6,1); my $lab00 = new Gtk::Label "Chip:"; my $lab01 = new Gtk::Label "Model:"; my $lab02 = new Gtk::Label "Version:"; my $lab10 = new Gtk::Label "Control IO:"; my $lab11 = new Gtk::Label "SIR IO:"; my $lab12 = new Gtk::Label "FIR IO:"; my $lab20 = new Gtk::Label "IRQ:"; my $lab21 = new Gtk::Label "DMA:"; my $lab22 = new Gtk::Label ""; for(my $i = 0; $i < 9; $i++) { $results[$i] = new Gtk::Label ""; my ($x,$y); $x = 2*($i % 3); $y = $i / 3; $table->attach_defaults($results[$i], $x+1,$x+2, $y,$y+1); } $table->set_col_spacings(6); $table->set_row_spacings(4); $table->attach_defaults($lab00, 0,1,0,1); $table->attach_defaults($lab01, 2,3,0,1); $table->attach_defaults($lab02, 4,5,0,1); $table->attach_defaults($lab10, 0,1,1,2); $table->attach_defaults($lab11, 2,3,1,2); $table->attach_defaults($lab12, 4,5,1,2); $table->attach_defaults($lab20, 0,1,2,3); $table->attach_defaults($lab21, 2,3,2,3); $table->attach_defaults($lab22, 4,5,2,3); my ($res); $res = `findchip`; chomp $res; my @chipinfo = split (/,/,$res); for(my $i = 0; $i < 8; $i++) { if(defined $chipinfo[$i]) { $results[$i]->set ($chipinfo[$i]); } else { $results[$i]->set ("?"); } } $box1->add($table); } create_item_factory; $main_window->signal_connect("destroy" => sub { destroy $main_window; exit } ); show_all $main_window; main Gtk; irda-utils-0.9.18/findchip/gfindchip.c0000644000175000017500000001145010454641046017114 0ustar samuelsamuel #include #include #include void dialog_close_cb(GtkWidget * w, gpointer data) { gtk_widget_destroy(data); } void show_dialog(char *title, char *body) { GtkWidget *dialog, *button, *label; dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), title); gtk_container_border_width(GTK_CONTAINER(dialog), 5); label = gtk_label_new(body); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); gtk_widget_show(label); button = gtk_button_new_with_label(" Close "); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(dialog_close_cb), dialog); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0); gtk_widget_show(button); gtk_widget_show(dialog); gtk_widget_grab_focus(button); } void about(void) { show_dialog("About gFindChip 0.01", "gFindChip 0.01\n\n\ Copyright (c) 2000 Jonathan Hudson ,\n\ Copyright (c) 2000 Dag Brattli ,\n\ All Rights Reserved.\n\n\ This program is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ the Free Software Foundation; either version 2 of the License, or\n\ (at your option) any later version.\n\ \n\ This program is distributed in the hope that it will be useful,\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ GNU General Public License for more details.\n\ \n\ You should have received a copy of the GNU General Public License\n\ along with this program; if not, write to the Free Software\n\ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n\ USA."); } static GtkItemFactoryEntry menu_items[] = { {"/_File", NULL, NULL, 0, ""}, {"/File/Quit", "Q", gtk_main_quit, 0, NULL}, {"/_Help", NULL, NULL, 0, ""}, {"/_Help/About", NULL, about, 0, NULL}, }; void get_main_menu(GtkWidget * window, GtkWidget ** menubar) { int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); GtkItemFactory *item_factory; GtkAccelGroup *accel_group; accel_group = gtk_accel_group_new(); item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "
", accel_group); gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL); gtk_accel_group_attach(accel_group, GTK_OBJECT(window)); if (menubar) *menubar = gtk_item_factory_get_widget(item_factory, "
"); } void MakeResultLabel(GtkWidget * table, GtkWidget * button[], int i, char *label) { int x, y, n; x = 2 * (i % 3); y = i / 3; n = i * 2 + 1; button[n] = gtk_label_new(label); gtk_label_set_justify(GTK_LABEL(button[n]), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults(GTK_TABLE(table), button[n], x + 1, x + 2, y, y + 1); gtk_widget_show(button[n]); } void MakeStaticLabels(GtkWidget * table, GtkWidget * button[]) { int i, x, y, n; static char *labels[] = { "Chip:", "Model:", "Version:", "Control I/O:", "SIR I/O:", "FIR I/O:", "IRQ:", "DMA:" }; for (i = 0; i < 8; i++) { x = 2 * (i % 3); y = i / 3; n = i * 2; button[n] = gtk_label_new(labels[i]); gtk_label_set_justify(GTK_LABEL(button[n]), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults(GTK_TABLE(table), button[n], x, x + 1, y, y + 1); gtk_widget_show(button[n]); } } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *menubar; GtkWidget *table; GtkWidget *button[16]; FILE *fp; int i = 0; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), "WM destroy"); gtk_window_set_title(GTK_WINDOW(window), "gFindChip"); main_vbox = gtk_vbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(main_vbox), 1); gtk_container_add(GTK_CONTAINER(window), main_vbox); gtk_widget_show(main_vbox); get_main_menu(window, &menubar); gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show(menubar); table = gtk_table_new(3, 6, 1); gtk_container_set_border_width(GTK_CONTAINER(window), 2); gtk_container_add(GTK_CONTAINER(main_vbox), table); MakeStaticLabels(table, button); if ((fp = popen("findchip", "r"))) { char buf[128]; char *p1, *p0, *p2; if (fgets(buf, sizeof(buf), fp)) { p0 = strchr(buf, '\n'); *p0 = 0; for (i = 0, p1 = buf; (p2 = strchr(p1, ',')); i++) { *p2 = 0; if (p1 != p2) { MakeResultLabel(table, button, i, p1); } p1 = p2 + 1; } if (*p1) { MakeResultLabel(table, button, i, p1); } } pclose(fp); } if (i == 0) { show_dialog("gFindChip", "Unable to find any known IR chip"); } gtk_widget_show(table); gtk_widget_show(window); gtk_main(); return (0); } irda-utils-0.9.18/findchip/Makefile0000644000175000017500000000376310454641046016465 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: 0.1 ## Description: Hardware probe for Infrared Communications Controllers ## Status: Experimental. ## Author: Jonathan Hudson ## Created at: Thu Jan 1 09:54:08 2000 ## Modified at: Tue Jan 25 10:01:42 2000 ## Modified by: Dag Brattli ## ## Copyright (c) 2000 Jonathan Hudson , ## Copyright (c) 2000 Dag Brattli , ## 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., 59 Temple Place, Suite 330, Boston, ## MA 02111-1307 USA ## ###################################################################### include ../output.mak CC = gcc CFLAGS= $(RPM_OPT_FLAGS) $(SYS_INCLUDES) -O2 -Wall -Wstrict-prototypes SRCS = findchip.c smc.c nsc.c winbond.c OBJS = $(SRCS:.c=.o) all: findchip .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) -c $< findchip: $(OBJS) $(prn_cc_o) $(ECMD)$(CC) $(OBJS) $(CFLAGS) -o $@ clean: $(ECMD)rm -f *.o *~ \#* distclean: $(ECMD)rm -f findchip gfindchip *.o *~ \#* install: findchip $(prn_install) $(ECMD)install findchip $(ROOT)/usr/sbin/ gfindchip: gfindchip.c $(prn_cc) $(ECMD))$(CC) $(CFLAGS) `gtk-config --cflags` $< -o $@ `gtk-config --libs` irda-utils-0.9.18/include/0000755000175000017500000000000010454641161014651 5ustar samuelsamuelirda-utils-0.9.18/include/irda.h0000644000175000017500000001543310454641046015751 0ustar samuelsamuel/********************************************************************* * * Filename: irda.h * Version: 1.0 * Description: IrDA header file to be used by any IrDA applications * Status: Stable. * Author: Dag Brattli * Created at: Mon Mar 8 14:06:12 1999 * Modified at: Sat Dec 25 16:07:54 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 2003 Jean Tourrilhes, All Rights Reserved. * * This header is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #ifndef IRDA_H #define IRDA_H #include /* Hint bit positions for first hint byte */ #define HINT_PNP 0x01 #define HINT_PDA 0x02 #define HINT_COMPUTER 0x04 #define HINT_PRINTER 0x08 #define HINT_MODEM 0x10 #define HINT_FAX 0x20 #define HINT_LAN 0x40 #define HINT_EXTENSION 0x80 /* Hint bit positions for second hint byte (first extension byte) */ #define HINT_TELEPHONY 0x01 #define HINT_FILE_SERVER 0x02 #define HINT_COMM 0x04 #define HINT_MESSAGE 0x08 #define HINT_HTTP 0x10 #define HINT_OBEX 0x20 /* IrLMP character code values */ #define CS_ASCII 0x00 #define CS_ISO_8859_1 0x01 #define CS_ISO_8859_2 0x02 #define CS_ISO_8859_3 0x03 #define CS_ISO_8859_4 0x04 #define CS_ISO_8859_5 0x05 #define CS_ISO_8859_6 0x06 #define CS_ISO_8859_7 0x07 #define CS_ISO_8859_8 0x08 #define CS_ISO_8859_9 0x09 #define CS_UNICODE 0xff /* These are the currently known dongles */ typedef enum { IRDA_TEKRAM_DONGLE = 0, IRDA_ESI_DONGLE = 1, IRDA_ACTISYS_DONGLE = 2, IRDA_ACTISYS_PLUS_DONGLE = 3, IRDA_GIRBIL_DONGLE = 4, IRDA_LITELINK_DONGLE = 5, IRDA_AIRPORT_DONGLE = 6, IRDA_OLD_BELKIN_DONGLE = 7, IRDA_EP7211_IR = 8, IRDA_MCP2120_DONGLE = 9, IRDA_ACT200L_DONGLE = 10, IRDA_MA600_DONGLE = 11, IRDA_TOIM3232_DONGLE = 12, } IRDA_DONGLE; /* Protocol types to be used for SOCK_DGRAM */ enum { IRDAPROTO_UNITDATA = 0, IRDAPROTO_ULTRA = 1, IRDAPROTO_MAX }; #define SOL_IRLMP 266 /* Same as SOL_IRDA for now */ #define SOL_IRTTP 266 /* Same as SOL_IRDA for now */ #define IRLMP_ENUMDEVICES 1 /* Return discovery log */ #define IRLMP_IAS_SET 2 /* Set an attribute in local IAS */ #define IRLMP_IAS_QUERY 3 /* Query remote IAS for attribute */ #define IRLMP_HINTS_SET 4 /* Set hint bits advertised */ #define IRLMP_QOS_SET 5 #define IRLMP_QOS_GET 6 #define IRLMP_MAX_SDU_SIZE 7 #define IRLMP_IAS_GET 8 /* Get an attribute from local IAS */ #define IRLMP_IAS_DEL 9 /* Remove attribute from local IAS */ #define IRLMP_HINT_MASK_SET 10 /* Set discovery filter */ #define IRLMP_WAITDEVICE 11 /* Wait for a new discovery */ #define IRTTP_MAX_SDU_SIZE IRLMP_MAX_SDU_SIZE /* Compatibility */ /* LM-IAS Limits */ #define IAS_MAX_STRING 256 /* See IrLMP 1.1, 4.3.3.2 */ #define IAS_MAX_OCTET_STRING 1024 /* See IrLMP 1.1, 4.3.3.2 */ #define IAS_MAX_CLASSNAME 60 /* See IrLMP 1.1, 4.3.1 */ #define IAS_MAX_ATTRIBNAME 60 /* See IrLMP 1.1, 4.3.3.1 */ #define IAS_MAX_ATTRIBNUMBER 256 /* See IrLMP 1.1, 4.3.3.1 */ /* For user space backward compatibility - may be fixed in kernel 2.5.X * Note : need 60+1 ('\0'), make it 64 for alignement - Jean II */ #define IAS_EXPORT_CLASSNAME 64 #define IAS_EXPORT_ATTRIBNAME 256 /* LM-IAS Attribute types */ #define IAS_MISSING 0 #define IAS_INTEGER 1 #define IAS_OCT_SEQ 2 #define IAS_STRING 3 #define LSAP_ANY 0xff struct sockaddr_irda { sa_family_t sir_family; /* AF_IRDA */ u_int8_t sir_lsap_sel; /* LSAP selector */ u_int32_t sir_addr; /* Device address */ char sir_name[25]; /* Usually :IrDA:TinyTP */ }; struct irda_device_info { u_int32_t saddr; /* Address of local interface */ u_int32_t daddr; /* Address of remote device */ char info[22]; /* Description */ u_int8_t charset; /* Charset used for description */ u_int8_t hints[2]; /* Hint bits */ }; struct irda_device_list { u_int32_t len; struct irda_device_info dev[1]; }; struct irda_ias_set { char irda_class_name[IAS_EXPORT_CLASSNAME]; char irda_attrib_name[IAS_EXPORT_ATTRIBNAME]; unsigned int irda_attrib_type; union { unsigned int irda_attrib_int; struct { unsigned short len; u_char octet_seq[IAS_MAX_OCTET_STRING]; } irda_attrib_octet_seq; struct { unsigned char len; unsigned char charset; unsigned char string[IAS_MAX_STRING]; } irda_attrib_string; } attribute; u_int32_t daddr; /* Address of device (for some queries only) */ }; /* Some private IOCTL's (max 16) */ #define SIOCSDONGLE (SIOCDEVPRIVATE + 0) #define SIOCGDONGLE (SIOCDEVPRIVATE + 1) #define SIOCSBANDWIDTH (SIOCDEVPRIVATE + 2) #define SIOCSMEDIABUSY (SIOCDEVPRIVATE + 3) #define SIOCGMEDIABUSY (SIOCDEVPRIVATE + 4) #define SIOCGRECEIVING (SIOCDEVPRIVATE + 5) #define SIOCSMODE (SIOCDEVPRIVATE + 6) #define SIOCGMODE (SIOCDEVPRIVATE + 7) #define SIOCSDTRRTS (SIOCDEVPRIVATE + 8) #define SIOCGQOS (SIOCDEVPRIVATE + 9) /* No reason to include just because of this one ;-) */ #define IRNAMSIZ 16 /* IrDA quality of service information (must not exceed 16 bytes) */ struct if_irda_qos { u_int32_t baudrate; u_int16_t data_size; u_int16_t window_size; u_int16_t min_turn_time; u_int16_t max_turn_time; u_int8_t add_bofs; u_int8_t link_disc; }; /* For setting RTS and DTR lines of a dongle */ struct if_irda_line { unsigned char dtr; unsigned char rts; }; /* IrDA interface configuration (data part must not exceed 16 bytes) */ struct if_irda_req { union { char ifrn_name[IRNAMSIZ]; /* if name, e.g. "irda0" */ } ifr_ifrn; /* Data part */ union { struct if_irda_line ifru_line; struct if_irda_qos ifru_qos; unsigned short ifru_flags; unsigned int ifru_receiving; unsigned int ifru_mode; unsigned int ifru_dongle; } ifr_ifru; }; #define ifr_baudrate ifr_ifru.ifru_qos.baudrate #define ifr_receiving ifr_ifru.ifru_receiving #define ifr_dongle ifr_ifru.ifru_dongle #define ifr_mode ifr_ifru.ifru_mode #define ifr_dtr ifr_ifru.ifru_line.dtr #define ifr_rts ifr_ifru.ifru_line.rts #endif /* IRDA_H */ irda-utils-0.9.18/irattach/0000755000175000017500000000000010454641161015025 5ustar samuelsamuelirda-utils-0.9.18/irattach/dongle_attach.c0000644000175000017500000000653110454641046017774 0ustar samuelsamuel/********************************************************************* * * Filename: dongle_attach.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Mon May 10 23:58:45 1999 * Modified at: Wed Oct 6 20:22:48 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* * Function main (argc, ) * * Initialize and try to receive test frames * */ int main(int argc, char *argv[]) { struct ifreq ifr; char dev[10]; int dongle = -1; int c; int fd; if (argc < 3) { printf("Usage: dongle_attach -d \n"); printf("\nExample: dongle_attach irda0 -d esi\n\n"); exit(-1); } strcpy(dev, argv[1]); while ((c = getopt(argc, argv, "d:")) != -1) { switch (c) { case 'd': if (strcmp(optarg, "esi") == 0) dongle = IRDA_ESI_DONGLE; else if (strcmp(optarg, "tekram") == 0) dongle = IRDA_TEKRAM_DONGLE; else if (strcmp(optarg, "actisys") == 0) dongle = IRDA_ACTISYS_DONGLE; else if (strcmp(optarg, "actisys+") == 0) dongle = IRDA_ACTISYS_PLUS_DONGLE; else if (strcmp(optarg, "girbil") == 0) dongle = IRDA_GIRBIL_DONGLE; else if (strcmp(optarg, "litelink") == 0) dongle = IRDA_LITELINK_DONGLE; else if (strcmp(optarg, "airport") == 0) dongle = IRDA_AIRPORT_DONGLE; else if (strcmp(optarg, "old_belkin") == 0) dongle = IRDA_OLD_BELKIN_DONGLE; else if (strcmp(optarg, "ep7211") == 0) dongle = IRDA_EP7211_IR; else if (strcmp(optarg, "mcp2120") == 0) dongle = IRDA_MCP2120_DONGLE; else if (strcmp(optarg, "act200l") == 0) dongle = IRDA_ACT200L_DONGLE; else if (strcmp(optarg, "ma600") == 0) dongle = IRDA_MA600_DONGLE; if (dongle == -1) { printf("Sorry, dongle not supported yet!\n"); exit(-1); } break; default: break; } } /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } strncpy(ifr.ifr_name, dev, IFNAMSIZ); ifr.ifr_data = (void *) dongle; if (ioctl(fd, SIOCSDONGLE, &ifr) < 0) { perror("ioctl"); exit(-1); } return 0; } irda-utils-0.9.18/irattach/irattach.c0000644000175000017500000004505610454641046017004 0ustar samuelsamuel/********************************************************************* * * Filename: irattach.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Dec 7 23:21:05 1997 * Modified at: Mon Apr 8 11:30:28 2002 * Modified by: Ronny Arild * Sources: * * Copyright (c) 1997, 1999-2000 Dag Brattli , * 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef N_IRDA #define N_IRDA 11 /* This one should go in .../asm/termio.h */ #endif /* N_IRDA */ #ifndef AF_IRDA #define AF_IRDA 23 #endif /* External prototypes */ extern void fork_now(int ttyfd); extern int set_sysctl_param(char *name, char *value); extern int execute(char *msg, char *cmd); /* Internal prototypes */ #define VERSION "0.9.17 (19.02.2006) Dag Brattli/Jean Tourrilhes" extern char *optarg; extern int optind; static int devfd = -1; /* File descriptor for the tty device */ static int fdflags = -1; /* Current file descriptor flags */ static int initfdflags = -1; /* Initial file descriptor flags */ static int initdisc = -1; /* Initial line discipline */ static struct termios termsave; /* Saved tty termios */ static int termvalid = -1; /* If termsave is valid */ /* Default path for pid file */ char *pidfile = "/var/run/irattach.pid"; /* Used by ioctl to the tty to obtain the network device name */ struct irtty_info { char name[6]; }; #define IRTTY_IOC_MAGIC 'e' #define IRTTY_IOCTDONGLE _IO(IRTTY_IOC_MAGIC, 1) #define IRTTY_IOCGNAME _IOR(IRTTY_IOC_MAGIC, 2, struct irtty_info) #define IRTTY_IOC_MAXNR 2 struct irtty_info info; /* IrDA Device Name of the device we manage */ char device[20]; struct dongle_list_s { int id; char *dongle; }; struct dongle_list_s dongle_list[] = { { IRDA_ESI_DONGLE, "esi" }, { IRDA_TEKRAM_DONGLE, "tekram" }, { IRDA_ACTISYS_DONGLE, "actisys" }, { IRDA_ACTISYS_PLUS_DONGLE, "actisys+" }, { IRDA_GIRBIL_DONGLE, "girbil" }, { IRDA_LITELINK_DONGLE, "litelink" }, { IRDA_AIRPORT_DONGLE, "airport" }, { IRDA_OLD_BELKIN_DONGLE, "old_belkin" }, { IRDA_EP7211_IR, "ep7211" }, { IRDA_MCP2120_DONGLE, "mcp2120" }, { IRDA_ACT200L_DONGLE, "act200l" }, { IRDA_MA600_DONGLE, "ma600" }, { IRDA_TOIM3232_DONGLE, "toim3232" }, { -1, NULL } }; /* Where to read device names */ #define PROC_NET_DEV "/proc/net/dev" /************************ COMMON SUBROUTINES ************************/ /* * Function modify_flags (set, clear) * * Modify the flags of an interface * */ static int modify_flags(char *dev, int set, int clear) { struct ifreq ifr; int sockfd; /* Create socket */ sockfd = socket(AF_IRDA, SOCK_STREAM, 0); if (sockfd < 0) { syslog (LOG_WARNING, "socket(AF_IRDA): %m"); return(-1); /* Can't clean_exit(), will recurse - Jean II */ } /* Try to read flags. Will fail if device doesn't exist */ strncpy(ifr.ifr_name, dev, IFNAMSIZ); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { syslog (LOG_WARNING, "ioctl(SIOCGIFFLAGS): %m"); close (sockfd); return -1; } /* Modify flags according to arguments */ ifr.ifr_flags |= set; ifr.ifr_flags &= ~clear; /* Not, set the modified flags */ strncpy(ifr.ifr_name, dev, IFNAMSIZ); if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { syslog (LOG_WARNING, "ioctl(SIOCSIFFLAGS): %m"); close (sockfd); return -1; } close(sockfd); return 0; } /* * Function ifup (name) * * Start device * */ static inline int ifup(char *dev) { syslog(LOG_INFO, "Starting device %s", dev); return(modify_flags(dev, IFF_UP|IFF_RUNNING, 0)); } /* * Function ifdown (name) * * Stop device * */ static inline int ifdown(char *dev) { syslog(LOG_INFO, "Stopping device %s", dev); return(modify_flags(dev, 0, IFF_UP)); } /********************* SIGNAL & ERROR HANDLING *********************/ /* * Put everything back in the state we found it */ void cleanup(int signo) { switch (signo) { case SIGTERM: case SIGINT: syslog(LOG_INFO, "got SIGTERM or SIGINT\n"); break; case SIGHUP: syslog(LOG_INFO, "got SIGHUP\n"); break; default: break; } ifdown(device); /* Reset the fd termios struct ++ */ if (devfd != -1) { fdflags &= ~O_NONBLOCK; if (fcntl (devfd, F_SETFL, fdflags) != 0) { syslog (LOG_ERR, "fcntl: fdflags: %m"); } if (initdisc != -1) if (ioctl(devfd, TIOCSETD, &initdisc) < 0){ fprintf(stderr, "Oups ! Can't set back original link discipline...\n"); syslog(LOG_ERR, "ioctl: set_inidisc: %m"); } if (termvalid != -1) if (tcsetattr(devfd, TCSANOW, &termsave) != 0) { syslog (LOG_ERR, "tcsetattr: %m"); } if (fcntl (devfd, F_SETFL, initfdflags) != 0) { syslog (LOG_ERR, "fcntl: initfdflags: %m"); } close(devfd); devfd = -1; } /* Delete pid file */ unlink(pidfile); syslog(LOG_INFO, "exiting ...\n"); if (signo == -1) exit(1); else exit(0); } /* To avoid recursion, clean_exit() should no be used above this * point - Jean II */ static inline void clean_exit(int status) { cleanup(status); //exit(-1); /* should not get here */ } static void print_usage(void) { int i; fprintf(stderr, "Usage: irattach [-d dongle] [-s] [-b] [-v] [-h]\n"); fprintf(stderr, " is tty name, device name or module name\n"); fprintf(stderr, "Dongles supported :\n"); for (i = 0; dongle_list[i].dongle != NULL; i++) fprintf(stderr, "\t%s\n", dongle_list[i].dongle); fprintf(stderr, "\n"); } /************************ MODULES MANAGEMENT ************************/ /* * Function load_module (name) * * Tries to load (modprobe) the module with the given name * */ static int load_module(char *name) { char msg[128], cmd[512]; int ret; sprintf(msg, "Trying to load module %s", name); sprintf(cmd, "/sbin/modprobe %s", name); ret = execute(msg, cmd); return ret; } /* * Extract an interface name out of /proc/net/irda * Important note : this procedure suppose that you don't alias irda devices */ static char * get_irdevname(char * name, /* Where to store the name */ int nsize, /* Size of name buffer */ char * buf) /* Current position in buffer */ { char * end; /* Skip leading spaces */ while(isspace(*buf)) buf++; /* Check if it's irda */ if(strncmp(buf, "irda", 4)) return(NULL); /* End of name (no alias) */ end = strchr(buf, ':'); /* Not found ??? To big ??? */ if((end == NULL) || (((end - buf) + 1) > nsize)) return(NULL); /* Copy */ memcpy(name, buf, (end - buf)); name[end - buf] = '\0'; return(end + 2); } /* * Function get_devlist () * * Get list of irda device on the system * */ static int get_devlist(char ifnames[][IFNAMSIZ + 1], int maxchars, int maxnames) { char buff[1024]; FILE * fh; int ifnum; /* Check if /proc/net/dev is available */ fh = fopen(PROC_NET_DEV, "r"); if(fh == NULL) return(-1); /* Success : use data from /proc/net/dev */ ifnum = 0; /* Eat 2 lines of header */ fgets(buff, sizeof(buff), fh); fgets(buff, sizeof(buff), fh); /* Read each device line */ while(fgets(buff, sizeof(buff), fh)) { /* Get an irda name */ if(get_irdevname(ifnames[ifnum], maxchars, buff)) { ifnum++; } if(ifnum > maxnames) { fclose(fh); return(-1); } } fclose(fh); return(ifnum); } /* * Function get_module_devices(char * modname) * * Load a module and figure out which IrDA interfaces were created. * */ static inline int get_module_devices(char * modname) { char before_names[10][IFNAMSIZ + 1]; int before_num; char after_names[15][IFNAMSIZ + 1]; int after_num; int firstone = -1; int pid; int i, j; int ret; /* Get list of devices before */ before_num = get_devlist(before_names, IFNAMSIZ + 1, 10); if(before_num < 0) { fprintf(stderr, "Could not get device name list.\n"); exit(-1); } /* Load the module */ ret = load_module(modname); if(ret) { fprintf(stderr, "Invalid module name [%s] !\n", device); print_usage(); exit(-1); } /* Get list of devices after */ after_num = get_devlist(after_names, IFNAMSIZ + 1, 15); if(after_num <= 0) { fprintf(stderr, "Could not get device name list.\n"); exit(-1); } /* Loop on all found names */ for(i = 0; i < after_num; i++) { /* Check if it was here before */ for(j = 0; j < before_num; j++) { if(!strcmp(before_names[j], after_names[i])) break; } /* If not found, it's a new interface */ if(j == before_num) { /* Already got one ??? */ if(firstone >= 0) { fprintf(stderr, "Found additional interface [%s]\n", after_names[i]); /* Create a new instance for this other * interface */ pid = fork(); /* If in the child */ if(!pid) { /* Get the interface name */ strcpy(device, after_names[i]); /* Exit so we manage this guy */ return(0); } /* In parent : continue looking at interface * list, spawn childs, and eventually * go back to manage the first one found */ } else { /* Get the interface name */ firstone = i; strcpy(device, after_names[i]); fprintf(stderr, "Found interface [%s]\n", device); } } } return(0); } /************************** TTY MANAGEMENT **************************/ /* * Function establish_irda (ttyfd) * * Turn the serial port into a irda interface. */ static void establish_irda (int ttyfd) { int irdadisc = N_IRDA; if (ioctl(ttyfd, TIOCEXCL, 0) < 0) { syslog (LOG_WARNING, "ioctl(TIOCEXCL): %m"); } if (ioctl(ttyfd, TIOCGETD, &initdisc) < 0) { syslog(LOG_ERR, "ioctl(TIOCGETD): %m"); clean_exit(-1); } if (ioctl(ttyfd, TIOCSETD, &irdadisc) < 0){ fprintf(stderr, "Maybe you don't have IrDA support in your kernel?\n"); syslog(LOG_ERR, "irattach: tty: set_disc(%d): %s\n", irdadisc, strerror(errno)); clean_exit(-1); } } /* * Function tty_configure (tios) * * Put a IrDA line discipline in a transparent mode. * */ static int tty_configure(struct termios *tios) { tios->c_cflag = CS8|CREAD|B9600|CLOCAL; /* Ignore break condition and parity errors */ tios->c_iflag = IGNBRK | IGNPAR; tios->c_oflag = 0; tios->c_lflag = 0; /* set input mode (non-canonical, no echo,..) */ tios->c_cc[VMIN] = 1; /* num of chars to wait for, before delivery */ tios->c_cc[VTIME] = 0; /* timeout before delivery */ return(0); } /* * Function init_irda (ttyfd) * * Initialize IrDA line discipline * */ static void init_irda_ldisc(int ttyfd) { struct termios tios; /* Get TTY configuration */ if (tcgetattr(ttyfd, &tios) != 0) { syslog (LOG_ERR, "tcgetattr: %m"); clean_exit(-1); } /* Save the original values */ memcpy(&termsave, &tios, sizeof(struct termios)); termvalid = 0; tty_configure(&tios); /* tcflush(ttyfd, TCIFLUSH); */ if (tcsetattr(ttyfd, TCSAFLUSH, &tios) < 0) { syslog(LOG_ERR, "tcsetattr: %m"); clean_exit(-1); } } /* * Function start_tty(ttyfd) * * Set up the serial device to be the irda interface. * * This needs to be called after the fork. */ static void start_tty(int ttyfd) { int cloexec; /* Set new flags -> blocking mode while we configure */ fdflags &= ~O_NONBLOCK; if (fcntl(ttyfd, F_SETFL, fdflags) == -1) { syslog(LOG_WARNING, "Couldn't set device fd flags: %m"); } /* We need to make sure the devfd/ttyfd will not be inherited by the * shells which get vfork'ed when we use popen(3) to execute commands * like sysctl and modprobe on behalf of irattach. In the daemon mode * we got most likely fd=0 which would be reused for stdin by /bin/sh * otherwise! * F_SETFD belongs to the fd, not file: no need to save and restore * later. * Martin */ if ((cloexec = fcntl(devfd, F_GETFD)) == -1) { syslog(LOG_ERR, "Couldn't get device fd close-on-exec flag: %m"); clean_exit(-1); } cloexec |= FD_CLOEXEC; if (fcntl(devfd, F_SETFD, cloexec) == -1) { syslog(LOG_ERR, "Couldn't set device fd close-on-exec flag: %m"); clean_exit(-1); } /* Set up the serial device as a irda interface */ init_irda_ldisc(ttyfd); establish_irda(ttyfd); /* Give it time to set up its terminal */ sleep(1); /* * Set device for non-blocking reads. */ if (fcntl(ttyfd, F_SETFL, fdflags | O_NONBLOCK) == -1) { syslog(LOG_ERR, "Couldn't set device to non-blocking mode: %m"); clean_exit(-1); } } /* * Function open_tty(ttyfd) * * Open the desired tty, save its state. * * This needs to be called before the fork. */ static int open_tty(char *dev) { int ttyfd; /* Open the serial device */ ttyfd = open(dev, O_NONBLOCK | O_RDWR, 0); if (ttyfd < 0) { fprintf(stderr, "Failed to open device %s: %s\n", dev, strerror(errno)); exit(-1); } /* Save old flags * Need to happen first, because we need to restore them when leaving * via clean_exit() */ if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1) { fprintf(stderr, "Couldn't get device %s flags: %s\n", dev, strerror(errno)); close(ttyfd); exit(-1); } initfdflags = fdflags; return(ttyfd); } /************************ DONGLE MANAGEMENT ************************/ /* * Function attach_dongle (name) * * Tries to load the dongle and attach it to the specified device * */ static inline void attach_dongle(int ttyfd, char *dev, int dongle) { /* If we have a tty channel, use it */ if(ttyfd != -1) { /* Attach dongle */ ioctl(ttyfd, IRTTY_IOCTDONGLE, dongle); } else { /* irport case (or maybe FIR drivers) */ int sockfd; struct ifreq ifr; /* Create socket */ sockfd = socket(AF_IRDA, SOCK_STREAM, 0); if (sockfd < 0) { perror("socket"); clean_exit(-1); } /* Attach dongle */ ifr.ifr_data = (void *) dongle; strncpy(ifr.ifr_name, dev, IFNAMSIZ); if (ioctl(sockfd, SIOCSDONGLE, &ifr) < 0) { perror("ioctl"); close(sockfd); clean_exit(-1); } /* Cleanup */ close(sockfd); } } /* * Function get_dongle (dongle) * * Find the dongle id corresponding to the name * */ static inline int get_dongle(char *dongle) { int i; for (i = 0; dongle_list[i].dongle != NULL; i++) { if (strcmp(dongle_list[i].dongle, dongle) == 0) return dongle_list[i].id; } return -1; } /******************************* MAIN *******************************/ /* * Function main (argc, ) * * Main function * */ int main(int argc, char *argv[]) { struct utsname buf; int tty = 0; /* True if first arg is a tty */ int modname = 0; /* True is first arg is a module name */ int dongle = -1; /* Dongle type requested */ int discovery = -1; /* True if discovery requested */ int c; int ret; int daemonize = 1; /* Go to background by default */ //printf("%s\n", VERSION); if ((argc < 2) || (argc > 5)) { print_usage(); exit(-1); } /* First arg is device name. Save it now, because in some cases * getopt() will remove it... */ strncpy(device, argv[1], 20); device[20] = '\0'; /* Look for options */ /* Do this before processing device, to handle "-h" and -v" * properly. Jean II */ while ((c = getopt(argc, argv, "d:hsvb")) != -1) { switch (c) { case 's': /* User wants to start discovery */ discovery = 1; break; case 'd': dongle = get_dongle(optarg); if (dongle == -1) { fprintf(stderr, "Sorry, dongle not supported yet!\n"); print_usage(); exit(-1); } break; case 'v': printf("Version: %s\n", VERSION); exit(0); case 'h': print_usage(); exit(0); case 'b': /* Do not fork to background */ daemonize = 0; break; default: print_usage(); exit(-1); } } /* Check if the device is a tty */ if(strncmp("/dev", device, 4) == 0) { /* We are managing a tty ! */ tty = 1; /* Create tty channel and make it exist */ devfd = open_tty(device); } else { /* Check for a irda device name */ if((strncmp("irda", device, 4) == 0) && (isdigit(device[4]))) { /* May fail if no alias in /etc/modules.conf. * Ignore, because the user may load module by hand. * Jean II */ load_module(device); } else { /* This is a module name - currently experimental */ modname = 1; /* Get list of devices associated with module */ /* This may fork as needed - Jean II */ get_module_devices(device); } } if(daemonize) { /* Go as a background daemon */ fork_now(devfd); } /* --- Deamon mode --- */ /* We can no longer print out directly to the terminal, we * now must use the syslog facility. * Jean II */ /* Trap signals */ if (signal(SIGHUP, cleanup) == SIG_ERR) syslog(LOG_INFO, "signal(SIGHUP): %m"); if (signal(SIGTERM, cleanup) == SIG_ERR) syslog(LOG_INFO, "signal(SIGTERM): %m"); if (signal(SIGINT, cleanup) == SIG_ERR) syslog(LOG_INFO, "signal(SIGINT): %m"); /* If device is a tty */ /* We may want to move that before the fork(), except for the sleep */ if (tty) { /* Setup tty channel */ start_tty(devfd); /* Get device name corresponding to the tty */ if (ioctl(devfd, IRTTY_IOCGNAME, &info) < 0) { syslog(LOG_ERR, "Are you using an old kernel?"); clean_exit(-1); } strncpy(device, info.name, 20); } /* --- IrDA stack and IrDA port loaded loaded --- */ /* We can not assume that the IrDA stack is present before * this point, so all sysctl/ioctl must be done after here. * The real name of the device is also only known at this point. * Jean II */ /* If dongle is chosen -> bind dongle driver to the irda port */ if (dongle != -1) { attach_dongle(devfd, device, dongle); } /* Use hostname as device name */ if (uname(&buf) == 0) set_sysctl_param("devname", strtok(buf.nodename, ".")); /* User may want to start discovery */ if(discovery > 0) set_sysctl_param("discovery", "1"); /* Start the network interface */ ret = ifup(device); if(ret < 0) clean_exit(-1); /* * Loop forever and wait for kill or ctrl-C since closing this * process will also close all open files for this process * which will in turn close the tty used for IrDA which is not * really what we want :-) */ while (1) pause(); return 0; } irda-utils-0.9.18/irattach/ChangeLog0000644000175000017500000000272210454641046016604 0ustar samuelsamuel2006-02-27 Samuel Ortiz * irattach can be kept in foreground. Debian patch from agi (agi@debian.org) 2004-01-16 Jean II * Changed ../include/irda.h from GPL to LGPL for external apps. Dag Brattli gave me his explicit approval via e-mail, and I'm the only other person having modified it. Note : the rest of the code is still GPL. 2003-08-18 Jean II * Move start_tty before fork to get error messages on console * Don't restore disc/termio in cleanup if invalid * Set FD_CLOEXEC on ttyfd so that popen does not inherit it (Martin) 2002-07-18 Jean II * Fix "irattach -h/-v" (thanks to Werner Heuser for spotting this) 2002-06-03 Jean II * Added ma600 dongle support 2002-05-22 Jean II * Added act200l dongle support 2002-04-17 Jean II * Merged and corrected patch from Ronny Arild : o proper exit in case of failure o restore initial tty settings o print error in invalid options * Reorganise code, add inline/static * Tighten device name parsing, return error and exit * Fix dongle loading for irport case * Accept module name as first argument and load all module devices * More logical operation order in main() 2002-04-03 Jean II * Addded ep7211 & mcp2120 dongles * Removed hard defined stuff in favor of irda.h 1999-10-09 Dag Brattli * irattach.c (cleanup): fixed function, so it will actually exit when a signal arrives 1999-10-07 Dag Brattli * Added AirPort support to irattach and dongle_attach irda-utils-0.9.18/irattach/Makefile0000644000175000017500000000413710454641046016474 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for Linux IrDA Manager ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Wed Oct 6 20:22:18 1999 ## Modified by: Dag Brattli ## ## $Id: Makefile 115 2006-02-28 22:16:46Z sambau $ ## ## Copyright (c) 1998-1999 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include ../output.mak CC = gcc LD = ld RM = rm -f CFLAGS = -O2 -W -Wall -Wstrict-prototypes -Wshadow $(SYS_INCLUDES) SYS_INCLUDES = -I/usr/include SYS_LIBPATH = -L/usr/lib -L/usr/local/lib INCLUDES = $(SYS_INCLUDES) -I../include/ LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) TARGETS = irattach dongle_attach all: $(TARGETS) .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< irattach: irattach.o util.o $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) irattach.o util.o -o $@ dongle_attach: dongle_attach.o $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) dongle_attach.o -o $@ install: $(TARGETS) $(prn_install) $(ECMD)install irattach $(ROOT)/usr/sbin $(ECMD)install dongle_attach $(ROOT)/usr/sbin clean: $(ECMD)$(RM) *.BAK *.bak *.o ,* *~ *.a distclean: $(ECMD)$(RM) *.BAK *.bak *.o ,* *~ *.a $(ECMD)$(RM) irattach dongle_attach tags: $(prn_etags) $(ECMD)etags *.[hc] */*.[hc] */*/*.[hc] depend: $(prn_depend) $(ECMD)makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) # DO NOT DELETE irda-utils-0.9.18/irattach/README0000644000175000017500000000640410454641046015713 0ustar samuelsamuelIrattach - Attaches the Linux-IrDA stack to a specified device Copyright (c) 2000 Dag Brattli , 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA irattach is used to bind the Linux-IrDA stack to a device driver. So this is something you must do in order to use IrDA on your Linux machine. irattach must be run as root or installed setuid root, as it requires root privileges Usage: irattach [-d dongle] [-s] where usually the name of a tty, but can also be a FIR device -d dongle attaches a dongle driver (see below for more info) -s starts discovery of remote IrDA devices Dongles: The currently known dongles are: tekram Tekram IrMate IR-210B dongle esi Extended Systems JetEye PC (ESI-9680) dongle actisys ACTiSYS IR-220L dongle actisys+ ACTiSYS IR-220L+ dongle girbil Greenwich GIrBIL dongle litelink Parallax LiteLink dongle airport old_belkin Belkin (old) SmartBeam dongle Modules: If you have compiled the IrDA stack as modules (recommended), then you will need to add these entries to your /etc/modules.conf file # IrDA over a normal serial port, or a serial port compatible IrDA port alias tty-ldisc-11 irtty # IrCOMM (for printing, PPP, Minicom etc) alias char-major-161 ircomm-tty # To be able to attach some dongles alias irda-dongle-0 tekram alias irda-dongle-1 esi alias irda-dongle-2 actisys alias irda-dongle-3 actisys alias irda-dongle-4 girbil alias irda-dongle-5 litelink alias irda-dongle-6 airport alias irda-dongle-7 old_belkin # To use the NSC driver on a Thinkpad laptop options nsc-ircc dongle_id=0x09 alias irda0 nsc-ircc Examples Attach the IrDA stack to the second serial port and start discovery $ ./irattach /dev/ttyS1 -s Attach the IrDA stack to the first serial port where you have an ACTiSYS dongle and start discovery $ ./irattach /dev/ttyS0 -d actisys -s Attach the IrDA stack to the NSC FIR (4Mbps) device driver on a Thinkpad laptop. You must also add some entries to /etc/conf.modules (see above) $ ./irattach irda0 -s 1 Device entries you will need to use IrCOMM: mknod /dev/ircomm0 c 161 0 mknod /dev/ircomm1 c 161 1 mknod /dev/irlpt0 c 161 17 mknod /dev/irlpt1 c 161 17 Afterwards, then "ll /dev/ir*" should look like this: crw-r--r-- 1 root 161, 0 Dec 22 14:15 /dev/ircomm0 crw-r--r-- 1 root 161, 1 Nov 5 08:36 /dev/ircomm1 crw-r--r-- 1 root 161, 16 Nov 5 08:36 /dev/irlpt0 crw-r--r-- 1 root 161, 17 Nov 5 08:36 /dev/irlpt1 Dag Brattli (Wed Jan 19 11:25:17 2000) irda-utils-0.9.18/irattach/util.c0000644000175000017500000000613310454641046016153 0ustar samuelsamuel#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern char *pidfile; int be_quiet = 1; int caught_signal = 0; /* * Function beep (ms, freq) * * * */ void beep(unsigned int ms, unsigned int freq) { int fd, arg; if (be_quiet) return; fd = open("/dev/console", O_RDWR); if (fd < 0) return; arg = (ms << 16) | freq; ioctl(fd, KDMKTONE, arg); close(fd); usleep(ms*1000); } #if 0 /* Unused ??? */ /* * Function open_dev (dev, mode) * * Open a device * */ int open_dev(dev_t dev, int mode) { char *fn; int fd; if ((fn = tmpnam(NULL)) == NULL) return -1; if (mknod(fn, mode, dev) != 0) return -1; fd = open(fn, (mode & S_IWRITE) ? O_RDWR: O_RDONLY); unlink(fn); return fd; } #endif /* * Function lookup_dev (name) * * Look up the minor number of the IrDA device * */ int lookup_dev(char *name) { FILE *f; int n; char s[32], t[32]; f = fopen("/proc/misc", "r"); if (f == NULL) return -errno; while (fgets(s, 32, f) != NULL) { if (sscanf(s, "%d %s", &n, t) == 2) if (strcmp(name, t) == 0) break; } fclose(f); if (strcmp(name, t) == 0) return n; else return -ENODEV; } int execute(char *msg, char *cmd) { int ret; FILE *f; char line[256]; syslog(LOG_INFO, "executing: '%s'", cmd); strcat(cmd, " 2>&1"); f = popen(cmd, "r"); while (fgets(line, 255, f)) { line[strlen(line)-1] = '\0'; syslog(LOG_INFO, "+ %s", line); } ret = pclose(f); if (WIFEXITED(ret)) { if (WEXITSTATUS(ret)) syslog(LOG_INFO, "%s exited with status %d", msg, WEXITSTATUS(ret)); return WEXITSTATUS(ret); } else syslog(LOG_INFO, "%s exited on signal %d", msg, WTERMSIG(ret)); return -1; } int execute_on_dev(char *action, char *class, char *dev, int minor) { char msg[128], cmd[512]; sprintf(msg, "%s cmd", action); sprintf(cmd, "./%s %s %s %d", class, action, dev, minor); return execute(msg, cmd); } /* * Function set_sysctl_param (name, value) * * Set parameter to in /proc/sys/net/irda * */ int set_sysctl_param(char *name, char *value) { char msg[128], cmd[512]; sprintf(msg, "Setting %s to %s", name, value); sprintf(cmd, "echo %s > /proc/sys/net/irda/%s", value, name); return execute(msg, cmd); } void write_pid(void) { FILE *f; f = fopen(pidfile, "w"); if (f == NULL) syslog(LOG_INFO, "could not open %s: %m", pidfile); else { fprintf(f, "%d\n", getpid()); fclose(f); } } void fork_now(int ttyfd) { int ret; int i; if ((ret = fork()) > 0) exit(0); if (ret == -1) syslog(LOG_INFO, "forking: %m"); if (setsid() < 0) syslog(LOG_INFO, "detaching from tty: %m"); if ((ret = fork()) > 0) { /* cleanup_files = 0; */ exit(0); } /* Close all open inherited files! Except for ttyfd! */ for (i = 0; i < 64; i++) if(i != ttyfd) close(i); write_pid(); } irda-utils-0.9.18/irdadump/0000755000175000017500000000000010454641161015033 5ustar samuelsamuelirda-utils-0.9.18/irdadump/capture.c0000644000175000017500000001600010454641046016641 0ustar samuelsamuel/********************************************************************* * * Filename: capture.c * Version: 0.1 * Description: Generate libpcap log files for Ethereal * Status: Experimental. * Author: Jan Kiszka * Created at: Thu Jul 17 16:32:35 PDT 2003 * Modified at: Thu Jul 17 16:32:35 PDT 2003 * Modified by: Jean Tourrilhes * * Copyright (c) 1999 Jan Kiszka, All Rights Reserved. * Copyright (c) 2003 Jean Tourrilhes, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include /* exit */ #include /* write */ #include #include #include #include #include "netbuf.h" #include "capture.h" #include #include /* * Linux-IrDA capture type */ #define DLT_LINUX_IRDA 144 /* * SLL pseudo header definitions */ #define SLL_HDR_LEN 16 /* total header length */ #define SLL_ADDRLEN 8 /* length of address field */ struct sll_header { u_int16_t sll_pkttype; /* packet type */ u_int16_t sll_hatype; /* link-layer address type */ u_int16_t sll_halen; /* link-layer address length */ u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ u_int16_t sll_protocol; /* protocol */ }; /* The LINUX_SLL_ values for "sll_pkttype" - see if_packet.h */ #define LINUX_SLL_HOST 0 #define LINUX_SLL_BROADCAST 1 #define LINUX_SLL_MULTICAST 2 #define LINUX_SLL_OTHERHOST 3 #define LINUX_SLL_OUTGOING 4 /* The LINUX_SLL_ values for "sll_protocol" - see if_ether.h */ #define LINUX_SLL_P_IRDA 0x0017 /* IrLAP frames */ #define SENT_FRAME 0x0100 #define RECV_FRAME 0x0101 struct pcaprec_hdr { __u32 ts_sec; __u32 ts_usec; __u32 incl_len; __u32 orig_len; }; #if 0 struct pseudo_hdr { __u8 not_used1; __u8 not_used2; __u16 type; }; #endif struct pcap_hdr { __u32 magic; __u16 version_major; __u16 version_minor; __u32 thiszone; __u32 sigfigs; __u32 snaplen; __u32 network; }; struct pcap_hdr fileHeader = { magic: 0xa1b2c3d4, version_major: 2, version_minor: 0, thiszone: 0, sigfigs: 0, snaplen: 2050 + sizeof(struct sll_header), network: DLT_LINUX_IRDA }; /* * Function capwrite_open () * * Open capture file and return its fd * */ int capwrite_open(char * capfilename) { int capturefile; /* Open the capture file */ capturefile = open(capfilename, O_WRONLY | O_CREAT | O_TRUNC, 00640); if (capturefile < 0) perror("Opening capture file"); return capturefile; } /* * Function capwrite_close () * * Close capture file if needed * */ void capwrite_close(int capturefile) { close(capturefile); } /* * Function capwrite_init () * * Write capture header in file * */ int capwrite_init(int capturefile) { /* Write capture file header */ if (write(capturefile, &fileHeader, sizeof(struct pcap_hdr)) < 0) return -1; return 0; } /* * Map the standard cooked Linux header to the capture format. * Cut'n'pasted from libpcap (BSD license). * Jean II */ void capwrite_fillsll(struct sll_header *hdrp, struct sockaddr_ll *from) { switch (from->sll_pkttype) { case PACKET_HOST: hdrp->sll_pkttype = htons(LINUX_SLL_HOST); break; case PACKET_BROADCAST: hdrp->sll_pkttype = htons(LINUX_SLL_BROADCAST); break; case PACKET_MULTICAST: hdrp->sll_pkttype = htons(LINUX_SLL_MULTICAST); break; case PACKET_OTHERHOST: hdrp->sll_pkttype = htons(LINUX_SLL_OTHERHOST); break; case PACKET_OUTGOING: hdrp->sll_pkttype = htons(LINUX_SLL_OUTGOING); break; default: hdrp->sll_pkttype = -1; break; } hdrp->sll_hatype = htons(from->sll_hatype); hdrp->sll_halen = htons(from->sll_halen); memcpy(hdrp->sll_addr, from->sll_addr, (from->sll_halen > SLL_ADDRLEN) ? SLL_ADDRLEN : from->sll_halen); hdrp->sll_protocol = from->sll_protocol; } /* * Function capwrite_dump () * * Write capture packet in file * */ int capwrite_dump(int capturefile, GNetBuf *frame_buf, int len, struct sockaddr_ll *from, struct timeval *curr_time) { struct pcaprec_hdr rec_hdr; struct sll_header psd_hdr; rec_hdr.ts_sec = curr_time->tv_sec; rec_hdr.ts_usec = curr_time->tv_usec; rec_hdr.orig_len = len + sizeof(psd_hdr); rec_hdr.incl_len = rec_hdr.orig_len; capwrite_fillsll(&psd_hdr, from); if ((write(capturefile, &rec_hdr, sizeof(rec_hdr)) < 0) || (write(capturefile, &psd_hdr, sizeof(psd_hdr)) < 0) || (write(capturefile, frame_buf->head, len) < 0)) { perror("write capture file"); exit(-1); } return 0; } /* * Function capread_open () * * Open capture file and return its fd * */ int capread_open(char * capfilename) { int capturefile; /* Open the capture file */ capturefile = open(capfilename, O_RDONLY, 00640); if (capturefile < 0) perror("Opening capture file"); return capturefile; } /* * Function capread_close () * * Close capture file if needed * */ void capread_close(int capturefile) { close(capturefile); } /* * Function capread_check () * * Read capture header from file and verifies it * */ int capread_check(int capturefile) { struct pcap_hdr readHeader; /* Write capture file header */ if (read(capturefile, &readHeader, sizeof(struct pcap_hdr)) != sizeof(struct pcap_hdr)) return -1; /* Compare */ if((readHeader.magic != fileHeader.magic) || (readHeader.version_major != fileHeader.version_major) || (readHeader.version_minor != fileHeader.version_minor) || (readHeader.network != fileHeader.network)) return -1; return 0; } /* * Function capwrite_get () * * Read capture packet from file * */ int capread_get(int capturefile, GNetBuf *frame_buf, int *plen, int *pdir, int *pprot, struct timeval *curr_time) { struct pcaprec_hdr rec_hdr; struct sll_header psd_hdr; if (read(capturefile, &rec_hdr, sizeof(rec_hdr)) != sizeof(rec_hdr)) return -1; curr_time->tv_sec = rec_hdr.ts_sec; curr_time->tv_usec = rec_hdr.ts_usec; *plen = rec_hdr.orig_len - sizeof(psd_hdr); if (read(capturefile, &psd_hdr, sizeof(psd_hdr)) != sizeof(psd_hdr)) return -1; /* Meta-data */ *pdir = psd_hdr.sll_pkttype != LINUX_SLL_HOST; *pprot = psd_hdr.sll_protocol; if (read(capturefile, frame_buf->head, *plen) != *plen) return -1; return 0; } irda-utils-0.9.18/irdadump/obex.h0000644000175000017500000000557610454641046016160 0ustar samuelsamuel/********************************************************************* * * Filename: obex.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Mon Apr 12 10:32:56 1999 * Modified at: Wed Apr 21 16:01:44 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #ifndef OBEX_H #define OBEX_H /* OBEX Commands */ #define OBEX_CONNECT 0x00 #define OBEX_DISCONNECT 0x01 #define OBEX_PUT 0x02 #define OBEX_GET 0x03 #define OBEX_COMMAND 0x04 #define OBEX_SETPATH 0x05 #define OBEX_ABORT 0x7f /* OBEX Responses */ #define OBEX_CONTINUE 0x10 #define OBEX_SWITCH_PRO 0x11 #define OBEX_SUCCESS 0x20 #define OBEX_CREATED 0x21 #define OBEX_ACCEPTED 0x22 #define OBEX_BAD_REQUEST 0x40 #define OBEX_FORBIDDEN 0x43 #define OBEX_CONFLICT 0x49 #define OBEX_INTERNAL_SERVER_ERROR 0x50 #define OBEX_NOT_IMPLEMENTED 0x51 #define OBEX_DATABASE_FULL 0x60 #define OBEX_DATABASE_LOCKED 0x61 #define HEADER_COUNT 0xc0 #define HEADER_NAME 0x01 /* - */ #define HEADER_ANAME 0x31 /* Same as HEADER_NAME, but in ASCII */ #define HEADER_TYPE 0x42 /* - */ #define HEADER_TIME 0x44 #define HEADER_LENGTH 0xc3 /* - */ #define HEADER_DESCRIPTION 0x05 /* - */ #define HEADER_TARGET 0x46 /* - */ #define HEADER_BODY 0x48 /* - */ #define HEADER_BODY_END 0x49 /* - */ #define OBEX_HI_MASK 0xc0 #define OBEX_UNICODE 0x00 #define OBEX_BYTE_STREAM 0x40 #define OBEX_BYTE 0x80 #define OBEX_INT 0xc0 #define OBEX_FINAL 0x80 /* Connect header */ struct obex_connect_frame { guint8 opcode; guint16 len; guint8 version; guint8 flags; guint16 mtu; } __attribute__((packed)); /* Minimal Obex header */ struct obex_minimal_frame { guint8 opcode; guint16 len; } __attribute__((packed)); #endif irda-utils-0.9.18/irdadump/irdadump.c0000644000175000017500000001507710454641046017020 0ustar samuelsamuel/********************************************************************* * * Filename: irdadump.c * Version: 0.6.1 * Description: irdadump sniffs IrDA frames, and is inspired by tcpdump * Status: Experimental. * Author: Dag Brattli * Created at: Sun Oct 4 20:33:05 1998 * Modified at: Wed Jan 19 11:03:32 2000 * Modified by: Dag Brattli * * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 2002-2003 Jean Tourrilhes, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include #include #include #include #include #include #include #include #include /* htons */ #include #include #include /* strncpy */ #include /* perror */ #include /* exit */ #include #include "capture.h" #include "irdadump.h" int config_print_diff = 0; int config_dump_frame = 0; int config_print_irlap = 1; int config_print_irlmp = 1; int config_print_lost_frames = 0; int config_snaplen = 32; int config_dump_bytes = 0; int config_snapcols = 16; int config_force_ttp = 0; int config_capturewrite = -1; int config_captureread = -1; int verbose = 0; int ifindex = 0; GNetBuf *frame_buf; struct timeval time1, time2; struct timeval *curr_time, *prev_time, *tmp_time; int fd = -1; /* * Function print_time (tvp) * * Print current time * */ inline void print_time(const struct timeval *timev, GString *str) { int s; s = (timev->tv_sec) % 86400; /* Modulo is not a proper modulo for negative ints */ if(s < 0) s += 86400; g_string_sprintfa(str, "%02d:%02d:%02d.%06u ", s / 3600, (s % 3600) / 60, s % 60, (u_int32_t) timev->tv_usec); } /* * Function print_diff_time (time, prev_time) * * Print the difference in time between this frame and the previous one * */ inline void print_diff_time(struct timeval *timev, struct timeval *prev_timev, GString *str) { float diff; if (prev_timev->tv_usec > timev->tv_usec) { timev->tv_usec += 1000000; timev->tv_sec--; } prev_timev->tv_usec = timev->tv_usec - prev_timev->tv_usec; prev_timev->tv_sec = timev->tv_sec - prev_timev->tv_sec; diff = ((float) prev_timev->tv_sec * 1000000 + prev_timev->tv_usec) / 1000.0; g_string_sprintfa(str, "(%07.2f ms) ", diff); } /* * Function irdadump_init () * * * */ int irdadump_init(char *ifdev) { struct ifreq ifr; /* Zero state of parser */ irlap_init(); curr_time = &time1; prev_time = &time2; /* Get time, so the first time diff is right */ gettimeofday(prev_time, (struct timezone*) 0); /* * Create socket, we must use SOCK_DGRAM to get the link level header * that we are interested in */ fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)); if (fd < 0) { return fd; } if (ifdev) { strncpy(ifr.ifr_name, ifdev, IFNAMSIZ); if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) { perror("ioctl"); exit(-1); } ifindex = ifr.ifr_ifindex; } frame_buf = g_netbuf_new(MAX_FRAME_SIZE); return fd; } /* * Function parse_irda_frame (buf, len) * * Do the various kind of parsing we need on this frame. * */ void parse_irda_frame(int type, GNetBuf *buf, int len, GString *str) { /* Captured time (more or less always Rx/Tx time) */ print_time(curr_time, str); if (config_print_diff) { print_diff_time(curr_time, prev_time, str); /* Swap */ tmp_time = prev_time; prev_time = curr_time; curr_time = tmp_time; } /* Full IrDA decoding of Frame */ if (config_print_irlap) parse_irlap_frame(type, buf, str); /* Overall size */ g_string_sprintfa(str, "(%d) ", len); /* Byte dumps */ if (config_dump_frame) { int i, maxlen; char c; g_string_append(str, "\n\t"); maxlen = (len < config_snaplen) ? len : config_snaplen; for (i=0;ihead[i]); g_string_append(str, "\n\t"); for (i=0;ihead[i]; if (c < 32 || c > 126) c='.'; g_string_sprintfa(str, " %c", c); } } if (config_dump_bytes) { int i, maxlen; maxlen = (len < config_snaplen) ? len : config_snaplen; for (i=0;ihead[i]); } } } /* * Function irdadump_loop () * * * */ int irdadump_loop(GString *str) { struct sockaddr_ll from; socklen_t fromlen; int len; g_netbuf_recycle(frame_buf); /* Read packets from capture file */ if (config_captureread >= 0) { int dir; int prot; int ret; ret = capread_get(config_captureread, frame_buf, &len, &dir, &prot, curr_time); if(ret < 0) { perror("read capture file"); exit(-1); } /* Filter away all non IrDA frames */ if (prot != ETH_P_IRDA) return -1; /* Filter away empty frames (forced speed change) */ if (len == 0) return -1; /* Data should be fine now */ g_netbuf_put(frame_buf, len); /* Regular parsing */ parse_irda_frame(dir, frame_buf, len, str); return(0); } /* Extract packet from socket */ fromlen = sizeof(struct sockaddr_ll); len = recvfrom(fd, frame_buf->data, MAX_FRAME_SIZE, 0, (struct sockaddr *) &from, &fromlen); if (len < 0) { g_message("recvfrom"); exit(-1); } /* Filter away all non IrDA frames */ if (from.sll_protocol != ntohs(ETH_P_IRDA)) return -1; /* Filter away frames from other IrDA interfaces */ if (ifindex && (from.sll_ifindex != ifindex)) return -1; /* Filter away empty frames (forced speed change) */ if (len == 0) return -1; /* Data should be fine now */ g_netbuf_put(frame_buf, len); /* Get time from packet */ if (ioctl(fd, SIOCGSTAMP, curr_time) < 0) { perror("ioctl"); exit(-1); } /* Regular parsings */ parse_irda_frame(from.sll_pkttype, frame_buf, len, str); /* Write packet into cature file if needed */ if (config_capturewrite >= 0) { capwrite_dump(config_capturewrite, frame_buf, len, &from, curr_time); } return 0; } irda-utils-0.9.18/irdadump/AUTHORS0000644000175000017500000000000010454641046016073 0ustar samuelsamuelirda-utils-0.9.18/irdadump/ChangeLog0000644000175000017500000000173710454641046016617 0ustar samuelsamuel2003-12-9 JeanII * Minor fixes 2003-11-21 JeanII * Migrate config to libglib 2.0 * Add -w to write out libpcap files * Add -r to read libpcap file * Reorg code, spin irlap.c out of irdadump.c 2002-10-10 JeanII * Get rid of compiler warnings * Avoid printing negative time * Add -p flag to disable parsing * Detect zero bitfields, workaround * Detect fragmented Obex packet, print {unterminated} * Parse headers of OBEX_CONTINUE packets 2002-04-04 JeanII * Fix and enable IrCOMM decoding (including IrLPT) * Add Extra IrCOMM parameters * IrNET decoding (minimal) * Decode IrLAP QoS parameters (on snrm:cmd & ua:rsp) 2002-04-03 JeanII * Add dump_bytes format (idea from Timothy Kilbourn) * Negative snaplen set to max (2050 bytes) * Add forcing TTP decoding * Garbage collect TTP connections on LAP closure This doesn't fix all problems, but is an improvement * Move TTP decoding in irlmp.c * Properly remove LMP control header (-> decode TTP connect properly) irda-utils-0.9.18/irdadump/irlap.c0000644000175000017500000004476210454641046016325 0ustar samuelsamuel/********************************************************************* * * Filename: irlap.c * Version: 0.6.1 * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Oct 4 20:33:05 1998 * Modified at: Wed Jan 19 11:03:32 2000 * Modified by: Dag Brattli * * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 2002-2003 Jean Tourrilhes, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include #include #include /* For strstr */ #include /* For printf */ #include #include "irdadump.h" int self_nr = 0; int self_ns = 0; int peer_nr = 0; int peer_ns = 0; struct ias_query last_ias; struct lsap_state conn[MAX_CONNECTIONS]; int conn_cache = -1; /* * Function find_connection (slsap_sel, dlsap_sel) * * * */ int find_connection(guint8 slsap_sel, guint8 dlsap_sel) { int i; /* Try cache first */ if (conn_cache != -1) { if ((conn[conn_cache].slsap_sel == slsap_sel) && (conn[conn_cache].dlsap_sel == dlsap_sel)) return conn_cache; } /* Just have to do linear search then */ for (i=0;i>=1; bit_index--; } return bit_index; } static inline guint32 byte_value(guint16 byte, guint32 *array) { int bit_index; bit_index = msb_index(byte); return index_value(bit_index, array); } void parse_irlap_params(guint8 clen, GNetBuf *buf, GString *str) { guint pi, pl; guint pv_byte; guint n = 0; g_string_append(str, "\n\tLAP QoS: "); while (n < clen) { pi = buf->data[n] & 0x7f; /* Remove critical bit */ pl = buf->data[n+1]; switch (pi) { case PI_BAUD_RATE: pv_byte = buf->data[n+2]; if(pl >= 2) pv_byte |= buf->data[n+3] << 8; g_string_sprintfa(str, "Baud Rate=%dbps ", byte_value(pv_byte, baud_rates)); break; case PI_MAX_TURN_TIME: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Max Turn Time=%dms ", byte_value(pv_byte, max_turn_times)); break; case PI_DATA_SIZE: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Data Size=%dB ", byte_value(pv_byte, data_sizes)); break; case PI_WINDOW_SIZE: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Window Size=%d ", byte_value(pv_byte, window_sizes)); break; case PI_ADD_BOFS: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Add BOFS=%d ", byte_value(pv_byte, add_bofs)); break; case PI_MIN_TURN_TIME: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Min Turn Time=%dus ", byte_value(pv_byte, min_turn_times)); break; case PI_LINK_DISC: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Link Disc=%ds ", byte_value(pv_byte, link_disc_times)); break; default: break; } n += pl+2; } g_netbuf_pull(buf, clen); } /* * Function parse_hints (hint) * * Parse and print the names of the various hint bits if they are set * */ inline void parse_hints(guint8 *hint, GString *str) { g_string_append(str, "[ "); if (hint[0] & HINT_PNP) g_string_append(str, "PnP "); if (hint[0] & HINT_PDA) g_string_append(str, "PDA/Palmtop "); if (hint[0] & HINT_COMPUTER) g_string_append(str, "Computer "); if (hint[0] & HINT_PRINTER) g_string_append(str, "Printer "); if (hint[0] & HINT_MODEM) g_string_append(str, "Modem "); if (hint[0] & HINT_FAX) g_string_append(str, "Fax "); if (hint[0] & HINT_LAN) g_string_append(str, "LAN Access "); if (hint[1] & HINT_TELEPHONY) g_string_append(str, "Telephony "); if (hint[1] & HINT_FILE_SERVER) g_string_append(str, "File Server "); if (hint[1] & HINT_COMM) g_string_append(str, "IrCOMM "); if (hint[1] & HINT_OBEX) g_string_append(str, "IrOBEX "); g_string_append(str, "] "); } /* * Function parse_xid_frame (command, pf, buf, len) * * Exchange station identification frame * */ inline void parse_xid_frame(guint8 command, guint8 pf, int type, GNetBuf *buf, GString *str) { struct xid_frame *frame = (struct xid_frame *) buf->data; guint8 S,s; guint32 saddr, daddr; char *info = NULL; guint8 hint[2]; /* Kill "unused" warning */ pf = pf; hint[0] = hint[1] = 0; saddr = GINT32_FROM_LE(frame->saddr); daddr = GINT32_FROM_LE(frame->daddr); switch(frame->flags) { case 0x00: S = 1; break; case 0x01: S = 6; break; case 0x02: S = 8; break; case 0x03: S = 16; break; default: S = 0; } s = frame->slotnr; /* * The last of the discovery command frames, and response frames * contains info */ if ((s == 0xff) || (!command)) { hint[0] = frame->discovery_info[0]; if (hint[0] & 0x80) { hint[1] = frame->discovery_info[1]; info = (char *) frame->discovery_info+3; } else info = (char *) frame->discovery_info+2; /* Terminate string */ buf->data[buf->len] = '\0'; } if (type) g_string_sprintfa(str, "xid:%s %08x > %08x S=%d ", command?"cmd":"rsp", saddr, daddr, S); else g_string_sprintfa(str, "xid:%s %08x < %08x S=%d ", command?"cmd":"rsp", daddr, saddr, S); /* Printing a * instead of 255 makes things more aligned */ if (s == 0xff) g_string_append(str, "s=* "); else g_string_sprintfa(str, "s=%d ", s); /* Print info if any */ if (info) { g_string_sprintfa(str, "%s hint=%02x%02x ", info, hint[0], hint[1]); parse_hints(hint, str); } } /* * Function parse_i_frame (buf, len, u_char) * * Information frames * */ inline void parse_i_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr, ns; nr = buf->data[1] >> 5; /* Next to receive */ ns = (buf->data[1] >> 1) & 0x07; /* Next to send */ /* Remove IrLAP header */ g_netbuf_pull(buf, 2); g_string_sprintfa(str, "i:%s %s ca=%02x pf=%d nr=%d ns=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf, nr, ns); /* Check if we should print IrLMP information */ if (config_print_irlmp) parse_irlmp(buf, str, caddr, type, cmd); if (config_print_lost_frames) { if (type) { self_nr = nr; if (self_nr != ((peer_ns + 1) % 8)) { g_string_sprintfa(str, "** %d frame(s) lost ** ", (peer_ns + 1 > self_nr) ? peer_ns + 1 - self_nr : peer_ns + 9 - self_nr); } if (ns != ((self_ns + 1) % 8)) { g_string_append(str, "** retransmit ** "); } self_ns = ns; } else { peer_nr = nr; if (peer_nr != ((self_ns + 1) % 8)) { g_string_sprintfa(str, "** %d frame(s) lost ** ", (self_ns + 1 > peer_nr) ? self_ns + 1 - peer_nr : self_ns + 9 - peer_nr); } if (ns != ((peer_ns + 1) % 8)) { g_string_append(str, "** retransmit **"); } peer_ns = ns; } } } /* * Function parse_ui_frame (buf, len, u_char) * * Information frames * */ inline void parse_ui_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { /* Remove IrLAP header */ g_netbuf_pull(buf, 2); g_string_sprintfa(str, "ui:%s %s ca=%02x pf=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf); /* Check if we should print IrLMP information */ if (config_print_irlmp) parse_ui_irlmp(buf, str, type); } /* * Function parse_frmr_frame (caddr, cmd, pf, type, frame, len) * * Frame reject frame * */ inline void parse_frmr_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr, ns; guint8 ctrl; ctrl = buf->data[1]; nr = buf->data[2] >> 5; /* Next to receive */ ns = (buf->data[2] >> 1) & 0x07; /* Next to send */ g_string_sprintfa(str, "frmr:%s %s ca=%02x pf=%d ctrl=%02x, nr=%d ns=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, ctrl, nr, pf, ns); } /* * Function parse_rr_frame (caddr, cmd, pf, type, frame, len) * * Receive ready frame * */ inline void parse_rr_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr; nr = buf->data[1] >> 5; /* Next to receive */ g_string_sprintfa(str, "rr:%s %s ca=%02x pf=%d nr=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf, nr); if (config_print_lost_frames) { if (type) { self_nr = nr; if (self_nr != ((peer_ns + 1) % 8)) { g_string_sprintfa(str, "** %d frame(s) lost ** ", (peer_ns + 1 > self_nr) ? peer_ns + 1 - self_nr : peer_ns + 9 - self_nr); } } else { peer_nr = nr; if (peer_nr != ((self_ns + 1) % 8)) { g_string_sprintfa(str, "** %d frame(s) lost ** ", (self_ns + 1 > peer_nr) ? self_ns + 1 - peer_nr : self_ns + 9 - peer_nr); } } } } /* * Function parse_rnr_frame (caddr, cmd, pf, type, frame, len) * * Receive not ready frame * */ inline void parse_rnr_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr; nr = buf->data[1] >> 5; /* Next to receive */ g_string_sprintfa(str, "rnr:%s %s ca=%02x pf=%d nr=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf, nr); } /* * Function parse_rej_frame (caddr, cmd, pf, type, frame, len) * * Reject frame * */ inline void parse_rej_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr; nr = buf->data[1] >> 5; /* Next to receive */ g_string_sprintfa(str, "rej:%s %s ca=%02x pf=%d nr=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf, nr); } /* * Function parse_srej_frame (caddr, cmd, pf, type, frame, len) * * Selective reject frame * */ inline void parse_srej_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { int nr; nr = buf->data[1] >> 5; /* Next to receive */ g_string_sprintfa(str, "srej:%s %s ca=%02x pf=%d nr=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf, nr); } /* * Function parse_ua_frame (caddr, cmd, pf, type, frame, len) * * Unnumbered acknowledgement frame * */ inline void parse_ua_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { struct ua_frame *frame = (struct ua_frame *) buf->data; gint32 saddr, daddr; int len; saddr = GINT32_FROM_LE(frame->saddr); daddr = GINT32_FROM_LE(frame->daddr); if (type) g_string_sprintfa(str, "ua:%s ca=%02x pf=%d %08x > %08x ", cmd?"cmd":"rsp", caddr, pf, saddr, daddr); else g_string_sprintfa(str, "ua:%s ca=%02x pf=%d %08x < %08x ", cmd?"cmd":"rsp", caddr, pf, daddr, saddr); /* Remove IrLAP header */ g_netbuf_pull(buf, sizeof(struct ua_frame)); /* Check for I field */ len = g_netbuf_get_len(buf); if(len != 0) { parse_irlap_params(len, buf, str); } } /* * Function parse_disc_frame (caddr, cmd, pf, type, frame, len) * * Disconnect frame * */ inline void parse_disc_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { /* Kill "unused" warning */ buf = buf; g_string_sprintfa(str, "disc:%s %s ca=%#02x pf=%d ", cmd ? "cmd" : "rsp", type ? ">" : "<", caddr, pf); /* LAP is closing, remove all zombies connections on this LAP */ garbage_connection(caddr); } /* * Function parse_dm_frame (caddr, cmd, pf, type, frame, len) * * Disconnected mode frame * */ inline void parse_dm_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { /* Kill "unused" warning */ buf = buf; g_string_sprintfa(str, "dm:%s %s ca=%#02x pf=%d ", cmd?"cmd":"rsp", type ? ">" : "<", caddr, pf); } /* * Function parse_rd_frame (caddr, cmd, pf, type, buf, str) * * Request disconnect frame * */ inline void parse_rd_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { /* Kill "unused" warning */ buf = buf; g_string_sprintfa(str, "rd:%s %s ca=%#02x pf=%d ", cmd?"cmd":"rsp", type ? ">" : "<", caddr, pf); } /* * Function parse_test_frame (caddr, cmd, pf, type, buf, str) * * Test frame * */ inline void parse_test_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { struct test_frame *frame = (struct test_frame *) buf->data; gint32 saddr, daddr; saddr = GINT32_FROM_LE(frame->saddr); daddr = GINT32_FROM_LE(frame->daddr); g_string_sprintfa(str, "test:%s ca=%#02x pf=%d %08x %s %08x ", cmd?"cmd":"rsp", caddr, pf, saddr, type ? ">" : "<", daddr); } /* * Function parse_snrm_frame (caddr, cmd, pf, type, frame, len) * * Set normal response mode frame * */ inline void parse_snrm_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { struct snrm_frame *frame = (struct snrm_frame *) buf->data; gint32 saddr, daddr; guint8 new_caddr; int len; saddr = GINT32_FROM_LE(frame->saddr); daddr = GINT32_FROM_LE(frame->daddr); new_caddr = frame->ncaddr; /* Which direction? */ if (type) g_string_sprintfa(str, "snrm:%s ca=%02x pf=%d %08x > " "%08x new-ca=%02x ", cmd ? "cmd" : "rsp", caddr, pf, saddr, daddr, new_caddr); else g_string_sprintfa(str, "snrm:%s ca=%02x pf=%d %08x < " "%08x new-ca=%02x ", cmd ? "cmd" : "rsp", caddr, pf, daddr, saddr, new_caddr); /* Remove IrLAP header */ g_netbuf_pull(buf, sizeof(struct snrm_frame)); /* Check for I field */ len = g_netbuf_get_len(buf); if(len != 0) { parse_irlap_params(len, buf, str); } } /* * Function parse_rnrm_frame (caddr, cmd, pf, type, frame, len) * * Request normal response mode * */ inline void parse_rnrm_frame(guint8 caddr, guint8 cmd, guint8 pf, int type, GNetBuf *buf, GString *str) { gint32 saddr, daddr; struct rnrm_frame *frame = (struct rnrm_frame *) buf->data; saddr = GINT32_FROM_LE(frame->saddr); daddr = GINT32_FROM_LE(frame->daddr); g_string_sprintfa(str, "snrm:%s ca=%02x pf=%d %08x %s %08x ", cmd?"cmd":"rsp", caddr, pf, saddr, type?">":"<", daddr); } /* * Function parse_irlap_frame (buf, len) * * Find out what kind of IrDA frame we have received, and dispatch the * right function to handle the frame * */ void parse_irlap_frame(int type, GNetBuf *buf, GString *str) { guint8 ctrl; guint8 cmd; guint8 caddr; guint8 pf; cmd = buf->data[0] & CMD_FRAME; caddr = buf->data[0] & CBROADCAST; pf = (buf->data[1] & PF_BIT) >> 4; ctrl = buf->data[1] & ~PF_BIT; /* Mask away poll/final bit */ /* * Optimize for the common case and check if the frame is an * I(nformation) frame. Only I-frames have bit 0 set to 0 */ if (~ctrl & 0x01) { parse_i_frame(caddr, cmd, pf, type, buf, str); return; } /* * We now check is the frame is an S(upervisory) frame. Only * S-frames have bit 0 set to 1 and bit 1 set to 0 */ if (~ctrl & 0x02) { /* * Received S(upervisory) frame, check which frame type it is * only the first nibble is of interest */ switch (ctrl & 0x0f) { case RR: parse_rr_frame(caddr, cmd, pf, type, buf, str); break; case RNR: parse_rnr_frame(caddr, cmd, pf, type, buf, str); break; case REJ: parse_rej_frame(caddr, cmd, pf, type, buf, str); break; case SREJ: parse_srej_frame(caddr, cmd, pf, type, buf, str); break; default: g_string_sprintfa(str, "Unknown S frame %02x received!\n", ctrl); break; } return; } /* * This must be a C(ontrol) frame */ switch(ctrl) { case XID_RSP: parse_xid_frame(cmd, pf, type, buf, str); break; case XID_CMD: parse_xid_frame(cmd, pf, type, buf, str); break; case SNRM_CMD: if (cmd) parse_snrm_frame(caddr, cmd, pf, type, buf, str); else parse_rnrm_frame(caddr, cmd, pf, type, buf, str); break; case DM_RSP: parse_dm_frame(caddr, cmd, pf, type, buf, str); break; case DISC_CMD: if (cmd) parse_disc_frame(caddr, cmd, pf, type, buf, str); else parse_rd_frame(caddr, cmd, pf, type, buf, str); break; case TEST_CMD: parse_test_frame(caddr, cmd, pf, type, buf, str); break; case UA_RSP: parse_ua_frame(caddr, cmd, pf, type, buf, str); break; case FRMR_RSP: parse_frmr_frame(caddr, cmd, pf, type, buf, str); break; case UI_FRAME: parse_ui_frame(caddr, cmd, pf, type, buf, str); break; default: g_string_sprintfa(str, "Unknown frame %02x received!\n", ctrl); break; } } int irlap_init(void) { memset(&last_ias, 0, sizeof(struct ias_query)); memset(&conn, 0, sizeof(struct lsap_state)); return(1); } irda-utils-0.9.18/irdadump/capture.h0000644000175000017500000000321210454641046016647 0ustar samuelsamuel/********************************************************************* * * Filename: capture.h * Version: * Description: * Status: Experimental. * Author: Jan Kiszka * Created at: Thu Jul 17 16:32:35 PDT 2003 * Modified at: Thu Jul 17 16:32:35 PDT 2003 * Modified by: Jean Tourrilhes * * Copyright (c) 1999 Jan Kiszka, All Rights Reserved. * Copyright (c) 2003 Jean Tourrilhes, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #ifndef CAPTURE_H #define CAPTURE_H #include "netbuf.h" struct sockaddr_ll; extern int capwrite_open(char * capfilename); extern void capwrite_close(int capturefile); extern int capwrite_init(int capturefile); extern int capwrite_dump(int capturefile, GNetBuf *frame_buf, int len, struct sockaddr_ll *from, struct timeval *curr_time); extern int capread_open(char * capfilename); extern void capread_close(int capturefile); extern int capread_check(int capturefile); extern int capread_get(int capturefile, GNetBuf *frame_buf, int *plen, int *pdir, int *pprot, struct timeval *curr_time); #endif irda-utils-0.9.18/irdadump/irdadump.h0000644000175000017500000001564010454641046017021 0ustar samuelsamuel/********************************************************************* * * Filename: irdadump.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Tue Feb 16 13:31:29 1999 * Modified at: Wed Dec 8 09:45:35 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #ifndef IRDADUMP_H #define IRDADUMP_H #include #ifndef AF_IRDA # define PF_IRDA 23 /* */ # define AF_IRDA PF_IRDA #endif #ifndef ARPHRD_IRDA # define ARPHRD_IRDA 783 #endif #ifndef ETH_P_IRDA # define ETH_P_IRDA 0x0017 #endif #define MAX_FRAME_SIZE 2050 #define IRADDR_ANY 0xffffffff /* Frame types and templates */ #define INVALID 0xff /* Unnumbered (U) commands */ #define SNRM_CMD 0x83 /* Set Normal Response Mode */ #define DISC_CMD 0x43 /* Disconnect */ #define XID_CMD 0x2f /* Exchange Station Identification */ #define TEST_CMD 0xe3 /* Test */ /* Unnumbered responses */ #define RNRM_RSP 0x83 /* Request Normal Response Mode */ #define UA_RSP 0x63 /* Unnumbered Acknowledgement */ #define FRMR_RSP 0x87 /* Frame Reject */ #define DM_RSP 0x0f /* Disconnect Mode */ #define RD_RSP 0x43 /* Request Disconnection */ #define XID_RSP 0xaf /* Exchange Station Identification */ #define TEST_RSP 0xe3 /* Test frame */ /* Supervisory (S) */ #define RR 0x01 /* Receive Ready */ #define REJ 0x09 /* Reject */ #define RNR 0x05 /* Receive Not Ready */ #define SREJ 0x0d /* Selective Reject */ /* Information (I) */ #define I_FRAME 0x00 /* Information Format */ #define UI_FRAME 0x03 /* Unnumbered Information */ #define CMD_FRAME 0x01 #define RSP_FRAME 0x00 #define PF_BIT 0x10 /* Poll/final bit */ #define BROADCAST 0xffffffff /* Broadcast device address */ #define CBROADCAST 0xfe /* Connection broadcast address */ /* IrLMP frame opcodes */ #define CONNECT_CMD 0x01 #define CONNECT_RSP 0x81 #define DISCONNECT 0x02 #define ACCESSMODE_CMD 0x03 #define ACCESSMODE_RSP 0x83 #define CONTROL_BIT 0x80 /* LSAP-SEL's */ #define LSAP_MASK 0x7f #define LSAP_IAS 0x00 #define LSAP_ANY 0xff #define IAP_LST 0x80 #define IAP_ACK 0x40 /* IrIAP Op-codes */ #define GET_INFO_BASE 0x01 #define GET_OBJECTS 0x02 #define GET_VALUE 0x03 #define GET_VALUE_BY_CLASS 0x04 #define GET_OBJECT_INFO 0x05 #define GET_ATTRIB_NAMES 0x06 #define IAS_SUCCESS 0x00 #define IAS_CLASS_UNKNOWN 0x01 #define IAS_ATTRIB_UNKNOWN 0x02 /* LM-IAS Attribute types */ #define IAS_MISSING 0 #define IAS_INTEGER 1 #define IAS_OCT_SEQ 2 #define IAS_STRING 3 /* LAP parameters definitions (high bit masked) */ #define PI_BAUD_RATE 0x01 #define PI_MAX_TURN_TIME 0x02 #define PI_DATA_SIZE 0x03 #define PI_WINDOW_SIZE 0x04 #define PI_ADD_BOFS 0x05 #define PI_MIN_TURN_TIME 0x06 #define PI_LINK_DISC 0x08 #define IR_115200_MAX 0x3f /* Baud rates (first byte) */ #define IR_2400 0x01 #define IR_9600 0x02 #define IR_19200 0x04 #define IR_38400 0x08 #define IR_57600 0x10 #define IR_115200 0x20 #define IR_576000 0x40 #define IR_1152000 0x80 /* Baud rates (second byte) */ #define IR_4000000 0x01 #define IR_16000000 0x02 struct xid_frame { guint8 caddr; /* Connection address */ guint8 control; guint8 ident; /* Should always be XID_FORMAT */ guint32 saddr; /* Source device address */ guint32 daddr; /* Destination device address */ guint8 flags; /* Discovery flags */ guint8 slotnr; guint8 version; guint8 discovery_info[0]; } __attribute__((packed)); struct test_frame { guint8 caddr; /* Connection address */ guint8 control; guint32 saddr; /* Source device address */ guint32 daddr; /* Destination device address */ guint8 info[0]; /* Information */ } __attribute__((packed)); struct ua_frame { guint8 caddr; guint8 control; guint32 saddr; /* Source device address */ guint32 daddr; /* Dest device address */ guint8 params[0]; } __attribute__((packed)); struct i_frame { guint8 caddr; guint8 control; guint8 data[0]; } __attribute__((packed)); struct s_frame { guint8 caddr; guint8 control; } __attribute__((packed)); struct rnrm_frame { guint8 caddr; /* Connection address */ guint8 control; guint32 saddr; /* Source device address */ guint32 daddr; /* Destination device address */ }__attribute__((packed)); struct snrm_frame { guint8 caddr; guint8 control; guint32 saddr; guint32 daddr; guint8 ncaddr; guint8 params[0]; } __attribute__((packed)); #define MAX_CONNECTIONS 15 struct ias_query { guint8 lsap_sel; int ttp; int obex; int ircomm; int irnet; }; struct lsap_state { gboolean valid; /* Is this a valid connection */ gboolean ttp; /* True if TTP connection */ gboolean obex; /* True if OBEX connection */ gboolean ircomm; /* True if IrCOMM/IrLTP connection */ gboolean irnet; /* True if IrNET connection */ guint32 saddr; /* Source device address */ guint32 daddr; /* Destination device address */ guint8 slsap_sel; /* Source logical service access point */ guint8 dlsap_sel; /* Destination logical service access point */ guint8 caddr; /* LAP connection address (for garbage collect) */ }; inline void parse_obex(GNetBuf *buf, GString *str, int cmd); inline void parse_irlmp(GNetBuf *buf, GString *str, guint8 caddr, int type, int cmd); inline void parse_ui_irlmp(GNetBuf *buf, GString *str, int type); void parse_ircomm_params(guint8 clen, GNetBuf *buf, GString *str); void parse_ircomm_connect(GNetBuf *buf, GString *str); void parse_ircomm_lmp(GNetBuf *buf, GString *str); void parse_ircomm_ttp(GNetBuf *buf, GString *str); int find_connection(guint8 slsap_sel, guint8 dlsap_sel); int find_free_connection(void); void parse_irlap_frame(int type, GNetBuf *buf, GString *str); int irlap_init(void); int irdadump_init(char *ifdev); int irdadump_loop(GString *str); /* Configuration options */ extern int config_print_diff; extern int config_print_irlap; extern int config_dump_frame; extern int config_print_irlap; extern int config_print_irlmp; extern int config_print_lost_frames; extern int config_snaplen; extern int config_dump_bytes; extern int config_snapcols; extern int config_force_ttp; extern int config_capturewrite; extern int config_captureread; #endif /* IRDADUMP_H */ irda-utils-0.9.18/irdadump/README0000644000175000017500000000507010454641046015717 0ustar samuelsamuelIRDADUMP 0.4.6 Dag Brattli University of Troms, Norway dagb@cs.uit.no http://www.cs.uit.no/linux-irda/irda-utils/ Irdadump is a tool for monitoring the IrDA traffic on one or more links. Just write "make" to compile the program. When you run the program, you should be able to see the IrDA traffic (if any). EXAMPLES: The output should look something like this: / # ./irdadump 20:11:45.412199 xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:45.492137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:45.572137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:45.652208 xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:45.732137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:45.812137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:45.892175 xid:cmd 0x0015c23b > 0xffffffff S=6 s=255 Linux 20:11:45.902362 xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=5 ACTiSYS IR100M 20:11:48.412197 xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:48.492656 xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:48.572177 xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:48.652169 xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:48.732177 xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:48.812153 xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:48.822371 xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=4 ACTiSYS IR100M 15 packets received by filter Turning on the "-d" option will make irdadump print the time difference between the current and the previous frame: / # ./irdadump -d 20:11:18.412475 (0982.06 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:18.492345 (0079.87 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:18.572376 (0080.03 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:18.652979 (0080.60 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:18.732354 (0079.38 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:18.755093 (0022.74 ms) xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=3 ACTiSYS IR100M 20:11:18.812350 (0057.26 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:18.892518 (0080.17 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=255 Linux 20:11:21.412486 (2519.97 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:21.492395 (0079.91 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:21.572368 (0079.97 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:21.652405 (0080.04 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:21.732458 (0080.05 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:21.812454 (0080.00 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:21.892433 (0079.98 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=255 Linux 20:11:21.902301 (0009.87 ms) xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=5 ACTiSYS IR100M 16 packets received by filter irda-utils-0.9.18/irdadump/irlmp.c0000644000175000017500000002534110454641046016331 0ustar samuelsamuel/********************************************************************* * * Filename: irlmp.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Wed Mar 31 15:30:46 1999 * Modified at: Wed Dec 8 09:46:16 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include /* For strstr */ #include /* For printf */ #include #include "irdadump.h" extern struct ias_query last_ias; extern struct lsap_state conn[]; /* * Function parse_iriap (buf) * * Try to parse and print the LM-IAS query * */ inline void parse_iriap_command(GNetBuf *buf, GString *str, guint8 slsap_sel) { guint8 opcode; char name[255]; char attr[255]; int n = 0; int name_len; int attr_len; /* Kill "unused" warning */ slsap_sel = slsap_sel; opcode = buf->data[n++]; opcode &= ~IAP_LST; /* Mask away LST bit */ switch (opcode) { case GET_INFO_BASE: case GET_VALUE_BY_CLASS: name_len = buf->data[n++]; memcpy( name, buf->data+n, name_len); n+=name_len; name[name_len] = '\0'; attr_len = buf->data[n++]; memcpy( attr, buf->data+n, attr_len); n+=attr_len; attr[attr_len] = '\0'; g_string_sprintfa(str, "GET_VALUE_BY_CLASS: \"%s\" \"%s\" ", name, attr); /* Check if this is a TinyTP lookup */ if (strstr(attr, "TinyTP")) last_ias.ttp = 1; else last_ias.ttp = 0; /* Reset to undefined (handle IAS failures properly) */ last_ias.lsap_sel = LSAP_ANY; /* Check if this is a OBEX lookup */ if (strstr(name, "OBEX")) last_ias.obex = 1; else last_ias.obex = 0; /* Check if this is a IrCOMM lookup */ if (strstr(name, "IrCOMM") || strstr(name, "IrLPT")) last_ias.ircomm = 1; else last_ias.ircomm = 0; /* Check if this is a IrNET lookup */ if (strstr(name, "IrNet")) last_ias.irnet = 1; else last_ias.irnet = 0; break; default: break; } } /* * Function parse_irias_value (buf) * * * */ void parse_irias_value(GNetBuf *buf, GString *str) { char string[255]; int n = 0; int charset; guint32 value_len; guint32 tmp_cpu32; guint16 tmp_cpu16; guint16 obj_id; guint16 len; guint8 type; /* Get length, MSB first */ memcpy(&len, buf->data+n, 2); n += 2; len = GUINT16_FROM_BE(len); /* Get object ID, MSB first */ memcpy(&obj_id, buf->data+n, 2); n += 2; obj_id = GUINT16_FROM_BE(obj_id); type = buf->data[n++]; switch(type) { case IAS_INTEGER: memcpy(&tmp_cpu32, buf->data+n, 4); n += 4; tmp_cpu32 = GUINT32_FROM_BE(tmp_cpu32); /* Legal values restricted to 0x01-0x6f, page 15 irttp */ g_string_sprintfa(str, "Integer: %02x ", tmp_cpu32); last_ias.lsap_sel = tmp_cpu32; break; case IAS_STRING: charset = buf->data[n++]; switch (charset) { case CS_ASCII: break; case CS_ISO_8859_1: case CS_ISO_8859_2: case CS_ISO_8859_3: case CS_ISO_8859_4: case CS_ISO_8859_5: case CS_ISO_8859_6: case CS_ISO_8859_7: case CS_ISO_8859_8: case CS_ISO_8859_9: case CS_UNICODE: default: break; } value_len = buf->data[n++]; /* Make sure the string is null-terminated */ memcpy(string, buf->data+n, value_len); string[value_len] = 0x00; g_string_sprintfa(str, "String: %s ", string); break; case IAS_OCT_SEQ: memcpy(&tmp_cpu16, buf->data+n, 2); n += 2; tmp_cpu16 = GUINT16_FROM_BE(tmp_cpu16); value_len = tmp_cpu16; g_netbuf_pull(buf, n); if (last_ias.ircomm) { g_string_append(str, "\n\tIrCOMM Parameters "); parse_ircomm_params(value_len, buf, str); } else g_string_append(str, "N/A "); break; default: g_print("%s() Unknown IAS value type! ", __FUNCTION__); break; } } /* * Function parse_iriap_response (buf) * * * */ inline void parse_iriap_response(GNetBuf *buf, GString *str, guint8 dlsap_sel) { guint8 opcode, rsp; /* Kill "unused" warning */ dlsap_sel = dlsap_sel; opcode = buf->data[0] & ~IAP_LST; /* Mask away LST bit */ rsp = buf->data[1]; g_netbuf_pull(buf, 2); switch(opcode) { case GET_INFO_BASE: g_print("%s() Sorry, GET_INFO_BASE not implemented!\n", __FUNCTION__); break; case GET_VALUE_BY_CLASS: g_string_append(str, "GET_VALUE_BY_CLASS: "); break; default: g_print("%s() Sorry, not implemented!\n", __FUNCTION__); break; } switch(rsp) { case IAS_SUCCESS: g_string_append(str, "Success "); parse_irias_value(buf, str); break; case IAS_CLASS_UNKNOWN: g_string_append(str, "No such class "); break; case IAS_ATTRIB_UNKNOWN: g_string_append(str, "No such attribute "); break; default: g_string_append(str, "Unknown response code "); } } /* * Function parse_irttp (buf, str) * * Parse IrTTP data frame * */ inline void parse_irnet(GNetBuf *buf, GString *str) { /* Kill "unused" warning */ buf = buf; g_string_sprintfa(str, "IrNET "); /* If you want to hook PPP frame decoding, you can do it here. * I don't think it's worth it, PPP has debug capabilities. * Jean II */ } /* * Function parse_irttp (buf, str) * * Parse IrTTP data frame * */ inline void parse_irttp(GNetBuf *buf, GString *str) { g_string_sprintfa(str, "TTP credits=%d ", buf->data[0] & 0x7f); if (buf->data[0] & 0x80) g_string_append(str, "More "); /* Remove TTP header */ g_netbuf_pull(buf, 1); } /* * Function parse_irttp_connect (buf, str) * * Parse IrTTP connect frame * */ inline void parse_irttp_connect(GNetBuf *buf, GString *str) { guint8 plen, pi, pl; guint16 tmp_cpu; g_string_sprintfa(str, "TTP credits=%d ", buf->data[0] & 0x7f); if (buf->data[0] & 0x80) { plen = buf->data[1]; pi = buf->data[2]; pl = buf->data[3]; memcpy(&tmp_cpu, buf->data+4, 2); /* Align value */ tmp_cpu = GUINT16_FROM_BE(tmp_cpu); /* Convert to host order */ /* Remove TTP parameters */ g_netbuf_pull(buf, plen); g_string_sprintfa(str, "MaxSduSize=%d ", tmp_cpu); } /* Remove TTP header */ g_netbuf_pull(buf, 1); } /* * Function parse_irlmp (buf) * * Parse IrLMP frame * */ inline void parse_irlmp(GNetBuf *buf, GString *str, guint8 caddr, int type, int cmd) { guint8 slsap_sel, dlsap_sel; int ctrl; int rsvd; int i; ctrl = buf->data[0] & CONTROL_BIT; dlsap_sel = buf->data[0] & LSAP_MASK; slsap_sel = buf->data[1]; /* Remove IrLMP header */ g_netbuf_pull(buf, 2); g_string_sprintfa(str, "LM slsap=%02x dlsap=%02x ", slsap_sel, dlsap_sel); /* Control or data? */ if (ctrl) { ctrl = buf->data[0]; rsvd = buf->data[1]; /* reason/status/rsvd */ /* Remove IrLMP control header (2 bytes) */ g_netbuf_pull(buf, 2); switch (ctrl) { case CONNECT_CMD: g_string_append(str, "CONN_CMD "); if (dlsap_sel == last_ias.lsap_sel) { i = find_free_connection(); if (i == -1) { printf("No more space for connection!\n"); return; } conn[i].valid = 1; conn[i].caddr = caddr; if (type) { conn[i].slsap_sel = slsap_sel; conn[i].dlsap_sel = dlsap_sel; } else { conn[i].slsap_sel = dlsap_sel; conn[i].dlsap_sel = slsap_sel; } conn[i].ttp = last_ias.ttp; conn[i].obex = last_ias.obex; conn[i].ircomm = last_ias.ircomm; conn[i].irnet = last_ias.irnet; if (conn[i].ttp) parse_irttp_connect(buf, str); if (conn[i].ircomm) parse_ircomm_connect(buf, str); if (conn[i].irnet) parse_irnet(buf, str); } else { if((config_force_ttp) && (dlsap_sel != 0x00)) parse_irttp_connect(buf, str); } break; case CONNECT_RSP: g_string_append(str, "CONN_RSP "); if (type) i = find_connection(slsap_sel, dlsap_sel); else i = find_connection(dlsap_sel, slsap_sel); if (i != -1) { if (conn[i].ttp) parse_irttp_connect(buf, str); if (conn[i].ircomm) parse_ircomm_connect(buf, str); if (conn[i].irnet) parse_irnet(buf, str); } else { if((config_force_ttp) && (slsap_sel != 0x00)) parse_irttp_connect(buf, str); } break; case DISCONNECT: g_string_append(str, "DISC "); /* Mark this connection as invalid */ if (type) i = find_connection(slsap_sel, dlsap_sel); else i = find_connection(dlsap_sel, slsap_sel); if (i != -1) { conn[i].valid = 0; } break; default: break; } } else { /* Check if this is a LM-IAS query */ if (dlsap_sel == 0x00) parse_iriap_command(buf, str, slsap_sel); else if (slsap_sel == 0x00) parse_iriap_response(buf, str, dlsap_sel); /* Find connection */ if (type) i = find_connection(slsap_sel, dlsap_sel); else i = find_connection(dlsap_sel, slsap_sel); if (i != -1) { if (conn[i].valid && conn[i].ttp) parse_irttp(buf, str); if (conn[i].valid && conn[i].obex) parse_obex(buf, str, cmd); if (conn[i].valid && conn[i].ircomm) { if (conn[i].ttp) parse_ircomm_ttp(buf, str); else parse_ircomm_lmp(buf, str); } if (conn[i].valid && conn[i].irnet) parse_irnet(buf, str); } /* Not IAS and unknow connection */ if((dlsap_sel != 0x00) && (slsap_sel != 0x00) && (i == -1)) { if(config_force_ttp) parse_irttp(buf, str); } } } /* * Function parse_ui_irlmp (buf) * * Parse IrLMP frame in UI frame * */ inline void parse_ui_irlmp(GNetBuf *buf, GString *str, int type) { guint8 slsap_sel, dlsap_sel; int ctrl; /* Kill "unused" warning */ type = type; ctrl = buf->data[0] & CONTROL_BIT; dlsap_sel = buf->data[0] & LSAP_MASK; slsap_sel = buf->data[1]; /* Remove IrLMP header */ g_netbuf_pull(buf, 2); g_string_sprintfa(str, "LM slsap=%02x dlsap=%02x ", slsap_sel, dlsap_sel); /* Let's see if it's Ultra, and decode it - Jean II */ if((slsap_sel == 0x70) && (dlsap_sel == 0x70)) { int upid = buf->data[0] & 0x7F; g_netbuf_pull(buf, 1); g_string_sprintfa(str, " Ultra-PID=%02x ", upid); /* Check Obex over Ultra */ if(upid == 0x01) { /* Remove SAR field */ g_netbuf_pull(buf, 1); /* Decode Obex stuff - no connection, always a command */ parse_obex(buf, str, 1); } } } irda-utils-0.9.18/irdadump/netbuf.c0000644000175000017500000001364510454641046016475 0ustar samuelsamuel/********************************************************************* * * Filename: netbuf.c * Version: 0.9 * Description: Network buffer handling routines. * Status: Experimental. * Author: Dag Brattli * Created at: Fri Mar 19 09:07:21 1999 * Modified at: Sat Oct 16 14:53:39 1999 * Modified by: Dag Brattli * Sources: skbuff.c by Alan Cox and * Florian La Roche * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include /* * Function msg_recycle (msg) * * Reuse an already used message. We just reset the state * */ GNetBuf *g_netbuf_recycle(GNetBuf *msg) { msg->data = msg->head; msg->tail = msg->head; msg->len = 0; msg->end = msg->head + msg->truesize; return msg; } /* * Function g_netbuf_new (len) * * Allocate new network buffer * */ GNetBuf *g_netbuf_new(guint len) { GNetBuf *msg; guint8 *buf; msg = g_malloc(sizeof(GNetBuf)); if (msg == NULL) return NULL; memset(msg, 0, sizeof(GNetBuf)); buf = g_malloc(len); if (buf == NULL) { g_free(msg); return NULL; } /* Init */ msg->truesize = len; msg->head = buf; g_netbuf_recycle(msg); return msg; } /* * Function g_netbuf_realloc (msg, len) * * Change the true size of the message * */ GNetBuf *g_netbuf_realloc(GNetBuf *msg, guint len) { guint8 *buf; /* g_print("msg->head=%p\n", msg->head); */ /* g_print("msg->data=%p\n", msg->data); */ /* g_print("msg->tail=%p\n", msg->tail); */ /* g_print("msg->len=%d\n", msg->len); */ /* g_print("msg->truesize=%d\n\n", msg->truesize); */ buf = realloc(msg->head, len); if (buf == NULL) return NULL; msg->truesize = len; msg->data = buf + (msg->data - msg->head); msg->tail = buf + (msg->tail - msg->head); msg->head = buf; msg->end = msg->head + len; /* g_print("msg->head=%p\n", msg->head); */ /* g_print("msg->data=%p\n", msg->data); */ /* g_print("msg->tail=%p\n", msg->tail); */ /* g_print("msg->len=%d\n", msg->len); */ /* g_print("msg->truesize=%d\n", msg->truesize); */ return msg; } /* * Function g_netbuf_free (msg) * * Free message * */ void g_netbuf_free(GNetBuf *msg) { if (!msg) return; if (msg->head) g_free(msg->head); g_free(msg); } /* * Function g_netbuf_put (msg, len) * * Make space for more data into message * */ guint8 *g_netbuf_put(GNetBuf *msg, guint len) { guint8 *tmp = msg->tail; msg->tail += len; msg->len += len; if (msg->tail > msg->end) { g_print("%s(), put over, trying to realloc ...!\n", __FUNCTION__ ); msg = g_netbuf_realloc(msg, msg->truesize+len); if (!msg) return NULL; tmp = msg->tail - len; } return tmp; } guint8 *g_netbuf_put_data(GNetBuf *msg, gint8 *data, guint len) { guint8 *tmp; /* Make room for more data */ tmp = g_netbuf_put(msg, len); /* Copy body data to object */ memcpy(tmp, data, len); return tmp; } /* * Function g_netbuf_push (buf, len) * * Insert new header in front of data * */ guint8 *g_netbuf_push(GNetBuf *msg, guint len) { if ((msg->data - len) < msg->head) { g_print("%s(), pushed under, trying to realloc!\n", __FUNCTION__); msg = g_netbuf_realloc(msg, msg->truesize+len); if (!msg) return NULL; /* Move data with offset len */ g_memmove(msg->data+len, msg->data, msg->len); msg->data = msg->data+len; msg->tail = msg->tail+len; } msg->data -= len; msg->len += len; return msg->data; } /* * Function g_netbuf_prepend_hdr (msg, hdr, len) * * * */ guint8 *g_netbuf_prepend_hdr(GNetBuf *msg, gint8 *hdr, guint len) { guint8 *tmp; /* Make room for header */ tmp = g_netbuf_push(msg, len); /* Copy body data to object */ memcpy(tmp, hdr, len); return tmp; } /* * Function g_netbuf_pull (msg, len) * * Remove header or data in front of the message * */ guint8 *g_netbuf_pull(GNetBuf *msg, guint len) { if (len > msg->len) return NULL; msg->len -= len; return msg->data += len; } /* * Function g_netbuf_reserve (msg, len) * * Reserve space in front of message for headers or data * */ void g_netbuf_reserve(GNetBuf *msg, guint len) { msg->data+=len; msg->tail+=len; } /* * Function msg_headroom (msg) * * Returns the number of bytes available for inserting headers or data * in front of the message. */ gint g_netbuf_headroom(GNetBuf *msg) { return msg->data - msg->head; } /* * Function g_netbuf_tailroom (msg) * * Returns the number of bytes available for inserting more data into the * message */ gint g_netbuf_tailroom(GNetBuf *msg) { return msg->end - msg->tail; } /* * Function g_netbuf_trim (msg, len) * * Set the length of the message * */ void g_netbuf_trim(GNetBuf *msg, guint len) { if (msg->len > len) { msg->len = len; msg->tail = msg->data+len; } } void g_netbuf_print(GNetBuf *msg) { guint i; for (i=0; ilen; i++) g_print("%02x", msg->data[i]); g_print("\n"); } irda-utils-0.9.18/irdadump/main.c0000644000175000017500000001202310454641046016123 0ustar samuelsamuel/********************************************************************* * * Filename: main.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Mar 28 12:28:51 1999 * Modified at: Wed Jan 19 11:05:52 2000 * Modified by: Dag Brattli * * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 2002-2003 Jean Tourrilhes, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include /* strdup */ #include #include #include #include #define VERSION "0.9.17 (19.02.2006) Dag Brattli/Jean Tourrilhes" int packets = 0; void cleanup(int signo) { /* Kill "unused" warning */ signo = signo; fflush(stdout); putc('\n', stdout); printf("%d packets received by filter\n", packets); if (config_capturewrite >= 0) capwrite_close(config_capturewrite); if (config_captureread >= 0) capread_close(config_captureread); exit(0); } int main(int argc, char *argv[]) { GString *line; char *ifdev = NULL; char *writefilename = NULL; char *readfilename = NULL; int fd, c; while ((c = getopt(argc, argv, "bc:di:lpr:s:tvw:x?")) != -1) { switch (c) { case 'b': /* Dumb bytes */ config_dump_bytes = 1; break; case 'c': /* set snapcols for byte printing */ c = atoi(optarg); if (c <= 0) { config_snapcols = 16; } else { config_snapcols = c ; } break; case 'd': /* Print diffs */ config_print_diff = 1; break; case 'i': /* Interface */ ifdev = (char *) strdup(optarg); printf("Using interface: %s\n", ifdev); break; case 'l': /* Set linebuffering */ setlinebuf(stdout); break; case 'p': /* Disable IrDA frame parsing, in case they * are garbage... Combine with -b or -x to * get only bytes display. */ config_print_irlap = 0; break; case 'r': /* Read libpcap log file - JeanII */ readfilename = (char *) strdup(optarg); break; case 's': /* set snaplen for printing */ c = atoi(optarg); if (c <= 0) { config_snaplen = 2050; } else { config_snaplen = c ; } case 't': /* Force TTP decoding of unknown connections */ config_force_ttp = 1; break; case 'v': /* version */ printf("Version: %s\n", VERSION); exit(0); case 'w': /* Write libpcap log file - J.K. */ writefilename = (char *) strdup(optarg); break; case 'x': /* Dump frame (byte + ascii) */ config_dump_frame = 1; break; case '?': /* usage */ fprintf(stderr,"Usage: %s [-d] [-x] [-b] [-s ] [-c ] [-p] [-i device] [-o log]\n", argv[0]); fprintf(stderr,"\t-d\tPrint diffs\n"); fprintf(stderr,"\t-l\tSet line buffering on output file.\n"); fprintf(stderr,"\t-s \tSet snaplen for -x & -b\n"); fprintf(stderr,"\t-x\tDump frame (bytes + ascii)\n"); fprintf(stderr,"\t-b\tDump bytes in columns\n"); fprintf(stderr,"\t-c \tSet number of colums for -b\n"); fprintf(stderr,"\t-p \tDisable parsing/decoding\n"); fprintf(stderr,"\t-i device\tIrDA port to listen on\n"); fprintf(stderr,"\t-w log\tWrites out raw capture file\n"); fprintf(stderr,"\t-r log\tRead from raw capture file\n"); exit(1); default: break; } } signal(SIGTERM, cleanup); signal(SIGINT, cleanup); signal(SIGHUP, cleanup); /* Open the capture file for writing. */ if(writefilename != NULL) { config_capturewrite = capwrite_open(writefilename); if(config_capturewrite < 0) return config_capturewrite; if(capwrite_init(config_capturewrite) < 0) return -1; } /* Open the capture file for reading. */ if(readfilename != NULL) { config_captureread = capread_open(readfilename); if(config_captureread < 0) { return config_captureread; } if(capread_check(config_captureread) < 0) { return -1; } } /* Initialise socket to IrDA stack */ fd = irdadump_init(ifdev); if (fd < 0) { perror(argv[0]); return fd; } line = g_string_sized_new(1024); while (1) { /* Get a packet from the IrDA device */ if (irdadump_loop(line) == -1) continue; packets++; /* Print line on the screen */ puts(line->str); /* Recycle line */ g_string_truncate(line, 0); } return 0; } irda-utils-0.9.18/irdadump/INSTALL0000644000175000017500000001722710454641046016077 0ustar samuelsamuelBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. irda-utils-0.9.18/irdadump/ircomm.c0000644000175000017500000000757210454641046016502 0ustar samuelsamuel/********************************************************************* * * Filename: ircomm.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Jun 6 13:40:30 1999 * Modified at: Fri Jun 11 10:47:08 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include "irdadump.h" #include "ircomm.h" #if 0 static char *ircomm_service_type[] = { "N/A", "THREE_WIRE_RAW", "THREE_WIRE", "N/A", "NINE_WIRE", "N/A", "N/A", "N/A", "CENTRONICS" }; static char *ircomm_port_type[] = { "SERIAL", "PARALLEL" }; #endif static inline guint bytes_to_uint(unsigned char *buf) { guint ret; ret = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; return(ret); } void parse_ircomm_params(guint8 clen, GNetBuf *buf, GString *str) { guint pi, pl; guint pv_byte; guint n = 0; while (n < clen) { pi = buf->data[n] & 0x7f; /* Remove critical bit */ pl = buf->data[n+1]; switch (pi) { case SERVICE_TYPE: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Service Type="); if (pv_byte & IRCOMM_CENTRONICS) g_string_sprintfa(str, "CENTRONICS "); if (pv_byte & IRCOMM_9_WIRE) g_string_sprintfa(str, "NINE_WIRE "); if (pv_byte & IRCOMM_3_WIRE) g_string_sprintfa(str, "THREE_WIRE "); if (pv_byte & IRCOMM_3_WIRE_RAW) g_string_sprintfa(str, "THREE_WIRE_RAW "); if (!(pv_byte & IRCOMM_VALID_SERVICES)) g_string_sprintfa(str, "N/A "); break; case PORT_TYPE: pv_byte = buf->data[n+2]; g_string_sprintfa(str, "Port Type="); if (pv_byte & IRCOMM_SERIAL) g_string_sprintfa(str, "SERIAL "); if (pv_byte & IRCOMM_PARALLEL) g_string_sprintfa(str, "PARALLEL "); if (!(pv_byte & IRCOMM_VALID_PORT_TYPES)) g_string_sprintfa(str, "N/A "); break; case DATA_RATE: pv_byte = bytes_to_uint(&(buf->data[n+2])); g_string_sprintfa(str, "Data Rate=%d ", pv_byte); break; case DATA_FORMAT: g_string_sprintfa(str, "Data Format=%02x ", buf->data[n+2]); break; case FLOW_CONTROL: g_string_sprintfa(str, "Flow Control=%02x ", buf->data[n+2]); break; case XON_XOFF_CHAR: g_string_sprintfa(str, "XON/XOFF=%02x,%02x ", buf->data[n+2], buf->data[n+3]); break; case DTELINE_STATE: g_string_sprintfa(str, "DTEline State=%02x ", buf->data[n+2]); break; default: break; } n += pl+2; } g_netbuf_pull(buf, clen); } void parse_ircomm_connect(GNetBuf *buf, GString *str) { parse_ircomm_ttp(buf, str); } void parse_ircomm_lmp(GNetBuf *buf, GString *str) { /* Kill "unused" warning */ buf = buf; g_string_append(str, "IrCOMM (IrLPT) "); return; } void parse_ircomm_ttp(GNetBuf *buf, GString *str) { int len; guint8 clen; /* Check for empty frames - Jean II */ len = g_netbuf_get_len(buf); if(len == 0) return; clen = buf->data[0]; g_netbuf_pull(buf, 1); if (clen) { g_string_append(str, "\n\tIrCOMM "); parse_ircomm_params(clen, buf, str); } else g_string_append(str, "IrCOMM "); } irda-utils-0.9.18/irdadump/COPYING0000644000175000017500000004311010454641046016067 0ustar samuelsamuel GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. irda-utils-0.9.18/irdadump/netbuf.h0000644000175000017500000000522610454641046016476 0ustar samuelsamuel/********************************************************************* * * Filename: gnetbuf.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Fri Mar 19 09:06:47 1999 * Modified at: Tue Sep 7 22:38:59 1999 * Modified by: Dag Brattli * Sources: skbuff.h by Alan Cox and * Florian La Roche * * Copyright (c) 1999 Dag Brattli, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * * This code is very inspired by skbuff.h, and this is how it work: * * |<------------ truesize ----------------->| * ------------------------------------------ * | headroom | len | tailroom | * ------------------------------------------ * ^ ^ ^ ^ * | | | | * head data tail end * ********************************************************************/ #ifndef G_NETBUF_H #define G_NETBUF_H #include typedef struct _GNetBuf GNetBuf; struct _GNetBuf { guint8 *data; /* Pointer to the actual data */ guint8 *head; /* Pointer to start of buffer */ guint8 *tail; /* Pointer to end of data */ guint8 *end; /* Pointer to end of buffer */ guint len; /* Length of data */ guint truesize; /* Real size of the buffer */ }; GNetBuf *g_netbuf_new(guint len); GNetBuf *g_netbuf_realloc(GNetBuf *buf, guint len); void g_netbuf_free(GNetBuf *msg); GNetBuf *g_netbuf_recycle(GNetBuf *msg); guint8 *g_netbuf_put(GNetBuf *msg, guint len); guint8 *g_netbuf_put_data(GNetBuf *msg, gint8 *data, guint len); guint8 *g_netbuf_push(GNetBuf *msg, guint len); guint8 *g_netbuf_pull(GNetBuf *msg, guint len); void g_netbuf_reserve(GNetBuf *msg, guint len); int g_netbuf_headroom(GNetBuf *msg); int g_netbuf_tailroom(GNetBuf *msg); void g_netbuf_set_size(GNetBuf *msg, guint len); void g_netbuf_print(GNetBuf *msg); static inline guint8 *g_netbuf_get_data(GNetBuf *msg) { return msg->data; } static inline guint g_netbuf_get_len(GNetBuf *msg) { return msg->len; } #endif irda-utils-0.9.18/irdadump/ircomm.h0000644000175000017500000000433310454641046016477 0ustar samuelsamuel/********************************************************************* * * Filename: ircomm.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Sun Jun 6 13:48:43 1999 * Modified at: Sat Oct 16 14:53:13 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #ifndef IRCOMM_H #define IRCOMM_H #include #include /* Parameters common to all service types */ #define SERVICE_TYPE 0x00 #define PORT_TYPE 0x01 #define PORT_NAME 0x02 #define FIXED_PORT_NAME 0x82 /* Parameters for both 3 wire and 9 wire */ #define DATA_RATE 0x10 #define DATA_FORMAT 0x11 #define FLOW_CONTROL 0x12 #define XON_XOFF_CHAR 0x13 #define ENQ_ACK_CHAR 0x14 #define LINESTATUS 0x15 #define BREAK_SIGNAL 0x16 /* Parameters for 9 wire */ #define DTELINE_STATE 0x20 #define DCELINE_STATE 0x21 #define POLL_FOR_LINE_SETTINGS 0x22 /* Service type (details) */ #define IRCOMM_3_WIRE_RAW 0x01 #define IRCOMM_3_WIRE 0x02 #define IRCOMM_9_WIRE 0x04 #define IRCOMM_CENTRONICS 0x08 #define IRCOMM_VALID_SERVICES 0x0F /* Port type (details) */ #define IRCOMM_SERIAL 0x01 #define IRCOMM_PARALLEL 0x02 #define IRCOMM_VALID_PORT_TYPES 0x03 #endif irda-utils-0.9.18/irdadump/NEWS0000644000175000017500000000000010454641046015522 0ustar samuelsamuelirda-utils-0.9.18/irdadump/Makefile0000644000175000017500000000220210454641046016471 0ustar samuelsamuelinclude ../output.mak CC = gcc LD = ld AR = ar RANLIB = ranlib RM = rm -f RM_CMD = $(ECMD)$(RM) *.BAK *.bak *.o ,* *~ *.a INCLUDES = $(SYS_INCLUDES) -I../include/ LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) # # System stuff # SYS_INCLUDES = -I/usr/include SYS_LIBRARIES = SYS_LIBPATH = -L/usr/lib -L/usr/local/lib CFLAGS= -O2 -W -Wall -I. `pkg-config --cflags glib-2.0` LIBIRDADUMP_OBJS = irdadump.o irlap.o irlmp.o obex.o ircomm.o netbuf.o capture.o IRDADUMP_OBJS = main.o LIBIRDADUMP_TARGET = lib_irdadump.a IRDADUMP_TARGET = irdadump all: lib_irdadump.a irdadump lib_irdadump.a: $(LIBIRDADUMP_OBJS) $(prn_ar) $(ECMD)$(AR) cru $(LIBIRDADUMP_TARGET) $(LIBIRDADUMP_OBJS) $(prn_ranlib) $(ECMD)$(RANLIB) $(LIBIRDADUMP_TARGET) irdadump: $(IRDADUMP_OBJS) $(LIBIRDADUMP_TARGET) $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) `pkg-config --libs glib-2.0` -o $(IRDADUMP_TARGET) $< $(LIBIRDADUMP_TARGET) .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< install: $(IRDADUMP_TARGET) $(prn_install) $(ECMD)install $(IRDADUMP_TARGET) $(ROOT)/usr/sbin clean: $(RM_CMD) distclean: $(RM_CMD) $(ECMD)$(RM) $(IRDADUMP_TARGET) irda-utils-0.9.18/irdadump/obex.c0000644000175000017500000002040010454641046016132 0ustar samuelsamuel/********************************************************************* * * Filename: obex.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Wed Mar 31 14:09:47 1999 * Modified at: Wed Apr 21 15:52:03 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Jean Tourrilhes, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include "irdadump.h" #include "obex.h" #include #include #include /* ntohs */ void unicode_to_char(guint8 *buf) { guint8 *buf2 = buf; int n=0; while ((buf2[n] = buf[n*2+1])) n++; } /* * Function parse_obex_header (buf) * * * */ int parse_obex_header(GNetBuf *buf, GString *str, int istext) { guint8 string[255]; guint32 tmp_int; guint16 tmp_short; int len = 0; /* g_print("%s()", __FUNCTION__);fflush(stdout); */ switch (buf->data[0] & OBEX_HI_MASK) { case OBEX_UNICODE: /* g_print("OBEX_UNICODE");fflush(stdout); */ memcpy(&tmp_short, buf->data+1, 2); /* Align value */ tmp_short = GINT16_FROM_BE(tmp_short) - 3; len += 3; memcpy(string, buf->data+3, tmp_short); unicode_to_char(string); len += tmp_short; /* g_print("%s ", string);fflush(stdout); */ g_string_sprintfa(str, "\"%s\" ", string); break; case OBEX_BYTE_STREAM: /* g_print("OBEX_BYTE_STREAM");fflush(stdout); */ memcpy(&tmp_short, buf->data+1, 2); /* Align value */ tmp_short = GINT16_FROM_BE(tmp_short) - 3; len += tmp_short + 3; if(istext) { memcpy(string, buf->data+3, tmp_short); string[tmp_short] = '\0'; g_string_sprintfa(str, "\"%s\" ", string); } else g_string_sprintfa(str, "[%d bytes] ", tmp_short); break; case OBEX_BYTE: /* g_print("OBEX_BYTE");fflush(stdout); */ g_string_sprintfa(str, "%d ", buf->data[0]); len += 2; break; case OBEX_INT: /* g_print("OBEX_INT");fflush(stdout); */ memcpy(&tmp_int, buf->data+1, 4); /* Align value */ len += 5; /* printf("%ld ", ntohl(tmp_int));fflush(stdout); */ g_string_sprintfa(str, "%d ", GINT32_FROM_BE(tmp_int)); break; default: g_print("******");fflush(stdout); break; } return len; } /* * Function parse_obex_put (buf) * * Parse an OBEX put command * */ inline void parse_obex_headers(GNetBuf *buf, GString *str) { struct obex_minimal_frame *frame; int final; guint16 size; int len; frame = (struct obex_minimal_frame *) buf->data; /* We know it's a put frame, but we have to check if it's the final */ final = frame->opcode & OBEX_FINAL; /* Length of this frame */ size = ntohs(frame->len); /* Remove the OBEX common header */ g_netbuf_pull(buf, 3); g_string_sprintfa(str, "final=%d len=%d ", final >> 7, size); /* Parse all headers */ while (buf->len > 0) { /* Read the header identifier */ /* g_print("hi=%02x", buf->data[0]);fflush(stdout); */ switch (buf->data[0]) { case HEADER_NAME: case HEADER_ANAME: g_string_append(str, "Name="); len = parse_obex_header(buf, str, 1); break; case HEADER_DESCRIPTION: g_string_append(str, "Description="); len = parse_obex_header(buf, str, 0); break; case HEADER_LENGTH: g_string_append(str, "Lenght="); len = parse_obex_header(buf, str, 0); break; case HEADER_TYPE: g_string_append(str, "Type="); len = parse_obex_header(buf, str, 1); break; case HEADER_TARGET: g_string_append(str, "Target="); len = parse_obex_header(buf, str, 1); break; case HEADER_BODY: g_string_append(str, "body="); len = parse_obex_header(buf, str, 0); break; case HEADER_BODY_END: g_string_append(str, "body-end="); len = parse_obex_header(buf, str, 0); break; default: g_string_append(str, "custom="); len = parse_obex_header(buf, str, 0); break; } /* g_print("len=%d\n", len);fflush(stdout); */ if(g_netbuf_pull(buf, len) == NULL) { g_string_append(str, "{unterminated} "); break; } } } inline void parse_obex_connect(GNetBuf *buf, GString *str) { struct obex_connect_frame *frame; guint16 length; guint8 version; int flags; guint16 mtu; frame = (struct obex_connect_frame *) buf->data; length = ntohs(frame->len); /* Check if it contains connection setup parameters - Jean II */ if(length == 7) { version = frame->version; flags = frame->flags; mtu = ntohs(frame->mtu); g_string_sprintfa(str, "CONNECT len=%d ver=%d.%d flags=%d mtu=%d ", length, ((version & 0xf0) >> 4), version & 0x0f, flags, mtu); } else g_string_sprintfa(str, "CONNECT len=%d ", length); } /* * The first success frame contains the negociated Obex parameters * We also need to parse the anser to GET request properly * Jean II */ inline void parse_obex_success(GNetBuf *buf, GString *str) { struct obex_connect_frame *frame; guint16 length; guint8 version; int flags; guint16 mtu; frame = (struct obex_connect_frame *) buf->data; length = ntohs(frame->len); switch(length) { case 7: /* Frame contains connection setup parameters */ version = frame->version; flags = frame->flags; mtu = ntohs(frame->mtu); g_string_sprintfa(str, "SUCCESS len=%d ver=%d.%d flags=%d mtu=%d ", length, ((version & 0xf0) >> 4), version & 0x0f, flags, mtu); break; case 3: /* Frame contains nothing */ g_string_sprintfa(str, "SUCCESS len=%d ", length); break; default: /* Frame contains some headers (probably a GET reply) */ g_string_append(str, "SUCCESS "); parse_obex_headers(buf, str); break; } } /* * Function parse_obex (buf) * * Parse OBEX commands and responses * */ inline void parse_obex(GNetBuf *buf, GString *str, int cmd) { guint8 opcode; int len; /* g_print(__FUNCTION__);fflush(stdout); */ g_string_append(str, "\n\tOBEX "); /* Check for empty frames - Jean II */ len = g_netbuf_get_len(buf); if(len == 0) return; opcode = buf->data[0] & ~OBEX_FINAL; /* Remove final bit */ /* Check if it's a command or response frame - Jean II */ if (!cmd) { switch (opcode) { case OBEX_CONTINUE: g_string_append(str, "CONTINUE "); parse_obex_headers(buf, str); break; case OBEX_SWITCH_PRO: g_string_append(str, "SWITCH_PRO "); break; case OBEX_SUCCESS: parse_obex_success(buf, str); break; case OBEX_CREATED: g_string_append(str, "CREATED "); break; case OBEX_ACCEPTED: g_string_append(str, "ACCEPTED "); break; case OBEX_BAD_REQUEST: g_string_append(str, "BAD REQUEST "); break; case OBEX_FORBIDDEN: g_string_append(str, "FORBIDDEN "); break; case OBEX_CONFLICT: g_string_append(str, "CONFLICT "); break; default: g_string_sprintfa(str, "Unknown response %02x ", opcode); break; } } else { switch (opcode) { case OBEX_CONNECT: parse_obex_connect(buf, str); break; case OBEX_PUT: g_string_append(str, "PUT "); parse_obex_headers(buf, str); break; case OBEX_GET: g_string_append(str, "GET "); parse_obex_headers(buf, str); break; case OBEX_DISCONNECT: g_string_append(str, "DISC "); break; case OBEX_ABORT: g_string_append(str, "ABORT "); break; case OBEX_SETPATH: g_string_append(str, "SETPATH "); break; default: if ((opcode > 0x04) && (opcode < 0x10)) g_string_append(str, "RESERVED "); else if ((opcode > 0x0f) && (opcode < 0x20)) g_string_append(str, "USER_DEFINED "); else g_string_sprintfa(str, "unknown opcode %#x ", opcode); break; } } } irda-utils-0.9.18/irdaping/0000755000175000017500000000000010454641161015023 5ustar samuelsamuelirda-utils-0.9.18/irdaping/irdaping.c0000644000175000017500000001744210454641046016776 0ustar samuelsamuel/********************************************************************* * * Filename: irdaping.c * Version: 0.4 * Description: Ping tool for irda frames * Status: Experimental. * Author: Dag Brattli * Created at: Sat Feb 20 02:09:06 1999 * Modified at: Tue Sep 7 21:00:24 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include /* For struct ifreq */ #include /* For struct sockaddr_pkt */ #include /* For ARPHRD_IRDA */ #include /* For ETH_P_ALL */ #include /* For htons */ /* * We should not really include kernel header files, but they are currently * the only ones that knows anything about IrDA and byte ordering. */ #include /* __cpu_to_le32 and co. */ #include /* For __u8 and co. */ #include #ifndef AF_IRDA #define AF_IRDA 23 /* */ #define PF_IRDA AF_IRDA #endif /* AF_IRDA */ #define TEST_FRAME 0xe3 #define CMD_FRAME 0x01 #define RSP_FRAME 0x00 #define PF_BIT 0x10 /* Poll/final bit */ #define BROADCAST 0xffffffff /* Broadcast device address */ #define CBROADCAST 0xfe /* Connection broadcast address */ #define DEV_DEFAULT "irda0" struct test_frame { __u8 caddr; /* Connection address */ __u8 control; __u32 saddr; /* Source device address */ __u32 daddr; /* Destination device address */ __u8 info[0]; /* Information */ } __attribute__((packed)); struct test_info { __u16 pkt_nr; struct timeval time; __u8 info[0]; } __attribute__((packed)); /* Group together all globals */ struct instance { int fd; /* Socket */ int packets; /* Number of frames received */ __u32 saddr; /* Source device address */ __u32 daddr; /* Destination device address */ struct ifreq ifr; int framelen; /* How large frames we should send */ char device[14]; /* Name of device, usually "irda0" */ struct timeval time_current; __u8 buf[2048]; } self; /* * Function cleanup (signo) * * Called at exit. Just print number of frames received. * */ void cleanup(int signo) { fflush(stdout); putc('\n', stdout); printf("%d packets received by filter\n", self.packets); exit(0); } /* * Function timeout (signo) * * Is called every time we should send a frame * */ void timeout(int signo) { struct test_frame *frame; struct test_info *info; struct sockaddr_pkt from; int n=0; int i; int count, rest; frame = (struct test_frame *) self.buf; info = (struct test_info *) frame->info; /* Build ping test frame */ self.saddr = *((__u32*) self.ifr.ifr_hwaddr.sa_data); frame->caddr = CBROADCAST | CMD_FRAME; frame->control = TEST_FRAME | PF_BIT; frame->saddr = __cpu_to_le32(self.saddr); frame->daddr = __cpu_to_le32(self.daddr); info->pkt_nr = __cpu_to_le16(self.packets++); gettimeofday(&self.time_current, (struct timezone*) 0); memcpy(&info->time, &self.time_current, sizeof(struct timezone)); /* Fill in some data in rest of frame */ rest = self.framelen-sizeof(struct test_frame)-sizeof(struct test_info); for (i=0;iinfo[i] = n++; } from.spkt_family = ARPHRD_IRDA; from.spkt_protocol = htons(AF_IRDA); memcpy(from.spkt_device, self.device, 6); count = sendto(self.fd, self.buf, self.framelen, 0, (struct sockaddr *) &from, sizeof(from)); if (count < 0) { perror("sendto"); exit(-1); } } /* * Function main (argc, ) * * Initialize and try to receive test frames * */ int main(int argc, char *argv[]) { int count; struct test_frame *frame; struct test_info *info; unsigned char buf[2048]; struct sockaddr from_sa; struct sockaddr_pkt from; socklen_t fromlen; struct timeval time, *timep; struct itimerval itime; float diff; int c; if (argc < 2) { printf("Usage: irdaping [-s ] [-i ]\n"); exit(-1); } /* Initialize */ memset(&self, 0, sizeof(struct instance)); self.daddr = (__u32) strtoul(argv[1], NULL, 0); self.framelen = 32; strncpy(self.device, DEV_DEFAULT, 14); while ((c = getopt(argc, argv, "hs:i:")) != -1) { switch (c) { case 's': /* Packet size */ self.framelen = strtol(optarg, NULL, 10); break; case 'i': /* Interface name */ strncpy(self.device, optarg, 14); break; case 'h': /* Help */ printf("Usage: irdaping [-s ] [-i ]\n"); exit(-1); default: break; } } /* Correct the framesize */ if (self.framelen < (12+sizeof(struct timeval))) self.framelen = 12+sizeof(struct timeval); /* Eventually we should use sigaction instead */ signal(SIGTERM, cleanup); signal(SIGINT, cleanup); signal(SIGHUP, cleanup); signal(SIGALRM, timeout); /* Create socket */ self.fd = socket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ALL)); if (self.fd < 0) { perror("socket"); exit(-1); } /* Bind to the interface */ memset(&from_sa, 0, sizeof(from_sa)); from_sa.sa_family = AF_PACKET; strncpy(from_sa.sa_data, self.device, sizeof(from_sa.sa_data)); if (bind(self.fd, &from_sa, sizeof(from_sa))) { perror("bind"); exit(-1); } /* Get source device address */ memset(&self.ifr, 0, sizeof(self.ifr)); strncpy(self.ifr.ifr_name, self.device, sizeof(self.ifr.ifr_name)); if (ioctl(self.fd, SIOCGIFHWADDR, &self.ifr) < 0 ) { perror("SIOCGIFHWADDR"); exit(-1); } itime.it_value.tv_sec = 1; itime.it_value.tv_usec = 0; itime.it_interval.tv_sec = 1; itime.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itime, NULL); printf("IrDA ping (0x%08x on %s): %d bytes\n", self.daddr, self.device, self.framelen); while(1) { fromlen = sizeof(struct sockaddr_pkt); count = recvfrom(self.fd, buf, 2048, 0, (struct sockaddr *) &from, &fromlen); if (count < 0) { perror("recvfrom"); exit(-1); } frame = (struct test_frame *) buf; info = (struct test_info *) frame->info; /* Assert that this is really a test response frame */ if ((frame->caddr & CMD_FRAME) || (frame->control != (TEST_FRAME|PF_BIT))) continue; if (count < sizeof(struct test_frame)) continue; printf( "%d bytes from ", count); printf( "0x%08x", __le32_to_cpu(frame->saddr)); /* Check if frame contains any addtional info */ if (count < (sizeof(struct test_frame)+ sizeof(struct test_info))) { printf("\n"); continue; } gettimeofday(&time, (struct timezone*) 0); /* Read time from frame */ timep = &info->time; if (timep->tv_usec > time.tv_usec) { time.tv_usec += 1000000; time.tv_sec--; } time.tv_usec = time.tv_usec - timep->tv_usec; time.tv_sec = time.tv_sec - timep->tv_sec; diff = ((float) time.tv_sec * 1000000.0 + time.tv_usec) / 1000.0; printf( ": irda_seq=%d ", __le16_to_cpu(info->pkt_nr)); printf( "time=%6.2f ms.\n", diff); } } irda-utils-0.9.18/irdaping/Makefile0000644000175000017500000000357410454641046016476 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for irdaping ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Mon Jun 21 10:20:50 1999 ## Modified by: Dag Brattli ## ## $Id: Makefile 115 2006-02-28 22:16:46Z sambau $ ## ## Copyright (c) 1998-1999 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include ../output.mak CC = gcc LD = ld RM = rm -f RM_CMD = $(ECMD)$(RM) *.BAK *.bak *.o ,* *~ *.a INCLUDES = $(SYS_INCLUDES) -I../include/ LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) # # System stuff # SYS_INCLUDES = -I/usr/include SYS_LIBRARIES = SYS_LIBPATH = -L/usr/lib -L/usr/local/lib CFLAGS= $(RPM_OPT_FLAGS) $(SYS_INCLUDES) -Wall -Wstrict-prototypes # # Files to make # SRCS = irdaping.c OBJS = $(SRCS:.c=.o) TARGETS = irdaping all: $(TARGETS) irdaping: $(OBJS) $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) $(OBJS) -o $@ .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< install: $(TARGETS) $(prn_install) $(ECMD)install irdaping $(ROOT)/usr/sbin clean: $(RM_CMD) distclean: $(RM_CMD) $(ECMD)$(RM) irdaping depend: $(prn_depend) $(ECMD)makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) # DO NOT DELETE irda-utils-0.9.18/irdaping/README0000644000175000017500000000032010454641046015700 0ustar samuelsamuel 00..00..00..11.. NNAAMMEE irdaping - sends IrLAP TEST frames remote device 00..00..00..22.. SSyynnooppssiiss irda-utils-0.9.18/irnetd/0000755000175000017500000000000010454641161014513 5ustar samuelsamuelirda-utils-0.9.18/irnetd/irnetd.c0000644000175000017500000000446210454641046016154 0ustar samuelsamuel/* * Automatic PPP connection using irNET * * Luiz Magalhaes - HPL '00 (luiz_magalhaes@hp.com) * Jean Tourrilhes - HPL '00 * * this program is available under the GNU Public License * you are welcome to use and change this program as long as * you keep this notice and make your code available under * the GPL */ /* This program listens to the events in /dev/irnet * and creates a PPP connection if it detects a * connection request */ /* History : * v1.0 : Luiz : just launch ppp * v1.1 : Luiz : add IrDA address selectivity * v1.2 : Jean : Add command line args and more comments * v1.3 : jean : Add "connect-delay 0 idle 10" by default... */ /* Usage : * If pppd support the nolock option, just run irnetd. * Otherwise, run : * You can play with more options as you wish... */ #include #include #include int main(int argc, char *argv[]) { char line[255]; char cmd1[] = "pppd /dev/irnet 9600 local "; char cmd2[] = "noauth nolock connect-delay 0 idle 10 "; char cmd3[] = "connect \"echo addr \0"; char cmd[255]; char *endp; char aux[10]= "01235678\"\0"; int i; FILE *irnet; /* Start building our command */ strcpy(cmd, cmd1); /* Check if we have some args to add */ if(argc == 1) { /* No arguments - use defaults */ strcat(cmd, cmd2); } else { /* Put args in the ppp command */ for(i = 1; i < argc; i++) { strcat(cmd, argv[i]); strcat(cmd, " "); } } /* Terminate the fixed part of the command */ strcat(cmd, cmd3); endp = cmd + strlen(cmd); strcat(cmd, aux); printf("The command is [%s]\n", cmd); /* Open IrNET event channel */ irnet = fopen("/dev/irnet","r"); if(irnet == NULL) { perror("Error opening /dev/irnet: "); return(-1); } /* Loop forever */ while(1) { /* Wait for one event */ fgets(line, 255, irnet); /* If we have a request... * Note : we could also trigger on discovery events, but that would * cause problems in many cases, so we keep to request only */ if(strncmp(line,"Req",3) == 0) { /* Copy over the IrDA address */ for(i=0; i<8; i++) endp[i] = line[i+13]; /* Run pppd to handle connection */ if(system(cmd) < 0) perror("irnetd: "); } } } irda-utils-0.9.18/irnetd/Makefile0000644000175000017500000000333410454641046016160 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for irnetd ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Sat Dec 25 16:13:54 1999 ## Modified by: Dag Brattli ## ## $Id: Makefile 115 2006-02-28 22:16:46Z sambau $ ## ## Copyright (c) 1998-1999 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include ../output.mak CC = gcc LD = ld RM = rm -f RM_CMD = $(ECMD)$(RM) *.BAK *.bak *.o *.so ,* *~ *.a *.orig *.rej INCLUDES = $(SYS_INCLUDES) -I../include LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) CFLAGS= $(RPM_OPT_FLAGS) -O2 -Wall -Wstrict-prototypes OBJS = irnetd.o TARGETS = irnetd all: $(TARGETS) .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< irnetd: $(OBJS) $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) $(OBJS) -o $@ install: irnetd $(prn_install) $(ECMD) install irnetd /usr/sbin/ clean: $(RM_CMD) distclean: $(RM_CMD) $(EMCD)$(RM) $(TARGETS) depend: $(prn_depend) $(ECMD)makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) # DO NOT DELETE irda-utils-0.9.18/irsockets/0000755000175000017500000000000010454641161015234 5ustar samuelsamuelirda-utils-0.9.18/irsockets/oldies/0000755000175000017500000000000010454641220016507 5ustar samuelsamuelirda-utils-0.9.18/irsockets/oldies/irdaspray.c0000644000175000017500000001471610454641046020670 0ustar samuelsamuel/********************************************************************* * * Filename: irdaspray.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Mon May 10 10:12:55 1999 * Modified at: Wed Jan 19 18:06:30 2000 * Modified by: Dag Brattli * * Copyright (c) 1999-2000 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ #define MAX_DEVICES 10 int fd; int mtu = 0; int frame_size = 1024; int frame_number = 100; unsigned char buf[4096]; int delay = 0; int echo = 0; /* Use discard service by default */ /* * Function echo_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * */ int irdaspray_discover_devices(int fd) { struct irda_device_list *list; unsigned char *buf; int len; int i; len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * MAX_DEVICES; buf = malloc(len); list = (struct irda_device_list *) buf; if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { perror("getsockopt"); exit(-1); } if (len > 0) { printf("Discovered: (list len=%d)\n", list->len); for (i=0;ilen;i++) { printf(" name: %s\n", list->dev[i].info); printf(" daddr: %08x\n", list->dev[i].daddr); printf(" saddr: %08x\n", list->dev[i].saddr); printf("\n"); if (list->dev[i].hints[0] & HINT_COMPUTER) { printf("Lets try this one\n"); return list->dev[i].daddr; } } } printf("Didn't find any devices!\n"); return -1; } /* * Function irdaspray_connect_request (self) * * Try to connect to remote device * */ static int irdaspray_connect_request(int fd) { struct sockaddr_irda peer; int len = sizeof(int); int daddr; /* * Open TTP connection to remote device! */ daddr = irdaspray_discover_devices(fd); if (daddr == -1) return -1; /* Disable IrTTP SAR */ if (setsockopt(fd, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, &mtu, sizeof(mtu))) { perror("setsockopt"); exit(-1); } peer.sir_family = AF_IRDA; if (echo) strncpy(peer.sir_name, "IrECHO", 25); else strncpy(peer.sir_name, "IrDISCARD", 25); peer.sir_addr = daddr; if (connect(fd, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); return -1; } /* Check what the IrLAP data size is */ if (getsockopt(fd, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, (void *) &mtu, &len)) { perror("getsockopt"); exit(-1); } /* printf(__FUNCTION__ "(), link mtu=%d\n", mtu); */ return 0; } int irdaspray_transmit(int fd) { int total = 0; int actual; int i; /* Transmit frames */ for (i=0; i * Created at: Mon Mar 8 14:32:49 1999 * Modified at: Wed Jan 19 18:06:05 2000 * Modified by: Dag Brattli * * Copyright (c) 1999-2000 Dag Brattli, 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. * * Neither Dag Brattli nor University of Troms admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif #define MAX_DEVICES 10 int discover_devices(int fd) { struct irda_device_list *list; unsigned char *buf; int len; int i; len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * MAX_DEVICES; buf = malloc(len); list = (struct irda_device_list *) buf; if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { perror("getsockopt"); exit(-1); } printf("len=%d\n", len); if (len > 0) { printf("Discovered:\n"); for (i=0;ilen;i++) { printf(" name: %s\n", list->dev[i].info); printf(" daddr: %08x\n", list->dev[i].daddr); printf(" saddr: %08x\n", list->dev[i].saddr); printf("\n"); } } return 0; } int main(int argc, char *argv[]) { int fd; int count; unsigned char buf[2048]; struct sockaddr_irda peer; int fromlen; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } printf("sizeof(struct irda_device_list)=%d\n", sizeof(struct irda_device_list)); printf("sizeof(struct irda_device_info)=%d\n", sizeof(struct irda_device_info)); discover_devices(fd); #if 0 peer.sir_family = AF_IRDA; strncpy(peer.sir_name, "P1284", 25); if (connect(fd, (struct sockaddr *) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); exit(-1); } #endif while(1) sleep(1); return 0; } irda-utils-0.9.18/irsockets/oldies/echo.c0000644000175000017500000000613110454641046017600 0ustar samuelsamuel/********************************************************************* * * Filename: echo.c * Version: 0.9 * Description: IrDA echo/discard service * Status: Experimental. * Author: Dag Brattli * Created at: Mon May 10 10:08:04 1999 * Modified at: Mon May 10 12:08:44 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ int discard = 0; /* Default is the echo service */ unsigned char buf[4098]; /* * Function main (argc, ) * * Implements IrDA Echo or Discard server * */ int main(int argc, char *argv[]) { struct sockaddr_irda peer, self; int addrlen; int actual; int fd, conn_fd; /* Check personality */ if (strcmp(argv[0], "discard") == 0) { printf("IrDA Discard server starting ...\n"); discard = 1; } else printf("IrDA Echo server starting ...\n"); /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Init self */ self.sir_family = AF_IRDA; if (discard) strncpy(self.sir_name, "IrDISCARD", 25); else strncpy(self.sir_name, "IrECHO", 25); self.sir_lsap_sel = LSAP_ANY; if (bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; } if (listen(fd, 8)) { perror("listen"); return -1; } for (;;) { addrlen = sizeof(struct sockaddr_irda); printf("Waiting for connection!\n"); conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (conn_fd < 0) { perror("accept"); return -1; } printf("Connected!\n"); do { actual = recv(conn_fd, &buf, sizeof(buf), 0); if (actual <= 0) break; printf("Got %d bytes\n", actual); if (!discard) { actual = send(conn_fd, &buf, actual, 0); printf("Sent %d bytes\n", actual); } } while (actual > 0); close(conn_fd); printf("Disconnected!\n"); } return 0; } irda-utils-0.9.18/irsockets/oldies/discard.c0000644000175000017500000001023010454641046020266 0ustar samuelsamuel/********************************************************************* * * Filename: discard.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Mon May 10 10:08:04 1999 * Modified at: Mon May 10 10:10:23 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* * Function irobex_listen (self) * * Wait for incomming connections * */ gint irobex_listen(obex_t *self, char *service) { int addrlen = sizeof(struct sockaddr_irda); int oflags; int mtu; int len = sizeof(int); DEBUG(3, __FUNCTION__ "()\n"); /* Bind local service */ self->trans.self.irda.sir_family = AF_IRDA; if (service == NULL) strncpy(self->trans.self.irda.sir_name, "OBEX", 25); else strncpy(self->trans.self.irda.sir_name, service, 25); self->trans.self.irda.sir_lsap_sel = LSAP_ANY; if (bind(self->fd, (struct sockaddr*) &self->trans.self.irda, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; } if (listen(self->fd, 2)) { perror("listen"); return -1; } self->fd = accept(self->fd, (struct sockaddr *) &self->trans.peer.irda, &addrlen); if (self->fd < 0) { perror("accept"); return -1; } /* Check if we should register for SIGIO */ if (self->async) { /* Register for asynchronous notification */ signal(SIGIO, &input_handler); fcntl(self->fd, F_SETOWN, getpid()); oflags = fcntl(0, F_GETFL); if( fcntl(self->fd, F_SETFL, oflags | FASYNC) < 0) { perror("fcntl"); return -1; } async_self = self; } /* Check what the IrLAP data size is */ if (getsockopt(self->fd, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, (void *) &mtu, &len)) { perror("getsockopt"); exit(-1); } self->trans.mtu = mtu; DEBUG(3, __FUNCTION__ "(), transport mtu=%d\n", mtu); return 0; } /* * Function irobex_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * */ gint irobex_discover_devices(obex_t *self) { struct irda_device_list *list; unsigned char *buf; int len; int i; len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * MAX_DEVICES; buf = g_malloc(len); list = (struct irda_device_list *) buf; if (getsockopt(self->fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { perror("getsockopt"); exit(-1); } if (len > 0) { g_print("Discovered: (list len=%d)\n", list->len); for (i=0;ilen;i++) { g_print(" name: %s\n", list->dev[i].info); g_print(" daddr: %08x\n", list->dev[i].daddr); g_print(" saddr: %08x\n", list->dev[i].saddr); g_print("\n"); self->trans.peer.irda.sir_addr = list->dev[i].daddr; self->trans.self.irda.sir_addr = list->dev[i].saddr; /* Make sure we discovered an OBEX device */ if (list->dev[i].hints[1] & HINT_OBEX) { DEBUG(0, __FUNCTION__ "(), this one looks good\n"); return 0; } } } DEBUG(0, __FUNCTION__ "(), didn't find any OBEX devices!\n"); return -1; } gint obex_data_indication(obex_t *self) { obex_common_hdr_t *hdr; GNetBuf *msg; int final; int actual; guint8 opcode; int size; DEBUG(4, __FUNCTION__ "()\n"); g_assert(self != NULL); msg = self->rx_msg; actual = recv(self->fd, msg->tail, g_netbuf_tailroom(msg), 0); DEBUG(4, __FUNCTION__ "(), got %d bytes\n", actual); } irda-utils-0.9.18/irsockets/irdaspray.c0000644000175000017500000005671110454641046017412 0ustar samuelsamuel/********************************************************************* * * Filename: irdaspray.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Jean Tourrilhes * Created at: 10/12/99 * Modified at: Mon May 10 18:31:35 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 2001 Jean Tourrilhes, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* gcc -O2 -Wall -o irdaspray irdaspray.c */ /* * This program demonstrate the use of auto-connect (connect to a service * without having to discover/specify an address) and how a program * can report discovery results to the user in case the service is not * unique on the network. * Of course, you need both auto-connect and query-ias in the kernel, and * a few bugs sorted out... * * Then, we show a cleaner way to perform discovery, by having better * memory allocation strategy, better handling of errors and setting the * hint mask in the kernel... * * Also, we include a nice feature which is a blocking discovery. Basically, * we ask the kernel to wake us up when it discover a device. This reduces * CPU usage (to zero) and decrease latency (to almost zero). This is * geared toward mobile devices (or to serve those mobile devices), but * also to implement "irmanager/irmonitor" kind of functionality... * * Also, everything about manipulating the IAS database and making query * is explained. That allow you to play with non-standard fields. * * Note that each feature require specific kernel support in the IrDA stack * so please check if your IrDA stack support that... In fact, this was * mostly written to test those kernel features. * * Jean Tourrilhes */ /* CONFIGURATION */ #define WAITFORDEVICE 1 #define CHECKBEFOREWAIT 1 #define SETHINTMASK 1 #define AUTOCONNECT 1 #define GETSOCKNAME 1 #define SETIAS 0 #define DELIAS 0 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* Memory allocation for discovery */ #define DISC_MAX_DEVICES 10 #define DISC_BUF_LEN sizeof(struct irda_device_list) + \ sizeof(struct irda_device_info) * DISC_MAX_DEVICES int frame_size = 1024; int frame_number = 100; unsigned char buf[8200]; int echo = 1; /* Use echo service by default (0 = discard) */ int server = 0; /* Act as a client by default (1 = server) */ int two = 0; /* Open only one client sockets (1 = two) */ /* * Function irdaspray_sethintmask (fd) * * Set the hint mask in the kernel to filter discoveries * * Note : Unless explicitely changed, this setting will remain valid * for any subsequent discoveries on this socket, such as : * o Waiting for device -> getsockopt(IRLMP_WAITDEVICE) * o Auto-connect -> connect(daddr = 0x0) * o Standard discovery -> getsockopt(IRLMP_ENUMDEVICES) */ void irdaspray_sethintmask(int fd) { unsigned char hints[4]; /* * The hint mask we use is set to catch any device that potentially * support things outside IrComm/IrLAN/IrLPT, so most device * worth connecting to via IrTTP. * Setting the hint mask with IrComm or IrObex could be usefull * for some apps... */ hints[0] = HINT_COMPUTER | HINT_PDA; hints[1] = 0; /* Set the filter used for performing discovery */ if (setsockopt(fd, SOL_IRLMP, IRLMP_HINT_MASK_SET, hints, sizeof(hints))) { perror("setsockopt"); exit(-1); } } /* * Function irdaspray_check_discovery (fd) * * Check the state of the discovery log * * See irdaspray_discover_devices() for details */ int irdaspray_check_discovery(int fd) { struct irda_device_list * list; unsigned char buf[DISC_BUF_LEN]; int len; /* Set the list to point to the correct place */ list = (struct irda_device_list *) buf; len = DISC_BUF_LEN; /* Perform a discovery and get device list */ if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { printf("Didn't find any devices!\n"); return -1; } /* Did we got any ? (in some rare cases, this test is true) */ if (list->len <= 0) { printf("Didn't find any devices!\n"); return -1; } return 0; } /* * Function irdaspray_waitfor_devices (fd) * * Wait until some device come into range... * * Note much to say. We set our hint mask, and call the stack with the * maximum amount of time we want to wait. * If a new device come in, we will wake up, otherwise it will timeout... * Note : this function is only triggered by *new* device, devices already * in range won't trigger this function. * The exact rules are : * If a device has been discovered, or has change its hint bits, * less than the discovery timeout in the past, then return, * otherwise block until this happen or timeout. * Therefore, if you poll continuously this function, you'd better sleep * a bit after a positive result before calling it again... */ int irdaspray_waitfor_device(int fd) { int timeout = 30000; /* Block only for 30s */ int len; #if SETHINTMASK /* Set the filter used for performing discovery */ irdaspray_sethintmask(fd); #endif #if CHECKBEFOREWAIT /* Note : before waiting for a new device to show up, we first * check if a device has not already been discovered */ if(irdaspray_check_discovery(fd) == 0) return 0; #endif /* Wait for a device to be in range */ printf("Waiting for a device...\n"); len = sizeof(timeout); if (getsockopt(fd, SOL_IRLMP, IRLMP_WAITDEVICE, &timeout, &len)) { if(errno != EAGAIN) { perror("getsockopt-wait"); exit(-1); } printf("Nothing found in the last %d s\n", timeout / 1000); return -1; } return 0; /* Found one device */ } /* * Function echo_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * * Note : in this function, the memory allocation for the discovery log * is done "the right way", so that we don't leak memory... */ int irdaspray_discover_devices(int fd, char *service_name) { struct irda_device_list * list; unsigned char buf[DISC_BUF_LEN]; struct irda_ias_set ias_query; int err; int len; int i; /* We are so proud of this feature that we show it again ! */ #if SETHINTMASK /* Set the filter used for performing discovery */ irdaspray_sethintmask(fd); #endif /* Set the list to point to the correct place */ list = (struct irda_device_list *) buf; len = DISC_BUF_LEN; /* Perform a discovery and get device list */ if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { printf("Didn't find any devices!\n"); return -1; } /* Did we got any ? (in some rare cases, this test is true) */ if (list->len <= 0) { printf("Didn't find any devices!\n"); return -1; } /* List all devices */ printf("Discovered %d devices :\n", list->len); for (i=0;ilen;i++) { printf(" [%d] name: %s, daddr: 0x%08x", i + 1, list->dev[i].info, list->dev[i].daddr); fflush(stdout); /* Ask if the requested service exist on this device */ len = sizeof(ias_query); ias_query.daddr = list->dev[i].daddr; strcpy(ias_query.irda_class_name, service_name); strcpy(ias_query.irda_attrib_name, "IrDA:TinyTP:LsapSel"); err = getsockopt(fd, SOL_IRLMP, IRLMP_IAS_QUERY, &ias_query, &len); if(err == 0) { printf(", has service %s\n", service_name); } else { if(errno != EADDRNOTAVAIL) printf(" \n"); else printf(", doesn't have %s\n", service_name); } } /* Ask the user */ printf("Enter device number:"); fflush(stdout); if(scanf("%X", &i) != 1) return -1; i--; if((i < 0) && (i > list->len)) return -1; return(list->dev[i].daddr); } /* * IRIAS set/get/query tests */ void irias_play(int fd) { struct irda_ias_set ias_query; int len; /* Get the name of our own device */ len = sizeof(ias_query); strcpy(ias_query.irda_class_name, "Device"); strcpy(ias_query.irda_attrib_name, "DeviceName"); if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, &len)) { printf("The name of our device is = ``%s''\n", ias_query.attribute.irda_attrib_string.string); } /* Get the name of the remote device */ len = sizeof(ias_query); strcpy(ias_query.irda_class_name, "Device"); strcpy(ias_query.irda_attrib_name, "DeviceName"); if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_QUERY, &ias_query, &len)) { printf("The name of the other device is = ``%s''\n", ias_query.attribute.irda_attrib_string.string); } /* Set an integer in IAS (new object) */ strcpy(ias_query.irda_class_name, "my:object"); ias_query.irda_attrib_type = IAS_INTEGER; strcpy(ias_query.irda_attrib_name, "my:int"); ias_query.attribute.irda_attrib_int = 45; if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set in IAS\n"); perror("setsockopt"); } /* Set a string in IAS (existing object) */ strcpy(ias_query.irda_class_name, "my:object"); ias_query.irda_attrib_type = IAS_STRING; strcpy(ias_query.irda_attrib_name, "my:string"); strcpy(ias_query.attribute.irda_attrib_string.string, "The String"); ias_query.attribute.irda_attrib_string.len = strlen("The String"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set in IAS\n"); perror("setsockopt"); } /* Set another string in IAS (system object) */ strcpy(ias_query.irda_class_name, "Device"); ias_query.irda_attrib_type = IAS_STRING; strcpy(ias_query.irda_attrib_name, "Owner"); strcpy(ias_query.attribute.irda_attrib_string.string, "Myself"); ias_query.attribute.irda_attrib_string.len = strlen("Myself"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set in IAS\n"); perror("setsockopt"); } /* Set yet another string in IAS (same object name as this socket) */ if (echo) strcpy(ias_query.irda_class_name, "IrECHO"); else strcpy(ias_query.irda_class_name, "IrDISCARD"); ias_query.irda_attrib_type = IAS_STRING; strcpy(ias_query.irda_attrib_name, "App-Name"); strcpy(ias_query.attribute.irda_attrib_string.string, "irdaspray.magic"); ias_query.attribute.irda_attrib_string.len = strlen("irdaspray.magic"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set in IAS\n"); perror("setsockopt"); } /* Set another integer in IAS (the object attached to this socket) */ strcpy(ias_query.irda_class_name, ""); ias_query.irda_attrib_type = IAS_INTEGER; strcpy(ias_query.irda_attrib_name, "App-Version"); ias_query.attribute.irda_attrib_int = 3; if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set <> in IAS\n"); perror("setsockopt"); } /* Try to set a kernel attribute (should fail) */ strcpy(ias_query.irda_class_name, "Device"); strcpy(ias_query.irda_attrib_name, "DeviceName"); strcpy(ias_query.attribute.irda_attrib_string.string, "Linux"); ias_query.attribute.irda_attrib_string.len = strlen("Linux"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, sizeof(ias_query))) { printf("Can't set in IAS\n"); perror("setsockopt"); } /* Read the integer in IAS */ len = sizeof(ias_query); strcpy(ias_query.irda_class_name, "my:object"); strcpy(ias_query.irda_attrib_name, "my:int"); if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, &len)) { printf("Type = %d\n", ias_query.irda_attrib_type); printf("Int = %d\n", ias_query.attribute.irda_attrib_int); } /* Read the string in IAS */ len = sizeof(ias_query); strcpy(ias_query.irda_class_name, "my:object"); strcpy(ias_query.irda_attrib_name, "my:string"); if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, &len)) { printf("Type = %d\n", ias_query.irda_attrib_type); printf("String = ``%s''\n", ias_query.attribute.irda_attrib_string.string); } } void irias_remove(int fd) { struct irda_ias_set ias_query; /* Delete the integer in IAS */ strcpy(ias_query.irda_class_name, "my:object"); strcpy(ias_query.irda_attrib_name, "my:int"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); perror("setsockopt"); } /* Delete the string in IAS */ strcpy(ias_query.irda_class_name, "my:object"); strcpy(ias_query.irda_attrib_name, "my:string"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); perror("setsockopt"); } /* Delete the other string in IAS */ strcpy(ias_query.irda_class_name, "Device"); strcpy(ias_query.irda_attrib_name, "Owner"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); perror("setsockopt"); } /* Delete the last string in IAS */ if (echo) strcpy(ias_query.irda_class_name, "IrECHO"); else strcpy(ias_query.irda_class_name, "IrDISCARD"); strcpy(ias_query.irda_attrib_name, "App-Name"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); } /* Delete the other integer in IAS */ strcpy(ias_query.irda_class_name, ""); strcpy(ias_query.irda_attrib_name, "App-Version"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove <> in IAS\n"); perror("setsockopt"); } /* Try to delete a kernel attribute (should fail) */ strcpy(ias_query.irda_class_name, "Device"); strcpy(ias_query.irda_attrib_name, "DeviceName"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); perror("setsockopt"); } /* Try to delete a non-existing attribute (should fail) */ strcpy(ias_query.irda_class_name, "None"); strcpy(ias_query.irda_attrib_name, "None"); if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, sizeof(ias_query))) { printf("Can't remove in IAS\n"); perror("setsockopt"); } } /* * Function irdaspray_connect_request (self) * * Try to connect to remote device * */ static int irdaspray_connect_request(int fd) { struct sockaddr_irda peer; struct sockaddr_irda self; char *service_name; int len = sizeof(int); int daddr; #if AUTOCONNECT int err; #endif /* Set the service name */ if (echo) service_name = "IrECHO"; else service_name = "IrDISCARD"; #if WAITFORDEVICE /* Wait until a device is in range */ if(irdaspray_waitfor_device(fd)) return -1; #endif #if AUTOCONNECT /* * First, we try the auto-connect, which in 99% of the case * should be good enough... * * Auto connect lookup devices in range and query them about the * service we want. If there is only one device that support * this service, we are magically connected to it... */ peer.sir_family = AF_IRDA; strncpy(peer.sir_name, service_name, 25); peer.sir_addr = 0x0; /* Maybe DEV_ADDR_ANY is better ? */ err = connect(fd, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda)); /* Check what has happened */ if(err == 0) { printf("Auto-connect did found exactly one device !\n"); return 0; } if(errno == EADDRNOTAVAIL) { printf("Auto-connect could not find anything...\n"); return -1; } if(errno != ENOTUNIQ) printf("Auto-connect failed...\n"); else printf("Auto-connect has found more than one device...\n"); #endif /* * At this point, if we don't have any user interface or if we * don't want to bother with that, we could just tell the user * to aim its device closer to the target and just quit... * (or we could pretend that we have seen nothing, which will * end up with the same result on the user) * However, for the purpose of the exercise, let's pretend that * the user doesn't want to move his device and has plenty of UI... */ /* Make a proper discovery, display device and ask user to choose */ daddr = irdaspray_discover_devices(fd, service_name); if (daddr == -1) return -1; /* Now we can try again to connect using the address selected */ peer.sir_family = AF_IRDA; strncpy(peer.sir_name, service_name, 25); peer.sir_addr = daddr; if (connect(fd, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); return -1; } #if GETSOCKNAME /* Get out info about our socket (local, not remote) */ len = sizeof(struct sockaddr_irda); if (getsockname(fd, (struct sockaddr*) &self, &len)) { perror("getsockname"); return -1; } printf("We have been assigned Address 0x%X and LSAP 0x%02X...\n", self.sir_addr, self.sir_lsap_sel); /* Note : getsockname return a valid lsap after a connect or a bind, * but return a valid addr only after an accept, and with my patch * also after a connect. */ #endif printf("Connected!\n"); /* Test if IR-IAS is happy */ #if SETIAS irias_play(fd); #endif #if DELIAS irias_remove(fd); #endif return 0; } int irdaspray_transmit(int fd) { int total = 0; int actual; int i; /* Transmit frames */ for (i=0; i 0) ; conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (conn_fd < 0) { perror("accept"); return -1; } /* Fork off receiver, so that we can accept multiple * simultaneous connections */ pid = fork(); /* If in children, receive, in parent, listen */ if(!pid) { printf("Connected!\n"); do { actual = recv(conn_fd, &buf, sizeof(buf), 0); if (actual <= 0) break; printf("Got %d bytes\n", actual); if (echo) { actual = send(conn_fd, &buf, actual, 0); printf("Sent %d bytes\n", actual); } } while (actual > 0); close(conn_fd); printf("Disconnected!\n"); /* Quit the child */ return(0); } } return 0; } static void usage(char *argv[]) { fprintf(stderr, "usage: %s [-s] [-c] [-d] [-e] [-h] [-b frame-size] [-n frames] \n", argv[0]); fprintf(stderr, " -s act as a server\n"); fprintf(stderr, " -c act as a client (default)\n"); fprintf(stderr, " -d use discard service for unidirection transfer\n"); fprintf(stderr, " -e use echo service for bidirection transfer (default)\n"); fprintf(stderr, " -t open two concurent client sockets\n"); fprintf(stderr, " -h print this message ;-)\n"); fprintf(stderr, " -b frame-size in bytes (default 1024, max 8192)\n"); fprintf(stderr, " -n number of frames (default 100)\n"); exit(1); } /* * Function main (argc, ) * * * */ int main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "vscdethb:m:n:f:")) != -1) { switch (c) { case 's': server = 1; /* Act as a server */ break; case 'c': server = 0; /* Act as a client */ break; case 'd': echo = 0; /* Use discard service instead of echo */ break; case 'e': echo = 1; /* Use echo service instead of discard */ break; case 't': two = 1; /* Open two client sockets */ break; case 'h': usage(argv); break; case 'n': frame_number = atoi(optarg); break; case 'b': frame_size = atoi(optarg); break; default: usage(argv); break; } } /* Start client or server as needed */ if(server) return(ir_server()); else return(ir_client()); } irda-utils-0.9.18/irsockets/send_ultra.c0000644000175000017500000000327410454641046017550 0ustar samuelsamuel/* * Jean II '99 * * Send ultra info. * Open a Ultra socket and send one packet... * * Note : Ultra can carry only 382 bytes / packet, and this including * the ultra header (the UPID). As we use a one byte UPID, that's 381 bytes. */ #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* * This is the Ultra protocol ID we are currently using (7 bits) * Currently, IrDA-Ultra defines only UPID 0x1 for Obex and 0x2 for IrWW. * Maybe you should use a bigger number to avoid clashes with future * standardisations... */ #define UPID 0x3 int main(int argc, char * argv[]) { struct sockaddr_irda self; /* Socket address */ int fd; /* The socket itself */ unsigned char buf[382]; /* Send buffer */ int actual; /* Initialise with a dummy string */ strcpy(buf, "Ultra-Test"); /* Look for command line args */ if(argc > 1) { strncpy(buf, argv[1], 380); buf[380] = '\0'; } /* Create socket - Ultra type */ fd = socket(AF_IRDA, SOCK_DGRAM, 1); if(fd < 0) { perror("Creating socket"); return(-1); } /* Bind to the specific Ultra PID */ self.sir_family = AF_IRDA; self.sir_lsap_sel = UPID; if(bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("Connect"); return(-1); } printf("Ready to send on Ultra-PID %d\n", UPID); /* Send a packet including the trailing '\0' */ actual = send(fd, &buf, strlen(buf) + 1, 0); printf("Sent Ultra packet ``%s''\n", buf); close(fd); return(0); } irda-utils-0.9.18/irsockets/ias_query.c0000644000175000017500000000342510454641046017407 0ustar samuelsamuel#include #include #include #include #include #include #include #include #include #include #include #include #include #include int ias_query(int fd, int daddr, char *class, char *attrib) { struct irda_ias_set query; int len; len = sizeof(struct irda_ias_set); printf("Querying for %s:%s\n", class, attrib); strncpy(query.irda_class_name, class, IAS_MAX_CLASSNAME); strncpy(query.irda_attrib_name, attrib, IAS_MAX_ATTRIBNAME); if(daddr) query.daddr = daddr; if (getsockopt(fd, SOL_IRLMP, IRLMP_IAS_QUERY, &query, &len)) { perror("getsockopt"); exit(-1); } if (len > 0) { printf("Success2\n"); switch (query.irda_attrib_type) { case IAS_INTEGER: printf("%s:%s=%d\n", class, attrib, query.attribute.irda_attrib_int); break; case IAS_OCT_SEQ: printf("got octseq\n"); break; case IAS_STRING: printf("%s:%s=%s\n", class, attrib, query.attribute.irda_attrib_string.string); break; case IAS_MISSING: printf("Missing!\n"); break; default: printf("Unknown type %d!\n", query.irda_attrib_type); break; } } return 0; } /* * Function main (argc, ) * * * */ int main(int argc, char *argv[]) { int fd; int iraddr; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Check args */ if(argc < 4) { fprintf(stderr, "Usage : %s iraddr class attrib\n", argv[0]); return 0; } /* Convert IrDA address to binary */ if(sscanf(argv[1], "%X", &iraddr) != 1) { fprintf(stderr, "Invalid address: \"%s\"...\n", argv[1]); return 0; } ias_query(fd, iraddr, argv[2], argv[3]); return 0; } irda-utils-0.9.18/irsockets/irprintfx.c0000644000175000017500000000546210454641046017436 0ustar samuelsamuel/********************************************************************* * * Filename: irprintf.c * Version: * Description: * Status: Experimental. * Authors: Dag Brattli * Jean Tourrilhes * Created at: 7/12/99 * Modified at: * Modified by: * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* * Read an Ir socket and display it on stdout * Use file descriptor */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ unsigned char buf[4098]; /* * Function main (argc, ) * * Implements IrDA Echo or Discard server * */ int main(int argc, char *argv[]) { struct sockaddr_irda peer, self; int addrlen; int fd, conn_fd; int actual; printf("IrDA printf server starting ...\n"); /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Init self */ self.sir_family = AF_IRDA; strncpy(self.sir_name, "MyServer", 25); self.sir_lsap_sel = LSAP_ANY; if (bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; } if (listen(fd, 8)) { perror("listen"); return -1; } for (;;) { addrlen = sizeof(struct sockaddr_irda); printf("Waiting for connection!\n"); conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (conn_fd < 0) { perror("accept"); return -1; } printf("Connected!\n"); do { actual = read(conn_fd, buf, sizeof(buf)); if((actual <= 0) || (buf[0] == 0x3)) break; fwrite(buf, 1, actual, stdout); } while (buf[0] != '\0'); fflush(stdout); close(conn_fd); printf("Disconnected!\n"); } return 0; } irda-utils-0.9.18/irsockets/irscanf.c0000644000175000017500000000765110454641046017040 0ustar samuelsamuel/********************************************************************* * * Filename: irscanf.c * Version: * Description: * Status: Experimental. * Authors: Dag Brattli * Jean Tourrilhes * Created at: 7/12/99 * Modified at: * Modified by: * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* * Read stdin and push it on an Ir socket * Use stream */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* Memory allocation for discovery */ #define DISC_MAX_DEVICES 10 #define DISC_BUF_LEN sizeof(struct irda_device_list) + \ sizeof(struct irda_device_info) * DISC_MAX_DEVICES unsigned char buf[4096]; /* * Function echo_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * */ int irscanf_discover_devices(int fd) { struct irda_device_list *list; unsigned char buf[DISC_BUF_LEN]; int len; int i; /* Set the list to point to the correct place */ list = (struct irda_device_list *) buf; len = DISC_BUF_LEN; if((getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) || (list->len <= 0)) { perror("getsockopt"); printf("Didn't find any devices!\n"); return(-1); } /* List all devices */ printf("Discovered %d devices :\n", list->len); for (i=0;ilen;i++) { printf(" [%d] name: %s, daddr: 0x%08x\n", i + 1, list->dev[i].info, list->dev[i].daddr); } /* Clever heuristic... */ printf("Lets try this one\n"); return list->dev[0].daddr; } /* * Function main (argc, ) * * * */ int main(int argc, char *argv[]) { struct sockaddr_irda peer; int daddr = 0; int fd; FILE *stream; int hints; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Set the filter used for performing discovery */ hints = HINT_COMPUTER | HINT_PDA; if (setsockopt(fd, SOL_IRLMP, IRLMP_HINT_MASK_SET, &hints, sizeof(hints))) { perror("setsockopt-hints"); exit(-1); } #if 0 /* Find a peer */ daddr = irscanf_discover_devices(fd); if (daddr == -1) return -1; #endif peer.sir_family = AF_IRDA; strncpy(peer.sir_name, "MyServer", 25); peer.sir_addr = daddr; if (connect(fd, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); return -1; } stream = fdopen(fd, "w"); if(stream == NULL) { perror("fdopen"); return -1; } printf("Connected!\n"); printf("Type your text with '.' on the last line...\n"); do { if((fgets(buf, sizeof(buf), stdin) == NULL) || (buf[0] == '.')) { buf[0] = 0x3; buf[1] = '\0'; } fwrite(buf, 1, strlen(buf), stream); fflush(stream); } while(buf[0] != 0x3); printf("Closing connection...\n"); fclose(stream); close (fd); return 0; } irda-utils-0.9.18/irsockets/recv_ultra.c0000644000175000017500000000303310454641046017547 0ustar samuelsamuel/* * Jean II '99 * * Receive ultra info. * Open a Ultra socket and wait for packets... */ #include #include /* Not needed */ #include #include #include /* Not needed */ #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* * This is the Ultra protocol ID we are currently using (7 bits) * Currently, IrDA-Ultra defines only UPID 0x1 for Obex and 0x2 for IrWW. * Maybe you should use a bigger number to avoid clashes with future * standardisations... */ #define UPID 0x3 int main(int argc, char * argv[]) { struct sockaddr_irda self; /* Socket address */ int fd; /* The socket itself */ unsigned char buf[382]; /* Receive buffer */ int actual; /* Create socket - Ultra type */ fd = socket(AF_IRDA, SOCK_DGRAM, 1); if(fd < 0) { perror("Creating socket"); return(-1); } /* Bind to the specific Ultra PID */ self.sir_family = AF_IRDA; self.sir_lsap_sel = UPID; if(bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("Connect"); return(-1); } /* Receive packets */ printf("Waiting for Ultra packets on UPID %d...\n", UPID); while(1) { /* Block on read */ actual = recv(fd, &buf, sizeof(buf), 0); buf[actual] = '\0'; /* Just to avoid crash on incorrect data */ printf("Received packet ``%s''\n", buf); } /* Never reached */ close(fd); printf("Disconnected!\n"); return(0); } irda-utils-0.9.18/irsockets/Makefile0000644000175000017500000000401410454641046016675 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for irsockets test programs ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Sat Dec 25 16:13:54 1999 ## Modified by: Dag Brattli ## ## $Id: Makefile 115 2006-02-28 22:16:46Z sambau $ ## ## Copyright (c) 1998-1999 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include ../output.mak CC = gcc LD = ld RM = rm -f RM_CMD = $(ECMD)$(RM) *.BAK *.bak *.o *.so ,* *~ *.a *.orig *.rej INCLUDES = $(SYS_INCLUDES) -I../include LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) # # System stuff # SYS_INCLUDES = -I/usr/include -I/usr/src/linux/include SYS_LIBRARIES = SYS_LIBPATH = -L/usr/lib -L/usr/local/lib CFLAGS= $(SYS_INCLUDES) $(RPM_OPT_FLAGS) -O2 -Wall -Wstrict-prototypes SRCS = irprintf.c irprintfx.c irscanf.c irscanfx.c irdaspray.c ias_query.c send_ultra.c recv_ultra.c OBJS = $(SRCS:.c=.o) TARGETS = irprintf irprintfx irscanf irscanfx irdaspray ias_query send_ultra recv_ultra all: $(OBJS) %: %.o $(prn_cc_o) $(ECMD)$(CC) $(XCFLAGS) -o $@ $^ $(LIBS) %.o: %.c $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< clean: $(prn_clean) $(RM_CMD) distclean: $(prn_distclean) $(RM_CMD) $(ECMD)$(RM) $(TARGETS) depend: $(prn_depend) $(ECMD)makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) # DO NOT DELETE irda-utils-0.9.18/irsockets/README0000644000175000017500000000356310454641046016125 0ustar samuelsamuel Sample directory ---------------- This directory contains a few sample program illustrating how to use the socket interface of the IrDA stack (IrSock) and how to write your own applications on top of IrSock. Note that applications can also use the OpenObex library on top of IrSock (prefered), or run on top of IrComm (discouraged). And there is also the option of using TCP/IP over IrDA. If you want more example of use of IrDA, you are encouraged to look at the source code of OpenObex and e-Squirt. Jean II irprintf -------- Sample IrSock server. Wait for connections from irscanf and dump on the console everything received over the IrDA socket. irscanf ------- Sample IrSock client. Grab anything from the console and sends it to the irprintf application. The combination of irscanf and irprintf make a crude one way chat over IrDA. irprintfx/irscanfx ------------------ Same programs as irprintf/irscanf, use internally file descriptors instead of stream (and therefore simpler). irdaspray --------- Utility to test IrDA performance. Can generate unidirectional or bidirectional streams of packets between a Client and a Server. For example : Client : irdaspray -n 10 -b 2000 Server : irdaspray -s More command line options and features are available, check the source code for details. The code also contains many examples on how to use some of the most advanced features of the Linux-IrDA stack, so is a good place to start if you want to program something fancy. send_ultra ---------- Send an Ultra packet (connectionless broadcast) recv_ultra ---------- Wait and receive some Ultra packets ias_query --------- Perform an IAS query to a remote device. This version works. Note that the irdaspray code contains many more example of interaction with IAS. oldies ------ Older applications. Those have some known problems, and some portions of the code is bad practice. irda-utils-0.9.18/irsockets/irprintf.c0000644000175000017500000000563610454641046017251 0ustar samuelsamuel/********************************************************************* * * Filename: irprintf.c * Version: * Description: * Status: Experimental. * Authors: Dag Brattli * Jean Tourrilhes * Created at: 7/12/99 * Modified at: * Modified by: * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* * Read an Ir socket and display it on stdout * Use stream */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ unsigned char buf[4098]; /* * Function main (argc, ) * * Implements IrDA Echo or Discard server * */ int main(int argc, char *argv[]) { struct sockaddr_irda peer, self; int addrlen; int fd, conn_fd; FILE *stream; printf("IrDA printf server starting ...\n"); /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Init self */ self.sir_family = AF_IRDA; strncpy(self.sir_name, "MyServer", 25); self.sir_lsap_sel = LSAP_ANY; if (bind(fd, (struct sockaddr*) &self, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; } if (listen(fd, 8)) { perror("listen"); return -1; } for (;;) { addrlen = sizeof(struct sockaddr_irda); printf("Waiting for connection!\n"); conn_fd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (conn_fd < 0) { perror("accept"); return -1; } stream = fdopen(conn_fd, "r"); if(stream == NULL) { perror("fdopen"); return -1; } printf("Connected!\n"); do { if((fgets(buf, sizeof(buf), stream) == NULL) || (buf[0] == 0x3)) buf[0] = '\0'; fwrite(buf, 1, strlen(buf), stdout); } while (buf[0] != '\0'); fflush(stdout); fclose(stream); close(conn_fd); printf("Disconnected!\n"); } return 0; } irda-utils-0.9.18/irsockets/irscanfx.c0000644000175000017500000000744310454641046017227 0ustar samuelsamuel/********************************************************************* * * Filename: irscanfx.c * Version: * Description: * Status: Experimental. * Authors: Dag Brattli * Jean Tourrilhes * Created at: 7/12/99 * Modified at: * Modified by: * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ /* * Read stdin and push it on an Ir socket * Use file descriptor */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* Memory allocation for discovery */ #define DISC_MAX_DEVICES 10 #define DISC_BUF_LEN sizeof(struct irda_device_list) + \ sizeof(struct irda_device_info) * DISC_MAX_DEVICES unsigned char buf[4096]; /* * Function echo_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * */ int irscanf_discover_devices(int fd) { struct irda_device_list *list; unsigned char buf[DISC_BUF_LEN]; int len; int i; /* Set the list to point to the correct place */ list = (struct irda_device_list *) buf; len = DISC_BUF_LEN; if((getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) || (list->len <= 0)) { perror("getsockopt"); printf("Didn't find any devices!\n"); return(-1); } /* List all devices */ printf("Discovered %d devices :\n", list->len); for (i=0;ilen;i++) { printf(" [%d] name: %s, daddr: 0x%08x\n", i + 1, list->dev[i].info, list->dev[i].daddr); } /* Clever heuristic... */ printf("Lets try this one\n"); return list->dev[0].daddr; } /* * Function main (argc, ) * * * */ int main(int argc, char *argv[]) { struct sockaddr_irda peer; int daddr = 0; int fd; int hints; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Set the filter used for performing discovery */ hints = HINT_COMPUTER | HINT_PDA; if (setsockopt(fd, SOL_IRLMP, IRLMP_HINT_MASK_SET, &hints, sizeof(hints))) { perror("setsockopt-hints"); exit(-1); } #if 0 /* Find a peer */ daddr = irscanf_discover_devices(fd); if (daddr == -1) return -1; #endif peer.sir_family = AF_IRDA; strncpy(peer.sir_name, "MyServer", 25); peer.sir_addr = daddr; if (connect(fd, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); return -1; } printf("Connected!\n"); printf("Type your text with '.' on the last line...\n"); do { if((fgets(buf, sizeof(buf), stdin) == NULL) || (buf[0] == '.')) { buf[0] = 0x3; buf[1] = '\0'; } write(fd, buf, strlen(buf)); } while(buf[0] != 0x3); printf("Closing connection...\n"); close (fd); return 0; } irda-utils-0.9.18/man/0000755000175000017500000000000010454641161014001 5ustar samuelsamuelirda-utils-0.9.18/man/irdaping.8.gz0000644000175000017500000000220610454641046016310 0ustar samuelsamuel3=Dirdaping.8uUmo6_q!-b*С負N$*۰A]ltJFRq< {HIIu w幣X h+Kjeʥ5sEqN(劍tzONZ} 6F$\ j0^3mtSe$ݻx;WcsQUBU,R]qQq1븿S|^8+XZ&ӺْZgI#إ=YՖoj8uB퉈|4K&{Р~Q$W4݌#e2Y+`!6K9cP#Y tHQڜ>͜>M,3sN_Cہ??l/Lgd:Y "1y`NB^O;g$ iIBA!JUHK$Y}'(q+ 0꒩D]]TskNUS٠YP:5;6ω=hX u픮-5yJ齂oK֔ud_*d FbhHBR#fר,R@e3Wov̮O|dq>Ǐ}jWY(>Ji\[dO05zsRɫ_, S Bq.qlI3?7/nȱ+F X,haO/]a4= 0B3]Nerd"&tF׋iWXWN9Х(qeiZNA]3x!,ՍIy3(Y>Nuw5+YXV,eT 1I\ëGtCת+i\nWnNwF9`p>+C8OZUG7c#q`o*#jMgwjfpQAoWؔP*a>sFǘ*1h8a߿b a'{rrK?{P݂\a./ίX+ʯ?xCwͺPxBQ@]ۡt_̀#1ÔTAp Gx蠾0X3?Kђ Lz z zK&irda-utils-0.9.18/man/smcinit.8.gz0000644000175000017500000000370310454641046016164 0ustar samuelsamuelc?Dsmcinit.8Xao_1P?dq ꢊlbK;"XKiaj}KҲ\[4l;3͛576[lDIcUM''$域n)Qt;LܶPZyzD[Z&o$Ӱ 5d4 L7 _ng<{kI9/m2.$IdiF˺V^қ?KYXA!%B;ZI;2֔vkU)KzP~C|{FlFF5Qņ7ͳUB4bU˔%K]rK웁6nWkx)[_Eղh`p|xc6IKn+n-k/;@1j[1&ek6|eVVkpP) &u H&Ϯ4Xy/5?ddD^69uDi?" V=-/E3缇+ xZbt!2-brYvlRiE]?o;(-VLJ=$Bt9r*-NwX-e+:Y.Bh%`cZ:ğkm_uD|ժ$+|oYٯKW3Kxi='Or$A'͎kڐ ahJwb F"Ż={iNKt9w.G?Q9etobmŖ|d1ZÑ ȺE?be39}keL2]0G`X\Q0EQoe9Xly)U#FR̲X%bR-LT^VlPwɘ4|HiC-XԢƝ~,)P/,_- 5Rv{5oNGb8>ri-Ho;afh[-&bJ wcs<Ĕ~1-J9Na%\F=r5+RHmKr GC(tl1a&2sF=w}Ƽ3w"?"Qp6-:-ᗸi-R45΃y-wxC1vPT{#mB?ij-ҿEoG9k-80dڤ[fr'c7!nW_}w 6b_^S>,KqlxȎճAY1]?-EnO775^817^ 6(74 irda-utils-0.9.18/man/TODO.man0000644000175000017500000000120210454641046015240 0ustar samuelsamuelTODO * separate header and footer include files * more man pages: irkbd, irsockets, .. * write DIAGNOSTICS section for every man page * format all SGML tags in the right case (for XML compatibility) * explain module options in detail, e.g. dongle_id=0xNN * create man page for the higher layer of the irda stack - ircomm(4) -> /dev/ircommX, based on null/zero/random/lp(4) - irlpt(4) -> /dev/irlptX - irnet(4) -> /dev/irnet - irlan(4) -> irlanX - irda(7) -> IrSock stuff, based on ip/tcp(7) + point to other manpages * find a way so that the resulting man page doesn't look crap, or rewrite everything in troff (see Wireless Tools). irda-utils-0.9.18/man/irnetd.8.gz0000644000175000017500000000107710454641046016005 0ustar samuelsamuelDirnetd.8uSn0+<9@IXVamHhz`͵Ŕ"rRЋaٙQ Yc;y`  2yseZ=6{9_]rXy%ŚOUI5[W (Ni EF?M}=u=}RC* gC.)irda-utils-0.9.18/man/COPYING0000644000175000017500000004311010454641046015035 0ustar samuelsamuel GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. irda-utils-0.9.18/man/tosh1800-smcinit.8.gz0000644000175000017500000000263210454641046017450 0ustar samuelsamuelc?Dtosh1800-smcinit.8Wn7}߯6 e;" "K2e)Z9@Qr_ob$AlK$̙3C:^bޞ{d' |@'^߿ҽ@GNp?#LMI{r"? lP%ViPhėL@K$k8z̓lL`4N$E9_9MҐO0K_^Rln6|wuqqN]@w=)@*f i '˲,Rb21?ׅxyx`TO1cXD\LQk[hV-|ΆI/I e5ni^TWUJ{k8_oJe#JكZ'=Y(d4ʫU3^;Ѕ(+I֭gŽgOQ 5~xyg<3R{b2--r` NdJ= E .}B1`d 4#FnXiҋap(tHaC9rru!'\ɥD4Eχ=#D |[0t2͌a &/o ȺV1$.ʄ *p Սhg`  K@3%XFH/31XйZN CX{D$#/Tp؋K+dVkK*&V*hxm tPU. 0jb P5'"Lo?$9'r%?hABlQyÞyEZJ3a]k{!lE?VЬ6Ek@Uއx𰸝1@>FDr׌iqj;+s) QHtԳdˈ%`x6#N-)+=}{.tX(Q 'iMtWϚ[>ҡ .LHomWb)J| #0N+h2>L&K(+e >NOQjF2WVogg.<דz=Iv;HMlӔ!w̞5G wOFE3;Ehu irda-utils-0.9.18/man/man-irdadump.sgml0000644000175000017500000000475110454641046017254 0ustar samuelsamuelLinux/IrDA Project"> Infrared-HOWTO"> Linux/IrDA-Tutorial"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. COPYRIGHT Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/Makefile0000644000175000017500000000267410454641046015454 0ustar samuelsamuel# Makefile for Linux/IrDA man pages. # v0.1 26/03/2001 wh # v0.2 Jean II # v0.3 29/04/2003 wh, added -9 to gzip, changed docbook-to-man to docbook2man include ../output.mak DOCBOOKCMD=docbook2man DESTDIR= VERSION=0.10 PREFIX= MANDIR=$(PREFIX)/usr/man MAN1DIR=$(MANDIR)/man1/ MAN4DIR=$(MANDIR)/man4/ MAN7DIR=$(MANDIR)/man7/ MAN8DIR=$(MANDIR)/man8/ MANPAGES4=irnet.4.gz MANPAGES7=irda.7.gz MANPAGES8=irattach.8.gz irdaping.8.gz irdadump.8.gz irpsion5.8.gz \ findchip.8.gz irnetd.8.gz smcinit.8.gz tosh1800-smcinit.8.gz # Man pages generated by DOCBOOK SGMLMAN=irattach.8 irdaping.8 irdadump.8 irpsion5.8 findchip.8 all: $(MANPAGES4) $(MANPAGES7) $(MANPAGES8) man-pages:all # Translate docbook to man with proper dependancies %.8: man-%.sgml man-%-inc.sgml $(prn_man) $(ECMD)$(DOCBOOKCMD) $< > $@ # GZIP the man page %.gz: % $(prn_gzip) $(ECMD)gzip -9 -f $^ install: man-pages $(prn_install) $(ECMD)install -m 755 -d $(MAN4DIR) $(ECMD)install -m 644 $(MANPAGES4) $(MAN4DIR)/ $(ECMD)install -m 755 -d $(MAN7DIR) $(ECMD)install -m 644 $(MANPAGES7) $(MAN7DIR)/ $(ECMD)install -m 755 -d $(MAN8DIR) $(ECMD)install -m 644 $(MANPAGES8) $(MAN8DIR)/ clean: $(ECMD)rm -f $(SGMLMAN) *~ manpage.* distclean: clean # Don't wipe out the gziped man pages by default, users don't have docbook # Don't wipe out manpage generated by hand realclean: $(ECMD)rm -f $(SGMLMAN) manpage.* dist: all (cd ..; tar cvfz man-irda-$(VERSION).tgz man-irda-$(VERSION)) irda-utils-0.9.18/man/man-irattach-inc.sgml0000644000175000017500000003551510454641046020017 0ustar samuelsamuel irattach 8 irattach binds the Linux-IrDA stack to a IrDA port irattach <dev> -s -d dongle -v -h DESCRIPTION irattach binds the Linux-IrDA stack to an IrDA port. It configures the low level of the Linux-IrDA stack in the kernel. This step is usually necessary before you (or applications) can use the higher layer of the IrDA stack. The irattach command loads the necessary Linux-IrDA driver, which configures the IrDA hardware, and configures the IrDA stack to operate on the new IrDA port. Multiple IrDA ports can be activated through multiple irattach commands. irattach by default uses the driver which connects to the Linux TTY subsystem and use the standard Linux serial driver. This works well for most machines and configurations, but limits the baud rate to 115200bps (IrDA SIR mode). The mode of operation will work with most FIR hardware (as found in laptops - they provide serial emulation) and most serial dongles (provided the proper dongle type is specified), making it a safe choice. However, USB dongles and a few FIR hardware don't support serial emulation and can't be used with the driver. irattach can also use one of the Linux FIR drivers (including USB dongle drivers) instead of the driver. Most FIR drivers require proper configuration of module parameters (this is documented below). FIR drivers allow you to use higher baud rates (generally up to 4Mbps). In general, Linux FIR support is not as stable and mature, due to lack of time and documentation. irattach must be run as root or installed setuid root, as it requires root privileges. If you have compiled the IrDA stack as modules (recommended), then you will need to edit the /etc/modules.conf file. See the &ir-howto; for details. OPTIONS : this is the name of a TTY, an IrDA interface or IrDA driver. irattach decides to use the driver or one of the FIR drivers based on this argument. TTY name : this is the serial port to be configured using the driver, such as . irattach will use the driver, so only SIR will be available. You need to check your serial configuration or BIOS to know which serial port is the IrDA port that need to be passed to irattach. interface name : this is the device name of an IrDA interface, such as . irattach will use one of the FIR drivers (including USB dongle drivers). The selected FIR driver must be loaded prior to the call to irattach, or the proper alias for the device name must be set in /etc/modules.conf. module name : this is the name of an FIR driver module, such as (see list below). All new IrDA interfaces created after loading the module will be configured, so this won't work if the module is already loaded. This feature is still experimental. : starts discovery of remote IrDA devices (note that the form "-s 1" is no longer supported) : shows version information (this happens, when no option is given, too) : shows help information. : attaches an additional dongle driver to the IrDA port. You need a dongle driver if you have an infrared device that connects to your computer's serial port (normal 9-pin serial port connector). These devices are called dongles, and can currently be used by any SIR driver (IrTTY or irport). This option is not compatible with FIR drivers, and only works with the irtty and irport drivers. The currently known (serial) dongles are: esi Extended Systems JetEye PC ESI-9680 tekram Tekram IrMate IR-210B dongle actisys ACTiSYS IR-220L dongle actisys+ ACTiSYS IR-220L+ dongle girbil Greenwich GIrBIL dongle litelink Parallax LiteLink dongle & Extended Systems JetEye PC ESI-9680B airport N.N. old_belkin Belkin (old) SmartBeam dongle or any dongle only capable of 9600 bauds ep7211 IR port driver for the Cirrus Logic EP7211 processor (ARM based) mcp2120 Dongles based on the MCP2120 (Microchip) act200l ACTiSYS Ir-200L dongles ma600 Mobile Action ma600 dongles toim3232 Vishay/Temic TOIM3232 and TOIM4232 based dongles FIR DRIVER MODULES If you are one of the lucky people which have a FIR chipset or USB dongle that is supported by one of the Linux-IrDA drivers, you can use irattach with the interface name of the IrDA port to configure. You will need to configure /etc/conf.modules appropriately, with at least an alias of to the driver name, or load the driver manually beforehand. You don't strictly need to use irattach with FIR drivers, you can use modprobe to load the driver, ifconfig to bring up the interface and set the various sysctl by hand, but irattach offer a convenient way to do it. Of course, you need to know which FIR driver applies to your hardware. You may use findchip to get information about the FIR chip. If this doesn't help, the &ir-howto; shows other means to retrieve these data. Also, you often need to configure the to ignore the IrDA port, otherwise both drivers will conflict. This can usually be done with setserial /dev/ttySx uart none. The currently known FIR drivers are: ali-ircc ALi FIR Controller Driver for ALi M5123 (options: io, irq, dma). This driver supports SIR, MIR and FIR (4Mbps) speeds. This chipset is used by e.g.: The ALi M5123 FIR Controller is embedded in ALi M1543C, M1535, M1535D, M1535+, M1535D South Bridge. irda-usb IrDA-USB device driver, for USB devices/dongles that comply with the official IrDA-USB class specification. Note: USB 2.0 is not yet tested. (options: qos_mtt_bits int, description "Minimum Turn Time"). This is used, for e.g.: ACTiSYS ACT-IR2000U KC Technology KC-180 Extended Systems XTNDAccess ESI-9685 Note that there is another USB driver for those devices called ir-usb which is NOT compatible with the IrDA stack and conflict with irda-usb. Because it always loads first, you have to remove ir-usb completely. Devices based on the SigmaTel chip are not not compliant with the IrDA-USB class specification and therfore not supported by this driver. nsc-ircc NSC IrDA device driver (options: io, irq, dma, dongle_id, qos_mtt_bits). This chipset is used by e.g.: IBM ThinkPad dongle_id=0x09 HP OmniBook 6000 dongle_id=0x08 sa1100_ir Infrared driver for devices based on the StrongARM SA1100 embedded microprocessor (options: power_level, tx_lpm). This driver may support FIR on devices that can do it. This chipset is used by e.g.: Samsung YOPY, COMPAQ iPAQ, SHARP Zaurus SL5000/5500 smc-ircc SMC IrCC controller driver (options: ircc_dma, ircc_irq). This chipset is used by e.g.: Fujitsu-Siemens Lifebook 635t Sony PCG-505TX w83977af_ir Winbond W83977AF IrDA device driver (options: io, irq, qos_mtt_bits). This chipset is used by e.g.: Corel NetWinder toshoboe Toshiba OBOE IrDA device driver, supports Toshiba Type-O IR chipset. (options: max_baud). This chipset is used by e.g.: Toshiba Libretto 100CT., and many more old Toshiba laptops. donauboe is a new version of toshoboe and has better FIR support and compability with the Donauoboe chip http://libxg.free.fr/lib-irda.html (options: ..). This chipset is used by e.g.: Toshiba Libretto 100CT., Tecra 8100, Portege 7020 and many more Toshiba laptops. vlsi_ir VLSI 82C147 SIR/MIR/FIR device driver This chipset is used by e.g.: HP Omnibook 800 (options: ..). clksrc int, description "clock input source selection" ringsize int array (min = 1, max = 2), description "tx, rx ring descriptor size" sirpulse int, description "sir pulse width tuning" mtt_bits int, description "IrLAP bitfield representing min-turn-time" EXAMPLES Attach the IrDA stack to the second serial port (integrated IrDA port using serial emulation) and start discovery: irattach /dev/ttyS1 -s Attach the IrDA stack to the first serial port where you have an external ACTiSYS serial dongle and start discovery: irattach /dev/ttyS0 -d actisys+ -s Attach the IrDA stack to the first IrDA-USB dongle and start discovery: modprobe irda-usb ; irattach irda0 -s Attach the IrDA stack to the NSC FIR (4Mbps) device driver on a Thinkpad laptop: modprobe nsc-ircc dongle_id=0x9 ; irattach irda0 -s. Attach the IrDA stack to the NSC FIR (4Mbps) device driver on a Thinkpad laptop: irattach irda0 -s. This assume that you have added the following entries to /etc/conf.modules: options nsc-ircc dongle_id=0x09 alias irda0 nsc-ircc CAVEATS The following hints are a very short introduction into the configuration of Linux/IrDA. If this doesn't help read the &ir-tutorial; and/or the &ir-howto; . Before configuring Linux/IrDA make sure whether you want to configure SIR or FIR. It's recommended to try SIR first, unless your device is not compatible with SIR (for example USB dongles). To get the SIR "serial" device have a look into the BIOS. Then run dmesg | grep tty to get a survey of tty devices supported by your machine. Now try to choose the one, which is probably the IrDA device and use irattach /dev/ttySx -s. If you don't succeed with SIR (which seems a rare case) you may try FIR. First look up the BIOS. Then run findchip to get information about the IrDA controller chip. Use setserial /dev/ttySx uart none to avoid conflicts with the serial driver. Note: don't use setserial if you configure SIR. Now you may use irattach. Finally irdadump should show at least your computer itself. If it doesn't start at the beginning. This man page deal only with the low level of the IrDA stack (IrDA ports and IrDA drivers). After this step is done, you usually need to setup your favorite application to access the high level IrDA stack (via IrCOMM, IrLPT, IrNET, IrLAN or IrSOCK), which is documented elsewhere. This man page doesn't document the usage of the irport driver. The irport driver support the same hardware as the irtty driver, but is configured like a FIR driver. DIAGNOSTICS This section currently contains the raw error messages from source code only. "ioctl(TIOCGETD): %m" "irattach: tty: set_disc(%d): %s" "tcsetattr: %m" "Failed to open %s: %m" "Couldn't get device fd flags: %m" "Couldn't set device to non-blocking mode: %m" BUGS N.N. irda-utils-0.9.18/man/man-irpsion5.sgml0000644000175000017500000000475110454641046017217 0ustar samuelsamuelLinux/IrDA Project"> Infrared-HOWTO"> Linux/IrDA-Tutorial"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. COPYRIGHT Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/irattach.8.gz0000644000175000017500000001163410454641046016317 0ustar samuelsamuel =Dirattach.8ZmsF>bJU6$EQlkPl3DH'T 0$' 3D~=3o.K0/OL󁜭t. ]K%WA.J2(, qK**󭌲pe#E+,L@^f2Qiѓv"bb\EV sݪ(JqOXf8Q8c ' r%sEk[9/Ҩuf#u6٣" /rPJW*]rza]ME/3{7 Fwl0p _gO?ݎ'Tϋ ŝwE{zy1{UɧX=ʿ\^Mwl4=d/2CQ ,sl#c9٢}{L5hf-KT*Eff<̌ Z,͏Z }VzRF?=tw{ܒ08 5"2Qܬ43o L HZedd 7Mz]|Ja9J&~p;[yUl0!EٚWH )gO"/KcpF+-鴽~"(W&Y^ ,+|GzVx}!cJsd 899׹Fb7Mi_e`H `c"S->K1Yp~2N+(srv:p} !c|1_1r[)`nT*(*c .lkmKaV, e(*` 9S\ȳ`X7|B.^KJd4A9}~_ *V;6Ys"yy& ikȆǐ`K(d#`Q܃`8־yfIp^I1VN,h|G9(UD&Nb@$cڼ֯OON|`Jκ}jc\^gKʫ H8T8c⟣OONnKg-7 7:Ģ+>jU?xhLo[K^M[Pro򷗧N^:*TƣIЃeZ+;y3x}pC}".Ԝ* b%9^`(yC^!~m _R3tp,"3;e@Mϡ   ؍ 5Q7"ۀb 9$Qo|@Qƒm':b0:,d)&8& $'-0sH#]XQ!sC*n)u>}6;H$mWdl G 9^#M} y6J+Kn T[ =] Fd%xrJT@VZXT'*Ha4F&,8,k0b}d]HRG^WYxl?+pOvN_0 Mx#,zuX*͞dd*_;݊d?Z 5fia2#/HN_oNN_CNs!:m~( zq"JNp#o,Y)-h{ Rs"pۺ6 ޲w.j=d" ozx<895Z1ʻzV#0n3AHƓO9L?:rap7g~'x(Ye+T)`^9+Y!*}697޾~, 9fc_E3v7p}{w="!7aK׀9sHV"T?@r1J ?I_&\JD2X8uz^ ;TFi;(g.2Wt:fS0 2(Nu_4tS@EƑ+m-FؠpS.S>HȟpB/D$GPtrN7TngpeRON]x[*ovB _H< 3]ݻPv\ڀrGau Y/;rɕQpc["KS? y/[uQ \poSkF ,+;p{X&i:SޢyG0bc$ԷYuY[vPхj^dخ0jt5]DvɌ~^62:jxD}H()Fq㙐2ON4q_NWUEZ7N }CMb0\ T:OgaH6Nf&He KKD#l/Ɓ">Wˣs}q6|NzDѨ܍*B|@Ә.ה^eoC2w8y RH.`:,a=8uwN0,XqSHZ;1:z7ؾ9p]c<|h5xg xF~ ̾f Qmz)+ڲlzu|{ UϰJ<'yٽlV,ʧZ1B Ӷ)^S&ks@d>>v|$MC7;GFnA!<Fտ'6otw5pc,tK0ҁ! #:;rK,TfHZGstg6|0fA8Cqѕ=!<pl+Zg Ğ{ $Cp(" fL:JѐH܇;и UDv5g8靸clbǺ:_)U٢89(C04'A1irda-utils-0.9.18/man/man-irdadump-inc.sgml0000644000175000017500000001255310454641046020022 0ustar samuelsamuel irdadump 8 irdadump monitors the IrDA traffic on one or more links. irdadump -b -c n -d -x -s n -t -l -v -i device OPTIONS dump bytes in columns set snapcols for byte printing with -b option prints the time difference between the current and the previous frame dump frame (bytes and ascii) set snaplen for -b and -x option force TTP decoding of unknown connections set line buffering on output file verbose interface DESCRIPTION irdadump is a tool for monitoring the IrDA traffic on one or more links. Just write "make" to compile the program. When you run the program, you should be able to see the IrDA traffic (if any). One advantage of implementing IrDA device drivers as network device drivers is that you should be able to attach sniffers to the device (or actually the packet type). That way, it is possible to use a really handy utility called irdadump (instead of tcpdump). This will make debugging MUCH easier. Linux-2.2 implements the BPF (Berkeley Packet Filter), so its possible to filter out exactly the frames you want to see. You may use hostname to separate different machines names. Or grep to filter the output, too. irdadump must be run as root or installed setuid root, as it requires root privileges. EXAMPLES The output should look something like this: / # ./irdadump 20:11:45.412199 xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:45.492137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:45.572137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:45.652208 xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:45.732137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:45.812137 xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:45.892175 xid:cmd 0x0015c23b > 0xffffffff S=6 s=255 Linux 20:11:45.902362 xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=5 ACTiSYS IR100M 20:11:48.412197 xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:48.492656 xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:48.572177 xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:48.652169 xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:48.732177 xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:48.812153 xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:48.822371 xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=4 ACTiSYS IR100M 15 packets received by filter Turning on the "-d" option will make irdadump print the time difference between the current and the previous frame: / # ./irdadump -d 20:11:18.412475 (0982.06 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:18.492345 (0079.87 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:18.572376 (0080.03 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:18.652979 (0080.60 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:18.732354 (0079.38 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 20:11:18.755093 (0022.74 ms) xid:rsp 0xf7be8388 < 0x0015c23b S=6 s=3 ACTiSYS IR100M 20:11:18.812350 (0057.26 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=5 20:11:18.892518 (0080.17 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=255 Linux 20:11:21.412486 (2519.97 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=0 20:11:21.492395 (0079.91 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=1 20:11:21.572368 (0079.97 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=2 20:11:21.652405 (0080.04 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=3 20:11:21.732458 (0080.05 ms) xid:cmd 0x0015c23b > 0xffffffff S=6 s=4 irdadump must be run as root or installed setuid root, as it requires root privileges. irdadump -d -x -s 256 will check the contents of the frames. This should tell us if the frames have malformed content, or if the irda stack is doing something wrong. DIAGNOSTICS N.N. BUGS N.N. irda-utils-0.9.18/man/man-irpsion5-inc.sgml0000644000175000017500000000357610454641046017772 0ustar samuelsamuel irpsion5 8 irpsion5 IrDA connectivity to a Psion V PDA irpsion5 -s file -r -b -v -q -S ms -D n OPTIONS send file to the Psion receive a file from the Psion receive multiple files (batch mode) verbose mode, progress indication quiet mode, no progress indication set discovery slot timeout, standard 80ms, default 120ms debug level DESCRIPTION N.N. irpsion5 must be run as root or installed setuid root, as it requires root privileges. EXAMPLES N.N. DIAGNOSTICS Error: unknown switch %s Call without args for usage: %s irda-utils-0.9.18/man/irdadump.8.gz0000644000175000017500000000376310454641046016331 0ustar samuelsamuelb=Dirdadump.8Xko_1p")bY-[N.nEӽ(hx#*E񥿽3$EH9pK( eYbV XeʴYl`36p&嫇2`و0W22q/Si*l-e!.q2s#%:?o'-rۡL[IʕnykﭯՆC +\T8J.9i_`2r\6͗b-KA.rPR-ږ=`|}q8j@#_ qI?eO*bQ҄TfBKbAfA*\8ɯm@&ߟ`bY/-| x3 !{?Z*>CC"!Ti GiҰш"`4h^0HIfniPd,JdZ`VBМ̵N8"Qr)H\,B"\X*H| M%XwfN*Iŏ')ZV k:Cmre9'ː(wP݄ ҟ3bȭR祆H/i,x19 yx`!PX ing;BJ g#eA:j]B.6|C Y*`̌,2 Dj9%S9CԈEKiykd|74 % Ӛ1rrQ8AP&XQ՛S] 4M(D \bch@E"(ec~acS:DÄ W<>_Z "+MNN.z V$ȩ3($s3GTF֛UO06u4m;lclFcY WUfInڝqƌmkHnWD-S+@Vl%! Lެǰ8 `W)c2Z"/G7uR(k)1E!iQcNV vkwXsZDav Ǽ_P={Gy{yNI^>b^.p/=~uD}kw=#Dz3TLO`0vq Taրdž50aրvdž50aoVvdX:ob~x5`*X\XReuL)ьew**K3C3v :xӅ8=QaTC No#@=ҫHXQۃ ~ uiAxmSoٽSw ۾C~ |7]s } B~'C H>}' Dn}q-;?AAtP?W?2 󻴝Da*Hp_յa]hlӱ qOlS`/5ЙѽZH:Z[!X$)7˛٢wOtpUGOS=u|nlrsa5.TUnXvҞ9> c.oRa{1a!h`T=@dAv!K=_"iImK2ʎG XSR"ya[$_۱N;ۊGpu*g"'V,WZF~8+`^z CE72,91˟m.d r}o.o <lkR#RfU]*J%^`7ZӢW((*=Z2>*VbVb` -Ӗⅻ1 {͕3q z!3r&'wȢa`Iv U¨Xy9KDWu[u"zA[z%3^92 l=ܤ~ 8[<:|'af*>2MVZ,Fp׉_(?j%k Qʵq!ɼljO,˪SYr/mxdyG}Ku/6E juPR/\K"<͙l6j}FI&ɿKsQaekFLcޟο,终}UʅA6VUgi9/(%8Ihn-3D0֠n6X෫_CJ's q{ O󳕳~kMTf}(S4-鲻H5[Iv'(F]sId}jie>$3C#S@R@hf^#wvk3D'GX"pA/v6^|WGMTa7dwO_'\3*K+iLinux/IrDA Project"> Linux/IrDA-Tutorial"> Infrared-HOWTO"> Infrared-Hardware-Survey"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html -*- &ir-hw; http://tuxmobil.org/ir_misc.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. COPYRIGHT Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/ChangeLog.man0000644000175000017500000000354610454641046016337 0ustar samuelsamuel0.10c 27.02.2006 Samuel Ortiz * Fixed "-v" option in man-irdadump-incl.sgml. Patch from agi (agi@debian.org) 0.10b 30.4.03 Jean II * Revert back to docbook-to-man ; docbook2man not available on Debian stable. * Add my wishes to TODO * Reword some parts of irattach to be more precise and accurate * Try to format better the irattach example section 0.10 29/04/2003 Werner Heuser * changed filenames: README, TODO, CHANGES to fit better into irda-utils Debian/GNU Linux package 0.9 29/04/2003 Werner Heuser * changed from docbook-to-man to docbook2man 0.8 16/03/2003 Werner Heuser * added irdadump options -b -c -t -v * added sa1100_ir driver options * added a caveats section to irattach o info about the devices (ircommN, irlptN) o dmesg | grep tty to get SIR device o use irdadump for debugging * changed download URL from mobilix.org to tuxmobil.org * minor changes 0.7 07/08/2002 Werner Heuser * added entry for -h option to irattach * reworked and tested all entries for irda-usb dongle in irattach to make them in sync with http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/IrDA.html 0.6 - 16.7.02 - Jean II o Integrate in irda-utils o Use generic rules in Makefile o Add install rules in Makefile o Updated irattach with latest dongles & other tweaks o Put back the original man pages, as docbook-to-man seems broken in my Debian 2.2. 0.5 11/08/2001 Werner Heuser * added vlsi_ir driver to irattach page * some new options for irdadump * some USB information was added * some more information about dongles was added * minor cosmetic changes 0.4 15/04/2001 Werner Heuser * added a new dongle_id to irattach * copyrighted under the GPL * minor cosmetic changes 0.3 13/04/2001 Werner Heuser * minor cosmetic changes 0.2 31/03/2001 Werner Heuser * man page formatted files included into distribution 0.1 26/03/2001 Werner Heuser * initial release irda-utils-0.9.18/man/irnet.4.gz0000644000175000017500000000374610454641046015642 0ustar samuelsamuelDirnet.4Xn8}^}EOq;X,֓Nokx;@q#ZSnvҍ<$6%ԩbf_'/)4)ӗ ~^$3,+]dBzE49[Ӌ MqUF8Tf-D0x7ƚqKXIzLe5d\>L?]?\-*72z|V%vB'| 'QdNސ2 SfF=6V/g6OfÏQJ΋i vu1leiJ?JLJI`Zf^풵[)5`:RlTź΅ n}bY`tF/`;iH9~m4j$$pSZ-F`É`9΂߇Ya6rJk Z0 T1DF 'mpN82umz9#VF4)sJ%\ kwH /ctLy'GUX62qo\q'm/[+(;\oo@דx6*wƊ]2RdՔжPYAI-Xܭ%J j1ܢt&6WQ`Bf* "Qv!ni29ofL9 l7e:b bMFD4;N}z8B~R'HAJO[[^ZdkM)_B~>fN䋨Cc%ubsN?9MPS=iqE//GN(S:1+V@̿6*7[9I˨Ak 8z!'%"o3+8s ,[[XFC%L÷HFCF2pF%de Be!o8k*N6(3muɐWȡuޕR\U)3HAB$N&X<:#"Y\ |_̗V}|3} 7UvC=s?FҒ¬%{ pF_uA1vN"bpC+$Mo<}\Ős__Xq6(}͒ %LXE odp~Ovvv;à{p_s\g~9W@Linux/IrDA Project"> Infrared-HOWTO"> Linux/IrDA-Tutorial"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. COPYRIGHT Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/irda.7.gz0000644000175000017500000000370210454641046015433 0ustar samuelsamuelDirda.7Xs6bGvGfQRp1Yͳl.w<0~(Γ"Vc{XW?`f'VzjE#T~2~3{QջiMzAO/[m]m;~>/뾝q x2Fa?vNKF~h]Xw{դ?! p-IgMrEVi.s-(?謰HBq}ǂ gB/ s5ɶ{T ΋N9)!0N#i΍tp&gE'/OQʬ[JJ䎽<hpq}SgئޯA~r<ц5J40uOj Y8.7`L6tg'cP4UمGɼ)u ]&VZo05 9WĤ!^417Ysj:$;ʶqT%/ W2 q80^K5@*ա8ԃd8HsQGCVw#N,LV,WVXo7l虑fg/ )0>u75 Ka~Gn0K^򆮼U;ώ*8xm{ "I IN mZIBq.ky3oYyA`YwmaA#EW8(/ i$NBkVR,sט_(7 -B 1,ʣ? _*rVިfL9&:gІ+(L]Pf'N8ꨦxF<Az'}`ac>>BϫೲU>)V+p<)T&uCxӼO߀%t:? D=}:)>/0Eb\] ʯ7\/+7 findchip 8 findchip checks the FIR chipset. findchip -d dongle -v -l <chip1 .. chipN> -h OPTIONS enables debug output be verbose lists supported chipsets prints help message DESCRIPTION findchip checks the FIR chipset. findchip must be run as root or installed setuid root, as it requires root privileges. EXAMPLES N.N. DIAGNOSTICS N.N. BUGS N.N. irda-utils-0.9.18/man/README.man0000644000175000017500000000220110454641046015430 0ustar samuelsamuelManual pages for Linux/IrDA, DocBook source files. (C) 2001-2003 Werner Heuser wehe@tuxmobil.org Published under the GPL, see file COPYING for details. 1) docbook2man These SGML sources use `docbook2man' to generate man pages. It's available at http://shell.ipoline.com/~elmert/comp/docbook2X/ Or as Debian/GNU-Linux package as well. 2) Document Structure Each man page consists of two parts: man-.sgml man--inc.sgml This structure may seem to complicated, but it is used to include the man pages into the Infrared-HOWTO http://tuxmobil.org/howtos.html as well. You may use `docbook-to-man man-[irda-template].sgml > [irda-template].8' to generate the according man page. See also Makefile. 3) How to Read the Man Pages Use `man -l FILE' to read the man pages in the current directory. Or gzip them and copy them to the appropriate man page directory. See also Makefile. 5) New Issues See http://tuxmobil.org/software/irda for new issues. 4) Criticism These man pages are not perfect. Please help to make them better. Your recommendations are welcome. Werner Heuser http://tuxmobil.org irda-utils-0.9.18/man/man-irdaping.sgml0000644000175000017500000000475110454641046017244 0ustar samuelsamuelLinux/IrDA Project"> Infrared-HOWTO"> Linux/IrDA-Tutorial"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. COPYRIGHT Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/man-irattach.sgml0000644000175000017500000000537110454641046017245 0ustar samuelsamuelLinux/IrDA Project"> Linux/IrDA-Tutorial"> Infrared-HOWTO"> Infrared-Hardware-Survey"> SGML"> ]>
wehe@tuxmobil.org
Werner Heuser 2001-03-26
&man-inc; SEE ALSO irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) &lip; http://irda.sourceforge.net -*- &ir-tutorial; http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- &ir-howto; http://tuxmobil.org/howtos.html -*- &ir-hw; http://tuxmobil.org/ir_misc.html AUTHOR This manual page is written by Werner Heuser wehe@tuxmobil.org. It is based on the READMEs from irda-utils by the &lip; and the &ir-tutorial;. It was subsequently updated and modified by Jean Tourrilhes jt@hpl.hp.com. COPYRIGHT Copyright (c) 2001 Werner Heuser Copyright (c) 2002 Jean Tourrilhes Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
irda-utils-0.9.18/man/findchip.8.gz0000644000175000017500000000174610454641046016307 0ustar samuelsamuelE=Dfindchip.8uUnF}W P8SRÈQnTEːܚe"Y/.%Չ]@8W=s6X\C.TC( Fy4{PJ y&[QRR.n[AH@NB)( 5}UmL>tMx'.岍Ee"z ?G A% vR}ܢC@5OM$EWT7IU]g0h/0xG_ࣥyL `>%E^6!5ta5擓/2 ؔ7ǢM?2  /}jw]n,x1O[.pQi֠l55ˠܢʤƓqkA]pr}ʪ]V8] нwТĽxVt|D;חTAIi@*B"5AB 8R!}\!`ny09xx;_$x"tp—L&0Kj4޽!"NFadzy:ͥ[,;qaXI UsVXϑ 4>+ ״ͱf۱kwCH#z)Ԩ}qD զm|X*UXŧاVfqrg~$UŎĪ-_-kuֳŪQ,;ō!#%t fh5j5~xzظ)-KvrC d:8G5|D2Lݷv $bx\BI:J HU'R7Z ܤcg)%irda-utils-0.9.18/man/man-irda-template-inc.sgml0000644000175000017500000000307710454641046020746 0ustar samuelsamuel findchip 8 findchip checks the FIR chipset. findchip -d dongle -v -l <chip1 .. chipN> -h OPTIONS enables debug output be verbose lists supported chipsets prints help message DESCRIPTION findchip checks the FIR chipset. findchip must be run as root or installed setuid root, as it requires root privileges. EXAMPLES N.N. DIAGNOSTICS N.N. BUGS N.N. irda-utils-0.9.18/man/man-irdaping-inc.sgml0000644000175000017500000000361510454641046020011 0ustar samuelsamuel irdaping 8 irdaping sends IrDA test frames irdaping daddr -s framesize OPTIONS ... ... DESCRIPTION This is a program similar to ping(8). It sends IrDA test frames (added some userdata which contains the frame number and the time the frame was sent). You can change the size of the frame by using the -s option. To get daddr you may use irdadump. irdaping must be run as root or installed setuid root, as it requires root privileges. EXAMPLES irdaping <daddr> [-s <framesize>] You may use an alias, which does not use any parameter alias irping="irdaping \`grep daddr /proc/net/irda/discovery|sed s/.*daddr://\`" It works fine when there is only one discovered client. DIAGNOSTICS N.N. BUGS N.N. irda-utils-0.9.18/output.mak0000644000175000017500000000111410454641046015257 0ustar samuelsamuelifeq ("$(V)", "1") EPRN = > /dev/null ECMD = MAKE_OUTPUT = else EPRN = ECMD = @ MAKE_OUTPUT = -s endif prn_cc = @echo " [CC] " $< $(EPRN) prn_cc_o = @echo " [CC] " $@ $(EPRN) prn_ar = @echo " [AR] " $@ $(EPRN) prn_ranlib = @echo " [RANLIB] " $@ $(EPRN) prn_clean = @echo " [CLEAN] " $(EPRN) prn_distclean = @echo " [DISTCLEAN] " $(EPRN) prn_etags = @echo " [ETAGS] " $@ $(EPRN) prn_install = @echo " [INSTALL] " $< $(EPRN) prn_depend = @echo " [DEPEND]" $(EPRN) prn_man = @echo " [DOCBOOK]" $< $(EPRN) prn_gzip = @echo " [GZIP]" $< $(EPRN) irda-utils-0.9.18/pcmcia/0000755000175000017500000000000010454641161014462 5ustar samuelsamuelirda-utils-0.9.18/pcmcia/ircard_cs.h0000644000175000017500000002071210454641046016570 0ustar samuelsamuel/********************************************************************* * * Filename: ircard_cs.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Fri Apr 2 15:59:20 1999 * Modified at: Wed Jun 30 01:00:45 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #ifndef IRCARD_CS_H #define IRCARD_CS_H #include /*#define PIO_THRESHOLD 4000000*/ #define PIO_THRESHOLD 1152000 /* * FIR Control Registers */ #define MCR 0x00 /* Master Control Register */ #define MCR_INTR_EN 0x80 /* FIR interrupt enable */ #define MCR_TX_EN 0x40 /* Transmit enable */ #define MCR_RX_EN 0x20 /* Receive enable */ #define MCR_BANK_MASK 0x1f /* Bank 0 */ #define MSR 0x01 /* Master Status Register */ #define MSR_TCV_I 0x80 /* Tranceiver interrupt */ #define MSR_TMR_I 0x40 /* Timer interrupt */ #define MSR_TX_I 0x20 /* Transmit interrupt */ #define MSR_RX_I 0x10 /* Receive interrupt */ #define MSR_I_MASK 0xf0 #define MSR_RX_COND_ID 0x08 /* Rx special condition */ #define MSR_RX_DATA_ID 0x0a /* Rx data available */ #define MSR_TX_EMPTY_ID 0x0c /* Tx buffer empty */ #define MSR_TX_COND_ID 0x0e /* Tx special condition */ #define MSR_ID_MASK 0x0e #define MISC 0x01 /* Miscellaneous Control Register */ #define MISC_XMIT 0x80 /* Use channel 2 for send */ #define MISC_RECV 0x40 /* Use channel 1 for receive */ #define RX_FIFO 0x02 #define TX_FIFO 0x02 #define TX_CTRL1 0x03 /* Transmit control register 1 */ #define TX_CTRL1_RTS 0x80 /* Transmit request to send (RTS) */ #define TX_CTRL1_FIFO_RDY_I 0x40 /* Transmit FIFO ready interrupt enable */ #define TX_CTRL1_UNDR_EOM_I 0x20 /* Transmit underrun/eom int. enable */ #define TX_CTRL1_FIFO_LVL 0x10 /* Transmit FIFO level */ #define TX_CTRL1_AUTO_RST_RTS 0x08 /* Auto reset RTS */ #define TX_CTRL1_AUTO_RST_EOM 0x04 /* Auto reset EOM */ #define TX_CTRL1_TX_IDLE 0x02 /* TX idle */ #define TX_CTRL1_UNDR_ABORT 0x01 /* Transmit underrun abort */ #define TX_CTRL2 0x04 /* Transmit control register 2 */ #define TX_CTRL2_EN_TX_CRC 0x40 /* Enable transmit CRC */ #define TX_CTRL2_EARLY_EOM_16 0x01 #define TX_CTRL2_EARLY_EOM_32 0x02 #define TX_CTRL2_EARLY_EOM_64 0x03 #define TX_CTRL2_EARLY_EOM_128 0x04 #define TX_CTRL2_EARLY_EOM_256 0x05 #define TX_CTRL2_EARLY_EOM_512 0x06 #define TX_CTRL2_EARLY_EOM_1K 0x07 #define TX_STAT 0x05 /* Transmit status register */ #define TX_STAT_FIFO_UNDR 0x08 /* Transmit FIFO underrun */ #define TX_STAT_EOM 0x04 /* Transmit end of message */ #define TX_STAT_FIFO_RDY 0x02 /* Transmit FIFO ready */ #define TX_STAT_EARLY_EOM 0x01 /* Transmit early end of message */ #define RX_CTRL 0x06 /* Receive control register */ #define RX_CTRL_COND_I 0x01 /* Rx special condition interrupt */ #define RX_CTRL_FIFO_READY 0x02 /* Rx FIFO ready */ #define RX_CTRL_EN_CRC 0x40 /* Enable checking of CRC */ #define RX_STAT 0x07 /* Receive status register */ #define RX_STAT_DATA_AVAIL 0x08 /* Receive data available */ #define RX_STAT_EOF 0x10 /* Receive end of frame */ #define RX_STAT_FIFO_OVRN 0x20 /* FIFO overrun interrupt enable */ #define RX_STAT_FRAME_ERROR 0x40 /* Rx Frame error */ #define RX_STAT_ABORT 0x80 /* Rx abort sequence detected */ #define RX_STAT_MASK 0xfc #define RESET 0x07 /* Reset command register */ #define RESET_ENTER_HUNT_MODE 0x10 #define RESET_RX_FIFO_PTR 0x20 #define RESET_RX_SPEC_BITS 0x30 #define RESET_RX_RFP 0x40 #define RESET_TX_SPEC_BITS 0x50 #define RESET_TX_FIFO_PTR 0x60 #define RESET_HARDWARE 0x70 /* Bank 1 */ #define FRAME_ADDR 0x01 /* Frame address register */ #define RX_BYTE_COUNT_LOW 0x02 /* Receive byte count low byte */ #define RX_BYTE_COUNT_HIGH 0x03 /* Receive byte count high byte */ #define RX_RING_FRM_PTR_LOW 0x04 /* Receive ring frame pointer low byte */ #define RX_RING_FRM_PTR_HIGH 0x05 /* Receive ring frame pointer high byte */ #define TX_BYTE_COUNT_LOW 0x06 /* Transmit byte count low byte */ #define TX_BYTE_COUNT_HIGH 0x07 /* Transmit byte count high byte */ /* Bank 2 */ #define IR_CONF 0x01 /* Infrared configuration register 1 */ #define IR_CONF_SIR 0x00 #define IR_CONF_MIR 0x02 #define IR_CONF_FIR 0x04 #define IR_CONF_MIR_1152 0x00 #define IR_CONF_MIR_576 0x10 #define IR_TRANS_CTRL 0x02 /* Infrared tranceiver control register */ #define IR_TRANS_CTRL_TXD_FRC 0x02 #define IR_TRANS_CTRL_XCVROFF 0x10 #define IR_CONF2 0x03 /* Infrared configuration register 2 */ #define IR_CONF2_IRQ_DEF 0x00 /* Default IRQ merging */ #define IR_CONF2_IRQ_UIRQ 0x01 /* Merge IRQs at UART pin */ #define TMR 0x04 /* General purpose timer register */ /* Bank 3 */ #define SH_MEM_PAGE 0x01 /* Shared memory page register */ #define TX_DMA_ADDR_LOW 0x02 /* Tx DMA start address (low byte) */ #define TX_DMA_ADDR_HIGH 0x03 /* Tx DMA start address (high byte) */ #define PAGE_DISABLE 0x40 /* Disable shared memory paging */ #define REVISION_ID 0x07 /* Revision ID */ /* Offset to transmit part of shared memory */ /* #define SHMEM_TX_START 0x1000 */ #define SHMEM_TX_START 0x4000 #define MAX_WINDOW 8 /* Just to make sure we are sane */ #define IRCARD_MAGIC 92612 struct frame_cb { int start; /* Start of frame in sh-mem */ int len; /* Lenght of frame in sh-mem */ }; struct shm_queue_t { struct frame_cb queue[MAX_WINDOW]; /* Info about frames in queue */ int ptr; /* Currently being sent */ int len; /* Lenght of queue */ int free; /* Next free slot */ int tail; /* Next free start in shmem */ }; struct ircard_cb { int magic; struct irda_device idev; dev_node_t node; int stop; struct shm_queue_t tx_q; /* Transmit queue info */ struct shm_queue_t rx_q; /* Receive queue info */ int data; /* Ptr to last frame received */ struct timeval stamp; struct timeval now; }; /* * Function ircard_set_mcr(iobase, itr, bank) * * Sets the value of the MCR register. Itr is the interrupt, transmit * and receive bits (7-5) of MCR. Bank is bank bits (4-0) of MCR. */ static inline void ircard_set_mcr(int iobase, __u8 itr, __u8 bank) { outb(itr|bank, iobase+MCR); } /* * Function __switch_bank (iobase, bank) * * Switches to requested bank, but does not preserve the previous contents * of MCR. Returns nothing. */ static inline void __switch_bank(int iobase, __u8 bank) { outb(bank, iobase+MCR); } /* * Function switch_bank (iobase, bank) * * Switches to requested bank. The original contents of the interrups, * transmit, and receive bits of MCR is preserved. Returns the the original * bank used before the call. */ static inline __u8 switch_bank(int iobase, __u8 bank) { __u8 old_bank; __u8 mcr; /* Read contents of MCR */ mcr = inb(iobase+MCR); /* Extract original bank */ old_bank = mcr & MCR_BANK_MASK; ircard_set_mcr(iobase, mcr & ~MCR_BANK_MASK, bank); return old_bank; } /* Makes the code more readable */ #define restore_bank switch_bank #endif irda-utils-0.9.18/pcmcia/config0000644000175000017500000006464110454641046015667 0ustar samuelsamuel# # config.sample 1.87 1999/02/16 01:33:35 (David Hinds) # # config.opts is now included at the very end # # Device driver definitions # device "3c589_cs" class "network" module "3c589_cs" device "ibmtr_cs" class "network" module "ibmtr_cs" device "nmclan_cs" class "network" module "nmclan_cs" device "oti12_cs" class "cdrom" module "oti12_cs" device "pcnet_cs" class "network" module "net/8390", "pcnet_cs" device "smc91c92_cs" class "network" module "smc91c92_cs" device "wavelan_cs" class "network" module "wavelan_cs" device "memory_cs" needs_mtd class "memory" module "memory_cs" device "ftl_cs" needs_mtd class "ftl" module "ftl_cs" device "serial_cs" class "serial" module "serial_cs" device "qlogic_cs" class "scsi" module "qlogic_cs" device "aha152x_cs" class "scsi" module "aha152x_cs" device "fdomain_cs" class "scsi" module "fdomain_cs" device "sym53c500_cs" class "scsi" module "sym53c500_cs" device "ide_cs" class "ide" module "ide_cs" device "fmvj18x_cs" class "network" module "fmvj18x_cs" device "netwave_cs" class "network" module "netwave_cs" device "xirc2ps_cs" class "network" module "xirc2ps_cs" device "iscc_cs" class "iscc" module "iscc_cs" device "3c574_cs" class "network" module "3c574_cs" device "teles_cs" class "teles" module "teles_cs" device "3c575_cb" class "network" module "cb_enabler", "3c575_cb" device "apa1480_cb" class "scsi" module "cb_enabler", "apa1480_cb" device "tulip_cb" class "network" module "cb_enabler", "tulip_cb" device "memory_cb" class "memory" module "cb_enabler", "memory_cb" device "epic_cb" class "network" module "cb_enabler", "epic_cb" device "serial_cb" class "serial" module "cb_enabler", "serial_cb" device "ircard_cs" class "irda" module "ircard_cs" # # Ethernet adapter definitions # card "3Com 3c589 Ethernet" version "3Com Corporation", "3C589" bind "3c589_cs" card "3Com 3c589D Ethernet" version "3Com Corporation", "3C589D" bind "3c589_cs" card "3Com 3CXE589E Ethernet" version "3Com", "Megahertz 589E" bind "3c589_cs" card "Accton EN2212 Ethernet" version "ACCTON", "EN2212" bind "pcnet_cs" card "Accton EN2216 Ethernet" version "ACCTON", "EN2216-PCMCIA-ETHERNET" bind "pcnet_cs" card "Accton UE2212 Ethernet" version "PCMCIA", "UE2212" bind "pcnet_cs" card "Accton UE2216 Ethernet" version "PCMCIA", "PCMCIA-ETHERNET-CARD", "UE2216" bind "pcnet_cs" card "Allied Telesis Ethernet" version "Allied Telesis,K.K", "Ethernet LAN Card" bind "pcnet_cs" card "AmbiCom AMB8002 Ethernet" version "AmbiCom Inc", "AMB8002", "Ethernet Combo" bind "pcnet_cs" card "AnyCom ECO Ethernet" version "AnyCom", "ECO Ethernet" bind "pcnet_cs" card "Argosy EN210 Ethernet" version "PCMCIA LAN", "Ethernet" bind "pcnet_cs" card "Asante FriendlyNet Ethernet" version "ASANTE", "FriendlyNet PC Card" bind "pcnet_cs" card "Billionton LNT-10TB" version "Billionton", "LNT-10TB" bind "pcnet_cs" card "California Access Ethernet" version "PCMCIAs", "ComboCard" bind "pcnet_cs" card "CeLAN Ethernet" version "PCMCIA", "ETHERNET V1.0" bind "pcnet_cs" card "CNet CN30BC Ethernet" version "CNet ", "CN30BC", "ETHERNET" bind "pcnet_cs" card "CNet CN40BC Ethernet" version "CNet", "CN40BC Ethernet" bind "pcnet_cs" card "Compaq Ethernet" version "Compaq", "Ethernet LAN Card" bind "xirc2ps_cs" card "Compaq Netelligent 10/100 Ethernet" version "Compaq", "Netelligent 10/100 PC Card" bind "xirc2ps_cs" card "COMPU-SHACK BASEline Ethernet" version "COMPU-SHACK", "BASEline PCMCIA 10 MBit Ethernetadapter" bind "pcnet_cs" card "Connectware LANdingGear Ethernet" manfid 0x0057, 0x1004 bind "pcnet_cs" card "CONTEC Ethernet" version "CONTEC Co.,Ltd." bind "fmvj18x_cs" card "Danpex EN-6200P2 Ethernet" version "*", "EN-6200P2" bind "pcnet_cs" card "DataTrek NetCard Ethernet" version "DataTrek.", "NetCard " bind "pcnet_cs" card "Dayna Commnunications CommuniCard E Ethernet" version "Dayna Communications, Inc.", "CommuniCard E" bind "pcnet_cs" card "Digital DEPCM-BA Ethernet" version "DIGITAL", "DEPCM-XX" bind "pcnet_cs" card "Digital PCP78-AC Ethernet" version "Digital", "Ethernet", "Adapter" bind "pcnet_cs" card "D-Link DE-650 Ethernet" version "D-Link", "DE-650" bind "pcnet_cs" card "D-Link DFE-650 Ethernet" version "D-Link", "DFE-650" bind "pcnet_cs" card "D-Link DE-660 Ethernet" version "D-Link", "DE-660" bind "pcnet_cs" card "D-Link DE-650 Ethernet" tuple 0x40, 0x0009, "D-Link PC Ethernet Card" bind "pcnet_cs" card "DynaLink L10C Ethernet" version "DYNALINK", "L10C" bind "pcnet_cs" card "E2000 NE2000-Compatible Ethernet" version "Ethernet Adapter", "E2000 PCMCIA Ethernet" bind "pcnet_cs" card "Edimax Ethernet Combo" version "Edimax Technology Inc.", "PCMCIA", "Ethernet Card" bind "pcnet_cs" card "Eiger Labs EPX-ET10T2 Ethernet" version "EIGER Labs Inc.", "Ethernet Combo card" bind "pcnet_cs" card "Eiger Labs EPX-ET10BT Ethernet" version "EIGER Labs Inc.", "Ethernet 10BaseT card" bind "pcnet_cs" card "Eiger Labs EPX-10BT Ethernet" version "Eiger Labs,Inc", "EPX-10BT PC Card Ethernet 10BT" bind "fmvj18x_cs" card "Eiger Labs EPX-ET 10BT Ethernet" version "Eiger labs,Inc.", "EPX-10BT PC Card Ethernet 10BT" bind "fmvj18x_cs" card "EZLink 4109 Ethernet" version "PCMCIA", "Ethernet Card" bind "pcnet_cs" card "EP-210 Ethernet" version "Ethernet PCMCIA adapter", "EP-210" bind "pcnet_cs" card "EP-210 Ethernet" version "EP-210 PCMCIA LAN CARD." bind "pcnet_cs" card "EP-220 Ethernet" version "PCMCIA", "ETHERNET" bind "pcnet_cs" card "Epson EEN10B Ethernet" version "Seiko Epson Corp.", "Ethernet" bind "pcnet_cs" card "Farallon ENet" version "Farallon", "ENet" bind "3c589_cs" card "Fujitsu FMV-J181 Ethernet" version "PCMCIA MBH10302" bind "fmvj18x_cs" card "Fujitsu FMV-J182 Ethernet" version "FUJITSU", "LAN Card(FMV-J182)" bind "fmvj18x_cs" card "Fujitsu Towa LA501 Ethernet" version "FUJITSU TOWA", "LA501" bind "fmvj18x_cs" card "Grey Cell GCS2000 Ethernet" version "Grey Cell", "GCS2000" bind "pcnet_cs" card "Grey Cell GCS2220 Ethernet" version "Grey Cell", "GCS2220" bind "pcnet_cs" card "GVC NIC-2000P Ethernet" version "GVC", "NIC-2000p" bind "pcnet_cs" card "GVC NIC-2000P Ethernet" version "PCMCIA", "Ethernet Combo card" bind "pcnet_cs" card "Hitachi HT-4840-11 Ethernet" version "HITACHI", "HT-4840-11" bind "fmvj18x_cs" card "IBM Credit Card Ethernet" version "IBM Corp.", "Ethernet" bind "pcnet_cs" card "IC-Card Ethernet" version "IC-CARD", "IC-CARD" bind "pcnet_cs" card "IC-Card Plus Ethernet" version "IC-CARD+", "IC-CARD+" bind "pcnet_cs" card "Intel EtherExpress PRO/100" version "Intel", "EtherExpress(TM) PRO/100 PC Card Mobile Adapter16" bind "xirc2ps_cs" card "Katron PE-520 Ethernet" version "KCI", "PE520 PCMCIA Ethernet Adapter" bind "pcnet_cs" card "KingMax Technology Ethernet" version "KingMax Technology Inc.", "EN10-T2", "PCMCIA Ethernet Card" bind "pcnet_cs" card "KingMax Technology Ethernet" version "KingMax Technology Inc.", "*", "Ethernet Card" bind "pcnet_cs" card "KingMax Technology Ethernet" version "KINGMAX", "EN10T2T" bind "pcnet_cs" card "Kingston KNE-PCM/x Ethernet" version "Kingston Technology Corp.", "EtheRx PC Card Ethernet Adapter" bind "pcnet_cs" card "Kingston KNE-PC2 Ethernet" version "Kingston", "KNE-PC2" bind "pcnet_cs" card "KTI PE-520 Plus Ethernet" version "KTI", "PE520 PLUS" bind "pcnet_cs" card "Linksys Ethernet" tuple 0x40, 0x0009, "E-CARD PC Ethernet Card" cis "cis/E-CARD.dat" bind "pcnet_cs" card "Linksys Ethernet" version "LINKSYS", "E-CARD" bind "pcnet_cs" card "Linksys Ethernet" version "E-CARD", "E-CARD" bind "pcnet_cs" card "Linksys Ethernet" version "Linksys", "Combo PCMCIA EthernetCard (EC2T)" bind "pcnet_cs" card "Longshine ShineNet LCS-8534 Ethernet" version "LONGSHINE", "PCMCIA Ethernet Card" bind "pcnet_cs" card "Longshine ShineNet LCS-8534 Ethernet" version "LONGSHINE", "*", "EP401" bind "pcnet_cs" card "Logitec LPM-LN10BA Ethernet" version "Cardwell", "PCMCIA", "ETHERNET" bind "pcnet_cs" card "Logitec LPM-LN20T Ethernet" version "Logitec", "LPM-LN20T" bind "pcnet_cs" card "MACNICA Ethernet" version "MACNICA", "ME1-JEIDA" bind "pcnet_cs" card "Megahertz CC10BT/2 Ethernet" version "Megahertz", "CC10BT/2" bind "smc91c92_cs" card "Maxtech PCN2000 Ethernet" version "MAXTECH", "PCN2000", "ETHERNET" bind "pcnet_cs" card "National Semiconductor InfoMover 4100 Ethernet" version "National Semiconductor", "InfoMover 4100" bind "pcnet_cs" card "National Semiconductor InfoMover NE4100 Ethernet" version "National Semiconductor", "InfoMover NE4100" bind "pcnet_cs" card "New Media Ethernet" version "New Media Corporation", "Ethernet" bind "nmclan_cs" card "New Media BASICS Ethernet" version "BASICS by New Media Corporation", "Ethernet", "SMC91C94" bind "smc91c92_cs" card "New Media LanSurfer" manfid 0x0057, 0x0021 bind "pcnet_cs" card "NextCom NC5310 Ethernet" version "NextComK.K.", "NC5310 Ver1.0 " bind "fmvj18x_cs" card "NE2000 Compatible Ethernet" version "PCMCIA", "Ethernet" bind "pcnet_cs" card "NE2000 Compatible Ethernet" version "PCMCIA", "Ethernet 10BaseT Card" bind "pcnet_cs" card "NE2000 Compatible Ethernet" version "NE2000 Compatible", "PCMCIA", "Ethernet Card" bind "pcnet_cs" card "NE2000 Compatible Ethernet" version "Ethernet", "Adapter" bind "pcnet_cs" card "NDC Instant-Link Ethernet" version "NDC", "Ethernet" bind "pcnet_cs" card "Eagle NE200 Ethernet" manfid 0x0004, 0x0004 bind "fmvj18x_cs" card "Novell Eagle 200T Ethernet" version "EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04" bind "fmvj18x_cs" card "Ositech Four of Diamonds Ethernet" version "Ositech", "Trumpcard:Four of Diamonds Ethernet" bind "smc91c92_cs" card "I-O DATA PCLA/T Ethernet" version "I-O DATA", "PCLA", "ETHERNET" bind "pcnet_cs" card "I-O DATA PCLA/TE Ethernet" version "IO DATA", "PCLATE", "ETHERNET" bind "pcnet_cs" card "Panasonic CF-VEL211 Ethernet" version "Matsushita Electric Industrial Co.,LTD.", "CF-VEL211" bind "pcnet_cs" card "PreMax PE-200 Ethernet" version "PMX ", "PE-200" bind "pcnet_cs" card "RATOC Ethernet" version "PCMCIA LAN MBH10304 ES" bind "fmvj18x_cs" card "Relia RE2408T Ethernet" version "PCMCIA LAN", "Ethernet" bind "pcnet_cs" card "Reliasys 2400A Ethernet" version "=RELIA==", "Ethernet" bind "pcnet_cs" card "RPTI EP400 Ethernet" version "RPTI LTD.", "EP400" bind "pcnet_cs" card "RPTI EP400 Ethernet" version "RPTI", "EP400 Ethernet NE2000 Compatible" bind "pcnet_cs" card "RPTI EP401 Ethernet" version "RPTI", "EP401 Ethernet NE2000 Compatible" bind "pcnet_cs" card "SCM Ethernet Combo" version "SCM", "Ethernet Combo card" bind "pcnet_cs" card "Sky Link Express" version "2408LAN", "Ethernet" bind "pcnet_cs" card "SMC EtherEZ Ethernet" version "SMC", "EtherEZ Ethernet 8020" bind "smc91c92_cs" card "SMC EZCard-10 Ethernet" version "SMC", "EZCard-10-PCMCIA" bind "pcnet_cs" card "Socket EA Ethernet" version "Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision D" bind "pcnet_cs" card "Socket EA Ethernet" version "Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision E" bind "pcnet_cs" card "Socket Low Power Ethernet" manfid 0x0104, 0x000d bind "pcnet_cs" card "SuperSocket Ethernet" version "Telecom Device K.K.", "SuperSocket RE450T" bind "pcnet_cs" card "Surecom Ethernet" version "TAMARACK", "Ethernet" bind "pcnet_cs" card "TDK LAC-CD02x Ethernet" version "TDK", "LAC-CD02x" bind "fmvj18x_cs" card "Xircom IIps Ethernet" version "Xircom", "*", "PS-CE2-10" bind "xirc2ps_cs" # # 10/100baseT network adapters # card "3Com 3c574TX Fast Ethernet" version "3Com", "3C574-TX Fast EtherLink PC Card" bind "3c574_cs" card "Abocom LinkMate FE1000 Fast Ethernet" version "Fast Ethernet", "Adapter" bind "pcnet_cs" card "AnyCom ECO 10/100 Fast Ethernet" version "AnyCom", "ECO Ethernet 10/100" bind "pcnet_cs" card "Apollo Fast Ethernet" manfid 0x0149, 0xc1ab bind "pcnet_cs" card "COMPU-SHACK FASTline 10/100 Fast Ethernet" version "COMPU-SHACK", "FASTline PCMCIA 10/100 Fast-Ethernet" bind "pcnet_cs" card "Linksys EtherFast 10/100 Fast Ethernet" version "Linksys", "EtherFast 10/100 PC Card (PCMPC100)" bind "pcnet_cs" card "Microcom C.E. Travel Card 10/100 Fast Ethernet" version "Microcom C.E.", "Travel Card LAN 10/100" bind "pcnet_cs" card "NetGear FA410TXC Fast Ethernet" version "NETGEAR", "FA410TX" bind "pcnet_cs" card "Toshiba Advanced Network Fast Ethernet" version "Toshiba Information Systems", "*", "TPCENET" bind "xirc2ps_cs" card "Xircom CE3-10/100 Fast Ethernet" version "Xircom", "*", "CE3-10/100" bind "xirc2ps_cs" # # Wireless network adapters # card "AT&T WaveLAN Adapter" version "AT&T", "WaveLAN/PCMCIA" bind "wavelan_cs" card "Digital RoamAbout/DS" version "Digital", "RoamAbout/DS" bind "wavelan_cs" card "Lucent Technologies WaveLAN Adapter" version "Lucent Technologies", "WaveLAN/PCMCIA" bind "wavelan_cs" card "NCR WaveLAN Adapter" version "NCR", "WaveLAN/PCMCIA" bind "wavelan_cs" card "Xircom CreditCard Netwave" version "Xircom", "CreditCard Netwave" bind "netwave_cs" card "IRDATA IrDA Adapter" version "IRDATA", "IRCARD" bind "ircard_cs" card "IBM Serial Infrared" version "", "SERIAL INFRARED" bind "ircard_cs" # # Modems and other serial devices # # NOTE: most modems do not need explicit entries here, because they # are correctly identified using the following generic entry. # card "Serial or Modem" function serial_port bind "serial_cs" card "Angia Fax/Modem" version "Intelligent", "ANGIA FAX/MODEM" bind "serial_cs" card "Cirrus Logic 14.4K Fax Modem" version "CIRRUS LOGIC", "FAX MODEM" bind "serial_cs" card "Compaq 28.8K Modem" version "COMPAQ", "PCMCIA 28800 FAX/DATA MODEM" bind "serial_cs" card "Compaq 33.6K Modem" version "COMPAQ", "PCMCIA 33600 FAX/DATA MODEM" bind "serial_cs" card "Dr. Neuhaus 14.4K FURY Card" version "Dr. Neuhaus", "FURY CARD 14K4" bind "serial_cs" card "E.TECH Bullet 33.6K Modem" version "PCMCIA ", "C336MX " bind "serial_cs" card "Gateway 2000 TelePath Fax Modem" version "GATEWAY2000", "CC3144", "*", "PCMCIA MODEM" bind "serial_cs" card "Intel-compatible Modem" version "Intel", "MODEM 2400+" bind "serial_cs" card "Macronix Fax/Modem" version "MACRONIX", "FAX/MODEM" bind "serial_cs" card "Megahertz PCMCIA Modem" version "MEGAHERTZ", "*", "*", "PCMCIA MODEM" bind "serial_cs" card "Megahertz V.34 Modem" version "MEGAHERTZ", "*", "V.34 PCMCIA MODEM" bind "serial_cs" card "MultiTech MultiModem" version "Multi-Tech", "MT1432LT" bind "serial_cs" card "MultiTech V.34 Modem" version "Multi-Tech", "MT2834LT" bind "serial_cs" card "Toshiba T144PF Modem" version "TOSHIBA", "T144PF", "*", "PCMCIA MODEM" bind "serial_cs" card "Computerboards PCM-COM422" version "Computerboards, Inc.", "PCM-COM422" bind "serial_cs" card "Fujitsu FMV-JMD711" version "FUJITSU", "FC14F ", "MBH10213" bind "serial_cs" card "Advantech COMpad-32/85" version "ADVANTECH", "COMpad-32/85" bind "serial_cs" card "Advantech COMpad-32/85" version "ADV", "*", "TECH", "COMpad-32/85" bind "serial_cs" card "IOTech Dual RS-232" version "IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card" bind "serial_cs" card "Omega Engineering QSP-100" manfid 0x0137, 0x0025 bind "serial_cs" card "Quatech Dual RS-232" version "Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card" bind "serial_cs" card "Quatech Quad RS-232" manfid 0x0137, 0x001b bind "serial_cs" card "Socket Communications Dual RS-232" manfid 0x0104, 0x0006 bind "serial_cs" # # Memory cards # card "Anonymous Memory" anonymous bind "memory_cs" card "Memory Card" function memory_card bind "memory_cs" card "IBM 2MB SRAM" version "IBM", "2MB SRAM" bind "memory_cs" card "IBM 4MB Series 1 Flash" version "IBM", "4MB FLASH" bind "memory_cs", "ftl_cs" card "IBM 8MB Series 2 Flash" version "IBM", "8MB FLASH" bind "memory_cs", "ftl_cs" card "Intel Series 2 2MB Flash" version "intel", "SERIES2-02 " bind "memory_cs", "ftl_cs" card "Intel Series 2 4MB Flash" version "intel", "SERIES2-04 " bind "memory_cs", "ftl_cs" card "Intel Series 2+ 8MB Flash" version "Intel", "S2E8 SW" bind "memory_cs", "ftl_cs" card "Intel Series 2+ 20MB Flash" version "Intel", "S2E20SW" bind "memory_cs", "ftl_cs" card "Intel Series 100 Flash" version "intel", "VALUE SERIES 100 " bind "memory_cs", "ftl_cs" card "I/O DATA 2MB SRAM" version "IO DATA", "PCS-2M", "2MB SRAM" bind "memory_cs" card "Maxtor MobileMax Flash" version "Maxtor", "MAXFL MobileMax Flash Memory Card" bind "memory_cs", "ftl_cs" card "Seiko/Epson WWB513EN20" version "SEIKO EPSON", "WWB513EN20" bind "memory_cs" card "Franklink/Rolodex REX-3000" version "Starfish, Inc.", "REX-3000" bind "memory_cs" card "Franklink/Rolodex REX-4100" version "Starfish, Inc.", "REX-4100" bind "memory_cs" # # Memory Technology Drivers # region "Generic or SRAM" default mtd "sram_mtd" region "Intel Series 2 Flash" jedec 0x89 0xa2 mtd "iflash2_mtd" region "Intel Series 100 Flash" jedec 0x89 0xaa mtd "iflash2_mtd" region "Intel Series 2+ Flash" jedec 0x89 0xa0 mtd "iflash2+_mtd" # # Token Ring adapters # card "3Com TokenLink Velocity Adapter" version "3Com", "TokenLink Velocity PC Card" bind "ibmtr_cs" card "IBM Token Ring Adapter" version "IBM", "TOKEN RING" bind "ibmtr_cs" # # SCSI host adapters # card "Adaptec APA-1460 SlimSCSI" version "Adaptec, Inc.", "APA-1460 SCSI Host Adapter" bind "aha152x_cs" card "Eiger Labs SCSI" version "EIger Labs", "PCMCIA-to-SCSI Adapter" bind "qlogic_cs" card "IBM SCSI" version "IBM Corp.", "SCSI PCMCIA Card" bind "fdomain_cs" card "IBM SCSI" version "SCSI PCMCIA Adapter Card" bind "fdomain_cs" #card "MACNICA mPS100 SCSI" # version "MACNICA", "MIRACLE SCSI", "mPS100" # bind "qlogic_cs" card "MACNICA mPS110 SCSI" version "MACNICA", "MIRACLE SCSI-II mPS110" bind "qlogic_cs" card "NEC PC-9801N-J03R SCSI" version "NEC", "PC-9801N-J03R" bind "qlogic_cs" card "New Media Bus Toaster SCSI" version "New Media", "SCSI", "Bus Toaster" bind "aha152x_cs" card "New Media Toast & Jam Sound/SCSI" version "New Media Corporation", "Multimedia Sound/SCSI" bind "aha152x_cs" card "Noteworthy Bus Toaster SCSI" version "NOTEWORTHY", "SCSI", "Bus Toaster" bind "aha152x_cs" card "New Media BASICS SCSI" version "BASICS by New Media Corporation", "SCSI Sym53C500" bind "sym53c500_cs" card "New Media Bus Toaster SCSI" version "New Media Corporation", "SCSI Bus Toaster Sym53C500" bind "sym53c500_cs" card "Qlogic FastSCSI" version "QLOGIC CORPORATION", "pc05" bind "qlogic_cs" card "Qlogic FastSCSI" version "QLOGIC CORPORATION", "pc05 rev 1.10" bind "qlogic_cs" card "Raven CD-Note SCSI" version "KME", "KXLC002", "00" bind "qlogic_cs" card "RATOC REX-9530 SCSI-2" version "RATOC System Inc.", "SCSI2 CARD 37" bind "qlogic_cs" card "SIMA TECH SCSI9000" version "*", "SCSI9000" bind "sym53c500_cs" card "Simple Technology SCSI" version " SIMPLE TECHNOLOGY Corporation", "SCSI PCMCIA Credit Card Controller" bind "fdomain_cs" card "Toshiba SCSC200B SCSI" version "TOSHIBA", "SCSC200B PC CARD SCSI-10" bind "qlogic_cs" # # Multifunction cards # card "3Com 3c562/3c563 Ethernet/Modem" manfid 0x0101, 0x0562 bind "3c589_cs" to 0, "serial_cs" to 1 card "3Com/Megahertz 3CXEM556 Ethernet/Modem" manfid 0x0101, 0x0035 cis "cis/3CXEM556.dat" bind "3c589_cs" to 0, "serial_cs" to 1 card "3Com/Megahertz 3CXEM556 B-INT Ethernet/Modem" manfid 0x0101, 0x003d cis "cis/3CXEM556.dat" bind "3c589_cs" to 0, "serial_cs" to 1 card "3Com/Megahertz 3CCFEM556 Ethernet/Modem" manfid 0x0101, 0x0556 cis "cis/3CCFEM556.dat" bind "3c574_cs" to 0, "serial_cs" to 1 card "Accton UE2218 LAN/Modem" version "PCMCIA", "UE2218-LAN/MODEM" cis "cis/PCMLM28.dat" bind "pcnet_cs", "serial_cs" card "Apex MultiCard Ethernet/Modem" version "APEX DATA", "MULTICARD", "ETHERNET-MODEM" bind "pcnet_cs" to 0, "serial_cs" to 1 card "Compaq Microcom CPQ550 Ethernet/Modem" manfid 0x0138, 0x110a bind "xirc2ps_cs", "serial_cs" card "Dayna Communicard Ethernet/Modem" version "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION" cis "cis/DP83903.dat" bind "pcnet_cs" to 0, "serial_cs" to 1 card "D-Link DME336T Ethernet/Modem" version "D-Link", "DME336T" bind "pcnet_cs", "serial_cs" card "D-Link DMF560TX Ethernet/Modem" manfid 0x0143, 0xc0ab bind "pcnet_cs", "serial_cs" card "Gateway Telepath Ethernet/Modem" version "Gateway 2000", "XJEM3336" bind "smc91c92_cs", "serial_cs" card "Grey Cell GCS3400 Ethernet/Modem" version "Grey Cell", "GCS3000" bind "pcnet_cs", "serial_cs" card "IBM Home and Away Ethernet/Modem" version "IBM", "Home and Away Credit Card Adapter" bind "pcnet_cs" to 0, "serial_cs" to 1 card "IBM Home and Away 28.8 Ethernet/Modem" version "IBM", "Home and Away 28.8 PC Card " bind "pcnet_cs" to 0, "serial_cs" to 1 card "IBM w95 Home and Away Ethernet/Modem" version "IBM", "w95 Home and Away Credit Card " bind "pcnet_cs" to 0, "serial_cs" to 1 card "Intel EtherExpress PRO/100 LAN/Modem" manfid 0x0089, 0x110a bind "xirc2ps_cs", "serial_cs" card "No-Name Ethernet/Modem" version "*", "FAX/Modem/Ethernet Combo Card " bind "pcnet_cs" to 0, "serial_cs" to 1 card "Linksys LANmodem 28.8" version "LINKSYS", "PCMLM28" cis "cis/PCMLM28.dat" bind "pcnet_cs", "serial_cs" card "Linksys LANmodem 33.6" version "LINKSYS", "PCMLM336" bind "pcnet_cs", "serial_cs" card "Megahertz CC/XJEM1144 Ethernet/Modem" version "MEGAHERTZ", "XJEM1144/CCEM1144", "PCMCIA MODEM" bind "smc91c92_cs", "serial_cs" card "Megahertz CC/XJEM1144 Ethernet/Modem" version "MEGAHERTZ", "XJEM1144/CCEM1144" bind "smc91c92_cs", "serial_cs" card "Megahertz EM1144T Ethernet/Modem" version "MEGAHERTZ", "EM1144T", "PCMCIA MODEM" bind "smc91c92_cs", "serial_cs" card "Megahertz CC/XJEM3288 Ethernet/Modem" version "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM" bind "smc91c92_cs", "serial_cs" card "Megahertz CC/XJEM3336 Ethernet/Modem" version "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM" bind "smc91c92_cs", "serial_cs" card "Motorola Marquis Ethernet/Modem" version "Motorola MARQUIS" bind "3c589_cs" to 0, "serial_cs" to 1 card "Motorola Mariner Ethernet/Modem" manfid 0x0109, 0x0501 bind "smc91c92_cs", "serial_cs" card "NSC DP83903-based Ethernet/Modem" version "*", "*", "*", "NSC MF LAN/Modem" cis "cis/DP83903.dat" bind "pcnet_cs" to 0, "serial_cs" to 1 card "Olicom GoCard 28.8 Ethernet/Modem" manfid 0x0121, 0x3122 bind "pcnet_cs", "serial_cs" card "Olicom GoCard 33.6 Ethernet/Modem" manfid 0x0121, 0x3222 bind "pcnet_cs", "serial_cs" card "Ositech Jack of Diamonds Ethernet/Modem" version "Ositech", "Trumpcard:Jack of Diamonds Modem+Ethernet" bind "smc91c92_cs", "serial_cs" card "Psion Gold Card V34 Ethernet" version "Psion Dacom", "Gold Card V34 Ethernet" cis "cis/PCMLM28.dat" bind "pcnet_cs", "serial_cs" card "Psion Gold Card Netglobal 56K+10Mb Ethernet" manfid 0x016c, 0x0020 bind "smc91c92_cs" to 0, "serial_cs" to 1 card "Rover ComboCard Ethernet/Modem" version "PCMCIAs", "ComboCard" bind "pcnet_cs", "serial_cs" card "TDK Global Networker Ethernet/Modem" version "TDK", "GlobalNetworker 3410/3412" bind "serial_cs" card "Xircom CE II Ethernet/Modem" version "Xircom", "CreditCard Ethernet+Modem II" bind "serial_cs" card "Xircom CEM28 Ethernet/Modem" version "Xircom", "*", "CEM28" bind "xirc2ps_cs", "serial_cs" card "Xircom CEM33 Ethernet/Modem" version "Xircom", "*", "CEM33" bind "xirc2ps_cs", "serial_cs" card "Xircom CEM56 Ethernet/Modem" version "Xircom", "*", "CEM56" bind "xirc2ps_cs", "serial_cs" card "Xircom RealPort REM10BT Ethernet/Modem" version "Xircom", "*", "REM10" bind "xirc2ps_cs", "serial_cs" # # ATA/IDE fixed disk devices # card "ATA/IDE Fixed Disk" function fixed_disk bind "ide_cs" card "ACE DoubleFlash 20MB" version "IBM", "IBM17JSSFP20" bind "ide_cs" card "Argosy EIDE CD-ROM" version "ARGOSY", "CD-ROM" bind "ide_cs" card "Caravelle CD-36N/CD-36E CD-ROM" version "Caravelle", "PSC-IDE ", "PSC000" bind "ide_cs" card "Creative Technology CD-ROM" version "Creative Technology Ltd.", "PCMCIA CD-ROM Interface Card" bind "ide_cs" card "Digital Mobile Media CD-ROM" version "Digital Equipment Corporation.", "Digital Mobile Media CD-ROM" bind "ide_cs" card "EXP CD940 CD-ROM" version "EXP ", "CD-ROM" bind "ide_cs" card "EXP Traveler 620 CD-ROM" version "EXP", "CD+GAME", "C1" bind "ide_cs" card "Freecom IQ-drive" version "FREECOM", "PCCARD-IDE" bind "ide_cs" card "IBM Max Portable CD-ROM" manfid 0x00a4, 0x002d bind "ide_cs" card "IO-DATA CDP-TX/PCIDE" version "IO DATA", "PCIDE" bind "ide_cs" card "IO-DATA PCIDE II" version "IO DATA", "PCIDEII" bind "ide_cs" card "IO-DATA CBIDE" version "WIT", "IDE16" bind "ide_cs" card "OTI-SCYLLA ATAPI CD-ROM" version "PCMCIA", "CD-ROM" bind "ide_cs" card "Ninja ATA" version " ", "NinjaATA-" bind "ide_cs" # # Non-ATA/IDE CD-ROM's # card "Innovative Communications CyberRom CD" version "Innovative Communications", "CyberRom CD" bind "oti12_cs" # # Miscellaneous card definitions # #card "Canon FDCard" # version "Canon Electronics INC.", "FDCard Ver. 1.00" # #card "New Media .WAVjammer" #version "New Media Corporation", ".WAVjammer" card "IBM Smart Capture Card" version "IBM Corp.", "Video Capture" bind "iscc_cs" card "TELES S0/PC ISDN" version "TELES", "S0/PC" bind "teles_cs" # # CardBus cards # card "3Com 3c575-TX Fast EtherLink XL" manfid 0x0101, 0x5057 bind "3c575_cb" card "3Com 3CCFE575B/3CXFE575B Fast EtherLink XL" manfid 0x0101, 0x5157 bind "3c575_cb" card "Adaptec APA-1480 SCSI Host Adapter" manfid 0x012f, 0xcb01 bind "apa1480_cb" card "D-Link DFE-660" manfid 0x50c7, 0xcafe bind "tulip_cb" card "Linksys EtherFast 10/100" manfid 0x0149, 0x0231 bind "tulip_cb" card "Linksys EtherFast 10/100" manfid 0x0149, 0xc2ab bind "tulip_cb" card "TDK NetworkFlyer LAK-CB100X" manfid 0x0105, 0x0500 bind "tulip_cb" card "Trumpcard: Seven of Spades Ethernet" manfid 0x0140, 0x0011 bind "epic_cb" card "Trumpcard: Jack of Spades Ethernet/Modem" manfid 0x0140, 0x000F bind "epic_cb" to 0, "serial_cb" to 1 # Include local configuration settings source ./config.opts irda-utils-0.9.18/pcmcia/ircard_cs.c0000644000175000017500000010663710454641046016576 0ustar samuelsamuel/********************************************************************* * * Filename: ircard_cs.c * Version: 0.8 * Description: IrDA FIR device driver for the IRDATA IRCARD which is * using the IBM 31T1502 controller chip * Status: Experimental. * Author: Dag Brattli * Created at: Fri Apr 2 00:01:11 1999 * Modified at: Fri Aug 27 12:30:00 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include /* Very important! */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ircard_cs.h" #if LINUX_VERSION_CODE < VERSION(2,3,14) #define net_device device #endif static char *version = "ircard_cs.c 0.1 Fri Apr 2 11:21:27 1999 (Dag Brattli)"; /* Parameters that can be set with 'insmod' */ /* The old way: bit map of interrupts to choose from */ /* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */ static u_int irq_mask = 0xdeb8; /* Newer, simpler way of listing specific interrupts */ static int irq_list[4] = { -1 }; /* The IBM 31T1100A tranceiver needs at least 120 us */ static int qos_mtt_bits = 0x0f; /* We have to set it to 500 us */ MODULE_PARM(irq_mask, "i"); MODULE_PARM(irq_list, "1-4i"); MODULE_PARM(qos_mtt_bits, "i"); static void ircard_config(dev_link_t *link); static void ircard_release(u_long arg); static int ircard_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *ircard_attach(void); static void ircard_detach(dev_link_t *); static int ircard_probe(struct irda_device *idev); static void ircard_change_speed(struct irda_device *idev, __u32 speed); static int ircard_hard_xmit(struct sk_buff *skb, struct net_device *dev); static void ircard_dma_write(struct irda_device *idev, int iobase); static int ircard_receive(struct irda_device *idev, int iobase); static void ircard_interrupt(int irq, void *dev_id, struct pt_regs *regs); static int ircard_is_receiving(struct irda_device *idev); static void ircard_wait_until_sent(struct irda_device *idev); static int ircard_net_close(struct net_device *dev); static int ircard_net_open(struct net_device *dev); static int ircard_net_init(struct net_device *dev); static dev_info_t dev_info = "ircard_cs"; static dev_link_t *dev_list = NULL; static void cs_error(client_handle_t handle, int func, int ret) { error_info_t err = { func, ret }; CardServices(ReportError, handle, &err); } /* * Function ircard_attach () * * creates an "instance" of the driver, allocating local data structures * for one device. The device is registered with Card Services. * */ static dev_link_t *ircard_attach(void) { client_reg_t client_reg; dev_link_t *link; struct ircard_cb *self; int ret, i; DEBUG(0, __FUNCTION__ "()\n"); /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); memset(link, 0, sizeof(struct dev_link_t)); link->release.function = &ircard_release; link->release.data = (u_long)link; /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE|IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID; if (irq_list[0] == -1) link->irq.IRQInfo2 = irq_mask; else for (i = 0; i < 4; i++) link->irq.IRQInfo2 |= 1 << irq_list[i]; link->irq.Handler = &ircard_interrupt; /* * General socket configuration defaults can go here. In this * client, we assume very little, and rely on the CIS for almost * everything. In most clients, many details (i.e., number, sizes, * and attributes of IO windows) are fixed by the nature of the * device, and can be hard-wired here. */ link->conf.Attributes = 0; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; /* Allocate space for private device-specific data */ self = kmalloc(sizeof(struct ircard_cb), GFP_KERNEL); memset(self, 0, sizeof(struct ircard_cb)); self->magic = IRCARD_MAGIC; link->priv = self; link->irq.Instance = &self->idev; /* Register with Card Services */ link->next = dev_list; dev_list = link; client_reg.dev_info = &dev_info; client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; client_reg.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; client_reg.event_handler = &ircard_event; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; ret = CardServices(RegisterClient, &link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); ircard_detach(link); return NULL; } return link; } /* * Function ircard_detach (link) * * This deletes a driver "instance". The device is de-registered with * Card Services. If it has been released, all local data structures are * freed. Otherwise, the structures will be freed when the device is * released. * */ static void ircard_detach(dev_link_t *link) { dev_link_t **linkp; struct ircard_cb *self; struct irda_device *idev; DEBUG(0, __FUNCTION__ "(0x%p)\n", link); self = (struct ircard_cb *) link->priv; idev = &self->idev; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; if (*linkp == NULL) return; /* * If the device is currently configured and active, we won't * actually delete it yet. Instead, it is marked so that when * the release() function is called, that will trigger a proper * detach(). */ if (link->state & DEV_CONFIG) { #ifdef PCMCIA_DEBUG printk(KERN_DEBUG "ircard_cs: detach postponed, '%s' " "still locked\n", link->dev->dev_name); #endif link->state |= DEV_STALE_LINK; return; } /* Break the link with Card Services */ if (link->handle) CardServices(DeregisterClient, link->handle); /* Unlink device structure, free pieces */ *linkp = link->next; if (self) { /* Close irport */ irport_stop(idev, idev->io.iobase2); irda_device_close(idev); kfree_s(self, sizeof(struct ircard_cb)); } kfree_s(link, sizeof(struct dev_link_t)); } #define CS_CHECK(fn, args...) \ while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed #define CFG_CHECK(fn, args...) \ if (CardServices(fn, args) != 0) goto next_entry /* * Function ircard_config (link) * * Configure the card and prepare for IO * */ static void ircard_config(dev_link_t *link) { struct irda_device *idev; struct ircard_cb *self; client_handle_t handle; tuple_t tuple; cisparse_t parse; int last_fn, last_ret; u_char buf[64]; win_req_t req; memreq_t map; handle = link->handle; self = (struct ircard_cb *) link->priv; ASSERT(self != NULL, return;); ASSERT(self->magic == IRCARD_MAGIC, return;); DEBUG(0, __FUNCTION__ "(0x%p)\n", link); /* * This reads the card's CONFIG tuple to find its configuration * registers. */ tuple.DesiredTuple = CISTPL_CONFIG; tuple.Attributes = 0; tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; CS_CHECK(GetFirstTuple, handle, &tuple); CS_CHECK(GetTupleData, handle, &tuple); CS_CHECK(ParseTuple, handle, &tuple, &parse); link->conf.ConfigBase = parse.config.base; link->conf.Present = parse.config.rmask[0]; DEBUG(0, __FUNCTION__ "() present=%x\n", link->conf.Present); /* Configure card */ link->state |= DEV_CONFIG; /* * In this loop, we scan the CIS for configuration table entries, * each of which describes a valid card configuration, including * voltage, IO window, memory window, and interrupt settings. * * We make no assumptions about the card to be configured: we use * just the information available in the CIS. In an ideal world, * this would work for any PCMCIA card, but it requires a complete * and accurate CIS. In practice, a driver usually "knows" most of * these things without consulting the CIS, and most client drivers * will only use the CIS to fill in implementation-defined details. * */ tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; CS_CHECK(GetFirstTuple, handle, &tuple); while (1) { cistpl_cftable_entry_t dflt = { 0 }; cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); CFG_CHECK(GetTupleData, handle, &tuple); CFG_CHECK(ParseTuple, handle, &tuple, &parse); if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; if (cfg->index == 0) goto next_entry; link->conf.ConfigIndex = cfg->index; /* Does this card need audio output? */ if (cfg->flags & CISTPL_CFTABLE_AUDIO) { link->conf.Attributes |= CONF_ENABLE_SPKR; link->conf.Status = CCSR_AUDIO_ENA; } /* * Use power settings for Vcc and Vpp if present * * Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1<conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; else if (dflt.vcc.present & (1<conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; if (cfg->vpp1.present & (1<conf.Vpp1 = link->conf.Vpp2 = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; else if (dflt.vpp1.present & (1<conf.Vpp1 = link->conf.Vpp2 = dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; /* Do we need to allocate an interrupt? */ if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) link->conf.Attributes |= CONF_ENABLE_IRQ; /* IO window settings */ link->io.NumPorts1 = link->io.NumPorts2 = 0; if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; if (!(io->flags & CISTPL_IO_16BIT)) link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.BasePort1 = io->win[0].base; link->io.NumPorts1 = io->win[0].len; if (io->nwin > 1) { link->io.Attributes2 = link->io.Attributes1; link->io.BasePort2 = io->win[1].base; link->io.NumPorts2 = io->win[1].len; } } /* This reserves IO space but doesn't actually enable it */ CFG_CHECK(RequestIO, link->handle, &link->io); /* * Now set up a common memory window, if needed. There is * room in the dev_link_t structure for one memory window * handle, but if the base addresses need to be saved, or * if multiple windows are needed, the info should go in * the private data structure for this device. * * Note that the memory window base is a physical address, * and needs to be mapped to virtual space with ioremap() * before it is used. */ if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM| WIN_ENABLE/*|WIN_USE_WAIT*/|WIN_MAP_BELOW_1MB; req.Base = 0; /*mem->win[0].host_addr;*/ req.Size = mem->win[0].len; req.Size = 0x8000; req.AccessSpeed = 0; link->win = (window_handle_t)link->handle; CFG_CHECK(RequestWindow, &link->win, &req); map.Page = 0; map.CardOffset = mem->win[0].card_addr; CFG_CHECK(MapMemPage, link->win, &map); } /* If we got this far, we're cool! */ break; next_entry: CS_CHECK(GetNextTuple, handle, &tuple); } /* * Allocate an interrupt line. Note that this does not assign a * handler to the interrupt, unless the 'Handler' member of the * irq structure is initialized. */ if (link->conf.Attributes & CONF_ENABLE_IRQ) CS_CHECK(RequestIRQ, link->handle, &link->irq); /* * This actually configures the PCMCIA socket -- setting up * the I/O windows and the interrupt mapping, and putting the * card and host interface into "Memory and IO" mode. */ CS_CHECK(RequestConfiguration, link->handle, &link->conf); /* * At this point, the dev_node_t structure(s) need to be * initialized and arranged in a linked list at link->dev. */ sprintf(self->node.dev_name, "ircard0"); self->node.major = self->node.minor = 0; link->dev = &self->node; /* Finally, report what we've done */ printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", self->node.dev_name, link->conf.ConfigIndex, link->conf.Vcc/10, link->conf.Vcc%10); if (link->conf.Vpp1) printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); if (link->conf.Attributes & CONF_ENABLE_IRQ) printk(", irq %d", link->irq.AssignedIRQ); if (link->io.NumPorts1) printk(", io 0x%04x-0x%04x", link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1-1); if (link->io.NumPorts2) printk(" & 0x%04x-0x%04x", link->io.BasePort2, link->io.BasePort2+link->io.NumPorts2-1); if (link->win) printk(", mem 0x%06lx-0x%06lx", req.Base, req.Base+req.Size-1); printk("\n"); /* Look up the irda device */ idev = &self->idev; /* Initialize IO */ idev->io.iobase = link->io.BasePort1+8; idev->io.iobase2 = link->io.BasePort1; /* Used by irport */ idev->io.irq = link->irq.AssignedIRQ; idev->io.io_ext = 8; idev->io.io_ext2 = 8; /* Used by irport */ idev->io.membase = (int) ioremap(req.Base, req.Size); idev->io.fifo_size = 16; idev->io.baudrate = 9600; DEBUG(0, __FUNCTION__ "(), membase=%08x\n", idev->io.membase); /* Reset Tx queue info */ self->tx_q.len = self->tx_q.ptr = self->tx_q.free = 0; self->tx_q.tail = SHMEM_TX_START + idev->io.membase; ircard_probe(idev); /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&idev->qos); /* The only value we must override it the baudrate */ idev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200|IR_576000|IR_1152000 |(IR_4000000 << 8); idev->qos.min_turn_time.bits = qos_mtt_bits; irda_qos_bits_to_value(&idev->qos); idev->flags = IFF_FIR|IFF_MIR|IFF_SIR|IFF_SHM|IFF_PIO; /* Specify which buffer allocation policy we need */ idev->rx_buff.flags = GFP_KERNEL; idev->tx_buff.flags = GFP_KERNEL; /* We still need the SIR buffer since we don't use shmem for that */ idev->rx_buff.truesize = 4000; idev->tx_buff.truesize = 4000; /* Initialize callbacks */ idev->change_speed = &ircard_change_speed; idev->wait_until_sent = &ircard_wait_until_sent; idev->is_receiving = &ircard_is_receiving; /* Override the network functions we need to use */ idev->netdev.init = &ircard_net_init; idev->netdev.hard_start_xmit = &irport_hard_xmit; /* used for SIR */ idev->netdev.open = &ircard_net_open; idev->netdev.stop = &ircard_net_close; /* Open the IrDA device */ irda_device_open(idev, (char *) dev_info, self); /*irda_device_open(idev, dev_name, self);*/ link->state &= ~DEV_CONFIG_PENDING; return; cs_failed: cs_error(link->handle, last_fn, last_ret); ircard_release((u_long)link); } /* * Function ircard_release (arg) * * After a card is removed, ircard_release() will unregister the net * device, and release the PCMCIA configuration. If the device is still * open, this will be postponed until it is closed. * */ static void ircard_release(u_long arg) { dev_link_t *link = (dev_link_t *) arg; struct ircard_cb *self; struct irda_device *idev; DEBUG(0, __FUNCTION__ "(0x%p)\n", link); self = (struct ircard_cb *) link->priv; idev = &self->idev; if (link->open) { DEBUG(1, "ircard_cs: release postponed, '%s' still open\n", self->node.dev_name); link->state |= DEV_STALE_CONFIG; return; } CardServices(ReleaseWindow, link->win); iounmap((void *)idev->io.membase); CardServices(ReleaseConfiguration, link->handle); CardServices(ReleaseIO, link->handle, &link->io); CardServices(ReleaseIRQ, link->handle, &link->irq); link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING); } /* * Function ircard_event (event, priority, args) * * The card status event handler. Mostly, this schedules other stuff to * run after an event is received. A CARD_REMOVAL event also sets some * flags to discourage the net drivers from trying to talk to the card * any more. * */ static int ircard_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; struct irda_device *idev; struct ircard_cb *self; DEBUG(1, __FUNCTION__ "(0x%06x)\n", event); self = (struct ircard_cb *) link->priv; idev = &self->idev; ASSERT(self != NULL, return -1;); ASSERT(self->magic == IRCARD_MAGIC, return -1;); switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; if (link->state & DEV_CONFIG) { self->stop = 1; link->release.expires = RUN_AT(HZ/20); add_timer(&link->release); } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ircard_config(link); break; case CS_EVENT_PM_SUSPEND: link->state |= DEV_SUSPEND; /* Fall through... */ case CS_EVENT_RESET_PHYSICAL: /* Mark the device as stopped, to block IO until later */ self->stop = 1; if (link->state & DEV_CONFIG) CardServices(ReleaseConfiguration, link->handle); break; case CS_EVENT_PM_RESUME: link->state &= ~DEV_SUSPEND; /* Fall through... */ case CS_EVENT_CARD_RESET: if (link->state & DEV_CONFIG) CardServices(RequestConfiguration, link->handle, &link->conf); self->stop = 0; /* * In a normal driver, additional code may go here to restore * the device state and restart IO. */ irport_start(idev, idev->io.iobase2); ircard_change_speed(idev, 9600); break; } return 0; } /* * Function ircard_probe (iobase, iobase2, irq, dma) * * * */ static int ircard_probe(struct irda_device *idev) { int revision; int iobase; iobase = idev->io.iobase; /* Read revision ID */ switch_bank(iobase, 3); revision = inb(iobase+REVISION_ID); /* (bank 3) */ printk("IBM 31T1502 controller revision %d\n", revision); /* Initialize shared memory page register */ outb(0, iobase+SH_MEM_PAGE); /* (bank 3) */ /* Enable Tx CRC just in case */ switch_bank(iobase, 0); outb(TX_CTRL2_EN_TX_CRC, iobase+TX_CTRL2); switch_bank(iobase, 3); outb(0, iobase+SH_MEM_PAGE); /* (bank 3) */ outb(0, iobase+TX_DMA_ADDR_LOW); /* (bank 3) */ outb(PAGE_DISABLE, iobase+TX_DMA_ADDR_HIGH); /* (bank 3) */ return 0; } /* * Function ircard_sir_to_fir (iobase) * * Some code to make the tranceiver switch from SIR to FIR mode * */ static void ircard_sir_to_fir(struct irda_device *idev, int iobase) { DEBUG(4, __FUNCTION__ "()\n"); __switch_bank(iobase, 2); /* Set XCRVOFF */ outb(IR_TRANS_CTRL_XCVROFF, iobase+IR_TRANS_CTRL); /* Wait a minimum of 2 us */ udelay(2); /* Set TXD_FORCE */ outb(IR_TRANS_CTRL_XCVROFF|IR_TRANS_CTRL_TXD_FRC, iobase+IR_TRANS_CTRL); /* Wait a minimum of 2 us */ udelay(2); /* Clear XCRVOFF */ outb(IR_TRANS_CTRL_TXD_FRC, iobase+IR_TRANS_CTRL); /* Wait a minimum of 2 us */ udelay(2); /* Clear TXD_FORCE */ outb(0, iobase+IR_TRANS_CTRL); } /* * Function ircard_fir_to_sir (iobase) * * Some code to make the tranceiver switch from FIR to SIR mode * */ static void ircard_fir_to_sir(struct irda_device *idev, int iobase) { DEBUG(4, __FUNCTION__ "()\n"); __switch_bank(iobase, 2); /* Set XCRVOFF */ outb(IR_TRANS_CTRL_XCVROFF, iobase+IR_TRANS_CTRL); /* Wait a minimum of 2 us */ udelay(2); /* Clear XCRVOFF */ outb(0, iobase+IR_TRANS_CTRL); } /* * Function ircard_change_speed (idev, baud) * * Change the speed of the device * */ static void ircard_change_speed(struct irda_device *idev, __u32 speed) { struct ircard_cb *self; unsigned long flags; int iobase; DEBUG(4, __FUNCTION__ "()\n"); ASSERT(idev != NULL, return;); ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return;); self = (struct ircard_cb *) idev->priv; iobase = idev->io.iobase; /* Serialize access to the driver */ spin_lock_irqsave(&idev->lock, flags); /* Check if we are switching from FIR to SIR, or SIR to FIR */ if ((idev->io.baudrate > 1152000) && (speed < 4000000)) ircard_fir_to_sir(idev, iobase); else if ((idev->io.baudrate < 4000000) && (speed > 1152000)) ircard_sir_to_fir(idev, iobase); /* Update accounting for new speed */ idev->io.baudrate = speed; if (speed > 115200) /* Install the FIR transmit handler */ idev->netdev.hard_start_xmit = &ircard_hard_xmit; else /* Install the SIR transmit handler */ idev->netdev.hard_start_xmit = &irport_hard_xmit; /* Reset hardware */ __switch_bank(iobase, 0); outb_p(0x07, iobase+7); /* Switch to bank2 and disable interrupts */ __switch_bank(iobase, 2); switch (speed) { default: DEBUG(4, __FUNCTION__ "(), unknown baud rate of %d\n", speed); /* FALLTHROUGH */ case 9600: /* FALLTHROUGH */ case 19200: /* FALLTHROUGH */ case 37600: /* FALLTHROUGH */ case 57600: /* FALLTHROUGH */ case 115200: irport_start(idev, idev->io.iobase2); irport_change_speed(idev, speed); outb_p(IR_CONF_SIR, iobase+IR_CONF); break; case 576000: DEBUG(0, __FUNCTION__ "(), handling baud of 576000\n"); irport_stop(idev, idev->io.iobase2); outb_p(IR_CONF_MIR_576|IR_CONF_MIR, iobase+IR_CONF); break; case 1152000: DEBUG(0, __FUNCTION__ "(), handling baud of 1152000\n"); irport_stop(idev, idev->io.iobase2); outb_p(IR_CONF_MIR_1152|IR_CONF_MIR, iobase+IR_CONF); break; case 4000000: DEBUG(4, __FUNCTION__ "(), handling baud of 4000000\n"); irport_stop(idev, idev->io.iobase2); outb_p(IR_CONF_FIR, iobase+IR_CONF); break; } idev->netdev.tbusy = 0; /* Enable some interrupts so we can receive frames */ if (speed > 115200) { /* Enable receiving, interrupts and go to bank 0*/ ircard_receive(idev, iobase); } spin_unlock_irqrestore(&idev->lock, flags); } /* * Function ircard_hard_xmit (skb, dev) * * Transmit the frame! * */ static int ircard_hard_xmit(struct sk_buff *skb, struct net_device *dev) { struct irda_device *idev; struct ircard_cb *self; unsigned long flags; int mtt, diff; idev = (struct irda_device *) dev->priv; self = idev->priv; /* Lock transmit buffer */ if (irda_lock((void *) &dev->tbusy) == FALSE) return -EBUSY; /* Serialize access to the driver */ spin_lock_irqsave(&idev->lock, flags); switch_bank(idev->io.iobase, 0); /* Register this frame */ self->tx_q.queue[self->tx_q.free].start = self->tx_q.tail; self->tx_q.queue[self->tx_q.free].len = skb->len; self->tx_q.tail += skb->len; /* Copy data to transmit part of shared memory */ copy_to_pc((void *) self->tx_q.queue[self->tx_q.free].start, skb->data, skb->len); self->tx_q.len++; self->tx_q.free++; /* Start transmit only if there is currently no transmit going on */ if (self->tx_q.len == 1) { /* Extract minimum turnaround time from skb */ mtt = irda_get_mtt(skb); /* Currently we just use udelay for the MTT delay */ if (mtt) { /* Check how much time we have used already */ do_gettimeofday(&self->now); diff = self->now.tv_usec - self->stamp.tv_usec; if (diff < 0) diff += 1000000; /* Check if the mtt is larger than the time we have * already used by all the protocol processing */ if (mtt > diff) { DEBUG(4, __FUNCTION__ "(), delay=%d us\n", mtt-diff); /* Currently we just use udelay for the MTT * delay */ udelay(mtt-diff); } } ircard_dma_write(idev, idev->io.iobase); } spin_unlock_irqrestore(&idev->lock, flags); dev_kfree_skb(skb); /* Not busy transmitting anymore */ dev->tbusy = 0; /* Return success */ return 0; } /* * Function ircard_dma_write (idev, iobase) * * Transmit data using shared memory (local DMA) * */ static void ircard_dma_write(struct irda_device *idev, int iobase) { struct ircard_cb *self; int addr; int ptr; self = idev->priv; ptr = self->tx_q.ptr; /* Disable Rx DMA */ switch_bank(iobase, 0); outb(0, iobase+MISC); /* (bank 0) */ idev->io.direction = IO_XMIT; ircard_set_mcr(iobase, MCR_INTR_EN|MCR_TX_EN, 0); /* Set early EOM level */ outb(TX_CTRL2_EN_TX_CRC|TX_CTRL2_EARLY_EOM_16, iobase+TX_CTRL2); /* Load the byte count to the transmit byte count register */ switch_bank(iobase, 1); outb(self->tx_q.queue[ptr].len & 0xff, iobase+TX_BYTE_COUNT_LOW); outb((self->tx_q.queue[ptr].len >> 8) & 0x1f, iobase+TX_BYTE_COUNT_HIGH); /* Set the Tx DMA start address (0 for the first transfer) */ switch_bank(iobase, 3); outb(0, iobase+SH_MEM_PAGE); /* (bank 3) */ /* Compute chip address */ addr = self->tx_q.queue[ptr].start - idev->io.membase; outb(addr & 0xff, iobase+TX_DMA_ADDR_LOW); /* (bank 3) */ outb(PAGE_DISABLE|((addr >> 8) & 0x3f), iobase+TX_DMA_ADDR_HIGH); /* Set host DMA controller for transmission */ switch_bank(iobase, 0); outb(0xc0, iobase+MISC); /* (bank 0) */ /*udelay(6);*/ /* Set RTS */ switch_bank(iobase, 0); outb(TX_CTRL1_RTS|TX_CTRL1_UNDR_EOM_I/*|TX_CTRL1_AUTO_RST_EOM*/, iobase+TX_CTRL1); /* (bank 0) */ } /* * Function ircard_xmit_complete (idev, underrun) * * Finished transmitting a frame * */ static inline void ircard_xmit_complete(struct irda_device *idev) { struct ircard_cb *self; int iobase; int stat; __u8 bank; int paranoid = 0; self = idev->priv; iobase = idev->io.iobase; bank = switch_bank(iobase, 0); /* Read Tx status register and check for transmission completion */ stat = inb(iobase+TX_STAT); /* (bank 0) */ if (stat & TX_STAT_FIFO_UNDR) { DEBUG(0, __FUNCTION__ "() FIFO underrun!\n"); idev->stats.tx_errors++; idev->stats.tx_fifo_errors++; } else { /* Spin until EOM */ while (!(stat & TX_STAT_EOM)) { if (paranoid++ > 1000) { DEBUG(0, __FUNCTION__ "(), breaking!\n"); break; } stat = inb(iobase+TX_STAT); } idev->stats.tx_packets++; idev->stats.tx_bytes += idev->tx_buff.len; } /* This will reset transmit enable */ ircard_set_mcr(iobase, MCR_INTR_EN, bank); /* Disable DMA */ outb(0, iobase+MISC); /* Reset Tx special condition bits */ outb(RESET_TX_SPEC_BITS, iobase+RESET); /* Unlock tx_buff and request another frame */ idev->netdev.tbusy = 0; /* Unlock */ idev->media_busy = FALSE; /* Finished with this frame, so prepare for next */ self->tx_q.ptr++; self->tx_q.len--; /* Any frames to be sent back-to-back? */ if (self->tx_q.len) { ircard_dma_write(idev, iobase); } else if (irda_device_txqueue_empty(idev)) { /* Reset EOM and RTS bits */ outb(0, iobase+TX_CTRL1); /* (bank 0) */ /* * No frames queued at card, and no frames in tx queue, so * now we can get ready for receiving */ ircard_receive(idev, iobase); } /* Tell the network layer, that we can accept more frames */ mark_bh(NET_BH); /* No need to restore original bank! */ } /* * Function ircard_receive (idev) * * Get ready for receiving a frame. The device will initiate a DMA * if it starts to receive a frame. * */ static int ircard_receive(struct irda_device *idev, int iobase) { struct ircard_cb *self; __u8 bank; self = idev->priv; bank = switch_bank(iobase, 0); /* Disable Rx, Tx */ ircard_set_mcr(iobase, MCR_INTR_EN, bank); /* Reset Tx queue info */ self->tx_q.len = self->tx_q.ptr = self->tx_q.free = 0; self->tx_q.tail = SHMEM_TX_START + idev->io.membase;; /* Reset Rx special condition bits */ outb(RESET_RX_SPEC_BITS, iobase+RESET); /* Reset Rx receive frame pointer */ outb(RESET_RX_RFP, iobase+RESET); /* Set receive and interrupt enable bits (but keep original bank) */ ircard_set_mcr(iobase, MCR_RX_EN|MCR_INTR_EN, bank); /* Enable Rx ready interrupt */ switch_bank(iobase, 0); /* Enable Rx interrupts */ outb(RX_CTRL_EN_CRC|RX_CTRL_COND_I, iobase+RX_CTRL); /* Make sure DMA is set properly */ outb(0xc0, iobase+MISC); idev->io.direction = IO_RECV; return 0; } /* * Function ircard_receive_complete (idev, iobase) * * * */ static int ircard_receive_complete(struct irda_device *idev, int iobase) { struct sk_buff *skb; struct ircard_cb *self; int len; int ptr; int stat; int start; self = idev->priv; /* Read receive ring frame pointer */ switch_bank(iobase, 1); ptr = inb(iobase+RX_RING_FRM_PTR_LOW); ptr |= ((inb(iobase+RX_RING_FRM_PTR_HIGH) & 0x3f) << 8); if (!ptr) return FALSE; stat = readb(idev->io.membase+ptr); len = (stat & 0x1f) << 8; len |= readb(idev->io.membase+ptr-1); if (stat & 0x80) { DEBUG(0, __FUNCTION__ "(), frame abort!\n"); /* switch_bank(iobase, 0); */ /* outb(RESET_RX_SPEC_BITS, iobase+RESET); */ /* outb(RESET_RX_FIFO_PTR, iobase+RESET); */ /* Skip frame */ idev->stats.rx_errors++; idev->stats.rx_frame_errors++; return FALSE; } if (stat & 0x40) { DEBUG(4, __FUNCTION__ "(), frame error!\n"); DEBUG(4, __FUNCTION__ "(), len=%d\n", len); /* Skip frame */ idev->stats.rx_errors++; idev->stats.rx_frame_errors++; return FALSE; } if (stat & 0x20) { DEBUG(4, __FUNCTION__ "(), overrun!\n"); DEBUG(4, __FUNCTION__ "(), len=%d\n", len); switch_bank(iobase, 0); outb(RESET_RX_SPEC_BITS, iobase+RESET); /* Skip frame */ idev->stats.rx_errors++; idev->stats.rx_fifo_errors++; return FALSE; } ASSERT(len>5, return FALSE;); /* Find start of frame */ start = idev->io.membase+ptr-len-1; if (start > self->data) { DEBUG(0, __FUNCTION__ "() Received Back-to-Back frames!!\n"); } /* Got a frame, so remember when */ do_gettimeofday(&self->stamp); /* Save pointer to start of next frame */ self->data = ptr+1; /* Remove CRC */ len -= 4; /* Limit frame to max data size + LAP header */ if (len > 2050) len = 2050; skb = dev_alloc_skb(len+1); if (skb == NULL) { printk(KERN_INFO __FUNCTION__ "(), memory squeeze, dropping frame.\n"); return FALSE; } /* Make sure IP header gets aligned */ skb_reserve(skb, 1); skb_put(skb, len); copy_from_pc(skb->data, (void *) start, len); idev->stats.rx_packets++; skb->dev = &idev->netdev; skb->mac.raw = skb->data; skb->protocol = htons(ETH_P_IRDA); netif_rx(skb); return TRUE; } /* * Function ircard_interrupt (irq, dev_id, regs) * * An interrupt from the chip has arrived. Time to do some work * */ static void ircard_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct irda_device *idev; __u8 msr, bank; int iobase; int bogus = 0; idev = (struct irda_device *) dev_id; if (idev == NULL) { WARNING("%s: irq %d for unknown device.\n", (char *) dev_info, irq); return; } if (idev->io.baudrate <= 115200) return irport_interrupt(irq, dev_id, regs); spin_lock(&idev->lock); idev->netdev.interrupt = 1; iobase = idev->io.iobase; /* Save bank, so the original bank is restored when we return */ bank = switch_bank(iobase, 0); /* Read interrupt status */ msr = inb(iobase+MSR) & MSR_ID_MASK; while (msr) { /* Check which interrupt this is */ switch (msr) { case MSR_TX_COND_ID: /* Tx special condition */ ircard_xmit_complete(idev); break; case MSR_RX_DATA_ID: /* Rx data available */ DEBUG(0, __FUNCTION__ "() should not get here!\n"); ircard_receive_complete(idev, iobase); break; case MSR_RX_COND_ID: /* Rx special condition */ ircard_receive_complete(idev, iobase); break; case MSR_TX_EMPTY_ID: /* Tx buffer empty */ DEBUG(0, __FUNCTION__ "() should not get here!\n"); break; default: DEBUG(0, __FUNCTION__ "(), unknown interrupt status=%#x\n", msr); break; }; if (bogus++ > 10) { WARNING(__FUNCTION__ "(), breaking!\n"); break; } msr = inb(iobase+MSR) & MSR_ID_MASK; } /* Restore bank */ restore_bank(iobase, bank); idev->netdev.interrupt = 0; spin_unlock(&idev->lock); } static int ircard_net_init(struct net_device *dev) { /* Setup to be a normal IrDA network device driver */ irda_device_setup(dev); /* Insert overrides below this line! */ return 0; } /* * Function ircard_net_open (dev) * * * */ static int ircard_net_open(struct net_device *dev) { struct irda_device *idev; int iobase; ASSERT(dev != NULL, return -1;); idev = (struct irda_device *) dev->priv; ASSERT(idev != NULL, return 0;); ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return 0;); iobase = idev->io.iobase; /* Ready to play! */ #if LINUX_VERSION_CODE < VERSION(2,2,11) dev->tbusy = 0; dev->interrupt = 0; dev->start = 1; #else irda_device_net_open(dev); #endif /* Start SIR driver */ irport_start(idev, idev->io.iobase2); MOD_INC_USE_COUNT; return 0; } /* * Function ircard_net_close (dev) * * * */ static int ircard_net_close(struct net_device *dev) { struct irda_device *idev; int iobase; #if LINUX_VERSION_CODE < VERSION(2,2,11) /* Stop device */ dev->tbusy = 1; dev->start = 0; #else irda_device_net_close(dev); #endif ASSERT(dev != NULL, return -1;); idev = (struct irda_device *) dev->priv; ASSERT(idev != NULL, return 0;); ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return 0;); iobase = idev->io.iobase; /* Stop SIR driver */ irport_stop(idev, idev->io.iobase2); MOD_DEC_USE_COUNT; return 0; } /* * Function uircc_wait_until_sent (idev) * * This function should put the currently thread to sleep until all data * have been sent, so it is safe to change the speed. */ static void ircard_wait_until_sent(struct irda_device *idev) { if (idev->io.baudrate > 115200) { /* Just delay 60 ms */ current->state = TASK_INTERRUPTIBLE; schedule_timeout(MSECS_TO_JIFFIES(60)); } else irport_wait_until_sent(idev); } /* * Function uircc_is_receiving (idev) * * Return TRUE is we are currently receiving a frame * */ static int ircard_is_receiving(struct irda_device *idev) { int status = FALSE; /* int iobase; */ ASSERT(idev != NULL, return FALSE;); ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return FALSE;); if (idev->io.baudrate > 115200) { /* Not impl yet */ } else status = (idev->rx_buff.state != OUTSIDE_FRAME); return status; } MODULE_AUTHOR("Dag Brattli "); MODULE_DESCRIPTION("IBM 31T1502 IrDA PCMCIA device driver"); /* * Function init_module () * * * */ int init_module(void) { servinfo_t serv; DEBUG(0, "%s\n", version); CardServices(GetCardServicesInfo, &serv); if (serv.Revision != CS_RELEASE_CODE) { printk(KERN_NOTICE "ircard_cs: Card Services release " "does not match!\n"); return -1; } register_pccard_driver(&dev_info, &ircard_attach, &ircard_detach); return 0; } /* * Function cleanup_module () * * * */ void cleanup_module(void) { DEBUG(0, "ircard_cs: unloading\n"); unregister_pccard_driver(&dev_info); while (dev_list != NULL) { if (dev_list->state & DEV_CONFIG) ircard_release((u_long)dev_list); ircard_detach(dev_list); } } irda-utils-0.9.18/psion/0000755000175000017500000000000010454641161014356 5ustar samuelsamuelirda-utils-0.9.18/psion/irpsion5.c0000644000175000017500000004014410454641046016277 0ustar samuelsamuel/********************************************************************* * * Filename: psion5.c * Version: 0.3 * Description: User space application for Psion 5 Palmtop Computers * Status: Experimental. * Author: Fons Botman * Created at: Mon Apr 19 21:51:29 CEST 1999 * * Copyright (c) 1999, Fons Botman, 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. * * Neither Fons Botman nor anyone else admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. * * Version history: * 0.3 Fons Botman, Fri Oct 1 22:11:11 CEST 1999 * Added some switches, workaround for discovery problem * 0.2 Fons Botman, Mon Sep 27 21:59:20 CEST 1999 * Fixed SDU size problem. * 0.1 Initial version. * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ /* Default slot_timeout */ static int slot_timeout = 120; static int debug_level = 0; #define DEBUG(n, str...) ( debug_level >= (n) ? printf(str) : 0 ) static int verbose = 1; #define MAX_DEVICES 10 int set_slot_timeout(int ms) { FILE* fp; char* varpath = "/proc/sys/net/irda/slot_timeout"; fp = fopen(varpath,"w"); if (fp == NULL) { perror(varpath); return 1; } else { DEBUG(1, "Setting slot_timeout to %d\n", slot_timeout); if (fprintf(fp,"%d\n", ms) <= 0) { perror(varpath); } if (fclose(fp) != 0) { perror(varpath); } } return 0; } int discover_devices(int fd) { struct irda_device_list *list; unsigned char *buf; socklen_t len; int i; /* Newer include files have an irda_device_info array of size one, so subtract 1 from MAX_DEVICES to be safe */ len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * (MAX_DEVICES-1); if (slot_timeout > 0) set_slot_timeout(slot_timeout); if (!(buf = malloc(len))) { fprintf(stderr, "Could not allocate discovery buffer.\n"); exit(1); } list = (struct irda_device_list *) buf; for ( i=0 ; i<5 ; i++ ) { if (0 == getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { DEBUG(1, "getsockopt IRLMP_ENUMDEVICES ok, len=%d\n", len); if (i == 0 && len == 4) { /* bug in 2.2.12 */ DEBUG(1, "Ignoring first empty reply\n"); sleep(1); continue; } break; } if (errno == EAGAIN) { /* retry after waiting a bit */ DEBUG(1, "Waiting for discovery to finish.\n"); sleep(1); } else { perror("getsockopt"); exit(-1); } } if (len < 4) { fprintf(stderr,"Unexpected len value: %d\n", len); exit(1); } if (list->len > 0) { DEBUG(1, "Discovered: (%d,%d)\n", len, list->len); for (i=0;ilen;i++) { DEBUG(1," daddr: %08x saddr: %08x " "hints: %02x%02x name: %s\n", list->dev[i].daddr, list->dev[i].saddr, list->dev[i].hints[0], list->dev[i].hints[1], list->dev[i].info); } } else { DEBUG(1, "No devices discovered.\n"); return 0; } /* Select obvious candidates */ for (i=0;ilen;i++) { if (0 == strncmp(list->dev[i].info,"Symbian EPOC",12)) { DEBUG(1, "Selecting first EPOC device.\n"); if (verbose) printf("Sending to %s\n", list->dev[i].info); return list->dev[i].daddr; } } for (i=0;ilen;i++) { if (0 == strncmp(list->dev[i].info,"Psion Series 5",14)) { DEBUG(1, "Selecting first Psion Series 5 device.\n"); if (verbose) printf("Sending to %s\n", list->dev[i].info); return list->dev[i].daddr; } } DEBUG(1, "Selecting first IRDA device.\n"); if (verbose) printf("Sending to %s\n", list->dev[0].info); return list->dev[0].daddr; } int irttp_get_mtu(int fd) { int mtu; socklen_t len = sizeof(int); /* Check what the IrTTP data size is */ if (getsockopt(fd, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, (void *)&mtu, &len)) { perror("getsockopt IRTTP_MAX_SDU_SIZE"); return -1; } DEBUG(1, "max_sdu_size = %d\n", mtu); return mtu; } int sendfile(char* filename) { int fd; struct sockaddr_irda peer; int daddr; FILE* f; int buflen; char *buf; int rc; struct stat s; int cnt; int t0, tx, t; unsigned long long int fdatell; fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); if (errno == EINVAL) fprintf(stderr, "Is IrDA active?, perhaps run irmanager\n"); exit(-1); } /* FIXME: We should use a better/any device selection mechanism */ daddr = discover_devices(fd); if (!daddr) { fprintf(stderr,"No IRDA device found\n"); exit(1); } peer.sir_family = AF_IRDA; peer.sir_addr = daddr; strcpy(peer.sir_name, "Epoc32:EikonIr:v1.0"); if (connect(fd, (struct sockaddr *) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); if (errno == ENETUNREACH) /* P5: System ^L IrDA is active, but IR-receive not selected */ fprintf(stderr, "No Psion5 or IR-receive is not selected\n"); /* Maybe we should retry in this case */ exit(-1); } DEBUG(1, "Connected to %x\n", daddr); buflen = irttp_get_mtu(fd); /* In case of linux compression, buflen may be 2044 */ if (buflen != 2045 && buflen != 2044) { fprintf(stderr, "Expecting mtu to be 2045, investigate!\n"); } DEBUG(1, "Setting mtu to 2044\n"); buflen = 2044; if (!(buf = malloc(buflen))) { perror("malloc"); exit(1); } /* FIXME : I got strange results when the buffer size was less than the mtu (e.g. 200), the psion did not seem to see the frames were not full length, and stopped after the number of frames based on the full mtu size. investigate. */ /* FIXME : psion connects to port 2, but does not get error back from us. Linux bug? */ if (!(f = fopen(filename,"rb"))) { perror(filename); exit(1); } rc = stat(filename,&s); if (rc != 0) { perror("stat"); exit(1); } /* FIXME map psion mode bits to unix filemodes */ fdatell = 62168263200000000ULL + 1000000 * ( s.st_mtime & 0x00000000FFFFFFFFULL); DEBUG(1, "date: %Ld\n", (unsigned long long) s.st_mtime); DEBUG(1, "date: %Ld\n", fdatell); sprintf(buf,"FILE %d %d %lu %lu %s", (int) s.st_size, 32 | (s.st_mode & S_IWUSR ? 0 : 1), (unsigned long) ((unsigned long long int) fdatell >> 32), (unsigned long) (fdatell & 0x00000000FFFFFFFFULL), filename); rc = write(fd,buf,strlen(buf)); if (rc != strlen(buf)) { perror("write"); fprintf(stderr,"rc = %d, strlen=%d\n", rc, strlen(buf)); exit(1); } DEBUG(1, "sent: %s\n", buf); rc = read(fd,buf,buflen-1); DEBUG(1, "Received (%d)\n", rc); if (rc < 0) { perror("reply error"); exit(1); } if (rc == 0) { fprintf(stderr, "EOF on reply?\n"); exit(1); } if (rc < buflen) { buf[rc] = 0; } /* should be "ACK Y" */ if (0 == strcmp(buf,"ACK N")) { fprintf(stderr, "Psion refused the file, disk full?\n"); exit(1); } if (0 != strcmp(buf,"ACK Y")) { fprintf(stderr, "Unexpected response: %s\n", buf); exit(1); } DEBUG(1, "ack received: %s\n", buf); cnt = 0; t0 = tx = t = time(NULL); while (!ferror(f) && !feof(f)) { int wrc; rc = fread(buf, 1, buflen, f); if (rc == 0) continue; wrc = write(fd,buf,rc); if (wrc < 0) { perror("write"); exit(1); } if (wrc < rc) { fprintf(stderr, "Problem: only sent %d of %d\n", wrc, rc); exit(1); } cnt += rc; if (verbose) { /* progress indication */ t = time(NULL); if (t - t0 == 0 || cnt == 0 || tx == t) /* avoid division errors */ /* only once per second */ continue; tx = t; printf("sent %d/%lu bytes=%4.1f%% in %d sec," " %g Kbytes/s, to go %li sec \r", cnt, s.st_size, 100.0 * cnt / s.st_size, t - t0, cnt / 1000.0 / (t - t0), ( s.st_size - cnt ) * (t - t0) / cnt); fflush(stdout); } } if (ferror(f)) { perror("ferror"); exit(1); } if (cnt != s.st_size) { printf("Warning: " "file size changed: initial: %lu, actual: %d\n", s.st_size, cnt); } /* Check for close on the other side */ rc = read(fd,buf,buflen); if (rc > 0) { fprintf(stderr, "Strange: the other side responded.\n"); fprintf(stderr, "rc=%d, data:%s\n", rc, buf); exit(1); } if (rc == 0) { fprintf(stderr, "Received end of file.\n"); } if (rc == -1) { if (errno == EPERM) { /* Strange error code to get in this case */ DEBUG(1, "Other side closed connection, OK\n"); } else { perror("last read"); exit(1); } } if (verbose) { t = time(NULL); if (t == t0) t++; /* white lie for fast transfers */ printf("\r%79s\r",""); /* Cleanup the progress line */ printf("Sent %s, %d bytes in %d sec. %g KBytes/sec\n", filename, cnt, t - t0, cnt / 1000.0 / (t - t0)); } close(fd); return 0; } int handle_client(int cfd) { int buflen; char* buf; int rc; /* fields of file transfer header */ unsigned int fsize; unsigned int fmode; unsigned int fdate1; unsigned int fdate2; char* fname; unsigned int fdate; unsigned long long int fdatell; FILE* f; int cnt; int t0, tx, t; buflen = irttp_get_mtu(cfd); DEBUG(1, "mtu=%d\n", buflen); if (buflen != 2045 && buflen != 2044) { fprintf(stderr, "Expecting mtu to be 2045, investigate!\n"); } DEBUG(1, "Setting mtu to 2044\n"); buflen = 2044; if (!(buf = malloc(buflen))) { perror("malloc"); exit(1); } if (!(buf = malloc(buflen))) { fprintf(stderr, "malloc buf failed\n"); exit(1); } /* Wait for the other side to send a header */ /* Sample headers received: DATA 185 FILE 55175 32 14689800 2691219200 Data size mode datehi datelo name */ /* This version only sends and receives files. It is possible to extend this to other data types the Psion can send and receive. */ rc = read(cfd, buf, buflen); if (rc < 0) { perror("1st read"); exit(1); } if (rc == 0) { perror("1st read 0"); exit(1); } assert(rc < buflen); buf[rc] = 0; DEBUG(1, "%s\n", buf); fsize = 0; fdate = 0; if (0 == strncmp(buf, "FILE ", 5)) { cnt = 0; /* to be safe */ rc = sscanf(buf, "FILE %u %u %u %u %n", &fsize, &fmode, &fdate1, &fdate2, &cnt); if (!(rc == 4 || rc == 5)) { /* grumble */ fprintf(stderr, "sscanf \"%s\" rc=%d\n", buf, rc); exit(1); } assert(cnt < buflen); fname = strdup(buf+cnt); fdatell = ((unsigned long long int) fdate1 << 32) + fdate2; fdate = ( fdatell - 62168263200000000ULL) / 1000000 ; DEBUG(1, "filename: %s\n", fname); DEBUG(1, "filesize: %d\n", fsize); DEBUG(1, "Filemode: %d", fmode); DEBUG(1, "%s", (fmode & 1 ? ", Readonly" : "")); DEBUG(1, "%s", (fmode & 2 ? ", Hidden" : "")); DEBUG(1, "%s", (fmode & 32 ? ", Modified" : "")); DEBUG(1, "%s", (fmode & ~35 ? ", Unknown" : "")); DEBUG(1, "\n"); DEBUG(1, "fdate1: %u = 0x%x\n", fdate1, fdate1); DEBUG(1, "fdate2: %u = 0x%x\n", fdate2, fdate2); DEBUG(1, "filedate: %Ld\n", fdatell); DEBUG(1, "filedate: %d = %s", fdate, asctime(gmtime((time_t*)&fdate))); if (!(f = fopen(fname,"wb"))) { perror(fname); exit(1); } } else if (0 == strncmp(buf, "DATA ", 5)) { rc = sscanf(buf, "DATA %d", &fsize); if (rc != 1) { fprintf(stderr, "sscanf rc=%d\n", rc); exit(1); } fname = strdup("/tmp/psion5-data"); if (!(f = fopen(fname,"wb"))) { perror(fname); exit(1); } } else { fprintf(stderr, "Unknown data type: %s\n", buf); exit(1); } rc = write(cfd,"ACK Y",5); if (rc != 5) { perror("1st write"); fprintf(stderr,"1st write rc = %d\n", rc); exit(1); } cnt = 0; t0 = tx = t = time(NULL); while (cnt < fsize) { int wrc; rc = read(cfd,buf,buflen); if (rc < 0) { perror("data read"); /* EPERM on disconnect ? */ exit(1); } if (rc == 0) { perror("data read 0"); exit(1); } wrc = fwrite(buf,rc,1,f); if (wrc != 1) { perror("fwrite"); exit(1); } cnt += rc; if (verbose) { /* progress indication */ t = time(NULL); if (t - t0 == 0 || cnt == 0 || tx == t) /* avoid division errors */ /* only once per second */ continue; tx = t; printf("got %d/%u bytes=%g%% in %d sec," " %g Kbytes/s, to go %i sec \r", cnt, fsize, 100.0 * cnt / fsize, t - t0, cnt / 1000.0 / (t - t0), ( fsize - cnt ) * (t - t0) / cnt); fflush(stdout); } } if (cnt != fsize) { printf("Warning: " "file size changed: initial: %u, actual: %d\n", fsize, cnt); } if (verbose) { if (t == t0) t++; /* white lie for fast transfers */ printf("\r%79s\r",""); /* Cleanup the progress line */ printf("Received %s, %d bytes in %d sec. %g KBytes/sec\n", fname, cnt, t - t0, cnt / 1000.0 / (t - t0)); } rc = fclose(f); if (rc != 0) { perror("fclose"); exit(1); } if (fdate) { struct utimbuf utb; utb.actime = fdate; utb.modtime = fdate; rc = utime(fname,&utb); if (rc != 0) { perror(fname); } } free(fname); close(cfd); return 0; } int receivefile(int mode) { /* The Psion 5 tries the following connections: Epoc32:EikonIr:v1.0 IrDA:TinyTP:LsapSel IrDA:IrCOMM Parameters IrLPT IrDA:IrLMP:LsapSel connect on 2 Warning: discovery reply after 101ms */ socklen_t addrlen = sizeof(struct sockaddr_irda); int fd; struct sockaddr_irda peer; int cfd; /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Bind local service */ peer.sir_family = AF_IRDA; strcpy(peer.sir_name, "Epoc32:EikonIr:v1.0"); peer.sir_lsap_sel = LSAP_ANY; if (bind(fd, (struct sockaddr*)&peer, sizeof(struct sockaddr_irda))) { perror("bind"); return -1; } if (listen(fd, 2)) { perror("listen"); return -1; } /* FIXME: allow more simultaneous clients */ for (;;) { cfd = accept(fd, (struct sockaddr *) &peer, &addrlen); if (cfd < 0) { perror("accept"); return -1; } if (handle_client(cfd)) break; if (mode == 1) break; } /* sleep(1); */ close(fd); return 0; } int main(int argc, char* argv[]) { char* argv0 = argv[0]; if (argc <= 1) { fprintf(stderr, "Usage: %s [-S ms] [-D n] [-v] [-q] " "[-s file] [-r] [-b]\n", argv0); fprintf(stderr, "\t-s file\tSend file to the Psion\n"); fprintf(stderr, "\t-r\tReceive a file from the Psion\n"); fprintf(stderr, "\t-b\tReceive multiple files (batch mode)\n"); fprintf(stderr, "\t-v\tVerbose mode, progress indication\n"); fprintf(stderr, "\t-q\tquiet mode, no progress indication\n"); fprintf(stderr, "\t-S ms\tSet discovery slot timeout,"); fprintf(stderr, " standard 80ms, default 120ms\n"); fprintf(stderr, "\t-D n\tDebug level\n"); exit(1); } /* skip program name */ argv++; argc--; for ( ; argc>0 && argv[0] ; argc-- , argv++) { if (0 == strcmp(argv[0],"-s")) { /* FIXME: sending multiple files does not work yet. We need to wait for the user to select receive again on the psion */ if (argv[1] && 0 == strcmp(argv[1],"--")) { /* Allow the user to send ANY filename */ argv++; argv++; for ( ; argv[1] ; argv++ , argc--) { sendfile(argv[1]); } } else { /* Send files upto next switch */ while (argv[1] && *argv[1] != '-') { sendfile(argv[1]); argv++; argc--; } } } else if (argv[0] && 0 == strcmp(argv[0],"-D")) { debug_level = atoi(argv[1]); argv++; argc--; } else if (argv[0] && 0 == strcmp(argv[0],"-S")) { slot_timeout = atoi(argv[1]); argv++; argc--; } else if (argv[0] && 0 == strcmp(argv[0],"-r")) { receivefile(1); } else if (argv[0] && 0 == strcmp(argv[0],"-b")) { receivefile(0); } else if (argv[0] && 0 == strcmp(argv[0],"-v")) { verbose = 1; } else if (argv[0] && 0 == strcmp(argv[0],"-q")) { verbose = 0; } else { fprintf(stderr,"Error: unknown switch %s\n", argv[0]); fprintf(stderr,"Call without args for usage: %s\n", argv0); exit(1); } } return 0; } irda-utils-0.9.18/psion/Makefile0000644000175000017500000000066410454641046016026 0ustar samuelsamuelinclude ../output.mak CC=gcc PSION_SRC= irpsion5.c PSION_OBJS= irpsion5.o PSION_TARGETS= irpsion5 all: $(PSION_TARGETS) clean: $(EMCD)rm -f *.o *~ core distclean: $(ECMD)rm -f irpsion5 *.o *~ core install: $(PSION_TARGETS) $(prn_install) $(ECMD)install $(PSION_TARGETS) $(ROOT)/usr/bin CFLAGS += -g -I../include -Wall -Wstrict-prototypes $(RPM_OPT_FLAGS) irpsion5: $(prn_cc_o) $(ECMD)$(CC) $(CFLAGS) $(PSION_SRC) -o $@irda-utils-0.9.18/smcinit/0000755000175000017500000000000010454641161014674 5ustar samuelsamuelirda-utils-0.9.18/smcinit/smcinit.c0000644000175000017500000003221310454641046016511 0ustar samuelsamuel/* * smcinit.c * * modified by Thomas Pinz * * IrDA configurator for laptops with SMSC 47N227 SuperIO, * smc-ircc and not initializing BIOS (tested on Toshiba Satellite 5100 * and Toshiba Tecra 9100). * Copyright (C) 2003, Rob Miller * * http://www.janerob.com/rob/ts5100/ * * * Cleanups, small fixes by Claudiu Costin * Expansions for several modes by Thomas Pinz * Generalization (entry point 2e OR 4e), code cleanup, HP nc6000 * by Jrme Fenal * * 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., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "smcinit.h" #define PROGNAME "smcinit" #define AUTHOR "Thomas Pinz" #define AUTHOR_EMAIL "" /* * default values */ #define MACHINE "Satellite 5200" #define SIR_IO 0x3f8 #define FIR_IO 0x130 #define FIR_IRQ 3 #define FIR_DMA 3 /* * lspci on 5100 says */ /* * 00:1f.0 ISA bridge: Intel Corp. 82801CAM ISA Bridge (LPC) (rev 02) */ #define BUS_LPC 0x00 #define LPC_DEV 0x1f #define LPC_FUNC 0x00 /* * (*) */ /* * Bitshifters */ #define SMC_SIR_IO ( (SIR_IO & 0xFF8) >> 2 ) /* CR25, p158: shift 2 down */ #define SMC_FIR_IO ( (FIR_IO & 0xFF8) >> 3 ) /* CR2B, p162: shift 3 down */ #define SMC_FIR_IRQ FIR_IRQ /* CR28, p160: equal */ #define SMC_FIR_DMA FIR_DMA /* CR2C, p162: equal */ /* * 82801 registers */ #define VID 0x00 #define DID 0x02 #define PIRQA_ROUT 0x60 #define PCI_DMA_C 0x90 #define COM_DEC 0xe0 #define LPC_EN 0xe6 #define GEN2_DEC 0xec /* * SMSC 47N227 registers */ // #define SMC_BASE 0x4e /* * 47N227 UART base offsets xxx enable fifo ? */ #define RCV (base) #define IER ((base)+1) #define IIR ((base)+2) #define FCR ((base)+2) #define LCR ((base)+3) #define MCR ((base)+4) #define LSR ((base)+5) #define MSR ((base)+6) #define SPR ((base)+7) #define DLSB (base) #define DMSB ((base)+1) struct option options[] = { {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, {"verbose", no_argument, NULL, 'v'}, {"sirio", required_argument, NULL, 's'}, {"firio", required_argument, NULL, 'f'}, {"firirq", required_argument, NULL, 'i'}, {"firdma", required_argument, NULL, 'd'}, {"tty", required_argument, NULL, 't'}, {NULL, 0, NULL, 0} }; static char *options_explications[] = { "\t\t\tshow program version", "\t\t\tshow this help", "\t\t\tbe verbose, show the compiled-in settings.", "\t\tset the SIR I/O port", "\t\tset the FIR I/O port", "\t\tset the FIR IRQ line", "\t\tset the FIR DMA channel", "\t\tspecify the serial tty to unbind from serial driver", NULL }; static char *short_options = "Vhvs:f:i:d:t:"; void print_usage(struct option *options_array, char **options_explications_array) { struct option *option; char *option_explication = NULL; int i; printf("%s %s %s\nUsage: %s [options]\nOptions:\n", PROGNAME, VERSION, AUTHOR, PROGNAME); i = 0; option = &options_array[0]; option_explication = options_explications_array[0]; while (option->name != NULL) { printf("-%c, --%s%s", option->val, option->name, (option->has_arg ? "=VALUE" : "")); if (options_explications_array[i] != NULL) printf("%s\n", options_explications_array[i]); else puts("\n"); i++; option = &options[i]; option_explication = options_explications_array[i]; } printf("Report suggestions and bugs to: %s\n", AUTHOR " " AUTHOR_EMAIL); } void print_version() { printf("%s %s\n", PROGNAME, VERSION); } void print_settings(int sir_io, int fir_io, int fir_irq, int fir_dma) { print_version(); printf("\n"); // printf("Default-Values for %s:\n", MACHINE); printf("SIR ioport: 0x%x\n", sir_io); printf("FIR ioport: 0x%x\n", fir_io); printf("FIR interupt: %d\n", fir_irq); printf("FIR DMA: %d\n", fir_dma); printf("\n"); } void die(const char *message) { fprintf(stderr, "%s: %s\n", PROGNAME, message); exit(1); } /* * Shamelessly taken from setserial.c by Ty T'so * * Unbind the specified device from kernel stock serial driver. */ int unbind_from_serial(char *device) { int fd; struct serial_struct old_serinfo, new_serinfo; if ((fd = open(device, O_RDWR|O_NONBLOCK)) < 0) { if (/*verbosity==0 && */errno==ENOENT) exit(201); perror(device); exit(201); } if (ioctl(fd, TIOCGSERIAL, &old_serinfo) < 0) { perror("Cannot get serial info"); exit(1); } new_serinfo = old_serinfo; new_serinfo.type = PORT_UNKNOWN; if (ioctl(fd, TIOCSSERIAL, &new_serinfo) < 0) { perror("Cannot set serial info"); exit(1); } close(fd); return 0; } #if 0 static struct pci_dev *find_pci_device(struct pci_access *access, struct pci_filter *filter) { struct pci_dev *dev; DEBUG("scanning PCI busses"); pci_scan_bus(access); DEBUG("looking for PCI device"); for (dev = access->devices; dev; dev = dev->next) { if (pci_filter_match(filter, dev)) { DEBUG("device found"); DEBUG_VAL("bus", dev->bus); DEBUG_VAL("dev", dev->dev); DEBUG_VAL("func", dev->func); return dev; } } return NULL; } #endif int set_smc(int * smc_base, int sir_io, int fir_io, int fir_irq, int fir_dma, int verbose) { /* * setpci.c */ struct pci_access *acc; struct pci_dev *dev; u16 twobyte; int i = 0, chip = 0; int local_sir_io, local_fir_io, local_fir_irq, local_fir_dma; unsigned int *address, SMC_BASE = 0; static unsigned int possible_cfgbase[] = { 0x2e, 0x4e, 0 }; local_sir_io = ((sir_io & 0xFF8) >> 2); /* CR25, p158: shift 2 down */ local_fir_io = ((fir_io & 0xFF8) >> 3); /* CR2B, p162: shift 3 down */ local_fir_irq = fir_irq; /* CR28, p160: equal */ local_fir_dma = fir_dma; /* CR2C, p162: equal */ if (getuid() != 0) { fprintf(stderr, "%s can only be used by root\n", PROGNAME); exit(1); } acc = pci_alloc(); pci_init(acc); dev = pci_get_dev(acc, 0, BUS_LPC, LPC_DEV, LPC_FUNC); /* 5100 also dev * 1f */ twobyte = pci_read_word(dev, VID); if (twobyte != 0x8086) { fprintf(stderr, "%s IO hub vendor %x not intel (0x8086)\n", PROGNAME, twobyte); return 1; } if (verbose) { printf("Detected IO hub vendor id: 0x%x\n", twobyte); } twobyte = pci_read_word(dev, DID); if ((twobyte != 0x24cc) & (twobyte != 0x248c)) { fprintf(stderr, "%s IO hub device %x not 82801CAM (0x248c or 0x24cc)\n", PROGNAME, twobyte); return 1; } if (verbose) { printf("Detected IO hub device id: 0x%x\n", twobyte); } pci_write_byte(dev, COM_DEC, 0x10); /* comb 2f8-2ff coma 3f8-3ff */ twobyte = pci_read_word(dev, LPC_EN); /* LPC_EN register */ twobyte &= 0xfffd; /* wipe bit 1 */ twobyte |= 0x0001; /* set bit 0 : COMA addr range enable */ pci_write_word(dev, LPC_EN, twobyte); twobyte = pci_read_word(dev, PCI_DMA_C); /* PCI_DMA register */ twobyte &= 0xfff3; /* wipe bits 2,3 */ twobyte = 0xc0c0; /* LPC I/F DMA on, channel 3 -- rtm (?? * PCI DMA ?) */ pci_write_word(dev, PCI_DMA_C, twobyte); pci_write_word(dev, GEN2_DEC, 0x131); /* LPC I/F 2nd decode * range */ pci_free_dev(dev); pci_cleanup(acc); /* * setsmc.c */ /* * test all possible SMC_BASE */ address = possible_cfgbase ; while ( (SMC_BASE = *address) != 0 ) { ioperm(SMC_BASE, 2, 1); outb(0x55, SMC_BASE); // enter configuration state outb(0x0d, SMC_BASE); // set for device id i = inb(SMC_BASE + 1); if ((i == 0x5a) || (i == 0x7a)) { chip = i; break; } address++; } if (chip != 0) { // if SMC 47N227 or other if (verbose) { printf("Detected smc_base: 0x%x \n \n", SMC_BASE); printf("Detected Chip id: 0x%x \n \n", i); } /* * ! sir-io ! */ outb(0x24, SMC_BASE); // select CR24 - UART1 base addr outb(0x00, SMC_BASE + 1); // disable UART1 outb(0x25, SMC_BASE); // select CR25 - UART2 base addr outb(local_sir_io, SMC_BASE + 1); // bits 2-9 of 0x3f8 i = inb(SMC_BASE + 1); if (verbose) { printf ("SIR ioport register \t write: 0x%x \t read: 0x%x \n", local_sir_io, i); } if (i != local_sir_io) { fprintf(stderr, "Sorry, SIR ioport could not be written. \n"); return 1; } /* * ! fir-irq ! */ outb(0x28, SMC_BASE); // select CR28 - UART1,2 IRQ select i = inb(SMC_BASE + 1); // get current setting for both outb((i & 0x00) | local_fir_irq, SMC_BASE + 1); // low order bits i = inb(SMC_BASE + 1); if (verbose) { printf ("FIR interrupt register\t write: 0x%d \t read: 0x%d \n", local_fir_irq, i); } if (i != local_fir_irq) { fprintf(stderr, "Sorry, FIR interrupt could not be written. \n"); return 1; } /* * ! fir-io ! */ outb(0x2B, SMC_BASE); // CR2B - SCE (FIR) base addr outb(local_fir_io, SMC_BASE + 1); // io i = inb(SMC_BASE + 1); if (verbose) { printf ("FIR ioport register\t write: 0x%x \t read: 0x%x \n", local_fir_io, i); } if (i != local_fir_io) { fprintf(stderr, "Sorry, FIR ioport could not be written. \n"); return 1; } /* * ! fir-dma ! */ outb(0x2C, SMC_BASE); // CR2C - SCE (FIR) DMA select outb(local_fir_dma, SMC_BASE + 1); // DMA i = inb(SMC_BASE + 1); if (verbose) { printf ("FIR dma register\t write: 0x%x \t read: 0x%x \n", local_fir_dma, i); } if (i != local_fir_dma) { fprintf(stderr, "Sorry, FIR dma could not be written. \n"); return 1; } outb(0x0C, SMC_BASE); // CR0C - UART mode i = inb(SMC_BASE + 1); // whatever already there outb((i & 0xC7) | 0x88, SMC_BASE + 1); // enable IrDA (HPSIR) // mode, high speed outb(0x07, SMC_BASE); // CR07 - Auto Pwr Mgt/boot drive sel i = inb(SMC_BASE + 1); // whatever already there outb(i | 0x20, SMC_BASE + 1); // enable UART2 autopower down outb(0x0a, SMC_BASE); // CR0a - ecp fifo / ir mux i = inb(SMC_BASE + 1); // whatever already there outb(i | 0x40, SMC_BASE + 1); // send active device to ir port outb(0x02, SMC_BASE); // CR02 - UART 1,2 power i = inb(SMC_BASE + 1); // whatever already there outb(0x80, SMC_BASE + 1); // UART2 power up mode, UART1 // power down outb(0x00, SMC_BASE); // CR00 - FDC Power/valid config cycle i = inb(SMC_BASE + 1); // whatever already there outb(i | 0x80, SMC_BASE + 1); // valid config cycle done outb(0xaa, SMC_BASE); // ?? twiggle config register ?? if (verbose) { printf("\n"); printf ("Initialization of the SMC 47Nxxx succeeded\n"); } } else { *smc_base = 0; fprintf(stderr, "%s id:%x not SMC 47Nxxx (should be 0x5a or 0x7a)\n", PROGNAME, i); return 1; } return 0; } int main(int argc, char **argv) { int opt, ret_val = 0; int verbose = 0; /* * set default values */ unsigned int sir_io = SIR_IO; unsigned int fir_io = FIR_IO; unsigned int fir_irq = FIR_IRQ; unsigned int fir_dma = FIR_DMA; const char *nptr; char *endptr; int smc_base; char tty_device[PATH_MAX]; tty_device[0]='\0'; tty_device[PATH_MAX-1]='\0'; while ((opt = getopt_long(argc, argv, short_options, options, NULL)) != -1) { switch (opt) { case 'V': print_version(); exit(0); break; case 'h': print_usage(options, options_explications); exit(0); break; case 'v': verbose = 1; break; case 't': nptr = optarg; strncpy(tty_device, nptr, PATH_MAX); /*if (! strncmp(tty_device, "/dev/tty", 8) ) { die("Specified device not a path to a device"); }*/ break; case 's': nptr = optarg; endptr = NULL; sir_io = strtoul(nptr, &endptr, 0); if (!nptr || !*nptr || !endptr || *endptr) { die("Cannot convert SIR I/O to number"); } break; case 'f': nptr = optarg; endptr = NULL; fir_io = strtoul(nptr, &endptr, 0); if (!nptr || !*nptr || !endptr || *endptr) { die("Cannot convert FIR I/O to number"); } break; case 'i': nptr = optarg; endptr = NULL; fir_irq = strtoul(nptr, &endptr, 0); if (!nptr || !*nptr || !endptr || *endptr) { die("Cannot convert FIR IRQ to number"); } break; case 'd': nptr = optarg; endptr = NULL; fir_dma = strtoul(nptr, &endptr, 0); if (!nptr || !*nptr || !endptr || *endptr) { die("Cannot convert FIR DMA to number"); } break; default: break; } // end switch } // end while if (verbose) { print_settings(sir_io, fir_io, fir_irq, fir_dma); } if (*tty_device) { ret_val = unbind_from_serial(tty_device); /* ret_val should always be 0 set_serial exits on error */ } ret_val += set_smc(&smc_base, sir_io, fir_io, fir_irq, fir_dma, verbose); return ret_val; } // end main irda-utils-0.9.18/smcinit/VERSION0000644000175000017500000000000710454641046015743 0ustar samuelsamuel0.5cvs irda-utils-0.9.18/smcinit/AUTHORS0000644000175000017500000000106110454641046015744 0ustar samuelsamuelThomas Pinz - many improvements for making the program to work with a lot Toshiba Satellite models Daniele Peri - tosh1800-smcinit.c (a.k.a toshsat1800-irdasetup.c) Rob Miller - tosh5100-smcinit.c Jos Manuel Mario Mario - tosh2450-smcinit.c Claudiu Costin - manual pages, various cleanups, RPM package and Linux distros integration Jrme Fenal - autoconf/automake, code cleanup, auto-discovery of entry point irda-utils-0.9.18/smcinit/ChangeLog0000644000175000017500000000377310454641046016462 0ustar samuelsamuel2006-02-27 samuel 0.5 release * Removed all distro specific stuff 2004-04-20 claudiuc 0.4-1 release 2004-04-20 claudiuc * add: added tosh2450-smcinit.c from Jos Manuel Mario Mario It make Toshiba Satellite 2450-101 to work on IrDA. Probably will be integrated in the general smcinit utility. 2004-04-13 claudiuc * doc: Written man page for Thomas new smcinit, but still I need to clean up old info. * update: Thomas added more tweaks so we have more supported laptops. * fixes: getopt() fixes be me prevent crash when parsing command line. * rename: renamed tosh-smcinit.c to smcinit.c because it can be used not only with Toshiba laptops, but at least with any LPC 47Nxxx SMSC-based chipset 2003-07-10 claudiuc * doc: added README.Tom from Thomas Pinz * improvement: added tosh-smcinit.c and tosh-superio.h from Thomas Pinz which will replace the tosh5100-smcinit.c 2003-07-10 claudiuc 0.3-1 release 2003-07-10 claudiuc * doc: written smcinit.8, improved the other 2 man pages, improved README and INSTALL. * compile: generate config.h because it's needed by *.c files (fixed in Makefile) 2003-07-08 claudiuc * doc: written INSTALL, updated AUTHORS, documentation from Rob Miller; fixed LSM file, written README, improved SuSE spec file * prog: added GPL notice in tosh5100-smcinit.c as Rob Miller pointed * redhat: RH 9.0 support (init script + spec file) 2003-07-02 claudiuc * build: SuSE spec improved to generated compatible SuSE RPM * compile: GNU'fied; now both utilities have --version and --help options; * doc: separated manual pages and some improvements 2003-07-01 claudiuc * cosmetic: renamed toshsat1800-irdasetup to tosh1800-smcinit * build: improved original Makefile, spec file for SuSE, my configure script for build system * compile: cleanup to remove warnings, broken compile; include headers for used libc functions * doc: first stage for my docs, manual page and renamed original docs to avoid confusion 2002-04-07 Daniele Peri * Added ports 0x178 and 0x130 irda-utils-0.9.18/smcinit/README.Tom0000644000175000017500000000772310454641046016325 0ustar samuelsamueltosh-smcinit ============ I've modified the tosh5100-smcinit.c to make it more flexible and renamed it to tosh-smcinit.c because it works with several notebooks of Toshiba. Please note that the names of the notebooks differ from country to country. I used the German names, you can see them at http://www.toshiba.de or http://newsletter.toshiba-tro.de/main (detailed hardware description) In many newer notebooks, Toshiba changed the SuperIO chip. They use no longer the LPC47N227, instead other chips are used like LPC47N24x. But we are working on modify the smc-ircc driver and smcinit so this chips will also work in the near future. If you own an other notebook than a Toshiba, your model is not in my list below and it use a newer chipset from Intel and the LPC47N2xx from SMSC, there are good chances to get IrDA working. If you have MS Windows installed, please send me your settings of the IrDA and I will include it. I need the IRQ, DMA and the 2 I/O port settings. Please also attach a copy of your /proc/interrupts, /proc/ioports and /proc/dma tosh-smcinit needs 4 parameters to initalize the SMC chip: SIR IOPort, FIR IOPort, FIR Interrupt and FIR DMA. I tested the following models, use the parameter in the list: Model SIR_IO FIR_IO FIR_IRQ FIR_DMA ID PCI-ID Satellite 3000 no Irda Satellite 5100 0x3f8 0x130 3 3 0x5a 248c * Satellite 5200 0x3f8 0x130 3 3 0x5a 248c * SatPro 2100 0x3f8 0x130 4 3 0x5a 248c SatPro 6100 0x3f8 0x130 3 1 0x5a 248c SatPro M10 0x2f8 0x130 3 1 0x5a 248c Satellite A10 no Irda Satellite P10 0x3f8 0x6f8 3 3 0x5a 248c Satellite P20 0x3f8 0x6f8 3 3 0x5a 248c Satellite A30 0x3f8 0x6f8 3 3 0x5a 248c Satellite M30 0x3f8 0x130 3 3 0x7a 24cc * Satellite A40 no Irda Portege A100 no Irda Portege M100 0x3f8 0x130 3 1 0x5a 24cc Portege M200 0x3f8 0x130 3 3 0x7a 24cc * Portege R100 no Irda Tecra 9100 0x3f8 0x130 3 1 0x5a 248c Tecra M1 0x3f8 0x130 3 1 0x5a 24cc Tecra M2 0x3f8 0x130 3 1 0x7a 24cc Tecra S1 unknown IRDA-Chip TE 2300 unknown IRDA-Chip (* = Compiled-In values, in this case, you don't need parameters) Other values for the parameters are sometimes also possible, if you got conflicts. OK, to make it running, you have to do the following steps: - Compile it. - Run tosh-smcinit *before* you insert the "smc-ircc" kernel module. For example you can do this in the /etc/modules.conf Without parameters, "tosh-smcinit" give no output, but if you run it as "tosh-smcinit -v", you will see if all should work. With --sirio=0x03f8, --firio=0x130, --firirq=3 and --firdma=3 you can set the parameters. More detailed instructions are in README.Rob, just replace tosh5100-smcinit with tosh-smcinit in his text. :) If you use a PCMCIA or miniPCI slot (also built-in WLAN), on some machines are conflicts at the I/O ports between IrDA and some cards. Sometimes it helps if you change I/O port range, which "pcmcia-cs" uses. The line include port 0x160-0x3f7, port 0x400-0x4ff, port 0x800-0x8ff, port 0xc00-0xcff in /etc/pcmcia/config.opts regulates it. Also IRQ-conflicts with other built-in components are possible. For example, my Atheros AR5212 miniPCI-Card got the IRQ 3 assigned from the ACPI BIOS. If you computer have a "classic" BIOS menu, look at the entry about the PCI-IRQ Routing. If the computer is "legacy-free", there are good chances to include the routing with the "acpi_irq_balance" and "acpi_irq_pci=n" kernel parameters. Thomas Pinz, Jan 2004, V0.3 E-Mail: tom_p@gmx.de irda-utils-0.9.18/smcinit/README.Peri0000644000175000017500000000573410454641046016465 0ustar samuelsamueltoshsat1800-irdasetup Version 0.2 2002/04/07 15:42 Description: IrDA configurator for laptops with ALI1533 bridge (LPC47N227 SuperIO), smc-ircc and not initializing BIOS (tested on Toshiba Satellite 1800-514) to be used with Linux kernel. Copyright (C) 2002, Daniele Peri http://lancelot.csai.unipa.it/~peri/toshsat1800-irdasetup.tgz Problem: Toshiba Satellite 1800 laptops are provided with a SMCS LPC47N227 SuperIO chip which is IrDA SIR/FIR capable. The chip is connected through an ALI1533 PCI-ISA bridge. The IrDA subsystem of the SuperIO chip is supported by the smc-ircc Linux kernel module. Unfortunately the BIOS neither configurates the SuperIO chip IrDA subsystem (SIR port, FIR port, dma, irq, IrDA mode, power) nor sets the PCI-ISA bridge to decode any usable port. Linux kernel is thus prevented to detect the second UART making impossible to use it in SIR mode. For the same reason, the FIR mode smc-ircc is able to detect the SuperIO chip but, once found the IrDA subsystem unconfigured, fails to install. Solution: toshsat1800-irdasetup sets SIR and FIR ioport addresses, DMA and IRQ of the SuperIO chip IrDA subsystem then powers on the second UART. It also configures the PCI-ISA bridge to decode SIR and FIR ports. All this configuration work should be rather done into the kernel but it was more practical and safe to make a small testing tool of it. It can be probably extended to include configuration kludges for other similar SuperIO and ISA bridge combination. Testing was carried on a Toshiba Satellite 1800-514 with Linux kernel 2.4.17. I hope this work could be helpful, it was quite funny to do it however. Compilation (Requires pci-utils): $ cd toshsat1800-irdasetup/ $ make Usage: Run it as root: $ ./toshsat1800-irdasetup then you can install the smc-ircc module: $ modprobe smc-ircc I've noticed that the smc-ircc needs parameters ircc_sir and ircc_fir to be specified. So you'd probably add: options smc-ircc ircc_dma=3 ircc_irq=7 ircc_cfg=0x2e ircc_sir=0x2e8 ircc_fir=0x2f8 to /etc/modules.conf You may also want to add a line like: pre-install smc-ircc /usr/local/sbin/toshsat1800-smcinit to /etc/modules.conf in order to obtain full automatic IrDA setup. You'll need to execute: $ depmod -a after modifying /etc/modules.conf to make changes effective. Default values works for Toshiba Satellite 1800 though any configuration value can be changed through options. So far I've discovered how to enable decoding of the following usable ports: 0x2e8, 0x2f8, 0x130, 0x178. The list of all options is obtaineable through: $ toshsat1800-irdasetup --help Appendix: Ericsson T39m. Setting up an Ircomm link with this phone requires to explicitly reduce the maximum speed to 115200: $ echo 115200 > /proc/sys/net/irda/max_baud_rate Disclaimer: This software is experimental. Use it at your own risk. Credits: * SMSC for the downloadable datasheets * Paul Hampson for its Linux IrDA mailing list messages. To do: * Add more ALI1533 usable ports irda-utils-0.9.18/smcinit/smcinit.h0000644000175000017500000000254310454641046016521 0ustar samuelsamuel/* * smcinit.h * * 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., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ /* * Debug Macros */ #undef DEBUG_ON #ifdef DEBUG_ON static int _debug = 0; #define DEBUG_LEVEL(level) _debug=level #define DEBUG(label) if(_debug){fprintf(stderr, "%s: %s\n", PROGNAME, label);} #define DEBUG_VAL(label, val) if(_debug){fprintf(stderr, "%s: %s: 0x%x\n", PROGNAME, label, val);} #define DEBUG_STRING(label, val) if(_debug){fprintf(stderr, "%s: %s: %s\n", PROGNAME, label, val);} #else #define DEBUG_LEVEL(level) #define DEBUG(label) #define DEBUG_VAL(label, val) #define DEBUG_STRING(label, val) #endif #define ERROR(label) fprintf(stderr, "%s: %s: %s\n", PROGNAME, label, strerror(errno)); #define VERSION "0.5cvs" irda-utils-0.9.18/smcinit/README0000644000175000017500000000370710454641046015565 0ustar samuelsamuel SMCINIT ======= Introduction ------------ This package is good for you if you own a Linux machine that have SMC-IRCC based IrDA subsystem and the BIOS doesn't initialize it. Otherwise you don't need it at all. If you reading here, then you may be the unhappy owner of Toshiba Satellite 1800, Toshiba Satellite 5100 or Toshiba Tecra 9100 laptop. Well, there's a chance that a bunch of other Toshiba laptops may share the same buggy BIOS and IrDA problems. Making it work -------------- Daniele Peri, Rob Miller and Paul Hampson mananged to build little utilities that initialize the LPC47N227 SuperIO allowing smc-ircc IrDA kernel driver to detect and use the SMSC chip. Note that for starting with Linux kernels from 2.6.x series this initializing will be integrated to the new smc-ircc kernel driver. Documentation ------------- Read the man pages. man smcminit (intro to smcinit utilities) man tosh1800-smcinit (built from Daniele Peri documentation and with my own additions) Read the very good documetation made by utilities authors. Note that man pages have been built from these docs. README.Tom - Thomas Pinz documentation on improvements made over 0.3-1 version README.Peri - Peri's README file README.Rob - Rob Miller irda.html page rendered as text file RobMiller-irda.html - The original Rob's irda.html page, renamed for posible name clashing reason CHANGELOG.Peri - Daniele Peri own changelog file ChangeLog - This package changelog INSTALL - Installation instruction for this package Contact ------- The SMCINIT package home page is: http://irda.sourceforge.net/smcinit/ See the AUTHORS file Please send the bugs and your wishes to the authors. The nice and important thing you can do is to send me (Claudiu Costin) your success story for a laptop or computer which is not listed here. Claudiu Costin April 13, 2004 irda-utils-0.9.18/smcinit/smcinit.lsm0000644000175000017500000000114010454641046017055 0ustar samuelsamuelBegin4 Title: smcinit Version: 0.5 Entered-date: Mon Feb 27 2006 Description: Initialize IrDA SMC chip for laptops based on SuperIO chipset Keywords: IrDA, infrared, Toshiba, laptop, Satellite, Tecra, SuperIO, nc6000 Author: Claudiu Costin Maintained-by: Claudiu Costin , Samuel Ortiz Primary-site: http://irda.sourceforge.net/smcinit/ Home-page: http://irda.sourceforge.net/smcinit/ Original-site: http://irda.sourceforge.net/smcinit/ Platforms: Linux only Copying-policy: GNU Public License End irda-utils-0.9.18/smcinit/TODO0000644000175000017500000000005710454641046015370 0ustar samuelsamuel- configure does not handle yet smcinit.lsm... irda-utils-0.9.18/smcinit/INSTALL0000644000175000017500000000274410454641046015736 0ustar samuelsamuel Installing smcinit ================== Prerequisites ------------- To successfully compile and install SMCINIT package you need to: * have a Linux 2.4.x based system. Prefferably Linux 2.4.18 kernel or better. * have GCC compiler and glibc devel package installed * have pciutils and pciutils-devel packages installed Compile & install ----------------- If you got the dist tarball, such as smcinit-0.5.tar.gz, untar it: tar xvfj smcinit-0.5.tar.gz cd smcinit-0.5 then: ./configure make make install (as root user) If you brave just checked out from the irda CVS, one more step is needed first: ./autogen.sh ./configure make make install (as root user) Notes ----- I tested the package on SuSE 8.1 and RedHat 9.0. It should work for any recent Linux distribution. Here are relevant packages to compile on SuSE 8.1: pciutils-devel-2.1.10-33 pciutils-2.1.10-33 libgcc-3.2-39 gcc-3.2-39 glibc-2.2.5-153 glibc-locale-2.2.5-154 glibc-devel-2.2.5-154 Here are relevant packages to compile on RedHat 9.0: pciutils-2.1.10-7 pciutils-devel-2.1.10-7 gcc-3.2.2-5 libgcc-3.2.2-5 gcc-c++-3.2.2-5 glibc-devel-2.3.2-11.9 glibc-common-2.3.2-11.9 glibc-2.3.2-11.9 glibc-kernheaders-2.4-8.10 Send me your story and packages when you compile these package on a system other than above ones. Thank you very much! Claudiu Costin July 10, 2003 irda-utils-0.9.18/smcinit/COPYING0000644000175000017500000004312710454641046015740 0ustar samuelsamuel GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. irda-utils-0.9.18/smcinit/Makefile0000644000175000017500000000205710454641046016342 0ustar samuelsamuelinclude ../output.mak CC = gcc RM = rm -f RM_CMD = $(ECMD)$(RM) *.BAK *.bak *.o ,* *~ *.a INCLUDES = $(SYS_INCLUDES) -I../include/ LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) # # System stuff # SYS_INCLUDES = -I/usr/include SYS_LIBRARIES = SYS_LIBPATH = -L/usr/lib -L/usr/local/lib CFLAGS= -O2 -W -Wall -I. SMCINIT_OBJS = smcinit.o tosh1800-smcinit.o tosh2450-smcinit.o SMCINIT_TARGETS = smcinit tosh1800-smcinit tosh2450-smcinit all: $(SMCINIT_TARGETS) smcinit: smcinit.o $(prn_cc_o) $(ECMD)$(CC) -o $@ $^ $(LIBS) -lpci tosh1800-smcinit: tosh1800-smcinit.o $(prn_cc_o) $(ECMD)$(CC) $(XCFLAGS) -o $@ $^ $(LIBS) -lpci tosh2450-smcinit: tosh2450-smcinit.o $(prn_cc_o) $(ECMD)$(CC) $(XCFLAGS) -o $@ $^ $(LIBS) -lpci %o: %c $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< install: $(SMCINIT_TARGETS) $(prn_install) $(ECMD)install smcinit $(ROOT)/usr/sbin $(ECMD)install tosh1800-smcinit $(ROOT)/usr/sbin $(ECMD)install tosh2450-smcinit $(ROOT)/usr/sbin clean: $(RM_CMD) distclean: $(RM_CMD) $(ECMD)$(RM) $(SMCINIT_TARGETS) irda-utils-0.9.18/smcinit/README.Rob0000644000175000017500000001756410454641046016314 0ustar samuelsamuelIRDA on the Toshiba 5100 Skip to here for info on the bugfix so you can use smc-ircc with SWSUSP. The 5100 has an Intel 82801CAM PCI bridge which includes an LPC interface; on this interface is an SMSC LPC47N227 Super I/O chip. The 47N227 has various interfaces (FDC, 2xRS232, IR, parallel), but it seems that only the IR is connected out to a physical port on the case. There are no standard serial (RS232) ports on the 5100. Unfortunately the BIOS does not set up either the LPC interface or the SMC IR in a way that the Linux smc-ircc driver expects. This is the same story as on the Satellite 1800 but a different PCI bridge interface. The work here is based directly on Paul Hampson's post (updated link!) to Linux-IrDA, although I made a small change to get it working. The program tosh5100-smcinit.c performs both of these functions, (1) set up the 82801 LPC interface to pass the standard COM1 port (and hopefully the SMC FIR on DMA 3 as well - but see below), and (2) set up the 47N227 to enable SIR on its UART2, assign it to 0x3f8 irq 3, and assign the FIR interface to 0x130. You should end up with something like kernel: SMC IrDA Controller found kernel: IrCC version 2.0, firport 0x130, sirport 0x2f8 dma=3, irq=3 kernel: irport_open_R0016f49f() in your logs after "modprobe smc-ircc". I have seen it fail the first time when loaded my modprobe due to "irport_open_R0016f49f(), can't get iobase of 0x3f8", just modprobe again. I've not seen this when loading by from /etc/modules. Please note: (1) I have only been able to test the SIR portion of this, as my motivator was to enable connecting a Palm III equivalent, and (2) development of the code linked here stopped pretty quickly once it started working, so there are multiple silly ideas, tries, etc. commented out. The set-up is as follows: 1. you need the lib files from pci-utils (pciutils-dev on debian). 2. the command to build it is gcc -g -O2 -o tosh5100-smcinit tosh5100-smcinit.c -lpci -L/usr/lib -I/usr/include/pci assuming your pci-utils lib is where mine is. put the binary in /usr/local/sbin. 3. enable the standard serial port (CONFIG_SERIAL) as a kernel module 4. /etc/serial.conf (debian) includes the line /dev/ttyS0 uart 16550 port 0x3F8 irq 3 which shows up in dmesg 5. add this line to /etc/modules.conf: pre-install smc-ircc /usr/local/sbin/tosh5100-smcinit 6. modprobe smc-ircc 5. irattach /dev/ttyS0 7. modprobe ircomm 8. if using a pilot with pilot-link, pilot-xfer -p /dev/ircomm0 -l I think that's it, although it's all buried in my start-up scripts now. Under Debian the the irattach etc. config files are stored in /etc/irda.conf, and I place an "irda" file in /etc/init.d when I want the IR enabled at boot. If this doesn't work for you, or you need some slightly different configuration (like different addresses, IRQs, or perhaps the 82801BAM), I suggest you get a digital camera (to see the IR beam, best suggestion I've heard in ages!), the datasheets for the 82801 and the 47N227, and have a play with these files: setpci.c PCI bridge set up setsmc.c SMC chip set up dumpsmc.c print SMC registers while r/w txmit/rcv (CPU burner! sufficiently fast that rcv picks up the glow even if no camera) Again I haven't abeen able to confirm whether the FIR does anything. Furthermore, Jonathan Buzzard's Toshiba HCI docs describe a call to set the SIR vs. FIR status which the work presented here does not access. (update 21 Aug 02) According to results from hacking around on the Toshiba Extras ACPI/HCI code, the SIR/FIR HCI call is not supported on this laptop. (update 30 Mar 03) After someone asked more questions about making this work on another Toshiba laptop, I compiled the following selection of log files and result messages: on the first modprobe smc-ircc (from the command line) for me it claims to fail: vista:~# modprobe smc-ircc /lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: init_module: No such device Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters /lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: insmod /lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o failed /lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: insmod smc-ircc failed dmesg and syslog have lots of debug announcements (still) but the interesting lines seem to be: found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227 ircc_open() SMC IrDA Controller found IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3 irport_open_Ra001cb4a() irport_open_Ra001cb4a(), can't get iobase of 0x3f8 ... irport_close_R13d1bc18(), Releasing Region 3f8 /var/log/messages should (might ?) also survive the crash: Mar 29 23:02:26 vista kernel: found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227 Mar 29 23:02:26 vista kernel: SMC IrDA Controller found Mar 29 23:02:26 vista kernel: IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3 on the second modprobe smc-ircc attempt, no complaints at the command line. dmesg/syslog say found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227 ircc_open() SMC IrDA Controller found IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3 irport_open_Ra001cb4a() IrDA: Registered device irda0 and now /var/log/messages has 2 more relevant lines: Mar 29 23:08:09 vista kernel: found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227 Mar 29 23:08:09 vista kernel: SMC IrDA Controller found Mar 29 23:08:09 vista kernel: IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3 Mar 29 23:08:09 vista kernel: IrDA: Registered device irda0 Mar 29 23:08:09 vista /etc/hotplug/net.agent: assuming irda0 is already up Please note, as I discuss on the 5100 page, there is a conflict between using irda here and the non-kernel PCMCIA code, specifically the ide_cs module which is needed for e.g. mounting compact flash cards. Under 2.4.21-pre4/ACPI-patch I am able to rmmod/modprobe the various pcmcia and irda modules to go back and forth using both systems. I have now added pre-install ide-cs /etc/init.d/irda stop post-remove ide-cs /etc/init.d/irda start to my /etc/modules.conf file, this way the IrDA shuts down when I plug in my CompactFlash card (in a PCMCIA adaptor), then comes back when I pop the card out. This didn't play well with SWSUSP because irattach doesn't always go away on a SIGTERM; in my /etc/init.d/irda script you will see that I now 'kill -9' it if it doesn't die nicely. smc-ircc bug with SWSUSP (suspend to swap partition) The problem: once smc-ircc has been loaded (even if you later remove it), SWSUSP crashes at the end of the suspend when it says 'freeing memory'. The line I think is missing is not in in kernels 2.4.20, 2.4.21pre4, or 2.5.67. The fix: In the Linux source tree, find drivers/net/irda/smc-ircc.c. Go to the end of the file and find the routine ircc_close(). Add a line to make the beginning look like this: #ifdef MODULE static int __exit ircc_close(struct ircc_cb *self) { int iobase; IRDA_DEBUG(0, "%s()\n", __FUNCTION__); ASSERT(self != NULL, return -1;); iobase = self->irport->io.fir_base; pm_unregister(self->pmdev); // <<<<<---------- add this line irport_close(self->irport); That's it; do 'make modules; make modules_install; rmmod smc-ircc; modprobe smc-ircc', and at least this part should not keep you from a sccessful suspend/ resume. One more thing, I'm now using smsc-ircc2 (see Jean Tourrilhes' page and the erratic source site for this code. This (currently) has the same pm_unregister () bug as smc-ircc above. I hope all of the above (smc-init and smc-ircc bugfix) works for you, or maybe helps, but there's absolutely no warranty -- if it doesn't work or otherwise causes your world to collapse, you may keep all the pieces. See also Linux on the Toshiba 5100-501. rob. ------------------------------------------------------------------------------- Last modified: Fri Apr 25 22:44:46 WAT 2003 irda-utils-0.9.18/smcinit/RobMiller-irda.html0000644000175000017500000002260310454641046020373 0ustar samuelsamuel IRDA on the Toshiba 5100 5105

IRDA on the Toshiba 5100

Skip to here for info on the bugfix so you can use smc-ircc with SWSUSP.

The 5100 has an Intel 82801CAM PCI bridge which includes an LPC interface; on this interface is an SMSC LPC47N227 Super I/O chip. The 47N227 has various interfaces (FDC, 2xRS232, IR, parallel), but it seems that only the IR is connected out to a physical port on the case. There are no standard serial (RS232) ports on the 5100. Unfortunately the BIOS does not set up either the LPC interface or the SMC IR in a way that the Linux smc-ircc driver expects.

This is the same story as on the Satellite 1800 but a different PCI bridge interface. The work here is based directly on Paul Hampson's post (updated link!) to Linux-IrDA, although I made a small change to get it working.

The program tosh5100-smcinit.c performs both of these functions, (1) set up the 82801 LPC interface to pass the standard COM1 port (and hopefully the SMC FIR on DMA 3 as well - but see below), and (2) set up the 47N227 to enable SIR on its UART2, assign it to 0x3f8 irq 3, and assign the FIR interface to 0x130.

You should end up with something like

 kernel: SMC IrDA Controller found
 kernel:  IrCC version 2.0, firport 0x130, sirport 0x2f8 dma=3, irq=3
 kernel: irport_open_R0016f49f()

in your logs after "modprobe smc-ircc". I have seen it fail the first time when loaded my modprobe due to "irport_open_R0016f49f(), can't get iobase of 0x3f8", just modprobe again. I've not seen this when loading by from /etc/modules.

Please note: (1) I have only been able to test the SIR portion of this, as my motivator was to enable connecting a Palm III equivalent, and (2) development of the code linked here stopped pretty quickly once it started working, so there are multiple silly ideas, tries, etc. commented out.

The set-up is as follows:

  1. you need the lib files from pci-utils (pciutils-dev on debian).

  2. the command to build it is 

gcc -g -O2 -o tosh5100-smcinit tosh5100-smcinit.c -lpci -L/usr/lib -I/usr/include/pci

   assuming your pci-utils lib is where mine is.  put the binary in /usr/local/sbin.

  3. enable the standard serial port (CONFIG_SERIAL) as a kernel module

  4. /etc/serial.conf (debian) includes the line
/dev/ttyS0 uart 16550 port 0x3F8 irq 3
   which shows up in dmesg

  5. add this line to /etc/modules.conf:
pre-install smc-ircc /usr/local/sbin/tosh5100-smcinit

  6. modprobe smc-ircc

  5. irattach /dev/ttyS0

  7. modprobe ircomm

  8. if using a pilot with pilot-link, pilot-xfer -p /dev/ircomm0 -l

I think that's it, although it's all buried in my start-up scripts now. Under Debian the the irattach etc. config files are stored in /etc/irda.conf, and I place an "irda" file in /etc/init.d when I want the IR enabled at boot.

If this doesn't work for you, or you need some slightly different configuration (like different addresses, IRQs, or perhaps the 82801BAM), I suggest you get a digital camera (to see the IR beam, best suggestion I've heard in ages!), the datasheets for the 82801 and the 47N227, and have a play with these files:

setpci.c PCI bridge set up
setsmc.c SMC chip set up
dumpsmc.c print SMC registers while r/w txmit/rcv (CPU burner! sufficiently fast that rcv picks up the glow even if no camera)

Again I haven't abeen able to confirm whether the FIR does anything. Furthermore, Jonathan Buzzard's Toshiba HCI docs describe a call to set the SIR vs. FIR status which the work presented here does not access.

(update 21 Aug 02) According to results from hacking around on the Toshiba Extras ACPI/HCI code, the SIR/FIR HCI call is not supported on this laptop.

(update 30 Mar 03) After someone asked more questions about making this work on another Toshiba laptop, I compiled the following selection of log files and result messages:

on the first modprobe smc-ircc (from the command line) for me it claims to fail:

vista:~# modprobe smc-ircc
/lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: init_module: No such device
Hint: insmod errors can be caused by incorrect module parameters,
including invalid IO or IRQ parameters
/lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: insmod
/lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o failed
/lib/modules/2.4.21-pre4/kernel/drivers/net/irda/smc-ircc.o: insmod smc-ircc failed

dmesg and syslog have lots of debug announcements (still) but the interesting lines seem to be:

found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227
ircc_open()
SMC IrDA Controller found
 IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3
irport_open_Ra001cb4a()
irport_open_Ra001cb4a(), can't get iobase of 0x3f8
...
irport_close_R13d1bc18(), Releasing Region 3f8

/var/log/messages should (might ?) also survive the crash:

Mar 29 23:02:26 vista kernel: found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227
Mar 29 23:02:26 vista kernel: SMC IrDA Controller found
Mar 29 23:02:26 vista kernel:  IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3

on the second modprobe smc-ircc attempt, no complaints at the command line. dmesg/syslog say

found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227
ircc_open()
SMC IrDA Controller found
 IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3
irport_open_Ra001cb4a()
IrDA: Registered device irda0

and now /var/log/messages has 2 more relevant lines:

Mar 29 23:08:09 vista kernel: found SMC SuperIO Chip (devid=0x5a rev=00 base=0x002e): LPC47N227
Mar 29 23:08:09 vista kernel: SMC IrDA Controller found
Mar 29 23:08:09 vista kernel:  IrCC version 2.0, firport 0x130, sirport 0x3f8 dma=3, irq=3
Mar 29 23:08:09 vista kernel: IrDA: Registered device irda0
Mar 29 23:08:09 vista /etc/hotplug/net.agent: assuming irda0 is already up

Please note, as I discuss on the 5100 page, there is a conflict between using irda here and the non-kernel PCMCIA code, specifically the ide_cs module which is needed for e.g. mounting compact flash cards. Under 2.4.21-pre4/ACPI-patch I am able to rmmod/modprobe the various pcmcia and irda modules to go back and forth using both systems.

I have now added

pre-install ide-cs /etc/init.d/irda stop
post-remove ide-cs /etc/init.d/irda start

to my /etc/modules.conf file, this way the IrDA shuts down when I plug in my CompactFlash card (in a PCMCIA adaptor), then comes back when I pop the card out. This didn't play well with SWSUSP because irattach doesn't always go away on a SIGTERM; in my /etc/init.d/irda script you will see that I now 'kill -9' it if it doesn't die nicely.

smc-ircc bug with SWSUSP (suspend to swap partition)

The problem: once smc-ircc has been loaded (even if you later remove it), SWSUSP crashes at the end of the suspend when it says 'freeing memory'. The line I think is missing is not in in kernels 2.4.20, 2.4.21pre4, or 2.5.67.

The fix: In the Linux source tree, find drivers/net/irda/smc-ircc.c. Go to the end of the file and find the routine ircc_close(). Add a line to make the beginning look like this:

#ifdef MODULE
static int __exit ircc_close(struct ircc_cb *self)
{
        int iobase;

        IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
        ASSERT(self != NULL, return -1;);
        iobase = self->irport->io.fir_base;
        pm_unregister(self->pmdev);    // <<<<<---------- add this line
        irport_close(self->irport);

That's it; do 'make modules; make modules_install; rmmod smc-ircc; modprobe smc-ircc', and at least this part should not keep you from a sccessful suspend/resume.

One more thing, I'm now using smsc-ircc2 (see Jean Tourrilhes' page and the erratic source site for this code. This (currently) has the same pm_unregister() bug as smc-ircc above.

I hope all of the above (smc-init and smc-ircc bugfix) works for you, or maybe helps, but there's absolutely no warranty -- if it doesn't work or otherwise causes your world to collapse, you may keep all the pieces.

See also Linux on the Toshiba 5100-501.

rob.


Last modified: Fri Apr 25 22:44:46 WAT 2003 irda-utils-0.9.18/smcinit/tosh1800-smcinit.c0000644000175000017500000004637610454641046020014 0ustar samuelsamuel/* * tosh1800-smcinit.c * * Based on toshsat1800-irdasetup, version 0.2 2002/04/07 15:42 * * * * IrDA configurator for laptops with ALI1533 bridge (47n227 SuperIO), * smc-ircc and not initializing BIOS (tested on Toshiba Satellite 1800-514) * to be used with Linux kernel. * Copyright (C) 2002, Daniele Peri * * http://lancelot.csai.unipa.it/~peri/toshsat1800-irdasetup.tgz * * * Cleanups, small fixes by Claudiu Costin * * * 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., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include "smcinit.h" #define PROGNAME "tosh1800-smcinit" #define AUTHOR "Daniele Peri" #define AUTHOR_EMAIL "" /* * ALI 1533 bitmapped decode addresses */ struct port_decoding_access_info { int port; u8 reg; u8 or_mask; }; struct port_decoding_access_info ali1533_ports[] = { {0x130, 0xb0, 0x80}, /* this sounds confusing: */ {0x178, 0xb0, 0x80}, /* both ports are decoded */ {0x3f8, 0xb4, 0x80}, {0x2f8, 0xb4, 0x30}, /* bit 4 enables decoding, bit 5 enables something unknown it can't stand without... */ {0x2e8, 0xb4, 0x08}, /* the followings are all the active bits in the default bitmap of Satellite1800-514: {0x3f8, 0xb4, 0x80}, {0x???, 0xb6, 0x80}, {0x???, 0xb6, 0x80}, {0x???, 0xb7, 0x40}, {0x???, 0xb7, 0x20}, {0x???, 0xb7, 0x10}, {0x???, 0xb7, 0x02}, {0x???, 0xb8, 0x80}, {0x???, 0xb8, 0x40}, {0x???, 0xb8, 0x02}, {0x???, 0xb9, 0x04}, {0x???, 0xb9, 0x02}, According to Paul Hampson decoded ISA ports are thus: 2e, 2f, 62, 66, 60, 64, 378-37f, 778-77f, 2f0-2f5, 3f7, 3f8-3ff Unfortunately I don't have any other information about the ALI1533. */ {0, 0, 0} }; /* SMC-IRCC * * */ /* Chip specific config function(s) */ static int configure_47N227_smc_ircc(int revision, int cfgbase, int sirbase, int firbase, int dma, int irq); struct smc_chip_model { char *name; u8 version_id; int (*config_function) (int revision, int cfgbase, int sirbase, int firbase, int dma, int irq); }; static struct smc_chip_model smc_chips[] = { {"LPC47N227", 0x5a, configure_47N227_smc_ircc}, {NULL, 0, NULL} }; /* * LPC47N227 */ #define LPC47N227_CFGACCESSKEY 0x55 #define LPC47N227_CFGEXITKEY 0xaa /* Register 0x00 */ #define LPC47N227_FDCPOWERVALIDCONF_REG 0x00 #define LPC47N227_FDCPOWER_MASK 0x08 #define LPC47N227_VALID_MASK 0x80 /* Register 0x02 */ #define LPC47N227_UART12POWER_REG 0x02 #define LPC47N227_UART1POWERDOWN_MASK 0x08 #define LPC47N227_UART2POWERDOWN_MASK 0x80 /* Register 0x07 */ #define LPC47N227_APMBOOTDRIVE_REG 0x07 #define LPC47N227_PARPORT2AUTOPWRDOWN_MASK 0x10 /* auto power down on if set */ #define LPC47N227_UART2AUTOPWRDOWN_MASK 0x20 /* auto power down on if set */ #define LPC47N227_UART1AUTOPWRDOWN_MASK 0x40 /* auto power down on if set */ /* Register 0x0c */ #define LPC47N227_UARTMODE0C_REG 0x0c #define LPC47N227_UART2MODE_MASK 0x38 #define LPC47N227_UART2MODE_VAL_COM 0x00 #define LPC47N227_UART2MODE_VAL_IRDA 0x08 #define LPC47N227_UART2MODE_VAL_ASKIR 0x10 /* Register 0x0d */ #define LPC47N227_DEVICEID_REG 0x0d #define LPC47N227_DEVICEID_DEFVAL 0x5a /* Register 0x0e */ #define LPC47N227_REVISIONID_REG 0x0e /* Register 0x25 */ #define LPC47N227_UART2BASEADDR_REG 0x25 /* Register 0x28 */ #define LPC47N227_UARTIRQSELECT_REG 0x28 #define LPC47N227_UART2IRQSELECT_MASK 0x0f #define LPC47N227_UART1IRQSELECT_MASK 0xf0 #define LPC47N227_UARTIRQSELECT_VAL_NONE 0x00 /* Register 0x2b */ #define LPC47N227_FIRBASEADDR_REG 0x2b /* Register 0x2c */ #define LPC47N227_FIRDMASELECT_REG 0x2c #define LPC47N227_FIRDMASELECT_MASK 0x0f #define LPC47N227_FIRDMASELECT_VAL_DMA1 0x01 /* 47n227 has three dma channels */ #define LPC47N227_FIRDMASELECT_VAL_DMA2 0x02 #define LPC47N227_FIRDMASELECT_VAL_DMA3 0x03 #define LPC47N227_FIRDMASELECT_VAL_NONE 0x0f /* * Defaults values for Toshiba Satellite 1800-514 */ #define DEF_CFGBASE 0x2e #define DEF_SIRBASE 0x2e8 #define DEF_FIRBASE 0x2f8 #define DEF_DMA 0x03 #define DEF_IRQ 0x07 #define DEF_ISABRIDGE_VENDOR_ID 0x10b9 #define DEF_ISABRIDGE_DEVICE_ID 0x1533 /* * Actions */ #define ACTION_CONFIG_ALI1533_PORTS_DECODING 1 #define ACTION_INIT_SMC_IRCC 2 #define ACTION_PRINT_ALI1533_CONFIGURATION 4 #define DEF_ACTIONS ACTION_CONFIG_ALI1533_PORTS_DECODING | ACTION_INIT_SMC_IRCC struct option options[] = { {"skip-decoding-cfg", no_argument, NULL, 'a'}, {"skip-smc-ircc-cfg", no_argument, NULL, 'b'}, {"vendor", required_argument, NULL, 'v'}, {"device", required_argument, NULL, 'x'}, {"cfgbase", required_argument, NULL, 'c'}, {"sirbase", required_argument, NULL, 's'}, {"firbase", required_argument, NULL, 'f'}, {"dma", required_argument, NULL, 'm'}, {"irq", required_argument, NULL, 'i'}, {"print", no_argument, NULL, 'p'}, {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, #ifdef DEBUG_ON {"debug", no_argument, NULL, 'd'}, #endif {NULL, 0, NULL, 0} }; static char *options_explications[] = { "\tskip ISA bridge decoding configuration", "\tskip SMC-IRCC configuration", "\tlook for the specified ISA bridge PCI vendor id", "\tlook for the specified ISA bridge PCI device id", "\tset SMC-IRCC IO cfgbase address", "\tset SMC-IRCC IO sirbase address", "\tset SMC-IRCC IO firbase address", "\t\tset SMC-IRCC DMA channel", "\t\tset SMC-IRCC IRQ", "\t\tprint ISA bridge configuration", "\t\tshow program version", "\t\tshow this help", #ifdef DEBUG_ON NULL, #endif NULL }; #ifdef DEBUG_ON static char *short_options = "abpv:x:c:s:f:m:i:dVh"; #endif #ifndef DEBUG_ON static char *short_options = "abpv:x:c:s:f:m:i:Vh"; #endif /* ALI 1533 */ static int find_ali1533_port_access_info(long port, struct port_decoding_access_info *info) { struct port_decoding_access_info *p; int i; p = &ali1533_ports[0]; i = 0; while (p->port != 0) { DEBUG_VAL("port", p->port); if (p->port == port) { memcpy(info, p, sizeof(struct port_decoding_access_info)); return 1; } i++; p = &ali1533_ports[i]; } return 0; } static int print_ali1533_port_status(struct pci_dev *dev) { struct port_decoding_access_info *p; u8 onebyte; int i; DEBUG("printing port status"); p = &ali1533_ports[0]; i = 0; puts("ALi 1533 Decoding status:"); while (p->port != 0) { DEBUG_VAL("port", p->port); onebyte = pci_read_byte(dev, p->reg); printf("port 0x%x %s\n", p->port, (onebyte & p->or_mask ? "enabled" : "disabled")); i++; p = &ali1533_ports[i]; } return 0; } /* Sets ALi1533 port decoding mode and * returns previous port decoding mode * (0=disabled, 1=enabled, -1 port unknown) */ static int set_ali1533_port(struct pci_dev *dev, int port, int decode) { struct port_decoding_access_info info; u8 previousval, onebyte, and_mask; int retval; DEBUG_VAL("looking for port", port); retval = find_ali1533_port_access_info(port, &info); if (retval) { previousval = pci_read_byte(dev, info.reg); DEBUG_VAL("current register value", previousval); and_mask = ~info.or_mask; DEBUG_VAL("and with mask", and_mask); onebyte = previousval & and_mask; if (decode) { DEBUG_VAL("or with mask", info.or_mask); onebyte |= info.or_mask; } DEBUG_VAL("writing value", onebyte); pci_write_byte(dev, info.reg, onebyte); return (previousval & info.or_mask) ? 1 : 0; } else { DEBUG_VAL("unknown port", port); } return -1; } /* PCI */ static struct pci_dev *find_pci_device(struct pci_access *access, struct pci_filter *filter) { struct pci_dev *dev; DEBUG("scanning PCI busses"); pci_scan_bus(access); DEBUG("looking for PCI device"); for (dev = access->devices; dev; dev = dev->next) { if (pci_filter_match(filter, dev)) { DEBUG("device found"); DEBUG_VAL("bus", dev->bus); DEBUG_VAL("dev", dev->dev); DEBUG_VAL("func", dev->func); return dev; } } return NULL; } /* Configure ali1533 PCI-ISA bridge to decode * SMC-IRCC ports */ static int configure_ali1533_smc_ports_decoding(int vendor_id, int device_id, int cfgbase, int firbase, int sirbase, int print) { struct pci_access *access; struct pci_dev *dev = NULL; struct pci_filter filter; int ports[2], port_previous_mode, i; /* claudiuc: cfgbase is not used yet */ int dummy; dummy = cfgbase; access = pci_alloc(); if (access == NULL) { DEBUG("impossible to obtain PCI access"); return 0; } DEBUG("initializing filter"); pci_filter_init(access, &filter); filter.vendor = vendor_id; filter.device = device_id; pci_init(access); dev = find_pci_device(access, &filter); if (dev) { if (print) { print_ali1533_port_status(dev); } else { syslog(LOG_NOTICE, "PCI device 0x%x:0x%x found at %02x:%02x:%02x. Configuring:", vendor_id, device_id, dev->bus, dev->dev, dev->func); ports[0] = sirbase; ports[1] = firbase; for (i = 0; i < 2; i++) { port_previous_mode = set_ali1533_port(dev, ports[i], 1); if (port_previous_mode == 1) { syslog(LOG_ERR, "port 0x%x was already enabled", ports[i] ); } else { syslog(LOG_NOTICE, "enabled decoding of port 0x%x", ports[i] ); } } } } if (dev != NULL) { syslog(LOG_NOTICE, "PCI device 0x%x:0x%x. Configuration ended", vendor_id, device_id); } else { syslog(LOG_ERR, "PCI device 0x%x:0x%x not found", vendor_id, device_id); } pci_cleanup(access); return dev != NULL; } /* SMC IRCC * * */ /* Configure 47N227 SuperIO IrDA subsystem * */ static int configure_47N227_smc_ircc(int revision, int cfgbase, int sirbase, int firbase, int dma, int irq) { u8 onebyte; int retval; /* claudiuc: revision is not used yet */ int dummy; dummy = revision; DEBUG_VAL("trying to init SMC with cfgbase", cfgbase); retval = ioperm(cfgbase, 2, 1); if (retval == -1) { syslog(LOG_ERR, "failed to obtain ioperm for cfgbase %m"); ERROR("failed to obtain ioperm for cfgbase"); return 0; } outb(LPC47N227_CFGACCESSKEY, cfgbase); /* outb(LPC47N227_DEVICEID_REG, cfgbase); if (inb(cfgbase+1) == LPC47N227_DEVICEID_DEFVAL) { */ /*syslog(LOG_NOTICE, "LPC47N227 present. Configuring:"); */ /*SIR Base */ DEBUG_VAL("setting sirbase to", sirbase); outb(LPC47N227_UART2BASEADDR_REG, cfgbase); onebyte = sirbase >> 2; outb(onebyte, cfgbase + 1); /* FIR Base */ DEBUG_VAL("setting firbase to", firbase); outb(LPC47N227_FIRBASEADDR_REG, cfgbase); onebyte = firbase >> 3; outb(onebyte, cfgbase + 1); /* DMA */ DEBUG_VAL("setting dma to", dma); outb(LPC47N227_FIRDMASELECT_REG, cfgbase); outb(dma & LPC47N227_FIRDMASELECT_MASK, cfgbase + 1); /* IRQ */ DEBUG_VAL("setting irq to", irq); outb(LPC47N227_UARTIRQSELECT_REG, cfgbase); onebyte = inb(cfgbase + 1); onebyte &= LPC47N227_UART1IRQSELECT_MASK; onebyte |= (irq & LPC47N227_UART2IRQSELECT_MASK); outb(onebyte, cfgbase + 1); syslog(LOG_NOTICE, "set sirbase=0x%x, firbase=0x%x, dma=%d, irq=%d", sirbase, firbase, dma, irq); DEBUG("setting other registers"); /* Set UART2 mode to IrDA */ outb(LPC47N227_UARTMODE0C_REG, cfgbase); onebyte = inb(cfgbase + 1); onebyte &= ~LPC47N227_UART2MODE_MASK | LPC47N227_UART2MODE_VAL_IRDA; outb(onebyte, cfgbase + 1); /* Set UART2 AUTO POWER DOWN */ outb(LPC47N227_APMBOOTDRIVE_REG, cfgbase); onebyte = inb(cfgbase + 1); outb(onebyte | LPC47N227_UART2AUTOPWRDOWN_MASK, cfgbase + 1); /* Set UART2 POWER ON */ outb(LPC47N227_UART12POWER_REG, cfgbase); onebyte = inb(cfgbase + 1); outb(onebyte | LPC47N227_UART2POWERDOWN_MASK, cfgbase + 1); syslog(LOG_NOTICE, "set UART 2 IR mode to IrDA, auto powerdown on and powered up"); /* Validate configuration */ outb(LPC47N227_FDCPOWERVALIDCONF_REG, cfgbase); onebyte = inb(cfgbase + 1); outb(onebyte | LPC47N227_VALID_MASK, cfgbase + 1); outb(LPC47N227_CFGEXITKEY, cfgbase); DEBUG("configuration ended"); return 1; } static struct smc_chip_model *find_smc_chip_model(struct smc_chip_model *chips, int version_id) { int i; for (i = 0; chips[i].name != NULL; i++) { if (chips[i].version_id == version_id) return &chips[i]; } return NULL; } static int configure_smc_ircc(int cfgbase, int sirbase, int firbase, int dma, int irq) { u8 version_id, revision_id; struct smc_chip_model *chip_model; int retval; DEBUG_VAL("trying to init SMC with cfgbase", cfgbase); retval = ioperm(cfgbase, 2, 1); if (retval == -1) { syslog(LOG_ERR, "failed to obtain ioperm for cfgbase %m"); ERROR("failed to obtain ioperm for cfgbase"); return 0; } outb(LPC47N227_CFGACCESSKEY, cfgbase); outb(LPC47N227_DEVICEID_REG, cfgbase); version_id = inb(cfgbase + 1); outb(LPC47N227_REVISIONID_REG, cfgbase); revision_id = inb(cfgbase + 1); outb(LPC47N227_CFGEXITKEY, cfgbase); chip_model = find_smc_chip_model(smc_chips, version_id); if (chip_model != NULL) { syslog(LOG_NOTICE, "%s chip (ver 0x%x, rev 0x%x) found. Configuring:", chip_model->name, version_id, revision_id); retval = (*(chip_model->config_function)) (revision_id, cfgbase, sirbase, firbase, dma, irq); syslog(LOG_NOTICE, "%s chip (ver 0x%x, rev 0x%x) configuration %ssuccessfully ended", chip_model->name, version_id, revision_id, (retval ? "" : "un")); return 1; } else { syslog(LOG_ERR, "Unknown chip version 0x%x", version_id); return 0; } } void print_usage(struct option *options_array, char **options_explications_array) { struct option *option; char *option_explication = NULL; int i; printf("%s %s %s\nUsage: %s [options]\nOptions:\n", PROGNAME, VERSION, AUTHOR, PROGNAME); i = 0; option = &options_array[0]; option_explication = options_explications_array[0]; while (option->name != NULL) { printf("-%c, --%s%s", option->val, option->name, (option->has_arg ? "=VALUE" : "")); if (options_explications_array[i] != NULL) printf("%s\n", options_explications_array[i]); else puts("\n"); i++; option = &options[i]; option_explication = options_explications_array[i]; } printf("Report suggestions and bugs to: %s\n", AUTHOR " " AUTHOR_EMAIL); } void print_version() { printf("%s %s\n", PROGNAME, VERSION); } int main(int argc, char **argv) { int cfgbase = DEF_CFGBASE; int sirbase = DEF_SIRBASE; int firbase = DEF_FIRBASE; int dma = DEF_DMA; int irq = DEF_IRQ; int isabridge_vendor_id = DEF_ISABRIDGE_VENDOR_ID; int isabridge_device_id = DEF_ISABRIDGE_DEVICE_ID; int actions = DEF_ACTIONS; int retval = 0, opt; while ((opt = getopt_long(argc, argv, short_options, options, NULL)) != -1) { switch (opt) { case 'a': { actions &= ~ACTION_CONFIG_ALI1533_PORTS_DECODING; break; } case 'b': { actions &= ~ACTION_INIT_SMC_IRCC; break; } case 'p': { actions |= ACTION_PRINT_ALI1533_CONFIGURATION; break; } case 'v': { isabridge_vendor_id = strtoul(optarg, NULL, 0); break; } case 'x': { isabridge_device_id = strtoul(optarg, NULL, 0); break; } case 'c': { cfgbase = strtoul(optarg, NULL, 0); break; } case 's': { sirbase = strtoul(optarg, NULL, 0); break; } case 'f': { firbase = strtoul(optarg, NULL, 0); break; } case 'm': { dma = strtoul(optarg, NULL, 0); break; } case 'i': { irq = strtoul(optarg, NULL, 0); break; } #ifdef DEBUG_ON case 'd': { DEBUG_LEVEL(1); break; } #endif case 'V': { print_version(); exit(0); break; } case 'h': { print_usage(options, options_explications); exit(0); break; } default: break; } } if (getuid() != 0) { fprintf(stderr, "%s can only be used by root\n", PROGNAME); exit(1); } if (actions & (ACTION_INIT_SMC_IRCC | ACTION_CONFIG_ALI1533_PORTS_DECODING)) { syslog(LOG_INFO, "%s %s %s", PROGNAME, VERSION, AUTHOR); } if (actions & ACTION_INIT_SMC_IRCC) { retval = configure_smc_ircc(cfgbase, sirbase, firbase, dma, irq); } if (actions & ACTION_CONFIG_ALI1533_PORTS_DECODING && retval) { retval = configure_ali1533_smc_ports_decoding(isabridge_vendor_id, isabridge_device_id, cfgbase, firbase, sirbase, actions & ACTION_PRINT_ALI1533_CONFIGURATION); } exit(!retval); } irda-utils-0.9.18/smcinit/tosh2450-smcinit.c0000644000175000017500000001004610454641046017777 0ustar samuelsamuel// tosh2450-smcinit.c // 17-06-2003 // By Jos Manuel Mario Mario // based on tosh5100-smcinit.c by Rob Miller. // small compile fixes by Claudiu Costin. #include #include #include #include #include #include #include "smcinit.h" #define INTEL_VID 0x8086 // 2450-101 uses 82801DB chip #define i82801DB_LPC_DID 0x24C0 // lspci on 2450-101 says // 00:1f.0 ISA bridge: Intel Corp. 82801DB ISA Bridge (LPC) (rev 02) // The LPC Bridge function of the ICH3 (82801CAM) and ICH4 (82801DB) // resides in PCI Device 31:Function 0. #define BUS_LPC 0x00 #define LPC_DEV 0x1f #define LPC_FUNC 0x00 // 82801DB registers #define VID 0x00 #define DID 0x02 #define PIRQA_ROUT 0x60 #define PCI_DMA_C 0x90 #define COM_DEC 0xe0 #define LPC_EN 0xe6 #define GEN2_DEC 0xec // SMSC 47N227 registers #define SMC_BASE 0x2e #define RCV base #define IER base+1 #define IIR base+2 #define FCR base+2 #define LCR base+3 #define MCR base+4 #define LSR base+5 #define MSR base+6 #define SPR base+7 #define DLSB base #define DMSB base+1 int main() { int i=0; /* setpci.c */ struct pci_access *acc; struct pci_dev *dev; u16 twobyte; acc = pci_alloc(); pci_init(acc); dev = pci_get_dev(acc, 0, BUS_LPC, LPC_DEV, LPC_FUNC); twobyte = pci_read_word(dev,VID); if (twobyte != INTEL_VID){ fprintf(stderr,"tosh2450-smcinit IO hub vendor %x not Intel (%x)\n",twobyte,INTEL_VID); return 1; } twobyte = pci_read_word(dev,DID); if (twobyte == i82801DB_LPC_DID){ fprintf(stderr,"tosh2450-smcinit Found IO hub device 82801DB (%x)\n",i82801DB_LPC_DID); } else { fprintf(stderr,"tosh2450-smcinit IO hub device %x not supported.\n",twobyte); return 1; } pci_write_byte(dev, COM_DEC, 0x10); // comb 2f8-2ff coma 3f8-3ff twobyte = pci_read_word(dev, LPC_EN); // LPC_EN register twobyte &= 0xfffd; // wipe bit 1 twobyte |= 0x0001; // set bit 0 : COMA addr range enable pci_write_word(dev, LPC_EN, twobyte); twobyte = pci_read_word(dev, PCI_DMA_C); // PCI_DMA register twobyte |= 0xc00c; // LPC I/F DMA on, channel 1 pci_write_word(dev, PCI_DMA_C, twobyte); pci_write_word(dev, GEN2_DEC, 0x131); // LPC I/F 2nd decode range pci_free_dev(dev); pci_cleanup(acc); /* setsmc.c */ ioperm(SMC_BASE, 2, 1); outb(0x55, SMC_BASE); // enter configuration state outb(0x0d, SMC_BASE); // set for device id if ((i = inb(SMC_BASE+1)) == 0x5a) // if SMC 47N227 { outb(0x24, SMC_BASE); // select CR24 - UART1 base addr outb(0x00, SMC_BASE+1); // disable UART1 outb(0x25, SMC_BASE); // select CR25 - UART2 base addr outb(0xFE, SMC_BASE+1); // bits 2-9 of 0x3f8 outb(0x28, SMC_BASE); // select CR28 - UART1,2 IRQ select i = inb(SMC_BASE+1); // get current setting for both outb((i & 0x00) | 0x07, SMC_BASE+1); // select IRQ 7 outb(0x2B, SMC_BASE); // CR2B - SCE (FIR) base addr outb(0x26, SMC_BASE+1); // 0x130 bits 2-9 outb(0x2C, SMC_BASE); // CR2C - SCE (FIR) DMA select outb(0x01, SMC_BASE+1); // select DMA 1 outb(0x0C, SMC_BASE); // CR0C - UART mode i = inb(SMC_BASE+1); // whatever already there outb((i & 0xC7) | 0x88, SMC_BASE+1); // enable IrDA (HPSIR) mode, high speed outb(0x07, SMC_BASE); // CR07 - Auto Pwr Mgt/boot drive sel i = inb(SMC_BASE+1); // whatever already there outb(i | 0x20, SMC_BASE+1); // enable UART2 autopower down outb(0x0a, SMC_BASE); // CR0a - ecp fifo / ir mux i = inb(SMC_BASE+1); // whatever already there outb(i | 0x40, SMC_BASE+1); // send active device to ir port outb(0x02, SMC_BASE); // CR02 - UART 1,2 power i = inb(SMC_BASE+1); // whatever already there outb(0x80, SMC_BASE+1); // UART2 power up mode, UART1 power down outb(0x00, SMC_BASE); // CR00 - FDC Power/valid config cycle i = inb(SMC_BASE + 1); // whatever already there outb(i | 0x80, SMC_BASE + 1); // valid config cycle done outb(0xaa, SMC_BASE); // ?? twiggle config register ?? } else { fprintf(stderr,"tosh2450-smcinit %x not SMC 47N227 (0x5a).\n",i); return 1; } return 0; } irda-utils-0.9.18/tekram/0000755000175000017500000000000010454641161014511 5ustar samuelsamuelirda-utils-0.9.18/tekram/irkbd.h0000644000175000017500000000521610454641046015763 0ustar samuelsamuel/********************************************************************* * * Filename: irkbd.h * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Wed Mar 24 11:31:10 1999 * Modified at: Mon May 3 11:27:30 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #ifndef IRKBD_H #define IRKBD_H #include /* Some commands */ #define IRKBD_CMD_INIT_KBD 0xfe #define IRKBD_CMD_INIT_MOUSE 0xff #define IRKBD_CMD_ENABLE 0x41 #define IRKBD_CMD_LED 0x31 #define IRKBD_CMD_KDB_SPEED 0x33 /* Some responses */ #define IRKBD_RSP_KBDOK 0x11 #define IRKBD_RSP_KBDERR 0x12 #define IRKBD_RSP_MSOK 0x21 #define IRKBD_RSP_MSERR 0x22 #define IRKBD_RSP_LEDOK 0x31 #define IRKBD_RSP_KBDSPEEDOK 0x33 #define IRKBD_RSP_RSPN41 0x41 #define IRKBD_RATE 15000 /* Polling rate, should be 15 ms */ #define IRKBD_IDLE_RATE 100000 /* 100 ms */ #define IRKBD_TIMEOUT 1 /* 1000 ms */ #define SUBFRAME_MASK 0xc0 #define SUBFRAME_MOUSE 0x80 #define SUBFRAME_MOUSE2 0xc0 #define SUBFRAME_KEYBOARD 0x40 #define SUBFRAME_RESPONSE 0x00 #define IRKBD_BUF_SIZE 4096 /* Must be power of 2! */ enum { IRKBD_IDLE, /* Not connected */ IRKBD_INIT_KBD, /* Initializing keyboard */ IRKBD_INIT_MOUSE, /* Initializing mouse */ IRKBD_READY, IRKBD_POLLING, /* Polling device */ }; /* Main structure */ struct irkbd_cb { int state; int sock; int fifo; int fd; int connected; __u32 saddr; /* my local address */ __u32 daddr; /* peer address */ int mtu_tx; struct itimerval watchdog_timer; __u8 frame[IRKBD_BUF_SIZE]; /* Buffer for received data */ int head; int tail; }; #endif /* IRKBD_H */ irda-utils-0.9.18/tekram/irkbd.c0000644000175000017500000002246410454641046015762 0ustar samuelsamuel/********************************************************************* * * Filename: irkbd.c * Version: * Description: * Status: Experimental. * Author: Dag Brattli * Created at: Wed Mar 24 11:25:17 1999 * Modified at: Sat Sep 4 21:20:22 1999 * Modified by: Dag Brattli * * Copyright (c) 1999 Dag Brattli, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "irkbd.h" static void irkbd_data_indication(int signo); static inline void irkbd_start_watchdog_timer(int sec, int usec); #ifndef AF_IRDA #define AF_IRDA 23 #endif /* AF_IRDA */ #define MAX_DEVICES 10 #define FIFO_NAME "/dev/irkbd" struct irkbd_cb irkbd; struct irkbd_cb *self = &irkbd; int power_save = 0; /* * Function irkbd_init () * * Initialize IrKBD * */ static void irkbd_init(struct irkbd_cb *self) { int fd; int oflags; memset(&irkbd, 0, sizeof(struct irkbd_cb)); /* Create socket */ fd = socket(AF_IRDA, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); exit(-1); } /* Register for asynchronous notification */ signal(SIGIO, &irkbd_data_indication); fcntl(fd, F_SETOWN, getpid()); oflags = fcntl(0, F_GETFL); if (fcntl(fd, F_SETFL, oflags | FASYNC) < 0) { perror("fcntl"); exit(-1); } self->sock = fd; /* Make fifo */ if (mknod (FIFO_NAME, 0666 | S_IFIFO, 0)) { /* Just be happy if it's already there */ if (errno != EEXIST) { perror("mknod"); exit(-1); } } fd = open(FIFO_NAME, O_RDWR|O_NONBLOCK); if (fd < 0) { perror("open"); exit(-1); } self->fifo = fd; fd = open("/dev/console", O_RDWR); if (fd < 0) return; self->fd = fd; self->state = IRKBD_IDLE; } /* * Function irkbd_discover_devices (fd) * * Try to discover some remote device(s) that we can connect to * */ static int irkbd_discover_devices(void) { struct irda_device_list *list; unsigned char *buf; socklen_t len; int i; len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * MAX_DEVICES; buf = malloc(len); list = (struct irda_device_list *) buf; if (getsockopt(self->sock, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) { perror("getsockopt"); exit(-1); } if (len > 0) { printf("Discovered: (list len=%d)\n", list->len); for (i=0;ilen;i++) { printf(" name: %s\n", list->dev[i].info); printf(" daddr: %08x\n", list->dev[i].daddr); printf(" saddr: %08x\n", list->dev[i].saddr); printf("\n"); self->daddr = list->dev[i].daddr; self->saddr = list->dev[i].saddr; if (strcmp(list->dev[i].info, "IR-660") == 0) { printf("This one looks good!\n"); return 0; } } } printf("Hmm, didn't find any! retry?\n"); return -1; } /* * Function irkbd_connect_request (self) * * Try to connect to remote device * */ static int irkbd_connect_request(void) { struct sockaddr_irda peer; int mtu = 0; socklen_t len = sizeof(int); int ret; /* * Open TTP connection to remote device! */ ret = irkbd_discover_devices(); if (ret == -1) return -1; /* Disable IrTTP SAR */ if (setsockopt(self->sock, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, &mtu, sizeof(mtu))) { perror("setsockopt"); exit(-1); } peer.sir_family = AF_IRDA; strncpy(peer.sir_name, "IrKBMS", 25); peer.sir_addr = self->daddr; if (connect(self->sock, (struct sockaddr*) &peer, sizeof(struct sockaddr_irda))) { perror("connect"); return -1; } /* Check what the IrLAP data size is */ if (getsockopt(self->sock, SOL_IRLMP, IRTTP_MAX_SDU_SIZE, (void *) &mtu, &len)) { perror("getsockopt"); exit(-1); } self->mtu_tx = mtu; /* printf(__FUNCTION__ "(), link mtu=%d\n", mtu); */ self->connected = 1; return 0; } /* * Function irkbd_data_request (self, cmd) * * Send command to device * */ static void irkbd_data_request(int cmd) { char buf[1]; int ret; switch (cmd) { case IRKBD_CMD_ENABLE: buf[0] = IRKBD_CMD_ENABLE; break; case IRKBD_CMD_INIT_KBD: buf[0] = IRKBD_CMD_INIT_KBD; break; case IRKBD_CMD_INIT_MOUSE: buf[0] = IRKBD_CMD_INIT_MOUSE; break; default: break; } ret = send(self->sock, buf, 1, 0); if (ret < 0) printf("Disconnected2!\n"); } /* * Function irkbd_process_response (self, rsp) * * Process response code * */ static inline void irkbd_handle_response(__u8 rsp) { switch (rsp) { case IRKBD_RSP_RSPN41: if (power_save++ > 100) irkbd_start_watchdog_timer(0, IRKBD_IDLE_RATE); else irkbd_start_watchdog_timer(0, IRKBD_RATE); break; case IRKBD_RSP_KBDOK: printf("OK!\n"); self->state = IRKBD_INIT_MOUSE; irkbd_start_watchdog_timer(0, IRKBD_RATE); break; case IRKBD_RSP_KBDERR: printf("Error!\n"); self->state = IRKBD_INIT_MOUSE; irkbd_start_watchdog_timer(0, IRKBD_RATE); break; case IRKBD_RSP_MSOK: printf("OK!\n"); self->state = IRKBD_READY; irkbd_start_watchdog_timer(0, 100000); break; case IRKBD_RSP_MSERR: printf("Error!\n"); self->state = IRKBD_READY; irkbd_start_watchdog_timer(0, 100000); break; case IRKBD_RSP_LEDOK: break; case IRKBD_RSP_KBDSPEEDOK: break; default: printf("%s(), unknown response %02x\n", __FUNCTION__, rsp); break; } } /* * Function irkbd_handle_mouse (self, scancode) * * Handle mouse event. The scancodes follows the PS/2 mouse protocol. Half * a protocol for half a mouse :-) */ static inline void irkbd_handle_mouse(__u8 scancode) { /* Write to fifo */ write(self->fifo, &scancode, 1); } static inline void handle_scancode(__u8 scancode) { /* Insert scancode into kernel */ if (ioctl(self->fd,TIOCSTI, &scancode)) perror("ioctl"); } /* * Function irkbd_data_indication (instance, sap, skb) * * Received some mouse and/or keyboard data * */ static void irkbd_data_indication(int signo) { __u8 *frame = self->frame; int actual; int i, n=0; __u8 len; __u8 sublen; __u8 subtype; actual = recv(self->sock, frame, 2048, 0); if (actual <= 0) { printf("Disconnected!\n"); self->connected = 0; } /* Get lenght of frame */ len = frame[n++]; /* Parse frame */ while (len > 0) { sublen = frame[n] & ~SUBFRAME_MASK; /* Len of subframe */ subtype = frame[n++] & SUBFRAME_MASK; /* Type of subframe */ len -= 1; switch (subtype) { case SUBFRAME_MOUSE: case SUBFRAME_MOUSE2: /* Mouse subframes contains 3 bytes pr. record */ for (i=0;iwatchdog_timer.it_value.tv_sec = sec; self->watchdog_timer.it_value.tv_usec = usec; setitimer(ITIMER_REAL, &self->watchdog_timer, NULL); } /* * Function irkbd_watchdog_timer_expired (data) * * * */ void irkbd_watchdog_timer_expired(int signo) { switch (self->state) { case IRKBD_POLLING: /* Optimize the common case */ irkbd_data_request(IRKBD_CMD_ENABLE); irkbd_start_watchdog_timer(IRKBD_TIMEOUT, 0); break; case IRKBD_IDLE: break; case IRKBD_INIT_KBD: printf("Initializing keyboard: "); irkbd_data_request(IRKBD_CMD_INIT_KBD); break; case IRKBD_INIT_MOUSE: printf("Initializing mouse: "); irkbd_data_request(IRKBD_CMD_INIT_MOUSE); break; case IRKBD_READY: printf("Running ...\n"); irkbd_data_request(IRKBD_CMD_ENABLE); self->state = IRKBD_POLLING; break; default: break; } } int main(int argc, char *argv[]) { int err; irkbd_init(self); signal(SIGALRM, irkbd_watchdog_timer_expired); for (;;) { /* Try connect */ err = irkbd_connect_request(); if (err) { sleep(5); continue; } self->state = IRKBD_INIT_KBD; self->state = IRKBD_INIT_MOUSE; irkbd_start_watchdog_timer(IRKBD_TIMEOUT, 0); while (self->connected) sleep(1); printf("Disconnected!\n"); } return 0; } irda-utils-0.9.18/tekram/Makefile0000644000175000017500000000354710454641046016164 0ustar samuelsamuel###################################################################### ## ## Filename: Makefile ## Version: ## Description: Makefile for irdaping ## Status: Experimental. ## Author: Dag Brattli ## Created at: Thu Feb 19 00:10:23 1998 ## Modified at: Tue Sep 7 21:01:30 1999 ## Modified by: Dag Brattli ## ## $Id: Makefile 115 2006-02-28 22:16:46Z sambau $ ## ## Copyright (c) 1998-1999 Dag Brattli, 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. ## ## Neither Dag Brattli nor University of Troms admit liability nor ## provide warranty for any of this software. This material is ## provided "AS-IS" and at no charge. ## ###################################################################### include ../output.mak CC = gcc LD = ld RM = rm -f RM_CMD = $(RM) *.BAK *.bak *.o ,* *~ *.a INCLUDES = $(SYS_INCLUDES) LIBRARIES = $(SYS_LIBRARIES) LIBPATH = $(SYS_LIBPATH) # # System stuff # SYS_INCLUDES = -I/usr/src/linux/include -I/usr/include -I../include SYS_LIBRARIES = SYS_LIBPATH = -L/usr/lib -L/usr/local/lib CFLAGS= $(RPM_OPT_FLAGS) $(SYS_INCLUDES) -Wall -Wstrict-prototypes # # Files to make # SRCS = irkbd.c OBJS = $(SRCS:.c=.o) all: irkbd irkbd: $(OBJS) $(prn_cc_o) $(ECMD)$(CC) $(OBJS) -o $@ .c.o: $(prn_cc) $(ECMD)$(CC) $(CFLAGS) $(INCLUDES) -c $< install: irkbd $(prn_install) $(ECMD)install irkbd $(ROOT)/usr/bin clean: $(ECMD)$(RM_CMD) distclean: $(ECMD)$(RM_CMD) $(ECMD)$(RM) irkbd depend: $(prn_depend) $(ECMD)makedepend -s "# DO NOT DELETE" -- $(INCLUDES) -- $(SRCS) # DO NOT DELETE irda-utils-0.9.18/tekram/README0000644000175000017500000000165710454641046015404 0ustar samuelsamuelINTRODUCTION: IrKBD is the keyboard/mouse protocol use by the Tekram IR-660 docking station. Without this docking-station there is no use in this program. Keyboard input with IrKBD will only work when running X11 since the program feeds raw scancodes back into the kernel again. HOWTO USE: One way of using irkbd is to let gpm read the input from /dev/irkbd. The next line is taken from my /etc/rc.d/init.d/gpm startup script. gpm -R -t $MOUSETYPE -M -t ps2 -m /dev/irkbd As you can see, gpm will read both the internal and "external" mice. Gpm will feed its output to /dev/gpmdata which can be read by X. Remember that gpm will output its data in MouseSystems format: Section "Pointer" Protocol "MouseSystems" Device "/dev/gpmdata" BaudRate 1200 Emulate3Timeout 50 EndSection So now you should be able to use both your internal mouse and the external connected to the IrDA docking station. -- Dag