From: Andy P. <at...@us...> - 2002-04-09 16:27:04
|
Update of /cvsroot/linux-vax/kernel-2.4/net/irda/irnet In directory usw-pr-cvs1:/tmp/cvs-serv31773/irda/irnet Modified Files: Config.in irnet.h irnet_irda.c irnet_irda.h irnet_ppp.c irnet_ppp.h Log Message: synch 2.4.15 commit 20 Index: Config.in =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/Config.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Config.in 14 Jan 2001 17:16:43 -0000 1.1.1.1 +++ Config.in 9 Apr 2002 16:26:57 -0000 1.2 @@ -1 +1,4 @@ -dep_tristate ' IrNET protocol' CONFIG_IRNET $CONFIG_IRDA +if [ "$CONFIG_NETDEVICES" != "n" ]; then + dep_tristate ' IrNET protocol' CONFIG_IRNET $CONFIG_IRDA $CONFIG_PPP +fi + Index: irnet.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/irnet.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- irnet.h 14 Jan 2001 17:16:46 -0000 1.1.1.1 +++ irnet.h 9 Apr 2002 16:26:57 -0000 1.2 @@ -5,11 +5,11 @@ * * 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 + * 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). + * under the GNU General Public License (GPL). */ #ifndef IRNET_H @@ -52,15 +52,13 @@ * 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 IrNET daemon (irnetd) to automatically handle incoming 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) + * o User space daemon (to automatically handle incoming requests) * * The setup is not currently the most easy, but this should get much * better when everything will get integrated... @@ -109,16 +107,16 @@ * 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 + * present module and irnetd. One critical area is how incoming request * are handled. - * When irnet receive an incomming request, it send an event to irnetd and - * drop the incomming IrNET socket. + * When irnet receive an incoming request, it send an event to irnetd and + * drop the incoming 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 + * is caching incoming 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 @@ -128,17 +126,17 @@ * History : * ------- * - * v1 - 15/5/00 - Jean II + * 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 + * 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 + * 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 : @@ -150,15 +148,57 @@ * another multilink bug (darn !) * o Remove LINKNAME_IOCTL cruft * - * v3b - 31/8/00 - Jean II + * v3b - 31.8.00 - Jean II * o Dump discovery log at event channel startup * - * v4 - 28/9/00 - Jean II + * 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) + * + * v5 - 11.01.01 - Jean II + * o Init self->max_header_size, just in case... + * o Set up ap->chan.hdrlen, to get zero copy on tx side working. + * o avoid tx->ttp->flow->ppp->tx->... loop, by checking flow state + * Thanks to Christian Gennerat for finding this bug ! + * --- + * o Declare the proper MTU/MRU that we can support + * (but PPP doesn't read the MTU value :-() + * o Declare hashbin HB_NOLOCK instead of HB_LOCAL to avoid + * disabling and enabling irq twice + * + * v6 - 31.05.01 - Jean II + * o Print source address in Found, Discovery, Expiry & Request events + * o Print requested source address in /proc/net/irnet + * o Change control channel input. Allow multiple commands in one line. + * o Add saddr command to change ap->rsaddr (and use that in IrDA) + * --- + * o Make the IrDA connection procedure totally asynchronous. + * Heavy rewrite of the IAS query code and the whole connection + * procedure. Now, irnet_connect() no longer need to be called from + * a process context... + * o Enable IrDA connect retries in ppp_irnet_send(). The good thing + * is that IrDA connect retries are directly driven by PPP LCP + * retries (we retry for each LCP packet), so that everything + * is transparently controlled from pppd lcp-max-configure. + * o Add ttp_connect flag to prevent rentry on the connect procedure + * o Test and fixups to eliminate side effects of retries + * + * v7 - 22.08.01 - Jean II + * o Cleanup : Change "saddr = 0x0" to "saddr = DEV_ADDR_ANY" + * o Fix bug in BLOCK_WHEN_CONNECT introduced in v6 : due to the + * asynchronous IAS query, self->tsap is NULL when PPP send the + * first packet. This was preventing "connect-delay 0" to work. + * Change the test in ppp_irnet_send() to self->ttp_connect. + * + * v8 - 1.11.01 - Jean II + * o Tighten the use of self->ttp_connect and self->ttp_open to + * prevent various race conditions. + * o Avoid leaking discovery log and skb + * o Replace "self" with "server" in irnet_connect_indication() to + * better detect cut'n'paste error ;-) */ /***************************** INCLUDES *****************************/ @@ -171,7 +211,10 @@ #include <linux/proc_fs.h> #include <linux/devfs_fs_kernel.h> #include <linux/netdevice.h> +#include <linux/miscdevice.h> #include <linux/poll.h> +#include <linux/config.h> +#include <linux/ctype.h> /* isspace() */ #include <asm/uaccess.h> #include <linux/ppp_defs.h> @@ -205,7 +248,7 @@ /* PPP side of the business */ #define BLOCK_WHEN_CONNECT /* Block packets when connecting */ -#undef CONNECT_IN_SEND /* Will crash hard your box... */ +#define CONNECT_IN_SEND /* Retry IrDA connection procedure */ #undef FLUSH_TO_PPP /* Not sure about this one, let's play safe */ #undef SECURE_DEVIRNET /* Bah... */ @@ -240,9 +283,11 @@ #define DEBUG_IRDA_SERV_INFO 0 /* various info */ #define DEBUG_IRDA_SERV_ERROR 1 /* problems */ #define DEBUG_IRDA_TCB_TRACE 0 /* IRDA IrTTP callbacks */ -#define DEBUG_IRDA_OCB_TRACE 0 /* IRDA other callbacks */ #define DEBUG_IRDA_CB_INFO 0 /* various info */ #define DEBUG_IRDA_CB_ERROR 1 /* problems */ +#define DEBUG_IRDA_OCB_TRACE 0 /* IRDA other callbacks */ +#define DEBUG_IRDA_OCB_INFO 0 /* various info */ +#define DEBUG_IRDA_OCB_ERROR 1 /* problems */ #define DEBUG_ASSERT 0 /* Verify all assertions */ @@ -342,13 +387,15 @@ /* ------------------------ IrTTP part ------------------------ */ /* We create a pseudo "socket" over the IrDA tranport */ int ttp_open; /* Set when IrTTP is ready */ + int ttp_connect; /* Set when IrTTP is connecting */ struct tsap_cb * tsap; /* IrTTP instance (the connection) */ char rname[NICKNAME_MAX_LEN + 1]; /* IrDA nickname of destination */ - __u32 raddr; /* Requested peer IrDA address */ - __u32 saddr; /* my local IrDA address */ + __u32 rdaddr; /* Requested peer IrDA address */ + __u32 rsaddr; /* Requested local IrDA address */ __u32 daddr; /* actual peer IrDA address */ + __u32 saddr; /* my local IrDA address */ __u8 dtsap_sel; /* Remote TSAP selector */ __u8 stsap_sel; /* Local TSAP selector */ @@ -365,17 +412,14 @@ int nslots; /* Number of slots for discovery */ struct iriap_cb * iriap; /* Used to query remote IAS */ - wait_queue_head_t query_wait; /* Wait for the answer to a query */ - struct ias_value * ias_result; /* Result of remote IAS query */ int errno; /* status of the IAS query */ - /* ---------------------- Optional parts ---------------------- */ -#ifdef INITIAL_DISCOVERY - /* Stuff used to dump discovery log */ + /* -------------------- Discovery log part -------------------- */ + /* Used by initial discovery on the control channel + * and by irnet_discover_daddr_and_lsap_sel() */ struct irda_device_info *discoveries; /* Copy of the discovery log */ int disco_index; /* Last read in the discovery log */ int disco_number; /* Size of the discovery log */ -#endif INITIAL_DISCOVERY } irnet_socket; @@ -402,8 +446,9 @@ { irnet_event event; int unit; - __u32 addr; - char name[NICKNAME_MAX_LEN + 1]; + __u32 saddr; + __u32 daddr; + char name[NICKNAME_MAX_LEN + 1]; /* 21 + 1 */ } irnet_log; /* @@ -450,4 +495,4 @@ /* Control channel stuff - allocated in irnet_irda.h */ extern struct irnet_ctrl_channel irnet_events; -#endif IRNET_H +#endif /* IRNET_H */ Index: irnet_irda.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/irnet_irda.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- irnet_irda.c 14 Jan 2001 17:16:52 -0000 1.1.1.1 +++ irnet_irda.c 9 Apr 2002 16:26:57 -0000 1.2 @@ -8,7 +8,6 @@ * and exchange frames with IrTTP. */ -#include <linux/config.h> #include "irnet_irda.h" /* Private header */ /************************* CONTROL CHANNEL *************************/ @@ -27,14 +26,15 @@ static void irnet_post_event(irnet_socket * ap, irnet_event event, [...1272 lines suppressed...] len += sprintf(buf+len, "daddr: %08x, ", self->daddr); len += sprintf(buf+len, "stsap_sel: %02x, ", self->stsap_sel); @@ -1426,7 +1765,7 @@ memset(&irnet_server, 0, sizeof(struct irnet_root)); /* Setup start of irnet instance list */ - irnet_server.list = hashbin_new(HB_LOCAL); + irnet_server.list = hashbin_new(HB_NOLOCK); DABORT(irnet_server.list == NULL, -ENOMEM, MODULE_ERROR, "Can't allocate hashbin!\n"); /* Init spinlock for instance list */ @@ -1469,7 +1808,7 @@ #ifdef CONFIG_PROC_FS /* Remove our /proc file */ remove_proc_entry("irnet", proc_irda); -#endif CONFIG_PROC_FS +#endif /* CONFIG_PROC_FS */ /* Remove our IrNET server from existence */ irnet_destroy_server(); Index: irnet_irda.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/irnet_irda.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- irnet_irda.h 14 Jan 2001 17:16:53 -0000 1.1.1.1 +++ irnet_irda.h 9 Apr 2002 16:26:57 -0000 1.2 @@ -13,8 +13,8 @@ #define IRNET_IRDA_H /***************************** INCLUDES *****************************/ +/* Please add other headers in irnet.h */ -#include <linux/config.h> #include "irnet.h" /* Module global include */ /************************ CONSTANTS & MACROS ************************/ @@ -68,13 +68,22 @@ irnet_post_event(irnet_socket *, irnet_event, __u32, + __u32, char *); /* ----------------------- IRDA SUBROUTINES ----------------------- */ static inline int irnet_open_tsap(irnet_socket *); -static int +static inline __u8 + irnet_ias_to_tsap(irnet_socket *, + int, + struct ias_value *); +static inline int irnet_find_lsap_sel(irnet_socket *); static inline int + irnet_connect_tsap(irnet_socket *); +static inline int + irnet_discover_next_daddr(irnet_socket *); +static inline int irnet_discover_daddr_and_lsap_sel(irnet_socket *); static inline int irnet_dname_to_daddr(irnet_socket *); @@ -134,6 +143,11 @@ __u16, struct ias_value *, void *); +static void + irnet_discovervalue_confirm(int, + __u16, + struct ias_value *, + void *); #ifdef DISCOVERY_EVENTS static void irnet_discovery_indication(discovery_t *, @@ -149,7 +163,7 @@ char **, off_t, int); -#endif CONFIG_PROC_FS +#endif /* CONFIG_PROC_FS */ /**************************** VARIABLES ****************************/ @@ -164,6 +178,6 @@ /* The /proc/net/irda directory, defined elsewhere... */ #ifdef CONFIG_PROC_FS extern struct proc_dir_entry *proc_irda; -#endif CONFIG_PROC_FS +#endif /* CONFIG_PROC_FS */ -#endif IRNET_IRDA_H +#endif /* IRNET_IRDA_H */ Index: irnet_ppp.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/irnet_ppp.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- irnet_ppp.c 14 Jan 2001 17:16:56 -0000 1.1.1.1 +++ irnet_ppp.c 9 Apr 2002 16:26:57 -0000 1.2 @@ -14,6 +14,7 @@ */ #include "irnet_ppp.h" /* Private header */ +/* Please put other headers in irnet.h - Thanks */ /************************* CONTROL CHANNEL *************************/ /* @@ -37,13 +38,15 @@ const char * buf, size_t count) { - char command[5 + NICKNAME_MAX_LEN + 2]; - int length = count; + char command[IRNET_MAX_COMMAND]; + char * start; /* Current command beeing processed */ + char * next; /* Next command to process */ + int length; /* Length of current command */ DENTER(CTRL_TRACE, "(ap=0x%X, count=%d)\n", (unsigned int) ap, count); /* Check for overflow... */ - DABORT(count > (5 + NICKNAME_MAX_LEN + 1), -ENOMEM, + DABORT(count >= IRNET_MAX_COMMAND, -ENOMEM, CTRL_ERROR, "Too much data !!!\n"); /* Get the data in the driver */ @@ -53,58 +56,110 @@ return -EFAULT; } - /* Strip out '\n' if needed, and safe terminate the string */ - if(command[length - 1] == '\0') - length--; - if(command[length - 1] == '\n') - length--; - command[length] = '\0'; - DEBUG(CTRL_INFO, "Command received is ``%s'' (%d-%d).\n", - command, length, count); - - /* Check if we recognised the command */ - /* First command : name */ - if(!strncmp(command, "name", 4)) + /* Safe terminate the string */ + command[count] = '\0'; + DEBUG(CTRL_INFO, "Command line received is ``%s'' (%d).\n", + command, count); + + /* Check every commands in the command line */ + next = command; + while(next != NULL) { - /* Copy the name only if is included and not "any" */ - if((length > 5) && (strcmp(command + 5, "any"))) + /* Look at the next command */ + start = next; + + /* Scrap whitespaces before the command */ + while(isspace(*start)) + start++; + + /* ',' is our command separator */ + next = strchr(start, ','); + if(next) { - /* Copy the name for later reuse (including the '/0') */ - memcpy(ap->rname, command + 5, length - 5 + 1); + *next = '\0'; /* Terminate command */ + length = next - start; /* Length */ + next++; /* Skip the '\0' */ } else - ap->rname[0] = '\0'; - DEXIT(CTRL_TRACE, " - rname = ``%s''\n", ap->rname); - return(count); - } + length = strlen(start); - /* Second command : addr */ - if(!strncmp(command, "addr", 4)) - { - /* Copy the address only if is included and not "any" */ - if((length > 5) && (strcmp(command + 5, "any"))) + DEBUG(CTRL_INFO, "Found command ``%s'' (%d).\n", start, length); + + /* Check if we recognised one of the known command + * We can't use "switch" with strings, so hack with "continue" */ + + /* First command : name -> Requested IrDA nickname */ + if(!strncmp(start, "name", 4)) { - char * endp; - __u32 daddr; + /* Copy the name only if is included and not "any" */ + if((length > 5) && (strcmp(start + 5, "any"))) + { + /* Strip out trailing whitespaces */ + while(isspace(start[length - 1])) + length--; + + /* Copy the name for later reuse */ + memcpy(ap->rname, start + 5, length - 5); + ap->rname[length - 5] = '\0'; + } + else + ap->rname[0] = '\0'; + DEBUG(CTRL_INFO, "Got rname = ``%s''\n", ap->rname); - /* Convert argument to a number (last arg is the base) */ - daddr = simple_strtoul(command + 5, &endp, 16); - /* Has it worked ? (endp should be command + count) */ - DABORT(endp <= (command + 5), -EINVAL, - CTRL_ERROR, "Invalid address.\n"); - /* Save it */ - ap->raddr = daddr; + /* Restart the loop */ + continue; } - else - ap->raddr = DEV_ADDR_ANY; - DEXIT(CTRL_TRACE, " - raddr = %08x\n", ap->raddr); - return(count); - } - /* Other possible command : connect N (number of retries) */ + /* Second command : addr, daddr -> Requested IrDA destination address + * Also process : saddr -> Requested IrDA source address */ + if((!strncmp(start, "addr", 4)) || + (!strncmp(start, "daddr", 5)) || + (!strncmp(start, "saddr", 5))) + { + __u32 addr = DEV_ADDR_ANY; + + /* Copy the address only if is included and not "any" */ + if((length > 5) && (strcmp(start + 5, "any"))) + { + char * begp = start + 5; + char * endp; - /* Failed... */ - DABORT(1, -EINVAL, CTRL_ERROR, "Not a recognised IrNET command.\n"); + /* Scrap whitespaces before the command */ + while(isspace(*begp)) + begp++; + + /* Convert argument to a number (last arg is the base) */ + addr = simple_strtoul(begp, &endp, 16); + /* Has it worked ? (endp should be start + length) */ + DABORT(endp <= (start + 5), -EINVAL, + CTRL_ERROR, "Invalid address.\n"); + } + /* Which type of address ? */ + if(start[0] == 's') + { + /* Save it */ + ap->rsaddr = addr; + DEBUG(CTRL_INFO, "Got rsaddr = %08x\n", ap->rsaddr); + } + else + { + /* Save it */ + ap->rdaddr = addr; + DEBUG(CTRL_INFO, "Got rdaddr = %08x\n", ap->rdaddr); + } + + /* Restart the loop */ + continue; + } + + /* Other possible command : connect N (number of retries) */ + + /* No command matched -> Failed... */ + DABORT(1, -EINVAL, CTRL_ERROR, "Not a recognised IrNET command.\n"); + } + + /* Success : we have parsed all commands successfully */ + return(count); } #ifdef INITIAL_DISCOVERY @@ -145,7 +200,8 @@ __u16 mask = irlmp_service_to_hint(S_LAN); /* Ask IrLMP for the current discovery log */ - ap->discoveries = irlmp_get_discoveries(&ap->disco_number, mask); + ap->discoveries = irlmp_get_discoveries(&ap->disco_number, mask, + DISCOVERY_DEFAULT_SLOTS); /* Check if the we got some results */ if(ap->discoveries == NULL) ap->disco_number = -1; @@ -157,9 +213,10 @@ if(ap->disco_index < ap->disco_number) { /* Write an event */ - sprintf(event, "Found %08x (%s)\n", + sprintf(event, "Found %08x (%s) behind %08x\n", ap->discoveries[ap->disco_index].daddr, - ap->discoveries[ap->disco_index].info); + ap->discoveries[ap->disco_index].info, + ap->discoveries[ap->disco_index].saddr); DEBUG(CTRL_INFO, "Writing discovery %d : %s\n", ap->disco_index, ap->discoveries[ap->disco_index].info); @@ -186,7 +243,7 @@ return done_event; } -#endif INITIAL_DISCOVERY +#endif /* INITIAL_DISCOVERY */ /*------------------------------------------------------------------*/ /* @@ -221,7 +278,7 @@ DEXIT(CTRL_TRACE, "\n"); return(strlen(event)); } -#endif INITIAL_DISCOVERY +#endif /* INITIAL_DISCOVERY */ /* Put ourselves on the wait queue to be woken up */ add_wait_queue(&irnet_events.rwait, &wait); @@ -256,53 +313,56 @@ switch(irnet_events.log[ap->event_index].event) { case IRNET_DISCOVER: - sprintf(event, "Discovered %08x (%s)\n", - irnet_events.log[ap->event_index].addr, - irnet_events.log[ap->event_index].name); + sprintf(event, "Discovered %08x (%s) behind %08x\n", + irnet_events.log[ap->event_index].daddr, + irnet_events.log[ap->event_index].name, + irnet_events.log[ap->event_index].saddr); break; case IRNET_EXPIRE: - sprintf(event, "Expired %08x (%s)\n", - irnet_events.log[ap->event_index].addr, - irnet_events.log[ap->event_index].name); + sprintf(event, "Expired %08x (%s) behind %08x\n", + irnet_events.log[ap->event_index].daddr, + irnet_events.log[ap->event_index].name, + irnet_events.log[ap->event_index].saddr); break; case IRNET_CONNECT_TO: sprintf(event, "Connected to %08x (%s) on ppp%d\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, irnet_events.log[ap->event_index].unit); break; case IRNET_CONNECT_FROM: sprintf(event, "Connection from %08x (%s) on ppp%d\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, irnet_events.log[ap->event_index].unit); break; case IRNET_REQUEST_FROM: - sprintf(event, "Request from %08x (%s)\n", - irnet_events.log[ap->event_index].addr, - irnet_events.log[ap->event_index].name); + sprintf(event, "Request from %08x (%s) behind %08x\n", + irnet_events.log[ap->event_index].daddr, + irnet_events.log[ap->event_index].name, + irnet_events.log[ap->event_index].saddr); break; case IRNET_NOANSWER_FROM: sprintf(event, "No-answer from %08x (%s) on ppp%d\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, irnet_events.log[ap->event_index].unit); break; case IRNET_BLOCKED_LINK: sprintf(event, "Blocked link with %08x (%s) on ppp%d\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, irnet_events.log[ap->event_index].unit); break; case IRNET_DISCONNECT_FROM: sprintf(event, "Disconnection from %08x (%s) on ppp%d\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, irnet_events.log[ap->event_index].unit); break; case IRNET_DISCONNECT_TO: sprintf(event, "Disconnected to %08x (%s)\n", - irnet_events.log[ap->event_index].addr, + irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name); break; default: @@ -346,7 +406,7 @@ #ifdef INITIAL_DISCOVERY if(ap->disco_number != -1) mask |= POLLIN | POLLRDNORM; -#endif INITIAL_DISCOVERY +#endif /* INITIAL_DISCOVERY */ DEXIT(CTRL_TRACE, " - mask=0x%X\n", mask); return mask; @@ -379,7 +439,7 @@ /* This could (should?) be enforced by the permissions on /dev/irnet. */ if(!capable(CAP_NET_ADMIN)) return -EPERM; -#endif SECURE_DEVIRNET +#endif /* SECURE_DEVIRNET */ /* Allocate a private structure for this IrNET instance */ ap = kmalloc(sizeof(*ap), GFP_KERNEL); @@ -394,8 +454,11 @@ /* PPP channel setup */ ap->ppp_open = 0; ap->chan.private = ap; + ap->chan.ops = &irnet_ppp_ops; + ap->chan.mtu = (2048 - TTP_MAX_HEADER - 2 - PPP_HDRLEN); + ap->chan.hdrlen = 2 + TTP_MAX_HEADER; /* for A/C + Max IrDA hdr */ /* PPP parameters */ - ap->mru = PPP_MRU; + ap->mru = (2048 - TTP_MAX_HEADER - 2 - PPP_HDRLEN); ap->xaccm[0] = ~0U; ap->xaccm[3] = 0x60000000U; ap->raccm = ~0U; @@ -476,7 +539,7 @@ /* If we are connected to ppp_generic, let it handle the job */ if(ap->ppp_open) - return ppp_channel_write(&ap->chan, buf, count); + return -EAGAIN; else return irnet_ctrl_write(ap, buf, count); } @@ -500,7 +563,7 @@ /* If we are connected to ppp_generic, let it handle the job */ if(ap->ppp_open) - return ppp_channel_read(&ap->chan, file, buf, count); + return -EAGAIN; else return irnet_ctrl_read(ap, file, buf, count); } @@ -523,9 +586,7 @@ DABORT(ap == NULL, mask, FS_ERROR, "ap is NULL !!!\n"); /* If we are connected to ppp_generic, let it handle the job */ - if(ap->ppp_open) - mask |= ppp_channel_poll(&ap->chan, file, wait); - else + if(!ap->ppp_open) mask |= irnet_ctrl_poll(ap, file, wait); DEXIT(FS_TRACE, " - mask=0x%X\n", mask); @@ -556,7 +617,7 @@ #ifdef SECURE_DEVIRNET if(!capable(CAP_NET_ADMIN)) return -EPERM; -#endif SECURE_DEVIRNET +#endif /* SECURE_DEVIRNET */ err = -EFAULT; switch(cmd) @@ -568,10 +629,7 @@ if((val == N_SYNC_PPP) || (val == N_PPP)) { DEBUG(FS_INFO, "Entering PPP discipline.\n"); - /* PPP channel setup */ - ap->chan.private = ap; - ap->chan.ops = &irnet_ppp_ops; - ap->chan.mtu = PPP_MRU; + /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ err = ppp_register_channel(&ap->chan); if(err == 0) { @@ -599,15 +657,6 @@ } break; - /* Attach this PPP instance to the PPP driver (set it active) */ - case PPPIOCATTACH: - case PPPIOCDETACH: - if(ap->ppp_open) - err = ppp_channel_ioctl(&ap->chan, cmd, arg); - else - DERROR(FS_ERROR, "Channel not registered !\n"); - break; - /* Query PPP channel and unit number */ case PPPIOCGCHAN: if(!ap->ppp_open) @@ -683,7 +732,7 @@ * we get rid of our own buffers */ #ifdef FLUSH_TO_PPP ppp_output_wakeup(&ap->chan); -#endif FLUSH_TO_PPP +#endif /* FLUSH_TO_PPP */ err = 0; break; @@ -769,7 +818,7 @@ /* prepend address/control fields if necessary */ if(needaddr) { - skb_push(skb,2); + skb_push(skb, 2); skb->data[0] = PPP_ALLSTATIONS; skb->data[1] = PPP_UI; } @@ -801,20 +850,18 @@ DASSERT(self != NULL, 0, PPP_ERROR, "Self is NULL !!!\n"); /* Check if we are connected */ - if(self->ttp_open == 0) + if(!(test_bit(0, &self->ttp_open))) { #ifdef CONNECT_IN_SEND /* Let's try to connect one more time... */ - /* Note : we won't connect fully yet, but we should be ready for - * next packet... */ - /* Note : we can't do that, we need to have a process context to - * go through interruptible_sleep_on() in irnet_find_lsap_sel() - * We need to find another way... */ + /* Note : we won't be connected after this call, but we should be + * ready for next packet... */ + /* If we are already connecting, this will fail */ irda_irnet_connect(self); -#endif CONNECT_IN_SEND +#endif /* CONNECT_IN_SEND */ - DEBUG(PPP_INFO, "IrTTP not ready ! (%d-0x%X)\n", - self->ttp_open, (unsigned int) self->tsap); + DEBUG(PPP_INFO, "IrTTP not ready ! (%d-%d)\n", + self->ttp_open, self->ttp_connect); /* Note : we can either drop the packet or block the packet. * @@ -837,12 +884,12 @@ */ #ifdef BLOCK_WHEN_CONNECT /* If we are attempting to connect */ - if(self->tsap) + if(test_bit(0, &self->ttp_connect)) { /* Blocking packet, ppp_generic will retry later */ return 0; } -#endif BLOCK_WHEN_CONNECT +#endif /* BLOCK_WHEN_CONNECT */ /* Dropping packet, pppd will retry later */ dev_kfree_skb(skb); @@ -1050,3 +1097,4 @@ return ppp_irnet_cleanup(); } #endif /* MODULE */ +MODULE_LICENSE("GPL"); Index: irnet_ppp.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/net/irda/irnet/irnet_ppp.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- irnet_ppp.h 14 Jan 2001 17:16:57 -0000 1.1.1.1 +++ irnet_ppp.h 9 Apr 2002 16:26:57 -0000 1.2 @@ -22,13 +22,8 @@ #define IRNET_MAJOR 10 /* Misc range */ #define IRNET_MINOR 187 /* Official allocation */ -#ifdef LINKNAME_IOCTL -/* Compatibility with old ppp drivers - * Should be defined in <linux/if_ppp.h> */ -#ifndef PPPIOCSLINKNAME -#define PPPIOCSLINKNAME _IOW('t', 74, struct ppp_option_data) -#endif PPPIOCSLINKNAME -#endif LINKNAME_IOCTL +/* IrNET control channel stuff */ +#define IRNET_MAX_COMMAND 256 /* Max length of a command line */ /* PPP hardcore stuff */ @@ -127,4 +122,4 @@ ppp_irnet_ioctl }; -#endif IRNET_PPP_H +#endif /* IRNET_PPP_H */ |