⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irnet.h

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* *	IrNET protocol module : Synchronous PPP over an IrDA socket. * *		Jean II - HPL `00 - <jt@hpl.hp.com> * * This file contains definitions and declarations global to the IrNET module, * all grouped in one place... * This file is a private header, so other modules don't want to know * what's in there... * * Note : as most part of the Linux kernel, this module is available * under the GNU Public License (GPL). */#ifndef IRNET_H#define IRNET_H/************************** DOCUMENTATION ***************************//* * What is IrNET * ------------- * IrNET is a protocol allowing to carry TCP/IP traffic between two * IrDA peers in an efficient fashion. It is a thin layer, passing PPP * packets to IrTTP and vice versa. It uses PPP in synchronous mode, * because IrTTP offer a reliable sequenced packet service (as opposed * to a byte stream). In fact, you could see IrNET as carrying TCP/IP * in a IrDA socket, using PPP to provide the glue. * * The main difference with traditional PPP over IrCOMM is that we * avoid the framing and serial emulation which are a performance * bottleneck. It also allows multipoint communications in a sensible * fashion. * * The main difference with IrLAN is that we use PPP for the link * management, which is more standard, interoperable and flexible than * the IrLAN protocol. For example, PPP adds authentication, * encryption, compression, header compression and automated routing * setup. And, as IrNET let PPP do the hard work, the implementation * is much simpler than IrLAN. * * The Linux implementation * ------------------------ * IrNET is written on top of the Linux-IrDA stack, and interface with * the generic Linux PPP driver. Because IrNET depend on recent * changes of the PPP driver interface, IrNET will work only with very * recent kernel (2.3.99-pre6 and up). *  * The present implementation offer the following features : *	o simple user interface using pppd *	o efficient implementation (interface directly to PPP and IrTTP) *	o addressing (you can specify the name of the IrNET recipient) *	o multipoint operation (limited by IrLAP specification) *	o information in /proc/net/irda/irnet *	o IrNET events on /dev/irnet (for user space daemon) *	o IrNET deamon (irnetd) to automatically handle incomming requests *	o Windows 2000 compatibility (tested, but need more work) * Currently missing : *	o Lot's of testing (that's your job) *	o Connection retries (may be too hard to do) *	o Check pppd persist mode *	o User space deamon (to automatically handle incomming requests) *	o A registered device number (comming, waiting from an answer)  *	o Final integration in Linux-IrDA (up to Dag)  * * The setup is not currently the most easy, but this should get much * better when everything will get integrated... * * Acknowledgements * ---------------- * This module is based on : *	o The PPP driver (ppp_synctty/ppp_generic) by Paul Mackerras *	o The IrLAN protocol (irlan_common/XXX) by Dag Brattli *	o The IrSock interface (af_irda) by Dag Brattli *	o Some other bits from the kernel and my drivers... * Infinite thanks to those brave souls for providing the infrastructure * upon which IrNET is built. * * Thanks to all my collegues in HP for helping me. In particular, * thanks to Salil Pradhan and Bill Serra for W2k testing... * Thanks to Luiz Magalhaes for irnetd and much testing... * * Thanks to Alan Cox for answering lot's of my stupid questions, and * to Paul Mackerras answering my questions on how to best integrate * IrNET and pppd. * * Jean II * * Note on some implementations choices... * ------------------------------------ *	1) Direct interface vs tty/socket * I could have used a tty interface to hook to ppp and use the full * socket API to connect to IrDA. The code would have been easier to * maintain, and maybe the code would have been smaller... * Instead, we hook directly to ppp_generic and to IrTTP, which make * things more complicated... * * The first reason is flexibility : this allow us to create IrNET * instances on demand (no /dev/ircommX crap) and to allow linkname * specification on pppd command line... * * Second reason is speed optimisation. If you look closely at the * transmit and receive paths, you will notice that they are "super lean" * (that's why they look ugly), with no function calls and as little data * copy and modification as I could... * *	2) irnetd in user space * irnetd is implemented in user space, which is necessary to call pppd. * This also give maximum benefits in term of flexibility and customability, * and allow to offer the event channel, useful for other stuff like debug. * * On the other hand, this require a loose coordination between the * present module and irnetd. One critical area is how incomming request * are handled. * When irnet receive an incomming request, it send an event to irnetd and * drop the incomming IrNET socket. * irnetd start a pppd instance, which create a new IrNET socket. This new * socket is then connected in the originating node to the pppd instance. * At this point, in the originating node, the first socket is closed. * * I admit, this is a bit messy and waste some ressources. The alternative * is caching incomming socket, and that's also quite messy and waste * ressources. * We also make connection time slower. For example, on a 115 kb/s link it * adds 60ms to the connection time (770 ms). However, this is slower than * the time it takes to fire up pppd on my P133... * * * History : * ------- * * v1 - 15/5/00 - Jean II *	o Basic IrNET (hook to ppp_generic & IrTTP - incl. multipoint) *	o control channel on /dev/irnet (set name/address) *	o event channel on /dev/irnet (for user space daemon) * * v2 - 5/6/00 - Jean II *	o Enable DROP_NOT_READY to avoid PPP timeouts & other weirdness... *	o Add DISCONNECT_TO event and rename DISCONNECT_FROM. *	o Set official device number alloaction on /dev/irnet * * v3 - 30/8/00 - Jean II *	o Update to latest Linux-IrDA changes : *		- queue_t => irda_queue_t *	o Update to ppp-2.4.0 : *		- move irda_irnet_connect from PPPIOCATTACH to TIOCSETD *	o Add EXPIRE event (depend on new IrDA-Linux patch) *	o Switch from `hashbin_remove' to `hashbin_remove_this' to fix *	  a multilink bug... (depend on new IrDA-Linux patch) *	o fix a self->daddr to self->raddr in irda_irnet_connect to fix *	  another multilink bug (darn !) *	o Remove LINKNAME_IOCTL cruft * * v3b - 31/8/00 - Jean II *	o Dump discovery log at event channel startup * * v4 - 28/9/00 - Jean II *	o Fix interaction between poll/select and dump discovery log *	o Add IRNET_BLOCKED_LINK event (depend on new IrDA-Linux patch) *	o Add IRNET_NOANSWER_FROM event (mostly to help support) *	o Release flow control in disconnect_indication *	o Block packets while connecting (speed up connections) *//***************************** INCLUDES *****************************/#include <linux/module.h>#include <linux/kernel.h>#include <linux/skbuff.h>#include <linux/tty.h>#include <linux/proc_fs.h>#include <linux/devfs_fs_kernel.h>#include <linux/netdevice.h>#include <linux/poll.h>#include <asm/uaccess.h>#include <linux/ppp_defs.h>#include <linux/if_ppp.h>#include <linux/ppp_channel.h>#include <net/irda/irda.h>#include <net/irda/iriap.h>#include <net/irda/irias_object.h>#include <net/irda/irlmp.h>#include <net/irda/irttp.h>#include <net/irda/discovery.h>/***************************** OPTIONS *****************************//* * Define or undefine to compile or not some optional part of the * IrNET driver... * Note : the present defaults make sense, play with that at your * own risk... *//* IrDA side of the business... */#define DISCOVERY_NOMASK	/* To enable W2k compatibility... */#define ADVERTISE_HINT		/* Advertise IrLAN hint bit */#define ALLOW_SIMULT_CONNECT	/* This seem to work, cross fingers... */#define DISCOVERY_EVENTS	/* Query the discovery log to post events */#define INITIAL_DISCOVERY	/* Dump current discovery log as events */#undef STREAM_COMPAT		/* Not needed - potentially messy */#undef CONNECT_INDIC_KICK	/* Might mess IrDA, not needed */#undef FAIL_SEND_DISCONNECT	/* Might mess IrDA, not needed */#undef PASS_CONNECT_PACKETS	/* Not needed ? Safe *//* PPP side of the business */#define BLOCK_WHEN_CONNECT	/* Block packets when connecting */#undef CONNECT_IN_SEND		/* Will crash hard your box... */#undef FLUSH_TO_PPP		/* Not sure about this one, let's play safe */#undef SECURE_DEVIRNET		/* Bah... *//****************************** DEBUG ******************************//* * This set of flags enable and disable all the various warning, * error and debug message of this driver. * Each section can be enabled and disabled independantly *//* In the PPP part */#define DEBUG_CTRL_TRACE	0	/* Control channel */#define DEBUG_CTRL_INFO		0	/* various info */#define DEBUG_CTRL_ERROR	1	/* problems */#define DEBUG_FS_TRACE		0	/* filesystem callbacks */#define DEBUG_FS_INFO		0	/* various info */#define DEBUG_FS_ERROR		1	/* problems */#define DEBUG_PPP_TRACE		0	/* PPP related functions */#define DEBUG_PPP_INFO		0	/* various info */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -