diff options
Diffstat (limited to 'include/net')
52 files changed, 1230 insertions, 1162 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 44fb44d2c..d711d0d51 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -53,8 +53,9 @@ extern int addrconf_set_dstaddr(void *arg); extern struct inet6_ifaddr * ipv6_chk_addr(struct in6_addr *addr, struct device *dev, int nd); -extern struct inet6_ifaddr * ipv6_get_saddr(struct dst_entry *dst, - struct in6_addr *daddr); +extern int ipv6_get_saddr(struct dst_entry *dst, + struct in6_addr *daddr, + struct in6_addr *saddr); extern struct inet6_ifaddr * ipv6_get_lladdr(struct device *dev); /* diff --git a/include/net/br.h b/include/net/br.h index c0b69e54a..1210b4e3e 100644 --- a/include/net/br.h +++ b/include/net/br.h @@ -258,6 +258,7 @@ struct br_stat { #define BR_UP 0x0001 /* bridging enabled */ #define BR_DEBUG 0x0002 /* debugging enabled */ #define BR_PROT_STATS 0x0004 /* protocol statistics enabled */ +#define BR_STP_DISABLED 0x0008 /* Spanning tree protocol disabled */ struct br_cf { unsigned int cmd; @@ -281,6 +282,7 @@ struct br_cf { #define BRCMD_ENABLE_PROT_STATS 13 #define BRCMD_DISABLE_PROT_STATS 14 #define BRCMD_ZERO_PROT_STATS 15 +#define BRCMD_TOGGLE_STP 16 /* prototypes of exported bridging functions... */ @@ -295,7 +297,7 @@ struct fdb *br_avl_find_addr(unsigned char addr[6]); struct fdb *br_avl_insert (struct fdb * new_node); void sprintf_avl (char **pbuffer, struct fdb * tree, off_t *pos,int* len, off_t offset, int length); int br_tree_get_info(char *buffer, char **start, off_t offset, int length, int dummy); - +void br_avl_delete_by_port(int port); /* externs */ extern struct br_stat br_stats; diff --git a/include/net/dst.h b/include/net/dst.h index 50b3373dd..baf4f414d 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -16,11 +16,7 @@ * 1 - rare events and bugs (default) * 2 - trace mode. */ -#ifdef NO_ANK_FIX #define RT_CACHE_DEBUG 0 -#else -#define RT_CACHE_DEBUG 1 -#endif #define DST_GC_MIN (1*HZ) #define DST_GC_INC (5*HZ) @@ -36,9 +32,10 @@ struct dst_entry struct device *dev; int obsolete; unsigned long lastuse; + unsigned long expires; unsigned mxlock; - unsigned window; unsigned pmtu; + unsigned window; unsigned rtt; unsigned long rate_last; /* rate limiting for ICMP */ unsigned long rate_tokens; @@ -98,6 +95,19 @@ void dst_release(struct dst_entry * dst) atomic_dec(&dst->use); } +/* The following primitive should be use if and only if + destination entry has just been removed from a location + accessed directly by hard irq. + */ +extern __inline__ +void dst_release_irqwait(struct dst_entry * dst) +{ + if (dst) { + synchronize_irq(); + atomic_dec(&dst->use); + } +} + extern __inline__ struct dst_entry * dst_check(struct dst_entry ** dst_p, u32 cookie) { @@ -152,6 +162,17 @@ extern __inline__ void dst_link_failure(struct sk_buff *skb) if (dst && dst->ops && dst->ops->link_failure) dst->ops->link_failure(skb); } + +extern __inline__ void dst_set_expires(struct dst_entry *dst, int timeout) +{ + unsigned long expires = jiffies + timeout; + + if (expires == 0) + expires = 1; + + if (dst->expires == 0 || (long)(dst->expires - expires) > 0) + dst->expires = expires; +} #endif #endif /* _NET_DST_H */ diff --git a/include/net/flow.h b/include/net/flow.h index 45d232fb9..e1ce1b2ae 100644 --- a/include/net/flow.h +++ b/include/net/flow.h @@ -19,10 +19,12 @@ struct flowi { struct { struct in6_addr * daddr; struct in6_addr * saddr; + __u32 flowlabel; } ip6_u; } nl_u; #define fl6_dst nl_u.ip6_u.daddr #define fl6_src nl_u.ip6_u.saddr +#define fl6_flowlabel nl_u.ip6_u.flowlabel #define fl4_dst nl_u.ip4_u.daddr #define fl4_src nl_u.ip4_u.saddr diff --git a/include/net/ip.h b/include/net/ip.h index 52686031e..5e80fb438 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -147,13 +147,14 @@ extern __inline__ int ip_finish_output(struct sk_buff *skb) skb->protocol = __constant_htons(ETH_P_IP); if (hh) { + read_lock_irq(&hh->hh_lock); memcpy(skb->data - 16, hh->hh_data, 16); + read_unlock_irq(&hh->hh_lock); skb_push(skb, dev->hard_header_len); return hh->hh_output(skb); } else if (dst->neighbour) return dst->neighbour->output(skb); - printk(KERN_DEBUG "khm\n"); kfree_skb(skb); return -EINVAL; } diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 905876d00..efd652f28 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h @@ -59,6 +59,7 @@ struct rt6_info #define rt6i_dev u.dst.dev #define rt6i_nexthop u.dst.neighbour +#define rt6i_expires u.dst.expires struct fib6_node *rt6i_node; @@ -67,7 +68,6 @@ struct rt6_info u32 rt6i_flags; u32 rt6i_metric; u8 rt6i_hoplimit; - unsigned long rt6i_expires; atomic_t rt6i_ref; union { diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 5c8d6bf8e..6e1fd8690 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -127,6 +127,8 @@ struct fib_table int (*tb_flush)(struct fib_table *table); int (*tb_get_info)(struct fib_table *table, char *buf, int first, int count); + void (*tb_select_default)(struct fib_table *table, + const struct rt_key *key, struct fib_result *res); unsigned char tb_data[0]; }; @@ -156,6 +158,12 @@ extern __inline__ int fib_lookup(const struct rt_key *key, struct fib_result *re return 0; } +extern __inline__ void fib_select_default(const struct rt_key *key, struct fib_result *res) +{ + if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) + main_table->tb_select_default(main_table, key, res); +} + #else /* CONFIG_IP_MULTIPLE_TABLES */ #define local_table (fib_tables[RT_TABLE_LOCAL]) #define main_table (fib_tables[RT_TABLE_MAIN]) @@ -179,6 +187,9 @@ extern __inline__ struct fib_table *fib_new_table(int id) return fib_tables[id] ? : __fib_new_table(id); } + +extern void fib_select_default(const struct rt_key *key, struct fib_result *res); + #endif /* CONFIG_IP_MULTIPLE_TABLES */ /* Exported by fib_frontend.c */ @@ -189,7 +200,7 @@ extern int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *ar extern int inet_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); extern int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb); extern int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, - struct device *dev, u32 *spec_dst); + struct device *dev, u32 *spec_dst, u32 *itag); extern void fib_select_multipath(const struct rt_key *key, struct fib_result *res); /* Exported by fib_semantics.c */ @@ -227,4 +238,20 @@ extern u32 fib_rules_policy(u32 saddr, struct fib_result *res, unsigned *flags); extern void fib_rules_init(void); #endif +extern __inline__ void fib_combine_itag(u32 *itag, struct fib_result *res) +{ +#ifdef CONFIG_NET_CLS_ROUTE +#ifdef CONFIG_IP_MULTIPLE_TABLES + u32 rtag; +#endif + *itag = FIB_RES_NH(*res).nh_tclassid<<16; +#ifdef CONFIG_IP_MULTIPLE_TABLES + rtag = fib_rules_tclass(res); + if (*itag == 0) + *itag = (rtag<<16); + *itag |= (rtag>>16); +#endif +#endif +} + #endif _NET_FIB_H diff --git a/include/net/ip_masq.h b/include/net/ip_masq.h index 70b627305..9c8e9bf94 100644 --- a/include/net/ip_masq.h +++ b/include/net/ip_masq.h @@ -126,6 +126,7 @@ extern int ip_masq_init(void); */ extern int ip_fw_masquerade(struct sk_buff **, __u32 maddr); extern int ip_fw_masq_icmp(struct sk_buff **, __u32 maddr); +extern int ip_fw_unmasq_icmp(struct sk_buff *); extern int ip_fw_demasquerade(struct sk_buff **); /* diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 118eec2e9..50e2299fb 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -4,7 +4,7 @@ * Authors: * Pedro Roque <roque@di.fc.ul.pt> * - * $Id: ipv6.h,v 1.14 1998/10/03 09:36:45 davem Exp $ + * $Id: ipv6.h,v 1.16 1999/04/22 10:07:27 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -124,6 +124,43 @@ struct ipv6_txoptions /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */ }; +struct ip6_flowlabel +{ + struct ip6_flowlabel *next; + u32 label; + struct in6_addr dst; + struct ipv6_txoptions *opt; + atomic_t users; + u32 linger; + u8 share; + u32 owner; + unsigned long lastuse; + unsigned long expires; +}; + +#define IPV6_FLOWINFO_MASK __constant_htonl(0x0FFFFFFF) +#define IPV6_FLOWLABEL_MASK __constant_htonl(0x000FFFFF) + +struct ipv6_fl_socklist +{ + struct ipv6_fl_socklist *next; + struct ip6_flowlabel *fl; +}; + +extern struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, u32 label); +extern struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, + struct ip6_flowlabel * fl, + struct ipv6_txoptions * fopt); +extern void fl6_free_socklist(struct sock *sk); +extern int ipv6_flowlabel_opt(struct sock *sk, char *optval, int optlen); +extern void ip6_flowlabel_init(void); +extern void ip6_flowlabel_cleanup(void); + +extern __inline__ void fl6_sock_release(struct ip6_flowlabel *fl) +{ + if (fl) + atomic_dec(&fl->users); +} extern int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *)); @@ -186,14 +223,6 @@ extern __inline__ int ipv6_addr_any(struct in6_addr *a) a->s6_addr32[2] | a->s6_addr32[3] ) == 0); } -extern __inline__ int gfp_any(void) -{ - int pri = GFP_KERNEL; - if (in_interrupt()) - pri = GFP_ATOMIC; - return pri; -} - /* * Prototypes exported by ipv6 */ diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h new file mode 100644 index 000000000..15e254b33 --- /dev/null +++ b/include/net/irda/discovery.h @@ -0,0 +1,66 @@ +/********************************************************************* + * + * Filename: discovery.h + * Version: + * Description: + * Status: Experimental. + * Author: Dag Brattli <dagb@cs.uit.no> + * Created at: Tue Apr 6 16:53:53 1999 + * Modified at: Thu Apr 22 11:04:56 1999 + * Modified by: Dag Brattli <dagb@cs.uit.no> + * + * 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 DISCOVERY_H +#define DISCOVERY_H + +#include <asm/param.h> + +#include <net/irda/irda.h> +#include <net/irda/irqueue.h> + +#define DISCOVERY_EXPIRE_TIMEOUT 6*HZ +#define DISCOVERY_DEFAULT_SLOTS 0 + +/* + * The DISCOVERY structure is used for both discovery requests and responses + */ +typedef struct { + QUEUE queue; /* Must be first! */ + + __u32 saddr; /* Which link the device was discovered */ + __u32 daddr; /* Remote device address */ + LAP_REASON condition; /* More info about the discovery */ + + __u16_host_order hints; /* Discovery hint bits */ + __u8 charset; + char info[32]; /* Usually the name of the device */ + __u8 info_len; /* Length of device info field */ + + int gen_addr_bit; /* Need to generate a new device address? */ + int nslots; /* Number of slots to use when discovering */ + int timestamp; /* Time discovered */ +} discovery_t; + +void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *discovery); +void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log); +void irlmp_expire_discoveries(hashbin_t *log, int saddr, int force); + +#endif diff --git a/include/net/irda/dongle.h b/include/net/irda/dongle.h index 8498f4176..d8983c009 100644 --- a/include/net/irda/dongle.h +++ b/include/net/irda/dongle.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Wed Oct 21 22:47:12 1998 - * Modified at: Mon Dec 14 11:47:25 1998 + * Modified at: Sat Feb 6 07:37:49 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -34,6 +34,7 @@ typedef enum { ESI_DONGLE, ACTISYS_DONGLE, ACTISYS_PLUS_DONGLE, + GIRBIL_DONGLE, } DONGLE_T; struct dongle { diff --git a/include/net/irda/ircomm_common.h b/include/net/irda/ircomm_common.h index a092d9808..cd1c41f86 100644 --- a/include/net/irda/ircomm_common.h +++ b/include/net/irda/ircomm_common.h @@ -19,14 +19,21 @@ * ********************************************************************/ +#ifndef IRCOMM_H +#define IRCOMM_H + /* #define DEBUG(n, args...) printk( KERN_DEBUG args) */ /* enable all debug message */ #include <linux/types.h> #include <net/irda/irmod.h> typedef enum { - COMM_DISCOVERY, COMM_IDLE, + + COMM_DISCOVERY_WAIT, + COMM_QUERYPARAM_WAIT, + COMM_QUERYLSAP_WAIT, + COMM_WAITI, COMM_WAITR, COMM_CONN, @@ -50,18 +57,31 @@ typedef enum { IRCOMM_DATA_REQUEST, LMP_DATA_INDICATION, IRCOMM_CONTROL_REQUEST, + + DISCOVERY_INDICATION, + GOT_PARAMETERS, + GOT_LSAPSEL, + QUERYIAS_ERROR, + } IRCOMM_EVENT; +typedef enum { + TX_READY, + TX_BUSY, + + IAS_PARAM, + CONTROL_CHANNEL, +} IRCOMM_CMD; + + #define IRCOMM_MAGIC 0x434f4d4d #define COMM_INIT_CTRL_PARAM 3 /* length of initial control parameters */ -#define COMM_CTRL_MIN 1 /* length of clen field */ -#define COMM_HEADER_SIZE (LAP_HEADER+LMP_HEADER+TTP_HEADER+COMM_CTRL_MIN) +#define COMM_HEADER 1 /* length of clen field */ +#define COMM_HEADER_SIZE (LAP_HEADER+LMP_HEADER+TTP_HEADER+COMM_HEADER) #define COMM_DEFAULT_DATA_SIZE 64 -#define IRCOMM_MAX_CONNECTION 1 /* Don't change */ +#define IRCOMM_MAX_CONNECTION 1 /* Don't change for now */ -#define IAS_PARAM 1 -#define CONTROL_CHANNEL 2 @@ -78,7 +98,7 @@ typedef enum { #define SERVICETYPE 0x00 -#define PORT_TYPE 0x02 +#define PORT_TYPE 0x01 #define PORT_NAME 0x02 #define FIXED_PORT_NAME 0x82 @@ -101,10 +121,6 @@ typedef enum { #define IEEE1284_MODE 0x34 #define IEEE1284_ECP_EPP_DATA_TRANSFER 0x35 -#define TX_READY 0xFE /* FIXME: this is not defined in IrCOMM spec */ -#define TX_BUSY 0XFF /* so we should find another way */ - - /* parameters of FLOW_CONTROL */ #define USE_RTS 0x08 /* use RTS on output */ @@ -131,6 +147,20 @@ typedef enum { /* parameters of DATA_FORMAT */ +#define IRCOMM_WLEN5 0x00 /* word length is 5bit */ +#define IRCOMM_WLEN6 0x01 /* word length is 6bit */ +#define IRCOMM_WLEN7 0x02 /* word length is 7bit */ +#define IRCOMM_WLEN8 0x03 /* word length is 8bit */ + +#define IRCOMM_STOP2 0x04 /* 2 stop bits mode */ +#define IRCOMM_PARENB 0x08 /* parity enable */ +#define IRCOMM_PARODD 0x00 /* odd parity */ +#define IRCOMM_PAREVEN 0x10 /* even parity */ +#define IRCOMM_PARMARK 0x20 +#define IRCOMM_PARSPC 0x30 + +/* parameters of LINE_STATUS */ + #define LSR_OE 0x02 /* Overrun error indicator */ #define LSR_PE 0x04 /* Parity error indicator */ #define LSR_FE 0x08 /* Frame error indicator */ @@ -146,30 +176,50 @@ struct ircomm_cb{ int in_use; int null_modem_mode; /* switch for null modem emulation */ int ttp_stop; + int max_txbuff_size; - int maxsdusize; - __u32 daddr; /* Device address of the peer device */ + __u32 maxsdusize; - void (*d_handler)(struct ircomm_cb *self); + __u32 daddr; /* Device address of the peer device */ + __u32 saddr; + __u32 skey; + __u32 ckey; + int queryias_lock; + int ias_type; + int disconnect_priority; /* P_NORMAL or P_HIGH. see irttp.h */ struct notify_t notify; /* container of callbacks */ + void (*d_handler)(struct ircomm_cb *self); + int control_ch_pending; struct sk_buff *ctrl_skb; /* queue of control channel */ + __u8 dlsap; /* IrLMP dlsap */ + __u8 lsap; /* sap of local device */ struct tsap_cb *tsap; /* IrTTP/LMP handle */ struct qos_info *qos; /* Quality of Service */ - int reason; /* I don't know about reason: see Irlmp.c or somewhere :p)*/ + int peer_cap; /* capability of peer device */ + + struct wait_queue *discovery_wait; + struct wait_queue *ias_wait; + + /* statistics */ + int tx_packets; + int rx_packets; + int tx_controls; + int pending_control_tuples; + int ignored_control_tuples; + - __u8 dlsap; /* IrLMP dlsap */ - __u8 lsap; /* sap of local device */ __u8 pi ; /* instruction of control channel*/ + __u8 port_type; __u8 peer_port_type; __u8 servicetype; - __u8 peer_servicetype; + __u8 peer_servicetype; __u8 data_format; __u8 peer_data_format; __u8 flow_ctrl; @@ -199,35 +249,25 @@ struct ircomm_cb{ __u32 data_rate; __u32 peer_data_rate; - char port_name[60]; - + char port_name[33]; + int port_name_critical; }; -void ircomm_connect_request(struct ircomm_cb *self, int maxsdusize); +void ircomm_connect_request(struct ircomm_cb *self, __u8 servicetype); void ircomm_connect_response(struct ircomm_cb *self, struct sk_buff *userdata, - int maxsdusize); + __u32 maxsdusize); void ircomm_disconnect_request(struct ircomm_cb *self, - struct sk_buff *userdata); -void ircomm_data_request(struct ircomm_cb *self, - struct sk_buff *userdata); -void ircomm_control_request(struct ircomm_cb *self); -void ircomm_append_ctrl(struct ircomm_cb *self, __u8 instruction); -struct ircomm_cb *ircomm_attach_cable( __u8 servicetype, struct notify_t notify, - void *handler); -int ircomm_detach_cable(struct ircomm_cb *self); - - -void ircomm_accept_data_indication(void *instance, void *sap, struct sk_buff *skb); -void ircomm_accept_connect_confirm(void *instance, void *sap, struct qos_info *qos, - int maxsdusize, struct sk_buff *skb); -void ircomm_accept_connect_indication(void *instance, void *sap, - struct qos_info *qos, - int maxsdusize, struct sk_buff *skb); -void ircomm_accept_disconnect_indication(void *instance, void *sap, LM_REASON reason, - struct sk_buff *skb); -void ircomm_accept_flow_indication(void *instance, void *sap, LOCAL_FLOW flow); -void ircomm_next_state( struct ircomm_cb *self, IRCOMM_STATE state); + struct sk_buff *userdata, int priority); +int ircomm_data_request(struct ircomm_cb *self, + struct sk_buff *userdata); +void ircomm_control_request(struct ircomm_cb *self, __u8 instruction); + +void ircomm_parse_tuples(struct ircomm_cb *self, struct sk_buff *skb, int type); + +struct ircomm_cb *ircomm_open_instance(struct notify_t notify); +int ircomm_close_instance(struct ircomm_cb *self); +#endif diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h index 22458aa0b..35c15fadc 100644 --- a/include/net/irda/irda.h +++ b/include/net/irda/irda.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Tue Dec 9 21:13:12 1997 - * Modified at: Sat Jan 16 01:23:15 1999 + * Modified at: Wed Apr 21 17:49:00 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -22,11 +22,15 @@ * ********************************************************************/ -#ifndef IRDA_H -#define IRDA_H +#ifndef NET_IRDA_H +#define NET_IRDA_H #include <linux/config.h> #include <linux/skbuff.h> +#include <linux/kernel.h> + +#include <net/irda/qos.h> +#include <net/irda/irqueue.h> #ifndef TRUE #define TRUE 1 @@ -39,14 +43,15 @@ #define ALIGN __attribute__((aligned)) #define PACK __attribute__((packed)) -/* use 0 for production, 1 for verification, >2 for debug */ + #ifdef CONFIG_IRDA_DEBUG extern __u32 irda_debug; -#define IRDA_DEBUG 3 +/* use 0 for production, 1 for verification, >2 for debug */ +#define IRDA_DEBUG_LEVEL 0 -#define DEBUG(n, args...) if (irda_debug >= (n)) printk( KERN_DEBUG args) +#define DEBUG(n, args...) if (irda_debug >= (n)) printk(KERN_DEBUG args) #define ASSERT(expr, func) \ if(!(expr)) { \ printk( "Assertion failed! %s,%s,%s,line=%d\n",\ @@ -57,46 +62,11 @@ if(!(expr)) { \ #define ASSERT(expr, func) #endif /* CONFIG_IRDA_DEBUG */ -#ifdef CHECK_SKB -static unsigned int check_skb = CHECK_SKB; - -#define SK_FREED_SKB 0x0DE2C0DE -#define SK_GOOD_SKB 0xDEC0DED1 -#define SK_HEAD_SKB 0x12231298 - -extern int skb_check(struct sk_buff *skb,int,int, char *); - -#ifdef IS_SKB -#undef IS_SKB -#endif - -#define IS_SKB(skb, func) \ -if( skb_check((skb), 0, __LINE__,__FILE__) == -1) { \ - ##func} - -#ifdef IS_SKB_HEAD -#undef IS_SKB_HEAD -#endif - -#define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__) - -#define ALLOC_SKB_MAGIC(skb) \ -if( check_skb) \ - skb->magic_debug_cookie = SK_GOOD_SKB; +#define WARNING(args...) printk(KERN_WARNING args) +#define MESSAGE(args...) printk(KERN_INFO args) +#define ERROR(args...) printk(KERN_ERR args) -#define FREE_SKB_MAGIC(skb) \ -if( check_skb) {\ - skb->magic_debug_cookie = SK_FREED_SKB; \ -} - -#else -#undef IS_SKB -#define IS_SKB(skb, func) -#undef IS_SKB_HEAD -#define IS_SKB_HEAD(skb) -#define ALLOC_SKB_MAGIC(skb) -#define FREE_SKB_MAGIC(skb) -#endif /* CHECK_SKB */ +#define MSECS_TO_JIFFIES(ms) (ms*HZ/1000) /* * Magic numbers used by Linux/IR. Random numbers which must be unique to @@ -117,39 +87,155 @@ if( check_skb) {\ #define IAS_OBJECT_MAGIC 0x34234 #define IAS_ATTRIB_MAGIC 0x45232 -#define IAS_DEVICE_ID 0x5342 +#define IAS_DEVICE_ID 0x5342 #define IAS_PNP_ID 0xd342 #define IAS_OBEX_ID 0x34323 #define IAS_IRLAN_ID 0x34234 #define IAS_IRCOMM_ID 0x2343 #define IAS_IRLPT_ID 0x9876 -#endif /* IRDA_H */ - - - - - - - - - - - - - - - - - +typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW; +/* IrDA Socket */ +struct tsap_cb; +struct irda_sock { + __u32 saddr; /* my local address */ + __u32 daddr; /* peer address */ + struct ias_object *ias_obj; + struct tsap_cb *tsap; /* TSAP used by this connection */ + __u8 dtsap_sel; /* remote TSAP address */ + __u8 stsap_sel; /* local TSAP address */ + + __u32 max_sdu_size_rx; + __u32 max_sdu_size_tx; + struct qos_info qos_tx; + __u16 mask; /* Hint bits mask */ + __u16 hints; /* Hint bits */ + __u32 ckey; /* IrLMP client handle */ + __u32 skey; /* IrLMP service handle */ + int nslots; /* Number of slots to use for discovery */ + int errno; + struct sock *sk; + struct wait_queue *ias_wait; /* Wait for LM-IAS answer */ + LOCAL_FLOW tx_flow; + LOCAL_FLOW rx_flow; +}; +/* + * This type is used by the protocols that transmit 16 bits words in + * little endian format. A little endian machine stores MSB of word in + * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] + * and LSB in byte[1]. + */ +typedef union { + __u16 word; + __u8 byte[2]; +} __u16_host_order; +/* + * Information monitored by some layers + */ +struct irda_statistics +{ + int rx_packets; /* total packets received */ + int tx_packets; /* total packets transmitted */ + int rx_errors; /* bad packets received */ + int tx_errors; /* packet transmit problems */ + int rx_dropped; /* no space in linux buffers */ + int tx_dropped; /* no space available in linux */ + int rx_compressed; + int tx_compressed; + int rx_bytes; /* total bytes received */ + int tx_bytes; /* total bytes transmitted */ + + int multicast; /* multicast packets received */ + int collisions; + + /* detailed rx_errors: */ + int rx_length_errors; + int rx_over_errors; /* receiver ring buff overflow */ + int rx_crc_errors; /* recved pkt with crc error */ + int rx_frame_errors; /* recv'd frame alignment error */ + int rx_fifo_errors; /* recv'r fifo overrun */ + int rx_missed_errors; /* receiver missed packet */ + + /* detailed tx_errors */ + int tx_aborted_errors; + int tx_carrier_errors; + int tx_fifo_errors; + int tx_heartbeat_errors; + int tx_window_errors; +}; + +/* Misc status information */ +typedef enum { + STATUS_OK, + STATUS_ABORTED, + STATUS_NO_ACTIVITY, + STATUS_NOISY, + STATUS_REMOTE, +} LINK_STATUS; + +typedef enum { + LOCK_NO_CHANGE, + LOCK_LOCKED, + LOCK_UNLOCKED, +} LOCK_STATUS; + +typedef enum { /* FIXME check the two first reason codes */ + LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */ + LAP_NO_RESPONSE, /* To many retransmits without response */ + LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */ + LAP_FOUND_NONE, /* No devices were discovered */ + LAP_MEDIA_BUSY, + LAP_PRIMARY_CONFLICT, +} LAP_REASON; + +/* + * IrLMP disconnect reasons. The order is very important, since they + * correspond to disconnect reasons sent in IrLMP disconnect frames, so + * please do not touch :-) + */ +typedef enum { + LM_USER_REQUEST = 1, /* User request */ + LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */ + LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */ + LM_LAP_RESET, /* IrLAP reset */ + LM_INIT_DISCONNECT, /* Link Management initiated disconnect */ + LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */ + LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */ + LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */ + LM_CONN_HALF_OPEN, /* Connection is half open */ + LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */ +} LM_REASON; +#define LM_UNKNOWN 0xff /* Unspecified disconnect reason */ +/* + * Notify structure used between transport and link management layers + */ +struct notify_t { + int (*data_indication)(void *priv, void *sap, struct sk_buff *skb); + int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb); + void (*connect_confirm)(void *instance, void *sap, + struct qos_info *qos, __u32 max_sdu_size, + struct sk_buff *skb); + void (*connect_indication)(void *instance, void *sap, + struct qos_info *qos, __u32 max_sdu_size, + struct sk_buff *skb); + void (*disconnect_indication)(void *instance, void *sap, + LM_REASON reason, struct sk_buff *); + void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow); + void *instance; /* Layer instance pointer */ + char name[16]; /* Name of layer */ +}; + +#define NOTIFY_MAX_NAME 16 + +#endif /* NET_IRDA_H */ diff --git a/include/net/irda/irda_device.h b/include/net/irda/irda_device.h index d8e546bb5..a3dcf2d6e 100644 --- a/include/net/irda/irda_device.h +++ b/include/net/irda/irda_device.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Haris Zukanovic <haris@stud.cs.uit.no> * Created at: Tue Apr 14 12:41:42 1998 - * Modified at: Mon Jan 18 10:52:10 1999 + * Modified at: Tue Apr 20 11:06:28 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Haris Zukanovic, <haris@stud.cs.uit.no> @@ -31,15 +31,23 @@ #include <linux/tty.h> #include <linux/netdevice.h> +#include <asm/spinlock.h> + #include <net/irda/irda.h> #include <net/irda/qos.h> #include <net/irda/irqueue.h> - -#define SIR_MODE 0x01 -#define MIR_MODE 0x02 -#define FIR_MODE 0x04 -#define IO_PIO 0x08 -#define IO_DMA 0x10 +#include <net/irda/irlap_frame.h> + +/* Some non-standard interface flags (should not conflict with any in if.h) */ +#define IFF_SIR 0x0001 /* Supports SIR speeds */ +#define IFF_MIR 0x0002 /* Supports MIR speeds */ +#define IFF_FIR 0x0004 /* Supports FIR speeds */ +#define IFF_VFIR 0x0008 /* Supports VFIR speeds */ +#define IFF_PIO 0x0010 /* Supports PIO transfer of data */ +#define IFF_DMA 0x0020 /* Supports DMA transfer of data */ +#define IFF_SHM 0x0040 /* Supports shared memory data transfers */ +#define IFF_DONGLE 0x0080 /* Interface has a dongle attached */ +#define IFF_AIR 0x0100 /* Supports A(dvanced)IR standards */ #define IO_XMIT 0x01 #define IO_RECV 0x02 @@ -48,29 +56,29 @@ struct chipio_t { int iobase, iobase2; /* IO base */ int io_ext, io_ext2; /* Length of iobase */ + int membase; /* Shared memory base */ int irq, irq2; /* Interrupts used */ int fifo_size; /* FIFO size */ int dma, dma2; /* DMA channel used */ int irqflags; /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */ - int direction; /* Used by some FIR drivers */ + int direction; /* Link direction, used by some FIR drivers */ int baudrate; /* Currently used baudrate */ int dongle_id; /* Dongle or transceiver currently used */ }; -/* Buffer specific info */ +/* IO buffer specific info (inspired by struct sk_buff) */ struct iobuff_t { int state; /* Receiving state (transmit state not used) */ int in_frame; /* True if receiving frame */ - __u8 *data; /* the buffer */ - __u8 *head; /* start of data in buffer */ + __u8 *head; /* start of buffer */ + __u8 *data; /* start of data in buffer */ __u8 *tail; /* end of data in buffer */ - int offset; /* Usually data + offset = head */ - int len; /* currently used bytes in buffer */ - int truesize; /* total size of the data area */ + int len; /* length of data */ + int truesize; /* total size of buffer */ __u16 fcs; int flags; /* Allocation flags (GFP_KERNEL | GFP_DMA ) */ @@ -83,7 +91,7 @@ struct iobuff_t { * stuff from IrDA port implementations. */ struct irda_device { - QUEUE q; /* Must be first */ + QUEUE q; /* Must be first */ int magic; /* Our magic bullet */ char name[16]; /* Name of device "irda0" */ @@ -93,7 +101,7 @@ struct irda_device { struct device netdev; /* Yes! we are some kind of netdevice */ struct enet_statistics stats; -/* int flags; */ + int flags; /* Interface flags (see defs above) */ void *priv; /* Pointer to low level implementation */ @@ -103,51 +111,62 @@ struct irda_device { struct iobuff_t tx_buff; struct iobuff_t rx_buff; - int media_busy; + /* spinlock_t lock; */ /* For serializing operations */ /* Media busy stuff */ + int media_busy; struct timer_list media_busy_timer; - struct timer_list todo_timer; - int (*hard_xmit)( struct sk_buff *skb, struct device *dev); - void (*change_speed)( struct irda_device *driver, int baud); - - int (*is_receiving)(struct irda_device *); /* receiving? */ + /* Callbacks for driver specific implementation */ + void (*change_speed)(struct irda_device *driver, int baud); + int (*is_receiving)(struct irda_device *); /* receiving? */ /* int (*is_tbusy)(struct irda_device *); */ /* transmitting? */ void (*wait_until_sent)(struct irda_device *); - - int new_speed; /* Will be removed in future */ + void (*set_caddr)(struct irda_device *); /* Set connection addr */ }; extern hashbin_t *irda_device; /* Function prototypes */ -int irda_device_init( void); -void irda_device_cleanup( void); +int irda_device_init(void); +void irda_device_cleanup(void); -int irda_device_open( struct irda_device *, char *name, void *priv); -void irda_device_close( struct irda_device *); +int irda_device_open(struct irda_device *, char *name, void *priv); +void irda_device_close(struct irda_device *); /* Interface to be uses by IrLAP */ -inline void irda_device_set_media_busy( struct irda_device *, int status); -inline int irda_device_is_media_busy( struct irda_device *); -inline int irda_device_is_receiving( struct irda_device *); -inline void irda_device_change_speed( struct irda_device *, int); - -inline struct qos_info *irda_device_get_qos( struct irda_device *self); -int irda_device_txqueue_empty( struct irda_device *self); +inline void irda_device_set_media_busy(struct irda_device *, int status); +inline int irda_device_is_media_busy(struct irda_device *); +inline int irda_device_is_receiving(struct irda_device *); +inline void irda_device_change_speed(struct irda_device *, int); -int irda_device_setup( struct device *dev); +inline struct qos_info *irda_device_get_qos(struct irda_device *self); +int irda_device_txqueue_empty(struct irda_device *self); -__inline__ int irda_get_mtt( struct sk_buff *skb); - -void setup_dma( int channel, char *buffer, int count, int mode); - -#endif +int irda_device_setup(struct device *dev); +void setup_dma(int channel, char *buffer, int count, int mode); +/* + * Function irda_get_mtt (skb) + * + * Utility function for getting the minimum turnaround time out of + * the skb, where it has been hidden in the cb field. + */ +inline static __u16 irda_get_mtt(struct sk_buff *skb) +{ + __u16 mtt; + if (((struct irlap_skb_cb *)(skb->cb))->magic != LAP_MAGIC) + mtt = 10000; + else + mtt = ((struct irlap_skb_cb *)(skb->cb))->mtt; + ASSERT(mtt <= 10000, return 10000;); + + return mtt; +} +#endif diff --git a/include/net/irda/iriap.h b/include/net/irda/iriap.h index 495da351e..071ed8561 100644 --- a/include/net/irda/iriap.h +++ b/include/net/irda/iriap.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: iriap.h - * Version: + * Version: 0.5 * Description: Information Access Protocol (IAP) * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Thu Aug 21 00:02:07 1997 - * Modified at: Sat Dec 5 13:45:37 1998 + * Modified at: Wed Apr 21 16:37:21 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -34,8 +34,8 @@ #include <net/irda/irqueue.h> #include <net/irda/timer.h> -#define LST 0x80 -#define ACK 0x40 +#define IAP_LST 0x80 +#define IAP_ACK 0x40 #define IAS_SERVER 0 #define IAS_CLIENT 1 @@ -51,27 +51,18 @@ #define IAS_SUCCESS 0 #define IAS_CLASS_UNKNOWN 1 #define IAS_ATTRIB_UNKNOWN 2 +#define IAS_DISCONNECT 10 -typedef void (*CONFIRM_CALLBACK)( __u16 obj_id, struct ias_value *value, - void *priv); - -struct iap_value { - char *full; - char *name; - char *attr; - __u16 obj_id; - __u8 ret_code; - __u8 type; - int len; - int value_int; - char *value_char; -}; +typedef void (*CONFIRM_CALLBACK)(int result, __u16 obj_id, + struct ias_value *value, void *priv); struct iriap_cb { QUEUE queue; /* Must be first */ int magic; /* Magic cookie */ int mode; /* Client or server */ + + __u32 saddr; __u32 daddr; __u8 operation; @@ -95,19 +86,15 @@ struct iriap_cb { int iriap_init(void); void iriap_cleanup(void); -void iriap_getvaluebyclass_request( __u32 addr, char *name, char *attr, +void iriap_getvaluebyclass_request( char *name, char *attr, + __u32 saddr, __u32 daddr, CONFIRM_CALLBACK callback, void *priv); -void iriap_getvaluebyclass_confirm( struct iriap_cb *self, - struct sk_buff *skb); +void iriap_getvaluebyclass_confirm(struct iriap_cb *self, struct sk_buff *skb); void iriap_send_ack( struct iriap_cb *self); -void iriap_data_indication( void *instance, void *sap, struct sk_buff *skb); -void iriap_connect_confirm( void *instance, void *sap, struct qos_info *qos, - int max_sdu_size, struct sk_buff *skb); -void iriap_connect_indication( void *instance, void *sap, - struct qos_info *qos, int max_sdu_size, - struct sk_buff *skb); -void iriap_call_indication( struct iriap_cb *self, struct sk_buff *skb); +void iriap_connect_confirm(void *instance, void *sap, struct qos_info *qos, + __u32 max_sdu_size, struct sk_buff *skb); +void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb); void iriap_register_server(void); @@ -121,3 +108,5 @@ static inline void iriap_start_watchdog_timer( struct iriap_cb *self, } #endif + + diff --git a/include/net/irda/irias_object.h b/include/net/irda/irias_object.h index efacac854..4a76018b6 100644 --- a/include/net/irda/irias_object.h +++ b/include/net/irda/irias_object.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Thu Oct 1 22:49:50 1998 - * Modified at: Sun Oct 25 00:28:56 1998 + * Modified at: Wed Feb 3 10:38:02 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -25,7 +25,7 @@ #ifndef LM_IAS_OBJECT_H #define LM_IAS_OBJECT_H -#include "irqueue.h" +#include <net/irda/irqueue.h> /* LM-IAS Attribute types */ #define IAS_MISSING 0 @@ -38,12 +38,10 @@ */ struct ias_object { QUEUE queue; /* Must be first! */ - int magic; char *name; int id; - hashbin_t *attribs; }; @@ -51,8 +49,7 @@ struct ias_object { * Values used by LM-IAS attributes */ struct ias_value { - /* Value description */ - __u8 type; + __u8 type; /* Value description */ int charset; /* Only used by string type */ int len; @@ -68,16 +65,11 @@ struct ias_value { * Attributes used by LM-IAS objects */ struct ias_attrib { - QUEUE queue; /* Must be first! */ - + QUEUE queue; /* Must be first! */ int magic; - /* Attribute name */ - char *name; - /* char *attr; What do we need this for? */ - - /* Attribute value */ - struct ias_value *value; + char *name; /* Attribute name */ + struct ias_value *value; /* Attribute value */ }; char *strdup( char *str); @@ -87,12 +79,12 @@ void irias_insert_object( struct ias_object *obj); void __irias_delete_object( struct ias_object *obj); void irias_delete_object( char *name); -void irias_add_integer_attrib( struct ias_object *obj, char *name, - int value); -void irias_add_string_attrib( struct ias_object *obj, char *name, - char *value); -void irias_add_octseq_attrib( struct ias_object *obj, char *name, - __u8 *octets, int len); +void irias_add_integer_attrib(struct ias_object *obj, char *name, int value); +void irias_add_string_attrib(struct ias_object *obj, char *name, char *value); +void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets, + int len); +int irias_object_change_attribute(char *obj_name, char *attrib_name, + struct ias_value *new_value); struct ias_object *irias_find_object( char *name); struct ias_attrib *irias_find_attrib( struct ias_object *obj, char *name); diff --git a/include/net/irda/irlan_cli.h b/include/net/irda/irlan_cli.h deleted file mode 100644 index fb677af20..000000000 --- a/include/net/irda/irlan_cli.h +++ /dev/null @@ -1,65 +0,0 @@ -/********************************************************************* - * - * Filename: client.h - * Version: 0.3 - * Description: IrDA LAN access layer - * Status: Experimental. - * Author: Dag Brattli <dagb@cs.uit.no> - * Created at: Sun Aug 31 20:14:37 1997 - * Modified at: Mon Oct 19 12:37:20 1998 - * Modified by: Dag Brattli <dagb@cs.uit.no> - * - * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, 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 IRLAN_CLIENT_H -#define IRLAN_CLIENT_H - -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/skbuff.h> -#include <linux/netdevice.h> - -int irlan_client_init(void); -void irlan_client_cleanup(void); - -void irlan_discovery_indication( DISCOVERY*); -void irlan_client_disconnect_indication( void *instance, void *sap, - LM_REASON reason, struct sk_buff *); - -void irlan_client_data_indication( void *instance, void *sap, - struct sk_buff *skb); - -void irlan_client_control_data_indication( void *instance, void *sap, - struct sk_buff *skb); - -void irlan_client_connect_confirm( void *instance, void *sap, - struct qos_info *qos, int max_sdu_size, - struct sk_buff *); -void irlan_client_connect_indication( void *instance, void *sap, - struct sk_buff *); -void irlan_client_connect_response( void *instance, void *sap, - int max_sdu_size, struct sk_buff *skb); - -void irlan_client_open_tsaps( struct irlan_cb *self); - -void irlan_client_extract_params( struct irlan_cb *self, - struct sk_buff *skb); -void check_response_param( struct irlan_cb *self, char *param, - char *value, int val_len); -void handle_request( struct irlan_cb *self); -void irlan_client_register_server(void); -void irlan_client_get_value_confirm( __u16 obj_id, struct ias_value *value, - void *priv); - -#endif diff --git a/include/net/irda/irlan_client.h b/include/net/irda/irlan_client.h new file mode 100644 index 000000000..62ea6157a --- /dev/null +++ b/include/net/irda/irlan_client.h @@ -0,0 +1,45 @@ +/********************************************************************* + * + * Filename: irlan_client.h + * Version: 0.3 + * Description: IrDA LAN access layer + * Status: Experimental. + * Author: Dag Brattli <dagb@cs.uit.no> + * Created at: Sun Aug 31 20:14:37 1997 + * Modified at: Thu Apr 22 14:13:34 1999 + * Modified by: Dag Brattli <dagb@cs.uit.no> + * + * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, 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 IRLAN_CLIENT_H +#define IRLAN_CLIENT_H + +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/skbuff.h> +#include <linux/netdevice.h> + +#include <net/irda/irias_object.h> +#include <net/irda/irlan_event.h> + +void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout); +void irlan_client_discovery_indication(discovery_t *); +void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr); + +void irlan_client_open_ctrl_tsap( struct irlan_cb *self); + +void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb); +void irlan_client_get_value_confirm(int result, __u16 obj_id, + struct ias_value *value, void *priv); +#endif diff --git a/include/net/irda/irlan_common.h b/include/net/irda/irlan_common.h index 33ba52377..35d83096f 100644 --- a/include/net/irda/irlan_common.h +++ b/include/net/irda/irlan_common.h @@ -1,12 +1,12 @@ /********************************************************************* * - * Filename: irlan.h - * Version: 0.1 + * Filename: irlan_common.h + * Version: 0.8 * Description: IrDA LAN access layer * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 31 20:14:37 1997 - * Modified at: Thu Oct 29 13:23:11 1998 + * Modified at: Thu Apr 22 14:30:37 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -25,15 +25,18 @@ #ifndef IRLAN_H #define IRLAN_H +#include <asm/param.h> /* for HZ */ + #include <linux/kernel.h> #include <linux/types.h> #include <linux/skbuff.h> #include <linux/netdevice.h> -#include "irqueue.h" -#include "irttp.h" +#include <net/irda/irqueue.h> +#include <net/irda/irttp.h> -#define IRLAN_MTU 1518 +#define IRLAN_MTU 1518 +#define IRLAN_TIMEOUT 10*HZ /* 10 seconds */ /* Command packet types */ #define CMD_GET_PROVIDER_INFO 0 @@ -61,23 +64,23 @@ #define MEDIA_802_5 2 /* Filter parameters */ -#define DATA_CHAN 1 +#define DATA_CHAN 1 #define FILTER_TYPE 2 #define FILTER_MODE 3 /* Filter types */ -#define IR_DIRECTED 1 -#define IR_FUNCTIONAL 2 -#define IR_GROUP 3 -#define IR_MAC_FRAME 4 -#define IR_MULTICAST 5 -#define IR_BROADCAST 6 -#define IR_IPX_SOCKET 7 +#define IRLAN_DIRECTED 0x01 +#define IRLAN_FUNCTIONAL 0x02 +#define IRLAN_GROUP 0x04 +#define IRLAN_MAC_FRAME 0x08 +#define IRLAN_MULTICAST 0x10 +#define IRLAN_BROADCAST 0x20 +#define IRLAN_IPX_SOCKET 0x40 /* Filter modes */ -#define ALL 1 -#define FILTER 2 -#define NONE 3 +#define ALL 1 +#define FILTER 2 +#define NONE 3 /* Filter operations */ #define GET 1 @@ -87,36 +90,50 @@ #define DYNAMIC 5 /* Access types */ -#define DIRECT 1 -#define PEER 2 -#define HOSTED 3 +#define ACCESS_DIRECT 1 +#define ACCESS_PEER 2 +#define ACCESS_HOSTED 3 + +#define IRLAN_BYTE 0 +#define IRLAN_SHORT 1 +#define IRLAN_ARRAY 2 #define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER+LAP_HEADER) /* - * IrLAN client subclass + * IrLAN client */ struct irlan_client_cb { - /* - * Client fields - */ + int state; + int open_retries; + + struct tsap_cb *tsap_ctrl; __u8 reconnect_key[255]; __u8 key_len; + __u16 recv_arb_val; + __u16 max_frame; + int filter_type; + int unicast_open; int broadcast_open; + + struct timer_list kick_timer; }; /* - * IrLAN servers subclass + * IrLAN provider */ -struct irlan_server_cb { +struct irlan_provider_cb { + int state; + struct tsap_cb *tsap_ctrl; + /* - * Store some values here which are used by the irlan_server to parse - * FILTER_OPERATIONs + * Store some values here which are used by the provider to parse + * the filter operations */ int data_chan; int filter_type; @@ -124,11 +141,13 @@ struct irlan_server_cb { int filter_operation; int filter_entry; + __u16 send_arb_val; + __u8 mac_address[6]; /* Generated MAC address for peer device */ }; /* - * IrLAN super class + * IrLAN */ struct irlan_cb { QUEUE queue; /* Must be first */ @@ -140,57 +159,56 @@ struct irlan_cb { __u32 saddr; /* Source devcie address */ __u32 daddr; /* Destination device address */ - int connected; /* TTP layer ready to exchange ether frames */ + int netdev_registered; + int notify_irmanager; - int state; /* Current state of IrLAN layer */ - - int media; + int media; /* Media type */ + int access_type; /* Currently used access type */ + __u8 version[2]; /* IrLAN version */ - struct tsap_cb *tsap_ctrl; struct tsap_cb *tsap_data; int use_udata; /* Use Unit Data transfers */ - __u8 dtsap_sel_data; /* Destination data TSAP selector */ __u8 stsap_sel_data; /* Source data TSAP selector */ + __u8 dtsap_sel_data; /* Destination data TSAP selector */ __u8 dtsap_sel_ctrl; /* Destination ctrl TSAP selector */ - int client; /* Client or server */ - union { - struct irlan_client_cb client; - struct irlan_server_cb server; - } t; - - /* void (*irlan_dev_init)(struct irlan_cb *); */ - - /* - * Used by extract_params, placed here for now to avoid placing - * them on the stack. FIXME: remove these! - */ - char name[255]; - char value[1016]; + struct irlan_client_cb client; /* Client specific fields */ + struct irlan_provider_cb provider; /* Provider specific fields */ + + struct timer_list watchdog_timer; }; -struct irlan_cb *irlan_open(void); - -void irlan_get_provider_info( struct irlan_cb *self); -void irlan_get_unicast_addr( struct irlan_cb *self); -void irlan_get_media_char( struct irlan_cb *self); -void irlan_open_data_channel( struct irlan_cb *self); -void irlan_set_multicast_filter( struct irlan_cb *self, int status); -void irlan_set_broadcast_filter( struct irlan_cb *self, int status); -void irlan_open_unicast_addr( struct irlan_cb *self); - -int insert_byte_param( struct sk_buff *skb, char *param, __u8 value); -int insert_string_param( struct sk_buff *skb, char *param, char *value); -int insert_array_param( struct sk_buff *skb, char *name, __u8 *value, - __u16 value_len); - -int insert_param( struct sk_buff *skb, char *param, int type, char *value_char, - __u8 value_byte, __u16 value_short); - -int irlan_get_response_param( __u8 *buf, char *name, char *value, int *len); -void print_ret_code( __u8 code); +struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr, int netdev); +void irlan_close(struct irlan_cb *self); +void irlan_close_tsaps(struct irlan_cb *self); +void irlan_mod_inc_use_count(void); +void irlan_mod_dec_use_count(void); + +int irlan_register_netdev(struct irlan_cb *self); +void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel); +void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout); + +void irlan_open_data_tsap(struct irlan_cb *self); + +void irlan_get_provider_info(struct irlan_cb *self); +void irlan_get_unicast_addr(struct irlan_cb *self); +void irlan_get_media_char(struct irlan_cb *self); +void irlan_open_data_channel(struct irlan_cb *self); +void irlan_close_data_channel(struct irlan_cb *self); +void irlan_set_multicast_filter(struct irlan_cb *self, int status); +void irlan_set_broadcast_filter(struct irlan_cb *self, int status); +void irlan_open_unicast_addr(struct irlan_cb *self); + +int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value); +int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value); +int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value); +int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value, + __u16 value_len); + +int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len); +void print_ret_code(__u8 code); extern hashbin_t *irlan; diff --git a/include/net/irda/irlan_eth.h b/include/net/irda/irlan_eth.h index 72f14ff75..6ad33ee48 100644 --- a/include/net/irda/irlan_eth.h +++ b/include/net/irda/irlan_eth.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Thu Oct 15 08:36:58 1998 - * Modified at: Thu Oct 15 12:28:12 1998 + * Modified at: Thu Apr 22 14:09:37 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -25,12 +25,11 @@ #ifndef IRLAN_ETH_H #define IRLAN_ETH_H -int irlan_eth_init( struct device *dev); -int irlan_eth_open( struct device *dev); -int irlan_eth_close( struct device *dev); - -void irlan_eth_rx( void *instance, void *sap, struct sk_buff *skb); -int irlan_eth_tx( struct sk_buff *skb, struct device *dev); +int irlan_eth_init(struct device *dev); +int irlan_eth_open(struct device *dev); +int irlan_eth_close(struct device *dev); +int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb); +int irlan_eth_xmit(struct sk_buff *skb, struct device *dev); void irlan_eth_flow_indication( void *instance, void *sap, LOCAL_FLOW flow); diff --git a/include/net/irda/irlan_event.h b/include/net/irda/irlan_event.h index d3a062af0..b9baac9eb 100644 --- a/include/net/irda/irlan_event.h +++ b/include/net/irda/irlan_event.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 31 20:14:37 1997 - * Modified at: Tue Oct 20 09:59:31 1998 + * Modified at: Tue Feb 2 09:45:17 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -44,7 +44,6 @@ typedef enum { IRLAN_SYNC } IRLAN_STATE; -/* IrLAN Client Events */ typedef enum { IRLAN_DISCOVERY_INDICATION, IRLAN_IAS_PROVIDER_AVAIL, @@ -61,26 +60,22 @@ typedef enum { IRLAN_GET_MEDIA_CMD, IRLAN_OPEN_DATA_CMD, IRLAN_FILTER_CONFIG_CMD, -} IRLAN_EVENT; -struct irlan_info { - __u8 dlsap_sel; - __u32 daddr; - struct tsap_cb *tsap; -}; + IRLAN_CHECK_CON_ARB, + IRLAN_PROVIDER_SIGNAL, + + IRLAN_WATCHDOG_TIMEOUT, +} IRLAN_EVENT; extern char *irlan_state[]; -void irlan_do_client_event( struct irlan_cb *self, - IRLAN_EVENT event, - struct sk_buff *skb); +void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, + struct sk_buff *skb); -void irlan_do_server_event( struct irlan_cb *self, - IRLAN_EVENT event, - struct sk_buff *skb, - struct irlan_info *info); +void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event, + struct sk_buff *skb); -void irlan_next_state( struct irlan_cb *self, - IRLAN_STATE state); +void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state); +void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state); #endif diff --git a/include/net/irda/irlan_filter.h b/include/net/irda/irlan_filter.h new file mode 100644 index 000000000..b68eec161 --- /dev/null +++ b/include/net/irda/irlan_filter.h @@ -0,0 +1,33 @@ +/********************************************************************* + * + * Filename: irlan_filter.h + * Version: + * Description: + * Status: Experimental. + * Author: Dag Brattli <dagb@cs.uit.no> + * Created at: Fri Jan 29 15:24:08 1999 + * Modified at: Sun Feb 7 23:35:31 1999 + * Modified by: Dag Brattli <dagb@cs.uit.no> + * + * Copyright (c) 1998 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 IRLAN_FILTER_H +#define IRLAN_FILTER_H + +void irlan_check_command_param(struct irlan_cb *self, char *param, + char *value); +void handle_filter_request(struct irlan_cb *self, struct sk_buff *skb); +int irlan_print_filter(int filter_type, char *buf); + +#endif /* IRLAN_FILTER_H */ diff --git a/include/net/irda/irlan_srv.h b/include/net/irda/irlan_provider.h index c187302e2..aafbf9141 100644 --- a/include/net/irda/irlan_srv.h +++ b/include/net/irda/irlan_provider.h @@ -1,12 +1,12 @@ /********************************************************************* * - * Filename: server.h + * Filename: irlan_provider.h * Version: 0.1 * Description: IrDA LAN access layer * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 31 20:14:37 1997 - * Modified at: Fri Oct 16 11:25:37 1998 + * Modified at: Thu Apr 22 14:29:16 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -32,31 +32,27 @@ #include <net/irda/irlan_common.h> -int irlan_server_init(void); -void irlan_server_cleanup(void); -struct irlan_cb *irlan_server_open(void); -void irlan_server_close( struct irlan_cb *self); +void irlan_provider_ctrl_disconnect_indication(void *instance, void *sap, + LM_REASON reason, + struct sk_buff *skb); -void irlan_server_disconnect_indication( void *instance, void *sap, - LM_REASON reason, +void irlan_provider_ctrl_data_indication(void *instance, void *sap, struct sk_buff *skb); -void irlan_server_data_indication( void *instance, void *sap, - struct sk_buff *skb); -void irlan_server_control_data_indication( void *instance, void *sap, - struct sk_buff *skb); +void irlan_provider_connect_indication(void *instance, void *sap, + struct qos_info *qos, + __u32 max_sdu_size, + struct sk_buff *skb); +void irlan_provider_connect_response(struct irlan_cb *, struct tsap_cb *); -void irlan_server_connect_indication( void *instance, void *sap, - struct qos_info *qos, int max_sdu_size, - struct sk_buff *skb); -void irlan_server_connect_response( struct irlan_cb *, struct tsap_cb *); +int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb); +int irlan_provider_parse_command(struct irlan_cb *self, int cmd, + struct sk_buff *skb); -int irlan_parse_open_data_cmd( struct irlan_cb *self, struct sk_buff *skb); -int irlan_server_extract_params( struct irlan_cb *self, int cmd, - struct sk_buff *skb); - -void irlan_server_send_reply( struct irlan_cb *self, int command, - int ret_code); -void irlan_server_register(void); +void irlan_provider_send_reply(struct irlan_cb *self, int command, + int ret_code); +int irlan_provider_open_ctrl_tsap(struct irlan_cb *self); #endif + + diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h index 524d2b799..f3b26110f 100644 --- a/include/net/irda/irlap.h +++ b/include/net/irda/irlap.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irlap.h - * Version: 0.3 + * Version: 0.8 * Description: An IrDA LAP driver for Linux * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Mon Aug 4 20:40:53 1997 - * Modified at: Sat Dec 12 12:25:33 1998 + * Modified at: Fri Apr 23 09:51:15 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -105,6 +105,7 @@ struct irlap_cb { struct timer_list backoff_timer; /* Timeouts which will be different with different turn time */ + int slot_timeout; int poll_timeout; int final_timeout; int wd_timeout; @@ -118,14 +119,15 @@ struct irlap_cb { int retry_count; /* Times tried to establish connection */ int add_wait; /* True if we are waiting for frame */ + __u8 connect_pending; + __u8 disconnect_pending; + + /* To send a faster RR if tx queue empty */ #ifdef CONFIG_IRDA_FAST_RR - /* - * To send a faster RR if tx queue empty - */ int fast_RR_timeout; int fast_RR; #endif - + int N1; /* N1 * F-timer = Negitiated link disconnect warning threshold */ int N2; /* N2 * F-timer = Negitiated link disconnect time */ int N3; /* Connection retry count */ @@ -155,23 +157,19 @@ struct irlap_cb { int discovery_count; hashbin_t *discovery_log; - DISCOVERY *discovery_cmd; + discovery_t *discovery_cmd; struct qos_info qos_tx; /* QoS requested by peer */ struct qos_info qos_rx; /* QoS requested by self */ struct notify_t notify; /* Callbacks to IrLMP */ - int mtt_required; /* Minumum turnaround time required */ - int xbofs_delay; /* Nr of XBOF's used to MTT */ - int bofs_count; /* Negotiated extra BOFs */ + int mtt_required; /* Minumum turnaround time required */ + int xbofs_delay; /* Nr of XBOF's used to MTT */ + int bofs_count; /* Negotiated extra BOFs */ struct irda_statistics stats; -#ifdef CONFIG_IRDA_RECYCLE_RR - struct sk_buff *recycle_rr_skb; -#endif - #ifdef CONFIG_IRDA_COMPRESSION struct irda_compressor compressor; struct irda_compressor decompressor; @@ -208,9 +206,9 @@ void irlap_status_indication( int quality_of_link); void irlap_test_request( __u8 *info, int len); -void irlap_discovery_request( struct irlap_cb *, DISCOVERY *discovery); -void irlap_discovery_confirm( struct irlap_cb *, hashbin_t *discovery_log); -void irlap_discovery_indication( struct irlap_cb *, DISCOVERY *discovery); +void irlap_discovery_request(struct irlap_cb *, discovery_t *discovery); +void irlap_discovery_confirm(struct irlap_cb *, hashbin_t *discovery_log); +void irlap_discovery_indication(struct irlap_cb *, discovery_t *discovery); void irlap_reset_indication( struct irlap_cb *self); void irlap_reset_confirm(void); @@ -221,12 +219,12 @@ int irlap_validate_ns_received( struct irlap_cb *, int ns); int irlap_generate_rand_time_slot( int S, int s); void irlap_initiate_connection_state( struct irlap_cb *); -void irlap_flush_all_queues( struct irlap_cb *); -void irlap_change_speed( struct irlap_cb *, int); -void irlap_wait_min_turn_around( struct irlap_cb *, struct qos_info *); +void irlap_flush_all_queues(struct irlap_cb *); +void irlap_change_speed(struct irlap_cb *, int); +void irlap_wait_min_turn_around(struct irlap_cb *, struct qos_info *); -void irlap_init_qos_capabilities( struct irlap_cb *, struct qos_info *); -void irlap_apply_default_connection_parameters( struct irlap_cb *self); -void irlap_apply_connection_parameters( struct irlap_cb *, struct qos_info *); +void irlap_init_qos_capabilities(struct irlap_cb *, struct qos_info *); +void irlap_apply_default_connection_parameters(struct irlap_cb *self); +void irlap_apply_connection_parameters(struct irlap_cb *, struct qos_info *); #endif diff --git a/include/net/irda/irlap_event.h b/include/net/irda/irlap_event.h index bf4128939..015814b45 100644 --- a/include/net/irda/irlap_event.h +++ b/include/net/irda/irlap_event.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sat Aug 16 00:59:29 1997 - * Modified at: Thu Dec 17 11:58:10 1998 + * Modified at: Tue Apr 6 17:10:38 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -25,7 +25,8 @@ #ifndef IRLAP_EVENT_H #define IRLAP_EVENT_H -#include "irmod.h" +#include <net/irda/irda.h> +#include <net/irda/discovery.h> struct irlap_cb; @@ -67,6 +68,7 @@ typedef enum { RECV_DISCOVERY_XID_RSP, RECV_SNRM_CMD, RECV_TEST_CMD, + RECV_TEST_RSP, RECV_UA_RSP, RECV_DM_RSP, RECV_I_CMD, @@ -108,10 +110,10 @@ struct irlap_info { int slot; /* Random chosen slot */ int s; /* Current slot */ - DISCOVERY *discovery; /* Discovery information */ + discovery_t *discovery; /* Discovery information */ }; -extern char *irlap_state[]; +extern const char *irlap_state[]; void irlap_do_event( struct irlap_cb *self, IRLAP_EVENT event, struct sk_buff *skb, struct irlap_info *info); diff --git a/include/net/irda/irlap_frame.h b/include/net/irda/irlap_frame.h index 6b661e4b5..7425b41b4 100644 --- a/include/net/irda/irlap_frame.h +++ b/include/net/irda/irlap_frame.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irlap_frame.h - * Version: 0.3 + * Version: 0.9 * Description: Build and transmit IrLAP frames * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Tue Aug 19 10:27:26 1997 - * Modified at: Mon Dec 14 14:22:23 1998 + * Modified at: Fri Apr 23 09:33:55 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -27,7 +27,7 @@ #include <linux/skbuff.h> -#include <net/irda/irmod.h> +#include <net/irda/irda.h> #include <net/irda/irlap.h> #include <net/irda/qos.h> @@ -59,81 +59,69 @@ #define I_FRAME 0x00 /* Information Format */ #define UI_FRAME 0x03 /* Unnumbered Information */ -#define CMD_FRAME 0x01 -#define RSP_FRAME 0x00 +#define CMD_FRAME 0x01 +#define RSP_FRAME 0x00 -#define PF_BIT 0x10 /* Poll/final bit */ - -#define IR_S 0x01 /* Supervisory frames */ -#define IR_RR 0x01 /* Receiver ready */ -#define IR_RNR 0x05 /* Receiver not ready */ -#define IR_REJ 0x09 /* Reject */ -#define IR_U 0x03 /* Unnumbered frames */ -#define IR_SNRM 0x2f /* Set Asynchronous Balanced Mode */ - -#define IR_DISC 0x43 /* Disconnect */ -#define IR_DM 0x0f /* Disconnected mode */ -#define IR_UA 0x63 /* Unnumbered acknowledge */ -#define IR_FRMR 0x87 /* Frame reject */ -#define IR_UI 0x03 /* Unnumbered information */ +#define PF_BIT 0x10 /* Poll/final bit */ struct xid_frame { - __u8 caddr __attribute__((packed)); /* Connection address */ - __u8 control __attribute__((packed)); - __u8 ident __attribute__((packed)); /* Should always be XID_FORMAT */ - __u32 saddr __attribute__((packed)); /* Source device address */ - __u32 daddr __attribute__((packed)); /* Destination device address */ - __u8 flags __attribute__((packed)); /* Discovery flags */ - __u8 slotnr __attribute__((packed)); - __u8 version __attribute__((packed)); - __u8 discovery_info[0] __attribute__((packed)); -}; + __u8 caddr; /* Connection address */ + __u8 control; + __u8 ident; /* Should always be XID_FORMAT */ + __u32 saddr; /* Source device address */ + __u32 daddr; /* Destination device address */ + __u8 flags; /* Discovery flags */ + __u8 slotnr; + __u8 version; + __u8 discovery_info[0]; +} PACK; struct test_frame { __u8 caddr; /* Connection address */ __u8 control; - __u8 saddr; /* Source device address */ - __u8 daddr; /* Destination device address */ - __u8 *info; /* Information */ -}; + __u32 saddr; /* Source device address */ + __u32 daddr; /* Destination device address */ + __u8 info[0]; /* Information */ +} PACK; struct ua_frame { - __u8 caddr __attribute__((packed)); - __u8 control __attribute__((packed)); + __u8 caddr; + __u8 control; - __u32 saddr __attribute__((packed)); /* Source device address */ - __u32 daddr __attribute__((packed)); /* Dest device address */ + __u32 saddr; /* Source device address */ + __u32 daddr; /* Dest device address */ __u8 params[0]; -}; +} PACK; struct i_frame { - __u8 caddr __attribute__((packed)); - __u8 control __attribute__((packed)); - __u8 data[0] __attribute__((packed)); -}; + __u8 caddr; + __u8 control; + __u8 data[0]; +} PACK; struct snrm_frame { - __u8 caddr __attribute__((packed)); - __u8 control __attribute__((packed)); - __u32 saddr __attribute__((packed)); - __u32 daddr __attribute__((packed)); - __u8 ncaddr __attribute__((packed)); + __u8 caddr; + __u8 control; + __u32 saddr; + __u32 daddr; + __u8 ncaddr; __u8 params[0]; -}; +} PACK; /* Per-packet information we need to hide inside sk_buff */ struct irlap_skb_cb { + int magic; /* Be sure that we can trust the information */ int mtt; /* minimum turn around time */ int xbofs; /* number of xbofs required */ int vs; /* next frame to send */ int vr; /* next frame to receive */ }; -__inline__ void irlap_insert_mtt( struct irlap_cb *self, struct sk_buff *skb); - void irlap_send_discovery_xid_frame( struct irlap_cb *, int S, __u8 s, - __u8 command, DISCOVERY *discovery); + __u8 command, discovery_t *discovery); void irlap_send_snrm_frame( struct irlap_cb *, struct qos_info *); +void irlap_send_test_frame(struct irlap_cb *self, __u32 daddr, + struct sk_buff *cmd); void irlap_send_ua_response_frame( struct irlap_cb *, struct qos_info *); void irlap_send_ui_frame( struct irlap_cb *self, struct sk_buff *skb, int command); @@ -150,6 +138,4 @@ void irlap_resend_rejected_frames( struct irlap_cb *, int command); void irlap_send_i_frame( struct irlap_cb *, struct sk_buff *, int command); void irlap_send_ui_frame( struct irlap_cb *, struct sk_buff *, int command); -/* void irlap_input( struct irlap_cb *self, struct sk_buff *skb); */ - #endif diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h index a10a08fe1..31785883a 100644 --- a/include/net/irda/irlmp.h +++ b/include/net/irda/irlmp.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irlmp.h - * Version: 0.3 + * Version: 0.9 * Description: IrDA Link Management Protocol (LMP) layer * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 17 20:54:32 1997 - * Modified at: Mon Dec 7 21:11:32 1998 + * Modified at: Fri Apr 23 09:15:07 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -25,20 +25,25 @@ #ifndef IRLMP_H #define IRLMP_H +#include <asm/param.h> /* for HZ */ + #include <linux/config.h> #include <linux/types.h> -#include "irmod.h" -#include "qos.h" -#include "irlap.h" -#include "irlmp_event.h" -#include "irqueue.h" +#include <net/irda/irda.h> +#include <net/irda/qos.h> +#include <net/irda/irlap.h> +#include <net/irda/irlmp_event.h> +#include <net/irda/irqueue.h> +#include <net/irda/discovery.h> /* LSAP-SEL's */ #define LSAP_MASK 0x7f #define LSAP_IAS 0x00 #define LSAP_ANY 0xff +#define DEV_ADDR_ANY 0xffffffff + /* Predefined LSAPs used by the various servers */ #define TSAP_IRLAN 0x05 #define LSAP_IRLPT 0x06 @@ -51,23 +56,7 @@ #define LM_MAX_CONNECTIONS 10 -/* 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 +#define LM_IDLE_TIMEOUT 2*HZ /* 2 seconds for now */ typedef enum { S_PNP, @@ -80,23 +69,27 @@ typedef enum { S_TELEPHONY, S_COMM, S_OBEX, + S_ANY, + S_END, } SERVICE; -#define S_END 0xff +typedef void (*DISCOVERY_CALLBACK1) (discovery_t *); +typedef void (*DISCOVERY_CALLBACK2) (hashbin_t *); -#define CLIENT 1 -#define SERVER 2 +typedef struct { + QUEUE queue; /* Must be first */ -typedef void (*DISCOVERY_CALLBACK) ( DISCOVERY*); + __u16 hints; /* Hint bits */ +} irlmp_service_t; -struct irlmp_registration { +typedef struct { QUEUE queue; /* Must be first */ - int service; /* LAN, OBEX, COMM etc. */ - int type; /* Client or server or both */ + __u16 hint_mask; - DISCOVERY_CALLBACK discovery_callback; -}; + DISCOVERY_CALLBACK1 callback1; + DISCOVERY_CALLBACK2 callback2; +} irlmp_client_t; struct lap_cb; /* Forward decl. */ @@ -138,18 +131,15 @@ struct lap_cb { IRLMP_STATE lap_state; - struct irlap_cb *irlap; /* Instance of IrLAP layer */ - + struct irlap_cb *irlap; /* Instance of IrLAP layer */ hashbin_t *lsaps; /* LSAP associated with this link */ - __u8 caddr; /* Connection address */ - + __u8 caddr; /* Connection address */ __u32 saddr; /* Source device address */ __u32 daddr; /* Destination device address */ - hashbin_t *cachelog; /* Discovered devices for this link */ - struct qos_info *qos; /* LAP QoS for this session */ + struct timer_list idle_timer; }; /* @@ -171,10 +161,8 @@ struct irlmp_cb { __u8 conflict_flag; - /* int discovery; */ - - DISCOVERY discovery_rsp; /* Discovery response to use by IrLAP */ - DISCOVERY discovery_cmd; /* Discovery command to use by IrLAP */ + discovery_t discovery_cmd; /* Discovery command to use by IrLAP */ + discovery_t discovery_rsp; /* Discovery response to use by IrLAP */ int free_lsap_sel; @@ -185,55 +173,72 @@ struct irlmp_cb { hashbin_t *links; /* IrLAP connection table */ hashbin_t *unconnected_lsaps; - hashbin_t *registry; + hashbin_t *clients; + hashbin_t *services; - __u8 hint[2]; /* Hint bits */ + hashbin_t *cachelog; + int running; + + spinlock_t lock; + + __u16_host_order hints; /* Hint bits */ }; /* Prototype declarations */ int irlmp_init(void); void irlmp_cleanup(void); - struct lsap_cb *irlmp_open_lsap( __u8 slsap, struct notify_t *notify); void irlmp_close_lsap( struct lsap_cb *self); -void irlmp_register_layer( int service, int type, int do_discovery, - DISCOVERY_CALLBACK); -void irlmp_unregister_layer( int service, int type); - -void irlmp_register_irlap( struct irlap_cb *self, __u32 saddr, - struct notify_t *); -void irlmp_unregister_irlap( __u32 saddr); - -void irlmp_connect_request( struct lsap_cb *, __u8 dlsap_sel, __u32 daddr, - struct qos_info *, struct sk_buff *); -void irlmp_connect_indication( struct lsap_cb *self, struct sk_buff *skb); -void irlmp_connect_response( struct lsap_cb *, struct sk_buff *); -void irlmp_connect_confirm( struct lsap_cb *, struct sk_buff *); - - -void irlmp_disconnect_indication( struct lsap_cb *self, LM_REASON reason, - struct sk_buff *userdata); -void irlmp_disconnect_request( struct lsap_cb *, struct sk_buff *userdata); - -void irlmp_discovery_confirm( struct lap_cb *, hashbin_t *discovery_log); -void irlmp_discovery_indication( struct lap_cb *, DISCOVERY *discovery); -void irlmp_discovery_request( int nslots); -DISCOVERY *irlmp_get_discovery_response(void); - -void irlmp_data_request( struct lsap_cb *, struct sk_buff *); -void irlmp_udata_request( struct lsap_cb *, struct sk_buff *); -void irlmp_data_indication( struct lsap_cb *, struct sk_buff *); -void irlmp_udata_indication( struct lsap_cb *, struct sk_buff *); +__u16 irlmp_service_to_hint(int service); +__u32 irlmp_register_service(__u16 hints); +int irlmp_unregister_service(__u32 handle); +__u32 irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 callback1, + DISCOVERY_CALLBACK2 callback2); +int irlmp_unregister_client(__u32 handle); +int irlmp_update_client(__u32 handle, __u16 hint_mask, + DISCOVERY_CALLBACK1, DISCOVERY_CALLBACK2); + +void irlmp_register_link(struct irlap_cb *, __u32 saddr, struct notify_t *); +void irlmp_unregister_link(__u32 saddr); + +int irlmp_connect_request(struct lsap_cb *, __u8 dlsap_sel, + __u32 saddr, __u32 daddr, + struct qos_info *, struct sk_buff *); +void irlmp_connect_indication(struct lsap_cb *self, struct sk_buff *skb); +void irlmp_connect_response(struct lsap_cb *, struct sk_buff *); +void irlmp_connect_confirm(struct lsap_cb *, struct sk_buff *); +struct lsap_cb *irlmp_dup(struct lsap_cb *self, void *instance); + +void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason, + struct sk_buff *userdata); +void irlmp_disconnect_request(struct lsap_cb *, struct sk_buff *userdata); + +void irlmp_discovery_confirm(hashbin_t *discovery_log); +void irlmp_discovery_request(int nslots); +void irlmp_do_discovery(int nslots); +discovery_t *irlmp_get_discovery_response(void); + +void irlmp_data_request(struct lsap_cb *, struct sk_buff *); +inline void irlmp_udata_request(struct lsap_cb *, struct sk_buff *); +inline void irlmp_data_indication(struct lsap_cb *, struct sk_buff *); +inline void irlmp_udata_indication(struct lsap_cb *, struct sk_buff *); void irlmp_status_request(void); -void irlmp_status_indication( LINK_STATUS link, LOCK_STATUS lock); +void irlmp_status_indication(LINK_STATUS link, LOCK_STATUS lock); -int irlmp_slsap_inuse( __u8 slsap); +int irlmp_slsap_inuse(__u8 slsap); __u8 irlmp_find_free_slsap(void); +LM_REASON irlmp_convert_lap_reason(LAP_REASON); -LM_REASON irlmp_convert_lap_reason( LAP_REASON); +__u32 irlmp_get_saddr(struct lsap_cb *self); +__u32 irlmp_get_daddr(struct lsap_cb *self); +extern char *lmp_reasons[]; +extern int sysctl_discovery_slots; +extern int sysctl_discovery; extern struct irlmp_cb *irlmp; +static inline hashbin_t *irlmp_get_cachelog(void) { return irlmp->cachelog; } + #endif diff --git a/include/net/irda/irlmp_event.h b/include/net/irda/irlmp_event.h index 1ffb6faa5..b83627983 100644 --- a/include/net/irda/irlmp_event.h +++ b/include/net/irda/irlmp_event.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Mon Aug 4 20:40:53 1997 - * Modified at: Wed Oct 28 14:58:23 1998 + * Modified at: Thu Feb 25 20:49:16 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -72,7 +72,7 @@ typedef enum { LM_LAP_DISCONNECT_REQUEST, LM_LAP_DISCOVERY_REQUEST, LM_LAP_DISCOVERY_CONFIRM, - + LM_LAP_IDLE_TIMEOUT, } IRLMP_EVENT; /* @@ -92,14 +92,15 @@ struct irlmp_event { int reason; - DISCOVERY *discovery; + discovery_t *discovery; }; -extern char *irlmp_state[]; -extern char *irlsap_state[]; +extern const char *irlmp_state[]; +extern const char *irlsap_state[]; void irlmp_watchdog_timer_expired( unsigned long data); void irlmp_discovery_timer_expired( unsigned long data); +void irlmp_idle_timer_expired( unsigned long data); void irlmp_next_station_state( IRLMP_STATE state); void irlmp_next_lsap_state( struct lsap_cb *self, LSAP_STATE state); diff --git a/include/net/irda/irlmp_frame.h b/include/net/irda/irlmp_frame.h index 64960f31d..d0584f1a7 100644 --- a/include/net/irda/irlmp_frame.h +++ b/include/net/irda/irlmp_frame.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irlmp_frame.h - * Version: 0.1 + * Version: 0.9 * Description: * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Tue Aug 19 02:09:59 1997 - * Modified at: Sun Oct 25 00:30:31 1998 + * Modified at: Tue Apr 6 17:12:57 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -27,31 +27,31 @@ #include <linux/skbuff.h> -/* Frame opcodes */ +#include <net/irda/discovery.h> + +/* IrLMP frame opcodes */ #define CONNECT_CMD 0x01 #define CONNECT_CNF 0x81 #define DISCONNECT 0x02 #define ACCESSMODE_CMD 0x03 #define ACCESSMODE_CNF 0x83 -#define CONTROL_BIT 0x80 +#define CONTROL_BIT 0x80 -inline void irlmp_send_data_pdu( struct lap_cb *self, __u8 dlsap, __u8 slsap, - int expedited, struct sk_buff *skb); -void irlmp_send_lcf_pdu( struct lap_cb *self, __u8 dlsap, __u8 slsap, - __u8 opcode, struct sk_buff *skb); -void irlmp_link_data_indication( struct lap_cb *, int reliable, - struct sk_buff *); -void irlmp_link_connect_indication( struct lap_cb *, struct qos_info *qos, - struct sk_buff *skb); -void irlmp_link_connect_request( __u32 daddr); -void irlmp_link_connect_confirm( struct lap_cb *self, struct qos_info *qos, - struct sk_buff *skb); -void irlmp_link_disconnect_indication( struct lap_cb *self, - struct irlap_cb *irlap, - LAP_REASON reason, - struct sk_buff *); -void irlmp_link_discovery_confirm( struct lap_cb *self, hashbin_t *log); -/* void irlmp_link_disconnect_request( void); */ +inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, + int expedited, struct sk_buff *skb); +void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, + __u8 opcode, struct sk_buff *skb); +void irlmp_link_data_indication(struct lap_cb *, int reliable, + struct sk_buff *); +void irlmp_link_connect_indication(struct lap_cb *, __u32 saddr, __u32 daddr, + struct qos_info *qos, struct sk_buff *skb); +void irlmp_link_connect_request(__u32 daddr); +void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos, + struct sk_buff *skb); +void irlmp_link_disconnect_indication(struct lap_cb *, struct irlap_cb *, + LAP_REASON reason, struct sk_buff *); +void irlmp_link_discovery_confirm(struct lap_cb *self, hashbin_t *log); +void irlmp_link_discovery_indication(struct lap_cb *, discovery_t *discovery); #endif diff --git a/include/net/irda/irlpt_cli.h b/include/net/irda/irlpt_cli.h index 1a54c68eb..ab3178885 100644 --- a/include/net/irda/irlpt_cli.h +++ b/include/net/irda/irlpt_cli.h @@ -1,12 +1,12 @@ /********************************************************************* * - * Filename: irlpt_client.h + * Filename: irlpt_cli.h * Version: 0.1 * Description: * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sat Feb 21 18:54:38 1998 - * Modified at: Mon Jan 11 15:58:16 1999 + * Modified at: Wed Apr 21 16:46:26 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net> @@ -34,9 +34,11 @@ * if it's static, it doesn't go in here. */ -void irlpt_client_get_value_confirm(__u16 obj_id, - struct ias_value *value, void *priv); -void irlpt_client_connect_indication( void *instance, void *sap, +void irlpt_client_get_value_confirm(int result, __u16 obj_id, + struct ias_value *value, + void *priv); +void irlpt_client_connect_indication( void *instance, + void *sap, struct qos_info *qos, int max_seg_size, struct sk_buff *skb); diff --git a/include/net/irda/irlpt_cli_fsm.h b/include/net/irda/irlpt_cli_fsm.h index 4013c2f4d..b6fd153a5 100644 --- a/include/net/irda/irlpt_cli_fsm.h +++ b/include/net/irda/irlpt_cli_fsm.h @@ -1,19 +1,21 @@ /********************************************************************* * - * Filename: irlpt_client_fsm.h + * Filename: irlpt_cli_fsm.h * Version: 0.1 * Sources: irlan_event.h * - * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. - * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, All Rights Reserved. + * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, + * All Rights Reserved. + * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, + * 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. * - * I, Thomas Davis, provide no warranty for any of this software. This material is - * provided "AS-IS" and at no charge. + * I, Thomas Davis, provide no warranty for any of this software. + * This material is provided "AS-IS" and at no charge. * ********************************************************************/ diff --git a/include/net/irda/irlpt_common.h b/include/net/irda/irlpt_common.h index 0e51b017a..83a9c307c 100644 --- a/include/net/irda/irlpt_common.h +++ b/include/net/irda/irlpt_common.h @@ -1,6 +1,6 @@ /********************************************************************* * - * Filename: irlpt.c + * Filename: irlpt_common.h * Version: * Description: * Status: Experimental. @@ -67,7 +67,6 @@ typedef enum { IRLPT_CLIENT_QUERY, IRLPT_CLIENT_READY, IRLPT_CLIENT_WAITI, - IRLPT_CLIENT_WAITR, IRLPT_CLIENT_CONN, } IRLPT_CLIENT_STATE; @@ -87,10 +86,6 @@ typedef enum { LMP_DISCONNECT, LMP_CONNECT_INDICATION, LMP_DISCONNECT_INDICATION, -#if 0 - TTP_CONNECT_INDICATION, - TTP_DISCONNECT_INDICATION, -#endif IRLPT_DISCOVERY_INDICATION, IRLPT_CONNECT_REQUEST, IRLPT_DISCONNECT_REQUEST, @@ -101,6 +96,7 @@ struct irlpt_info { struct lsap_cb *lsap; __u8 dlsap_sel; __u32 daddr; + __u32 saddr; }; /* Command packet types */ @@ -142,7 +138,8 @@ struct irlpt_cb { int magic; /* magic used to detect corruption of the struct */ - __u32 daddr; /* my local address. */ + __u32 daddr; /* address of remote printer */ + __u32 saddr; /* my local address. */ struct timer_list retry_timer; @@ -168,6 +165,14 @@ struct irlpt_cb { struct wait_queue *write_wait; struct wait_queue *ex_wait; + /* this is used to remove the printer when it's gone */ + struct timer_list lpt_timer; + void (*timeout) (unsigned long data); + + void (*do_event) (struct irlpt_cb *self, IRLPT_EVENT event, + struct sk_buff *skb, + struct irlpt_info *info); + /* this is used by the server side of the system */ IRLPT_SERVER_STATE connected; diff --git a/include/net/irda/irlpt_server.h b/include/net/irda/irlpt_server.h index 7984a331d..44e310f95 100644 --- a/include/net/irda/irlpt_server.h +++ b/include/net/irda/irlpt_server.h @@ -1,6 +1,6 @@ /********************************************************************* * - * Filename: server.h + * Filename: irlpt_server.h * Version: 0.1 * Description: * Status: Experimental. diff --git a/include/net/irda/irlpt_server_fsm.h b/include/net/irda/irlpt_server_fsm.h index 8f23226c3..c7ee3f871 100644 --- a/include/net/irda/irlpt_server_fsm.h +++ b/include/net/irda/irlpt_server_fsm.h @@ -1,19 +1,21 @@ /********************************************************************* * - * Filename: server_fsm.h<2> + * Filename: server_server_fsm.h * Version: 0.1 * Sources: irlan_event.h * - * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. - * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, All Rights Reserved. + * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, + * All Rights Reserved. + * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, + * 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. * - * I, Thomas Davis, provide no warranty for any of this software. This material is - * provided "AS-IS" and at no charge. + * I, Thomas Davis, provide no warranty for any of this software. + * This material is provided "AS-IS" and at no charge. * ********************************************************************/ @@ -23,8 +25,11 @@ #include <linux/kernel.h> #include <linux/skbuff.h> -void irlpt_server_do_event( struct irlpt_cb *self, IRLPT_EVENT event, - struct sk_buff *skb, struct irlpt_info *info); -void irlpt_server_next_state( struct irlpt_cb *self, IRLPT_SERVER_STATE state); +void irlpt_server_do_event( struct irlpt_cb *self, + IRLPT_EVENT event, + struct sk_buff *skb, + struct irlpt_info *info); +void irlpt_server_next_state( struct irlpt_cb *self, + IRLPT_SERVER_STATE state); #endif diff --git a/include/net/irda/irmod.h b/include/net/irda/irmod.h index a2f592572..651e87dbc 100644 --- a/include/net/irda/irmod.h +++ b/include/net/irda/irmod.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Mon Dec 15 13:58:52 1997 - * Modified at: Tue Jan 12 14:56:11 1999 + * Modified at: Fri Apr 9 11:13:39 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -29,7 +29,6 @@ #include <linux/miscdevice.h> #include <net/irda/irqueue.h> -#include <net/irda/qos.h> #define IRMGR_IOC_MAGIC 'm' #define IRMGR_IOCTNPC _IO(IRMGR_IOC_MAGIC, 1) @@ -99,167 +98,43 @@ struct irda_cb { QUEUE *todo_queue; /* Todo list */ }; -typedef struct { - char irda_call[7]; /* 6 call + SSID (shifted ascii!) */ -} irda_address; - -struct sockaddr_irda { - short sirda_family; - irda_address sirda_call; - int sirda_ndigis; -}; - -/* - * This type is used by the protocols that transmit 16 bits words in - * little endian format. A little endian machine stores MSB of word in - * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] - * and LSB in byte[1]. - */ -typedef union { - __u16 word; - __u8 byte[2]; -} __u16_host_order; +int irmod_init_module(void); +void irmod_cleanup_module(void); /* - * Information monitored by some layers + * Function irda_lock (lock) + * + * Lock variable. Returns false if the lock is already set. + * */ -struct irda_statistics +static inline int irda_lock(int *lock) { - int rx_packets; /* total packets received */ - int tx_packets; /* total packets transmitted */ - int rx_errors; /* bad packets received */ - int tx_errors; /* packet transmit problems */ - int rx_dropped; /* no space in linux buffers */ - int tx_dropped; /* no space available in linux */ - int rx_compressed; - int tx_compressed; - int rx_bytes; /* total bytes received */ - int tx_bytes; /* total bytes transmitted */ + if (test_and_set_bit( 0, (void *) lock)) { + DEBUG(3, __FUNCTION__ + "(), Trying to lock, already locked variable!\n"); + return FALSE; + } + return TRUE; +} - int multicast; /* multicast packets received */ - int collisions; - - /* detailed rx_errors: */ - int rx_length_errors; - int rx_over_errors; /* receiver ring buff overflow */ - int rx_crc_errors; /* recved pkt with crc error */ - int rx_frame_errors; /* recv'd frame alignment error */ - int rx_fifo_errors; /* recv'r fifo overrun */ - int rx_missed_errors; /* receiver missed packet */ +inline int irda_unlock(int *lock); - /* detailed tx_errors */ - int tx_aborted_errors; - int tx_carrier_errors; - int tx_fifo_errors; - int tx_heartbeat_errors; - int tx_window_errors; -}; +void irda_notify_init(struct notify_t *notify); -typedef enum { - NO_CHANGE, - LOCKED, - UNLOCKED, -} LOCK_STATUS; +void irda_execute_as_process(void *self, TODO_CALLBACK callback, __u32 param); +void irmanager_notify(struct irmanager_event *event); -/* Misc status information */ -typedef enum { - STATUS_OK, - STATUS_ABORTED, - STATUS_NO_ACTIVITY, - STATUS_NOISY, - STATUS_REMOTE, -} LINK_STATUS; +extern void irda_proc_modcount(struct inode *, int); +void irda_mod_inc_use_count(void); +void irda_mod_dec_use_count(void); -typedef enum { /* FIXME check the two first reason codes */ - LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */ - LAP_NO_RESPONSE, /* To many retransmits without response */ - LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */ - LAP_FOUND_NONE, /* No devices were discovered */ - LAP_MEDIA_BUSY, - LAP_PRIMARY_CONFLICT, -} LAP_REASON; +#endif /* IRMOD_H */ -/* - * IrLMP disconnect reasons. The order is very important, since they - * correspond to disconnect reasons sent in IrLMP disconnect frames, so - * please do not touch :-) - */ -typedef enum { - LM_USER_REQUEST = 1, /* User request */ - LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */ - LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */ - LM_LAP_RESET, /* IrLAP reset */ - LM_INIT_DISCONNECT, /* Link Management initiated disconnect */ -} LM_REASON; /* FIXME: Just for now */ -/* - * 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 - -/* - * The DISCOVERY structure is used for both discovery requests and responses - */ -#define DISCOVERY struct discovery_t -struct discovery_t { - QUEUE queue; /* Must be first! */ - - __u32 saddr; /* Which link the device was discovered */ - __u32 daddr; /* Remote device address */ - LAP_REASON condition; /* More info about the discovery */ - - __u8 hint[2]; /* Discovery hint bits */ - __u8 charset; - char info[32]; /* Usually the name of the device */ - __u8 info_len; /* Length of device info field */ - - int gen_addr_bit; /* Need to generate a new device address? */ -}; -typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW; -/* - * Notify structure used between transport and link management layers - */ -struct notify_t { - void (*data_indication)( void *instance, void *sap, - struct sk_buff *skb); - void (*udata_indication)( void *instance, void *sap, - struct sk_buff *skb); - void (*connect_confirm)( void *instance, void *sap, - struct qos_info *qos, int max_sdu_size, - struct sk_buff *skb); - void (*connect_indication)( void *instance, void *sap, - struct qos_info *qos, int max_sdu_size, - struct sk_buff *skb); - void (*disconnect_indication)( void *instance, void *sap, - LM_REASON reason, struct sk_buff *); - void (*flow_indication)( void *instance, void *sap, LOCAL_FLOW flow); - void *instance; /* Layer instance pointer */ - char name[16]; /* Name of layer */ -}; -#define NOTIFY_MAX_NAME 16 - -int irmod_init_module(void); -void irmod_cleanup_module(void); -inline int irda_lock( int *lock); -inline int irda_unlock( int *lock); -void irda_notify_init( struct notify_t *notify); -void irda_execute_as_process( void *self, TODO_CALLBACK callback, __u32 param); -void irmanager_notify( struct irmanager_event *event); -#endif diff --git a/include/net/irda/irobex.h b/include/net/irda/irobex.h deleted file mode 100644 index 8f69707d0..000000000 --- a/include/net/irda/irobex.h +++ /dev/null @@ -1,135 +0,0 @@ -/********************************************************************* - * - * Filename: irobex.h - * Version: - * Description: - * Status: Experimental. - * Author: Dag Brattli <dagb@cs.uit.no> - * Created at: Sat Jul 4 22:43:57 1998 - * Modified at: Wed Jan 13 15:55:28 1999 - * Modified by: Dag Brattli <dagb@cs.uit.no> - * - * Copyright (c) 1998 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 IROBEX_H -#define IROBEX_H - -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/skbuff.h> -/* #include <linux/netdevice.h> */ -#include <linux/miscdevice.h> - -#include <net/irda/timer.h> -#include <net/irda/qos.h> -#include <net/irda/irmod.h> - -#define LOW_THRESHOLD 4 -#define HIGH_THRESHOLD 8 -#define IROBEX_MAX_QUEUE 12 - -/* Small structure to be used by the IOCTL call */ -struct irobex_ioc_t { - __u32 daddr; -}; - -#define IROBEX_IOC_MAGIC 'k' - -#define IROBEX_IOCSCONNECT _IOW(IROBEX_IOC_MAGIC, 1, 4) -#define IROBEX_IOCSDISCONNECT _IOW(IROBEX_IOC_MAGIC, 2, 4) -#define IROBEX_IOC_MAXNR 2 - -#define IROBEX_MAX_HEADER (TTP_HEADER+LMP_HEADER+LAP_HEADER) - -typedef enum { - OBEX_IDLE, /* Doing nothing */ - OBEX_DISCOVER, /* Trying to discovery remote device */ - OBEX_QUERY, /* Querying remote LM-IAS */ - OBEX_CONN, /* Trying to connect to remote device */ - OBEX_DATA, /* Data transfer ready */ -} OBEX_STATE; - -struct irobex_cb { - QUEUE queue; /* Must be first! */ - - int magic; /* magic used to detect corruption of the struct */ - - OBEX_STATE state; /* Current state */ - - __u32 saddr; /* my local address */ - __u32 daddr; /* peer address */ - unsigned long time_discovered; - - char devname[9]; /* name of the registered device */ - struct tsap_cb *tsap; - int eof; - - __u8 dtsap_sel; /* remote TSAP address */ - __u8 stsap_sel; /* local TSAP address */ - - int irlap_data_size; - - struct miscdevice dev; - - int count; /* open count */ - - struct sk_buff_head rx_queue; /* Receive queue */ - - struct wait_queue *read_wait; - struct wait_queue *write_wait; - - struct fasync_struct *async; - - struct timer_list watchdog_timer; - - LOCAL_FLOW tx_flow; - LOCAL_FLOW rx_flow; -}; - -int irobex_init(void); -void irobex_cleanup(void); -struct irobex_cb *irobex_open(void); -void irobex_close( struct irobex_cb *self); - -void irobex_discovery_indication( DISCOVERY *); - -void irobex_data_request( int handle, struct sk_buff *skb); -void irobex_data_indication( void *instance, void *sap, struct sk_buff *skb); -void irobex_control_data_indication( void *instance, void *sap, - struct sk_buff *skb); - -void irobex_connect_request( struct irobex_cb *self); -void irobex_connect(struct irobex_cb *self, struct sk_buff *skb); -void irobex_connect_confirm( void *instance, void *sap, struct qos_info *qos, - int max_sdu_size, struct sk_buff *skb); -void irobex_disconnect_indication( void *instance, void *sap, LM_REASON reason, - struct sk_buff *skb); -void irobex_flow_indication( void *instance, void *sap, LOCAL_FLOW flow); - -void irobex_extract_params( struct sk_buff *skb); -void irobex_get_value_confirm(__u16 obj_id, struct ias_value *value, - void *priv); -void irobex_register_server( struct irobex_cb *self); - -void irobex_watchdog_timer_expired( unsigned long data); - -inline void irobex_start_watchdog_timer( struct irobex_cb *self, int timeout) -{ - irda_start_timer( &self->watchdog_timer, timeout, (unsigned long) self, - irobex_watchdog_timer_expired); -} - -extern struct irobex_cb *irobex; - -#endif diff --git a/include/net/irda/irqueue.h b/include/net/irda/irqueue.h index 0551e3b52..1e208ccf4 100644 --- a/include/net/irda/irqueue.h +++ b/include/net/irda/irqueue.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Tue Jun 9 13:26:50 1998 - * Modified at: Sun Oct 25 00:26:31 1998 + * Modified at: Thu Feb 25 20:34:21 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (C) 1998, Aage Kvalnes <aage@cs.uit.no> @@ -30,7 +30,7 @@ #include <linux/types.h> #include <asm/spinlock.h> -#include <net/irda/irda.h> +/* #include <net/irda/irda.h> */ #ifndef QUEUE_H #define QUEUE_H @@ -51,6 +51,10 @@ #define HASHBIN_SIZE 8 #define HASHBIN_MASK 0x7 +#ifndef ALIGN +#define ALIGN __attribute__((aligned)) +#endif + typedef void (*FREE_FUNC)( void *arg); /* diff --git a/include/net/irda/irttp.h b/include/net/irda/irttp.h index 02a486dd5..aec1d57dc 100644 --- a/include/net/irda/irttp.h +++ b/include/net/irda/irttp.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irttp.h - * Version: 0.3 + * Version: 1.0 * Description: Tiny Transport Protocol (TTP) definitions * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sun Aug 31 20:14:31 1997 - * Modified at: Sat Dec 5 13:48:12 1998 + * Modified at: Sat Apr 10 10:19:56 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -27,42 +27,44 @@ #include <linux/types.h> #include <linux/skbuff.h> +#include <asm/spinlock.h> -#include <net/irda/irmod.h> +#include <net/irda/irda.h> #include <net/irda/irlmp.h> #include <net/irda/qos.h> #include <net/irda/irqueue.h> -#define TTP_MAX_CONNECTIONS LM_MAX_CONNECTIONS -#define TTP_HEADER 1 -#define TTP_HEADER_WITH_SAR 6 -#define TTP_PARAMETERS 0x80 -#define TTP_MORE 0x80 +#define TTP_MAX_CONNECTIONS LM_MAX_CONNECTIONS +#define TTP_HEADER 1 +#define TTP_HEADER_WITH_SAR 6 +#define TTP_PARAMETERS 0x80 +#define TTP_MORE 0x80 #define DEFAULT_INITIAL_CREDIT 22 -#define LOW_THRESHOLD 4 -#define HIGH_THRESHOLD 8 -#define TTP_MAX_QUEUE 22 +#define LOW_THRESHOLD 4 +#define HIGH_THRESHOLD 8 +#define TTP_MAX_QUEUE 22 /* Some priorities for disconnect requests */ -#define P_NORMAL 0 -#define P_HIGH 1 +#define P_NORMAL 0 +#define P_HIGH 1 #define SAR_DISABLE 0 +#define SAR_UNBOUND 0xffffffff /* * This structure contains all data assosiated with one instance of a TTP * connection. */ struct tsap_cb { - QUEUE queue; /* For linking it into the hashbin */ - int magic; /* Just in case */ + QUEUE queue; /* For linking it into the hashbin */ + int magic; /* Just in case */ - int max_seg_size; /* Max data that fit into an IrLAP frame */ + int max_seg_size; /* Max data that fit into an IrLAP frame */ - __u8 stsap_sel; /* Source TSAP */ - __u8 dtsap_sel; /* Destination TSAP */ + __u8 stsap_sel; /* Source TSAP */ + __u8 dtsap_sel; /* Destination TSAP */ struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */ @@ -79,21 +81,21 @@ struct tsap_cb { struct sk_buff_head rx_fragments; int tx_queue_lock; int rx_queue_lock; + spinlock_t lock; struct notify_t notify; /* Callbacks to client layer */ struct irda_statistics stats; struct timer_list todo_timer; - int rx_sdu_busy; /* RxSdu.busy */ - int rx_sdu_size; /* The current size of a partially received frame */ - int rx_max_sdu_size; /* Max receive user data size */ + int rx_sdu_busy; /* RxSdu.busy */ + __u32 rx_sdu_size; /* Current size of a partially received frame */ + __u32 rx_max_sdu_size; /* Max receive user data size */ - int tx_sdu_busy; /* TxSdu.busy */ - int tx_max_sdu_size; /* Max transmit user data size */ - - int no_defrag; /* Don't reassemble received fragments */ + int tx_sdu_busy; /* TxSdu.busy */ + __u32 tx_max_sdu_size; /* Max transmit user data size */ + int close_pend; /* Close, but disconnect_pend */ int disconnect_pend; /* Disconnect, but still data to send */ struct sk_buff *disconnect_skb; }; @@ -107,28 +109,34 @@ struct irttp_cb { int irttp_init(void); void irttp_cleanup(void); -struct tsap_cb *irttp_open_tsap( __u8 stsap, int credit, - struct notify_t *notify); -void irttp_close_tsap( struct tsap_cb *self); +struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, + struct notify_t *notify); +int irttp_close_tsap(struct tsap_cb *self); -int irttp_data_request( struct tsap_cb *self, struct sk_buff *skb); -int irttp_udata_request( struct tsap_cb *self, struct sk_buff *skb); +int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb); +int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb); -void irttp_connect_request( struct tsap_cb *self, __u8 dtsap_sel, __u32 daddr, - struct qos_info *qos, int max_sdu_size, +int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, + __u32 saddr, __u32 daddr, + struct qos_info *qos, __u32 max_sdu_size, + struct sk_buff *userdata); +void irttp_connect_confirm(void *instance, void *sap, struct qos_info *qos, + __u32 max_sdu_size, struct sk_buff *skb); +void irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, struct sk_buff *userdata); -void irttp_connect_confirm( void *instance, void *sap, struct qos_info *qos, - int max_sdu_size, struct sk_buff *skb); -void irttp_connect_response( struct tsap_cb *self, int max_sdu_size, - struct sk_buff *userdata); +struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance); +void irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb, + int priority); +void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow); -void irttp_disconnect_request( struct tsap_cb *self, struct sk_buff *skb, - int priority); -void irttp_flow_request( struct tsap_cb *self, LOCAL_FLOW flow); +static __inline __u32 irttp_get_saddr(struct tsap_cb *self) +{ + return irlmp_get_saddr(self->lsap); +} -static __inline__ void irttp_no_reassemble( struct tsap_cb *self) +static __inline __u32 irttp_get_daddr(struct tsap_cb *self) { - self->no_defrag = TRUE; + return irlmp_get_daddr(self->lsap); } extern struct irttp_cb *irttp; diff --git a/include/net/irda/irtty.h b/include/net/irda/irtty.h index 313a32d9b..920909600 100644 --- a/include/net/irda/irtty.h +++ b/include/net/irda/irtty.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: irtty.h - * Version: 0.1 + * Version: 1.0 * Description: * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Tue Dec 9 21:13:12 1997 - * Modified at: Mon Dec 14 11:22:37 1998 + * Modified at: Sun Feb 7 01:57:33 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997 Dag Brattli, All Rights Reserved. @@ -65,4 +65,6 @@ struct irtty_cb { int irtty_register_dongle( struct dongle *dongle); void irtty_unregister_dongle( struct dongle *dongle); +void irtty_set_dtr_rts(struct tty_struct *tty, int dtr, int rts); + #endif diff --git a/include/net/irda/irvtd.h b/include/net/irda/irvtd.h index 43d61c9c0..1fc7d6b0f 100644 --- a/include/net/irda/irvtd.h +++ b/include/net/irda/irvtd.h @@ -17,12 +17,13 @@ * ********************************************************************/ -#ifndef IRCOMM_H -#define IRCOMM_H +#ifndef IRVTD_H +#define IRVTD_H #include <linux/types.h> #include <linux/ioctl.h> #include <linux/tqueue.h> +#include <linux/serial.h> #include <net/irda/irmod.h> #include <net/irda/qos.h> @@ -34,18 +35,11 @@ #define IRVTD_RX_QUEUE_HIGH 10 #define IRVTD_RX_QUEUE_LOW 2 +#define IRCOMM_MAJOR 60; /* Zero means automatic allocation + 60,61,62,and 63 is reserved for experiment */ +#define IRVTD_MINOR 64 + -/* - * Serial input interrupt line counters -- external structure - * Four lines can interrupt: CTS, DSR, RI, DCD - * - * this structure must be compatible with serial_icounter_struct defined in - * <linux/serial.h>. - */ -struct icounter_struct { - int cts, dsr, rng, dcd; - int reserved[16]; -}; struct irvtd_cb { @@ -53,9 +47,10 @@ struct irvtd_cb { /* if daddr is NULL, remote device have not been discovered yet */ + int tx_disable; int rx_disable; - struct sk_buff *txbuff; /* buffer queue */ - struct sk_buff_head rxbuff; /* buffer queue */ + struct sk_buff *txbuff; + struct sk_buff_head rxbuff; struct ircomm_cb *comm; /* ircomm instance */ /* @@ -63,7 +58,6 @@ struct irvtd_cb { * See linux/serial.h */ - int baud_base; int flags; struct tty_struct *tty; @@ -75,30 +69,24 @@ struct irvtd_cb { struct wait_queue *delta_msr_wait; struct wait_queue *tx_wait; - struct tq_struct rx_tqueue; + struct timer_list timer; long pgrp; long session; - struct termios normal_termios; - struct termios callout_termios; unsigned short closing_wait; /* time to wait before closing */ unsigned short close_delay; + int custom_divisor; int mcr; int msr; int cts_stoptx; int ttp_stoptx; int ttp_stoprx; - struct icounter_struct icount; + int disconnect_pend; + struct serial_icounter_struct icount; int read_status_mask; int ignore_status_mask; }; -/* Debug function */ - -/* #define CHECK_SKB(skb) check_skb((skb), __LINE__,__FILE__) */ - - - #endif diff --git a/include/net/irda/irvtd_driver.h b/include/net/irda/irvtd_driver.h deleted file mode 100644 index 4983b3d2c..000000000 --- a/include/net/irda/irvtd_driver.h +++ /dev/null @@ -1,122 +0,0 @@ -/********************************************************************* - * - * Filename: irvtd_driver.h - * Version: 0.1 - * - * Copyright (c) 1998, Takahide Higuchi <thiguchi@pluto.dti.ne.jp>, - * 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. - * - * I, Takahide Higuchi, provide no warranty for any of this software. - * This material is provided "AS-IS" and at no charge. - * - ********************************************************************/ - -#include <linux/tty.h> - -#include <net/irda/irlap.h> -#include <net/irda/irlmp.h> -#include <net/irda/irttp.h> - - -#define VSP_TYPE_NORMAL 1 -#define VSP_TYPE_CALLOUT 2 -#define IRCOMM_MAJOR 60; /* Zero means automatic allocation - 60,61,62,and 63 is reserved for experiment */ -#define IRVTD_MINOR 64 -#define IRVTD_CALLOUT_MINOR 32 - -#define IRVTD_TYPE_NORMAL 11 -#define IRVTD_TYPE_CALLOUT 12 - - -#define IRCOMM_HEADER 1 -#define IRCOMM_RESERVE LAP_HEADER+LMP_HEADER+TTP_HEADER+IRCOMM_HEADER - - - - - -/* - * Definitions for ircomm_cb_struct flags field - * this section is "stolen" from linux-kernel (drivers/char/serial.c) - */ -#define IRVTD_ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes - on the callout port */ -/* #define IRVTD_ASYNC_FOURPORT 0x0002 */ -/* Set OU1, OUT2 per AST Fourport settings */ - -#define IRVTD_ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ - -#define IRVTD_ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ - -#define IRVTD_ASYNC_SPD_MASK 0x0030 -#define IRVTD_ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ - -#define IRVTD_ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ -#define IRVTD_ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ - -#define IRVTD_ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ -#define IRVTD_ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ -#define IRVTD_ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ -#define IRVTD_ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ -#define IRVTD_ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ - -#define IRVTD_ASYNC_FLAGS 0x0FFF /* Possible legal async flags */ -#define IRVTD_ASYNC_USR_MASK 0x0430 /* Legal flags that non-privileged - * users can set or reset */ - -/* Internal flags used only by kernel/chr_drv/serial.c */ -#define IRVTD_ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ -#define IRVTD_ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */ -#define IRVTD_ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ -#define IRVTD_ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ -#define IRVTD_ASYNC_CLOSING 0x08000000 /* Serial port is closing */ -#define IRVTD_ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ -#define IRVTD_ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ -#define IRVTD_ASYNC_SHARE_IRQ 0x01000000 /* for multifunction cards */ - - -#define IRVTD_ASYNC_CLOSING_WAIT_INF 0 -#define IRVTD_ASYNC_CLOSING_WAIT_NONE 65535 - -/**************************************/ - -#define DELTA_DTR 0x01 -#define DELTA_RTS 0x02 -#define MCR_DTR 0x04 -#define MCR_RTS 0x08 - -#define DELTA_CTS 0x01 -#define DELTA_DSR 0x02 -#define DELTA_RI 0x04 -#define DELTA_DCD 0x08 -#define MSR_CTS 0x10 -#define MSR_DSR 0x20 -#define MSR_RI 0x40 -#define MSR_DCD 0x80 - -#define LSR_OE 0x02 /* Overrun error indicator */ -#define LSR_PE 0x04 /* Parity error indicator */ -#define LSR_FE 0x08 /* Frame error indicator */ -#define LSR_BI 0x01 /* Break interrupt indicator */ - - - -/**************************************/ - - - - -int irvtd_register_ttydriver(void); -void irvtd_unregister_ttydriver(void); - -void irvtd_flush_chars(struct tty_struct *tty); - - - - diff --git a/include/net/irda/pc87108.h b/include/net/irda/pc87108.h index ed47bdc1b..8be4feea1 100644 --- a/include/net/irda/pc87108.h +++ b/include/net/irda/pc87108.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Fri Nov 13 14:37:40 1998 - * Modified at: Thu Dec 10 19:58:20 1998 + * Modified at: Mon Jan 25 23:10:25 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no> @@ -148,8 +148,8 @@ #define FRM_ST_MAX_LEN 0x10 /* Max frame len exceeded */ #define FRM_ST_PHY_ERR 0x08 /* Physical layer error */ #define FRM_ST_BAD_CRC 0x04 -#define FRM_ST_OVR2 0x02 /* Receive overrun */ -#define FRM_ST_OVR1 0x01 /* Frame status FIFO overrun */ +#define FRM_ST_OVR1 0x02 /* Receive overrun */ +#define FRM_ST_OVR2 0x01 /* Frame status FIFO overrun */ #define RFLFL 0x06 #define RFLFH 0x07 diff --git a/include/net/irda/timer.h b/include/net/irda/timer.h index 35a5be260..6c194a3d4 100644 --- a/include/net/irda/timer.h +++ b/include/net/irda/timer.h @@ -6,7 +6,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sat Aug 16 00:59:29 1997 - * Modified at: Mon Nov 2 14:31:55 1998 + * Modified at: Tue Apr 6 16:17:16 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1997, 1998 Dag Brattli <dagb@cs.uit.no>, @@ -26,54 +26,57 @@ #ifndef TIMER_H #define TIMER_H -#include "irda.h" -#include "irmod.h" -#include "irlap.h" -#include "irlmp.h" -#include "irda_device.h" +#include <asm/param.h> /* for HZ */ + +#include <net/irda/irda.h> +#include <net/irda/irmod.h> +#include <net/irda/irlap.h> +#include <net/irda/irlmp.h> +#include <net/irda/irda_device.h> /* * Timeout definitions, some defined in IrLAP p. 92 */ -#define POLL_TIMEOUT 45 /* Must never exceed 500 ms */ -#define FINAL_TIMEOUT 50 /* Must never exceed 500 ms */ +#define POLL_TIMEOUT 450*HZ/1000 /* Must never exceed 500 ms */ +#define FINAL_TIMEOUT 500*HZ/1000 /* Must never exceed 500 ms */ /* * Normally twice of p-timer. Note 3, IrLAP p. 60 suggests at least twice * duration of the P-timer. */ #define WD_TIMEOUT POLL_TIMEOUT*2 -#define MEDIABUSY_TIMEOUT 50 /* 500 msec */ +#define MEDIABUSY_TIMEOUT 500*HZ/1000 /* 500 msec */ /* * Slot timer must never exceed 85 ms, and must always be at least 25 ms, * suggested to 75-85 msec by IrDA lite */ -#define SLOT_TIMEOUT 8 -#define QUERY_TIMEOUT 100 +#define SLOT_TIMEOUT 80*HZ/1000 +#define QUERY_TIMEOUT HZ /* 1 sec */ -#define WATCHDOG_TIMEOUT 2000 /* 20 sec */ -#define RETRY_TIMEOUT 51 +#define WATCHDOG_TIMEOUT 20*HZ /* 20 sec */ -typedef void (*TIMER_CALLBACK)( unsigned long); +typedef void (*TIMER_CALLBACK)(unsigned long); -void irda_start_timer( struct timer_list *ptimer, int timeout, int data, - TIMER_CALLBACK callback); +void irda_start_timer(struct timer_list *ptimer, int timeout, int data, + TIMER_CALLBACK callback); -inline void irlap_start_slot_timer( struct irlap_cb *self, int timeout); -inline void irlap_start_query_timer( struct irlap_cb *self, int timeout); -inline void irlap_start_final_timer( struct irlap_cb *self, int timeout); -inline void irlap_start_wd_timer( struct irlap_cb *self, int timeout); -inline void irlap_start_backoff_timer( struct irlap_cb *self, int timeout); +inline void irlap_start_slot_timer(struct irlap_cb *self, int timeout); +inline void irlap_start_query_timer(struct irlap_cb *self, int timeout); +inline void irlap_start_final_timer(struct irlap_cb *self, int timeout); +inline void irlap_start_wd_timer(struct irlap_cb *self, int timeout); +inline void irlap_start_backoff_timer(struct irlap_cb *self, int timeout); -inline void irda_device_start_mbusy_timer( struct irda_device *self); +inline void irda_device_start_mbusy_timer(struct irda_device *self); struct lsap_cb; -inline void irlmp_start_watchdog_timer( struct lsap_cb *, int timeout); -inline void irlmp_start_discovery_timer( struct irlmp_cb *, int timeout); +struct lap_cb; +inline void irlmp_start_watchdog_timer(struct lsap_cb *, int timeout); +inline void irlmp_start_discovery_timer(struct irlmp_cb *, int timeout); +inline void irlmp_start_idle_timer(struct lap_cb *, int timeout); struct irobex_cb; -inline void irobex_start_watchdog_timer( struct irobex_cb *, int timeout); +inline void irobex_start_watchdog_timer(struct irobex_cb *, int timeout); #endif diff --git a/include/net/irda/uircc.h b/include/net/irda/uircc.h index a8b4c02dd..adab0c74f 100644 --- a/include/net/irda/uircc.h +++ b/include/net/irda/uircc.h @@ -7,7 +7,7 @@ * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sat Dec 26 11:00:49 1998 - * Modified at: Tue Jan 19 23:52:46 1999 + * Modified at: Thu Mar 11 01:37:20 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli, All Rights Reserved. @@ -77,6 +77,7 @@ #define UIRCC_CR12 0x0c /* Timer counter initial value (low byte) */ #define UIRCC_CR13 0x0d /* Timer counter initial value (high byte) */ +#define UIRCC_CR15 0x0f /* Status registers (read only) */ #define UIRCC_SR0 0x00 /* Transmit/receive status register */ @@ -102,9 +103,10 @@ #define UIRCC_SR9 0x09 /* System status 1 */ #define UIRCC_SR10 0x0a /* Modem select status */ - +#define UIRCC_SR11 0x0b #define UIRCC_SR12 0x0c /* Timer counter status (low byte) */ #define UIRCC_SR13 0x0d /* Timer counter status (high byte) */ +#define UIRCC_SR15 0x0f /* Private data for each instance */ struct uircc_cb { diff --git a/include/net/irda/wrapper.h b/include/net/irda/wrapper.h index 838713f31..ca21ebec5 100644 --- a/include/net/irda/wrapper.h +++ b/include/net/irda/wrapper.h @@ -1,12 +1,12 @@ /********************************************************************* * * Filename: wrapper.h - * Version: + * Version: 1.0 * Description: IrDA Wrapper layer * Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Mon Aug 4 20:40:53 1997 - * Modified at: Thu Nov 19 13:17:56 1998 + * Modified at: Fri Jan 29 10:15:46 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> * * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. @@ -28,7 +28,7 @@ #include <linux/types.h> #include <linux/skbuff.h> -#include "irda_device.h" +#include <net/irda/irda_device.h> #define BOF 0xc0 /* Beginning of frame */ #define XBOF 0xff @@ -40,9 +40,6 @@ #define IR_TRANS 0x20 /* Asynchronous transparency modifier */ -#define SOP BOF /* Start of */ -#define EOP EOF /* End of */ - enum { OUTSIDE_FRAME = 1, BEGIN_FRAME, diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 76dd6f4fd..5c5d90bb0 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -226,7 +226,6 @@ extern __inline__ void neigh_confirm(struct neighbour *neigh) neigh->confirmed = jiffies; } - extern __inline__ struct neighbour * neigh_lookup(struct neigh_table *tbl, const void *pkey, struct device *dev) { @@ -258,6 +257,7 @@ extern __inline__ int neigh_event_send(struct neighbour *neigh, struct sk_buff * extern __inline__ void neigh_table_lock(struct neigh_table *tbl) { atomic_inc(&tbl->lock); + synchronize_bh(); } extern __inline__ void neigh_table_unlock(struct neigh_table *tbl) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 0d3c25e25..4c37d11ed 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -50,7 +50,7 @@ struct tcf_proto_ops unsigned long (*get)(struct tcf_proto*, u32 handle); void (*put)(struct tcf_proto*, unsigned long); - int (*change)(struct tcf_proto*, u32 handle, struct rtattr **, unsigned long *); + int (*change)(struct tcf_proto*, unsigned long, u32 handle, struct rtattr **, unsigned long *); int (*delete)(struct tcf_proto*, unsigned long); void (*walk)(struct tcf_proto*, struct tcf_walker *arg); @@ -77,6 +77,13 @@ extern __inline__ int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, str return -1; } +extern __inline__ unsigned long cls_set_class(unsigned long *clp, unsigned long cl) +{ + cl = xchg(clp, cl); + synchronize_bh(); + return cl; +} + extern int register_tcf_proto_ops(struct tcf_proto_ops *ops); extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops); diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 142f7b3c7..9911464fc 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -5,7 +5,7 @@ #define PSCHED_JIFFIES 2 #define PSCHED_CPU 3 -#define PSCHED_CLOCK_SOURCE PSCHED_GETTIMEOFDAY +#define PSCHED_CLOCK_SOURCE PSCHED_JIFFIES #include <linux/pkt_sched.h> #include <net/pkt_cls.h> @@ -25,6 +25,7 @@ struct Qdisc_class_ops { /* Child qdisc manipulation */ int (*graft)(struct Qdisc *, unsigned long cl, struct Qdisc *, struct Qdisc **); + struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); /* Class manipulation routines */ unsigned long (*get)(struct Qdisc *, u32 classid); @@ -35,7 +36,7 @@ struct Qdisc_class_ops /* Filter manipulation */ struct tcf_proto ** (*tcf_chain)(struct Qdisc *, unsigned long); - unsigned long (*bind_tcf)(struct Qdisc *, u32 classid); + unsigned long (*bind_tcf)(struct Qdisc *, unsigned long, u32 classid); void (*unbind_tcf)(struct Qdisc *, unsigned long); /* rtnetlink specific */ @@ -57,6 +58,7 @@ struct Qdisc_ops int (*init)(struct Qdisc *, struct rtattr *arg); void (*reset)(struct Qdisc *); void (*destroy)(struct Qdisc *); + int (*change)(struct Qdisc *, struct rtattr *arg); int (*dump)(struct Qdisc *, struct sk_buff *); }; @@ -74,13 +76,12 @@ struct Qdisc int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev); struct sk_buff * (*dequeue)(struct Qdisc *dev); unsigned flags; -#define TCQ_F_DEFAULT 1 -#define TCQ_F_BUILTIN 2 +#define TCQ_F_BUILTIN 1 +#define TCQ_F_THROTTLED 2 struct Qdisc_ops *ops; struct Qdisc *next; u32 handle; - u32 classid; - struct Qdisc *parent; + atomic_t refcnt; struct sk_buff_head q; struct device *dev; @@ -89,6 +90,11 @@ struct Qdisc unsigned long tx_last; int (*reshape_fail)(struct sk_buff *skb, struct Qdisc *q); + /* This field is deprecated, but it is still used by CBQ + * and it will live until better solution will be invented. + */ + struct Qdisc *__parent; + char data[0]; }; @@ -129,6 +135,15 @@ struct qdisc_rate_table which have fast and precise clock source, but it is too expensive. */ +/* General note about internal clock. + + Any clock source returns time intervals, measured in units + close to 1usec. With source PSCHED_GETTIMEOFDAY it is precisely + microseconds, otherwise something close but different chosen to minimize + arithmetic cost. Ratio usec/internal untis in form nominator/denominator + may be read from /proc/net/psched. + */ + #if PSCHED_CLOCK_SOURCE == PSCHED_GETTIMEOFDAY @@ -138,8 +153,12 @@ typedef long psched_tdiff_t; #define PSCHED_GET_TIME(stamp) do_gettimeofday(&(stamp)) #define PSCHED_US2JIFFIE(usecs) (((usecs)+(1000000/HZ-1))/(1000000/HZ)) +#define PSCHED_EXPORTLIST EXPORT_SYMBOL(psched_tod_diff); + #else /* PSCHED_CLOCK_SOURCE != PSCHED_GETTIMEOFDAY */ +#define PSCHED_EXPORTLIST PSCHED_EXPORTLIST_1 PSCHED_EXPORTLIST_2 + typedef u64 psched_time_t; typedef long psched_tdiff_t; @@ -147,10 +166,6 @@ extern psched_time_t psched_time_base; #if PSCHED_CLOCK_SOURCE == PSCHED_JIFFIES -#define PSCHED_WATCHER unsigned long - -extern PSCHED_WATCHER psched_time_mark; - #if HZ == 100 #define PSCHED_JSCALE 13 #elif HZ == 1024 @@ -159,24 +174,49 @@ extern PSCHED_WATCHER psched_time_mark; #define PSCHED_JSCALE 0 #endif +#define PSCHED_EXPORTLIST_2 + +#if ~0UL == 0xFFFFFFFF + +#define PSCHED_WATCHER unsigned long + +extern PSCHED_WATCHER psched_time_mark; + #define PSCHED_GET_TIME(stamp) ((stamp) = psched_time_base + (((unsigned long)(jiffies-psched_time_mark))<<PSCHED_JSCALE)) -#define PSCHED_US2JIFFIE(delay) ((delay)>>PSCHED_JSCALE) + +#define PSCHED_EXPORTLIST_1 EXPORT_SYMBOL(psched_time_base); \ + EXPORT_SYMBOL(psched_time_mark); + +#else + +#define PSCHED_GET_TIME(stamp) ((stamp) = (jiffies<<PSCHED_JSCALE)) + +#define PSCHED_EXPORTLIST_1 + +#endif + +#define PSCHED_US2JIFFIE(delay) (((delay)+(1<<PSCHED_JSCALE)-1)>>PSCHED_JSCALE) #elif PSCHED_CLOCK_SOURCE == PSCHED_CPU extern psched_tdiff_t psched_clock_per_hz; extern int psched_clock_scale; +#define PSCHED_EXPORTLIST_2 EXPORT_SYMBOL(psched_clock_per_hz); \ + EXPORT_SYMBOL(psched_clock_scale); + #define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz) #if CPU == 586 || CPU == 686 #define PSCHED_GET_TIME(stamp) \ -({ u32 hi, lo; \ - __asm__ __volatile__ (".byte 0x0f,0x31" :"=a" (lo), "=d" (hi)); \ - (stamp) = ((((u64)hi)<<32) + lo)>>psched_clock_scale; \ +({ u64 __cur; \ + __asm__ __volatile__ (".byte 0x0f,0x31" :"=A" (__cur)); \ + (stamp) = __cur>>psched_clock_scale; \ }) +#define PSCHED_EXPORTLIST_1 + #elif defined (__alpha__) #define PSCHED_WATCHER u32 @@ -191,6 +231,9 @@ extern PSCHED_WATCHER psched_time_mark; (stamp) = (psched_time_base + __res)>>psched_clock_scale; \ }) +#define PSCHED_EXPORTLIST_1 EXPORT_SYMBOL(psched_time_base); \ + EXPORT_SYMBOL(psched_time_mark); + #else #error PSCHED_CLOCK_SOURCE=PSCHED_CPU is not supported on this arch. @@ -219,13 +262,15 @@ extern PSCHED_WATCHER psched_time_mark; __delta; \ }) +extern int psched_tod_diff(int delta_sec, int bound); + #define PSCHED_TDIFF_SAFE(tv1, tv2, bound, guard) \ ({ \ int __delta_sec = (tv1).tv_sec - (tv2).tv_sec; \ int __delta = (tv1).tv_usec - (tv2).tv_usec; \ switch (__delta_sec) { \ default: \ - __delta = (bound); guard; break; \ + __delta = psched_tod_diff(__delta_sec, bound); guard; break; \ case 2: \ __delta += 1000000; \ case 1: \ @@ -290,6 +335,8 @@ struct tcf_police u32 index; int action; + int result; + u32 ewma_rate; u32 burst; u32 mtu; @@ -298,10 +345,12 @@ struct tcf_police psched_time_t t_c; struct qdisc_rate_table *R_tab; struct qdisc_rate_table *P_tab; + + struct tc_stats stats; }; extern void tcf_police_destroy(struct tcf_police *p); -extern struct tcf_police * tcf_police_locate(struct rtattr *rta); +extern struct tcf_police * tcf_police_locate(struct rtattr *rta, struct rtattr *est); extern int tcf_police_dump(struct sk_buff *skb, struct tcf_police *p); extern int tcf_police(struct sk_buff *skb, struct tcf_police *p); @@ -327,7 +376,6 @@ void dev_deactivate(struct device *dev); void qdisc_reset(struct Qdisc *qdisc); void qdisc_destroy(struct Qdisc *qdisc); struct Qdisc * qdisc_create_dflt(struct device *dev, struct Qdisc_ops *ops); -struct Qdisc * dev_set_scheduler(struct device *dev, struct Qdisc *qdisc); int qdisc_new_estimator(struct tc_stats *stats, struct rtattr *opt); void qdisc_kill_estimator(struct tc_stats *stats); struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab); diff --git a/include/net/route.h b/include/net/route.h index bd76d033b..66df47122 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -57,6 +57,9 @@ struct rt_key __u32 src; int iif; int oif; +#ifdef CONFIG_IP_ROUTE_FWMARK + __u32 fwmark; +#endif __u8 tos; __u8 scope; }; @@ -93,6 +96,16 @@ struct rtable extern struct rtable *rt_hash_table[RT_HASH_DIVISOR]; +struct ip_rt_acct +{ + __u32 o_bytes; + __u32 o_packets; + __u32 i_bytes; + __u32 i_packets; +}; + +extern struct ip_rt_acct ip_rt_acct[256]; + extern void ip_rt_init(void); extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw, u32 src, u8 tos, struct device *dev); @@ -101,6 +114,7 @@ extern void rt_cache_flush(int how); extern int ip_route_output(struct rtable **, u32 dst, u32 src, u32 tos, int oif); extern int ip_route_input(struct sk_buff*, u32 dst, u32 src, u8 tos, struct device *devin); extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); +extern void ip_rt_update_pmtu(struct dst_entry *dst, unsigned mtu); extern void ip_rt_send_redirect(struct sk_buff *skb); extern unsigned inet_addr_type(u32 addr); diff --git a/include/net/sock.h b/include/net/sock.h index c03168f4b..e11c1be22 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -81,6 +81,10 @@ #include <net/dn.h> #endif +#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) +#include <net/irda/irda.h> +#endif + #ifdef CONFIG_FILTER #include <linux/filter.h> #endif @@ -99,8 +103,7 @@ struct unix_opt { struct semaphore readsem; struct sock * other; struct sock ** list; - int marksweep; -#define MARKED 1 + struct sock * gc_tree; int inflight; }; @@ -143,12 +146,11 @@ struct ipv6_pinfo { struct in6_addr daddr; struct in6_addr *daddr_cache; - __u32 flow_lbl; + __u32 flow_label; __u32 frag_size; int hop_limit; int mcast_hops; int mcast_oif; - __u8 priority; /* pktoption flags */ union { @@ -159,7 +161,7 @@ struct ipv6_pinfo { hopopts:1, dstopts:1, authhdr:1, - unused:1; + rxflow:1; } bits; __u8 all; } rxopt; @@ -167,9 +169,11 @@ struct ipv6_pinfo { /* sockopt flags */ __u8 mc_loop:1, recverr:1, + sndflow:1, pmtudisc:2; struct ipv6_mc_socklist *ipv6_mc_list; + struct ipv6_fl_socklist *ipv6_fl_list; __u32 dst_cookie; struct ipv6_txoptions *opt; @@ -453,8 +457,7 @@ struct sock { #ifdef CONFIG_FILTER /* Socket Filtering Instructions */ - int filter; - struct sock_filter *filter_data; + struct sk_filter *filter; #endif /* CONFIG_FILTER */ /* This is where all the private (optional) areas that don't @@ -493,6 +496,9 @@ struct sock { #if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE) struct econet_opt *af_econet; #endif +#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) + struct irda_sock *irda; +#endif } protinfo; /* IP 'private area' or will be eventually. */ @@ -790,11 +796,11 @@ extern void sklist_destroy_socket(struct sock **list, struct sock *sk); * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller * than pkt_len we keep whole skb->data. */ -extern __inline__ int sk_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) +extern __inline__ int sk_filter(struct sk_buff *skb, struct sk_filter *filter) { int pkt_len; - pkt_len = sk_run_filter(skb->data, skb->len, filter, flen); + pkt_len = sk_run_filter(skb, filter->insns, filter->len); if(!pkt_len) return 1; /* Toss Packet */ else @@ -802,6 +808,23 @@ extern __inline__ int sk_filter(struct sk_buff *skb, struct sock_filter *filter, return 0; } + +extern __inline__ void sk_filter_release(struct sock *sk, struct sk_filter *fp) +{ + unsigned int size = sk_filter_len(fp); + + atomic_sub(size, &sk->omem_alloc); + + if (atomic_dec_and_test(&fp->refcnt)) + kfree_s(fp, size); +} + +extern __inline__ void sk_filter_charge(struct sock *sk, struct sk_filter *fp) +{ + atomic_inc(&fp->refcnt); + atomic_add(sk_filter_len(fp), &sk->omem_alloc); +} + #endif /* CONFIG_FILTER */ /* @@ -830,6 +853,9 @@ extern __inline__ void skb_set_owner_r(struct sk_buff *skb, struct sock *sk) extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { +#ifdef CONFIG_FILTER + struct sk_filter *filter; +#endif /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces number of warnings when compiling with -W --ANK */ @@ -837,11 +863,8 @@ extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) return -ENOMEM; #ifdef CONFIG_FILTER - if (sk->filter) - { - if (sk_filter(skb, sk->filter_data, sk->filter)) - return -EPERM; /* Toss packet */ - } + if ((filter = sk->filter) != NULL && sk_filter(skb, filter)) + return -EPERM; /* Toss packet */ #endif /* CONFIG_FILTER */ skb_set_owner_r(skb, sk); @@ -906,6 +929,10 @@ extern void net_delete_timer (struct sock *); extern void net_reset_timer (struct sock *, int, unsigned long); extern void net_timer (unsigned long); +extern __inline__ int gfp_any(void) +{ + return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; +} /* * Enable debug/info messages diff --git a/include/net/tcp.h b/include/net/tcp.h index 5da07ba9d..2d91a8d43 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -174,6 +174,7 @@ struct tcp_tw_bucket { struct tcp_func *af_specific; struct tcp_bind_bucket *tb; struct tcp_tw_bucket *next_death; + struct tcp_tw_bucket **pprev_death; int death_slot; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) struct in6_addr v6_daddr; @@ -487,9 +488,7 @@ extern void tcp_shutdown (struct sock *sk, int how); extern int tcp_v4_rcv(struct sk_buff *skb, unsigned short len); -extern int tcp_do_sendmsg(struct sock *sk, - int iovlen, struct iovec *iov, - int flags); +extern int tcp_do_sendmsg(struct sock *sk, struct msghdr *msg); extern int tcp_ioctl(struct sock *sk, int cmd, @@ -718,6 +717,30 @@ extern __inline__ int tcp_raise_window(struct sock *sk) return (new_win && (new_win > (cur_win << 1))); } +/* Recalculate snd_ssthresh, we want to set it to: + * + * one half the current congestion window, but no + * less than two segments + * + * We must take into account the current send window + * as well, however we keep track of that using different + * units so a conversion is necessary. -DaveM + */ +extern __inline__ __u32 tcp_recalc_ssthresh(struct tcp_opt *tp) +{ + __u32 snd_wnd_packets = tp->snd_wnd / tp->mss_cache; + + return max(min(snd_wnd_packets, tp->snd_cwnd) >> 1, 2); +} + +/* TCP timestamps are only 32-bits, this causes a slight + * complication on 64-bit systems since we store a snapshot + * of jiffies in the buffer control blocks below. We decidely + * only use of the low 32-bits of jiffies and hide the ugly + * casts with the following macro. + */ +#define tcp_time_stamp ((__u32)(jiffies)) + /* This is what the send packet queueing engine uses to pass * TCP per-packet control information to the transmission * code. We also store the host-order sequence numbers in @@ -734,7 +757,7 @@ struct tcp_skb_cb { } header; /* For incoming frames */ __u32 seq; /* Starting sequence number */ __u32 end_seq; /* SEQ + FIN + SYN + datalen */ - unsigned long when; /* used to compute rtt's */ + __u32 when; /* used to compute rtt's */ __u8 flags; /* TCP header flags. */ /* NOTE: These must match up to the flags byte in a @@ -795,21 +818,43 @@ static __inline__ int tcp_snd_test(struct sock *sk, struct sk_buff *skb) * c) We are retransmiting [Nagle] * d) We have too many packets 'in flight' * - * Don't use the nagle rule for urgent data. + * Don't use the nagle rule for urgent data (or + * for the final FIN -DaveM). */ if ((sk->nonagle == 2 && (skb->len < tp->mss_cache)) || (!sk->nonagle && skb->len < (tp->mss_cache >> 1) && tp->packets_out && - !(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_URG))) + !(TCP_SKB_CB(skb)->flags & (TCPCB_FLAG_URG|TCPCB_FLAG_FIN)))) nagle_check = 0; + /* Don't be strict about the congestion window for the + * final FIN frame. -DaveM + */ return (nagle_check && - (tcp_packets_in_flight(tp) < tp->snd_cwnd) && + ((tcp_packets_in_flight(tp) < tp->snd_cwnd) || + (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)) && !after(TCP_SKB_CB(skb)->end_seq, tp->snd_una + tp->snd_wnd) && tp->retransmits == 0); } +/* Push out any pending frames which were held back due to + * TCP_CORK or attempt at coalescing tiny packets. + * The socket must be locked by the caller. + */ +static __inline__ void tcp_push_pending_frames(struct sock *sk, struct tcp_opt *tp) +{ + if(tp->send_head) { + if(tcp_snd_test(sk, tp->send_head)) + tcp_write_xmit(sk); + else if(tp->packets_out == 0 && !tp->pending) { + /* We held off on this in tcp_send_skb() */ + tp->pending = TIME_PROBE0; + tcp_reset_xmit_timer(sk, TIME_PROBE0, tp->rto); + } + } +} + /* This tells the input processing path that an ACK should go out * right now. */ @@ -912,7 +957,7 @@ static __inline__ void tcp_build_and_update_options(__u32 *ptr, struct tcp_opt * * can generate. */ extern __inline__ void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, - int offer_wscale, int wscale, __u32 tstamp) + int offer_wscale, int wscale, __u32 tstamp, __u32 ts_recent) { /* We always get an MSS option. * The option bytes which will be seen in normal data @@ -936,7 +981,7 @@ extern __inline__ void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sa *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); *ptr++ = htonl(tstamp); /* TSVAL */ - *ptr++ = __constant_htonl(0); /* TSECR */ + *ptr++ = htonl(ts_recent); /* TSECR */ } else if(sack) *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h index b697d7c3c..d49bc86e0 100644 --- a/include/net/transp_v6.h +++ b/include/net/transp_v6.h @@ -13,6 +13,8 @@ extern struct proto rawv6_prot; extern struct proto udpv6_prot; extern struct proto tcpv6_prot; +struct flowi; + extern void rawv6_init(void); extern void udpv6_init(void); extern void tcpv6_init(void); @@ -26,8 +28,7 @@ extern int datagram_recv_ctl(struct sock *sk, struct sk_buff *skb); extern int datagram_send_ctl(struct msghdr *msg, - int *oif, - struct in6_addr **src_addr, + struct flowi *fl, struct ipv6_txoptions *opt, int *hlimit); |